From 03efed8a2a1b8e00164eb4720a82a7dd5e368a8e Mon Sep 17 00:00:00 2001 From: Tiger Yang Date: Sat, 28 May 2011 00:34:19 +0800 Subject: ocfs2: Bugfix for hard readonly mount ocfs2 cannot currently mount a device that is readonly at the media ("hard readonly"). Fix the broken places. see detail: http://oss.oracle.com/bugzilla/show_bug.cgi?id=1322 [ Description edited -- Joel ] Signed-off-by: Tiger Yang Reviewed-by: Sunil Mushran Signed-off-by: Joel Becker diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 7642d7c..da103f5 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -1692,7 +1692,7 @@ int ocfs2_open_lock(struct inode *inode) mlog(0, "inode %llu take PRMODE open lock\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); - if (ocfs2_mount_local(osb)) + if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb)) goto out; lockres = &OCFS2_I(inode)->ip_open_lockres; @@ -1718,6 +1718,12 @@ int ocfs2_try_open_lock(struct inode *inode, int write) (unsigned long long)OCFS2_I(inode)->ip_blkno, write ? "EXMODE" : "PRMODE"); + if (ocfs2_is_hard_readonly(osb)) { + if (write) + status = -EROFS; + goto out; + } + if (ocfs2_mount_local(osb)) goto out; @@ -2298,7 +2304,7 @@ int ocfs2_inode_lock_full_nested(struct inode *inode, if (ocfs2_is_hard_readonly(osb)) { if (ex) status = -EROFS; - goto bail; + goto getbh; } if (ocfs2_mount_local(osb)) @@ -2356,7 +2362,7 @@ local: mlog_errno(status); goto bail; } - +getbh: if (ret_bh) { status = ocfs2_assign_bh(inode, ret_bh, local_bh); if (status < 0) { @@ -2628,8 +2634,11 @@ int ocfs2_dentry_lock(struct dentry *dentry, int ex) BUG_ON(!dl); - if (ocfs2_is_hard_readonly(osb)) - return -EROFS; + if (ocfs2_is_hard_readonly(osb)) { + if (ex) + return -EROFS; + return 0; + } if (ocfs2_mount_local(osb)) return 0; @@ -2647,7 +2656,7 @@ void ocfs2_dentry_unlock(struct dentry *dentry, int ex) struct ocfs2_dentry_lock *dl = dentry->d_fsdata; struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); - if (!ocfs2_mount_local(osb)) + if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); } diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index cdbaf5e..029c4cd 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1974,7 +1974,8 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) * If we failed before we got a uuid_str yet, we can't stop * heartbeat. Otherwise, do it. */ - if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str) + if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str && + !ocfs2_is_hard_readonly(osb)) hangup_needed = 1; if (osb->cconn) -- cgit v0.10.2 From 3d75be7c4771c7e4d5b5fa586a599af8473de32c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sun, 29 May 2011 22:56:31 +0300 Subject: ocfs2: checking the wrong variable in ocfs2_move_extent() "new_phys_cpos" is always a valid pointer here. ocfs2_probe_alloc_group() allocates "*new_phys_cpos". Signed-off-by: Dan Carpenter Signed-off-by: Joel Becker diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index cd94270..d3433d6 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c @@ -746,7 +746,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context, */ ocfs2_probe_alloc_group(inode, gd_bh, &goal_bit, len, move_max_hop, new_phys_cpos); - if (!new_phys_cpos) { + if (!*new_phys_cpos) { ret = -ENOSPC; goto out_commit; } -- cgit v0.10.2 From 87f0d5c8db7aad85b9120c26723fdc63cd84a460 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sun, 29 May 2011 22:57:16 +0300 Subject: ocfs2: null deref on allocation error The original code had a null derefence in the error handling. Signed-off-by: Dan Carpenter Signed-off-by: Joel Becker diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index bc91072..d9a6ce7 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -381,7 +381,7 @@ int ocfs2_info_handle_freeinode(struct inode *inode, if (!oifi) { status = -ENOMEM; mlog_errno(status); - goto bail; + goto out_err; } if (o2info_from_user(*oifi, req)) @@ -431,7 +431,7 @@ bail: o2info_set_request_error(&oifi->ifi_req, req); kfree(oifi); - +out_err: return status; } @@ -666,7 +666,7 @@ int ocfs2_info_handle_freefrag(struct inode *inode, if (!oiff) { status = -ENOMEM; mlog_errno(status); - goto bail; + goto out_err; } if (o2info_from_user(*oiff, req)) @@ -716,7 +716,7 @@ bail: o2info_set_request_error(&oiff->iff_req, req); kfree(oiff); - +out_err: return status; } -- cgit v0.10.2 From 730e663bd82c1a10a85ff00728d34152a5a67ec8 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Mon, 30 May 2011 21:58:05 +0900 Subject: ocfs2: use proper little-endian bitops Using __test_and_{set,clear}_bit_le() with ignoring its return value can be replaced with __{set,clear}_bit_le(). Signed-off-by: Akinobu Mita Cc: Joel Becker Cc: Mark Fasheh Cc: ocfs2-devel@oss.oracle.com Signed-off-by: Joel Becker diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 4092858..bcde467 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -836,13 +836,13 @@ static inline unsigned int ocfs2_clusters_to_megabytes(struct super_block *sb, static inline void _ocfs2_set_bit(unsigned int bit, unsigned long *bitmap) { - __test_and_set_bit_le(bit, bitmap); + __set_bit_le(bit, bitmap); } #define ocfs2_set_bit(bit, addr) _ocfs2_set_bit((bit), (unsigned long *)(addr)) static inline void _ocfs2_clear_bit(unsigned int bit, unsigned long *bitmap) { - __test_and_clear_bit_le(bit, bitmap); + __clear_bit_le(bit, bitmap); } #define ocfs2_clear_bit(bit, addr) _ocfs2_clear_bit((bit), (unsigned long *)(addr)) -- cgit v0.10.2 From bf61549a2d8e0326f5d6e4d1718883a7212d725f Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 09:58:05 +0200 Subject: x86: Fix memblock_x86_check_reserved_size() use in efi_reserve_boot_services() The return value of memblock_x86_check_reserved_size() doesn't indicate whether there's an overlapping reservatoin or not. It indicates whether the caller needs to iterate further to discover all reserved portions of the specified area. efi_reserve_boot_esrvices() wants to check whether the boot services area overlaps with other reservations but incorrectly used membloc_x86_check_reserved_size(). Use memblock_is_region_reserved() instead. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310457490-3356-2-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 899e393..a4c322c 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -325,8 +325,7 @@ void __init efi_reserve_boot_services(void) if ((start+size >= virt_to_phys(_text) && start <= virt_to_phys(_end)) || !e820_all_mapped(start, start+size, E820_RAM) || - memblock_x86_check_reserved_size(&start, &size, - 1<num_pages = 0; memblock_dbg(PFX "Could not reserve boot range " -- cgit v0.10.2 From 53348f27168534561c0c814843bbf181314374f4 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 09:58:06 +0200 Subject: bootmem: Fix __free_pages_bootmem() to use @order properly a226f6c899 (FRV: Clean up bootmem allocator's page freeing algorithm) separated out __free_pages_bootmem() from free_all_bootmem_core(). __free_pages_bootmem() takes @order argument but it assumes @order is either 0 or ilog2(BITS_PER_LONG). Note that all the current users match that assumption and this doesn't cause actual problems. Fix it by using 1 << order instead of BITS_PER_LONG. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310457490-3356-3-git-send-email-tj@kernel.org Cc: David Howells Signed-off-by: H. Peter Anvin diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9119faa..b6da6ed 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -705,10 +705,10 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order) int loop; prefetchw(page); - for (loop = 0; loop < BITS_PER_LONG; loop++) { + for (loop = 0; loop < (1 << order); loop++) { struct page *p = &page[loop]; - if (loop + 1 < BITS_PER_LONG) + if (loop + 1 < (1 << order)) prefetchw(p + 1); __ClearPageReserved(p); set_page_count(p, 0); -- cgit v0.10.2 From 15fb09722df32b7685be1cbcac198bb556ddaffe Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 09:58:07 +0200 Subject: memblock: Use MEMBLOCK_ALLOC_ACCESSIBLE instead of ANYWHERE in memblock_alloc_try_nid() After node affine allocation fails, memblock_alloc_try_nid() calls memblock_alloc_base() with @max_addr set to MEMBLOCK_ALLOC_ANYWHERE. This is inconsistent with memblock_alloc() and what the function's sole user - sparc/mm/init_64 - expects, although it doesn't make any difference as sparc64 doesn't have highmem and ACCESSIBLE equals ANYWHERE. This patch makes memblock_alloc_try_nid() use ACCESSIBLE instead of ANYWHERE. This isn't complete as node affine allocation doesn't consider memblock.current_limit. It will be handled with future changes. This patch doesn't introduce any behavior difference. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310457490-3356-4-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/mm/memblock.c b/mm/memblock.c index a0562d1..87e512d 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -612,7 +612,7 @@ phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, i if (res) return res; - return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ANYWHERE); + return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); } -- cgit v0.10.2 From 348968eb151e2569ad0ebe19b2f9c3c25b5c816a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 09:58:08 +0200 Subject: memblock: Use round_up/down() instead of memblock_align_up/down() Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310457490-3356-5-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/mm/memblock.c b/mm/memblock.c index 87e512d..9882a88 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -41,17 +41,6 @@ static inline const char *memblock_type_name(struct memblock_type *type) /* * Address comparison utilities */ - -static phys_addr_t __init_memblock memblock_align_down(phys_addr_t addr, phys_addr_t size) -{ - return addr & ~(size - 1); -} - -static phys_addr_t __init_memblock memblock_align_up(phys_addr_t addr, phys_addr_t size) -{ - return (addr + (size - 1)) & ~(size - 1); -} - static unsigned long __init_memblock memblock_addrs_overlap(phys_addr_t base1, phys_addr_t size1, phys_addr_t base2, phys_addr_t size2) { @@ -87,7 +76,7 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_ if (end < size) return MEMBLOCK_ERROR; - base = memblock_align_down((end - size), align); + base = round_down(end - size, align); /* Prevent allocations returning 0 as it's also used to * indicate an allocation failure @@ -102,7 +91,7 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_ res_base = memblock.reserved.regions[j].base; if (res_base < size) break; - base = memblock_align_down(res_base - size, align); + base = round_down(res_base - size, align); } return MEMBLOCK_ERROR; @@ -486,7 +475,7 @@ phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, ph /* We align the size to limit fragmentation. Without this, a lot of * small allocs quickly eat up the whole reserve array on sparc */ - size = memblock_align_up(size, align); + size = round_up(size, align); found = memblock_find_base(size, align, 0, max_addr); if (found != MEMBLOCK_ERROR && @@ -562,7 +551,7 @@ static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp, start = mp->base; end = start + mp->size; - start = memblock_align_up(start, align); + start = round_up(start, align); while (start < end) { phys_addr_t this_end; int this_nid; @@ -590,7 +579,7 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n /* We align the size to limit fragmentation. Without this, a lot of * small allocs quickly eat up the whole reserve array on sparc */ - size = memblock_align_up(size, align); + size = round_up(size, align); /* We do a bottom-up search for a region with the right * nid since that's easier considering how memblock_nid_range() -- cgit v0.10.2 From 1f5026a7e21e409c2b9dd54f6dfb9446511fb7c5 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 09:58:09 +0200 Subject: memblock: Kill MEMBLOCK_ERROR 25818f0f28 (memblock: Make MEMBLOCK_ERROR be 0) thankfully made MEMBLOCK_ERROR 0 and there already are codes which expect error return to be 0. There's no point in keeping MEMBLOCK_ERROR around. End its misery. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310457490-3356-6-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c index 3d2661c..5636308 100644 --- a/arch/x86/kernel/aperture_64.c +++ b/arch/x86/kernel/aperture_64.c @@ -88,7 +88,7 @@ static u32 __init allocate_aperture(void) */ addr = memblock_find_in_range(GART_MIN_ADDR, GART_MAX_ADDR, aper_size, aper_size); - if (addr == MEMBLOCK_ERROR || addr + aper_size > GART_MAX_ADDR) { + if (!addr || addr + aper_size > GART_MAX_ADDR) { printk(KERN_ERR "Cannot allocate aperture memory hole (%lx,%uK)\n", addr, aper_size>>10); diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c index 452932d..95680fc 100644 --- a/arch/x86/kernel/check.c +++ b/arch/x86/kernel/check.c @@ -86,7 +86,7 @@ void __init setup_bios_corruption_check(void) u64 size; addr = memblock_x86_find_in_range_size(addr, &size, PAGE_SIZE); - if (addr == MEMBLOCK_ERROR) + if (!addr) break; if (addr >= corruption_check_size) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 3e2ef84..0f9ff58 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -745,7 +745,7 @@ u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) for (start = startt; ; start += size) { start = memblock_x86_find_in_range_size(start, &size, align); - if (start == MEMBLOCK_ERROR) + if (!start) return 0; if (size >= sizet) break; diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index afaf384..31ffe20 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -331,7 +331,7 @@ static void __init relocate_initrd(void) ramdisk_here = memblock_find_in_range(0, end_of_lowmem, area_size, PAGE_SIZE); - if (ramdisk_here == MEMBLOCK_ERROR) + if (!ramdisk_here) panic("Cannot find place for new RAMDISK of size %lld\n", ramdisk_size); @@ -554,7 +554,7 @@ static void __init reserve_crashkernel(void) crash_base = memblock_find_in_range(alignment, CRASH_KERNEL_ADDR_MAX, crash_size, alignment); - if (crash_base == MEMBLOCK_ERROR) { + if (!crash_base) { pr_info("crashkernel reservation failed - No suitable area found.\n"); return; } diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c index a91ae77..a1f13dd 100644 --- a/arch/x86/kernel/trampoline.c +++ b/arch/x86/kernel/trampoline.c @@ -14,7 +14,7 @@ void __init setup_trampolines(void) /* Has to be in very low memory so we can execute real-mode AP code. */ mem = memblock_find_in_range(0, 1<<20, size, PAGE_SIZE); - if (mem == MEMBLOCK_ERROR) + if (!mem) panic("Cannot allocate trampoline\n"); x86_trampoline_base = __va(mem); diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 3032644..13cf05a 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -68,7 +68,7 @@ static void __init find_early_table_space(unsigned long end, int use_pse, #endif base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE); - if (base == MEMBLOCK_ERROR) + if (!base) panic("Cannot find space for the kernel page tables"); pgt_buf_start = base >> PAGE_SHIFT; diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 992da5e..e126117 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -66,7 +66,7 @@ u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align) return addr; } - return MEMBLOCK_ERROR; + return 0; } static __init struct range *find_range_array(int count) @@ -78,7 +78,7 @@ static __init struct range *find_range_array(int count) end = memblock.current_limit; mem = memblock_find_in_range(0, end, size, sizeof(struct range)); - if (mem == MEMBLOCK_ERROR) + if (!mem) panic("can not find more space for range array"); /* @@ -274,7 +274,7 @@ u64 __init memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size { u64 addr; addr = find_memory_core_early(nid, size, align, start, end); - if (addr != MEMBLOCK_ERROR) + if (addr) return addr; /* Fallback, should already have start end within node range */ diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index fbeaaf4..fa1015d 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -226,10 +226,10 @@ static void __init setup_node_data(int nid, u64 start, u64 end) } else { nd_pa = memblock_x86_find_in_range_node(nid, nd_low, nd_high, nd_size, SMP_CACHE_BYTES); - if (nd_pa == MEMBLOCK_ERROR) + if (!nd_pa) nd_pa = memblock_find_in_range(nd_low, nd_high, nd_size, SMP_CACHE_BYTES); - if (nd_pa == MEMBLOCK_ERROR) { + if (!nd_pa) { pr_err("Cannot find %zu bytes in node %d\n", nd_size, nid); return; @@ -395,7 +395,7 @@ static int __init numa_alloc_distance(void) phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped), size, PAGE_SIZE); - if (phys == MEMBLOCK_ERROR) { + if (!phys) { pr_warning("NUMA: Warning: can't allocate distance table!\n"); /* don't retry until explicitly reset */ numa_distance = (void *)1LU; diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c index 3adebe7..58878b5 100644 --- a/arch/x86/mm/numa_32.c +++ b/arch/x86/mm/numa_32.c @@ -199,7 +199,7 @@ void __init init_alloc_remap(int nid, u64 start, u64 end) /* allocate node memory and the lowmem remap area */ node_pa = memblock_find_in_range(start, end, size, LARGE_PAGE_BYTES); - if (node_pa == MEMBLOCK_ERROR) { + if (!node_pa) { pr_warning("remap_alloc: failed to allocate %lu bytes for node %d\n", size, nid); return; @@ -209,7 +209,7 @@ void __init init_alloc_remap(int nid, u64 start, u64 end) remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT, size, LARGE_PAGE_BYTES); - if (remap_pa == MEMBLOCK_ERROR) { + if (!remap_pa) { pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n", size, nid); memblock_x86_free_range(node_pa, node_pa + size); diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index d0ed086..e3d471c 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -351,7 +351,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped), phys_size, PAGE_SIZE); - if (phys == MEMBLOCK_ERROR) { + if (!phys) { pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n"); goto no_emu; } diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 7525e38..d235ec5 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -2,8 +2,6 @@ #define _LINUX_MEMBLOCK_H #ifdef __KERNEL__ -#define MEMBLOCK_ERROR 0 - #ifdef CONFIG_HAVE_MEMBLOCK /* * Logical memory blocks. @@ -164,7 +162,7 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo #else static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align) { - return MEMBLOCK_ERROR; + return 0; } #endif /* CONFIG_HAVE_MEMBLOCK */ diff --git a/kernel/printk.c b/kernel/printk.c index 3518539..b1d5a61 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -199,7 +199,7 @@ void __init setup_log_buf(int early) unsigned long mem; mem = memblock_alloc(new_log_buf_len, PAGE_SIZE); - if (mem == MEMBLOCK_ERROR) + if (!mem) return; new_log_buf = __va(mem); } else { diff --git a/mm/memblock.c b/mm/memblock.c index 9882a88..1969936 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -74,7 +74,7 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_ /* In case, huge size is requested */ if (end < size) - return MEMBLOCK_ERROR; + return 0; base = round_down(end - size, align); @@ -94,7 +94,7 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_ base = round_down(res_base - size, align); } - return MEMBLOCK_ERROR; + return 0; } static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size, @@ -126,10 +126,10 @@ static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size, if (bottom >= top) continue; found = memblock_find_region(bottom, top, size, align); - if (found != MEMBLOCK_ERROR) + if (found) return found; } - return MEMBLOCK_ERROR; + return 0; } /* @@ -214,10 +214,10 @@ static int __init_memblock memblock_double_array(struct memblock_type *type) */ if (use_slab) { new_array = kmalloc(new_size, GFP_KERNEL); - addr = new_array == NULL ? MEMBLOCK_ERROR : __pa(new_array); + addr = new_array ? __pa(new_array) : 0; } else addr = memblock_find_base(new_size, sizeof(phys_addr_t), 0, MEMBLOCK_ALLOC_ACCESSIBLE); - if (addr == MEMBLOCK_ERROR) { + if (!addr) { pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", memblock_type_name(type), type->max, type->max * 2); return -1; @@ -478,8 +478,7 @@ phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, ph size = round_up(size, align); found = memblock_find_base(size, align, 0, max_addr); - if (found != MEMBLOCK_ERROR && - !memblock_add_region(&memblock.reserved, found, size)) + if (found && !memblock_add_region(&memblock.reserved, found, size)) return found; return 0; @@ -559,14 +558,14 @@ static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp, this_end = memblock_nid_range(start, end, &this_nid); if (this_nid == nid) { phys_addr_t ret = memblock_find_region(start, this_end, size, align); - if (ret != MEMBLOCK_ERROR && + if (ret && !memblock_add_region(&memblock.reserved, ret, size)) return ret; } start = this_end; } - return MEMBLOCK_ERROR; + return 0; } phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid) @@ -588,7 +587,7 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n for (i = 0; i < mem->cnt; i++) { phys_addr_t ret = memblock_alloc_nid_region(&mem->regions[i], size, align, nid); - if (ret != MEMBLOCK_ERROR) + if (ret) return ret; } diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 6e93dc7..5b0eb06 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c @@ -43,7 +43,7 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align, addr = find_memory_core_early(nid, size, align, goal, limit); - if (addr == MEMBLOCK_ERROR) + if (!addr) return NULL; ptr = phys_to_virt(addr); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b6da6ed..c7f0e5b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3878,13 +3878,13 @@ u64 __init find_memory_core_early(int nid, u64 size, u64 align, addr = memblock_find_in_range(final_start, final_end, size, align); - if (addr == MEMBLOCK_ERROR) + if (!addr) continue; return addr; } - return MEMBLOCK_ERROR; + return 0; } #endif -- cgit v0.10.2 From fc769a8e70a3348d5de49e5f69f6aff810157360 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 09:58:10 +0200 Subject: memblock: Replace memblock_find_base() with memblock_find_in_range() memblock_find_base() is a static function with two callers in memblock.c and memblock_find_in_range() is a wrapper around it which just changes the types and order of parameters. Make memblock_find_in_range() take phys_addr_t instead of u64 for consistency and replace memblock_find_base() with it. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310457490-3356-7-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/include/linux/memblock.h b/include/linux/memblock.h index d235ec5..3496888 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -46,7 +46,8 @@ extern int memblock_can_resize; #define memblock_dbg(fmt, ...) \ if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -u64 memblock_find_in_range(u64 start, u64 end, u64 size, u64 align); +phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, + phys_addr_t size, phys_addr_t align); int memblock_free_reserved_regions(void); int memblock_reserve_reserved_regions(void); diff --git a/mm/memblock.c b/mm/memblock.c index 1969936..0f9626f 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -97,8 +97,11 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_ return 0; } -static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size, - phys_addr_t align, phys_addr_t start, phys_addr_t end) +/* + * Find a free area with specified alignment in a specific range. + */ +phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start, phys_addr_t end, + phys_addr_t size, phys_addr_t align) { long i; @@ -133,14 +136,6 @@ static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size, } /* - * Find a free area with specified alignment in a specific range. - */ -u64 __init_memblock memblock_find_in_range(u64 start, u64 end, u64 size, u64 align) -{ - return memblock_find_base(size, align, start, end); -} - -/* * Free memblock.reserved.regions */ int __init_memblock memblock_free_reserved_regions(void) @@ -216,7 +211,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type) new_array = kmalloc(new_size, GFP_KERNEL); addr = new_array ? __pa(new_array) : 0; } else - addr = memblock_find_base(new_size, sizeof(phys_addr_t), 0, MEMBLOCK_ALLOC_ACCESSIBLE); + addr = memblock_find_in_range(0, MEMBLOCK_ALLOC_ACCESSIBLE, new_size, sizeof(phys_addr_t)); if (!addr) { pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", memblock_type_name(type), type->max, type->max * 2); @@ -477,7 +472,7 @@ phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, ph */ size = round_up(size, align); - found = memblock_find_base(size, align, 0, max_addr); + found = memblock_find_in_range(0, max_addr, size, align); if (found && !memblock_add_region(&memblock.reserved, found, size)) return found; -- cgit v0.10.2 From 5dfe8660a3d7f1ee1265c3536433ee53da3f98a3 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 09:46:10 +0200 Subject: bootmem: Replace work_with_active_regions() with for_each_mem_pfn_range() Callback based iteration is cumbersome and much less useful than for_each_*() iterator. This patch implements for_each_mem_pfn_range() which replaces work_with_active_regions(). All the current users of work_with_active_regions() are converted. This simplifies walking over early_node_map and will allow converting internal logics in page_alloc to use iterator instead of walking early_node_map directly, which in turn will enable moving node information to memblock. powerpc change is only compile tested. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/20110714074610.GD3455@htj.dyndns.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 2164006..6f06ea5 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -127,45 +127,25 @@ static int __cpuinit fake_numa_create_new_node(unsigned long end_pfn, } /* - * get_active_region_work_fn - A helper function for get_node_active_region - * Returns datax set to the start_pfn and end_pfn if they contain - * the initial value of datax->start_pfn between them - * @start_pfn: start page(inclusive) of region to check - * @end_pfn: end page(exclusive) of region to check - * @datax: comes in with ->start_pfn set to value to search for and - * goes out with active range if it contains it - * Returns 1 if search value is in range else 0 - */ -static int __init get_active_region_work_fn(unsigned long start_pfn, - unsigned long end_pfn, void *datax) -{ - struct node_active_region *data; - data = (struct node_active_region *)datax; - - if (start_pfn <= data->start_pfn && end_pfn > data->start_pfn) { - data->start_pfn = start_pfn; - data->end_pfn = end_pfn; - return 1; - } - return 0; - -} - -/* - * get_node_active_region - Return active region containing start_pfn + * get_node_active_region - Return active region containing pfn * Active range returned is empty if none found. - * @start_pfn: The page to return the region for. - * @node_ar: Returned set to the active region containing start_pfn + * @pfn: The page to return the region for + * @node_ar: Returned set to the active region containing @pfn */ -static void __init get_node_active_region(unsigned long start_pfn, - struct node_active_region *node_ar) +static void __init get_node_active_region(unsigned long pfn, + struct node_active_region *node_ar) { - int nid = early_pfn_to_nid(start_pfn); + unsigned long start_pfn, end_pfn; + int i, nid; - node_ar->nid = nid; - node_ar->start_pfn = start_pfn; - node_ar->end_pfn = start_pfn; - work_with_active_regions(nid, get_active_region_work_fn, node_ar); + for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) { + if (pfn >= start_pfn && pfn < end_pfn) { + node_ar->nid = nid; + node_ar->start_pfn = start_pfn; + node_ar->end_pfn = end_pfn; + break; + } + } } static void map_cpu_to_node(int cpu, int node) diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index e126117..da0d5c8 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -115,28 +115,13 @@ static void __init memblock_x86_subtract_reserved(struct range *range, int az) memblock_reserve_reserved_regions(); } -struct count_data { - int nr; -}; - -static int __init count_work_fn(unsigned long start_pfn, - unsigned long end_pfn, void *datax) -{ - struct count_data *data = datax; - - data->nr++; - - return 0; -} - static int __init count_early_node_map(int nodeid) { - struct count_data data; - - data.nr = 0; - work_with_active_regions(nodeid, count_work_fn, &data); + int i, cnt = 0; - return data.nr; + for_each_mem_pfn_range(i, nodeid, NULL, NULL, NULL) + cnt++; + return cnt; } int __init __get_free_all_memory_range(struct range **rangep, int nodeid, diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index f02c34d..8ec3520 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c @@ -2178,18 +2178,6 @@ static inline void iommu_prepare_isa(void) static int md_domain_init(struct dmar_domain *domain, int guest_width); -static int __init si_domain_work_fn(unsigned long start_pfn, - unsigned long end_pfn, void *datax) -{ - int *ret = datax; - - *ret = iommu_domain_identity_map(si_domain, - (uint64_t)start_pfn << PAGE_SHIFT, - (uint64_t)end_pfn << PAGE_SHIFT); - return *ret; - -} - static int __init si_domain_init(int hw) { struct dmar_drhd_unit *drhd; @@ -2221,9 +2209,15 @@ static int __init si_domain_init(int hw) return 0; for_each_online_node(nid) { - work_with_active_regions(nid, si_domain_work_fn, &ret); - if (ret) - return ret; + unsigned long start_pfn, end_pfn; + int i; + + for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) { + ret = iommu_domain_identity_map(si_domain, + PFN_PHYS(start_pfn), PFN_PHYS(end_pfn)); + if (ret) + return ret; + } } return 0; diff --git a/include/linux/mm.h b/include/linux/mm.h index c70a326..57e4c9f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1327,9 +1327,27 @@ int add_from_early_node_map(struct range *range, int az, int nr_range, int nid); u64 __init find_memory_core_early(int nid, u64 size, u64 align, u64 goal, u64 limit); -typedef int (*work_fn_t)(unsigned long, unsigned long, void *); -extern void work_with_active_regions(int nid, work_fn_t work_fn, void *data); extern void sparse_memory_present_with_active_regions(int nid); + +extern void __next_mem_pfn_range(int *idx, int nid, + unsigned long *out_start_pfn, + unsigned long *out_end_pfn, int *out_nid); + +/** + * for_each_mem_pfn_range - early memory pfn range iterator + * @i: an integer used as loop variable + * @nid: node selector, %MAX_NUMNODES for all nodes + * @p_start: ptr to ulong for start pfn of the range, can be %NULL + * @p_end: ptr to ulong for end pfn of the range, can be %NULL + * @p_nid: ptr to int for nid of the range, can be %NULL + * + * Walks over configured memory ranges. Available after early_node_map is + * populated. + */ +#define for_each_mem_pfn_range(i, nid, p_start, p_end, p_nid) \ + for (i = -1, __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid); \ + i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid)) + #endif /* CONFIG_ARCH_POPULATES_NODE_MAP */ #if !defined(CONFIG_ARCH_POPULATES_NODE_MAP) && \ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c7f0e5b..69fffab 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3903,18 +3903,6 @@ int __init add_from_early_node_map(struct range *range, int az, return nr_range; } -void __init work_with_active_regions(int nid, work_fn_t work_fn, void *data) -{ - int i; - int ret; - - for_each_active_range_index_in_nid(i, nid) { - ret = work_fn(early_node_map[i].start_pfn, - early_node_map[i].end_pfn, data); - if (ret) - break; - } -} /** * sparse_memory_present_with_active_regions - Call memory_present for each active range * @nid: The node to call memory_present for. If MAX_NUMNODES, all nodes will be used. @@ -4421,6 +4409,34 @@ static inline void setup_nr_node_ids(void) } #endif +/* + * Common iterator interface used to define for_each_mem_pfn_range(). + */ +void __meminit __next_mem_pfn_range(int *idx, int nid, + unsigned long *out_start_pfn, + unsigned long *out_end_pfn, int *out_nid) +{ + struct node_active_region *r = NULL; + + while (++*idx < nr_nodemap_entries) { + if (nid == MAX_NUMNODES || nid == early_node_map[*idx].nid) { + r = &early_node_map[*idx]; + break; + } + } + if (!r) { + *idx = -1; + return; + } + + if (out_start_pfn) + *out_start_pfn = r->start_pfn; + if (out_end_pfn) + *out_end_pfn = r->end_pfn; + if (out_nid) + *out_nid = r->nid; +} + /** * add_active_range - Register a range of PFNs backed by physical memory * @nid: The node ID the range resides on -- cgit v0.10.2 From 96e907d1360240d1958fe8ce3a3ac640733330d4 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 10:46:29 +0200 Subject: bootmem: Reimplement __absent_pages_in_range() using for_each_mem_pfn_range() __absent_pages_in_range() was needlessly complex. Reimplement it using for_each_mem_pfn_range(). Also, update zone_absent_pages_in_node() such that it doesn't call __absent_pages_in_range() with @zone_start_pfn which is larger than @zone_end_pfn. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310460395-30913-3-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 69fffab..3092a97 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4044,46 +4044,16 @@ unsigned long __meminit __absent_pages_in_range(int nid, unsigned long range_start_pfn, unsigned long range_end_pfn) { - int i = 0; - unsigned long prev_end_pfn = 0, hole_pages = 0; - unsigned long start_pfn; - - /* Find the end_pfn of the first active range of pfns in the node */ - i = first_active_region_index_in_nid(nid); - if (i == -1) - return 0; - - prev_end_pfn = min(early_node_map[i].start_pfn, range_end_pfn); - - /* Account for ranges before physical memory on this node */ - if (early_node_map[i].start_pfn > range_start_pfn) - hole_pages = prev_end_pfn - range_start_pfn; - - /* Find all holes for the zone within the node */ - for (; i != -1; i = next_active_region_index_in_nid(i, nid)) { - - /* No need to continue if prev_end_pfn is outside the zone */ - if (prev_end_pfn >= range_end_pfn) - break; - - /* Make sure the end of the zone is not within the hole */ - start_pfn = min(early_node_map[i].start_pfn, range_end_pfn); - prev_end_pfn = max(prev_end_pfn, range_start_pfn); + unsigned long nr_absent = range_end_pfn - range_start_pfn; + unsigned long start_pfn, end_pfn; + int i; - /* Update the hole size cound and move on */ - if (start_pfn > range_start_pfn) { - BUG_ON(prev_end_pfn > start_pfn); - hole_pages += start_pfn - prev_end_pfn; - } - prev_end_pfn = early_node_map[i].end_pfn; + for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) { + start_pfn = clamp(start_pfn, range_start_pfn, range_end_pfn); + end_pfn = clamp(end_pfn, range_start_pfn, range_end_pfn); + nr_absent -= end_pfn - start_pfn; } - - /* Account for ranges past physical memory on this node */ - if (range_end_pfn > prev_end_pfn) - hole_pages += range_end_pfn - - max(range_start_pfn, prev_end_pfn); - - return hole_pages; + return nr_absent; } /** @@ -4104,14 +4074,14 @@ static unsigned long __meminit zone_absent_pages_in_node(int nid, unsigned long zone_type, unsigned long *ignored) { + unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type]; + unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type]; unsigned long node_start_pfn, node_end_pfn; unsigned long zone_start_pfn, zone_end_pfn; get_pfn_range_for_nid(nid, &node_start_pfn, &node_end_pfn); - zone_start_pfn = max(arch_zone_lowest_possible_pfn[zone_type], - node_start_pfn); - zone_end_pfn = min(arch_zone_highest_possible_pfn[zone_type], - node_end_pfn); + zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high); + zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high); adjust_zone_range_for_zone_movable(nid, zone_type, node_start_pfn, node_end_pfn, -- cgit v0.10.2 From c13291a536b835b2ab278ab201f2cb1ce22f2785 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 10:46:30 +0200 Subject: bootmem: Use for_each_mem_pfn_range() in page_alloc.c The previous patch added for_each_mem_pfn_range() which is more versatile than for_each_active_range_index_in_nid(). This patch replaces for_each_active_range_index_in_nid() and open coded early_node_map[] walks with for_each_mem_pfn_range(). All conversions in this patch are straight-forward and shouldn't cause any functional difference. After the conversions, for_each_active_range_index_in_nid() doesn't have any user left and is removed. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310460395-30913-4-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3092a97..902f03a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3711,34 +3711,6 @@ __meminit int init_currently_empty_zone(struct zone *zone, } #ifdef CONFIG_ARCH_POPULATES_NODE_MAP -/* - * Basic iterator support. Return the first range of PFNs for a node - * Note: nid == MAX_NUMNODES returns first region regardless of node - */ -static int __meminit first_active_region_index_in_nid(int nid) -{ - int i; - - for (i = 0; i < nr_nodemap_entries; i++) - if (nid == MAX_NUMNODES || early_node_map[i].nid == nid) - return i; - - return -1; -} - -/* - * Basic iterator support. Return the next active range of PFNs for a node - * Note: nid == MAX_NUMNODES returns next region regardless of node - */ -static int __meminit next_active_region_index_in_nid(int index, int nid) -{ - for (index = index + 1; index < nr_nodemap_entries; index++) - if (nid == MAX_NUMNODES || early_node_map[index].nid == nid) - return index; - - return -1; -} - #ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID /* * Required by SPARSEMEM. Given a PFN, return what node the PFN is on. @@ -3748,15 +3720,12 @@ static int __meminit next_active_region_index_in_nid(int index, int nid) */ int __meminit __early_pfn_to_nid(unsigned long pfn) { - int i; - - for (i = 0; i < nr_nodemap_entries; i++) { - unsigned long start_pfn = early_node_map[i].start_pfn; - unsigned long end_pfn = early_node_map[i].end_pfn; + unsigned long start_pfn, end_pfn; + int i, nid; + for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) if (start_pfn <= pfn && pfn < end_pfn) - return early_node_map[i].nid; - } + return nid; /* This is a memory hole */ return -1; } @@ -3785,11 +3754,6 @@ bool __meminit early_pfn_in_nid(unsigned long pfn, int node) } #endif -/* Basic iterator support to walk early_node_map[] */ -#define for_each_active_range_index_in_nid(i, nid) \ - for (i = first_active_region_index_in_nid(nid); i != -1; \ - i = next_active_region_index_in_nid(i, nid)) - /** * free_bootmem_with_active_regions - Call free_bootmem_node for each active range * @nid: The node to free memory on. If MAX_NUMNODES, all nodes are freed. @@ -3799,25 +3763,19 @@ bool __meminit early_pfn_in_nid(unsigned long pfn, int node) * add_active_ranges() contain no holes and may be freed, this * this function may be used instead of calling free_bootmem() manually. */ -void __init free_bootmem_with_active_regions(int nid, - unsigned long max_low_pfn) +void __init free_bootmem_with_active_regions(int nid, unsigned long max_low_pfn) { - int i; - - for_each_active_range_index_in_nid(i, nid) { - unsigned long size_pages = 0; - unsigned long end_pfn = early_node_map[i].end_pfn; - - if (early_node_map[i].start_pfn >= max_low_pfn) - continue; + unsigned long start_pfn, end_pfn; + int i, this_nid; - if (end_pfn > max_low_pfn) - end_pfn = max_low_pfn; + for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, &this_nid) { + start_pfn = min(start_pfn, max_low_pfn); + end_pfn = min(end_pfn, max_low_pfn); - size_pages = end_pfn - early_node_map[i].start_pfn; - free_bootmem_node(NODE_DATA(early_node_map[i].nid), - PFN_PHYS(early_node_map[i].start_pfn), - size_pages << PAGE_SHIFT); + if (start_pfn < end_pfn) + free_bootmem_node(NODE_DATA(this_nid), + PFN_PHYS(start_pfn), + (end_pfn - start_pfn) << PAGE_SHIFT); } } @@ -3891,15 +3849,12 @@ u64 __init find_memory_core_early(int nid, u64 size, u64 align, int __init add_from_early_node_map(struct range *range, int az, int nr_range, int nid) { + unsigned long start_pfn, end_pfn; int i; - u64 start, end; /* need to go over early_node_map to find out good range for node */ - for_each_active_range_index_in_nid(i, nid) { - start = early_node_map[i].start_pfn; - end = early_node_map[i].end_pfn; - nr_range = add_range(range, az, nr_range, start, end); - } + for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) + nr_range = add_range(range, az, nr_range, start_pfn, end_pfn); return nr_range; } @@ -3913,12 +3868,11 @@ int __init add_from_early_node_map(struct range *range, int az, */ void __init sparse_memory_present_with_active_regions(int nid) { - int i; + unsigned long start_pfn, end_pfn; + int i, this_nid; - for_each_active_range_index_in_nid(i, nid) - memory_present(early_node_map[i].nid, - early_node_map[i].start_pfn, - early_node_map[i].end_pfn); + for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, &this_nid) + memory_present(this_nid, start_pfn, end_pfn); } /** @@ -3935,13 +3889,15 @@ void __init sparse_memory_present_with_active_regions(int nid) void __meminit get_pfn_range_for_nid(unsigned int nid, unsigned long *start_pfn, unsigned long *end_pfn) { + unsigned long this_start_pfn, this_end_pfn; int i; + *start_pfn = -1UL; *end_pfn = 0; - for_each_active_range_index_in_nid(i, nid) { - *start_pfn = min(*start_pfn, early_node_map[i].start_pfn); - *end_pfn = max(*end_pfn, early_node_map[i].end_pfn); + for_each_mem_pfn_range(i, nid, &this_start_pfn, &this_end_pfn, NULL) { + *start_pfn = min(*start_pfn, this_start_pfn); + *end_pfn = max(*end_pfn, this_end_pfn); } if (*start_pfn == -1UL) @@ -4484,6 +4440,7 @@ void __init add_active_range(unsigned int nid, unsigned long start_pfn, void __init remove_active_range(unsigned int nid, unsigned long start_pfn, unsigned long end_pfn) { + unsigned long this_start_pfn, this_end_pfn; int i, j; int removed = 0; @@ -4491,26 +4448,22 @@ void __init remove_active_range(unsigned int nid, unsigned long start_pfn, nid, start_pfn, end_pfn); /* Find the old active region end and shrink */ - for_each_active_range_index_in_nid(i, nid) { - if (early_node_map[i].start_pfn >= start_pfn && - early_node_map[i].end_pfn <= end_pfn) { + for_each_mem_pfn_range(i, nid, &this_start_pfn, &this_end_pfn, NULL) { + if (this_start_pfn >= start_pfn && this_end_pfn <= end_pfn) { /* clear it */ early_node_map[i].start_pfn = 0; early_node_map[i].end_pfn = 0; removed = 1; continue; } - if (early_node_map[i].start_pfn < start_pfn && - early_node_map[i].end_pfn > start_pfn) { - unsigned long temp_end_pfn = early_node_map[i].end_pfn; + if (this_start_pfn < start_pfn && this_end_pfn > start_pfn) { early_node_map[i].end_pfn = start_pfn; - if (temp_end_pfn > end_pfn) - add_active_range(nid, end_pfn, temp_end_pfn); + if (this_end_pfn > end_pfn) + add_active_range(nid, end_pfn, this_end_pfn); continue; } - if (early_node_map[i].start_pfn >= start_pfn && - early_node_map[i].end_pfn > end_pfn && - early_node_map[i].start_pfn < end_pfn) { + if (this_start_pfn >= start_pfn && this_end_pfn > end_pfn && + this_start_pfn < end_pfn) { early_node_map[i].start_pfn = end_pfn; continue; } @@ -4593,15 +4546,11 @@ void __init sort_node_map(void) unsigned long __init node_map_pfn_alignment(void) { unsigned long accl_mask = 0, last_end = 0; + unsigned long start, end, mask; int last_nid = -1; - int i; - - for_each_active_range_index_in_nid(i, MAX_NUMNODES) { - int nid = early_node_map[i].nid; - unsigned long start = early_node_map[i].start_pfn; - unsigned long end = early_node_map[i].end_pfn; - unsigned long mask; + int i, nid; + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, &nid) { if (!start || last_nid < 0 || last_nid == nid) { last_nid = nid; last_end = end; @@ -4628,12 +4577,12 @@ unsigned long __init node_map_pfn_alignment(void) /* Find the lowest pfn for a node */ static unsigned long __init find_min_pfn_for_node(int nid) { - int i; unsigned long min_pfn = ULONG_MAX; + unsigned long start_pfn; + int i; - /* Assuming a sorted map, the first range found has the starting pfn */ - for_each_active_range_index_in_nid(i, nid) - min_pfn = min(min_pfn, early_node_map[i].start_pfn); + for_each_mem_pfn_range(i, nid, &start_pfn, NULL, NULL) + min_pfn = min(min_pfn, start_pfn); if (min_pfn == ULONG_MAX) { printk(KERN_WARNING @@ -4662,15 +4611,16 @@ unsigned long __init find_min_pfn_with_active_regions(void) */ static unsigned long __init early_calculate_totalpages(void) { - int i; unsigned long totalpages = 0; + unsigned long start_pfn, end_pfn; + int i, nid; + + for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) { + unsigned long pages = end_pfn - start_pfn; - for (i = 0; i < nr_nodemap_entries; i++) { - unsigned long pages = early_node_map[i].end_pfn - - early_node_map[i].start_pfn; totalpages += pages; if (pages) - node_set_state(early_node_map[i].nid, N_HIGH_MEMORY); + node_set_state(nid, N_HIGH_MEMORY); } return totalpages; } @@ -4725,6 +4675,8 @@ restart: /* Spread kernelcore memory as evenly as possible throughout nodes */ kernelcore_node = required_kernelcore / usable_nodes; for_each_node_state(nid, N_HIGH_MEMORY) { + unsigned long start_pfn, end_pfn; + /* * Recalculate kernelcore_node if the division per node * now exceeds what is necessary to satisfy the requested @@ -4741,13 +4693,10 @@ restart: kernelcore_remaining = kernelcore_node; /* Go through each range of PFNs within this node */ - for_each_active_range_index_in_nid(i, nid) { - unsigned long start_pfn, end_pfn; + for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) { unsigned long size_pages; - start_pfn = max(early_node_map[i].start_pfn, - zone_movable_pfn[nid]); - end_pfn = early_node_map[i].end_pfn; + start_pfn = max(start_pfn, zone_movable_pfn[nid]); if (start_pfn >= end_pfn) continue; @@ -4849,8 +4798,8 @@ static void check_for_regular_memory(pg_data_t *pgdat) */ void __init free_area_init_nodes(unsigned long *max_zone_pfn) { - unsigned long nid; - int i; + unsigned long start_pfn, end_pfn; + int i, nid; /* Sort early_node_map as initialisation assumes it is sorted */ sort_node_map(); @@ -4900,11 +4849,9 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn) } /* Print out the early_node_map[] */ - printk("early_node_map[%d] active PFN ranges\n", nr_nodemap_entries); - for (i = 0; i < nr_nodemap_entries; i++) - printk(" %3d: %0#10lx -> %0#10lx\n", early_node_map[i].nid, - early_node_map[i].start_pfn, - early_node_map[i].end_pfn); + printk("Early memory PFN ranges\n"); + for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) + printk(" %3d: %0#10lx -> %0#10lx\n", nid, start_pfn, end_pfn); /* Initialise every node */ mminit_verify_pageflags_layout(); -- cgit v0.10.2 From b2fea988f4f3b38ff4edfc1556a843c91932804c Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 10:46:31 +0200 Subject: memblock: Improve generic memblock_nid_range() using for_each_mem_pfn_range() Given an address range, memblock_nid_range() determines the node the start of the range belongs to and upto where the range stays in the same node. It's implemented by calling get_pfn_range_for_nid(), which determines min and max pfns for a given node, for each node and testing whether start address falls in there. This is not only inefficient but also incorrect when nodes interleave as min-max ranges for nodes overlap. This patch reimplements memblock_nid_range() using for_each_mem_pfn_range(). It's simpler, walks the mem ranges once and can find the exact range the start address falls in. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310460395-30913-5-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/mm/memblock.c b/mm/memblock.c index 0f9626f..97f3486 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -511,28 +511,14 @@ phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align) phys_addr_t __weak __init memblock_nid_range(phys_addr_t start, phys_addr_t end, int *nid) { #ifdef CONFIG_ARCH_POPULATES_NODE_MAP - /* - * This code originates from sparc which really wants use to walk by addresses - * and returns the nid. This is not very convenient for early_pfn_map[] users - * as the map isn't sorted yet, and it really wants to be walked by nid. - * - * For now, I implement the inefficient method below which walks the early - * map multiple times. Eventually we may want to use an ARCH config option - * to implement a completely different method for both case. - */ unsigned long start_pfn, end_pfn; int i; - for (i = 0; i < MAX_NUMNODES; i++) { - get_pfn_range_for_nid(i, &start_pfn, &end_pfn); - if (start < PFN_PHYS(start_pfn) || start >= PFN_PHYS(end_pfn)) - continue; - *nid = i; - return min(end, PFN_PHYS(end_pfn)); - } + for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, nid) + if (start >= PFN_PHYS(start_pfn) && start < PFN_PHYS(end_pfn)) + return min(end, PFN_PHYS(end_pfn)); #endif *nid = 0; - return end; } -- cgit v0.10.2 From f9b18db3b1cedc75e5d002a4d7097891c3399736 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 10:46:32 +0200 Subject: memblock: Don't allow archs to override memblock_nid_range() memblock_nid_range() is used to implement memblock_[try_]alloc_nid(). The generic version determines the range by walking early_node_map with for_each_mem_pfn_range(). The generic version is defined __weak to allow arch override. Currently, only sparc overrides it; however, with the previous update to the generic implementation, there isn't much to be gained with arch override. Sparc would behave exactly the same with the generic implementation. This patch disallows arch override for memblock_nid_range() and make both generic and sparc versions static. sparc is only compile tested. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310460395-30913-6-git-send-email-tj@kernel.org Cc: "David S. Miller" Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 3fd8e18..8415f61 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -785,7 +785,7 @@ static int find_node(unsigned long addr) return -1; } -u64 memblock_nid_range(u64 start, u64 end, int *nid) +static u64 memblock_nid_range(u64 start, u64 end, int *nid) { *nid = find_node(start); start += PAGE_SIZE; @@ -803,7 +803,7 @@ u64 memblock_nid_range(u64 start, u64 end, int *nid) return start; } #else -u64 memblock_nid_range(u64 start, u64 end, int *nid) +static u64 memblock_nid_range(u64 start, u64 end, int *nid) { *nid = 0; return end; diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 3496888..329ffb2 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -89,7 +89,6 @@ extern int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size); extern void memblock_dump_all(void); /* Provided by the architecture */ -extern phys_addr_t memblock_nid_range(phys_addr_t start, phys_addr_t end, int *nid); extern int memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1, phys_addr_t addr2, phys_addr_t size2); diff --git a/mm/memblock.c b/mm/memblock.c index 97f3486..22cd999 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -508,7 +508,7 @@ phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align) * have been done to populate it. */ -phys_addr_t __weak __init memblock_nid_range(phys_addr_t start, phys_addr_t end, int *nid) +static phys_addr_t __init memblock_nid_range(phys_addr_t start, phys_addr_t end, int *nid) { #ifdef CONFIG_ARCH_POPULATES_NODE_MAP unsigned long start_pfn, end_pfn; -- cgit v0.10.2 From 34e1845548418e5cecee0568ba721e1f089c092c Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 10:46:33 +0200 Subject: memblock: Make memblock_alloc_[try_]nid() top-down NUMA aware memblock alloc functions - memblock_alloc_[try_]nid() - weren't properly top-down because memblock_nid_range() scanned forward. This patch reverses memblock_nid_range(), renames it to memblock_nid_range_rev() and updates related functions to implement proper top-down allocation. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310460395-30913-7-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/mm/memblock.c b/mm/memblock.c index 22cd999..447cf64 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -499,27 +499,26 @@ phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align) /* - * Additional node-local allocators. Search for node memory is bottom up - * and walks memblock regions within that node bottom-up as well, but allocation - * within an memblock region is top-down. XXX I plan to fix that at some stage + * Additional node-local top-down allocators. * * WARNING: Only available after early_node_map[] has been populated, * on some architectures, that is after all the calls to add_active_range() * have been done to populate it. */ -static phys_addr_t __init memblock_nid_range(phys_addr_t start, phys_addr_t end, int *nid) +static phys_addr_t __init memblock_nid_range_rev(phys_addr_t start, + phys_addr_t end, int *nid) { #ifdef CONFIG_ARCH_POPULATES_NODE_MAP unsigned long start_pfn, end_pfn; int i; for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, nid) - if (start >= PFN_PHYS(start_pfn) && start < PFN_PHYS(end_pfn)) - return min(end, PFN_PHYS(end_pfn)); + if (end > PFN_PHYS(start_pfn) && end <= PFN_PHYS(end_pfn)) + return max(start, PFN_PHYS(start_pfn)); #endif *nid = 0; - return end; + return start; } static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp, @@ -531,21 +530,19 @@ static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp, start = mp->base; end = start + mp->size; - start = round_up(start, align); while (start < end) { - phys_addr_t this_end; + phys_addr_t this_start; int this_nid; - this_end = memblock_nid_range(start, end, &this_nid); + this_start = memblock_nid_range_rev(start, end, &this_nid); if (this_nid == nid) { - phys_addr_t ret = memblock_find_region(start, this_end, size, align); + phys_addr_t ret = memblock_find_region(this_start, end, size, align); if (ret && !memblock_add_region(&memblock.reserved, ret, size)) return ret; } - start = this_end; + end = this_start; } - return 0; } @@ -561,11 +558,7 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n */ size = round_up(size, align); - /* We do a bottom-up search for a region with the right - * nid since that's easier considering how memblock_nid_range() - * works - */ - for (i = 0; i < mem->cnt; i++) { + for (i = mem->cnt - 1; i >= 0; i--) { phys_addr_t ret = memblock_alloc_nid_region(&mem->regions[i], size, align, nid); if (ret) -- cgit v0.10.2 From e64980405cc6aa74ef178d8d9aa4018c867ceed1 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 10:46:34 +0200 Subject: memblock: Separate out memblock_find_in_range_node() Node affine memblock allocation logic is currently implemented across memblock_alloc_nid() and memblock_alloc_nid_region(). This reorganizes it such that it resembles that of non-NUMA allocation API. Area finding is collected and moved into new exported function memblock_find_in_range_node() which is symmetrical to non-NUMA counterpart - it handles @start/@end and understands ANYWHERE and ACCESSIBLE. memblock_alloc_nid() now simply calls memblock_find_in_range_node() and reserves the returned area. This makes memblock_alloc[_try]_nid() observe ACCESSIBLE limit on node affine allocations too (again, this doesn't make any difference for the current sole user - sparc64). Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310460395-30913-8-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 329ffb2..7400d029 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -61,6 +61,10 @@ extern long memblock_reserve(phys_addr_t base, phys_addr_t size); /* The numa aware allocator is only available if * CONFIG_ARCH_POPULATES_NODE_MAP is set */ +extern phys_addr_t memblock_find_in_range_node(phys_addr_t start, + phys_addr_t end, + phys_addr_t size, + phys_addr_t align, int nid); extern phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); extern phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, diff --git a/mm/memblock.c b/mm/memblock.c index 447cf64..a8edb42 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -521,49 +521,56 @@ static phys_addr_t __init memblock_nid_range_rev(phys_addr_t start, return start; } -static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp, +phys_addr_t __init memblock_find_in_range_node(phys_addr_t start, + phys_addr_t end, phys_addr_t size, phys_addr_t align, int nid) { - phys_addr_t start, end; + struct memblock_type *mem = &memblock.memory; + int i; - start = mp->base; - end = start + mp->size; + BUG_ON(0 == size); - while (start < end) { - phys_addr_t this_start; - int this_nid; + /* Pump up max_addr */ + if (end == MEMBLOCK_ALLOC_ACCESSIBLE) + end = memblock.current_limit; - this_start = memblock_nid_range_rev(start, end, &this_nid); - if (this_nid == nid) { - phys_addr_t ret = memblock_find_region(this_start, end, size, align); - if (ret && - !memblock_add_region(&memblock.reserved, ret, size)) - return ret; + for (i = mem->cnt - 1; i >= 0; i--) { + struct memblock_region *r = &mem->regions[i]; + phys_addr_t base = max(start, r->base); + phys_addr_t top = min(end, r->base + r->size); + + while (base < top) { + phys_addr_t tbase, ret; + int tnid; + + tbase = memblock_nid_range_rev(base, top, &tnid); + if (nid == MAX_NUMNODES || tnid == nid) { + ret = memblock_find_region(tbase, top, size, align); + if (ret) + return ret; + } + top = tbase; } - end = this_start; } + return 0; } phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid) { - struct memblock_type *mem = &memblock.memory; - int i; - - BUG_ON(0 == size); + phys_addr_t found; - /* We align the size to limit fragmentation. Without this, a lot of + /* + * We align the size to limit fragmentation. Without this, a lot of * small allocs quickly eat up the whole reserve array on sparc */ size = round_up(size, align); - for (i = mem->cnt - 1; i >= 0; i--) { - phys_addr_t ret = memblock_alloc_nid_region(&mem->regions[i], - size, align, nid); - if (ret) - return ret; - } + found = memblock_find_in_range_node(0, MEMBLOCK_ALLOC_ACCESSIBLE, + size, align, nid); + if (found && !memblock_add_region(&memblock.reserved, found, size)) + return found; return 0; } -- cgit v0.10.2 From eb40c4c27f1722f058e4713ccfedebac577d5190 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 10:46:35 +0200 Subject: memblock, x86: Replace memblock_x86_find_in_range_node() with generic memblock calls With the previous changes, generic NUMA aware memblock API has feature parity with memblock_x86_find_in_range_node(). There currently are two users - x86 setup_node_data() and __alloc_memory_core_early() in nobootmem.c. This patch converts the former to use memblock_alloc_nid() and the latter memblock_find_range_in_node(), and kills memblock_x86_find_in_range_node() and related functions including find_memory_early_core_early() in page_alloc.c. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310460395-30913-9-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index 0cd3800..161792e 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -15,7 +15,6 @@ int get_free_all_memory_range(struct range **rangep, int nodeid); void memblock_x86_register_active_regions(int nid, unsigned long start_pfn, unsigned long last_pfn); u64 memblock_x86_hole_size(u64 start, u64 end); -u64 memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size, u64 align); u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); u64 memblock_x86_memory_in_range(u64 addr, u64 limit); bool memblock_x86_check_reserved_size(u64 *addrp, u64 *sizep, u64 align); diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index da0d5c8..e4569f8 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -252,21 +252,6 @@ void __init memblock_x86_free_range(u64 start, u64 end) } /* - * Need to call this function after memblock_x86_register_active_regions, - * so early_node_map[] is filled already. - */ -u64 __init memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size, u64 align) -{ - u64 addr; - addr = find_memory_core_early(nid, size, align, start, end); - if (addr) - return addr; - - /* Fallback, should already have start end within node range */ - return memblock_find_in_range(start, end, size, align); -} - -/* * Finds an active region in the address range from start_pfn to last_pfn and * returns its range in ei_startpfn and ei_endpfn for the memblock entry. */ diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index fa1015d..824efad 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -192,8 +192,6 @@ int __init numa_add_memblk(int nid, u64 start, u64 end) /* Initialize NODE_DATA for a node on the local memory */ static void __init setup_node_data(int nid, u64 start, u64 end) { - const u64 nd_low = PFN_PHYS(MAX_DMA_PFN); - const u64 nd_high = PFN_PHYS(max_pfn_mapped); const size_t nd_size = roundup(sizeof(pg_data_t), PAGE_SIZE); bool remapped = false; u64 nd_pa; @@ -224,17 +222,12 @@ static void __init setup_node_data(int nid, u64 start, u64 end) nd_pa = __pa(nd); remapped = true; } else { - nd_pa = memblock_x86_find_in_range_node(nid, nd_low, nd_high, - nd_size, SMP_CACHE_BYTES); - if (!nd_pa) - nd_pa = memblock_find_in_range(nd_low, nd_high, - nd_size, SMP_CACHE_BYTES); + nd_pa = memblock_alloc_nid(nd_size, SMP_CACHE_BYTES, nid); if (!nd_pa) { pr_err("Cannot find %zu bytes in node %d\n", nd_size, nid); return; } - memblock_x86_reserve_range(nd_pa, nd_pa + nd_size, "NODE_DATA"); nd = __va(nd_pa); } diff --git a/include/linux/mm.h b/include/linux/mm.h index 57e4c9f..9ebc65a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1325,8 +1325,6 @@ extern void free_bootmem_with_active_regions(int nid, unsigned long max_low_pfn); int add_from_early_node_map(struct range *range, int az, int nr_range, int nid); -u64 __init find_memory_core_early(int nid, u64 size, u64 align, - u64 goal, u64 limit); extern void sparse_memory_present_with_active_regions(int nid); extern void __next_mem_pfn_range(int *idx, int nid, diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 5b0eb06..c781626 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c @@ -41,8 +41,7 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align, if (limit > memblock.current_limit) limit = memblock.current_limit; - addr = find_memory_core_early(nid, size, align, goal, limit); - + addr = memblock_find_in_range_node(goal, limit, size, align, nid); if (!addr) return NULL; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 902f03a..8ab5e5e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3779,73 +3779,6 @@ void __init free_bootmem_with_active_regions(int nid, unsigned long max_low_pfn) } } -#ifdef CONFIG_HAVE_MEMBLOCK -/* - * Basic iterator support. Return the last range of PFNs for a node - * Note: nid == MAX_NUMNODES returns last region regardless of node - */ -static int __meminit last_active_region_index_in_nid(int nid) -{ - int i; - - for (i = nr_nodemap_entries - 1; i >= 0; i--) - if (nid == MAX_NUMNODES || early_node_map[i].nid == nid) - return i; - - return -1; -} - -/* - * Basic iterator support. Return the previous active range of PFNs for a node - * Note: nid == MAX_NUMNODES returns next region regardless of node - */ -static int __meminit previous_active_region_index_in_nid(int index, int nid) -{ - for (index = index - 1; index >= 0; index--) - if (nid == MAX_NUMNODES || early_node_map[index].nid == nid) - return index; - - return -1; -} - -#define for_each_active_range_index_in_nid_reverse(i, nid) \ - for (i = last_active_region_index_in_nid(nid); i != -1; \ - i = previous_active_region_index_in_nid(i, nid)) - -u64 __init find_memory_core_early(int nid, u64 size, u64 align, - u64 goal, u64 limit) -{ - int i; - - /* Need to go over early_node_map to find out good range for node */ - for_each_active_range_index_in_nid_reverse(i, nid) { - u64 addr; - u64 ei_start, ei_last; - u64 final_start, final_end; - - ei_last = early_node_map[i].end_pfn; - ei_last <<= PAGE_SHIFT; - ei_start = early_node_map[i].start_pfn; - ei_start <<= PAGE_SHIFT; - - final_start = max(ei_start, goal); - final_end = min(ei_last, limit); - - if (final_start >= final_end) - continue; - - addr = memblock_find_in_range(final_start, final_end, size, align); - - if (!addr) - continue; - - return addr; - } - - return 0; -} -#endif - int __init add_from_early_node_map(struct range *range, int az, int nr_range, int nid) { -- cgit v0.10.2 From ed7b56a799cade11f458cd83e1150af54a66b7e8 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:15:54 +0200 Subject: memblock: Remove memblock_memory_can_coalesce() Arch could implement memblock_memor_can_coalesce() to veto merging of adjacent or overlapping memblock regions; however, no arch did and any vetoing would trigger WARN_ON(). Memblock regions are supposed to deal with proper memory anyway. Remove the unused hook. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-2-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 7400d029..aa5df9e1 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -92,10 +92,6 @@ extern int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size); extern void memblock_dump_all(void); -/* Provided by the architecture */ -extern int memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1, - phys_addr_t addr2, phys_addr_t size2); - /** * memblock_set_current_limit - Set the current allocation limit to allow * limiting allocations to what is currently diff --git a/mm/memblock.c b/mm/memblock.c index a8edb42..bd3a3a9 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -251,12 +251,6 @@ static int __init_memblock memblock_double_array(struct memblock_type *type) return 0; } -extern int __init_memblock __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1, - phys_addr_t addr2, phys_addr_t size2) -{ - return 1; -} - static long __init_memblock memblock_add_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size) { @@ -282,17 +276,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, * of a block. */ if (base < rgn->base && end >= rgn->base) { - /* If we can't coalesce, create a new block */ - if (!memblock_memory_can_coalesce(base, size, - rgn->base, - rgn->size)) { - /* Overlap & can't coalesce are mutually - * exclusive, if you do that, be prepared - * for trouble - */ - WARN_ON(end != rgn->base); - goto new_block; - } /* We extend the bottom of the block down to our * base */ @@ -316,17 +299,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, * top of a block */ if (base <= rend && end >= rend) { - /* If we can't coalesce, create a new block */ - if (!memblock_memory_can_coalesce(rgn->base, - rgn->size, - base, size)) { - /* Overlap & can't coalesce are mutually - * exclusive, if you do that, be prepared - * for trouble - */ - WARN_ON(rend != base); - goto new_block; - } /* We adjust our base down to enclose the * original block and destroy it. It will be * part of our new allocation. Since we've @@ -349,7 +321,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, return 0; } - new_block: /* If we are out of space, we fail. It's too late to resize the array * but then this shouldn't have happened in the first place. */ -- cgit v0.10.2 From 784656f9c680d334e7b4cdb6951c5c913e5a26bf Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:15:55 +0200 Subject: memblock: Reimplement memblock_add_region() memblock_add_region() carefully checked for merge and overlap conditions while adding a new region, which is complicated and makes it difficult to allow arbitrary overlaps or add more merge conditions (e.g. node ID). This re-implements memblock_add_region() such that insertion is done in two steps - all non-overlapping portions of new area are inserted as separate regions first and then memblock_merge_regions() scan and merge all neighbouring compatible regions. This makes addition logic simpler and more versatile and enables adding node information to memblock. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-3-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/mm/memblock.c b/mm/memblock.c index bd3a3a9..992aa18 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -251,117 +251,142 @@ static int __init_memblock memblock_double_array(struct memblock_type *type) return 0; } -static long __init_memblock memblock_add_region(struct memblock_type *type, - phys_addr_t base, phys_addr_t size) +/** + * memblock_merge_regions - merge neighboring compatible regions + * @type: memblock type to scan + * + * Scan @type and merge neighboring compatible regions. + */ +static void __init_memblock memblock_merge_regions(struct memblock_type *type) { - phys_addr_t end = base + size; - int i, slot = -1; + int i = 0; - /* First try and coalesce this MEMBLOCK with others */ - for (i = 0; i < type->cnt; i++) { - struct memblock_region *rgn = &type->regions[i]; - phys_addr_t rend = rgn->base + rgn->size; + /* cnt never goes below 1 */ + while (i < type->cnt - 1) { + struct memblock_region *this = &type->regions[i]; + struct memblock_region *next = &type->regions[i + 1]; - /* Exit if there's no possible hits */ - if (rgn->base > end || rgn->size == 0) - break; - - /* Check if we are fully enclosed within an existing - * block - */ - if (rgn->base <= base && rend >= end) - return 0; + if (this->base + this->size != next->base) { + BUG_ON(this->base + this->size > next->base); + i++; + continue; + } - /* Check if we overlap or are adjacent with the bottom - * of a block. - */ - if (base < rgn->base && end >= rgn->base) { - /* We extend the bottom of the block down to our - * base - */ - rgn->base = base; - rgn->size = rend - base; + this->size += next->size; + memmove(next, next + 1, (type->cnt - (i + 1)) * sizeof(*next)); + type->cnt--; + } +} - /* Return if we have nothing else to allocate - * (fully coalesced) - */ - if (rend >= end) - return 0; +/** + * memblock_insert_region - insert new memblock region + * @type: memblock type to insert into + * @idx: index for the insertion point + * @base: base address of the new region + * @size: size of the new region + * + * Insert new memblock region [@base,@base+@size) into @type at @idx. + * @type must already have extra room to accomodate the new region. + */ +static void __init_memblock memblock_insert_region(struct memblock_type *type, + int idx, phys_addr_t base, + phys_addr_t size) +{ + struct memblock_region *rgn = &type->regions[idx]; - /* We continue processing from the end of the - * coalesced block. - */ - base = rend; - size = end - base; - } + BUG_ON(type->cnt >= type->max); + memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn)); + rgn->base = base; + rgn->size = size; + type->cnt++; +} - /* Now check if we overlap or are adjacent with the - * top of a block - */ - if (base <= rend && end >= rend) { - /* We adjust our base down to enclose the - * original block and destroy it. It will be - * part of our new allocation. Since we've - * freed an entry, we know we won't fail - * to allocate one later, so we won't risk - * losing the original block allocation. - */ - size += (base - rgn->base); - base = rgn->base; - memblock_remove_region(type, i--); - } - } +/** + * memblock_add_region - add new memblock region + * @type: memblock type to add new region into + * @base: base address of the new region + * @size: size of the new region + * + * Add new memblock region [@base,@base+@size) into @type. The new region + * is allowed to overlap with existing ones - overlaps don't affect already + * existing regions. @type is guaranteed to be minimal (all neighbouring + * compatible regions are merged) after the addition. + * + * RETURNS: + * 0 on success, -errno on failure. + */ +static long __init_memblock memblock_add_region(struct memblock_type *type, + phys_addr_t base, phys_addr_t size) +{ + bool insert = false; + phys_addr_t obase = base, end = base + size; + int i, nr_new; - /* If the array is empty, special case, replace the fake - * filler region and return - */ - if ((type->cnt == 1) && (type->regions[0].size == 0)) { + /* special case for empty array */ + if (type->regions[0].size == 0) { + WARN_ON(type->cnt != 1); type->regions[0].base = base; type->regions[0].size = size; return 0; } - - /* If we are out of space, we fail. It's too late to resize the array - * but then this shouldn't have happened in the first place. +repeat: + /* + * The following is executed twice. Once with %false @insert and + * then with %true. The first counts the number of regions needed + * to accomodate the new area. The second actually inserts them. */ - if (WARN_ON(type->cnt >= type->max)) - return -1; + base = obase; + nr_new = 0; + + for (i = 0; i < type->cnt; i++) { + struct memblock_region *rgn = &type->regions[i]; + phys_addr_t rbase = rgn->base; + phys_addr_t rend = rbase + rgn->size; - /* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */ - for (i = type->cnt - 1; i >= 0; i--) { - if (base < type->regions[i].base) { - type->regions[i+1].base = type->regions[i].base; - type->regions[i+1].size = type->regions[i].size; - } else { - type->regions[i+1].base = base; - type->regions[i+1].size = size; - slot = i + 1; + if (rbase >= end) break; + if (rend <= base) + continue; + /* + * @rgn overlaps. If it separates the lower part of new + * area, insert that portion. + */ + if (rbase > base) { + nr_new++; + if (insert) + memblock_insert_region(type, i++, base, + rbase - base); } + /* area below @rend is dealt with, forget about it */ + base = min(rend, end); } - if (base < type->regions[0].base) { - type->regions[0].base = base; - type->regions[0].size = size; - slot = 0; + + /* insert the remaining portion */ + if (base < end) { + nr_new++; + if (insert) + memblock_insert_region(type, i, base, end - base); } - type->cnt++; - /* The array is full ? Try to resize it. If that fails, we undo - * our allocation and return an error + /* + * If this was the first round, resize array and repeat for actual + * insertions; otherwise, merge and return. */ - if (type->cnt == type->max && memblock_double_array(type)) { - BUG_ON(slot < 0); - memblock_remove_region(type, slot); - return -1; + if (!insert) { + while (type->cnt + nr_new > type->max) + if (memblock_double_array(type) < 0) + return -ENOMEM; + insert = true; + goto repeat; + } else { + memblock_merge_regions(type); + return 0; } - - return 0; } long __init_memblock memblock_add(phys_addr_t base, phys_addr_t size) { return memblock_add_region(&memblock.memory, base, size); - } static long __init_memblock __memblock_remove(struct memblock_type *type, -- cgit v0.10.2 From 67e24bcb725cabd15ef577bf301275d03d6086d7 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:42:03 +0200 Subject: memblock: Use __meminit[data] instead of __init[data] From 19ab281ed67b87a6623d725237a7333ca79f1e75 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:22:16 +0200 memblock will be extended to include early_node_map[], which is also used during memory hotplug. Make memblock use __meminit[data] instead of __init[data] so that memory hotplug code can safely reference it. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/20110714094203.GE3455@htj.dyndns.org Reported-by: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/include/linux/memblock.h b/include/linux/memblock.h index aa5df9e1..434b958 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -152,8 +152,8 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo #ifdef ARCH_DISCARD_MEMBLOCK -#define __init_memblock __init -#define __initdata_memblock __initdata +#define __init_memblock __meminit +#define __initdata_memblock __meminitdata #else #define __init_memblock #define __initdata_memblock -- cgit v0.10.2 From 7c0caeb866b0f648d91bb75b8bc6f86af95bb033 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:43:42 +0200 Subject: memblock: Add optional region->nid From 83103b92f3234ec830852bbc5c45911bd6cbdb20 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:22:16 +0200 Add optional region->nid which can be enabled by arch using CONFIG_HAVE_MEMBLOCK_NODE_MAP. When enabled, memblock also carries NUMA node information and replaces early_node_map[]. Newly added memblocks have MAX_NUMNODES as nid. Arch can then call memblock_set_node() to set node information. memblock takes care of merging and node affine allocations w.r.t. node information. When MEMBLOCK_NODE_MAP is enabled, early_node_map[], related data structures and functions to manipulate and iterate it are disabled. memblock version of __next_mem_pfn_range() is provided such that for_each_mem_pfn_range() behaves the same and its users don't have to be updated. -v2: Yinghai spotted section mismatch caused by missing __init_memblock in memblock_set_node(). Fixed. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/20110714094342.GF3455@htj.dyndns.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 434b958..c36a55d 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -24,6 +24,9 @@ struct memblock_region { phys_addr_t base; phys_addr_t size; +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP + int nid; +#endif }; struct memblock_type { @@ -58,6 +61,29 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size); extern long memblock_free(phys_addr_t base, phys_addr_t size); extern long memblock_reserve(phys_addr_t base, phys_addr_t size); +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid); + +static inline void memblock_set_region_node(struct memblock_region *r, int nid) +{ + r->nid = nid; +} + +static inline int memblock_get_region_node(const struct memblock_region *r) +{ + return r->nid; +} +#else +static inline void memblock_set_region_node(struct memblock_region *r, int nid) +{ +} + +static inline int memblock_get_region_node(const struct memblock_region *r) +{ + return 0; +} +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + /* The numa aware allocator is only available if * CONFIG_ARCH_POPULATES_NODE_MAP is set */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 9ebc65a..ceb1e4a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1307,12 +1307,14 @@ extern void free_area_init_node(int nid, unsigned long * zones_size, * CONFIG_ARCH_POPULATES_NODE_MAP */ extern void free_area_init_nodes(unsigned long *max_zone_pfn); +#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP extern void add_active_range(unsigned int nid, unsigned long start_pfn, unsigned long end_pfn); extern void remove_active_range(unsigned int nid, unsigned long start_pfn, unsigned long end_pfn); extern void remove_all_active_ranges(void); void sort_node_map(void); +#endif unsigned long node_map_pfn_alignment(void); unsigned long __absent_pages_in_range(int nid, unsigned long start_pfn, unsigned long end_pfn); diff --git a/mm/Kconfig b/mm/Kconfig index 8ca47a5..30a5d47 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -131,6 +131,9 @@ config SPARSEMEM_VMEMMAP config HAVE_MEMBLOCK boolean +config HAVE_MEMBLOCK_NODE_MAP + boolean + # eventually, we can have this option just 'select SPARSEMEM' config MEMORY_HOTPLUG bool "Allow for memory hot-add" diff --git a/mm/memblock.c b/mm/memblock.c index 992aa18..e815f4b 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -161,12 +161,8 @@ int __init_memblock memblock_reserve_reserved_regions(void) static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r) { - unsigned long i; - - for (i = r; i < type->cnt - 1; i++) { - type->regions[i].base = type->regions[i + 1].base; - type->regions[i].size = type->regions[i + 1].size; - } + memmove(&type->regions[r], &type->regions[r + 1], + (type->cnt - (r + 1)) * sizeof(type->regions[r])); type->cnt--; /* Special case for empty arrays */ @@ -174,6 +170,7 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u type->cnt = 1; type->regions[0].base = 0; type->regions[0].size = 0; + memblock_set_region_node(&type->regions[0], MAX_NUMNODES); } } @@ -266,7 +263,9 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type) struct memblock_region *this = &type->regions[i]; struct memblock_region *next = &type->regions[i + 1]; - if (this->base + this->size != next->base) { + if (this->base + this->size != next->base || + memblock_get_region_node(this) != + memblock_get_region_node(next)) { BUG_ON(this->base + this->size > next->base); i++; continue; @@ -290,7 +289,7 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type) */ static void __init_memblock memblock_insert_region(struct memblock_type *type, int idx, phys_addr_t base, - phys_addr_t size) + phys_addr_t size, int nid) { struct memblock_region *rgn = &type->regions[idx]; @@ -298,6 +297,7 @@ static void __init_memblock memblock_insert_region(struct memblock_type *type, memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn)); rgn->base = base; rgn->size = size; + memblock_set_region_node(rgn, nid); type->cnt++; } @@ -327,6 +327,7 @@ static long __init_memblock memblock_add_region(struct memblock_type *type, WARN_ON(type->cnt != 1); type->regions[0].base = base; type->regions[0].size = size; + memblock_set_region_node(&type->regions[0], MAX_NUMNODES); return 0; } repeat: @@ -355,7 +356,7 @@ repeat: nr_new++; if (insert) memblock_insert_region(type, i++, base, - rbase - base); + rbase - base, MAX_NUMNODES); } /* area below @rend is dealt with, forget about it */ base = min(rend, end); @@ -365,7 +366,8 @@ repeat: if (base < end) { nr_new++; if (insert) - memblock_insert_region(type, i, base, end - base); + memblock_insert_region(type, i, base, end - base, + MAX_NUMNODES); } /* @@ -459,6 +461,101 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size) return memblock_add_region(_rgn, base, size); } +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP +/* + * Common iterator interface used to define for_each_mem_range(). + */ +void __init_memblock __next_mem_pfn_range(int *idx, int nid, + unsigned long *out_start_pfn, + unsigned long *out_end_pfn, int *out_nid) +{ + struct memblock_type *type = &memblock.memory; + struct memblock_region *r; + + while (++*idx < type->cnt) { + r = &type->regions[*idx]; + + if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size)) + continue; + if (nid == MAX_NUMNODES || nid == r->nid) + break; + } + if (*idx >= type->cnt) { + *idx = -1; + return; + } + + if (out_start_pfn) + *out_start_pfn = PFN_UP(r->base); + if (out_end_pfn) + *out_end_pfn = PFN_DOWN(r->base + r->size); + if (out_nid) + *out_nid = r->nid; +} + +/** + * memblock_set_node - set node ID on memblock regions + * @base: base of area to set node ID for + * @size: size of area to set node ID for + * @nid: node ID to set + * + * Set the nid of memblock memory regions in [@base,@base+@size) to @nid. + * Regions which cross the area boundaries are split as necessary. + * + * RETURNS: + * 0 on success, -errno on failure. + */ +int __init_memblock memblock_set_node(phys_addr_t base, phys_addr_t size, + int nid) +{ + struct memblock_type *type = &memblock.memory; + phys_addr_t end = base + size; + int i; + + /* we'll create at most two more regions */ + while (type->cnt + 2 > type->max) + if (memblock_double_array(type) < 0) + return -ENOMEM; + + for (i = 0; i < type->cnt; i++) { + struct memblock_region *rgn = &type->regions[i]; + phys_addr_t rbase = rgn->base; + phys_addr_t rend = rbase + rgn->size; + + if (rbase >= end) + break; + if (rend <= base) + continue; + + if (rbase < base) { + /* + * @rgn intersects from below. Split and continue + * to process the next region - the new top half. + */ + rgn->base = base; + rgn->size = rend - rgn->base; + memblock_insert_region(type, i, rbase, base - rbase, + rgn->nid); + } else if (rend > end) { + /* + * @rgn intersects from above. Split and redo the + * current region - the new bottom half. + */ + rgn->base = end; + rgn->size = rend - rgn->base; + memblock_insert_region(type, i--, rbase, end - rbase, + rgn->nid); + } else { + /* @rgn is fully contained, set ->nid */ + rgn->nid = nid; + } + } + + memblock_merge_regions(type); + return 0; +} +#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr) { phys_addr_t found; @@ -689,19 +786,26 @@ void __init_memblock memblock_set_current_limit(phys_addr_t limit) memblock.current_limit = limit; } -static void __init_memblock memblock_dump(struct memblock_type *region, char *name) +static void __init_memblock memblock_dump(struct memblock_type *type, char *name) { unsigned long long base, size; int i; - pr_info(" %s.cnt = 0x%lx\n", name, region->cnt); - - for (i = 0; i < region->cnt; i++) { - base = region->regions[i].base; - size = region->regions[i].size; + pr_info(" %s.cnt = 0x%lx\n", name, type->cnt); - pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes\n", - name, i, base, base + size - 1, size); + for (i = 0; i < type->cnt; i++) { + struct memblock_region *rgn = &type->regions[i]; + char nid_buf[32] = ""; + + base = rgn->base; + size = rgn->size; +#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP + if (memblock_get_region_node(rgn) != MAX_NUMNODES) + snprintf(nid_buf, sizeof(nid_buf), " on node %d", + memblock_get_region_node(rgn)); +#endif + pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes%s\n", + name, i, base, base + size - 1, size, nid_buf); } } @@ -759,11 +863,13 @@ void __init memblock_init(void) */ memblock.memory.regions[0].base = 0; memblock.memory.regions[0].size = 0; + memblock_set_region_node(&memblock.memory.regions[0], MAX_NUMNODES); memblock.memory.cnt = 1; /* Ditto. */ memblock.reserved.regions[0].base = 0; memblock.reserved.regions[0].size = 0; + memblock_set_region_node(&memblock.reserved.regions[0], MAX_NUMNODES); memblock.reserved.cnt = 1; memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8ab5e5e..3c7ea45 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -182,28 +182,31 @@ static unsigned long __meminitdata nr_all_pages; static unsigned long __meminitdata dma_reserve; #ifdef CONFIG_ARCH_POPULATES_NODE_MAP - /* - * MAX_ACTIVE_REGIONS determines the maximum number of distinct - * ranges of memory (RAM) that may be registered with add_active_range(). - * Ranges passed to add_active_range() will be merged if possible - * so the number of times add_active_range() can be called is - * related to the number of nodes and the number of holes - */ - #ifdef CONFIG_MAX_ACTIVE_REGIONS - /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */ - #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS - #else - #if MAX_NUMNODES >= 32 - /* If there can be many nodes, allow up to 50 holes per node */ - #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50) + #ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP + /* + * MAX_ACTIVE_REGIONS determines the maximum number of distinct ranges + * of memory (RAM) that may be registered with add_active_range(). + * Ranges passed to add_active_range() will be merged if possible so + * the number of times add_active_range() can be called is related to + * the number of nodes and the number of holes + */ + #ifdef CONFIG_MAX_ACTIVE_REGIONS + /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */ + #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS #else - /* By default, allow up to 256 distinct regions */ - #define MAX_ACTIVE_REGIONS 256 + #if MAX_NUMNODES >= 32 + /* If there can be many nodes, allow up to 50 holes per node */ + #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50) + #else + /* By default, allow up to 256 distinct regions */ + #define MAX_ACTIVE_REGIONS 256 + #endif #endif - #endif - static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS]; - static int __meminitdata nr_nodemap_entries; + static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS]; + static int __meminitdata nr_nodemap_entries; +#endif /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */ + static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES]; static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES]; static unsigned long __initdata required_kernelcore; @@ -4268,6 +4271,7 @@ static inline void setup_nr_node_ids(void) } #endif +#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP /* * Common iterator interface used to define for_each_mem_pfn_range(). */ @@ -4456,6 +4460,11 @@ void __init sort_node_map(void) sizeof(struct node_active_region), cmp_node_active_region, NULL); } +#else /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */ +static inline void sort_node_map(void) +{ +} +#endif /** * node_map_pfn_alignment - determine the maximum internode alignment -- cgit v0.10.2 From 0608f70c78a384c2f225f2de226ca057a196f108 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:44:23 +0200 Subject: x86: Use HAVE_MEMBLOCK_NODE_MAP From 5732e1247898d67cbf837585150fe9f68974671d Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:22:16 +0200 Convert x86 to HAVE_MEMBLOCK_NODE_MAP. The only difference in memory handling is that allocations can't no longer cross node boundaries whether they're node affine or not, which shouldn't matter at all. This conversion will enable further simplification of boot memory handling. -v2: Fix build failure on !NUMA configurations discovered by hpa. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/20110714094423.GG3455@htj.dyndns.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index da34972..97f0894 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -25,6 +25,7 @@ config X86 select HAVE_IOREMAP_PROT select HAVE_KPROBES select HAVE_MEMBLOCK + select HAVE_MEMBLOCK_NODE_MAP select ARCH_WANT_OPTIONAL_GPIOLIB select ARCH_WANT_FRAME_POINTERS select HAVE_DMA_ATTRS diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index 161792e..1460db2 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -12,8 +12,6 @@ int __get_free_all_memory_range(struct range **range, int nodeid, unsigned long start_pfn, unsigned long end_pfn); int get_free_all_memory_range(struct range **rangep, int nodeid); -void memblock_x86_register_active_regions(int nid, unsigned long start_pfn, - unsigned long last_pfn); u64 memblock_x86_hole_size(u64 start, u64 end); u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); u64 memblock_x86_memory_in_range(u64 addr, u64 limit); diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 29f7c6d9..5d173db 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -650,18 +650,18 @@ void __init initmem_init(void) highstart_pfn = highend_pfn = max_pfn; if (max_pfn > max_low_pfn) highstart_pfn = max_low_pfn; - memblock_x86_register_active_regions(0, 0, highend_pfn); - sparse_memory_present_with_active_regions(0); printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", pages_to_mb(highend_pfn - highstart_pfn)); num_physpages = highend_pfn; high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1; #else - memblock_x86_register_active_regions(0, 0, max_low_pfn); - sparse_memory_present_with_active_regions(0); num_physpages = max_low_pfn; high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; #endif + + memblock_set_node(0, (phys_addr_t)ULLONG_MAX, 0); + sparse_memory_present_with_active_regions(0); + #ifdef CONFIG_FLATMEM max_mapnr = num_physpages; #endif diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index d865c4a..7fb064c 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -607,7 +607,7 @@ kernel_physical_mapping_init(unsigned long start, #ifndef CONFIG_NUMA void __init initmem_init(void) { - memblock_x86_register_active_regions(0, 0, max_pfn); + memblock_set_node(0, (phys_addr_t)ULLONG_MAX, 0); } #endif diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index e4569f8..97fbc39 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -283,20 +283,6 @@ static int __init memblock_x86_find_active_region(const struct memblock_region * return 1; } -/* Walk the memblock.memory map and register active regions within a node */ -void __init memblock_x86_register_active_regions(int nid, unsigned long start_pfn, - unsigned long last_pfn) -{ - unsigned long ei_startpfn; - unsigned long ei_endpfn; - struct memblock_region *r; - - for_each_memblock(memory, r) - if (memblock_x86_find_active_region(r, start_pfn, last_pfn, - &ei_startpfn, &ei_endpfn)) - add_active_range(nid, ei_startpfn, ei_endpfn); -} - /* * Find the hole size (in bytes) in the memory range. * @start: starting address of the memory range to scan diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 824efad..f4a40bd 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -498,13 +498,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) if (WARN_ON(nodes_empty(node_possible_map))) return -EINVAL; - for (i = 0; i < mi->nr_blks; i++) - memblock_x86_register_active_regions(mi->blk[i].nid, - mi->blk[i].start >> PAGE_SHIFT, - mi->blk[i].end >> PAGE_SHIFT); - - /* for out of order entries */ - sort_node_map(); + for (i = 0; i < mi->nr_blks; i++) { + struct numa_memblk *mb = &mi->blk[i]; + memblock_set_node(mb->start, mb->end - mb->start, mb->nid); + } /* * If sections array is gonna be used for pfn -> nid mapping, check @@ -538,6 +535,8 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) setup_node_data(nid, start, end); } + /* Dump memblock with node info and return. */ + memblock_dump_all(); return 0; } @@ -575,7 +574,7 @@ static int __init numa_init(int (*init_func)(void)) nodes_clear(node_possible_map); nodes_clear(node_online_map); memset(&numa_meminfo, 0, sizeof(numa_meminfo)); - remove_all_active_ranges(); + WARN_ON(memblock_set_node(0, ULLONG_MAX, MAX_NUMNODES)); numa_reset_distance(); ret = init_func(); -- cgit v0.10.2 From ab5d140b9eafae402aa3e673a63c5ef6164a9dd2 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:15:58 +0200 Subject: x86: Use __memblock_alloc_base() in early_reserve_e820() early_reserve_e820() implements its own ad-hoc early allocator using memblock_x86_find_in_range_size(). Use __memblock_alloc_base() instead and remove the unnecessary @startt parameter (it's top-down allocation anyway). Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-6-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h index 908b969..3778256 100644 --- a/arch/x86/include/asm/e820.h +++ b/arch/x86/include/asm/e820.h @@ -117,7 +117,7 @@ static inline void early_memtest(unsigned long start, unsigned long end) extern unsigned long e820_end_of_ram_pfn(void); extern unsigned long e820_end_of_low_ram_pfn(void); -extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); +extern u64 early_reserve_e820(u64 sizet, u64 align); void memblock_x86_fill(void); void memblock_find_dma_reserve(void); diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 0f9ff58..b99d940 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -737,35 +737,17 @@ core_initcall(e820_mark_nvs_memory); /* * pre allocated 4k and reserved it in memblock and e820_saved */ -u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) +u64 __init early_reserve_e820(u64 size, u64 align) { - u64 size = 0; u64 addr; - u64 start; - for (start = startt; ; start += size) { - start = memblock_x86_find_in_range_size(start, &size, align); - if (!start) - return 0; - if (size >= sizet) - break; + addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); + if (addr) { + e820_update_range_saved(addr, size, E820_RAM, E820_RESERVED); + printk(KERN_INFO "update e820_saved for early_reserve_e820\n"); + update_e820_saved(); } -#ifdef CONFIG_X86_32 - if (start >= MAXMEM) - return 0; - if (start + size > MAXMEM) - size = MAXMEM - start; -#endif - - addr = round_down(start + size - sizet, align); - if (addr < start) - return 0; - memblock_x86_reserve_range(addr, addr + sizet, "new next"); - e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED); - printk(KERN_INFO "update e820_saved for early_reserve_e820\n"); - update_e820_saved(); - return addr; } diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 9103b89..8faeaa0 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c @@ -836,10 +836,8 @@ early_param("alloc_mptable", parse_alloc_mptable_opt); void __init early_reserve_e820_mpc_new(void) { - if (enable_update_mptable && alloc_mptable) { - u64 startt = 0; - mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4); - } + if (enable_update_mptable && alloc_mptable) + mpc_new_phys = early_reserve_e820(mpc_new_length, 4); } static int __init update_mp_table(void) -- cgit v0.10.2 From 35fd0808d7d8d001cd72f112e3bca84664b596a3 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:15:59 +0200 Subject: memblock: Implement for_each_free_mem_range() Implement for_each_free_mem_range() which iterates over free memory areas according to memblock (memory && !reserved). This will be used to simplify memblock users. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-7-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Signed-off-by: H. Peter Anvin diff --git a/include/linux/memblock.h b/include/linux/memblock.h index c36a55d..31def58 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -61,6 +61,26 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size); extern long memblock_free(phys_addr_t base, phys_addr_t size); extern long memblock_reserve(phys_addr_t base, phys_addr_t size); +extern void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start, + phys_addr_t *out_end, int *out_nid); + +/** + * for_each_free_mem_range - iterate through free memblock areas + * @i: u64 used as loop variable + * @nid: node selector, %MAX_NUMNODES for all nodes + * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL + * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL + * @p_nid: ptr to int for nid of the range, can be %NULL + * + * Walks over free (memory && !reserved) areas of memblock. Available as + * soon as memblock is initialized. + */ +#define for_each_free_mem_range(i, nid, p_start, p_end, p_nid) \ + for (i = 0, \ + __next_free_mem_range(&i, nid, p_start, p_end, p_nid); \ + i != (u64)ULLONG_MAX; \ + __next_free_mem_range(&i, nid, p_start, p_end, p_nid)) + #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid); diff --git a/mm/memblock.c b/mm/memblock.c index e815f4b..c4a8750 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -461,6 +461,82 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size) return memblock_add_region(_rgn, base, size); } +/** + * __next_free_mem_range - next function for for_each_free_mem_range() + * @idx: pointer to u64 loop variable + * @nid: nid: node selector, %MAX_NUMNODES for all nodes + * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL + * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL + * @p_nid: ptr to int for nid of the range, can be %NULL + * + * Find the first free area from *@idx which matches @nid, fill the out + * parameters, and update *@idx for the next iteration. The lower 32bit of + * *@idx contains index into memory region and the upper 32bit indexes the + * areas before each reserved region. For example, if reserved regions + * look like the following, + * + * 0:[0-16), 1:[32-48), 2:[128-130) + * + * The upper 32bit indexes the following regions. + * + * 0:[0-0), 1:[16-32), 2:[48-128), 3:[130-MAX) + * + * As both region arrays are sorted, the function advances the two indices + * in lockstep and returns each intersection. + */ +void __init_memblock __next_free_mem_range(u64 *idx, int nid, + phys_addr_t *out_start, + phys_addr_t *out_end, int *out_nid) +{ + struct memblock_type *mem = &memblock.memory; + struct memblock_type *rsv = &memblock.reserved; + int mi = *idx & 0xffffffff; + int ri = *idx >> 32; + + for ( ; mi < mem->cnt; mi++) { + struct memblock_region *m = &mem->regions[mi]; + phys_addr_t m_start = m->base; + phys_addr_t m_end = m->base + m->size; + + /* only memory regions are associated with nodes, check it */ + if (nid != MAX_NUMNODES && nid != memblock_get_region_node(m)) + continue; + + /* scan areas before each reservation for intersection */ + for ( ; ri < rsv->cnt + 1; ri++) { + struct memblock_region *r = &rsv->regions[ri]; + phys_addr_t r_start = ri ? r[-1].base + r[-1].size : 0; + phys_addr_t r_end = ri < rsv->cnt ? r->base : ULLONG_MAX; + + /* if ri advanced past mi, break out to advance mi */ + if (r_start >= m_end) + break; + /* if the two regions intersect, we're done */ + if (m_start < r_end) { + if (out_start) + *out_start = max(m_start, r_start); + if (out_end) + *out_end = min(m_end, r_end); + if (out_nid) + *out_nid = memblock_get_region_node(m); + /* + * The region which ends first is advanced + * for the next iteration. + */ + if (m_end <= r_end) + mi++; + else + ri++; + *idx = (u32)mi | (u64)ri << 32; + return; + } + } + } + + /* signal end of iteration */ + *idx = ULLONG_MAX; +} + #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP /* * Common iterator interface used to define for_each_mem_range(). -- cgit v0.10.2 From 8d89ac808417e92a33fb5fa3c86352016643775a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:16:00 +0200 Subject: x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range() setup_bios_corruption_check() and memtest do_one_pass() open code memblock free area iteration using memblock_x86_find_in_range_size(). Convert them to use for_each_free_mem_range() instead. This leaves memblock_x86_find_in_range_size() and memblock_x86_check_reserved_size() unused. Kill them. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-8-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index 1460db2..d2a5a59 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -3,8 +3,6 @@ #define ARCH_DISCARD_MEMBLOCK -u64 memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align); - void memblock_x86_reserve_range(u64 start, u64 end, char *name); void memblock_x86_free_range(u64 start, u64 end); struct range; @@ -15,6 +13,5 @@ int get_free_all_memory_range(struct range **rangep, int nodeid); u64 memblock_x86_hole_size(u64 start, u64 end); u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); u64 memblock_x86_memory_in_range(u64 addr, u64 limit); -bool memblock_x86_check_reserved_size(u64 *addrp, u64 *sizep, u64 align); #endif diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c index 95680fc..621cd23 100644 --- a/arch/x86/kernel/check.c +++ b/arch/x86/kernel/check.c @@ -62,7 +62,8 @@ early_param("memory_corruption_check_size", set_corruption_check_size); void __init setup_bios_corruption_check(void) { - u64 addr = PAGE_SIZE; /* assume first page is reserved anyway */ + phys_addr_t start, end; + u64 i; if (memory_corruption_check == -1) { memory_corruption_check = @@ -82,28 +83,23 @@ void __init setup_bios_corruption_check(void) corruption_check_size = round_up(corruption_check_size, PAGE_SIZE); - while (addr < corruption_check_size && num_scan_areas < MAX_SCAN_AREAS) { - u64 size; - addr = memblock_x86_find_in_range_size(addr, &size, PAGE_SIZE); + for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) { + start = clamp_t(phys_addr_t, round_up(start, PAGE_SIZE), + PAGE_SIZE, corruption_check_size); + end = clamp_t(phys_addr_t, round_down(end, PAGE_SIZE), + PAGE_SIZE, corruption_check_size); + if (start >= end) + continue; - if (!addr) - break; - - if (addr >= corruption_check_size) - break; - - if ((addr + size) > corruption_check_size) - size = corruption_check_size - addr; - - memblock_x86_reserve_range(addr, addr + size, "SCAN RAM"); - scan_areas[num_scan_areas].addr = addr; - scan_areas[num_scan_areas].size = size; - num_scan_areas++; + memblock_x86_reserve_range(start, end, "SCAN RAM"); + scan_areas[num_scan_areas].addr = start; + scan_areas[num_scan_areas].size = end - start; /* Assume we've already mapped this early memory */ - memset(__va(addr), 0, size); + memset(__va(start), 0, end - start); - addr += size; + if (++num_scan_areas >= MAX_SCAN_AREAS) + break; } if (num_scan_areas) diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 97fbc39..648d47d 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -7,68 +7,6 @@ #include #include -/* Check for already reserved areas */ -bool __init memblock_x86_check_reserved_size(u64 *addrp, u64 *sizep, u64 align) -{ - struct memblock_region *r; - u64 addr = *addrp, last; - u64 size = *sizep; - bool changed = false; - -again: - last = addr + size; - for_each_memblock(reserved, r) { - if (last > r->base && addr < r->base) { - size = r->base - addr; - changed = true; - goto again; - } - if (last > (r->base + r->size) && addr < (r->base + r->size)) { - addr = round_up(r->base + r->size, align); - size = last - addr; - changed = true; - goto again; - } - if (last <= (r->base + r->size) && addr >= r->base) { - *sizep = 0; - return false; - } - } - if (changed) { - *addrp = addr; - *sizep = size; - } - return changed; -} - -/* - * Find next free range after start, and size is returned in *sizep - */ -u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align) -{ - struct memblock_region *r; - - for_each_memblock(memory, r) { - u64 ei_start = r->base; - u64 ei_last = ei_start + r->size; - u64 addr; - - addr = round_up(ei_start, align); - if (addr < start) - addr = round_up(start, align); - if (addr >= ei_last) - continue; - *sizep = ei_last - addr; - while (memblock_x86_check_reserved_size(&addr, sizep, align)) - ; - - if (*sizep) - return addr; - } - - return 0; -} - static __init struct range *find_range_array(int count) { u64 end, size, mem; diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c index 92faf3a..46a5ff2 100644 --- a/arch/x86/mm/memtest.c +++ b/arch/x86/mm/memtest.c @@ -70,24 +70,19 @@ static void __init memtest(u64 pattern, u64 start_phys, u64 size) static void __init do_one_pass(u64 pattern, u64 start, u64 end) { - u64 size = 0; - - while (start < end) { - start = memblock_x86_find_in_range_size(start, &size, 1); - - /* done ? */ - if (start >= end) - break; - if (start + size > end) - size = end - start; - - printk(KERN_INFO " %010llx - %010llx pattern %016llx\n", - (unsigned long long) start, - (unsigned long long) start + size, - (unsigned long long) cpu_to_be64(pattern)); - memtest(pattern, start, size); - - start += size; + u64 i; + phys_addr_t this_start, this_end; + + for_each_free_mem_range(i, MAX_NUMNODES, &this_start, &this_end, NULL) { + this_start = clamp_t(phys_addr_t, this_start, start, end); + this_end = clamp_t(phys_addr_t, this_end, start, end); + if (this_start < this_end) { + printk(KERN_INFO " %010llx - %010llx pattern %016llx\n", + (unsigned long long)this_start, + (unsigned long long)this_end, + (unsigned long long)cpu_to_be64(pattern)); + memtest(pattern, this_start, this_end - this_start); + } } } -- cgit v0.10.2 From 64a02daacbc880bac1d6b3aeefbcd226a9341fa7 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:16:01 +0200 Subject: memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only nomemblock is currently used only by x86 and on x86_32 free_all_memory_core_early() silently freed only the low mem because get_free_all_memory_range() in arch/x86/mm/memblock.c implicitly limited range to max_low_pfn. Rename free_all_memory_core_early() to free_low_memory_core_early() and make it call __get_free_all_memory_range() and limit the range to max_low_pfn explicitly. This makes things clearer and also is consistent with the bootmem behavior. This leaves get_free_all_memory_range() without any user. Kill it. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-9-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index d2a5a59..6c72eca 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -8,7 +8,6 @@ void memblock_x86_free_range(u64 start, u64 end); struct range; int __get_free_all_memory_range(struct range **range, int nodeid, unsigned long start_pfn, unsigned long end_pfn); -int get_free_all_memory_range(struct range **rangep, int nodeid); u64 memblock_x86_hole_size(u64 start, u64 end); u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 648d47d..0e8442a 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -89,16 +89,6 @@ int __init __get_free_all_memory_range(struct range **rangep, int nodeid, return nr_range; } -int __init get_free_all_memory_range(struct range **rangep, int nodeid) -{ - unsigned long end_pfn = -1UL; - -#ifdef CONFIG_X86_32 - end_pfn = max_low_pfn; -#endif - return __get_free_all_memory_range(rangep, nodeid, 0, end_pfn); -} - static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free) { int i, count; diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index dd27f40..92e2711 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c @@ -19,7 +19,7 @@ unsigned long __init numa_free_all_bootmem(void) for_each_online_node(i) pages += free_all_bootmem_node(NODE_DATA(i)); - pages += free_all_memory_core_early(MAX_NUMNODES); + pages += free_low_memory_core_early(MAX_NUMNODES); return pages; } diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index ab344a5..66d3e95 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h @@ -44,7 +44,7 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat, unsigned long endpfn); extern unsigned long init_bootmem(unsigned long addr, unsigned long memend); -unsigned long free_all_memory_core_early(int nodeid); +extern unsigned long free_low_memory_core_early(int nodeid); extern unsigned long free_all_bootmem_node(pg_data_t *pgdat); extern unsigned long free_all_bootmem(void); diff --git a/mm/nobootmem.c b/mm/nobootmem.c index c781626..2037a8a 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c @@ -106,7 +106,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end) __free_pages_bootmem(pfn_to_page(i), 0); } -unsigned long __init free_all_memory_core_early(int nodeid) +unsigned long __init free_low_memory_core_early(int nodeid) { int i; u64 start, end; @@ -114,7 +114,7 @@ unsigned long __init free_all_memory_core_early(int nodeid) struct range *range = NULL; int nr_range; - nr_range = get_free_all_memory_range(&range, nodeid); + nr_range = __get_free_all_memory_range(&range, nodeid, 0, max_low_pfn); for (i = 0; i < nr_range; i++) { start = range[i].start; @@ -136,7 +136,7 @@ unsigned long __init free_all_bootmem_node(pg_data_t *pgdat) { register_page_bootmem_info_node(pgdat); - /* free_all_memory_core_early(MAX_NUMNODES) will be called later */ + /* free_low_memory_core_early(MAX_NUMNODES) will be called later */ return 0; } @@ -154,7 +154,7 @@ unsigned long __init free_all_bootmem(void) * Use MAX_NUMNODES will make sure all ranges in early_node_map[] * will be used instead of only Node0 related */ - return free_all_memory_core_early(MAX_NUMNODES); + return free_low_memory_core_early(MAX_NUMNODES); } /** -- cgit v0.10.2 From 8a9ca34c11e1695dab7aff3cfa7780fbfe76b2f8 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:16:02 +0200 Subject: memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range() __get_free_all_memory_range() walks memblock, calculates free memory areas and fills in the specified range. It can be easily replaced with for_each_free_mem_range(). Convert free_low_memory_core_early() and add_highpages_with_active_regions() to for_each_free_mem_range(). This leaves __get_free_all_memory_range() without any user. Kill it and related functions. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-10-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index 6c72eca..bc9e44b 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -5,9 +5,6 @@ void memblock_x86_reserve_range(u64 start, u64 end, char *name); void memblock_x86_free_range(u64 start, u64 end); -struct range; -int __get_free_all_memory_range(struct range **range, int nodeid, - unsigned long start_pfn, unsigned long end_pfn); u64 memblock_x86_hole_size(u64 start, u64 end); u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 5d173db..0c1da39 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -427,23 +427,17 @@ static void __init add_one_highpage_init(struct page *page) void __init add_highpages_with_active_regions(int nid, unsigned long start_pfn, unsigned long end_pfn) { - struct range *range; - int nr_range; - int i; - - nr_range = __get_free_all_memory_range(&range, nid, start_pfn, end_pfn); - - for (i = 0; i < nr_range; i++) { - struct page *page; - int node_pfn; - - for (node_pfn = range[i].start; node_pfn < range[i].end; - node_pfn++) { - if (!pfn_valid(node_pfn)) - continue; - page = pfn_to_page(node_pfn); - add_one_highpage_init(page); - } + phys_addr_t start, end; + u64 i; + + for_each_free_mem_range(i, nid, &start, &end, NULL) { + unsigned long pfn = clamp_t(unsigned long, PFN_UP(start), + start_pfn, end_pfn); + unsigned long e_pfn = clamp_t(unsigned long, PFN_DOWN(end), + start_pfn, end_pfn); + for ( ; pfn < e_pfn; pfn++) + if (pfn_valid(pfn)) + add_one_highpage_init(pfn_to_page(pfn)); } } #else diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 0e8442a..4107c1a 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -30,65 +30,6 @@ static __init struct range *find_range_array(int count) return range; } -static void __init memblock_x86_subtract_reserved(struct range *range, int az) -{ - u64 final_start, final_end; - struct memblock_region *r; - - /* Take out region array itself at first*/ - memblock_free_reserved_regions(); - - memblock_dbg("Subtract (%ld early reservations)\n", memblock.reserved.cnt); - - for_each_memblock(reserved, r) { - memblock_dbg(" [%010llx-%010llx]\n", (u64)r->base, (u64)r->base + r->size - 1); - final_start = PFN_DOWN(r->base); - final_end = PFN_UP(r->base + r->size); - if (final_start >= final_end) - continue; - subtract_range(range, az, final_start, final_end); - } - - /* Put region array back ? */ - memblock_reserve_reserved_regions(); -} - -static int __init count_early_node_map(int nodeid) -{ - int i, cnt = 0; - - for_each_mem_pfn_range(i, nodeid, NULL, NULL, NULL) - cnt++; - return cnt; -} - -int __init __get_free_all_memory_range(struct range **rangep, int nodeid, - unsigned long start_pfn, unsigned long end_pfn) -{ - int count; - struct range *range; - int nr_range; - - count = (memblock.reserved.cnt + count_early_node_map(nodeid)) * 2; - - range = find_range_array(count); - nr_range = 0; - - /* - * Use early_node_map[] and memblock.reserved.region to get range array - * at first - */ - nr_range = add_from_early_node_map(range, count, nr_range, nodeid); - subtract_range(range, count, 0, start_pfn); - subtract_range(range, count, end_pfn, -1ULL); - - memblock_x86_subtract_reserved(range, count); - nr_range = clean_sort_range(range, count); - - *rangep = range; - return nr_range; -} - static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free) { int i, count; diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 2037a8a..7075bc0 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c @@ -108,21 +108,25 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end) unsigned long __init free_low_memory_core_early(int nodeid) { - int i; - u64 start, end; unsigned long count = 0; - struct range *range = NULL; - int nr_range; - - nr_range = __get_free_all_memory_range(&range, nodeid, 0, max_low_pfn); - - for (i = 0; i < nr_range; i++) { - start = range[i].start; - end = range[i].end; - count += end - start; - __free_pages_memory(start, end); + phys_addr_t start, end; + u64 i; + + /* free reserved array temporarily so that it's treated as free area */ + memblock_free_reserved_regions(); + + for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) { + unsigned long start_pfn = PFN_UP(start); + unsigned long end_pfn = min_t(unsigned long, + PFN_DOWN(end), max_low_pfn); + if (start_pfn < end_pfn) { + __free_pages_memory(start_pfn, end_pfn); + count += end_pfn - start_pfn; + } } + /* put region array back? */ + memblock_reserve_reserved_regions(); return count; } -- cgit v0.10.2 From 6b5d41a1b97f5529284f16170211b87fd60264c0 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:16:03 +0200 Subject: memblock, x86: Reimplement memblock_find_dma_reserve() using iterators memblock_find_dma_reserve() wants to find out how much memory is reserved under MAX_DMA_PFN. memblock_x86_memory_[free_]in_range() are used to find out the amounts of all available and free memory in the area, which are then subtracted to find out the amount of reservation. memblock_x86_memblock_[free_]in_range() are implemented using __memblock_x86_memory_in_range() which builds ranges from memblock and then count them, which is rather unnecessarily complex. This patch open codes the counting logic directly in memblock_find_dma_reserve() using memblock iterators and removes now unused __memblock_x86_memory_in_range() and find_range_array(). Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-11-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index bc9e44b..a0cc7d6 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -7,7 +7,5 @@ void memblock_x86_reserve_range(u64 start, u64 end, char *name); void memblock_x86_free_range(u64 start, u64 end); u64 memblock_x86_hole_size(u64 start, u64 end); -u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit); -u64 memblock_x86_memory_in_range(u64 addr, u64 limit); #endif diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index b99d940..84475f1 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1093,15 +1093,30 @@ void __init memblock_x86_fill(void) void __init memblock_find_dma_reserve(void) { #ifdef CONFIG_X86_64 - u64 free_size_pfn; - u64 mem_size_pfn; + u64 nr_pages = 0, nr_free_pages = 0; + unsigned long start_pfn, end_pfn; + phys_addr_t start, end; + int i; + u64 u; + /* * need to find out used area below MAX_DMA_PFN * need to use memblock to get free size in [0, MAX_DMA_PFN] * at first, and assume boot_mem will not take below MAX_DMA_PFN */ - mem_size_pfn = memblock_x86_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT; - free_size_pfn = memblock_x86_free_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT; - set_dma_reserve(mem_size_pfn - free_size_pfn); + for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) { + start_pfn = min_t(unsigned long, start_pfn, MAX_DMA_PFN); + end_pfn = min_t(unsigned long, end_pfn, MAX_DMA_PFN); + nr_pages += end_pfn - start_pfn; + } + + for_each_free_mem_range(u, MAX_NUMNODES, &start, &end, NULL) { + start_pfn = min_t(unsigned long, PFN_UP(start), MAX_DMA_PFN); + end_pfn = min_t(unsigned long, PFN_DOWN(end), MAX_DMA_PFN); + if (start_pfn < end_pfn) + nr_free_pages += end_pfn - start_pfn; + } + + set_dma_reserve(nr_pages - nr_free_pages); #endif } diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 4107c1a..a9d0972 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -7,93 +7,6 @@ #include #include -static __init struct range *find_range_array(int count) -{ - u64 end, size, mem; - struct range *range; - - size = sizeof(struct range) * count; - end = memblock.current_limit; - - mem = memblock_find_in_range(0, end, size, sizeof(struct range)); - if (!mem) - panic("can not find more space for range array"); - - /* - * This range is tempoaray, so don't reserve it, it will not be - * overlapped because We will not alloccate new buffer before - * We discard this one - */ - range = __va(mem); - memset(range, 0, size); - - return range; -} - -static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free) -{ - int i, count; - struct range *range; - int nr_range; - u64 final_start, final_end; - u64 free_size; - struct memblock_region *r; - - count = (memblock.reserved.cnt + memblock.memory.cnt) * 2; - - range = find_range_array(count); - nr_range = 0; - - addr = PFN_UP(addr); - limit = PFN_DOWN(limit); - - for_each_memblock(memory, r) { - final_start = PFN_UP(r->base); - final_end = PFN_DOWN(r->base + r->size); - if (final_start >= final_end) - continue; - if (final_start >= limit || final_end <= addr) - continue; - - nr_range = add_range(range, count, nr_range, final_start, final_end); - } - subtract_range(range, count, 0, addr); - subtract_range(range, count, limit, -1ULL); - - /* Subtract memblock.reserved.region in range ? */ - if (!get_free) - goto sort_and_count_them; - for_each_memblock(reserved, r) { - final_start = PFN_DOWN(r->base); - final_end = PFN_UP(r->base + r->size); - if (final_start >= final_end) - continue; - if (final_start >= limit || final_end <= addr) - continue; - - subtract_range(range, count, final_start, final_end); - } - -sort_and_count_them: - nr_range = clean_sort_range(range, count); - - free_size = 0; - for (i = 0; i < nr_range; i++) - free_size += range[i].end - range[i].start; - - return free_size << PAGE_SHIFT; -} - -u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) -{ - return __memblock_x86_memory_in_range(addr, limit, true); -} - -u64 __init memblock_x86_memory_in_range(u64 addr, u64 limit) -{ - return __memblock_x86_memory_in_range(addr, limit, false); -} - void __init memblock_x86_reserve_range(u64 start, u64 end, char *name) { if (start == end) -- cgit v0.10.2 From 474b881bf4ee86aba55d46a4fdf293de32cba91b Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:16:04 +0200 Subject: x86: Use absent_pages_in_range() instead of memblock_x86_hole_size() memblock_x86_hole_size() calculates the total size of holes in a given range according to memblock and is used by numa emulation code and numa_meminfo_cover_memory(). Since conversion to MEMBLOCK_NODE_MAP, absent_pages_in_range() also uses memblock and gives the same result. This patch replaces memblock_x86_hole_size() uses with absent_pages_in_range(). After the conversion the x86 function doesn't have any user left and is killed. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-12-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index a0cc7d6..17a882e 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -6,6 +6,4 @@ void memblock_x86_reserve_range(u64 start, u64 end, char *name); void memblock_x86_free_range(u64 start, u64 end); -u64 memblock_x86_hole_size(u64 start, u64 end); - #endif diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index a9d0972..7325c5d 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c @@ -32,55 +32,3 @@ void __init memblock_x86_free_range(u64 start, u64 end) memblock_free(start, end - start); } - -/* - * Finds an active region in the address range from start_pfn to last_pfn and - * returns its range in ei_startpfn and ei_endpfn for the memblock entry. - */ -static int __init memblock_x86_find_active_region(const struct memblock_region *ei, - unsigned long start_pfn, - unsigned long last_pfn, - unsigned long *ei_startpfn, - unsigned long *ei_endpfn) -{ - u64 align = PAGE_SIZE; - - *ei_startpfn = round_up(ei->base, align) >> PAGE_SHIFT; - *ei_endpfn = round_down(ei->base + ei->size, align) >> PAGE_SHIFT; - - /* Skip map entries smaller than a page */ - if (*ei_startpfn >= *ei_endpfn) - return 0; - - /* Skip if map is outside the node */ - if (*ei_endpfn <= start_pfn || *ei_startpfn >= last_pfn) - return 0; - - /* Check for overlaps */ - if (*ei_startpfn < start_pfn) - *ei_startpfn = start_pfn; - if (*ei_endpfn > last_pfn) - *ei_endpfn = last_pfn; - - return 1; -} - -/* - * Find the hole size (in bytes) in the memory range. - * @start: starting address of the memory range to scan - * @end: ending address of the memory range to scan - */ -u64 __init memblock_x86_hole_size(u64 start, u64 end) -{ - unsigned long start_pfn = start >> PAGE_SHIFT; - unsigned long last_pfn = end >> PAGE_SHIFT; - unsigned long ei_startpfn, ei_endpfn, ram = 0; - struct memblock_region *r; - - for_each_memblock(memory, r) - if (memblock_x86_find_active_region(r, start_pfn, last_pfn, - &ei_startpfn, &ei_endpfn)) - ram += ei_endpfn - ei_startpfn; - - return end - start - ((u64)ram << PAGE_SHIFT); -} diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index f4a40bd..88e5627 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -475,8 +475,8 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi) numaram = 0; } - e820ram = max_pfn - (memblock_x86_hole_size(0, - PFN_PHYS(max_pfn)) >> PAGE_SHIFT); + e820ram = max_pfn - absent_pages_in_range(0, max_pfn); + /* We seem to lose 3 pages somewhere. Allow 1M of slack. */ if ((s64)(e820ram - numaram) >= (1 << (20 - PAGE_SHIFT))) { printk(KERN_ERR "NUMA: nodes only cover %LuMB of your %LuMB e820 RAM. Not used.\n", diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index e3d471c..971fe70 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -28,6 +28,16 @@ static int __init emu_find_memblk_by_nid(int nid, const struct numa_meminfo *mi) return -ENOENT; } +static u64 mem_hole_size(u64 start, u64 end) +{ + unsigned long start_pfn = PFN_UP(start); + unsigned long end_pfn = PFN_DOWN(end); + + if (start_pfn < end_pfn) + return PFN_PHYS(absent_pages_in_range(start_pfn, end_pfn)); + return 0; +} + /* * Sets up nid to range from @start to @end. The return value is -errno if * something went wrong, 0 otherwise. @@ -89,7 +99,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei, * Calculate target node size. x86_32 freaks on __udivdi3() so do * the division in ulong number of pages and convert back. */ - size = max_addr - addr - memblock_x86_hole_size(addr, max_addr); + size = max_addr - addr - mem_hole_size(addr, max_addr); size = PFN_PHYS((unsigned long)(size >> PAGE_SHIFT) / nr_nodes); /* @@ -135,8 +145,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei, * Continue to add memory to this fake node if its * non-reserved memory is less than the per-node size. */ - while (end - start - - memblock_x86_hole_size(start, end) < size) { + while (end - start - mem_hole_size(start, end) < size) { end += FAKE_NODE_MIN_SIZE; if (end > limit) { end = limit; @@ -150,7 +159,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei, * this one must extend to the boundary. */ if (end < dma32_end && dma32_end - end - - memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE) + mem_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE) end = dma32_end; /* @@ -158,8 +167,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei, * next node, this one must extend to the end of the * physical node. */ - if (limit - end - - memblock_x86_hole_size(end, limit) < size) + if (limit - end - mem_hole_size(end, limit) < size) end = limit; ret = emu_setup_memblk(ei, pi, nid++ % nr_nodes, @@ -180,7 +188,7 @@ static u64 __init find_end_of_node(u64 start, u64 max_addr, u64 size) { u64 end = start + size; - while (end - start - memblock_x86_hole_size(start, end) < size) { + while (end - start - mem_hole_size(start, end) < size) { end += FAKE_NODE_MIN_SIZE; if (end > max_addr) { end = max_addr; @@ -211,8 +219,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei, * creates a uniform distribution of node sizes across the entire * machine (but not necessarily over physical nodes). */ - min_size = (max_addr - addr - memblock_x86_hole_size(addr, max_addr)) / - MAX_NUMNODES; + min_size = (max_addr - addr - mem_hole_size(addr, max_addr)) / MAX_NUMNODES; min_size = max(min_size, FAKE_NODE_MIN_SIZE); if ((min_size & FAKE_NODE_MIN_HASH_MASK) < min_size) min_size = (min_size + FAKE_NODE_MIN_SIZE) & @@ -252,7 +259,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei, * this one must extend to the boundary. */ if (end < dma32_end && dma32_end - end - - memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE) + mem_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE) end = dma32_end; /* @@ -260,8 +267,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei, * next node, this one must extend to the end of the * physical node. */ - if (limit - end - - memblock_x86_hole_size(end, limit) < size) + if (limit - end - mem_hole_size(end, limit) < size) end = limit; ret = emu_setup_memblk(ei, pi, nid++ % MAX_NUMNODES, -- cgit v0.10.2 From c378ddd53f9b8832a46fd4fec050a97fc2269858 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:46:03 +0200 Subject: memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option From 6839454ae63f1eb21e515c10229ca95c22955fec Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jul 2011 11:22:17 +0200 Make ARCH_DISCARD_MEMBLOCK a config option so that it can be handled together with other MEMBLOCK options. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/20110714094603.GH3455@htj.dyndns.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 97f0894..28116d4 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -26,6 +26,7 @@ config X86 select HAVE_KPROBES select HAVE_MEMBLOCK select HAVE_MEMBLOCK_NODE_MAP + select ARCH_DISCARD_MEMBLOCK select ARCH_WANT_OPTIONAL_GPIOLIB select ARCH_WANT_FRAME_POINTERS select HAVE_DMA_ATTRS diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index 17a882e..bc56670 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h @@ -1,8 +1,6 @@ #ifndef _X86_MEMBLOCK_H #define _X86_MEMBLOCK_H -#define ARCH_DISCARD_MEMBLOCK - void memblock_x86_reserve_range(u64 start, u64 end, char *name); void memblock_x86_free_range(u64 start, u64 end); diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 31def58..2491355 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -197,7 +197,7 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo region++) -#ifdef ARCH_DISCARD_MEMBLOCK +#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK #define __init_memblock __meminit #define __initdata_memblock __meminitdata #else diff --git a/mm/Kconfig b/mm/Kconfig index 30a5d47..7c56971 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -134,6 +134,9 @@ config HAVE_MEMBLOCK config HAVE_MEMBLOCK_NODE_MAP boolean +config ARCH_DISCARD_MEMBLOCK + boolean + # eventually, we can have this option just 'select SPARSEMEM' config MEMORY_HOTPLUG bool "Allow for memory hot-add" diff --git a/mm/memblock.c b/mm/memblock.c index c4a8750..ebc6119 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -959,7 +959,7 @@ static int __init early_memblock(char *p) } early_param("memblock", early_memblock); -#if defined(CONFIG_DEBUG_FS) && !defined(ARCH_DISCARD_MEMBLOCK) +#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK) static int memblock_debug_show(struct seq_file *m, void *private) { -- cgit v0.10.2 From 24aa07882b672fff2da2f5c955759f0bd13d32d5 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 12 Jul 2011 11:16:06 +0200 Subject: memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones Other than sanity check and debug message, the x86 specific version of memblock reserve/free functions are simple wrappers around the generic versions - memblock_reserve/free(). This patch adds debug messages with caller identification to the generic versions and replaces x86 specific ones and kills them. arch/x86/include/asm/memblock.h and arch/x86/mm/memblock.c are empty after this change and removed. Signed-off-by: Tejun Heo Link: http://lkml.kernel.org/r/1310462166-31469-14-git-send-email-tj@kernel.org Cc: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Signed-off-by: H. Peter Anvin diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h deleted file mode 100644 index bc56670..0000000 --- a/arch/x86/include/asm/memblock.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _X86_MEMBLOCK_H -#define _X86_MEMBLOCK_H - -void memblock_x86_reserve_range(u64 start, u64 end, char *name); -void memblock_x86_free_range(u64 start, u64 end); - -#endif diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c index 5636308..6e76c19 100644 --- a/arch/x86/kernel/aperture_64.c +++ b/arch/x86/kernel/aperture_64.c @@ -94,7 +94,7 @@ static u32 __init allocate_aperture(void) addr, aper_size>>10); return 0; } - memblock_x86_reserve_range(addr, addr + aper_size, "aperture64"); + memblock_reserve(addr, aper_size); /* * Kmemleak should not scan this block as it may not be mapped via the * kernel direct mapping. diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c index 621cd23..5da1269 100644 --- a/arch/x86/kernel/check.c +++ b/arch/x86/kernel/check.c @@ -91,7 +91,7 @@ void __init setup_bios_corruption_check(void) if (start >= end) continue; - memblock_x86_reserve_range(start, end, "SCAN RAM"); + memblock_reserve(start, end - start); scan_areas[num_scan_areas].addr = start; scan_areas[num_scan_areas].size = end - start; diff --git a/arch/x86/kernel/head.c b/arch/x86/kernel/head.c index af0699b..48d9d4e 100644 --- a/arch/x86/kernel/head.c +++ b/arch/x86/kernel/head.c @@ -52,5 +52,5 @@ void __init reserve_ebda_region(void) lowmem = 0x9f000; /* reserve all memory between lowmem and the 1MB mark */ - memblock_x86_reserve_range(lowmem, 0x100000, "* BIOS reserved"); + memblock_reserve(lowmem, 0x100000 - lowmem); } diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c index 3bb0850..be9282b 100644 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c @@ -33,7 +33,8 @@ void __init i386_start_kernel(void) { memblock_init(); - memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS"); + memblock_reserve(__pa_symbol(&_text), + __pa_symbol(&__bss_stop) - __pa_symbol(&_text)); #ifdef CONFIG_BLK_DEV_INITRD /* Reserve INITRD */ @@ -42,7 +43,7 @@ void __init i386_start_kernel(void) u64 ramdisk_image = boot_params.hdr.ramdisk_image; u64 ramdisk_size = boot_params.hdr.ramdisk_size; u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size); - memblock_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK"); + memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image); } #endif diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 5655c22..fd25b11 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -100,7 +100,8 @@ void __init x86_64_start_reservations(char *real_mode_data) memblock_init(); - memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS"); + memblock_reserve(__pa_symbol(&_text), + __pa_symbol(&__bss_stop) - __pa_symbol(&_text)); #ifdef CONFIG_BLK_DEV_INITRD /* Reserve INITRD */ @@ -109,7 +110,7 @@ void __init x86_64_start_reservations(char *real_mode_data) unsigned long ramdisk_image = boot_params.hdr.ramdisk_image; unsigned long ramdisk_size = boot_params.hdr.ramdisk_size; unsigned long ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size); - memblock_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK"); + memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image); } #endif diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 8faeaa0..a6b79c1 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c @@ -564,9 +564,7 @@ void __init default_get_smp_config(unsigned int early) static void __init smp_reserve_memory(struct mpf_intel *mpf) { - unsigned long size = get_mpc_size(mpf->physptr); - - memblock_x86_reserve_range(mpf->physptr, mpf->physptr+size, "* MP-table mpc"); + memblock_reserve(mpf->physptr, get_mpc_size(mpf->physptr)); } static int __init smp_scan_config(unsigned long base, unsigned long length) @@ -595,7 +593,7 @@ static int __init smp_scan_config(unsigned long base, unsigned long length) mpf, (u64)virt_to_phys(mpf)); mem = virt_to_phys(mpf); - memblock_x86_reserve_range(mem, mem + sizeof(*mpf), "* MP-table mpf"); + memblock_reserve(mem, sizeof(*mpf)); if (mpf->physptr) smp_reserve_memory(mpf); diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 31ffe20..97d227e 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -306,7 +306,8 @@ static void __init cleanup_highmap(void) static void __init reserve_brk(void) { if (_brk_end > _brk_start) - memblock_x86_reserve_range(__pa(_brk_start), __pa(_brk_end), "BRK"); + memblock_reserve(__pa(_brk_start), + __pa(_brk_end) - __pa(_brk_start)); /* Mark brk area as locked down and no longer taking any new allocations */ @@ -337,7 +338,7 @@ static void __init relocate_initrd(void) /* Note: this includes all the lowmem currently occupied by the initrd, we rely on that fact to keep the data intact. */ - memblock_x86_reserve_range(ramdisk_here, ramdisk_here + area_size, "NEW RAMDISK"); + memblock_reserve(ramdisk_here, area_size); initrd_start = ramdisk_here + PAGE_OFFSET; initrd_end = initrd_start + ramdisk_size; printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n", @@ -393,7 +394,7 @@ static void __init reserve_initrd(void) initrd_start = 0; if (ramdisk_size >= (end_of_lowmem>>1)) { - memblock_x86_free_range(ramdisk_image, ramdisk_end); + memblock_free(ramdisk_image, ramdisk_end - ramdisk_image); printk(KERN_ERR "initrd too large to handle, " "disabling initrd\n"); return; @@ -416,7 +417,7 @@ static void __init reserve_initrd(void) relocate_initrd(); - memblock_x86_free_range(ramdisk_image, ramdisk_end); + memblock_free(ramdisk_image, ramdisk_end - ramdisk_image); } #else static void __init reserve_initrd(void) @@ -490,15 +491,13 @@ static void __init memblock_x86_reserve_range_setup_data(void) { struct setup_data *data; u64 pa_data; - char buf[32]; if (boot_params.hdr.version < 0x0209) return; pa_data = boot_params.hdr.setup_data; while (pa_data) { data = early_memremap(pa_data, sizeof(*data)); - sprintf(buf, "setup data %x", data->type); - memblock_x86_reserve_range(pa_data, pa_data+sizeof(*data)+data->len, buf); + memblock_reserve(pa_data, sizeof(*data) + data->len); pa_data = data->next; early_iounmap(data, sizeof(*data)); } @@ -568,7 +567,7 @@ static void __init reserve_crashkernel(void) return; } } - memblock_x86_reserve_range(crash_base, crash_base + crash_size, "CRASH KERNEL"); + memblock_reserve(crash_base, crash_size); printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " "for crashkernel (System RAM: %ldMB)\n", @@ -626,7 +625,7 @@ static __init void reserve_ibft_region(void) addr = find_ibft_region(&size); if (size) - memblock_x86_reserve_range(addr, addr + size, "* ibft"); + memblock_reserve(addr, size); } static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10; diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c index a1f13dd..a73b610 100644 --- a/arch/x86/kernel/trampoline.c +++ b/arch/x86/kernel/trampoline.c @@ -18,7 +18,7 @@ void __init setup_trampolines(void) panic("Cannot allocate trampoline\n"); x86_trampoline_base = __va(mem); - memblock_x86_reserve_range(mem, mem + size, "TRAMPOLINE"); + memblock_reserve(mem, size); printk(KERN_DEBUG "Base memory trampoline at [%p] %llx size %zu\n", x86_trampoline_base, (unsigned long long)mem, size); diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 3d11327..23d8e5f 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile @@ -27,6 +27,4 @@ obj-$(CONFIG_AMD_NUMA) += amdtopology.o obj-$(CONFIG_ACPI_NUMA) += srat.o obj-$(CONFIG_NUMA_EMU) += numa_emulation.o -obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o - obj-$(CONFIG_MEMTEST) += memtest.o diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 13cf05a..0b736b9 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -81,7 +81,7 @@ static void __init find_early_table_space(unsigned long end, int use_pse, void __init native_pagetable_reserve(u64 start, u64 end) { - memblock_x86_reserve_range(start, end, "PGTABLE"); + memblock_reserve(start, end - start); } struct map_range { @@ -280,8 +280,8 @@ unsigned long __init_refok init_memory_mapping(unsigned long start, * pgt_buf_end) and free the other ones (pgt_buf_end - pgt_buf_top) * so that they can be reused for other purposes. * - * On native it just means calling memblock_x86_reserve_range, on Xen it - * also means marking RW the pagetable pages that we allocated before + * On native it just means calling memblock_reserve, on Xen it also + * means marking RW the pagetable pages that we allocated before * but that haven't been used. * * In fact on xen we mark RO the whole range pgt_buf_start - diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c deleted file mode 100644 index 7325c5d..0000000 --- a/arch/x86/mm/memblock.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -void __init memblock_x86_reserve_range(u64 start, u64 end, char *name) -{ - if (start == end) - return; - - if (WARN_ONCE(start > end, "memblock_x86_reserve_range: wrong range [%#llx, %#llx)\n", start, end)) - return; - - memblock_dbg(" memblock_x86_reserve_range: [%#010llx-%#010llx] %16s\n", start, end - 1, name); - - memblock_reserve(start, end - start); -} - -void __init memblock_x86_free_range(u64 start, u64 end) -{ - if (start == end) - return; - - if (WARN_ONCE(start > end, "memblock_x86_free_range: wrong range [%#llx, %#llx)\n", start, end)) - return; - - memblock_dbg(" memblock_x86_free_range: [%#010llx-%#010llx]\n", start, end - 1); - - memblock_free(start, end - start); -} diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c index 46a5ff2..c80b9fb 100644 --- a/arch/x86/mm/memtest.c +++ b/arch/x86/mm/memtest.c @@ -34,7 +34,7 @@ static void __init reserve_bad_mem(u64 pattern, u64 start_bad, u64 end_bad) (unsigned long long) pattern, (unsigned long long) start_bad, (unsigned long long) end_bad); - memblock_x86_reserve_range(start_bad, end_bad, "BAD RAM"); + memblock_reserve(start_bad, end_bad - start_bad); } static void __init memtest(u64 pattern, u64 start_phys, u64 size) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 88e5627..496f494 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -364,8 +364,7 @@ void __init numa_reset_distance(void) /* numa_distance could be 1LU marking allocation failure, test cnt */ if (numa_distance_cnt) - memblock_x86_free_range(__pa(numa_distance), - __pa(numa_distance) + size); + memblock_free(__pa(numa_distance), size); numa_distance_cnt = 0; numa_distance = NULL; /* enable table creation */ } @@ -394,7 +393,7 @@ static int __init numa_alloc_distance(void) numa_distance = (void *)1LU; return -ENOMEM; } - memblock_x86_reserve_range(phys, phys + size, "NUMA DIST"); + memblock_reserve(phys, size); numa_distance = __va(phys); numa_distance_cnt = cnt; diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c index 58878b5..534255a 100644 --- a/arch/x86/mm/numa_32.c +++ b/arch/x86/mm/numa_32.c @@ -204,7 +204,7 @@ void __init init_alloc_remap(int nid, u64 start, u64 end) size, nid); return; } - memblock_x86_reserve_range(node_pa, node_pa + size, "KVA RAM"); + memblock_reserve(node_pa, size); remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT, @@ -212,10 +212,10 @@ void __init init_alloc_remap(int nid, u64 start, u64 end) if (!remap_pa) { pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n", size, nid); - memblock_x86_free_range(node_pa, node_pa + size); + memblock_free(node_pa, size); return; } - memblock_x86_reserve_range(remap_pa, remap_pa + size, "KVA PG"); + memblock_reserve(remap_pa, size); remap_va = phys_to_virt(remap_pa); /* perform actual remap */ diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index 971fe70..46db568 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -361,7 +361,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n"); goto no_emu; } - memblock_x86_reserve_range(phys, phys + phys_size, "TMP NUMA DIST"); + memblock_reserve(phys, phys_size); phys_dist = __va(phys); for (i = 0; i < numa_dist_cnt; i++) @@ -430,7 +430,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) /* free the copied physical distance table */ if (phys_dist) - memblock_x86_free_range(__pa(phys_dist), __pa(phys_dist) + phys_size); + memblock_free(__pa(phys_dist), phys_size); return; no_emu: diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index a4c322c..3b4e86b 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -280,8 +280,7 @@ void __init efi_memblock_x86_reserve_range(void) boot_params.efi_info.efi_memdesc_size; memmap.desc_version = boot_params.efi_info.efi_memdesc_version; memmap.desc_size = boot_params.efi_info.efi_memdesc_size; - memblock_x86_reserve_range(pmap, pmap + memmap.nr_map * memmap.desc_size, - "EFI memmap"); + memblock_reserve(pmap, memmap.nr_map * memmap.desc_size); } #if EFI_DEBUG @@ -332,8 +331,7 @@ void __init efi_reserve_boot_services(void) "[0x%010llx-0x%010llx]\n", start, start+size-1); } else - memblock_x86_reserve_range(start, start+size, - "EFI Boot"); + memblock_reserve(start, size); } } diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 0ccccb6..ad54fa1 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -1720,10 +1720,8 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd, __xen_write_cr3(true, __pa(pgd)); xen_mc_issue(PARAVIRT_LAZY_CPU); - memblock_x86_reserve_range(__pa(xen_start_info->pt_base), - __pa(xen_start_info->pt_base + - xen_start_info->nr_pt_frames * PAGE_SIZE), - "XEN PAGETABLES"); + memblock_reserve(__pa(xen_start_info->pt_base), + xen_start_info->nr_pt_frames * PAGE_SIZE); return pgd; } @@ -1799,10 +1797,8 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd, PFN_DOWN(__pa(initial_page_table))); xen_write_cr3(__pa(initial_page_table)); - memblock_x86_reserve_range(__pa(xen_start_info->pt_base), - __pa(xen_start_info->pt_base + - xen_start_info->nr_pt_frames * PAGE_SIZE), - "XEN PAGETABLES"); + memblock_reserve(__pa(xen_start_info->pt_base), + xen_start_info->nr_pt_frames * PAGE_SIZE)); return initial_page_table; } diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 60aeeb5..73daaf7 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -63,7 +63,7 @@ static void __init xen_add_extra_mem(unsigned long pages) e820_add_region(extra_start, size, E820_RAM); sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); - memblock_x86_reserve_range(extra_start, extra_start + size, "XEN EXTRA"); + memblock_reserve(extra_start, size); xen_extra_mem_size += size; @@ -287,9 +287,8 @@ char * __init xen_memory_setup(void) * - xen_start_info * See comment above "struct start_info" in */ - memblock_x86_reserve_range(__pa(xen_start_info->mfn_list), - __pa(xen_start_info->pt_base), - "XEN START INFO"); + memblock_reserve(__pa(xen_start_info->mfn_list), + xen_start_info->pt_base - xen_start_info->mfn_list); sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 2491355..9074631 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -17,8 +17,6 @@ #include #include -#include - #define INIT_MEMBLOCK_REGIONS 128 struct memblock_region { diff --git a/mm/memblock.c b/mm/memblock.c index ebc6119..0cb4da6 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -449,6 +449,9 @@ long __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size) long __init_memblock memblock_free(phys_addr_t base, phys_addr_t size) { + memblock_dbg(" memblock_free: [%#016llx-%#016llx] %pF\n", + base, base + size, (void *)_RET_IP_); + return __memblock_remove(&memblock.reserved, base, size); } @@ -456,6 +459,8 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size) { struct memblock_type *_rgn = &memblock.reserved; + memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n", + base, base + size, (void *)_RET_IP_); BUG_ON(0 == size); return memblock_add_region(_rgn, base, size); diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 7075bc0..29d948c 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c @@ -47,7 +47,7 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align, ptr = phys_to_virt(addr); memset(ptr, 0, size); - memblock_x86_reserve_range(addr, addr + size, "BOOTMEM"); + memblock_reserve(addr, size); /* * The min_count is set to 0 so that bootmem allocated blocks * are never reported as leaks. @@ -175,7 +175,7 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, unsigned long size) { kmemleak_free_part(__va(physaddr), size); - memblock_x86_free_range(physaddr, physaddr + size); + memblock_free(physaddr, size); } /** @@ -190,7 +190,7 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, void __init free_bootmem(unsigned long addr, unsigned long size) { kmemleak_free_part(__va(addr), size); - memblock_x86_free_range(addr, addr + size); + memblock_free(addr, size); } static void * __init ___alloc_bootmem_nopanic(unsigned long size, -- cgit v0.10.2 From a150439c4a97db379f0ed6faa46fbbb6e7bf3cb2 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 14 Jul 2011 11:57:10 -0700 Subject: memblock: Cast phys_addr_t to unsigned long long for printf use phys_addr_t is not necessarily the same thing as unsigned long long. It is, however, easier to cast it to unsigned long long for printf purposes than it is to deal with differnent printf formats. Signed-off-by: H. Peter Anvin Cc: Tejun Heo Link: http://lkml.kernel.org/r/4E1F4D2C.3000507@zytor.com diff --git a/mm/memblock.c b/mm/memblock.c index 0cb4da6..a75723d 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -450,7 +450,9 @@ long __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size) long __init_memblock memblock_free(phys_addr_t base, phys_addr_t size) { memblock_dbg(" memblock_free: [%#016llx-%#016llx] %pF\n", - base, base + size, (void *)_RET_IP_); + (unsigned long long)base, + (unsigned long long)base + size, + (void *)_RET_IP_); return __memblock_remove(&memblock.reserved, base, size); } @@ -460,7 +462,9 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size) struct memblock_type *_rgn = &memblock.reserved; memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n", - base, base + size, (void *)_RET_IP_); + (unsigned long long)base, + (unsigned long long)base + size, + (void *)_RET_IP_); BUG_ON(0 == size); return memblock_add_region(_rgn, base, size); -- cgit v0.10.2 From d2eece376648d2f7ba0a7d78f3c4d0421e608ac2 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:21:54 -0700 Subject: ocfs2/cluster: Abort heartbeat start on hard-ro devices Currently if the heartbeat device is hard-ro, the o2hb thread keeps chugging along and dumping errors along the way. The user needs to manually stop the heartbeat. The patch addresses this shortcoming by adding a limit to the number of times the hb thread will iterate in an unsteady state. If the hb thread does not ready steady state in that many interation, the start is aborted. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 9a3e6bb..4728a74 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -216,6 +216,7 @@ struct o2hb_region { struct list_head hr_all_item; unsigned hr_unclean_stop:1, + hr_aborted_start:1, hr_item_pinned:1, hr_item_dropped:1; @@ -254,6 +255,10 @@ struct o2hb_region { * a more complete api that doesn't lead to this sort of fragility. */ atomic_t hr_steady_iterations; + /* terminate o2hb thread if it does not reach steady state + * (hr_steady_iterations == 0) within hr_unsteady_iterations */ + atomic_t hr_unsteady_iterations; + char hr_dev_name[BDEVNAME_SIZE]; unsigned int hr_timeout_ms; @@ -324,6 +329,10 @@ static void o2hb_write_timeout(struct work_struct *work) static void o2hb_arm_write_timeout(struct o2hb_region *reg) { + /* Arm writeout only after thread reaches steady state */ + if (atomic_read(®->hr_steady_iterations) != 0) + return; + mlog(ML_HEARTBEAT, "Queue write timeout for %u ms\n", O2HB_MAX_WRITE_TIMEOUT_MS); @@ -537,9 +546,14 @@ static int o2hb_verify_crc(struct o2hb_region *reg, return read == computed; } -/* We want to make sure that nobody is heartbeating on top of us -- - * this will help detect an invalid configuration. */ -static void o2hb_check_last_timestamp(struct o2hb_region *reg) +/* + * Compare the slot data with what we wrote in the last iteration. + * If the match fails, print an appropriate error message. This is to + * detect errors like... another node hearting on the same slot, + * flaky device that is losing writes, etc. + * Returns 1 if check succeeds, 0 otherwise. + */ +static int o2hb_check_own_slot(struct o2hb_region *reg) { struct o2hb_disk_slot *slot; struct o2hb_disk_heartbeat_block *hb_block; @@ -548,13 +562,13 @@ static void o2hb_check_last_timestamp(struct o2hb_region *reg) slot = ®->hr_slots[o2nm_this_node()]; /* Don't check on our 1st timestamp */ if (!slot->ds_last_time) - return; + return 0; hb_block = slot->ds_raw_block; if (le64_to_cpu(hb_block->hb_seq) == slot->ds_last_time && le64_to_cpu(hb_block->hb_generation) == slot->ds_last_generation && hb_block->hb_node == slot->ds_node_num) - return; + return 1; #define ERRSTR1 "Another node is heartbeating on device" #define ERRSTR2 "Heartbeat generation mismatch on device" @@ -574,6 +588,8 @@ static void o2hb_check_last_timestamp(struct o2hb_region *reg) (unsigned long long)slot->ds_last_time, hb_block->hb_node, (unsigned long long)le64_to_cpu(hb_block->hb_generation), (unsigned long long)le64_to_cpu(hb_block->hb_seq)); + + return 0; } static inline void o2hb_prepare_block(struct o2hb_region *reg, @@ -719,17 +735,24 @@ static void o2hb_shutdown_slot(struct o2hb_disk_slot *slot) o2nm_node_put(node); } -static void o2hb_set_quorum_device(struct o2hb_region *reg, - struct o2hb_disk_slot *slot) +static void o2hb_set_quorum_device(struct o2hb_region *reg) { - assert_spin_locked(&o2hb_live_lock); - if (!o2hb_global_heartbeat_active()) return; - if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap)) + /* Prevent race with o2hb_heartbeat_group_drop_item() */ + if (kthread_should_stop()) + return; + + /* Tag region as quorum only after thread reaches steady state */ + if (atomic_read(®->hr_steady_iterations) != 0) return; + spin_lock(&o2hb_live_lock); + + if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap)) + goto unlock; + /* * A region can be added to the quorum only when it sees all * live nodes heartbeat on it. In other words, the region has been @@ -737,13 +760,10 @@ static void o2hb_set_quorum_device(struct o2hb_region *reg, */ if (memcmp(reg->hr_live_node_bitmap, o2hb_live_node_bitmap, sizeof(o2hb_live_node_bitmap))) - return; - - if (slot->ds_changed_samples < O2HB_LIVE_THRESHOLD) - return; + goto unlock; - printk(KERN_NOTICE "o2hb: Region %s is now a quorum device\n", - config_item_name(®->hr_item)); + printk(KERN_NOTICE "o2hb: Region %s (%s) is now a quorum device\n", + config_item_name(®->hr_item), reg->hr_dev_name); set_bit(reg->hr_region_num, o2hb_quorum_region_bitmap); @@ -754,6 +774,8 @@ static void o2hb_set_quorum_device(struct o2hb_region *reg, if (o2hb_pop_count(&o2hb_quorum_region_bitmap, O2NM_MAX_REGIONS) > O2HB_PIN_CUT_OFF) o2hb_region_unpin(NULL); +unlock: + spin_unlock(&o2hb_live_lock); } static int o2hb_check_slot(struct o2hb_region *reg, @@ -925,8 +947,6 @@ fire_callbacks: slot->ds_equal_samples = 0; } out: - o2hb_set_quorum_device(reg, slot); - spin_unlock(&o2hb_live_lock); o2hb_run_event_list(&event); @@ -957,7 +977,8 @@ static int o2hb_highest_node(unsigned long *nodes, static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) { - int i, ret, highest_node, change = 0; + int i, ret, highest_node; + int membership_change = 0, own_slot_ok = 0; unsigned long configured_nodes[BITS_TO_LONGS(O2NM_MAX_NODES)]; unsigned long live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; struct o2hb_bio_wait_ctxt write_wc; @@ -966,7 +987,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) sizeof(configured_nodes)); if (ret) { mlog_errno(ret); - return ret; + goto bail; } /* @@ -982,8 +1003,9 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) highest_node = o2hb_highest_node(configured_nodes, O2NM_MAX_NODES); if (highest_node >= O2NM_MAX_NODES) { - mlog(ML_NOTICE, "ocfs2_heartbeat: no configured nodes found!\n"); - return -EINVAL; + mlog(ML_NOTICE, "o2hb: No configured nodes found!\n"); + ret = -EINVAL; + goto bail; } /* No sense in reading the slots of nodes that don't exist @@ -993,29 +1015,27 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) ret = o2hb_read_slots(reg, highest_node + 1); if (ret < 0) { mlog_errno(ret); - return ret; + goto bail; } /* With an up to date view of the slots, we can check that no * other node has been improperly configured to heartbeat in * our slot. */ - o2hb_check_last_timestamp(reg); + own_slot_ok = o2hb_check_own_slot(reg); /* fill in the proper info for our next heartbeat */ o2hb_prepare_block(reg, reg->hr_generation); - /* And fire off the write. Note that we don't wait on this I/O - * until later. */ ret = o2hb_issue_node_write(reg, &write_wc); if (ret < 0) { mlog_errno(ret); - return ret; + goto bail; } i = -1; while((i = find_next_bit(configured_nodes, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) { - change |= o2hb_check_slot(reg, ®->hr_slots[i]); + membership_change |= o2hb_check_slot(reg, ®->hr_slots[i]); } /* @@ -1030,18 +1050,39 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) * disk */ mlog(ML_ERROR, "Write error %d on device \"%s\"\n", write_wc.wc_error, reg->hr_dev_name); - return write_wc.wc_error; + ret = write_wc.wc_error; + goto bail; } - o2hb_arm_write_timeout(reg); + /* Skip disarming the timeout if own slot has stale/bad data */ + if (own_slot_ok) { + o2hb_set_quorum_device(reg); + o2hb_arm_write_timeout(reg); + } +bail: /* let the person who launched us know when things are steady */ - if (!change && (atomic_read(®->hr_steady_iterations) != 0)) { - if (atomic_dec_and_test(®->hr_steady_iterations)) + if (atomic_read(®->hr_steady_iterations) != 0) { + if (!ret && own_slot_ok && !membership_change) { + if (atomic_dec_and_test(®->hr_steady_iterations)) + wake_up(&o2hb_steady_queue); + } + } + + if (atomic_read(®->hr_steady_iterations) != 0) { + if (atomic_dec_and_test(®->hr_unsteady_iterations)) { + printk(KERN_NOTICE "o2hb: Unable to stabilize " + "heartbeart on region %s (%s)\n", + config_item_name(®->hr_item), + reg->hr_dev_name); + atomic_set(®->hr_steady_iterations, 0); + reg->hr_aborted_start = 1; wake_up(&o2hb_steady_queue); + ret = -EIO; + } } - return 0; + return ret; } /* Subtract b from a, storing the result in a. a *must* have a larger @@ -1095,7 +1136,8 @@ static int o2hb_thread(void *data) /* Pin node */ o2nm_depend_this_node(); - while (!kthread_should_stop() && !reg->hr_unclean_stop) { + while (!kthread_should_stop() && + !reg->hr_unclean_stop && !reg->hr_aborted_start) { /* We track the time spent inside * o2hb_do_disk_heartbeat so that we avoid more than * hr_timeout_ms between disk writes. On busy systems @@ -1103,10 +1145,7 @@ static int o2hb_thread(void *data) * likely to time itself out. */ do_gettimeofday(&before_hb); - i = 0; - do { - ret = o2hb_do_disk_heartbeat(reg); - } while (ret && ++i < 2); + ret = o2hb_do_disk_heartbeat(reg); do_gettimeofday(&after_hb); elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb); @@ -1117,7 +1156,8 @@ static int o2hb_thread(void *data) after_hb.tv_sec, (unsigned long) after_hb.tv_usec, elapsed_msec); - if (elapsed_msec < reg->hr_timeout_ms) { + if (!kthread_should_stop() && + elapsed_msec < reg->hr_timeout_ms) { /* the kthread api has blocked signals for us so no * need to record the return value. */ msleep_interruptible(reg->hr_timeout_ms - elapsed_msec); @@ -1134,20 +1174,20 @@ static int o2hb_thread(void *data) * to timeout on this region when we could just as easily * write a clear generation - thus indicating to them that * this node has left this region. - * - * XXX: Should we skip this on unclean_stop? */ - o2hb_prepare_block(reg, 0); - ret = o2hb_issue_node_write(reg, &write_wc); - if (ret == 0) { - o2hb_wait_on_io(reg, &write_wc); - } else { - mlog_errno(ret); + */ + if (!reg->hr_unclean_stop && !reg->hr_aborted_start) { + o2hb_prepare_block(reg, 0); + ret = o2hb_issue_node_write(reg, &write_wc); + if (ret == 0) + o2hb_wait_on_io(reg, &write_wc); + else + mlog_errno(ret); } /* Unpin node */ o2nm_undepend_this_node(); - mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread exiting\n"); + mlog(ML_HEARTBEAT|ML_KTHREAD, "o2hb thread exiting\n"); return 0; } @@ -1426,6 +1466,8 @@ static void o2hb_region_release(struct config_item *item) struct page *page; struct o2hb_region *reg = to_o2hb_region(item); + mlog(ML_HEARTBEAT, "hb region release (%s)\n", reg->hr_dev_name); + if (reg->hr_tmp_block) kfree(reg->hr_tmp_block); @@ -1792,7 +1834,10 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, live_threshold <<= 1; spin_unlock(&o2hb_live_lock); } - atomic_set(®->hr_steady_iterations, live_threshold + 1); + ++live_threshold; + atomic_set(®->hr_steady_iterations, live_threshold); + /* unsteady_iterations is double the steady_iterations */ + atomic_set(®->hr_unsteady_iterations, (live_threshold << 1)); hb_task = kthread_run(o2hb_thread, reg, "o2hb-%s", reg->hr_item.ci_name); @@ -1809,14 +1854,12 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, ret = wait_event_interruptible(o2hb_steady_queue, atomic_read(®->hr_steady_iterations) == 0); if (ret) { - /* We got interrupted (hello ptrace!). Clean up */ - spin_lock(&o2hb_live_lock); - hb_task = reg->hr_task; - reg->hr_task = NULL; - spin_unlock(&o2hb_live_lock); + atomic_set(®->hr_steady_iterations, 0); + reg->hr_aborted_start = 1; + } - if (hb_task) - kthread_stop(hb_task); + if (reg->hr_aborted_start) { + ret = -EIO; goto out; } @@ -1833,8 +1876,8 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, ret = -EIO; if (hb_task && o2hb_global_heartbeat_active()) - printk(KERN_NOTICE "o2hb: Heartbeat started on region %s\n", - config_item_name(®->hr_item)); + printk(KERN_NOTICE "o2hb: Heartbeat started on region %s (%s)\n", + config_item_name(®->hr_item), reg->hr_dev_name); out: if (filp) @@ -2092,13 +2135,6 @@ static void o2hb_heartbeat_group_drop_item(struct config_group *group, /* stop the thread when the user removes the region dir */ spin_lock(&o2hb_live_lock); - if (o2hb_global_heartbeat_active()) { - clear_bit(reg->hr_region_num, o2hb_region_bitmap); - clear_bit(reg->hr_region_num, o2hb_live_region_bitmap); - if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap)) - quorum_region = 1; - clear_bit(reg->hr_region_num, o2hb_quorum_region_bitmap); - } hb_task = reg->hr_task; reg->hr_task = NULL; reg->hr_item_dropped = 1; @@ -2107,19 +2143,30 @@ static void o2hb_heartbeat_group_drop_item(struct config_group *group, if (hb_task) kthread_stop(hb_task); + if (o2hb_global_heartbeat_active()) { + spin_lock(&o2hb_live_lock); + clear_bit(reg->hr_region_num, o2hb_region_bitmap); + clear_bit(reg->hr_region_num, o2hb_live_region_bitmap); + if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap)) + quorum_region = 1; + clear_bit(reg->hr_region_num, o2hb_quorum_region_bitmap); + spin_unlock(&o2hb_live_lock); + printk(KERN_NOTICE "o2hb: Heartbeat %s on region %s (%s)\n", + ((atomic_read(®->hr_steady_iterations) == 0) ? + "stopped" : "start aborted"), config_item_name(item), + reg->hr_dev_name); + } + /* * If we're racing a dev_write(), we need to wake them. They will * check reg->hr_task */ if (atomic_read(®->hr_steady_iterations) != 0) { + reg->hr_aborted_start = 1; atomic_set(®->hr_steady_iterations, 0); wake_up(&o2hb_steady_queue); } - if (o2hb_global_heartbeat_active()) - printk(KERN_NOTICE "o2hb: Heartbeat stopped on region %s\n", - config_item_name(®->hr_item)); - config_item_put(item); if (!o2hb_global_heartbeat_active() || !quorum_region) -- cgit v0.10.2 From 1dfecf810e0eacb35987905082f23e5c2cd26e91 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:22:54 -0700 Subject: ocfs2/cluster: Clean up messages in o2net o2net messages needed a facelift. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index db5ee4b..6e97895 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -545,7 +545,7 @@ static void o2net_set_nn_state(struct o2net_node *nn, } if (was_valid && !valid) { - printk(KERN_NOTICE "o2net: no longer connected to " + printk(KERN_NOTICE "o2net: No longer connected to " SC_NODEF_FMT "\n", SC_NODEF_ARGS(old_sc)); o2net_complete_nodes_nsw(nn); } @@ -555,7 +555,7 @@ static void o2net_set_nn_state(struct o2net_node *nn, cancel_delayed_work(&nn->nn_connect_expired); printk(KERN_NOTICE "o2net: %s " SC_NODEF_FMT "\n", o2nm_this_node() > sc->sc_node->nd_num ? - "connected to" : "accepted connection from", + "Connected to" : "Accepted connection from", SC_NODEF_ARGS(sc)); } @@ -643,7 +643,7 @@ static void o2net_state_change(struct sock *sk) o2net_sc_queue_work(sc, &sc->sc_connect_work); break; default: - printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT + printk(KERN_INFO "o2net: Connection to " SC_NODEF_FMT " shutdown, state %d\n", SC_NODEF_ARGS(sc), sk->sk_state); o2net_sc_queue_work(sc, &sc->sc_shutdown_work); @@ -1284,11 +1284,11 @@ static int o2net_check_handshake(struct o2net_sock_container *sc) struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); if (hand->protocol_version != cpu_to_be64(O2NET_PROTOCOL_VERSION)) { - mlog(ML_NOTICE, SC_NODEF_FMT " advertised net protocol " - "version %llu but %llu is required, disconnecting\n", - SC_NODEF_ARGS(sc), - (unsigned long long)be64_to_cpu(hand->protocol_version), - O2NET_PROTOCOL_VERSION); + printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " Advertised net " + "protocol version %llu but %llu is required. " + "Disconnecting.\n", SC_NODEF_ARGS(sc), + (unsigned long long)be64_to_cpu(hand->protocol_version), + O2NET_PROTOCOL_VERSION); /* don't bother reconnecting if its the wrong version. */ o2net_ensure_shutdown(nn, sc, -ENOTCONN); @@ -1302,33 +1302,33 @@ static int o2net_check_handshake(struct o2net_sock_container *sc) */ if (be32_to_cpu(hand->o2net_idle_timeout_ms) != o2net_idle_timeout()) { - mlog(ML_NOTICE, SC_NODEF_FMT " uses a network idle timeout of " - "%u ms, but we use %u ms locally. disconnecting\n", - SC_NODEF_ARGS(sc), - be32_to_cpu(hand->o2net_idle_timeout_ms), - o2net_idle_timeout()); + printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a network " + "idle timeout of %u ms, but we use %u ms locally. " + "Disconnecting.\n", SC_NODEF_ARGS(sc), + be32_to_cpu(hand->o2net_idle_timeout_ms), + o2net_idle_timeout()); o2net_ensure_shutdown(nn, sc, -ENOTCONN); return -1; } if (be32_to_cpu(hand->o2net_keepalive_delay_ms) != o2net_keepalive_delay()) { - mlog(ML_NOTICE, SC_NODEF_FMT " uses a keepalive delay of " - "%u ms, but we use %u ms locally. disconnecting\n", - SC_NODEF_ARGS(sc), - be32_to_cpu(hand->o2net_keepalive_delay_ms), - o2net_keepalive_delay()); + printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a keepalive " + "delay of %u ms, but we use %u ms locally. " + "Disconnecting.\n", SC_NODEF_ARGS(sc), + be32_to_cpu(hand->o2net_keepalive_delay_ms), + o2net_keepalive_delay()); o2net_ensure_shutdown(nn, sc, -ENOTCONN); return -1; } if (be32_to_cpu(hand->o2hb_heartbeat_timeout_ms) != O2HB_MAX_WRITE_TIMEOUT_MS) { - mlog(ML_NOTICE, SC_NODEF_FMT " uses a heartbeat timeout of " - "%u ms, but we use %u ms locally. disconnecting\n", - SC_NODEF_ARGS(sc), - be32_to_cpu(hand->o2hb_heartbeat_timeout_ms), - O2HB_MAX_WRITE_TIMEOUT_MS); + printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a heartbeat " + "timeout of %u ms, but we use %u ms locally. " + "Disconnecting.\n", SC_NODEF_ARGS(sc), + be32_to_cpu(hand->o2hb_heartbeat_timeout_ms), + O2HB_MAX_WRITE_TIMEOUT_MS); o2net_ensure_shutdown(nn, sc, -ENOTCONN); return -1; } @@ -1539,28 +1539,16 @@ static void o2net_idle_timer(unsigned long data) { struct o2net_sock_container *sc = (struct o2net_sock_container *)data; struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); - #ifdef CONFIG_DEBUG_FS - ktime_t now = ktime_get(); + unsigned long msecs = ktime_to_ms(ktime_get()) - + ktime_to_ms(sc->sc_tv_timer); +#else + unsigned long msecs = o2net_idle_timeout(); #endif - printk(KERN_NOTICE "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u " - "seconds, shutting it down.\n", SC_NODEF_ARGS(sc), - o2net_idle_timeout() / 1000, - o2net_idle_timeout() % 1000); - -#ifdef CONFIG_DEBUG_FS - mlog(ML_NOTICE, "Here are some times that might help debug the " - "situation: (Timer: %lld, Now %lld, DataReady %lld, Advance %lld-%lld, " - "Key 0x%08x, Func %u, FuncTime %lld-%lld)\n", - (long long)ktime_to_us(sc->sc_tv_timer), (long long)ktime_to_us(now), - (long long)ktime_to_us(sc->sc_tv_data_ready), - (long long)ktime_to_us(sc->sc_tv_advance_start), - (long long)ktime_to_us(sc->sc_tv_advance_stop), - sc->sc_msg_key, sc->sc_msg_type, - (long long)ktime_to_us(sc->sc_tv_func_start), - (long long)ktime_to_us(sc->sc_tv_func_stop)); -#endif + printk(KERN_NOTICE "o2net: Connection to " SC_NODEF_FMT " has been " + "idle for %lu.%lu secs, shutting it down.\n", SC_NODEF_ARGS(sc), + msecs / 1000, msecs % 1000); /* * Initialize the nn_timeout so that the next connection attempt @@ -1693,8 +1681,8 @@ static void o2net_start_connect(struct work_struct *work) out: if (ret) { - mlog(ML_NOTICE, "connect attempt to " SC_NODEF_FMT " failed " - "with errno %d\n", SC_NODEF_ARGS(sc), ret); + printk(KERN_NOTICE "o2net: Connect attempt to " SC_NODEF_FMT + " failed with errno %d\n", SC_NODEF_ARGS(sc), ret); /* 0 err so that another will be queued and attempted * from set_nn_state */ if (sc) @@ -1717,8 +1705,8 @@ static void o2net_connect_expired(struct work_struct *work) spin_lock(&nn->nn_lock); if (!nn->nn_sc_valid) { - mlog(ML_ERROR, "no connection established with node %u after " - "%u.%u seconds, giving up and returning errors.\n", + printk(KERN_NOTICE "o2net: No connection established with " + "node %u after %u.%u seconds, giving up.\n", o2net_num_from_nn(nn), o2net_idle_timeout() / 1000, o2net_idle_timeout() % 1000); @@ -1861,21 +1849,21 @@ static int o2net_accept_one(struct socket *sock) node = o2nm_get_node_by_ip(sin.sin_addr.s_addr); if (node == NULL) { - mlog(ML_NOTICE, "attempt to connect from unknown node at %pI4:%d\n", - &sin.sin_addr.s_addr, ntohs(sin.sin_port)); + printk(KERN_NOTICE "o2net: Attempt to connect from unknown " + "node at %pI4:%d\n", &sin.sin_addr.s_addr, + ntohs(sin.sin_port)); ret = -EINVAL; goto out; } if (o2nm_this_node() >= node->nd_num) { local_node = o2nm_get_node_by_num(o2nm_this_node()); - mlog(ML_NOTICE, "unexpected connect attempt seen at node '%s' (" - "%u, %pI4:%d) from node '%s' (%u, %pI4:%d)\n", - local_node->nd_name, local_node->nd_num, - &(local_node->nd_ipv4_address), - ntohs(local_node->nd_ipv4_port), - node->nd_name, node->nd_num, &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); + printk(KERN_NOTICE "o2net: Unexpected connect attempt seen " + "at node '%s' (%u, %pI4:%d) from node '%s' (%u, " + "%pI4:%d)\n", local_node->nd_name, local_node->nd_num, + &(local_node->nd_ipv4_address), + ntohs(local_node->nd_ipv4_port), node->nd_name, + node->nd_num, &sin.sin_addr.s_addr, ntohs(sin.sin_port)); ret = -EINVAL; goto out; } @@ -1900,10 +1888,10 @@ static int o2net_accept_one(struct socket *sock) ret = 0; spin_unlock(&nn->nn_lock); if (ret) { - mlog(ML_NOTICE, "attempt to connect from node '%s' at " - "%pI4:%d but it already has an open connection\n", - node->nd_name, &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); + printk(KERN_NOTICE "o2net: Attempt to connect from node '%s' " + "at %pI4:%d but it already has an open connection\n", + node->nd_name, &sin.sin_addr.s_addr, + ntohs(sin.sin_port)); goto out; } @@ -1983,7 +1971,7 @@ static int o2net_open_listening_sock(__be32 addr, __be16 port) ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); if (ret < 0) { - mlog(ML_ERROR, "unable to create socket, ret=%d\n", ret); + printk(KERN_ERR "o2net: Error %d while creating socket\n", ret); goto out; } @@ -2000,16 +1988,15 @@ static int o2net_open_listening_sock(__be32 addr, __be16 port) sock->sk->sk_reuse = 1; ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); if (ret < 0) { - mlog(ML_ERROR, "unable to bind socket at %pI4:%u, " - "ret=%d\n", &addr, ntohs(port), ret); + printk(KERN_ERR "o2net: Error %d while binding socket at " + "%pI4:%u\n", ret, &addr, ntohs(port)); goto out; } ret = sock->ops->listen(sock, 64); - if (ret < 0) { - mlog(ML_ERROR, "unable to listen on %pI4:%u, ret=%d\n", - &addr, ntohs(port), ret); - } + if (ret < 0) + printk(KERN_ERR "o2net: Error %d while listening on %pI4:%u\n", + ret, &addr, ntohs(port)); out: if (ret) { -- cgit v0.10.2 From 8decab3c8dadcdf4f54ffb30df6e6f67b398b6e0 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:23:54 -0700 Subject: ocfs2/dlm: Clean up messages in o2dlm o2dlm messages needed a facelift. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 6ed6b95..ce225fb 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -539,17 +539,17 @@ again: static void __dlm_print_nodes(struct dlm_ctxt *dlm) { - int node = -1; + int node = -1, num = 0; assert_spin_locked(&dlm->spinlock); - printk(KERN_NOTICE "o2dlm: Nodes in domain %s: ", dlm->name); - + printk("( "); while ((node = find_next_bit(dlm->domain_map, O2NM_MAX_NODES, node + 1)) < O2NM_MAX_NODES) { printk("%d ", node); + ++num; } - printk("\n"); + printk(") %u nodes\n", num); } static int dlm_exit_domain_handler(struct o2net_msg *msg, u32 len, void *data, @@ -566,11 +566,10 @@ static int dlm_exit_domain_handler(struct o2net_msg *msg, u32 len, void *data, node = exit_msg->node_idx; - printk(KERN_NOTICE "o2dlm: Node %u leaves domain %s\n", node, dlm->name); - spin_lock(&dlm->spinlock); clear_bit(node, dlm->domain_map); clear_bit(node, dlm->exit_domain_map); + printk(KERN_NOTICE "o2dlm: Node %u leaves domain %s ", node, dlm->name); __dlm_print_nodes(dlm); /* notify anything attached to the heartbeat events */ @@ -755,6 +754,7 @@ void dlm_unregister_domain(struct dlm_ctxt *dlm) dlm_mark_domain_leaving(dlm); dlm_leave_domain(dlm); + printk(KERN_NOTICE "o2dlm: Leaving domain %s\n", dlm->name); dlm_force_free_mles(dlm); dlm_complete_dlm_shutdown(dlm); } @@ -970,7 +970,7 @@ static int dlm_assert_joined_handler(struct o2net_msg *msg, u32 len, void *data, clear_bit(assert->node_idx, dlm->exit_domain_map); __dlm_set_joining_node(dlm, DLM_LOCK_RES_OWNER_UNKNOWN); - printk(KERN_NOTICE "o2dlm: Node %u joins domain %s\n", + printk(KERN_NOTICE "o2dlm: Node %u joins domain %s ", assert->node_idx, dlm->name); __dlm_print_nodes(dlm); @@ -1701,8 +1701,10 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) bail: spin_lock(&dlm->spinlock); __dlm_set_joining_node(dlm, DLM_LOCK_RES_OWNER_UNKNOWN); - if (!status) + if (!status) { + printk(KERN_NOTICE "o2dlm: Joining domain %s ", dlm->name); __dlm_print_nodes(dlm); + } spin_unlock(&dlm->spinlock); if (ctxt) { diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index 8d39e0fd6..c7f3e22 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c @@ -319,27 +319,23 @@ static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm, tmpret = o2net_send_message(DLM_CREATE_LOCK_MSG, dlm->key, &create, sizeof(create), res->owner, &status); if (tmpret >= 0) { - // successfully sent and received - ret = status; // this is already a dlm_status + ret = status; if (ret == DLM_REJECTED) { - mlog(ML_ERROR, "%s:%.*s: BUG. this is a stale lockres " - "no longer owned by %u. that node is coming back " - "up currently.\n", dlm->name, create.namelen, + mlog(ML_ERROR, "%s: res %.*s, Stale lockres no longer " + "owned by node %u. That node is coming back up " + "currently.\n", dlm->name, create.namelen, create.name, res->owner); dlm_print_one_lock_resource(res); BUG(); } } else { - mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to " - "node %u\n", tmpret, DLM_CREATE_LOCK_MSG, dlm->key, - res->owner); - if (dlm_is_host_down(tmpret)) { + mlog(ML_ERROR, "%s: res %.*s, Error %d send CREATE LOCK to " + "node %u\n", dlm->name, create.namelen, create.name, + tmpret, res->owner); + if (dlm_is_host_down(tmpret)) ret = DLM_RECOVERING; - mlog(0, "node %u died so returning DLM_RECOVERING " - "from lock message!\n", res->owner); - } else { + else ret = dlm_err_to_dlm_status(tmpret); - } } return ret; diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 11eefb8..9f3b093 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -829,8 +829,8 @@ lookup: * but they might own this lockres. wait on them. */ bit = find_next_bit(dlm->recovery_map, O2NM_MAX_NODES, 0); if (bit < O2NM_MAX_NODES) { - mlog(ML_NOTICE, "%s:%.*s: at least one node (%d) to " - "recover before lock mastery can begin\n", + mlog(0, "%s: res %.*s, At least one node (%d) " + "to recover before lock mastery can begin\n", dlm->name, namelen, (char *)lockid, bit); wait_on_recovery = 1; } @@ -864,8 +864,8 @@ redo_request: * dlm spinlock would be detectable be a change on the mle, * so we only need to clear out the recovery map once. */ if (dlm_is_recovery_lock(lockid, namelen)) { - mlog(ML_NOTICE, "%s: recovery map is not empty, but " - "must master $RECOVERY lock now\n", dlm->name); + mlog(0, "%s: Recovery map is not empty, but must " + "master $RECOVERY lock now\n", dlm->name); if (!dlm_pre_master_reco_lockres(dlm, res)) wait_on_recovery = 0; else { @@ -883,8 +883,8 @@ redo_request: spin_lock(&dlm->spinlock); bit = find_next_bit(dlm->recovery_map, O2NM_MAX_NODES, 0); if (bit < O2NM_MAX_NODES) { - mlog(ML_NOTICE, "%s:%.*s: at least one node (%d) to " - "recover before lock mastery can begin\n", + mlog(0, "%s: res %.*s, At least one node (%d) " + "to recover before lock mastery can begin\n", dlm->name, namelen, (char *)lockid, bit); wait_on_recovery = 1; } else @@ -913,8 +913,8 @@ redo_request: * yet, keep going until it does. this is how the * master will know that asserts are needed back to * the lower nodes. */ - mlog(0, "%s:%.*s: requests only up to %u but master " - "is %u, keep going\n", dlm->name, namelen, + mlog(0, "%s: res %.*s, Requests only up to %u but " + "master is %u, keep going\n", dlm->name, namelen, lockid, nodenum, mle->master); } } @@ -924,13 +924,12 @@ wait: ret = dlm_wait_for_lock_mastery(dlm, res, mle, &blocked); if (ret < 0) { wait_on_recovery = 1; - mlog(0, "%s:%.*s: node map changed, redo the " - "master request now, blocked=%d\n", - dlm->name, res->lockname.len, + mlog(0, "%s: res %.*s, Node map changed, redo the master " + "request now, blocked=%d\n", dlm->name, res->lockname.len, res->lockname.name, blocked); if (++tries > 20) { - mlog(ML_ERROR, "%s:%.*s: spinning on " - "dlm_wait_for_lock_mastery, blocked=%d\n", + mlog(ML_ERROR, "%s: res %.*s, Spinning on " + "dlm_wait_for_lock_mastery, blocked = %d\n", dlm->name, res->lockname.len, res->lockname.name, blocked); dlm_print_one_lock_resource(res); @@ -940,7 +939,8 @@ wait: goto redo_request; } - mlog(0, "lockres mastered by %u\n", res->owner); + mlog(0, "%s: res %.*s, Mastered by %u\n", dlm->name, res->lockname.len, + res->lockname.name, res->owner); /* make sure we never continue without this */ BUG_ON(res->owner == O2NM_MAX_NODES); @@ -2187,8 +2187,6 @@ int dlm_drop_lockres_ref(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) namelen = res->lockname.len; BUG_ON(namelen > O2NM_MAX_NAME_LEN); - mlog(0, "%s:%.*s: sending deref to %d\n", - dlm->name, namelen, lockname, res->owner); memset(&deref, 0, sizeof(deref)); deref.node_idx = dlm->node_num; deref.namelen = namelen; @@ -2197,14 +2195,12 @@ int dlm_drop_lockres_ref(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) ret = o2net_send_message(DLM_DEREF_LOCKRES_MSG, dlm->key, &deref, sizeof(deref), res->owner, &r); if (ret < 0) - mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to " - "node %u\n", ret, DLM_DEREF_LOCKRES_MSG, dlm->key, - res->owner); + mlog(ML_ERROR, "%s: res %.*s, error %d send DEREF to node %u\n", + dlm->name, namelen, lockname, ret, res->owner); else if (r < 0) { /* BAD. other node says I did not have a ref. */ - mlog(ML_ERROR,"while dropping ref on %s:%.*s " - "(master=%u) got %d.\n", dlm->name, namelen, - lockname, res->owner, r); + mlog(ML_ERROR, "%s: res %.*s, DEREF to node %u got %d\n", + dlm->name, namelen, lockname, res->owner, r); dlm_print_one_lock_resource(res); BUG(); } @@ -2916,9 +2912,9 @@ static int dlm_do_migrate_request(struct dlm_ctxt *dlm, &migrate, sizeof(migrate), nodenum, &status); if (ret < 0) { - mlog(ML_ERROR, "Error %d when sending message %u (key " - "0x%x) to node %u\n", ret, DLM_MIGRATE_REQUEST_MSG, - dlm->key, nodenum); + mlog(ML_ERROR, "%s: res %.*s, Error %d send " + "MIGRATE_REQUEST to node %u\n", dlm->name, + migrate.namelen, migrate.name, ret, nodenum); if (!dlm_is_host_down(ret)) { mlog(ML_ERROR, "unhandled error=%d!\n", ret); BUG(); diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 7efab6d..a3c312c 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -430,6 +430,8 @@ static void dlm_begin_recovery(struct dlm_ctxt *dlm) { spin_lock(&dlm->spinlock); BUG_ON(dlm->reco.state & DLM_RECO_STATE_ACTIVE); + printk(KERN_NOTICE "o2dlm: Begin recovery on domain %s for node %u\n", + dlm->name, dlm->reco.dead_node); dlm->reco.state |= DLM_RECO_STATE_ACTIVE; spin_unlock(&dlm->spinlock); } @@ -440,9 +442,18 @@ static void dlm_end_recovery(struct dlm_ctxt *dlm) BUG_ON(!(dlm->reco.state & DLM_RECO_STATE_ACTIVE)); dlm->reco.state &= ~DLM_RECO_STATE_ACTIVE; spin_unlock(&dlm->spinlock); + printk(KERN_NOTICE "o2dlm: End recovery on domain %s\n", dlm->name); wake_up(&dlm->reco.event); } +static void dlm_print_recovery_master(struct dlm_ctxt *dlm) +{ + printk(KERN_NOTICE "o2dlm: Node %u (%s) is the Recovery Master for the " + "dead node %u in domain %s\n", dlm->reco.new_master, + (dlm->node_num == dlm->reco.new_master ? "me" : "he"), + dlm->reco.dead_node, dlm->name); +} + static int dlm_do_recovery(struct dlm_ctxt *dlm) { int status = 0; @@ -505,9 +516,8 @@ static int dlm_do_recovery(struct dlm_ctxt *dlm) } mlog(0, "another node will master this recovery session.\n"); } - mlog(0, "dlm=%s (%d), new_master=%u, this node=%u, dead_node=%u\n", - dlm->name, task_pid_nr(dlm->dlm_reco_thread_task), dlm->reco.new_master, - dlm->node_num, dlm->reco.dead_node); + + dlm_print_recovery_master(dlm); /* it is safe to start everything back up here * because all of the dead node's lock resources @@ -518,15 +528,13 @@ static int dlm_do_recovery(struct dlm_ctxt *dlm) return 0; master_here: - mlog(ML_NOTICE, "(%d) Node %u is the Recovery Master for the Dead Node " - "%u for Domain %s\n", task_pid_nr(dlm->dlm_reco_thread_task), - dlm->node_num, dlm->reco.dead_node, dlm->name); + dlm_print_recovery_master(dlm); status = dlm_remaster_locks(dlm, dlm->reco.dead_node); if (status < 0) { /* we should never hit this anymore */ - mlog(ML_ERROR, "error %d remastering locks for node %u, " - "retrying.\n", status, dlm->reco.dead_node); + mlog(ML_ERROR, "%s: Error %d remastering locks for node %u, " + "retrying.\n", dlm->name, status, dlm->reco.dead_node); /* yield a bit to allow any final network messages * to get handled on remaining nodes */ msleep(100); @@ -567,7 +575,7 @@ static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node) BUG_ON(ndata->state != DLM_RECO_NODE_DATA_INIT); ndata->state = DLM_RECO_NODE_DATA_REQUESTING; - mlog(0, "requesting lock info from node %u\n", + mlog(0, "%s: Requesting lock info from node %u\n", dlm->name, ndata->node_num); if (ndata->node_num == dlm->node_num) { @@ -640,7 +648,7 @@ static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node) spin_unlock(&dlm_reco_state_lock); } - mlog(0, "done requesting all lock info\n"); + mlog(0, "%s: Done requesting all lock info\n", dlm->name); /* nodes should be sending reco data now * just need to wait */ @@ -802,10 +810,9 @@ static int dlm_request_all_locks(struct dlm_ctxt *dlm, u8 request_from, /* negative status is handled by caller */ if (ret < 0) - mlog(ML_ERROR, "Error %d when sending message %u (key " - "0x%x) to node %u\n", ret, DLM_LOCK_REQUEST_MSG, - dlm->key, request_from); - + mlog(ML_ERROR, "%s: Error %d send LOCK_REQUEST to node %u " + "to recover dead node %u\n", dlm->name, ret, + request_from, dead_node); // return from here, then // sleep until all received or error return ret; @@ -956,9 +963,9 @@ static int dlm_send_all_done_msg(struct dlm_ctxt *dlm, u8 dead_node, u8 send_to) ret = o2net_send_message(DLM_RECO_DATA_DONE_MSG, dlm->key, &done_msg, sizeof(done_msg), send_to, &tmpret); if (ret < 0) { - mlog(ML_ERROR, "Error %d when sending message %u (key " - "0x%x) to node %u\n", ret, DLM_RECO_DATA_DONE_MSG, - dlm->key, send_to); + mlog(ML_ERROR, "%s: Error %d send RECO_DATA_DONE to node %u " + "to recover dead node %u\n", dlm->name, ret, send_to, + dead_node); if (!dlm_is_host_down(ret)) { BUG(); } @@ -1127,9 +1134,11 @@ static int dlm_send_mig_lockres_msg(struct dlm_ctxt *dlm, if (ret < 0) { /* XXX: negative status is not handled. * this will end up killing this node. */ - mlog(ML_ERROR, "Error %d when sending message %u (key " - "0x%x) to node %u\n", ret, DLM_MIG_LOCKRES_MSG, - dlm->key, send_to); + mlog(ML_ERROR, "%s: res %.*s, Error %d send MIG_LOCKRES to " + "node %u (%s)\n", dlm->name, mres->lockname_len, + mres->lockname, ret, send_to, + (orig_flags & DLM_MRES_MIGRATION ? + "migration" : "recovery")); } else { /* might get an -ENOMEM back here */ ret = status; @@ -2324,9 +2333,9 @@ static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node) dlm_revalidate_lvb(dlm, res, dead_node); if (res->owner == dead_node) { if (res->state & DLM_LOCK_RES_DROPPING_REF) { - mlog(ML_NOTICE, "Ignore %.*s for " + mlog(ML_NOTICE, "%s: res %.*s, Skip " "recovery as it is being freed\n", - res->lockname.len, + dlm->name, res->lockname.len, res->lockname.name); } else dlm_move_lockres_to_recovery_list(dlm, diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c index 1d6d1d2..46faac2 100644 --- a/fs/ocfs2/dlm/dlmthread.c +++ b/fs/ocfs2/dlm/dlmthread.c @@ -185,8 +185,6 @@ static void dlm_purge_lockres(struct dlm_ctxt *dlm, /* clear our bit from the master's refmap, ignore errors */ ret = dlm_drop_lockres_ref(dlm, res); if (ret < 0) { - mlog(ML_ERROR, "%s: deref %.*s failed %d\n", dlm->name, - res->lockname.len, res->lockname.name, ret); if (!dlm_is_host_down(ret)) BUG(); } -- cgit v0.10.2 From 394eb3d38a3ecc549cc34a3040103a9164be516b Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:24:54 -0700 Subject: ocfs2: Clean up messages in stack_o2cb.c o2cb messages needed a facelift. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index 19965b0..be935d8 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c @@ -263,8 +263,8 @@ static void o2dlm_eviction_cb(int node_num, void *data) { struct ocfs2_cluster_connection *conn = data; - mlog(ML_NOTICE, "o2dlm has evicted node %d from group %.*s\n", - node_num, conn->cc_namelen, conn->cc_name); + printk(KERN_NOTICE "o2cb: o2dlm has evicted node %d from domain %.*s\n", + node_num, conn->cc_namelen, conn->cc_name); conn->cc_recovery_handler(node_num, conn->cc_recovery_data); } -- cgit v0.10.2 From 0afbba13226fcdbd4327f6b13a42f6efbb8c9caf Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:25:54 -0700 Subject: ocfs2/dlm: Cleanup up dlm_finish_local_lockres_recovery() dlm_finish_local_lockres_recovery() needed a facelift. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index a3c312c..41e74f0 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -2093,6 +2093,9 @@ static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm, list_for_each_entry_safe(res, next, &dlm->reco.resources, recovering) { if (res->owner == dead_node) { + mlog(0, "%s: res %.*s, Changing owner from %u to %u\n", + dlm->name, res->lockname.len, res->lockname.name, + res->owner, new_master); list_del_init(&res->recovering); spin_lock(&res->spinlock); /* new_master has our reference from @@ -2114,40 +2117,30 @@ static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm, for (i = 0; i < DLM_HASH_BUCKETS; i++) { bucket = dlm_lockres_hash(dlm, i); hlist_for_each_entry(res, hash_iter, bucket, hash_node) { - if (res->state & DLM_LOCK_RES_RECOVERING) { - if (res->owner == dead_node) { - mlog(0, "(this=%u) res %.*s owner=%u " - "was not on recovering list, but " - "clearing state anyway\n", - dlm->node_num, res->lockname.len, - res->lockname.name, new_master); - } else if (res->owner == dlm->node_num) { - mlog(0, "(this=%u) res %.*s owner=%u " - "was not on recovering list, " - "owner is THIS node, clearing\n", - dlm->node_num, res->lockname.len, - res->lockname.name, new_master); - } else - continue; + if (!(res->state & DLM_LOCK_RES_RECOVERING)) + continue; - if (!list_empty(&res->recovering)) { - mlog(0, "%s:%.*s: lockres was " - "marked RECOVERING, owner=%u\n", - dlm->name, res->lockname.len, - res->lockname.name, res->owner); - list_del_init(&res->recovering); - dlm_lockres_put(res); - } - spin_lock(&res->spinlock); - /* new_master has our reference from - * the lock state sent during recovery */ - dlm_change_lockres_owner(dlm, res, new_master); - res->state &= ~DLM_LOCK_RES_RECOVERING; - if (__dlm_lockres_has_locks(res)) - __dlm_dirty_lockres(dlm, res); - spin_unlock(&res->spinlock); - wake_up(&res->wq); + if (res->owner != dead_node && + res->owner != dlm->node_num) + continue; + + if (!list_empty(&res->recovering)) { + list_del_init(&res->recovering); + dlm_lockres_put(res); } + + /* new_master has our reference from + * the lock state sent during recovery */ + mlog(0, "%s: res %.*s, Changing owner from %u to %u\n", + dlm->name, res->lockname.len, res->lockname.name, + res->owner, new_master); + spin_lock(&res->spinlock); + dlm_change_lockres_owner(dlm, res, new_master); + res->state &= ~DLM_LOCK_RES_RECOVERING; + if (__dlm_lockres_has_locks(res)) + __dlm_dirty_lockres(dlm, res); + spin_unlock(&res->spinlock); + wake_up(&res->wq); } } } -- cgit v0.10.2 From 8d400b81cc83b171ff872587723a37eb7fae9abe Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:26:54 -0700 Subject: ocfs2/dlm: Clean up refmap helpers Patch cleans up helpers that set/clear refmap bits and grab/drop inflight lock ref counts. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index d602abb..4a5d580 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h @@ -902,46 +902,15 @@ struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm, const char *name, unsigned int namelen); -#define dlm_lockres_set_refmap_bit(bit,res) \ - __dlm_lockres_set_refmap_bit(bit,res,__FILE__,__LINE__) -#define dlm_lockres_clear_refmap_bit(bit,res) \ - __dlm_lockres_clear_refmap_bit(bit,res,__FILE__,__LINE__) - -static inline void __dlm_lockres_set_refmap_bit(int bit, - struct dlm_lock_resource *res, - const char *file, - int line) -{ - //printk("%s:%d:%.*s: setting bit %d\n", file, line, - // res->lockname.len, res->lockname.name, bit); - set_bit(bit, res->refmap); -} - -static inline void __dlm_lockres_clear_refmap_bit(int bit, - struct dlm_lock_resource *res, - const char *file, - int line) -{ - //printk("%s:%d:%.*s: clearing bit %d\n", file, line, - // res->lockname.len, res->lockname.name, bit); - clear_bit(bit, res->refmap); -} - -void __dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, - struct dlm_lock_resource *res, - const char *file, - int line); -void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, - struct dlm_lock_resource *res, - int new_lockres, - const char *file, - int line); -#define dlm_lockres_drop_inflight_ref(d,r) \ - __dlm_lockres_drop_inflight_ref(d,r,__FILE__,__LINE__) -#define dlm_lockres_grab_inflight_ref(d,r) \ - __dlm_lockres_grab_inflight_ref(d,r,0,__FILE__,__LINE__) -#define dlm_lockres_grab_inflight_ref_new(d,r) \ - __dlm_lockres_grab_inflight_ref(d,r,1,__FILE__,__LINE__) +void dlm_lockres_set_refmap_bit(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, int bit); +void dlm_lockres_clear_refmap_bit(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, int bit); + +void dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); +void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock); void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock); diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 9f3b093..11e446ff 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -631,39 +631,58 @@ error: return NULL; } -void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, - struct dlm_lock_resource *res, - int new_lockres, - const char *file, - int line) +void dlm_lockres_set_refmap_bit(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, int bit) { - if (!new_lockres) - assert_spin_locked(&res->spinlock); + assert_spin_locked(&res->spinlock); + + mlog(0, "res %.*s, set node %u, %ps()\n", res->lockname.len, + res->lockname.name, bit, __builtin_return_address(0)); + + set_bit(bit, res->refmap); +} + +void dlm_lockres_clear_refmap_bit(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, int bit) +{ + assert_spin_locked(&res->spinlock); + + mlog(0, "res %.*s, clr node %u, %ps()\n", res->lockname.len, + res->lockname.name, bit, __builtin_return_address(0)); + + clear_bit(bit, res->refmap); +} + + +void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + assert_spin_locked(&res->spinlock); if (!test_bit(dlm->node_num, res->refmap)) { BUG_ON(res->inflight_locks != 0); - dlm_lockres_set_refmap_bit(dlm->node_num, res); + dlm_lockres_set_refmap_bit(dlm, res, dlm->node_num); } res->inflight_locks++; - mlog(0, "%s:%.*s: inflight++: now %u\n", - dlm->name, res->lockname.len, res->lockname.name, - res->inflight_locks); + mlog(0, "%s: res %.*s, inflight++: now %u, %ps()\n", dlm->name, + res->lockname.len, res->lockname.name, res->inflight_locks, + __builtin_return_address(0)); } -void __dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, - struct dlm_lock_resource *res, - const char *file, - int line) +void dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) { assert_spin_locked(&res->spinlock); BUG_ON(res->inflight_locks == 0); + res->inflight_locks--; - mlog(0, "%s:%.*s: inflight--: now %u\n", - dlm->name, res->lockname.len, res->lockname.name, - res->inflight_locks); + mlog(0, "%s: res %.*s, inflight--: now %u, %ps()\n", dlm->name, + res->lockname.len, res->lockname.name, res->inflight_locks, + __builtin_return_address(0)); + if (res->inflight_locks == 0) - dlm_lockres_clear_refmap_bit(dlm->node_num, res); + dlm_lockres_clear_refmap_bit(dlm, res, dlm->node_num); wake_up(&res->wq); } @@ -843,8 +862,10 @@ lookup: /* finally add the lockres to its hash bucket */ __dlm_insert_lockres(dlm, res); - /* since this lockres is new it doesn't not require the spinlock */ - dlm_lockres_grab_inflight_ref_new(dlm, res); + + spin_lock(&res->spinlock); + dlm_lockres_grab_inflight_ref(dlm, res); + spin_unlock(&res->spinlock); /* if this node does not become the master make sure to drop * this inflight reference below */ @@ -1426,9 +1447,7 @@ way_up_top: } if (res->owner == dlm->node_num) { - mlog(0, "%s:%.*s: setting bit %u in refmap\n", - dlm->name, namelen, name, request->node_idx); - dlm_lockres_set_refmap_bit(request->node_idx, res); + dlm_lockres_set_refmap_bit(dlm, res, request->node_idx); spin_unlock(&res->spinlock); response = DLM_MASTER_RESP_YES; if (mle) @@ -1493,10 +1512,8 @@ way_up_top: * go back and clean the mles on any * other nodes */ dispatch_assert = 1; - dlm_lockres_set_refmap_bit(request->node_idx, res); - mlog(0, "%s:%.*s: setting bit %u in refmap\n", - dlm->name, namelen, name, - request->node_idx); + dlm_lockres_set_refmap_bit(dlm, res, + request->node_idx); } else response = DLM_MASTER_RESP_NO; } else { @@ -1702,7 +1719,7 @@ again: "lockres, set the bit in the refmap\n", namelen, lockname, to); spin_lock(&res->spinlock); - dlm_lockres_set_refmap_bit(to, res); + dlm_lockres_set_refmap_bit(dlm, res, to); spin_unlock(&res->spinlock); } } @@ -2256,7 +2273,7 @@ int dlm_deref_lockres_handler(struct o2net_msg *msg, u32 len, void *data, else { BUG_ON(res->state & DLM_LOCK_RES_DROPPING_REF); if (test_bit(node, res->refmap)) { - dlm_lockres_clear_refmap_bit(node, res); + dlm_lockres_clear_refmap_bit(dlm, res, node); cleared = 1; } } @@ -2316,7 +2333,7 @@ static void dlm_deref_lockres_worker(struct dlm_work_item *item, void *data) BUG_ON(res->state & DLM_LOCK_RES_DROPPING_REF); if (test_bit(node, res->refmap)) { __dlm_wait_on_lockres_flags(res, DLM_LOCK_RES_SETREF_INPROG); - dlm_lockres_clear_refmap_bit(node, res); + dlm_lockres_clear_refmap_bit(dlm, res, node); cleared = 1; } spin_unlock(&res->spinlock); @@ -2798,7 +2815,8 @@ static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm, BUG_ON(!list_empty(&lock->bast_list)); BUG_ON(lock->ast_pending); BUG_ON(lock->bast_pending); - dlm_lockres_clear_refmap_bit(lock->ml.node, res); + dlm_lockres_clear_refmap_bit(dlm, res, + lock->ml.node); list_del_init(&lock->list); dlm_lock_put(lock); /* In a normal unlock, we would have added a @@ -2819,7 +2837,7 @@ static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm, mlog(0, "%s:%.*s: node %u had a ref to this " "migrating lockres, clearing\n", dlm->name, res->lockname.len, res->lockname.name, bit); - dlm_lockres_clear_refmap_bit(bit, res); + dlm_lockres_clear_refmap_bit(dlm, res, bit); } bit++; } @@ -2933,7 +2951,7 @@ static int dlm_do_migrate_request(struct dlm_ctxt *dlm, dlm->name, res->lockname.len, res->lockname.name, nodenum); spin_lock(&res->spinlock); - dlm_lockres_set_refmap_bit(nodenum, res); + dlm_lockres_set_refmap_bit(dlm, res, nodenum); spin_unlock(&res->spinlock); } } @@ -3267,7 +3285,7 @@ int dlm_finish_migration(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, * mastery reference here since old_master will briefly have * a reference after the migration completes */ spin_lock(&res->spinlock); - dlm_lockres_set_refmap_bit(old_master, res); + dlm_lockres_set_refmap_bit(dlm, res, old_master); spin_unlock(&res->spinlock); mlog(0, "now time to do a migrate request to other nodes\n"); diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 41e74f0..f1a3aa8 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -1776,7 +1776,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, dlm->name, mres->lockname_len, mres->lockname, from); spin_lock(&res->spinlock); - dlm_lockres_set_refmap_bit(from, res); + dlm_lockres_set_refmap_bit(dlm, res, from); spin_unlock(&res->spinlock); added++; break; @@ -1974,7 +1974,7 @@ skip_lvb: mlog(0, "%s:%.*s: added lock for node %u, " "setting refmap bit\n", dlm->name, res->lockname.len, res->lockname.name, ml->node); - dlm_lockres_set_refmap_bit(ml->node, res); + dlm_lockres_set_refmap_bit(dlm, res, ml->node); added++; } spin_unlock(&res->spinlock); @@ -2254,12 +2254,12 @@ static void dlm_free_dead_locks(struct dlm_ctxt *dlm, res->lockname.len, res->lockname.name, freed, dead_node); __dlm_print_one_lock_resource(res); } - dlm_lockres_clear_refmap_bit(dead_node, res); + dlm_lockres_clear_refmap_bit(dlm, res, dead_node); } else if (test_bit(dead_node, res->refmap)) { mlog(0, "%s:%.*s: dead node %u had a ref, but had " "no locks and had not purged before dying\n", dlm->name, res->lockname.len, res->lockname.name, dead_node); - dlm_lockres_clear_refmap_bit(dead_node, res); + dlm_lockres_clear_refmap_bit(dlm, res, dead_node); } /* do not kick thread yet */ -- cgit v0.10.2 From e9f0b6a6233105c188064328c3f15e21942d0241 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:27:54 -0700 Subject: ocfs2/dlm: Trace insert/remove of resource to/from hash Add mlog to trace adding and removing the resource from/to the hash table. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index 4a5d580..b1748ac 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h @@ -877,9 +877,8 @@ static inline void dlm_lockres_get(struct dlm_lock_resource *res) kref_get(&res->refs); } void dlm_lockres_put(struct dlm_lock_resource *res); -void __dlm_unhash_lockres(struct dlm_lock_resource *res); -void __dlm_insert_lockres(struct dlm_ctxt *dlm, - struct dlm_lock_resource *res); +void __dlm_unhash_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res); +void __dlm_insert_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res); struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm, const char *name, unsigned int len, diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index ce225fb..200d988 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -157,16 +157,18 @@ static int dlm_protocol_compare(struct dlm_protocol_version *existing, static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm); -void __dlm_unhash_lockres(struct dlm_lock_resource *lockres) +void __dlm_unhash_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { - if (!hlist_unhashed(&lockres->hash_node)) { - hlist_del_init(&lockres->hash_node); - dlm_lockres_put(lockres); - } + if (hlist_unhashed(&res->hash_node)) + return; + + mlog(0, "%s: Unhash res %.*s\n", dlm->name, res->lockname.len, + res->lockname.name); + hlist_del_init(&res->hash_node); + dlm_lockres_put(res); } -void __dlm_insert_lockres(struct dlm_ctxt *dlm, - struct dlm_lock_resource *res) +void __dlm_insert_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) { struct hlist_head *bucket; struct qstr *q; @@ -180,6 +182,9 @@ void __dlm_insert_lockres(struct dlm_ctxt *dlm, dlm_lockres_get(res); hlist_add_head(&res->hash_node, bucket); + + mlog(0, "%s: Hash res %.*s\n", dlm->name, res->lockname.len, + res->lockname.name); } struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm, diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c index 46faac2..4eff65e 100644 --- a/fs/ocfs2/dlm/dlmthread.c +++ b/fs/ocfs2/dlm/dlmthread.c @@ -207,7 +207,7 @@ static void dlm_purge_lockres(struct dlm_ctxt *dlm, BUG(); } - __dlm_unhash_lockres(res); + __dlm_unhash_lockres(dlm, res); /* lockres is not in the hash now. drop the flag and wake up * any processes waiting in dlm_get_lock_resource. */ -- cgit v0.10.2 From ed8625c6fb93d750ed022db571a8a7b7a6724b3b Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:28:54 -0700 Subject: ocfs2/dlm: Cleanup dlm_wait_for_node_death() and dlm_wait_for_node_recovery() dlm_wait_for_node_death() and dlm_wait_for_node_recovery() needed a facelift. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index b1748ac..a5952ce 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h @@ -859,8 +859,8 @@ void dlm_complete_recovery_thread(struct dlm_ctxt *dlm); void dlm_wait_for_recovery(struct dlm_ctxt *dlm); void dlm_kick_recovery_thread(struct dlm_ctxt *dlm); int dlm_is_node_dead(struct dlm_ctxt *dlm, u8 node); -int dlm_wait_for_node_death(struct dlm_ctxt *dlm, u8 node, int timeout); -int dlm_wait_for_node_recovery(struct dlm_ctxt *dlm, u8 node, int timeout); +void dlm_wait_for_node_death(struct dlm_ctxt *dlm, u8 node, int timeout); +void dlm_wait_for_node_recovery(struct dlm_ctxt *dlm, u8 node, int timeout); void dlm_put(struct dlm_ctxt *dlm); struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm); diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index f1a3aa8..01ebfd0 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -362,40 +362,38 @@ static int dlm_is_node_recovered(struct dlm_ctxt *dlm, u8 node) } -int dlm_wait_for_node_death(struct dlm_ctxt *dlm, u8 node, int timeout) +void dlm_wait_for_node_death(struct dlm_ctxt *dlm, u8 node, int timeout) { - if (timeout) { - mlog(ML_NOTICE, "%s: waiting %dms for notification of " - "death of node %u\n", dlm->name, timeout, node); + if (dlm_is_node_dead(dlm, node)) + return; + + printk(KERN_NOTICE "o2dlm: Waiting on the death of node %u in " + "domain %s\n", node, dlm->name); + + if (timeout) wait_event_timeout(dlm->dlm_reco_thread_wq, - dlm_is_node_dead(dlm, node), - msecs_to_jiffies(timeout)); - } else { - mlog(ML_NOTICE, "%s: waiting indefinitely for notification " - "of death of node %u\n", dlm->name, node); + dlm_is_node_dead(dlm, node), + msecs_to_jiffies(timeout)); + else wait_event(dlm->dlm_reco_thread_wq, dlm_is_node_dead(dlm, node)); - } - /* for now, return 0 */ - return 0; } -int dlm_wait_for_node_recovery(struct dlm_ctxt *dlm, u8 node, int timeout) +void dlm_wait_for_node_recovery(struct dlm_ctxt *dlm, u8 node, int timeout) { - if (timeout) { - mlog(0, "%s: waiting %dms for notification of " - "recovery of node %u\n", dlm->name, timeout, node); + if (dlm_is_node_recovered(dlm, node)) + return; + + printk(KERN_NOTICE "o2dlm: Waiting on the recovery of node %u in " + "domain %s\n", node, dlm->name); + + if (timeout) wait_event_timeout(dlm->dlm_reco_thread_wq, - dlm_is_node_recovered(dlm, node), - msecs_to_jiffies(timeout)); - } else { - mlog(0, "%s: waiting indefinitely for notification " - "of recovery of node %u\n", dlm->name, node); + dlm_is_node_recovered(dlm, node), + msecs_to_jiffies(timeout)); + else wait_event(dlm->dlm_reco_thread_wq, dlm_is_node_recovered(dlm, node)); - } - /* for now, return 0 */ - return 0; } /* callers of the top-level api calls (dlmlock/dlmunlock) should -- cgit v0.10.2 From ff0a522e7db79625aa27a433467eb94c5e255718 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:29:54 -0700 Subject: ocfs2/dlm: Take inflight reference count for remotely mastered resources too The inflight reference count, in the lock resource, is taken to pin the resource in memory. We take it when a new resource is created and release it after a lock is attached to it. We do this to prevent the resource from getting purged prematurely. Earlier this reference count was being taken for locally mastered resources only. This patch extends the same functionality for remotely mastered ones. We are doing this because the same premature purging could occur for remotely mastered resources if the remote node were to die before completion of the create lock. Fix for Oracle bug#12405575. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index c7f3e22..3ef2c1a 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c @@ -183,10 +183,6 @@ static enum dlm_status dlmlock_master(struct dlm_ctxt *dlm, kick_thread = 1; } } - /* reduce the inflight count, this may result in the lockres - * being purged below during calc_usage */ - if (lock->ml.node == dlm->node_num) - dlm_lockres_drop_inflight_ref(dlm, res); spin_unlock(&res->spinlock); wake_up(&res->wq); @@ -737,6 +733,14 @@ retry_lock: } } + /* Inflight taken in dlm_get_lock_resource() is dropped here */ + spin_lock(&res->spinlock); + dlm_lockres_drop_inflight_ref(dlm, res); + spin_unlock(&res->spinlock); + + dlm_lockres_calc_usage(dlm, res); + dlm_kick_thread(dlm, res); + if (status != DLM_NORMAL) { lock->lksb->flags &= ~DLM_LKSB_GET_LVB; if (status != DLM_NOTQUEUED) diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 11e446ff..005261c 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -659,11 +659,8 @@ void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, { assert_spin_locked(&res->spinlock); - if (!test_bit(dlm->node_num, res->refmap)) { - BUG_ON(res->inflight_locks != 0); - dlm_lockres_set_refmap_bit(dlm, res, dlm->node_num); - } res->inflight_locks++; + mlog(0, "%s: res %.*s, inflight++: now %u, %ps()\n", dlm->name, res->lockname.len, res->lockname.name, res->inflight_locks, __builtin_return_address(0)); @@ -677,12 +674,11 @@ void dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, BUG_ON(res->inflight_locks == 0); res->inflight_locks--; + mlog(0, "%s: res %.*s, inflight--: now %u, %ps()\n", dlm->name, res->lockname.len, res->lockname.name, res->inflight_locks, __builtin_return_address(0)); - if (res->inflight_locks == 0) - dlm_lockres_clear_refmap_bit(dlm, res, dlm->node_num); wake_up(&res->wq); } @@ -716,7 +712,6 @@ struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm, unsigned int hash; int tries = 0; int bit, wait_on_recovery = 0; - int drop_inflight_if_nonlocal = 0; BUG_ON(!lockid); @@ -728,36 +723,33 @@ lookup: spin_lock(&dlm->spinlock); tmpres = __dlm_lookup_lockres_full(dlm, lockid, namelen, hash); if (tmpres) { - int dropping_ref = 0; - spin_unlock(&dlm->spinlock); - spin_lock(&tmpres->spinlock); - /* We wait for the other thread that is mastering the resource */ + /* Wait on the thread that is mastering the resource */ if (tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN) { __dlm_wait_on_lockres(tmpres); BUG_ON(tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN); + spin_unlock(&tmpres->spinlock); + dlm_lockres_put(tmpres); + tmpres = NULL; + goto lookup; } - if (tmpres->owner == dlm->node_num) { - BUG_ON(tmpres->state & DLM_LOCK_RES_DROPPING_REF); - dlm_lockres_grab_inflight_ref(dlm, tmpres); - } else if (tmpres->state & DLM_LOCK_RES_DROPPING_REF) - dropping_ref = 1; - spin_unlock(&tmpres->spinlock); - - /* wait until done messaging the master, drop our ref to allow - * the lockres to be purged, start over. */ - if (dropping_ref) { - spin_lock(&tmpres->spinlock); - __dlm_wait_on_lockres_flags(tmpres, DLM_LOCK_RES_DROPPING_REF); + /* Wait on the resource purge to complete before continuing */ + if (tmpres->state & DLM_LOCK_RES_DROPPING_REF) { + BUG_ON(tmpres->owner == dlm->node_num); + __dlm_wait_on_lockres_flags(tmpres, + DLM_LOCK_RES_DROPPING_REF); spin_unlock(&tmpres->spinlock); dlm_lockres_put(tmpres); tmpres = NULL; goto lookup; } - mlog(0, "found in hash!\n"); + /* Grab inflight ref to pin the resource */ + dlm_lockres_grab_inflight_ref(dlm, tmpres); + + spin_unlock(&tmpres->spinlock); if (res) dlm_lockres_put(res); res = tmpres; @@ -863,14 +855,11 @@ lookup: /* finally add the lockres to its hash bucket */ __dlm_insert_lockres(dlm, res); + /* Grab inflight ref to pin the resource */ spin_lock(&res->spinlock); dlm_lockres_grab_inflight_ref(dlm, res); spin_unlock(&res->spinlock); - /* if this node does not become the master make sure to drop - * this inflight reference below */ - drop_inflight_if_nonlocal = 1; - /* get an extra ref on the mle in case this is a BLOCK * if so, the creator of the BLOCK may try to put the last * ref at this time in the assert master handler, so we @@ -973,8 +962,6 @@ wait: wake_waiters: spin_lock(&res->spinlock); - if (res->owner != dlm->node_num && drop_inflight_if_nonlocal) - dlm_lockres_drop_inflight_ref(dlm, res); res->state &= ~DLM_LOCK_RES_IN_PROGRESS; spin_unlock(&res->spinlock); wake_up(&res->wq); diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c index 4eff65e..e73c833 100644 --- a/fs/ocfs2/dlm/dlmthread.c +++ b/fs/ocfs2/dlm/dlmthread.c @@ -94,24 +94,26 @@ int __dlm_lockres_unused(struct dlm_lock_resource *res) { int bit; + assert_spin_locked(&res->spinlock); + if (__dlm_lockres_has_locks(res)) return 0; + /* Locks are in the process of being created */ + if (res->inflight_locks) + return 0; + if (!list_empty(&res->dirty) || res->state & DLM_LOCK_RES_DIRTY) return 0; if (res->state & DLM_LOCK_RES_RECOVERING) return 0; + /* Another node has this resource with this node as the master */ bit = find_next_bit(res->refmap, O2NM_MAX_NODES, 0); if (bit < O2NM_MAX_NODES) return 0; - /* - * since the bit for dlm->node_num is not set, inflight_locks better - * be zero - */ - BUG_ON(res->inflight_locks != 0); return 1; } -- cgit v0.10.2 From a2c0cc1579176bd0808ef7deea456767dfa80217 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:30:54 -0700 Subject: ocfs2/dlm: dlmlock_remote() needs to account for remastery In dlmlock_remote(), we wait for the resource to stop being active before setting the inprogress flag. Active includes recovery, migration, etc. The problem here is that if the resource was being recovered or migrated, the new owner could very well be that node itself (and thus not a remote node). This problem was observed in Oracle bug#12583620. The error messages observed were as follows: dlm_send_remote_lock_request:337 ERROR: Error -40 (ELOOP) when sending message 503 (key 0xd6d8c7) to node 2 dlmlock_remote:271 ERROR: dlm status = DLM_BADARGS dlmlock:751 ERROR: dlm status = DLM_BADARGS Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index 3ef2c1a..f32fcba 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c @@ -227,10 +227,16 @@ static enum dlm_status dlmlock_remote(struct dlm_ctxt *dlm, lock->ml.type, res->lockname.len, res->lockname.name, flags); + /* + * Wait if resource is getting recovered, remastered, etc. + * If the resource was remastered and new owner is self, then exit. + */ spin_lock(&res->spinlock); - - /* will exit this call with spinlock held */ __dlm_wait_on_lockres(res); + if (res->owner == dlm->node_num) { + spin_unlock(&res->spinlock); + return DLM_RECOVERING; + } res->state |= DLM_LOCK_RES_IN_PROGRESS; /* add lock to local (secondary) queue */ @@ -710,18 +716,10 @@ retry_lock: if (status == DLM_RECOVERING || status == DLM_MIGRATING || status == DLM_FORWARD) { - mlog(0, "retrying lock with migration/" - "recovery/in progress\n"); msleep(100); - /* no waiting for dlm_reco_thread */ if (recovery) { if (status != DLM_RECOVERING) goto retry_lock; - - mlog(0, "%s: got RECOVERING " - "for $RECOVERY lock, master " - "was %u\n", dlm->name, - res->owner); /* wait to see the node go down, then * drop down and allow the lockres to * get cleaned up. need to remaster. */ -- cgit v0.10.2 From bb570a5d9e74f71d32751823052db4a97d6a5e7c Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:31:54 -0700 Subject: ocfs2/cluster: Fix output in file elapsed_time_in_ms The o2hb debugfs file, elapsed_time_in_ms, should return values only after the timer is armed atleast once. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 4728a74..a4e855e 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1198,6 +1198,7 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) struct o2hb_debug_buf *db = inode->i_private; struct o2hb_region *reg; unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long lts; char *buf = NULL; int i = -1; int out = 0; @@ -1234,9 +1235,11 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) case O2HB_DB_TYPE_REGION_ELAPSED_TIME: reg = (struct o2hb_region *)db->db_data; - out += snprintf(buf + out, PAGE_SIZE - out, "%u\n", - jiffies_to_msecs(jiffies - - reg->hr_last_timeout_start)); + lts = reg->hr_last_timeout_start; + /* If 0, it has never been set before */ + if (lts) + lts = jiffies_to_msecs(jiffies - lts); + out += snprintf(buf + out, PAGE_SIZE - out, "%lu\n", lts); goto done; case O2HB_DB_TYPE_REGION_PINNED: -- cgit v0.10.2 From 3ba169ccec1c5ad0f678e04fd29b990197fdfe79 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:32:54 -0700 Subject: ocfs2/cluster: Add new function o2net_fill_node_map() Patch adds function o2net_fill_node_map() to return the bitmap of nodes that it is connected to. This bitmap is also accessible by the user via the debugfs file, /sys/kernel/debug/o2net/connected_nodes. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index 3a583590..dc45deb 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c @@ -47,6 +47,7 @@ #define SC_DEBUG_NAME "sock_containers" #define NST_DEBUG_NAME "send_tracking" #define STATS_DEBUG_NAME "stats" +#define NODES_DEBUG_NAME "connected_nodes" #define SHOW_SOCK_CONTAINERS 0 #define SHOW_SOCK_STATS 1 @@ -55,6 +56,7 @@ static struct dentry *o2net_dentry; static struct dentry *sc_dentry; static struct dentry *nst_dentry; static struct dentry *stats_dentry; +static struct dentry *nodes_dentry; static DEFINE_SPINLOCK(o2net_debug_lock); @@ -491,53 +493,87 @@ static const struct file_operations sc_seq_fops = { .release = sc_fop_release, }; -int o2net_debugfs_init(void) +static int o2net_fill_bitmap(char *buf, int len) { - o2net_dentry = debugfs_create_dir(O2NET_DEBUG_DIR, NULL); - if (!o2net_dentry) { - mlog_errno(-ENOMEM); - goto bail; - } + unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + int i = -1, out = 0; - nst_dentry = debugfs_create_file(NST_DEBUG_NAME, S_IFREG|S_IRUSR, - o2net_dentry, NULL, - &nst_seq_fops); - if (!nst_dentry) { - mlog_errno(-ENOMEM); - goto bail; - } + o2net_fill_node_map(map, sizeof(map)); - sc_dentry = debugfs_create_file(SC_DEBUG_NAME, S_IFREG|S_IRUSR, - o2net_dentry, NULL, - &sc_seq_fops); - if (!sc_dentry) { - mlog_errno(-ENOMEM); - goto bail; - } + while ((i = find_next_bit(map, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) + out += snprintf(buf + out, PAGE_SIZE - out, "%d ", i); + out += snprintf(buf + out, PAGE_SIZE - out, "\n"); - stats_dentry = debugfs_create_file(STATS_DEBUG_NAME, S_IFREG|S_IRUSR, - o2net_dentry, NULL, - &stats_seq_fops); - if (!stats_dentry) { - mlog_errno(-ENOMEM); - goto bail; - } + return out; +} + +static int nodes_fop_open(struct inode *inode, struct file *file) +{ + char *buf; + + buf = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + i_size_write(inode, o2net_fill_bitmap(buf, PAGE_SIZE)); + + file->private_data = buf; return 0; -bail: - debugfs_remove(stats_dentry); - debugfs_remove(sc_dentry); - debugfs_remove(nst_dentry); - debugfs_remove(o2net_dentry); - return -ENOMEM; } +static int o2net_debug_release(struct inode *inode, struct file *file) +{ + kfree(file->private_data); + return 0; +} + +static ssize_t o2net_debug_read(struct file *file, char __user *buf, + size_t nbytes, loff_t *ppos) +{ + return simple_read_from_buffer(buf, nbytes, ppos, file->private_data, + i_size_read(file->f_mapping->host)); +} + +static const struct file_operations nodes_fops = { + .open = nodes_fop_open, + .release = o2net_debug_release, + .read = o2net_debug_read, + .llseek = generic_file_llseek, +}; + void o2net_debugfs_exit(void) { + debugfs_remove(nodes_dentry); debugfs_remove(stats_dentry); debugfs_remove(sc_dentry); debugfs_remove(nst_dentry); debugfs_remove(o2net_dentry); } +int o2net_debugfs_init(void) +{ + mode_t mode = S_IFREG|S_IRUSR; + + o2net_dentry = debugfs_create_dir(O2NET_DEBUG_DIR, NULL); + if (o2net_dentry) + nst_dentry = debugfs_create_file(NST_DEBUG_NAME, mode, + o2net_dentry, NULL, &nst_seq_fops); + if (nst_dentry) + sc_dentry = debugfs_create_file(SC_DEBUG_NAME, mode, + o2net_dentry, NULL, &sc_seq_fops); + if (sc_dentry) + stats_dentry = debugfs_create_file(STATS_DEBUG_NAME, mode, + o2net_dentry, NULL, &stats_seq_fops); + if (stats_dentry) + nodes_dentry = debugfs_create_file(NODES_DEBUG_NAME, mode, + o2net_dentry, NULL, &nodes_fops); + if (nodes_dentry) + return 0; + + o2net_debugfs_exit(); + mlog_errno(-ENOMEM); + return -ENOMEM; +} + #endif /* CONFIG_DEBUG_FS */ diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 6e97895..ae13d5c 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -1034,6 +1034,25 @@ static int o2net_tx_can_proceed(struct o2net_node *nn, return ret; } +/* Get a map of all nodes to which this node is currently connected to */ +void o2net_fill_node_map(unsigned long *map, unsigned bytes) +{ + struct o2net_sock_container *sc; + int node, ret; + + BUG_ON(bytes < (BITS_TO_LONGS(O2NM_MAX_NODES) * sizeof(unsigned long))); + + memset(map, 0, bytes); + for (node = 0; node < O2NM_MAX_NODES; ++node) { + o2net_tx_can_proceed(o2net_nn_from_num(node), &sc, &ret); + if (!ret) { + set_bit(node, map); + sc_put(sc); + } + } +} +EXPORT_SYMBOL_GPL(o2net_fill_node_map); + int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec, size_t caller_veclen, u8 target_node, int *status) { diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h index fd6179e..5bada2a 100644 --- a/fs/ocfs2/cluster/tcp.h +++ b/fs/ocfs2/cluster/tcp.h @@ -106,6 +106,8 @@ int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, struct list_head *unreg_list); void o2net_unregister_handler_list(struct list_head *list); +void o2net_fill_node_map(unsigned long *map, unsigned bytes); + struct o2nm_node; int o2net_register_hb_callbacks(void); void o2net_unregister_hb_callbacks(void); -- cgit v0.10.2 From 6b27f62fc750d85bc6fc3718b3b38ec60edc2d74 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:33:54 -0700 Subject: ocfs2/cluster: Cluster up now includes network connections too The cluster up check only checks to see if the node is heartbeating or not. If yes it continues assuming that the node is connected to all the nodes. But if that is not the case, the cluster join aborts with a stack of errors that are not easy to comprehend. This patch adds the network connect check upfront and prints the nodes that the node is not yet connected to, before aborting. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 200d988..92f2ead 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -2138,13 +2138,6 @@ struct dlm_ctxt * dlm_register_domain(const char *domain, goto leave; } - if (!o2hb_check_local_node_heartbeating()) { - mlog(ML_ERROR, "the local node has not been configured, or is " - "not heartbeating\n"); - ret = -EPROTO; - goto leave; - } - mlog(0, "register called for domain \"%s\"\n", domain); retry: diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index be935d8..9436801 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c @@ -28,6 +28,7 @@ #include "cluster/masklog.h" #include "cluster/nodemanager.h" #include "cluster/heartbeat.h" +#include "cluster/tcp.h" #include "stackglue.h" @@ -256,6 +257,61 @@ static void o2cb_dump_lksb(struct ocfs2_dlm_lksb *lksb) } /* + * Check if this node is heartbeating and is connected to all other + * heartbeating nodes. + */ +static int o2cb_cluster_check(void) +{ + u8 node_num; + int i; + unsigned long hbmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long netmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; + + node_num = o2nm_this_node(); + if (node_num == O2NM_MAX_NODES) { + printk(KERN_ERR "o2cb: This node has not been configured.\n"); + return -EINVAL; + } + + /* + * o2dlm expects o2net sockets to be created. If not, then + * dlm_join_domain() fails with a stack of errors which are both cryptic + * and incomplete. The idea here is to detect upfront whether we have + * managed to connect to all nodes or not. If not, then list the nodes + * to allow the user to check the configuration (incorrect IP, firewall, + * etc.) Yes, this is racy. But its not the end of the world. + */ +#define O2CB_MAP_STABILIZE_COUNT 60 + for (i = 0; i < O2CB_MAP_STABILIZE_COUNT; ++i) { + o2hb_fill_node_map(hbmap, sizeof(hbmap)); + if (!test_bit(node_num, hbmap)) { + printk(KERN_ERR "o2cb: %s heartbeat has not been " + "started.\n", (o2hb_global_heartbeat_active() ? + "Global" : "Local")); + return -EINVAL; + } + o2net_fill_node_map(netmap, sizeof(netmap)); + /* Force set the current node to allow easy compare */ + set_bit(node_num, netmap); + if (!memcmp(hbmap, netmap, sizeof(hbmap))) + return 0; + if (i < O2CB_MAP_STABILIZE_COUNT) + msleep(1000); + } + + printk(KERN_ERR "o2cb: This node could not connect to nodes:"); + i = -1; + while ((i = find_next_bit(hbmap, O2NM_MAX_NODES, + i + 1)) < O2NM_MAX_NODES) { + if (!test_bit(i, netmap)) + printk(" %u", i); + } + printk(".\n"); + + return -ENOTCONN; +} + +/* * Called from the dlm when it's about to evict a node. This is how the * classic stack signals node death. */ @@ -280,12 +336,11 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn) BUG_ON(conn == NULL); BUG_ON(conn->cc_proto == NULL); - /* for now we only have one cluster/node, make sure we see it - * in the heartbeat universe */ - if (!o2hb_check_local_node_heartbeating()) { - if (o2hb_global_heartbeat_active()) - mlog(ML_ERROR, "Global heartbeat not started\n"); - rc = -EINVAL; + /* Ensure cluster stack is up and all nodes are connected */ + rc = o2cb_cluster_check(); + if (rc) { + printk(KERN_ERR "o2cb: Cluster check failed. Fix errors " + "before retrying.\n"); goto out; } -- cgit v0.10.2 From 619c200de144b44f5e405305241bcd7edbb8c6cf Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:34:54 -0700 Subject: ocfs2: Clean up messages in the fs Convert useful messages from ML_NOTICE to KERN_NOTICE to improve readability. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 295d564..8eaaa78 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -1544,9 +1544,9 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, /* we need to run complete recovery for offline orphan slots */ ocfs2_replay_map_set_state(osb, REPLAY_NEEDED); - mlog(ML_NOTICE, "Recovering node %d from slot %d on device (%u,%u)\n", - node_num, slot_num, - MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); + printk(KERN_NOTICE "ocfs2: Begin replay journal (node %d, slot %d) on "\ + "device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev), + MINOR(osb->sb->s_dev)); OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); @@ -1601,6 +1601,9 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, jbd2_journal_destroy(journal); + printk(KERN_NOTICE "ocfs2: End replay journal (node %d, slot %d) on "\ + "device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev), + MINOR(osb->sb->s_dev)); done: /* drop the lock on this nodes journal */ if (got_lock) diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c index dc8007f..942fd65 100644 --- a/fs/ocfs2/quota_local.c +++ b/fs/ocfs2/quota_local.c @@ -404,7 +404,9 @@ struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery( int status = 0; struct ocfs2_quota_recovery *rec; - mlog(ML_NOTICE, "Beginning quota recovery in slot %u\n", slot_num); + printk(KERN_NOTICE "ocfs2: Beginning quota recovery on device (%s) for " + "slot %u\n", osb->dev_str, slot_num); + rec = ocfs2_alloc_quota_recovery(); if (!rec) return ERR_PTR(-ENOMEM); @@ -596,7 +598,9 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, struct inode *lqinode; unsigned int flags; - mlog(ML_NOTICE, "Finishing quota recovery in slot %u\n", slot_num); + printk(KERN_NOTICE "ocfs2: Finishing quota recovery on device (%s) for " + "slot %u\n", osb->dev_str, slot_num); + mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); for (type = 0; type < MAXQUOTAS; type++) { if (list_empty(&(rec->r_list[type]))) @@ -612,8 +616,9 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, /* Someone else is holding the lock? Then he must be * doing the recovery. Just skip the file... */ if (status == -EAGAIN) { - mlog(ML_NOTICE, "skipping quota recovery for slot %d " - "because quota file is locked.\n", slot_num); + printk(KERN_NOTICE "ocfs2: Skipping quota recovery on " + "device (%s) for slot %d because quota file is " + "locked.\n", osb->dev_str, slot_num); status = 0; goto out_put; } else if (status < 0) { diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index 26fc001..1424c15 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -493,8 +493,8 @@ int ocfs2_find_slot(struct ocfs2_super *osb) goto bail; } } else - mlog(ML_NOTICE, "slot %d is already allocated to this node!\n", - slot); + printk(KERN_INFO "ocfs2: Slot %d on device (%s) was already " + "allocated to this node!\n", slot, osb->dev_str); ocfs2_set_slot(si, slot, osb->node_num); osb->slot_num = slot; diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 56f6102..3e78503 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1107,9 +1107,9 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) ocfs2_set_ro_flag(osb, 1); - printk(KERN_NOTICE "Readonly device detected. No cluster " - "services will be utilized for this mount. Recovery " - "will be skipped.\n"); + printk(KERN_NOTICE "ocfs2: Readonly device (%s) detected. " + "Cluster services will not be used for this mount. " + "Recovery will be skipped.\n", osb->dev_str); } if (!ocfs2_is_hard_readonly(osb)) { @@ -2462,8 +2462,8 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) goto finally; } } else { - mlog(ML_NOTICE, "File system was not unmounted cleanly, " - "recovering volume.\n"); + printk(KERN_NOTICE "ocfs2: File system on device (%s) was not " + "unmounted cleanly, recovering it.\n", osb->dev_str); } local = ocfs2_mount_local(osb); -- cgit v0.10.2 From a035bff6b82aca89c1223e2c614adc2d17ec8aa2 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Sun, 24 Jul 2011 10:35:54 -0700 Subject: ocfs2: Add comment about orphan scanning Add a comment that explains the reason as to why orphan scan scans all the slots. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 8eaaa78..0a42ae9 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -1811,6 +1811,20 @@ static inline unsigned long ocfs2_orphan_scan_timeout(void) * every slot, queuing a recovery of the slot on the ocfs2_wq thread. This * is done to catch any orphans that are left over in orphan directories. * + * It scans all slots, even ones that are in use. It does so to handle the + * case described below: + * + * Node 1 has an inode it was using. The dentry went away due to memory + * pressure. Node 1 closes the inode, but it's on the free list. The node + * has the open lock. + * Node 2 unlinks the inode. It grabs the dentry lock to notify others, + * but node 1 has no dentry and doesn't get the message. It trylocks the + * open lock, sees that another node has a PR, and does nothing. + * Later node 2 runs its orphan dir. It igets the inode, trylocks the + * open lock, sees the PR still, and does nothing. + * Basically, we have to trigger an orphan iput on node 1. The only way + * for this to happen is if node 1 runs node 2's orphan dir. + * * ocfs2_queue_orphan_scan gets called every ORPHAN_SCAN_SCHEDULE_TIMEOUT * seconds. It gets an EX lock on os_lockres and checks sequence number * stored in LVB. If the sequence number has changed, it means some other -- cgit v0.10.2 From 5cffff9e29866a3de98c2c25135b3199491f93b0 Mon Sep 17 00:00:00 2001 From: Wengang Wang Date: Sun, 24 Jul 2011 10:36:54 -0700 Subject: ocfs2: Fix ocfs2_page_mkwrite() This patch address two shortcomings in ocfs2_page_mkwrite(): 1. Makes the function return better VM_FAULT_* errors. 2. It handles a error that is triggered when a page is dropped from the mapping due to memory pressure. This patch locks the page to prevent that. [Patch was cleaned up by Sunil Mushran.] Signed-off-by: Wengang Wang Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index c1efe93..ff98c16 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -863,6 +863,12 @@ struct ocfs2_write_ctxt { struct page *w_target_page; /* + * w_target_locked is used for page_mkwrite path indicating no unlocking + * against w_target_page in ocfs2_write_end_nolock. + */ + unsigned int w_target_locked:1; + + /* * ocfs2_write_end() uses this to know what the real range to * write in the target should be. */ @@ -895,6 +901,24 @@ void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages) static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc) { + int i; + + /* + * w_target_locked is only set to true in the page_mkwrite() case. + * The intent is to allow us to lock the target page from write_begin() + * to write_end(). The caller must hold a ref on w_target_page. + */ + if (wc->w_target_locked) { + BUG_ON(!wc->w_target_page); + for (i = 0; i < wc->w_num_pages; i++) { + if (wc->w_target_page == wc->w_pages[i]) { + wc->w_pages[i] = NULL; + break; + } + } + mark_page_accessed(wc->w_target_page); + page_cache_release(wc->w_target_page); + } ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); brelse(wc->w_di_bh); @@ -1132,20 +1156,17 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, */ lock_page(mmap_page); + /* Exit and let the caller retry */ if (mmap_page->mapping != mapping) { + WARN_ON(mmap_page->mapping); unlock_page(mmap_page); - /* - * Sanity check - the locking in - * ocfs2_pagemkwrite() should ensure - * that this code doesn't trigger. - */ - ret = -EINVAL; - mlog_errno(ret); + ret = -EAGAIN; goto out; } page_cache_get(mmap_page); wc->w_pages[i] = mmap_page; + wc->w_target_locked = true; } else { wc->w_pages[i] = find_or_create_page(mapping, index, GFP_NOFS); @@ -1160,6 +1181,8 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, wc->w_target_page = wc->w_pages[i]; } out: + if (ret) + wc->w_target_locked = false; return ret; } @@ -1817,11 +1840,23 @@ try_again: */ ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len, cluster_of_pages, mmap_page); - if (ret) { + if (ret && ret != -EAGAIN) { mlog_errno(ret); goto out_quota; } + /* + * ocfs2_grab_pages_for_write() returns -EAGAIN if it could not lock + * the target page. In this case, we exit with no error and no target + * page. This will trigger the caller, page_mkwrite(), to re-try + * the operation. + */ + if (ret == -EAGAIN) { + BUG_ON(wc->w_target_page); + ret = 0; + goto out_quota; + } + ret = ocfs2_write_cluster_by_desc(mapping, data_ac, meta_ac, wc, pos, len); if (ret) { diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index 3e9393c..9cd4108 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -61,7 +61,7 @@ static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf) static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, struct page *page) { - int ret; + int ret = VM_FAULT_NOPAGE; struct inode *inode = file->f_path.dentry->d_inode; struct address_space *mapping = inode->i_mapping; loff_t pos = page_offset(page); @@ -71,32 +71,25 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, void *fsdata; loff_t size = i_size_read(inode); - /* - * Another node might have truncated while we were waiting on - * cluster locks. - * We don't check size == 0 before the shift. This is borrowed - * from do_generic_file_read. - */ last_index = (size - 1) >> PAGE_CACHE_SHIFT; - if (unlikely(!size || page->index > last_index)) { - ret = -EINVAL; - goto out; - } /* - * The i_size check above doesn't catch the case where nodes - * truncated and then re-extended the file. We'll re-check the - * page mapping after taking the page lock inside of - * ocfs2_write_begin_nolock(). + * There are cases that lead to the page no longer bebongs to the + * mapping. + * 1) pagecache truncates locally due to memory pressure. + * 2) pagecache truncates when another is taking EX lock against + * inode lock. see ocfs2_data_convert_worker. + * + * The i_size check doesn't catch the case where nodes truncated and + * then re-extended the file. We'll re-check the page mapping after + * taking the page lock inside of ocfs2_write_begin_nolock(). + * + * Let VM retry with these cases. */ - if (!PageUptodate(page) || page->mapping != inode->i_mapping) { - /* - * the page has been umapped in ocfs2_data_downconvert_worker. - * So return 0 here and let VFS retry. - */ - ret = 0; + if ((page->mapping != inode->i_mapping) || + (!PageUptodate(page)) || + (page_offset(page) >= size)) goto out; - } /* * Call ocfs2_write_begin() and ocfs2_write_end() to take @@ -116,17 +109,21 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, if (ret) { if (ret != -ENOSPC) mlog_errno(ret); + if (ret == -ENOMEM) + ret = VM_FAULT_OOM; + else + ret = VM_FAULT_SIGBUS; goto out; } - ret = ocfs2_write_end_nolock(mapping, pos, len, len, locked_page, - fsdata); - if (ret < 0) { - mlog_errno(ret); + if (!locked_page) { + ret = VM_FAULT_NOPAGE; goto out; } + ret = ocfs2_write_end_nolock(mapping, pos, len, len, locked_page, + fsdata); BUG_ON(ret != len); - ret = 0; + ret = VM_FAULT_LOCKED; out: return ret; } @@ -168,8 +165,6 @@ static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) out: ocfs2_unblock_signals(&oldset); - if (ret) - ret = VM_FAULT_SIGBUS; return ret; } -- cgit v0.10.2 From 93862d5e1ab875664c6cc95254fc365028a48bb1 Mon Sep 17 00:00:00 2001 From: Sunil Mushran Date: Mon, 25 Jul 2011 14:58:15 -0700 Subject: ocfs2: Implement llseek() ocfs2 implements its own llseek() to provide the SEEK_HOLE/SEEK_DATA functionality. SEEK_HOLE sets the file pointer to the start of either a hole or an unwritten (preallocated) extent, that is greater than or equal to the supplied offset. SEEK_DATA sets the file pointer to the start of an allocated extent (not unwritten) that is greater than or equal to the supplied offset. If the supplied offset is on a desired region, then the file pointer is set to it. Offsets greater than or equal to the file size return -ENXIO. Unwritten (preallocated) extents are considered holes because the file system treats reads to such regions in the same way as it does to holes. Signed-off-by: Sunil Mushran diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index 23457b4..2f5b92e 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -832,6 +832,102 @@ out: return ret; } +int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin) +{ + struct inode *inode = file->f_mapping->host; + int ret; + unsigned int is_last = 0, is_data = 0; + u16 cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits; + u32 cpos, cend, clen, hole_size; + u64 extoff, extlen; + struct buffer_head *di_bh = NULL; + struct ocfs2_extent_rec rec; + + BUG_ON(origin != SEEK_DATA && origin != SEEK_HOLE); + + ret = ocfs2_inode_lock(inode, &di_bh, 0); + if (ret) { + mlog_errno(ret); + goto out; + } + + down_read(&OCFS2_I(inode)->ip_alloc_sem); + + if (*offset >= inode->i_size) { + ret = -ENXIO; + goto out_unlock; + } + + if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { + if (origin == SEEK_HOLE) + *offset = inode->i_size; + goto out_unlock; + } + + clen = 0; + cpos = *offset >> cs_bits; + cend = ocfs2_clusters_for_bytes(inode->i_sb, inode->i_size); + + while (cpos < cend && !is_last) { + ret = ocfs2_get_clusters_nocache(inode, di_bh, cpos, &hole_size, + &rec, &is_last); + if (ret) { + mlog_errno(ret); + goto out_unlock; + } + + extoff = cpos; + extoff <<= cs_bits; + + if (rec.e_blkno == 0ULL) { + clen = hole_size; + is_data = 0; + } else { + clen = le16_to_cpu(rec.e_leaf_clusters) - + (cpos - le32_to_cpu(rec.e_cpos)); + is_data = (rec.e_flags & OCFS2_EXT_UNWRITTEN) ? 0 : 1; + } + + if ((!is_data && origin == SEEK_HOLE) || + (is_data && origin == SEEK_DATA)) { + if (extoff > *offset) + *offset = extoff; + goto out_unlock; + } + + if (!is_last) + cpos += clen; + } + + if (origin == SEEK_HOLE) { + extoff = cpos; + extoff <<= cs_bits; + extlen = clen; + extlen <<= cs_bits; + + if ((extoff + extlen) > inode->i_size) + extlen = inode->i_size - extoff; + extoff += extlen; + if (extoff > *offset) + *offset = extoff; + goto out_unlock; + } + + ret = -ENXIO; + +out_unlock: + + brelse(di_bh); + + up_read(&OCFS2_I(inode)->ip_alloc_sem); + + ocfs2_inode_unlock(inode, 0); +out: + if (ret && ret != -ENXIO) + ret = -ENXIO; + return ret; +} + int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr, struct buffer_head *bhs[], int flags, int (*validate)(struct super_block *sb, diff --git a/fs/ocfs2/extent_map.h b/fs/ocfs2/extent_map.h index e79d41c..67ea57d 100644 --- a/fs/ocfs2/extent_map.h +++ b/fs/ocfs2/extent_map.h @@ -53,6 +53,8 @@ int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 map_start, u64 map_len); +int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin); + int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster, u32 *num_clusters, struct ocfs2_extent_list *el, diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 0fc2bd3..c0f015e 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2591,6 +2591,57 @@ bail: return ret; } +/* Refer generic_file_llseek_unlocked() */ +static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int origin) +{ + struct inode *inode = file->f_mapping->host; + int ret = 0; + + mutex_lock(&inode->i_mutex); + + switch (origin) { + case SEEK_SET: + break; + case SEEK_END: + offset += inode->i_size; + break; + case SEEK_CUR: + if (offset == 0) { + offset = file->f_pos; + goto out; + } + offset += file->f_pos; + break; + case SEEK_DATA: + case SEEK_HOLE: + ret = ocfs2_seek_data_hole_offset(file, &offset, origin); + if (ret) + goto out; + break; + default: + ret = -EINVAL; + goto out; + } + + if (offset < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET)) + ret = -EINVAL; + if (!ret && offset > inode->i_sb->s_maxbytes) + ret = -EINVAL; + if (ret) + goto out; + + if (offset != file->f_pos) { + file->f_pos = offset; + file->f_version = 0; + } + +out: + mutex_unlock(&inode->i_mutex); + if (ret) + return ret; + return offset; +} + const struct inode_operations ocfs2_file_iops = { .setattr = ocfs2_setattr, .getattr = ocfs2_getattr, @@ -2615,7 +2666,7 @@ const struct inode_operations ocfs2_special_file_iops = { * ocfs2_fops_no_plocks and ocfs2_dops_no_plocks! */ const struct file_operations ocfs2_fops = { - .llseek = generic_file_llseek, + .llseek = ocfs2_file_llseek, .read = do_sync_read, .write = do_sync_write, .mmap = ocfs2_mmap, @@ -2663,7 +2714,7 @@ const struct file_operations ocfs2_dops = { * the cluster. */ const struct file_operations ocfs2_fops_no_plocks = { - .llseek = generic_file_llseek, + .llseek = ocfs2_file_llseek, .read = do_sync_read, .write = do_sync_write, .mmap = ocfs2_mmap, -- cgit v0.10.2 From a11f7e63c59810a81494d4c4b028af707d4c7ca4 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Wed, 22 Jun 2011 14:23:38 -0700 Subject: ocfs2: serialize unaligned aio Fix a corruption that can happen when we have (two or more) outstanding aio's to an overlapping unaligned region. Ext4 (e9e3bcecf44c04b9e6b505fd8e2eb9cea58fb94d) and xfs recently had to fix similar issues. In our case what happens is that we can have an outstanding aio on a region and if a write comes in with some bytes overlapping the original aio we may decide to read that region into a page before continuing (typically because of buffered-io fallback). Since we have no ordering guarantees with the aio, we can read stale or bad data into the page and then write it back out. If the i/o is page and block aligned, then we avoid this issue as there won't be any need to read data from disk. I took the same approach as Eric in the ext4 patch and introduced some serialization of unaligned async direct i/o. I don't expect this to have an effect on the most common cases of AIO. Unaligned aio will be slower though, but that's far more acceptable than data corruption. Signed-off-by: Mark Fasheh Signed-off-by: Joel Becker diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index ac97bca..4c1ec8f 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -564,6 +564,7 @@ static void ocfs2_dio_end_io(struct kiocb *iocb, { struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; int level; + wait_queue_head_t *wq = ocfs2_ioend_wq(inode); /* this io's submitter should not have unlocked this before we could */ BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); @@ -573,6 +574,15 @@ static void ocfs2_dio_end_io(struct kiocb *iocb, ocfs2_iocb_clear_sem_locked(iocb); } + if (ocfs2_iocb_is_unaligned_aio(iocb)) { + ocfs2_iocb_clear_unaligned_aio(iocb); + + if (atomic_dec_and_test(&OCFS2_I(inode)->ip_unaligned_aio) && + waitqueue_active(wq)) { + wake_up_all(wq); + } + } + ocfs2_iocb_clear_rw_locked(iocb); level = ocfs2_iocb_rw_locked_level(iocb); diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index 75cf3ad..ffb2da3 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h @@ -78,6 +78,7 @@ enum ocfs2_iocb_lock_bits { OCFS2_IOCB_RW_LOCK = 0, OCFS2_IOCB_RW_LOCK_LEVEL, OCFS2_IOCB_SEM, + OCFS2_IOCB_UNALIGNED_IO, OCFS2_IOCB_NUM_LOCKS }; @@ -91,4 +92,17 @@ enum ocfs2_iocb_lock_bits { clear_bit(OCFS2_IOCB_SEM, (unsigned long *)&iocb->private) #define ocfs2_iocb_is_sem_locked(iocb) \ test_bit(OCFS2_IOCB_SEM, (unsigned long *)&iocb->private) + +#define ocfs2_iocb_set_unaligned_aio(iocb) \ + set_bit(OCFS2_IOCB_UNALIGNED_IO, (unsigned long *)&iocb->private) +#define ocfs2_iocb_clear_unaligned_aio(iocb) \ + clear_bit(OCFS2_IOCB_UNALIGNED_IO, (unsigned long *)&iocb->private) +#define ocfs2_iocb_is_unaligned_aio(iocb) \ + test_bit(OCFS2_IOCB_UNALIGNED_IO, (unsigned long *)&iocb->private) + +#define OCFS2_IOEND_WQ_HASH_SZ 37 +#define ocfs2_ioend_wq(v) (&ocfs2__ioend_wq[((unsigned long)(v)) %\ + OCFS2_IOEND_WQ_HASH_SZ]) +extern wait_queue_head_t ocfs2__ioend_wq[OCFS2_IOEND_WQ_HASH_SZ]; + #endif /* OCFS2_FILE_H */ diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index b1e35a3..145f453 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2038,6 +2038,23 @@ out: return ret; } +static void ocfs2_aiodio_wait(struct inode *inode) +{ + wait_queue_head_t *wq = ocfs2_ioend_wq(inode); + + wait_event(*wq, (atomic_read(&OCFS2_I(inode)->ip_unaligned_aio) == 0)); +} + +static int ocfs2_is_io_unaligned(struct inode *inode, size_t count, loff_t pos) +{ + int blockmask = inode->i_sb->s_blocksize - 1; + loff_t final_size = pos + count; + + if ((pos & blockmask) || (final_size & blockmask)) + return 1; + return 0; +} + static int ocfs2_prepare_inode_for_refcount(struct inode *inode, struct file *file, loff_t pos, size_t count, @@ -2216,6 +2233,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); int full_coherency = !(osb->s_mount_opt & OCFS2_MOUNT_COHERENCY_BUFFERED); + int unaligned_dio = 0; trace_ocfs2_file_aio_write(inode, file, file->f_path.dentry, (unsigned long long)OCFS2_I(inode)->ip_blkno, @@ -2284,6 +2302,10 @@ relock: goto out; } + if (direct_io && !is_sync_kiocb(iocb)) + unaligned_dio = ocfs2_is_io_unaligned(inode, iocb->ki_left, + *ppos); + /* * We can't complete the direct I/O as requested, fall back to * buffered I/O. @@ -2299,6 +2321,18 @@ relock: goto relock; } + if (unaligned_dio) { + /* + * Wait on previous unaligned aio to complete before + * proceeding. + */ + ocfs2_aiodio_wait(inode); + + /* Mark the iocb as needing a decrement in ocfs2_dio_end_io */ + atomic_inc(&OCFS2_I(inode)->ip_unaligned_aio); + ocfs2_iocb_set_unaligned_aio(iocb); + } + /* * To later detect whether a journal commit for sync writes is * necessary, we sample i_size, and cluster count here. @@ -2371,8 +2405,12 @@ out_dio: if ((ret == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) { rw_level = -1; have_alloc_sem = 0; + unaligned_dio = 0; } + if (unaligned_dio) + atomic_dec(&OCFS2_I(inode)->ip_unaligned_aio); + out: if (rw_level != -1) ocfs2_rw_unlock(inode, rw_level); diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h index 1c508b1..88924a3 100644 --- a/fs/ocfs2/inode.h +++ b/fs/ocfs2/inode.h @@ -43,6 +43,9 @@ struct ocfs2_inode_info /* protects extended attribute changes on this inode */ struct rw_semaphore ip_xattr_sem; + /* Number of outstanding AIO's which are not page aligned */ + atomic_t ip_unaligned_aio; + /* These fields are protected by ip_lock */ spinlock_t ip_lock; u32 ip_open_count; diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 029c4cd..603f5fe 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -54,6 +54,7 @@ #include "ocfs1_fs_compat.h" #include "alloc.h" +#include "aops.h" #include "blockcheck.h" #include "dlmglue.h" #include "export.h" @@ -1616,12 +1617,17 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) return 0; } +wait_queue_head_t ocfs2__ioend_wq[OCFS2_IOEND_WQ_HASH_SZ]; + static int __init ocfs2_init(void) { - int status; + int status, i; ocfs2_print_version(); + for (i = 0; i < OCFS2_IOEND_WQ_HASH_SZ; i++) + init_waitqueue_head(&ocfs2__ioend_wq[i]); + status = init_ocfs2_uptodate_cache(); if (status < 0) { mlog_errno(status); @@ -1760,7 +1766,7 @@ static void ocfs2_inode_init_once(void *data) ocfs2_extent_map_init(&oi->vfs_inode); INIT_LIST_HEAD(&oi->ip_io_markers); oi->ip_dir_start_lookup = 0; - + atomic_set(&oi->ip_unaligned_aio, 0); init_rwsem(&oi->ip_alloc_sem); init_rwsem(&oi->ip_xattr_sem); mutex_init(&oi->ip_io_mutex); -- cgit v0.10.2 From c7e25e6e0b0486492c5faaf6312b37413642c48e Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 23 Jun 2011 22:51:47 +0200 Subject: ocfs2: Avoid livelock in ocfs2_readpage() When someone writes to an inode, readers accessing the same inode via ocfs2_readpage() just busyloop trying to get ip_alloc_sem because do_generic_file_read() looks up the page again and retries ->readpage() when previous attempt failed with AOP_TRUNCATED_PAGE. When there are enough readers, they can occupy all CPUs and in non-preempt kernel the system is deadlocked because writer holding ip_alloc_sem is never run to release the semaphore. Fix the problem by making reader block on ip_alloc_sem to break the busy loop. Signed-off-by: Jan Kara Signed-off-by: Joel Becker diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 4c1ec8f..ba3ca1e 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -290,7 +290,15 @@ static int ocfs2_readpage(struct file *file, struct page *page) } if (down_read_trylock(&oi->ip_alloc_sem) == 0) { + /* + * Unlock the page and cycle ip_alloc_sem so that we don't + * busyloop waiting for ip_alloc_sem to unlock + */ ret = AOP_TRUNCATED_PAGE; + unlock_page(page); + unlock = 0; + down_read(&oi->ip_alloc_sem); + up_read(&oi->ip_alloc_sem); goto out_inode_unlock; } -- cgit v0.10.2 From a858393b0ce5c330bda466e5ae3a658ca98588ae Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 16 Sep 2011 16:26:30 +0300 Subject: Bluetooth: EFS: l2cap extended feature mask update Update L2CAP extended feature mask to reflect recent BT spec. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index ab90ae0..2933767 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -91,13 +91,17 @@ struct l2cap_conninfo { #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 -/* L2CAP feature mask */ +/* L2CAP extended feature mask */ #define L2CAP_FEAT_FLOWCTL 0x00000001 #define L2CAP_FEAT_RETRANS 0x00000002 +#define L2CAP_FEAT_BIDIR_QOS 0x00000004 #define L2CAP_FEAT_ERTM 0x00000008 #define L2CAP_FEAT_STREAMING 0x00000010 #define L2CAP_FEAT_FCS 0x00000020 +#define L2CAP_FEAT_EXT_FLOW 0x00000040 #define L2CAP_FEAT_FIXED_CHAN 0x00000080 +#define L2CAP_FEAT_EXT_WINDOW 0x00000100 +#define L2CAP_FEAT_UCD 0x00000200 /* L2CAP checksum option */ #define L2CAP_FCS_NONE 0x00 -- cgit v0.10.2 From a5fd6f300433ef7458c6d934f81f47ebd7c7e805 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 16 Sep 2011 16:26:32 +0300 Subject: Bluetooth: EFS: add enable_hs kernel param Add enable_hs kernel parameter. L2CAP_FEAT_EXT_FLOW depends on it. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 8cd1291..3158cec 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -57,6 +57,7 @@ #include int disable_ertm; +int enable_hs; static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN; static u8 l2cap_fixed_chan[8] = { 0x02, }; @@ -2782,6 +2783,9 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm if (!disable_ertm) feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING | L2CAP_FEAT_FCS; + if (enable_hs) + feat_mask |= L2CAP_FEAT_EXT_FLOW; + put_unaligned_le32(feat_mask, rsp->data); l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf), buf); @@ -4306,3 +4310,6 @@ void l2cap_exit(void) module_param(disable_ertm, bool, 0644); MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode"); + +module_param(enable_hs, bool, 0644); +MODULE_PARM_DESC(enable_hs, "Enable High Speed"); -- cgit v0.10.2 From 794d175698f0e78be7f2e3f4bdbe0e7cd3f2d6ae Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 26 Aug 2011 14:06:02 +0200 Subject: Bluetooth: hidp: Stop I/O on shutdown Current hidp driver purges the in/out queue on HID shutdown, but does not prevent further I/O. If a driver uses hidp_output_raw_report or hidp_get_raw_report during shutdown, the driver hangs for 5 or 10 seconds per call until it gets a timeout. That is, if the output queue of an HID driver has 10 messages pending, it will take 50s until hid_destroy_device() will return. The hidp_session_sem semaphore is held during shutdown so no other HID device may be added/removed during this time. This patch makes hidp_output_raw_report and hidp_get_raw_report fail if session->terminate is true. Also hidp_session will wakeup all current calls to these functions to cancel the current operations. We already purge the current I/O queues on hidp_stop(), so this data loss does not change the behaviour of the HID drivers. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 075a3e9..d7bae2b 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -255,6 +255,9 @@ static int __hidp_send_ctrl_message(struct hidp_session *session, BT_DBG("session %p data %p size %d", session, data, size); + if (atomic_read(&session->terminate)) + return -EIO; + skb = alloc_skb(size + 1, GFP_ATOMIC); if (!skb) { BT_ERR("Can't allocate memory for new frame"); @@ -329,6 +332,7 @@ static int hidp_get_raw_report(struct hid_device *hid, struct sk_buff *skb; size_t len; int numbered_reports = hid->report_enum[report_type].numbered; + int ret; switch (report_type) { case HID_FEATURE_REPORT: @@ -352,8 +356,9 @@ static int hidp_get_raw_report(struct hid_device *hid, session->waiting_report_number = numbered_reports ? report_number : -1; set_bit(HIDP_WAITING_FOR_RETURN, &session->flags); data[0] = report_number; - if (hidp_send_ctrl_message(hid->driver_data, report_type, data, 1)) - goto err_eio; + ret = hidp_send_ctrl_message(hid->driver_data, report_type, data, 1); + if (ret) + goto err; /* Wait for the return of the report. The returned report gets put in session->report_return. */ @@ -365,11 +370,13 @@ static int hidp_get_raw_report(struct hid_device *hid, 5*HZ); if (res == 0) { /* timeout */ - goto err_eio; + ret = -EIO; + goto err; } if (res < 0) { /* signal */ - goto err_restartsys; + ret = -ERESTARTSYS; + goto err; } } @@ -390,14 +397,10 @@ static int hidp_get_raw_report(struct hid_device *hid, return len; -err_restartsys: - clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); - mutex_unlock(&session->report_mutex); - return -ERESTARTSYS; -err_eio: +err: clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); mutex_unlock(&session->report_mutex); - return -EIO; + return ret; } static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, @@ -422,11 +425,10 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s /* Set up our wait, and send the report request to the device. */ set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); - if (hidp_send_ctrl_message(hid->driver_data, report_type, - data, count)) { - ret = -ENOMEM; + ret = hidp_send_ctrl_message(hid->driver_data, report_type, data, + count); + if (ret) goto err; - } /* Wait for the ACK from the device. */ while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { @@ -739,6 +741,10 @@ static int hidp_session(void *arg) remove_wait_queue(sk_sleep(intr_sk), &intr_wait); remove_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait); + clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); + clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); + wake_up_interruptible(&session->report_queue); + down_write(&hidp_session_sem); hidp_del_timer(session); -- cgit v0.10.2 From cd11cdd28468d6222ce6489b2212fa7b0efaefdf Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 6 Oct 2011 17:35:31 -0300 Subject: Bluetooth: use list_for_each_entry() in hidp list_for_each_entry is much more meaningful. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index d7bae2b..08bfbb0 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -81,12 +81,10 @@ static unsigned char hidp_mkeyspat[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr) { struct hidp_session *session; - struct list_head *p; BT_DBG(""); - list_for_each(p, &hidp_session_list) { - session = list_entry(p, struct hidp_session, list); + list_for_each_entry(session, &hidp_session_list, list) { if (!bacmp(bdaddr, &session->bdaddr)) return session; } @@ -1140,19 +1138,16 @@ int hidp_del_connection(struct hidp_conndel_req *req) int hidp_get_connlist(struct hidp_connlist_req *req) { - struct list_head *p; + struct hidp_session *session; int err = 0, n = 0; BT_DBG(""); down_read(&hidp_session_sem); - list_for_each(p, &hidp_session_list) { - struct hidp_session *session; + list_for_each_entry(session, &hidp_session_list, list) { struct hidp_conninfo ci; - session = list_entry(p, struct hidp_session, list); - __hidp_copy_session(session, &ci); if (copy_to_user(req->ci, &ci, sizeof(ci))) { -- cgit v0.10.2 From dc0da5cdac44aea6a04b18acc5526931430e0c35 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 6 Oct 2011 18:02:13 -0300 Subject: Bluetooth: prioritize the interrupt channel in hidp Interrupt channel has low latency requiments, should be processed first. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 08bfbb0..2694a0a 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -714,18 +714,18 @@ static int hidp_session(void *arg) intr_sk->sk_state != BT_CONNECTED) break; - while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) { + while ((skb = skb_dequeue(&intr_sk->sk_receive_queue))) { skb_orphan(skb); if (!skb_linearize(skb)) - hidp_recv_ctrl_frame(session, skb); + hidp_recv_intr_frame(session, skb); else kfree_skb(skb); } - while ((skb = skb_dequeue(&intr_sk->sk_receive_queue))) { + while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) { skb_orphan(skb); if (!skb_linearize(skb)) - hidp_recv_intr_frame(session, skb); + hidp_recv_ctrl_frame(session, skb); else kfree_skb(skb); } -- cgit v0.10.2 From 679344e44e09c74848535a28948df7c3b3c1a071 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 6 Oct 2011 20:51:37 -0300 Subject: Bluetooth: Trasmit interrupt channel messages first interrupt channel is low latency. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 2694a0a..6cb1d9e 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -663,25 +663,32 @@ static int hidp_send_frame(struct socket *sock, unsigned char *data, int len) return kernel_sendmsg(sock, &msg, &iv, 1, len); } -static void hidp_process_transmit(struct hidp_session *session) +static void hidp_process_intr_transmit(struct hidp_session *session) { struct sk_buff *skb; BT_DBG("session %p", session); - while ((skb = skb_dequeue(&session->ctrl_transmit))) { - if (hidp_send_frame(session->ctrl_sock, skb->data, skb->len) < 0) { - skb_queue_head(&session->ctrl_transmit, skb); + while ((skb = skb_dequeue(&session->intr_transmit))) { + if (hidp_send_frame(session->intr_sock, skb->data, skb->len) < 0) { + skb_queue_head(&session->intr_transmit, skb); break; } hidp_set_timer(session); kfree_skb(skb); } +} - while ((skb = skb_dequeue(&session->intr_transmit))) { - if (hidp_send_frame(session->intr_sock, skb->data, skb->len) < 0) { - skb_queue_head(&session->intr_transmit, skb); +static void hidp_process_ctrl_transmit(struct hidp_session *session) +{ + struct sk_buff *skb; + + BT_DBG("session %p", session); + + while ((skb = skb_dequeue(&session->ctrl_transmit))) { + if (hidp_send_frame(session->ctrl_sock, skb->data, skb->len) < 0) { + skb_queue_head(&session->ctrl_transmit, skb); break; } @@ -722,6 +729,8 @@ static int hidp_session(void *arg) kfree_skb(skb); } + hidp_process_intr_transmit(session); + while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) { skb_orphan(skb); if (!skb_linearize(skb)) @@ -730,7 +739,7 @@ static int hidp_session(void *arg) kfree_skb(skb); } - hidp_process_transmit(session); + hidp_process_ctrl_transmit(session); schedule(); set_current_state(TASK_INTERRUPTIBLE); -- cgit v0.10.2 From 3415a5fdde715062aa18bd6361f8e75cfbb31208 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 6 Oct 2011 21:17:32 -0300 Subject: Bluetooth: Fix input device registration This is a regression fix. It made impossible use input device when hid fails. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 6cb1d9e..8d99a17 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -812,7 +812,7 @@ static int hidp_setup_input(struct hidp_session *session, struct hidp_connadd_req *req) { struct input_dev *input; - int err, i; + int i; input = input_allocate_device(); if (!input) @@ -859,13 +859,6 @@ static int hidp_setup_input(struct hidp_session *session, input->event = hidp_input_event; - err = input_register_device(input); - if (err < 0) { - input_free_device(input); - session->input = NULL; - return err; - } - return 0; } @@ -1067,7 +1060,11 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, !session->waiting_for_startup); } - err = hid_add_device(session->hid); + if (session->hid) + err = hid_add_device(session->hid); + else + err = input_register_device(session->input); + if (err < 0) { atomic_inc(&session->terminate); wake_up_process(session->task); -- cgit v0.10.2 From 192893c72197b3f49f76a315024bdcd5aa26fff3 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 6 Oct 2011 21:27:56 -0300 Subject: Bluetooth: Remove wrong error check d458a9dfc add this check, but now it proves to be wrong. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 8d99a17..7722d83 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -1023,7 +1023,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, if (req->rd_size > 0) { err = hidp_setup_hid(session, req); - if (err && err != -ENODEV) + if (err) goto purge; } -- cgit v0.10.2 From ab88f7149e0e3284623adcaa60460a9a69d9f131 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 6 Oct 2011 22:05:37 -0300 Subject: Bluetooth: Uses test_and_clear_bit() when possible Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 7722d83..f2bec49 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -496,10 +496,9 @@ static void hidp_process_handshake(struct hidp_session *session, case HIDP_HSHK_ERR_INVALID_REPORT_ID: case HIDP_HSHK_ERR_UNSUPPORTED_REQUEST: case HIDP_HSHK_ERR_INVALID_PARAMETER: - if (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) { - clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); + if (test_and_clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) wake_up_interruptible(&session->report_queue); - } + /* FIXME: Call into SET_ GET_ handlers here */ break; @@ -520,10 +519,8 @@ static void hidp_process_handshake(struct hidp_session *session, } /* Wake up the waiting thread. */ - if (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { - clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); + if (test_and_clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) wake_up_interruptible(&session->report_queue); - } } static void hidp_process_hid_control(struct hidp_session *session, -- cgit v0.10.2 From 1785dbf9e30be62ab45e34900e574b8307bc98b5 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Tue, 30 Aug 2011 11:53:35 -0400 Subject: Bluetooth: hidp: safely acquire hci connection Claim device lock to safely enumerate hci connection list and bump hci connection proxy device ref count simultaneously. This patch incorporates David Herrmann's fix to prevent adding an HID device when the hci connection no longer exists. Signed-off-by: David Herrmann Signed-off-by: Peter Hurley Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index f2bec49..304a73f 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -95,8 +95,6 @@ static void __hidp_link_session(struct hidp_session *session) { __module_get(THIS_MODULE); list_add(&session->list, &hidp_session_list); - - hci_conn_hold_device(session->conn); } static void __hidp_unlink_session(struct hidp_session *session) @@ -785,24 +783,26 @@ static int hidp_session(void *arg) return 0; } -static struct device *hidp_get_device(struct hidp_session *session) +static struct hci_conn *hidp_find_connection(struct hidp_session *session) { bdaddr_t *src = &bt_sk(session->ctrl_sock->sk)->src; bdaddr_t *dst = &bt_sk(session->ctrl_sock->sk)->dst; - struct device *device = NULL; + struct hci_conn *conn; struct hci_dev *hdev; hdev = hci_get_route(dst, src); if (!hdev) return NULL; - session->conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); - if (session->conn) - device = &session->conn->dev; + hci_dev_lock_bh(hdev); + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); + if (conn) + hci_conn_hold_device(conn); + hci_dev_unlock_bh(hdev); hci_dev_put(hdev); - return device; + return conn; } static int hidp_setup_input(struct hidp_session *session, @@ -852,7 +852,7 @@ static int hidp_setup_input(struct hidp_session *session, input->relbit[0] |= BIT_MASK(REL_WHEEL); } - input->dev.parent = hidp_get_device(session); + input->dev.parent = &session->conn->dev; input->event = hidp_input_event; @@ -952,7 +952,7 @@ static int hidp_setup_hid(struct hidp_session *session, strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64); strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64); - hid->dev.parent = hidp_get_device(session); + hid->dev.parent = &session->conn->dev; hid->ll_driver = &hidp_hid_driver; hid->hid_get_raw_report = hidp_get_raw_report; @@ -993,6 +993,12 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, goto failed; } + session->conn = hidp_find_connection(session); + if (!session->conn) { + err = -ENOTCONN; + goto failed; + } + bacpy(&session->bdaddr, &bt_sk(ctrl_sock->sk)->dst); session->ctrl_mtu = min_t(uint, l2cap_pi(ctrl_sock->sk)->chan->omtu, @@ -1018,6 +1024,8 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID); session->idle_to = req->idle_to; + __hidp_link_session(session); + if (req->rd_size > 0) { err = hidp_setup_hid(session, req); if (err) @@ -1030,8 +1038,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, goto purge; } - __hidp_link_session(session); - hidp_set_timer(session); if (session->hid) { @@ -1084,8 +1090,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, unlink: hidp_del_timer(session); - __hidp_unlink_session(session); - if (session->input) { input_unregister_device(session->input); session->input = NULL; @@ -1100,6 +1104,8 @@ unlink: session->rd_data = NULL; purge: + __hidp_unlink_session(session); + skb_queue_purge(&session->ctrl_transmit); skb_queue_purge(&session->intr_transmit); -- cgit v0.10.2 From 81b25cd04387fbceb76fe893db4863a380941413 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 6 Oct 2011 23:32:29 -0300 Subject: Bluetooth: Delay session allocation in hidp It gets allocated only when it is really needed. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 304a73f..fbbf802 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -979,18 +979,20 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst)) return -ENOTUNIQ; - session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL); - if (!session) - return -ENOMEM; - BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size); down_write(&hidp_session_sem); s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst); if (s && s->state == BT_CONNECTED) { - err = -EEXIST; - goto failed; + up_write(&hidp_session_sem); + return -EEXIST; + } + + session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL); + if (!session) { + up_write(&hidp_session_sem); + return -ENOMEM; } session->conn = hidp_find_connection(session); -- cgit v0.10.2 From 3e90dc86f4b840297bd1fafdb9ba1bf58f2e0e49 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Fri, 7 Oct 2011 01:29:51 -0300 Subject: Bluetooth: Rename hidp_find_connection() hidp_get_connection() makes more sense because we hold a reference to the connection inside this function. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index fbbf802..217ef47 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -783,7 +783,7 @@ static int hidp_session(void *arg) return 0; } -static struct hci_conn *hidp_find_connection(struct hidp_session *session) +static struct hci_conn *hidp_get_connection(struct hidp_session *session) { bdaddr_t *src = &bt_sk(session->ctrl_sock->sk)->src; bdaddr_t *dst = &bt_sk(session->ctrl_sock->sk)->dst; @@ -995,7 +995,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, return -ENOMEM; } - session->conn = hidp_find_connection(session); + session->conn = hidp_get_connection(session); if (!session->conn) { err = -ENOTCONN; goto failed; -- cgit v0.10.2 From 784f694d0f3ca927361aa0c26de1aa340eb5b275 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:39 +0200 Subject: wl12xx: replace wl->mac_addr with vif->addr The mac address of the interface already exists in vif->addr. Use it instead of wl->mac_addr. It seems that due to some fw bug, we still need to set nvs->mac to the actual mac addresss, otherwise the fw doesn't function well (e.g. can't get dhcp address). Thus, use wl->mac_addr for this purpose, and don't delete it yet. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index a52299e..bee44c7 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -358,7 +358,8 @@ static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask) return 0; } -int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 role_type, u8 *role_id) +int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, + u8 *role_id) { struct wl12xx_cmd_role_enable *cmd; int ret; @@ -381,7 +382,7 @@ int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 role_type, u8 *role_id) goto out_free; } - memcpy(cmd->mac_address, wl->mac_addr, ETH_ALEN); + memcpy(cmd->mac_address, addr, ETH_ALEN); cmd->role_type = role_type; ret = wl1271_cmd_send(wl, CMD_ROLE_ENABLE, cmd, sizeof(*cmd), 0); @@ -1200,14 +1201,14 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr) return ret; } -int wl1271_build_qos_null_data(struct wl1271 *wl) +int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct ieee80211_qos_hdr template; memset(&template, 0, sizeof(template)); memcpy(template.addr1, wl->bssid, ETH_ALEN); - memcpy(template.addr2, wl->mac_addr, ETH_ALEN); + memcpy(template.addr2, vif->addr, ETH_ALEN); memcpy(template.addr3, wl->bssid, ETH_ALEN); template.frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index b7bd427..1ae949f 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -36,7 +36,8 @@ int wl128x_cmd_general_parms(struct wl1271 *wl); int wl1271_cmd_radio_parms(struct wl1271 *wl); int wl128x_cmd_radio_parms(struct wl1271 *wl); int wl1271_cmd_ext_radio_parms(struct wl1271 *wl); -int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 role_type, u8 *role_id); +int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, + u8 *role_id); int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); int wl12xx_cmd_role_start_dev(struct wl1271 *wl); int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); @@ -62,7 +63,7 @@ int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, struct sk_buff *skb); int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr); -int wl1271_build_qos_null_data(struct wl1271 *wl); +int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); int wl1271_cmd_build_klv_null_data(struct wl1271 *wl); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 674ad2a..7e3ff80 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -234,7 +234,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) wl1271_debug(DEBUG_EVENT, "status: 0x%x", mbox->scheduled_scan_status); - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, wl->scan_vif); } if (vector & PERIODIC_SCAN_REPORT_EVENT_ID) { diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 04db64c..4692a91 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -123,7 +123,8 @@ out: return ret; } -static int wl1271_ap_init_null_template(struct wl1271 *wl) +static int wl1271_ap_init_null_template(struct wl1271 *wl, + struct ieee80211_vif *vif) { struct ieee80211_hdr_3addr *nullfunc; int ret; @@ -141,8 +142,8 @@ static int wl1271_ap_init_null_template(struct wl1271 *wl) /* nullfunc->addr1 is filled by FW */ - memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN); - memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN); + memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); + memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, @@ -153,7 +154,8 @@ out: return ret; } -static int wl1271_ap_init_qos_null_template(struct wl1271 *wl) +static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, + struct ieee80211_vif *vif) { struct ieee80211_qos_hdr *qosnull; int ret; @@ -171,8 +173,8 @@ static int wl1271_ap_init_qos_null_template(struct wl1271 *wl) /* qosnull->addr1 is filled by FW */ - memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN); - memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN); + memcpy(qosnull->addr2, vif->addr, ETH_ALEN); + memcpy(qosnull->addr3, vif->addr, ETH_ALEN); rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, @@ -449,7 +451,7 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) return 0; } -int wl1271_ap_init_templates(struct wl1271 *wl) +int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) { int ret; @@ -457,11 +459,11 @@ int wl1271_ap_init_templates(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_ap_init_null_template(wl); + ret = wl1271_ap_init_null_template(wl, vif); if (ret < 0) return ret; - ret = wl1271_ap_init_qos_null_template(wl); + ret = wl1271_ap_init_qos_null_template(wl, vif); if (ret < 0) return ret; @@ -476,9 +478,10 @@ int wl1271_ap_init_templates(struct wl1271 *wl) return 0; } -static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl) +static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, + struct ieee80211_vif *vif) { - return wl1271_ap_init_templates(wl); + return wl1271_ap_init_templates(wl, vif); } int wl1271_init_ap_rates(struct wl1271 *wl) @@ -576,7 +579,7 @@ out: } -int wl1271_hw_init(struct wl1271 *wl) +int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) { struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; @@ -694,7 +697,7 @@ int wl1271_hw_init(struct wl1271 *wl) /* Mode specific init - post mem init */ if (is_ap) - ret = wl1271_ap_hw_init_post_mem(wl); + ret = wl1271_ap_hw_init_post_mem(wl, vif); else ret = wl1271_sta_hw_init_post_mem(wl); diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h index 3a3c230..b1f97bc 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/init.h @@ -32,8 +32,8 @@ int wl1271_init_phy_config(struct wl1271 *wl); int wl1271_init_pta(struct wl1271 *wl); int wl1271_init_energy_detection(struct wl1271 *wl); int wl1271_chip_specific_init(struct wl1271 *wl); -int wl1271_hw_init(struct wl1271 *wl); +int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif); int wl1271_init_ap_rates(struct wl1271 *wl); -int wl1271_ap_init_templates(struct wl1271 *wl); +int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 884f82b..652471e 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1896,6 +1896,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EINVAL; goto out; } + /* + * we still need this in order to configure the fw + * while uploading the nvs + */ memcpy(wl->mac_addr, vif->addr, ETH_ALEN); if (wl->state != WL1271_STATE_OFF) { @@ -1923,18 +1927,19 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, * the STA role can get packets only from * its associated bssid) */ - ret = wl12xx_cmd_role_enable(wl, + ret = wl12xx_cmd_role_enable(wl, vif->addr, WL1271_ROLE_DEVICE, &wl->dev_role_id); if (ret < 0) goto irq_disable; } - ret = wl12xx_cmd_role_enable(wl, role_type, &wl->role_id); + ret = wl12xx_cmd_role_enable(wl, vif->addr, + role_type, &wl->role_id); if (ret < 0) goto irq_disable; - ret = wl1271_hw_init(wl); + ret = wl1271_hw_init(wl, vif); if (ret < 0) goto irq_disable; @@ -2019,6 +2024,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); + wl->scan_vif = NULL; wl->scan.req = NULL; ieee80211_scan_completed(wl->hw, true); } @@ -2885,7 +2891,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, wl12xx_cmd_role_stop_dev(wl); } - ret = wl1271_scan(hw->priv, ssid, len, req); + ret = wl1271_scan(hw->priv, vif, ssid, len, req); out_sleep: wl1271_ps_elp_sleep(wl); out: @@ -2921,6 +2927,7 @@ static void wl1271_op_cancel_hw_scan(struct ieee80211_hw *hw, } wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); + wl->scan_vif = NULL; wl->scan.req = NULL; ieee80211_scan_completed(wl->hw, true); @@ -3295,7 +3302,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, goto out; } - ret = wl1271_ap_init_templates(wl); + ret = wl1271_ap_init_templates(wl, vif); if (ret < 0) goto out; } @@ -3428,7 +3435,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (ret < 0) goto out; - ret = wl1271_build_qos_null_data(wl); + ret = wl1271_build_qos_null_data(wl, vif); if (ret < 0) goto out; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 128ccb7..a857618 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -53,6 +53,7 @@ void wl1271_scan_complete_work(struct work_struct *work) wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan.req = NULL; + wl->scan_vif = NULL; ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) @@ -155,8 +156,9 @@ static int wl1271_get_scan_channels(struct wl1271 *wl, #define WL1271_NOTHING_TO_SCAN 1 -static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band, - bool passive, u32 basic_rate) +static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, + enum ieee80211_band band, + bool passive, u32 basic_rate) { struct wl1271_cmd_scan *cmd; struct wl1271_cmd_trigger_scan_to *trigger; @@ -208,7 +210,7 @@ static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band, memcpy(cmd->params.ssid, wl->scan.ssid, wl->scan.ssid_len); } - memcpy(cmd->addr, wl->mac_addr, ETH_ALEN); + memcpy(cmd->addr, vif->addr, ETH_ALEN); ret = wl1271_cmd_build_probe_req(wl, wl->scan.ssid, wl->scan.ssid_len, wl->scan.req->ie, wl->scan.req->ie_len, @@ -241,7 +243,7 @@ out: return ret; } -void wl1271_scan_stm(struct wl1271 *wl) +void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) { int ret = 0; enum ieee80211_band band; @@ -254,10 +256,10 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_2GHZ_ACTIVE: band = IEEE80211_BAND_2GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, false, rate); + ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -265,13 +267,13 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_2GHZ_PASSIVE: band = IEEE80211_BAND_2GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, true, rate); + ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { if (wl->enable_11a) wl->scan.state = WL1271_SCAN_STATE_5GHZ_ACTIVE; else wl->scan.state = WL1271_SCAN_STATE_DONE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -279,10 +281,10 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_5GHZ_ACTIVE: band = IEEE80211_BAND_5GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, false, rate); + ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -290,10 +292,10 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_5GHZ_PASSIVE: band = IEEE80211_BAND_5GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, true, rate); + ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_DONE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -317,7 +319,8 @@ void wl1271_scan_stm(struct wl1271 *wl) } } -int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, +int wl1271_scan(struct wl1271 *wl, struct ieee80211_vif *vif, + const u8 *ssid, size_t ssid_len, struct cfg80211_scan_request *req) { /* @@ -338,6 +341,7 @@ int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, wl->scan.ssid_len = 0; } + wl->scan_vif = vif; wl->scan.req = req; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); @@ -346,7 +350,7 @@ int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work, msecs_to_jiffies(WL1271_SCAN_TIMEOUT)); - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); return 0; } diff --git a/drivers/net/wireless/wl12xx/scan.h b/drivers/net/wireless/wl12xx/scan.h index 9211515..15177bd 100644 --- a/drivers/net/wireless/wl12xx/scan.h +++ b/drivers/net/wireless/wl12xx/scan.h @@ -26,13 +26,14 @@ #include "wl12xx.h" -int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, +int wl1271_scan(struct wl1271 *wl, struct ieee80211_vif *vif, + const u8 *ssid, size_t ssid_len, struct cfg80211_scan_request *req); int wl1271_scan_stop(struct wl1271 *wl); int wl1271_scan_build_probe_req(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band); -void wl1271_scan_stm(struct wl1271 *wl); +void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_scan_complete_work(struct work_struct *work); int wl1271_scan_sched_scan_config(struct wl1271 *wl, struct cfg80211_sched_scan_request *req, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 1ec90fc..b8de2f5 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -507,6 +507,7 @@ struct wl1271 { u32 mbox_ptr[2]; /* Are we currently scanning */ + struct ieee80211_vif *scan_vif; struct wl1271_scan scan; struct delayed_work scan_complete_work; -- cgit v0.10.2 From 92c77c734f958474ac73af670834bc32cb833e54 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:40 +0200 Subject: wl12xx: start reworking the init sequence Split the init sequence into common commands (non role-specific) and role-specific commands. We still need to call the common commands only on add_interface() (rather than on start()) as the fw must get the mac address when uploading the nvs. Future patches will refactor the init sequence further more. Signed-off-by: Eliad Peller [fixed a couple of sparse warnings] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 4692a91..145601d 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -33,7 +33,7 @@ #include "tx.h" #include "io.h" -int wl1271_sta_init_templates_config(struct wl1271 *wl) +int wl1271_init_templates_config(struct wl1271 *wl) { int ret, i; @@ -88,6 +88,29 @@ int wl1271_sta_init_templates_config(struct wl1271 *wl) if (ret < 0) return ret; + /* + * Put very large empty placeholders for all templates. These + * reserve memory for later. + */ + ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL, + WL1271_CMD_TEMPL_MAX_SIZE, + 0, WL1271_RATE_AUTOMATIC); + if (ret < 0) + return ret; + + ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL, + WL1271_CMD_TEMPL_MAX_SIZE, + 0, WL1271_RATE_AUTOMATIC); + if (ret < 0) + return ret; + + ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL, + sizeof + (struct wl12xx_disconn_template), + 0, WL1271_RATE_AUTOMATIC); + if (ret < 0) + return ret; + for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, WL1271_CMD_TEMPL_DFLT_SIZE, i, @@ -185,68 +208,32 @@ out: return ret; } -static int wl1271_ap_init_templates_config(struct wl1271 *wl) +static int wl12xx_init_rx_config(struct wl1271 *wl) { int ret; - /* - * Put very large empty placeholders for all templates. These - * reserve memory for later. - */ - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL, - WL1271_CMD_TEMPL_MAX_SIZE, - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL, - WL1271_CMD_TEMPL_MAX_SIZE, - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL, - sizeof - (struct wl12xx_disconn_template), - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL, - sizeof(struct wl12xx_null_data_template), - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL, - sizeof - (struct wl12xx_qos_null_data_template), - 0, WL1271_RATE_AUTOMATIC); + ret = wl1271_acx_rx_msdu_life_time(wl); if (ret < 0) return ret; return 0; } -static int wl12xx_init_rx_config(struct wl1271 *wl) +int wl1271_init_phy_config(struct wl1271 *wl) { int ret; - ret = wl1271_acx_rx_msdu_life_time(wl); + ret = wl1271_acx_pd_threshold(wl); if (ret < 0) return ret; return 0; } -int wl1271_init_phy_config(struct wl1271 *wl) +static int wl12xx_init_phy_vif_config(struct wl1271 *wl) { int ret; - ret = wl1271_acx_pd_threshold(wl); - if (ret < 0) - return ret; - ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME); if (ret < 0) return ret; @@ -329,6 +316,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl) return 0; } +/* generic sta initialization (non vif-specific) */ static int wl1271_sta_hw_init(struct wl1271 *wl) { int ret; @@ -344,57 +332,20 @@ static int wl1271_sta_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_sta_init_templates_config(wl); - if (ret < 0) - return ret; - - ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0); - if (ret < 0) - return ret; - - /* Initialize connection monitoring thresholds */ - ret = wl1271_acx_conn_monit_params(wl, false); - if (ret < 0) - return ret; - - /* Beacon filtering */ - ret = wl1271_init_beacon_filter(wl); - if (ret < 0) - return ret; - /* FM WLAN coexistence */ ret = wl1271_acx_fm_coex(wl); if (ret < 0) return ret; - /* Beacons and broadcast settings */ - ret = wl1271_init_beacon_broadcast(wl); - if (ret < 0) - return ret; - /* Configure for ELP power saving */ ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); if (ret < 0) return ret; - /* Configure rssi/snr averaging weights */ - ret = wl1271_acx_rssi_snr_avg_weights(wl); - if (ret < 0) - return ret; - ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) return ret; - ret = wl12xx_acx_mem_cfg(wl); - if (ret < 0) - return ret; - - /* Configure the FW logger */ - ret = wl12xx_init_fwlog(wl); - if (ret < 0) - return ret; - return 0; } @@ -418,14 +369,11 @@ static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) return 0; } +/* generic ap initialization (non vif-specific) */ static int wl1271_ap_hw_init(struct wl1271 *wl) { int ret; - ret = wl1271_ap_init_templates_config(wl); - if (ret < 0) - return ret; - /* Configure for power always on */ ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); if (ret < 0) @@ -435,19 +383,6 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_acx_ap_max_tx_retry(wl); - if (ret < 0) - return ret; - - ret = wl12xx_acx_mem_cfg(wl); - if (ret < 0) - return ret; - - /* initialize Tx power */ - ret = wl1271_acx_tx_power(wl, wl->power_level); - if (ret < 0) - return ret; - return 0; } @@ -578,14 +513,133 @@ out: return ret; } +/* vif-specifc initialization */ +static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif) +{ + int ret; + + ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0); + if (ret < 0) + return ret; + + /* Initialize connection monitoring thresholds */ + ret = wl1271_acx_conn_monit_params(wl, false); + if (ret < 0) + return ret; + + /* Beacon filtering */ + ret = wl1271_init_beacon_filter(wl); + if (ret < 0) + return ret; + + /* Beacons and broadcast settings */ + ret = wl1271_init_beacon_broadcast(wl); + if (ret < 0) + return ret; -int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) + /* Configure rssi/snr averaging weights */ + ret = wl1271_acx_rssi_snr_avg_weights(wl); + if (ret < 0) + return ret; + + return 0; +} + +/* vif-specific intialization */ +static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif) +{ + int ret; + + ret = wl1271_acx_ap_max_tx_retry(wl); + if (ret < 0) + return ret; + + /* initialize Tx power */ + ret = wl1271_acx_tx_power(wl, wl->power_level); + if (ret < 0) + return ret; + + return 0; +} + +int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) { struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; - int ret, i; bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + int ret, i; + + /* Mode specific init */ + if (is_ap) { + ret = wl1271_ap_hw_init(wl); + if (ret < 0) + return ret; + + ret = wl12xx_init_ap_role(wl, vif); + if (ret < 0) + return ret; + } else { + ret = wl1271_sta_hw_init(wl); + if (ret < 0) + return ret; + + ret = wl12xx_init_sta_role(wl, vif); + if (ret < 0) + return ret; + } + + wl12xx_init_phy_vif_config(wl); + + /* Default TID/AC configuration */ + BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); + for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { + conf_ac = &wl->conf.tx.ac_conf[i]; + ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, + conf_ac->cw_max, conf_ac->aifsn, + conf_ac->tx_op_limit); + if (ret < 0) + return ret; + + conf_tid = &wl->conf.tx.tid_conf[i]; + ret = wl1271_acx_tid_cfg(wl, + conf_tid->queue_id, + conf_tid->channel_type, + conf_tid->tsid, + conf_tid->ps_scheme, + conf_tid->ack_policy, + conf_tid->apsd_conf[0], + conf_tid->apsd_conf[1]); + if (ret < 0) + return ret; + } + + /* Configure HW encryption */ + ret = wl1271_acx_feature_cfg(wl); + if (ret < 0) + return ret; + + /* Mode specific init - post mem init */ + if (is_ap) + ret = wl1271_ap_hw_init_post_mem(wl, vif); + else + ret = wl1271_sta_hw_init_post_mem(wl); + + if (ret < 0) + return ret; + + /* Configure initiator BA sessions policies */ + ret = wl1271_set_ba_policies(wl); + if (ret < 0) + return ret; + + return 0; +} + +int wl1271_hw_init(struct wl1271 *wl) +{ + int ret; + if (wl->chip.id == CHIP_ID_1283_PG20) ret = wl128x_cmd_general_parms(wl); else @@ -605,12 +659,17 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; - /* Mode specific init */ - if (is_ap) - ret = wl1271_ap_hw_init(wl); - else - ret = wl1271_sta_hw_init(wl); + /* Init templates */ + ret = wl1271_init_templates_config(wl); + if (ret < 0) + return ret; + ret = wl12xx_acx_mem_cfg(wl); + if (ret < 0) + return ret; + + /* Configure the FW logger */ + ret = wl12xx_init_fwlog(wl); if (ret < 0) return ret; @@ -658,61 +717,20 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) goto out_free_memmap; - /* Default TID/AC configuration */ - BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); - for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { - conf_ac = &wl->conf.tx.ac_conf[i]; - ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, - conf_ac->cw_max, conf_ac->aifsn, - conf_ac->tx_op_limit); - if (ret < 0) - goto out_free_memmap; - - conf_tid = &wl->conf.tx.tid_conf[i]; - ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id, - conf_tid->channel_type, - conf_tid->tsid, - conf_tid->ps_scheme, - conf_tid->ack_policy, - conf_tid->apsd_conf[0], - conf_tid->apsd_conf[1]); - if (ret < 0) - goto out_free_memmap; - } - /* Enable data path */ ret = wl1271_cmd_data_path(wl, 1); if (ret < 0) goto out_free_memmap; - /* Configure HW encryption */ - ret = wl1271_acx_feature_cfg(wl); - if (ret < 0) - goto out_free_memmap; - /* configure PM */ ret = wl1271_acx_pm_config(wl); if (ret < 0) goto out_free_memmap; - /* Mode specific init - post mem init */ - if (is_ap) - ret = wl1271_ap_hw_init_post_mem(wl, vif); - else - ret = wl1271_sta_hw_init_post_mem(wl); - - if (ret < 0) - goto out_free_memmap; - ret = wl12xx_acx_set_rate_mgmt_params(wl); if (ret < 0) goto out_free_memmap; - /* Configure initiator BA sessions policies */ - ret = wl1271_set_ba_policies(wl); - if (ret < 0) - goto out_free_memmap; - /* configure hangover */ ret = wl12xx_acx_config_hangover(wl); if (ret < 0) diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h index b1f97bc..64320c0 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/init.h @@ -27,12 +27,13 @@ #include "wl12xx.h" int wl1271_hw_init_power_auth(struct wl1271 *wl); -int wl1271_sta_init_templates_config(struct wl1271 *wl); +int wl1271_init_templates_config(struct wl1271 *wl); int wl1271_init_phy_config(struct wl1271 *wl); int wl1271_init_pta(struct wl1271 *wl); int wl1271_init_energy_detection(struct wl1271 *wl); int wl1271_chip_specific_init(struct wl1271 *wl); -int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif); +int wl1271_hw_init(struct wl1271 *wl); +int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif); int wl1271_init_ap_rates(struct wl1271 *wl); int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 652471e..901e43a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -676,7 +676,7 @@ static int wl1271_plt_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_sta_init_templates_config(wl); + ret = wl1271_init_templates_config(wl); if (ret < 0) return ret; @@ -1919,6 +1919,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto power_off; + ret = wl1271_hw_init(wl); + if (ret < 0) + goto irq_disable; + if (wl->bss_type == BSS_TYPE_STA_BSS || wl->bss_type == BSS_TYPE_IBSS) { /* @@ -1939,7 +1943,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto irq_disable; - ret = wl1271_hw_init(wl, vif); + ret = wl1271_init_vif_specific(wl, vif); if (ret < 0) goto irq_disable; -- cgit v0.10.2 From 87fbcb0f8c5c8fd57a4e3e7e638977c04ce1e0ca Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:41 +0200 Subject: wl12xx: define wl12xx_vif Define a per-vif data struct. This struct holds all the vif-specifc data, which is currently being hold by the global wl struct. Start by moving the basic_rate_set field into it. NOTE: in order to make the patches a bit smaller, start by using wl->vif in some functions, instead of changing all the function prototypes at once. finally, wl->vif will be removed altogether. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index bee44c7..c99fc61 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -555,7 +555,7 @@ out: return ret; } -int wl12xx_cmd_role_start_sta(struct wl1271 *wl) +int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; int ret; @@ -572,7 +572,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl) if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; - cmd->sta.basic_rate_set = cpu_to_le32(wl->basic_rate_set); + cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->sta.ssid_len = wl->ssid_len; @@ -592,7 +592,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wl->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wl->rate_set); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -649,7 +649,7 @@ out: return ret; } -int wl12xx_cmd_role_start_ap(struct wl1271 *wl) +int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; @@ -683,7 +683,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl) cmd->ap.bss_index = WL1271_AP_BSS_INDEX; cmd->ap.global_hlid = wl->ap_global_hlid; cmd->ap.broadcast_hlid = wl->ap_bcast_hlid; - cmd->ap.basic_rate_set = cpu_to_le32(wl->basic_rate_set); + cmd->ap.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP; @@ -767,7 +767,7 @@ out: return ret; } -int wl12xx_cmd_role_start_ibss(struct wl1271 *wl) +int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; @@ -785,7 +785,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl) if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; - cmd->ibss.basic_rate_set = cpu_to_le32(wl->basic_rate_set); + cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; @@ -805,7 +805,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wl->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wl->rate_set); wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid); @@ -1085,7 +1085,8 @@ out: } -int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid) +int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 aid) { struct sk_buff *skb; int ret = 0; @@ -1095,7 +1096,7 @@ int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid) goto out; ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data, - skb->len, 0, wl->basic_rate_set); + skb->len, 0, wlvif->basic_rate_set); out: dev_kfree_skb(skb); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 1ae949f..234a8dc 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -41,11 +41,11 @@ int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); int wl12xx_cmd_role_start_dev(struct wl1271 *wl); int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); -int wl12xx_cmd_role_start_sta(struct wl1271 *wl); +int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_sta(struct wl1271 *wl); -int wl12xx_cmd_role_start_ap(struct wl1271 *wl); +int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_ap(struct wl1271 *wl); -int wl12xx_cmd_role_start_ibss(struct wl1271 *wl); +int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); @@ -56,7 +56,8 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, void *buf, size_t buf_len, int index, u32 rates); int wl1271_cmd_build_null_data(struct wl1271 *wl); -int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid); +int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 aid); int wl1271_cmd_build_probe_req(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 3999fd5..0419aaf 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -353,7 +353,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_HEX(rate_set); - DRIVER_STATE_PRINT_HEX(basic_rate_set); DRIVER_STATE_PRINT_HEX(basic_rate); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 145601d..c00bdf8 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -122,7 +122,8 @@ int wl1271_init_templates_config(struct wl1271 *wl) return 0; } -static int wl1271_ap_init_deauth_template(struct wl1271 *wl) +static int wl1271_ap_init_deauth_template(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl12xx_disconn_template *tmpl; int ret; @@ -137,7 +138,7 @@ static int wl1271_ap_init_deauth_template(struct wl1271 *wl) tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH); - rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, tmpl, sizeof(*tmpl), 0, rate); @@ -149,6 +150,7 @@ out: static int wl1271_ap_init_null_template(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_hdr_3addr *nullfunc; int ret; u32 rate; @@ -168,7 +170,7 @@ static int wl1271_ap_init_null_template(struct wl1271 *wl, memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); - rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, sizeof(*nullfunc), 0, rate); @@ -180,6 +182,7 @@ out: static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_qos_hdr *qosnull; int ret; u32 rate; @@ -199,7 +202,7 @@ static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, memcpy(qosnull->addr2, vif->addr, ETH_ALEN); memcpy(qosnull->addr3, vif->addr, ETH_ALEN); - rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, sizeof(*qosnull), 0, rate); @@ -370,7 +373,7 @@ static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) } /* generic ap initialization (non vif-specific) */ -static int wl1271_ap_hw_init(struct wl1271 *wl) +static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; @@ -379,7 +382,7 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_init_ap_rates(wl); + ret = wl1271_init_ap_rates(wl, wlvif); if (ret < 0) return ret; @@ -388,9 +391,10 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; - ret = wl1271_ap_init_deauth_template(wl); + ret = wl1271_ap_init_deauth_template(wl, wlvif); if (ret < 0) return ret; @@ -419,18 +423,19 @@ static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, return wl1271_ap_init_templates(wl, vif); } -int wl1271_init_ap_rates(struct wl1271 *wl) +int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int i, ret; struct conf_tx_rate_class rc; u32 supported_rates; - wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set); + wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", + wlvif->basic_rate_set); - if (wl->basic_rate_set == 0) + if (wlvif->basic_rate_set == 0) return -EINVAL; - rc.enabled_rates = wl->basic_rate_set; + rc.enabled_rates = wlvif->basic_rate_set; rc.long_retry_limit = 10; rc.short_retry_limit = 10; rc.aflags = 0; @@ -439,7 +444,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl) return ret; /* use the min basic rate for AP broadcast/multicast */ - rc.enabled_rates = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); rc.short_retry_limit = 10; rc.long_retry_limit = 10; rc.aflags = 0; @@ -451,7 +456,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl) * If the basic rates contain OFDM rates, use OFDM only * rates for unicast TX as well. Else use all supported rates. */ - if ((wl->basic_rate_set & CONF_TX_OFDM_RATES)) + if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES)) supported_rates = CONF_TX_OFDM_RATES; else supported_rates = CONF_TX_AP_ENABLED_RATES; @@ -564,6 +569,7 @@ static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif) int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); @@ -572,7 +578,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) /* Mode specific init */ if (is_ap) { - ret = wl1271_ap_hw_init(wl); + ret = wl1271_ap_hw_init(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h index 64320c0..81140b8 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/init.h @@ -34,7 +34,7 @@ int wl1271_init_energy_detection(struct wl1271 *wl); int wl1271_chip_specific_init(struct wl1271 *wl); int wl1271_hw_init(struct wl1271 *wl); int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif); -int wl1271_init_ap_rates(struct wl1271 *wl); +int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 901e43a..0c43cf5 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1837,6 +1837,11 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) return WL12XX_INVALID_ROLE_TYPE; } +static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) +{ + wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; +} + static int wl1271_op_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -1857,6 +1862,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EBUSY; goto out; } + wl12xx_init_vif_data(wl12xx_vif_to_data(vif)); /* * in some very corner case HW recovery scenarios its possible to @@ -2163,7 +2169,8 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, cancel_work_sync(&wl->recovery_work); } -static int wl1271_join(struct wl1271 *wl, bool set_assoc) +static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool set_assoc) { int ret; bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); @@ -2184,9 +2191,9 @@ static int wl1271_join(struct wl1271 *wl, bool set_assoc) set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags); if (is_ibss) - ret = wl12xx_cmd_role_start_ibss(wl); + ret = wl12xx_cmd_role_start_ibss(wl, wlvif); else - ret = wl12xx_cmd_role_start_sta(wl); + ret = wl12xx_cmd_role_start_sta(wl, wlvif); if (ret < 0) goto out; @@ -2244,10 +2251,10 @@ out: return ret; } -static void wl1271_set_band_rate(struct wl1271 *wl) +static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - wl->basic_rate_set = wl->bitrate_masks[wl->band]; - wl->rate_set = wl->basic_rate_set; + wlvif->basic_rate_set = wl->bitrate_masks[wl->band]; + wl->rate_set = wlvif->basic_rate_set; } static bool wl12xx_is_roc(struct wl1271 *wl) @@ -2261,7 +2268,8 @@ static bool wl12xx_is_roc(struct wl1271 *wl) return true; } -static int wl1271_sta_handle_idle(struct wl1271 *wl, bool idle) +static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool idle) { int ret; @@ -2276,7 +2284,8 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, bool idle) if (ret < 0) goto out; } - wl->rate_set = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl->rate_set = wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) goto out; @@ -2310,6 +2319,8 @@ out: static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: reconfig all vifs */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_conf *conf = &hw->conf; int channel, ret = 0; bool is_ap; @@ -2371,10 +2382,11 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * association frames and other control messages. */ if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) - wl1271_set_band_rate(wl); + wl1271_set_band_rate(wl, wlvif); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) wl1271_warning("rate policy for channel " @@ -2387,7 +2399,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (ret < 0) goto out_sleep; } - ret = wl1271_join(wl, false); + ret = wl1271_join(wl, wlvif, false); if (ret < 0) wl1271_warning("cmd join on channel " "failed %d", ret); @@ -2413,7 +2425,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) } if (changed & IEEE80211_CONF_CHANGE_IDLE && !is_ap) { - ret = wl1271_sta_handle_idle(wl, + ret = wl1271_sta_handle_idle(wl, wlvif, conf->flags & IEEE80211_CONF_IDLE); if (ret < 0) wl1271_warning("idle mode change failed %d", ret); @@ -3207,6 +3219,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); int ret = 0; @@ -3235,7 +3248,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, dev_kfree_skb(beacon); goto out; } - min_rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + min_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); tmpl_id = is_ap ? CMD_TEMPL_AP_BEACON : CMD_TEMPL_BEACON; ret = wl1271_cmd_template_set(wl, tmpl_id, @@ -3290,17 +3303,18 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; if ((changed & BSS_CHANGED_BASIC_RATES)) { u32 rates = bss_conf->basic_rates; - wl->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, + wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); wl->basic_rate = wl1271_tx_min_rate_get(wl, - wl->basic_rate_set); + wlvif->basic_rate_set); - ret = wl1271_init_ap_rates(wl); + ret = wl1271_init_ap_rates(wl, wlvif); if (ret < 0) { wl1271_error("AP rate policy change failed %d", ret); goto out; @@ -3318,7 +3332,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if ((changed & BSS_CHANGED_BEACON_ENABLED)) { if (bss_conf->enable_beacon) { if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { - ret = wl12xx_cmd_role_start_ap(wl); + ret = wl12xx_cmd_role_start_ap(wl, wlvif); if (ret < 0) goto out; @@ -3366,6 +3380,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); bool do_join = false, set_assoc = false; bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); bool ibss_joined = false; @@ -3480,11 +3495,12 @@ sta_not_found: * to use with control frames. */ rates = bss_conf->basic_rates; - wl->basic_rate_set = + wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); if (sta_rate_set) wl->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rate_set, @@ -3499,7 +3515,7 @@ sta_not_found: * updates it by itself when the first beacon is * received after a join. */ - ret = wl1271_cmd_build_ps_poll(wl, wl->aid); + ret = wl1271_cmd_build_ps_poll(wl, wlvif, wl->aid); if (ret < 0) goto out; @@ -3534,9 +3550,10 @@ sta_not_found: ieee80211_enable_dyn_ps(wl->vif); /* revert back to minimum rates for the current band */ - wl1271_set_band_rate(wl); + wl1271_set_band_rate(wl, wlvif); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) goto out; @@ -3587,11 +3604,12 @@ sta_not_found: if (bss_conf->ibss_joined) { u32 rates = bss_conf->basic_rates; - wl->basic_rate_set = + wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); /* by default, use 11b + OFDM rates */ wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES; @@ -3634,7 +3652,7 @@ sta_not_found: } if (do_join) { - ret = wl1271_join(wl, set_assoc); + ret = wl1271_join(wl, wlvif, set_assoc); if (ret < 0) { wl1271_warning("cmd join failed %d", ret); goto out; @@ -4750,6 +4768,7 @@ int wl1271_init_ieee80211(struct wl1271 *wl) SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl)); wl->hw->sta_data_size = sizeof(struct wl1271_station); + wl->hw->vif_data_size = sizeof(struct wl12xx_vif); wl->hw->max_rx_aggregation_subframes = 8; @@ -4824,7 +4843,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->rx_counter = 0; wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; - wl->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wl->basic_rate = CONF_TX_RATE_MASK_BASIC; wl->rate_set = CONF_TX_RATE_MASK_BASIC; wl->band = IEEE80211_BAND_2GHZ; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b8de2f5..7e30dd5 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -525,7 +525,6 @@ struct wl1271 { * bits 16-23 - 802.11n MCS index mask * support only 1 stream, thus only 8 bits for the MCS rates (0-7). */ - u32 basic_rate_set; u32 basic_rate; u32 rate_set; u32 bitrate_masks[IEEE80211_NUM_BANDS]; @@ -639,6 +638,21 @@ struct wl1271_station { u8 hlid; }; +struct wl12xx_vif { + u32 basic_rate_set; +}; + +static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) +{ + return (struct wl12xx_vif *)vif->drv_priv; +} + +static inline +struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) +{ + return container_of((void *)wlvif, struct ieee80211_vif, drv_priv); +} + int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); int wl1271_recalc_rx_streaming(struct wl1271 *wl); -- cgit v0.10.2 From 30d0c8fd5b87d1c5486705d6420545a21533e115 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:42 +0200 Subject: wl12xx: move rate_set into wlvif move rate_set into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index ca044a7..1ef9b0b 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -739,7 +739,7 @@ int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats) return 0; } -int wl1271_acx_sta_rate_policies(struct wl1271 *wl) +int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_rate_policy *acx; struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf; @@ -755,7 +755,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl) } wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x", - wl->basic_rate, wl->rate_set); + wl->basic_rate, wlvif->rate_set); /* configure one basic rate class */ acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE); @@ -772,7 +772,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl) /* configure one AP supported rate class */ acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE); - acx->rate_policy.enabled_rates = cpu_to_le32(wl->rate_set); + acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; acx->rate_policy.aflags = c->aflags; diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index e3f93b4..81779f4 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1261,7 +1261,7 @@ int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble); int wl1271_acx_cts_protect(struct wl1271 *wl, enum acx_ctsprotect_type ctsprotect); int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats); -int wl1271_acx_sta_rate_policies(struct wl1271 *wl); +int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c, u8 idx); int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index c99fc61..6a2f758 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -578,7 +578,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.ssid_len = wl->ssid_len; memcpy(cmd->sta.ssid, wl->ssid, wl->ssid_len); memcpy(cmd->sta.bssid, wl->bssid, ETH_ALEN); - cmd->sta.local_rates = cpu_to_le32(wl->rate_set); + cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { ret = wl12xx_allocate_link(wl, &wl->sta_hlid); @@ -587,12 +587,12 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) } cmd->sta.hlid = wl->sta_hlid; cmd->sta.session = wl12xx_get_new_session_id(wl); - cmd->sta.remote_rates = cpu_to_le32(wl->rate_set); + cmd->sta.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wlvif->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wlvif->rate_set); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -792,7 +792,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ibss.ssid_len = wl->ssid_len; memcpy(cmd->ibss.ssid, wl->ssid, wl->ssid_len); memcpy(cmd->ibss.bssid, wl->bssid, ETH_ALEN); - cmd->sta.local_rates = cpu_to_le32(wl->rate_set); + cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { ret = wl12xx_allocate_link(wl, &wl->sta_hlid); @@ -800,12 +800,12 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } cmd->ibss.hlid = wl->sta_hlid; - cmd->ibss.remote_rates = cpu_to_le32(wl->rate_set); + cmd->ibss.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wlvif->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wlvif->rate_set); wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 0419aaf..e63fea4 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -352,7 +352,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); - DRIVER_STATE_PRINT_HEX(rate_set); DRIVER_STATE_PRINT_HEX(basic_rate); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index c00bdf8..37955da 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -320,7 +320,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl) } /* generic sta initialization (non vif-specific) */ -static int wl1271_sta_hw_init(struct wl1271 *wl) +static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; @@ -345,7 +345,7 @@ static int wl1271_sta_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) return ret; @@ -586,7 +586,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; } else { - ret = wl1271_sta_hw_init(wl); + ret = wl1271_sta_hw_init(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0c43cf5..195dcbd 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1840,6 +1840,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; + wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; } static int wl1271_op_add_interface(struct ieee80211_hw *hw, @@ -2106,7 +2107,6 @@ deinit: wl->tx_packets_count = 0; wl->time_offset = 0; wl->session_counter = 0; - wl->rate_set = CONF_TX_RATE_MASK_BASIC; wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl->vif = NULL; @@ -2254,7 +2254,7 @@ out: static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { wlvif->basic_rate_set = wl->bitrate_masks[wl->band]; - wl->rate_set = wlvif->basic_rate_set; + wlvif->rate_set = wlvif->basic_rate_set; } static bool wl12xx_is_roc(struct wl1271 *wl) @@ -2284,9 +2284,9 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; } - wl->rate_set = wl1271_tx_min_rate_get(wl, - wlvif->basic_rate_set); - ret = wl1271_acx_sta_rate_policies(wl); + wlvif->rate_set = + wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; ret = wl1271_acx_keep_alive_config( @@ -2387,7 +2387,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wl->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) wl1271_warning("rate policy for channel " "failed %d", ret); @@ -3502,10 +3502,11 @@ sta_not_found: wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); if (sta_rate_set) - wl->rate_set = wl1271_tx_enabled_rates_get(wl, + wlvif->rate_set = + wl1271_tx_enabled_rates_get(wl, sta_rate_set, wl->band); - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; @@ -3554,7 +3555,7 @@ sta_not_found: wl->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; @@ -3612,8 +3613,8 @@ sta_not_found: wlvif->basic_rate_set); /* by default, use 11b + OFDM rates */ - wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES; - ret = wl1271_acx_sta_rate_policies(wl); + wlvif->rate_set = CONF_TX_IBSS_DEFAULT_RATES; + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; } @@ -4844,7 +4845,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; wl->basic_rate = CONF_TX_RATE_MASK_BASIC; - wl->rate_set = CONF_TX_RATE_MASK_BASIC; wl->band = IEEE80211_BAND_2GHZ; wl->vif = NULL; wl->flags = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 7e30dd5..6f3efba 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -526,7 +526,6 @@ struct wl1271 { * support only 1 stream, thus only 8 bits for the MCS rates (0-7). */ u32 basic_rate; - u32 rate_set; u32 bitrate_masks[IEEE80211_NUM_BANDS]; /* The current band */ @@ -640,6 +639,14 @@ struct wl1271_station { struct wl12xx_vif { u32 basic_rate_set; + + /* + * currently configured rate set: + * bits 0-15 - 802.11abg rates + * bits 16-23 - 802.11n MCS index mask + * support only 1 stream, thus only 8 bits for the MCS rates (0-7). + */ + u32 rate_set; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From d2d66c56cf6c8727662aa321991f791604c22094 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:43 +0200 Subject: wl12xx: move basic_rate into wlvif move basic_rate into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 1ef9b0b..015938f 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -755,11 +755,11 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) } wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x", - wl->basic_rate, wlvif->rate_set); + wlvif->basic_rate, wlvif->rate_set); /* configure one basic rate class */ acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE); - acx->rate_policy.enabled_rates = cpu_to_le32(wl->basic_rate); + acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->basic_rate); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; acx->rate_policy.aflags = c->aflags; @@ -1567,7 +1567,7 @@ out: return ret; } -int wl1271_acx_config_ps(struct wl1271 *wl) +int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl1271_acx_config_ps *config_ps; int ret; @@ -1582,7 +1582,7 @@ int wl1271_acx_config_ps(struct wl1271 *wl) config_ps->exit_retries = wl->conf.conn.psm_exit_retries; config_ps->enter_retries = wl->conf.conn.psm_entry_retries; - config_ps->null_data_rate = cpu_to_le32(wl->basic_rate); + config_ps->null_data_rate = cpu_to_le32(wlvif->basic_rate); ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps, sizeof(*config_ps)); diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 81779f4..2678e1d 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1295,7 +1295,7 @@ int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl); -int wl1271_acx_config_ps(struct wl1271 *wl); +int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); int wl1271_acx_fm_coex(struct wl1271 *wl); int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 6a2f758..ce73415 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1031,7 +1031,7 @@ out: return ret; } -int wl1271_cmd_build_null_data(struct wl1271 *wl) +int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct sk_buff *skb = NULL; int size; @@ -1043,7 +1043,8 @@ int wl1271_cmd_build_null_data(struct wl1271 *wl) size = sizeof(struct wl12xx_null_data_template); ptr = NULL; } else { - skb = ieee80211_nullfunc_get(wl->hw, wl->vif); + skb = ieee80211_nullfunc_get(wl->hw, + wl12xx_wlvif_to_vif(wlvif)); if (!skb) goto out; size = skb->len; @@ -1051,7 +1052,7 @@ int wl1271_cmd_build_null_data(struct wl1271 *wl) } ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, ptr, size, 0, - wl->basic_rate); + wlvif->basic_rate); out: dev_kfree_skb(skb); @@ -1062,19 +1063,21 @@ out: } -int wl1271_cmd_build_klv_null_data(struct wl1271 *wl) +int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct sk_buff *skb = NULL; int ret = -ENOMEM; - skb = ieee80211_nullfunc_get(wl->hw, wl->vif); + skb = ieee80211_nullfunc_get(wl->hw, vif); if (!skb) goto out; ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, skb->data, skb->len, CMD_TEMPL_KLV_IDX_NULL_DATA, - wl->basic_rate); + wlvif->basic_rate); out: dev_kfree_skb(skb); @@ -1161,7 +1164,8 @@ out: return skb; } -int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr) +int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, + __be32 ip_addr) { int ret; struct wl12xx_arp_rsp_template tmpl; @@ -1197,13 +1201,14 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, &tmpl, sizeof(tmpl), 0, - wl->basic_rate); + wlvif->basic_rate); return ret; } int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_qos_hdr template; memset(&template, 0, sizeof(template)); @@ -1221,7 +1226,7 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) return wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, &template, sizeof(template), 0, - wl->basic_rate); + wlvif->basic_rate); } int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid) diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 234a8dc..d5749f5b 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -55,7 +55,7 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, size_t len); int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, void *buf, size_t buf_len, int index, u32 rates); -int wl1271_cmd_build_null_data(struct wl1271 *wl); +int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid); int wl1271_cmd_build_probe_req(struct wl1271 *wl, @@ -63,9 +63,11 @@ int wl1271_cmd_build_probe_req(struct wl1271 *wl, const u8 *ie, size_t ie_len, u8 band); struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, struct sk_buff *skb); -int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr); +int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, + __be32 ip_addr); int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); -int wl1271_cmd_build_klv_null_data(struct wl1271 *wl); +int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index e63fea4..620acbf 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -352,7 +352,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); - DRIVER_STATE_PRINT_HEX(basic_rate); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); DRIVER_STATE_PRINT_INT(psm_entry_retry); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 7e3ff80..af4cef3 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -31,12 +31,16 @@ void wl1271_pspoll_work(struct work_struct *work) { + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; struct delayed_work *dwork; struct wl1271 *wl; int ret; dwork = container_of(work, struct delayed_work, work); wl = container_of(dwork, struct wl1271, pspoll_work); + vif = wl->vif; /* TODO: move work into vif struct */ + wlvif = wl12xx_vif_to_data(vif); wl1271_debug(DEBUG_EVENT, "pspoll work"); @@ -60,14 +64,16 @@ void wl1271_pspoll_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, wl->basic_rate, true); + wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, wlvif->basic_rate, + true); wl1271_ps_elp_sleep(wl); out: mutex_unlock(&wl->mutex); }; -static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl) +static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int delay = wl->conf.conn.ps_poll_recovery_period; int ret; @@ -80,7 +86,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl) /* force active mode receive data from the AP */ if (test_bit(WL1271_FLAG_PSM, &wl->flags)) { ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); if (ret < 0) return; set_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); @@ -97,6 +103,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl) } static int wl1271_event_ps_report(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct event_mailbox *mbox, bool *beacon_loss) { @@ -118,7 +125,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, if (wl->psm_entry_retry < total_retries) { wl->psm_entry_retry++; ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } else { wl1271_info("No ack to nullfunc from AP."); wl->psm_entry_retry = 0; @@ -217,6 +224,8 @@ static void wl1271_event_mbox_dump(struct event_mailbox *mbox) static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; u32 vector; bool beacon_loss = false; @@ -276,13 +285,13 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) if ((vector & PS_REPORT_EVENT_ID) && !is_ap) { wl1271_debug(DEBUG_EVENT, "PS_REPORT_EVENT"); - ret = wl1271_event_ps_report(wl, mbox, &beacon_loss); + ret = wl1271_event_ps_report(wl, wlvif, mbox, &beacon_loss); if (ret < 0) return ret; } if ((vector & PSPOLL_DELIVERY_FAILURE_EVENT_ID) && !is_ap) - wl1271_event_pspoll_delivery_fail(wl); + wl1271_event_pspoll_delivery_fail(wl, wlvif); if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "RSSI_SNR_TRIGGER_0_EVENT"); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 37955da..ed27c5f 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -331,7 +331,7 @@ static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) } /* PS config */ - ret = wl1271_acx_config_ps(wl); + ret = wl12xx_acx_config_ps(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 195dcbd..8863ea5 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1609,7 +1609,8 @@ static struct notifier_block wl1271_dev_notifier = { }; #ifdef CONFIG_PM -static int wl1271_configure_suspend_sta(struct wl1271 *wl) +static int wl1271_configure_suspend_sta(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret = 0; @@ -1628,7 +1629,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl) wl->ps_compl = &compl; ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); if (ret < 0) goto out_sleep; @@ -1682,16 +1683,18 @@ out_unlock: } -static int wl1271_configure_suspend(struct wl1271 *wl) +static int wl1271_configure_suspend(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { if (wl->bss_type == BSS_TYPE_STA_BSS) - return wl1271_configure_suspend_sta(wl); + return wl1271_configure_suspend_sta(wl, wlvif); if (wl->bss_type == BSS_TYPE_AP_BSS) return wl1271_configure_suspend_ap(wl); return 0; } -static void wl1271_configure_resume(struct wl1271 *wl) +static void wl1271_configure_resume(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; bool is_sta = wl->bss_type == BSS_TYPE_STA_BSS; @@ -1709,7 +1712,7 @@ static void wl1271_configure_resume(struct wl1271 *wl) /* exit psm if it wasn't configured */ if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } else if (is_ap) { wl1271_acx_beacon_filter_opt(wl, false); } @@ -1723,13 +1726,15 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); WARN_ON(!wow || !wow->any); wl->wow_enabled = true; - ret = wl1271_configure_suspend(wl); + ret = wl1271_configure_suspend(wl, wlvif); if (ret < 0) { wl1271_warning("couldn't prepare device to suspend"); return ret; @@ -1760,6 +1765,8 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, static int wl1271_op_resume(struct ieee80211_hw *hw) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; bool run_irq_work = false; @@ -1783,7 +1790,7 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) wl1271_irq(0, wl); wl1271_enable_interrupts(wl); } - wl1271_configure_resume(wl); + wl1271_configure_resume(wl, wlvif); wl->wow_enabled = false; return 0; @@ -1840,6 +1847,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; + wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; } @@ -2214,7 +2222,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl1271_cmd_build_klv_null_data(wl); + ret = wl12xx_cmd_build_klv_null_data(wl, wlvif); if (ret < 0) goto out; @@ -2384,7 +2392,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) wl1271_set_band_rate(wl, wlvif); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl, wlvif); @@ -2450,7 +2458,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { wl1271_debug(DEBUG_PSM, "psm enabled"); ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } } else if (!(conf->flags & IEEE80211_CONF_PS) && test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { @@ -2460,7 +2468,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (test_bit(WL1271_FLAG_PSM, &wl->flags)) ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } if (conf->power_level != wl->power_level) { @@ -3311,7 +3319,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); - wl->basic_rate = wl1271_tx_min_rate_get(wl, + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_init_ap_rates(wl, wlvif); @@ -3450,7 +3458,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); if (!is_zero_ether_addr(wl->bssid)) { - ret = wl1271_cmd_build_null_data(wl); + ret = wl12xx_cmd_build_null_data(wl, wlvif); if (ret < 0) goto out; @@ -3498,7 +3506,7 @@ sta_not_found: wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); if (sta_rate_set) @@ -3552,7 +3560,7 @@ sta_not_found: /* revert back to minimum rates for the current band */ wl1271_set_band_rate(wl, wlvif); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl, wlvif); @@ -3608,7 +3616,7 @@ sta_not_found: wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3636,7 +3644,7 @@ sta_not_found: * isn't being set (when sending), so we have to * reconfigure the template upon every ip change. */ - ret = wl1271_cmd_build_arp_rsp(wl, addr); + ret = wl1271_cmd_build_arp_rsp(wl, wlvif, addr); if (ret < 0) { wl1271_warning("build arp rsp failed: %d", ret); goto out; @@ -3689,7 +3697,7 @@ sta_not_found: mode = STATION_POWER_SAVE_MODE; ret = wl1271_ps_set_mode(wl, mode, - wl->basic_rate, + wlvif->basic_rate, true); if (ret < 0) goto out; @@ -4844,7 +4852,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->rx_counter = 0; wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; - wl->basic_rate = CONF_TX_RATE_MASK_BASIC; wl->band = IEEE80211_BAND_2GHZ; wl->vif = NULL; wl->flags = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 6f3efba..d355c73 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -519,13 +519,6 @@ struct wl1271 { /* Our association ID */ u16 aid; - /* - * currently configured rate set: - * bits 0-15 - 802.11abg rates - * bits 16-23 - 802.11n MCS index mask - * support only 1 stream, thus only 8 bits for the MCS rates (0-7). - */ - u32 basic_rate; u32 bitrate_masks[IEEE80211_NUM_BANDS]; /* The current band */ @@ -646,6 +639,7 @@ struct wl12xx_vif { * bits 16-23 - 802.11n MCS index mask * support only 1 stream, thus only 8 bits for the MCS rates (0-7). */ + u32 basic_rate; u32 rate_set; }; -- cgit v0.10.2 From cdf09495588fda7e9c15c25bc20cb828e07be314 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:44 +0200 Subject: wl12xx: replace wl->bssid with vif->bss_conf.bssid Use the per-interface vif->bss_conf instead of the global wl->bssid. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index ce73415..b9bb76b 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -557,6 +557,7 @@ out: int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_cmd_role_start *cmd; int ret; @@ -577,7 +578,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->sta.ssid_len = wl->ssid_len; memcpy(cmd->sta.ssid, wl->ssid, wl->ssid_len); - memcpy(cmd->sta.bssid, wl->bssid, ETH_ALEN); + memcpy(cmd->sta.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { @@ -769,6 +770,7 @@ out: int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_cmd_role_start *cmd; struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; int ret; @@ -791,7 +793,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->ibss.ssid_len = wl->ssid_len; memcpy(cmd->ibss.ssid, wl->ssid, wl->ssid_len); - memcpy(cmd->ibss.bssid, wl->bssid, ETH_ALEN); + memcpy(cmd->ibss.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { @@ -807,7 +809,8 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl->role_id, cmd->sta.hlid, cmd->sta.session, wlvif->basic_rate_set, wlvif->rate_set); - wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid); + wl1271_debug(DEBUG_CMD, "vif->bss_conf.bssid = %pM", + vif->bss_conf.bssid); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -1213,9 +1216,9 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) memset(&template, 0, sizeof(template)); - memcpy(template.addr1, wl->bssid, ETH_ALEN); + memcpy(template.addr1, vif->bss_conf.bssid, ETH_ALEN); memcpy(template.addr2, vif->addr, ETH_ALEN); - memcpy(template.addr3, wl->bssid, ETH_ALEN); + memcpy(template.addr3, vif->bss_conf.bssid, ETH_ALEN); template.frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC | diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index af4cef3..30d05fd 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -184,7 +184,7 @@ static void wl1271_stop_ba_event(struct wl1271 *wl) if (!wl->ba_rx_bitmap) return; ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, - wl->bssid); + wl->vif->bss_conf.bssid); } else { int i; struct wl1271_link *lnk; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8863ea5..d19c3fe 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2098,7 +2098,6 @@ deinit: wl1271_tx_reset(wl, reset_tx_queues); wl1271_power_off(wl); - memset(wl->bssid, 0, ETH_ALEN); memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; wl->bss_type = MAX_BSS_TYPE; @@ -2249,8 +2248,6 @@ static int wl1271_unjoin(struct wl1271 *wl) if (ret < 0) goto out; - memset(wl->bssid, 0, ETH_ALEN); - /* reset TX security counters on a clean disconnect */ wl->tx_security_last_seq_lsb = 0; wl->tx_security_seq = 0; @@ -3449,15 +3446,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, wl->rssi_thold = bss_conf->cqm_rssi_thold; } - if ((changed & BSS_CHANGED_BSSID) && - /* - * Now we know the correct bssid, so we send a new join command - * and enable the BSSID filter - */ - memcmp(wl->bssid, bss_conf->bssid, ETH_ALEN)) { - memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); - - if (!is_zero_ether_addr(wl->bssid)) { + if (changed & BSS_CHANGED_BSSID) + if (!is_zero_ether_addr(bss_conf->bssid)) { ret = wl12xx_cmd_build_null_data(wl, wlvif); if (ret < 0) goto out; @@ -3469,7 +3459,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, /* Need to update the BSSID (for filtering etc) */ do_join = true; } - } if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_HT)) { rcu_read_lock(); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d355c73..44a5dae 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -399,7 +399,6 @@ struct wl1271 { s8 hw_pg_ver; - u8 bssid[ETH_ALEN]; u8 mac_addr[ETH_ALEN]; u8 bss_type; u8 set_bss_type; -- cgit v0.10.2 From 536129c8ad35de87ff2f864f205a54ac32bfebcc Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:45 +0200 Subject: wl12xx: move bss_type into wlvif move bss_type into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index b9bb76b..096a713 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1042,7 +1042,7 @@ int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif) int ret = -ENOMEM; - if (wl->bss_type == BSS_TYPE_IBSS) { + if (wlvif->bss_type == BSS_TYPE_IBSS) { size = sizeof(struct wl12xx_null_data_template); ptr = NULL; } else { diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 620acbf..8f88ad6 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -350,7 +350,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(rx_counter); DRIVER_STATE_PRINT_INT(session_counter); DRIVER_STATE_PRINT_INT(state); - DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 30d05fd..072addc 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -178,9 +178,9 @@ static void wl1271_event_rssi_trigger(struct wl1271 *wl, wl->last_rssi_event = event; } -static void wl1271_stop_ba_event(struct wl1271 *wl) +static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - if (wl->bss_type != BSS_TYPE_AP_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (!wl->ba_rx_bitmap) return; ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, @@ -229,7 +229,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) int ret; u32 vector; bool beacon_loss = false; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); bool disconnect_sta = false; unsigned long sta_bitmap = 0; @@ -263,7 +263,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) } if (vector & SOFT_GEMINI_SENSE_EVENT_ID && - wl->bss_type == BSS_TYPE_STA_BSS) + wlvif->bss_type == BSS_TYPE_STA_BSS) wl12xx_event_soft_gemini_sense(wl, mbox->soft_gemini_sense_info); @@ -306,7 +306,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) wl->ba_allowed = !!mbox->rx_ba_allowed; if (wl->vif && !wl->ba_allowed) - wl1271_stop_ba_event(wl); + wl1271_stop_ba_event(wl, wlvif); } if ((vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) && !is_ap) { diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index ed27c5f..e54cc69 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -478,7 +478,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) return 0; } -static int wl1271_set_ba_policies(struct wl1271 *wl) +static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) { /* Reset the BA RX indicators */ wl->ba_rx_bitmap = 0; @@ -486,8 +486,8 @@ static int wl1271_set_ba_policies(struct wl1271 *wl) wl->ba_rx_session_count = 0; /* BA is supported in STA/AP modes */ - if (wl->bss_type != BSS_TYPE_AP_BSS && - wl->bss_type != BSS_TYPE_STA_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS && + wlvif->bss_type != BSS_TYPE_STA_BSS) { wl->ba_support = false; return 0; } @@ -572,7 +572,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret, i; @@ -635,7 +635,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) return ret; /* Configure initiator BA sessions policies */ - ret = wl1271_set_ba_policies(wl); + ret = wl1271_set_ba_policies(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index d19c3fe..5b13af0 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -377,6 +377,7 @@ static char *fwlog_param; static bool bug_on_recovery; static void __wl1271_op_remove_interface(struct wl1271 *wl, + struct ieee80211_vif *vif, bool reset_tx_queues); static void wl1271_free_ap_keys(struct wl1271 *wl); @@ -844,6 +845,8 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, static void wl12xx_fw_status(struct wl1271 *wl, struct wl12xx_fw_status *status) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct timespec ts; u32 old_tx_blk_count = wl->tx_blocks_available; int avail, freed_blocks; @@ -898,7 +901,7 @@ static void wl12xx_fw_status(struct wl1271 *wl, clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); /* for AP update num of allocated TX blocks per link and ps status */ - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) wl12xx_irq_update_links_status(wl, status); /* update the host-chipset time offset */ @@ -1004,7 +1007,7 @@ irqreturn_t wl1271_irq(int irq, void *cookie) * In order to avoid starvation of the TX path, * call the work function directly. */ - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, wl->vif); } else { spin_unlock_irqrestore(&wl->wl_lock, flags); } @@ -1251,7 +1254,7 @@ static void wl1271_recovery_work(struct work_struct *work) } /* reboot the chipset */ - __wl1271_op_remove_interface(wl, false); + __wl1271_op_remove_interface(wl, wl->vif, false); clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1389,8 +1392,6 @@ int wl1271_plt_start(struct wl1271 *wl) goto out; } - wl->bss_type = BSS_TYPE_STA_BSS; - while (retries) { retries--; ret = wl1271_chip_wakeup(wl); @@ -1482,6 +1483,8 @@ int wl1271_plt_stop(struct wl1271 *wl) static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct wl1271 *wl = hw->priv; + struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb); + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(control->control.vif); unsigned long flags; int q, mapping; u8 hlid = 0; @@ -1489,13 +1492,13 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) mapping = skb_get_queue_mapping(skb); q = wl1271_tx_get_queue(mapping); - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) hlid = wl12xx_tx_get_hlid_ap(wl, skb); spin_lock_irqsave(&wl->wl_lock, flags); /* queue the packet */ - if (wl->bss_type == BSS_TYPE_AP_BSS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS) { if (!wl1271_is_active_sta(wl, hlid)) { wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); @@ -1552,7 +1555,7 @@ int wl1271_tx_dummy_packet(struct wl1271 *wl) /* The FW is low on RX memory blocks, so send the dummy packet asap */ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, wl->vif); /* * If the FW TX is busy, TX work will be scheduled by the threaded @@ -1686,9 +1689,9 @@ out_unlock: static int wl1271_configure_suspend(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - if (wl->bss_type == BSS_TYPE_STA_BSS) + if (wlvif->bss_type == BSS_TYPE_STA_BSS) return wl1271_configure_suspend_sta(wl, wlvif); - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) return wl1271_configure_suspend_ap(wl); return 0; } @@ -1697,8 +1700,8 @@ static void wl1271_configure_resume(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - bool is_sta = wl->bss_type == BSS_TYPE_STA_BSS; - bool is_ap = wl->bss_type == BSS_TYPE_AP_BSS; + bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS; + bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS; if (!is_sta && !is_ap) return; @@ -1820,9 +1823,9 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); } -static u8 wl12xx_get_role_type(struct wl1271 *wl) +static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - switch (wl->bss_type) { + switch (wlvif->bss_type) { case BSS_TYPE_AP_BSS: if (wl->p2p) return WL1271_ROLE_P2P_GO; @@ -1839,13 +1842,14 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) return WL1271_ROLE_IBSS; default: - wl1271_error("invalid bss_type: %d", wl->bss_type); + wl1271_error("invalid bss_type: %d", wlvif->bss_type); } return WL12XX_INVALID_ROLE_TYPE; } static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { + wlvif->bss_type = MAX_BSS_TYPE; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -1856,6 +1860,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, { struct wl1271 *wl = hw->priv; struct wiphy *wiphy = hw->wiphy; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int retries = WL1271_BOOT_RETRIES; int ret = 0; u8 role_type; @@ -1871,7 +1876,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EBUSY; goto out; } - wl12xx_init_vif_data(wl12xx_vif_to_data(vif)); + wl12xx_init_vif_data(wlvif); /* * in some very corner case HW recovery scenarios its possible to @@ -1888,25 +1893,25 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wl->p2p = 1; /* fall-through */ case NL80211_IFTYPE_STATION: - wl->bss_type = BSS_TYPE_STA_BSS; + wlvif->bss_type = BSS_TYPE_STA_BSS; wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_ADHOC: - wl->bss_type = BSS_TYPE_IBSS; + wlvif->bss_type = BSS_TYPE_IBSS; wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_P2P_GO: wl->p2p = 1; /* fall-through */ case NL80211_IFTYPE_AP: - wl->bss_type = BSS_TYPE_AP_BSS; + wlvif->bss_type = BSS_TYPE_AP_BSS; break; default: ret = -EOPNOTSUPP; goto out; } - role_type = wl12xx_get_role_type(wl); + role_type = wl12xx_get_role_type(wl, wlvif); if (role_type == WL12XX_INVALID_ROLE_TYPE) { ret = -EINVAL; goto out; @@ -1938,8 +1943,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto irq_disable; - if (wl->bss_type == BSS_TYPE_STA_BSS || - wl->bss_type == BSS_TYPE_IBSS) { + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { /* * The device role is a special role used for * rx and tx frames prior to association (as @@ -2020,8 +2025,10 @@ out: } static void __wl1271_op_remove_interface(struct wl1271 *wl, + struct ieee80211_vif *vif, bool reset_tx_queues) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret, i; wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); @@ -2037,7 +2044,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, mutex_unlock(&wl_list_mutex); /* enable dyn ps just in case (if left on due to fw crash etc) */ - if (wl->bss_type == BSS_TYPE_STA_BSS) + if (wlvif->bss_type == BSS_TYPE_STA_BSS) ieee80211_enable_dyn_ps(wl->vif); if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { @@ -2054,7 +2061,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, if (ret < 0) goto deinit; - if (wl->bss_type == BSS_TYPE_STA_BSS) { + if (wlvif->bss_type == BSS_TYPE_STA_BSS) { ret = wl12xx_cmd_role_disable(wl, &wl->dev_role_id); if (ret < 0) goto deinit; @@ -2100,7 +2107,6 @@ deinit: memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; - wl->bss_type = MAX_BSS_TYPE; wl->set_bss_type = MAX_BSS_TYPE; wl->p2p = 0; wl->band = IEEE80211_BAND_2GHZ; @@ -2169,7 +2175,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, */ if (wl->vif) { WARN_ON(wl->vif != vif); - __wl1271_op_remove_interface(wl, true); + __wl1271_op_remove_interface(wl, vif, true); } mutex_unlock(&wl->mutex); @@ -2180,7 +2186,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, bool set_assoc) { int ret; - bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); + bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); /* * One of the side effects of the JOIN command is that is clears @@ -2364,7 +2370,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) goto out; } - is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) @@ -2375,7 +2381,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ((wl->band != conf->channel->band) || (wl->channel != channel))) { /* send all pending packets */ - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, vif); wl->band = conf->channel->band; wl->channel = channel; @@ -2536,6 +2542,9 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, { struct wl1271_filter_params *fp = (void *)(unsigned long)multicast; struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 configure filter changed %x" @@ -2553,7 +2562,7 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, if (ret < 0) goto out; - if (wl->bss_type != BSS_TYPE_AP_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (*total & FIF_ALLMULTI) ret = wl1271_acx_group_address_tbl(wl, false, NULL, 0); else if (fp) @@ -2673,12 +2682,13 @@ out: return ret; } -static int wl1271_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, u32 tx_seq_32, u16 tx_seq_16, struct ieee80211_sta *sta) { int ret; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); if (is_ap) { struct wl1271_station *wl_sta; @@ -2774,6 +2784,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_key_conf *key_conf) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; u32 tx_seq_32 = 0; u16 tx_seq_16 = 0; @@ -2833,7 +2844,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (cmd) { case SET_KEY: - ret = wl1271_set_key(wl, KEY_ADD_OR_REPLACE, + ret = wl1271_set_key(wl, wlvif, KEY_ADD_OR_REPLACE, key_conf->keyidx, key_type, key_conf->keylen, key_conf->key, tx_seq_32, tx_seq_16, sta); @@ -2844,7 +2855,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, break; case DISABLE_KEY: - ret = wl1271_set_key(wl, KEY_REMOVE, + ret = wl1271_set_key(wl, wlvif, KEY_REMOVE, key_conf->keyidx, key_type, key_conf->keylen, key_conf->key, 0, 0, sta); @@ -2966,6 +2977,7 @@ static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw, struct ieee80211_sched_scan_ies *ies) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; wl1271_debug(DEBUG_MAC80211, "wl1271_op_sched_scan_start"); @@ -2976,11 +2988,11 @@ static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw, if (ret < 0) goto out; - ret = wl1271_scan_sched_scan_config(wl, req, ies); + ret = wl1271_scan_sched_scan_config(wl, wlvif, req, ies); if (ret < 0) goto out_sleep; - ret = wl1271_scan_sched_scan_start(wl); + ret = wl1271_scan_sched_scan_start(wl, wlvif); if (ret < 0) goto out_sleep; @@ -3225,7 +3237,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, u32 changed) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret = 0; if ((changed & BSS_CHANGED_BEACON_INT)) { @@ -3387,7 +3399,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); bool do_join = false, set_assoc = false; - bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); + bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); bool ibss_joined = false; u32 sta_rate_set = 0; int ret; @@ -3623,7 +3635,7 @@ sta_not_found: if (changed & BSS_CHANGED_ARP_FILTER) { __be32 addr = bss_conf->arp_addr_list[0]; - WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS); + WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS); if (bss_conf->arp_addr_cnt == 1 && bss_conf->arp_filter_enabled) { @@ -3742,7 +3754,8 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw, u32 changed) { struct wl1271 *wl = hw->priv; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed 0x%x", @@ -3933,6 +3946,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, struct ieee80211_sta *sta) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; u8 hlid; @@ -3941,7 +3955,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; - if (wl->bss_type != BSS_TYPE_AP_BSS) + if (wlvif->bss_type != BSS_TYPE_AP_BSS) goto out; wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid); @@ -3983,6 +3997,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, struct ieee80211_sta *sta) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_station *wl_sta; int ret = 0, id; @@ -3991,7 +4006,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; - if (wl->bss_type != BSS_TYPE_AP_BSS) + if (wlvif->bss_type != BSS_TYPE_AP_BSS) goto out; wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); @@ -4026,6 +4041,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, u8 buf_size) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; u8 hlid, *ba_bitmap; @@ -4043,10 +4059,10 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, goto out; } - if (wl->bss_type == BSS_TYPE_STA_BSS) { + if (wlvif->bss_type == BSS_TYPE_STA_BSS) { hlid = wl->sta_hlid; ba_bitmap = &wl->ba_rx_bitmap; - } else if (wl->bss_type == BSS_TYPE_AP_BSS) { + } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { struct wl1271_station *wl_sta; wl_sta = (struct wl1271_station *)sta->drv_priv; @@ -4197,10 +4213,6 @@ static bool wl1271_tx_frames_pending(struct ieee80211_hw *hw) /* packets are considered pending if in the TX queue or the FW */ ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->tx_frames_cnt > 0); - - /* the above is appropriate for STA mode for PS purposes */ - WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS); - out: mutex_unlock(&wl->mutex); @@ -4846,7 +4858,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->flags = 0; wl->sg_enabled = true; wl->hw_pg_ver = -1; - wl->bss_type = MAX_BSS_TYPE; wl->set_bss_type = MAX_BSS_TYPE; wl->last_tx_hlid = 0; wl->ap_ps_map = 0; diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index dee4cfe..9cfa0b2 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -185,6 +185,8 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) { struct wl1271_acx_mem_map *wl_mem_map = wl->target_mem_map; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); u32 buf_size; u32 fw_rx_counter = status->fw_rx_counter & NUM_RX_PKT_DESC_MOD_MASK; u32 drv_rx_counter = wl->rx_counter & NUM_RX_PKT_DESC_MOD_MASK; @@ -192,7 +194,7 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) u32 mem_block; u32 pkt_length; u32 pkt_offset; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); bool had_data = false; bool unaligned = false; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index a857618..197d2c2 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -34,6 +34,7 @@ void wl1271_scan_complete_work(struct work_struct *work) { struct delayed_work *dwork; struct wl1271 *wl; + struct wl12xx_vif *wlvif; int ret; bool is_sta, is_ibss; @@ -50,6 +51,8 @@ void wl1271_scan_complete_work(struct work_struct *work) if (wl->scan.state == WL1271_SCAN_STATE_IDLE) goto out; + wlvif = wl12xx_vif_to_data(wl->scan_vif); + wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan.req = NULL; @@ -65,8 +68,8 @@ void wl1271_scan_complete_work(struct work_struct *work) } /* return to ROC if needed */ - is_sta = (wl->bss_type == BSS_TYPE_STA_BSS); - is_ibss = (wl->bss_type == BSS_TYPE_IBSS); + is_sta = (wlvif->bss_type == BSS_TYPE_STA_BSS); + is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); if (((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) || (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && !test_bit(wl->dev_role_id, wl->roc_map)) { @@ -589,6 +592,7 @@ out: } int wl1271_scan_sched_scan_config(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct cfg80211_sched_scan_request *req, struct ieee80211_sched_scan_ies *ies) { @@ -671,14 +675,14 @@ out: return ret; } -int wl1271_scan_sched_scan_start(struct wl1271 *wl) +int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl1271_cmd_sched_scan_start *start; int ret = 0; wl1271_debug(DEBUG_CMD, "cmd periodic scan start"); - if (wl->bss_type != BSS_TYPE_STA_BSS) + if (wlvif->bss_type != BSS_TYPE_STA_BSS) return -EOPNOTSUPP; if (!test_bit(WL1271_FLAG_IDLE, &wl->flags)) diff --git a/drivers/net/wireless/wl12xx/scan.h b/drivers/net/wireless/wl12xx/scan.h index 15177bd..a7ed43d 100644 --- a/drivers/net/wireless/wl12xx/scan.h +++ b/drivers/net/wireless/wl12xx/scan.h @@ -36,9 +36,10 @@ int wl1271_scan_build_probe_req(struct wl1271 *wl, void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_scan_complete_work(struct work_struct *work); int wl1271_scan_sched_scan_config(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct cfg80211_sched_scan_request *req, struct ieee80211_sched_scan_ies *ies); -int wl1271_scan_sched_scan_start(struct wl1271 *wl); +int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif); void wl1271_scan_sched_scan_stop(struct wl1271 *wl); void wl1271_scan_sched_scan_results(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index bad9e29..5561ec2 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -32,10 +32,11 @@ #include "tx.h" #include "event.h" -static int wl1271_set_default_wep_key(struct wl1271 *wl, u8 id) +static int wl1271_set_default_wep_key(struct wl1271 *wl, + struct wl12xx_vif *wlvif, u8 id) { int ret; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); if (is_ap) ret = wl12xx_cmd_set_default_wep_key(wl, id, @@ -178,14 +179,17 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb) } } -static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct sk_buff *skb) +static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + if (wl12xx_is_dummy_packet(wl, skb)) return wl->system_hlid; - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) return wl12xx_tx_get_hlid_ap(wl, skb); wl1271_tx_update_filters(wl, skb); @@ -208,9 +212,11 @@ static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, return ALIGN(packet_length, WL1271_TX_ALIGN_TO); } -static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, - u32 buf_offset, u8 hlid) +static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb, u32 extra, u32 buf_offset, + u8 hlid) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_tx_hw_descr *desc; u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; u32 len; @@ -257,7 +263,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); wl->tx_allocated_pkts[ac]++; - if (wl->bss_type == BSS_TYPE_AP_BSS && + if (wlvif->bss_type == BSS_TYPE_AP_BSS && hlid >= WL1271_AP_STA_HLID_START) wl->links[hlid].allocated_pkts++; @@ -273,10 +279,11 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, return ret; } -static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, - u32 extra, struct ieee80211_tx_info *control, - u8 hlid) +static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb, u32 extra, + struct ieee80211_tx_info *control, u8 hlid) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct timespec ts; struct wl1271_tx_hw_descr *desc; int aligned_len, ac, rate_idx; @@ -298,7 +305,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, hosttime = (timespec_to_ns(&ts) >> 10); desc->start_time = cpu_to_le32(hosttime - wl->time_offset); - if (wl->bss_type != BSS_TYPE_AP_BSS) + if (wlvif->bss_type != BSS_TYPE_AP_BSS) desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); else desc->life_time = cpu_to_le16(TX_HW_AP_MODE_PKT_LIFETIME_TU); @@ -324,8 +331,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, } desc->hlid = hlid; - - if (wl->bss_type != BSS_TYPE_AP_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { /* if the packets are destined for AP (have a STA entry) send them with AP rate policies, otherwise use default basic rates */ @@ -383,16 +389,27 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, u32 buf_offset) { struct ieee80211_tx_info *info; + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; u32 extra = 0; int ret = 0; u32 total_len; u8 hlid; + bool is_dummy; if (!skb) return -EINVAL; info = IEEE80211_SKB_CB(skb); + /* TODO: handle dummy packets on multi-vifs */ + is_dummy = wl12xx_is_dummy_packet(wl, skb); + if (is_dummy) + info->control.vif = wl->vif; + + vif = info->control.vif; + wlvif = wl12xx_vif_to_data(vif); + if (info->control.hw_key && info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) extra = WL1271_TKIP_IV_SPACE; @@ -406,26 +423,25 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, (cipher == WLAN_CIPHER_SUITE_WEP104); if (unlikely(is_wep && wl->default_key != idx)) { - ret = wl1271_set_default_wep_key(wl, idx); + ret = wl1271_set_default_wep_key(wl, wlvif, idx); if (ret < 0) return ret; wl->default_key = idx; } } - - hlid = wl1271_tx_get_hlid(wl, skb); + hlid = wl1271_tx_get_hlid(wl, vif, skb); if (hlid == WL12XX_INVALID_LINK_ID) { wl1271_error("invalid hlid. dropping skb 0x%p", skb); return -EINVAL; } - ret = wl1271_tx_allocate(wl, skb, extra, buf_offset, hlid); + ret = wl1271_tx_allocate(wl, vif, skb, extra, buf_offset, hlid); if (ret < 0) return ret; - wl1271_tx_fill_hdr(wl, skb, extra, info, hlid); + wl1271_tx_fill_hdr(wl, vif, skb, extra, info, hlid); - if (wl->bss_type == BSS_TYPE_AP_BSS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS && !is_dummy) { wl1271_tx_ap_update_inconnection_sta(wl, skb); wl1271_tx_regulate_link(wl, hlid); } @@ -444,7 +460,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, memset(wl->aggr_buf + buf_offset + skb->len, 0, total_len - skb->len); /* Revert side effects in the dummy packet skb, so it can be reused */ - if (wl12xx_is_dummy_packet(wl, skb)) + if (is_dummy) skb_pull(skb, sizeof(struct wl1271_tx_hw_descr)); return total_len; @@ -586,12 +602,13 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl) return skb; } -static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) +static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { unsigned long flags; struct sk_buff *skb = NULL; - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) skb = wl1271_ap_skb_dequeue(wl); else skb = wl1271_sta_skb_dequeue(wl); @@ -610,15 +627,17 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) return skb; } -static void wl1271_skb_queue_head(struct wl1271 *wl, struct sk_buff *skb) +static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); if (wl12xx_is_dummy_packet(wl, skb)) { set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags); - } else if (wl->bss_type == BSS_TYPE_AP_BSS) { - u8 hlid = wl1271_tx_get_hlid(wl, skb); + } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { + u8 hlid = wl1271_tx_get_hlid(wl, vif, skb); skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ @@ -639,19 +658,20 @@ static bool wl1271_tx_is_data_present(struct sk_buff *skb) return ieee80211_is_data_present(hdr->frame_control); } -void wl1271_tx_work_locked(struct wl1271 *wl) +void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct sk_buff *skb; u32 buf_offset = 0; bool sent_packets = false; bool had_data = false; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret; if (unlikely(wl->state == WL1271_STATE_OFF)) return; - while ((skb = wl1271_skb_dequeue(wl))) { + while ((skb = wl1271_skb_dequeue(wl, wlvif))) { if (wl1271_tx_is_data_present(skb)) had_data = true; @@ -661,7 +681,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl) * Aggregation buffer is full. * Flush buffer and try again. */ - wl1271_skb_queue_head(wl, skb); + wl1271_skb_queue_head(wl, vif, skb); wl1271_write(wl, WL1271_SLV_MEM_DATA, wl->aggr_buf, buf_offset, true); sent_packets = true; @@ -672,7 +692,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl) * Firmware buffer is full. * Queue back last skb, and stop aggregating. */ - wl1271_skb_queue_head(wl, skb); + wl1271_skb_queue_head(wl, vif, skb); /* No work left, avoid scheduling redundant tx work */ set_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); goto out_ack; @@ -726,7 +746,7 @@ void wl1271_tx_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, wl->vif); wl1271_ps_elp_sleep(wl); out: @@ -888,12 +908,14 @@ void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid) /* caller must hold wl->mutex and TX must be stopped */ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int i; struct sk_buff *skb; struct ieee80211_tx_info *info; /* TX failure */ - if (wl->bss_type == BSS_TYPE_AP_BSS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS) { for (i = 0; i < AP_MAX_LINKS; i++) { wl1271_free_sta(wl, i); wl1271_tx_reset_link_queues(wl, i); diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index dc4f09a..ba9403a 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -204,7 +204,7 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) } void wl1271_tx_work(struct work_struct *work); -void wl1271_tx_work_locked(struct wl1271 *wl); +void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_tx_complete(struct wl1271 *wl); void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues); void wl1271_tx_flush(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 44a5dae..97ed19c 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,7 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 bss_type; u8 set_bss_type; u8 p2p; /* we are using p2p role */ u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; @@ -630,6 +629,8 @@ struct wl1271_station { }; struct wl12xx_vif { + u8 bss_type; + u32 basic_rate_set; /* -- cgit v0.10.2 From 10bcf745ae737cfbca1796386d76b0636b086770 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:46 +0200 Subject: wl12xx: remove set_bss_type field set_bss_type is no longer evaluated, so delete it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 5b13af0..50ee9d4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1894,11 +1894,9 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, /* fall-through */ case NL80211_IFTYPE_STATION: wlvif->bss_type = BSS_TYPE_STA_BSS; - wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_ADHOC: wlvif->bss_type = BSS_TYPE_IBSS; - wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_P2P_GO: wl->p2p = 1; @@ -2107,7 +2105,6 @@ deinit: memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; - wl->set_bss_type = MAX_BSS_TYPE; wl->p2p = 0; wl->band = IEEE80211_BAND_2GHZ; @@ -3439,10 +3436,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, wl1271_debug(DEBUG_ADHOC, "ad-hoc beaconing: %s", bss_conf->enable_beacon ? "enabled" : "disabled"); - if (bss_conf->enable_beacon) - wl->set_bss_type = BSS_TYPE_IBSS; - else - wl->set_bss_type = BSS_TYPE_STA_BSS; do_join = true; } @@ -4858,7 +4851,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->flags = 0; wl->sg_enabled = true; wl->hw_pg_ver = -1; - wl->set_bss_type = MAX_BSS_TYPE; wl->last_tx_hlid = 0; wl->ap_ps_map = 0; wl->ap_fw_ps_map = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 97ed19c..0578d75 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,7 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 set_bss_type; u8 p2p; /* we are using p2p role */ u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v0.10.2 From fb0e707c838ac7d8aae7ab90ea448e5ac1e29697 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:47 +0200 Subject: wl12xx: move p2p into wlvif move p2p field into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 50ee9d4..111a465 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1827,13 +1827,13 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) { switch (wlvif->bss_type) { case BSS_TYPE_AP_BSS: - if (wl->p2p) + if (wlvif->p2p) return WL1271_ROLE_P2P_GO; else return WL1271_ROLE_AP; case BSS_TYPE_STA_BSS: - if (wl->p2p) + if (wlvif->p2p) return WL1271_ROLE_P2P_CL; else return WL1271_ROLE_STA; @@ -1890,7 +1890,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, switch (ieee80211_vif_type_p2p(vif)) { case NL80211_IFTYPE_P2P_CLIENT: - wl->p2p = 1; + wlvif->p2p = 1; /* fall-through */ case NL80211_IFTYPE_STATION: wlvif->bss_type = BSS_TYPE_STA_BSS; @@ -1899,7 +1899,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wlvif->bss_type = BSS_TYPE_IBSS; break; case NL80211_IFTYPE_P2P_GO: - wl->p2p = 1; + wlvif->p2p = 1; /* fall-through */ case NL80211_IFTYPE_AP: wlvif->bss_type = BSS_TYPE_AP_BSS; @@ -2105,7 +2105,6 @@ deinit: memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; - wl->p2p = 0; wl->band = IEEE80211_BAND_2GHZ; wl->rx_counter = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 0578d75..d84c0de 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,7 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 p2p; /* we are using p2p role */ u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; int channel; @@ -629,6 +628,7 @@ struct wl1271_station { struct wl12xx_vif { u8 bss_type; + u8 p2p; /* we are using p2p role */ u32 basic_rate_set; -- cgit v0.10.2 From 1fe9f1616ee0852e9422d1f676630e9a4531ace3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:48 +0200 Subject: wl12xx: move ssid and ssid_len into wlvif move ssid and ssid_len into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 096a713..1f29eab 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -576,8 +576,8 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; - cmd->sta.ssid_len = wl->ssid_len; - memcpy(cmd->sta.ssid, wl->ssid, wl->ssid_len); + cmd->sta.ssid_len = wlvif->ssid_len; + memcpy(cmd->sta.ssid, wlvif->ssid, wlvif->ssid_len); memcpy(cmd->sta.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); @@ -659,7 +659,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wl->role_id); /* trying to use hidden SSID with an old hostapd version */ - if (wl->ssid_len == 0 && !bss_conf->hidden_ssid) { + if (wlvif->ssid_len == 0 && !bss_conf->hidden_ssid) { wl1271_error("got a null SSID from beacon/bss"); ret = -EINVAL; goto out; @@ -693,8 +693,8 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (!bss_conf->hidden_ssid) { /* take the SSID from the beacon for backward compatibility */ cmd->ap.ssid_type = WL12XX_SSID_TYPE_PUBLIC; - cmd->ap.ssid_len = wl->ssid_len; - memcpy(cmd->ap.ssid, wl->ssid, wl->ssid_len); + cmd->ap.ssid_len = wlvif->ssid_len; + memcpy(cmd->ap.ssid, wlvif->ssid, wlvif->ssid_len); } else { cmd->ap.ssid_type = WL12XX_SSID_TYPE_HIDDEN; cmd->ap.ssid_len = bss_conf->ssid_len; @@ -791,8 +791,8 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; - cmd->ibss.ssid_len = wl->ssid_len; - memcpy(cmd->ibss.ssid, wl->ssid, wl->ssid_len); + cmd->ibss.ssid_len = wlvif->ssid_len; + memcpy(cmd->ibss.ssid, wlvif->ssid, wlvif->ssid_len); memcpy(cmd->ibss.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 111a465..0da9ddc 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2103,8 +2103,6 @@ deinit: wl1271_tx_reset(wl, reset_tx_queues); wl1271_power_off(wl); - memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); - wl->ssid_len = 0; wl->band = IEEE80211_BAND_2GHZ; wl->rx_counter = 0; @@ -3078,9 +3076,10 @@ out: return ret; } -static int wl1271_ssid_set(struct wl1271 *wl, struct sk_buff *skb, +static int wl1271_ssid_set(struct ieee80211_vif *vif, struct sk_buff *skb, int offset) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); u8 ssid_len; const u8 *ptr = cfg80211_find_ie(WLAN_EID_SSID, skb->data + offset, skb->len - offset); @@ -3096,8 +3095,8 @@ static int wl1271_ssid_set(struct wl1271 *wl, struct sk_buff *skb, return -EINVAL; } - wl->ssid_len = ssid_len; - memcpy(wl->ssid, ptr+2, ssid_len); + wlvif->ssid_len = ssid_len; + memcpy(wlvif->ssid, ptr+2, ssid_len); return 0; } @@ -3133,17 +3132,19 @@ static void wl12xx_remove_vendor_ie(struct sk_buff *skb, } static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, + struct ieee80211_vif *vif, u8 *probe_rsp_data, size_t probe_rsp_len, u32 rates) { - struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; u8 probe_rsp_templ[WL1271_CMD_TEMPL_MAX_SIZE]; int ssid_ie_offset, ie_offset, templ_len; const u8 *ptr; /* no need to change probe response if the SSID is set correctly */ - if (wl->ssid_len > 0) + if (wlvif->ssid_len > 0) return wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, probe_rsp_data, @@ -3256,7 +3257,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, wl1271_debug(DEBUG_MASTER, "beacon updated"); - ret = wl1271_ssid_set(wl, beacon, ieoffset); + ret = wl1271_ssid_set(vif, beacon, ieoffset); if (ret < 0) { dev_kfree_skb(beacon); goto out; @@ -3291,7 +3292,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); if (is_ap) - ret = wl1271_ap_set_probe_resp_tmpl(wl, + ret = wl1271_ap_set_probe_resp_tmpl(wl, vif, beacon->data, beacon->len, min_rate); @@ -3528,7 +3529,7 @@ sta_not_found: wl->probereq = wl1271_cmd_build_ap_probe_req(wl, NULL); ieoffset = offsetof(struct ieee80211_mgmt, u.probe_req.variable); - wl1271_ssid_set(wl, wl->probereq, ieoffset); + wl1271_ssid_set(vif, wl->probereq, ieoffset); /* enable the connection monitoring feature */ ret = wl1271_acx_conn_monit_params(wl, true); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d84c0de..539cf40 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,8 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; - u8 ssid_len; int channel; u8 role_id; u8 dev_role_id; @@ -630,6 +628,9 @@ struct wl12xx_vif { u8 bss_type; u8 p2p; /* we are using p2p role */ + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; + u8 ssid_len; + u32 basic_rate_set; /* -- cgit v0.10.2 From bddb29b83a9874fda21c34abe7627cbf14fec10e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:49 +0200 Subject: wl12xx: move probereq into wlvif move probereq into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0da9ddc..006e174 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3525,11 +3525,12 @@ sta_not_found: /* * Get a template for hardware connection maintenance */ - dev_kfree_skb(wl->probereq); - wl->probereq = wl1271_cmd_build_ap_probe_req(wl, NULL); + dev_kfree_skb(wlvif->probereq); + wlvif->probereq = wl1271_cmd_build_ap_probe_req(wl, + NULL); ieoffset = offsetof(struct ieee80211_mgmt, u.probe_req.variable); - wl1271_ssid_set(vif, wl->probereq, ieoffset); + wl1271_ssid_set(vif, wlvif->probereq, ieoffset); /* enable the connection monitoring feature */ ret = wl1271_acx_conn_monit_params(wl, true); @@ -3546,8 +3547,8 @@ sta_not_found: wl->aid = 0; /* free probe-request template */ - dev_kfree_skb(wl->probereq); - wl->probereq = NULL; + dev_kfree_skb(wlvif->probereq); + wlvif->probereq = NULL; /* re-enable dynamic ps - just in case */ ieee80211_enable_dyn_ps(wl->vif); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 197d2c2..e3b863b 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -64,7 +64,7 @@ void wl1271_scan_complete_work(struct work_struct *work) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { /* restore hardware connection monitoring template */ - wl1271_cmd_build_ap_probe_req(wl, wl->probereq); + wl1271_cmd_build_ap_probe_req(wl, wlvif->probereq); } /* return to ROC if needed */ diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 539cf40..8d10056 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -507,9 +507,6 @@ struct wl1271 { bool sched_scanning; - /* probe-req template for the current AP */ - struct sk_buff *probereq; - /* Our association ID */ u16 aid; @@ -641,6 +638,9 @@ struct wl12xx_vif { */ u32 basic_rate; u32 rate_set; + + /* probe-req template for the current AP */ + struct sk_buff *probereq; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From 6840e37aec6fd9ffa5b4cf62674af55afdb565ed Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:50 +0200 Subject: wl12xx: move aid into wlvif move aid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 006e174..e0a557f 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2217,7 +2217,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl1271_acx_aid(wl, wl->aid); + ret = wl1271_acx_aid(wl, wlvif->aid); if (ret < 0) goto out; @@ -3487,7 +3487,7 @@ sta_not_found: if (bss_conf->assoc) { u32 rates; int ieoffset; - wl->aid = bss_conf->aid; + wlvif->aid = bss_conf->aid; set_assoc = true; wl->ps_poll_failures = 0; @@ -3518,7 +3518,7 @@ sta_not_found: * updates it by itself when the first beacon is * received after a join. */ - ret = wl1271_cmd_build_ps_poll(wl, wlvif, wl->aid); + ret = wl1271_cmd_build_ps_poll(wl, wlvif, wlvif->aid); if (ret < 0) goto out; @@ -3544,7 +3544,7 @@ sta_not_found: bool was_ifup = !!test_and_clear_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags); - wl->aid = 0; + wlvif->aid = 0; /* free probe-request template */ dev_kfree_skb(wlvif->probereq); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 8d10056..e6d3c21 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -507,9 +507,6 @@ struct wl1271 { bool sched_scanning; - /* Our association ID */ - u16 aid; - u32 bitrate_masks[IEEE80211_NUM_BANDS]; /* The current band */ @@ -641,6 +638,9 @@ struct wl12xx_vif { /* probe-req template for the current AP */ struct sk_buff *probereq; + + /* Our association ID */ + u16 aid; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From 0603d891c5b5153f667a79357d4652824c22b54e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:51 +0200 Subject: wl12xx: move role_id into wlvif move role_id into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 015938f..9b4eef6 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -33,7 +33,7 @@ #include "reg.h" #include "ps.h" -int wl1271_acx_wake_up_conditions(struct wl1271 *wl) +int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_wake_up_condition *wake_up; int ret; @@ -46,7 +46,7 @@ int wl1271_acx_wake_up_conditions(struct wl1271 *wl) goto out; } - wake_up->role_id = wl->role_id; + wake_up->role_id = wlvif->role_id; wake_up->wake_up_event = wl->conf.conn.wake_up_event; wake_up->listen_interval = wl->conf.conn.listen_interval; @@ -84,7 +84,8 @@ out: return ret; } -int wl1271_acx_tx_power(struct wl1271 *wl, int power) +int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif, + int power) { struct acx_current_tx_power *acx; int ret; @@ -100,7 +101,7 @@ int wl1271_acx_tx_power(struct wl1271 *wl, int power) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->current_tx_power = power * 10; ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); @@ -114,7 +115,7 @@ out: return ret; } -int wl1271_acx_feature_cfg(struct wl1271 *wl) +int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_feature_config *feature; int ret; @@ -128,7 +129,7 @@ int wl1271_acx_feature_cfg(struct wl1271 *wl) } /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ - feature->role_id = wl->role_id; + feature->role_id = wlvif->role_id; feature->data_flow_options = 0; feature->options = 0; @@ -210,7 +211,8 @@ out: return ret; } -int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time) +int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_slot_type slot_time) { struct acx_slot *slot; int ret; @@ -223,7 +225,7 @@ int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time) goto out; } - slot->role_id = wl->role_id; + slot->role_id = wlvif->role_id; slot->wone_index = STATION_WONE_INDEX; slot->slot_time = slot_time; @@ -238,8 +240,8 @@ out: return ret; } -int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, - void *mc_list, u32 mc_list_len) +int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, void *mc_list, u32 mc_list_len) { struct acx_dot11_grp_addr_tbl *acx; int ret; @@ -253,7 +255,7 @@ int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, } /* MAC filtering */ - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->enabled = enable; acx->num_groups = mc_list_len; memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN); @@ -270,7 +272,8 @@ out: return ret; } -int wl1271_acx_service_period_timeout(struct wl1271 *wl) +int wl1271_acx_service_period_timeout(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct acx_rx_timeout *rx_timeout; int ret; @@ -283,7 +286,7 @@ int wl1271_acx_service_period_timeout(struct wl1271 *wl) wl1271_debug(DEBUG_ACX, "acx service period timeout"); - rx_timeout->role_id = wl->role_id; + rx_timeout->role_id = wlvif->role_id; rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout); rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout); @@ -300,7 +303,8 @@ out: return ret; } -int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold) +int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u32 rts_threshold) { struct acx_rts_threshold *rts; int ret; @@ -320,7 +324,7 @@ int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold) goto out; } - rts->role_id = wl->role_id; + rts->role_id = wlvif->role_id; rts->threshold = cpu_to_le16((u16)rts_threshold); ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); @@ -363,7 +367,8 @@ out: return ret; } -int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter) +int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable_filter) { struct acx_beacon_filter_option *beacon_filter = NULL; int ret = 0; @@ -380,7 +385,7 @@ int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter) goto out; } - beacon_filter->role_id = wl->role_id; + beacon_filter->role_id = wlvif->role_id; beacon_filter->enable = enable_filter; /* @@ -401,7 +406,8 @@ out: return ret; } -int wl1271_acx_beacon_filter_table(struct wl1271 *wl) +int wl1271_acx_beacon_filter_table(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct acx_beacon_filter_ie_table *ie_table; int i, idx = 0; @@ -417,7 +423,7 @@ int wl1271_acx_beacon_filter_table(struct wl1271 *wl) } /* configure default beacon pass-through rules */ - ie_table->role_id = wl->role_id; + ie_table->role_id = wlvif->role_id; ie_table->num_ie = 0; for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) { struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]); @@ -458,7 +464,8 @@ out: #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff -int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable) +int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { struct acx_conn_monit_params *acx; u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE; @@ -479,7 +486,7 @@ int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable) timeout = wl->conf.conn.bss_lose_timeout; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->synch_fail_thold = cpu_to_le32(threshold); acx->bss_lose_timeout = cpu_to_le32(timeout); @@ -582,7 +589,7 @@ out: return ret; } -int wl1271_acx_bcn_dtim_options(struct wl1271 *wl) +int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_beacon_broadcast *bb; int ret; @@ -595,7 +602,7 @@ int wl1271_acx_bcn_dtim_options(struct wl1271 *wl) goto out; } - bb->role_id = wl->role_id; + bb->role_id = wlvif->role_id; bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout); bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout); bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps; @@ -612,7 +619,7 @@ out: return ret; } -int wl1271_acx_aid(struct wl1271 *wl, u16 aid) +int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid) { struct acx_aid *acx_aid; int ret; @@ -625,7 +632,7 @@ int wl1271_acx_aid(struct wl1271 *wl, u16 aid) goto out; } - acx_aid->role_id = wl->role_id; + acx_aid->role_id = wlvif->role_id; acx_aid->aid = cpu_to_le16(aid); ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid)); @@ -668,7 +675,8 @@ out: return ret; } -int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble) +int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_preamble_type preamble) { struct acx_preamble *acx; int ret; @@ -681,7 +689,7 @@ int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->preamble = preamble; ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx)); @@ -695,7 +703,7 @@ out: return ret; } -int wl1271_acx_cts_protect(struct wl1271 *wl, +int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif, enum acx_ctsprotect_type ctsprotect) { struct acx_ctsprotect *acx; @@ -709,7 +717,7 @@ int wl1271_acx_cts_protect(struct wl1271 *wl, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->ctsprotect = ctsprotect; ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx)); @@ -839,8 +847,8 @@ out: return ret; } -int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, - u8 aifsn, u16 txop) +int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop) { struct acx_ac_cfg *acx; int ret = 0; @@ -855,7 +863,7 @@ int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->ac = ac; acx->cw_min = cw_min; acx->cw_max = cpu_to_le16(cw_max); @@ -873,7 +881,8 @@ out: return ret; } -int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, +int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 queue_id, u8 channel_type, u8 tsid, u8 ps_scheme, u8 ack_policy, u32 apsd_conf0, u32 apsd_conf1) { @@ -889,7 +898,7 @@ int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->queue_id = queue_id; acx->channel_type = channel_type; acx->tsid = tsid; @@ -1098,7 +1107,8 @@ out: return ret; } -int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable) +int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { struct wl1271_acx_bet_enable *acx = NULL; int ret = 0; @@ -1114,7 +1124,7 @@ int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE; acx->max_consecutive = wl->conf.conn.bet_max_consecutive; @@ -1129,7 +1139,8 @@ out: return ret; } -int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address) +int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 enable, __be32 address) { struct wl1271_acx_arp_filter *acx; int ret; @@ -1142,7 +1153,7 @@ int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->version = ACX_IPV4_VERSION; acx->enable = enable; @@ -1189,7 +1200,8 @@ out: return ret; } -int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable) +int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { struct wl1271_acx_keep_alive_mode *acx = NULL; int ret = 0; @@ -1202,7 +1214,7 @@ int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->enabled = enable; ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx)); @@ -1216,7 +1228,8 @@ out: return ret; } -int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid) +int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 index, u8 tpl_valid) { struct wl1271_acx_keep_alive_config *acx = NULL; int ret = 0; @@ -1229,7 +1242,7 @@ int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval); acx->index = index; acx->tpl_validation = tpl_valid; @@ -1247,8 +1260,8 @@ out: return ret; } -int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable, - s16 thold, u8 hyst) +int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, s16 thold, u8 hyst) { struct wl1271_acx_rssi_snr_trigger *acx = NULL; int ret = 0; @@ -1263,7 +1276,7 @@ int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable, wl->last_rssi_event = -1; - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing); acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON; acx->type = WL1271_ACX_TRIG_TYPE_EDGE; @@ -1288,7 +1301,8 @@ out: return ret; } -int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl) +int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl1271_acx_rssi_snr_avg_weights *acx = NULL; struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger; @@ -1302,7 +1316,7 @@ int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->rssi_beacon = c->avg_weight_rssi_beacon; acx->rssi_data = c->avg_weight_rssi_data; acx->snr_beacon = c->avg_weight_snr_beacon; @@ -1367,6 +1381,7 @@ out: } int wl1271_acx_set_ht_information(struct wl1271 *wl, + struct wl12xx_vif *wlvif, u16 ht_operation_mode) { struct wl1271_acx_ht_information *acx; @@ -1380,7 +1395,7 @@ int wl1271_acx_set_ht_information(struct wl1271 *wl, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->ht_protection = (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION); acx->rifs_mode = 0; @@ -1402,7 +1417,8 @@ out: } /* Configure BA session initiator/receiver parameters setting in the FW. */ -int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl) +int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl1271_acx_ba_initiator_policy *acx; int ret; @@ -1416,7 +1432,7 @@ int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl) } /* set for the current role */ - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap; acx->win_size = wl->conf.ht.tx_ba_win_size; acx->inactivity_timeout = wl->conf.ht.inactivity_timeout; @@ -1496,6 +1512,8 @@ out: int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_acx_ps_rx_streaming *rx_streaming; u32 conf_queues, enable_queues; int i, ret = 0; @@ -1523,7 +1541,7 @@ int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable) if (!(conf_queues & BIT(i))) continue; - rx_streaming->role_id = wl->role_id; + rx_streaming->role_id = wlvif->role_id; rx_streaming->tid = i; rx_streaming->enable = enable_queues & BIT(i); rx_streaming->period = wl->conf.rx_streaming.interval; @@ -1542,7 +1560,7 @@ out: return ret; } -int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl) +int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl1271_acx_ap_max_tx_retry *acx = NULL; int ret; @@ -1553,7 +1571,7 @@ int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl) if (!acx) return -ENOMEM; - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries); ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx)); diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 2678e1d..7fccfcc 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1234,39 +1234,49 @@ enum { }; -int wl1271_acx_wake_up_conditions(struct wl1271 *wl); +int wl1271_acx_wake_up_conditions(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth); -int wl1271_acx_tx_power(struct wl1271 *wl, int power); -int wl1271_acx_feature_cfg(struct wl1271 *wl); +int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif, + int power); +int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map, size_t len); int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl); int wl1271_acx_pd_threshold(struct wl1271 *wl); -int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time); -int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, - void *mc_list, u32 mc_list_len); -int wl1271_acx_service_period_timeout(struct wl1271 *wl); -int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold); +int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_slot_type slot_time); +int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, void *mc_list, u32 mc_list_len); +int wl1271_acx_service_period_timeout(struct wl1271 *wl, + struct wl12xx_vif *wlvif); +int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u32 rts_threshold); int wl1271_acx_dco_itrim_params(struct wl1271 *wl); -int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter); -int wl1271_acx_beacon_filter_table(struct wl1271 *wl); -int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable); +int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable_filter); +int wl1271_acx_beacon_filter_table(struct wl1271 *wl, + struct wl12xx_vif *wlvif); +int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable); int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable); int wl12xx_acx_sg_cfg(struct wl1271 *wl); int wl1271_acx_cca_threshold(struct wl1271 *wl); -int wl1271_acx_bcn_dtim_options(struct wl1271 *wl); -int wl1271_acx_aid(struct wl1271 *wl, u16 aid); +int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid); int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask); -int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble); -int wl1271_acx_cts_protect(struct wl1271 *wl, +int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_preamble_type preamble); +int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif, enum acx_ctsprotect_type ctsprotect); int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats); int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c, u8 idx); -int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, - u8 aifsn, u16 txop); -int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, +int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop); +int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 queue_id, u8 channel_type, u8 tsid, u8 ps_scheme, u8 ack_policy, u32 apsd_conf0, u32 apsd_conf1); int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold); @@ -1276,25 +1286,32 @@ int wl1271_acx_init_mem_config(struct wl1271 *wl); int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap); int wl1271_acx_init_rx_interrupt(struct wl1271 *wl); int wl1271_acx_smart_reflex(struct wl1271 *wl); -int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable); -int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address); +int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable); +int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 enable, __be32 address); int wl1271_acx_pm_config(struct wl1271 *wl); -int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable); -int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid); -int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable, - s16 thold, u8 hyst); -int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl); +int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *vif, + bool enable); +int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 index, u8 tpl_valid); +int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, s16 thold, u8 hyst); +int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl1271_acx_set_ht_capabilities(struct wl1271 *wl, struct ieee80211_sta_ht_cap *ht_cap, bool allow_ht_operation, u8 hlid); int wl1271_acx_set_ht_information(struct wl1271 *wl, + struct wl12xx_vif *wlvif, u16 ht_operation_mode); -int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl); +int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn, bool enable, u8 peer_hlid); int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); -int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl); +int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); int wl1271_acx_fm_coex(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 1f29eab..918faca 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -567,9 +567,9 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role start sta %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role start sta %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -592,7 +592,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", - wl->role_id, cmd->sta.hlid, cmd->sta.session, + wlvif->role_id, cmd->sta.hlid, cmd->sta.session, wlvif->basic_rate_set, wlvif->rate_set); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); @@ -615,7 +615,7 @@ out: } /* use this function to stop ibss as well */ -int wl12xx_cmd_role_stop_sta(struct wl1271 *wl) +int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -629,9 +629,9 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role stop sta %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role stop sta %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; cmd->disc_type = DISCONNECT_IMMEDIATE; cmd->reason = cpu_to_le16(WLAN_REASON_UNSPECIFIED); @@ -656,7 +656,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; int ret; - wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wlvif->role_id); /* trying to use hidden SSID with an old hostapd version */ if (wlvif->ssid_len == 0 && !bss_conf->hidden_ssid) { @@ -679,7 +679,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (ret < 0) goto out_free_global; - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; cmd->ap.aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period); cmd->ap.bss_index = WL1271_AP_BSS_INDEX; cmd->ap.global_hlid = wl->ap_global_hlid; @@ -737,7 +737,7 @@ out: return ret; } -int wl12xx_cmd_role_stop_ap(struct wl1271 *wl) +int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -748,9 +748,9 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role stop ap %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role stop ap %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; ret = wl1271_cmd_send(wl, CMD_ROLE_STOP, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -781,9 +781,9 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role start ibss %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role start ibss %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -806,7 +806,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", - wl->role_id, cmd->sta.hlid, cmd->sta.session, + wlvif->role_id, cmd->sta.hlid, cmd->sta.session, wlvif->basic_rate_set, wlvif->rate_set); wl1271_debug(DEBUG_CMD, "vif->bss_conf.bssid = %pM", @@ -966,7 +966,8 @@ out: return ret; } -int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode) +int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ps_mode) { struct wl1271_cmd_ps_params *ps_params = NULL; int ret = 0; @@ -979,7 +980,7 @@ int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode) goto out; } - ps_params->role_id = wl->role_id; + ps_params->role_id = wlvif->role_id; ps_params->ps_mode = ps_mode; ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params, diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index d5749f5b..bf2c45b 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -42,15 +42,16 @@ int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); int wl12xx_cmd_role_start_dev(struct wl1271 *wl); int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); -int wl12xx_cmd_role_stop_sta(struct wl1271 *wl); +int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); -int wl12xx_cmd_role_stop_ap(struct wl1271 *wl); +int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_data_path(struct wl1271 *wl, bool enable); -int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode); +int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ps_mode); int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, size_t len); int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 8f88ad6..3309fea 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -620,11 +620,19 @@ static ssize_t beacon_filtering_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; char buf[10]; size_t len; unsigned long value; int ret; + if (!wl->vif) + return -EINVAL; + + vif = wl->vif; + wlvif = wl12xx_vif_to_data(vif); + len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; @@ -642,7 +650,7 @@ static ssize_t beacon_filtering_write(struct file *file, if (ret < 0) goto out; - ret = wl1271_acx_beacon_filter_opt(wl, !!value); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value); wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 072addc..28a4396 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -64,8 +64,8 @@ void wl1271_pspoll_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, wlvif->basic_rate, - true); + wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, + wlvif->basic_rate, true); wl1271_ps_elp_sleep(wl); out: @@ -85,7 +85,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, /* force active mode receive data from the AP */ if (test_bit(WL1271_FLAG_PSM, &wl->flags)) { - ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); if (ret < 0) return; @@ -124,7 +124,8 @@ static int wl1271_event_ps_report(struct wl1271 *wl, if (wl->psm_entry_retry < total_retries) { wl->psm_entry_retry++; - ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, + STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); } else { wl1271_info("No ack to nullfunc from AP."); @@ -136,7 +137,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, wl->psm_entry_retry = 0; /* enable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, true); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); if (ret < 0) break; @@ -146,7 +147,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, */ if (wl->band == IEEE80211_BAND_2GHZ) /* enable beacon early termination */ - ret = wl1271_acx_bet_enable(wl, true); + ret = wl1271_acx_bet_enable(wl, wlvif, true); if (wl->ps_compl) { complete(wl->ps_compl); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index e54cc69..1eaa0a3 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -233,35 +233,37 @@ int wl1271_init_phy_config(struct wl1271 *wl) return 0; } -static int wl12xx_init_phy_vif_config(struct wl1271 *wl) +static int wl12xx_init_phy_vif_config(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME); + ret = wl1271_acx_slot(wl, wlvif, DEFAULT_SLOT_TIME); if (ret < 0) return ret; - ret = wl1271_acx_service_period_timeout(wl); + ret = wl1271_acx_service_period_timeout(wl, wlvif); if (ret < 0) return ret; - ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold); + ret = wl1271_acx_rts_threshold(wl, wlvif, wl->hw->wiphy->rts_threshold); if (ret < 0) return ret; return 0; } -static int wl1271_init_beacon_filter(struct wl1271 *wl) +static int wl1271_init_beacon_filter(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; /* disable beacon filtering at this stage */ - ret = wl1271_acx_beacon_filter_opt(wl, false); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); if (ret < 0) return ret; - ret = wl1271_acx_beacon_filter_table(wl); + ret = wl1271_acx_beacon_filter_table(wl, wlvif); if (ret < 0) return ret; @@ -294,11 +296,12 @@ int wl1271_init_energy_detection(struct wl1271 *wl) return 0; } -static int wl1271_init_beacon_broadcast(struct wl1271 *wl) +static int wl1271_init_beacon_broadcast(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_bcn_dtim_options(wl); + ret = wl1271_acx_bcn_dtim_options(wl, wlvif); if (ret < 0) return ret; @@ -352,20 +355,22 @@ static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) return 0; } -static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) +static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl, + struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret, i; /* disable all keep-alive templates */ for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { - ret = wl1271_acx_keep_alive_config(wl, i, + ret = wl1271_acx_keep_alive_config(wl, wlvif, i, ACX_KEEP_ALIVE_TPL_INVALID); if (ret < 0) return ret; } /* disable the keep-alive feature */ - ret = wl1271_acx_keep_alive_mode(wl, false); + ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); if (ret < 0) return ret; @@ -410,7 +415,7 @@ int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) * when operating as AP we want to receive external beacons for * configuring ERP protection. */ - ret = wl1271_acx_beacon_filter_opt(wl, false); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); if (ret < 0) return ret; @@ -495,7 +500,7 @@ static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl->ba_support = true; /* 802.11n initiator BA session setting */ - return wl12xx_acx_set_ba_initiator_policy(wl); + return wl12xx_acx_set_ba_initiator_policy(wl, wlvif); } int wl1271_chip_specific_init(struct wl1271 *wl) @@ -519,31 +524,31 @@ out: } /* vif-specifc initialization */ -static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif) +static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0); + ret = wl1271_acx_group_address_tbl(wl, wlvif, true, NULL, 0); if (ret < 0) return ret; /* Initialize connection monitoring thresholds */ - ret = wl1271_acx_conn_monit_params(wl, false); + ret = wl1271_acx_conn_monit_params(wl, wlvif, false); if (ret < 0) return ret; /* Beacon filtering */ - ret = wl1271_init_beacon_filter(wl); + ret = wl1271_init_beacon_filter(wl, wlvif); if (ret < 0) return ret; /* Beacons and broadcast settings */ - ret = wl1271_init_beacon_broadcast(wl); + ret = wl1271_init_beacon_broadcast(wl, wlvif); if (ret < 0) return ret; /* Configure rssi/snr averaging weights */ - ret = wl1271_acx_rssi_snr_avg_weights(wl); + ret = wl1271_acx_rssi_snr_avg_weights(wl, wlvif); if (ret < 0) return ret; @@ -551,16 +556,16 @@ static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif) } /* vif-specific intialization */ -static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif) +static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_ap_max_tx_retry(wl); + ret = wl1271_acx_ap_max_tx_retry(wl, wlvif); if (ret < 0) return ret; /* initialize Tx power */ - ret = wl1271_acx_tx_power(wl, wl->power_level); + ret = wl1271_acx_tx_power(wl, wlvif, wl->power_level); if (ret < 0) return ret; @@ -582,7 +587,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; - ret = wl12xx_init_ap_role(wl, vif); + ret = wl12xx_init_ap_role(wl, wlvif); if (ret < 0) return ret; } else { @@ -590,25 +595,25 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; - ret = wl12xx_init_sta_role(wl, vif); + ret = wl12xx_init_sta_role(wl, wlvif); if (ret < 0) return ret; } - wl12xx_init_phy_vif_config(wl); + wl12xx_init_phy_vif_config(wl, wlvif); /* Default TID/AC configuration */ BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { conf_ac = &wl->conf.tx.ac_conf[i]; - ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, - conf_ac->cw_max, conf_ac->aifsn, - conf_ac->tx_op_limit); + ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac, + conf_ac->cw_min, conf_ac->cw_max, + conf_ac->aifsn, conf_ac->tx_op_limit); if (ret < 0) return ret; conf_tid = &wl->conf.tx.tid_conf[i]; - ret = wl1271_acx_tid_cfg(wl, + ret = wl1271_acx_tid_cfg(wl, wlvif, conf_tid->queue_id, conf_tid->channel_type, conf_tid->tsid, @@ -621,7 +626,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) } /* Configure HW encryption */ - ret = wl1271_acx_feature_cfg(wl); + ret = wl1271_acx_feature_cfg(wl, wlvif); if (ret < 0) return ret; @@ -629,7 +634,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (is_ap) ret = wl1271_ap_hw_init_post_mem(wl, vif); else - ret = wl1271_sta_hw_init_post_mem(wl); + ret = wl1271_sta_hw_init_post_mem(wl, vif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index e0a557f..b3d4ef5 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -402,7 +402,10 @@ static LIST_HEAD(wl_list); static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; + if (operstate != IF_OPER_UP) return 0; @@ -413,7 +416,7 @@ static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) if (ret < 0) return ret; - wl12xx_croc(wl, wl->role_id); + wl12xx_croc(wl, wlvif->role_id); wl1271_info("Association completed."); return 0; @@ -695,7 +698,7 @@ static int wl1271_plt_init(struct wl1271 *wl) goto out_free_memmap; /* Initialize connection monitoring thresholds */ - ret = wl1271_acx_conn_monit_params(wl, false); + ret = wl1271_acx_conn_monit_params(wl, NULL, false); /* TODO: fix */ if (ret < 0) goto out_free_memmap; @@ -727,14 +730,16 @@ static int wl1271_plt_init(struct wl1271 *wl) BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { conf_ac = &wl->conf.tx.ac_conf[i]; - ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, + /* TODO: fix */ + ret = wl1271_acx_ac_cfg(wl, NULL, conf_ac->ac, conf_ac->cw_min, conf_ac->cw_max, conf_ac->aifsn, conf_ac->tx_op_limit); if (ret < 0) goto out_free_memmap; conf_tid = &wl->conf.tx.tid_conf[i]; - ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id, + /* TODO: fix */ + ret = wl1271_acx_tid_cfg(wl, NULL, conf_tid->queue_id, conf_tid->channel_type, conf_tid->tsid, conf_tid->ps_scheme, @@ -1631,7 +1636,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, DECLARE_COMPLETION_ONSTACK(compl); wl->ps_compl = &compl; - ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); if (ret < 0) goto out_sleep; @@ -1664,7 +1669,8 @@ out: } -static int wl1271_configure_suspend_ap(struct wl1271 *wl) +static int wl1271_configure_suspend_ap(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret = 0; @@ -1677,7 +1683,7 @@ static int wl1271_configure_suspend_ap(struct wl1271 *wl) if (ret < 0) goto out_unlock; - ret = wl1271_acx_beacon_filter_opt(wl, true); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); wl1271_ps_elp_sleep(wl); out_unlock: @@ -1692,7 +1698,7 @@ static int wl1271_configure_suspend(struct wl1271 *wl, if (wlvif->bss_type == BSS_TYPE_STA_BSS) return wl1271_configure_suspend_sta(wl, wlvif); if (wlvif->bss_type == BSS_TYPE_AP_BSS) - return wl1271_configure_suspend_ap(wl); + return wl1271_configure_suspend_ap(wl, wlvif); return 0; } @@ -1714,10 +1720,10 @@ static void wl1271_configure_resume(struct wl1271 *wl, if (is_sta) { /* exit psm if it wasn't configured */ if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) - wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, + wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); } else if (is_ap) { - wl1271_acx_beacon_filter_opt(wl, false); + wl1271_acx_beacon_filter_opt(wl, wlvif, false); } wl1271_ps_elp_sleep(wl); @@ -1850,6 +1856,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->bss_type = MAX_BSS_TYPE; + wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -1957,7 +1964,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, } ret = wl12xx_cmd_role_enable(wl, vif->addr, - role_type, &wl->role_id); + role_type, &wlvif->role_id); if (ret < 0) goto irq_disable; @@ -2065,7 +2072,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, goto deinit; } - ret = wl12xx_cmd_role_disable(wl, &wl->role_id); + ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id); if (ret < 0) goto deinit; @@ -2123,7 +2130,7 @@ deinit: wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; wl->sched_scanning = false; - wl->role_id = WL12XX_INVALID_ROLE_ID; + wlvif->role_id = WL12XX_INVALID_ROLE_ID; wl->dev_role_id = WL12XX_INVALID_ROLE_ID; memset(wl->roles_map, 0, sizeof(wl->roles_map)); memset(wl->links_map, 0, sizeof(wl->links_map)); @@ -2213,11 +2220,11 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, * the join. The acx_aid starts the keep-alive process, and the order * of the commands below is relevant. */ - ret = wl1271_acx_keep_alive_mode(wl, true); + ret = wl1271_acx_keep_alive_mode(wl, wlvif, true); if (ret < 0) goto out; - ret = wl1271_acx_aid(wl, wlvif->aid); + ret = wl1271_acx_aid(wl, wlvif, wlvif->aid); if (ret < 0) goto out; @@ -2225,7 +2232,8 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl1271_acx_keep_alive_config(wl, CMD_TEMPL_KLV_IDX_NULL_DATA, + ret = wl1271_acx_keep_alive_config(wl, wlvif, + CMD_TEMPL_KLV_IDX_NULL_DATA, ACX_KEEP_ALIVE_TPL_VALID); if (ret < 0) goto out; @@ -2234,7 +2242,7 @@ out: return ret; } -static int wl1271_unjoin(struct wl1271 *wl) +static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; @@ -2244,7 +2252,7 @@ static int wl1271_unjoin(struct wl1271 *wl) } /* to stop listening to a channel, we disconnect */ - ret = wl12xx_cmd_role_stop_sta(wl); + ret = wl12xx_cmd_role_stop_sta(wl, wlvif); if (ret < 0) goto out; @@ -2295,7 +2303,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; ret = wl1271_acx_keep_alive_config( - wl, CMD_TEMPL_KLV_IDX_NULL_DATA, + wl, wlvif, CMD_TEMPL_KLV_IDX_NULL_DATA, ACX_KEEP_ALIVE_TPL_INVALID); if (ret < 0) goto out; @@ -2454,7 +2462,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) */ if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { wl1271_debug(DEBUG_PSM, "psm enabled"); - ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, + STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); } } else if (!(conf->flags & IEEE80211_CONF_PS) && @@ -2464,12 +2473,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) clear_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags); if (test_bit(WL1271_FLAG_PSM, &wl->flags)) - ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, + STATION_ACTIVE_MODE, wlvif->basic_rate, true); } if (conf->power_level != wl->power_level) { - ret = wl1271_acx_tx_power(wl, conf->power_level); + ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); if (ret < 0) goto out_sleep; @@ -2558,9 +2568,11 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (*total & FIF_ALLMULTI) - ret = wl1271_acx_group_address_tbl(wl, false, NULL, 0); + ret = wl1271_acx_group_address_tbl(wl, wlvif, false, + NULL, 0); else if (fp) - ret = wl1271_acx_group_address_tbl(wl, fp->enabled, + ret = wl1271_acx_group_address_tbl(wl, wlvif, + fp->enabled, fp->mc_list, fp->mc_list_length); if (ret < 0) @@ -3051,6 +3063,8 @@ out: static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; mutex_lock(&wl->mutex); @@ -3064,7 +3078,7 @@ static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) if (ret < 0) goto out; - ret = wl1271_acx_rts_threshold(wl, value); + ret = wl1271_acx_rts_threshold(wl, wlvif, value); if (ret < 0) wl1271_warning("wl1271_op_set_rts_threshold failed: %d", ret); @@ -3190,16 +3204,18 @@ static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, } static int wl1271_bss_erp_info_changed(struct wl1271 *wl, + struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; if (changed & BSS_CHANGED_ERP_SLOT) { if (bss_conf->use_short_slot) - ret = wl1271_acx_slot(wl, SLOT_TIME_SHORT); + ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_SHORT); else - ret = wl1271_acx_slot(wl, SLOT_TIME_LONG); + ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_LONG); if (ret < 0) { wl1271_warning("Set slot time failed %d", ret); goto out; @@ -3208,16 +3224,18 @@ static int wl1271_bss_erp_info_changed(struct wl1271 *wl, if (changed & BSS_CHANGED_ERP_PREAMBLE) { if (bss_conf->use_short_preamble) - wl1271_acx_set_preamble(wl, ACX_PREAMBLE_SHORT); + wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_SHORT); else - wl1271_acx_set_preamble(wl, ACX_PREAMBLE_LONG); + wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_LONG); } if (changed & BSS_CHANGED_ERP_CTS_PROT) { if (bss_conf->use_cts_prot) - ret = wl1271_acx_cts_protect(wl, CTSPROTECT_ENABLE); + ret = wl1271_acx_cts_protect(wl, wlvif, + CTSPROTECT_ENABLE); else - ret = wl1271_acx_cts_protect(wl, CTSPROTECT_DISABLE); + ret = wl1271_acx_cts_protect(wl, wlvif, + CTSPROTECT_DISABLE); if (ret < 0) { wl1271_warning("Set ctsprotect failed %d", ret); goto out; @@ -3359,7 +3377,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, } } else { if (test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { - ret = wl12xx_cmd_role_stop_ap(wl); + ret = wl12xx_cmd_role_stop_ap(wl, wlvif); if (ret < 0) goto out; @@ -3369,14 +3387,14 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, } } - ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed); + ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed); if (ret < 0) goto out; /* Handle HT information change */ if ((changed & BSS_CHANGED_HT) && (bss_conf->channel_type != NL80211_CHAN_NO_HT)) { - ret = wl1271_acx_set_ht_information(wl, + ret = wl1271_acx_set_ht_information(wl, wlvif, bss_conf->ht_operation_mode); if (ret < 0) { wl1271_warning("Set ht information failed %d", ret); @@ -3418,7 +3436,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, } else { if (test_and_clear_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) { - wl1271_unjoin(wl); + wl1271_unjoin(wl, wlvif); wl12xx_cmd_role_start_dev(wl); wl12xx_roc(wl, wl->dev_role_id); } @@ -3443,7 +3461,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, bool enable = false; if (bss_conf->cqm_rssi_thold) enable = true; - ret = wl1271_acx_rssi_snr_trigger(wl, enable, + ret = wl1271_acx_rssi_snr_trigger(wl, wlvif, enable, bss_conf->cqm_rssi_thold, bss_conf->cqm_rssi_hyst); if (ret < 0) @@ -3533,7 +3551,7 @@ sta_not_found: wl1271_ssid_set(vif, wlvif->probereq, ieoffset); /* enable the connection monitoring feature */ - ret = wl1271_acx_conn_monit_params(wl, true); + ret = wl1271_acx_conn_monit_params(wl, wlvif, true); if (ret < 0) goto out; } else { @@ -3563,10 +3581,10 @@ sta_not_found: goto out; /* disable connection monitor features */ - ret = wl1271_acx_conn_monit_params(wl, false); + ret = wl1271_acx_conn_monit_params(wl, wlvif, false); /* Disable the keep-alive feature */ - ret = wl1271_acx_keep_alive_mode(wl, false); + ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); if (ret < 0) goto out; @@ -3578,7 +3596,7 @@ sta_not_found: * no IF_OPER_UP notification. */ if (!was_ifup) { - ret = wl12xx_croc(wl, wl->role_id); + ret = wl12xx_croc(wl, wlvif->role_id); if (ret < 0) goto out; } @@ -3593,7 +3611,7 @@ sta_not_found: goto out; } - wl1271_unjoin(wl); + wl1271_unjoin(wl, wlvif); if (!(conf_flags & IEEE80211_CONF_IDLE)) { wl12xx_cmd_role_start_dev(wl); wl12xx_roc(wl, wl->dev_role_id); @@ -3623,7 +3641,7 @@ sta_not_found: } } - ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed); + ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed); if (ret < 0) goto out; @@ -3645,11 +3663,11 @@ sta_not_found: goto out; } - ret = wl1271_acx_arp_ip_filter(wl, + ret = wl1271_acx_arp_ip_filter(wl, wlvif, ACX_ARP_FILTER_ARP_FILTERING, addr); } else - ret = wl1271_acx_arp_ip_filter(wl, 0, addr); + ret = wl1271_acx_arp_ip_filter(wl, wlvif, 0, addr); if (ret < 0) goto out; @@ -3664,7 +3682,7 @@ sta_not_found: /* ROC until connected (after EAPOL exchange) */ if (!is_ibss) { - ret = wl12xx_roc(wl, wl->role_id); + ret = wl12xx_roc(wl, wlvif->role_id); if (ret < 0) goto out; @@ -3691,7 +3709,7 @@ sta_not_found: enum wl1271_cmd_ps_mode mode; mode = STATION_POWER_SAVE_MODE; - ret = wl1271_ps_set_mode(wl, mode, + ret = wl1271_ps_set_mode(wl, wlvif, mode, wlvif->basic_rate, true); if (ret < 0) @@ -3730,7 +3748,7 @@ sta_not_found: /* Handle HT information change. Done after join. */ if ((changed & BSS_CHANGED_HT) && (bss_conf->channel_type != NL80211_CHAN_NO_HT)) { - ret = wl1271_acx_set_ht_information(wl, + ret = wl1271_acx_set_ht_information(wl, wlvif, bss_conf->ht_operation_mode); if (ret < 0) { wl1271_warning("Set ht information failed %d", ret); @@ -3780,6 +3798,7 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw, const struct ieee80211_tx_queue_params *params) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); u8 ps_scheme; int ret = 0; @@ -3826,13 +3845,13 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw, * the txop is confed in units of 32us by the mac80211, * we need us */ - ret = wl1271_acx_ac_cfg(wl, wl1271_tx_get_queue(queue), + ret = wl1271_acx_ac_cfg(wl, wlvif, wl1271_tx_get_queue(queue), params->cw_min, params->cw_max, params->aifs, params->txop << 5); if (ret < 0) goto out_sleep; - ret = wl1271_acx_tid_cfg(wl, wl1271_tx_get_queue(queue), + ret = wl1271_acx_tid_cfg(wl, wlvif, wl1271_tx_get_queue(queue), CONF_CHANNEL_TYPE_EDCF, wl1271_tx_get_queue(queue), ps_scheme, CONF_ACK_POLICY_LEGACY, @@ -4861,7 +4880,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_security_seq = 0; wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; - wl->role_id = WL12XX_INVALID_ROLE_ID; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->sta_hlid = WL12XX_INVALID_LINK_ID; wl->dev_role_id = WL12XX_INVALID_ROLE_ID; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index c15ebf2..ac3f207 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -143,8 +143,8 @@ out: return 0; } -int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, - u32 rates, bool send) +int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum wl1271_cmd_ps_mode mode, u32 rates, bool send) { int ret; @@ -152,13 +152,13 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, case STATION_POWER_SAVE_MODE: wl1271_debug(DEBUG_PSM, "entering psm"); - ret = wl1271_acx_wake_up_conditions(wl); + ret = wl1271_acx_wake_up_conditions(wl, wlvif); if (ret < 0) { wl1271_error("couldn't set wake up conditions"); return ret; } - ret = wl1271_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE); + ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_POWER_SAVE_MODE); if (ret < 0) return ret; @@ -170,17 +170,17 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, /* disable beacon early termination */ if (wl->band == IEEE80211_BAND_2GHZ) { - ret = wl1271_acx_bet_enable(wl, false); + ret = wl1271_acx_bet_enable(wl, wlvif, false); if (ret < 0) return ret; } /* disable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, false); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); if (ret < 0) return ret; - ret = wl1271_cmd_ps_mode(wl, STATION_ACTIVE_MODE); + ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_ACTIVE_MODE); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/ps.h index 25eb9bc..6ad0a0b 100644 --- a/drivers/net/wireless/wl12xx/ps.h +++ b/drivers/net/wireless/wl12xx/ps.h @@ -27,8 +27,8 @@ #include "wl12xx.h" #include "acx.h" -int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, - u32 rates, bool send); +int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum wl1271_cmd_ps_mode mode, u32 rates, bool send); void wl1271_ps_elp_sleep(struct wl1271 *wl); int wl1271_ps_elp_wakeup(struct wl1271 *wl); void wl1271_elp_work(struct work_struct *work); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index e3b863b..9d0dfb5 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -163,6 +163,7 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, enum ieee80211_band band, bool passive, u32 basic_rate) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_cmd_scan *cmd; struct wl1271_cmd_trigger_scan_to *trigger; int ret; @@ -182,11 +183,11 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, if (passive) scan_options |= WL1271_SCAN_OPT_PASSIVE; - if (WARN_ON(wl->role_id == WL12XX_INVALID_ROLE_ID)) { + if (WARN_ON(wlvif->role_id == WL12XX_INVALID_ROLE_ID)) { ret = -EINVAL; goto out; } - cmd->params.role_id = wl->role_id; + cmd->params.role_id = wlvif->role_id; cmd->params.scan_options = cpu_to_le16(scan_options); cmd->params.n_ch = wl1271_get_scan_channels(wl, wl->scan.req, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index e6d3c21..e249b45 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -401,7 +401,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; - u8 role_id; u8 dev_role_id; u8 system_hlid; u8 sta_hlid; @@ -621,6 +620,7 @@ struct wl1271_station { struct wl12xx_vif { u8 bss_type; u8 p2p; /* we are using p2p role */ + u8 role_id; u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v0.10.2 From 7edebf56ca424484b9e0e51a6188c93c7fdd3a41 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:52 +0200 Subject: wl12xx: move dev_role_id into wlvif move dev_role_id into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 918faca..36544ff 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -464,7 +464,7 @@ static int wl12xx_get_new_session_id(struct wl1271 *wl) return wl->session_counter; } -int wl12xx_cmd_role_start_dev(struct wl1271 *wl) +int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; int ret; @@ -475,9 +475,9 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role start dev %d", wl->dev_role_id); + wl1271_debug(DEBUG_CMD, "cmd role start dev %d", wlvif->dev_role_id); - cmd->role_id = wl->dev_role_id; + cmd->role_id = wlvif->dev_role_id; if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -514,7 +514,7 @@ out: return ret; } -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl) +int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -530,7 +530,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl) wl1271_debug(DEBUG_CMD, "cmd role stop dev"); - cmd->role_id = wl->dev_role_id; + cmd->role_id = wlvif->dev_role_id; cmd->disc_type = DISCONNECT_IMMEDIATE; cmd->reason = cpu_to_le16(WLAN_REASON_UNSPECIFIED); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index bf2c45b..fb40556 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -39,8 +39,8 @@ int wl1271_cmd_ext_radio_parms(struct wl1271 *wl); int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, u8 *role_id); int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); -int wl12xx_cmd_role_start_dev(struct wl1271 *wl); -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); +int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b3d4ef5..f4d3df1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1857,6 +1857,7 @@ static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->bss_type = MAX_BSS_TYPE; wlvif->role_id = WL12XX_INVALID_ROLE_ID; + wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -1958,7 +1959,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, */ ret = wl12xx_cmd_role_enable(wl, vif->addr, WL1271_ROLE_DEVICE, - &wl->dev_role_id); + &wlvif->dev_role_id); if (ret < 0) goto irq_disable; } @@ -2067,7 +2068,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, goto deinit; if (wlvif->bss_type == BSS_TYPE_STA_BSS) { - ret = wl12xx_cmd_role_disable(wl, &wl->dev_role_id); + ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id); if (ret < 0) goto deinit; } @@ -2131,7 +2132,7 @@ deinit: wl->ap_ps_map = 0; wl->sched_scanning = false; wlvif->role_id = WL12XX_INVALID_ROLE_ID; - wl->dev_role_id = WL12XX_INVALID_ROLE_ID; + wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; memset(wl->roles_map, 0, sizeof(wl->roles_map)); memset(wl->links_map, 0, sizeof(wl->links_map)); memset(wl->roc_map, 0, sizeof(wl->roc_map)); @@ -2289,11 +2290,11 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (idle) { /* no need to croc if we weren't busy (e.g. during boot) */ if (wl12xx_is_roc(wl)) { - ret = wl12xx_croc(wl, wl->dev_role_id); + ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) goto out; - ret = wl12xx_cmd_role_stop_dev(wl); + ret = wl12xx_cmd_role_stop_dev(wl, wlvif); if (ret < 0) goto out; } @@ -2315,11 +2316,11 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, ieee80211_sched_scan_stopped(wl->hw); } - ret = wl12xx_cmd_role_start_dev(wl); + ret = wl12xx_cmd_role_start_dev(wl, wlvif); if (ret < 0) goto out; - ret = wl12xx_roc(wl, wl->dev_role_id); + ret = wl12xx_roc(wl, wlvif->dev_role_id); if (ret < 0) goto out; clear_bit(WL1271_FLAG_IDLE, &wl->flags); @@ -2408,7 +2409,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { if (wl12xx_is_roc(wl)) { /* roaming */ - ret = wl12xx_croc(wl, wl->dev_role_id); + ret = wl12xx_croc(wl, + wlvif->dev_role_id); if (ret < 0) goto out_sleep; } @@ -2424,11 +2426,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) */ if (wl12xx_is_roc(wl) && !(conf->flags & IEEE80211_CONF_IDLE)) { - ret = wl12xx_croc(wl, wl->dev_role_id); + ret = wl12xx_croc(wl, + wlvif->dev_role_id); if (ret < 0) goto out_sleep; - ret = wl12xx_roc(wl, wl->dev_role_id); + ret = wl12xx_roc(wl, + wlvif->dev_role_id); if (ret < 0) wl1271_warning("roc failed %d", ret); @@ -2891,6 +2895,8 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int ret; u8 *ssid = NULL; size_t len = 0; @@ -2925,8 +2931,8 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, ret = -EBUSY; goto out_sleep; } - wl12xx_croc(wl, wl->dev_role_id); - wl12xx_cmd_role_stop_dev(wl); + wl12xx_croc(wl, wlvif->dev_role_id); + wl12xx_cmd_role_stop_dev(wl, wlvif); } ret = wl1271_scan(hw->priv, vif, ssid, len, req); @@ -3437,8 +3443,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (test_and_clear_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) { wl1271_unjoin(wl, wlvif); - wl12xx_cmd_role_start_dev(wl); - wl12xx_roc(wl, wl->dev_role_id); + wl12xx_cmd_role_start_dev(wl, wlvif); + wl12xx_roc(wl, wlvif->dev_role_id); } } } @@ -3605,16 +3611,17 @@ sta_not_found: * roaming on the same channel. until we will * have a better flow...) */ - if (test_bit(wl->dev_role_id, wl->roc_map)) { - ret = wl12xx_croc(wl, wl->dev_role_id); + if (test_bit(wlvif->dev_role_id, wl->roc_map)) { + ret = wl12xx_croc(wl, + wlvif->dev_role_id); if (ret < 0) goto out; } wl1271_unjoin(wl, wlvif); if (!(conf_flags & IEEE80211_CONF_IDLE)) { - wl12xx_cmd_role_start_dev(wl); - wl12xx_roc(wl, wl->dev_role_id); + wl12xx_cmd_role_start_dev(wl, wlvif); + wl12xx_roc(wl, wlvif->dev_role_id); } } } @@ -3693,12 +3700,12 @@ sta_not_found: * stop device role if started (we might already be in * STA role). TODO: make it better. */ - if (wl->dev_role_id != WL12XX_INVALID_ROLE_ID) { - ret = wl12xx_croc(wl, wl->dev_role_id); + if (wlvif->dev_role_id != WL12XX_INVALID_ROLE_ID) { + ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) goto out; - ret = wl12xx_cmd_role_stop_dev(wl); + ret = wl12xx_cmd_role_stop_dev(wl, wlvif); if (ret < 0) goto out; } @@ -4882,7 +4889,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->sta_hlid = WL12XX_INVALID_LINK_ID; - wl->dev_role_id = WL12XX_INVALID_ROLE_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->session_counter = 0; wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 9d0dfb5..9372136 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -34,6 +34,7 @@ void wl1271_scan_complete_work(struct work_struct *work) { struct delayed_work *dwork; struct wl1271 *wl; + struct ieee80211_vif *vif; struct wl12xx_vif *wlvif; int ret; bool is_sta, is_ibss; @@ -51,7 +52,8 @@ void wl1271_scan_complete_work(struct work_struct *work) if (wl->scan.state == WL1271_SCAN_STATE_IDLE) goto out; - wlvif = wl12xx_vif_to_data(wl->scan_vif); + vif = wl->scan_vif; + wlvif = wl12xx_vif_to_data(vif); wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); @@ -72,10 +74,10 @@ void wl1271_scan_complete_work(struct work_struct *work) is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); if (((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) || (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && - !test_bit(wl->dev_role_id, wl->roc_map)) { + !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ - wl12xx_cmd_role_start_dev(wl); - wl12xx_roc(wl, wl->dev_role_id); + wl12xx_cmd_role_start_dev(wl, wlvif); + wl12xx_roc(wl, wlvif->dev_role_id); } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 5561ec2..538d861 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -77,7 +77,8 @@ static void wl1271_free_tx_id(struct wl1271 *wl, int id) } static int wl1271_tx_update_filters(struct wl1271 *wl, - struct sk_buff *skb) + struct wl12xx_vif *wlvif, + struct sk_buff *skb) { struct ieee80211_hdr *hdr; int ret; @@ -97,11 +98,11 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, goto out; wl1271_debug(DEBUG_CMD, "starting device role for roaming"); - ret = wl12xx_cmd_role_start_dev(wl); + ret = wl12xx_cmd_role_start_dev(wl, wlvif); if (ret < 0) goto out; - ret = wl12xx_roc(wl, wl->dev_role_id); + ret = wl12xx_roc(wl, wlvif->dev_role_id); if (ret < 0) goto out; out: @@ -192,7 +193,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, if (wlvif->bss_type == BSS_TYPE_AP_BSS) return wl12xx_tx_get_hlid_ap(wl, skb); - wl1271_tx_update_filters(wl, skb); + wl1271_tx_update_filters(wl, wlvif, skb); if ((test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index e249b45..4c69ae1 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -401,7 +401,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; - u8 dev_role_id; u8 system_hlid; u8 sta_hlid; u8 dev_hlid; @@ -622,6 +621,9 @@ struct wl12xx_vif { u8 p2p; /* we are using p2p role */ u8 role_id; + /* sta/ibss specific */ + u8 dev_role_id; + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v0.10.2 From 154da67c7da14ffd8da292394f8cbc81cc5ea4e3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:53 +0200 Subject: wl12xx: move sta_hlid into wlvif move sta_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 36544ff..2a9a4b2 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -581,12 +581,12 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) memcpy(cmd->sta.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); - if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wl->sta_hlid); + if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { + ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); if (ret) goto out_free; } - cmd->sta.hlid = wl->sta_hlid; + cmd->sta.hlid = wlvif->sta.hlid; cmd->sta.session = wl12xx_get_new_session_id(wl); cmd->sta.remote_rates = cpu_to_le32(wlvif->rate_set); @@ -605,7 +605,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wl->sta_hlid); + wl12xx_free_link(wl, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -620,7 +620,7 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) struct wl12xx_cmd_role_stop *cmd; int ret; - if (WARN_ON(wl->sta_hlid == WL12XX_INVALID_LINK_ID)) + if (WARN_ON(wlvif->sta.hlid == WL12XX_INVALID_LINK_ID)) return -EINVAL; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -641,7 +641,7 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wl->sta_hlid); + wl12xx_free_link(wl, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -796,12 +796,12 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) memcpy(cmd->ibss.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); - if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wl->sta_hlid); + if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { + ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); if (ret) goto out_free; } - cmd->ibss.hlid = wl->sta_hlid; + cmd->ibss.hlid = wlvif->sta.hlid; cmd->ibss.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " @@ -822,7 +822,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wl->sta_hlid); + wl12xx_free_link(wl, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -1264,15 +1264,17 @@ out: return ret; } -int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_cmd_set_keys *cmd; int ret = 0; /* hlid might have already been deleted */ - if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) + if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) return 0; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -1281,7 +1283,7 @@ int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, goto out; } - cmd->hlid = wl->sta_hlid; + cmd->hlid = wlvif->sta.hlid; if (key_type == KEY_WEP) cmd->lid_key_type = WEP_DEFAULT_LID_TYPE; diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index fb40556..25ab400 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -70,7 +70,8 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); -int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16); int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f4d3df1..3358cfe 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -412,7 +412,7 @@ static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) if (test_and_set_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags)) return 0; - ret = wl12xx_cmd_set_peer_state(wl, wl->sta_hlid); + ret = wl12xx_cmd_set_peer_state(wl, wlvif->sta.hlid); if (ret < 0) return ret; @@ -1858,6 +1858,7 @@ static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) wlvif->bss_type = MAX_BSS_TYPE; wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -2081,7 +2082,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, } deinit: /* clear all hlids (except system_hlid) */ - wl->sta_hlid = WL12XX_INVALID_LINK_ID; + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; wl->ap_global_hlid = WL12XX_INVALID_LINK_ID; @@ -2765,10 +2766,10 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, /* don't remove key if hlid was already deleted */ if (action == KEY_REMOVE && - wl->sta_hlid == WL12XX_INVALID_LINK_ID) + wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) return 0; - ret = wl1271_cmd_set_sta_key(wl, action, + ret = wl1271_cmd_set_sta_key(wl, vif, action, id, key_type, key_size, key, addr, tx_seq_32, tx_seq_16); @@ -2779,7 +2780,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (key_type == KEY_WEP) { ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key, - wl->sta_hlid); + wlvif->sta.hlid); if (ret < 0) return ret; } @@ -3731,7 +3732,7 @@ sta_not_found: ret = wl1271_acx_set_ht_capabilities(wl, &sta_ht_cap, true, - wl->sta_hlid); + wlvif->sta.hlid); if (ret < 0) { wl1271_warning("Set ht cap true failed %d", ret); @@ -3743,7 +3744,7 @@ sta_not_found: ret = wl1271_acx_set_ht_capabilities(wl, &sta_ht_cap, false, - wl->sta_hlid); + wlvif->sta.hlid); if (ret < 0) { wl1271_warning("Set ht cap false failed %d", ret); @@ -4080,7 +4081,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, } if (wlvif->bss_type == BSS_TYPE_STA_BSS) { - hlid = wl->sta_hlid; + hlid = wlvif->sta.hlid; ba_bitmap = &wl->ba_rx_bitmap; } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { struct wl1271_station *wl_sta; @@ -4888,7 +4889,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; - wl->sta_hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->session_counter = 0; wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 538d861..db55767 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -42,7 +42,7 @@ static int wl1271_set_default_wep_key(struct wl1271 *wl, ret = wl12xx_cmd_set_default_wep_key(wl, id, wl->ap_bcast_hlid); else - ret = wl12xx_cmd_set_default_wep_key(wl, id, wl->sta_hlid); + ret = wl12xx_cmd_set_default_wep_key(wl, id, wlvif->sta.hlid); if (ret < 0) return ret; @@ -199,7 +199,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && !ieee80211_is_auth(hdr->frame_control) && !ieee80211_is_assoc_req(hdr->frame_control)) - return wl->sta_hlid; + return wlvif->sta.hlid; else return wl->dev_hlid; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 4c69ae1..a1084d1 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -402,7 +402,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; u8 system_hlid; - u8 sta_hlid; u8 dev_hlid; u8 ap_global_hlid; u8 ap_bcast_hlid; @@ -624,6 +623,12 @@ struct wl12xx_vif { /* sta/ibss specific */ u8 dev_role_id; + union { + struct { + u8 hlid; + } sta; + }; + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v0.10.2 From a8ab39a4b588e8523be2fa75671bdc9612d3467a Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:54 +0200 Subject: wl12xx: move ap_global_hlid and ap_bcast_hlid into wlvif move ap_global_hlid and ap_bcast_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 2a9a4b2..d0124e6 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -671,19 +671,19 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - ret = wl12xx_allocate_link(wl, &wl->ap_global_hlid); + ret = wl12xx_allocate_link(wl, &wlvif->ap.global_hlid); if (ret < 0) goto out_free; - ret = wl12xx_allocate_link(wl, &wl->ap_bcast_hlid); + ret = wl12xx_allocate_link(wl, &wlvif->ap.bcast_hlid); if (ret < 0) goto out_free_global; cmd->role_id = wlvif->role_id; cmd->ap.aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period); cmd->ap.bss_index = WL1271_AP_BSS_INDEX; - cmd->ap.global_hlid = wl->ap_global_hlid; - cmd->ap.broadcast_hlid = wl->ap_bcast_hlid; + cmd->ap.global_hlid = wlvif->ap.global_hlid; + cmd->ap.broadcast_hlid = wlvif->ap.bcast_hlid; cmd->ap.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; @@ -725,10 +725,10 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; out_free_bcast: - wl12xx_free_link(wl, &wl->ap_bcast_hlid); + wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); out_free_global: - wl12xx_free_link(wl, &wl->ap_global_hlid); + wl12xx_free_link(wl, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -758,8 +758,8 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wl->ap_bcast_hlid); - wl12xx_free_link(wl, &wl->ap_global_hlid); + wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); + wl12xx_free_link(wl, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -1264,12 +1264,11 @@ out: return ret; } -int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_cmd_set_keys *cmd; int ret = 0; @@ -1334,9 +1333,10 @@ out: * TODO: merge with sta/ibss into 1 set_key function. * note there are slight diffs */ -int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, - u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, - u16 tx_seq_16) +int wl1271_cmd_set_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 action, u8 id, u8 key_type, + u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, + u16 tx_seq_16) { struct wl1271_cmd_set_keys *cmd; int ret = 0; @@ -1346,7 +1346,7 @@ int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, if (!cmd) return -ENOMEM; - if (hlid == wl->ap_bcast_hlid) { + if (hlid == wlvif->ap.bcast_hlid) { if (key_type == KEY_WEP) lid_type = WEP_DEFAULT_LID_TYPE; else diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 25ab400..9624828 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -70,11 +70,12 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); -int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16); -int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +int wl1271_cmd_set_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, u16 tx_seq_16); int wl12xx_cmd_set_peer_state(struct wl1271 *wl, u8 hlid); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3358cfe..731e34b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1488,8 +1488,9 @@ int wl1271_plt_stop(struct wl1271 *wl) static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct wl1271 *wl = hw->priv; - struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb); - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(control->control.vif); + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_vif *vif = info->control.vif; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q, mapping; u8 hlid = 0; @@ -1498,7 +1499,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) q = wl1271_tx_get_queue(mapping); if (wlvif->bss_type == BSS_TYPE_AP_BSS) - hlid = wl12xx_tx_get_hlid_ap(wl, skb); + hlid = wl12xx_tx_get_hlid_ap(wl, wlvif, skb); spin_lock_irqsave(&wl->wl_lock, flags); @@ -1858,7 +1859,12 @@ static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) wlvif->bss_type = MAX_BSS_TYPE; wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + + /* TODO: init union by type */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -2084,8 +2090,8 @@ deinit: /* clear all hlids (except system_hlid) */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; - wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; - wl->ap_global_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; /* * this must be before the cancel_work calls below, so that the work @@ -2653,7 +2659,7 @@ static void wl1271_free_ap_keys(struct wl1271 *wl) } } -static int wl1271_ap_init_hwenc(struct wl1271 *wl) +static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int i, ret = 0; struct wl1271_ap_key *key; @@ -2667,9 +2673,9 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl) key = wl->recorded_ap_keys[i]; hlid = key->hlid; if (hlid == WL12XX_INVALID_LINK_ID) - hlid = wl->ap_bcast_hlid; + hlid = wlvif->ap.bcast_hlid; - ret = wl1271_cmd_set_ap_key(wl, KEY_ADD_OR_REPLACE, + ret = wl1271_cmd_set_ap_key(wl, wlvif, KEY_ADD_OR_REPLACE, key->id, key->key_type, key->key_size, key->key, hlid, key->tx_seq_32, @@ -2683,7 +2689,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl) if (wep_key_added) { ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key, - wl->ap_bcast_hlid); + wlvif->ap.bcast_hlid); if (ret < 0) goto out; } @@ -2709,7 +2715,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl_sta = (struct wl1271_station *)sta->drv_priv; hlid = wl_sta->hlid; } else { - hlid = wl->ap_bcast_hlid; + hlid = wlvif->ap.bcast_hlid; } if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { @@ -2725,7 +2731,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, key, hlid, tx_seq_32, tx_seq_16); } else { - ret = wl1271_cmd_set_ap_key(wl, action, + ret = wl1271_cmd_set_ap_key(wl, wlvif, action, id, key_type, key_size, key, hlid, tx_seq_32, tx_seq_16); @@ -2769,7 +2775,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) return 0; - ret = wl1271_cmd_set_sta_key(wl, vif, action, + ret = wl1271_cmd_set_sta_key(wl, wlvif, action, id, key_type, key_size, key, addr, tx_seq_32, tx_seq_16); @@ -3375,7 +3381,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if (ret < 0) goto out; - ret = wl1271_ap_init_hwenc(wl); + ret = wl1271_ap_init_hwenc(wl, wlvif); if (ret < 0) goto out; @@ -4891,8 +4897,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->system_hlid = WL12XX_SYSTEM_HLID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->session_counter = 0; - wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; - wl->ap_global_hlid = WL12XX_INVALID_LINK_ID; wl->active_sta_count = 0; setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index db55767..53c6451 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -40,7 +40,7 @@ static int wl1271_set_default_wep_key(struct wl1271 *wl, if (is_ap) ret = wl12xx_cmd_set_default_wep_key(wl, id, - wl->ap_bcast_hlid); + wlvif->ap.bcast_hlid); else ret = wl12xx_cmd_set_default_wep_key(wl, id, wlvif->sta.hlid); @@ -156,7 +156,8 @@ bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb) return wl->dummy_packet == skb; } -u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb) +u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb) { struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb); @@ -174,9 +175,9 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb) hdr = (struct ieee80211_hdr *)skb->data; if (ieee80211_is_mgmt(hdr->frame_control)) - return wl->ap_global_hlid; + return wlvif->ap.global_hlid; else - return wl->ap_bcast_hlid; + return wlvif->ap.bcast_hlid; } } @@ -191,7 +192,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, return wl->system_hlid; if (wlvif->bss_type == BSS_TYPE_AP_BSS) - return wl12xx_tx_get_hlid_ap(wl, skb); + return wl12xx_tx_get_hlid_ap(wl, wlvif, skb); wl1271_tx_update_filters(wl, wlvif, skb); @@ -341,9 +342,9 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, else rate_idx = ACX_TX_BASIC_RATE; } else { - if (hlid == wl->ap_global_hlid) + if (hlid == wlvif->ap.global_hlid) rate_idx = ACX_TX_AP_MODE_MGMT_RATE; - else if (hlid == wl->ap_bcast_hlid) + else if (hlid == wlvif->ap.bcast_hlid) rate_idx = ACX_TX_AP_MODE_BCST_RATE; else rate_idx = ac; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index ba9403a..0964c93 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -212,7 +212,8 @@ u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band); u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set, enum ieee80211_band rate_band); u32 wl1271_tx_min_rate_get(struct wl1271 *wl, u32 rate_set); -u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb); +u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb); void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid); void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index a1084d1..aa84899 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -403,8 +403,6 @@ struct wl1271 { int channel; u8 system_hlid; u8 dev_hlid; - u8 ap_global_hlid; - u8 ap_bcast_hlid; unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; @@ -627,6 +625,10 @@ struct wl12xx_vif { struct { u8 hlid; } sta; + struct { + u8 global_hlid; + u8 bcast_hlid; + } ap; }; u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; -- cgit v0.10.2 From 98b8625301e55bd3e4340f704edc378e4707e577 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:55 +0200 Subject: wl12xx: move session_counter into wlvif move session_counter into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index d0124e6..89d263e 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -454,14 +454,15 @@ static void wl12xx_free_link(struct wl1271 *wl, u8 *hlid) *hlid = WL12XX_INVALID_LINK_ID; } -static int wl12xx_get_new_session_id(struct wl1271 *wl) +static int wl12xx_get_new_session_id(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { - if (wl->session_counter >= SESSION_COUNTER_MAX) - wl->session_counter = 0; + if (wlvif->session_counter >= SESSION_COUNTER_MAX) + wlvif->session_counter = 0; - wl->session_counter++; + wlvif->session_counter++; - return wl->session_counter; + return wlvif->session_counter; } int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -488,7 +489,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } cmd->device.hlid = wl->dev_hlid; - cmd->device.session = wl->session_counter; + cmd->device.session = wlvif->session_counter; wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d", cmd->role_id, cmd->device.hlid, cmd->device.session); @@ -587,7 +588,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } cmd->sta.hlid = wlvif->sta.hlid; - cmd->sta.session = wl12xx_get_new_session_id(wl); + cmd->sta.session = wl12xx_get_new_session_id(wl, wlvif); cmd->sta.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 3309fea..d8d8568 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -348,7 +348,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(tx_blocks_freed); DRIVER_STATE_PRINT_INT(tx_security_last_seq_lsb); DRIVER_STATE_PRINT_INT(rx_counter); - DRIVER_STATE_PRINT_INT(session_counter); DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 731e34b..63871b4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2128,7 +2128,6 @@ deinit: wl->tx_results_count = 0; wl->tx_packets_count = 0; wl->time_offset = 0; - wl->session_counter = 0; wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl->vif = NULL; @@ -4896,7 +4895,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; - wl->session_counter = 0; wl->active_sta_count = 0; setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 53c6451..da8427f 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -321,15 +321,15 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, * FW expects the dummy packet to have an invalid session id - * any session id that is different than the one set in the join */ - tx_attr = ((~wl->session_counter) << + tx_attr = (SESSION_COUNTER_INVALID << TX_HW_ATTR_OFST_SESSION_COUNTER) & TX_HW_ATTR_SESSION_COUNTER; tx_attr |= TX_HW_ATTR_TX_DUMMY_REQ; } else { /* configure the tx attributes */ - tx_attr = - wl->session_counter << TX_HW_ATTR_OFST_SESSION_COUNTER; + tx_attr = wlvif->session_counter << + TX_HW_ATTR_OFST_SESSION_COUNTER; } desc->hlid = hlid; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index aa84899..9fcaa03 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -429,9 +429,6 @@ struct wl1271 { /* Time-offset between host and chipset clocks */ s64 time_offset; - /* Session counter for the chipset */ - int session_counter; - /* Frames scheduled for transmission, not handled yet */ struct sk_buff_head tx_queue[NUM_TX_QUEUES]; int tx_queue_count[NUM_TX_QUEUES]; @@ -650,6 +647,9 @@ struct wl12xx_vif { /* Our association ID */ u16 aid; + + /* Session counter for the chipset */ + int session_counter; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) @@ -671,7 +671,8 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */ -#define SESSION_COUNTER_MAX 7 /* maximum value for the session counter */ +#define SESSION_COUNTER_MAX 6 /* maximum value for the session counter */ +#define SESSION_COUNTER_INVALID 7 /* used with dummy_packet */ #define WL1271_DEFAULT_POWER_LEVEL 0 -- cgit v0.10.2 From e936bbe0dc235458408c060deaa43f5b8b0bd705 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:56 +0200 Subject: wl12xx: move some logic into wl12xx_init_vif_data Initialize the vif data according to the vif type Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 63871b4..effba53 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1854,20 +1854,52 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) return WL12XX_INVALID_ROLE_TYPE; } -static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) +static int wl12xx_init_vif_data(struct ieee80211_vif *vif) { - wlvif->bss_type = MAX_BSS_TYPE; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + + /* make sure wlvif is zeroed */ + memset(wlvif, 0, sizeof(*wlvif)); + + switch (ieee80211_vif_type_p2p(vif)) { + case NL80211_IFTYPE_P2P_CLIENT: + wlvif->p2p = 1; + /* fall-through */ + case NL80211_IFTYPE_STATION: + wlvif->bss_type = BSS_TYPE_STA_BSS; + break; + case NL80211_IFTYPE_ADHOC: + wlvif->bss_type = BSS_TYPE_IBSS; + break; + case NL80211_IFTYPE_P2P_GO: + wlvif->p2p = 1; + /* fall-through */ + case NL80211_IFTYPE_AP: + wlvif->bss_type = BSS_TYPE_AP_BSS; + break; + default: + wlvif->bss_type = MAX_BSS_TYPE; + return -EOPNOTSUPP; + } + wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; - /* TODO: init union by type */ - wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + /* init sta/ibss data */ + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; + + } else { + /* init ap data */ + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + } wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; + return 0; } static int wl1271_op_add_interface(struct ieee80211_hw *hw, @@ -1891,7 +1923,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EBUSY; goto out; } - wl12xx_init_vif_data(wlvif); /* * in some very corner case HW recovery scenarios its possible to @@ -1903,26 +1934,9 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; } - switch (ieee80211_vif_type_p2p(vif)) { - case NL80211_IFTYPE_P2P_CLIENT: - wlvif->p2p = 1; - /* fall-through */ - case NL80211_IFTYPE_STATION: - wlvif->bss_type = BSS_TYPE_STA_BSS; - break; - case NL80211_IFTYPE_ADHOC: - wlvif->bss_type = BSS_TYPE_IBSS; - break; - case NL80211_IFTYPE_P2P_GO: - wlvif->p2p = 1; - /* fall-through */ - case NL80211_IFTYPE_AP: - wlvif->bss_type = BSS_TYPE_AP_BSS; - break; - default: - ret = -EOPNOTSUPP; + ret = wl12xx_init_vif_data(vif); + if (ret < 0) goto out; - } role_type = wl12xx_get_role_type(wl, wlvif); if (role_type == WL12XX_INVALID_ROLE_TYPE) { -- cgit v0.10.2 From afaf8bdb2b08bbf493b03757243821df72b26c53 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:57 +0200 Subject: wl12xx: move dev_hlid into wlvif move dev_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 89d263e..166d984 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -483,12 +483,12 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; - if (wl->dev_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wl->dev_hlid); + if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) { + ret = wl12xx_allocate_link(wl, &wlvif->dev_hlid); if (ret) goto out_free; } - cmd->device.hlid = wl->dev_hlid; + cmd->device.hlid = wlvif->dev_hlid; cmd->device.session = wlvif->session_counter; wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d", @@ -504,9 +504,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error */ - __clear_bit(wl->dev_hlid, wl->links_map); - wl->dev_hlid = WL12XX_INVALID_LINK_ID; - + wl12xx_free_link(wl, &wlvif->dev_hlid); out_free: kfree(cmd); @@ -520,7 +518,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) struct wl12xx_cmd_role_stop *cmd; int ret; - if (WARN_ON(wl->dev_hlid == WL12XX_INVALID_LINK_ID)) + if (WARN_ON(wlvif->dev_hlid == WL12XX_INVALID_LINK_ID)) return -EINVAL; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -547,7 +545,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wl->dev_hlid); + wl12xx_free_link(wl, &wlvif->dev_hlid); out_free: kfree(cmd); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index effba53..e8d73d7 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1884,6 +1884,7 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; if (wlvif->bss_type == BSS_TYPE_STA_BSS || wlvif->bss_type == BSS_TYPE_IBSS) { @@ -2103,7 +2104,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, deinit: /* clear all hlids (except system_hlid) */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; - wl->dev_hlid = WL12XX_INVALID_LINK_ID; + wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; @@ -4908,7 +4909,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; - wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->active_sta_count = 0; setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index da8427f..8db68c6 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -94,7 +94,7 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, if (!ieee80211_is_auth(hdr->frame_control)) return 0; - if (wl->dev_hlid != WL12XX_INVALID_LINK_ID) + if (wlvif->dev_hlid != WL12XX_INVALID_LINK_ID) goto out; wl1271_debug(DEBUG_CMD, "starting device role for roaming"); @@ -202,7 +202,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, !ieee80211_is_assoc_req(hdr->frame_control)) return wlvif->sta.hlid; else - return wl->dev_hlid; + return wlvif->dev_hlid; } static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9fcaa03..752b6b9 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -402,7 +402,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; u8 system_hlid; - u8 dev_hlid; unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; @@ -617,6 +616,7 @@ struct wl12xx_vif { /* sta/ibss specific */ u8 dev_role_id; + u8 dev_hlid; union { struct { -- cgit v0.10.2 From 6a8997964366f51c39d8efcfdc0e6319b2bd01fa Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:58 +0200 Subject: wl12xx: move beacon_int into wlvif move beacon_int into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 166d984..68375ff 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -573,7 +573,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); - cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int); + cmd->sta.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->sta.ssid_len = wlvif->ssid_len; memcpy(cmd->sta.ssid, wlvif->ssid, wlvif->ssid_len); @@ -684,7 +684,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ap.global_hlid = wlvif->ap.global_hlid; cmd->ap.broadcast_hlid = wlvif->ap.bcast_hlid; cmd->ap.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); - cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); + cmd->ap.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP; cmd->channel = wl->channel; @@ -787,7 +787,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); - cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int); + cmd->ibss.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->ibss.ssid_len = wlvif->ssid_len; diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index d8d8568..439db1f 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -351,7 +351,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); - DRIVER_STATE_PRINT_INT(beacon_int); DRIVER_STATE_PRINT_INT(psm_entry_retry); DRIVER_STATE_PRINT_INT(ps_poll_failures); DRIVER_STATE_PRINT_INT(power_level); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index e8d73d7..577266d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1900,6 +1900,8 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; + wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + return 0; } @@ -3286,7 +3288,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, wl1271_debug(DEBUG_MASTER, "beacon interval updated: %d", bss_conf->beacon_int); - wl->beacon_int = bss_conf->beacon_int; + wlvif->beacon_int = bss_conf->beacon_int; } if ((changed & BSS_CHANGED_BEACON)) { @@ -4889,7 +4891,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) } wl->channel = WL1271_DEFAULT_CHANNEL; - wl->beacon_int = WL1271_DEFAULT_BEACON_INT; wl->default_key = 0; wl->rx_counter = 0; wl->psm_entry_retry = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 752b6b9..9d4b72e 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -503,9 +503,6 @@ struct wl1271 { /* The current band */ enum ieee80211_band band; - /* Beaconing interval (needed for ad-hoc) */ - u32 beacon_int; - /* Default key (for WEP) */ u32 default_key; @@ -645,6 +642,9 @@ struct wl12xx_vif { /* probe-req template for the current AP */ struct sk_buff *probereq; + /* Beaconing interval (needed for ad-hoc) */ + u32 beacon_int; + /* Our association ID */ u16 aid; -- cgit v0.10.2 From f75c753f3c77b758fa5ace90c15b2ea3b7a3d46d Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:59 +0200 Subject: wl12xx: move default_key into wlvif move default_key into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 577266d..09983de 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2704,7 +2704,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) } if (wep_key_added) { - ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key, + ret = wl12xx_cmd_set_default_wep_key(wl, wlvif->default_key, wlvif->ap.bcast_hlid); if (ret < 0) goto out; @@ -2801,8 +2801,8 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, /* the default WEP key needs to be configured at least once */ if (key_type == KEY_WEP) { ret = wl12xx_cmd_set_default_wep_key(wl, - wl->default_key, - wlvif->sta.hlid); + wlvif->default_key, + wlvif->sta.hlid); if (ret < 0) return ret; } @@ -4891,7 +4891,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) } wl->channel = WL1271_DEFAULT_CHANNEL; - wl->default_key = 0; wl->rx_counter = 0; wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8db68c6..509ae10 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -424,11 +424,11 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, is_wep = (cipher == WLAN_CIPHER_SUITE_WEP40) || (cipher == WLAN_CIPHER_SUITE_WEP104); - if (unlikely(is_wep && wl->default_key != idx)) { + if (unlikely(is_wep && wlvif->default_key != idx)) { ret = wl1271_set_default_wep_key(wl, wlvif, idx); if (ret < 0) return ret; - wl->default_key = idx; + wlvif->default_key = idx; } } hlid = wl1271_tx_get_hlid(wl, vif, skb); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9d4b72e..91e6cd3 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -503,9 +503,6 @@ struct wl1271 { /* The current band */ enum ieee80211_band band; - /* Default key (for WEP) */ - u32 default_key; - /* Rx Streaming */ struct work_struct rx_streaming_enable_work; struct work_struct rx_streaming_disable_work; @@ -645,6 +642,9 @@ struct wl12xx_vif { /* Beaconing interval (needed for ad-hoc) */ u32 beacon_int; + /* Default key (for WEP) */ + u32 default_key; + /* Our association ID */ u16 aid; -- cgit v0.10.2 From 252efa4f978a2901039fffc934060fb8ccf82ac7 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:00 +0200 Subject: wl12xx: move pspoll_work into wlvif move pspoll_work into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 28a4396..4e3474c1 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -38,9 +38,9 @@ void wl1271_pspoll_work(struct work_struct *work) int ret; dwork = container_of(work, struct delayed_work, work); - wl = container_of(dwork, struct wl1271, pspoll_work); - vif = wl->vif; /* TODO: move work into vif struct */ - wlvif = wl12xx_vif_to_data(vif); + wlvif = container_of(dwork, struct wl12xx_vif, pspoll_work); + vif = container_of((void *)wlvif, struct ieee80211_vif, drv_priv); + wl = wlvif->wl; wl1271_debug(DEBUG_EVENT, "pspoll work"); @@ -90,7 +90,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, if (ret < 0) return; set_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); - ieee80211_queue_delayed_work(wl->hw, &wl->pspoll_work, + ieee80211_queue_delayed_work(wl->hw, &wlvif->pspoll_work, msecs_to_jiffies(delay)); } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 09983de..76f4663 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1766,7 +1766,7 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, wl1271_enable_interrupts(wl); flush_work(&wl->tx_work); - flush_delayed_work(&wl->pspoll_work); + flush_delayed_work(&wlvif->pspoll_work); flush_delayed_work(&wl->elp_work); return 0; @@ -1902,6 +1902,8 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + INIT_DELAYED_WORK(&wlvif->pspoll_work, wl1271_pspoll_work); + return 0; } @@ -1941,6 +1943,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto out; + wlvif->wl = wl; role_type = wl12xx_get_role_type(wl, wlvif); if (role_type == WL12XX_INVALID_ROLE_TYPE) { ret = -EINVAL; @@ -2126,7 +2129,7 @@ deinit: del_timer_sync(&wl->rx_streaming_timer); cancel_work_sync(&wl->rx_streaming_enable_work); cancel_work_sync(&wl->rx_streaming_disable_work); - cancel_delayed_work_sync(&wl->pspoll_work); + cancel_delayed_work_sync(&wlvif->pspoll_work); cancel_delayed_work_sync(&wl->elp_work); mutex_lock(&wl->mutex); @@ -4874,7 +4877,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) skb_queue_head_init(&wl->deferred_tx_queue); INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work); - INIT_DELAYED_WORK(&wl->pspoll_work, wl1271_pspoll_work); INIT_WORK(&wl->netstack_work, wl1271_netstack_work); INIT_WORK(&wl->tx_work, wl1271_tx_work); INIT_WORK(&wl->recovery_work, wl1271_recovery_work); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 91e6cd3..d6d5a7b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -511,7 +511,6 @@ struct wl1271 { struct completion *elp_compl; struct completion *ps_compl; struct delayed_work elp_work; - struct delayed_work pspoll_work; /* counter for ps-poll delivery failures */ int ps_poll_failures; @@ -604,6 +603,7 @@ struct wl1271_station { }; struct wl12xx_vif { + struct wl1271 *wl; u8 bss_type; u8 p2p; /* we are using p2p role */ u8 role_id; @@ -650,6 +650,8 @@ struct wl12xx_vif { /* Session counter for the chipset */ int session_counter; + + struct delayed_work pspoll_work; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From 6ec45dc282f6983d5685758c5e8993bc2c818d3c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:01 +0200 Subject: wl12xx: move ps_compl into wlvif move ps_compl into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 4e3474c1..7a9913a 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -149,9 +149,9 @@ static int wl1271_event_ps_report(struct wl1271 *wl, /* enable beacon early termination */ ret = wl1271_acx_bet_enable(wl, wlvif, true); - if (wl->ps_compl) { - complete(wl->ps_compl); - wl->ps_compl = NULL; + if (wlvif->ps_compl) { + complete(wlvif->ps_compl); + wlvif->ps_compl = NULL; } break; default: diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 76f4663..cb23553 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1636,7 +1636,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { DECLARE_COMPLETION_ONSTACK(compl); - wl->ps_compl = &compl; + wlvif->ps_compl = &compl; ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); if (ret < 0) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d6d5a7b..7166a79 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -509,7 +509,6 @@ struct wl1271 { struct timer_list rx_streaming_timer; struct completion *elp_compl; - struct completion *ps_compl; struct delayed_work elp_work; /* counter for ps-poll delivery failures */ @@ -651,6 +650,7 @@ struct wl12xx_vif { /* Session counter for the chipset */ int session_counter; + struct completion *ps_compl; struct delayed_work pspoll_work; }; -- cgit v0.10.2 From 74ec839557878007c3f97d1bc89e09fde5d0f3fa Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:02 +0200 Subject: wl12xx: move ps_poll_failures and psm_entry_retry into wlvif move ps_poll_failures and psm_entry_retries into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 439db1f..cd390e0 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -351,8 +351,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); - DRIVER_STATE_PRINT_INT(psm_entry_retry); - DRIVER_STATE_PRINT_INT(ps_poll_failures); DRIVER_STATE_PRINT_INT(power_level); DRIVER_STATE_PRINT_INT(rssi_thold); DRIVER_STATE_PRINT_INT(last_rssi_event); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 7a9913a..6c48b8c 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -78,8 +78,8 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, int delay = wl->conf.conn.ps_poll_recovery_period; int ret; - wl->ps_poll_failures++; - if (wl->ps_poll_failures == 1) + wlvif->ps_poll_failures++; + if (wlvif->ps_poll_failures == 1) wl1271_info("AP with dysfunctional ps-poll, " "trying to work around it."); @@ -118,23 +118,23 @@ static int wl1271_event_ps_report(struct wl1271 *wl, if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { /* remain in active mode */ - wl->psm_entry_retry = 0; + wlvif->psm_entry_retry = 0; break; } - if (wl->psm_entry_retry < total_retries) { - wl->psm_entry_retry++; + if (wlvif->psm_entry_retry < total_retries) { + wlvif->psm_entry_retry++; ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); } else { wl1271_info("No ack to nullfunc from AP."); - wl->psm_entry_retry = 0; + wlvif->psm_entry_retry = 0; *beacon_loss = true; } break; case EVENT_ENTER_POWER_SAVE_SUCCESS: - wl->psm_entry_retry = 0; + wlvif->psm_entry_retry = 0; /* enable beacon filtering */ ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index cb23553..fd2b9f2 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2141,7 +2141,6 @@ deinit: wl->band = IEEE80211_BAND_2GHZ; wl->rx_counter = 0; - wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; wl->tx_blocks_available = 0; wl->tx_allocated_blocks = 0; @@ -3540,7 +3539,7 @@ sta_not_found: wlvif->aid = bss_conf->aid; set_assoc = true; - wl->ps_poll_failures = 0; + wlvif->ps_poll_failures = 0; /* * use basic rates from AP, and determine lowest rate @@ -4894,7 +4893,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->channel = WL1271_DEFAULT_CHANNEL; wl->rx_counter = 0; - wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; wl->band = IEEE80211_BAND_2GHZ; wl->vif = NULL; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 7166a79..9d9d3fb 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -511,12 +511,6 @@ struct wl1271 { struct completion *elp_compl; struct delayed_work elp_work; - /* counter for ps-poll delivery failures */ - int ps_poll_failures; - - /* retry counter for PSM entries */ - u8 psm_entry_retry; - /* in dBm */ int power_level; @@ -652,6 +646,12 @@ struct wl12xx_vif { struct completion *ps_compl; struct delayed_work pspoll_work; + + /* counter for ps-poll delivery failures */ + int ps_poll_failures; + + /* retry counter for PSM entries */ + u8 psm_entry_retry; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From 04324d99818d16da4f64e266b45cad2e5803b961 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:03 +0200 Subject: wl12xx: move rssi_thold and last_rssi_event into wlvif move rssi_thold and last_rssi_event into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 9b4eef6..5b70cc1 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -1274,7 +1274,7 @@ int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, goto out; } - wl->last_rssi_event = -1; + wlvif->last_rssi_event = -1; acx->role_id = wlvif->role_id; acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index cd390e0..e53f9683 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -352,8 +352,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(power_level); - DRIVER_STATE_PRINT_INT(rssi_thold); - DRIVER_STATE_PRINT_INT(last_rssi_event); DRIVER_STATE_PRINT_INT(sg_enabled); DRIVER_STATE_PRINT_INT(enable_11a); DRIVER_STATE_PRINT_INT(noise); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 6c48b8c..775ad95 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -162,21 +162,23 @@ static int wl1271_event_ps_report(struct wl1271 *wl, } static void wl1271_event_rssi_trigger(struct wl1271 *wl, + struct ieee80211_vif *vif, struct event_mailbox *mbox) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); enum nl80211_cqm_rssi_threshold_event event; s8 metric = mbox->rssi_snr_trigger_metric[0]; wl1271_debug(DEBUG_EVENT, "RSSI trigger metric: %d", metric); - if (metric <= wl->rssi_thold) + if (metric <= wlvif->rssi_thold) event = NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW; else event = NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH; - if (event != wl->last_rssi_event) - ieee80211_cqm_rssi_notify(wl->vif, event, GFP_KERNEL); - wl->last_rssi_event = event; + if (event != wlvif->last_rssi_event) + ieee80211_cqm_rssi_notify(vif, event, GFP_KERNEL); + wlvif->last_rssi_event = event; } static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -297,7 +299,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "RSSI_SNR_TRIGGER_0_EVENT"); if (wl->vif) - wl1271_event_rssi_trigger(wl, mbox); + wl1271_event_rssi_trigger(wl, vif, mbox); } if ((vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID)) { diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index fd2b9f2..72ab256 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3497,7 +3497,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, bss_conf->cqm_rssi_hyst); if (ret < 0) goto out; - wl->rssi_thold = bss_conf->cqm_rssi_thold; + wlvif->rssi_thold = bss_conf->cqm_rssi_thold; } if (changed & BSS_CHANGED_BSSID) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9d9d3fb..5a82450 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -514,9 +514,6 @@ struct wl1271 { /* in dBm */ int power_level; - int rssi_thold; - int last_rssi_event; - struct wl1271_stats stats; __le32 buffer_32; @@ -652,6 +649,9 @@ struct wl12xx_vif { /* retry counter for PSM entries */ u8 psm_entry_retry; + + int rssi_thold; + int last_rssi_event; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From d0802abdf9c60b1dadb097e806022f3449b0cc6b Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:04 +0200 Subject: wl12xx: move ba fields into wlvif move ba_fields into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index e53f9683..ee42a43 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -357,8 +357,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(noise); DRIVER_STATE_PRINT_LHEX(ap_hlid_map[0]); DRIVER_STATE_PRINT_INT(last_tx_hlid); - DRIVER_STATE_PRINT_INT(ba_support); - DRIVER_STATE_PRINT_HEX(ba_rx_bitmap); DRIVER_STATE_PRINT_HEX(ap_fw_ps_map); DRIVER_STATE_PRINT_LHEX(ap_ps_map); DRIVER_STATE_PRINT_HEX(quirks); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 775ad95..8c31274 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -184,9 +184,9 @@ static void wl1271_event_rssi_trigger(struct wl1271 *wl, static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) { if (wlvif->bss_type != BSS_TYPE_AP_BSS) { - if (!wl->ba_rx_bitmap) + if (!wlvif->sta.ba_rx_bitmap) return; - ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, + ieee80211_stop_rx_ba_session(wl->vif, wlvif->sta.ba_rx_bitmap, wl->vif->bss_conf.bssid); } else { int i; @@ -306,9 +306,9 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) wl1271_debug(DEBUG_EVENT, "BA_SESSION_RX_CONSTRAINT_EVENT_ID. " "ba_allowed = 0x%x", mbox->rx_ba_allowed); - wl->ba_allowed = !!mbox->rx_ba_allowed; + wlvif->ba_allowed = !!mbox->rx_ba_allowed; - if (wl->vif && !wl->ba_allowed) + if (wl->vif && !wlvif->ba_allowed) wl1271_stop_ba_event(wl, wlvif); } diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 1eaa0a3..80e89e3 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -486,18 +486,17 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) { /* Reset the BA RX indicators */ - wl->ba_rx_bitmap = 0; - wl->ba_allowed = true; + wlvif->ba_allowed = true; wl->ba_rx_session_count = 0; /* BA is supported in STA/AP modes */ if (wlvif->bss_type != BSS_TYPE_AP_BSS && wlvif->bss_type != BSS_TYPE_STA_BSS) { - wl->ba_support = false; + wlvif->ba_support = false; return 0; } - wl->ba_support = true; + wlvif->ba_support = true; /* 802.11n initiator BA session setting */ return wl12xx_acx_set_ba_initiator_policy(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 72ab256..984dae8 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4106,7 +4106,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, if (wlvif->bss_type == BSS_TYPE_STA_BSS) { hlid = wlvif->sta.hlid; - ba_bitmap = &wl->ba_rx_bitmap; + ba_bitmap = &wlvif->sta.ba_rx_bitmap; } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { struct wl1271_station *wl_sta; @@ -4127,7 +4127,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, switch (action) { case IEEE80211_AMPDU_RX_START: - if (!wl->ba_support || !wl->ba_allowed) { + if (!wlvif->ba_support || !wlvif->ba_allowed) { ret = -ENOTSUPP; break; } diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 509ae10..6ce6163 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -941,7 +941,7 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) } } - wl->ba_rx_bitmap = 0; + wlvif->sta.ba_rx_bitmap = 0; } for (i = 0; i < NUM_TX_QUEUES; i++) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 5a82450..fcc7791 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -546,11 +546,6 @@ struct wl1271 { /* bands supported by this instance of wl12xx */ struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; - /* RX BA constraint value */ - bool ba_support; - u8 ba_rx_bitmap; - bool ba_allowed; - int tcxo_clock; /* @@ -605,6 +600,7 @@ struct wl12xx_vif { union { struct { u8 hlid; + u8 ba_rx_bitmap; } sta; struct { u8 global_hlid; @@ -652,6 +648,10 @@ struct wl12xx_vif { int rssi_thold; int last_rssi_event; + + /* RX BA constraint value */ + bool ba_support; + bool ba_allowed; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From c7ffb902cca655e4d6bdda4156407008573bb214 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:05 +0200 Subject: wl12xx: move ap_hlid_map into wlvif.ap Add wlvif->links_map bitmap to represent all the links allocated for this vif. AP vif also has a sta_hlid_map bitmap, which represents the links stations connected to it (sta_hlid_bitmap is a subset of wlvif->links_map, which itself is a subset of the global wl->links_map) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 68375ff..102a8a5 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -434,23 +434,25 @@ out: return ret; } -static int wl12xx_allocate_link(struct wl1271 *wl, u8 *hlid) +int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) { u8 link = find_first_zero_bit(wl->links_map, WL12XX_MAX_LINKS); if (link >= WL12XX_MAX_LINKS) return -EBUSY; __set_bit(link, wl->links_map); + __set_bit(link, wlvif->links_map); *hlid = link; return 0; } -static void wl12xx_free_link(struct wl1271 *wl, u8 *hlid) +void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) { if (*hlid == WL12XX_INVALID_LINK_ID) return; __clear_bit(*hlid, wl->links_map); + __clear_bit(*hlid, wlvif->links_map); *hlid = WL12XX_INVALID_LINK_ID; } @@ -484,7 +486,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->channel = wl->channel; if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wlvif->dev_hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->dev_hlid); if (ret) goto out_free; } @@ -504,7 +506,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error */ - wl12xx_free_link(wl, &wlvif->dev_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->dev_hlid); out_free: kfree(cmd); @@ -545,7 +547,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wlvif->dev_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->dev_hlid); out_free: kfree(cmd); @@ -581,7 +583,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->sta.hlid); if (ret) goto out_free; } @@ -604,7 +606,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wlvif->sta.hlid); + wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -640,7 +642,7 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wlvif->sta.hlid); + wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -670,11 +672,11 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - ret = wl12xx_allocate_link(wl, &wlvif->ap.global_hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->ap.global_hlid); if (ret < 0) goto out_free; - ret = wl12xx_allocate_link(wl, &wlvif->ap.bcast_hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->ap.bcast_hlid); if (ret < 0) goto out_free_global; @@ -724,10 +726,10 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; out_free_bcast: - wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.bcast_hlid); out_free_global: - wl12xx_free_link(wl, &wlvif->ap.global_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -757,8 +759,8 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); - wl12xx_free_link(wl, &wlvif->ap.global_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.bcast_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -796,7 +798,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->sta.hlid); if (ret) goto out_free; } @@ -821,7 +823,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wlvif->sta.hlid); + wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); out_free: kfree(cmd); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 9624828..d2670d3 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -89,6 +89,9 @@ int wl12xx_cmd_stop_fwlog(struct wl1271 *wl); int wl12xx_cmd_channel_switch(struct wl1271 *wl, struct ieee80211_channel_switch *ch_switch); int wl12xx_cmd_stop_channel_switch(struct wl1271 *wl); +int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 *hlid); +void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid); enum wl1271_commands { CMD_INTERROGATE = 1, /*use this to read information elements*/ diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index ee42a43..f0398d0 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -355,7 +355,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(sg_enabled); DRIVER_STATE_PRINT_INT(enable_11a); DRIVER_STATE_PRINT_INT(noise); - DRIVER_STATE_PRINT_LHEX(ap_hlid_map[0]); DRIVER_STATE_PRINT_INT(last_tx_hlid); DRIVER_STATE_PRINT_HEX(ap_fw_ps_map); DRIVER_STATE_PRINT_LHEX(ap_ps_map); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 8c31274..486c8ee 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -189,11 +189,12 @@ static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) ieee80211_stop_rx_ba_session(wl->vif, wlvif->sta.ba_rx_bitmap, wl->vif->bss_conf.bssid); } else { - int i; + u8 hlid; struct wl1271_link *lnk; - for (i = WL1271_AP_STA_HLID_START; i < AP_MAX_LINKS; i++) { - lnk = &wl->links[i]; - if (!wl1271_is_active_sta(wl, i) || !lnk->ba_bitmap) + for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, + WL12XX_MAX_LINKS) { + lnk = &wl->links[hlid]; + if (!lnk->ba_bitmap) continue; ieee80211_stop_rx_ba_session(wl->vif, @@ -355,10 +356,8 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) const u8 *addr; int h; - for (h = find_first_bit(&sta_bitmap, AP_MAX_LINKS); - h < AP_MAX_LINKS; - h = find_next_bit(&sta_bitmap, AP_MAX_LINKS, h+1)) { - if (!wl1271_is_active_sta(wl, h)) + for_each_set_bit(h, &sta_bitmap, WL12XX_MAX_LINKS) { + if (!test_bit(h, wlvif->ap.sta_hlid_map)) continue; addr = wl->links[h].addr; diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/event.h index 49c1a0e..1d878ba 100644 --- a/drivers/net/wireless/wl12xx/event.h +++ b/drivers/net/wireless/wl12xx/event.h @@ -132,7 +132,4 @@ void wl1271_event_mbox_config(struct wl1271 *wl); int wl1271_event_handle(struct wl1271 *wl, u8 mbox); void wl1271_pspoll_work(struct work_struct *work); -/* Functions from main.c */ -bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid); - #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 984dae8..f712f0f 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -778,10 +778,6 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) { bool fw_ps, single_sta; - /* only regulate station links */ - if (hlid < WL1271_AP_STA_HLID_START) - return; - fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); single_sta = (wl->active_sta_count == 1); @@ -801,21 +797,11 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) wl1271_ps_link_start(wl, hlid, true); } -bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid) -{ - int id; - - /* global/broadcast "stations" are always active */ - if (hlid < WL1271_AP_STA_HLID_START) - return true; - - id = hlid - WL1271_AP_STA_HLID_START; - return test_bit(id, wl->ap_hlid_map); -} - static void wl12xx_irq_update_links_status(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct wl12xx_fw_status *status) { + struct wl1271_link *lnk; u32 cur_fw_ps_map; u8 hlid, cnt; @@ -831,19 +817,14 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, wl->ap_fw_ps_map = cur_fw_ps_map; } - for (hlid = WL1271_AP_STA_HLID_START; hlid < AP_MAX_LINKS; hlid++) { - if (!wl1271_is_active_sta(wl, hlid)) - continue; - - cnt = status->tx_lnk_free_pkts[hlid] - - wl->links[hlid].prev_freed_pkts; + for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, WL12XX_MAX_LINKS) { + lnk = &wl->links[hlid]; + cnt = status->tx_lnk_free_pkts[hlid] - lnk->prev_freed_pkts; - wl->links[hlid].prev_freed_pkts = - status->tx_lnk_free_pkts[hlid]; - wl->links[hlid].allocated_pkts -= cnt; + lnk->prev_freed_pkts = status->tx_lnk_free_pkts[hlid]; + lnk->allocated_pkts -= cnt; - wl12xx_irq_ps_regulate_link(wl, hlid, - wl->links[hlid].allocated_pkts); + wl12xx_irq_ps_regulate_link(wl, hlid, lnk->allocated_pkts); } } @@ -907,7 +888,7 @@ static void wl12xx_fw_status(struct wl1271 *wl, /* for AP update num of allocated TX blocks per link and ps status */ if (wlvif->bss_type == BSS_TYPE_AP_BSS) - wl12xx_irq_update_links_status(wl, status); + wl12xx_irq_update_links_status(wl, wlvif, status); /* update the host-chipset time offset */ getnstimeofday(&ts); @@ -1505,7 +1486,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) /* queue the packet */ if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - if (!wl1271_is_active_sta(wl, hlid)) { + if (!test_bit(hlid, wlvif->links_map)) { wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); dev_kfree_skb(skb); @@ -2152,7 +2133,7 @@ deinit: wl->vif = NULL; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl1271_free_ap_keys(wl); - memset(wl->ap_hlid_map, 0, sizeof(wl->ap_hlid_map)); + memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; wl->sched_scanning = false; @@ -3946,43 +3927,44 @@ static int wl1271_op_get_survey(struct ieee80211_hw *hw, int idx, } static int wl1271_allocate_sta(struct wl1271 *wl, - struct ieee80211_sta *sta, - u8 *hlid) + struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta) { struct wl1271_station *wl_sta; - int id; + int ret; - id = find_first_zero_bit(wl->ap_hlid_map, AP_MAX_STATIONS); - if (id >= AP_MAX_STATIONS) { + + if (wl->active_sta_count >= AP_MAX_STATIONS) { wl1271_warning("could not allocate HLID - too much stations"); return -EBUSY; } wl_sta = (struct wl1271_station *)sta->drv_priv; - set_bit(id, wl->ap_hlid_map); - wl_sta->hlid = WL1271_AP_STA_HLID_START + id; - *hlid = wl_sta->hlid; + ret = wl12xx_allocate_link(wl, wlvif, &wl_sta->hlid); + if (ret < 0) { + wl1271_warning("could not allocate HLID - too many links"); + return -EBUSY; + } + + set_bit(wl_sta->hlid, wlvif->ap.sta_hlid_map); memcpy(wl->links[wl_sta->hlid].addr, sta->addr, ETH_ALEN); wl->active_sta_count++; return 0; } -void wl1271_free_sta(struct wl1271 *wl, u8 hlid) +/* TODO: change wl1271_tx_reset(), so we can get sta as param */ +void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) { - int id = hlid - WL1271_AP_STA_HLID_START; - - if (hlid < WL1271_AP_STA_HLID_START) + if (!test_bit(hlid, wlvif->ap.sta_hlid_map)) return; - if (!test_bit(id, wl->ap_hlid_map)) - return; - - clear_bit(id, wl->ap_hlid_map); + clear_bit(hlid, wlvif->ap.sta_hlid_map); memset(wl->links[hlid].addr, 0, ETH_ALEN); wl->links[hlid].ba_bitmap = 0; wl1271_tx_reset_link_queues(wl, hlid); __clear_bit(hlid, &wl->ap_ps_map); __clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); + wl12xx_free_link(wl, wlvif, &hlid); wl->active_sta_count--; } @@ -3992,6 +3974,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, { struct wl1271 *wl = hw->priv; struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl1271_station *wl_sta; int ret = 0; u8 hlid; @@ -4005,10 +3988,13 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid); - ret = wl1271_allocate_sta(wl, sta, &hlid); + ret = wl1271_allocate_sta(wl, wlvif, sta); if (ret < 0) goto out; + wl_sta = (struct wl1271_station *)sta->drv_priv; + hlid = wl_sta->hlid; + ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out_free_sta; @@ -4030,7 +4016,7 @@ out_sleep: out_free_sta: if (ret < 0) - wl1271_free_sta(wl, hlid); + wl1271_free_sta(wl, wlvif, hlid); out: mutex_unlock(&wl->mutex); @@ -4057,8 +4043,8 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); wl_sta = (struct wl1271_station *)sta->drv_priv; - id = wl_sta->hlid - WL1271_AP_STA_HLID_START; - if (WARN_ON(!test_bit(id, wl->ap_hlid_map))) + id = wl_sta->hlid; + if (WARN_ON(!test_bit(id, wlvif->ap.sta_hlid_map))) goto out; ret = wl1271_ps_elp_wakeup(wl); @@ -4069,7 +4055,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, if (ret < 0) goto out_sleep; - wl1271_free_sta(wl, wl_sta->hlid); + wl1271_free_sta(wl, wlvif, wl_sta->hlid); out_sleep: wl1271_ps_elp_sleep(wl); @@ -4841,7 +4827,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) int i, j, ret; unsigned int order; - BUILD_BUG_ON(AP_MAX_LINKS > WL12XX_MAX_LINKS); + BUILD_BUG_ON(AP_MAX_STATIONS > WL12XX_MAX_LINKS); hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops); if (!hw) { @@ -4869,7 +4855,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) skb_queue_head_init(&wl->tx_queue[i]); for (i = 0; i < NUM_TX_QUEUES; i++) - for (j = 0; j < AP_MAX_LINKS; j++) + for (j = 0; j < WL12XX_MAX_LINKS; j++) skb_queue_head_init(&wl->links[j].tx_queue[i]); skb_queue_head_init(&wl->deferred_rx_queue); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 6ce6163..1b3d8e3 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -125,18 +125,16 @@ static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl, wl1271_acx_set_inconnection_sta(wl, hdr->addr1); } -static void wl1271_tx_regulate_link(struct wl1271 *wl, u8 hlid) +static void wl1271_tx_regulate_link(struct wl1271 *wl, + struct wl12xx_vif *wlvif, + u8 hlid) { bool fw_ps, single_sta; u8 tx_pkts; - /* only regulate station links */ - if (hlid < WL1271_AP_STA_HLID_START) + if (WARN_ON(!test_bit(hlid, wlvif->links_map))) return; - if (WARN_ON(!wl1271_is_active_sta(wl, hlid))) - return; - fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); tx_pkts = wl->links[hlid].allocated_pkts; single_sta = (wl->active_sta_count == 1); @@ -266,7 +264,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, wl->tx_allocated_pkts[ac]++; if (wlvif->bss_type == BSS_TYPE_AP_BSS && - hlid >= WL1271_AP_STA_HLID_START) + test_bit(hlid, wlvif->ap.sta_hlid_map)) wl->links[hlid].allocated_pkts++; ret = 0; @@ -445,7 +443,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, if (wlvif->bss_type == BSS_TYPE_AP_BSS && !is_dummy) { wl1271_tx_ap_update_inconnection_sta(wl, skb); - wl1271_tx_regulate_link(wl, hlid); + wl1271_tx_regulate_link(wl, wlvif, hlid); } /* @@ -563,7 +561,8 @@ out: return skb; } -static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl) +static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct sk_buff *skb = NULL; unsigned long flags; @@ -571,15 +570,14 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl) struct sk_buff_head *queue; /* start from the link after the last one */ - start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS; + start_hlid = (wl->last_tx_hlid + 1) % WL12XX_MAX_LINKS; /* dequeue according to AC, round robin on each link */ - for (i = 0; i < AP_MAX_LINKS; i++) { - h = (start_hlid + i) % AP_MAX_LINKS; + for (i = 0; i < WL12XX_MAX_LINKS; i++) { + h = (start_hlid + i) % WL12XX_MAX_LINKS; /* only consider connected stations */ - if (h >= WL1271_AP_STA_HLID_START && - !test_bit(h - WL1271_AP_STA_HLID_START, wl->ap_hlid_map)) + if (!test_bit(h, wlvif->links_map)) continue; queue = wl1271_select_queue(wl, wl->links[h].tx_queue); @@ -611,7 +609,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, struct sk_buff *skb = NULL; if (wlvif->bss_type == BSS_TYPE_AP_BSS) - skb = wl1271_ap_skb_dequeue(wl); + skb = wl1271_ap_skb_dequeue(wl, wlvif); else skb = wl1271_sta_skb_dequeue(wl); @@ -643,7 +641,8 @@ static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ - wl->last_tx_hlid = (hlid + AP_MAX_LINKS - 1) % AP_MAX_LINKS; + wl->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % + WL12XX_MAX_LINKS; } else { skb_queue_head(&wl->tx_queue[q], skb); } @@ -918,8 +917,8 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) /* TX failure */ if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - for (i = 0; i < AP_MAX_LINKS; i++) { - wl1271_free_sta(wl, i); + for (i = 0; i < WL12XX_MAX_LINKS; i++) { + wl1271_free_sta(wl, wlvif, i); wl1271_tx_reset_link_queues(wl, i); wl->links[i].allocated_pkts = 0; wl->links[i].prev_freed_pkts = 0; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index 0964c93..add4402 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -219,6 +219,6 @@ void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); /* from main.c */ -void wl1271_free_sta(struct wl1271 *wl, u8 hlid); +void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid); #endif diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index fcc7791..5fd3c26 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -146,12 +146,6 @@ extern u32 wl12xx_debug_level; #define WL12XX_SYSTEM_HLID 0 /* - * TODO: we currently don't support multirole. remove - * this constant from the code when we do. - */ -#define WL1271_AP_STA_HLID_START 3 - -/* * When in AP-mode, we allow (at least) this number of packets * to be transmitted to FW for a STA in PS-mode. Only when packets are * present in the FW buffers it will wake the sleeping STA. We want to put @@ -236,13 +230,6 @@ struct wl1271_stats { #define AP_MAX_STATIONS 8 -/* Broadcast and Global links + system link + links to stations */ -/* - * TODO: when WL1271_AP_STA_HLID_START is no longer constant, change all - * the places that use this. - */ -#define AP_MAX_LINKS (AP_MAX_STATIONS + WL1271_AP_STA_HLID_START) - /* FW status registers */ struct wl12xx_fw_status { __le32 intr; @@ -537,9 +524,6 @@ struct wl1271 { /* Most recently reported noise in dBm */ s8 noise; - /* map for HLIDs of associated stations - when operating in AP mode */ - unsigned long ap_hlid_map[BITS_TO_LONGS(AP_MAX_STATIONS)]; - /* recoreded keys for AP-mode - set here before AP startup */ struct wl1271_ap_key *recorded_ap_keys[MAX_NUM_KEYS]; @@ -559,7 +543,7 @@ struct wl1271 { * AP-mode - links indexed by HLID. The global and broadcast links * are always active. */ - struct wl1271_link links[AP_MAX_LINKS]; + struct wl1271_link links[WL12XX_MAX_LINKS]; /* the hlid of the link where the last transmitted skb came from */ int last_tx_hlid; @@ -605,9 +589,15 @@ struct wl12xx_vif { struct { u8 global_hlid; u8 bcast_hlid; + + /* HLIDs bitmap of associated stations */ + unsigned long sta_hlid_map[BITS_TO_LONGS( + WL12XX_MAX_LINKS)]; } ap; }; + unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v0.10.2 From 170d0e6732c5fb1d4103ded3da95a5630c24e5dd Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:06 +0200 Subject: wl12xx: move recorded_ap_keys into wlvif move recorded_ap_keys into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f712f0f..194d7cc 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -379,7 +379,7 @@ static bool bug_on_recovery; static void __wl1271_op_remove_interface(struct wl1271 *wl, struct ieee80211_vif *vif, bool reset_tx_queues); -static void wl1271_free_ap_keys(struct wl1271 *wl); +static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif); static void wl1271_device_release(struct device *dev) @@ -2132,7 +2132,7 @@ deinit: wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl->vif = NULL; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; - wl1271_free_ap_keys(wl); + wl1271_free_ap_keys(wl, wlvif); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; @@ -2603,9 +2603,10 @@ out: kfree(fp); } -static int wl1271_record_ap_key(struct wl1271 *wl, u8 id, u8 key_type, - u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, - u16 tx_seq_16) +static int wl1271_record_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 id, u8 key_type, u8 key_size, + const u8 *key, u8 hlid, u32 tx_seq_32, + u16 tx_seq_16) { struct wl1271_ap_key *ap_key; int i; @@ -2620,10 +2621,10 @@ static int wl1271_record_ap_key(struct wl1271 *wl, u8 id, u8 key_type, * an existing key. */ for (i = 0; i < MAX_NUM_KEYS; i++) { - if (wl->recorded_ap_keys[i] == NULL) + if (wlvif->ap.recorded_keys[i] == NULL) break; - if (wl->recorded_ap_keys[i]->id == id) { + if (wlvif->ap.recorded_keys[i]->id == id) { wl1271_warning("trying to record key replacement"); return -EINVAL; } @@ -2644,17 +2645,17 @@ static int wl1271_record_ap_key(struct wl1271 *wl, u8 id, u8 key_type, ap_key->tx_seq_32 = tx_seq_32; ap_key->tx_seq_16 = tx_seq_16; - wl->recorded_ap_keys[i] = ap_key; + wlvif->ap.recorded_keys[i] = ap_key; return 0; } -static void wl1271_free_ap_keys(struct wl1271 *wl) +static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int i; for (i = 0; i < MAX_NUM_KEYS; i++) { - kfree(wl->recorded_ap_keys[i]); - wl->recorded_ap_keys[i] = NULL; + kfree(wlvif->ap.recorded_keys[i]); + wlvif->ap.recorded_keys[i] = NULL; } } @@ -2666,10 +2667,10 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) for (i = 0; i < MAX_NUM_KEYS; i++) { u8 hlid; - if (wl->recorded_ap_keys[i] == NULL) + if (wlvif->ap.recorded_keys[i] == NULL) break; - key = wl->recorded_ap_keys[i]; + key = wlvif->ap.recorded_keys[i]; hlid = key->hlid; if (hlid == WL12XX_INVALID_LINK_ID) hlid = wlvif->ap.bcast_hlid; @@ -2694,7 +2695,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) } out: - wl1271_free_ap_keys(wl); + wl1271_free_ap_keys(wl, wlvif); return ret; } @@ -2725,7 +2726,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (action != KEY_ADD_OR_REPLACE) return 0; - ret = wl1271_record_ap_key(wl, id, + ret = wl1271_record_ap_key(wl, wlvif, id, key_type, key_size, key, hlid, tx_seq_32, tx_seq_16); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 5fd3c26..074de4e 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -524,9 +524,6 @@ struct wl1271 { /* Most recently reported noise in dBm */ s8 noise; - /* recoreded keys for AP-mode - set here before AP startup */ - struct wl1271_ap_key *recorded_ap_keys[MAX_NUM_KEYS]; - /* bands supported by this instance of wl12xx */ struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -593,6 +590,9 @@ struct wl12xx_vif { /* HLIDs bitmap of associated stations */ unsigned long sta_hlid_map[BITS_TO_LONGS( WL12XX_MAX_LINKS)]; + + /* recoreded keys - set here before AP startup */ + struct wl1271_ap_key *recorded_keys[MAX_NUM_KEYS]; } ap; }; -- cgit v0.10.2 From 5a9b80e2cd993f77d6d068470a4fd77fdfae44ab Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 9 Oct 2011 12:12:16 +0200 Subject: Bluetooth: btusb: also be quiet when suspending usb_submit_urb() returns -ENODEV when a usb device is disconnected. In commit 4935f1c164ac528dff3538f97953b385ba500710 ("Bluetooth: btusb: be quiet on device disconnect") I stopped treating that return as an error in the three btusb_*_complete() functions. It turns out btusb_send_frame() generates a similar error if the system is suspended while the bluetooth usb device is enabled. The sensible thing to do here seems to be to treat -ENODEV (and -EPERM) just like the btusb_*_complete() functions now do. Signed-off-by: Paul Bolle Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 675246a..18fde3b 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -767,7 +767,9 @@ skip_waking: err = usb_submit_urb(urb, GFP_ATOMIC); if (err < 0) { - BT_ERR("%s urb %p submission failed", hdev->name, urb); + if (err != -EPERM && err != -ENODEV) + BT_ERR("%s urb %p submission failed (%d)", + hdev->name, urb, -err); kfree(urb->setup_packet); usb_unanchor_urb(urb); } else { -- cgit v0.10.2 From d4b8d1c9c1564f4cbce86cbbee099fadf735b226 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 9 Oct 2011 12:12:22 +0200 Subject: Bluetooth: btusb: hide more usb_submit_urb errors There are still three calls of usb_submit_urb() that will print errors if those calls return -EPERM or -ENODEV. I have never triggered these, so I'm not sure when these return values might be seen. It still makes sense to be silent if these occur (since "urb is being killed" and "device got disconnected" aren't things to worry about). Signed-off-by: Paul Bolle Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 18fde3b..abfc4ee 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -312,7 +312,8 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) err = usb_submit_urb(urb, mem_flags); if (err < 0) { - BT_ERR("%s urb %p submission failed (%d)", + if (err != -EPERM && err != -ENODEV) + BT_ERR("%s urb %p submission failed (%d)", hdev->name, urb, -err); usb_unanchor_urb(urb); } @@ -397,7 +398,8 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags) err = usb_submit_urb(urb, mem_flags); if (err < 0) { - BT_ERR("%s urb %p submission failed (%d)", + if (err != -EPERM && err != -ENODEV) + BT_ERR("%s urb %p submission failed (%d)", hdev->name, urb, -err); usb_unanchor_urb(urb); } @@ -520,7 +522,8 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags) err = usb_submit_urb(urb, mem_flags); if (err < 0) { - BT_ERR("%s urb %p submission failed (%d)", + if (err != -EPERM && err != -ENODEV) + BT_ERR("%s urb %p submission failed (%d)", hdev->name, urb, -err); usb_unanchor_urb(urb); } -- cgit v0.10.2 From 1d095475f58680af17e4a0e8dd84269b3f08ce54 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:49 +0200 Subject: wl12xx: refactor fw init into a new function The fw boot and initialization currently happens inside the add_interface() callback. This is wrong, as add_interface is called for each new vif. However, we due to some fw limitation (we have to know the actual mac address on boot), we can't completely move it into the start() callback. Until the fw will be fixed, refactor the fw init into a new function, and call it from add_interface() Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 194d7cc..3667acf 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1888,60 +1888,12 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) return 0; } -static int wl1271_op_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +static bool wl12xx_init_fw(struct wl1271 *wl) { - struct wl1271 *wl = hw->priv; - struct wiphy *wiphy = hw->wiphy; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int retries = WL1271_BOOT_RETRIES; - int ret = 0; - u8 role_type; bool booted = false; - - wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", - ieee80211_vif_type_p2p(vif), vif->addr); - - mutex_lock(&wl->mutex); - if (wl->vif) { - wl1271_debug(DEBUG_MAC80211, - "multiple vifs are not supported yet"); - ret = -EBUSY; - goto out; - } - - /* - * in some very corner case HW recovery scenarios its possible to - * get here before __wl1271_op_remove_interface is complete, so - * opt out if that is the case. - */ - if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) { - ret = -EBUSY; - goto out; - } - - ret = wl12xx_init_vif_data(vif); - if (ret < 0) - goto out; - - wlvif->wl = wl; - role_type = wl12xx_get_role_type(wl, wlvif); - if (role_type == WL12XX_INVALID_ROLE_TYPE) { - ret = -EINVAL; - goto out; - } - /* - * we still need this in order to configure the fw - * while uploading the nvs - */ - memcpy(wl->mac_addr, vif->addr, ETH_ALEN); - - if (wl->state != WL1271_STATE_OFF) { - wl1271_error("cannot start because not in off state: %d", - wl->state); - ret = -EBUSY; - goto out; - } + struct wiphy *wiphy = wl->hw->wiphy; + int ret; while (retries) { retries--; @@ -1957,30 +1909,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto irq_disable; - if (wlvif->bss_type == BSS_TYPE_STA_BSS || - wlvif->bss_type == BSS_TYPE_IBSS) { - /* - * The device role is a special role used for - * rx and tx frames prior to association (as - * the STA role can get packets only from - * its associated bssid) - */ - ret = wl12xx_cmd_role_enable(wl, vif->addr, - WL1271_ROLE_DEVICE, - &wlvif->dev_role_id); - if (ret < 0) - goto irq_disable; - } - - ret = wl12xx_cmd_role_enable(wl, vif->addr, - role_type, &wlvif->role_id); - if (ret < 0) - goto irq_disable; - - ret = wl1271_init_vif_specific(wl, vif); - if (ret < 0) - goto irq_disable; - booted = true; break; @@ -2007,9 +1935,6 @@ power_off: goto out; } - wl->vif = vif; - wl->state = WL1271_STATE_ON; - set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); wl1271_info("firmware booted (%s)", wl->chip.fw_ver_str); /* update hw/fw version info in wiphy struct */ @@ -2027,6 +1952,96 @@ power_off: wl1271_debug(DEBUG_MAC80211, "11a is %ssupported", wl->enable_11a ? "" : "not "); + wl->state = WL1271_STATE_ON; +out: + return booted; +} + +static int wl1271_op_add_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int ret = 0; + u8 role_type; + bool booted = false; + + wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", + ieee80211_vif_type_p2p(vif), vif->addr); + + mutex_lock(&wl->mutex); + if (wl->vif) { + wl1271_debug(DEBUG_MAC80211, + "multiple vifs are not supported yet"); + ret = -EBUSY; + goto out; + } + + /* + * in some very corner case HW recovery scenarios its possible to + * get here before __wl1271_op_remove_interface is complete, so + * opt out if that is the case. + */ + if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) { + ret = -EBUSY; + goto out; + } + + ret = wl12xx_init_vif_data(vif); + if (ret < 0) + goto out; + + wlvif->wl = wl; + role_type = wl12xx_get_role_type(wl, wlvif); + if (role_type == WL12XX_INVALID_ROLE_TYPE) { + ret = -EINVAL; + goto out; + } + + /* + * TODO: after the nvs issue will be solved, move this block + * to start(), and make sure here the driver is ON. + */ + if (wl->state == WL1271_STATE_OFF) { + /* + * we still need this in order to configure the fw + * while uploading the nvs + */ + memcpy(wl->mac_addr, vif->addr, ETH_ALEN); + + booted = wl12xx_init_fw(wl); + if (!booted) { + ret = -EINVAL; + goto out; + } + } + + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + /* + * The device role is a special role used for + * rx and tx frames prior to association (as + * the STA role can get packets only from + * its associated bssid) + */ + ret = wl12xx_cmd_role_enable(wl, vif->addr, + WL1271_ROLE_DEVICE, + &wlvif->dev_role_id); + if (ret < 0) + goto out; + } + + ret = wl12xx_cmd_role_enable(wl, vif->addr, + role_type, &wlvif->role_id); + if (ret < 0) + goto out; + + ret = wl1271_init_vif_specific(wl, vif); + if (ret < 0) + goto out; + + wl->vif = vif; + set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); out: mutex_unlock(&wl->mutex); -- cgit v0.10.2 From 4438aca9e16901d8d32a025ca27ad8284a117e09 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:50 +0200 Subject: wl12xx: move last_tx_hlid into wlvif move last_tx_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index f0398d0..bbc8004 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -355,7 +355,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(sg_enabled); DRIVER_STATE_PRINT_INT(enable_11a); DRIVER_STATE_PRINT_INT(noise); - DRIVER_STATE_PRINT_INT(last_tx_hlid); DRIVER_STATE_PRINT_HEX(ap_fw_ps_map); DRIVER_STATE_PRINT_LHEX(ap_ps_map); DRIVER_STATE_PRINT_HEX(quirks); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3667acf..0606b0d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4901,7 +4901,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->flags = 0; wl->sg_enabled = true; wl->hw_pg_ver = -1; - wl->last_tx_hlid = 0; wl->ap_ps_map = 0; wl->ap_fw_ps_map = 0; wl->quirks = 0; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 1b3d8e3..951ff03 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -570,7 +570,7 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, struct sk_buff_head *queue; /* start from the link after the last one */ - start_hlid = (wl->last_tx_hlid + 1) % WL12XX_MAX_LINKS; + start_hlid = (wlvif->last_tx_hlid + 1) % WL12XX_MAX_LINKS; /* dequeue according to AC, round robin on each link */ for (i = 0; i < WL12XX_MAX_LINKS; i++) { @@ -591,12 +591,12 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, if (skb) { int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); - wl->last_tx_hlid = h; + wlvif->last_tx_hlid = h; spin_lock_irqsave(&wl->wl_lock, flags); wl->tx_queue_count[q]--; spin_unlock_irqrestore(&wl->wl_lock, flags); } else { - wl->last_tx_hlid = 0; + wlvif->last_tx_hlid = 0; } return skb; @@ -641,7 +641,7 @@ static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ - wl->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % + wlvif->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % WL12XX_MAX_LINKS; } else { skb_queue_head(&wl->tx_queue[q], skb); @@ -924,7 +924,7 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) wl->links[i].prev_freed_pkts = 0; } - wl->last_tx_hlid = 0; + wlvif->last_tx_hlid = 0; } else { for (i = 0; i < NUM_TX_QUEUES; i++) { while ((skb = skb_dequeue(&wl->tx_queue[i]))) { diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 074de4e..b350f0b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -542,9 +542,6 @@ struct wl1271 { */ struct wl1271_link links[WL12XX_MAX_LINKS]; - /* the hlid of the link where the last transmitted skb came from */ - int last_tx_hlid; - /* AP-mode - a bitmap of links currently in PS mode according to FW */ u32 ap_fw_ps_map; @@ -596,6 +593,9 @@ struct wl12xx_vif { } ap; }; + /* the hlid of the last transmitted skb */ + int last_tx_hlid; + unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; -- cgit v0.10.2 From d6a3cc2ef962ad4392a2401cae513a18a6d35099 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:51 +0200 Subject: wl12xx: unify STA and AP tx_queue mechanism Make sta use the global wl->links[hlid].tx_queue (by considering its links map) instead of wl->tx_queue, and then unify the tx and tx_reset flows for the various vifs. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0606b0d..abe5ef8 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1474,31 +1474,26 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q, mapping; - u8 hlid = 0; + u8 hlid; mapping = skb_get_queue_mapping(skb); q = wl1271_tx_get_queue(mapping); - if (wlvif->bss_type == BSS_TYPE_AP_BSS) - hlid = wl12xx_tx_get_hlid_ap(wl, wlvif, skb); + hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); spin_lock_irqsave(&wl->wl_lock, flags); /* queue the packet */ - if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - if (!test_bit(hlid, wlvif->links_map)) { - wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", - hlid, q); - dev_kfree_skb(skb); - goto out; - } - - wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q); - skb_queue_tail(&wl->links[hlid].tx_queue[q], skb); - } else { - skb_queue_tail(&wl->tx_queue[q], skb); + if (hlid == WL12XX_INVALID_LINK_ID || + !test_bit(hlid, wlvif->links_map)) { + wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); + dev_kfree_skb(skb); + goto out; } + wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q); + skb_queue_tail(&wl->links[hlid].tx_queue[q], skb); + wl->tx_queue_count[q]++; /* @@ -2131,7 +2126,8 @@ deinit: mutex_lock(&wl->mutex); /* let's notify MAC80211 about the remaining pending TX frames */ - wl1271_tx_reset(wl, reset_tx_queues); + wl12xx_tx_reset_wlvif(wl, wlvif); + wl12xx_tx_reset(wl, reset_tx_queues); wl1271_power_off(wl); wl->band = IEEE80211_BAND_2GHZ; @@ -3968,7 +3964,6 @@ static int wl1271_allocate_sta(struct wl1271 *wl, return 0; } -/* TODO: change wl1271_tx_reset(), so we can get sta as param */ void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) { if (!test_bit(hlid, wlvif->ap.sta_hlid_map)) @@ -4868,9 +4863,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->plat_dev = plat_dev; for (i = 0; i < NUM_TX_QUEUES; i++) - skb_queue_head_init(&wl->tx_queue[i]); - - for (i = 0; i < NUM_TX_QUEUES; i++) for (j = 0; j < WL12XX_MAX_LINKS; j++) skb_queue_head_init(&wl->links[j].tx_queue[i]); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 951ff03..6c0135b 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -179,12 +179,10 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, } } -static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, - struct sk_buff *skb) +u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - if (wl12xx_is_dummy_packet(wl, skb)) return wl->system_hlid; @@ -429,7 +427,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, wlvif->default_key = idx; } } - hlid = wl1271_tx_get_hlid(wl, vif, skb); + hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); if (hlid == WL12XX_INVALID_LINK_ID) { wl1271_error("invalid hlid. dropping skb 0x%p", skb); return -EINVAL; @@ -538,19 +536,18 @@ static struct sk_buff_head *wl1271_select_queue(struct wl1271 *wl, return &queues[q]; } -static struct sk_buff *wl1271_sta_skb_dequeue(struct wl1271 *wl) +static struct sk_buff *wl12xx_lnk_skb_dequeue(struct wl1271 *wl, + struct wl1271_link *lnk) { - struct sk_buff *skb = NULL; + struct sk_buff *skb; unsigned long flags; struct sk_buff_head *queue; - queue = wl1271_select_queue(wl, wl->tx_queue); + queue = wl1271_select_queue(wl, lnk->tx_queue); if (!queue) - goto out; + return NULL; skb = skb_dequeue(queue); - -out: if (skb) { int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); spin_lock_irqsave(&wl->wl_lock, flags); @@ -561,13 +558,11 @@ out: return skb; } -static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, - struct wl12xx_vif *wlvif) +static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct sk_buff *skb = NULL; - unsigned long flags; int i, h, start_hlid; - struct sk_buff_head *queue; /* start from the link after the last one */ start_hlid = (wlvif->last_tx_hlid + 1) % WL12XX_MAX_LINKS; @@ -580,24 +575,16 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, if (!test_bit(h, wlvif->links_map)) continue; - queue = wl1271_select_queue(wl, wl->links[h].tx_queue); - if (!queue) + skb = wl12xx_lnk_skb_dequeue(wl, &wl->links[h]); + if (!skb) continue; - skb = skb_dequeue(queue); - if (skb) - break; + wlvif->last_tx_hlid = h; + break; } - if (skb) { - int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); - wlvif->last_tx_hlid = h; - spin_lock_irqsave(&wl->wl_lock, flags); - wl->tx_queue_count[q]--; - spin_unlock_irqrestore(&wl->wl_lock, flags); - } else { + if (!skb) wlvif->last_tx_hlid = 0; - } return skb; } @@ -608,11 +595,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, unsigned long flags; struct sk_buff *skb = NULL; - if (wlvif->bss_type == BSS_TYPE_AP_BSS) - skb = wl1271_ap_skb_dequeue(wl, wlvif); - else - skb = wl1271_sta_skb_dequeue(wl); - + skb = wl12xx_vif_skb_dequeue(wl, wlvif); if (!skb && test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) { int q; @@ -627,24 +610,21 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, return skb; } -static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, +static void wl1271_skb_queue_head(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); if (wl12xx_is_dummy_packet(wl, skb)) { set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags); - } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - u8 hlid = wl1271_tx_get_hlid(wl, vif, skb); + } else { + u8 hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ wlvif->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % - WL12XX_MAX_LINKS; - } else { - skb_queue_head(&wl->tx_queue[q], skb); + WL12XX_MAX_LINKS; } spin_lock_irqsave(&wl->wl_lock, flags); @@ -682,7 +662,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) * Aggregation buffer is full. * Flush buffer and try again. */ - wl1271_skb_queue_head(wl, vif, skb); + wl1271_skb_queue_head(wl, wlvif, skb); wl1271_write(wl, WL1271_SLV_MEM_DATA, wl->aggr_buf, buf_offset, true); sent_packets = true; @@ -693,7 +673,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) * Firmware buffer is full. * Queue back last skb, and stop aggregating. */ - wl1271_skb_queue_head(wl, vif, skb); + wl1271_skb_queue_head(wl, wlvif, skb); /* No work left, avoid scheduling redundant tx work */ set_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); goto out_ack; @@ -907,41 +887,30 @@ void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid) } /* caller must hold wl->mutex and TX must be stopped */ -void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) +void wl12xx_tx_reset_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int i; - struct sk_buff *skb; - struct ieee80211_tx_info *info; /* TX failure */ - if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - for (i = 0; i < WL12XX_MAX_LINKS; i++) { + for_each_set_bit(i, wlvif->links_map, WL12XX_MAX_LINKS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS) wl1271_free_sta(wl, wlvif, i); - wl1271_tx_reset_link_queues(wl, i); - wl->links[i].allocated_pkts = 0; - wl->links[i].prev_freed_pkts = 0; - } - - wlvif->last_tx_hlid = 0; - } else { - for (i = 0; i < NUM_TX_QUEUES; i++) { - while ((skb = skb_dequeue(&wl->tx_queue[i]))) { - wl1271_debug(DEBUG_TX, "freeing skb 0x%p", - skb); - - if (!wl12xx_is_dummy_packet(wl, skb)) { - info = IEEE80211_SKB_CB(skb); - info->status.rates[0].idx = -1; - info->status.rates[0].count = 0; - ieee80211_tx_status_ni(wl->hw, skb); - } - } - } + else + wlvif->sta.ba_rx_bitmap = 0; - wlvif->sta.ba_rx_bitmap = 0; + wl1271_tx_reset_link_queues(wl, i); + wl->links[i].allocated_pkts = 0; + wl->links[i].prev_freed_pkts = 0; } + wlvif->last_tx_hlid = 0; + +} +/* caller must hold wl->mutex and TX must be stopped */ +void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues) +{ + int i; + struct sk_buff *skb; + struct ieee80211_tx_info *info; for (i = 0; i < NUM_TX_QUEUES; i++) wl->tx_queue_count[i] = 0; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index add4402..050a047 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -206,7 +206,8 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) void wl1271_tx_work(struct work_struct *work); void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_tx_complete(struct wl1271 *wl); -void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues); +void wl12xx_tx_reset_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif); +void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues); void wl1271_tx_flush(struct wl1271 *wl); u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band); u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set, @@ -214,6 +215,8 @@ u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set, u32 wl1271_tx_min_rate_get(struct wl1271 *wl, u32 rate_set); u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb); +u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb); void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid); void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b350f0b..4802f68 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -416,7 +416,6 @@ struct wl1271 { s64 time_offset; /* Frames scheduled for transmission, not handled yet */ - struct sk_buff_head tx_queue[NUM_TX_QUEUES]; int tx_queue_count[NUM_TX_QUEUES]; long stopped_queues_map; -- cgit v0.10.2 From baf6277ae964b1d3830aa74b13e87ff9ba29145c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:52 +0200 Subject: wl12xx: move some functions from remove_interface() to stop() Leave only vif-specific deinit stuff in remove_interface(). Move the global deinit (including power_off) to stop(). Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index abe5ef8..e53829a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1803,7 +1803,83 @@ static int wl1271_op_start(struct ieee80211_hw *hw) static void wl1271_op_stop(struct ieee80211_hw *hw) { + struct wl1271 *wl = hw->priv; + int i; + wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); + + mutex_lock(&wl_list_mutex); + list_del(&wl->list); + + /* + * this must be before the cancel_work calls below, so that the work + * functions don't perform further work. + */ + wl->state = WL1271_STATE_OFF; + mutex_unlock(&wl_list_mutex); + + wl1271_disable_interrupts(wl); + wl1271_flush_deferred_work(wl); + cancel_delayed_work_sync(&wl->scan_complete_work); + cancel_work_sync(&wl->netstack_work); + cancel_work_sync(&wl->tx_work); + del_timer_sync(&wl->rx_streaming_timer); + cancel_work_sync(&wl->rx_streaming_enable_work); + cancel_work_sync(&wl->rx_streaming_disable_work); + cancel_delayed_work_sync(&wl->elp_work); + + /* let's notify MAC80211 about the remaining pending TX frames */ + wl12xx_tx_reset(wl, true); + mutex_lock(&wl->mutex); + + wl1271_power_off(wl); + + wl->band = IEEE80211_BAND_2GHZ; + + wl->rx_counter = 0; + wl->power_level = WL1271_DEFAULT_POWER_LEVEL; + wl->tx_blocks_available = 0; + wl->tx_allocated_blocks = 0; + wl->tx_results_count = 0; + wl->tx_packets_count = 0; + wl->time_offset = 0; + wl->vif = NULL; + wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; + wl->ap_fw_ps_map = 0; + wl->ap_ps_map = 0; + wl->sched_scanning = false; + memset(wl->roles_map, 0, sizeof(wl->roles_map)); + memset(wl->links_map, 0, sizeof(wl->links_map)); + memset(wl->roc_map, 0, sizeof(wl->roc_map)); + wl->active_sta_count = 0; + + /* The system link is always allocated */ + __set_bit(WL12XX_SYSTEM_HLID, wl->links_map); + + /* + * this is performed after the cancel_work calls and the associated + * mutex_lock, so that wl1271_op_add_interface does not accidentally + * get executed before all these vars have been reset. + */ + wl->flags = 0; + + wl->tx_blocks_freed = 0; + + for (i = 0; i < NUM_TX_QUEUES; i++) { + wl->tx_pkts_freed[i] = 0; + wl->tx_allocated_pkts[i] = 0; + } + + wl1271_debugfs_reset(wl); + + kfree(wl->fw_status); + wl->fw_status = NULL; + kfree(wl->tx_res_if); + wl->tx_res_if = NULL; + kfree(wl->target_mem_map); + wl->target_mem_map = NULL; + + mutex_unlock(&wl->mutex); } static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -2053,7 +2129,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, bool reset_tx_queues) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - int ret, i; + int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); @@ -2063,15 +2139,12 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, wl1271_info("down"); - mutex_lock(&wl_list_mutex); - list_del(&wl->list); - mutex_unlock(&wl_list_mutex); - /* enable dyn ps just in case (if left on due to fw crash etc) */ if (wlvif->bss_type == BSS_TYPE_STA_BSS) - ieee80211_enable_dyn_ps(wl->vif); + ieee80211_enable_dyn_ps(vif); - if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { + if (wl->scan.state != WL1271_SCAN_STATE_IDLE && + wl->scan_vif == vif) { wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan_vif = NULL; @@ -2104,82 +2177,18 @@ deinit: wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; - /* - * this must be before the cancel_work calls below, so that the work - * functions don't perform further work. - */ - wl->state = WL1271_STATE_OFF; - - mutex_unlock(&wl->mutex); - - wl1271_disable_interrupts(wl); - wl1271_flush_deferred_work(wl); - cancel_delayed_work_sync(&wl->scan_complete_work); - cancel_work_sync(&wl->netstack_work); - cancel_work_sync(&wl->tx_work); - del_timer_sync(&wl->rx_streaming_timer); - cancel_work_sync(&wl->rx_streaming_enable_work); - cancel_work_sync(&wl->rx_streaming_disable_work); - cancel_delayed_work_sync(&wlvif->pspoll_work); - cancel_delayed_work_sync(&wl->elp_work); - - mutex_lock(&wl->mutex); - - /* let's notify MAC80211 about the remaining pending TX frames */ wl12xx_tx_reset_wlvif(wl, wlvif); - wl12xx_tx_reset(wl, reset_tx_queues); - wl1271_power_off(wl); - - wl->band = IEEE80211_BAND_2GHZ; - - wl->rx_counter = 0; - wl->power_level = WL1271_DEFAULT_POWER_LEVEL; - wl->tx_blocks_available = 0; - wl->tx_allocated_blocks = 0; - wl->tx_results_count = 0; - wl->tx_packets_count = 0; - wl->time_offset = 0; wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; - wl->vif = NULL; - wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl1271_free_ap_keys(wl, wlvif); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); - wl->ap_fw_ps_map = 0; - wl->ap_ps_map = 0; - wl->sched_scanning = false; wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; - memset(wl->roles_map, 0, sizeof(wl->roles_map)); - memset(wl->links_map, 0, sizeof(wl->links_map)); - memset(wl->roc_map, 0, sizeof(wl->roc_map)); - wl->active_sta_count = 0; - /* The system link is always allocated */ - __set_bit(WL12XX_SYSTEM_HLID, wl->links_map); - - /* - * this is performed after the cancel_work calls and the associated - * mutex_lock, so that wl1271_op_add_interface does not accidentally - * get executed before all these vars have been reset. - */ - wl->flags = 0; - - wl->tx_blocks_freed = 0; - - for (i = 0; i < NUM_TX_QUEUES; i++) { - wl->tx_pkts_freed[i] = 0; - wl->tx_allocated_pkts[i] = 0; - } - - wl1271_debugfs_reset(wl); + mutex_unlock(&wl->mutex); + cancel_delayed_work_sync(&wlvif->pspoll_work); - kfree(wl->fw_status); - wl->fw_status = NULL; - kfree(wl->tx_res_if); - wl->tx_res_if = NULL; - kfree(wl->target_mem_map); - wl->target_mem_map = NULL; + mutex_lock(&wl->mutex); } static void wl1271_op_remove_interface(struct ieee80211_hw *hw, -- cgit v0.10.2 From 83587505a2b63bb434f76b26a22f48283b86a467 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:53 +0200 Subject: wl12xx: move bitrate_masks into wlvif move bitrate_masks into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 102a8a5..ff653e8 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1111,15 +1111,16 @@ out: return ret; } -int wl1271_cmd_build_probe_req(struct wl1271 *wl, +int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct sk_buff *skb; int ret; u32 rate; - skb = ieee80211_probereq_get(wl->hw, wl->vif, ssid, ssid_len, + skb = ieee80211_probereq_get(wl->hw, vif, ssid, ssid_len, ie, ie_len); if (!skb) { ret = -ENOMEM; @@ -1128,7 +1129,7 @@ int wl1271_cmd_build_probe_req(struct wl1271 *wl, wl1271_dump(DEBUG_SCAN, "PROBE REQ: ", skb->data, skb->len); - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); if (band == IEEE80211_BAND_2GHZ) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); @@ -1142,19 +1143,21 @@ out: } struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct sk_buff *skb) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); int ret; u32 rate; if (!skb) - skb = ieee80211_ap_probereq_get(wl->hw, wl->vif); + skb = ieee80211_ap_probereq_get(wl->hw, vif); if (!skb) goto out; wl1271_dump(DEBUG_SCAN, "AP PROBE REQ: ", skb->data, skb->len); - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[wl->band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wl->band]); if (wl->band == IEEE80211_BAND_2GHZ) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index d2670d3..8182cf1 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -59,10 +59,11 @@ int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid); -int wl1271_cmd_build_probe_req(struct wl1271 *wl, +int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band); struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct sk_buff *skb); int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, __be32 ip_addr); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index e53829a..acfc497 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1906,7 +1906,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) return WL12XX_INVALID_ROLE_TYPE; } -static int wl12xx_init_vif_data(struct ieee80211_vif *vif) +static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); @@ -1949,6 +1949,8 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; } + wlvif->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; + wlvif->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -2058,7 +2060,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; } - ret = wl12xx_init_vif_data(vif); + ret = wl12xx_init_vif_data(wl, vif); if (ret < 0) goto out; @@ -2178,8 +2180,6 @@ deinit: wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; wl12xx_tx_reset_wlvif(wl, wlvif); - wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; - wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl1271_free_ap_keys(wl, wlvif); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wlvif->role_id = WL12XX_INVALID_ROLE_ID; @@ -2293,7 +2293,7 @@ out: static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - wlvif->basic_rate_set = wl->bitrate_masks[wl->band]; + wlvif->basic_rate_set = wlvif->bitrate_masks[wl->band]; wlvif->rate_set = wlvif->basic_rate_set; } @@ -3578,6 +3578,7 @@ sta_not_found: */ dev_kfree_skb(wlvif->probereq); wlvif->probereq = wl1271_cmd_build_ap_probe_req(wl, + wlvif, NULL); ieoffset = offsetof(struct ieee80211_mgmt, u.probe_req.variable); @@ -4202,6 +4203,7 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif, const struct cfg80211_bitrate_mask *mask) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271 *wl = hw->priv; int i; @@ -4212,7 +4214,7 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, mutex_lock(&wl->mutex); for (i = 0; i < IEEE80211_NUM_BANDS; i++) - wl->bitrate_masks[i] = + wlvif->bitrate_masks[i] = wl1271_tx_enabled_rates_get(wl, mask->control[i].legacy, i); @@ -4931,8 +4933,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) /* Apply default driver configuration. */ wl1271_conf_init(wl); - wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; - wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; order = get_order(WL1271_AGGR_BUFFER_SIZE); wl->aggr_buf = (u8 *)__get_free_pages(GFP_KERNEL, order); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 9372136..e1a8ce0 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -66,7 +66,7 @@ void wl1271_scan_complete_work(struct work_struct *work) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { /* restore hardware connection monitoring template */ - wl1271_cmd_build_ap_probe_req(wl, wlvif->probereq); + wl1271_cmd_build_ap_probe_req(wl, wlvif, wlvif->probereq); } /* return to ROC if needed */ @@ -218,9 +218,9 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, memcpy(cmd->addr, vif->addr, ETH_ALEN); - ret = wl1271_cmd_build_probe_req(wl, wl->scan.ssid, wl->scan.ssid_len, - wl->scan.req->ie, wl->scan.req->ie_len, - band); + ret = wl1271_cmd_build_probe_req(wl, wlvif, wl->scan.ssid, + wl->scan.ssid_len, wl->scan.req->ie, + wl->scan.req->ie_len, band); if (ret < 0) { wl1271_error("PROBE request template failed"); goto out; @@ -251,6 +251,7 @@ out: void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; enum ieee80211_band band; u32 rate; @@ -261,7 +262,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_ACTIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE; @@ -272,7 +273,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_PASSIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { if (wl->enable_11a) @@ -286,7 +287,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_5GHZ_ACTIVE: band = IEEE80211_BAND_5GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE; @@ -297,7 +298,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_5GHZ_PASSIVE: band = IEEE80211_BAND_5GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_DONE; @@ -642,7 +643,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, } if (!force_passive && cfg->active[0]) { - ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, + ret = wl1271_cmd_build_probe_req(wl, wlvif, req->ssids[0].ssid, req->ssids[0].ssid_len, ies->ie[IEEE80211_BAND_2GHZ], ies->len[IEEE80211_BAND_2GHZ], @@ -654,7 +655,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, } if (!force_passive && cfg->active[1]) { - ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, + ret = wl1271_cmd_build_probe_req(wl, wlvif, req->ssids[0].ssid, req->ssids[0].ssid_len, ies->ie[IEEE80211_BAND_5GHZ], ies->len[IEEE80211_BAND_5GHZ], diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 4802f68..33ccdf8 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -484,8 +484,6 @@ struct wl1271 { bool sched_scanning; - u32 bitrate_masks[IEEE80211_NUM_BANDS]; - /* The current band */ enum ieee80211_band band; @@ -600,6 +598,7 @@ struct wl12xx_vif { u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; + u32 bitrate_masks[IEEE80211_NUM_BANDS]; u32 basic_rate_set; /* -- cgit v0.10.2 From 87627214738fcfd44803e90193f9f2f4583ce68b Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:54 +0200 Subject: wl12xx: add vifs list keep a list of all the vifs associated with our hw. it will be later used in order to iterate through vifs. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index acfc497..56d5923 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1957,6 +1957,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; INIT_DELAYED_WORK(&wlvif->pspoll_work, wl1271_pspoll_work); + INIT_LIST_HEAD(&wlvif->list); return 0; } @@ -2114,6 +2115,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; wl->vif = vif; + list_add(&wlvif->list, &wl->wlvif_list); set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); out: mutex_unlock(&wl->mutex); @@ -2181,6 +2183,7 @@ deinit: wl12xx_tx_reset_wlvif(wl, wlvif); wl1271_free_ap_keys(wl, wlvif); + list_del(&wlvif->list); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; @@ -4869,6 +4872,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) memset(wl, 0, sizeof(*wl)); INIT_LIST_HEAD(&wl->list); + INIT_LIST_HEAD(&wl->wlvif_list); wl->hw = hw; wl->plat_dev = plat_dev; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 33ccdf8..55561c5 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -394,6 +394,8 @@ struct wl1271 { unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; + struct list_head wlvif_list; + struct wl1271_acx_mem_map *target_mem_map; /* Accounting for allocated / available TX blocks on HW */ @@ -564,6 +566,7 @@ struct wl1271_station { struct wl12xx_vif { struct wl1271 *wl; + struct list_head list; u8 bss_type; u8 p2p; /* we are using p2p role */ u8 role_id; @@ -653,6 +656,9 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) return container_of((void *)wlvif, struct ieee80211_vif, drv_priv); } +#define wl12xx_for_each_wlvif(wl, wlvif) \ + list_for_each_entry(wlvif, &wl->wlvif_list, list) + int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); int wl1271_recalc_rx_streaming(struct wl1271 *wl); -- cgit v0.10.2 From a32d0cdfcb7e5d41f210e13cbc78dc86a5a85a08 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:55 +0200 Subject: wl12xx: support multiple vifs in the tx path Pass the wlvif associated with each skb as param. Note that dummy packet doesn't belong to any particular vif, so we pass NULL in this case. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 56d5923..0623f5d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -993,7 +993,7 @@ irqreturn_t wl1271_irq(int irq, void *cookie) * In order to avoid starvation of the TX path, * call the work function directly. */ - wl1271_tx_work_locked(wl, wl->vif); + wl1271_tx_work_locked(wl); } else { spin_unlock_irqrestore(&wl->wl_lock, flags); } @@ -1537,7 +1537,7 @@ int wl1271_tx_dummy_packet(struct wl1271 *wl) /* The FW is low on RX memory blocks, so send the dummy packet asap */ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) - wl1271_tx_work_locked(wl, wl->vif); + wl1271_tx_work_locked(wl); /* * If the FW TX is busy, TX work will be scheduled by the threaded @@ -2413,7 +2413,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ((wl->band != conf->channel->band) || (wl->channel != channel))) { /* send all pending packets */ - wl1271_tx_work_locked(wl, vif); + wl1271_tx_work_locked(wl); wl->band = conf->channel->band; wl->channel = channel; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 6c0135b..c7be151 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -210,17 +210,17 @@ static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, return ALIGN(packet_length, WL1271_TX_ALIGN_TO); } -static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, +static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb, u32 extra, u32 buf_offset, u8 hlid) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_tx_hw_descr *desc; u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; u32 len; u32 total_blocks; int id, ret = -EBUSY, ac; u32 spare_blocks = wl->tx_spare_blocks; + bool is_dummy = false; if (buf_offset + total_len > WL1271_AGGR_BUFFER_SIZE) return -EAGAIN; @@ -235,8 +235,10 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, len = wl12xx_calc_packet_alignment(wl, total_len); /* in case of a dummy packet, use default amount of spare mem blocks */ - if (unlikely(wl12xx_is_dummy_packet(wl, skb))) + if (unlikely(wl12xx_is_dummy_packet(wl, skb))) { + is_dummy = true; spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; + } total_blocks = (len + TX_HW_BLOCK_SIZE - 1) / TX_HW_BLOCK_SIZE + spare_blocks; @@ -261,7 +263,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); wl->tx_allocated_pkts[ac]++; - if (wlvif->bss_type == BSS_TYPE_AP_BSS && + if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS && test_bit(hlid, wlvif->ap.sta_hlid_map)) wl->links[hlid].allocated_pkts++; @@ -277,16 +279,16 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, return ret; } -static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, +static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb, u32 extra, struct ieee80211_tx_info *control, u8 hlid) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct timespec ts; struct wl1271_tx_hw_descr *desc; int aligned_len, ac, rate_idx; s64 hosttime; u16 tx_attr; + bool is_dummy; desc = (struct wl1271_tx_hw_descr *) skb->data; @@ -303,7 +305,8 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, hosttime = (timespec_to_ns(&ts) >> 10); desc->start_time = cpu_to_le32(hosttime - wl->time_offset); - if (wlvif->bss_type != BSS_TYPE_AP_BSS) + is_dummy = wl12xx_is_dummy_packet(wl, skb); + if (is_dummy || wlvif->bss_type != BSS_TYPE_AP_BSS) desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); else desc->life_time = cpu_to_le16(TX_HW_AP_MODE_PKT_LIFETIME_TU); @@ -312,7 +315,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); desc->tid = skb->priority; - if (wl12xx_is_dummy_packet(wl, skb)) { + if (is_dummy) { /* * FW expects the dummy packet to have an invalid session id - * any session id that is different than the one set in the join @@ -329,7 +332,9 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, } desc->hlid = hlid; - if (wlvif->bss_type != BSS_TYPE_AP_BSS) { + if (is_dummy) + rate_idx = 0; + else if (wlvif->bss_type != BSS_TYPE_AP_BSS) { /* if the packets are destined for AP (have a STA entry) send them with AP rate policies, otherwise use default basic rates */ @@ -383,12 +388,10 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, } /* caller must hold wl->mutex */ -static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, - u32 buf_offset) +static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb, u32 buf_offset) { struct ieee80211_tx_info *info; - struct ieee80211_vif *vif; - struct wl12xx_vif *wlvif; u32 extra = 0; int ret = 0; u32 total_len; @@ -402,11 +405,6 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, /* TODO: handle dummy packets on multi-vifs */ is_dummy = wl12xx_is_dummy_packet(wl, skb); - if (is_dummy) - info->control.vif = wl->vif; - - vif = info->control.vif; - wlvif = wl12xx_vif_to_data(vif); if (info->control.hw_key && info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) @@ -433,13 +431,13 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, return -EINVAL; } - ret = wl1271_tx_allocate(wl, vif, skb, extra, buf_offset, hlid); + ret = wl1271_tx_allocate(wl, wlvif, skb, extra, buf_offset, hlid); if (ret < 0) return ret; - wl1271_tx_fill_hdr(wl, vif, skb, extra, info, hlid); + wl1271_tx_fill_hdr(wl, wlvif, skb, extra, info, hlid); - if (wlvif->bss_type == BSS_TYPE_AP_BSS && !is_dummy) { + if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS) { wl1271_tx_ap_update_inconnection_sta(wl, skb); wl1271_tx_regulate_link(wl, wlvif, hlid); } @@ -589,13 +587,19 @@ static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl, return skb; } -static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, - struct wl12xx_vif *wlvif) +static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) { unsigned long flags; + struct wl12xx_vif *wlvif; struct sk_buff *skb = NULL; - skb = wl12xx_vif_skb_dequeue(wl, wlvif); + /* TODO: rememeber last vif and consider it */ + wl12xx_for_each_wlvif(wl, wlvif) { + skb = wl12xx_vif_skb_dequeue(wl, wlvif); + if (skb) + break; + } + if (!skb && test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) { int q; @@ -639,24 +643,35 @@ static bool wl1271_tx_is_data_present(struct sk_buff *skb) return ieee80211_is_data_present(hdr->frame_control); } -void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) +void wl1271_tx_work_locked(struct wl1271 *wl) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; struct sk_buff *skb; u32 buf_offset = 0; bool sent_packets = false; bool had_data = false; - bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); + /* TODO: save bitmap of relevant stations */ + bool is_sta = false; int ret; if (unlikely(wl->state == WL1271_STATE_OFF)) return; - while ((skb = wl1271_skb_dequeue(wl, wlvif))) { + while ((skb = wl1271_skb_dequeue(wl))) { + wlvif = NULL; + if (!wl12xx_is_dummy_packet(wl, skb)) { + struct ieee80211_tx_info *info; + struct ieee80211_vif *vif; + + info = IEEE80211_SKB_CB(skb); + vif = info->control.vif; + wlvif = wl12xx_vif_to_data(vif); + } + if (wl1271_tx_is_data_present(skb)) had_data = true; - ret = wl1271_prepare_tx_frame(wl, skb, buf_offset); + ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset); if (ret == -EAGAIN) { /* * Aggregation buffer is full. @@ -683,6 +698,8 @@ void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) } buf_offset += ret; wl->tx_packets_count++; + if (wlvif && wlvif->bss_type == BSS_TYPE_STA_BSS) + is_sta = true; } out_ack: @@ -702,7 +719,7 @@ out_ack: wl1271_handle_tx_low_watermark(wl); } - if (!is_ap && wl->conf.rx_streaming.interval && had_data && + if (is_sta && wl->conf.rx_streaming.interval && had_data && (wl->conf.rx_streaming.always || test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { u32 timeout = wl->conf.rx_streaming.duration; @@ -727,7 +744,7 @@ void wl1271_tx_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_tx_work_locked(wl, wl->vif); + wl1271_tx_work_locked(wl); wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index 050a047..fe29ff5 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -204,7 +204,7 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) } void wl1271_tx_work(struct work_struct *work); -void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif); +void wl1271_tx_work_locked(struct wl1271 *wl); void wl1271_tx_complete(struct wl1271 *wl); void wl12xx_tx_reset_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif); void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues); -- cgit v0.10.2 From a4e4130dcea01f3e0dfcbfeaf0d815b971e6e515 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 11:49:15 +0200 Subject: wl12xx: configure sleep_policy according to active roles If there is an active AP role, stay always on. Otherwise, allow chip to enter elp. (Note that this is a global configuration, so if the device is already configured according to our policy, we don't have to configure it again) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 80e89e3..4af7e2f 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -343,11 +343,6 @@ static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (ret < 0) return ret; - /* Configure for ELP power saving */ - ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); - if (ret < 0) - return ret; - ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) return ret; @@ -382,11 +377,6 @@ static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - /* Configure for power always on */ - ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); - if (ret < 0) - return ret; - ret = wl1271_init_ap_rates(wl, wlvif); if (ret < 0) return ret; @@ -577,9 +567,26 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); - int ret, i; + /* + * consider all existing roles before configuring psm. + * TODO: reconfigure on interface removal. + */ + if (!wl->ap_count) { + if (is_ap) { + /* Configure for power always on */ + ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); + if (ret < 0) + return ret; + } else if (!wl->sta_count) { + /* Configure for ELP power saving */ + ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); + if (ret < 0) + return ret; + } + } + /* Mode specific init */ if (is_ap) { ret = wl1271_ap_hw_init(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0623f5d..b52deac 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2117,6 +2117,11 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wl->vif = vif; list_add(&wlvif->list, &wl->wlvif_list); set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); + + if (wlvif->bss_type == BSS_TYPE_AP_BSS) + wl->ap_count++; + else + wl->sta_count++; out: mutex_unlock(&wl->mutex); @@ -2188,6 +2193,11 @@ deinit: wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + if (wlvif->bss_type == BSS_TYPE_AP_BSS) + wl->ap_count--; + else + wl->sta_count--; + mutex_unlock(&wl->mutex); cancel_delayed_work_sync(&wlvif->pspoll_work); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 55561c5..fd78f8c 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -395,6 +395,8 @@ struct wl1271 { unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; struct list_head wlvif_list; + u8 sta_count; + u8 ap_count; struct wl1271_acx_mem_map *target_mem_map; -- cgit v0.10.2 From 4b730b6a814fe52425d90ff3db3d8deefb22fb24 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:57 +0200 Subject: wl12xx: make event handling support multirole Some events don't indicate the role they are intended for. In these cases, iterate through all the relevant vifs, and pass the event to each one of them. This is only a workaround. future fw releases should indicate the relevant role_id for such events. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 486c8ee..dbc40bb 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -162,10 +162,10 @@ static int wl1271_event_ps_report(struct wl1271 *wl, } static void wl1271_event_rssi_trigger(struct wl1271 *wl, - struct ieee80211_vif *vif, + struct wl12xx_vif *wlvif, struct event_mailbox *mbox) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); enum nl80211_cqm_rssi_threshold_event event; s8 metric = mbox->rssi_snr_trigger_metric[0]; @@ -183,11 +183,13 @@ static void wl1271_event_rssi_trigger(struct wl1271 *wl, static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (!wlvif->sta.ba_rx_bitmap) return; - ieee80211_stop_rx_ba_session(wl->vif, wlvif->sta.ba_rx_bitmap, - wl->vif->bss_conf.bssid); + ieee80211_stop_rx_ba_session(vif, wlvif->sta.ba_rx_bitmap, + vif->bss_conf.bssid); } else { u8 hlid; struct wl1271_link *lnk; @@ -197,7 +199,7 @@ static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (!lnk->ba_bitmap) continue; - ieee80211_stop_rx_ba_session(wl->vif, + ieee80211_stop_rx_ba_session(vif, lnk->ba_bitmap, lnk->addr); } @@ -207,12 +209,21 @@ static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) static void wl12xx_event_soft_gemini_sense(struct wl1271 *wl, u8 enable) { + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; + if (enable) { /* disable dynamic PS when requested by the firmware */ - ieee80211_disable_dyn_ps(wl->vif); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_disable_dyn_ps(vif); + } set_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); } else { - ieee80211_enable_dyn_ps(wl->vif); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_enable_dyn_ps(vif); + } clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); wl1271_recalc_rx_streaming(wl); } @@ -228,12 +239,11 @@ static void wl1271_event_mbox_dump(struct event_mailbox *mbox) static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; int ret; u32 vector; bool beacon_loss = false; - bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); bool disconnect_sta = false; unsigned long sta_bitmap = 0; @@ -266,8 +276,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) } } - if (vector & SOFT_GEMINI_SENSE_EVENT_ID && - wlvif->bss_type == BSS_TYPE_STA_BSS) + if (vector & SOFT_GEMINI_SENSE_EVENT_ID) wl12xx_event_soft_gemini_sense(wl, mbox->soft_gemini_sense_info); @@ -280,40 +289,54 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) * BSS_LOSE_EVENT, beacon loss has to be reported to the stack. * */ - if ((vector & BSS_LOSE_EVENT_ID) && !is_ap) { + if (vector & BSS_LOSE_EVENT_ID) { + /* TODO: check for multi-role */ wl1271_info("Beacon loss detected."); /* indicate to the stack, that beacons have been lost */ beacon_loss = true; } - if ((vector & PS_REPORT_EVENT_ID) && !is_ap) { + if (vector & PS_REPORT_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "PS_REPORT_EVENT"); - ret = wl1271_event_ps_report(wl, wlvif, mbox, &beacon_loss); - if (ret < 0) - return ret; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + ret = wl1271_event_ps_report(wl, wlvif, + mbox, &beacon_loss); + if (ret < 0) + return ret; + } } - if ((vector & PSPOLL_DELIVERY_FAILURE_EVENT_ID) && !is_ap) - wl1271_event_pspoll_delivery_fail(wl, wlvif); + if (vector & PSPOLL_DELIVERY_FAILURE_EVENT_ID) + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_event_pspoll_delivery_fail(wl, wlvif); + } if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) { + /* TODO: check actual multi-role support */ wl1271_debug(DEBUG_EVENT, "RSSI_SNR_TRIGGER_0_EVENT"); - if (wl->vif) - wl1271_event_rssi_trigger(wl, vif, mbox); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_event_rssi_trigger(wl, wlvif, mbox); + } } - if ((vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID)) { + if (vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID) { + u8 role_id = mbox->role_id; wl1271_debug(DEBUG_EVENT, "BA_SESSION_RX_CONSTRAINT_EVENT_ID. " - "ba_allowed = 0x%x", mbox->rx_ba_allowed); + "ba_allowed = 0x%x, role_id=%d", + mbox->rx_ba_allowed, role_id); - wlvif->ba_allowed = !!mbox->rx_ba_allowed; + wl12xx_for_each_wlvif(wl, wlvif) { + if (role_id != 0xff && role_id != wlvif->role_id) + continue; - if (wl->vif && !wlvif->ba_allowed) - wl1271_stop_ba_event(wl, wlvif); + wlvif->ba_allowed = !!mbox->rx_ba_allowed; + if (!wlvif->ba_allowed) + wl1271_stop_ba_event(wl, wlvif); + } } - if ((vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) && !is_ap) { + if (vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "CHANNEL_SWITCH_COMPLETE_EVENT_ID. " "status = 0x%x", mbox->channel_switch_status); @@ -322,48 +345,63 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) * 1) channel switch complete with status=0 * 2) channel switch failed status=1 */ - if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags) && - (wl->vif)) - ieee80211_chswitch_done(wl->vif, - mbox->channel_switch_status ? false : true); + if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags)) { + /* TODO: configure only the relevant vif */ + wl12xx_for_each_wlvif_sta(wl, wlvif) { + struct ieee80211_vif *vif = + wl12xx_wlvif_to_vif(wlvif); + bool success = mbox->channel_switch_status ? + false : true; + + ieee80211_chswitch_done(vif, success); + } + } } if ((vector & DUMMY_PACKET_EVENT_ID)) { wl1271_debug(DEBUG_EVENT, "DUMMY_PACKET_ID_EVENT_ID"); - if (wl->vif) - wl1271_tx_dummy_packet(wl); + wl1271_tx_dummy_packet(wl); } /* * "TX retries exceeded" has a different meaning according to mode. * In AP mode the offending station is disconnected. */ - if ((vector & MAX_TX_RETRY_EVENT_ID) && is_ap) { + if (vector & MAX_TX_RETRY_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "MAX_TX_RETRY_EVENT_ID"); sta_bitmap |= le16_to_cpu(mbox->sta_tx_retry_exceeded); disconnect_sta = true; } - if ((vector & INACTIVE_STA_EVENT_ID) && is_ap) { + if (vector & INACTIVE_STA_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "INACTIVE_STA_EVENT_ID"); sta_bitmap |= le16_to_cpu(mbox->sta_aging_status); disconnect_sta = true; } - if (is_ap && disconnect_sta) { + if (disconnect_sta) { u32 num_packets = wl->conf.tx.max_tx_retries; struct ieee80211_sta *sta; const u8 *addr; int h; for_each_set_bit(h, &sta_bitmap, WL12XX_MAX_LINKS) { - if (!test_bit(h, wlvif->ap.sta_hlid_map)) + bool found = false; + /* find the ap vif connected to this sta */ + wl12xx_for_each_wlvif_ap(wl, wlvif) { + if (!test_bit(h, wlvif->ap.sta_hlid_map)) + continue; + found = true; + break; + } + if (!found) continue; + vif = wl12xx_wlvif_to_vif(wlvif); addr = wl->links[h].addr; rcu_read_lock(); - sta = ieee80211_find_sta(wl->vif, addr); + sta = ieee80211_find_sta(vif, addr); if (sta) { wl1271_debug(DEBUG_EVENT, "remove sta %d", h); ieee80211_report_low_ack(sta, num_packets); @@ -372,8 +410,11 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) } } - if (wl->vif && beacon_loss) - ieee80211_connection_loss(wl->vif); + if (beacon_loss) + wl12xx_for_each_wlvif_sta(wl, wlvif) { + vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_connection_loss(vif); + } return 0; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index fd78f8c..de9a2b6 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -661,6 +661,16 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) #define wl12xx_for_each_wlvif(wl, wlvif) \ list_for_each_entry(wlvif, &wl->wlvif_list, list) +#define wl12xx_for_each_wlvif_bss_type(wl, wlvif, _bss_type) \ + wl12xx_for_each_wlvif(wl, wlvif) \ + if (wlvif->bss_type == _bss_type) + +#define wl12xx_for_each_wlvif_sta(wl, wlvif) \ + wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_STA_BSS) + +#define wl12xx_for_each_wlvif_ap(wl, wlvif) \ + wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_AP_BSS) + int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); int wl1271_recalc_rx_streaming(struct wl1271 *wl); -- cgit v0.10.2 From 48e93e402ad19f570bae323b07911bdf6562af8e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:58 +0200 Subject: wl12xx: move tx_security_seq into wlvif The last security seq num has to be saved across reconfigs. Add a new "persistent" struct into wlvif, which won't get deleted on wl12xx_init_vif_data() Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index bbc8004..669b081 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -346,7 +346,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(tx_results_count); DRIVER_STATE_PRINT_LHEX(flags); DRIVER_STATE_PRINT_INT(tx_blocks_freed); - DRIVER_STATE_PRINT_INT(tx_security_last_seq_lsb); DRIVER_STATE_PRINT_INT(rx_counter); DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b52deac..8d87df5 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1206,6 +1206,7 @@ static void wl1271_recovery_work(struct work_struct *work) { struct wl1271 *wl = container_of(work, struct wl1271, recovery_work); + struct wl12xx_vif *wlvif; mutex_lock(&wl->mutex); @@ -1227,9 +1228,12 @@ static void wl1271_recovery_work(struct work_struct *work) * in the firmware during recovery. This doens't hurt if the network is * not encrypted. */ - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || - test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) - wl->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING; + wl12xx_for_each_wlvif(wl, wlvif) { + if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + wlvif->tx_security_seq += + WL1271_TX_SQN_POST_RECOVERY_PADDING; + } /* Prevent spurious TX during FW restart */ ieee80211_stop_queues(wl->hw); @@ -1910,8 +1914,8 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - /* make sure wlvif is zeroed */ - memset(wlvif, 0, sizeof(*wlvif)); + /* clear everything but the persistent data */ + memset(wlvif, 0, offsetof(struct wl12xx_vif, persistent)); switch (ieee80211_vif_type_p2p(vif)) { case NL80211_IFTYPE_P2P_CLIENT: @@ -2297,8 +2301,8 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; /* reset TX security counters on a clean disconnect */ - wl->tx_security_last_seq_lsb = 0; - wl->tx_security_seq = 0; + wlvif->tx_security_last_seq_lsb = 0; + wlvif->tx_security_seq = 0; out: return ret; @@ -2870,20 +2874,20 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, key_type = KEY_TKIP; key_conf->hw_key_idx = key_conf->keyidx; - tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); - tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); + tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); + tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); break; case WLAN_CIPHER_SUITE_CCMP: key_type = KEY_AES; key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); - tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); + tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); + tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); break; case WL1271_CIPHER_SUITE_GEM: key_type = KEY_GEM; - tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); - tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); + tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); + tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); break; default: wl1271_error("Unknown key algo 0x%x", key_conf->cipher); @@ -4923,8 +4927,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->quirks = 0; wl->platform_quirks = 0; wl->sched_scanning = false; - wl->tx_security_seq = 0; - wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->active_sta_count = 0; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index c7be151..8c35d37 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -755,6 +755,8 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, struct wl1271_tx_hw_res_descr *result) { struct ieee80211_tx_info *info; + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; struct sk_buff *skb; int id = result->id; int rate = -1; @@ -774,6 +776,10 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, return; } + /* info->control is valid as long as we don't update info->status */ + vif = info->control.vif; + wlvif = wl12xx_vif_to_data(vif); + /* update the TX status info */ if (result->status == TX_SUCCESS) { if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) @@ -801,14 +807,14 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP || info->control.hw_key->cipher == WL1271_CIPHER_SUITE_GEM)) { u8 fw_lsb = result->tx_security_sequence_number_lsb; - u8 cur_lsb = wl->tx_security_last_seq_lsb; + u8 cur_lsb = wlvif->tx_security_last_seq_lsb; /* * update security sequence number, taking care of potential * wrap-around */ - wl->tx_security_seq += (fw_lsb - cur_lsb + 256) % 256; - wl->tx_security_last_seq_lsb = fw_lsb; + wlvif->tx_security_seq += (fw_lsb - cur_lsb) & 0xff; + wlvif->tx_security_last_seq_lsb = fw_lsb; } /* remove private header from packet */ diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index de9a2b6..d584885 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -437,17 +437,6 @@ struct wl1271 { struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS]; int tx_frames_cnt; - /* - * Security sequence number - * bits 0-15: lower 16 bits part of sequence number - * bits 16-47: higher 32 bits part of sequence number - * bits 48-63: not in use - */ - u64 tx_security_seq; - - /* 8 bits of the last sequence number in use */ - u8 tx_security_last_seq_lsb; - /* FW Rx counter */ u32 rx_counter; @@ -645,6 +634,25 @@ struct wl12xx_vif { /* RX BA constraint value */ bool ba_support; bool ba_allowed; + + /* + * This struct must be last! + * data that has to be saved acrossed reconfigs (e.g. recovery) + * should be declared in this struct. + */ + struct { + u8 persistent[0]; + /* + * Security sequence number + * bits 0-15: lower 16 bits part of sequence number + * bits 16-47: higher 32 bits part of sequence number + * bits 48-63: not in use + */ + u64 tx_security_seq; + + /* 8 bits of the last sequence number in use */ + u8 tx_security_last_seq_lsb; + }; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v0.10.2 From 9eb599e9c62dcfd4efece1936c385381b366b684 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:59 +0200 Subject: wl12xx: rearm rx streaming per vif Currently, the rx streaming doesn't support multi-vif (the actual wlvif is taken from wl->vif, and the management is global). Make the rx streaming timers/works per-vif, and pass the the actual vif as param. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 5b70cc1..21e74ca 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -1510,10 +1510,9 @@ out: return ret; } -int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable) +int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_acx_ps_rx_streaming *rx_streaming; u32 conf_queues, enable_queues; int i, ret = 0; diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 7fccfcc..c06119b 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1310,7 +1310,8 @@ int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl, int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn, bool enable, u8 peer_hlid); int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); -int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); +int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable); int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 669b081..4abff82 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -505,6 +505,7 @@ static ssize_t rx_streaming_interval_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; unsigned long value; int ret; @@ -528,7 +529,9 @@ static ssize_t rx_streaming_interval_write(struct file *file, if (ret < 0) goto out; - wl1271_recalc_rx_streaming(wl); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_recalc_rx_streaming(wl, wlvif); + } wl1271_ps_elp_sleep(wl); out: @@ -557,6 +560,7 @@ static ssize_t rx_streaming_always_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; unsigned long value; int ret; @@ -580,7 +584,9 @@ static ssize_t rx_streaming_always_write(struct file *file, if (ret < 0) goto out; - wl1271_recalc_rx_streaming(wl); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_recalc_rx_streaming(wl, wlvif); + } wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index dbc40bb..be9e112 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -220,12 +220,12 @@ static void wl12xx_event_soft_gemini_sense(struct wl1271 *wl, } set_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); } else { + clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); wl12xx_for_each_wlvif_sta(wl, wlvif) { vif = wl12xx_wlvif_to_vif(wlvif); ieee80211_enable_dyn_ps(vif); + wl1271_recalc_rx_streaming(wl, wlvif); } - clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); - wl1271_recalc_rx_streaming(wl); } } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8d87df5..5ce01f1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -502,12 +502,13 @@ static int wl1271_reg_notify(struct wiphy *wiphy, return 0; } -static int wl1271_set_rx_streaming(struct wl1271 *wl, bool enable) +static int wl1271_set_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { int ret = 0; /* we should hold wl->mutex */ - ret = wl1271_acx_ps_rx_streaming(wl, enable); + ret = wl1271_acx_ps_rx_streaming(wl, wlvif, enable); if (ret < 0) goto out; @@ -523,7 +524,7 @@ out: * this function is being called when the rx_streaming interval * has beed changed or rx_streaming should be disabled */ -int wl1271_recalc_rx_streaming(struct wl1271 *wl) +int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret = 0; int period = wl->conf.rx_streaming.interval; @@ -537,11 +538,11 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl) test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) && (wl->conf.rx_streaming.always || test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) - ret = wl1271_set_rx_streaming(wl, true); + ret = wl1271_set_rx_streaming(wl, wlvif, true); else { - ret = wl1271_set_rx_streaming(wl, false); + ret = wl1271_set_rx_streaming(wl, wlvif, false); /* don't cancel_work_sync since we might deadlock */ - del_timer_sync(&wl->rx_streaming_timer); + del_timer_sync(&wlvif->rx_streaming_timer); } out: return ret; @@ -550,8 +551,9 @@ out: static void wl1271_rx_streaming_enable_work(struct work_struct *work) { int ret; - struct wl1271 *wl = - container_of(work, struct wl1271, rx_streaming_enable_work); + struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif, + rx_streaming_enable_work); + struct wl1271 *wl = wlvif->wl; mutex_lock(&wl->mutex); @@ -568,12 +570,12 @@ static void wl1271_rx_streaming_enable_work(struct work_struct *work) if (ret < 0) goto out; - ret = wl1271_set_rx_streaming(wl, true); + ret = wl1271_set_rx_streaming(wl, wlvif, true); if (ret < 0) goto out_sleep; /* stop it after some time of inactivity */ - mod_timer(&wl->rx_streaming_timer, + mod_timer(&wlvif->rx_streaming_timer, jiffies + msecs_to_jiffies(wl->conf.rx_streaming.duration)); out_sleep: @@ -585,8 +587,9 @@ out: static void wl1271_rx_streaming_disable_work(struct work_struct *work) { int ret; - struct wl1271 *wl = - container_of(work, struct wl1271, rx_streaming_disable_work); + struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif, + rx_streaming_disable_work); + struct wl1271 *wl = wlvif->wl; mutex_lock(&wl->mutex); @@ -597,7 +600,7 @@ static void wl1271_rx_streaming_disable_work(struct work_struct *work) if (ret < 0) goto out; - ret = wl1271_set_rx_streaming(wl, false); + ret = wl1271_set_rx_streaming(wl, wlvif, false); if (ret) goto out_sleep; @@ -609,8 +612,9 @@ out: static void wl1271_rx_streaming_timer(unsigned long data) { - struct wl1271 *wl = (struct wl1271 *)data; - ieee80211_queue_work(wl->hw, &wl->rx_streaming_disable_work); + struct wl12xx_vif *wlvif = (struct wl12xx_vif *)data; + struct wl1271 *wl = wlvif->wl; + ieee80211_queue_work(wl->hw, &wlvif->rx_streaming_disable_work); } static void wl1271_conf_init(struct wl1271 *wl) @@ -1827,9 +1831,6 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) cancel_delayed_work_sync(&wl->scan_complete_work); cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->tx_work); - del_timer_sync(&wl->rx_streaming_timer); - cancel_work_sync(&wl->rx_streaming_enable_work); - cancel_work_sync(&wl->rx_streaming_disable_work); cancel_delayed_work_sync(&wl->elp_work); /* let's notify MAC80211 about the remaining pending TX frames */ @@ -1960,9 +1961,16 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + INIT_WORK(&wlvif->rx_streaming_enable_work, + wl1271_rx_streaming_enable_work); + INIT_WORK(&wlvif->rx_streaming_disable_work, + wl1271_rx_streaming_disable_work); INIT_DELAYED_WORK(&wlvif->pspoll_work, wl1271_pspoll_work); INIT_LIST_HEAD(&wlvif->list); + setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer, + (unsigned long) wlvif); + return 0; } @@ -2203,6 +2211,9 @@ deinit: wl->sta_count--; mutex_unlock(&wl->mutex); + del_timer_sync(&wlvif->rx_streaming_timer); + cancel_work_sync(&wlvif->rx_streaming_enable_work); + cancel_work_sync(&wlvif->rx_streaming_disable_work); cancel_delayed_work_sync(&wlvif->pspoll_work); mutex_lock(&wl->mutex); @@ -4903,10 +4914,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) INIT_WORK(&wl->tx_work, wl1271_tx_work); INIT_WORK(&wl->recovery_work, wl1271_recovery_work); INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work); - INIT_WORK(&wl->rx_streaming_enable_work, - wl1271_rx_streaming_enable_work); - INIT_WORK(&wl->rx_streaming_disable_work, - wl1271_rx_streaming_disable_work); wl->freezable_wq = create_freezable_workqueue("wl12xx_wq"); if (!wl->freezable_wq) { @@ -4930,8 +4937,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->active_sta_count = 0; - setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, - (unsigned long) wl); wl->fwlog_size = 0; init_waitqueue_head(&wl->fwlog_waitq); diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index 9cfa0b2..dd2f8b7 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -28,6 +28,7 @@ #include "acx.h" #include "reg.h" #include "rx.h" +#include "tx.h" #include "io.h" static u8 wl12xx_rx_get_mem_block(struct wl12xx_fw_status *status, @@ -96,7 +97,7 @@ static void wl1271_rx_status(struct wl1271 *wl, } static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, - bool unaligned) + bool unaligned, u8 *hlid) { struct wl1271_rx_descriptor *desc; struct sk_buff *skb; @@ -159,6 +160,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, * payload aligned to 4 bytes. */ memcpy(buf, data + sizeof(*desc), length - sizeof(*desc)); + *hlid = desc->hlid; hdr = (struct ieee80211_hdr *)skb->data; if (ieee80211_is_beacon(hdr->frame_control)) @@ -169,10 +171,10 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, wl1271_rx_status(wl, desc, IEEE80211_SKB_RXCB(skb), beacon); seq_num = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4; - wl1271_debug(DEBUG_RX, "rx skb 0x%p: %d B %s seq %d", skb, + wl1271_debug(DEBUG_RX, "rx skb 0x%p: %d B %s seq %d hlid %d", skb, skb->len - desc->pad_len, beacon ? "beacon" : "", - seq_num); + seq_num, *hlid); skb_trim(skb, skb->len - desc->pad_len); @@ -185,8 +187,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) { struct wl1271_acx_mem_map *wl_mem_map = wl->target_mem_map; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0}; u32 buf_size; u32 fw_rx_counter = status->fw_rx_counter & NUM_RX_PKT_DESC_MOD_MASK; u32 drv_rx_counter = wl->rx_counter & NUM_RX_PKT_DESC_MOD_MASK; @@ -194,8 +195,7 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) u32 mem_block; u32 pkt_length; u32 pkt_offset; - bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); - bool had_data = false; + u8 hlid; bool unaligned = false; while (drv_rx_counter != fw_rx_counter) { @@ -255,8 +255,11 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) */ if (wl1271_rx_handle_data(wl, wl->aggr_buf + pkt_offset, - pkt_length, unaligned) == 1) - had_data = true; + pkt_length, unaligned, + &hlid) == 1) { + WARN_ON(hlid >= WL12XX_MAX_LINKS); + __set_bit(hlid, active_hlids); + } wl->rx_counter++; drv_rx_counter++; @@ -272,17 +275,5 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) if (wl->quirks & WL12XX_QUIRK_END_OF_TRANSACTION) wl1271_write32(wl, RX_DRIVER_COUNTER_ADDRESS, wl->rx_counter); - if (!is_ap && wl->conf.rx_streaming.interval && had_data && - (wl->conf.rx_streaming.always || - test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { - u32 timeout = wl->conf.rx_streaming.duration; - - /* restart rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - ieee80211_queue_work(wl->hw, - &wl->rx_streaming_enable_work); - - mod_timer(&wl->rx_streaming_timer, - jiffies + msecs_to_jiffies(timeout)); - } + wl12xx_rearm_rx_streaming(wl, active_hlids); } diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8c35d37..a06aa4e 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -643,21 +643,58 @@ static bool wl1271_tx_is_data_present(struct sk_buff *skb) return ieee80211_is_data_present(hdr->frame_control); } +void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids) +{ + struct wl12xx_vif *wlvif; + u32 timeout; + u8 hlid; + + if (!wl->conf.rx_streaming.interval) + return; + + if (!wl->conf.rx_streaming.always && + !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags)) + return; + + timeout = wl->conf.rx_streaming.duration; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + bool found = false; + for_each_set_bit(hlid, active_hlids, WL12XX_MAX_LINKS) { + if (test_bit(hlid, wlvif->links_map)) { + found = true; + break; + } + } + + if (!found) + continue; + + /* enable rx streaming */ + if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + ieee80211_queue_work(wl->hw, + &wlvif->rx_streaming_enable_work); + + mod_timer(&wlvif->rx_streaming_timer, + jiffies + msecs_to_jiffies(timeout)); + } +} + void wl1271_tx_work_locked(struct wl1271 *wl) { struct wl12xx_vif *wlvif; struct sk_buff *skb; + struct wl1271_tx_hw_descr *desc; u32 buf_offset = 0; bool sent_packets = false; - bool had_data = false; - /* TODO: save bitmap of relevant stations */ - bool is_sta = false; + unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0}; int ret; if (unlikely(wl->state == WL1271_STATE_OFF)) return; while ((skb = wl1271_skb_dequeue(wl))) { + bool has_data = false; + wlvif = NULL; if (!wl12xx_is_dummy_packet(wl, skb)) { struct ieee80211_tx_info *info; @@ -667,9 +704,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl) vif = info->control.vif; wlvif = wl12xx_vif_to_data(vif); } - - if (wl1271_tx_is_data_present(skb)) - had_data = true; + has_data = wlvif && wl1271_tx_is_data_present(skb); ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset); if (ret == -EAGAIN) { @@ -698,8 +733,10 @@ void wl1271_tx_work_locked(struct wl1271 *wl) } buf_offset += ret; wl->tx_packets_count++; - if (wlvif && wlvif->bss_type == BSS_TYPE_STA_BSS) - is_sta = true; + if (has_data) { + desc = (struct wl1271_tx_hw_descr *) skb->data; + __set_bit(desc->hlid, active_hlids); + } } out_ack: @@ -719,19 +756,7 @@ out_ack: wl1271_handle_tx_low_watermark(wl); } - if (is_sta && wl->conf.rx_streaming.interval && had_data && - (wl->conf.rx_streaming.always || - test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { - u32 timeout = wl->conf.rx_streaming.duration; - - /* enable rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - ieee80211_queue_work(wl->hw, - &wl->rx_streaming_enable_work); - - mod_timer(&wl->rx_streaming_timer, - jiffies + msecs_to_jiffies(timeout)); - } + wl12xx_rearm_rx_streaming(wl, active_hlids); } void wl1271_tx_work(struct work_struct *work) diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index fe29ff5..2dbb24e 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -220,6 +220,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid); void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); +void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids); /* from main.c */ void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d584885..52d1cd0 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -480,11 +480,6 @@ struct wl1271 { /* The current band */ enum ieee80211_band band; - /* Rx Streaming */ - struct work_struct rx_streaming_enable_work; - struct work_struct rx_streaming_disable_work; - struct timer_list rx_streaming_timer; - struct completion *elp_compl; struct delayed_work elp_work; @@ -635,6 +630,11 @@ struct wl12xx_vif { bool ba_support; bool ba_allowed; + /* Rx Streaming */ + struct work_struct rx_streaming_enable_work; + struct work_struct rx_streaming_disable_work; + struct timer_list rx_streaming_timer; + /* * This struct must be last! * data that has to be saved acrossed reconfigs (e.g. recovery) @@ -681,7 +681,7 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); -int wl1271_recalc_rx_streaming(struct wl1271 *wl); +int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif); void wl12xx_queue_recovery_work(struct wl1271 *wl); size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); -- cgit v0.10.2 From ba8447f64159927baf673d827e404605471d8f68 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:00 +0200 Subject: wl12xx: make WL1271_FLAG_STA_ASSOCIATED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index be9e112..cfb2835 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -52,7 +52,7 @@ void wl1271_pspoll_work(struct work_struct *work) if (!test_and_clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags)) goto out; - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) goto out; /* diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 5ce01f1..d91e8bc 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -400,10 +400,9 @@ static struct platform_device wl1271_device = { static DEFINE_MUTEX(wl_list_mutex); static LIST_HEAD(wl_list); -static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) +static int wl1271_check_operstate(struct wl1271 *wl, struct wl12xx_vif *wlvif, + unsigned char operstate) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; if (operstate != IF_OPER_UP) @@ -430,6 +429,7 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what, struct ieee80211_hw *hw; struct wl1271 *wl; struct wl1271 *wl_temp; + struct wl12xx_vif *wlvif; int ret = 0; /* Check that this notification is for us. */ @@ -463,17 +463,18 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what, if (wl->state == WL1271_STATE_OFF) goto out; - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) - goto out; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) + continue; - wl1271_check_operstate(wl, dev->operstate); + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; - wl1271_ps_elp_sleep(wl); + wl1271_check_operstate(wl, wlvif, dev->operstate); + wl1271_ps_elp_sleep(wl); + } out: mutex_unlock(&wl->mutex); @@ -535,7 +536,7 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif) /* reconfigure/disable according to new streaming_period */ if (period && - test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) && + test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && (wl->conf.rx_streaming.always || test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) ret = wl1271_set_rx_streaming(wl, wlvif, true); @@ -558,7 +559,7 @@ static void wl1271_rx_streaming_enable_work(struct work_struct *work) mutex_lock(&wl->mutex); if (test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags) || - !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || (!wl->conf.rx_streaming.always && !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) goto out; @@ -1233,7 +1234,7 @@ static void wl1271_recovery_work(struct work_struct *work) * not encrypted. */ wl12xx_for_each_wlvif(wl, wlvif) { - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) wlvif->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING; @@ -1609,7 +1610,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, mutex_lock(&wl->mutex); - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) goto out_unlock; ret = wl1271_ps_elp_wakeup(wl); @@ -2253,11 +2254,11 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, * Keep the below message for now, unless it starts bothering * users who really like to roam a lot :) */ - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) wl1271_info("JOIN while associated."); if (set_assoc) - set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags); + set_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags); if (is_ibss) ret = wl12xx_cmd_role_start_ibss(wl, wlvif); @@ -2266,7 +2267,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) goto out; /* @@ -2449,7 +2450,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * possible rate for the band as a fixed rate for * association frames and other control messages. */ - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) wl1271_set_band_rate(wl, wlvif); wlvif->basic_rate = @@ -2460,7 +2461,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wl1271_warning("rate policy for channel " "failed %d", ret); - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, + &wlvif->flags)) { if (wl12xx_is_roc(wl)) { /* roaming */ ret = wl12xx_croc(wl, @@ -2518,7 +2520,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * If we're not, we'll enter it when joining an SSID, * through the bss_info_changed() hook. */ - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { wl1271_debug(DEBUG_PSM, "psm enabled"); ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, @@ -2981,7 +2983,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, /* cancel ROC before scanning */ if (wl12xx_is_roc(wl)) { - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { /* don't allow scanning right now */ ret = -EBUSY; goto out_sleep; @@ -3619,8 +3621,8 @@ sta_not_found: } else { /* use defaults when not associated */ bool was_assoc = - !!test_and_clear_bit(WL1271_FLAG_STA_ASSOCIATED, - &wl->flags); + !!test_and_clear_bit(WLVIF_FLAG_STA_ASSOCIATED, + &wlvif->flags); bool was_ifup = !!test_and_clear_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags); @@ -3749,7 +3751,7 @@ sta_not_found: if (ret < 0) goto out; - wl1271_check_operstate(wl, + wl1271_check_operstate(wl, wlvif, ieee80211_get_operstate(vif)); } /* diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index e1a8ce0..687f59b 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -64,7 +64,7 @@ void wl1271_scan_complete_work(struct work_struct *work) if (ret < 0) goto out; - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { /* restore hardware connection monitoring template */ wl1271_cmd_build_ap_probe_req(wl, wlvif, wlvif->probereq); } @@ -72,7 +72,7 @@ void wl1271_scan_complete_work(struct work_struct *work) /* return to ROC if needed */ is_sta = (wlvif->bss_type == BSS_TYPE_STA_BSS); is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); - if (((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) || + if (((is_sta && !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) || (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index a06aa4e..bbb101b 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -192,7 +192,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_tx_update_filters(wl, wlvif, skb); - if ((test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + if ((test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && !ieee80211_is_auth(hdr->frame_control) && !ieee80211_is_assoc_req(hdr->frame_control)) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 52d1cd0..efb35a6 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -313,7 +313,6 @@ struct wl1271_ap_key { }; enum wl12xx_flags { - WL1271_FLAG_STA_ASSOCIATED, WL1271_FLAG_IBSS_JOINED, WL1271_FLAG_GPIO_POWER, WL1271_FLAG_TX_QUEUE_STOPPED, @@ -338,6 +337,10 @@ enum wl12xx_flags { WL1271_FLAG_CS_PROGRESS, }; +enum wl12xx_vif_flags { + WLVIF_FLAG_STA_ASSOCIATED, +}; + struct wl1271_link { /* AP-mode - TX queue per AC in link */ struct sk_buff_head tx_queue[NUM_TX_QUEUES]; @@ -553,6 +556,7 @@ struct wl1271_station { struct wl12xx_vif { struct wl1271 *wl; struct list_head list; + unsigned long flags; u8 bss_type; u8 p2p; /* we are using p2p role */ u8 role_id; -- cgit v0.10.2 From eee514e3d6cecc7abdf1b27734169004fefb0941 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:01 +0200 Subject: wl12xx: make WL1271_FLAG_IBSS_JOINED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index d91e8bc..ac5be73 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3494,11 +3494,11 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (changed & BSS_CHANGED_IBSS) { if (bss_conf->ibss_joined) { - set_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags); + set_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags); ibss_joined = true; } else { - if (test_and_clear_bit(WL1271_FLAG_IBSS_JOINED, - &wl->flags)) { + if (test_and_clear_bit(WLVIF_FLAG_IBSS_JOINED, + &wlvif->flags)) { wl1271_unjoin(wl, wlvif); wl12xx_cmd_role_start_dev(wl, wlvif); wl12xx_roc(wl, wlvif->dev_role_id); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 687f59b..765f08b 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -73,7 +73,7 @@ void wl1271_scan_complete_work(struct work_struct *work) is_sta = (wlvif->bss_type == BSS_TYPE_STA_BSS); is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); if (((is_sta && !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) || - (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && + (is_ibss && !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags))) && !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ wl12xx_cmd_role_start_dev(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index bbb101b..8965fd1 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -193,7 +193,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_tx_update_filters(wl, wlvif, skb); if ((test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || - test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && + test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) && !ieee80211_is_auth(hdr->frame_control) && !ieee80211_is_assoc_req(hdr->frame_control)) return wlvif->sta.hlid; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index efb35a6..489c205 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -313,7 +313,6 @@ struct wl1271_ap_key { }; enum wl12xx_flags { - WL1271_FLAG_IBSS_JOINED, WL1271_FLAG_GPIO_POWER, WL1271_FLAG_TX_QUEUE_STOPPED, WL1271_FLAG_TX_PENDING, @@ -339,6 +338,7 @@ enum wl12xx_flags { enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, + WLVIF_FLAG_IBSS_JOINED, }; struct wl1271_link { -- cgit v0.10.2 From 53d40d0b863e22b697f8d85e1f95cb6f9d2d95b1 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:02 +0200 Subject: wl12xx: make WL1271_FLAG_AP_STARTED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index ac5be73..41cc5fe 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1235,7 +1235,7 @@ static void wl1271_recovery_work(struct work_struct *work) */ wl12xx_for_each_wlvif(wl, wlvif) { if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || - test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) wlvif->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING; } @@ -1662,7 +1662,7 @@ static int wl1271_configure_suspend_ap(struct wl1271 *wl, mutex_lock(&wl->mutex); - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) goto out_unlock; ret = wl1271_ps_elp_wakeup(wl); @@ -2768,7 +2768,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, hlid = wlvif->ap.bcast_hlid; } - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { /* * We do not support removing keys after AP shutdown. * Pretend we do to make mac80211 happy. @@ -3426,7 +3426,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if ((changed & BSS_CHANGED_BEACON_ENABLED)) { if (bss_conf->enable_beacon) { - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { ret = wl12xx_cmd_role_start_ap(wl, wlvif); if (ret < 0) goto out; @@ -3435,16 +3435,16 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if (ret < 0) goto out; - set_bit(WL1271_FLAG_AP_STARTED, &wl->flags); + set_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); wl1271_debug(DEBUG_AP, "started AP"); } } else { - if (test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { ret = wl12xx_cmd_role_stop_ap(wl, wlvif); if (ret < 0) goto out; - clear_bit(WL1271_FLAG_AP_STARTED, &wl->flags); + clear_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); wl1271_debug(DEBUG_AP, "stopped AP"); } } diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8965fd1..a60d8fe 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -168,7 +168,7 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, } else { struct ieee80211_hdr *hdr; - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) return wl->system_hlid; hdr = (struct ieee80211_hdr *)skb->data; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 489c205..9b28e47 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -325,7 +325,6 @@ enum wl12xx_flags { WL1271_FLAG_PSPOLL_FAILURE, WL1271_FLAG_STA_STATE_SENT, WL1271_FLAG_FW_TX_BUSY, - WL1271_FLAG_AP_STARTED, WL1271_FLAG_IF_INITIALIZED, WL1271_FLAG_DUMMY_PACKET_PENDING, WL1271_FLAG_SUSPENDED, @@ -339,6 +338,7 @@ enum wl12xx_flags { enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, + WLVIF_FLAG_AP_STARTED, }; struct wl1271_link { -- cgit v0.10.2 From c29bb001e448ef57e077db9f1c5ae864e3f8abab Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:03 +0200 Subject: wl12xx: make WL1271_FLAG_PSM flag per-vif move WL1271_FLAG_PSM and WL1271_FLAG_PSM_REQUESTED into per-vif flags. These flags should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index cfb2835..d8b183b 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -84,7 +84,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, "trying to work around it."); /* force active mode receive data from the AP */ - if (test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); if (ret < 0) @@ -116,7 +116,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, case EVENT_ENTER_POWER_SAVE_FAIL: wl1271_debug(DEBUG_PSM, "PSM entry failed"); - if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { /* remain in active mode */ wlvif->psm_entry_retry = 0; break; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 41cc5fe..2fe0ee1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1618,7 +1618,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, goto out_unlock; /* enter psm if needed*/ - if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { DECLARE_COMPLETION_ONSTACK(compl); wlvif->ps_compl = &compl; @@ -1705,7 +1705,7 @@ static void wl1271_configure_resume(struct wl1271 *wl, if (is_sta) { /* exit psm if it wasn't configured */ - if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); } else if (is_ap) { @@ -2512,8 +2512,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); if (conf->flags & IEEE80211_CONF_PS && - !test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { - set_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags); + !test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { + set_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags); /* * We enter PSM only if we're already associated. @@ -2527,12 +2527,12 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wlvif->basic_rate, true); } } else if (!(conf->flags & IEEE80211_CONF_PS) && - test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { + test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { wl1271_debug(DEBUG_PSM, "psm disabled"); - clear_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags); + clear_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags); - if (test_bit(WL1271_FLAG_PSM, &wl->flags)) + if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); @@ -3769,8 +3769,8 @@ sta_not_found: } /* If we want to go in PSM but we're not there yet */ - if (test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags) && - !test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags) && + !test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { enum wl1271_cmd_ps_mode mode; mode = STATION_POWER_SAVE_MODE; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index ac3f207..8cd81ce 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -32,6 +32,7 @@ void wl1271_elp_work(struct work_struct *work) { struct delayed_work *dwork; struct wl1271 *wl; + struct wl12xx_vif *wlvif; dwork = container_of(work, struct delayed_work, work); wl = container_of(dwork, struct wl1271, elp_work); @@ -47,11 +48,15 @@ void wl1271_elp_work(struct work_struct *work) if (unlikely(!test_bit(WL1271_FLAG_ELP_REQUESTED, &wl->flags))) goto out; - if (test_bit(WL1271_FLAG_IN_ELP, &wl->flags) || - (!test_bit(WL1271_FLAG_PSM, &wl->flags) && - !test_bit(WL1271_FLAG_IDLE, &wl->flags))) + if (test_bit(WL1271_FLAG_IN_ELP, &wl->flags)) goto out; + wl12xx_for_each_wlvif(wl, wlvif) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) && + !test_bit(WL1271_FLAG_IDLE, &wl->flags)) + goto out; + } + wl1271_debug(DEBUG_PSM, "chip to elp"); wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); set_bit(WL1271_FLAG_IN_ELP, &wl->flags); @@ -65,13 +70,17 @@ out: /* Routines to toggle sleep mode while in ELP */ void wl1271_ps_elp_sleep(struct wl1271 *wl) { + struct wl12xx_vif *wlvif; + /* we shouldn't get consecutive sleep requests */ if (WARN_ON(test_and_set_bit(WL1271_FLAG_ELP_REQUESTED, &wl->flags))) return; - if (!test_bit(WL1271_FLAG_PSM, &wl->flags) && - !test_bit(WL1271_FLAG_IDLE, &wl->flags)) - return; + wl12xx_for_each_wlvif(wl, wlvif) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) && + !test_bit(WL1271_FLAG_IDLE, &wl->flags)) + return; + } ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, msecs_to_jiffies(ELP_ENTRY_DELAY)); @@ -162,7 +171,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - set_bit(WL1271_FLAG_PSM, &wl->flags); + set_bit(WLVIF_FLAG_PSM, &wlvif->flags); break; case STATION_ACTIVE_MODE: default: @@ -184,7 +193,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - clear_bit(WL1271_FLAG_PSM, &wl->flags); + clear_bit(WLVIF_FLAG_PSM, &wlvif->flags); break; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9b28e47..ea6b729 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -318,8 +318,6 @@ enum wl12xx_flags { WL1271_FLAG_TX_PENDING, WL1271_FLAG_IN_ELP, WL1271_FLAG_ELP_REQUESTED, - WL1271_FLAG_PSM, - WL1271_FLAG_PSM_REQUESTED, WL1271_FLAG_IRQ_RUNNING, WL1271_FLAG_IDLE, WL1271_FLAG_PSPOLL_FAILURE, @@ -339,6 +337,8 @@ enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, WLVIF_FLAG_AP_STARTED, + WLVIF_FLAG_PSM, + WLVIF_FLAG_PSM_REQUESTED, }; struct wl1271_link { -- cgit v0.10.2 From 8181aecce9ea3731ff5554c6f9cf16bf249a61fa Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:04 +0200 Subject: wl12xx: make WL1271_FLAG_STA_STATE_SENT flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 2fe0ee1..63340ad 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -408,7 +408,7 @@ static int wl1271_check_operstate(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (operstate != IF_OPER_UP) return 0; - if (test_and_set_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags)) + if (test_and_set_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags)) return 0; ret = wl12xx_cmd_set_peer_state(wl, wlvif->sta.hlid); @@ -3624,8 +3624,8 @@ sta_not_found: !!test_and_clear_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags); bool was_ifup = - !!test_and_clear_bit(WL1271_FLAG_STA_STATE_SENT, - &wl->flags); + !!test_and_clear_bit(WLVIF_FLAG_STA_STATE_SENT, + &wlvif->flags); wlvif->aid = 0; /* free probe-request template */ diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index ea6b729..9de57dd 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -321,7 +321,6 @@ enum wl12xx_flags { WL1271_FLAG_IRQ_RUNNING, WL1271_FLAG_IDLE, WL1271_FLAG_PSPOLL_FAILURE, - WL1271_FLAG_STA_STATE_SENT, WL1271_FLAG_FW_TX_BUSY, WL1271_FLAG_IF_INITIALIZED, WL1271_FLAG_DUMMY_PACKET_PENDING, @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_AP_STARTED, WLVIF_FLAG_PSM, WLVIF_FLAG_PSM_REQUESTED, + WLVIF_FLAG_STA_STATE_SENT, }; struct wl1271_link { -- cgit v0.10.2 From 0744bdb60b51dce54553d5af9a6133f1fe419032 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:05 +0200 Subject: wl12xx: make WL1271_FLAG_RX_STREAMING_STARTED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 63340ad..9042445 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -514,9 +514,9 @@ static int wl1271_set_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, goto out; if (enable) - set_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags); + set_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags); else - clear_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags); + clear_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags); out: return ret; } @@ -531,7 +531,7 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif) int period = wl->conf.rx_streaming.interval; /* don't reconfigure if rx_streaming is disabled */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) goto out; /* reconfigure/disable according to new streaming_period */ @@ -558,7 +558,7 @@ static void wl1271_rx_streaming_enable_work(struct work_struct *work) mutex_lock(&wl->mutex); - if (test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags) || + if (test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags) || !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || (!wl->conf.rx_streaming.always && !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) @@ -594,7 +594,7 @@ static void wl1271_rx_streaming_disable_work(struct work_struct *work) mutex_lock(&wl->mutex); - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) goto out; ret = wl1271_ps_elp_wakeup(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index a60d8fe..3cf7166 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -670,7 +670,7 @@ void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids) continue; /* enable rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) ieee80211_queue_work(wl->hw, &wlvif->rx_streaming_enable_work); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9de57dd..5b5c930 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -327,7 +327,6 @@ enum wl12xx_flags { WL1271_FLAG_SUSPENDED, WL1271_FLAG_PENDING_WORK, WL1271_FLAG_SOFT_GEMINI, - WL1271_FLAG_RX_STREAMING_STARTED, WL1271_FLAG_RECOVERY_IN_PROGRESS, WL1271_FLAG_CS_PROGRESS, }; @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_PSM, WLVIF_FLAG_PSM_REQUESTED, WLVIF_FLAG_STA_STATE_SENT, + WLVIF_FLAG_RX_STREAMING_STARTED, }; struct wl1271_link { -- cgit v0.10.2 From 10c8cd01e329b2973eddddafe67ae499eef83b19 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:06 +0200 Subject: wl12xx: make WL1271_FLAG_IF_INITIALIZED per-vif Make the initialization flag per-vif, and add some checks for it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 9042445..fb5951c 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1817,14 +1817,20 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); - mutex_lock(&wl_list_mutex); - list_del(&wl->list); - + mutex_lock(&wl->mutex); + if (wl->state == WL1271_STATE_OFF) { + mutex_unlock(&wl->mutex); + return; + } /* * this must be before the cancel_work calls below, so that the work * functions don't perform further work. */ wl->state = WL1271_STATE_OFF; + mutex_unlock(&wl->mutex); + + mutex_lock(&wl_list_mutex); + list_del(&wl->list); mutex_unlock(&wl_list_mutex); wl1271_disable_interrupts(wl); @@ -1971,7 +1977,6 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wlvif); - return 0; } @@ -2069,7 +2074,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, * get here before __wl1271_op_remove_interface is complete, so * opt out if that is the case. */ - if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) { + if (test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags) || + test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) { ret = -EBUSY; goto out; } @@ -2129,7 +2135,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wl->vif = vif; list_add(&wlvif->list, &wl->wlvif_list); - set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); + set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags); if (wlvif->bss_type == BSS_TYPE_AP_BSS) wl->ap_count++; @@ -2155,6 +2161,9 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); + if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) + return; + /* because of hardware recovery, we may get here twice */ if (wl->state != WL1271_STATE_ON) return; @@ -2224,8 +2233,14 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); mutex_lock(&wl->mutex); + + if (wl->state == WL1271_STATE_OFF || + !test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) + goto out; + /* * wl->vif can be null here if someone shuts down the interface * just when hardware recovery has been started. @@ -2234,7 +2249,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, WARN_ON(wl->vif != vif); __wl1271_op_remove_interface(wl, vif, true); } - +out: mutex_unlock(&wl->mutex); cancel_work_sync(&wl->recovery_work); } @@ -3843,6 +3858,9 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw, if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; + if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))) + goto out; + ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 5b5c930..740a9b1 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -322,7 +322,6 @@ enum wl12xx_flags { WL1271_FLAG_IDLE, WL1271_FLAG_PSPOLL_FAILURE, WL1271_FLAG_FW_TX_BUSY, - WL1271_FLAG_IF_INITIALIZED, WL1271_FLAG_DUMMY_PACKET_PENDING, WL1271_FLAG_SUSPENDED, WL1271_FLAG_PENDING_WORK, @@ -332,6 +331,7 @@ enum wl12xx_flags { }; enum wl12xx_vif_flags { + WLVIF_FLAG_INITIALIZED, WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, WLVIF_FLAG_AP_STARTED, -- cgit v0.10.2 From 836d6600ea0e785fcf8159a3c4b7350276bcd49a Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:07 +0200 Subject: wl12xx: make WL1271_FLAG_PSPOLL_FAILURE flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index d8b183b..1f60a1f 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -49,7 +49,7 @@ void wl1271_pspoll_work(struct work_struct *work) if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; - if (!test_and_clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags)) + if (!test_and_clear_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags)) goto out; if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) @@ -89,7 +89,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, wlvif->basic_rate, true); if (ret < 0) return; - set_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); + set_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags); ieee80211_queue_delayed_work(wl->hw, &wlvif->pspoll_work, msecs_to_jiffies(delay)); } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index fb5951c..73973b4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2524,7 +2524,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * incorrectly changed after the pspoll failure active window. */ if (changed & IEEE80211_CONF_CHANGE_PS) - clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); + clear_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags); if (conf->flags & IEEE80211_CONF_PS && !test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 740a9b1..bf410f8 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -320,7 +320,6 @@ enum wl12xx_flags { WL1271_FLAG_ELP_REQUESTED, WL1271_FLAG_IRQ_RUNNING, WL1271_FLAG_IDLE, - WL1271_FLAG_PSPOLL_FAILURE, WL1271_FLAG_FW_TX_BUSY, WL1271_FLAG_DUMMY_PACKET_PENDING, WL1271_FLAG_SUSPENDED, @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_PSM_REQUESTED, WLVIF_FLAG_STA_STATE_SENT, WLVIF_FLAG_RX_STREAMING_STARTED, + WLVIF_FLAG_PSPOLL_FAILURE, }; struct wl1271_link { -- cgit v0.10.2 From 52630c5d89840bf09826fe89cc15f868e92223ef Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:08 +0200 Subject: wl12xx: make WL1271_FLAG_CS_PROGRESS flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 1f60a1f..a47312d 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -345,16 +345,18 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) * 1) channel switch complete with status=0 * 2) channel switch failed status=1 */ - if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags)) { - /* TODO: configure only the relevant vif */ - wl12xx_for_each_wlvif_sta(wl, wlvif) { - struct ieee80211_vif *vif = - wl12xx_wlvif_to_vif(wlvif); - bool success = mbox->channel_switch_status ? - false : true; - - ieee80211_chswitch_done(vif, success); - } + + /* TODO: configure only the relevant vif */ + wl12xx_for_each_wlvif_sta(wl, wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + bool success; + + if (!test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, + &wl->flags)) + continue; + + success = mbox->channel_switch_status ? false : true; + ieee80211_chswitch_done(vif, success); } } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 73973b4..0647d46 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2317,7 +2317,7 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags)) { + if (test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) { wl12xx_cmd_stop_channel_switch(wl); ieee80211_chswitch_done(wl->vif, false); } @@ -4275,6 +4275,7 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif; int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 channel switch"); @@ -4291,10 +4292,13 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, if (ret < 0) goto out; - ret = wl12xx_cmd_channel_switch(wl, ch_switch); + /* TODO: change mac80211 to pass vif as param */ + wl12xx_for_each_wlvif_sta(wl, wlvif) { + ret = wl12xx_cmd_channel_switch(wl, ch_switch); - if (!ret) - set_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags); + if (!ret) + set_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags); + } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index bf410f8..fc8c975 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -326,7 +326,6 @@ enum wl12xx_flags { WL1271_FLAG_PENDING_WORK, WL1271_FLAG_SOFT_GEMINI, WL1271_FLAG_RECOVERY_IN_PROGRESS, - WL1271_FLAG_CS_PROGRESS, }; enum wl12xx_vif_flags { @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_STA_STATE_SENT, WLVIF_FLAG_RX_STREAMING_STARTED, WLVIF_FLAG_PSPOLL_FAILURE, + WLVIF_FLAG_CS_PROGRESS, }; struct wl1271_link { -- cgit v0.10.2 From 1b92f15ee0e0f06222d4fd36dc36960d217243b3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:09 +0200 Subject: wl12xx: add band field to wlvif add band field into the per-interface data. mac80211 configures some values (e.g. band, channel) globally, while we configure them per-interface. In order to make it easier to keep track of the configured value for each value while keeping sync with mac80211, save these values both globally and per-vif. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index ff653e8..6cf8cdc 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -481,7 +481,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start dev %d", wlvif->dev_role_id); cmd->role_id = wlvif->dev_role_id; - if (wl->band == IEEE80211_BAND_5GHZ) + if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -571,7 +571,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start sta %d", wlvif->role_id); cmd->role_id = wlvif->role_id; - if (wl->band == IEEE80211_BAND_5GHZ) + if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); @@ -704,7 +704,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ap.local_rates = cpu_to_le32(0xffffffff); - switch (wl->band) { + switch (wlvif->band) { case IEEE80211_BAND_2GHZ: cmd->band = RADIO_BAND_2_4GHZ; break; @@ -712,7 +712,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = RADIO_BAND_5GHZ; break; default: - wl1271_warning("ap start - unknown band: %d", (int)wl->band); + wl1271_warning("ap start - unknown band: %d", (int)wlvif->band); cmd->band = RADIO_BAND_2_4GHZ; break; } @@ -785,7 +785,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start ibss %d", wlvif->role_id); cmd->role_id = wlvif->role_id; - if (wl->band == IEEE80211_BAND_5GHZ) + if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); @@ -1157,8 +1157,8 @@ struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, wl1271_dump(DEBUG_SCAN, "AP PROBE REQ: ", skb->data, skb->len); - rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wl->band]); - if (wl->band == IEEE80211_BAND_2GHZ) + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wlvif->band]); + if (wlvif->band == IEEE80211_BAND_2GHZ) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); else @@ -1428,7 +1428,8 @@ out: return ret; } -int wl12xx_cmd_add_peer(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid) +int wl12xx_cmd_add_peer(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta, u8 hlid) { struct wl12xx_cmd_add_peer *cmd; int i, ret; @@ -1455,13 +1456,13 @@ int wl12xx_cmd_add_peer(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid) else cmd->psd_type[i] = WL1271_PSD_LEGACY; - sta_rates = sta->supp_rates[wl->band]; + sta_rates = sta->supp_rates[wlvif->band]; if (sta->ht_cap.ht_supported) sta_rates |= sta->ht_cap.mcs.rx_mask[0] << HW_HT_RATES_OFFSET; cmd->supported_rates = cpu_to_le32(wl1271_tx_enabled_rates_get(wl, sta_rates, - wl->band)); + wlvif->band)); wl1271_debug(DEBUG_CMD, "new peer rates=0x%x queues=0x%x", cmd->supported_rates, sta->uapsd_queues); @@ -1601,7 +1602,8 @@ out: return ret; } -static int wl12xx_cmd_roc(struct wl1271 *wl, u8 role_id) +static int wl12xx_cmd_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 role_id) { struct wl12xx_cmd_roc *cmd; int ret = 0; @@ -1619,7 +1621,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, u8 role_id) cmd->role_id = role_id; cmd->channel = wl->channel; - switch (wl->band) { + switch (wlvif->band) { case IEEE80211_BAND_2GHZ: cmd->band = RADIO_BAND_2_4GHZ; break; @@ -1627,7 +1629,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, u8 role_id) cmd->band = RADIO_BAND_5GHZ; break; default: - wl1271_error("roc - unknown band: %d", (int)wl->band); + wl1271_error("roc - unknown band: %d", (int)wlvif->band); ret = -EINVAL; goto out_free; } @@ -1674,14 +1676,14 @@ out: return ret; } -int wl12xx_roc(struct wl1271 *wl, u8 role_id) +int wl12xx_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 role_id) { int ret = 0; if (WARN_ON(test_bit(role_id, wl->roc_map))) return 0; - ret = wl12xx_cmd_roc(wl, role_id); + ret = wl12xx_cmd_roc(wl, wlvif, role_id); if (ret < 0) goto out; diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 8182cf1..968d5bd 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -80,9 +80,10 @@ int wl1271_cmd_set_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, u16 tx_seq_16); int wl12xx_cmd_set_peer_state(struct wl1271 *wl, u8 hlid); -int wl12xx_roc(struct wl1271 *wl, u8 role_id); +int wl12xx_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 role_id); int wl12xx_croc(struct wl1271 *wl, u8 role_id); -int wl12xx_cmd_add_peer(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid); +int wl12xx_cmd_add_peer(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta, u8 hlid); int wl12xx_cmd_remove_peer(struct wl1271 *wl, u8 hlid); int wl12xx_cmd_config_fwlog(struct wl1271 *wl); int wl12xx_cmd_start_fwlog(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index a47312d..fd2e7b2 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -145,7 +145,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, * BET has only a minor effect in 5GHz and masks * channel switch IEs, so we only enable BET on 2.4GHz */ - if (wl->band == IEEE80211_BAND_2GHZ) + if (wlvif->band == IEEE80211_BAND_2GHZ) /* enable beacon early termination */ ret = wl1271_acx_bet_enable(wl, wlvif, true); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0647d46..8e395f1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1968,6 +1968,12 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + /* + * mac80211 configures some values globally, while we treat them + * per-interface. thus, on init, we have to copy them from wl + */ + wlvif->band = wl->band; + INIT_WORK(&wlvif->rx_streaming_enable_work, wl1271_rx_streaming_enable_work); INIT_WORK(&wlvif->rx_streaming_disable_work, @@ -2337,7 +2343,7 @@ out: static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - wlvif->basic_rate_set = wlvif->bitrate_masks[wl->band]; + wlvif->basic_rate_set = wlvif->bitrate_masks[wlvif->band]; wlvif->rate_set = wlvif->basic_rate_set; } @@ -2390,7 +2396,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl12xx_roc(wl, wlvif->dev_role_id); + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); if (ret < 0) goto out; clear_bit(WL1271_FLAG_IDLE, &wl->flags); @@ -2451,11 +2457,12 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) /* if the channel changes while joined, join again */ if (changed & IEEE80211_CONF_CHANGE_CHANNEL && - ((wl->band != conf->channel->band) || + ((wlvif->band != conf->channel->band) || (wl->channel != channel))) { /* send all pending packets */ wl1271_tx_work_locked(wl); wl->band = conf->channel->band; + wlvif->band = conf->channel->band; wl->channel = channel; if (!is_ap) { @@ -2502,7 +2509,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (ret < 0) goto out_sleep; - ret = wl12xx_roc(wl, + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); if (ret < 0) wl1271_warning("roc failed %d", @@ -3420,7 +3427,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, u32 rates = bss_conf->basic_rates; wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, - wl->band); + wlvif->band); wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3516,7 +3523,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, &wlvif->flags)) { wl1271_unjoin(wl, wlvif); wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif->dev_role_id); + wl12xx_roc(wl, wlvif, wlvif->dev_role_id); } } } @@ -3595,7 +3602,7 @@ sta_not_found: rates = bss_conf->basic_rates; wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, - wl->band); + wlvif->band); wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3603,7 +3610,7 @@ sta_not_found: wlvif->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rate_set, - wl->band); + wlvif->band); ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; @@ -3694,7 +3701,8 @@ sta_not_found: wl1271_unjoin(wl, wlvif); if (!(conf_flags & IEEE80211_CONF_IDLE)) { wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif->dev_role_id); + wl12xx_roc(wl, wlvif, + wlvif->dev_role_id); } } } @@ -3708,7 +3716,7 @@ sta_not_found: u32 rates = bss_conf->basic_rates; wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, - wl->band); + wlvif->band); wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3762,7 +3770,7 @@ sta_not_found: /* ROC until connected (after EAPOL exchange) */ if (!is_ibss) { - ret = wl12xx_roc(wl, wlvif->role_id); + ret = wl12xx_roc(wl, wlvif, wlvif->role_id); if (ret < 0) goto out; @@ -4068,7 +4076,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, if (ret < 0) goto out_free_sta; - ret = wl12xx_cmd_add_peer(wl, sta, hlid); + ret = wl12xx_cmd_add_peer(wl, wlvif, sta, hlid); if (ret < 0) goto out_sleep; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 8cd81ce..8153408 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -178,7 +178,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_debug(DEBUG_PSM, "leaving psm"); /* disable beacon early termination */ - if (wl->band == IEEE80211_BAND_2GHZ) { + if (wlvif->band == IEEE80211_BAND_2GHZ) { ret = wl1271_acx_bet_enable(wl, wlvif, false); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 765f08b..2711438 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -77,7 +77,7 @@ void wl1271_scan_complete_work(struct work_struct *work) !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif->dev_role_id); + wl12xx_roc(wl, wlvif, wlvif->dev_role_id); } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 3cf7166..604913f 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -102,7 +102,7 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, if (ret < 0) goto out; - ret = wl12xx_roc(wl, wlvif->dev_role_id); + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); if (ret < 0) goto out; out: @@ -809,7 +809,8 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, if (result->status == TX_SUCCESS) { if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) info->flags |= IEEE80211_TX_STAT_ACK; - rate = wl1271_rate_to_idx(result->rate_class_index, wl->band); + rate = wl1271_rate_to_idx(result->rate_class_index, + wlvif->band); retries = result->ack_failures; } else if (result->status == TX_RETRY_EXCEEDED) { wl->stats.excessive_retries++; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index fc8c975..a689ad0 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -591,6 +591,9 @@ struct wl12xx_vif { u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; + /* The current band */ + enum ieee80211_band band; + u32 bitrate_masks[IEEE80211_NUM_BANDS]; u32 basic_rate_set; -- cgit v0.10.2 From 61f845f4f441a90e5328a78c6c4e0646d99fc2f0 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:10 +0200 Subject: wl12xx: add channel field to wlvif add channel into the per-interface data. mac80211 configures some values (e.g. band, channel) globally, while we configure them per-interface. In order to make it easier to keep track of the configured value for each value while keeping sync with mac80211, save these values both globally and per-vif. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 6cf8cdc..4c5c518 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -483,7 +483,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->role_id = wlvif->dev_role_id; if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) { ret = wl12xx_allocate_link(wl, wlvif, &wlvif->dev_hlid); @@ -573,7 +573,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->role_id = wlvif->role_id; if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->sta.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; @@ -689,7 +689,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ap.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; if (!bss_conf->hidden_ssid) { /* take the SSID from the beacon for backward compatibility */ @@ -787,7 +787,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->role_id = wlvif->role_id; if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ibss.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; @@ -1608,7 +1608,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct wl12xx_cmd_roc *cmd; int ret = 0; - wl1271_debug(DEBUG_CMD, "cmd roc %d (%d)", wl->channel, role_id); + wl1271_debug(DEBUG_CMD, "cmd roc %d (%d)", wlvif->channel, role_id); if (WARN_ON(role_id == WL12XX_INVALID_ROLE_ID)) return -EINVAL; @@ -1620,7 +1620,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, } cmd->role_id = role_id; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; switch (wlvif->band) { case IEEE80211_BAND_2GHZ: cmd->band = RADIO_BAND_2_4GHZ; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8e395f1..5137275 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1973,6 +1973,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) * per-interface. thus, on init, we have to copy them from wl */ wlvif->band = wl->band; + wlvif->channel = wl->channel; INIT_WORK(&wlvif->rx_streaming_enable_work, wl1271_rx_streaming_enable_work); @@ -2458,12 +2459,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) /* if the channel changes while joined, join again */ if (changed & IEEE80211_CONF_CHANGE_CHANNEL && ((wlvif->band != conf->channel->band) || - (wl->channel != channel))) { + (wlvif->channel != channel))) { /* send all pending packets */ wl1271_tx_work_locked(wl); wl->band = conf->channel->band; - wlvif->band = conf->channel->band; wl->channel = channel; + wlvif->band = conf->channel->band; + wlvif->channel = channel; if (!is_ap) { /* diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index a689ad0..02dedd1 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -593,6 +593,7 @@ struct wl12xx_vif { /* The current band */ enum ieee80211_band band; + int channel; u32 bitrate_masks[IEEE80211_NUM_BANDS]; u32 basic_rate_set; -- cgit v0.10.2 From 6bd650299046f00df6d7374c7f61c5afe6df6696 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:11 +0200 Subject: wl12xx: add power_level field to wlvif move power_level into the per-interface data. mac80211 configures some values (e.g. band, channel) globally, while we configure them per-interface. In order to make it easier to keep track of the configured value for each value while keeping sync with mac80211, save these values both globally and per-vif. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 4af7e2f..74f5690 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -554,7 +554,7 @@ static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) return ret; /* initialize Tx power */ - ret = wl1271_acx_tx_power(wl, wlvif, wl->power_level); + ret = wl1271_acx_tx_power(wl, wlvif, wlvif->power_level); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 5137275..cffb40b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1974,6 +1974,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) */ wlvif->band = wl->band; wlvif->channel = wl->channel; + wlvif->power_level = wl->power_level; INIT_WORK(&wlvif->rx_streaming_enable_work, wl1271_rx_streaming_enable_work); @@ -2562,12 +2563,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wlvif->basic_rate, true); } - if (conf->power_level != wl->power_level) { + if (conf->power_level != wlvif->power_level) { ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); if (ret < 0) goto out_sleep; wl->power_level = conf->power_level; + wlvif->power_level = conf->power_level; } out_sleep: diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 02dedd1..2689522 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -631,6 +631,9 @@ struct wl12xx_vif { /* retry counter for PSM entries */ u8 psm_entry_retry; + /* in dBm */ + int power_level; + int rssi_thold; int last_rssi_event; -- cgit v0.10.2 From 9f259c4e5e42d5f0c25675dc1088cd96dc81a9f1 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:12 +0200 Subject: wl12xx: make op_config configure all vifs When mac80211 changes a global (hw) config, iterate through all the relevant vifs and update them. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index cffb40b..b2640ed 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2408,63 +2408,20 @@ out: return ret; } -static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) +static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct ieee80211_conf *conf, u32 changed) { - struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: reconfig all vifs */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - struct ieee80211_conf *conf = &hw->conf; - int channel, ret = 0; - bool is_ap; + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); + int channel, ret; channel = ieee80211_frequency_to_channel(conf->channel->center_freq); - wl1271_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d %s" - " changed 0x%x", - channel, - conf->flags & IEEE80211_CONF_PS ? "on" : "off", - conf->power_level, - conf->flags & IEEE80211_CONF_IDLE ? "idle" : "in use", - changed); - - /* - * mac80211 will go to idle nearly immediately after transmitting some - * frames, such as the deauth. To make sure those frames reach the air, - * wait here until the TX queue is fully flushed. - */ - if ((changed & IEEE80211_CONF_CHANGE_IDLE) && - (conf->flags & IEEE80211_CONF_IDLE)) - wl1271_tx_flush(wl); - - mutex_lock(&wl->mutex); - - if (unlikely(wl->state == WL1271_STATE_OFF)) { - /* we support configuring the channel and band while off */ - if ((changed & IEEE80211_CONF_CHANGE_CHANNEL)) { - wl->band = conf->channel->band; - wl->channel = channel; - } - - if ((changed & IEEE80211_CONF_CHANGE_POWER)) - wl->power_level = conf->power_level; - - goto out; - } - - is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - /* if the channel changes while joined, join again */ if (changed & IEEE80211_CONF_CHANGE_CHANNEL && ((wlvif->band != conf->channel->band) || (wlvif->channel != channel))) { /* send all pending packets */ wl1271_tx_work_locked(wl); - wl->band = conf->channel->band; - wl->channel = channel; wlvif->band = conf->channel->band; wlvif->channel = channel; @@ -2493,7 +2450,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) - goto out_sleep; + return ret; } ret = wl1271_join(wl, wlvif, false); if (ret < 0) @@ -2510,7 +2467,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) - goto out_sleep; + return ret; ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); @@ -2566,12 +2523,65 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (conf->power_level != wlvif->power_level) { ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); if (ret < 0) - goto out_sleep; + return ret; - wl->power_level = conf->power_level; wlvif->power_level = conf->power_level; } + return 0; +} + +static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) +{ + struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif; + struct ieee80211_conf *conf = &hw->conf; + int channel, ret = 0; + + channel = ieee80211_frequency_to_channel(conf->channel->center_freq); + + wl1271_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d %s" + " changed 0x%x", + channel, + conf->flags & IEEE80211_CONF_PS ? "on" : "off", + conf->power_level, + conf->flags & IEEE80211_CONF_IDLE ? "idle" : "in use", + changed); + + /* + * mac80211 will go to idle nearly immediately after transmitting some + * frames, such as the deauth. To make sure those frames reach the air, + * wait here until the TX queue is fully flushed. + */ + if ((changed & IEEE80211_CONF_CHANGE_IDLE) && + (conf->flags & IEEE80211_CONF_IDLE)) + wl1271_tx_flush(wl); + + mutex_lock(&wl->mutex); + + /* we support configuring the channel and band even while off */ + if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { + wl->band = conf->channel->band; + wl->channel = channel; + } + + if (changed & IEEE80211_CONF_CHANGE_POWER) + wl->power_level = conf->power_level; + + if (unlikely(wl->state == WL1271_STATE_OFF)) + goto out; + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + + /* configure each interface */ + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl12xx_config_vif(wl, wlvif, conf, changed); + if (ret < 0) + goto out_sleep; + } + out_sleep: wl1271_ps_elp_sleep(wl); -- cgit v0.10.2 From 6e8cd3310491b10db20d0f7eaf5713b05fa7b753 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:13 +0200 Subject: wl12xx: replace all remaining wl->vif references wl->vif is appropriate only when a single vif is being used. Instead, pass wlvif as parameter or iterate through all the vifs (e.g. when a global configuration was changed) Leave wl->vif only to determine whether a vif was already added (this check will be removed as well after both the driver and fw will support multiple vifs) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 4c5c518..65bf952 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -654,7 +654,8 @@ out: int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; - struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; int ret; wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wlvif->role_id); @@ -773,7 +774,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_cmd_role_start *cmd; - struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; int ret; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -1096,10 +1097,11 @@ out: int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct sk_buff *skb; int ret = 0; - skb = ieee80211_pspoll_get(wl->hw, wl->vif); + skb = ieee80211_pspoll_get(wl->hw, vif); if (!skb) goto out; @@ -1176,6 +1178,7 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, __be32 ip_addr) { int ret; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_arp_rsp_template tmpl; struct ieee80211_hdr_3addr *hdr; struct arphdr *arp_hdr; @@ -1187,8 +1190,8 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_TODS); - memcpy(hdr->addr1, wl->vif->bss_conf.bssid, ETH_ALEN); - memcpy(hdr->addr2, wl->vif->addr, ETH_ALEN); + memcpy(hdr->addr1, vif->bss_conf.bssid, ETH_ALEN); + memcpy(hdr->addr2, vif->addr, ETH_ALEN); memset(hdr->addr3, 0xff, ETH_ALEN); /* llc layer */ @@ -1204,7 +1207,7 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, arp_hdr->ar_op = cpu_to_be16(ARPOP_REPLY); /* arp payload */ - memcpy(tmpl.sender_hw, wl->vif->addr, ETH_ALEN); + memcpy(tmpl.sender_hw, vif->addr, ETH_ALEN); tmpl.sender_ip = ip_addr; ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 4abff82..d6c2d0c 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -615,19 +615,12 @@ static ssize_t beacon_filtering_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; - struct ieee80211_vif *vif; struct wl12xx_vif *wlvif; char buf[10]; size_t len; unsigned long value; int ret; - if (!wl->vif) - return -EINVAL; - - vif = wl->vif; - wlvif = wl12xx_vif_to_data(vif); - len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; @@ -645,7 +638,9 @@ static ssize_t beacon_filtering_write(struct file *file, if (ret < 0) goto out; - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value); + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value); + } wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b2640ed..08fc9d4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -779,7 +779,9 @@ static int wl1271_plt_init(struct wl1271 *wl) return ret; } -static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) +static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, + struct wl12xx_vif *wlvif, + u8 hlid, u8 tx_pkts) { bool fw_ps, single_sta; @@ -791,7 +793,7 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) * packets in FW or if the STA is awake. */ if (!fw_ps || tx_pkts < WL1271_PS_STA_MAX_PACKETS) - wl1271_ps_link_end(wl, hlid); + wl12xx_ps_link_end(wl, wlvif, hlid); /* * Start high-level PS if the STA is asleep with enough blocks in FW. @@ -799,7 +801,7 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) * case FW-memory congestion is not a problem. */ else if (!single_sta && fw_ps && tx_pkts >= WL1271_PS_STA_MAX_PACKETS) - wl1271_ps_link_start(wl, hlid, true); + wl12xx_ps_link_start(wl, wlvif, hlid, true); } static void wl12xx_irq_update_links_status(struct wl1271 *wl, @@ -829,15 +831,15 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, lnk->prev_freed_pkts = status->tx_lnk_free_pkts[hlid]; lnk->allocated_pkts -= cnt; - wl12xx_irq_ps_regulate_link(wl, hlid, lnk->allocated_pkts); + wl12xx_irq_ps_regulate_link(wl, wlvif, hlid, + lnk->allocated_pkts); } } static void wl12xx_fw_status(struct wl1271 *wl, struct wl12xx_fw_status *status) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; struct timespec ts; u32 old_tx_blk_count = wl->tx_blocks_available; int avail, freed_blocks; @@ -892,8 +894,9 @@ static void wl12xx_fw_status(struct wl1271 *wl, clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); /* for AP update num of allocated TX blocks per link and ps status */ - if (wlvif->bss_type == BSS_TYPE_AP_BSS) + wl12xx_for_each_wlvif_ap(wl, wlvif) { wl12xx_irq_update_links_status(wl, wlvif, status); + } /* update the host-chipset time offset */ getnstimeofday(&ts); @@ -1212,6 +1215,7 @@ static void wl1271_recovery_work(struct work_struct *work) struct wl1271 *wl = container_of(work, struct wl1271, recovery_work); struct wl12xx_vif *wlvif; + struct ieee80211_vif *vif; mutex_lock(&wl->mutex); @@ -1249,7 +1253,12 @@ static void wl1271_recovery_work(struct work_struct *work) } /* reboot the chipset */ - __wl1271_op_remove_interface(wl, wl->vif, false); + while (!list_empty(&wl->wlvif_list)) { + wlvif = list_first_entry(&wl->wlvif_list, + struct wl12xx_vif, list); + vif = wl12xx_wlvif_to_vif(wlvif); + __wl1271_op_remove_interface(wl, vif, false); + } clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1721,18 +1730,19 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) { struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); WARN_ON(!wow || !wow->any); wl->wow_enabled = true; - ret = wl1271_configure_suspend(wl, wlvif); - if (ret < 0) { - wl1271_warning("couldn't prepare device to suspend"); - return ret; + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl1271_configure_suspend(wl, wlvif); + if (ret < 0) { + wl1271_warning("couldn't prepare device to suspend"); + return ret; + } } /* flush any remaining work */ wl1271_debug(DEBUG_MAC80211, "flushing remaining works"); @@ -1751,7 +1761,9 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, wl1271_enable_interrupts(wl); flush_work(&wl->tx_work); - flush_delayed_work(&wlvif->pspoll_work); + wl12xx_for_each_wlvif(wl, wlvif) { + flush_delayed_work(&wlvif->pspoll_work); + } flush_delayed_work(&wl->elp_work); return 0; @@ -1760,8 +1772,7 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, static int wl1271_op_resume(struct ieee80211_hw *hw) { struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; unsigned long flags; bool run_irq_work = false; @@ -1785,7 +1796,9 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) wl1271_irq(0, wl); wl1271_enable_interrupts(wl); } - wl1271_configure_resume(wl, wlvif); + wl12xx_for_each_wlvif(wl, wlvif) { + wl1271_configure_resume(wl, wlvif); + } wl->wow_enabled = false; return 0; @@ -2242,6 +2255,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, { struct wl1271 *wl = hw->priv; struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *iter; mutex_lock(&wl->mutex); @@ -2253,10 +2267,14 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, * wl->vif can be null here if someone shuts down the interface * just when hardware recovery has been started. */ - if (wl->vif) { - WARN_ON(wl->vif != vif); + wl12xx_for_each_wlvif(wl, iter) { + if (iter != wlvif) + continue; + __wl1271_op_remove_interface(wl, vif, true); + break; } + WARN_ON(iter != wlvif); out: mutex_unlock(&wl->mutex); cancel_work_sync(&wl->recovery_work); @@ -2326,8 +2344,10 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) int ret; if (test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + wl12xx_cmd_stop_channel_switch(wl); - ieee80211_chswitch_done(wl->vif, false); + ieee80211_chswitch_done(vif, false); } /* to stop listening to a channel, we disconnect */ @@ -2642,8 +2662,7 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, { struct wl1271_filter_params *fp = (void *)(unsigned long)multicast; struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; int ret; @@ -2662,17 +2681,20 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, if (ret < 0) goto out; - if (wlvif->bss_type != BSS_TYPE_AP_BSS) { - if (*total & FIF_ALLMULTI) - ret = wl1271_acx_group_address_tbl(wl, wlvif, false, - NULL, 0); - else if (fp) - ret = wl1271_acx_group_address_tbl(wl, wlvif, - fp->enabled, - fp->mc_list, - fp->mc_list_length); - if (ret < 0) - goto out_sleep; + wl12xx_for_each_wlvif(wl, wlvif) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { + if (*total & FIF_ALLMULTI) + ret = wl1271_acx_group_address_tbl(wl, wlvif, + false, + NULL, 0); + else if (fp) + ret = wl1271_acx_group_address_tbl(wl, wlvif, + fp->enabled, + fp->mc_list, + fp->mc_list_length); + if (ret < 0) + goto out_sleep; + } } /* @@ -3162,8 +3184,7 @@ out: static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) { struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; int ret = 0; mutex_lock(&wl->mutex); @@ -3177,10 +3198,11 @@ static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) if (ret < 0) goto out; - ret = wl1271_acx_rts_threshold(wl, wlvif, value); - if (ret < 0) - wl1271_warning("wl1271_op_set_rts_threshold failed: %d", ret); - + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl1271_acx_rts_threshold(wl, wlvif, value); + if (ret < 0) + wl1271_warning("set rts threshold failed: %d", ret); + } wl1271_ps_elp_sleep(wl); out: @@ -3669,7 +3691,7 @@ sta_not_found: wlvif->probereq = NULL; /* re-enable dynamic ps - just in case */ - ieee80211_enable_dyn_ps(wl->vif); + ieee80211_enable_dyn_ps(vif); /* revert back to minimum rates for the current band */ wl1271_set_band_rate(wl, wlvif); @@ -4305,9 +4327,11 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, mutex_lock(&wl->mutex); if (unlikely(wl->state == WL1271_STATE_OFF)) { - mutex_unlock(&wl->mutex); - ieee80211_chswitch_done(wl->vif, false); - return; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_chswitch_done(vif, false); + } + goto out; } ret = wl1271_ps_elp_wakeup(wl); diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 8153408..84a1afa 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -232,9 +232,11 @@ static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid) wl1271_handle_tx_low_watermark(wl); } -void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues) +void wl12xx_ps_link_start(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 hlid, bool clean_queues) { struct ieee80211_sta *sta; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); if (test_bit(hlid, &wl->ap_ps_map)) return; @@ -244,7 +246,7 @@ void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues) clean_queues); rcu_read_lock(); - sta = ieee80211_find_sta(wl->vif, wl->links[hlid].addr); + sta = ieee80211_find_sta(vif, wl->links[hlid].addr); if (!sta) { wl1271_error("could not find sta %pM for starting ps", wl->links[hlid].addr); @@ -262,9 +264,10 @@ void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues) __set_bit(hlid, &wl->ap_ps_map); } -void wl1271_ps_link_end(struct wl1271 *wl, u8 hlid) +void wl12xx_ps_link_end(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) { struct ieee80211_sta *sta; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); if (!test_bit(hlid, &wl->ap_ps_map)) return; @@ -274,7 +277,7 @@ void wl1271_ps_link_end(struct wl1271 *wl, u8 hlid) __clear_bit(hlid, &wl->ap_ps_map); rcu_read_lock(); - sta = ieee80211_find_sta(wl->vif, wl->links[hlid].addr); + sta = ieee80211_find_sta(vif, wl->links[hlid].addr); if (!sta) { wl1271_error("could not find sta %pM for ending ps", wl->links[hlid].addr); diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/ps.h index 6ad0a0b..a12052f0 100644 --- a/drivers/net/wireless/wl12xx/ps.h +++ b/drivers/net/wireless/wl12xx/ps.h @@ -32,8 +32,9 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, void wl1271_ps_elp_sleep(struct wl1271 *wl); int wl1271_ps_elp_wakeup(struct wl1271 *wl); void wl1271_elp_work(struct work_struct *work); -void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues); -void wl1271_ps_link_end(struct wl1271 *wl, u8 hlid); +void wl12xx_ps_link_start(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 hlid, bool clean_queues); +void wl12xx_ps_link_end(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid); #define WL1271_PS_COMPLETE_TIMEOUT 500 diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 604913f..185a65d 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -146,7 +146,7 @@ static void wl1271_tx_regulate_link(struct wl1271 *wl, * case FW-memory congestion is not a problem. */ if (!single_sta && fw_ps && tx_pkts >= WL1271_PS_STA_MAX_PACKETS) - wl1271_ps_link_start(wl, hlid, true); + wl12xx_ps_link_start(wl, wlvif, hlid, true); } bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb) -- cgit v0.10.2 From f02774343030c2794bb58b6150420dfefc31c39f Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:14 +0200 Subject: wl12xx: call stop() on recovery The recovery work should call stop() after it removed all the existing interfaces. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 08fc9d4..433a06f 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -379,6 +379,7 @@ static bool bug_on_recovery; static void __wl1271_op_remove_interface(struct wl1271 *wl, struct ieee80211_vif *vif, bool reset_tx_queues); +static void wl1271_op_stop(struct ieee80211_hw *hw); static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif); @@ -1220,7 +1221,7 @@ static void wl1271_recovery_work(struct work_struct *work) mutex_lock(&wl->mutex); if (wl->state != WL1271_STATE_ON) - goto out; + goto out_unlock; /* Avoid a recursive recovery */ set_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1259,6 +1260,8 @@ static void wl1271_recovery_work(struct work_struct *work) vif = wl12xx_wlvif_to_vif(wlvif); __wl1271_op_remove_interface(wl, vif, false); } + mutex_unlock(&wl->mutex); + wl1271_op_stop(wl->hw); clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1269,8 +1272,8 @@ static void wl1271_recovery_work(struct work_struct *work) * to restart the HW. */ ieee80211_wake_queues(wl->hw); - -out: + return; +out_unlock: mutex_unlock(&wl->mutex); } -- cgit v0.10.2 From e5a359f873f50cc123d5ca97637caa30fa095bb9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:15 +0200 Subject: wl12xx: use dynamic rate policies allocate the rate policies dynamically, instead of using hardcoded indexes. this is needed for proper multi-role configuration. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 21e74ca..e2e4670 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -766,7 +766,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) wlvif->basic_rate, wlvif->rate_set); /* configure one basic rate class */ - acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE); + acx->rate_policy_idx = cpu_to_le32(wlvif->sta.basic_rate_idx); acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->basic_rate); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; @@ -779,7 +779,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) } /* configure one AP supported rate class */ - acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE); + acx->rate_policy_idx = cpu_to_le32(wlvif->sta.ap_rate_idx); acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; @@ -796,7 +796,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) * (p2p packets should always go out with OFDM rates, even * if we are currently connected to 11b AP) */ - acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE_P2P); + acx->rate_policy_idx = cpu_to_le32(wlvif->sta.p2p_rate_idx); acx->rate_policy.enabled_rates = cpu_to_le32(CONF_TX_RATE_MASK_BASIC_P2P); acx->rate_policy.short_retry_limit = c->short_retry_limit; diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index c06119b..b2d85be 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -654,11 +654,6 @@ struct acx_rate_class { u8 reserved; }; -#define ACX_TX_BASIC_RATE 0 -#define ACX_TX_AP_FULL_RATE 1 -#define ACX_TX_BASIC_RATE_P2P 2 -#define ACX_TX_AP_MODE_MGMT_RATE 4 -#define ACX_TX_AP_MODE_BCST_RATE 5 struct acx_rate_policy { struct acx_header header; diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 74f5690..ba286d0 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -434,7 +434,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) rc.long_retry_limit = 10; rc.short_retry_limit = 10; rc.aflags = 0; - ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE); + ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.mgmt_rate_idx); if (ret < 0) return ret; @@ -443,7 +443,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) rc.short_retry_limit = 10; rc.long_retry_limit = 10; rc.aflags = 0; - ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE); + ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.bcast_rate_idx); if (ret < 0) return ret; @@ -465,7 +465,8 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) rc.short_retry_limit = 10; rc.long_retry_limit = 10; rc.aflags = 0; - ret = wl1271_acx_ap_rate_policy(wl, &rc, i); + ret = wl1271_acx_ap_rate_policy(wl, &rc, + wlvif->ap.ucast_rate_idx[i]); if (ret < 0) return ret; } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 433a06f..cd272256 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1910,6 +1910,27 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) mutex_unlock(&wl->mutex); } +static int wl12xx_allocate_rate_policy(struct wl1271 *wl, u8 *idx) +{ + u8 policy = find_first_zero_bit(wl->rate_policies_map, + WL12XX_MAX_RATE_POLICIES); + if (policy >= WL12XX_MAX_RATE_POLICIES) + return -EBUSY; + + __set_bit(policy, wl->rate_policies_map); + *idx = policy; + return 0; +} + +static void wl12xx_free_rate_policy(struct wl1271 *wl, u8 *idx) +{ + if (WARN_ON(*idx >= WL12XX_MAX_RATE_POLICIES)) + return; + + __clear_bit(*idx, wl->rate_policies_map); + *idx = WL12XX_MAX_RATE_POLICIES; +} + static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) { switch (wlvif->bss_type) { @@ -1937,6 +1958,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int i; /* clear everything but the persistent data */ memset(wlvif, 0, offsetof(struct wl12xx_vif, persistent)); @@ -1970,11 +1992,18 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->bss_type == BSS_TYPE_IBSS) { /* init sta/ibss data */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; - + wl12xx_allocate_rate_policy(wl, &wlvif->sta.basic_rate_idx); + wl12xx_allocate_rate_policy(wl, &wlvif->sta.ap_rate_idx); + wl12xx_allocate_rate_policy(wl, &wlvif->sta.p2p_rate_idx); } else { /* init ap data */ wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + wl12xx_allocate_rate_policy(wl, &wlvif->ap.mgmt_rate_idx); + wl12xx_allocate_rate_policy(wl, &wlvif->ap.bcast_rate_idx); + for (i = 0; i < CONF_TX_MAX_AC_COUNT; i++) + wl12xx_allocate_rate_policy(wl, + &wlvif->ap.ucast_rate_idx[i]); } wlvif->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; @@ -2181,7 +2210,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, bool reset_tx_queues) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - int ret; + int i, ret; wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); @@ -2227,10 +2256,23 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, } deinit: /* clear all hlids (except system_hlid) */ - wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; + wl12xx_free_rate_policy(wl, &wlvif->sta.basic_rate_idx); + wl12xx_free_rate_policy(wl, &wlvif->sta.ap_rate_idx); + wl12xx_free_rate_policy(wl, &wlvif->sta.p2p_rate_idx); + } else { + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + wl12xx_free_rate_policy(wl, &wlvif->ap.mgmt_rate_idx); + wl12xx_free_rate_policy(wl, &wlvif->ap.bcast_rate_idx); + for (i = 0; i < CONF_TX_MAX_AC_COUNT; i++) + wl12xx_free_rate_policy(wl, + &wlvif->ap.ucast_rate_idx[i]); + } wl12xx_tx_reset_wlvif(wl, wlvif); wl1271_free_ap_keys(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 185a65d..69ac03f 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -339,16 +339,16 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, send them with AP rate policies, otherwise use default basic rates */ if (control->control.sta) - rate_idx = ACX_TX_AP_FULL_RATE; + rate_idx = wlvif->sta.ap_rate_idx; else - rate_idx = ACX_TX_BASIC_RATE; + rate_idx = wlvif->sta.basic_rate_idx; } else { if (hlid == wlvif->ap.global_hlid) - rate_idx = ACX_TX_AP_MODE_MGMT_RATE; + rate_idx = wlvif->ap.mgmt_rate_idx; else if (hlid == wlvif->ap.bcast_hlid) - rate_idx = ACX_TX_AP_MODE_BCST_RATE; + rate_idx = wlvif->ap.bcast_rate_idx; else - rate_idx = ac; + rate_idx = wlvif->ap.ucast_rate_idx[ac]; } tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 2689522..d169d52 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -142,6 +142,8 @@ extern u32 wl12xx_debug_level; #define WL12XX_INVALID_ROLE_ID 0xff #define WL12XX_INVALID_LINK_ID 0xff +#define WL12XX_MAX_RATE_POLICIES 16 + /* Defined by FW as 0. Will not be freed or allocated. */ #define WL12XX_SYSTEM_HLID 0 @@ -396,8 +398,11 @@ struct wl1271 { unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; + unsigned long rate_policies_map[ + BITS_TO_LONGS(WL12XX_MAX_RATE_POLICIES)]; struct list_head wlvif_list; + u8 sta_count; u8 ap_count; @@ -569,6 +574,10 @@ struct wl12xx_vif { struct { u8 hlid; u8 ba_rx_bitmap; + + u8 basic_rate_idx; + u8 ap_rate_idx; + u8 p2p_rate_idx; } sta; struct { u8 global_hlid; @@ -580,6 +589,10 @@ struct wl12xx_vif { /* recoreded keys - set here before AP startup */ struct wl1271_ap_key *recorded_keys[MAX_NUM_KEYS]; + + u8 mgmt_rate_idx; + u8 bcast_rate_idx; + u8 ucast_rate_idx[CONF_TX_MAX_AC_COUNT]; } ap; }; -- cgit v0.10.2 From f750c82045d8f5d0d6d59e517eb485ffbbe014b2 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:16 +0200 Subject: wl12xx: add elp wakeup/sleep calls to add_interface add_interface might be called while the chip is in elp. add elp_wakeup/sleep calls to handle it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index cd272256..6e6ac63f 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2115,6 +2115,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ieee80211_vif_type_p2p(vif), vif->addr); mutex_lock(&wl->mutex); + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out_unlock; + if (wl->vif) { wl1271_debug(DEBUG_MAC80211, "multiple vifs are not supported yet"); @@ -2195,6 +2199,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, else wl->sta_count++; out: + wl1271_ps_elp_sleep(wl); +out_unlock: mutex_unlock(&wl->mutex); mutex_lock(&wl_list_mutex); -- cgit v0.10.2 From e4120df982c2051f3cfc02f6278798c5166a72f8 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:17 +0200 Subject: wl12xx: use round-robin policy for tx Currently, a single vif might starve all the other vifs. Save the last vif we dequeued a packet from, and continue with the following one using a round-robin policy. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 6e6ac63f..f29d18d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2282,6 +2282,8 @@ deinit: wl12xx_tx_reset_wlvif(wl, wlvif); wl1271_free_ap_keys(wl, wlvif); + if (wl->last_wlvif == wlvif) + wl->last_wlvif = NULL; list_del(&wlvif->list); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wlvif->role_id = WL12XX_INVALID_ROLE_ID; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 69ac03f..5aeef95 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -590,14 +590,28 @@ static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl, static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) { unsigned long flags; - struct wl12xx_vif *wlvif; + struct wl12xx_vif *wlvif = wl->last_wlvif; struct sk_buff *skb = NULL; - /* TODO: rememeber last vif and consider it */ - wl12xx_for_each_wlvif(wl, wlvif) { - skb = wl12xx_vif_skb_dequeue(wl, wlvif); - if (skb) - break; + if (wlvif) { + wl12xx_for_each_wlvif_continue(wl, wlvif) { + skb = wl12xx_vif_skb_dequeue(wl, wlvif); + if (skb) { + wl->last_wlvif = wlvif; + break; + } + } + } + + /* do another pass */ + if (!skb) { + wl12xx_for_each_wlvif(wl, wlvif) { + skb = wl12xx_vif_skb_dequeue(wl, wlvif); + if (skb) { + wl->last_wlvif = wlvif; + break; + } + } } if (!skb && diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d169d52..8815fd9 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -552,6 +552,9 @@ struct wl1271 { /* AP-mode - number of currently connected stations */ int active_sta_count; + + /* last wlvif we transmitted from */ + struct wl12xx_vif *last_wlvif; }; struct wl1271_station { @@ -693,6 +696,9 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) #define wl12xx_for_each_wlvif(wl, wlvif) \ list_for_each_entry(wlvif, &wl->wlvif_list, list) +#define wl12xx_for_each_wlvif_continue(wl, wlvif) \ + list_for_each_entry_continue(wlvif, &wl->wlvif_list, list) + #define wl12xx_for_each_wlvif_bss_type(wl, wlvif, _bss_type) \ wl12xx_for_each_wlvif(wl, wlvif) \ if (wlvif->bss_type == _bss_type) -- cgit v0.10.2 From c7e7c227b63836933ef736fa2d7cc526174b1563 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 6 Oct 2011 22:59:37 +0300 Subject: wl12xx: remove sdio_test module This module has been causing more trouble than being useful. It only tests the SDIO speed by connecting to the wl12xx chip and does some throughput calculations. It is an ugly quick hack and, if we really want to have it as part of wl12xx we need to clean it up and implement it properly. A tarball of the code has been created and posted here, with some instructions: http://wireless.kernel.org/en/users/Drivers/wl12xx#SDIO_performance_test_module Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig index 3fe388b..af08c86 100644 --- a/drivers/net/wireless/wl12xx/Kconfig +++ b/drivers/net/wireless/wl12xx/Kconfig @@ -42,16 +42,6 @@ config WL12XX_SDIO If you choose to build a module, it'll be called wl12xx_sdio. Say N if unsure. -config WL12XX_SDIO_TEST - tristate "TI wl12xx SDIO testing support" - depends on WL12XX && MMC && WL12XX_SDIO - default n - ---help--- - This module adds support for the SDIO bus testing with the - TI wl12xx chipsets. You probably don't want this unless you are - testing a new hardware platform. Select this if you want to test the - SDIO bus which is connected to the wl12xx chip. - config WL12XX_PLATFORM_DATA bool depends on WL12XX_SDIO != n || WL1251_SDIO != n diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile index 621b348..fe67262 100644 --- a/drivers/net/wireless/wl12xx/Makefile +++ b/drivers/net/wireless/wl12xx/Makefile @@ -3,14 +3,11 @@ wl12xx-objs = main.o cmd.o io.o event.o tx.o rx.o ps.o acx.o \ wl12xx_spi-objs = spi.o wl12xx_sdio-objs = sdio.o -wl12xx_sdio_test-objs = sdio_test.o wl12xx-$(CONFIG_NL80211_TESTMODE) += testmode.o obj-$(CONFIG_WL12XX) += wl12xx.o obj-$(CONFIG_WL12XX_SPI) += wl12xx_spi.o obj-$(CONFIG_WL12XX_SDIO) += wl12xx_sdio.o -obj-$(CONFIG_WL12XX_SDIO_TEST) += wl12xx_sdio_test.o - # small builtin driver bit obj-$(CONFIG_WL12XX_PLATFORM_DATA) += wl12xx_platform_data.o diff --git a/drivers/net/wireless/wl12xx/sdio_test.c b/drivers/net/wireless/wl12xx/sdio_test.c deleted file mode 100644 index f25d5d9..0000000 --- a/drivers/net/wireless/wl12xx/sdio_test.c +++ /dev/null @@ -1,543 +0,0 @@ -/* - * SDIO testing driver for wl12xx - * - * Copyright (C) 2010 Nokia Corporation - * - * Contact: Roger Quadros - * - * wl12xx read/write routines taken from the main module - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "wl12xx.h" -#include "io.h" -#include "boot.h" - -#ifndef SDIO_VENDOR_ID_TI -#define SDIO_VENDOR_ID_TI 0x0097 -#endif - -#ifndef SDIO_DEVICE_ID_TI_WL1271 -#define SDIO_DEVICE_ID_TI_WL1271 0x4076 -#endif - -static bool rx, tx; - -module_param(rx, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(rx, "Perform rx test. Default (0). " - "This test continuously reads data from the SDIO device.\n"); - -module_param(tx, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(tx, "Perform tx test. Default (0). " - "This test continuously writes data to the SDIO device.\n"); - -struct wl1271_test { - struct wl1271 wl; - struct task_struct *test_task; -}; - -static const struct sdio_device_id wl1271_devices[] = { - { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) }, - {} -}; - -static inline struct sdio_func *wl_to_func(struct wl1271 *wl) -{ - return wl->if_priv; -} - -static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl) -{ - return &(wl_to_func(wl)->dev); -} - -static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, - size_t len, bool fixed) -{ - int ret = 0; - struct sdio_func *func = wl_to_func(wl); - - if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { - ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); - } else { - if (fixed) - ret = sdio_readsb(func, buf, addr, len); - else - ret = sdio_memcpy_fromio(func, buf, addr, len); - - wl1271_debug(DEBUG_SDIO, "sdio read 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); - } - - if (ret) - wl1271_error("sdio read failed (%d)", ret); -} - -static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, - size_t len, bool fixed) -{ - int ret = 0; - struct sdio_func *func = wl_to_func(wl); - - if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { - sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio write 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); - } else { - wl1271_debug(DEBUG_SDIO, "sdio write 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); - - if (fixed) - ret = sdio_writesb(func, addr, buf, len); - else - ret = sdio_memcpy_toio(func, addr, buf, len); - } - if (ret) - wl1271_error("sdio write failed (%d)", ret); - -} - -static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) -{ - struct sdio_func *func = wl_to_func(wl); - int ret; - - /* Let the SDIO stack handle wlan_enable control, so we - * keep host claimed while wlan is in use to keep wl1271 - * alive. - */ - if (enable) { - /* Power up the card */ - ret = pm_runtime_get_sync(&func->dev); - if (ret < 0) - goto out; - - /* Runtime PM might be disabled, power up the card manually */ - ret = mmc_power_restore_host(func->card->host); - if (ret < 0) - goto out; - - sdio_claim_host(func); - sdio_enable_func(func); - } else { - sdio_disable_func(func); - sdio_release_host(func); - - /* Runtime PM might be disabled, power off the card manually */ - ret = mmc_power_save_host(func->card->host); - if (ret < 0) - goto out; - - /* Power down the card */ - ret = pm_runtime_put_sync(&func->dev); - } - -out: - return ret; -} - -static void wl1271_sdio_disable_interrupts(struct wl1271 *wl) -{ -} - -static void wl1271_sdio_enable_interrupts(struct wl1271 *wl) -{ -} - - -static struct wl1271_if_operations sdio_ops = { - .read = wl1271_sdio_raw_read, - .write = wl1271_sdio_raw_write, - .power = wl1271_sdio_set_power, - .dev = wl1271_sdio_wl_to_dev, - .enable_irq = wl1271_sdio_enable_interrupts, - .disable_irq = wl1271_sdio_disable_interrupts, -}; - -static void wl1271_fw_wakeup(struct wl1271 *wl) -{ - u32 elp_reg; - - elp_reg = ELPCTRL_WAKE_UP; - wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); -} - -static int wl1271_fetch_firmware(struct wl1271 *wl) -{ - const struct firmware *fw; - int ret; - - if (wl->chip.id == CHIP_ID_1283_PG20) - ret = request_firmware(&fw, WL128X_FW_NAME, - wl1271_wl_to_dev(wl)); - else - ret = request_firmware(&fw, WL127X_FW_NAME, - wl1271_wl_to_dev(wl)); - - if (ret < 0) { - wl1271_error("could not get firmware: %d", ret); - return ret; - } - - if (fw->size % 4) { - wl1271_error("firmware size is not multiple of 32 bits: %zu", - fw->size); - ret = -EILSEQ; - goto out; - } - - wl->fw_len = fw->size; - wl->fw = vmalloc(wl->fw_len); - - if (!wl->fw) { - wl1271_error("could not allocate memory for the firmware"); - ret = -ENOMEM; - goto out; - } - - memcpy(wl->fw, fw->data, wl->fw_len); - - ret = 0; - -out: - release_firmware(fw); - - return ret; -} - -static int wl1271_fetch_nvs(struct wl1271 *wl) -{ - const struct firmware *fw; - int ret; - - ret = request_firmware(&fw, WL12XX_NVS_NAME, wl1271_wl_to_dev(wl)); - - if (ret < 0) { - wl1271_error("could not get nvs file: %d", ret); - return ret; - } - - wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL); - - if (!wl->nvs) { - wl1271_error("could not allocate memory for the nvs file"); - ret = -ENOMEM; - goto out; - } - - wl->nvs_len = fw->size; - -out: - release_firmware(fw); - - return ret; -} - -static int wl1271_chip_wakeup(struct wl1271 *wl) -{ - struct wl1271_partition_set partition; - int ret; - - msleep(WL1271_PRE_POWER_ON_SLEEP); - ret = wl1271_power_on(wl); - if (ret) - return ret; - - msleep(WL1271_POWER_ON_SLEEP); - - /* We don't need a real memory partition here, because we only want - * to use the registers at this point. */ - memset(&partition, 0, sizeof(partition)); - partition.reg.start = REGISTERS_BASE; - partition.reg.size = REGISTERS_DOWN_SIZE; - wl1271_set_partition(wl, &partition); - - /* ELP module wake up */ - wl1271_fw_wakeup(wl); - - /* whal_FwCtrl_BootSm() */ - - /* 0. read chip id from CHIP_ID */ - wl->chip.id = wl1271_read32(wl, CHIP_ID_B); - - /* 1. check if chip id is valid */ - - switch (wl->chip.id) { - case CHIP_ID_1271_PG10: - wl1271_warning("chip id 0x%x (1271 PG10) support is obsolete", - wl->chip.id); - break; - case CHIP_ID_1271_PG20: - wl1271_notice("chip id 0x%x (1271 PG20)", - wl->chip.id); - break; - case CHIP_ID_1283_PG20: - wl1271_notice("chip id 0x%x (1283 PG20)", - wl->chip.id); - break; - case CHIP_ID_1283_PG10: - default: - wl1271_warning("unsupported chip id: 0x%x", wl->chip.id); - return -ENODEV; - } - - return ret; -} - -static struct wl1271_partition_set part_down = { - .mem = { - .start = 0x00000000, - .size = 0x000177c0 - }, - .reg = { - .start = REGISTERS_BASE, - .size = 0x00008800 - }, - .mem2 = { - .start = 0x00000000, - .size = 0x00000000 - }, - .mem3 = { - .start = 0x00000000, - .size = 0x00000000 - }, -}; - -static int tester(void *data) -{ - struct wl1271 *wl = data; - struct sdio_func *func = wl_to_func(wl); - struct device *pdev = &func->dev; - int ret = 0; - bool rx_started = 0; - bool tx_started = 0; - uint8_t *tx_buf, *rx_buf; - int test_size = PAGE_SIZE; - u32 addr = 0; - struct wl1271_partition_set partition; - - /* We assume chip is powered up and firmware fetched */ - - memcpy(&partition, &part_down, sizeof(partition)); - partition.mem.start = addr; - wl1271_set_partition(wl, &partition); - - tx_buf = kmalloc(test_size, GFP_KERNEL); - rx_buf = kmalloc(test_size, GFP_KERNEL); - if (!tx_buf || !rx_buf) { - dev_err(pdev, - "Could not allocate memory. Test will not run.\n"); - ret = -ENOMEM; - goto free; - } - - memset(tx_buf, 0x5a, test_size); - - /* write something in data area so we can read it back */ - wl1271_write(wl, addr, tx_buf, test_size, false); - - while (!kthread_should_stop()) { - if (rx && !rx_started) { - dev_info(pdev, "starting rx test\n"); - rx_started = 1; - } else if (!rx && rx_started) { - dev_info(pdev, "stopping rx test\n"); - rx_started = 0; - } - - if (tx && !tx_started) { - dev_info(pdev, "starting tx test\n"); - tx_started = 1; - } else if (!tx && tx_started) { - dev_info(pdev, "stopping tx test\n"); - tx_started = 0; - } - - if (rx_started) - wl1271_read(wl, addr, rx_buf, test_size, false); - - if (tx_started) - wl1271_write(wl, addr, tx_buf, test_size, false); - - if (!rx_started && !tx_started) - msleep(100); - } - -free: - kfree(tx_buf); - kfree(rx_buf); - return ret; -} - -static int __devinit wl1271_probe(struct sdio_func *func, - const struct sdio_device_id *id) -{ - const struct wl12xx_platform_data *wlan_data; - struct wl1271 *wl; - struct wl1271_test *wl_test; - int ret = 0; - - /* wl1271 has 2 sdio functions we handle just the wlan part */ - if (func->num != 0x02) - return -ENODEV; - - wl_test = kzalloc(sizeof(struct wl1271_test), GFP_KERNEL); - if (!wl_test) { - dev_err(&func->dev, "Could not allocate memory\n"); - return -ENOMEM; - } - - wl = &wl_test->wl; - - wl->if_priv = func; - wl->if_ops = &sdio_ops; - - /* Grab access to FN0 for ELP reg. */ - func->card->quirks |= MMC_QUIRK_LENIENT_FN0; - - /* Use block mode for transferring over one block size of data */ - func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; - - wlan_data = wl12xx_get_platform_data(); - if (IS_ERR(wlan_data)) { - ret = PTR_ERR(wlan_data); - dev_err(&func->dev, "missing wlan platform data: %d\n", ret); - goto out_free; - } - - wl->irq = wlan_data->irq; - wl->ref_clock = wlan_data->board_ref_clock; - wl->tcxo_clock = wlan_data->board_tcxo_clock; - - sdio_set_drvdata(func, wl_test); - - /* power up the device */ - ret = wl1271_chip_wakeup(wl); - if (ret) { - dev_err(&func->dev, "could not wake up chip\n"); - goto out_free; - } - - if (wl->fw == NULL) { - ret = wl1271_fetch_firmware(wl); - if (ret < 0) { - dev_err(&func->dev, "firmware fetch error\n"); - goto out_off; - } - } - - /* fetch NVS */ - if (wl->nvs == NULL) { - ret = wl1271_fetch_nvs(wl); - if (ret < 0) { - dev_err(&func->dev, "NVS fetch error\n"); - goto out_off; - } - } - - ret = wl1271_load_firmware(wl); - if (ret < 0) { - dev_err(&func->dev, "firmware load error: %d\n", ret); - goto out_free; - } - - dev_info(&func->dev, "initialized\n"); - - /* I/O testing will be done in the tester thread */ - - wl_test->test_task = kthread_run(tester, wl, "sdio_tester"); - if (IS_ERR(wl_test->test_task)) { - dev_err(&func->dev, "unable to create kernel thread\n"); - ret = PTR_ERR(wl_test->test_task); - goto out_free; - } - - return 0; - -out_off: - /* power off the chip */ - wl1271_power_off(wl); - -out_free: - kfree(wl_test); - return ret; -} - -static void __devexit wl1271_remove(struct sdio_func *func) -{ - struct wl1271_test *wl_test = sdio_get_drvdata(func); - - /* stop the I/O test thread */ - kthread_stop(wl_test->test_task); - - /* power off the chip */ - wl1271_power_off(&wl_test->wl); - - vfree(wl_test->wl.fw); - wl_test->wl.fw = NULL; - kfree(wl_test->wl.nvs); - wl_test->wl.nvs = NULL; - - kfree(wl_test); -} - -static struct sdio_driver wl1271_sdio_driver = { - .name = "wl12xx_sdio_test", - .id_table = wl1271_devices, - .probe = wl1271_probe, - .remove = __devexit_p(wl1271_remove), -}; - -static int __init wl1271_init(void) -{ - int ret; - - ret = sdio_register_driver(&wl1271_sdio_driver); - if (ret < 0) - pr_err("failed to register sdio driver: %d\n", ret); - - return ret; -} -module_init(wl1271_init); - -static void __exit wl1271_exit(void) -{ - sdio_unregister_driver(&wl1271_sdio_driver); -} -module_exit(wl1271_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Roger Quadros "); - -- cgit v0.10.2 From fbe936bcb59d8e6e054c325a441082b55538bf8f Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 4 Oct 2011 23:10:28 +0300 Subject: wl12xx: add an sdio glue struct to keep wl and device side-by-side In order to fully abstract the bus, we need to save the device structure *beside* wl1271, instead of inside it. This will help re-structuring the driver so that we avoid the duplicated code in the bus modules. Signed-off-by: Felipe Balbi [forward-ported and cleaned up and rephrased commit message] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 516a898..5a42680 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -44,6 +44,11 @@ #define SDIO_DEVICE_ID_TI_WL1271 0x4076 #endif +struct wl12xx_sdio_glue { + struct device *dev; + struct wl1271 *wl; +}; + static const struct sdio_device_id wl1271_devices[] __devinitconst = { { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) }, {} @@ -57,14 +62,14 @@ static void wl1271_sdio_set_block_size(struct wl1271 *wl, unsigned int blksz) sdio_release_host(wl->if_priv); } -static inline struct sdio_func *wl_to_func(struct wl1271 *wl) +static inline struct wl12xx_sdio_glue *wl_to_glue(struct wl1271 *wl) { return wl->if_priv; } static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl) { - return &(wl_to_func(wl)->dev); + return wl_to_glue(wl)->dev; } static irqreturn_t wl1271_hardirq(int irq, void *cookie) @@ -110,7 +115,8 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { int ret; - struct sdio_func *func = wl_to_func(wl); + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); @@ -135,7 +141,8 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { int ret; - struct sdio_func *func = wl_to_func(wl); + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); @@ -158,8 +165,9 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, static int wl1271_sdio_power_on(struct wl1271 *wl) { - struct sdio_func *func = wl_to_func(wl); int ret; + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); /* If enabled, tell runtime PM not to power off the card */ if (pm_runtime_enabled(&func->dev)) { @@ -182,8 +190,9 @@ out: static int wl1271_sdio_power_off(struct wl1271 *wl) { - struct sdio_func *func = wl_to_func(wl); int ret; + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); sdio_disable_func(func); sdio_release_host(func); @@ -224,21 +233,34 @@ static int __devinit wl1271_probe(struct sdio_func *func, struct ieee80211_hw *hw; const struct wl12xx_platform_data *wlan_data; struct wl1271 *wl; + struct wl12xx_sdio_glue *glue; unsigned long irqflags; mmc_pm_flag_t mmcflags; - int ret; + int ret = -ENOMEM; /* We are only able to handle the wlan function */ if (func->num != 0x02) return -ENODEV; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + wl1271_error("can't allocate glue"); + goto out; + } + hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) - return PTR_ERR(hw); + if (IS_ERR(hw)) { + wl1271_error("can't allocate hw"); + ret = PTR_ERR(hw); + goto out_free_glue; + } wl = hw->priv; - wl->if_priv = func; + glue->dev = &func->dev; + glue->wl = wl; + + wl->if_priv = glue; wl->if_ops = &sdio_ops; /* Grab access to FN0 for ELP reg. */ @@ -251,7 +273,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (IS_ERR(wlan_data)) { ret = PTR_ERR(wlan_data); wl1271_error("missing wlan platform data: %d", ret); - goto out_free; + goto out_free_hw; } wl->irq = wlan_data->irq; @@ -269,7 +291,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, DRIVER_NAME, wl); if (ret < 0) { wl1271_error("request_irq() failed: %d", ret); - goto out_free; + goto out_free_hw; } ret = enable_irq_wake(wl->irq); @@ -294,25 +316,29 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (ret) goto out_irq; - sdio_set_drvdata(func, wl); + sdio_set_drvdata(func, glue); /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); return 0; - out_irq: +out_irq: free_irq(wl->irq, wl); - out_free: +out_free_hw: wl1271_free_hw(wl); +out_free_glue: + kfree(glue); +out: return ret; } static void __devexit wl1271_remove(struct sdio_func *func) { - struct wl1271 *wl = sdio_get_drvdata(func); + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); + struct wl1271 *wl = glue->wl; /* Undo decrement done above in wl1271_probe */ pm_runtime_get_noresume(&func->dev); @@ -324,6 +350,7 @@ static void __devexit wl1271_remove(struct sdio_func *func) } free_irq(wl->irq, wl); wl1271_free_hw(wl); + kfree(glue); } #ifdef CONFIG_PM -- cgit v0.10.2 From b65019f661733ece3be0680be307d238d4dec68e Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 4 Oct 2011 23:36:47 +0300 Subject: wl12xx: add an spi glue struct to keep wl and device side-by-side In order to fully abstract the bus, we need to save the device structure *beside* wl1271, instead of inside it. This will help re-structuring the driver so that we avoid the duplicated code in the bus modules. Signed-off-by: Felipe Balbi [forward-ported and cleaned up and rephrased commit message] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 0f97186..16f0c71 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -69,14 +69,19 @@ #define WSPI_MAX_NUM_OF_CHUNKS (WL1271_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) -static inline struct spi_device *wl_to_spi(struct wl1271 *wl) +struct wl12xx_spi_glue { + struct device *dev; + struct wl1271 *wl; +}; + +static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl) { return wl->if_priv; } static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl) { - return &(wl_to_spi(wl)->dev); + return wl_to_glue(wl)->dev; } static void wl1271_spi_disable_interrupts(struct wl1271 *wl) @@ -91,6 +96,7 @@ static void wl1271_spi_enable_interrupts(struct wl1271 *wl) static void wl1271_spi_reset(struct wl1271 *wl) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); u8 *cmd; struct spi_transfer t; struct spi_message m; @@ -110,7 +116,7 @@ static void wl1271_spi_reset(struct wl1271 *wl) t.len = WSPI_INIT_CMD_LEN; spi_message_add_tail(&t, &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); @@ -118,6 +124,7 @@ static void wl1271_spi_reset(struct wl1271 *wl) static void wl1271_spi_init(struct wl1271 *wl) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; struct spi_transfer t; struct spi_message m; @@ -165,7 +172,7 @@ static void wl1271_spi_init(struct wl1271 *wl) t.len = WSPI_INIT_CMD_LEN; spi_message_add_tail(&t, &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); } @@ -174,6 +181,7 @@ static void wl1271_spi_init(struct wl1271 *wl) static int wl1271_spi_read_busy(struct wl1271 *wl) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); struct spi_transfer t[1]; struct spi_message m; u32 *busy_buf; @@ -194,7 +202,7 @@ static int wl1271_spi_read_busy(struct wl1271 *wl) t[0].len = sizeof(u32); t[0].cs_change = true; spi_message_add_tail(&t[0], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); if (*busy_buf & 0x1) return 0; @@ -208,6 +216,7 @@ static int wl1271_spi_read_busy(struct wl1271 *wl) static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); struct spi_transfer t[2]; struct spi_message m; u32 *busy_buf; @@ -243,7 +252,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, t[1].cs_change = true; spi_message_add_tail(&t[1], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) && wl1271_spi_read_busy(wl)) { @@ -259,7 +268,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, t[0].cs_change = true; spi_message_add_tail(&t[0], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, chunk_len); @@ -274,6 +283,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS]; struct spi_message m; u32 commands[WSPI_MAX_NUM_OF_CHUNKS]; @@ -318,7 +328,7 @@ static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, cmd++; } - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); } static irqreturn_t wl1271_hardirq(int irq, void *cookie) @@ -362,11 +372,12 @@ static struct wl1271_if_operations spi_ops = { static int __devinit wl1271_probe(struct spi_device *spi) { + struct wl12xx_spi_glue *glue; struct wl12xx_platform_data *pdata; struct ieee80211_hw *hw; struct wl1271 *wl; unsigned long irqflags; - int ret; + int ret = -ENOMEM; pdata = spi->dev.platform_data; if (!pdata) { @@ -374,14 +385,25 @@ static int __devinit wl1271_probe(struct spi_device *spi) return -ENODEV; } + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + wl1271_error("can't allocate glue"); + goto out; + } + hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) - return PTR_ERR(hw); + if (IS_ERR(hw)) { + ret = PTR_ERR(hw); + goto out_free_glue; + } wl = hw->priv; - dev_set_drvdata(&spi->dev, wl); - wl->if_priv = spi; + glue->dev = &spi->dev; + glue->wl = wl; + + spi_set_drvdata(spi, glue); + wl->if_priv = glue; wl->if_ops = &spi_ops; @@ -392,14 +414,14 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { wl1271_error("spi_setup failed"); - goto out_free; + goto out_free_hw; } wl->set_power = pdata->set_power; if (!wl->set_power) { wl1271_error("set power function missing in platform data"); ret = -ENODEV; - goto out_free; + goto out_free_hw; } wl->ref_clock = pdata->board_ref_clock; @@ -415,7 +437,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) if (wl->irq < 0) { wl1271_error("irq missing in platform data"); ret = -ENODEV; - goto out_free; + goto out_free_hw; } ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq, @@ -423,7 +445,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) DRIVER_NAME, wl); if (ret < 0) { wl1271_error("request_irq() failed: %d", ret); - goto out_free; + goto out_free_hw; } disable_irq(wl->irq); @@ -438,22 +460,27 @@ static int __devinit wl1271_probe(struct spi_device *spi) return 0; - out_irq: +out_irq: free_irq(wl->irq, wl); - out_free: +out_free_hw: wl1271_free_hw(wl); +out_free_glue: + kfree(glue); +out: return ret; } static int __devexit wl1271_remove(struct spi_device *spi) { - struct wl1271 *wl = dev_get_drvdata(&spi->dev); + struct wl12xx_spi_glue *glue = spi_get_drvdata(spi); + struct wl1271 *wl = glue->wl; wl1271_unregister_hw(wl); free_irq(wl->irq, wl); wl1271_free_hw(wl); + kfree(glue); return 0; } -- cgit v0.10.2 From 025aef8fcfbdf680376c4f7aa31b9ac85cebc700 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 5 Oct 2011 09:00:12 +0300 Subject: wl12xx: add a platform device to the sdio module The platform device will be used to match the platform driver that will be implemented by the core module. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [call platform_device_add() instead of platform_device_register()] [store alloc'ed device platform directly in glue->core] [fixed the length of memset(res...)] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 5a42680..e7ee5d1 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ struct wl12xx_sdio_glue { struct device *dev; struct wl1271 *wl; + struct platform_device *core; }; static const struct sdio_device_id wl1271_devices[] __devinitconst = { @@ -234,6 +236,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, const struct wl12xx_platform_data *wlan_data; struct wl1271 *wl; struct wl12xx_sdio_glue *glue; + struct resource res[1]; unsigned long irqflags; mmc_pm_flag_t mmcflags; int ret = -ENOMEM; @@ -321,8 +324,47 @@ static int __devinit wl1271_probe(struct sdio_func *func, /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); + glue->core = platform_device_alloc("wl12xx-sdio", -1); + if (!glue->core) { + wl1271_error("can't allocate platform_device"); + ret = -ENOMEM; + goto out_unreg_hw; + } + + glue->core->dev.parent = &func->dev; + + memset(res, 0x00, sizeof(res)); + + res[0].start = wlan_data->irq; + res[0].flags = IORESOURCE_IRQ; + res[0].name = "irq"; + + ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); + if (ret) { + wl1271_error("can't add resources"); + goto out_dev_put; + } + + ret = platform_device_add_data(glue->core, wlan_data, + sizeof(*wlan_data)); + if (ret) { + wl1271_error("can't add platform data"); + goto out_dev_put; + } + + ret = platform_device_add(glue->core); + if (ret) { + wl1271_error("can't add platform device"); + goto out_dev_put; + } return 0; +out_dev_put: + platform_device_put(glue->core); + +out_unreg_hw: + wl1271_unregister_hw(wl); + out_irq: free_irq(wl->irq, wl); @@ -350,6 +392,8 @@ static void __devexit wl1271_remove(struct sdio_func *func) } free_irq(wl->irq, wl); wl1271_free_hw(wl); + platform_device_del(glue->core); + platform_device_put(glue->core); kfree(glue); } -- cgit v0.10.2 From 0969d6793f4899a4c5f56443d50f272068b97142 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 5 Oct 2011 09:29:13 +0300 Subject: wl12xx: add a platform device to the spi module The platform device will be used to match the platform driver that will be implemented by the core module. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [call platform_device_add() instead of platform_device_register()] [store alloc'ed device platform directly in glue->core] [fixed the length of memset(res...)] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 16f0c71..2dd6598 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "wl12xx.h" @@ -72,6 +73,7 @@ struct wl12xx_spi_glue { struct device *dev; struct wl1271 *wl; + struct platform_device *core; }; static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl) @@ -376,6 +378,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) struct wl12xx_platform_data *pdata; struct ieee80211_hw *hw; struct wl1271 *wl; + struct resource res[1]; unsigned long irqflags; int ret = -ENOMEM; @@ -458,8 +461,47 @@ static int __devinit wl1271_probe(struct spi_device *spi) if (ret) goto out_irq; + glue->core = platform_device_alloc("wl12xx-spi", -1); + if (!glue->core) { + wl1271_error("can't allocate platform_device"); + ret = -ENOMEM; + goto out_unreg_hw; + } + + glue->core->dev.parent = &spi->dev; + + memset(res, 0x00, sizeof(res)); + + res[0].start = spi->irq; + res[0].flags = IORESOURCE_IRQ; + res[0].name = "irq"; + + ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); + if (ret) { + wl1271_error("can't add resources"); + goto out_dev_put; + } + + ret = platform_device_add_data(glue->core, pdata, sizeof(*pdata)); + if (ret) { + wl1271_error("can't add platform data"); + goto out_dev_put; + } + + ret = platform_device_add(glue->core); + if (ret) { + wl1271_error("can't register platform device"); + goto out_dev_put; + } + return 0; +out_dev_put: + platform_device_put(glue->core); + +out_unreg_hw: + wl1271_unregister_hw(wl); + out_irq: free_irq(wl->irq, wl); @@ -480,6 +522,8 @@ static int __devexit wl1271_remove(struct spi_device *spi) wl1271_unregister_hw(wl); free_irq(wl->irq, wl); wl1271_free_hw(wl); + platform_device_del(glue->core); + platform_device_put(glue->core); kfree(glue); return 0; -- cgit v0.10.2 From ce2a217c8268906640ebf7291d7a06210a35dd2f Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 5 Oct 2011 14:12:55 +0300 Subject: wl12xx: add platform driver to the core module Nnow that we have a platform_device on both glue layers, add a platform_driver to the core driver. It's currently an empty platform_driver but more functionality will be added on later patches. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [added platform_driver.driver initialization] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f29d18d..3262e8a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -5200,6 +5200,45 @@ int wl1271_free_hw(struct wl1271 *wl) } EXPORT_SYMBOL_GPL(wl1271_free_hw); +static int __devinit wl12xx_probe(struct platform_device *pdev) +{ + return 0; +} + +static int __devexit wl12xx_remove(struct platform_device *pdev) +{ + return 0; +} + +static const struct platform_device_id wl12xx_id_table[] __devinitconst = { + { "wl12xx-sdio", 0 }, + { "wl12xx-spi", 0 }, + { } /* Terminating Entry */ +}; +MODULE_DEVICE_TABLE(platform, wl12xx_id_table); + +static struct platform_driver wl12xx_driver = { + .probe = wl12xx_probe, + .remove = __devexit_p(wl12xx_remove), + .id_table = wl12xx_id_table, + .driver = { + .name = "wl12xx", + .owner = THIS_MODULE, + } +}; + +static int __init wl12xx_init(void) +{ + return platform_driver_register(&wl12xx_driver); +} +module_init(wl12xx_init); + +static void __exit wl12xx_exit(void) +{ + platform_driver_unregister(&wl12xx_driver); +} +module_exit(wl12xx_exit); + u32 wl12xx_debug_level = DEBUG_NONE; EXPORT_SYMBOL_GPL(wl12xx_debug_level); module_param_named(debug_level, wl12xx_debug_level, uint, S_IRUSR | S_IWUSR); -- cgit v0.10.2 From a390e85cfe91c346ff4745bcd45ad0a7e7101aa2 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 6 Oct 2011 10:07:44 +0300 Subject: wl12xx: move common init code from bus modules to main Move all common parts from sdio.c and spi.c to main.c, since they now can be handled as part of the platform driver. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [added a bunch of fixes and a new pdata element] [moved some new code into main.c as well] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/io.c b/drivers/net/wireless/wl12xx/io.c index c2da66f..1a7df8a 100644 --- a/drivers/net/wireless/wl12xx/io.c +++ b/drivers/net/wireless/wl12xx/io.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "wl12xx.h" #include "wl12xx_80211.h" @@ -46,7 +47,7 @@ bool wl1271_set_block_size(struct wl1271 *wl) { if (wl->if_ops->set_block_size) { - wl->if_ops->set_block_size(wl, WL12XX_BUS_BLOCK_SIZE); + wl->if_ops->set_block_size(wl->dev, WL12XX_BUS_BLOCK_SIZE); return true; } @@ -55,12 +56,12 @@ bool wl1271_set_block_size(struct wl1271 *wl) void wl1271_disable_interrupts(struct wl1271 *wl) { - wl->if_ops->disable_irq(wl); + disable_irq(wl->irq); } void wl1271_enable_interrupts(struct wl1271 *wl) { - wl->if_ops->enable_irq(wl); + enable_irq(wl->irq); } /* Set the SPI partitions to access the chip addresses @@ -128,13 +129,13 @@ EXPORT_SYMBOL_GPL(wl1271_set_partition); void wl1271_io_reset(struct wl1271 *wl) { if (wl->if_ops->reset) - wl->if_ops->reset(wl); + wl->if_ops->reset(wl->dev); } void wl1271_io_init(struct wl1271 *wl) { if (wl->if_ops->init) - wl->if_ops->init(wl); + wl->if_ops->init(wl->dev); } void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val) diff --git a/drivers/net/wireless/wl12xx/io.h b/drivers/net/wireless/wl12xx/io.h index e839341..e82dad1 100644 --- a/drivers/net/wireless/wl12xx/io.h +++ b/drivers/net/wireless/wl12xx/io.h @@ -51,23 +51,17 @@ void wl1271_enable_interrupts(struct wl1271 *wl); void wl1271_io_reset(struct wl1271 *wl); void wl1271_io_init(struct wl1271 *wl); -static inline struct device *wl1271_wl_to_dev(struct wl1271 *wl) -{ - return wl->if_ops->dev(wl); -} - - /* Raw target IO, address is not translated */ static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { - wl->if_ops->write(wl, addr, buf, len, fixed); + wl->if_ops->write(wl->dev, addr, buf, len, fixed); } static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { - wl->if_ops->read(wl, addr, buf, len, fixed); + wl->if_ops->read(wl->dev, addr, buf, len, fixed); } static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr) @@ -155,13 +149,13 @@ static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val) static inline void wl1271_power_off(struct wl1271 *wl) { - wl->if_ops->power(wl, false); + wl->if_ops->power(wl->dev, false); clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); } static inline int wl1271_power_on(struct wl1271 *wl) { - int ret = wl->if_ops->power(wl, true); + int ret = wl->if_ops->power(wl->dev, true); if (ret == 0) set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3262e8a..1cf9877 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "wl12xx.h" #include "wl12xx_80211.h" @@ -1067,7 +1068,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl) wl1271_debug(DEBUG_BOOT, "booting firmware %s", fw_name); - ret = request_firmware(&fw, fw_name, wl1271_wl_to_dev(wl)); + ret = request_firmware(&fw, fw_name, wl->dev); if (ret < 0) { wl1271_error("could not get firmware: %d", ret); @@ -1105,7 +1106,7 @@ static int wl1271_fetch_nvs(struct wl1271 *wl) const struct firmware *fw; int ret; - ret = request_firmware(&fw, WL12XX_NVS_NAME, wl1271_wl_to_dev(wl)); + ret = request_firmware(&fw, WL12XX_NVS_NAME, wl->dev); if (ret < 0) { wl1271_error("could not get nvs file: %d", ret); @@ -4979,7 +4980,7 @@ int wl1271_init_ieee80211(struct wl1271 *wl) wl->hw->wiphy->reg_notifier = wl1271_reg_notify; - SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl)); + SET_IEEE80211_DEV(wl->hw, wl->dev); wl->hw->sta_data_size = sizeof(struct wl1271_station); wl->hw->vif_data_size = sizeof(struct wl12xx_vif); @@ -5200,13 +5201,116 @@ int wl1271_free_hw(struct wl1271 *wl) } EXPORT_SYMBOL_GPL(wl1271_free_hw); +static irqreturn_t wl12xx_hardirq(int irq, void *cookie) +{ + struct wl1271 *wl = cookie; + unsigned long flags; + + wl1271_debug(DEBUG_IRQ, "IRQ"); + + /* complete the ELP completion */ + spin_lock_irqsave(&wl->wl_lock, flags); + set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); + if (wl->elp_compl) { + complete(wl->elp_compl); + wl->elp_compl = NULL; + } + + if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) { + /* don't enqueue a work right now. mark it as pending */ + set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags); + wl1271_debug(DEBUG_IRQ, "should not enqueue work"); + disable_irq_nosync(wl->irq); + pm_wakeup_event(wl->dev, 0); + spin_unlock_irqrestore(&wl->wl_lock, flags); + return IRQ_HANDLED; + } + spin_unlock_irqrestore(&wl->wl_lock, flags); + + return IRQ_WAKE_THREAD; +} + static int __devinit wl12xx_probe(struct platform_device *pdev) { + struct wl12xx_platform_data *pdata = pdev->dev.platform_data; + struct ieee80211_hw *hw; + struct wl1271 *wl; + unsigned long irqflags; + int ret = -ENODEV; + + hw = wl1271_alloc_hw(); + if (IS_ERR(hw)) { + wl1271_error("can't allocate hw"); + ret = PTR_ERR(hw); + goto out; + } + + wl = hw->priv; + wl->irq = platform_get_irq(pdev, 0); + wl->ref_clock = pdata->board_ref_clock; + wl->tcxo_clock = pdata->board_tcxo_clock; + wl->platform_quirks = pdata->platform_quirks; + wl->set_power = pdata->set_power; + wl->dev = &pdev->dev; + wl->if_ops = pdata->ops; + + platform_set_drvdata(pdev, wl); + + if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) + irqflags = IRQF_TRIGGER_RISING; + else + irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; + + ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wl1271_irq, + irqflags, + pdev->name, wl); + if (ret < 0) { + wl1271_error("request_irq() failed: %d", ret); + goto out_free_hw; + } + + ret = enable_irq_wake(wl->irq); + if (!ret) { + wl->irq_wake_enabled = true; + device_init_wakeup(wl->dev, 1); + if (pdata->pwr_in_suspend) + hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; + + } + disable_irq(wl->irq); + + ret = wl1271_init_ieee80211(wl); + if (ret) + goto out_irq; + + ret = wl1271_register_hw(wl); + if (ret) + goto out_irq; + return 0; + +out_irq: + free_irq(wl->irq, wl); + +out_free_hw: + wl1271_free_hw(wl); + +out: + return ret; } static int __devexit wl12xx_remove(struct platform_device *pdev) { + struct wl1271 *wl = platform_get_drvdata(pdev); + + if (wl->irq_wake_enabled) { + device_init_wakeup(wl->dev, 0); + disable_irq_wake(wl->irq); + } + wl1271_unregister_hw(wl); + free_irq(wl->irq, wl); + wl1271_free_hw(wl); + return 0; } diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index e7ee5d1..78e5352 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -47,7 +47,6 @@ struct wl12xx_sdio_glue { struct device *dev; - struct wl1271 *wl; struct platform_device *core; }; @@ -57,67 +56,22 @@ static const struct sdio_device_id wl1271_devices[] __devinitconst = { }; MODULE_DEVICE_TABLE(sdio, wl1271_devices); -static void wl1271_sdio_set_block_size(struct wl1271 *wl, unsigned int blksz) +static void wl1271_sdio_set_block_size(struct device *child, + unsigned int blksz) { - sdio_claim_host(wl->if_priv); - sdio_set_block_size(wl->if_priv, blksz); - sdio_release_host(wl->if_priv); -} - -static inline struct wl12xx_sdio_glue *wl_to_glue(struct wl1271 *wl) -{ - return wl->if_priv; -} - -static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl) -{ - return wl_to_glue(wl)->dev; -} - -static irqreturn_t wl1271_hardirq(int irq, void *cookie) -{ - struct wl1271 *wl = cookie; - unsigned long flags; - - wl1271_debug(DEBUG_IRQ, "IRQ"); - - /* complete the ELP completion */ - spin_lock_irqsave(&wl->wl_lock, flags); - set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); - if (wl->elp_compl) { - complete(wl->elp_compl); - wl->elp_compl = NULL; - } - - if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) { - /* don't enqueue a work right now. mark it as pending */ - set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags); - wl1271_debug(DEBUG_IRQ, "should not enqueue work"); - disable_irq_nosync(wl->irq); - pm_wakeup_event(wl1271_sdio_wl_to_dev(wl), 0); - spin_unlock_irqrestore(&wl->wl_lock, flags); - return IRQ_HANDLED; - } - spin_unlock_irqrestore(&wl->wl_lock, flags); - - return IRQ_WAKE_THREAD; -} - -static void wl1271_sdio_disable_interrupts(struct wl1271 *wl) -{ - disable_irq(wl->irq); -} + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); + struct sdio_func *func = dev_to_sdio_func(glue->dev); -static void wl1271_sdio_enable_interrupts(struct wl1271 *wl) -{ - enable_irq(wl->irq); + sdio_claim_host(func); + sdio_set_block_size(func, blksz); + sdio_release_host(func); } -static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, +static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, size_t len, bool fixed) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { @@ -139,11 +93,11 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, wl1271_error("sdio read failed (%d)", ret); } -static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, +static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, size_t len, bool fixed) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { @@ -165,10 +119,9 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, wl1271_error("sdio write failed (%d)", ret); } -static int wl1271_sdio_power_on(struct wl1271 *wl) +static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); struct sdio_func *func = dev_to_sdio_func(glue->dev); /* If enabled, tell runtime PM not to power off the card */ @@ -190,10 +143,9 @@ out: return ret; } -static int wl1271_sdio_power_off(struct wl1271 *wl) +static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); struct sdio_func *func = dev_to_sdio_func(glue->dev); sdio_disable_func(func); @@ -211,33 +163,29 @@ static int wl1271_sdio_power_off(struct wl1271 *wl) return ret; } -static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) +static int wl12xx_sdio_set_power(struct device *child, bool enable) { + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); + if (enable) - return wl1271_sdio_power_on(wl); + return wl12xx_sdio_power_on(glue); else - return wl1271_sdio_power_off(wl); + return wl12xx_sdio_power_off(glue); } static struct wl1271_if_operations sdio_ops = { - .read = wl1271_sdio_raw_read, - .write = wl1271_sdio_raw_write, - .power = wl1271_sdio_set_power, - .dev = wl1271_sdio_wl_to_dev, - .enable_irq = wl1271_sdio_enable_interrupts, - .disable_irq = wl1271_sdio_disable_interrupts, + .read = wl12xx_sdio_raw_read, + .write = wl12xx_sdio_raw_write, + .power = wl12xx_sdio_set_power, .set_block_size = wl1271_sdio_set_block_size, }; static int __devinit wl1271_probe(struct sdio_func *func, const struct sdio_device_id *id) { - struct ieee80211_hw *hw; - const struct wl12xx_platform_data *wlan_data; - struct wl1271 *wl; + struct wl12xx_platform_data *wlan_data; struct wl12xx_sdio_glue *glue; struct resource res[1]; - unsigned long irqflags; mmc_pm_flag_t mmcflags; int ret = -ENOMEM; @@ -251,20 +199,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, goto out; } - hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) { - wl1271_error("can't allocate hw"); - ret = PTR_ERR(hw); - goto out_free_glue; - } - - wl = hw->priv; - glue->dev = &func->dev; - glue->wl = wl; - - wl->if_priv = glue; - wl->if_ops = &sdio_ops; /* Grab access to FN0 for ELP reg. */ func->card->quirks |= MMC_QUIRK_LENIENT_FN0; @@ -276,48 +211,17 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (IS_ERR(wlan_data)) { ret = PTR_ERR(wlan_data); wl1271_error("missing wlan platform data: %d", ret); - goto out_free_hw; - } - - wl->irq = wlan_data->irq; - wl->ref_clock = wlan_data->board_ref_clock; - wl->tcxo_clock = wlan_data->board_tcxo_clock; - wl->platform_quirks = wlan_data->platform_quirks; - - if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) - irqflags = IRQF_TRIGGER_RISING; - else - irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; - - ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq, - irqflags, - DRIVER_NAME, wl); - if (ret < 0) { - wl1271_error("request_irq() failed: %d", ret); - goto out_free_hw; + goto out_free_glue; } - ret = enable_irq_wake(wl->irq); - if (!ret) { - wl->irq_wake_enabled = true; - device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1); + /* if sdio can keep power while host is suspended, enable wow */ + mmcflags = sdio_get_host_pm_caps(func); + wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); - /* if sdio can keep power while host is suspended, enable wow */ - mmcflags = sdio_get_host_pm_caps(func); - wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); + if (mmcflags & MMC_PM_KEEP_POWER) + wlan_data->pwr_in_suspend = true; - if (mmcflags & MMC_PM_KEEP_POWER) - hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; - } - disable_irq(wl->irq); - - ret = wl1271_init_ieee80211(wl); - if (ret) - goto out_irq; - - ret = wl1271_register_hw(wl); - if (ret) - goto out_irq; + wlan_data->ops = &sdio_ops; sdio_set_drvdata(func, glue); @@ -328,7 +232,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (!glue->core) { wl1271_error("can't allocate platform_device"); ret = -ENOMEM; - goto out_unreg_hw; + goto out_free_glue; } glue->core->dev.parent = &func->dev; @@ -362,17 +266,9 @@ static int __devinit wl1271_probe(struct sdio_func *func, out_dev_put: platform_device_put(glue->core); -out_unreg_hw: - wl1271_unregister_hw(wl); - -out_irq: - free_irq(wl->irq, wl); - -out_free_hw: - wl1271_free_hw(wl); - out_free_glue: kfree(glue); + out: return ret; } @@ -380,18 +276,10 @@ out: static void __devexit wl1271_remove(struct sdio_func *func) { struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); - struct wl1271 *wl = glue->wl; /* Undo decrement done above in wl1271_probe */ pm_runtime_get_noresume(&func->dev); - wl1271_unregister_hw(wl); - if (wl->irq_wake_enabled) { - device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0); - disable_irq_wake(wl->irq); - } - free_irq(wl->irq, wl); - wl1271_free_hw(wl); platform_device_del(glue->core); platform_device_put(glue->core); kfree(glue); diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 2dd6598..22c1337 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -72,33 +72,12 @@ struct wl12xx_spi_glue { struct device *dev; - struct wl1271 *wl; struct platform_device *core; }; -static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl) +static void wl12xx_spi_reset(struct device *child) { - return wl->if_priv; -} - -static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl) -{ - return wl_to_glue(wl)->dev; -} - -static void wl1271_spi_disable_interrupts(struct wl1271 *wl) -{ - disable_irq(wl->irq); -} - -static void wl1271_spi_enable_interrupts(struct wl1271 *wl) -{ - enable_irq(wl->irq); -} - -static void wl1271_spi_reset(struct wl1271 *wl) -{ - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); u8 *cmd; struct spi_transfer t; struct spi_message m; @@ -124,9 +103,9 @@ static void wl1271_spi_reset(struct wl1271 *wl) kfree(cmd); } -static void wl1271_spi_init(struct wl1271 *wl) +static void wl12xx_spi_init(struct device *child) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; struct spi_transfer t; struct spi_message m; @@ -181,9 +160,10 @@ static void wl1271_spi_init(struct wl1271 *wl) #define WL1271_BUSY_WORD_TIMEOUT 1000 -static int wl1271_spi_read_busy(struct wl1271 *wl) +static int wl12xx_spi_read_busy(struct device *child) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); + struct wl1271 *wl = dev_get_drvdata(child); struct spi_transfer t[1]; struct spi_message m; u32 *busy_buf; @@ -215,10 +195,11 @@ static int wl1271_spi_read_busy(struct wl1271 *wl) return -ETIMEDOUT; } -static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, +static void wl12xx_spi_raw_read(struct device *child, int addr, void *buf, size_t len, bool fixed) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); + struct wl1271 *wl = dev_get_drvdata(child); struct spi_transfer t[2]; struct spi_message m; u32 *busy_buf; @@ -257,7 +238,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, spi_sync(to_spi_device(glue->dev), &m); if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) && - wl1271_spi_read_busy(wl)) { + wl12xx_spi_read_busy(child)) { memset(buf, 0, chunk_len); return; } @@ -282,10 +263,10 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, } } -static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, - size_t len, bool fixed) +static void wl12xx_spi_raw_write(struct device *child, int addr, void *buf, + size_t len, bool fixed) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS]; struct spi_message m; u32 commands[WSPI_MAX_NUM_OF_CHUNKS]; @@ -333,42 +314,11 @@ static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, spi_sync(to_spi_device(glue->dev), &m); } -static irqreturn_t wl1271_hardirq(int irq, void *cookie) -{ - struct wl1271 *wl = cookie; - unsigned long flags; - - wl1271_debug(DEBUG_IRQ, "IRQ"); - - /* complete the ELP completion */ - spin_lock_irqsave(&wl->wl_lock, flags); - set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); - if (wl->elp_compl) { - complete(wl->elp_compl); - wl->elp_compl = NULL; - } - spin_unlock_irqrestore(&wl->wl_lock, flags); - - return IRQ_WAKE_THREAD; -} - -static int wl1271_spi_set_power(struct wl1271 *wl, bool enable) -{ - if (wl->set_power) - wl->set_power(enable); - - return 0; -} - static struct wl1271_if_operations spi_ops = { - .read = wl1271_spi_raw_read, - .write = wl1271_spi_raw_write, - .reset = wl1271_spi_reset, - .init = wl1271_spi_init, - .power = wl1271_spi_set_power, - .dev = wl1271_spi_wl_to_dev, - .enable_irq = wl1271_spi_enable_interrupts, - .disable_irq = wl1271_spi_disable_interrupts, + .read = wl12xx_spi_raw_read, + .write = wl12xx_spi_raw_write, + .reset = wl12xx_spi_reset, + .init = wl12xx_spi_init, .set_block_size = NULL, }; @@ -376,10 +326,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) { struct wl12xx_spi_glue *glue; struct wl12xx_platform_data *pdata; - struct ieee80211_hw *hw; - struct wl1271 *wl; struct resource res[1]; - unsigned long irqflags; int ret = -ENOMEM; pdata = spi->dev.platform_data; @@ -388,27 +335,17 @@ static int __devinit wl1271_probe(struct spi_device *spi) return -ENODEV; } + pdata->ops = &spi_ops; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { wl1271_error("can't allocate glue"); goto out; } - hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) { - ret = PTR_ERR(hw); - goto out_free_glue; - } - - wl = hw->priv; - glue->dev = &spi->dev; - glue->wl = wl; spi_set_drvdata(spi, glue); - wl->if_priv = glue; - - wl->if_ops = &spi_ops; /* This is the only SPI value that we need to set here, the rest * comes from the board-peripherals file */ @@ -417,55 +354,14 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { wl1271_error("spi_setup failed"); - goto out_free_hw; - } - - wl->set_power = pdata->set_power; - if (!wl->set_power) { - wl1271_error("set power function missing in platform data"); - ret = -ENODEV; - goto out_free_hw; - } - - wl->ref_clock = pdata->board_ref_clock; - wl->tcxo_clock = pdata->board_tcxo_clock; - wl->platform_quirks = pdata->platform_quirks; - - if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) - irqflags = IRQF_TRIGGER_RISING; - else - irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; - - wl->irq = spi->irq; - if (wl->irq < 0) { - wl1271_error("irq missing in platform data"); - ret = -ENODEV; - goto out_free_hw; - } - - ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq, - irqflags, - DRIVER_NAME, wl); - if (ret < 0) { - wl1271_error("request_irq() failed: %d", ret); - goto out_free_hw; + goto out_free_glue; } - disable_irq(wl->irq); - - ret = wl1271_init_ieee80211(wl); - if (ret) - goto out_irq; - - ret = wl1271_register_hw(wl); - if (ret) - goto out_irq; - glue->core = platform_device_alloc("wl12xx-spi", -1); if (!glue->core) { wl1271_error("can't allocate platform_device"); ret = -ENOMEM; - goto out_unreg_hw; + goto out_free_glue; } glue->core->dev.parent = &spi->dev; @@ -499,15 +395,6 @@ static int __devinit wl1271_probe(struct spi_device *spi) out_dev_put: platform_device_put(glue->core); -out_unreg_hw: - wl1271_unregister_hw(wl); - -out_irq: - free_irq(wl->irq, wl); - -out_free_hw: - wl1271_free_hw(wl); - out_free_glue: kfree(glue); out: @@ -517,11 +404,7 @@ out: static int __devexit wl1271_remove(struct spi_device *spi) { struct wl12xx_spi_glue *glue = spi_get_drvdata(spi); - struct wl1271 *wl = glue->wl; - wl1271_unregister_hw(wl); - free_irq(wl->irq, wl); - wl1271_free_hw(wl); platform_device_del(glue->core); platform_device_put(glue->core); kfree(glue); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 8815fd9..d202893 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -288,17 +288,14 @@ struct wl1271_scan { }; struct wl1271_if_operations { - void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len, + void (*read)(struct device *child, int addr, void *buf, size_t len, bool fixed); - void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len, + void (*write)(struct device *child, int addr, void *buf, size_t len, bool fixed); - void (*reset)(struct wl1271 *wl); - void (*init)(struct wl1271 *wl); - int (*power)(struct wl1271 *wl, bool enable); - struct device* (*dev)(struct wl1271 *wl); - void (*enable_irq)(struct wl1271 *wl); - void (*disable_irq)(struct wl1271 *wl); - void (*set_block_size) (struct wl1271 *wl, unsigned int blksz); + void (*reset)(struct device *child); + void (*init)(struct device *child); + int (*power)(struct device *child, bool enable); + void (*set_block_size) (struct device *child, unsigned int blksz); }; #define MAX_NUM_KEYS 14 @@ -362,6 +359,8 @@ struct wl1271 { struct ieee80211_hw *hw; bool mac80211_registered; + struct device *dev; + void *if_priv; struct wl1271_if_operations *if_ops; diff --git a/drivers/net/wireless/wl12xx/wl12xx_platform_data.c b/drivers/net/wireless/wl12xx/wl12xx_platform_data.c index 973b110..3c96b33 100644 --- a/drivers/net/wireless/wl12xx/wl12xx_platform_data.c +++ b/drivers/net/wireless/wl12xx/wl12xx_platform_data.c @@ -2,7 +2,7 @@ #include #include -static const struct wl12xx_platform_data *platform_data; +static struct wl12xx_platform_data *platform_data; int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data) { @@ -18,7 +18,7 @@ int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data) return 0; } -const struct wl12xx_platform_data *wl12xx_get_platform_data(void) +struct wl12xx_platform_data *wl12xx_get_platform_data(void) { if (!platform_data) return ERR_PTR(-ENODEV); diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h index 4b69739..0d63731 100644 --- a/include/linux/wl12xx.h +++ b/include/linux/wl12xx.h @@ -54,6 +54,9 @@ struct wl12xx_platform_data { int board_ref_clock; int board_tcxo_clock; unsigned long platform_quirks; + bool pwr_in_suspend; + + struct wl1271_if_operations *ops; }; /* Platform does not support level trigger interrupts */ @@ -73,6 +76,6 @@ int wl12xx_set_platform_data(const struct wl12xx_platform_data *data) #endif -const struct wl12xx_platform_data *wl12xx_get_platform_data(void); +struct wl12xx_platform_data *wl12xx_get_platform_data(void); #endif -- cgit v0.10.2 From 4b32a2c9a636eaab69c797d9ebc7e086a6bd2fb7 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 6 Oct 2011 10:46:20 +0300 Subject: wl12xx: mark some symbols static after re-factoring a bunch of symbols are only used inside main.c which allows us to mark them as static. Signed-off-by: Felipe Balbi [forward-ported] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/io.h b/drivers/net/wireless/wl12xx/io.h index e82dad1..d398cbc 100644 --- a/drivers/net/wireless/wl12xx/io.h +++ b/drivers/net/wireless/wl12xx/io.h @@ -170,15 +170,10 @@ u16 wl1271_top_reg_read(struct wl1271 *wl, int addr); int wl1271_set_partition(struct wl1271 *wl, struct wl1271_partition_set *p); +bool wl1271_set_block_size(struct wl1271 *wl); + /* Functions from wl1271_main.c */ -int wl1271_register_hw(struct wl1271 *wl); -void wl1271_unregister_hw(struct wl1271 *wl); -int wl1271_init_ieee80211(struct wl1271 *wl); -struct ieee80211_hw *wl1271_alloc_hw(void); -int wl1271_free_hw(struct wl1271 *wl); -irqreturn_t wl1271_irq(int irq, void *data); -bool wl1271_set_block_size(struct wl1271 *wl); int wl1271_tx_dummy_packet(struct wl1271 *wl); #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 1cf9877..5692705 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -931,7 +931,7 @@ static void wl1271_netstack_work(struct work_struct *work) #define WL1271_IRQ_MAX_LOOPS 256 -irqreturn_t wl1271_irq(int irq, void *cookie) +static irqreturn_t wl1271_irq(int irq, void *cookie) { int ret; u32 intr; @@ -1053,7 +1053,6 @@ out: return IRQ_HANDLED; } -EXPORT_SYMBOL_GPL(wl1271_irq); static int wl1271_fetch_firmware(struct wl1271 *wl) { @@ -4848,7 +4847,7 @@ static struct bin_attribute fwlog_attr = { .read = wl1271_sysfs_read_fwlog, }; -int wl1271_register_hw(struct wl1271 *wl) +static int wl1271_register_hw(struct wl1271 *wl) { int ret; @@ -4889,9 +4888,8 @@ int wl1271_register_hw(struct wl1271 *wl) return 0; } -EXPORT_SYMBOL_GPL(wl1271_register_hw); -void wl1271_unregister_hw(struct wl1271 *wl) +static void wl1271_unregister_hw(struct wl1271 *wl) { if (wl->state == WL1271_STATE_PLT) __wl1271_plt_stop(wl); @@ -4901,9 +4899,8 @@ void wl1271_unregister_hw(struct wl1271 *wl) wl->mac80211_registered = false; } -EXPORT_SYMBOL_GPL(wl1271_unregister_hw); -int wl1271_init_ieee80211(struct wl1271 *wl) +static int wl1271_init_ieee80211(struct wl1271 *wl) { static const u32 cipher_suites[] = { WLAN_CIPHER_SUITE_WEP40, @@ -4989,11 +4986,10 @@ int wl1271_init_ieee80211(struct wl1271 *wl) return 0; } -EXPORT_SYMBOL_GPL(wl1271_init_ieee80211); #define WL1271_DEFAULT_CHANNEL 0 -struct ieee80211_hw *wl1271_alloc_hw(void) +static struct ieee80211_hw *wl1271_alloc_hw(void) { struct ieee80211_hw *hw; struct platform_device *plat_dev = NULL; @@ -5162,9 +5158,8 @@ err_hw_alloc: return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(wl1271_alloc_hw); -int wl1271_free_hw(struct wl1271 *wl) +static int wl1271_free_hw(struct wl1271 *wl) { /* Unblock any fwlog readers */ mutex_lock(&wl->mutex); @@ -5199,7 +5194,6 @@ int wl1271_free_hw(struct wl1271 *wl) return 0; } -EXPORT_SYMBOL_GPL(wl1271_free_hw); static irqreturn_t wl12xx_hardirq(int irq, void *cookie) { -- cgit v0.10.2 From f79f890c9ccd8d10f7e5e2f7c590b0c2e854bfb6 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 6 Oct 2011 13:05:25 +0300 Subject: wl12xx: drop unneeded plat_dev now that useless plat_dev is unnecessary, we can remove it. Signed-off-by: Felipe Balbi [forward ported and fixed sysfs file creation] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 5692705..c72f749 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -383,22 +383,6 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, static void wl1271_op_stop(struct ieee80211_hw *hw); static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif); - -static void wl1271_device_release(struct device *dev) -{ - -} - -static struct platform_device wl1271_device = { - .name = "wl1271", - .id = -1, - - /* device model insists to have a release function */ - .dev = { - .release = wl1271_device_release, - }, -}; - static DEFINE_MUTEX(wl_list_mutex); static LIST_HEAD(wl_list); @@ -4992,7 +4976,6 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) static struct ieee80211_hw *wl1271_alloc_hw(void) { struct ieee80211_hw *hw; - struct platform_device *plat_dev = NULL; struct wl1271 *wl; int i, j, ret; unsigned int order; @@ -5006,13 +4989,6 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) goto err_hw_alloc; } - plat_dev = kmemdup(&wl1271_device, sizeof(wl1271_device), GFP_KERNEL); - if (!plat_dev) { - wl1271_error("could not allocate platform_device"); - ret = -ENOMEM; - goto err_plat_alloc; - } - wl = hw->priv; memset(wl, 0, sizeof(*wl)); @@ -5020,7 +4996,6 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) INIT_LIST_HEAD(&wl->wlvif_list); wl->hw = hw; - wl->plat_dev = plat_dev; for (i = 0; i < NUM_TX_QUEUES; i++) for (j = 0; j < WL12XX_MAX_LINKS; j++) @@ -5095,49 +5070,8 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) goto err_dummy_packet; } - /* Register platform device */ - ret = platform_device_register(wl->plat_dev); - if (ret) { - wl1271_error("couldn't register platform device"); - goto err_fwlog; - } - dev_set_drvdata(&wl->plat_dev->dev, wl); - - /* Create sysfs file to control bt coex state */ - ret = device_create_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); - if (ret < 0) { - wl1271_error("failed to create sysfs file bt_coex_state"); - goto err_platform; - } - - /* Create sysfs file to get HW PG version */ - ret = device_create_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); - if (ret < 0) { - wl1271_error("failed to create sysfs file hw_pg_ver"); - goto err_bt_coex_state; - } - - /* Create sysfs file for the FW log */ - ret = device_create_bin_file(&wl->plat_dev->dev, &fwlog_attr); - if (ret < 0) { - wl1271_error("failed to create sysfs file fwlog"); - goto err_hw_pg_ver; - } - return hw; -err_hw_pg_ver: - device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); - -err_bt_coex_state: - device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); - -err_platform: - platform_device_unregister(wl->plat_dev); - -err_fwlog: - free_page((unsigned long)wl->fwlog); - err_dummy_packet: dev_kfree_skb(wl->dummy_packet); @@ -5149,9 +5083,6 @@ err_wq: err_hw: wl1271_debugfs_exit(wl); - kfree(plat_dev); - -err_plat_alloc: ieee80211_free_hw(hw); err_hw_alloc: @@ -5167,17 +5098,15 @@ static int wl1271_free_hw(struct wl1271 *wl) wake_up_interruptible_all(&wl->fwlog_waitq); mutex_unlock(&wl->mutex); - device_remove_bin_file(&wl->plat_dev->dev, &fwlog_attr); + device_remove_bin_file(wl->dev, &fwlog_attr); - device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); + device_remove_file(wl->dev, &dev_attr_hw_pg_ver); - device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); - platform_device_unregister(wl->plat_dev); + device_remove_file(wl->dev, &dev_attr_bt_coex_state); free_page((unsigned long)wl->fwlog); dev_kfree_skb(wl->dummy_packet); free_pages((unsigned long)wl->aggr_buf, get_order(WL1271_AGGR_BUFFER_SIZE)); - kfree(wl->plat_dev); wl1271_debugfs_exit(wl); @@ -5281,8 +5210,35 @@ static int __devinit wl12xx_probe(struct platform_device *pdev) if (ret) goto out_irq; + /* Create sysfs file to control bt coex state */ + ret = device_create_file(wl->dev, &dev_attr_bt_coex_state); + if (ret < 0) { + wl1271_error("failed to create sysfs file bt_coex_state"); + goto out_irq; + } + + /* Create sysfs file to get HW PG version */ + ret = device_create_file(wl->dev, &dev_attr_hw_pg_ver); + if (ret < 0) { + wl1271_error("failed to create sysfs file hw_pg_ver"); + goto out_bt_coex_state; + } + + /* Create sysfs file for the FW log */ + ret = device_create_bin_file(wl->dev, &fwlog_attr); + if (ret < 0) { + wl1271_error("failed to create sysfs file fwlog"); + goto out_hw_pg_ver; + } + return 0; +out_hw_pg_ver: + device_remove_file(wl->dev, &dev_attr_hw_pg_ver); + +out_bt_coex_state: + device_remove_file(wl->dev, &dev_attr_bt_coex_state); + out_irq: free_irq(wl->irq, wl); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d202893..158714a 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -355,7 +355,6 @@ struct wl1271_link { }; struct wl1271 { - struct platform_device *plat_dev; struct ieee80211_hw *hw; bool mac80211_registered; -- cgit v0.10.2 From 0f4e31222a2c0b93f25a87effd2033cb78c7a79c Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 11:02:42 +0300 Subject: wl12xx: move debugging definitions to a separate file Separate the debugging macros and other definitions to a new debug.h file. This is be needed because the sdio and spi modules don't need to depend on the wl12xx module anymore, but still need to include wl12xx.h. Currently they do depend on it, because of the debugging global that wl12xx exports. A future patch will remove this dependency. Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index e2e4670..bde1d86 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -29,6 +29,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "reg.h" #include "ps.h" diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index d4e628d..4ce634b 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -24,6 +24,7 @@ #include #include +#include "debug.h" #include "acx.h" #include "reg.h" #include "boot.h" diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 65bf952..2413c43 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -29,6 +29,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "reg.h" #include "io.h" #include "acx.h" diff --git a/drivers/net/wireless/wl12xx/debug.h b/drivers/net/wireless/wl12xx/debug.h new file mode 100644 index 0000000..b85fd8c4 --- /dev/null +++ b/drivers/net/wireless/wl12xx/debug.h @@ -0,0 +1,101 @@ +/* + * This file is part of wl12xx + * + * Copyright (C) 2011 Texas Instruments. All rights reserved. + * Copyright (C) 2008-2009 Nokia Corporation + * + * Contact: Luciano Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +#include +#include + +#define DRIVER_NAME "wl12xx" +#define DRIVER_PREFIX DRIVER_NAME ": " + +enum { + DEBUG_NONE = 0, + DEBUG_IRQ = BIT(0), + DEBUG_SPI = BIT(1), + DEBUG_BOOT = BIT(2), + DEBUG_MAILBOX = BIT(3), + DEBUG_TESTMODE = BIT(4), + DEBUG_EVENT = BIT(5), + DEBUG_TX = BIT(6), + DEBUG_RX = BIT(7), + DEBUG_SCAN = BIT(8), + DEBUG_CRYPT = BIT(9), + DEBUG_PSM = BIT(10), + DEBUG_MAC80211 = BIT(11), + DEBUG_CMD = BIT(12), + DEBUG_ACX = BIT(13), + DEBUG_SDIO = BIT(14), + DEBUG_FILTERS = BIT(15), + DEBUG_ADHOC = BIT(16), + DEBUG_AP = BIT(17), + DEBUG_MASTER = (DEBUG_ADHOC | DEBUG_AP), + DEBUG_ALL = ~0, +}; + +extern u32 wl12xx_debug_level; + +#define DEBUG_DUMP_LIMIT 1024 + +#define wl1271_error(fmt, arg...) \ + pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg) + +#define wl1271_warning(fmt, arg...) \ + pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg) + +#define wl1271_notice(fmt, arg...) \ + pr_info(DRIVER_PREFIX fmt "\n", ##arg) + +#define wl1271_info(fmt, arg...) \ + pr_info(DRIVER_PREFIX fmt "\n", ##arg) + +#define wl1271_debug(level, fmt, arg...) \ + do { \ + if (level & wl12xx_debug_level) \ + pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \ + } while (0) + +/* TODO: use pr_debug_hex_dump when it becomes available */ +#define wl1271_dump(level, prefix, buf, len) \ + do { \ + if (level & wl12xx_debug_level) \ + print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ + DUMP_PREFIX_OFFSET, 16, 1, \ + buf, \ + min_t(size_t, len, DEBUG_DUMP_LIMIT), \ + 0); \ + } while (0) + +#define wl1271_dump_ascii(level, prefix, buf, len) \ + do { \ + if (level & wl12xx_debug_level) \ + print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ + DUMP_PREFIX_OFFSET, 16, 1, \ + buf, \ + min_t(size_t, len, DEBUG_DUMP_LIMIT), \ + true); \ + } while (0) + +#endif /* __DEBUG_H__ */ diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index d6c2d0c..a9e0b73 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -27,6 +27,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "acx.h" #include "ps.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index fd2e7b2..e22df6c 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -22,6 +22,7 @@ */ #include "wl12xx.h" +#include "debug.h" #include "reg.h" #include "io.h" #include "event.h" diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index ba286d0..c6084f8 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -25,6 +25,7 @@ #include #include +#include "debug.h" #include "init.h" #include "wl12xx_80211.h" #include "acx.h" diff --git a/drivers/net/wireless/wl12xx/io.c b/drivers/net/wireless/wl12xx/io.c index 1a7df8a..079ad38 100644 --- a/drivers/net/wireless/wl12xx/io.c +++ b/drivers/net/wireless/wl12xx/io.c @@ -27,6 +27,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "io.h" #include "tx.h" diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index c72f749..44d52ef 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -35,6 +35,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "reg.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 84a1afa..9f4e8c0 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -25,6 +25,7 @@ #include "ps.h" #include "io.h" #include "tx.h" +#include "debug.h" #define WL1271_WAKEUP_TIMEOUT 500 diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index dd2f8b7..8c277c0 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -25,6 +25,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "acx.h" #include "reg.h" #include "rx.h" diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 2711438..fb2c431 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -24,6 +24,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "cmd.h" #include "scan.h" #include "acx.h" diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 78e5352..55c63ad 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -34,6 +34,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 22c1337..bcc7d7c 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -31,6 +31,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index 4ae8eff..61fff45 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -26,6 +26,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "acx.h" #include "reg.h" diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 5aeef95..5351f01 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -26,6 +26,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "io.h" #include "reg.h" #include "ps.h" diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 158714a..b7036df 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -35,9 +35,6 @@ #include "conf.h" #include "ini.h" -#define DRIVER_NAME "wl1271" -#define DRIVER_PREFIX DRIVER_NAME ": " - /* * FW versions support BA 11n * versions marks x.x.x.50-60.x @@ -45,73 +42,6 @@ #define WL12XX_BA_SUPPORT_FW_COST_VER2_START 50 #define WL12XX_BA_SUPPORT_FW_COST_VER2_END 60 -enum { - DEBUG_NONE = 0, - DEBUG_IRQ = BIT(0), - DEBUG_SPI = BIT(1), - DEBUG_BOOT = BIT(2), - DEBUG_MAILBOX = BIT(3), - DEBUG_TESTMODE = BIT(4), - DEBUG_EVENT = BIT(5), - DEBUG_TX = BIT(6), - DEBUG_RX = BIT(7), - DEBUG_SCAN = BIT(8), - DEBUG_CRYPT = BIT(9), - DEBUG_PSM = BIT(10), - DEBUG_MAC80211 = BIT(11), - DEBUG_CMD = BIT(12), - DEBUG_ACX = BIT(13), - DEBUG_SDIO = BIT(14), - DEBUG_FILTERS = BIT(15), - DEBUG_ADHOC = BIT(16), - DEBUG_AP = BIT(17), - DEBUG_MASTER = (DEBUG_ADHOC | DEBUG_AP), - DEBUG_ALL = ~0, -}; - -extern u32 wl12xx_debug_level; - -#define DEBUG_DUMP_LIMIT 1024 - -#define wl1271_error(fmt, arg...) \ - pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg) - -#define wl1271_warning(fmt, arg...) \ - pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg) - -#define wl1271_notice(fmt, arg...) \ - pr_info(DRIVER_PREFIX fmt "\n", ##arg) - -#define wl1271_info(fmt, arg...) \ - pr_info(DRIVER_PREFIX fmt "\n", ##arg) - -#define wl1271_debug(level, fmt, arg...) \ - do { \ - if (level & wl12xx_debug_level) \ - pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \ - } while (0) - -/* TODO: use pr_debug_hex_dump when it will be available */ -#define wl1271_dump(level, prefix, buf, len) \ - do { \ - if (level & wl12xx_debug_level) \ - print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ - DUMP_PREFIX_OFFSET, 16, 1, \ - buf, \ - min_t(size_t, len, DEBUG_DUMP_LIMIT), \ - 0); \ - } while (0) - -#define wl1271_dump_ascii(level, prefix, buf, len) \ - do { \ - if (level & wl12xx_debug_level) \ - print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ - DUMP_PREFIX_OFFSET, 16, 1, \ - buf, \ - min_t(size_t, len, DEBUG_DUMP_LIMIT), \ - true); \ - } while (0) - #define WL127X_FW_NAME "ti-connectivity/wl127x-fw-3.bin" #define WL128X_FW_NAME "ti-connectivity/wl128x-fw-3.bin" -- cgit v0.10.2 From 3c4d386868dcbfb9fa51427e314fde39ee70b0ff Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 14:14:25 +0300 Subject: wl12xx: sdio: use dev_dbg instead of wl1271_debug To prevent a useless dependency between the sdio module and the wl12xx module, we need to replace the wl1271_debug macros (and friends) for dev_dbg and other equivalents. At the same time, remove the SDIO data hexdump, since this produces way too much data and is not particularly useful. There's not print_hex_dump() equivalent for dynamic debug, so it's hard to control when the dumps are printed out. Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 55c63ad..57e72b4 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -34,7 +34,6 @@ #include #include "wl12xx.h" -#include "debug.h" #include "wl12xx_80211.h" #include "io.h" @@ -77,21 +76,20 @@ static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); + dev_dbg(child->parent, "sdio read 52 addr 0x%x, byte 0x%02x\n", + addr, ((u8 *)buf)[0]); } else { if (fixed) ret = sdio_readsb(func, buf, addr, len); else ret = sdio_memcpy_fromio(func, buf, addr, len); - wl1271_debug(DEBUG_SDIO, "sdio read 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); + dev_dbg(child->parent, "sdio read 53 addr 0x%x, %zu bytes\n", + addr, len); } if (ret) - wl1271_error("sdio read failed (%d)", ret); + dev_err(child->parent, "sdio read failed (%d)\n", ret); } static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, @@ -103,12 +101,11 @@ static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio write 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); + dev_dbg(child->parent, "sdio write 52 addr 0x%x, byte 0x%02x\n", + addr, ((u8 *)buf)[0]); } else { - wl1271_debug(DEBUG_SDIO, "sdio write 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); + dev_dbg(child->parent, "sdio write 53 addr 0x%x, %zu bytes\n", + addr, len); if (fixed) ret = sdio_writesb(func, addr, buf, len); @@ -117,7 +114,7 @@ static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, } if (ret) - wl1271_error("sdio write failed (%d)", ret); + dev_err(child->parent, "sdio write failed (%d)\n", ret); } static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) @@ -196,7 +193,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { - wl1271_error("can't allocate glue"); + dev_err(&func->dev, "can't allocate glue\n"); goto out; } @@ -211,13 +208,13 @@ static int __devinit wl1271_probe(struct sdio_func *func, wlan_data = wl12xx_get_platform_data(); if (IS_ERR(wlan_data)) { ret = PTR_ERR(wlan_data); - wl1271_error("missing wlan platform data: %d", ret); + dev_err(glue->dev, "missing wlan platform data: %d\n", ret); goto out_free_glue; } /* if sdio can keep power while host is suspended, enable wow */ mmcflags = sdio_get_host_pm_caps(func); - wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); + dev_dbg(glue->dev, "sdio PM caps = 0x%x\n", mmcflags); if (mmcflags & MMC_PM_KEEP_POWER) wlan_data->pwr_in_suspend = true; @@ -231,7 +228,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, glue->core = platform_device_alloc("wl12xx-sdio", -1); if (!glue->core) { - wl1271_error("can't allocate platform_device"); + dev_err(glue->dev, "can't allocate platform_device"); ret = -ENOMEM; goto out_free_glue; } @@ -246,20 +243,20 @@ static int __devinit wl1271_probe(struct sdio_func *func, ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); if (ret) { - wl1271_error("can't add resources"); + dev_err(glue->dev, "can't add resources\n"); goto out_dev_put; } ret = platform_device_add_data(glue->core, wlan_data, sizeof(*wlan_data)); if (ret) { - wl1271_error("can't add platform data"); + dev_err(glue->dev, "can't add platform data\n"); goto out_dev_put; } ret = platform_device_add(glue->core); if (ret) { - wl1271_error("can't add platform device"); + dev_err(glue->dev, "can't add platform device\n"); goto out_dev_put; } return 0; @@ -296,16 +293,16 @@ static int wl1271_suspend(struct device *dev) mmc_pm_flag_t sdio_flags; int ret = 0; - wl1271_debug(DEBUG_MAC80211, "wl1271 suspend. wow_enabled: %d", - wl->wow_enabled); + dev_dbg(dev, "wl1271 suspend. wow_enabled: %d\n", + wl->wow_enabled); /* check whether sdio should keep power */ if (wl->wow_enabled) { sdio_flags = sdio_get_host_pm_caps(func); if (!(sdio_flags & MMC_PM_KEEP_POWER)) { - wl1271_error("can't keep power while host " - "is suspended"); + dev_err(dev, "can't keep power while host " + "is suspended\n"); ret = -EINVAL; goto out; } @@ -313,7 +310,7 @@ static int wl1271_suspend(struct device *dev) /* keep power while host suspended */ ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); if (ret) { - wl1271_error("error while trying to keep power"); + dev_err(dev, "error while trying to keep power\n"); goto out; } @@ -329,7 +326,7 @@ static int wl1271_resume(struct device *dev) struct sdio_func *func = dev_to_sdio_func(dev); struct wl1271 *wl = sdio_get_drvdata(func); - wl1271_debug(DEBUG_MAC80211, "wl1271 resume"); + dev_dbg(dev, "wl1271 resume\n"); if (wl->wow_enabled) { /* claim back host */ sdio_claim_host(func); -- cgit v0.10.2 From e5d3625e8741d204e8c3f0a959f92c9e901519aa Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 14:33:29 +0300 Subject: wl12xx: spi: use dev_err instead of wl1271_error To prevent a useless dependency between the spi module and the wl12xx module, we need to replace the wl1271_error macros with dev_err. At the same time, remove the SPI data hexdump, since this produces way too much data and is not particularly useful. There's no print_hex_dump() equivalent for dynamic debug, so it's hard to control when the dumps are printed out. Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index bcc7d7c..976d3d5 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -31,7 +31,6 @@ #include #include "wl12xx.h" -#include "debug.h" #include "wl12xx_80211.h" #include "io.h" @@ -85,7 +84,8 @@ static void wl12xx_spi_reset(struct device *child) cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); if (!cmd) { - wl1271_error("could not allocate cmd for spi reset"); + dev_err(child->parent, + "could not allocate cmd for spi reset\n"); return; } @@ -100,7 +100,6 @@ static void wl12xx_spi_reset(struct device *child) spi_sync(to_spi_device(glue->dev), &m); - wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); } @@ -113,7 +112,8 @@ static void wl12xx_spi_init(struct device *child) cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); if (!cmd) { - wl1271_error("could not allocate cmd for spi init"); + dev_err(child->parent, + "could not allocate cmd for spi init\n"); return; } @@ -155,7 +155,6 @@ static void wl12xx_spi_init(struct device *child) spi_message_add_tail(&t, &m); spi_sync(to_spi_device(glue->dev), &m); - wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); } @@ -192,7 +191,7 @@ static int wl12xx_spi_read_busy(struct device *child) } /* The SPI bus is unresponsive, the read failed. */ - wl1271_error("SPI read busy-word timeout!\n"); + dev_err(child->parent, "SPI read busy-word timeout!\n"); return -ETIMEDOUT; } @@ -254,9 +253,6 @@ static void wl12xx_spi_raw_read(struct device *child, int addr, void *buf, spi_sync(to_spi_device(glue->dev), &m); - wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); - wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, chunk_len); - if (!fixed) addr += chunk_len; buf += chunk_len; @@ -302,9 +298,6 @@ static void wl12xx_spi_raw_write(struct device *child, int addr, void *buf, t[i].len = chunk_len; spi_message_add_tail(&t[i++], &m); - wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); - wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, chunk_len); - if (!fixed) addr += chunk_len; buf += chunk_len; @@ -332,7 +325,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) pdata = spi->dev.platform_data; if (!pdata) { - wl1271_error("no platform data"); + dev_err(&spi->dev, "no platform data\n"); return -ENODEV; } @@ -340,7 +333,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { - wl1271_error("can't allocate glue"); + dev_err(&spi->dev, "can't allocate glue\n"); goto out; } @@ -354,13 +347,13 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { - wl1271_error("spi_setup failed"); + dev_err(glue->dev, "spi_setup failed\n"); goto out_free_glue; } glue->core = platform_device_alloc("wl12xx-spi", -1); if (!glue->core) { - wl1271_error("can't allocate platform_device"); + dev_err(glue->dev, "can't allocate platform_device\n"); ret = -ENOMEM; goto out_free_glue; } @@ -375,19 +368,19 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); if (ret) { - wl1271_error("can't add resources"); + dev_err(glue->dev, "can't add resources\n"); goto out_dev_put; } ret = platform_device_add_data(glue->core, pdata, sizeof(*pdata)); if (ret) { - wl1271_error("can't add platform data"); + dev_err(glue->dev, "can't add platform data\n"); goto out_dev_put; } ret = platform_device_add(glue->core); if (ret) { - wl1271_error("can't register platform device"); + dev_err(glue->dev, "can't register platform device\n"); goto out_dev_put; } -- cgit v0.10.2 From d57b0e8b8990419b7b7ae0dda5cc4452720b3c7c Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 14:04:31 +0300 Subject: Bluetooth: convert flushable variable to flag in l2cap chan flushable variable inside l2cap_chan is a logical one and can be easily converted to flag. Added flags in l2cap_chan structure. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 2933767..0fe5d59 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -326,7 +326,6 @@ struct l2cap_chan { __u8 sec_level; __u8 role_switch; __u8 force_reliable; - __u8 flushable; __u8 force_active; __u8 ident; @@ -346,6 +345,7 @@ struct l2cap_chan { unsigned long conf_state; unsigned long conn_state; + unsigned long flags; __u8 next_tx_seq; __u8 expected_ack_seq; @@ -463,6 +463,11 @@ enum { CONN_RNR_SENT, }; +/* Definitions for flags in l2cap_chan */ +enum { + FLAG_FLUSHABLE, +}; + #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 3158cec..b21ecff 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1253,7 +1253,8 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len); - if (!chan->flushable && lmp_no_flush_capable(hcon->hdev)) + if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && + lmp_no_flush_capable(hcon->hdev)) flags = ACL_START_NO_FLUSH; else flags = ACL_START; diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 61f1f62..99782cb 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -446,7 +446,8 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch break; case BT_FLUSHABLE: - if (put_user(chan->flushable, (u32 __user *) optval)) + if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags), + (u32 __user *) optval)) err = -EFAULT; break; @@ -655,7 +656,10 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch } } - chan->flushable = opt; + if (opt) + set_bit(FLAG_FLUSHABLE, &chan->flags); + else + clear_bit(FLAG_FLUSHABLE, &chan->flags); break; case BT_POWER: @@ -931,7 +935,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->sec_level = pchan->sec_level; chan->role_switch = pchan->role_switch; chan->force_reliable = pchan->force_reliable; - chan->flushable = pchan->flushable; + chan->flags = pchan->flags; chan->force_active = pchan->force_active; } else { @@ -962,7 +966,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->sec_level = BT_SECURITY_LOW; chan->role_switch = 0; chan->force_reliable = 0; - chan->flushable = BT_FLUSHABLE_OFF; + chan->flags = 0; chan->force_active = BT_POWER_FORCE_ACTIVE_ON; } -- cgit v0.10.2 From ecf61bdba845b5e77cf1d5e8620ef54abcfa50ef Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 14:04:32 +0300 Subject: Bluetooth: convert force_reliable variable to flag in l2cap chan force_reliable variable inside l2cap_chan is a logical one and can be easily converted to flag Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 0fe5d59..6c0d247 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -325,7 +325,6 @@ struct l2cap_chan { __u8 sec_level; __u8 role_switch; - __u8 force_reliable; __u8 force_active; __u8 ident; @@ -465,6 +464,7 @@ enum { /* Definitions for flags in l2cap_chan */ enum { + FLAG_FORCE_RELIABLE, FLAG_FLUSHABLE, }; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index b21ecff..57e4b2c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -948,7 +948,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) list_for_each_entry(chan, &conn->chan_l, list) { struct sock *sk = chan->sk; - if (chan->force_reliable) + if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) sk->sk_err = err; } diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 99782cb..405d736 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -359,7 +359,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us if (chan->role_switch) opt |= L2CAP_LM_MASTER; - if (chan->force_reliable) + if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) opt |= L2CAP_LM_RELIABLE; if (put_user(opt, (u32 __user *) optval)) @@ -550,7 +550,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us chan->sec_level = BT_SECURITY_HIGH; chan->role_switch = (opt & L2CAP_LM_MASTER); - chan->force_reliable = (opt & L2CAP_LM_RELIABLE); + + if (opt & L2CAP_LM_RELIABLE) + set_bit(FLAG_FORCE_RELIABLE, &chan->flags); + else + clear_bit(FLAG_FORCE_RELIABLE, &chan->flags); break; default: @@ -934,7 +938,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->tx_win = pchan->tx_win; chan->sec_level = pchan->sec_level; chan->role_switch = pchan->role_switch; - chan->force_reliable = pchan->force_reliable; chan->flags = pchan->flags; chan->force_active = pchan->force_active; } else { @@ -965,7 +968,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->tx_win = L2CAP_DEFAULT_TX_WINDOW; chan->sec_level = BT_SECURITY_LOW; chan->role_switch = 0; - chan->force_reliable = 0; chan->flags = 0; chan->force_active = BT_POWER_FORCE_ACTIVE_ON; -- cgit v0.10.2 From 15770b1ab9747de47604da3494e187056b120aff Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 14:04:33 +0300 Subject: Bluetooth: convert force_active variable to flag in l2cap chan force_active variable inside l2cap_chan is a logical one and can be easily converted to flag Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 6c0d247..440e7b8 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -325,7 +325,6 @@ struct l2cap_chan { __u8 sec_level; __u8 role_switch; - __u8 force_active; __u8 ident; @@ -464,6 +463,7 @@ enum { /* Definitions for flags in l2cap_chan */ enum { + FLAG_FORCE_ACTIVE, FLAG_FORCE_RELIABLE, FLAG_FLUSHABLE, }; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 57e4b2c..aeeacf8 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -605,7 +605,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) else flags = ACL_START; - bt_cb(skb)->force_active = chan->force_active; + bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); hci_send_acl(chan->conn->hcon, skb, flags); } @@ -1259,7 +1259,7 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) else flags = ACL_START; - bt_cb(skb)->force_active = chan->force_active; + bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); hci_send_acl(hcon, skb, flags); } diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 405d736..bf196c6 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -459,7 +459,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch break; } - pwr.force_active = chan->force_active; + pwr.force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); len = min_t(unsigned int, len, sizeof(pwr)); if (copy_to_user(optval, (char *) &pwr, len)) @@ -680,7 +680,11 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch err = -EFAULT; break; } - chan->force_active = pwr.force_active; + + if (pwr.force_active) + set_bit(FLAG_FORCE_ACTIVE, &chan->flags); + else + clear_bit(FLAG_FORCE_ACTIVE, &chan->flags); break; default: @@ -939,7 +943,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->sec_level = pchan->sec_level; chan->role_switch = pchan->role_switch; chan->flags = pchan->flags; - chan->force_active = pchan->force_active; } else { switch (sk->sk_type) { @@ -969,8 +972,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->sec_level = BT_SECURITY_LOW; chan->role_switch = 0; chan->flags = 0; - chan->force_active = BT_POWER_FORCE_ACTIVE_ON; - + set_bit(FLAG_FORCE_ACTIVE, &chan->flags); } /* Default config options */ -- cgit v0.10.2 From 43bd0f32d5cf6593e420b26e2c1c41dc371a47d7 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 14:04:34 +0300 Subject: Bluetooth: convert role_switch variable to flag in l2cap chan role_switch variable inside l2cap_chan is a logical one and can be easily converted to flag Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 440e7b8..aea083c 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -324,7 +324,6 @@ struct l2cap_chan { __le16 sport; __u8 sec_level; - __u8 role_switch; __u8 ident; @@ -463,6 +462,7 @@ enum { /* Definitions for flags in l2cap_chan */ enum { + FLAG_ROLE_SWITCH, FLAG_FORCE_ACTIVE, FLAG_FORCE_RELIABLE, FLAG_FLUSHABLE, diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index aeeacf8..18a08c5 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3938,12 +3938,12 @@ static int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr)) { lm1 |= HCI_LM_ACCEPT; - if (c->role_switch) + if (test_bit(FLAG_ROLE_SWITCH, &c->flags)) lm1 |= HCI_LM_MASTER; exact++; } else if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) { lm2 |= HCI_LM_ACCEPT; - if (c->role_switch) + if (test_bit(FLAG_ROLE_SWITCH, &c->flags)) lm2 |= HCI_LM_MASTER; } } diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index bf196c6..48ad8ba 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -356,7 +356,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us break; } - if (chan->role_switch) + if (test_bit(FLAG_ROLE_SWITCH, &chan->flags)) opt |= L2CAP_LM_MASTER; if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) @@ -549,7 +549,10 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us if (opt & L2CAP_LM_SECURE) chan->sec_level = BT_SECURITY_HIGH; - chan->role_switch = (opt & L2CAP_LM_MASTER); + if (opt & L2CAP_LM_MASTER) + set_bit(FLAG_ROLE_SWITCH, &chan->flags); + else + clear_bit(FLAG_ROLE_SWITCH, &chan->flags); if (opt & L2CAP_LM_RELIABLE) set_bit(FLAG_FORCE_RELIABLE, &chan->flags); @@ -941,7 +944,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->max_tx = pchan->max_tx; chan->tx_win = pchan->tx_win; chan->sec_level = pchan->sec_level; - chan->role_switch = pchan->role_switch; chan->flags = pchan->flags; } else { @@ -970,7 +972,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->fcs = L2CAP_FCS_CRC16; chan->tx_win = L2CAP_DEFAULT_TX_WINDOW; chan->sec_level = BT_SECURITY_LOW; - chan->role_switch = 0; chan->flags = 0; set_bit(FLAG_FORCE_ACTIVE, &chan->flags); } -- cgit v0.10.2 From 8d6765aa39434ad65a3ae3b695f9c799f32d1d12 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:41 +0300 Subject: Bluetooth: clean up spaces in L2CAP header Spaces converted to tabs Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index aea083c..08ad40b 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -134,10 +134,9 @@ struct l2cap_conninfo { #define L2CAP_SDU_CONTINUE 0xC000 /* L2CAP Command rej. reasons */ -#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 -#define L2CAP_REJ_MTU_EXCEEDED 0x0001 -#define L2CAP_REJ_INVALID_CID 0x0002 - +#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 +#define L2CAP_REJ_MTU_EXCEEDED 0x0001 +#define L2CAP_REJ_INVALID_CID 0x0002 /* L2CAP structures */ struct l2cap_hdr { @@ -273,13 +272,13 @@ struct l2cap_info_rsp { } __packed; /* info type */ -#define L2CAP_IT_CL_MTU 0x0001 -#define L2CAP_IT_FEAT_MASK 0x0002 -#define L2CAP_IT_FIXED_CHAN 0x0003 +#define L2CAP_IT_CL_MTU 0x0001 +#define L2CAP_IT_FEAT_MASK 0x0002 +#define L2CAP_IT_FIXED_CHAN 0x0003 /* info result */ -#define L2CAP_IR_SUCCESS 0x0000 -#define L2CAP_IR_NOTSUPP 0x0001 +#define L2CAP_IR_SUCCESS 0x0000 +#define L2CAP_IR_NOTSUPP 0x0001 struct l2cap_conn_param_update_req { __le16 min; -- cgit v0.10.2 From 48309fd477ef867babb6819f67fe082c133a5fa9 Mon Sep 17 00:00:00 2001 From: Shahar Lev Date: Fri, 7 Oct 2011 18:17:25 +0200 Subject: wl12xx: remove warning message during IBSS Tx mac80211 sets the carrier on an IBSS interface even when no network is joined. Ignore garbage frames transmitted on a disconnected IBSS interface without printing warnings. Signed-off-by: Shahar Lev [merged with wlvif changes] Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 5351f01..27a45e1 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -428,7 +428,15 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, } hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); if (hlid == WL12XX_INVALID_LINK_ID) { - wl1271_error("invalid hlid. dropping skb 0x%p", skb); + if (wlvif->bss_type == BSS_TYPE_IBSS && + !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) { + /* It's ok to drop packets when not joined to IBSS */ + wl1271_debug(DEBUG_TX, "dropping skb while IBSS not " + " joined"); + } else { + wl1271_error("invalid hlid. dropping skb 0x%p", skb); + } + return -EINVAL; } -- cgit v0.10.2 From ccb62000d5e92772b6d5c2acce2f56263886ed89 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 15:54:15 +0300 Subject: wl12xx: use the same plat dev name for both SPI and SDIO There's no need to have the bus name included in the platform device name that we create. The core driver doesn't need to know about the type of bus it uses. Any differences between the buses that need to be handled differently in the core, can be passed in the platform data (as the pwr_in_suspend boolean does). Use "wl12xx" for the device name in both bus drivers. Rename the platform driver name to "wl12xx_driver", just to differentiate from the platform device names. Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 44d52ef..a2d1693 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -5266,8 +5266,7 @@ static int __devexit wl12xx_remove(struct platform_device *pdev) } static const struct platform_device_id wl12xx_id_table[] __devinitconst = { - { "wl12xx-sdio", 0 }, - { "wl12xx-spi", 0 }, + { "wl12xx", 0 }, { } /* Terminating Entry */ }; MODULE_DEVICE_TABLE(platform, wl12xx_id_table); @@ -5277,7 +5276,7 @@ static struct platform_driver wl12xx_driver = { .remove = __devexit_p(wl12xx_remove), .id_table = wl12xx_id_table, .driver = { - .name = "wl12xx", + .name = "wl12xx_driver", .owner = THIS_MODULE, } }; diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 57e72b4..ed97f9c 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -226,7 +226,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); - glue->core = platform_device_alloc("wl12xx-sdio", -1); + glue->core = platform_device_alloc("wl12xx", -1); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device"); ret = -ENOMEM; diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 976d3d5..9e6f7fa 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -351,7 +351,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) goto out_free_glue; } - glue->core = platform_device_alloc("wl12xx-spi", -1); + glue->core = platform_device_alloc("wl12xx", -1); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device\n"); ret = -ENOMEM; -- cgit v0.10.2 From 669bb3962bd7f781879222eeb7263d527551dd5e Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Tue, 11 Oct 2011 15:57:01 -0300 Subject: Bluetooth: Fix permission of enable_le param With 0444 it is impossible to change the param, changing it to 0644. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d7d96b6..0e57634 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3104,5 +3104,5 @@ void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) kfree_skb(skb); } -module_param(enable_le, bool, 0444); +module_param(enable_le, bool, 0644); MODULE_PARM_DESC(enable_le, "Enable LE support"); -- cgit v0.10.2 From 0f1680147ce2509383e053fa843020e0e9f3c6ce Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 13:52:25 +0200 Subject: wl12xx: handle injected packets Injected packets are sent with no vif, causing the wl12xx to NULL-dereference in multiple places. Furthermore, injected packets are currently not sent at all, as system_hlid doesn't belong to any specific role, so wl1271_skb_dequeue() never return its packets. Handle both these problems. Reported-by: Luciano Coelho Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index a2d1693..f76be5a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1477,11 +1477,14 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) struct wl1271 *wl = hw->priv; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_vif *vif = info->control.vif; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif = NULL; unsigned long flags; int q, mapping; u8 hlid; + if (vif) + wlvif = wl12xx_vif_to_data(vif); + mapping = skb_get_queue_mapping(skb); q = wl1271_tx_get_queue(mapping); @@ -1491,7 +1494,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) /* queue the packet */ if (hlid == WL12XX_INVALID_LINK_ID || - !test_bit(hlid, wlvif->links_map)) { + (wlvif && !test_bit(hlid, wlvif->links_map))) { wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); dev_kfree_skb(skb); goto out; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 27a45e1..c7ad4f5 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -185,7 +185,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - if (wl12xx_is_dummy_packet(wl, skb)) + if (!wlvif || wl12xx_is_dummy_packet(wl, skb)) return wl->system_hlid; if (wlvif->bss_type == BSS_TYPE_AP_BSS) @@ -264,7 +264,8 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); wl->tx_allocated_pkts[ac]++; - if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS && + if (!is_dummy && wlvif && + wlvif->bss_type == BSS_TYPE_AP_BSS && test_bit(hlid, wlvif->ap.sta_hlid_map)) wl->links[hlid].allocated_pkts++; @@ -307,7 +308,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, desc->start_time = cpu_to_le32(hosttime - wl->time_offset); is_dummy = wl12xx_is_dummy_packet(wl, skb); - if (is_dummy || wlvif->bss_type != BSS_TYPE_AP_BSS) + if (is_dummy || !wlvif || wlvif->bss_type != BSS_TYPE_AP_BSS) desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); else desc->life_time = cpu_to_le16(TX_HW_AP_MODE_PKT_LIFETIME_TU); @@ -326,14 +327,14 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, TX_HW_ATTR_SESSION_COUNTER; tx_attr |= TX_HW_ATTR_TX_DUMMY_REQ; - } else { + } else if (wlvif) { /* configure the tx attributes */ tx_attr = wlvif->session_counter << TX_HW_ATTR_OFST_SESSION_COUNTER; } desc->hlid = hlid; - if (is_dummy) + if (is_dummy || !wlvif) rate_idx = 0; else if (wlvif->bss_type != BSS_TYPE_AP_BSS) { /* if the packets are destined for AP (have a STA entry) @@ -446,7 +447,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_tx_fill_hdr(wl, wlvif, skb, extra, info, hlid); - if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS) { + if (!is_dummy && wlvif && wlvif->bss_type == BSS_TYPE_AP_BSS) { wl1271_tx_ap_update_inconnection_sta(wl, skb); wl1271_tx_regulate_link(wl, wlvif, hlid); } @@ -623,6 +624,9 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) } } + if (!skb) + skb = wl12xx_lnk_skb_dequeue(wl, &wl->links[wl->system_hlid]); + if (!skb && test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) { int q; @@ -716,19 +720,14 @@ void wl1271_tx_work_locked(struct wl1271 *wl) return; while ((skb = wl1271_skb_dequeue(wl))) { + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); bool has_data = false; wlvif = NULL; - if (!wl12xx_is_dummy_packet(wl, skb)) { - struct ieee80211_tx_info *info; - struct ieee80211_vif *vif; + if (!wl12xx_is_dummy_packet(wl, skb) && info->control.vif) + wlvif = wl12xx_vif_to_data(info->control.vif); - info = IEEE80211_SKB_CB(skb); - vif = info->control.vif; - wlvif = wl12xx_vif_to_data(vif); - } has_data = wlvif && wl1271_tx_is_data_present(skb); - ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset); if (ret == -EAGAIN) { /* -- cgit v0.10.2 From 6327eb980d2ff0c96363b81cb0ce580165cb81b8 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:42 +0300 Subject: Bluetooth: EWS: extended window size option support Adds support for extended window size (EWS) config option. We enable EWS feature in L2CAP Info RSP when hs enabled. EWS option is included in L2CAP Config Req if tx_win (which is set via socket) bigger then standard default value (63) && hs enabled && remote side supports EWS feature. Using EWS selects extended control field in L2CAP. Code partly based on Qualcomm and Atheros patches sent upstream a year ago. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 08ad40b..51998ff 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -32,6 +32,7 @@ #define L2CAP_DEFAULT_MIN_MTU 48 #define L2CAP_DEFAULT_FLUSH_TO 0xffff #define L2CAP_DEFAULT_TX_WINDOW 63 +#define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF #define L2CAP_DEFAULT_MAX_TX 3 #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ @@ -233,6 +234,7 @@ struct l2cap_conf_opt { #define L2CAP_CONF_QOS 0x03 #define L2CAP_CONF_RFC 0x04 #define L2CAP_CONF_FCS 0x05 +#define L2CAP_CONF_EWS 0x07 #define L2CAP_CONF_MAX_SIZE 22 @@ -333,7 +335,7 @@ struct l2cap_chan { __u8 fcs; - __u8 tx_win; + __u16 tx_win; __u8 max_tx; __u16 retrans_timeout; __u16 monitor_timeout; @@ -357,7 +359,7 @@ struct l2cap_chan { struct sk_buff *sdu; struct sk_buff *sdu_last_frag; - __u8 remote_tx_win; + __u16 remote_tx_win; __u8 remote_max_tx; __u16 remote_mps; @@ -442,6 +444,7 @@ enum { CONF_CONNECT_PEND, CONF_NO_FCS_RECV, CONF_STATE2_DEVICE, + CONF_EWS_RECV, }; #define L2CAP_CONF_MAX_CONF_REQ 2 @@ -465,6 +468,7 @@ enum { FLAG_FORCE_ACTIVE, FLAG_FORCE_RELIABLE, FLAG_FLUSHABLE, + FLAG_EXT_CTRL, }; #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 18a08c5..6e34312 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1898,6 +1898,22 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask) } } +static inline bool __l2cap_ews_supported(struct l2cap_chan *chan) +{ + return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_WINDOW; +} + +static inline void l2cap_txwin_setup(struct l2cap_chan *chan) +{ + if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && + __l2cap_ews_supported(chan)) + /* use extended control field */ + set_bit(FLAG_EXT_CTRL, &chan->flags); + else + chan->tx_win = min_t(u16, chan->tx_win, + L2CAP_DEFAULT_TX_WINDOW); +} + static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) { struct l2cap_conf_req *req = data; @@ -1944,7 +1960,6 @@ done: case L2CAP_MODE_ERTM: rfc.mode = L2CAP_MODE_ERTM; - rfc.txwin_size = chan->tx_win; rfc.max_transmit = chan->max_tx; rfc.retrans_timeout = 0; rfc.monitor_timeout = 0; @@ -1952,6 +1967,11 @@ done: if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10) rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); + l2cap_txwin_setup(chan); + + rfc.txwin_size = min_t(u16, chan->tx_win, + L2CAP_DEFAULT_TX_WINDOW); + l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); @@ -1963,6 +1983,10 @@ done: chan->fcs = L2CAP_FCS_NONE; l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); } + + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, + chan->tx_win); break; case L2CAP_MODE_STREAMING: @@ -2038,6 +2062,15 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) break; + case L2CAP_CONF_EWS: + if (!enable_hs) + return -ECONNREFUSED; + + set_bit(FLAG_EXT_CTRL, &chan->flags); + set_bit(CONF_EWS_RECV, &chan->conf_state); + chan->remote_tx_win = val; + break; + default: if (hint) break; @@ -2098,7 +2131,11 @@ done: break; case L2CAP_MODE_ERTM: - chan->remote_tx_win = rfc.txwin_size; + if (!test_bit(CONF_EWS_RECV, &chan->conf_state)) + chan->remote_tx_win = rfc.txwin_size; + else + rfc.txwin_size = L2CAP_DEFAULT_TX_WINDOW; + chan->remote_max_tx = rfc.max_transmit; if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10) @@ -2190,6 +2227,13 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); break; + + case L2CAP_CONF_EWS: + chan->tx_win = min_t(u16, val, + L2CAP_DEFAULT_EXT_WINDOW); + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, + 2, chan->tx_win); + break; } } @@ -2785,7 +2829,8 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING | L2CAP_FEAT_FCS; if (enable_hs) - feat_mask |= L2CAP_FEAT_EXT_FLOW; + feat_mask |= L2CAP_FEAT_EXT_FLOW + | L2CAP_FEAT_EXT_WINDOW; put_unaligned_le32(feat_mask, rsp->data); l2cap_send_cmd(conn, cmd->ident, diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 48ad8ba..836d12e 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -331,7 +331,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us opts.mode = chan->mode; opts.fcs = chan->fcs; opts.max_tx = chan->max_tx; - opts.txwin_size = (__u16)chan->tx_win; + opts.txwin_size = chan->tx_win; len = min_t(unsigned int, len, sizeof(opts)); if (copy_to_user(optval, (char *) &opts, len)) @@ -501,7 +501,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us opts.mode = chan->mode; opts.fcs = chan->fcs; opts.max_tx = chan->max_tx; - opts.txwin_size = (__u16)chan->tx_win; + opts.txwin_size = chan->tx_win; len = min_t(unsigned int, sizeof(opts), optlen); if (copy_from_user((char *) &opts, optval, len)) { @@ -509,7 +509,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us break; } - if (opts.txwin_size > L2CAP_DEFAULT_TX_WINDOW) { + if (opts.txwin_size > L2CAP_DEFAULT_EXT_WINDOW) { err = -EINVAL; break; } @@ -533,7 +533,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us chan->omtu = opts.omtu; chan->fcs = opts.fcs; chan->max_tx = opts.max_tx; - chan->tx_win = (__u8)opts.txwin_size; + chan->tx_win = opts.txwin_size; break; case L2CAP_LM: -- cgit v0.10.2 From 57253fd8c91e76780e9628451f680efcbcc52c85 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:43 +0300 Subject: Bluetooth: EWS: adds ext control field bit mask Adds extended control field bit masks and rearrange defines to logical groups: masks, flags and shift groups. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 51998ff..fa7edab 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -109,18 +109,35 @@ struct l2cap_conninfo { #define L2CAP_FCS_CRC16 0x01 /* L2CAP Control Field bit masks */ -#define L2CAP_CTRL_SAR 0xC000 -#define L2CAP_CTRL_REQSEQ 0x3F00 -#define L2CAP_CTRL_TXSEQ 0x007E -#define L2CAP_CTRL_RETRANS 0x0080 -#define L2CAP_CTRL_FINAL 0x0080 -#define L2CAP_CTRL_POLL 0x0010 -#define L2CAP_CTRL_SUPERVISE 0x000C -#define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ - -#define L2CAP_CTRL_TXSEQ_SHIFT 1 -#define L2CAP_CTRL_REQSEQ_SHIFT 8 -#define L2CAP_CTRL_SAR_SHIFT 14 +#define L2CAP_CTRL_SAR 0xC000 +#define L2CAP_CTRL_REQSEQ 0x3F00 +#define L2CAP_CTRL_TXSEQ 0x007E +#define L2CAP_CTRL_SUPERVISE 0x000C + +#define L2CAP_CTRL_RETRANS 0x0080 +#define L2CAP_CTRL_FINAL 0x0080 +#define L2CAP_CTRL_POLL 0x0010 +#define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ + +#define L2CAP_CTRL_TXSEQ_SHIFT 1 +#define L2CAP_CTRL_SUPER_SHIFT 2 +#define L2CAP_CTRL_REQSEQ_SHIFT 8 +#define L2CAP_CTRL_SAR_SHIFT 14 + +/* L2CAP Extended Control Field bit mask */ +#define L2CAP_EXT_CTRL_TXSEQ 0xFFFC0000 +#define L2CAP_EXT_CTRL_SAR 0x00030000 +#define L2CAP_EXT_CTRL_SUPERVISE 0x00030000 +#define L2CAP_EXT_CTRL_REQSEQ 0x0000FFFC + +#define L2CAP_EXT_CTRL_POLL 0x00040000 +#define L2CAP_EXT_CTRL_FINAL 0x00000002 +#define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */ + +#define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2 +#define L2CAP_EXT_CTRL_SAR_SHIFT 16 +#define L2CAP_EXT_CTRL_SUPER_SHIFT 16 +#define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 /* L2CAP Supervisory Function */ #define L2CAP_SUPER_RCV_READY 0x0000 -- cgit v0.10.2 From ab784b7383735681660ccbdda4569fff196c2672 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:44 +0300 Subject: Bluetooth: EWS: rewrite handling Supervisory (S) bits Supervisory bits occupy different windows in standard / extended control fields. Convert hardcoded masks to relative ones and use shift to access S-bit window. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index fa7edab..f24f5cf 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -140,10 +140,10 @@ struct l2cap_conninfo { #define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 /* L2CAP Supervisory Function */ -#define L2CAP_SUPER_RCV_READY 0x0000 -#define L2CAP_SUPER_REJECT 0x0004 -#define L2CAP_SUPER_RCV_NOT_READY 0x0008 -#define L2CAP_SUPER_SELECT_REJECT 0x000C +#define L2CAP_SUPER_RR 0x00 +#define L2CAP_SUPER_REJ 0x01 +#define L2CAP_SUPER_RNR 0x02 +#define L2CAP_SUPER_SREJ 0x03 /* L2CAP Segmentation and Reassembly */ #define L2CAP_SDU_UNSEGMENTED 0x0000 @@ -518,6 +518,25 @@ static inline int l2cap_tx_window_full(struct l2cap_chan *ch) #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) +static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (ctrl & L2CAP_EXT_CTRL_SUPERVISE) >> + L2CAP_EXT_CTRL_SUPER_SHIFT; + else + return (ctrl & L2CAP_CTRL_SUPERVISE) >> L2CAP_CTRL_SUPER_SHIFT; +} + +static inline __u32 __set_ctrl_super(struct l2cap_chan *chan, __u32 super) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (super << L2CAP_EXT_CTRL_SUPER_SHIFT) & + L2CAP_EXT_CTRL_SUPERVISE; + else + return (super << L2CAP_CTRL_SUPER_SHIFT) & + L2CAP_CTRL_SUPERVISE; +} + extern int disable_ertm; int l2cap_init_sockets(void); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 6e34312..93b5da6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -613,10 +613,10 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) { if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { - control |= L2CAP_SUPER_RCV_NOT_READY; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); set_bit(CONN_RNR_SENT, &chan->conn_state); } else - control |= L2CAP_SUPER_RCV_READY; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; @@ -1408,7 +1408,7 @@ static void l2cap_send_ack(struct l2cap_chan *chan) control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { - control |= L2CAP_SUPER_RCV_NOT_READY; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); set_bit(CONN_RNR_SENT, &chan->conn_state); l2cap_send_sframe(chan, control); return; @@ -1417,7 +1417,7 @@ static void l2cap_send_ack(struct l2cap_chan *chan) if (l2cap_ertm_send(chan) > 0) return; - control |= L2CAP_SUPER_RCV_READY; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); l2cap_send_sframe(chan, control); } @@ -1426,7 +1426,7 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan) struct srej_list *tail; u16 control; - control = L2CAP_SUPER_SELECT_REJECT; + control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); control |= L2CAP_CTRL_FINAL; tail = list_entry((&chan->srej_l)->prev, struct srej_list, list); @@ -3119,7 +3119,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { - control |= L2CAP_SUPER_RCV_NOT_READY; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); l2cap_send_sframe(chan, control); set_bit(CONN_RNR_SENT, &chan->conn_state); } @@ -3131,7 +3131,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) if (!test_bit(CONN_LOCAL_BUSY, &chan->conn_state) && chan->frames_sent == 0) { - control |= L2CAP_SUPER_RCV_READY; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); l2cap_send_sframe(chan, control); } } @@ -3287,7 +3287,7 @@ static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan) set_bit(CONN_LOCAL_BUSY, &chan->conn_state); control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; - control |= L2CAP_SUPER_RCV_NOT_READY; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); l2cap_send_sframe(chan, control); set_bit(CONN_RNR_SENT, &chan->conn_state); @@ -3303,7 +3303,8 @@ static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan) goto done; control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; - control |= L2CAP_SUPER_RCV_READY | L2CAP_CTRL_POLL; + control |= L2CAP_CTRL_POLL; + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); l2cap_send_sframe(chan, control); chan->retry_count = 1; @@ -3367,7 +3368,7 @@ static void l2cap_resend_srejframe(struct l2cap_chan *chan, u8 tx_seq) kfree(l); return; } - control = L2CAP_SUPER_SELECT_REJECT; + control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); control |= l->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; l2cap_send_sframe(chan, control); list_del(&l->list); @@ -3381,7 +3382,7 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) u16 control; while (tx_seq != chan->expected_tx_seq) { - control = L2CAP_SUPER_SELECT_REJECT; + control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); control |= chan->expected_tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; l2cap_send_sframe(chan, control); @@ -3645,10 +3646,12 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c return; } - if (rx_control & L2CAP_CTRL_POLL) + if (rx_control & L2CAP_CTRL_POLL) { l2cap_send_srejtail(chan); - else - l2cap_send_sframe(chan, L2CAP_SUPER_RCV_READY); + } else { + rx_control = __set_ctrl_super(chan, L2CAP_SUPER_RR); + l2cap_send_sframe(chan, rx_control); + } } static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) @@ -3663,20 +3666,20 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont clear_bit(CONN_WAIT_F, &chan->conn_state); } - switch (rx_control & L2CAP_CTRL_SUPERVISE) { - case L2CAP_SUPER_RCV_READY: + switch (__get_ctrl_super(chan, rx_control)) { + case L2CAP_SUPER_RR: l2cap_data_channel_rrframe(chan, rx_control); break; - case L2CAP_SUPER_REJECT: + case L2CAP_SUPER_REJ: l2cap_data_channel_rejframe(chan, rx_control); break; - case L2CAP_SUPER_SELECT_REJECT: + case L2CAP_SUPER_SREJ: l2cap_data_channel_srejframe(chan, rx_control); break; - case L2CAP_SUPER_RCV_NOT_READY: + case L2CAP_SUPER_RNR: l2cap_data_channel_rnrframe(chan, rx_control); break; } -- cgit v0.10.2 From 7e0ef6ee13ecdf38c2c8b0b0c8ef729710b994eb Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:45 +0300 Subject: Bluetooth: EWS: rewrite handling SAR bits Segmentation and Reassembly (SAR) occupies different windows in standard and extended control fields. Convert hardcoded masks to relative ones and use shift to access SAR bits. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index f24f5cf..0759ac6 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -146,10 +146,10 @@ struct l2cap_conninfo { #define L2CAP_SUPER_SREJ 0x03 /* L2CAP Segmentation and Reassembly */ -#define L2CAP_SDU_UNSEGMENTED 0x0000 -#define L2CAP_SDU_START 0x4000 -#define L2CAP_SDU_END 0x8000 -#define L2CAP_SDU_CONTINUE 0xC000 +#define L2CAP_SAR_UNSEGMENTED 0x00 +#define L2CAP_SAR_START 0x01 +#define L2CAP_SAR_END 0x02 +#define L2CAP_SAR_CONTINUE 0x03 /* L2CAP Command rej. reasons */ #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 @@ -516,7 +516,34 @@ static inline int l2cap_tx_window_full(struct l2cap_chan *ch) #define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) -#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) +static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (ctrl & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT; + else + return (ctrl & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT; +} + +static inline __u32 __set_ctrl_sar(struct l2cap_chan *chan, __u32 sar) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (sar << L2CAP_EXT_CTRL_SAR_SHIFT) & L2CAP_EXT_CTRL_SAR; + else + return (sar << L2CAP_CTRL_SAR_SHIFT) & L2CAP_CTRL_SAR; +} + +static inline bool __is_sar_start(struct l2cap_chan *chan, __u32 ctrl) +{ + return __get_ctrl_sar(chan, ctrl) == L2CAP_SAR_START; +} + +static inline __u32 __get_sar_mask(struct l2cap_chan *chan) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return L2CAP_EXT_CTRL_SAR; + else + return L2CAP_CTRL_SAR; +} static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) { diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 93b5da6..9ee42ba 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1311,7 +1311,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) tx_skb = skb_clone(skb, GFP_ATOMIC); bt_cb(skb)->retries++; control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); - control &= L2CAP_CTRL_SAR; + control &= __get_sar_mask(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) control |= L2CAP_CTRL_FINAL; @@ -1351,7 +1351,7 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) bt_cb(skb)->retries++; control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); - control &= L2CAP_CTRL_SAR; + control &= __get_sar_mask(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) control |= L2CAP_CTRL_FINAL; @@ -1582,7 +1582,7 @@ static int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, si size_t size = 0; skb_queue_head_init(&sar_queue); - control = L2CAP_SDU_START; + control = __set_ctrl_sar(chan, L2CAP_SAR_START); skb = l2cap_create_iframe_pdu(chan, msg, chan->remote_mps, control, len); if (IS_ERR(skb)) return PTR_ERR(skb); @@ -1595,10 +1595,10 @@ static int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, si size_t buflen; if (len > chan->remote_mps) { - control = L2CAP_SDU_CONTINUE; + control = __set_ctrl_sar(chan, L2CAP_SAR_CONTINUE); buflen = chan->remote_mps; } else { - control = L2CAP_SDU_END; + control = __set_ctrl_sar(chan, L2CAP_SAR_END); buflen = len; } @@ -1654,7 +1654,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) case L2CAP_MODE_STREAMING: /* Entire SDU fits into one PDU */ if (len <= chan->remote_mps) { - control = L2CAP_SDU_UNSEGMENTED; + control = __set_ctrl_sar(chan, L2CAP_SAR_UNSEGMENTED); skb = l2cap_create_iframe_pdu(chan, msg, len, control, 0); if (IS_ERR(skb)) @@ -3201,15 +3201,15 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u1 { int err = -EINVAL; - switch (control & L2CAP_CTRL_SAR) { - case L2CAP_SDU_UNSEGMENTED: + switch (__get_ctrl_sar(chan, control)) { + case L2CAP_SAR_UNSEGMENTED: if (chan->sdu) break; err = chan->ops->recv(chan->data, skb); break; - case L2CAP_SDU_START: + case L2CAP_SAR_START: if (chan->sdu) break; @@ -3231,7 +3231,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u1 err = 0; break; - case L2CAP_SDU_CONTINUE: + case L2CAP_SAR_CONTINUE: if (!chan->sdu) break; @@ -3245,7 +3245,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u1 err = 0; break; - case L2CAP_SDU_END: + case L2CAP_SAR_END: if (!chan->sdu) break; @@ -3343,7 +3343,7 @@ static void l2cap_check_srej_gap(struct l2cap_chan *chan, u8 tx_seq) break; skb = skb_dequeue(&chan->srej_q); - control = bt_cb(skb)->sar << L2CAP_CTRL_SAR_SHIFT; + control = __set_ctrl_sar(chan, bt_cb(skb)->sar); err = l2cap_reassemble_sdu(chan, skb, control); if (err < 0) { @@ -3398,7 +3398,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont { u8 tx_seq = __get_txseq(rx_control); u8 req_seq = __get_reqseq(rx_control); - u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT; + u8 sar = __get_ctrl_sar(chan, rx_control); int tx_seq_offset, expected_tx_seq_offset; int num_to_ack = (chan->tx_win/6) + 1; int err = 0; @@ -3707,7 +3707,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) if (l2cap_check_fcs(chan, skb)) goto drop; - if (__is_sar_start(control) && __is_iframe(control)) + if (__is_sar_start(chan, control) && __is_iframe(control)) len -= 2; if (chan->fcs == L2CAP_FCS_CRC16) @@ -3811,7 +3811,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk if (l2cap_check_fcs(chan, skb)) goto drop; - if (__is_sar_start(control)) + if (__is_sar_start(chan, control)) len -= 2; if (chan->fcs == L2CAP_FCS_CRC16) -- cgit v0.10.2 From 0b209fae88c6e844f2ee9d4d791f0f31f7f42ae9 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:46 +0300 Subject: Bluetooth: EWS: rewrite reqseq calculation reqseq calculation uses now information about control field type. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 0759ac6..57b64bb 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -365,11 +365,11 @@ struct l2cap_chan { __u8 next_tx_seq; __u8 expected_ack_seq; __u8 expected_tx_seq; - __u8 buffer_seq; __u8 buffer_seq_srej; __u8 srej_save_reqseq; __u8 frames_sent; __u8 unacked_frames; + __u16 buffer_seq; __u8 retry_count; __u8 num_acked; __u16 sdu_len; @@ -512,8 +512,24 @@ static inline int l2cap_tx_window_full(struct l2cap_chan *ch) return sub == ch->remote_tx_win; } +static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (ctrl & L2CAP_EXT_CTRL_REQSEQ) >> + L2CAP_EXT_CTRL_REQSEQ_SHIFT; + else + return (ctrl & L2CAP_CTRL_REQSEQ) >> L2CAP_CTRL_REQSEQ_SHIFT; +} + +static inline __u32 __set_reqseq(struct l2cap_chan *chan, __u32 reqseq) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (reqseq << L2CAP_EXT_CTRL_REQSEQ_SHIFT) & + L2CAP_EXT_CTRL_REQSEQ; + else + return (reqseq << L2CAP_CTRL_REQSEQ_SHIFT) & L2CAP_CTRL_REQSEQ; +} #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) -#define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 9ee42ba..f35eb73 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -618,7 +618,7 @@ static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) } else control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); - control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control |= __set_reqseq(chan, chan->buffer_seq); l2cap_send_sframe(chan, control); } @@ -1316,8 +1316,8 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) control |= L2CAP_CTRL_FINAL; - control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) - | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); + control |= __set_reqseq(chan, chan->buffer_seq); + control |= tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); @@ -1356,8 +1356,8 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) control |= L2CAP_CTRL_FINAL; - control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) - | (chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); + control |= __set_reqseq(chan, chan->buffer_seq); + control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); @@ -1405,7 +1405,7 @@ static void l2cap_send_ack(struct l2cap_chan *chan) { u16 control = 0; - control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control |= __set_reqseq(chan, chan->buffer_seq); if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); @@ -1430,7 +1430,7 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan) control |= L2CAP_CTRL_FINAL; tail = list_entry((&chan->srej_l)->prev, struct srej_list, list); - control |= tail->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control |= __set_reqseq(chan, tail->tx_seq); l2cap_send_sframe(chan, control); } @@ -3116,7 +3116,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) chan->frames_sent = 0; - control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control |= __set_reqseq(chan, chan->buffer_seq); if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); @@ -3286,7 +3286,7 @@ static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan) set_bit(CONN_LOCAL_BUSY, &chan->conn_state); - control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control = __set_reqseq(chan, chan->buffer_seq); control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); l2cap_send_sframe(chan, control); @@ -3302,7 +3302,7 @@ static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan) if (!test_bit(CONN_RNR_SENT, &chan->conn_state)) goto done; - control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control = __set_reqseq(chan, chan->buffer_seq); control |= L2CAP_CTRL_POLL; control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); l2cap_send_sframe(chan, control); @@ -3369,7 +3369,7 @@ static void l2cap_resend_srejframe(struct l2cap_chan *chan, u8 tx_seq) return; } control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); - control |= l->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control |= __set_reqseq(chan, l->tx_seq); l2cap_send_sframe(chan, control); list_del(&l->list); list_add_tail(&l->list, &chan->srej_l); @@ -3383,7 +3383,7 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) while (tx_seq != chan->expected_tx_seq) { control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); - control |= chan->expected_tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; + control |= __set_reqseq(chan, chan->expected_tx_seq); l2cap_send_sframe(chan, control); new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC); @@ -3397,7 +3397,7 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) { u8 tx_seq = __get_txseq(rx_control); - u8 req_seq = __get_reqseq(rx_control); + u16 req_seq = __get_reqseq(chan, rx_control); u8 sar = __get_ctrl_sar(chan, rx_control); int tx_seq_offset, expected_tx_seq_offset; int num_to_ack = (chan->tx_win/6) + 1; @@ -3531,10 +3531,10 @@ drop: static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control) { - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, __get_reqseq(rx_control), - rx_control); + BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, + __get_reqseq(chan, rx_control), rx_control); - chan->expected_ack_seq = __get_reqseq(rx_control); + chan->expected_ack_seq = __get_reqseq(chan, rx_control); l2cap_drop_acked_frames(chan); if (rx_control & L2CAP_CTRL_POLL) { @@ -3571,7 +3571,7 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_control) { - u8 tx_seq = __get_reqseq(rx_control); + u16 tx_seq = __get_reqseq(chan, rx_control); BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); @@ -3592,7 +3592,7 @@ static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_c } static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control) { - u8 tx_seq = __get_reqseq(rx_control); + u16 tx_seq = __get_reqseq(chan, rx_control); BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); @@ -3628,7 +3628,7 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_control) { - u8 tx_seq = __get_reqseq(rx_control); + u16 tx_seq = __get_reqseq(chan, rx_control); BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); @@ -3692,7 +3692,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) { struct l2cap_chan *chan = l2cap_pi(sk)->chan; u16 control; - u8 req_seq; + u16 req_seq; int len, next_tx_seq_offset, req_seq_offset; control = get_unaligned_le16(skb->data); @@ -3718,7 +3718,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) goto drop; } - req_seq = __get_reqseq(control); + req_seq = __get_reqseq(chan, control); req_seq_offset = (req_seq - chan->expected_ack_seq) % 64; if (req_seq_offset < 0) req_seq_offset += 64; -- cgit v0.10.2 From fb45de7dbaf2cf8eec43a88bdb98889f0d4d5d5f Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:47 +0300 Subject: Bluetooth: EWS: rewrite L2CAP ERTM txseq calculation L2CAP ERTM txseq calculation uses now information about control field type. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 57b64bb..3ca24af 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -316,7 +316,7 @@ struct l2cap_conn_param_update_rsp { /* ----- L2CAP channels and connections ----- */ struct srej_list { - __u8 tx_seq; + __u16 tx_seq; struct list_head list; }; @@ -362,14 +362,14 @@ struct l2cap_chan { unsigned long conn_state; unsigned long flags; - __u8 next_tx_seq; - __u8 expected_ack_seq; - __u8 expected_tx_seq; - __u8 buffer_seq_srej; - __u8 srej_save_reqseq; - __u8 frames_sent; - __u8 unacked_frames; + __u16 next_tx_seq; + __u16 expected_ack_seq; + __u16 expected_tx_seq; __u16 buffer_seq; + __u16 buffer_seq_srej; + __u16 srej_save_reqseq; + __u16 frames_sent; + __u16 unacked_frames; __u8 retry_count; __u8 num_acked; __u16 sdu_len; @@ -529,7 +529,25 @@ static inline __u32 __set_reqseq(struct l2cap_chan *chan, __u32 reqseq) else return (reqseq << L2CAP_CTRL_REQSEQ_SHIFT) & L2CAP_CTRL_REQSEQ; } -#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) + +static inline __u16 __get_txseq(struct l2cap_chan *chan, __u32 ctrl) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (ctrl & L2CAP_EXT_CTRL_TXSEQ) >> + L2CAP_EXT_CTRL_TXSEQ_SHIFT; + else + return (ctrl & L2CAP_CTRL_TXSEQ) >> L2CAP_CTRL_TXSEQ_SHIFT; +} + +static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return (txseq << L2CAP_EXT_CTRL_TXSEQ_SHIFT) & + L2CAP_EXT_CTRL_TXSEQ; + else + return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; +} + #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index f35eb73..1c367d6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1270,7 +1270,7 @@ static void l2cap_streaming_send(struct l2cap_chan *chan) while ((skb = skb_dequeue(&chan->tx_q))) { control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); - control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; + control |= __set_txseq(chan, chan->next_tx_seq); put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); if (chan->fcs == L2CAP_FCS_CRC16) { @@ -1284,7 +1284,7 @@ static void l2cap_streaming_send(struct l2cap_chan *chan) } } -static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) +static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) { struct sk_buff *skb, *tx_skb; u16 control, fcs; @@ -1317,7 +1317,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) control |= L2CAP_CTRL_FINAL; control |= __set_reqseq(chan, chan->buffer_seq); - control |= tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; + control |= __set_txseq(chan, tx_seq); put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); @@ -1357,7 +1357,7 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) control |= L2CAP_CTRL_FINAL; control |= __set_reqseq(chan, chan->buffer_seq); - control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; + control |= __set_txseq(chan, chan->next_tx_seq); put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); @@ -3136,7 +3136,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) } } -static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, u8 tx_seq, u8 sar) +static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, u16 tx_seq, u8 sar) { struct sk_buff *next_skb; int tx_seq_offset, next_tx_seq_offset; @@ -3330,7 +3330,7 @@ void l2cap_chan_busy(struct l2cap_chan *chan, int busy) } } -static void l2cap_check_srej_gap(struct l2cap_chan *chan, u8 tx_seq) +static void l2cap_check_srej_gap(struct l2cap_chan *chan, u16 tx_seq) { struct sk_buff *skb; u16 control; @@ -3357,7 +3357,7 @@ static void l2cap_check_srej_gap(struct l2cap_chan *chan, u8 tx_seq) } } -static void l2cap_resend_srejframe(struct l2cap_chan *chan, u8 tx_seq) +static void l2cap_resend_srejframe(struct l2cap_chan *chan, u16 tx_seq) { struct srej_list *l, *tmp; u16 control; @@ -3376,7 +3376,7 @@ static void l2cap_resend_srejframe(struct l2cap_chan *chan, u8 tx_seq) } } -static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) +static void l2cap_send_srejframe(struct l2cap_chan *chan, u16 tx_seq) { struct srej_list *new; u16 control; @@ -3396,7 +3396,7 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) { - u8 tx_seq = __get_txseq(rx_control); + u16 tx_seq = __get_txseq(chan, rx_control); u16 req_seq = __get_reqseq(chan, rx_control); u8 sar = __get_ctrl_sar(chan, rx_control); int tx_seq_offset, expected_tx_seq_offset; @@ -3763,7 +3763,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk struct l2cap_chan *chan; struct sock *sk = NULL; u16 control; - u8 tx_seq; + u16 tx_seq; int len; chan = l2cap_get_chan_by_scid(conn, cid); @@ -3820,7 +3820,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk if (len > chan->mps || len < 0 || __is_sframe(control)) goto drop; - tx_seq = __get_txseq(control); + tx_seq = __get_txseq(chan, control); if (chan->expected_tx_seq != tx_seq) { /* Frame(s) missing - must discard partial SDU */ -- cgit v0.10.2 From 793c2f1cb9d722231290daf1744e6c5b7269f445 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:48 +0300 Subject: Bluetooth: EWS: rewrite check frame type function Check frame function uses now information about control field type. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 3ca24af..9444dce 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -548,8 +548,22 @@ static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; } -#define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) -#define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) +static inline bool __is_sframe(struct l2cap_chan *chan, __u32 ctrl) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return ctrl & L2CAP_EXT_CTRL_FRAME_TYPE; + else + return ctrl & L2CAP_CTRL_FRAME_TYPE; +} + +static inline __u32 __set_sframe(struct l2cap_chan *chan) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return L2CAP_EXT_CTRL_FRAME_TYPE; + else + return L2CAP_CTRL_FRAME_TYPE; +} + static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) { if (test_bit(FLAG_EXT_CTRL, &chan->flags)) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 1c367d6..9262a00 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -578,7 +578,8 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) BT_DBG("chan %p, control 0x%2.2x", chan, control); count = min_t(unsigned int, conn->mtu, hlen); - control |= L2CAP_CTRL_FRAME_TYPE; + + control |= __set_sframe(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) control |= L2CAP_CTRL_FINAL; @@ -3707,7 +3708,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) if (l2cap_check_fcs(chan, skb)) goto drop; - if (__is_sar_start(chan, control) && __is_iframe(control)) + if (__is_sar_start(chan, control) && !__is_sframe(chan, control)) len -= 2; if (chan->fcs == L2CAP_FCS_CRC16) @@ -3734,7 +3735,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) goto drop; } - if (__is_iframe(control)) { + if (!__is_sframe(chan, control)) { if (len < 0) { l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); goto drop; @@ -3817,7 +3818,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk if (chan->fcs == L2CAP_FCS_CRC16) len -= 2; - if (len > chan->mps || len < 0 || __is_sframe(control)) + if (len > chan->mps || len < 0 || __is_sframe(chan, control)) goto drop; tx_seq = __get_txseq(chan, control); -- cgit v0.10.2 From 03f6715d463e6ee3e724ac64a9bedf1ad7d2b9b4 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:49 +0300 Subject: Bluetooth: EWS: rewrite handling FINAL (F) bit Handle final (F) bit in L2CAP using information about control field type. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 9444dce..3110c43 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -612,6 +612,21 @@ static inline __u32 __set_ctrl_super(struct l2cap_chan *chan, __u32 super) L2CAP_CTRL_SUPERVISE; } +static inline __u32 __set_ctrl_final(struct l2cap_chan *chan) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return L2CAP_EXT_CTRL_FINAL; + else + return L2CAP_CTRL_FINAL; +} + +static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return ctrl & L2CAP_EXT_CTRL_FINAL; + else + return ctrl & L2CAP_CTRL_FINAL; +} extern int disable_ertm; int l2cap_init_sockets(void); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 9262a00..c500d1c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -582,7 +582,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) control |= __set_sframe(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) - control |= L2CAP_CTRL_FINAL; + control |= __set_ctrl_final(chan); if (test_and_clear_bit(CONN_SEND_PBIT, &chan->conn_state)) control |= L2CAP_CTRL_POLL; @@ -1315,7 +1315,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) control &= __get_sar_mask(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) - control |= L2CAP_CTRL_FINAL; + control |= __set_ctrl_final(chan); control |= __set_reqseq(chan, chan->buffer_seq); control |= __set_txseq(chan, tx_seq); @@ -1355,7 +1355,7 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) control &= __get_sar_mask(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) - control |= L2CAP_CTRL_FINAL; + control |= __set_ctrl_final(chan); control |= __set_reqseq(chan, chan->buffer_seq); control |= __set_txseq(chan, chan->next_tx_seq); @@ -1428,7 +1428,7 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan) u16 control; control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); - control |= L2CAP_CTRL_FINAL; + control |= __set_ctrl_final(chan); tail = list_entry((&chan->srej_l)->prev, struct srej_list, list); control |= __set_reqseq(chan, tail->tx_seq); @@ -3407,7 +3407,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont BT_DBG("chan %p len %d tx_seq %d rx_control 0x%4.4x", chan, skb->len, tx_seq, rx_control); - if (L2CAP_CTRL_FINAL & rx_control && + if (__is_ctrl_final(chan, rx_control) && test_bit(CONN_WAIT_F, &chan->conn_state)) { __clear_monitor_timer(chan); if (chan->unacked_frames > 0) @@ -3512,7 +3512,7 @@ expected: return err; } - if (rx_control & L2CAP_CTRL_FINAL) { + if (__is_ctrl_final(chan, rx_control)) { if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) l2cap_retransmit_frames(chan); } @@ -3551,7 +3551,7 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co l2cap_send_i_or_rr_or_rnr(chan); } - } else if (rx_control & L2CAP_CTRL_FINAL) { + } else if (__is_ctrl_final(chan, rx_control)) { clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) @@ -3581,7 +3581,7 @@ static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_c chan->expected_ack_seq = tx_seq; l2cap_drop_acked_frames(chan); - if (rx_control & L2CAP_CTRL_FINAL) { + if (__is_ctrl_final(chan, rx_control)) { if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) l2cap_retransmit_frames(chan); } else { @@ -3612,7 +3612,7 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_ chan->srej_save_reqseq = tx_seq; set_bit(CONN_SREJ_ACT, &chan->conn_state); } - } else if (rx_control & L2CAP_CTRL_FINAL) { + } else if (__is_ctrl_final(chan, rx_control)) { if (test_bit(CONN_SREJ_ACT, &chan->conn_state) && chan->srej_save_reqseq == tx_seq) clear_bit(CONN_SREJ_ACT, &chan->conn_state); @@ -3659,7 +3659,7 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont { BT_DBG("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len); - if (L2CAP_CTRL_FINAL & rx_control && + if (__is_ctrl_final(chan, rx_control) && test_bit(CONN_WAIT_F, &chan->conn_state)) { __clear_monitor_timer(chan); if (chan->unacked_frames > 0) -- cgit v0.10.2 From e37817353bf94a4e00faad78ffb8cc07f8556252 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:50 +0300 Subject: Bluetooth: EWS: rewrite handling POLL (P) bit Handle POLL (P) bit in L2CAP ERTM using information about control field type. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 3110c43..67a2fdb 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -627,6 +627,22 @@ static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl) else return ctrl & L2CAP_CTRL_FINAL; } + +static inline __u32 __set_ctrl_poll(struct l2cap_chan *chan) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return L2CAP_EXT_CTRL_POLL; + else + return L2CAP_CTRL_POLL; +} + +static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return ctrl & L2CAP_EXT_CTRL_POLL; + else + return ctrl & L2CAP_CTRL_POLL; +} extern int disable_ertm; int l2cap_init_sockets(void); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index c500d1c..97aa545 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -585,7 +585,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) control |= __set_ctrl_final(chan); if (test_and_clear_bit(CONN_SEND_PBIT, &chan->conn_state)) - control |= L2CAP_CTRL_POLL; + control |= __set_ctrl_poll(chan); skb = bt_skb_alloc(count, GFP_ATOMIC); if (!skb) @@ -3304,7 +3304,7 @@ static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan) goto done; control = __set_reqseq(chan, chan->buffer_seq); - control |= L2CAP_CTRL_POLL; + control |= __set_ctrl_poll(chan); control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); l2cap_send_sframe(chan, control); chan->retry_count = 1; @@ -3538,7 +3538,7 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co chan->expected_ack_seq = __get_reqseq(chan, rx_control); l2cap_drop_acked_frames(chan); - if (rx_control & L2CAP_CTRL_POLL) { + if (__is_ctrl_poll(chan, rx_control)) { set_bit(CONN_SEND_FBIT, &chan->conn_state); if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) { if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state) && @@ -3599,7 +3599,7 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_ clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); - if (rx_control & L2CAP_CTRL_POLL) { + if (__is_ctrl_poll(chan, rx_control)) { chan->expected_ack_seq = tx_seq; l2cap_drop_acked_frames(chan); @@ -3637,17 +3637,17 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c chan->expected_ack_seq = tx_seq; l2cap_drop_acked_frames(chan); - if (rx_control & L2CAP_CTRL_POLL) + if (__is_ctrl_poll(chan, rx_control)) set_bit(CONN_SEND_FBIT, &chan->conn_state); if (!test_bit(CONN_SREJ_SENT, &chan->conn_state)) { __clear_retrans_timer(chan); - if (rx_control & L2CAP_CTRL_POLL) + if (__is_ctrl_poll(chan, rx_control)) l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_FINAL); return; } - if (rx_control & L2CAP_CTRL_POLL) { + if (__is_ctrl_poll(chan, rx_control)) { l2cap_send_srejtail(chan); } else { rx_control = __set_ctrl_super(chan, L2CAP_SUPER_RR); -- cgit v0.10.2 From e4ca6d9854dc252e294007fc91249ce34d9a82e8 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:52 +0300 Subject: Bluetooth: EWS: recalculate L2CAP header size Recalculate length of L2CAP header based on Control field length. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 97aa545..439e715 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -566,12 +566,17 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) struct sk_buff *skb; struct l2cap_hdr *lh; struct l2cap_conn *conn = chan->conn; - int count, hlen = L2CAP_HDR_SIZE + 2; + int count, hlen; u8 flags; if (chan->state != BT_CONNECTED) return; + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + hlen = L2CAP_EXT_HDR_SIZE; + else + hlen = L2CAP_ENH_HDR_SIZE; + if (chan->fcs == L2CAP_FCS_CRC16) hlen += 2; @@ -1534,7 +1539,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; struct sk_buff *skb; - int err, count, hlen = L2CAP_HDR_SIZE + 2; + int err, count, hlen; struct l2cap_hdr *lh; BT_DBG("sk %p len %d", sk, (int)len); @@ -1542,6 +1547,11 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, if (!conn) return ERR_PTR(-ENOTCONN); + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + hlen = L2CAP_EXT_HDR_SIZE; + else + hlen = L2CAP_ENH_HDR_SIZE; + if (sdulen) hlen += 2; @@ -3098,7 +3108,12 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, static int l2cap_check_fcs(struct l2cap_chan *chan, struct sk_buff *skb) { u16 our_fcs, rcv_fcs; - int hdr_size = L2CAP_HDR_SIZE + 2; + int hdr_size; + + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + hdr_size = L2CAP_EXT_HDR_SIZE; + else + hdr_size = L2CAP_ENH_HDR_SIZE; if (chan->fcs == L2CAP_FCS_CRC16) { skb_trim(skb, skb->len - 2); -- cgit v0.10.2 From d43cb289b065121cbf99434502cf544daf262c5a Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 11 Oct 2011 13:37:54 +0300 Subject: Bluetooth: EWS: define L2CAP header sizes Adds definitins for L2CAP header sizes to be uses when calculating payload size instead of magic numbers. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 67a2fdb..806b950 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -162,6 +162,12 @@ struct l2cap_hdr { __le16 cid; } __packed; #define L2CAP_HDR_SIZE 4 +#define L2CAP_ENH_HDR_SIZE 6 +#define L2CAP_EXT_HDR_SIZE 8 + +#define L2CAP_FCS_SIZE 2 +#define L2CAP_SDULEN_SIZE 2 +#define L2CAP_PSMLEN_SIZE 2 struct l2cap_cmd_hdr { __u8 code; -- cgit v0.10.2 From 5a9e7057c5b3feed2d403ef69cfb0bdbacab3a6d Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 13 Oct 2011 16:18:53 +0300 Subject: Bluetooth: EFS: definitions and headers Define Extended Flow Specification structures and default values. Based upon haijun.liu series of patches (sent Sun, 22 Aug 2010) Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 806b950..3b54e9b 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -241,6 +241,7 @@ struct l2cap_conf_rsp { #define L2CAP_CONF_UNACCEPT 0x0001 #define L2CAP_CONF_REJECT 0x0002 #define L2CAP_CONF_UNKNOWN 0x0003 +#define L2CAP_CONF_EFS_REJECT 0x0005 struct l2cap_conf_opt { __u8 type; @@ -257,6 +258,7 @@ struct l2cap_conf_opt { #define L2CAP_CONF_QOS 0x03 #define L2CAP_CONF_RFC 0x04 #define L2CAP_CONF_FCS 0x05 +#define L2CAP_CONF_EFS 0x06 #define L2CAP_CONF_EWS 0x07 #define L2CAP_CONF_MAX_SIZE 22 @@ -276,6 +278,15 @@ struct l2cap_conf_rfc { #define L2CAP_MODE_ERTM 0x03 #define L2CAP_MODE_STREAMING 0x04 +struct l2cap_conf_efs { + __u8 id; + __u8 stype; + __le16 msdu; + __le32 sdu_itime; + __le32 acc_lat; + __le32 flush_to; +} __packed; + struct l2cap_disconn_req { __le16 dcid; __le16 scid; @@ -386,6 +397,20 @@ struct l2cap_chan { __u8 remote_max_tx; __u16 remote_mps; + __u8 local_id; + __u8 local_stype; + __u16 local_msdu; + __u32 local_sdu_itime; + __u32 local_acc_lat; + __u32 local_flush_to; + + __u8 remote_id; + __u8 remote_stype; + __u16 remote_msdu; + __u32 remote_sdu_itime; + __u32 remote_acc_lat; + __u32 remote_flush_to; + struct timer_list chan_timer; struct timer_list retrans_timer; struct timer_list monitor_timer; @@ -492,6 +517,7 @@ enum { FLAG_FORCE_RELIABLE, FLAG_FLUSHABLE, FLAG_EXT_CTRL, + FLAG_EFS_ENABLE, }; #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) -- cgit v0.10.2 From 8f7975b153faab4b78369458a892dd705e7c395b Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 13 Oct 2011 16:18:54 +0300 Subject: Bluetooth: EFS: assign default values in chan add Assign default EFS values when creating L2CAP channel Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 3b54e9b..e67ecd1 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -39,6 +39,9 @@ #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ #define L2CAP_DEFAULT_ACK_TO 200 #define L2CAP_LE_DEFAULT_MTU 23 +#define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF +#define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF +#define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ @@ -287,6 +290,12 @@ struct l2cap_conf_efs { __le32 flush_to; } __packed; +#define L2CAP_SERV_NOTRAFIC 0x00 +#define L2CAP_SERV_BESTEFFORT 0x01 +#define L2CAP_SERV_GUARANTEED 0x02 + +#define L2CAP_BESTEFFORT_ID 0x01 + struct l2cap_disconn_req { __le16 dcid; __le16 scid; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 439e715..410c9cd 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -338,6 +338,13 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) chan->omtu = L2CAP_DEFAULT_MTU; } + chan->local_id = L2CAP_BESTEFFORT_ID; + chan->local_stype = L2CAP_SERV_BESTEFFORT; + chan->local_msdu = L2CAP_DEFAULT_MAX_SDU_SIZE; + chan->local_sdu_itime = L2CAP_DEFAULT_SDU_ITIME; + chan->local_acc_lat = L2CAP_DEFAULT_ACC_LAT; + chan->local_flush_to = L2CAP_DEFAULT_FLUSH_TO; + chan_hold(chan); list_add(&chan->list, &conn->chan_l); -- cgit v0.10.2 From f89cef09cee60a9715150a6e335dce4e64df7400 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 13 Oct 2011 16:18:55 +0300 Subject: Bluetooth: EFS: add efs option in L2CAP conf req Add Extended Flow Specification option when building L2CAP Configuration Request. EFS is added if both the local and remote L2CAP entities have indicated support for the Extended Flow Specification for BR/EDR. ... < ACL data: handle 1 flags 0x00 dlen 10 L2CAP(s): Info req: type 2 > ACL data: handle 1 flags 0x02 dlen 16 L2CAP(s): Info rsp: type 2 result 0 Extended feature mask 0x01f8 Enhanced Retransmission mode Streaming mode FCS Option Extended Flow Specification Fixed Channels Extended Window Size ... < ACL data: handle 1 flags 0x00 dlen 45 L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 33 RFC 0x03 (Enhanced Retransmission, TxWin 63, MaxTx 3, RTo 0, MTo 0, MPS 498) EFS (Id 0x01, SerType Best Effort, MaxSDU 0xffff, SDUitime 0xffffffff, AccLat 0xffffffff, FlushTO 0x0000ffff) ... Based upon haijun.liu series of patches (sent Sun, 22 Aug 2010) Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 410c9cd..2213346 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1870,6 +1870,37 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val) *ptr += L2CAP_CONF_OPT_SIZE + len; } +static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan) +{ + struct l2cap_conf_efs efs; + + switch(chan->mode) { + case L2CAP_MODE_ERTM: + efs.id = chan->local_id; + efs.stype = chan->local_stype; + efs.msdu = cpu_to_le16(chan->local_msdu); + efs.sdu_itime = cpu_to_le32(chan->local_sdu_itime); + efs.acc_lat = cpu_to_le32(L2CAP_DEFAULT_ACC_LAT); + efs.flush_to = cpu_to_le32(L2CAP_DEFAULT_FLUSH_TO); + break; + + case L2CAP_MODE_STREAMING: + efs.id = 1; + efs.stype = L2CAP_SERV_BESTEFFORT; + efs.msdu = cpu_to_le16(chan->local_msdu); + efs.sdu_itime = cpu_to_le32(chan->local_sdu_itime); + efs.acc_lat = 0; + efs.flush_to = 0; + break; + + default: + return; + } + + l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs), + (unsigned long) &efs); +} + static void l2cap_ack_timeout(unsigned long arg) { struct l2cap_chan *chan = (void *) arg; @@ -1921,6 +1952,11 @@ static inline bool __l2cap_ews_supported(struct l2cap_chan *chan) return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_WINDOW; } +static inline bool __l2cap_efs_supported(struct l2cap_chan *chan) +{ + return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_FLOW; +} + static inline void l2cap_txwin_setup(struct l2cap_chan *chan) { if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && @@ -1949,6 +1985,9 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) break; + if (__l2cap_efs_supported(chan)) + set_bit(FLAG_EFS_ENABLE, &chan->flags); + /* fall through */ default: chan->mode = l2cap_select_mode(rfc.mode, chan->conn->feat_mask); @@ -1993,6 +2032,9 @@ done: l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) + l2cap_add_opt_efs(&ptr, chan); + if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS)) break; @@ -2020,6 +2062,9 @@ done: l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) + l2cap_add_opt_efs(&ptr, chan); + if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS)) break; -- cgit v0.10.2 From 928abaa777501ddab94b1b49aae485a2c730d303 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 12 Oct 2011 10:53:57 +0300 Subject: Bluetooth: AMP: read local amp info HCI command Implementation of Read Local AMP Info Command Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index aaf79af..c5fcd13 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -726,6 +726,21 @@ struct hci_cp_write_page_scan_activity { #define PAGE_SCAN_TYPE_STANDARD 0x00 #define PAGE_SCAN_TYPE_INTERLACED 0x01 +#define HCI_OP_READ_LOCAL_AMP_INFO 0x1409 +struct hci_rp_read_local_amp_info { + __u8 status; + __u8 amp_status; + __le32 total_bw; + __le32 max_bw; + __le32 min_latency; + __le32 max_pdu; + __u8 amp_type; + __le16 pal_cap; + __le16 max_assoc_size; + __le32 max_flush_to; + __le32 be_flush_to; +} __packed; + #define HCI_OP_LE_SET_EVENT_MASK 0x2001 struct hci_cp_le_set_event_mask { __u8 mask[8]; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5b92442..32cddb0 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -150,6 +150,17 @@ struct hci_dev { __u16 sniff_min_interval; __u16 sniff_max_interval; + __u8 amp_status; + __u32 amp_total_bw; + __u32 amp_max_bw; + __u32 amp_min_latency; + __u32 amp_max_pdu; + __u8 amp_type; + __u16 amp_pal_cap; + __u16 amp_assoc_size; + __u32 amp_max_flush_to; + __u32 amp_be_flush_to; + unsigned int auto_accept_delay; unsigned long quirks; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0e57634..41967fe 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -748,6 +748,30 @@ static void hci_cc_write_ca_timeout(struct hci_dev *hdev, struct sk_buff *skb) hci_req_complete(hdev, HCI_OP_WRITE_CA_TIMEOUT, status); } +static void hci_cc_read_local_amp_info(struct hci_dev *hdev, + struct sk_buff *skb) +{ + struct hci_rp_read_local_amp_info *rp = (void *) skb->data; + + BT_DBG("%s status 0x%x", hdev->name, rp->status); + + if (rp->status) + return; + + hdev->amp_status = rp->amp_status; + hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); + hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); + hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); + hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); + hdev->amp_type = rp->amp_type; + hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); + hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); + hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); + hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); + + hci_req_complete(hdev, HCI_OP_READ_LOCAL_AMP_INFO, rp->status); +} + static void hci_cc_delete_stored_link_key(struct hci_dev *hdev, struct sk_buff *skb) { @@ -1898,6 +1922,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk hci_cc_write_ca_timeout(hdev, skb); break; + case HCI_OP_READ_LOCAL_AMP_INFO: + hci_cc_read_local_amp_info(hdev, skb); + break; + case HCI_OP_DELETE_STORED_LINK_KEY: hci_cc_delete_stored_link_key(hdev, skb); break; -- cgit v0.10.2 From 0ac7e7002c4d0841197e9ccb8cfecc5b8c58b200 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 8 Oct 2011 14:58:47 +0200 Subject: Bluetooth: Fix hci core device initialization We must not call device_del() if we didn't use device_add(). See module.c for comments on that. Therefore, we need to call device_initialize() when allocating the hci device and later device_add() instead of device_register(). This also fixes a bug when hci_register_dev() failed and we call hci_free_dev() without a valid core device. hci_free_dev() segfaults while calling put_device() on invalid memory. We already do this with hci_conn connections (hci_conn_init_sysfs()) so they do not need to be fixed. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 32cddb0..c8cc23c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -608,6 +608,7 @@ int hci_recv_frame(struct sk_buff *skb); int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); +void hci_init_sysfs(struct hci_dev *hdev); int hci_register_sysfs(struct hci_dev *hdev); void hci_unregister_sysfs(struct hci_dev *hdev); void hci_conn_init_sysfs(struct hci_conn *conn); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index b84458d..d2445cb 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -912,6 +912,7 @@ struct hci_dev *hci_alloc_dev(void) if (!hdev) return NULL; + hci_init_sysfs(hdev); skb_queue_head_init(&hdev->driver_init); return hdev; diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 22f1a6c..a7d5de3 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -542,6 +542,17 @@ static int auto_accept_delay_get(void *data, u64 *val) DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, auto_accept_delay_set, "%llu\n"); +void hci_init_sysfs(struct hci_dev *hdev) +{ + struct device *dev = &hdev->dev; + + dev->type = &bt_host; + dev->class = bt_class; + + dev_set_drvdata(dev, hdev); + device_initialize(dev); +} + int hci_register_sysfs(struct hci_dev *hdev) { struct device *dev = &hdev->dev; @@ -549,15 +560,10 @@ int hci_register_sysfs(struct hci_dev *hdev) BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); - dev->type = &bt_host; - dev->class = bt_class; dev->parent = hdev->parent; - dev_set_name(dev, "%s", hdev->name); - dev_set_drvdata(dev, hdev); - - err = device_register(dev); + err = device_add(dev); if (err < 0) return err; -- cgit v0.10.2 From ce242970f0934869483221c410d09c00bc8967e7 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 8 Oct 2011 14:58:48 +0200 Subject: Bluetooth: Rename sysfs un/register to add/del As we introduced hci_init_sysfs() we should also rename hci_register_sysfs() and hci_unregister_sysfs() to hci_add_sysfs() and hci_del_sysfs() like we do with hci_conn_add/del_sysfs(). It looks more consistent now. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index c8cc23c..119b795 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -609,8 +609,8 @@ int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); void hci_init_sysfs(struct hci_dev *hdev); -int hci_register_sysfs(struct hci_dev *hdev); -void hci_unregister_sysfs(struct hci_dev *hdev); +int hci_add_sysfs(struct hci_dev *hdev); +void hci_del_sysfs(struct hci_dev *hdev); void hci_conn_init_sysfs(struct hci_conn *conn); void hci_conn_add_sysfs(struct hci_conn *conn); void hci_conn_del_sysfs(struct hci_conn *conn); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index d2445cb..4975578 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1506,7 +1506,7 @@ int hci_register_dev(struct hci_dev *hdev) if (!hdev->workqueue) goto nomem; - hci_register_sysfs(hdev); + hci_add_sysfs(hdev); hdev->rfkill = rfkill_alloc(hdev->name, &hdev->dev, RFKILL_TYPE_BLUETOOTH, &hci_rfkill_ops, hdev); @@ -1561,7 +1561,7 @@ int hci_unregister_dev(struct hci_dev *hdev) rfkill_destroy(hdev->rfkill); } - hci_unregister_sysfs(hdev); + hci_del_sysfs(hdev); hci_del_off_timer(hdev); del_timer(&hdev->adv_timer); diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index a7d5de3..1f9f876 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -553,7 +553,7 @@ void hci_init_sysfs(struct hci_dev *hdev) device_initialize(dev); } -int hci_register_sysfs(struct hci_dev *hdev) +int hci_add_sysfs(struct hci_dev *hdev) { struct device *dev = &hdev->dev; int err; @@ -587,7 +587,7 @@ int hci_register_sysfs(struct hci_dev *hdev) return 0; } -void hci_unregister_sysfs(struct hci_dev *hdev) +void hci_del_sysfs(struct hci_dev *hdev) { BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); -- cgit v0.10.2 From 33ca954daf1ac03c86237b73235d8b0856d84981 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 8 Oct 2011 14:58:49 +0200 Subject: Bluetooth: Forward errors from hci_register_dev We need to catch errors when calling hci_add_sysfs() and return them to the caller to avoid kernel oopses on device_add() failure. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 4975578..fdcbf8f 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1426,7 +1426,7 @@ int hci_add_adv_entry(struct hci_dev *hdev, int hci_register_dev(struct hci_dev *hdev) { struct list_head *head = &hci_dev_list, *p; - int i, id = 0; + int i, id = 0, error; BT_DBG("%p name %s bus %d owner %p", hdev, hdev->name, hdev->bus, hdev->owner); @@ -1503,10 +1503,14 @@ int hci_register_dev(struct hci_dev *hdev) write_unlock_bh(&hci_dev_list_lock); hdev->workqueue = create_singlethread_workqueue(hdev->name); - if (!hdev->workqueue) - goto nomem; + if (!hdev->workqueue) { + error = -ENOMEM; + goto err; + } - hci_add_sysfs(hdev); + error = hci_add_sysfs(hdev); + if (error < 0) + goto err_wqueue; hdev->rfkill = rfkill_alloc(hdev->name, &hdev->dev, RFKILL_TYPE_BLUETOOTH, &hci_rfkill_ops, hdev); @@ -1525,12 +1529,14 @@ int hci_register_dev(struct hci_dev *hdev) return id; -nomem: +err_wqueue: + destroy_workqueue(hdev->workqueue); +err: write_lock_bh(&hci_dev_list_lock); list_del(&hdev->list); write_unlock_bh(&hci_dev_list_lock); - return -ENOMEM; + return error; } EXPORT_SYMBOL(hci_register_dev); -- cgit v0.10.2 From 56b7d137855eb02cba8aecbb67d49c24b43644b0 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Fri, 14 Oct 2011 19:20:01 -0300 Subject: Bluetooth: return proper error if sock_queue_rcv_skb() fails Improve error handling at cmd_status() and cmd_complete() Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5a94eec..42e2614 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -48,6 +48,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) struct sk_buff *skb; struct mgmt_hdr *hdr; struct mgmt_ev_cmd_status *ev; + int err; BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status); @@ -65,10 +66,11 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) ev->status = status; put_unaligned_le16(cmd, &ev->opcode); - if (sock_queue_rcv_skb(sk, skb) < 0) + err = sock_queue_rcv_skb(sk, skb); + if (err < 0) kfree_skb(skb); - return 0; + return err; } static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, @@ -77,6 +79,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, struct sk_buff *skb; struct mgmt_hdr *hdr; struct mgmt_ev_cmd_complete *ev; + int err; BT_DBG("sock %p", sk); @@ -96,10 +99,11 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, if (rp) memcpy(ev->data, rp, rp_len); - if (sock_queue_rcv_skb(sk, skb) < 0) + err = sock_queue_rcv_skb(sk, skb); + if (err < 0) kfree_skb(skb); - return 0; + return err;; } static int read_version(struct sock *sk) -- cgit v0.10.2 From b7059136d765603f2cff05d5e2d4850a4e505ec8 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Fri, 14 Oct 2011 19:23:27 -0300 Subject: Bluetooth: Add missing cmd_status() in mgmt Improve error handling in mgmt load_keys() Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 42e2614..9d0e223 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -917,7 +917,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len) cp = (void *) data; if (len < sizeof(*cp)) - return -EINVAL; + return cmd_status(sk, index, MGMT_OP_LOAD_KEYS, EINVAL); key_count = get_unaligned_le16(&cp->key_count); @@ -925,7 +925,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len) if (expected_len != len) { BT_ERR("load_keys: expected %u bytes, got %u bytes", len, expected_len); - return -EINVAL; + return cmd_status(sk, index, MGMT_OP_LOAD_KEYS, EINVAL); } hdev = hci_dev_get(index); -- cgit v0.10.2 From 12dc0743015fee37f4090f0937c898294cd2d133 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Fri, 14 Oct 2011 19:32:56 -0300 Subject: Bluetooth: Use list_for_each_entry() in mgmt Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9d0e223..080cfb6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -694,14 +694,11 @@ static int update_eir(struct hci_dev *hdev) static u8 get_service_classes(struct hci_dev *hdev) { - struct list_head *p; + struct bt_uuid *uuid; u8 val = 0; - list_for_each(p, &hdev->uuids) { - struct bt_uuid *uuid = list_entry(p, struct bt_uuid, list); - + list_for_each_entry(uuid, &hdev->uuids, list) val |= uuid->svc_hint; - } return val; } -- cgit v0.10.2 From c636ef58865920c8ba9f877c1040bc73eb61e5cb Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Fri, 14 Oct 2011 19:56:21 -0300 Subject: Bluetooth: Fix mgmt interaction with userspace Partially revert 34918cd7. struct mgmt_key_info needs to have the same size as its version exported to userspace. Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index d66da0f..3062fd3 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -101,8 +101,6 @@ struct mgmt_key_info { u8 type; u8 val[16]; u8 pin_len; - u8 dlen; - u8 data[0]; } __packed; #define MGMT_OP_LOAD_KEYS 0x000D -- cgit v0.10.2 From e5b82e58922749e79b84b85cfc6845cbfd1908ed Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Sat, 15 Oct 2011 18:03:15 -0300 Subject: Bluetooth: Fix missing cmd_status in mgmt set_service_cache() was missing a cmd_status for the error case. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 080cfb6..9ffd7c3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -897,6 +897,9 @@ static int set_service_cache(struct sock *sk, u16 index, unsigned char *data, if (err == 0) err = cmd_complete(sk, index, MGMT_OP_SET_SERVICE_CACHE, NULL, 0); + else + cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, -err); + hci_dev_unlock_bh(hdev); hci_dev_put(hdev); -- cgit v0.10.2 From 88843ab06b6f279bff1c32e4218541ac7efe2600 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 17 Oct 2011 12:19:56 +0300 Subject: Bluetooth: EWS: handling different Control fields There are three different Control Field formats: the Standard Control Field, the Enhanced Control Field, and the Extended Control Field. Patch adds function to handle all those fields seamlessly. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index e67ecd1..41f0906 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -27,6 +27,8 @@ #ifndef __L2CAP_H #define __L2CAP_H +#include + /* L2CAP defaults */ #define L2CAP_DEFAULT_MTU 672 #define L2CAP_DEFAULT_MIN_MTU 48 @@ -684,6 +686,32 @@ static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl) else return ctrl & L2CAP_CTRL_POLL; } + +static inline __u32 __get_control(struct l2cap_chan *chan, void *p) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return get_unaligned_le32(p); + else + return get_unaligned_le16(p); +} + +static inline void __put_control(struct l2cap_chan *chan, __u32 control, + void *p) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return put_unaligned_le32(control, p); + else + return put_unaligned_le16(control, p); +} + +static inline __u8 __ctrl_size(struct l2cap_chan *chan) +{ + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) + return L2CAP_EXT_HDR_SIZE - L2CAP_HDR_SIZE; + else + return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; +} + extern int disable_ertm; int l2cap_init_sockets(void); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 2213346..a253942 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -568,7 +568,7 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, hci_send_acl(conn->hcon, skb, flags); } -static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) +static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control) { struct sk_buff *skb; struct l2cap_hdr *lh; @@ -587,7 +587,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) if (chan->fcs == L2CAP_FCS_CRC16) hlen += 2; - BT_DBG("chan %p, control 0x%2.2x", chan, control); + BT_DBG("chan %p, control 0x%8.8x", chan, control); count = min_t(unsigned int, conn->mtu, hlen); @@ -606,7 +606,8 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); lh->len = cpu_to_le16(hlen - L2CAP_HDR_SIZE); lh->cid = cpu_to_le16(chan->dcid); - put_unaligned_le16(control, skb_put(skb, 2)); + + __put_control(chan, control, skb_put(skb, __ctrl_size(chan))); if (chan->fcs == L2CAP_FCS_CRC16) { u16 fcs = crc16(0, (u8 *)lh, count - 2); @@ -623,7 +624,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) hci_send_acl(chan->conn->hcon, skb, flags); } -static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) +static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u32 control) { if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); @@ -1279,12 +1280,13 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) static void l2cap_streaming_send(struct l2cap_chan *chan) { struct sk_buff *skb; - u16 control, fcs; + u32 control; + u16 fcs; while ((skb = skb_dequeue(&chan->tx_q))) { - control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); + control = __get_control(chan, skb->data + L2CAP_HDR_SIZE); control |= __set_txseq(chan, chan->next_tx_seq); - put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); + __put_control(chan, control, skb->data + L2CAP_HDR_SIZE); if (chan->fcs == L2CAP_FCS_CRC16) { fcs = crc16(0, (u8 *)skb->data, skb->len - 2); @@ -1300,7 +1302,8 @@ static void l2cap_streaming_send(struct l2cap_chan *chan) static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) { struct sk_buff *skb, *tx_skb; - u16 control, fcs; + u16 fcs; + u32 control; skb = skb_peek(&chan->tx_q); if (!skb) @@ -1323,7 +1326,8 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) tx_skb = skb_clone(skb, GFP_ATOMIC); bt_cb(skb)->retries++; - control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); + + control = __get_control(chan, tx_skb->data + L2CAP_HDR_SIZE); control &= __get_sar_mask(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) @@ -1332,7 +1336,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) control |= __set_reqseq(chan, chan->buffer_seq); control |= __set_txseq(chan, tx_seq); - put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); + __put_control(chan, control, tx_skb->data + L2CAP_HDR_SIZE); if (chan->fcs == L2CAP_FCS_CRC16) { fcs = crc16(0, (u8 *)tx_skb->data, tx_skb->len - 2); @@ -1345,7 +1349,8 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) static int l2cap_ertm_send(struct l2cap_chan *chan) { struct sk_buff *skb, *tx_skb; - u16 control, fcs; + u16 fcs; + u32 control; int nsent = 0; if (chan->state != BT_CONNECTED) @@ -1363,7 +1368,7 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) bt_cb(skb)->retries++; - control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); + control = __get_control(chan, tx_skb->data + L2CAP_HDR_SIZE); control &= __get_sar_mask(chan); if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) @@ -1371,8 +1376,8 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) control |= __set_reqseq(chan, chan->buffer_seq); control |= __set_txseq(chan, chan->next_tx_seq); - put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); + __put_control(chan, control, tx_skb->data + L2CAP_HDR_SIZE); if (chan->fcs == L2CAP_FCS_CRC16) { fcs = crc16(0, (u8 *)skb->data, tx_skb->len - 2); @@ -1416,7 +1421,7 @@ static int l2cap_retransmit_frames(struct l2cap_chan *chan) static void l2cap_send_ack(struct l2cap_chan *chan) { - u16 control = 0; + u32 control = 0; control |= __set_reqseq(chan, chan->buffer_seq); @@ -1437,7 +1442,7 @@ static void l2cap_send_ack(struct l2cap_chan *chan) static void l2cap_send_srejtail(struct l2cap_chan *chan) { struct srej_list *tail; - u16 control; + u32 control; control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); control |= __set_ctrl_final(chan); @@ -1541,7 +1546,7 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct ms static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, - u16 control, u16 sdulen) + u32 control, u16 sdulen) { struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; @@ -1575,7 +1580,9 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); lh->cid = cpu_to_le16(chan->dcid); lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE)); - put_unaligned_le16(control, skb_put(skb, 2)); + + __put_control(chan, control, skb_put(skb, __ctrl_size(chan))); + if (sdulen) put_unaligned_le16(sdulen, skb_put(skb, 2)); @@ -1596,7 +1603,7 @@ static int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, si { struct sk_buff *skb; struct sk_buff_head sar_queue; - u16 control; + u32 control; size_t size = 0; skb_queue_head_init(&sar_queue); @@ -1640,7 +1647,7 @@ static int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, si int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) { struct sk_buff *skb; - u16 control; + u32 control; int err; /* Connectionless channel */ @@ -3180,7 +3187,7 @@ static int l2cap_check_fcs(struct l2cap_chan *chan, struct sk_buff *skb) static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) { - u16 control = 0; + u32 control = 0; chan->frames_sent = 0; @@ -3265,7 +3272,7 @@ static void append_skb_frag(struct sk_buff *skb, skb->truesize += new_frag->truesize; } -static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control) +static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u32 control) { int err = -EINVAL; @@ -3348,7 +3355,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u1 static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan) { - u16 control; + u32 control; BT_DBG("chan %p, Enter local busy", chan); @@ -3365,7 +3372,7 @@ static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan) static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan) { - u16 control; + u32 control; if (!test_bit(CONN_RNR_SENT, &chan->conn_state)) goto done; @@ -3401,7 +3408,7 @@ void l2cap_chan_busy(struct l2cap_chan *chan, int busy) static void l2cap_check_srej_gap(struct l2cap_chan *chan, u16 tx_seq) { struct sk_buff *skb; - u16 control; + u32 control; while ((skb = skb_peek(&chan->srej_q)) && !test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { @@ -3428,7 +3435,7 @@ static void l2cap_check_srej_gap(struct l2cap_chan *chan, u16 tx_seq) static void l2cap_resend_srejframe(struct l2cap_chan *chan, u16 tx_seq) { struct srej_list *l, *tmp; - u16 control; + u32 control; list_for_each_entry_safe(l, tmp, &chan->srej_l, list) { if (l->tx_seq == tx_seq) { @@ -3447,7 +3454,7 @@ static void l2cap_resend_srejframe(struct l2cap_chan *chan, u16 tx_seq) static void l2cap_send_srejframe(struct l2cap_chan *chan, u16 tx_seq) { struct srej_list *new; - u16 control; + u32 control; while (tx_seq != chan->expected_tx_seq) { control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); @@ -3462,7 +3469,7 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u16 tx_seq) chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; } -static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) +static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_control, struct sk_buff *skb) { u16 tx_seq = __get_txseq(chan, rx_control); u16 req_seq = __get_reqseq(chan, rx_control); @@ -3471,7 +3478,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont int num_to_ack = (chan->tx_win/6) + 1; int err = 0; - BT_DBG("chan %p len %d tx_seq %d rx_control 0x%4.4x", chan, skb->len, + BT_DBG("chan %p len %d tx_seq %d rx_control 0x%8.8x", chan, skb->len, tx_seq, rx_control); if (__is_ctrl_final(chan, rx_control) && @@ -3597,9 +3604,9 @@ drop: return 0; } -static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control) +static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u32 rx_control) { - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, __get_reqseq(chan, rx_control), rx_control); chan->expected_ack_seq = __get_reqseq(chan, rx_control); @@ -3637,11 +3644,11 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co } } -static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_control) +static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u32 rx_control) { u16 tx_seq = __get_reqseq(chan, rx_control); - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, tx_seq, rx_control); clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); @@ -3658,11 +3665,11 @@ static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_c set_bit(CONN_REJ_ACT, &chan->conn_state); } } -static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control) +static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u32 rx_control) { u16 tx_seq = __get_reqseq(chan, rx_control); - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, tx_seq, rx_control); clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); @@ -3694,11 +3701,11 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_ } } -static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_control) +static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u32 rx_control) { u16 tx_seq = __get_reqseq(chan, rx_control); - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, tx_seq, rx_control); set_bit(CONN_REMOTE_BUSY, &chan->conn_state); chan->expected_ack_seq = tx_seq; @@ -3722,9 +3729,9 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c } } -static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) +static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u32 rx_control, struct sk_buff *skb) { - BT_DBG("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len); + BT_DBG("chan %p rx_control 0x%8.8x len %d", chan, rx_control, skb->len); if (__is_ctrl_final(chan, rx_control) && test_bit(CONN_WAIT_F, &chan->conn_state)) { @@ -3759,12 +3766,12 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) { struct l2cap_chan *chan = l2cap_pi(sk)->chan; - u16 control; + u32 control; u16 req_seq; int len, next_tx_seq_offset, req_seq_offset; - control = get_unaligned_le16(skb->data); - skb_pull(skb, 2); + control = __get_control(chan, skb->data); + skb_pull(skb, __ctrl_size(chan)); len = skb->len; /* @@ -3830,7 +3837,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk { struct l2cap_chan *chan; struct sock *sk = NULL; - u16 control; + u32 control; u16 tx_seq; int len; @@ -3872,8 +3879,8 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk goto done; case L2CAP_MODE_STREAMING: - control = get_unaligned_le16(skb->data); - skb_pull(skb, 2); + control = __get_control(chan, skb->data); + skb_pull(skb, __ctrl_size(chan)); len = skb->len; if (l2cap_check_fcs(chan, skb)) -- cgit v0.10.2 From 836be934218eb80abc5515d584c329c26951086f Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 17 Oct 2011 12:19:57 +0300 Subject: Bluetooth: EWS: support extended seq numbers Adds support for extended sequence numbers found in extended control fields. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index e727555..fb1acb3 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -158,7 +158,7 @@ struct bt_skb_cb { __u8 pkt_type; __u8 incoming; __u16 expect; - __u8 tx_seq; + __u16 tx_seq; __u8 retries; __u8 sar; unsigned short channel; diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 41f0906..fddc82a 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -381,6 +381,7 @@ struct l2cap_chan { __u8 fcs; __u16 tx_win; + __u16 tx_win_max; __u8 max_tx; __u16 retrans_timeout; __u16 monitor_timeout; @@ -543,6 +544,22 @@ enum { L2CAP_DEFAULT_ACK_TO); #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) +static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) +{ + int offset; + + offset = (seq1 - seq2) % (chan->tx_win_max + 1); + if (offset < 0) + offset += (chan->tx_win_max + 1); + + return offset; +} + +static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) +{ + return (seq + 1) % (chan->tx_win_max + 1); +} + static inline int l2cap_tx_window_full(struct l2cap_chan *ch) { int sub; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a253942..86c8720 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1295,7 +1295,7 @@ static void l2cap_streaming_send(struct l2cap_chan *chan) l2cap_do_send(chan, skb); - chan->next_tx_seq = (chan->next_tx_seq + 1) % 64; + chan->next_tx_seq = __next_seq(chan, chan->next_tx_seq); } } @@ -1389,7 +1389,8 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) __set_retrans_timer(chan); bt_cb(skb)->tx_seq = chan->next_tx_seq; - chan->next_tx_seq = (chan->next_tx_seq + 1) % 64; + + chan->next_tx_seq = __next_seq(chan, chan->next_tx_seq); if (bt_cb(skb)->retries == 1) chan->unacked_frames++; @@ -1967,12 +1968,15 @@ static inline bool __l2cap_efs_supported(struct l2cap_chan *chan) static inline void l2cap_txwin_setup(struct l2cap_chan *chan) { if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && - __l2cap_ews_supported(chan)) + __l2cap_ews_supported(chan)) { /* use extended control field */ set_bit(FLAG_EXT_CTRL, &chan->flags); - else + chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; + } else { chan->tx_win = min_t(u16, chan->tx_win, L2CAP_DEFAULT_TX_WINDOW); + chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; + } } static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) @@ -2138,6 +2142,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) set_bit(FLAG_EXT_CTRL, &chan->flags); set_bit(CONF_EWS_RECV, &chan->conf_state); + chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; chan->remote_tx_win = val; break; @@ -3225,18 +3230,14 @@ static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, return 0; } - tx_seq_offset = (tx_seq - chan->buffer_seq) % 64; - if (tx_seq_offset < 0) - tx_seq_offset += 64; + tx_seq_offset = __seq_offset(chan, tx_seq, chan->buffer_seq); do { if (bt_cb(next_skb)->tx_seq == tx_seq) return -EINVAL; - next_tx_seq_offset = (bt_cb(next_skb)->tx_seq - - chan->buffer_seq) % 64; - if (next_tx_seq_offset < 0) - next_tx_seq_offset += 64; + next_tx_seq_offset = __seq_offset(chan, + bt_cb(next_skb)->tx_seq, chan->buffer_seq); if (next_tx_seq_offset > tx_seq_offset) { __skb_queue_before(&chan->srej_q, next_skb, skb); @@ -3426,9 +3427,8 @@ static void l2cap_check_srej_gap(struct l2cap_chan *chan, u16 tx_seq) break; } - chan->buffer_seq_srej = - (chan->buffer_seq_srej + 1) % 64; - tx_seq = (tx_seq + 1) % 64; + chan->buffer_seq_srej = __next_seq(chan, chan->buffer_seq_srej); + tx_seq = __next_seq(chan, tx_seq); } } @@ -3463,10 +3463,13 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u16 tx_seq) new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC); new->tx_seq = chan->expected_tx_seq; - chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; + + chan->expected_tx_seq = __next_seq(chan, chan->expected_tx_seq); + list_add_tail(&new->list, &chan->srej_l); } - chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; + + chan->expected_tx_seq = __next_seq(chan, chan->expected_tx_seq); } static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_control, struct sk_buff *skb) @@ -3492,9 +3495,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_cont chan->expected_ack_seq = req_seq; l2cap_drop_acked_frames(chan); - tx_seq_offset = (tx_seq - chan->buffer_seq) % 64; - if (tx_seq_offset < 0) - tx_seq_offset += 64; + tx_seq_offset = __seq_offset(chan, tx_seq, chan->buffer_seq); /* invalid tx_seq */ if (tx_seq_offset >= chan->tx_win) { @@ -3542,10 +3543,8 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_cont l2cap_send_srejframe(chan, tx_seq); } } else { - expected_tx_seq_offset = - (chan->expected_tx_seq - chan->buffer_seq) % 64; - if (expected_tx_seq_offset < 0) - expected_tx_seq_offset += 64; + expected_tx_seq_offset = __seq_offset(chan, + chan->expected_tx_seq, chan->buffer_seq); /* duplicated tx_seq */ if (tx_seq_offset < expected_tx_seq_offset) @@ -3570,7 +3569,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_cont return 0; expected: - chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; + chan->expected_tx_seq = __next_seq(chan, chan->expected_tx_seq); if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) { bt_cb(skb)->tx_seq = tx_seq; @@ -3580,7 +3579,8 @@ expected: } err = l2cap_reassemble_sdu(chan, skb, rx_control); - chan->buffer_seq = (chan->buffer_seq + 1) % 64; + chan->buffer_seq = __next_seq(chan, chan->buffer_seq); + if (err < 0) { l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); return err; @@ -3794,14 +3794,11 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) } req_seq = __get_reqseq(chan, control); - req_seq_offset = (req_seq - chan->expected_ack_seq) % 64; - if (req_seq_offset < 0) - req_seq_offset += 64; - next_tx_seq_offset = - (chan->next_tx_seq - chan->expected_ack_seq) % 64; - if (next_tx_seq_offset < 0) - next_tx_seq_offset += 64; + req_seq_offset = __seq_offset(chan, req_seq, chan->expected_ack_seq); + + next_tx_seq_offset = __seq_offset(chan, chan->next_tx_seq, + chan->expected_ack_seq); /* check for invalid req-seq */ if (req_seq_offset > next_tx_seq_offset) { @@ -3907,7 +3904,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk /* TODO: Notify userland of missing data */ } - chan->expected_tx_seq = (tx_seq + 1) % 64; + chan->expected_tx_seq = __next_seq(chan, tx_seq); if (l2cap_reassemble_sdu(chan, skb, control) == -EMSGSIZE) l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); -- cgit v0.10.2 From 03a512137da58e18bec15b46c409a62e0250447e Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 17 Oct 2011 12:19:58 +0300 Subject: Bluetooth: EWS: remove magic numbers in l2cap Remove magic numbers for FCS, SDU LEN and PSM LEN when calculating packet payload. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 86c8720..aa33499 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -585,7 +585,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control) hlen = L2CAP_ENH_HDR_SIZE; if (chan->fcs == L2CAP_FCS_CRC16) - hlen += 2; + hlen += L2CAP_FCS_SIZE; BT_DBG("chan %p, control 0x%8.8x", chan, control); @@ -610,8 +610,8 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control) __put_control(chan, control, skb_put(skb, __ctrl_size(chan))); if (chan->fcs == L2CAP_FCS_CRC16) { - u16 fcs = crc16(0, (u8 *)lh, count - 2); - put_unaligned_le16(fcs, skb_put(skb, 2)); + u16 fcs = crc16(0, (u8 *)lh, count - L2CAP_FCS_SIZE); + put_unaligned_le16(fcs, skb_put(skb, L2CAP_FCS_SIZE)); } if (lmp_no_flush_capable(conn->hcon->hdev)) @@ -1289,8 +1289,10 @@ static void l2cap_streaming_send(struct l2cap_chan *chan) __put_control(chan, control, skb->data + L2CAP_HDR_SIZE); if (chan->fcs == L2CAP_FCS_CRC16) { - fcs = crc16(0, (u8 *)skb->data, skb->len - 2); - put_unaligned_le16(fcs, skb->data + skb->len - 2); + fcs = crc16(0, (u8 *)skb->data, + skb->len - L2CAP_FCS_SIZE); + put_unaligned_le16(fcs, + skb->data + skb->len - L2CAP_FCS_SIZE); } l2cap_do_send(chan, skb); @@ -1339,8 +1341,10 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) __put_control(chan, control, tx_skb->data + L2CAP_HDR_SIZE); if (chan->fcs == L2CAP_FCS_CRC16) { - fcs = crc16(0, (u8 *)tx_skb->data, tx_skb->len - 2); - put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2); + fcs = crc16(0, (u8 *)tx_skb->data, + tx_skb->len - L2CAP_FCS_SIZE); + put_unaligned_le16(fcs, + tx_skb->data + tx_skb->len - L2CAP_FCS_SIZE); } l2cap_do_send(chan, tx_skb); @@ -1380,8 +1384,10 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) __put_control(chan, control, tx_skb->data + L2CAP_HDR_SIZE); if (chan->fcs == L2CAP_FCS_CRC16) { - fcs = crc16(0, (u8 *)skb->data, tx_skb->len - 2); - put_unaligned_le16(fcs, skb->data + tx_skb->len - 2); + fcs = crc16(0, (u8 *)skb->data, + tx_skb->len - L2CAP_FCS_SIZE); + put_unaligned_le16(fcs, skb->data + + tx_skb->len - L2CAP_FCS_SIZE); } l2cap_do_send(chan, tx_skb); @@ -1491,7 +1497,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; struct sk_buff *skb; - int err, count, hlen = L2CAP_HDR_SIZE + 2; + int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE; struct l2cap_hdr *lh; BT_DBG("sk %p len %d", sk, (int)len); @@ -1566,10 +1572,10 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, hlen = L2CAP_ENH_HDR_SIZE; if (sdulen) - hlen += 2; + hlen += L2CAP_SDULEN_SIZE; if (chan->fcs == L2CAP_FCS_CRC16) - hlen += 2; + hlen += L2CAP_FCS_SIZE; count = min_t(unsigned int, (conn->mtu - hlen), len); skb = bt_skb_send_alloc(sk, count + hlen, @@ -1585,7 +1591,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, __put_control(chan, control, skb_put(skb, __ctrl_size(chan))); if (sdulen) - put_unaligned_le16(sdulen, skb_put(skb, 2)); + put_unaligned_le16(sdulen, skb_put(skb, L2CAP_SDULEN_SIZE)); err = l2cap_skbuff_fromiovec(sk, msg, len, count, skb); if (unlikely(err < 0)) { @@ -1594,7 +1600,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, } if (chan->fcs == L2CAP_FCS_CRC16) - put_unaligned_le16(0, skb_put(skb, 2)); + put_unaligned_le16(0, skb_put(skb, L2CAP_FCS_SIZE)); bt_cb(skb)->retries = 0; return skb; @@ -3180,7 +3186,7 @@ static int l2cap_check_fcs(struct l2cap_chan *chan, struct sk_buff *skb) hdr_size = L2CAP_ENH_HDR_SIZE; if (chan->fcs == L2CAP_FCS_CRC16) { - skb_trim(skb, skb->len - 2); + skb_trim(skb, skb->len - L2CAP_FCS_SIZE); rcv_fcs = get_unaligned_le16(skb->data + skb->len); our_fcs = crc16(0, skb->data - hdr_size, skb->len + hdr_size); @@ -3290,7 +3296,7 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u3 break; chan->sdu_len = get_unaligned_le16(skb->data); - skb_pull(skb, 2); + skb_pull(skb, L2CAP_SDULEN_SIZE); if (chan->sdu_len > chan->imtu) { err = -EMSGSIZE; @@ -3783,10 +3789,10 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) goto drop; if (__is_sar_start(chan, control) && !__is_sframe(chan, control)) - len -= 2; + len -= L2CAP_SDULEN_SIZE; if (chan->fcs == L2CAP_FCS_CRC16) - len -= 2; + len -= L2CAP_FCS_SIZE; if (len > chan->mps) { l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); @@ -3884,10 +3890,10 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk goto drop; if (__is_sar_start(chan, control)) - len -= 2; + len -= L2CAP_SDULEN_SIZE; if (chan->fcs == L2CAP_FCS_CRC16) - len -= 2; + len -= L2CAP_FCS_SIZE; if (len > chan->mps || len < 0 || __is_sframe(chan, control)) goto drop; -- cgit v0.10.2 From c8f791626a8840fe60a05ab55468dfb3922cb35a Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 17 Oct 2011 12:19:59 +0300 Subject: Bluetooth: EWS: fix max_pdu calculation Fix max_pdu_size calculationin for RFC. Change magic number to human readable defines. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index aa33499..7891126 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1990,6 +1990,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) struct l2cap_conf_req *req = data; struct l2cap_conf_rfc rfc = { .mode = chan->mode }; void *ptr = req->data; + u16 size; BT_DBG("chan %p", chan); @@ -2037,9 +2038,12 @@ done: rfc.max_transmit = chan->max_tx; rfc.retrans_timeout = 0; rfc.monitor_timeout = 0; - rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); - if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10) - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); + + size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - + L2CAP_EXT_HDR_SIZE - + L2CAP_SDULEN_SIZE - + L2CAP_FCS_SIZE); + rfc.max_pdu_size = cpu_to_le16(size); l2cap_txwin_setup(chan); @@ -2072,9 +2076,12 @@ done: rfc.max_transmit = 0; rfc.retrans_timeout = 0; rfc.monitor_timeout = 0; - rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); - if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10) - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); + + size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - + L2CAP_EXT_HDR_SIZE - + L2CAP_SDULEN_SIZE - + L2CAP_FCS_SIZE); + rfc.max_pdu_size = cpu_to_le16(size); l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); @@ -2110,6 +2117,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC }; u16 mtu = L2CAP_DEFAULT_MTU; u16 result = L2CAP_CONF_SUCCESS; + u16 size; BT_DBG("chan %p", chan); @@ -2219,10 +2227,13 @@ done: chan->remote_max_tx = rfc.max_transmit; - if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10) - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); - - chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); + size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), + chan->conn->mtu - + L2CAP_EXT_HDR_SIZE - + L2CAP_SDULEN_SIZE - + L2CAP_FCS_SIZE); + rfc.max_pdu_size = cpu_to_le16(size); + chan->remote_mps = size; rfc.retrans_timeout = le16_to_cpu(L2CAP_DEFAULT_RETRANS_TO); @@ -2237,10 +2248,13 @@ done: break; case L2CAP_MODE_STREAMING: - if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10) - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); - - chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); + size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), + chan->conn->mtu - + L2CAP_EXT_HDR_SIZE - + L2CAP_SDULEN_SIZE - + L2CAP_FCS_SIZE); + rfc.max_pdu_size = cpu_to_le16(size); + chan->remote_mps = size; set_bit(CONF_MODE_DONE, &chan->conf_state); -- cgit v0.10.2 From 42dceae2819b5ac6fc9a0d414ae05a8960e2a1d9 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 17 Oct 2011 14:35:30 +0300 Subject: Bluetooth: EFS: parse L2CAP config request Add parsing Extended Flow Specification option in L2CAP Config Request Based upon haijun.liu series of patches (sent Sun, 22 Aug 2010) Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 7891126..bda6da7 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -2115,6 +2115,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) int type, hint, olen; unsigned long val; struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC }; + struct l2cap_conf_efs efs; + u8 remote_efs = 0; u16 mtu = L2CAP_DEFAULT_MTU; u16 result = L2CAP_CONF_SUCCESS; u16 size; @@ -2147,7 +2149,12 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) case L2CAP_CONF_FCS: if (val == L2CAP_FCS_NONE) set_bit(CONF_NO_FCS_RECV, &chan->conf_state); + break; + case L2CAP_CONF_EFS: + remote_efs = 1; + if (olen == sizeof(efs)) + memcpy(&efs, (void *) val, olen); break; case L2CAP_CONF_EWS: @@ -2182,6 +2189,13 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) break; } + if (remote_efs) { + if (__l2cap_efs_supported(chan)) + set_bit(FLAG_EFS_ENABLE, &chan->flags); + else + return -ECONNREFUSED; + } + if (chan->mode != rfc.mode) return -ECONNREFUSED; @@ -2200,7 +2214,6 @@ done: sizeof(rfc), (unsigned long) &rfc); } - if (result == L2CAP_CONF_SUCCESS) { /* Configure output options and let the other side know * which ones we don't like. */ @@ -2213,6 +2226,22 @@ done: } l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu); + if (remote_efs) { + if (chan->local_stype != L2CAP_SERV_NOTRAFIC && + efs.stype != L2CAP_SERV_NOTRAFIC && + efs.stype != chan->local_stype) { + + result = L2CAP_CONF_UNACCEPT; + + if (chan->num_conf_req >= 1) + return -ECONNREFUSED; + + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, + sizeof(efs), + (unsigned long) &efs); + } + } + switch (rfc.mode) { case L2CAP_MODE_BASIC: chan->fcs = L2CAP_FCS_NONE; @@ -2245,6 +2274,19 @@ done: l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { + chan->remote_id = efs.id; + chan->remote_stype = efs.stype; + chan->remote_msdu = le16_to_cpu(efs.msdu); + chan->remote_flush_to = + le32_to_cpu(efs.flush_to); + chan->remote_acc_lat = + le32_to_cpu(efs.acc_lat); + chan->remote_sdu_itime = + le32_to_cpu(efs.sdu_itime); + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, + sizeof(efs), (unsigned long) &efs); + } break; case L2CAP_MODE_STREAMING: -- cgit v0.10.2 From 2856ac13b8ab41a17b1c65e4eed51543e55f4bac Mon Sep 17 00:00:00 2001 From: Shubhrajyoti D Date: Fri, 28 Oct 2011 17:14:17 +0530 Subject: spi/omap: Use a workqueue per omap2_mcspi controller Currently all the spi controllers share the work queue. This patch allocates a work queue per controller. Signed-off-by: Steve Wilkins Signed-off-by: Shubhrajyoti D Signed-off-by: Grant Likely diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 322be7a..0192d1b 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -121,6 +121,7 @@ struct omap2_mcspi { /* SPI1 has 4 channels, while SPI2 has 2 */ struct omap2_mcspi_dma *dma_channels; struct device *dev; + struct workqueue_struct *wq; }; struct omap2_mcspi_cs { @@ -143,8 +144,6 @@ struct omap2_mcspi_regs { static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL]; -static struct workqueue_struct *omap2_mcspi_wq; - #define MOD_REG_BIT(val, mask, set) do { \ if (set) \ val |= mask; \ @@ -1043,7 +1042,7 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m) spin_lock_irqsave(&mcspi->lock, flags); list_add_tail(&m->queue, &mcspi->msg_queue); - queue_work(omap2_mcspi_wq, &mcspi->work); + queue_work(mcspi->wq, &mcspi->work); spin_unlock_irqrestore(&mcspi->lock, flags); return 0; @@ -1088,6 +1087,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) struct omap2_mcspi *mcspi; struct resource *r; int status = 0, i; + char wq_name[20]; master = spi_alloc_master(&pdev->dev, sizeof *mcspi); if (master == NULL) { @@ -1111,6 +1111,13 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) mcspi = spi_master_get_devdata(master); mcspi->master = master; + sprintf(wq_name, "omap2_mcspi/%d", master->bus_num); + mcspi->wq = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 1); + if (mcspi->wq == NULL) { + status = -ENOMEM; + goto err1; + } + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (r == NULL) { status = -ENODEV; @@ -1217,6 +1224,7 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) spi_unregister_master(master); iounmap(base); kfree(dma_channels); + destroy_workqueue(mcspi->wq); return 0; } @@ -1275,10 +1283,6 @@ static struct platform_driver omap2_mcspi_driver = { static int __init omap2_mcspi_init(void) { - omap2_mcspi_wq = create_singlethread_workqueue( - omap2_mcspi_driver.driver.name); - if (omap2_mcspi_wq == NULL) - return -1; return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe); } subsys_initcall(omap2_mcspi_init); @@ -1287,7 +1291,6 @@ static void __exit omap2_mcspi_exit(void) { platform_driver_unregister(&omap2_mcspi_driver); - destroy_workqueue(omap2_mcspi_wq); } module_exit(omap2_mcspi_exit); -- cgit v0.10.2 From 751c925cbb3a270f9771e3945494cb44bd9e732a Mon Sep 17 00:00:00 2001 From: Shubhrajyoti D Date: Fri, 28 Oct 2011 17:14:18 +0530 Subject: spi/omap: call pm_runtime_disable in error path and remove omap mcspi probe() doesnt call pm_runtime disable functions in case of failure. remove() doesnt call pm_runtime disable. This could lead to warnings as below on subsequent insmod. ~# insmod spi-omap2-mcspi.ko [ 255.383671] omap2_mcspi omap2_mcspi.1: Unbalanced pm_runtime_enable! ... This patch adds the pm_runtime disable() at appropriate stages. Signed-off-by: Hebbar, Gururaja Signed-off-by: Shubhrajyoti D Signed-off-by: Grant Likely diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 0192d1b..22e1726 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1196,6 +1196,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) err4: spi_master_put(master); err3: + pm_runtime_disable(&pdev->dev); kfree(mcspi->dma_channels); err2: release_mem_region(r->start, resource_size(r)); @@ -1217,6 +1218,7 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) dma_channels = mcspi->dma_channels; omap2_mcspi_disable_clocks(mcspi); + pm_runtime_disable(&pdev->dev); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); release_mem_region(r->start, resource_size(r)); -- cgit v0.10.2 From 39f1b56593293a3d1d3b49b97a59337a19fef053 Mon Sep 17 00:00:00 2001 From: Shubhrajyoti D Date: Fri, 28 Oct 2011 17:14:19 +0530 Subject: spi/omap: Correct the error path Currently McSPI driver doesnt follow correct failure fallback steps attempting to correct the same. Also: - label names changed to give meaningful names. - Setting the driver data to NULL in remove Signed-off-by: Hebbar, Gururaja Signed-off-by: Shubhrajyoti D Signed-off-by: Grant Likely diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 22e1726..0b0dfb7 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1115,13 +1115,13 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) mcspi->wq = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 1); if (mcspi->wq == NULL) { status = -ENOMEM; - goto err1; + goto free_master; } r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (r == NULL) { status = -ENODEV; - goto err1; + goto free_master; } r->start += pdata->regs_offset; @@ -1130,14 +1130,14 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) if (!request_mem_region(r->start, resource_size(r), dev_name(&pdev->dev))) { status = -EBUSY; - goto err1; + goto free_master; } mcspi->base = ioremap(r->start, resource_size(r)); if (!mcspi->base) { dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); status = -ENOMEM; - goto err2; + goto release_region; } mcspi->dev = &pdev->dev; @@ -1152,7 +1152,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) GFP_KERNEL); if (mcspi->dma_channels == NULL) - goto err2; + goto unmap_io; for (i = 0; i < master->num_chipselect; i++) { char dma_ch_name[14]; @@ -1182,26 +1182,33 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) mcspi->dma_channels[i].dma_tx_sync_dev = dma_res->start; } + if (status < 0) + goto dma_chnl_free; + pm_runtime_enable(&pdev->dev); if (status || omap2_mcspi_master_setup(mcspi) < 0) - goto err3; + goto disable_pm; status = spi_register_master(master); if (status < 0) - goto err4; + goto err_spi_register; return status; -err4: +err_spi_register: spi_master_put(master); -err3: +disable_pm: pm_runtime_disable(&pdev->dev); +dma_chnl_free: kfree(mcspi->dma_channels); -err2: - release_mem_region(r->start, resource_size(r)); +unmap_io: iounmap(mcspi->base); -err1: +release_region: + release_mem_region(r->start, resource_size(r)); +free_master: + kfree(master); + platform_set_drvdata(pdev, NULL); return status; } @@ -1227,6 +1234,7 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) iounmap(base); kfree(dma_channels); destroy_workqueue(mcspi->wq); + platform_set_drvdata(pdev, NULL); return 0; } -- cgit v0.10.2 From 92b3a5c1bc3c7da1ae4675d014124f4a97ddb632 Mon Sep 17 00:00:00 2001 From: Tomoya MORINAGA Date: Fri, 28 Oct 2011 09:35:21 +0900 Subject: spi-topcliff-pch: Support new device LAPIS Semiconductor ML7831 IOH ML7831 is companion chip for Intel Atom E6xx series. Signed-off-by: Tomoya MORINAGA Signed-off-by: Grant Likely diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 52e2900..b02920a 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -346,14 +346,14 @@ config SPI_TI_SSP serial port. config SPI_TOPCLIFF_PCH - tristate "Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH SPI controller" + tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) SPI" depends on PCI help SPI driver for the Topcliff PCH (Platform Controller Hub) SPI bus used in some x86 embedded processors. - This driver also supports the ML7213, a companion chip for the - Atom E6xx series and compatible with the Intel EG20T PCH. + This driver also supports the ML7213/ML7223/ML7831, a companion chip + for the Atom E6xx series and compatible with the Intel EG20T PCH. config SPI_TXX9 tristate "Toshiba TXx9 SPI controller" diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 6a80749..2b1e966 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -95,16 +95,18 @@ #define PCH_CLOCK_HZ 50000000 #define PCH_MAX_SPBR 1023 -/* Definition for ML7213 by OKI SEMICONDUCTOR */ +/* Definition for ML7213/ML7831 by OKI SEMICONDUCTOR */ #define PCI_VENDOR_ID_ROHM 0x10DB #define PCI_DEVICE_ID_ML7213_SPI 0x802c #define PCI_DEVICE_ID_ML7223_SPI 0x800F +#define PCI_DEVICE_ID_ML7831_SPI 0x8816 /* * Set the number of SPI instance max * Intel EG20T PCH : 1ch * OKI SEMICONDUCTOR ML7213 IOH : 2ch * OKI SEMICONDUCTOR ML7223 IOH : 1ch + * OKI SEMICONDUCTOR ML7831 IOH : 1ch */ #define PCH_SPI_MAX_DEV 2 @@ -218,6 +220,7 @@ static struct pci_device_id pch_spi_pcidev_id[] = { { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_GE_SPI), 1, }, { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_SPI), 2, }, { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_SPI), 1, }, + { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_SPI), 1, }, { } }; -- cgit v0.10.2 From 2b246283277862c4866a005852af5c70fd581824 Mon Sep 17 00:00:00 2001 From: Tomoya MORINAGA Date: Fri, 28 Oct 2011 09:35:22 +0900 Subject: spi-topcliff-pch: Change company name OKI SEMICONDUCTOR to LAPIS Semiconductor On October 1 in 2011, OKI SEMICONDUCTOR Co., Ltd. changed the company name in to LAPIS Semiconductor Co., Ltd. Signed-off-by: Tomoya MORINAGA Signed-off-by: Grant Likely diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 2b1e966..7086583 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -1,7 +1,7 @@ /* * SPI bus driver for the Topcliff PCH used by Intel SoCs * - * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. + * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,7 +95,7 @@ #define PCH_CLOCK_HZ 50000000 #define PCH_MAX_SPBR 1023 -/* Definition for ML7213/ML7831 by OKI SEMICONDUCTOR */ +/* Definition for ML7213/ML7223/ML7831 by LAPIS Semiconductor */ #define PCI_VENDOR_ID_ROHM 0x10DB #define PCI_DEVICE_ID_ML7213_SPI 0x802c #define PCI_DEVICE_ID_ML7223_SPI 0x800F @@ -104,9 +104,9 @@ /* * Set the number of SPI instance max * Intel EG20T PCH : 1ch - * OKI SEMICONDUCTOR ML7213 IOH : 2ch - * OKI SEMICONDUCTOR ML7223 IOH : 1ch - * OKI SEMICONDUCTOR ML7831 IOH : 1ch + * LAPIS Semiconductor ML7213 IOH : 2ch + * LAPIS Semiconductor ML7223 IOH : 1ch + * LAPIS Semiconductor ML7831 IOH : 1ch */ #define PCH_SPI_MAX_DEV 2 @@ -1756,4 +1756,4 @@ MODULE_PARM_DESC(use_dma, "to use DMA for data transfers pass 1 else 0; default 1"); MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Intel EG20T PCH/OKI SEMICONDUCTOR ML7xxx IOH SPI Driver"); +MODULE_DESCRIPTION("Intel EG20T PCH/LAPIS Semiconductor ML7xxx IOH SPI Driver"); -- cgit v0.10.2 From 0f60be20ca783ef5eb26936032f4114b935348cf Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Sat, 29 Oct 2011 21:15:07 +0200 Subject: scripts/package/Makefile: Fix typo: an deb -> a deb Signed-off-by: Paul Menzel Signed-off-by: Jiri Kosina diff --git a/scripts/package/Makefile b/scripts/package/Makefile index bc6aa00..87bf080 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -141,7 +141,7 @@ perf-%pkg: FORCE help: FORCE @echo ' rpm-pkg - Build both source and binary RPM kernel packages' @echo ' binrpm-pkg - Build only the binary kernel package' - @echo ' deb-pkg - Build the kernel as an deb package' + @echo ' deb-pkg - Build the kernel as a deb package' @echo ' tar-pkg - Build the kernel as an uncompressed tarball' @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' -- cgit v0.10.2 From 0314322d1303065568f33869cbd01d7f7367efc4 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Fri, 29 Jul 2011 12:53:20 +0000 Subject: Docs: Pedantry: [Cc]ordic -> CORDIC According to: http://en.wikipedia.org/wiki/CORDIC it stands for: *CO*ordinate *R*otation *DI*gital *C*omputer Signed-off-by: Michael Witten Signed-off-by: Jiri Kosina diff --git a/include/linux/cordic.h b/include/linux/cordic.h index f932093..686f6bf 100644 --- a/include/linux/cordic.h +++ b/include/linux/cordic.h @@ -36,7 +36,7 @@ struct cordic_iq { * @coord: function output parameter holding the i/q coordinate. * * The function calculates the i/q coordinate for a given angle using - * cordic algorithm. The coordinate consists of a real (i) and an + * CORDIC algorithm. The coordinate consists of a real (i) and an * imaginary (q) part. The real part is essentially the cosine of the * angle and the imaginary part is the sine of the angle. The returned * values are scaled by 2^16 for precision. The range for theta is diff --git a/lib/Kconfig b/lib/Kconfig index 6c695ff..0bb69f6 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -270,9 +270,9 @@ config AVERAGE If unsure, say N. config CORDIC - tristate "Cordic function" + tristate "CORDIC function" help - The option provides arithmetic function using cordic algorithm + The option provides arithmetic function using CORDIC algorithm so its calculations are in fixed point. Modules can select this when they require this function. Module will be called cordic. diff --git a/lib/cordic.c b/lib/cordic.c index aa27a88..09b3403 100644 --- a/lib/cordic.c +++ b/lib/cordic.c @@ -96,6 +96,6 @@ struct cordic_iq cordic_calc_iq(s32 theta) } EXPORT_SYMBOL(cordic_calc_iq); -MODULE_DESCRIPTION("Cordic functions"); +MODULE_DESCRIPTION("CORDIC functions"); MODULE_AUTHOR("Broadcom Corporation"); MODULE_LICENSE("Dual BSD/GPL"); -- cgit v0.10.2 From d89ce936b4d6905c2bdf7fa06778d89ae2ee2151 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Fri, 29 Jul 2011 12:59:51 +0000 Subject: Docs: wording: functions -> algorithm The code seems to provide a single function that implements the CORDIC algorithm. Signed-off-by: Michael Witten Signed-off-by: Jiri Kosina diff --git a/lib/Kconfig b/lib/Kconfig index 0bb69f6..d8c8a16 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -270,7 +270,7 @@ config AVERAGE If unsure, say N. config CORDIC - tristate "CORDIC function" + tristate "CORDIC algorithm" help The option provides arithmetic function using CORDIC algorithm so its calculations are in fixed point. Modules can select this diff --git a/lib/cordic.c b/lib/cordic.c index 09b3403..6cf4778 100644 --- a/lib/cordic.c +++ b/lib/cordic.c @@ -96,6 +96,6 @@ struct cordic_iq cordic_calc_iq(s32 theta) } EXPORT_SYMBOL(cordic_calc_iq); -MODULE_DESCRIPTION("CORDIC functions"); +MODULE_DESCRIPTION("CORDIC algorithm"); MODULE_AUTHOR("Broadcom Corporation"); MODULE_LICENSE("Dual BSD/GPL"); -- cgit v0.10.2 From c620846967f335aafb874b9043a10a8fdda68a24 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Fri, 29 Jul 2011 13:00:47 +0000 Subject: Docs: wording: Insert `the' Signed-off-by: Michael Witten Signed-off-by: Jiri Kosina diff --git a/include/linux/cordic.h b/include/linux/cordic.h index 686f6bf..cf68ca4 100644 --- a/include/linux/cordic.h +++ b/include/linux/cordic.h @@ -35,7 +35,7 @@ struct cordic_iq { * @theta: angle in degrees for which i/q coordinate is to be calculated. * @coord: function output parameter holding the i/q coordinate. * - * The function calculates the i/q coordinate for a given angle using + * The function calculates the i/q coordinate for a given angle using the * CORDIC algorithm. The coordinate consists of a real (i) and an * imaginary (q) part. The real part is essentially the cosine of the * angle and the imaginary part is the sine of the angle. The returned -- cgit v0.10.2 From 435a95c5c8b279668cea32014e5c30821581792d Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Fri, 29 Jul 2011 13:36:04 +0000 Subject: Docs: Kconfig: CORDIC description This is just some copyediting. Signed-off-by: Michael Witten Signed-off-by: Jiri Kosina diff --git a/lib/Kconfig b/lib/Kconfig index d8c8a16..abff69d 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -272,9 +272,8 @@ config AVERAGE config CORDIC tristate "CORDIC algorithm" help - The option provides arithmetic function using CORDIC algorithm - so its calculations are in fixed point. Modules can select this - when they require this function. Module will be called cordic. + This option provides an implementation of the CORDIC algorithm; + calculations are in fixed point. Module will be called cordic. config LLIST bool -- cgit v0.10.2 From a127e2d518269ad95364639c293c8a5c1a1cdd3c Mon Sep 17 00:00:00 2001 From: Kautuk Consul Date: Fri, 23 Sep 2011 22:08:29 +0530 Subject: namespace: mnt_want_write: Remove unused label 'out' I was studying the code and I saw that the out label is not being used at all so I removed it and its usage from the function. Signed-off-by: Kautuk Consul Signed-off-by: Jiri Kosina diff --git a/fs/namespace.c b/fs/namespace.c index b4febb2..9a1ddcd 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -352,9 +352,7 @@ int mnt_want_write(struct vfsmount *mnt) if (__mnt_is_readonly(mnt)) { mnt_dec_writers(mnt); ret = -EROFS; - goto out; } -out: preempt_enable(); return ret; } -- cgit v0.10.2 From 800100afc7a01ed581702bfaa6014f646e6eff5d Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Tue, 11 Oct 2011 13:23:29 +0200 Subject: h8300: drivers/serial/Kconfig was moved commit ab4382d27412e7e3e7c936e8d50d8888dfac3df8 moved drivers/serial/Kconfig to drivers/tty/serial/Kconfig, so we need to source the latter file. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 7ed7714..d1f377f 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -195,7 +195,7 @@ config UNIX98_PTYS source "drivers/char/pcmcia/Kconfig" -source "drivers/serial/Kconfig" +source "drivers/tty/serial/Kconfig" source "drivers/i2c/Kconfig" -- cgit v0.10.2 From 6099e419ae7e1dd44c808693bd1905d22a6db15f Mon Sep 17 00:00:00 2001 From: Arvind R Date: Wed, 12 Oct 2011 10:28:56 +0530 Subject: edac:i82975x fix 32bit compile and cleanup the clean up achieves: 1. fix warning on 32-bit compile 2. reorder info extraction for clarity 3. add error-trap diagnostic message 4. handle ALL modes of memory configurations Signed-off-by: Arvind R. Signed-off-by: Jiri Kosina diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c index a5da732..4184e01 100644 --- a/drivers/edac/i82975x_edac.c +++ b/drivers/edac/i82975x_edac.c @@ -277,11 +277,9 @@ static void i82975x_get_error_info(struct mem_ctl_info *mci, static int i82975x_process_error_info(struct mem_ctl_info *mci, struct i82975x_error_info *info, int handle_errors) { - int row, multi_chan, chan; + int row, chan; unsigned long offst, page; - multi_chan = mci->csrows[0].nr_channels - 1; - if (!(info->errsts2 & 0x0003)) return 0; @@ -294,20 +292,30 @@ static int i82975x_process_error_info(struct mem_ctl_info *mci, } page = (unsigned long) info->eap; - if (info->xeap & 1) - page |= 0x100000000ul; - chan = page & 1; page >>= 1; - offst = page & ((1 << PAGE_SHIFT) - 1); - page >>= PAGE_SHIFT; + if (info->xeap & 1) + page |= 0x80000000; + page >>= (PAGE_SHIFT - 1); row = edac_mc_find_csrow_by_page(mci, page); + if (row == -1) { + i82975x_mc_printk(mci, KERN_ERR, "error processing EAP:\n" + "\tXEAP=%u\n" + "\t EAP=0x%08x\n" + "\tPAGE=0x%08x\n", + (info->xeap & 1) ? 1 : 0, info->eap, (unsigned int) page); + return 0; + } + chan = (mci->csrows[row].nr_channels == 1) ? 0 : info->eap & 1; + offst = info->eap + & ((1 << PAGE_SHIFT) - + (1 << mci->csrows[row].grain)); + if (info->errsts & 0x0002) edac_mc_handle_ue(mci, page, offst , row, "i82975x UE"); else edac_mc_handle_ce(mci, page, offst, info->derrsyn, row, - multi_chan ? chan : 0, - "i82975x CE"); + chan, "i82975x CE"); return 1; } @@ -410,7 +418,7 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci, csrow->last_page = cumul_size - 1; csrow->nr_pages = cumul_size - last_cumul_size; last_cumul_size = cumul_size; - csrow->grain = 1 << 6; /* I82975X_EAP has 64B resolution */ + csrow->grain = 1 << 7; /* 128Byte cache-line resolution */ csrow->mtype = MEM_DDR2; /* I82975x supports only DDR2 */ csrow->dtype = i82975x_dram_type(mch_window, index); csrow->edac_mode = EDAC_SECDED; /* only supported */ -- cgit v0.10.2 From 3007c48a6a1bc6c7b81d5d9890bcbd5c0b519235 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 23 Oct 2011 17:23:54 +0200 Subject: treewide: remove commented out Kconfig entries These Kconfig entries have been commented out since (at least) v2.6.12-rc2 (the first commit of the git repository). There's no indication why they're commented out. They might as well be removed. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig index bad27a6..c5e69ab 100644 --- a/arch/frv/Kconfig +++ b/arch/frv/Kconfig @@ -341,16 +341,6 @@ source "drivers/pci/Kconfig" source "drivers/pcmcia/Kconfig" -#config MATH_EMULATION -# bool "Math emulation support (EXPERIMENTAL)" -# depends on EXPERIMENTAL -# help -# At some point in the future, this will cause floating-point math -# instructions to be emulated by the kernel on machines that lack a -# floating-point math coprocessor. Thrill-seekers and chronically -# sleep-deprived psychotic hacker types can say Y now, everyone else -# should probably wait a while. - menu "Power management options" config ARCH_SUSPEND_POSSIBLE diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index b122adc..c616420 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2386,10 +2386,6 @@ config TC Linux driver support status is documented at: -#config ACCESSBUS -# bool "Access.Bus support" -# depends on TC - config MMU bool default y diff --git a/arch/mips/sgi-ip27/Kconfig b/arch/mips/sgi-ip27/Kconfig index bc5e976..4b2ea28 100644 --- a/arch/mips/sgi-ip27/Kconfig +++ b/arch/mips/sgi-ip27/Kconfig @@ -1,9 +1,3 @@ -#config SGI_SN0_XXL -# bool "IP27 XXL" -# depends on SGI_IP27 -# This options adds support for userspace processes up to 16TB size. -# Normally the limit is just .5TB. - choice prompt "Node addressing mode" depends on SGI_IP27 diff --git a/drivers/parisc/Kconfig b/drivers/parisc/Kconfig index 553a990..6202649 100644 --- a/drivers/parisc/Kconfig +++ b/drivers/parisc/Kconfig @@ -108,13 +108,6 @@ config IOMMU_HELPER depends on IOMMU_SBA || IOMMU_CCIO default y -#config PCI_EPIC -# bool "EPIC/SAGA PCI support" -# depends on PCI -# default y -# help -# Say Y here for V-class PCI, DMA/IOMMU, IRQ subsystem support. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" -- cgit v0.10.2 From d593b5413d13be31782385bf5b27af3b3bad59eb Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 23 Oct 2011 17:24:31 +0200 Subject: snd-aoa: remove commented out Kconfig entry config SND_AOA_TOPAZ has been commented out since it was added five years ago with commit f3d9478b ("[...] add snd-aoa"). There's no indication why it's commented out. It might as well be removed. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/sound/aoa/codecs/Kconfig b/sound/aoa/codecs/Kconfig index 808eb11..0c68e32 100644 --- a/sound/aoa/codecs/Kconfig +++ b/sound/aoa/codecs/Kconfig @@ -7,14 +7,6 @@ config SND_AOA_ONYX codec chip found in the latest Apple machines (most of those with digital audio output). -#config SND_AOA_TOPAZ -# tristate "support Topaz chips" -# ---help--- -# This option enables support for the Topaz (CS84xx) -# codec chips found in the latest Apple machines, -# these chips do the digital input and output on -# some PowerMacs. - config SND_AOA_TAS tristate "support TAS chips" select I2C -- cgit v0.10.2 From ff5f483f30918759e78371a8deb498c46fdae051 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 23 Oct 2011 17:25:59 +0200 Subject: powerpc: 4xx: remove commented out Kconfig entries These Kconfig entries have been commented out ever since commit f6557331 ("[...] Re-organize Kconfig code for 4xx in arch/powerpc"). There's no indication why they're commented out. It looks like they're just "old, unused [...] config options" that were not removed, as other entries were in that commit, but only commented out. They might as well be removed now. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/powerpc/platforms/40x/Kconfig b/arch/powerpc/platforms/40x/Kconfig index d733d7c..e568e85 100644 --- a/arch/powerpc/platforms/40x/Kconfig +++ b/arch/powerpc/platforms/40x/Kconfig @@ -1,19 +1,3 @@ -#config BUBINGA -# bool "Bubinga" -# depends on 40x -# default n -# select 405EP -# help -# This option enables support for the IBM 405EP evaluation board. - -#config CPCI405 -# bool "CPCI405" -# depends on 40x -# default n -# select 405GP -# help -# This option enables support for the CPCI405 board. - config ACADIA bool "Acadia" depends on 40x @@ -73,14 +57,6 @@ config MAKALU help This option enables support for the AMCC PPC405EX board. -#config SYCAMORE -# bool "Sycamore" -# depends on 40x -# default n -# select 405GPR -# help -# This option enables support for the IBM PPC405GPr evaluation board. - config WALNUT bool "Walnut" depends on 40x @@ -185,17 +161,3 @@ config IBM405_ERR77 # All 40x-based cores, up until the 405GPR and 405EP have this errata. config IBM405_ERR51 bool - -#config BIOS_FIXUP -# bool -# depends on BUBINGA || EP405 || SYCAMORE || WALNUT -# default y - -#config PPC4xx_DMA -# bool "PPC4xx DMA controller support" -# depends on 4xx - -#config PPC4xx_EDMA -# bool -# depends on !STB03xxx && PPC4xx_DMA -# default y diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig index e958b6f..595e28a 100644 --- a/arch/powerpc/platforms/44x/Kconfig +++ b/arch/powerpc/platforms/44x/Kconfig @@ -197,22 +197,6 @@ config ICON help This option enables support for the AMCC PPC440SPe evaluation board. -#config LUAN -# bool "Luan" -# depends on 44x -# default n -# select 440SP -# help -# This option enables support for the IBM PPC440SP evaluation board. - -#config OCOTEA -# bool "Ocotea" -# depends on 44x -# default n -# select 440GX -# help -# This option enables support for the IBM PPC440GX evaluation board. - config XILINX_VIRTEX440_GENERIC_BOARD bool "Generic Xilinx Virtex 5 FXT board support" depends on 44x -- cgit v0.10.2 From 6d21af4f7d0ab660b24c8635f4ed577f40cd2978 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Wed, 26 Oct 2011 10:16:11 +0100 Subject: irq: Fix comment typo ist->is Signed-off-by: Javi Merino Signed-off-by: Jiri Kosina diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 9b956fa..3261c4d 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1281,7 +1281,7 @@ EXPORT_SYMBOL(free_irq); * and to set up the interrupt handler in the right order. * * If you want to set up a threaded irq handler for your device - * then you need to supply @handler and @thread_fn. @handler ist + * then you need to supply @handler and @thread_fn. @handler is * still called in hard interrupt context and has to check * whether the interrupt originates from the device. If yes it * needs to disable the interrupt on the device and return -- cgit v0.10.2 From eeb3151ced1307c418e4c00433f814e210e4b899 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Tue, 11 Oct 2011 17:31:55 +0200 Subject: ARM: pxa: Fix typo 'CONFIG_BACKLIGHT_PWM__MODULE' Signed-off-by: Paul Bolle Acked-by: Marek Vasut Signed-off-by: Jiri Kosina diff --git a/arch/arm/mach-pxa/colibri-pxa270-income.c b/arch/arm/mach-pxa/colibri-pxa270-income.c index 80538b8..248804b 100644 --- a/arch/arm/mach-pxa/colibri-pxa270-income.c +++ b/arch/arm/mach-pxa/colibri-pxa270-income.c @@ -183,7 +183,7 @@ static inline void income_lcd_init(void) {} /****************************************************************************** * Backlight ******************************************************************************/ -#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM__MODULE) +#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE) static struct platform_pwm_backlight_data income_backlight_data = { .pwm_id = 0, .max_brightness = 0x3ff, -- cgit v0.10.2 From bfc994b5fcdee8d29ee7a6aafc025fe0863f0f83 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 30 Oct 2011 12:51:41 +0100 Subject: Kconfig: remove a few puzzling comments These comments mention CONFIG options that do not exist: not as a symbol in a Kconfig file (without the CONFIG_ prefix) and neither as a symbol (with that prefix) in the code. There's one reference to XSCALE_PMU_TIMER as a negative dependency. But XSCALE_PMU_TIMER is never defined (CONFIG_XSCALE_PMU_TIMER is also unused in the code). It shows up with type "unknown" if you search for it in menuconfig. Apparently a negative dependency on an unknown symbol is always true. That negative dependency can be removed too. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7536b9c..49e41d6 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1083,10 +1083,9 @@ config IWMMXT Enable support for iWMMXt context switching at run time if running on a CPU that supports it. -# bool 'Use XScale PMU as timer source' CONFIG_XSCALE_PMU_TIMER config XSCALE_PMU bool - depends on CPU_XSCALE && !XSCALE_PMU_TIMER + depends on CPU_XSCALE default y config CPU_HAS_PMU diff --git a/arch/cris/Kconfig.debug b/arch/cris/Kconfig.debug index 0b9a630..14881e8 100644 --- a/arch/cris/Kconfig.debug +++ b/arch/cris/Kconfig.debug @@ -1,6 +1,5 @@ menu "Kernel hacking" -#bool 'Debug kmalloc/kfree' CONFIG_DEBUG_MALLOC config PROFILING bool "Kernel profiling support" diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index 2209e35..c2d11fe 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -66,8 +66,6 @@ config SGI_NEWPORT_CONSOLE Say Y here if you want the console on the Newport aka XL graphics card of your Indy. Most people say Y here. -# bool 'IODC console' CONFIG_IODC_CONSOLE - config DUMMY_CONSOLE bool depends on VGA_CONSOLE!=y || SGI_NEWPORT_CONSOLE!=y diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index cbb505b..251f662 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -163,8 +163,6 @@ config IP_PNP_RARP operating on your network. Read for details. -# not yet ready.. -# bool ' IP: ARP support' CONFIG_IP_PNP_ARP config NET_IPIP tristate "IP: tunneling" select INET_TUNNEL -- cgit v0.10.2 From d631097577f6fe027f4903f62eabced6445d19bf Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Mon, 31 Oct 2011 11:07:42 +0200 Subject: tracing: fix event_subsystem ref counting Fix a bug introduced by e9dbfae5, which prevents event_subsystem from ever being released. Ref_count was added to keep track of subsystem users, not for counting events. Subsystem is created with ref_count = 1, so there is no need to increment it for every event, we have nr_events for that. Fix this by touching ref_count only when we actually have a new user - subsystem_open(). Cc: stable@vger.kernel.org Signed-off-by: Ilya Dryomov Link: http://lkml.kernel.org/r/1320052062-7846-1-git-send-email-idryomov@gmail.com Signed-off-by: Steven Rostedt diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 581876f..c212a7f 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1078,7 +1078,6 @@ event_subsystem_dir(const char *name, struct dentry *d_events) /* First see if we did not already create this dir */ list_for_each_entry(system, &event_subsystems, list) { if (strcmp(system->name, name) == 0) { - __get_system(system); system->nr_events++; return system->entry; } -- cgit v0.10.2 From e1d01d5416f3ab7fc88b5850d56510e47e4f62e4 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Wed, 12 Oct 2011 23:19:32 +0200 Subject: isdn: hisax: Fix wrong macro name 'HISAX_DE_AOC' That should be 'CONFIG_DE_AOC'. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c index b0d9ab1..6a8acf6 100644 --- a/drivers/isdn/hisax/l3dss1.c +++ b/drivers/isdn/hisax/l3dss1.c @@ -353,7 +353,7 @@ l3dss1_parse_facility(struct PStack *st, struct l3_process *pc, { l3dss1_dummy_invoke(st, cr, id, ident, p, nlen); return; } -#ifdef HISAX_DE_AOC +#ifdef CONFIG_DE_AOC { #define FOO1(s,a,b) \ @@ -422,9 +422,9 @@ l3dss1_parse_facility(struct PStack *st, struct l3_process *pc, #undef FOO1 } -#else /* not HISAX_DE_AOC */ +#else /* not CONFIG_DE_AOC */ l3_debug(st, "invoke break"); -#endif /* not HISAX_DE_AOC */ +#endif /* not CONFIG_DE_AOC */ break; case 2: /* return result */ /* if no process available handle separately */ -- cgit v0.10.2 From f854b5bc264023b21bbcb4b358cd858d5d45a4cb Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Wed, 12 Oct 2011 14:04:22 +0200 Subject: ARM: imx: Fix typo 'MACH_MX31_3DS_MXC_NAND_USE_BBT' Signed-off-by: Paul Bolle Tested-by: Fabio Estevam Signed-off-by: Jiri Kosina diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c index c20be75..5750ca5 100644 --- a/arch/arm/mach-imx/mach-mx31_3ds.c +++ b/arch/arm/mach-imx/mach-mx31_3ds.c @@ -542,7 +542,7 @@ static const struct mxc_nand_platform_data mx31_3ds_nand_board_info __initconst = { .width = 1, .hw_ecc = 1, -#ifdef MACH_MX31_3DS_MXC_NAND_USE_BBT +#ifdef CONFIG_MACH_MX31_3DS_MXC_NAND_USE_BBT .flash_bbt = 1, #endif }; -- cgit v0.10.2 From ed0449af5373abd766c79fbf83254bebc996bd23 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Tue, 1 Nov 2011 09:09:35 +0800 Subject: tracing: Restore system filter behavior Though not all events have field 'prev_pid', it was allowed to do this: # echo 'prev_pid == 100' > events/sched/filter but commit 75b8e98263fdb0bfbdeba60d4db463259f1fe8a2 (tracing/filter: Swap entire filter of events) broke it without any reason. Link: http://lkml.kernel.org/r/4EAF46CF.8040408@cn.fujitsu.com Signed-off-by: Li Zefan Signed-off-by: Steven Rostedt diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 96efa67..c3da42d 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h @@ -172,6 +172,7 @@ enum { TRACE_EVENT_FL_FILTERED_BIT, TRACE_EVENT_FL_RECORDED_CMD_BIT, TRACE_EVENT_FL_CAP_ANY_BIT, + TRACE_EVENT_FL_NO_SET_FILTER_BIT, }; enum { @@ -179,6 +180,7 @@ enum { TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT), TRACE_EVENT_FL_RECORDED_CMD = (1 << TRACE_EVENT_FL_RECORDED_CMD_BIT), TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT), + TRACE_EVENT_FL_NO_SET_FILTER = (1 << TRACE_EVENT_FL_NO_SET_FILTER_BIT), }; struct ftrace_event_call { diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 816d3d0..86040d9 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -1649,7 +1649,9 @@ static int replace_system_preds(struct event_subsystem *system, */ err = replace_preds(call, NULL, ps, filter_string, true); if (err) - goto fail; + call->flags |= TRACE_EVENT_FL_NO_SET_FILTER; + else + call->flags &= ~TRACE_EVENT_FL_NO_SET_FILTER; } list_for_each_entry(call, &ftrace_events, list) { @@ -1658,6 +1660,9 @@ static int replace_system_preds(struct event_subsystem *system, if (strcmp(call->class->system, system->name) != 0) continue; + if (call->flags & TRACE_EVENT_FL_NO_SET_FILTER) + continue; + filter_item = kzalloc(sizeof(*filter_item), GFP_KERNEL); if (!filter_item) goto fail_mem; -- cgit v0.10.2 From a9866a0975881ba5e819b0a02324ba683b5cdb81 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Fri, 21 Oct 2011 11:53:34 +0800 Subject: MAINTAINERS: add ARM/FREESCALE MXS entry As suggested by Pengutronix, they want to get Sascha relieved from the burden of maintaining MXS sub-architecture. Since I brought the most of MXS core code to mainline (with the great help from Pengutronix people, thanks!), I would like to step up for maintaining MXS. Signed-off-by: Shawn Guo Acked-by: Sascha Hauer diff --git a/MAINTAINERS b/MAINTAINERS index ab77670..8fe3f01 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -804,6 +804,13 @@ S: Maintained T: git git://git.linaro.org/people/shawnguo/linux-2.6.git F: arch/arm/mach-imx/*imx6* +ARM/FREESCALE MXS ARM ARCHITECTURE +M: Shawn Guo +L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) +S: Maintained +T: git git://git.linaro.org/people/shawnguo/linux-2.6.git +F: arch/arm/mach-mxs/ + ARM/GLOMATION GESBC9312SX MACHINE SUPPORT M: Lennert Buytenhek L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) -- cgit v0.10.2 From 87121ca504fd1d963a66b3fb0c72054b0fd9a177 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Fri, 7 Oct 2011 16:31:46 +0200 Subject: oprofile: Fix crash when unloading module (hr timer mode) Oprofile may crash in a KVM guest while unlaoding modules. This happens if oprofile_arch_init() fails and oprofile switches to the hr timer mode as a fallback. In this case oprofile_arch_exit() is called, but it never was initialized properly which causes the crash. This patch fixes this. oprofile: using timer interrupt. BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [] unregister_syscore_ops+0x41/0x58 PGD 41da3f067 PUD 41d80e067 PMD 0 Oops: 0002 [#1] PREEMPT SMP CPU 5 Modules linked in: oprofile(-) Pid: 2382, comm: modprobe Not tainted 3.1.0-rc7-00018-g709a39d #18 Advanced Micro Device Anaheim/Anaheim RIP: 0010:[] [] unregister_syscore_ops+0x41/0x58 RSP: 0018:ffff88041de1de98 EFLAGS: 00010296 RAX: 0000000000000000 RBX: ffffffffa00060e0 RCX: dead000000200200 RDX: 0000000000000000 RSI: dead000000100100 RDI: ffffffff8178c620 RBP: ffff88041de1dea8 R08: 0000000000000001 R09: 0000000000000082 R10: 0000000000000000 R11: ffff88041de1dde8 R12: 0000000000000080 R13: fffffffffffffff5 R14: 0000000000000001 R15: 0000000000610210 FS: 00007f9ae5bef700(0000) GS:ffff88042fd40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000000000000008 CR3: 000000041ca44000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process modprobe (pid: 2382, threadinfo ffff88041de1c000, task ffff88042db6d040) Stack: ffff88041de1deb8 ffffffffa0006770 ffff88041de1deb8 ffffffffa000251e ffff88041de1dec8 ffffffffa00022c2 ffff88041de1ded8 ffffffffa0004993 ffff88041de1df78 ffffffff81073115 656c69666f72706f 0000000000610200 Call Trace: [] op_nmi_exit+0x15/0x17 [oprofile] [] oprofile_arch_exit+0xe/0x10 [oprofile] [] oprofile_exit+0x13/0x15 [oprofile] [] sys_delete_module+0x1c3/0x22f [] ? trace_hardirqs_on_thunk+0x3a/0x3f [] system_call_fastpath+0x16/0x1b Code: 20 c6 78 81 e8 c5 cc 23 00 48 8b 13 48 8b 43 08 48 be 00 01 10 00 00 00 ad de 48 b9 00 02 20 00 00 00 ad de 48 c7 c7 20 c6 78 81 89 42 08 48 89 10 48 89 33 48 89 4b 08 e8 a6 c0 23 00 5a 5b RIP [] unregister_syscore_ops+0x41/0x58 RSP CR2: 0000000000000008 ---[ end trace 06d4e95b6aa3b437 ]--- CC: stable@kernel.org # 2.6.37+ Signed-off-by: Robert Richter diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c index dccd863..f8c752e 100644 --- a/drivers/oprofile/oprof.c +++ b/drivers/oprofile/oprof.c @@ -239,26 +239,45 @@ int oprofile_set_ulong(unsigned long *addr, unsigned long val) return err; } +static int timer_mode; + static int __init oprofile_init(void) { int err; + /* always init architecture to setup backtrace support */ err = oprofile_arch_init(&oprofile_ops); - if (err < 0 || timer) { - printk(KERN_INFO "oprofile: using timer interrupt.\n"); + + timer_mode = err || timer; /* fall back to timer mode on errors */ + if (timer_mode) { + if (!err) + oprofile_arch_exit(); err = oprofile_timer_init(&oprofile_ops); if (err) return err; } - return oprofilefs_register(); + + err = oprofilefs_register(); + if (!err) + return 0; + + /* failed */ + if (timer_mode) + oprofile_timer_exit(); + else + oprofile_arch_exit(); + + return err; } static void __exit oprofile_exit(void) { - oprofile_timer_exit(); oprofilefs_unregister(); - oprofile_arch_exit(); + if (timer_mode) + oprofile_timer_exit(); + else + oprofile_arch_exit(); } diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c index 3ef4462..878fba1 100644 --- a/drivers/oprofile/timer_int.c +++ b/drivers/oprofile/timer_int.c @@ -110,6 +110,7 @@ int oprofile_timer_init(struct oprofile_operations *ops) ops->start = oprofile_hrtimer_start; ops->stop = oprofile_hrtimer_stop; ops->cpu_type = "timer"; + printk(KERN_INFO "oprofile: using timer interrupt.\n"); return 0; } -- cgit v0.10.2 From 97f7f8189fe54e3cfe324ef9ad35064f3d2d3bff Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Mon, 10 Oct 2011 16:21:10 +0200 Subject: oprofile, x86: Fix crash when unloading module (nmi timer mode) If oprofile uses the nmi timer interrupt there is a crash while unloading the module. The bug can be triggered with oprofile build as module and kernel parameter nolapic set. This patch fixes this. oprofile: using NMI timer interrupt. BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [] unregister_syscore_ops+0x41/0x58 PGD 42dbca067 PUD 41da6a067 PMD 0 Oops: 0002 [#1] PREEMPT SMP CPU 5 Modules linked in: oprofile(-) [last unloaded: oprofile] Pid: 2518, comm: modprobe Not tainted 3.1.0-rc7-00019-gb2fb49d #19 Advanced Micro Device Anaheim/Anaheim RIP: 0010:[] [] unregister_syscore_ops+0x41/0x58 RSP: 0018:ffff88041ef71e98 EFLAGS: 00010296 RAX: 0000000000000000 RBX: ffffffffa0017100 RCX: dead000000200200 RDX: 0000000000000000 RSI: dead000000100100 RDI: ffffffff8178c620 RBP: ffff88041ef71ea8 R08: 0000000000000001 R09: 0000000000000082 R10: 0000000000000000 R11: ffff88041ef71de8 R12: 0000000000000080 R13: fffffffffffffff5 R14: 0000000000000001 R15: 0000000000610210 FS: 00007fc902f20700(0000) GS:ffff88042fd40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000000000000008 CR3: 000000041cdb6000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process modprobe (pid: 2518, threadinfo ffff88041ef70000, task ffff88041d348040) Stack: ffff88041ef71eb8 ffffffffa0017790 ffff88041ef71eb8 ffffffffa0013532 ffff88041ef71ec8 ffffffffa00132d6 ffff88041ef71ed8 ffffffffa00159b2 ffff88041ef71f78 ffffffff81073115 656c69666f72706f 0000000000610200 Call Trace: [] op_nmi_exit+0x15/0x17 [oprofile] [] oprofile_arch_exit+0xe/0x10 [oprofile] [] oprofile_exit+0x1e/0x20 [oprofile] [] sys_delete_module+0x1c3/0x22f [] ? trace_hardirqs_on_thunk+0x3a/0x3f [] system_call_fastpath+0x16/0x1b Code: 20 c6 78 81 e8 c5 cc 23 00 48 8b 13 48 8b 43 08 48 be 00 01 10 00 00 00 ad de 48 b9 00 02 20 00 00 00 ad de 48 c7 c7 20 c6 78 81 89 42 08 48 89 10 48 89 33 48 89 4b 08 e8 a6 c0 23 00 5a 5b RIP [] unregister_syscore_ops+0x41/0x58 RSP CR2: 0000000000000008 ---[ end trace 43a541a52956b7b0 ]--- CC: stable@kernel.org # 2.6.37+ Signed-off-by: Robert Richter diff --git a/arch/x86/oprofile/init.c b/arch/x86/oprofile/init.c index cdfe4c5..f148cf6 100644 --- a/arch/x86/oprofile/init.c +++ b/arch/x86/oprofile/init.c @@ -21,6 +21,7 @@ extern int op_nmi_timer_init(struct oprofile_operations *ops); extern void op_nmi_exit(void); extern void x86_backtrace(struct pt_regs * const regs, unsigned int depth); +static int nmi_timer; int __init oprofile_arch_init(struct oprofile_operations *ops) { @@ -31,8 +32,9 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) #ifdef CONFIG_X86_LOCAL_APIC ret = op_nmi_init(ops); #endif + nmi_timer = (ret != 0); #ifdef CONFIG_X86_IO_APIC - if (ret < 0) + if (nmi_timer) ret = op_nmi_timer_init(ops); #endif ops->backtrace = x86_backtrace; @@ -44,6 +46,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) void oprofile_arch_exit(void) { #ifdef CONFIG_X86_LOCAL_APIC - op_nmi_exit(); + if (!nmi_timer) + op_nmi_exit(); #endif } -- cgit v0.10.2 From 159a80b2142df709416ab369113de7d511c48331 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Tue, 11 Oct 2011 19:39:16 +0200 Subject: oprofile, x86: Add kernel parameter oprofile.cpu_type=timer We need this to better test x86 NMI timer mode. Otherwise it is very hard to setup systems with NMI timer enabled, but we have this e.g. in virtual machine environments. Signed-off-by: Robert Richter diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 854ed5ca..f7735a1 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1848,6 +1848,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. arch_perfmon: [X86] Force use of architectural perfmon on Intel CPUs instead of the CPU specific event set. + timer: [X86] Force use of architectural NMI + timer mode (see also oprofile.timer + for generic hr timer mode) oops=panic Always panic on oopses. Default is to just kill the process, but there is a small probability of diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c index 68894fd..7ca4d43 100644 --- a/arch/x86/oprofile/nmi_int.c +++ b/arch/x86/oprofile/nmi_int.c @@ -613,24 +613,36 @@ static int __init p4_init(char **cpu_type) return 0; } -static int force_arch_perfmon; -static int force_cpu_type(const char *str, struct kernel_param *kp) +enum __force_cpu_type { + reserved = 0, /* do not force */ + timer, + arch_perfmon, +}; + +static int force_cpu_type; + +static int set_cpu_type(const char *str, struct kernel_param *kp) { - if (!strcmp(str, "arch_perfmon")) { - force_arch_perfmon = 1; + if (!strcmp(str, "timer")) { + force_cpu_type = timer; + printk(KERN_INFO "oprofile: forcing NMI timer mode\n"); + } else if (!strcmp(str, "arch_perfmon")) { + force_cpu_type = arch_perfmon; printk(KERN_INFO "oprofile: forcing architectural perfmon\n"); + } else { + force_cpu_type = 0; } return 0; } -module_param_call(cpu_type, force_cpu_type, NULL, NULL, 0); +module_param_call(cpu_type, set_cpu_type, NULL, NULL, 0); static int __init ppro_init(char **cpu_type) { __u8 cpu_model = boot_cpu_data.x86_model; struct op_x86_model_spec *spec = &op_ppro_spec; /* default */ - if (force_arch_perfmon && cpu_has_arch_perfmon) + if (force_cpu_type == arch_perfmon && cpu_has_arch_perfmon) return 0; /* @@ -697,6 +709,9 @@ int __init op_nmi_init(struct oprofile_operations *ops) if (!cpu_has_apic) return -ENODEV; + if (force_cpu_type == timer) + return -ENODEV; + switch (vendor) { case X86_VENDOR_AMD: /* Needs to be at least an Athlon (or hammer in 32bit mode) */ -- cgit v0.10.2 From 75c43a20b220f885c39ffa7cdbbb1191e257a9a9 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Fri, 14 Oct 2011 15:46:10 +0200 Subject: oprofile: Remove exit function for timer mode Remove exit functions by moving init/exit code to oprofile's setup/ shutdown functions. Doing so the oprofile module exit code will be easier and less error-prone. Signed-off-by: Robert Richter diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c index f8c752e..f7cd069 100644 --- a/drivers/oprofile/oprof.c +++ b/drivers/oprofile/oprof.c @@ -262,9 +262,7 @@ static int __init oprofile_init(void) return 0; /* failed */ - if (timer_mode) - oprofile_timer_exit(); - else + if (!timer_mode) oprofile_arch_exit(); return err; @@ -274,9 +272,7 @@ static int __init oprofile_init(void) static void __exit oprofile_exit(void) { oprofilefs_unregister(); - if (timer_mode) - oprofile_timer_exit(); - else + if (!timer_mode) oprofile_arch_exit(); } diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c index 878fba1..93404f7 100644 --- a/drivers/oprofile/timer_int.c +++ b/drivers/oprofile/timer_int.c @@ -97,24 +97,24 @@ static struct notifier_block __refdata oprofile_cpu_notifier = { .notifier_call = oprofile_cpu_notify, }; -int oprofile_timer_init(struct oprofile_operations *ops) +static int oprofile_hrtimer_setup(void) { - int rc; - - rc = register_hotcpu_notifier(&oprofile_cpu_notifier); - if (rc) - return rc; - ops->create_files = NULL; - ops->setup = NULL; - ops->shutdown = NULL; - ops->start = oprofile_hrtimer_start; - ops->stop = oprofile_hrtimer_stop; - ops->cpu_type = "timer"; - printk(KERN_INFO "oprofile: using timer interrupt.\n"); - return 0; + return register_hotcpu_notifier(&oprofile_cpu_notifier); } -void oprofile_timer_exit(void) +static void oprofile_hrtimer_shutdown(void) { unregister_hotcpu_notifier(&oprofile_cpu_notifier); } + +int oprofile_timer_init(struct oprofile_operations *ops) +{ + ops->create_files = NULL; + ops->setup = oprofile_hrtimer_setup; + ops->shutdown = oprofile_hrtimer_shutdown; + ops->start = oprofile_hrtimer_start; + ops->stop = oprofile_hrtimer_stop; + ops->cpu_type = "timer"; + printk(KERN_INFO "oprofile: using timer interrupt.\n"); + return 0; +} -- cgit v0.10.2 From dcfce4a095932e6e95d83ad982be3609947963bc Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Tue, 11 Oct 2011 17:11:08 +0200 Subject: oprofile, x86: Reimplement nmi timer mode using perf event The legacy x86 nmi watchdog code was removed with the implementation of the perf based nmi watchdog. This broke Oprofile's nmi timer mode. To run nmi timer mode we relied on a continuous ticking nmi source which the nmi watchdog provided. The nmi tick was no longer available and current watchdog can not be used anymore since it runs with very long periods in the range of seconds. This patch reimplements the nmi timer mode using a perf counter nmi source. V2: * removing pr_info() * fix undefined reference to `__udivdi3' for 32 bit build * fix section mismatch of .cpuinit.data:nmi_timer_cpu_nb * removed nmi timer setup in arch/x86 * implemented function stubs for op_nmi_init/exit() * made code more readable in oprofile_init() V3: * fix architectural initialization in oprofile_init() * fix CONFIG_OPROFILE_NMI_TIMER dependencies Acked-by: Peter Zijlstra Signed-off-by: Robert Richter diff --git a/arch/Kconfig b/arch/Kconfig index 4b0669c..2505740 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -30,6 +30,10 @@ config OPROFILE_EVENT_MULTIPLEX config HAVE_OPROFILE bool +config OPROFILE_NMI_TIMER + def_bool y + depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + config KPROBES bool "Kprobes" depends on MODULES diff --git a/arch/x86/oprofile/Makefile b/arch/x86/oprofile/Makefile index 446902b..1599f56 100644 --- a/arch/x86/oprofile/Makefile +++ b/arch/x86/oprofile/Makefile @@ -4,9 +4,8 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ oprof.o cpu_buffer.o buffer_sync.o \ event_buffer.o oprofile_files.o \ oprofilefs.o oprofile_stats.o \ - timer_int.o ) + timer_int.o nmi_timer_int.o ) oprofile-y := $(DRIVER_OBJS) init.o backtrace.o oprofile-$(CONFIG_X86_LOCAL_APIC) += nmi_int.o op_model_amd.o \ op_model_ppro.o op_model_p4.o -oprofile-$(CONFIG_X86_IO_APIC) += nmi_timer_int.o diff --git a/arch/x86/oprofile/init.c b/arch/x86/oprofile/init.c index f148cf6..9e138d0 100644 --- a/arch/x86/oprofile/init.c +++ b/arch/x86/oprofile/init.c @@ -16,37 +16,23 @@ * with the NMI mode driver. */ +#ifdef CONFIG_X86_LOCAL_APIC extern int op_nmi_init(struct oprofile_operations *ops); -extern int op_nmi_timer_init(struct oprofile_operations *ops); extern void op_nmi_exit(void); -extern void x86_backtrace(struct pt_regs * const regs, unsigned int depth); +#else +static int op_nmi_init(struct oprofile_operations *ops) { return -ENODEV; } +static void op_nmi_exit(void) { } +#endif -static int nmi_timer; +extern void x86_backtrace(struct pt_regs * const regs, unsigned int depth); int __init oprofile_arch_init(struct oprofile_operations *ops) { - int ret; - - ret = -ENODEV; - -#ifdef CONFIG_X86_LOCAL_APIC - ret = op_nmi_init(ops); -#endif - nmi_timer = (ret != 0); -#ifdef CONFIG_X86_IO_APIC - if (nmi_timer) - ret = op_nmi_timer_init(ops); -#endif ops->backtrace = x86_backtrace; - - return ret; + return op_nmi_init(ops); } - void oprofile_arch_exit(void) { -#ifdef CONFIG_X86_LOCAL_APIC - if (!nmi_timer) - op_nmi_exit(); -#endif + op_nmi_exit(); } diff --git a/arch/x86/oprofile/nmi_timer_int.c b/arch/x86/oprofile/nmi_timer_int.c deleted file mode 100644 index 720bf5a..0000000 --- a/arch/x86/oprofile/nmi_timer_int.c +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file nmi_timer_int.c - * - * @remark Copyright 2003 OProfile authors - * @remark Read the file COPYING - * - * @author Zwane Mwaikambo - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -static int profile_timer_exceptions_notify(struct notifier_block *self, - unsigned long val, void *data) -{ - struct die_args *args = (struct die_args *)data; - int ret = NOTIFY_DONE; - - switch (val) { - case DIE_NMI: - oprofile_add_sample(args->regs, 0); - ret = NOTIFY_STOP; - break; - default: - break; - } - return ret; -} - -static struct notifier_block profile_timer_exceptions_nb = { - .notifier_call = profile_timer_exceptions_notify, - .next = NULL, - .priority = NMI_LOW_PRIOR, -}; - -static int timer_start(void) -{ - if (register_die_notifier(&profile_timer_exceptions_nb)) - return 1; - return 0; -} - - -static void timer_stop(void) -{ - unregister_die_notifier(&profile_timer_exceptions_nb); - synchronize_sched(); /* Allow already-started NMIs to complete. */ -} - - -int __init op_nmi_timer_init(struct oprofile_operations *ops) -{ - ops->start = timer_start; - ops->stop = timer_stop; - ops->cpu_type = "timer"; - printk(KERN_INFO "oprofile: using NMI timer interrupt.\n"); - return 0; -} diff --git a/drivers/oprofile/nmi_timer_int.c b/drivers/oprofile/nmi_timer_int.c new file mode 100644 index 0000000..76f1c93 --- /dev/null +++ b/drivers/oprofile/nmi_timer_int.c @@ -0,0 +1,173 @@ +/** + * @file nmi_timer_int.c + * + * @remark Copyright 2011 Advanced Micro Devices, Inc. + * + * @author Robert Richter + */ + +#include +#include +#include +#include +#include + +#ifdef CONFIG_OPROFILE_NMI_TIMER + +static DEFINE_PER_CPU(struct perf_event *, nmi_timer_events); +static int ctr_running; + +static struct perf_event_attr nmi_timer_attr = { + .type = PERF_TYPE_HARDWARE, + .config = PERF_COUNT_HW_CPU_CYCLES, + .size = sizeof(struct perf_event_attr), + .pinned = 1, + .disabled = 1, +}; + +static void nmi_timer_callback(struct perf_event *event, + struct perf_sample_data *data, + struct pt_regs *regs) +{ + event->hw.interrupts = 0; /* don't throttle interrupts */ + oprofile_add_sample(regs, 0); +} + +static int nmi_timer_start_cpu(int cpu) +{ + struct perf_event *event = per_cpu(nmi_timer_events, cpu); + + if (!event) { + event = perf_event_create_kernel_counter(&nmi_timer_attr, cpu, NULL, + nmi_timer_callback, NULL); + if (IS_ERR(event)) + return PTR_ERR(event); + per_cpu(nmi_timer_events, cpu) = event; + } + + if (event && ctr_running) + perf_event_enable(event); + + return 0; +} + +static void nmi_timer_stop_cpu(int cpu) +{ + struct perf_event *event = per_cpu(nmi_timer_events, cpu); + + if (event && ctr_running) + perf_event_disable(event); +} + +static int nmi_timer_cpu_notifier(struct notifier_block *b, unsigned long action, + void *data) +{ + int cpu = (unsigned long)data; + switch (action) { + case CPU_DOWN_FAILED: + case CPU_ONLINE: + nmi_timer_start_cpu(cpu); + break; + case CPU_DOWN_PREPARE: + nmi_timer_stop_cpu(cpu); + break; + } + return NOTIFY_DONE; +} + +static struct notifier_block nmi_timer_cpu_nb = { + .notifier_call = nmi_timer_cpu_notifier +}; + +static int nmi_timer_start(void) +{ + int cpu; + + get_online_cpus(); + ctr_running = 1; + for_each_online_cpu(cpu) + nmi_timer_start_cpu(cpu); + put_online_cpus(); + + return 0; +} + +static void nmi_timer_stop(void) +{ + int cpu; + + get_online_cpus(); + for_each_online_cpu(cpu) + nmi_timer_stop_cpu(cpu); + ctr_running = 0; + put_online_cpus(); +} + +static void nmi_timer_shutdown(void) +{ + struct perf_event *event; + int cpu; + + get_online_cpus(); + unregister_cpu_notifier(&nmi_timer_cpu_nb); + for_each_possible_cpu(cpu) { + event = per_cpu(nmi_timer_events, cpu); + if (!event) + continue; + perf_event_disable(event); + per_cpu(nmi_timer_events, cpu) = NULL; + perf_event_release_kernel(event); + } + + put_online_cpus(); +} + +static int nmi_timer_setup(void) +{ + int cpu, err; + u64 period; + + /* clock cycles per tick: */ + period = (u64)cpu_khz * 1000; + do_div(period, HZ); + nmi_timer_attr.sample_period = period; + + get_online_cpus(); + err = register_cpu_notifier(&nmi_timer_cpu_nb); + if (err) + goto out; + /* can't attach events to offline cpus: */ + for_each_online_cpu(cpu) { + err = nmi_timer_start_cpu(cpu); + if (err) + break; + } + if (err) + nmi_timer_shutdown(); +out: + put_online_cpus(); + return err; +} + +int __init op_nmi_timer_init(struct oprofile_operations *ops) +{ + int err = 0; + + err = nmi_timer_setup(); + if (err) + return err; + nmi_timer_shutdown(); /* only check, don't alloc */ + + ops->create_files = NULL; + ops->setup = nmi_timer_setup; + ops->shutdown = nmi_timer_shutdown; + ops->start = nmi_timer_start; + ops->stop = nmi_timer_stop; + ops->cpu_type = "timer"; + + printk(KERN_INFO "oprofile: using NMI timer interrupt.\n"); + + return 0; +} + +#endif diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c index f7cd069..ed2c3ec 100644 --- a/drivers/oprofile/oprof.c +++ b/drivers/oprofile/oprof.c @@ -246,26 +246,24 @@ static int __init oprofile_init(void) int err; /* always init architecture to setup backtrace support */ + timer_mode = 0; err = oprofile_arch_init(&oprofile_ops); + if (!err) { + if (!timer && !oprofilefs_register()) + return 0; + oprofile_arch_exit(); + } - timer_mode = err || timer; /* fall back to timer mode on errors */ - if (timer_mode) { - if (!err) - oprofile_arch_exit(); + /* setup timer mode: */ + timer_mode = 1; + /* no nmi timer mode if oprofile.timer is set */ + if (timer || op_nmi_timer_init(&oprofile_ops)) { err = oprofile_timer_init(&oprofile_ops); if (err) return err; } - err = oprofilefs_register(); - if (!err) - return 0; - - /* failed */ - if (!timer_mode) - oprofile_arch_exit(); - - return err; + return oprofilefs_register(); } diff --git a/drivers/oprofile/oprof.h b/drivers/oprofile/oprof.h index 177b73d..769fb0f 100644 --- a/drivers/oprofile/oprof.h +++ b/drivers/oprofile/oprof.h @@ -36,6 +36,15 @@ struct dentry; void oprofile_create_files(struct super_block *sb, struct dentry *root); int oprofile_timer_init(struct oprofile_operations *ops); void oprofile_timer_exit(void); +#ifdef CONFIG_OPROFILE_NMI_TIMER +int op_nmi_timer_init(struct oprofile_operations *ops); +#else +static inline int op_nmi_timer_init(struct oprofile_operations *ops) +{ + return -ENODEV; +} +#endif + int oprofile_set_ulong(unsigned long *addr, unsigned long val); int oprofile_set_timeout(unsigned long time); diff --git a/kernel/events/core.c b/kernel/events/core.c index d1a1bee..d2e28bd 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1322,6 +1322,7 @@ retry: } raw_spin_unlock_irq(&ctx->lock); } +EXPORT_SYMBOL_GPL(perf_event_disable); static void perf_set_shadow_time(struct perf_event *event, struct perf_event_context *ctx, @@ -1806,6 +1807,7 @@ retry: out: raw_spin_unlock_irq(&ctx->lock); } +EXPORT_SYMBOL_GPL(perf_event_enable); int perf_event_refresh(struct perf_event *event, int refresh) { -- cgit v0.10.2 From 49aa29513ec995f201664cf6eee36e5326ed38bf Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Wed, 2 Nov 2011 16:46:46 -0400 Subject: tracing: Add boiler plate for subsystem filter The system filter can be used to set multiple event filters that exist within the system. But currently it displays the last filter written that does not necessarily correspond to the filters within the system. The system filter itself is not used to filter any events. The system filter is just a means to set filters of the events within it. Because this causes an ambiguous state when the system filter reads a filter string but the events within the system have different strings it is best to just show a boiler plate: ### global filter ### # Use this to set filters for multiple events. # Only events with the given fields will be affected. # If no events are modified, an error message will be displayed here. If an error occurs while writing to the system filter, the system filter will replace the boiler plate with the error message as it currently does. Signed-off-by: Steven Rostedt diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 86040d9..fdc6d22 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -27,6 +27,12 @@ #include "trace.h" #include "trace_output.h" +#define DEFAULT_SYS_FILTER_MESSAGE \ + "### global filter ###\n" \ + "# Use this to set filters for multiple events.\n" \ + "# Only events with the given fields will be affected.\n" \ + "# If no events are modified, an error message will be displayed here" + enum filter_op_ids { OP_OR, @@ -646,7 +652,7 @@ void print_subsystem_event_filter(struct event_subsystem *system, if (filter && filter->filter_string) trace_seq_printf(s, "%s\n", filter->filter_string); else - trace_seq_printf(s, "none\n"); + trace_seq_printf(s, DEFAULT_SYS_FILTER_MESSAGE "\n"); mutex_unlock(&event_mutex); } @@ -1838,7 +1844,10 @@ int apply_subsystem_event_filter(struct event_subsystem *system, if (!filter) goto out; - replace_filter_string(filter, filter_string); + /* System filters just show a default message */ + kfree(filter->filter_string); + filter->filter_string = NULL; + /* * No event actually uses the system filter * we can free it without synchronize_sched(). @@ -1848,14 +1857,12 @@ int apply_subsystem_event_filter(struct event_subsystem *system, parse_init(ps, filter_ops, filter_string); err = filter_parse(ps); - if (err) { - append_filter_err(ps, system->filter); - goto out; - } + if (err) + goto err_filter; err = replace_system_preds(system, ps, filter_string); if (err) - append_filter_err(ps, system->filter); + goto err_filter; out: filter_opstack_clear(ps); @@ -1865,6 +1872,11 @@ out_unlock: mutex_unlock(&event_mutex); return err; + +err_filter: + replace_filter_string(filter, filter_string); + append_filter_err(ps, system->filter); + goto out; } #ifdef CONFIG_PERF_EVENTS -- cgit v0.10.2 From 3890c136357284cb0656f9dd0e62286995ad32e9 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Fri, 28 Oct 2011 15:48:36 +0800 Subject: tracing: update Documentation on max preds limit Preds is no longer stored in a fixed-size stack. The max preds now is 2^14, and is way more than enough, so don't bother to document it. Link: http://lkml.kernel.org/r/4EAA5E54.1080102@cn.fujitsu.com Signed-off-by: Li Zefan Signed-off-by: Steven Rostedt diff --git a/Documentation/trace/events.txt b/Documentation/trace/events.txt index b510564..bb24c2a 100644 --- a/Documentation/trace/events.txt +++ b/Documentation/trace/events.txt @@ -191,8 +191,6 @@ And for string fields they are: Currently, only exact string matches are supported. -Currently, the maximum number of predicates in a filter is 16. - 5.2 Setting filters ------------------- -- cgit v0.10.2 From 11be0b3c18d654a8d5ed441fa9e988193a57c1d2 Mon Sep 17 00:00:00 2001 From: Vsevolod Alekseev Date: Sat, 5 Nov 2011 02:35:28 -0700 Subject: security.h: fix misc typos/grammar errors in comments Fix various typos/grammar errors in include/linux/security.h comments (no code changes). Signed-off-by: Vsevolod Alekseev Acked-by: Randy Dunlap Signed-off-by: Jiri Kosina diff --git a/include/linux/security.h b/include/linux/security.h index 19d8e04..94c3533 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -186,7 +186,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * Security module identifier. * * @name: - * A string that acts as a unique identifeir for the LSM with max number + * A string that acts as a unique identifier for the LSM with max number * of characters = SECURITY_NAME_MAX. * * Security hooks for program execution operations. @@ -275,7 +275,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * @copy copied data which will be passed to the security module. * Returns 0 if the copy was successful. * @sb_remount: - * Extracts security system specifc mount options and verifys no changes + * Extracts security system specific mount options and verifies no changes * are being made to those options. * @sb superblock being remounted * @data contains the filesystem-specific data. @@ -380,15 +380,15 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * Return 0 if permission is granted. * @inode_mkdir: * Check permissions to create a new directory in the existing directory - * associated with inode strcture @dir. - * @dir containst the inode structure of parent of the directory to be created. + * associated with inode structure @dir. + * @dir contains the inode structure of parent of the directory to be created. * @dentry contains the dentry structure of new directory. * @mode contains the mode of new directory. * Return 0 if permission is granted. * @path_mkdir: * Check permissions to create a new directory in the existing directory - * associated with path strcture @path. - * @dir containst the path structure of parent of the directory + * associated with path structure @path. + * @dir contains the path structure of parent of the directory * to be created. * @dentry contains the dentry structure of new directory. * @mode contains the mode of new directory. @@ -578,7 +578,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * @file contains the file structure. * @cmd contains the operation to perform. * @arg contains the operational arguments. - * Check permission for an ioctl operation on @file. Note that @arg can + * Check permission for an ioctl operation on @file. Note that @arg * sometimes represents a user space pointer; in other cases, it may be a * simple integer value. When @arg represents a user space pointer, it * should never be used by the security module. @@ -606,7 +606,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * Return 0 if permission is granted. * @file_fcntl: * Check permission before allowing the file operation specified by @cmd - * from being performed on the file @file. Note that @arg can sometimes + * from being performed on the file @file. Note that @arg sometimes * represents a user space pointer; in other cases, it may be a simple * integer value. When @arg represents a user space pointer, it should * never be used by the security module. @@ -793,7 +793,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * information can be saved using the eff_cap field of the * netlink_skb_parms structure. Also may be used to provide fine * grained control over message transmission. - * @sk associated sock of task sending the message., + * @sk associated sock of task sending the message. * @skb contains the sk_buff structure for the netlink message. * Return 0 if the information was successfully saved and message * is allowed to be transmitted. @@ -1080,9 +1080,9 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * should free it. * @key points to the key to be queried. * @_buffer points to a pointer that should be set to point to the - * resulting string (if no label or an error occurs). + * resulting string (if no label or an error occurs). * Return the length of the string (including terminating NUL) or -ve if - * an error. + * an error. * May also return 0 (and a NULL buffer pointer) if there is no label. * * Security hooks affecting all System V IPC operations. @@ -1268,7 +1268,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * credentials. * @tsk contains the task_struct for the process. * @cred contains the credentials to use. - * @ns contains the user namespace we want the capability in + * @ns contains the user namespace we want the capability in * @cap contains the capability . * @audit: Whether to write an audit message or not * Return 0 if the capability is granted for @tsk. @@ -1370,7 +1370,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * @ctxlen contains the length of @ctx. * * @inode_getsecctx: - * Returns a string containing all relavent security context information + * Returns a string containing all relevant security context information * * @inode we wish to get the security context of. * @ctx is a pointer in which to place the allocated security context. -- cgit v0.10.2 From e5e78d08f3ab3094783b8df08a5b6d1d1a56a58f Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Wed, 2 Nov 2011 20:24:16 -0400 Subject: lockdep: Show subclass in pretty print of lockdep output The pretty print of the lockdep debug splat uses just the lock name to show how the locking scenario happens. But when it comes to nesting locks, the output becomes confusing which takes away the point of the pretty printing of the lock scenario. Without displaying the subclass info, we get the following output: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(slock-AF_INET); lock(slock-AF_INET); lock(slock-AF_INET); lock(slock-AF_INET); *** DEADLOCK *** The above looks more of a A->A locking bug than a A->B B->A. By adding the subclass to the output, we can see what really happened: other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(slock-AF_INET); lock(slock-AF_INET/1); lock(slock-AF_INET); lock(slock-AF_INET/1); *** DEADLOCK *** This bug was discovered while tracking down a real bug caught by lockdep. Link: http://lkml.kernel.org/r/20111025202049.GB25043@hostway.ca Cc: Peter Zijlstra Reported-by: Thomas Gleixner Tested-by: Simon Kirby Signed-off-by: Steven Rostedt diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 91d67ce..6bd915d 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c @@ -490,36 +490,32 @@ void get_usage_chars(struct lock_class *class, char usage[LOCK_USAGE_CHARS]) usage[i] = '\0'; } -static int __print_lock_name(struct lock_class *class) +static void __print_lock_name(struct lock_class *class) { char str[KSYM_NAME_LEN]; const char *name; name = class->name; - if (!name) - name = __get_key_name(class->key, str); - - return printk("%s", name); -} - -static void print_lock_name(struct lock_class *class) -{ - char str[KSYM_NAME_LEN], usage[LOCK_USAGE_CHARS]; - const char *name; - - get_usage_chars(class, usage); - - name = class->name; if (!name) { name = __get_key_name(class->key, str); - printk(" (%s", name); + printk("%s", name); } else { - printk(" (%s", name); + printk("%s", name); if (class->name_version > 1) printk("#%d", class->name_version); if (class->subclass) printk("/%d", class->subclass); } +} + +static void print_lock_name(struct lock_class *class) +{ + char usage[LOCK_USAGE_CHARS]; + + get_usage_chars(class, usage); + + printk(" ("); + __print_lock_name(class); printk("){%s}", usage); } -- cgit v0.10.2 From 8ee3c92b7f2751c392be2d8fc360a410480b8757 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Fri, 4 Nov 2011 10:45:23 -0400 Subject: ftrace: Remove force undef config value left for testing A forced undef of a config value was used for testing and was accidently left in during the final commit. This causes x86 to run slower than needed while running function tracing as well as causes the function graph selftest to fail when DYNMAIC_FTRACE is not set. This is because the code in MCOUNT expects the ftrace code to be processed with the config value set that happened to be forced not set. The forced config option was left in by: commit 6331c28c962561aee59e5a493b7556a4bb585957 ftrace: Fix dynamic selftest failure on some archs Link: http://lkml.kernel.org/r/20111102150255.GA6973@debian Cc: stable@vger.kernel.org Reported-by: Rabin Vincent Signed-off-by: Steven Rostedt diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 077d853..0fcc6ca 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -151,7 +151,6 @@ void clear_ftrace_function(void) ftrace_pid_function = ftrace_stub; } -#undef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST #ifndef CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST /* * For those archs that do not test ftrace_trace_stop in their -- cgit v0.10.2 From c8452afb7426f7e21388492f40227582e3e83879 Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Tue, 18 Oct 2011 19:55:51 +0200 Subject: jump_label: jump_label_inc may return before the code is patched If cpu A calls jump_label_inc() just after atomic_add_return() is called by cpu B, atomic_inc_not_zero() will return value greater then zero and jump_label_inc() will return to a caller before jump_label_update() finishes its job on cpu B. Link: http://lkml.kernel.org/r/20111018175551.GH17571@redhat.com Cc: stable@vger.kernel.org Cc: Peter Zijlstra Acked-by: Jason Baron Signed-off-by: Gleb Natapov Signed-off-by: Steven Rostedt diff --git a/kernel/jump_label.c b/kernel/jump_label.c index a8ce450..e6f1f24 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -66,8 +66,9 @@ void jump_label_inc(struct jump_label_key *key) return; jump_label_lock(); - if (atomic_add_return(1, &key->enabled) == 1) + if (atomic_read(&key->enabled) == 0) jump_label_update(key, JUMP_LABEL_ENABLE); + atomic_inc(&key->enabled); jump_label_unlock(); } -- cgit v0.10.2 From 49908a1b25d448d68fd26faca260e1850201575f Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Fri, 4 Nov 2011 16:32:25 -0400 Subject: perf: Fix parsing of __print_flags() in TP_printk() A update is made to the sched:sched_switch event that adds some logic to the first parameter of the __print_flags() that shows the state of tasks. This change cause perf to fail parsing the flags. A simple fix is needed to have the parser be able to process ops within the argument. Cc: stable@vger.kernel.org Reported-by: Andrew Vagin Signed-off-by: Steven Rostedt diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 0a7ed5b..6c164dc 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -1537,6 +1537,8 @@ process_flags(struct event *event, struct print_arg *arg, char **tok) field = malloc_or_die(sizeof(*field)); type = process_arg(event, field, &token); + while (type == EVENT_OP) + type = process_op(event, field, &token); if (test_type_token(type, token, EVENT_DELIM, ",")) goto out_free; -- cgit v0.10.2 From d4d34b981a5327eec956c6cb4cce397ce6f57279 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Fri, 4 Nov 2011 20:32:39 -0400 Subject: ftrace: Fix hash record accounting bug If the set_ftrace_filter is cleared by writing just whitespace to it, then the filter hash refcounts will be decremented but not updated. This causes two bugs: 1) No functions will be enabled for tracing when they all should be 2) If the users clears the set_ftrace_filter twice, it will crash ftrace: ------------[ cut here ]------------ WARNING: at /home/rostedt/work/git/linux-trace.git/kernel/trace/ftrace.c:1384 __ftrace_hash_rec_update.part.27+0x157/0x1a7() Modules linked in: Pid: 2330, comm: bash Not tainted 3.1.0-test+ #32 Call Trace: [] warn_slowpath_common+0x83/0x9b [] warn_slowpath_null+0x1a/0x1c [] __ftrace_hash_rec_update.part.27+0x157/0x1a7 [] ? ftrace_regex_release+0xa7/0x10f [] ? kfree+0xe5/0x115 [] ftrace_hash_move+0x2e/0x151 [] ftrace_regex_release+0xba/0x10f [] fput+0xfd/0x1c2 [] filp_close+0x6d/0x78 [] sys_dup3+0x197/0x1c1 [] sys_dup2+0x4f/0x54 [] system_call_fastpath+0x16/0x1b ---[ end trace 77a3a7ee73794a02 ]--- Link: http://lkml.kernel.org/r/20111101141420.GA4918@debian Reported-by: Rabin Vincent Signed-off-by: Steven Rostedt diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 0fcc6ca..7caa450 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1210,7 +1210,9 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable, if (!src->count) { free_ftrace_hash_rcu(*dst); rcu_assign_pointer(*dst, EMPTY_HASH); - return 0; + /* still need to update the function records */ + ret = 0; + goto out; } /* -- cgit v0.10.2 From 7e9a49ef542610609144d1afcd516dc3fafac4d6 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Mon, 7 Nov 2011 16:08:49 +0100 Subject: tracing/latency: Fix header output for latency tracers In case the the graph tracer (CONFIG_FUNCTION_GRAPH_TRACER) or even the function tracer (CONFIG_FUNCTION_TRACER) are not set, the latency tracers do not display proper latency header. The involved/fixed latency tracers are: wakeup_rt wakeup preemptirqsoff preemptoff irqsoff The patch adds proper handling of tracer configuration options for latency tracers, and displaying correct header info accordingly. * The current output (for wakeup tracer) with both graph and function tracers disabled is: # tracer: wakeup # -0 0d.h5 1us+: 0:120:R + [000] 7: 0:R watchdog/0 -0 0d.h5 3us+: ttwu_do_activate.clone.1 <-try_to_wake_up ... * The fixed output is: # tracer: wakeup # # wakeup latency trace v1.1.5 on 3.1.0-tip+ # -------------------------------------------------------------------- # latency: 55 us, #4/4, CPU#0 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:2) # ----------------- # | task: migration/0-6 (uid:0 nice:0 policy:1 rt_prio:99) # ----------------- # # _------=> CPU# # / _-----=> irqs-off # | / _----=> need-resched # || / _---=> hardirq/softirq # ||| / _--=> preempt-depth # |||| / delay # cmd pid ||||| time | caller # \ / ||||| \ | / cat-1129 0d..4 1us : 1129:120:R + [000] 6: 0:R migration/0 cat-1129 0d..4 2us+: ttwu_do_activate.clone.1 <-try_to_wake_up * The current output (for wakeup tracer) with only function tracer enabled is: # tracer: wakeup # cat-1140 0d..4 1us+: 1140:120:R + [000] 6: 0:R migration/0 cat-1140 0d..4 2us : ttwu_do_activate.clone.1 <-try_to_wake_up * The fixed output is: # tracer: wakeup # # wakeup latency trace v1.1.5 on 3.1.0-tip+ # -------------------------------------------------------------------- # latency: 207 us, #109/109, CPU#1 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:2) # ----------------- # | task: watchdog/1-12 (uid:0 nice:0 policy:1 rt_prio:99) # ----------------- # # _------=> CPU# # / _-----=> irqs-off # | / _----=> need-resched # || / _---=> hardirq/softirq # ||| / _--=> preempt-depth # |||| / delay # cmd pid ||||| time | caller # \ / ||||| \ | / -0 1d.h5 1us+: 0:120:R + [001] 12: 0:R watchdog/1 -0 1d.h5 3us : ttwu_do_activate.clone.1 <-try_to_wake_up Link: http://lkml.kernel.org/r/20111107150849.GE1807@m.brq.redhat.com Cc: Frederic Weisbecker Cc: Ingo Molnar Signed-off-by: Jiri Olsa Signed-off-by: Steven Rostedt diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index b24a72d..b296186 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2140,6 +2140,21 @@ enum print_line_t print_trace_line(struct trace_iterator *iter) return print_trace_fmt(iter); } +void trace_latency_header(struct seq_file *m) +{ + struct trace_iterator *iter = m->private; + + /* print nothing if the buffers are empty */ + if (trace_empty(iter)) + return; + + if (iter->iter_flags & TRACE_FILE_LAT_FMT) + print_trace_header(m, iter); + + if (!(trace_flags & TRACE_ITER_VERBOSE)) + print_lat_help_header(m); +} + void trace_default_header(struct seq_file *m) { struct trace_iterator *iter = m->private; diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 092e1f8..f8ec229 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -370,6 +370,7 @@ void trace_graph_function(struct trace_array *tr, unsigned long ip, unsigned long parent_ip, unsigned long flags, int pc); +void trace_latency_header(struct seq_file *m); void trace_default_header(struct seq_file *m); void print_trace_header(struct seq_file *m, struct trace_iterator *iter); int trace_empty(struct trace_iterator *iter); diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c index a1a3359..a248c68 100644 --- a/kernel/trace/trace_irqsoff.c +++ b/kernel/trace/trace_irqsoff.c @@ -280,9 +280,20 @@ static enum print_line_t irqsoff_print_line(struct trace_iterator *iter) } static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { } -static void irqsoff_print_header(struct seq_file *s) { } static void irqsoff_trace_open(struct trace_iterator *iter) { } static void irqsoff_trace_close(struct trace_iterator *iter) { } + +#ifdef CONFIG_FUNCTION_TRACER +static void irqsoff_print_header(struct seq_file *s) +{ + trace_default_header(s); +} +#else +static void irqsoff_print_header(struct seq_file *s) +{ + trace_latency_header(s); +} +#endif /* CONFIG_FUNCTION_TRACER */ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ /* diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c index e4a70c0..ff791ea 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c @@ -280,9 +280,20 @@ static enum print_line_t wakeup_print_line(struct trace_iterator *iter) } static void wakeup_graph_return(struct ftrace_graph_ret *trace) { } -static void wakeup_print_header(struct seq_file *s) { } static void wakeup_trace_open(struct trace_iterator *iter) { } static void wakeup_trace_close(struct trace_iterator *iter) { } + +#ifdef CONFIG_FUNCTION_TRACER +static void wakeup_print_header(struct seq_file *s) +{ + trace_default_header(s); +} +#else +static void wakeup_print_header(struct seq_file *s) +{ + trace_latency_header(s); +} +#endif /* CONFIG_FUNCTION_TRACER */ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ /* -- cgit v0.10.2 From 5ada9913630d48438f2e07551af43cbf297372d4 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 24 Oct 2011 15:30:57 +0200 Subject: Bluetooth: Return proper error codes on rfcomm tty init Forward error codes from tty core to the rfcomm_init caller instead of using generic -1 errors. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index c258796..2b753a3 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -1155,9 +1155,11 @@ static const struct tty_operations rfcomm_ops = { int __init rfcomm_init_ttys(void) { + int error; + rfcomm_tty_driver = alloc_tty_driver(RFCOMM_TTY_PORTS); if (!rfcomm_tty_driver) - return -1; + return -ENOMEM; rfcomm_tty_driver->owner = THIS_MODULE; rfcomm_tty_driver->driver_name = "rfcomm"; @@ -1172,10 +1174,11 @@ int __init rfcomm_init_ttys(void) rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); - if (tty_register_driver(rfcomm_tty_driver)) { + error = tty_register_driver(rfcomm_tty_driver); + if (error) { BT_ERR("Can't register RFCOMM TTY driver"); put_tty_driver(rfcomm_tty_driver); - return -1; + return error; } BT_INFO("RFCOMM TTY layer initialized"); -- cgit v0.10.2 From 96af7391b752cf3d2de3aef8f03c45ba76d3ac5e Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 24 Oct 2011 15:30:58 +0200 Subject: Bluetooth: Replace rfcomm tty tasklet by workqueue Remove old tasklets and replace by workqueue. To avoid reentrancy (which tasklets always avoid) we use the system_nrt_wq. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 2b753a3..947f1b3 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -65,7 +66,7 @@ struct rfcomm_dev { struct rfcomm_dlc *dlc; struct tty_struct *tty; wait_queue_head_t wait; - struct tasklet_struct wakeup_task; + struct work_struct wakeup_task; struct device *tty_dev; @@ -81,7 +82,7 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb); static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err); static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig); -static void rfcomm_tty_wakeup(unsigned long arg); +static void rfcomm_tty_wakeup(struct work_struct *work); /* ---- Device functions ---- */ static void rfcomm_dev_destruct(struct rfcomm_dev *dev) @@ -257,7 +258,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) atomic_set(&dev->opened, 0); init_waitqueue_head(&dev->wait); - tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev); + INIT_WORK(&dev->wakeup_task, rfcomm_tty_wakeup); skb_queue_head_init(&dev->pending); @@ -351,7 +352,7 @@ static void rfcomm_wfree(struct sk_buff *skb) struct rfcomm_dev *dev = (void *) skb->sk; atomic_sub(skb->truesize, &dev->wmem_alloc); if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags)) - tasklet_schedule(&dev->wakeup_task); + queue_work(system_nrt_wq, &dev->wakeup_task); rfcomm_dev_put(dev); } @@ -635,9 +636,10 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig) } /* ---- TTY functions ---- */ -static void rfcomm_tty_wakeup(unsigned long arg) +static void rfcomm_tty_wakeup(struct work_struct *work) { - struct rfcomm_dev *dev = (void *) arg; + struct rfcomm_dev *dev = container_of(work, struct rfcomm_dev, + wakeup_task); struct tty_struct *tty = dev->tty; if (!tty) return; @@ -762,7 +764,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp) rfcomm_dlc_close(dev->dlc, 0); clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags); - tasklet_kill(&dev->wakeup_task); + cancel_work_sync(&dev->wakeup_task); rfcomm_dlc_lock(dev->dlc); tty->driver_data = NULL; -- cgit v0.10.2 From 13ea4015d37d2dbe597580898b5fafbe6f593f72 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 26 Oct 2011 10:43:18 +0200 Subject: Bluetooth: Ignore hci_unregister_dev return value Make all bluetooth drivers ignore the return value of hci_unregister_dev as it always returns 0. In the next step, hci_unregister_dev can be modified to return void. Some of the drivers already ignore the return value (including btusb), hence, this will increase consitency in the bluetooth drivers. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 005919a..6580d50 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -750,9 +750,7 @@ static void bfusb_disconnect(struct usb_interface *intf) bfusb_close(hdev); - if (hci_unregister_dev(hdev) < 0) - BT_ERR("Can't unregister HCI device %s", hdev->name); - + hci_unregister_dev(hdev); hci_free_dev(hdev); } diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index aed1904..c6a0c61 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -844,9 +844,7 @@ static int bluecard_close(bluecard_info_t *info) /* Turn FPGA off */ outb(0x80, iobase + 0x30); - if (hci_unregister_dev(hdev) < 0) - BT_ERR("Can't unregister HCI device %s", hdev->name); - + hci_unregister_dev(hdev); hci_free_dev(hdev); return 0; diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 4fc0194..0c97e5d 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -636,9 +636,7 @@ static int bt3c_close(bt3c_info_t *info) bt3c_hci_close(hdev); - if (hci_unregister_dev(hdev) < 0) - BT_ERR("Can't unregister HCI device %s", hdev->name); - + hci_unregister_dev(hdev); hci_free_dev(hdev); return 0; diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 526b618..200b3a2 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -565,9 +565,7 @@ static int btuart_close(btuart_info_t *info) spin_unlock_irqrestore(&(info->lock), flags); - if (hci_unregister_dev(hdev) < 0) - BT_ERR("Can't unregister HCI device %s", hdev->name); - + hci_unregister_dev(hdev); hci_free_dev(hdev); return 0; diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 5e4c2de..969bb22 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -551,9 +551,7 @@ static int dtl1_close(dtl1_info_t *info) spin_unlock_irqrestore(&(info->lock), flags); - if (hci_unregister_dev(hdev) < 0) - BT_ERR("Can't unregister HCI device %s", hdev->name); - + hci_unregister_dev(hdev); hci_free_dev(hdev); return 0; diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 67c180c..2e302a1 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -264,10 +264,7 @@ static int vhci_release(struct inode *inode, struct file *file) struct vhci_data *data = file->private_data; struct hci_dev *hdev = data->hdev; - if (hci_unregister_dev(hdev) < 0) { - BT_ERR("Can't unregister HCI device %s", hdev->name); - } - + hci_unregister_dev(hdev); hci_free_dev(hdev); file->private_data = NULL; -- cgit v0.10.2 From 59735631d24e3463f139a21255e0db94bc59081e Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 26 Oct 2011 10:43:19 +0200 Subject: Bluetooth: Make hci_unregister_dev return void hci_unregister_dev cannot fail and always returns 0. The drivers already ignore the return value so we can safely make it return void. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 119b795..967e18f7 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -554,7 +554,7 @@ struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); struct hci_dev *hci_alloc_dev(void); void hci_free_dev(struct hci_dev *hdev); int hci_register_dev(struct hci_dev *hdev); -int hci_unregister_dev(struct hci_dev *hdev); +void hci_unregister_dev(struct hci_dev *hdev); int hci_suspend_dev(struct hci_dev *hdev); int hci_resume_dev(struct hci_dev *hdev); int hci_dev_open(__u16 dev); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index fdcbf8f..557ff90 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1541,7 +1541,7 @@ err: EXPORT_SYMBOL(hci_register_dev); /* Unregister HCI device */ -int hci_unregister_dev(struct hci_dev *hdev) +void hci_unregister_dev(struct hci_dev *hdev) { int i; @@ -1583,8 +1583,6 @@ int hci_unregister_dev(struct hci_dev *hdev) hci_dev_unlock_bh(hdev); __hci_dev_put(hdev); - - return 0; } EXPORT_SYMBOL(hci_unregister_dev); -- cgit v0.10.2 From c3eae82a844bb33e8182c7ee81828516b51ad642 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Sat, 29 Oct 2011 21:52:49 +0400 Subject: Bluetooth: ath3k: output firmware filename when request_firmware failed This makes it much easier for the users to understand why the driver refuses to load when the firmware is unavailable. Signed-off-by: Paul Fertser Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index db7cb81..39b25ac 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -30,6 +30,7 @@ #include #define VERSION "1.0" +#define ATH3K_FIRMWARE "ath3k-1.fw" #define ATH3K_DNLOAD 0x01 #define ATH3K_GETSTATE 0x05 @@ -400,9 +401,15 @@ static int ath3k_probe(struct usb_interface *intf, return 0; } - if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) { - BT_ERR("Error loading firmware"); - return -EIO; + ret = request_firmware(&firmware, ATH3K_FIRMWARE, &udev->dev); + if (ret < 0) { + if (ret == -ENOENT) + BT_ERR("Firmware file \"%s\" not found", + ATH3K_FIRMWARE); + else + BT_ERR("Firmware file \"%s\" request failed (err=%d)", + ATH3K_FIRMWARE, ret); + return ret; } ret = ath3k_load_firmware(udev, firmware); @@ -441,4 +448,4 @@ MODULE_AUTHOR("Atheros Communications"); MODULE_DESCRIPTION("Atheros AR30xx firmware driver"); MODULE_VERSION(VERSION); MODULE_LICENSE("GPL"); -MODULE_FIRMWARE("ath3k-1.fw"); +MODULE_FIRMWARE(ATH3K_FIRMWARE); -- cgit v0.10.2 From 0e8b207e8a4442f1a662e1a3827e61e40279630a Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 17 Oct 2011 14:35:32 +0300 Subject: Bluetooth: EFS: implement L2CAP config pending state Add L2CAP Config Pending state for EFS. Currently after receiving Config Response Pending respond with Config Response Success. ... > ACL data: handle 1 flags 0x02 dlen 16 L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0 Connection successful > ACL data: handle 1 flags 0x02 dlen 45 L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 33 RFC 0x03 (Enhanced Retransmission, TxWin 63, MaxTx 3, RTo 0, MTo 0, MPS 1009) EFS (Id 0x01, SerType Best Effort, MaxSDU 0xffff, SDUitime 0xffffffff, AccLat 0xffffffff, FlushTO 0x0000ffff) < ACL data: handle 1 flags 0x00 dlen 45 L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 33 RFC 0x03 (Enhanced Retransmission, TxWin 63, MaxTx 3, RTo 0, MTo 0, MPS 498) EFS (Id 0x01, SerType Best Effort, MaxSDU 0xffff, SDUitime 0xffffffff, AccLat 0xffffffff, FlushTO 0x0000ffff) < ACL data: handle 1 flags 0x00 dlen 47 L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 4 clen 33 Pending MTU 672 RFC 0x03 (Enhanced Retransmission, TxWin 63, MaxTx 3, RTo 2000, MTo 12000, MPS 498) EFS (Id 0x01, SerType Best Effort, MaxSDU 0xffff, SDUitime 0xffffffff, AccLat 0xffffffff, FlushTO 0x0000ffff) > ACL data: handle 1 flags 0x02 dlen 47 L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 4 clen 33 Pending MTU 672 RFC 0x03 (Enhanced Retransmission, TxWin 63, MaxTx 3, RTo 2000, MTo 12000, MPS 498) EFS (Id 0x01, SerType Best Effort, MaxSDU 0xffff, SDUitime 0xffffffff, AccLat 0xffffffff, FlushTO 0x0000ffff) > ACL data: handle 1 flags 0x02 dlen 14 L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0 Success < ACL data: handle 1 flags 0x00 dlen 14 L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0 Success < ACL data: handle 1 flags 0x00 dlen 510 L2CAP(d): cid 0x0040 len 506 ext_ctrl 0x00010000 fcs 0xebe0 [psm 4113] I-frame: Start (len 672) TxSeq 0 ReqSeq 0 ... Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index fddc82a..38a5615 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -246,6 +246,7 @@ struct l2cap_conf_rsp { #define L2CAP_CONF_UNACCEPT 0x0001 #define L2CAP_CONF_REJECT 0x0002 #define L2CAP_CONF_UNKNOWN 0x0003 +#define L2CAP_CONF_PENDING 0x0004 #define L2CAP_CONF_EFS_REJECT 0x0005 struct l2cap_conf_opt { @@ -505,6 +506,8 @@ enum { CONF_NO_FCS_RECV, CONF_STATE2_DEVICE, CONF_EWS_RECV, + CONF_LOC_CONF_PEND, + CONF_REM_CONF_PEND, }; #define L2CAP_CONF_MAX_CONF_REQ 2 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index bda6da7..c12d3bf 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -2239,6 +2239,11 @@ done: l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs), (unsigned long) &efs); + } else { + /* Send PENDING Conf Rsp and mark state + local PENDING */ + result = L2CAP_CONF_PENDING; + set_bit(CONF_LOC_CONF_PEND, &chan->conf_state); } } @@ -2379,7 +2384,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi chan->mode = rfc.mode; - if (*result == L2CAP_CONF_SUCCESS) { + if (*result == L2CAP_CONF_SUCCESS || *result == L2CAP_CONF_PENDING) { switch (rfc.mode) { case L2CAP_MODE_ERTM: chan->retrans_timeout = le16_to_cpu(rfc.retrans_timeout); @@ -2785,6 +2790,21 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr chan->num_conf_req++; } + /* Got Conf Rsp PENDING from remote side and asume we sent + Conf Rsp PENDING in the code above */ + if (test_bit(CONF_REM_CONF_PEND, &chan->conf_state) && + test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) { + + /* check compatibility */ + + clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state); + set_bit(CONF_OUTPUT_DONE, &chan->conf_state); + + l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, + l2cap_build_conf_rsp(chan, rsp, + L2CAP_CONF_SUCCESS, 0x0000), rsp); + } + unlock: bh_unlock_sock(sk); return 0; @@ -2814,8 +2834,33 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr switch (result) { case L2CAP_CONF_SUCCESS: l2cap_conf_rfc_get(chan, rsp->data, len); + clear_bit(CONF_REM_CONF_PEND, &chan->conf_state); break; + case L2CAP_CONF_PENDING: + set_bit(CONF_REM_CONF_PEND, &chan->conf_state); + + if (test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) { + char buf[64]; + + len = l2cap_parse_conf_rsp(chan, rsp->data, len, + buf, &result); + if (len < 0) { + l2cap_send_disconn_req(conn, chan, ECONNRESET); + goto done; + } + + /* check compatibility */ + + clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state); + set_bit(CONF_OUTPUT_DONE, &chan->conf_state); + + l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, + l2cap_build_conf_rsp(chan, buf, + L2CAP_CONF_SUCCESS, 0x0000), buf); + } + goto done; + case L2CAP_CONF_UNACCEPT: if (chan->num_conf_rsp <= L2CAP_CONF_MAX_CONF_RSP) { char req[64]; -- cgit v0.10.2 From 3e6b3b95f26e1253cd429cf949b9c41598ba3033 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Tue, 1 Nov 2011 14:06:23 -0200 Subject: Bluetooth: small styles clean ups to l2cap_core.c Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index c12d3bf..7d663bd 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -2237,11 +2237,10 @@ done: return -ECONNREFUSED; l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, - sizeof(efs), + sizeof(efs), (unsigned long) &efs); } else { - /* Send PENDING Conf Rsp and mark state - local PENDING */ + /* Send PENDING Conf Rsp */ result = L2CAP_CONF_PENDING; set_bit(CONF_LOC_CONF_PEND, &chan->conf_state); } @@ -2373,8 +2372,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi case L2CAP_CONF_EWS: chan->tx_win = min_t(u16, val, L2CAP_DEFAULT_EXT_WINDOW); - l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, - 2, chan->tx_win); + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, + chan->tx_win); break; } } @@ -2801,7 +2800,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr set_bit(CONF_OUTPUT_DONE, &chan->conf_state); l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, - l2cap_build_conf_rsp(chan, rsp, + l2cap_build_conf_rsp(chan, rsp, L2CAP_CONF_SUCCESS, 0x0000), rsp); } @@ -2856,7 +2855,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr set_bit(CONF_OUTPUT_DONE, &chan->conf_state); l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, - l2cap_build_conf_rsp(chan, buf, + l2cap_build_conf_rsp(chan, buf, L2CAP_CONF_SUCCESS, 0x0000), buf); } goto done; -- cgit v0.10.2 From c6337ea6e5771a3c51c1ac7295a16f390220abe1 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 20 Oct 2011 17:02:44 +0300 Subject: Bluetooth: remove magic offset and size make code readable by removing magic numbers Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 7d663bd..18b0bba 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3021,7 +3021,7 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; rsp->type = cpu_to_le16(L2CAP_IT_FIXED_CHAN); rsp->result = cpu_to_le16(L2CAP_IR_SUCCESS); - memcpy(buf + 4, l2cap_fixed_chan, 8); + memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf), buf); } else { -- cgit v0.10.2 From 457f48507deb0e8c8dd299c7d8dce7c2c0e291e8 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 31 Oct 2011 16:17:21 +0200 Subject: Bluetooth: correct debug output l2cap_set_timer function prints sk instead of chan pointer. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 18b0bba..76210cd 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -220,7 +220,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) static void l2cap_set_timer(struct l2cap_chan *chan, struct timer_list *timer, long timeout) { - BT_DBG("chan %p state %d timeout %ld", chan->sk, chan->state, timeout); + BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); if (!mod_timer(timer, jiffies + msecs_to_jiffies(timeout))) chan_hold(chan); -- cgit v0.10.2 From 8035ded466049ca2fe8c04564a0fa00f222abe3f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 1 Nov 2011 10:58:56 +0200 Subject: Bluetooth: replace list_for_each with list_for_each_entry whenever possible When all items in the list have the same type there is no much of a point to use list_for_each except if you want to use the list pointer itself. Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 91bcd3a..a6cd856 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -65,15 +65,13 @@ static DECLARE_RWSEM(bnep_session_sem); static struct bnep_session *__bnep_get_session(u8 *dst) { struct bnep_session *s; - struct list_head *p; BT_DBG(""); - list_for_each(p, &bnep_session_list) { - s = list_entry(p, struct bnep_session, list); + list_for_each_entry(s, &bnep_session_list, list) if (!compare_ether_addr(dst, s->eh.h_source)) return s; - } + return NULL; } @@ -667,17 +665,14 @@ static void __bnep_copy_ci(struct bnep_conninfo *ci, struct bnep_session *s) int bnep_get_connlist(struct bnep_connlist_req *req) { - struct list_head *p; + struct bnep_session *s; int err = 0, n = 0; down_read(&bnep_session_sem); - list_for_each(p, &bnep_session_list) { - struct bnep_session *s; + list_for_each_entry(s, &bnep_session_list, list) { struct bnep_conninfo ci; - s = list_entry(p, struct bnep_session, list); - __bnep_copy_ci(&ci, s); if (copy_to_user(req->ci, &ci, sizeof(ci))) { diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c index 7d00ddf..9e8940b 100644 --- a/net/bluetooth/cmtp/core.c +++ b/net/bluetooth/cmtp/core.c @@ -53,15 +53,13 @@ static LIST_HEAD(cmtp_session_list); static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr) { struct cmtp_session *session; - struct list_head *p; BT_DBG(""); - list_for_each(p, &cmtp_session_list) { - session = list_entry(p, struct cmtp_session, list); + list_for_each_entry(session, &cmtp_session_list, list) if (!bacmp(bdaddr, &session->bdaddr)) return session; - } + return NULL; } @@ -431,19 +429,16 @@ int cmtp_del_connection(struct cmtp_conndel_req *req) int cmtp_get_connlist(struct cmtp_connlist_req *req) { - struct list_head *p; + struct cmtp_session *session; int err = 0, n = 0; BT_DBG(""); down_read(&cmtp_session_sem); - list_for_each(p, &cmtp_session_list) { - struct cmtp_session *session; + list_for_each_entry(session, &cmtp_session_list, list) { struct cmtp_conninfo ci; - session = list_entry(p, struct cmtp_session, list); - __cmtp_copy_session(session, &ci); if (copy_to_user(req->ci, &ci, sizeof(ci))) { diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index c1c597e..6e98ff3 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -453,16 +453,13 @@ int hci_conn_del(struct hci_conn *conn) struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) { int use_src = bacmp(src, BDADDR_ANY); - struct hci_dev *hdev = NULL; - struct list_head *p; + struct hci_dev *hdev = NULL, *d; BT_DBG("%s -> %s", batostr(src), batostr(dst)); read_lock_bh(&hci_dev_list_lock); - list_for_each(p, &hci_dev_list) { - struct hci_dev *d = list_entry(p, struct hci_dev, list); - + list_for_each_entry(d, &hci_dev_list, list) { if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags)) continue; @@ -855,10 +852,10 @@ EXPORT_SYMBOL(hci_conn_put_device); int hci_get_conn_list(void __user *arg) { + register struct hci_conn *c; struct hci_conn_list_req req, *cl; struct hci_conn_info *ci; struct hci_dev *hdev; - struct list_head *p; int n = 0, size, err; if (copy_from_user(&req, arg, sizeof(req))) @@ -882,10 +879,7 @@ int hci_get_conn_list(void __user *arg) ci = cl->conn_info; hci_dev_lock_bh(hdev); - list_for_each(p, &hdev->conn_hash.list) { - register struct hci_conn *c; - c = list_entry(p, struct hci_conn, list); - + list_for_each_entry(c, &hdev->conn_hash.list, list) { bacpy(&(ci + n)->bdaddr, &c->dst); (ci + n)->handle = c->handle; (ci + n)->type = c->type; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 557ff90..f04f2eca2 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -319,8 +319,7 @@ static void hci_linkpol_req(struct hci_dev *hdev, unsigned long opt) * Device is held on return. */ struct hci_dev *hci_dev_get(int index) { - struct hci_dev *hdev = NULL; - struct list_head *p; + struct hci_dev *hdev = NULL, *d; BT_DBG("%d", index); @@ -328,8 +327,7 @@ struct hci_dev *hci_dev_get(int index) return NULL; read_lock(&hci_dev_list_lock); - list_for_each(p, &hci_dev_list) { - struct hci_dev *d = list_entry(p, struct hci_dev, list); + list_for_each_entry(d, &hci_dev_list, list) { if (d->id == index) { hdev = hci_dev_hold(d); break; @@ -794,9 +792,9 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg) int hci_get_dev_list(void __user *arg) { + struct hci_dev *hdev; struct hci_dev_list_req *dl; struct hci_dev_req *dr; - struct list_head *p; int n = 0, size, err; __u16 dev_num; @@ -815,11 +813,7 @@ int hci_get_dev_list(void __user *arg) dr = dl->dev_req; read_lock_bh(&hci_dev_list_lock); - list_for_each(p, &hci_dev_list) { - struct hci_dev *hdev; - - hdev = list_entry(p, struct hci_dev, list); - + list_for_each_entry(hdev, &hci_dev_list, list) { hci_del_off_timer(hdev); if (!test_bit(HCI_MGMT, &hdev->flags)) @@ -1008,16 +1002,11 @@ int hci_link_keys_clear(struct hci_dev *hdev) struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) { - struct list_head *p; - - list_for_each(p, &hdev->link_keys) { - struct link_key *k; - - k = list_entry(p, struct link_key, list); + struct link_key *k; + list_for_each_entry(k, &hdev->link_keys, list) if (bacmp(bdaddr, &k->bdaddr) == 0) return k; - } return NULL; } @@ -1280,16 +1269,11 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) { - struct list_head *p; - - list_for_each(p, &hdev->blacklist) { - struct bdaddr_list *b; - - b = list_entry(p, struct bdaddr_list, list); + struct bdaddr_list *b; + list_for_each_entry(b, &hdev->blacklist, list) if (bacmp(bdaddr, &b->bdaddr) == 0) return b; - } return NULL; } @@ -2031,16 +2015,12 @@ EXPORT_SYMBOL(hci_send_sco); static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote) { struct hci_conn_hash *h = &hdev->conn_hash; - struct hci_conn *conn = NULL; + struct hci_conn *conn = NULL, *c; int num = 0, min = ~0; - struct list_head *p; /* We don't have to lock device here. Connections are always * added and removed with TX task disabled. */ - list_for_each(p, &h->list) { - struct hci_conn *c; - c = list_entry(p, struct hci_conn, list); - + list_for_each_entry(c, &h->list, list) { if (c->type != type || skb_queue_empty(&c->data_q)) continue; @@ -2089,14 +2069,12 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type) { struct hci_conn_hash *h = &hdev->conn_hash; - struct list_head *p; - struct hci_conn *c; + struct hci_conn *c; BT_ERR("%s link tx timeout", hdev->name); /* Kill stalled connections */ - list_for_each(p, &h->list) { - c = list_entry(p, struct hci_conn, list); + list_for_each_entry(c, &h->list, list) { if (c->type == type && c->sent) { BT_ERR("%s killing stalled connection %s", hdev->name, batostr(&c->dst)); diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 1f9f876..f8e6aa3 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -435,17 +435,12 @@ static const struct file_operations inquiry_cache_fops = { static int blacklist_show(struct seq_file *f, void *p) { struct hci_dev *hdev = f->private; - struct list_head *l; + struct bdaddr_list *b; hci_dev_lock_bh(hdev); - list_for_each(l, &hdev->blacklist) { - struct bdaddr_list *b; - - b = list_entry(l, struct bdaddr_list, list); - + list_for_each_entry(b, &hdev->blacklist, list) seq_printf(f, "%s\n", batostr(&b->bdaddr)); - } hci_dev_unlock_bh(hdev); @@ -484,17 +479,12 @@ static void print_bt_uuid(struct seq_file *f, u8 *uuid) static int uuids_show(struct seq_file *f, void *p) { struct hci_dev *hdev = f->private; - struct list_head *l; + struct bt_uuid *uuid; hci_dev_lock_bh(hdev); - list_for_each(l, &hdev->uuids) { - struct bt_uuid *uuid; - - uuid = list_entry(l, struct bt_uuid, list); - + list_for_each_entry(uuid, &hdev->uuids, list) print_bt_uuid(f, uuid->uuid); - } hci_dev_unlock_bh(hdev); diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 217ef47..2efd6cc 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -88,6 +88,7 @@ static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr) if (!bacmp(bdaddr, &session->bdaddr)) return session; } + return NULL; } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9ffd7c3..7809aa9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -123,6 +123,7 @@ static int read_index_list(struct sock *sk) { struct mgmt_rp_read_index_list *rp; struct list_head *p; + struct hci_dev *d; size_t rp_len; u16 count; int i, err; @@ -146,9 +147,7 @@ static int read_index_list(struct sock *sk) put_unaligned_le16(count, &rp->num_controllers); i = 0; - list_for_each(p, &hci_dev_list) { - struct hci_dev *d = list_entry(p, struct hci_dev, list); - + list_for_each_entry(d, &hci_dev_list, list) { hci_del_off_timer(d); set_bit(HCI_MGMT, &d->flags); @@ -277,13 +276,9 @@ static void mgmt_pending_foreach(u16 opcode, int index, static struct pending_cmd *mgmt_pending_find(u16 opcode, int index) { - struct list_head *p; - - list_for_each(p, &cmd_list) { - struct pending_cmd *cmd; - - cmd = list_entry(p, struct pending_cmd, list); + struct pending_cmd *cmd; + list_for_each_entry(cmd, &cmd_list, list) { if (cmd->opcode != opcode) continue; @@ -592,7 +587,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data) u16 eir_len = 0; u16 uuid16_list[HCI_MAX_EIR_LENGTH / sizeof(u16)]; int i, truncated = 0; - struct list_head *p; + struct bt_uuid *uuid; size_t name_len; name_len = strlen(hdev->dev_name); @@ -617,8 +612,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data) memset(uuid16_list, 0, sizeof(uuid16_list)); /* Group all UUID16 types */ - list_for_each(p, &hdev->uuids) { - struct bt_uuid *uuid = list_entry(p, struct bt_uuid, list); + list_for_each_entry(uuid, &hdev->uuids, list) { u16 uuid16; uuid16 = get_uuid16(uuid->uuid); @@ -1069,6 +1063,7 @@ static int get_connections(struct sock *sk, u16 index) { struct mgmt_rp_get_connections *rp; struct hci_dev *hdev; + struct hci_conn *c; struct list_head *p; size_t rp_len; u16 count; @@ -1097,11 +1092,8 @@ static int get_connections(struct sock *sk, u16 index) put_unaligned_le16(count, &rp->conn_count); i = 0; - list_for_each(p, &hdev->conn_hash.list) { - struct hci_conn *c = list_entry(p, struct hci_conn, list); - + list_for_each_entry(c, &hdev->conn_hash.list, list) bacpy(&rp->conn[i++], &c->dst); - } err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); @@ -1270,13 +1262,9 @@ static int set_io_capability(struct sock *sk, u16 index, unsigned char *data, static inline struct pending_cmd *find_pairing(struct hci_conn *conn) { struct hci_dev *hdev = conn->hdev; - struct list_head *p; - - list_for_each(p, &cmd_list) { - struct pending_cmd *cmd; - - cmd = list_entry(p, struct pending_cmd, list); + struct pending_cmd *cmd; + list_for_each_entry(cmd, &cmd_list, list) { if (cmd->opcode != MGMT_OP_PAIR_DEVICE) continue; diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 38b618c..3d35eba 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -377,13 +377,11 @@ static void rfcomm_dlc_unlink(struct rfcomm_dlc *d) static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci) { struct rfcomm_dlc *d; - struct list_head *p; - list_for_each(p, &s->dlcs) { - d = list_entry(p, struct rfcomm_dlc, list); + list_for_each_entry(d, &s->dlcs, list) if (d->dlci == dlci) return d; - } + return NULL; } @@ -2115,15 +2113,13 @@ static struct hci_cb rfcomm_cb = { static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) { struct rfcomm_session *s; - struct list_head *pp, *p; rfcomm_lock(); - list_for_each(p, &session_list) { - s = list_entry(p, struct rfcomm_session, list); - list_for_each(pp, &s->dlcs) { + list_for_each_entry(s, &session_list, list) { + struct rfcomm_dlc *d; + list_for_each_entry(d, &s->dlcs, list) { struct sock *sk = s->sock->sk; - struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); seq_printf(f, "%s %s %ld %d %d %d %d\n", batostr(&bt_sk(sk)->src), diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 947f1b3..fa8f4de5 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -134,13 +134,10 @@ static inline void rfcomm_dev_put(struct rfcomm_dev *dev) static struct rfcomm_dev *__rfcomm_dev_get(int id) { struct rfcomm_dev *dev; - struct list_head *p; - list_for_each(p, &rfcomm_dev_list) { - dev = list_entry(p, struct rfcomm_dev, list); + list_for_each_entry(dev, &rfcomm_dev_list, list) if (dev->id == id) return dev; - } return NULL; } @@ -198,7 +195,7 @@ static DEVICE_ATTR(channel, S_IRUGO, show_channel, NULL); static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) { - struct rfcomm_dev *dev; + struct rfcomm_dev *dev, *entry; struct list_head *head = &rfcomm_dev_list, *p; int err = 0; @@ -213,8 +210,8 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) if (req->dev_id < 0) { dev->id = 0; - list_for_each(p, &rfcomm_dev_list) { - if (list_entry(p, struct rfcomm_dev, list)->id != dev->id) + list_for_each_entry(entry, &rfcomm_dev_list, list) { + if (entry->id != dev->id) break; dev->id++; @@ -223,9 +220,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) } else { dev->id = req->dev_id; - list_for_each(p, &rfcomm_dev_list) { - struct rfcomm_dev *entry = list_entry(p, struct rfcomm_dev, list); - + list_for_each_entry(entry, &rfcomm_dev_list, list) { if (entry->id == dev->id) { err = -EADDRINUSE; goto out; @@ -456,9 +451,9 @@ static int rfcomm_release_dev(void __user *arg) static int rfcomm_get_dev_list(void __user *arg) { + struct rfcomm_dev *dev; struct rfcomm_dev_list_req *dl; struct rfcomm_dev_info *di; - struct list_head *p; int n = 0, size, err; u16 dev_num; @@ -480,8 +475,7 @@ static int rfcomm_get_dev_list(void __user *arg) read_lock_bh(&rfcomm_dev_lock); - list_for_each(p, &rfcomm_dev_list) { - struct rfcomm_dev *dev = list_entry(p, struct rfcomm_dev, list); + list_for_each_entry(dev, &rfcomm_dev_list, list) { if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) continue; (di + n)->id = dev->id; -- cgit v0.10.2 From 5e59b791c3561e2fbb4aee17df3505ad25c16b7a Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 1 Nov 2011 10:58:57 +0200 Subject: Bluetooth: set skbuffer priority based on L2CAP socket priority This uses SO_PRIORITY to set the skbuffer priority field Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 967e18f7..9285a65 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -32,6 +32,9 @@ #define HCI_PROTO_L2CAP 0 #define HCI_PROTO_SCO 1 +/* HCI priority */ +#define HCI_PRIO_MAX 7 + /* HCI Core structures */ struct inquiry_data { bdaddr_t bdaddr; diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 38a5615..c10bf1d 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -747,7 +747,8 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk); void l2cap_chan_close(struct l2cap_chan *chan, int reason); void l2cap_chan_destroy(struct l2cap_chan *chan); int l2cap_chan_connect(struct l2cap_chan *chan); -int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); +int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, + u32 priority); void l2cap_chan_busy(struct l2cap_chan *chan, int busy); #endif /* __L2CAP_H */ diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 76210cd..ac2c41a 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -564,6 +564,7 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, flags = ACL_START; bt_cb(skb)->force_active = BT_POWER_FORCE_ACTIVE_ON; + skb->priority = HCI_PRIO_MAX; hci_send_acl(conn->hcon, skb, flags); } @@ -1265,7 +1266,8 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) struct hci_conn *hcon = chan->conn->hcon; u16 flags; - BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len); + BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, + skb->priority); if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && lmp_no_flush_capable(hcon->hdev)) @@ -1483,6 +1485,8 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count)) return -EFAULT; + (*frag)->priority = skb->priority; + sent += count; len -= count; @@ -1492,7 +1496,9 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in return sent; } -static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) +static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, + struct msghdr *msg, size_t len, + u32 priority) { struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; @@ -1500,7 +1506,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE; struct l2cap_hdr *lh; - BT_DBG("sk %p len %d", sk, (int)len); + BT_DBG("sk %p len %d priority %u", sk, (int)len, priority); count = min_t(unsigned int, (conn->mtu - hlen), len); skb = bt_skb_send_alloc(sk, count + hlen, @@ -1508,6 +1514,8 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct if (!skb) return ERR_PTR(err); + skb->priority = priority; + /* Create L2CAP header */ lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); lh->cid = cpu_to_le16(chan->dcid); @@ -1522,7 +1530,9 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct return skb; } -static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) +static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, + struct msghdr *msg, size_t len, + u32 priority) { struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; @@ -1538,6 +1548,8 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct ms if (!skb) return ERR_PTR(err); + skb->priority = priority; + /* Create L2CAP header */ lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); lh->cid = cpu_to_le16(chan->dcid); @@ -1651,7 +1663,8 @@ static int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, si return size; } -int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) +int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, + u32 priority) { struct sk_buff *skb; u32 control; @@ -1659,7 +1672,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) /* Connectionless channel */ if (chan->chan_type == L2CAP_CHAN_CONN_LESS) { - skb = l2cap_create_connless_pdu(chan, msg, len); + skb = l2cap_create_connless_pdu(chan, msg, len, priority); if (IS_ERR(skb)) return PTR_ERR(skb); @@ -1674,7 +1687,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) return -EMSGSIZE; /* Create a basic PDU */ - skb = l2cap_create_basic_pdu(chan, msg, len); + skb = l2cap_create_basic_pdu(chan, msg, len, priority); if (IS_ERR(skb)) return PTR_ERR(skb); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 836d12e..646aefc 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -721,7 +721,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms return -ENOTCONN; } - err = l2cap_chan_send(chan, msg, len); + err = l2cap_chan_send(chan, msg, len, sk->sk_priority); release_sock(sk); return err; -- cgit v0.10.2 From 262038fcb2a50e9b5553243452918fda08cdf83d Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 1 Nov 2011 10:58:58 +0200 Subject: Bluetooth: make use sk_priority to priritize RFCOMM packets Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 3d35eba..24bf961 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -65,7 +65,8 @@ static DEFINE_MUTEX(rfcomm_mutex); static LIST_HEAD(session_list); -static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len); +static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len, + u32 priority); static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci); static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci); static int rfcomm_queue_disc(struct rfcomm_dlc *d); @@ -747,19 +748,34 @@ void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, bdaddr_t *d } /* ---- RFCOMM frame sending ---- */ -static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len) +static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len, + u32 priority) { struct socket *sock = s->sock; + struct sock *sk = sock->sk; struct kvec iv = { data, len }; struct msghdr msg; - BT_DBG("session %p len %d", s, len); + BT_DBG("session %p len %d priority %u", s, len, priority); + + if (sk->sk_priority != priority) { + lock_sock(sk); + sk->sk_priority = priority; + release_sock(sk); + } memset(&msg, 0, sizeof(msg)); return kernel_sendmsg(sock, &msg, &iv, 1, len); } +static int rfcomm_send_cmd(struct rfcomm_session *s, struct rfcomm_cmd *cmd) +{ + BT_DBG("%p cmd %u", s, cmd->ctrl); + + return rfcomm_send_frame(s, (void *) cmd, sizeof(*cmd), HCI_PRIO_MAX); +} + static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci) { struct rfcomm_cmd cmd; @@ -771,7 +787,7 @@ static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci) cmd.len = __len8(0); cmd.fcs = __fcs2((u8 *) &cmd); - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); + return rfcomm_send_cmd(s, &cmd); } static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci) @@ -785,7 +801,7 @@ static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci) cmd.len = __len8(0); cmd.fcs = __fcs2((u8 *) &cmd); - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); + return rfcomm_send_cmd(s, &cmd); } static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci) @@ -799,7 +815,7 @@ static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci) cmd.len = __len8(0); cmd.fcs = __fcs2((u8 *) &cmd); - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); + return rfcomm_send_cmd(s, &cmd); } static int rfcomm_queue_disc(struct rfcomm_dlc *d) @@ -813,6 +829,8 @@ static int rfcomm_queue_disc(struct rfcomm_dlc *d) if (!skb) return -ENOMEM; + skb->priority = HCI_PRIO_MAX; + cmd = (void *) __skb_put(skb, sizeof(*cmd)); cmd->addr = d->addr; cmd->ctrl = __ctrl(RFCOMM_DISC, 1); @@ -835,7 +853,7 @@ static int rfcomm_send_dm(struct rfcomm_session *s, u8 dlci) cmd.len = __len8(0); cmd.fcs = __fcs2((u8 *) &cmd); - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); + return rfcomm_send_cmd(s, &cmd); } static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type) @@ -860,7 +878,7 @@ static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type) *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d) @@ -902,7 +920,7 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, @@ -940,7 +958,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status) @@ -967,7 +985,7 @@ static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status) *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig) @@ -994,7 +1012,7 @@ static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr) @@ -1016,7 +1034,7 @@ static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr) *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } static int rfcomm_send_fcon(struct rfcomm_session *s, int cr) @@ -1038,7 +1056,7 @@ static int rfcomm_send_fcon(struct rfcomm_session *s, int cr) *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } static int rfcomm_send_test(struct rfcomm_session *s, int cr, u8 *pattern, int len) @@ -1089,7 +1107,7 @@ static int rfcomm_send_credits(struct rfcomm_session *s, u8 addr, u8 credits) *ptr = __fcs(buf); ptr++; - return rfcomm_send_frame(s, buf, ptr - buf); + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); } static void rfcomm_make_uih(struct sk_buff *skb, u8 addr) @@ -1767,7 +1785,8 @@ static inline int rfcomm_process_tx(struct rfcomm_dlc *d) return skb_queue_len(&d->tx_queue); while (d->tx_credits && (skb = skb_dequeue(&d->tx_queue))) { - err = rfcomm_send_frame(d->session, skb->data, skb->len); + err = rfcomm_send_frame(d->session, skb->data, skb->len, + skb->priority); if (err < 0) { skb_queue_head(&d->tx_queue, skb); break; diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 482722b..40988e2 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -597,6 +597,8 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock, break; } + skb->priority = sk->sk_priority; + err = rfcomm_dlc_send(d, skb); if (err < 0) { kfree_skb(skb); -- cgit v0.10.2 From 164a6e78990f6201dc3105ff88335ca91392a427 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 1 Nov 2011 17:06:44 +0200 Subject: Bluetooth: Fix command complete/status for discovery commands This patch adds the necessary code to send proper command status or command complete events to the start/stop discovery management commands. Before this patch these events were completely missing. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9285a65..5a9db9a 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -887,6 +887,7 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, u8 *eir); int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); +int mgmt_inquiry_failed(u16 index, u8 status); int mgmt_discovering(u16 index, u8 discovering); int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr); int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 41967fe..d8fa657 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -979,6 +979,8 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) if (status) { hci_req_complete(hdev, HCI_OP_INQUIRY, status); hci_conn_check_pending(hdev); + if (test_bit(HCI_MGMT, &hdev->flags)) + mgmt_inquiry_failed(hdev->id, status); return; } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 7809aa9..38220a2 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2339,8 +2339,35 @@ int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name) return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL); } +int mgmt_inquiry_failed(u16 index, u8 status) +{ + struct pending_cmd *cmd; + int err; + + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, index); + if (!cmd) + return -ENOENT; + + err = cmd_status(cmd->sk, index, cmd->opcode, status); + mgmt_pending_remove(cmd); + + return err; +} + int mgmt_discovering(u16 index, u8 discovering) { + struct pending_cmd *cmd; + + if (discovering) + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, index); + else + cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index); + + if (cmd != NULL) { + cmd_complete(cmd->sk, index, cmd->opcode, NULL, 0); + mgmt_pending_remove(cmd); + } + return mgmt_event(MGMT_EV_DISCOVERING, index, &discovering, sizeof(discovering), NULL); } -- cgit v0.10.2 From db54467a89266c02f9ce6c6db1d193365cff62a4 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 26 Sep 2011 14:19:47 +0200 Subject: Bluetooth: rfcomm: Fix sleep in invalid context in rfcomm_security_cfm This was triggered by turning off encryption on ACL link when rfcomm was using high security. rfcomm_security_cfm (which is called from rx task) was closing DLC and this involves sending disconnect message (and locking socket). Move closing DLC to rfcomm_process_dlcs and only flag DLC for closure in rfcomm_security_cfm. BUG: sleeping function called from invalid context at net/core/sock.c:2032 in_atomic(): 1, irqs_disabled(): 0, pid: 1788, name: kworker/0:3 [] (unwind_backtrace+0x0/0x108) from [] (dump_stack+0x20/0x24) [] (dump_stack+0x20/0x24) from [] (__might_sleep+0x110/0x12c) [] (__might_sleep+0x110/0x12c) from [] (lock_sock_nested+0x2c/0x64) [] (lock_sock_nested+0x2c/0x64) from [] (l2cap_sock_sendmsg+0x58/0xcc) [] (l2cap_sock_sendmsg+0x58/0xcc) from [] (sock_sendmsg+0xb0/0xd0) [] (sock_sendmsg+0xb0/0xd0) from [] (kernel_sendmsg+0x3c/0x44) [] (kernel_sendmsg+0x3c/0x44) from [] (rfcomm_send_frame+0x50/0x58) [] (rfcomm_send_frame+0x50/0x58) from [] (rfcomm_send_disc+0x78/0x80) [] (rfcomm_send_disc+0x78/0x80) from [] (__rfcomm_dlc_close+0x2d0/0x2fc) [] (__rfcomm_dlc_close+0x2d0/0x2fc) from [] (rfcomm_security_cfm+0x140/0x1e0) [] (rfcomm_security_cfm+0x140/0x1e0) from [] (hci_event_packet+0x1ce8/0x4d84) [] (hci_event_packet+0x1ce8/0x4d84) from [] (hci_rx_task+0x1d0/0x2d0) [] (hci_rx_task+0x1d0/0x2d0) from [] (tasklet_action+0x138/0x1e4) [] (tasklet_action+0x138/0x1e4) from [] (__do_softirq+0xcc/0x274) [] (__do_softirq+0xcc/0x274) from [] (do_softirq+0x60/0x6c) [] (do_softirq+0x60/0x6c) from [] (local_bh_enable_ip+0xc8/0xd4) [] (local_bh_enable_ip+0xc8/0xd4) from [] (_raw_spin_unlock_bh+0x48/0x4c) [] (_raw_spin_unlock_bh+0x48/0x4c) from [] (data_from_chip+0xf4/0xaec) [] (data_from_chip+0xf4/0xaec) from [] (send_skb_to_core+0x40/0x178) [] (send_skb_to_core+0x40/0x178) from [] (cg2900_hu_receive+0x15c/0x2d0) [] (cg2900_hu_receive+0x15c/0x2d0) from [] (hci_uart_tty_receive+0x74/0xa0) [] (hci_uart_tty_receive+0x74/0xa0) from [] (flush_to_ldisc+0x188/0x198) [] (flush_to_ldisc+0x188/0x198) from [] (process_one_work+0x144/0x4b8) [] (process_one_work+0x144/0x4b8) from [] (worker_thread+0x198/0x468) [] (worker_thread+0x198/0x468) from [] (kthread+0x98/0xa0) [] (kthread+0x98/0xa0) from [] (kernel_thread_exit+0x0/0x8) Signed-off-by: Szymon Janc Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h index d5eee20..e2e3eca 100644 --- a/include/net/bluetooth/rfcomm.h +++ b/include/net/bluetooth/rfcomm.h @@ -211,6 +211,7 @@ struct rfcomm_dlc { #define RFCOMM_AUTH_ACCEPT 6 #define RFCOMM_AUTH_REJECT 7 #define RFCOMM_DEFER_SETUP 8 +#define RFCOMM_ENC_DROP 9 /* Scheduling flags and events */ #define RFCOMM_SCHED_WAKEUP 31 diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 24bf961..8743f36 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -1819,6 +1819,11 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s) continue; } + if (test_bit(RFCOMM_ENC_DROP, &d->flags)) { + __rfcomm_dlc_close(d, ECONNREFUSED); + continue; + } + if (test_and_clear_bit(RFCOMM_AUTH_ACCEPT, &d->flags)) { rfcomm_dlc_clear_timer(d); if (d->out) { @@ -2094,7 +2099,7 @@ static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt) if (test_and_clear_bit(RFCOMM_SEC_PENDING, &d->flags)) { rfcomm_dlc_clear_timer(d); if (status || encrypt == 0x00) { - __rfcomm_dlc_close(d, ECONNREFUSED); + set_bit(RFCOMM_ENC_DROP, &d->flags); continue; } } @@ -2105,7 +2110,7 @@ static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt) rfcomm_dlc_set_timer(d, RFCOMM_AUTH_TIMEOUT); continue; } else if (d->sec_level == BT_SECURITY_HIGH) { - __rfcomm_dlc_close(d, ECONNREFUSED); + set_bit(RFCOMM_ENC_DROP, &d->flags); continue; } } -- cgit v0.10.2 From 43611a7b16038753e0510dfb0c038c80a10c80c3 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 17 Oct 2011 23:05:49 +0200 Subject: Bluetooth: Increase HCI reset timeout in hci_dev_do_close I've noticed that my CSR usb dongle was not working if it was plugged in when PC was booting. It looks like I get two HCI reset command complete events (see hcidump logs below). The root cause is reset called from off_timer. Timeout for this reset to complete is set to 250ms and my bt dongle requires more time for replying with command complete event. After that, chip seems to reply with reset command complete event for next non-reset command. Attached patch increase mentioned timeout to HCI_INIT_TIMEOUT, this value is already used for timeouting hci_reset_req in hci_dev_reset(). This might also be related to BT not working after suspend that was reported here some time ago. Hcidump log: 2011-09-12 23:13:27.379465 < HCI Command: Reset (0x03|0x0003) plen 0 2011-09-12 23:13:27.380797 > HCI Event: Command Complete (0x0e) plen 4 Reset (0x03|0x0003) ncmd 1 status 0x00 2011-09-12 23:13:27.380859 < HCI Command: Read Local Supported Features (0x04|0x000 3) plen 0 2011-09-12 23:13:27.760789 > HCI Event: Command Complete (0x0e) plen 4 Reset (0x03|0x0003) ncmd 1 status 0x00 2011-09-12 23:13:27.760831 < HCI Command: Read Local Version Information (0x04|0x00 01) plen 0 2011-09-12 23:13:27.764780 > HCI Event: Command Complete (0x0e) plen 12 Read Local Version Information (0x04|0x0001) ncmd 1 status 0x00 HCI Version: 1.1 (0x1) HCI Revision: 0x36f LMP Version: 1.1 (0x1) LMP Subversion: 0x36f Manufacturer: Cambridge Silicon Radio (10) Signed-off-by: Szymon Janc Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f04f2eca2..f2ec434 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -611,7 +611,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) if (!test_bit(HCI_RAW, &hdev->flags)) { set_bit(HCI_INIT, &hdev->flags); __hci_request(hdev, hci_reset_req, 0, - msecs_to_jiffies(250)); + msecs_to_jiffies(HCI_INIT_TIMEOUT)); clear_bit(HCI_INIT, &hdev->flags); } -- cgit v0.10.2 From df164df9a77979d1774ede353988c1a62584594b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 24 Oct 2011 22:36:26 +0200 Subject: Bluetooth: Set HCI_MGMT flag only in read_controller_info The HCI_MGMT flag should only be set when user space requests the full controller information. This way we avoid potential issues with setting change events ariving before the actual read_controller_info command finishes. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 38220a2..cbc8a6d 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -150,8 +150,6 @@ static int read_index_list(struct sock *sk) list_for_each_entry(d, &hci_dev_list, list) { hci_del_off_timer(d); - set_bit(HCI_MGMT, &d->flags); - if (test_bit(HCI_SETUP, &d->flags)) continue; -- cgit v0.10.2 From 52a1020e80beece986002f673eca24dae6255b55 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 25 Oct 2011 12:09:52 +0200 Subject: Bluetooth: ath3k: Use GFP_KERNEL instead of GFP_ATOMIC We are allowed to sleep here so no need to use GFP_ATOMIC. The caller (ath3k_probe) calls request_firmware() which definitely sleeps. Hence, we should avoid using GFP_ATOMIC. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 39b25ac..1622772 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -106,7 +106,7 @@ static int ath3k_load_firmware(struct usb_device *udev, pipe = usb_sndctrlpipe(udev, 0); - send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC); + send_buf = kmalloc(BULK_SIZE, GFP_KERNEL); if (!send_buf) { BT_ERR("Can't allocate memory chunk for firmware"); return -ENOMEM; @@ -177,7 +177,7 @@ static int ath3k_load_fwfile(struct usb_device *udev, count = firmware->size; - send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC); + send_buf = kmalloc(BULK_SIZE, GFP_KERNEL); if (!send_buf) { BT_ERR("Can't allocate memory chunk for firmware"); return -ENOMEM; -- cgit v0.10.2 From 844e4b76cc4806827024cccf35a9beaf13d27f3d Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 26 Oct 2011 11:13:13 +0200 Subject: Bluetooth: bcm203x: Fix race condition on disconnect When disconnecting a bcm203x device we kill and destroy the usb-urb, however, there might still be a pending work-structure which resubmits the now invalid urb. To avoid this race condition, we simply set a shutdown-flag and synchronously kill the worker first. This also adds a comment to all schedule_work()s, as it is really not clear that they are used as replacement for short timers (which can be seen in the git history). Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 8b1b643..ec743c2 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -65,6 +66,7 @@ struct bcm203x_data { unsigned long state; struct work_struct work; + atomic_t shutdown; struct urb *urb; unsigned char *buffer; @@ -97,6 +99,7 @@ static void bcm203x_complete(struct urb *urb) data->state = BCM203X_SELECT_MEMORY; + /* use workqueue to have a small delay */ schedule_work(&data->work); break; @@ -155,6 +158,9 @@ static void bcm203x_work(struct work_struct *work) struct bcm203x_data *data = container_of(work, struct bcm203x_data, work); + if (atomic_read(&data->shutdown)) + return; + if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) BT_ERR("Can't submit URB"); } @@ -243,6 +249,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id usb_set_intfdata(intf, data); + /* use workqueue to have a small delay */ schedule_work(&data->work); return 0; @@ -254,6 +261,9 @@ static void bcm203x_disconnect(struct usb_interface *intf) BT_DBG("intf %p", intf); + atomic_inc(&data->shutdown); + cancel_work_sync(&data->work); + usb_kill_urb(data->urb); usb_set_intfdata(intf, NULL); -- cgit v0.10.2 From deceb024f1083d7eecaba7f2ee65d57f31f91bd5 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 25 Oct 2011 21:13:36 +0200 Subject: Bluetooth: bcm203x: Use GFP_KERNEL in workqueue A workqueue is allowed to sleep so we can safely use GFP_KERNEL instead of GFP_ATOMIC. This is still legacy code when the driver used timer BHs and not a worqueue. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index ec743c2..54952ab 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -161,7 +161,7 @@ static void bcm203x_work(struct work_struct *work) if (atomic_read(&data->shutdown)) return; - if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) + if (usb_submit_urb(data->urb, GFP_KERNEL) < 0) BT_ERR("Can't submit URB"); } -- cgit v0.10.2 From 7f103a0d23d2778b86cea407c1992522d41ead81 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 26 Oct 2011 11:22:46 +0200 Subject: Bluetooth: bfusb: Fix error path on firmware load When loading the usb-configuration we do not signal the end of configuration on memory allocation error. This patch moves the memory allocation to the top so every error path uses "goto error" now to correctly send the usb-ctrl message when detecting some error. This also replaces GFP_ATOMIC with GFP_KERNEL as we are allowed to sleep here. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 6580d50..a936763 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -568,22 +568,23 @@ static int bfusb_load_firmware(struct bfusb_data *data, BT_INFO("BlueFRITZ! USB loading firmware"); + buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_KERNEL); + if (!buf) { + BT_ERR("Can't allocate memory chunk for firmware"); + return -ENOMEM; + } + pipe = usb_sndctrlpipe(data->udev, 0); if (usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, 0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) { BT_ERR("Can't change to loading configuration"); + kfree(buf); return -EBUSY; } data->udev->toggle[0] = data->udev->toggle[1] = 0; - buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_ATOMIC); - if (!buf) { - BT_ERR("Can't allocate memory chunk for firmware"); - return -ENOMEM; - } - pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep); while (count) { -- cgit v0.10.2 From 25df0845e054f70a8735ee0184739472d8a573c9 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 1 Nov 2011 17:27:50 +0100 Subject: Bluetooth: hidp: Fix module reference cleanup Calling module_put(THIS_MODULE) is *never* safe when we cannot go sure that we own at least two references. This is because the call may unload our module before it returns and then the "return" will jump into invalid memory. Gladly, module.h provides a wrapper for kthread-users: module_put_and_exit(). This puts our module and then exits the kthread without returning to the module. This patch fixes the hidp kthread to use this wrapper instead of manually freeing its own reference. See nfsd or lockd for other kthreads using this. Calling __module_get() inside the kthread is safe as the hidp module will always wait until the kthread sets "waiting_for_startup" to 0. Signed-off-by: David Herrmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 2efd6cc..56dc660 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -94,7 +94,6 @@ static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr) static void __hidp_link_session(struct hidp_session *session) { - __module_get(THIS_MODULE); list_add(&session->list, &hidp_session_list); } @@ -103,7 +102,6 @@ static void __hidp_unlink_session(struct hidp_session *session) hci_conn_put_device(session->conn); list_del(&session->list); - module_put(THIS_MODULE); } static void __hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci) @@ -703,6 +701,7 @@ static int hidp_session(void *arg) BT_DBG("session %p", session); + __module_get(THIS_MODULE); set_user_nice(current, -15); init_waitqueue_entry(&ctrl_wait, current); @@ -781,6 +780,7 @@ static int hidp_session(void *arg) kfree(session->rd_data); kfree(session); + module_put_and_exit(0); return 0; } -- cgit v0.10.2 From 3c32fa93e5a54cd54e52541892857b0c7164a61e Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 20 Oct 2011 17:21:34 -0200 Subject: Bluetooth: Fix hidp_get_connection() This functions needs crtl_sock and intr_sock to be set first. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 56dc660..3c2d888 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -996,12 +996,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, return -ENOMEM; } - session->conn = hidp_get_connection(session); - if (!session->conn) { - err = -ENOTCONN; - goto failed; - } - bacpy(&session->bdaddr, &bt_sk(ctrl_sock->sk)->dst); session->ctrl_mtu = min_t(uint, l2cap_pi(ctrl_sock->sk)->chan->omtu, @@ -1015,6 +1009,12 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, session->intr_sock = intr_sock; session->state = BT_CONNECTED; + session->conn = hidp_get_connection(session); + if (!session->conn) { + err = -ENOTCONN; + goto failed; + } + setup_timer(&session->timer, hidp_idle_timeout, (unsigned long)session); skb_queue_head_init(&session->ctrl_transmit); -- cgit v0.10.2 From 73d80deb7bdf0171f22e76dc2429c1f99eff90e2 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 2 Nov 2011 15:52:01 +0200 Subject: Bluetooth: prioritizing data over HCI This implement priority based scheduler using skbuffer priority set via SO_PRIORITY socket option. It introduces hci_chan_hash (list of HCI Channel/hci_chan) per connection, each item in this list refer to a L2CAP connection and it is used to queue the data for transmission. Signed-off-by: Luiz Augusto von Dentz Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5a9db9a..f97792c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -67,6 +67,12 @@ struct hci_conn_hash { unsigned int le_num; }; +struct hci_chan_hash { + struct list_head list; + spinlock_t lock; + unsigned int num; +}; + struct bdaddr_list { struct list_head list; bdaddr_t bdaddr; @@ -287,6 +293,7 @@ struct hci_conn { unsigned int sent; struct sk_buff_head data_q; + struct hci_chan_hash chan_hash; struct timer_list disc_timer; struct timer_list idle_timer; @@ -309,6 +316,14 @@ struct hci_conn { void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); }; +struct hci_chan { + struct list_head list; + + struct hci_conn *conn; + struct sk_buff_head data_q; + unsigned int sent; +}; + extern struct hci_proto *hci_proto[]; extern struct list_head hci_dev_list; extern struct list_head hci_cb_list; @@ -469,6 +484,28 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, return NULL; } +static inline void hci_chan_hash_init(struct hci_conn *c) +{ + struct hci_chan_hash *h = &c->chan_hash; + INIT_LIST_HEAD(&h->list); + spin_lock_init(&h->lock); + h->num = 0; +} + +static inline void hci_chan_hash_add(struct hci_conn *c, struct hci_chan *chan) +{ + struct hci_chan_hash *h = &c->chan_hash; + list_add(&chan->list, &h->list); + h->num++; +} + +static inline void hci_chan_hash_del(struct hci_conn *c, struct hci_chan *chan) +{ + struct hci_chan_hash *h = &c->chan_hash; + list_del(&chan->list); + h->num--; +} + void hci_acl_connect(struct hci_conn *conn); void hci_acl_disconn(struct hci_conn *conn, __u8 reason); void hci_add_sco(struct hci_conn *conn, __u16 handle); @@ -480,6 +517,10 @@ int hci_conn_del(struct hci_conn *conn); void hci_conn_hash_flush(struct hci_dev *hdev); void hci_conn_check_pending(struct hci_dev *hdev); +struct hci_chan *hci_chan_create(struct hci_conn *conn); +int hci_chan_del(struct hci_chan *chan); +void hci_chan_hash_flush(struct hci_conn *conn); + struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); int hci_conn_check_link_mode(struct hci_conn *conn); @@ -849,7 +890,7 @@ int hci_register_notifier(struct notifier_block *nb); int hci_unregister_notifier(struct notifier_block *nb); int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); -void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags); +void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index c10bf1d..6ae9492 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -451,6 +451,7 @@ struct l2cap_ops { struct l2cap_conn { struct hci_conn *hcon; + struct hci_chan *hchan; bdaddr_t *dst; bdaddr_t *src; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 6e98ff3..e545376 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -374,6 +374,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) skb_queue_head_init(&conn->data_q); + hci_chan_hash_init(conn); + setup_timer(&conn->disc_timer, hci_conn_timeout, (unsigned long)conn); setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn); setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept, @@ -432,6 +434,8 @@ int hci_conn_del(struct hci_conn *conn) tasklet_disable(&hdev->tx_task); + hci_chan_hash_flush(conn); + hci_conn_hash_del(hdev, conn); if (hdev->notify) hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); @@ -950,3 +954,52 @@ int hci_get_auth_info(struct hci_dev *hdev, void __user *arg) return copy_to_user(arg, &req, sizeof(req)) ? -EFAULT : 0; } + +struct hci_chan *hci_chan_create(struct hci_conn *conn) +{ + struct hci_dev *hdev = conn->hdev; + struct hci_chan *chan; + + BT_DBG("%s conn %p", hdev->name, conn); + + chan = kzalloc(sizeof(struct hci_chan), GFP_ATOMIC); + if (!chan) + return NULL; + + chan->conn = conn; + skb_queue_head_init(&chan->data_q); + + tasklet_disable(&hdev->tx_task); + hci_chan_hash_add(conn, chan); + tasklet_enable(&hdev->tx_task); + + return chan; +} + +int hci_chan_del(struct hci_chan *chan) +{ + struct hci_conn *conn = chan->conn; + struct hci_dev *hdev = conn->hdev; + + BT_DBG("%s conn %p chan %p", hdev->name, conn, chan); + + tasklet_disable(&hdev->tx_task); + hci_chan_hash_del(conn, chan); + tasklet_enable(&hdev->tx_task); + + skb_queue_purge(&chan->data_q); + kfree(chan); + + return 0; +} + +void hci_chan_hash_flush(struct hci_conn *conn) +{ + struct hci_chan_hash *h = &conn->chan_hash; + struct hci_chan *chan, *tmp; + + BT_DBG("conn %p", conn); + + list_for_each_entry_safe(chan, tmp, &h->list, list) + hci_chan_del(chan); +} diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f2ec434..631327d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1937,23 +1937,18 @@ static void hci_add_acl_hdr(struct sk_buff *skb, __u16 handle, __u16 flags) hdr->dlen = cpu_to_le16(len); } -void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) +static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue, + struct sk_buff *skb, __u16 flags) { struct hci_dev *hdev = conn->hdev; struct sk_buff *list; - BT_DBG("%s conn %p flags 0x%x", hdev->name, conn, flags); - - skb->dev = (void *) hdev; - bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; - hci_add_acl_hdr(skb, conn->handle, flags); - list = skb_shinfo(skb)->frag_list; if (!list) { /* Non fragmented */ BT_DBG("%s nonfrag skb %p len %d", hdev->name, skb, skb->len); - skb_queue_tail(&conn->data_q, skb); + skb_queue_tail(queue, skb); } else { /* Fragmented */ BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len); @@ -1961,9 +1956,9 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) skb_shinfo(skb)->frag_list = NULL; /* Queue all fragments atomically */ - spin_lock_bh(&conn->data_q.lock); + spin_lock_bh(&queue->lock); - __skb_queue_tail(&conn->data_q, skb); + __skb_queue_tail(queue, skb); flags &= ~ACL_START; flags |= ACL_CONT; @@ -1976,11 +1971,25 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len); - __skb_queue_tail(&conn->data_q, skb); + __skb_queue_tail(queue, skb); } while (list); - spin_unlock_bh(&conn->data_q.lock); + spin_unlock_bh(&queue->lock); } +} + +void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags) +{ + struct hci_conn *conn = chan->conn; + struct hci_dev *hdev = conn->hdev; + + BT_DBG("%s chan %p flags 0x%x", hdev->name, chan, flags); + + skb->dev = (void *) hdev; + bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; + hci_add_acl_hdr(skb, conn->handle, flags); + + hci_queue_acl(conn, &chan->data_q, skb, flags); tasklet_schedule(&hdev->tx_task); } @@ -2083,11 +2092,90 @@ static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type) } } -static inline void hci_sched_acl(struct hci_dev *hdev) +static inline struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type, + int *quote) { + struct hci_conn_hash *h = &hdev->conn_hash; + struct hci_chan *chan = NULL; + int num = 0, min = ~0, cur_prio = 0; struct hci_conn *conn; + int cnt, q, conn_num = 0; + + BT_DBG("%s", hdev->name); + + list_for_each_entry(conn, &h->list, list) { + struct hci_chan_hash *ch; + struct hci_chan *tmp; + + if (conn->type != type) + continue; + + if (conn->state != BT_CONNECTED && conn->state != BT_CONFIG) + continue; + + conn_num++; + + ch = &conn->chan_hash; + + list_for_each_entry(tmp, &ch->list, list) { + struct sk_buff *skb; + + if (skb_queue_empty(&tmp->data_q)) + continue; + + skb = skb_peek(&tmp->data_q); + if (skb->priority < cur_prio) + continue; + + if (skb->priority > cur_prio) { + num = 0; + min = ~0; + cur_prio = skb->priority; + } + + num++; + + if (conn->sent < min) { + min = conn->sent; + chan = tmp; + } + } + + if (hci_conn_num(hdev, type) == conn_num) + break; + } + + if (!chan) + return NULL; + + switch (chan->conn->type) { + case ACL_LINK: + cnt = hdev->acl_cnt; + break; + case SCO_LINK: + case ESCO_LINK: + cnt = hdev->sco_cnt; + break; + case LE_LINK: + cnt = hdev->le_mtu ? hdev->le_cnt : hdev->acl_cnt; + break; + default: + cnt = 0; + BT_ERR("Unknown link type"); + } + + q = cnt / num; + *quote = q ? q : 1; + BT_DBG("chan %p quote %d", chan, *quote); + return chan; +} + +static inline void hci_sched_acl(struct hci_dev *hdev) +{ + struct hci_chan *chan; struct sk_buff *skb; int quote; + unsigned int cnt; BT_DBG("%s", hdev->name); @@ -2101,17 +2189,23 @@ static inline void hci_sched_acl(struct hci_dev *hdev) hci_link_tx_to(hdev, ACL_LINK); } - while (hdev->acl_cnt && (conn = hci_low_sent(hdev, ACL_LINK, "e))) { - while (quote-- && (skb = skb_dequeue(&conn->data_q))) { - BT_DBG("skb %p len %d", skb, skb->len); + cnt = hdev->acl_cnt; - hci_conn_enter_active_mode(conn, bt_cb(skb)->force_active); + while (hdev->acl_cnt && + (chan = hci_chan_sent(hdev, ACL_LINK, "e))) { + while (quote-- && (skb = skb_dequeue(&chan->data_q))) { + BT_DBG("chan %p skb %p len %d priority %u", chan, skb, + skb->len, skb->priority); + + hci_conn_enter_active_mode(chan->conn, + bt_cb(skb)->force_active); hci_send_frame(skb); hdev->acl_last_tx = jiffies; hdev->acl_cnt--; - conn->sent++; + chan->sent++; + chan->conn->sent++; } } } @@ -2165,7 +2259,7 @@ static inline void hci_sched_esco(struct hci_dev *hdev) static inline void hci_sched_le(struct hci_dev *hdev) { - struct hci_conn *conn; + struct hci_chan *chan; struct sk_buff *skb; int quote, cnt; @@ -2183,17 +2277,20 @@ static inline void hci_sched_le(struct hci_dev *hdev) } cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt; - while (cnt && (conn = hci_low_sent(hdev, LE_LINK, "e))) { - while (quote-- && (skb = skb_dequeue(&conn->data_q))) { - BT_DBG("skb %p len %d", skb, skb->len); + while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, "e))) { + while (quote-- && (skb = skb_dequeue(&chan->data_q))) { + BT_DBG("chan %p skb %p len %d priority %u", chan, skb, + skb->len, skb->priority); hci_send_frame(skb); hdev->le_last_tx = jiffies; cnt--; - conn->sent++; + chan->sent++; + chan->conn->sent++; } } + if (hdev->le_pkts) hdev->le_cnt = cnt; else diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ac2c41a..15751fa 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -566,7 +566,25 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, bt_cb(skb)->force_active = BT_POWER_FORCE_ACTIVE_ON; skb->priority = HCI_PRIO_MAX; - hci_send_acl(conn->hcon, skb, flags); + hci_send_acl(conn->hchan, skb, flags); +} + +static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) +{ + struct hci_conn *hcon = chan->conn->hcon; + u16 flags; + + BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, + skb->priority); + + if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && + lmp_no_flush_capable(hcon->hdev)) + flags = ACL_START_NO_FLUSH; + else + flags = ACL_START; + + bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); + hci_send_acl(chan->conn->hchan, skb, flags); } static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control) @@ -575,7 +593,6 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control) struct l2cap_hdr *lh; struct l2cap_conn *conn = chan->conn; int count, hlen; - u8 flags; if (chan->state != BT_CONNECTED) return; @@ -615,14 +632,8 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control) put_unaligned_le16(fcs, skb_put(skb, L2CAP_FCS_SIZE)); } - if (lmp_no_flush_capable(conn->hcon->hdev)) - flags = ACL_START_NO_FLUSH; - else - flags = ACL_START; - - bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); - - hci_send_acl(chan->conn->hcon, skb, flags); + skb->priority = HCI_PRIO_MAX; + l2cap_do_send(chan, skb); } static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u32 control) @@ -1002,6 +1013,8 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) chan->ops->close(chan->data); } + hci_chan_del(conn->hchan); + if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) del_timer_sync(&conn->info_timer); @@ -1024,18 +1037,26 @@ static void security_timeout(unsigned long arg) static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) { struct l2cap_conn *conn = hcon->l2cap_data; + struct hci_chan *hchan; if (conn || status) return conn; + hchan = hci_chan_create(hcon); + if (!hchan) + return NULL; + conn = kzalloc(sizeof(struct l2cap_conn), GFP_ATOMIC); - if (!conn) + if (!conn) { + hci_chan_del(hchan); return NULL; + } hcon->l2cap_data = conn; conn->hcon = hcon; + conn->hchan = hchan; - BT_DBG("hcon %p conn %p", hcon, conn); + BT_DBG("hcon %p conn %p hchan %p", hcon, conn, hchan); if (hcon->hdev->le_mtu && hcon->type == LE_LINK) conn->mtu = hcon->hdev->le_mtu; @@ -1261,24 +1282,6 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan) __clear_retrans_timer(chan); } -static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) -{ - struct hci_conn *hcon = chan->conn->hcon; - u16 flags; - - BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, - skb->priority); - - if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && - lmp_no_flush_capable(hcon->hdev)) - flags = ACL_START_NO_FLUSH; - else - flags = ACL_START; - - bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); - hci_send_acl(hcon, skb, flags); -} - static void l2cap_streaming_send(struct l2cap_chan *chan) { struct sk_buff *skb; diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 759b635..94e94ca 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -181,7 +181,8 @@ static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) if (!skb) return; - hci_send_acl(conn->hcon, skb, 0); + skb->priority = HCI_PRIO_MAX; + hci_send_acl(conn->hchan, skb, 0); mod_timer(&conn->security_timer, jiffies + msecs_to_jiffies(SMP_TIMEOUT)); -- cgit v0.10.2 From ec1cce24d5950e797f10650abf7890ead67c6e64 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 2 Nov 2011 15:52:02 +0200 Subject: Bluetooth: handle priority change within quote The quote is calculated based on the first buffer in the queue so if the priority changes to something lower than the priority of the first skb the quote needs to be recalculated. Signed-off-by: Luiz Augusto von Dentz Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 631327d..19e4453 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2193,10 +2193,17 @@ static inline void hci_sched_acl(struct hci_dev *hdev) while (hdev->acl_cnt && (chan = hci_chan_sent(hdev, ACL_LINK, "e))) { - while (quote-- && (skb = skb_dequeue(&chan->data_q))) { + u32 priority = (skb_peek(&chan->data_q))->priority; + while (quote-- && (skb = skb_peek(&chan->data_q))) { BT_DBG("chan %p skb %p len %d priority %u", chan, skb, skb->len, skb->priority); + /* Stop if priority has changed */ + if (skb->priority < priority) + break; + + skb = skb_dequeue(&chan->data_q); + hci_conn_enter_active_mode(chan->conn, bt_cb(skb)->force_active); @@ -2278,10 +2285,17 @@ static inline void hci_sched_le(struct hci_dev *hdev) cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt; while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, "e))) { - while (quote-- && (skb = skb_dequeue(&chan->data_q))) { + u32 priority = (skb_peek(&chan->data_q))->priority; + while (quote-- && (skb = skb_peek(&chan->data_q))) { BT_DBG("chan %p skb %p len %d priority %u", chan, skb, skb->len, skb->priority); + /* Stop if priority has changed */ + if (skb->priority < priority) + break; + + skb = skb_dequeue(&chan->data_q); + hci_send_frame(skb); hdev->le_last_tx = jiffies; -- cgit v0.10.2 From 02b20f0bb661829cbd431e5deb2474e909e65cec Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 2 Nov 2011 15:52:03 +0200 Subject: Bluetooth: recalculate priorities when channels are starving To avoid starvation the priority is recalculated so that the starving channels are promoted to HCI_PRIO_MAX - 1 (6). HCI_PRIO_MAX (7) is considered special, because it requires CAP_NET_ADMIN capability which can be used to provide more guaranties, so it is not used when promoting. Signed-off-by: Luiz Augusto von Dentz Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 19e4453..4221fd5 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2170,6 +2170,53 @@ static inline struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type, return chan; } +static void hci_prio_recalculate(struct hci_dev *hdev, __u8 type) +{ + struct hci_conn_hash *h = &hdev->conn_hash; + struct hci_conn *conn; + int num = 0; + + BT_DBG("%s", hdev->name); + + list_for_each_entry(conn, &h->list, list) { + struct hci_chan_hash *ch; + struct hci_chan *chan; + + if (conn->type != type) + continue; + + if (conn->state != BT_CONNECTED && conn->state != BT_CONFIG) + continue; + + num++; + + ch = &conn->chan_hash; + list_for_each_entry(chan, &ch->list, list) { + struct sk_buff *skb; + + if (chan->sent) { + chan->sent = 0; + continue; + } + + if (skb_queue_empty(&chan->data_q)) + continue; + + skb = skb_peek(&chan->data_q); + if (skb->priority >= HCI_PRIO_MAX - 1) + continue; + + skb->priority = HCI_PRIO_MAX - 1; + + BT_DBG("chan %p skb %p promoted to %d", chan, skb, + skb->priority); + } + + if (hci_conn_num(hdev, type) == num) + break; + } +} + static inline void hci_sched_acl(struct hci_dev *hdev) { struct hci_chan *chan; @@ -2215,6 +2262,9 @@ static inline void hci_sched_acl(struct hci_dev *hdev) chan->conn->sent++; } } + + if (cnt != hdev->acl_cnt) + hci_prio_recalculate(hdev, ACL_LINK); } /* Schedule SCO */ @@ -2268,7 +2318,7 @@ static inline void hci_sched_le(struct hci_dev *hdev) { struct hci_chan *chan; struct sk_buff *skb; - int quote, cnt; + int quote, cnt, tmp; BT_DBG("%s", hdev->name); @@ -2284,6 +2334,7 @@ static inline void hci_sched_le(struct hci_dev *hdev) } cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt; + tmp = cnt; while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, "e))) { u32 priority = (skb_peek(&chan->data_q))->priority; while (quote-- && (skb = skb_peek(&chan->data_q))) { @@ -2309,6 +2360,9 @@ static inline void hci_sched_le(struct hci_dev *hdev) hdev->le_cnt = cnt; else hdev->acl_cnt = cnt; + + if (cnt != tmp) + hci_prio_recalculate(hdev, LE_LINK); } static void hci_tx_task(unsigned long arg) -- cgit v0.10.2 From b8aabfc92249b239c425da7e4ca85b7e4855e984 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 2 Nov 2011 15:52:04 +0200 Subject: Bluetooth: use buffer priority to mark URB_ISO_ASAP flag Signed-off-by: Luiz Augusto von Dentz Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index abfc4ee..9db2476 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -727,6 +727,9 @@ static int btusb_send_frame(struct sk_buff *skb) usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, skb->len, btusb_tx_complete, skb); + if (skb->priority >= HCI_PRIO_MAX - 1) + urb->transfer_flags = URB_ISO_ASAP; + hdev->stat.acl_tx++; break; -- cgit v0.10.2 From 6b3c7104677a731cf6d3638e09d9d6c530b9bc25 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 2 Nov 2011 09:57:10 +0200 Subject: Bluetooth: Initialize tx_win_max for fixed channel tx_win_max is initialized during L2CAP configuration phase. For fixed channels (e.g. A2MP) we want to have it initialized when channel is created. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 646aefc..9ed6501 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -943,6 +943,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->fcs = pchan->fcs; chan->max_tx = pchan->max_tx; chan->tx_win = pchan->tx_win; + chan->tx_win_max = pchan->tx_win_max; chan->sec_level = pchan->sec_level; chan->flags = pchan->flags; } else { @@ -971,6 +972,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->max_tx = L2CAP_DEFAULT_MAX_TX; chan->fcs = L2CAP_FCS_CRC16; chan->tx_win = L2CAP_DEFAULT_TX_WINDOW; + chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; chan->sec_level = BT_SECURITY_LOW; chan->flags = 0; set_bit(FLAG_FORCE_ACTIVE, &chan->flags); -- cgit v0.10.2 From c14968b0c1792901ac1cbbbf18f42e37b5a6f4df Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:28 -0700 Subject: Bluetooth: Add BT_CHANNEL_POLICY socket option Allow control of AMP functionality on L2CAP sockets. By default, connections will be restricted to BR/EDR. Manipulating the BT_CHANNEL_POLICY option allows for channels to be moved to or created on AMP controllers. Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index fb1acb3..38cd3da 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -77,6 +77,33 @@ struct bt_power { #define BT_POWER_FORCE_ACTIVE_OFF 0 #define BT_POWER_FORCE_ACTIVE_ON 1 +#define BT_CHANNEL_POLICY 10 + +/* BR/EDR only (default policy) + * AMP controllers cannot be used. + * Channel move requests from the remote device are denied. + * If the L2CAP channel is currently using AMP, move the channel to BR/EDR. + */ +#define BT_CHANNEL_POLICY_BREDR_ONLY 0 + +/* BR/EDR Preferred + * Allow use of AMP controllers. + * If the L2CAP channel is currently on AMP, move it to BR/EDR. + * Channel move requests from the remote device are allowed. + */ +#define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 + +/* AMP Preferred + * Allow use of AMP controllers + * If the L2CAP channel is currently on BR/EDR and AMP controller + * resources are available, initiate a channel move to AMP. + * Channel move requests from the remote device are allowed. + * If the L2CAP socket has not been connected yet, try to create + * and configure the channel directly on an AMP controller rather + * than BR/EDR. + */ +#define BT_CHANNEL_POLICY_AMP_PREFERRED 2 + __attribute__((format (printf, 2, 3))) int bt_printk(const char *level, const char *fmt, ...); -- cgit v0.10.2 From d7c4d11c649ae694b78f145120ed693a004fe496 Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:29 -0700 Subject: Bluetooth: Change scope of the enable_hs module parameter This variable is currently only accessible within l2cap_core.c, but it is also needed in l2cap_sock.c Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 6ae9492..1a62573 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -734,6 +734,7 @@ static inline __u8 __ctrl_size(struct l2cap_chan *chan) } extern int disable_ertm; +extern int enable_hs; int l2cap_init_sockets(void); void l2cap_cleanup_sockets(void); -- cgit v0.10.2 From 2ea664822af6705574dfbbf8c77fc7d75a94e9b3 Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:30 -0700 Subject: Bluetooth: Add channel policy to getsockopt/setsockopt Each channel has a policy to require BR/EDR (the default), prefer BR/EDR, or prefer AMP. Check for valid policy value and L2CAP mode. Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 1a62573..9c7d06e 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -367,6 +367,7 @@ struct l2cap_chan { __u16 flush_to; __u8 mode; __u8 chan_type; + __u8 chan_policy; __le16 sport; diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 9ed6501..664762e 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -467,6 +467,16 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch break; + case BT_CHANNEL_POLICY: + if (!enable_hs) { + err = -ENOPROTOOPT; + break; + } + + if (put_user(chan->chan_policy, (u32 __user *) optval)) + err = -EFAULT; + break; + default: err = -ENOPROTOOPT; break; @@ -690,6 +700,31 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch clear_bit(FLAG_FORCE_ACTIVE, &chan->flags); break; + case BT_CHANNEL_POLICY: + if (!enable_hs) { + err = -ENOPROTOOPT; + break; + } + + if (get_user(opt, (u32 __user *) optval)) { + err = -EFAULT; + break; + } + + if (opt > BT_CHANNEL_POLICY_AMP_PREFERRED) { + err = -EINVAL; + break; + } + + if (chan->mode != L2CAP_MODE_ERTM && + chan->mode != L2CAP_MODE_STREAMING) { + err = -EOPNOTSUPP; + break; + } + + chan->chan_policy = (u8) opt; + break; + default: err = -ENOPROTOOPT; break; -- cgit v0.10.2 From 38094c75b54c52b45f48b80fd2f6d1138a1b9b2b Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:31 -0700 Subject: Bluetooth: Add AMP-related data and structures for channel signals AMP channel creation and channel moves are coordinated using the L2CAP signaling channel. These definitions cover the "create channel", "move channel", and "move channel confirm" signals. Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 9c7d06e..88d462a 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -94,6 +94,12 @@ struct l2cap_conninfo { #define L2CAP_ECHO_RSP 0x09 #define L2CAP_INFO_REQ 0x0a #define L2CAP_INFO_RSP 0x0b +#define L2CAP_CREATE_CHAN_REQ 0x0c +#define L2CAP_CREATE_CHAN_RSP 0x0d +#define L2CAP_MOVE_CHAN_REQ 0x0e +#define L2CAP_MOVE_CHAN_RSP 0x0f +#define L2CAP_MOVE_CHAN_CFM 0x10 +#define L2CAP_MOVE_CHAN_CFM_RSP 0x11 #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 @@ -217,14 +223,15 @@ struct l2cap_conn_rsp { #define L2CAP_CID_DYN_START 0x0040 #define L2CAP_CID_DYN_END 0xffff -/* connect result */ +/* connect/create channel results */ #define L2CAP_CR_SUCCESS 0x0000 #define L2CAP_CR_PEND 0x0001 #define L2CAP_CR_BAD_PSM 0x0002 #define L2CAP_CR_SEC_BLOCK 0x0003 #define L2CAP_CR_NO_MEM 0x0004 +#define L2CAP_CR_BAD_AMP 0x0005 -/* connect status */ +/* connect/create channel status */ #define L2CAP_CS_NO_INFO 0x0000 #define L2CAP_CS_AUTHEN_PEND 0x0001 #define L2CAP_CS_AUTHOR_PEND 0x0002 @@ -319,6 +326,49 @@ struct l2cap_info_rsp { __u8 data[0]; } __packed; +struct l2cap_create_chan_req { + __le16 psm; + __le16 scid; + __u8 amp_id; +} __packed; + +struct l2cap_create_chan_rsp { + __le16 dcid; + __le16 scid; + __le16 result; + __le16 status; +} __packed; + +struct l2cap_move_chan_req { + __le16 icid; + __u8 dest_amp_id; +} __packed; + +struct l2cap_move_chan_rsp { + __le16 icid; + __le16 result; +} __packed; + +#define L2CAP_MR_SUCCESS 0x0000 +#define L2CAP_MR_PEND 0x0001 +#define L2CAP_MR_BAD_ID 0x0002 +#define L2CAP_MR_SAME_ID 0x0003 +#define L2CAP_MR_NOT_SUPP 0x0004 +#define L2CAP_MR_COLLISION 0x0005 +#define L2CAP_MR_NOT_ALLOWED 0x0006 + +struct l2cap_move_chan_cfm { + __le16 icid; + __le16 result; +} __packed; + +#define L2CAP_MC_CONFIRMED 0x0000 +#define L2CAP_MC_UNCONFIRMED 0x0001 + +struct l2cap_move_chan_cfm_rsp { + __le16 icid; +} __packed; + /* info type */ #define L2CAP_IT_CL_MTU 0x0001 #define L2CAP_IT_FEAT_MASK 0x0002 -- cgit v0.10.2 From f94ff6fff7b8b5896a173d165e9ec579c83067f2 Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:32 -0700 Subject: Bluetooth: Add signal handlers for channel creation Handle both "create channel request" and "create channel response". Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 15751fa..cf48330 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3104,6 +3104,45 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm return 0; } +static inline int l2cap_create_channel_req(struct l2cap_conn *conn, + struct l2cap_cmd_hdr *cmd, u16 cmd_len, + void *data) +{ + struct l2cap_create_chan_req *req = data; + struct l2cap_create_chan_rsp rsp; + u16 psm, scid; + + if (cmd_len != sizeof(*req)) + return -EPROTO; + + if (!enable_hs) + return -EINVAL; + + psm = le16_to_cpu(req->psm); + scid = le16_to_cpu(req->scid); + + BT_DBG("psm %d, scid %d, amp_id %d", psm, scid, req->amp_id); + + /* Placeholder: Always reject */ + rsp.dcid = 0; + rsp.scid = cpu_to_le16(scid); + rsp.result = L2CAP_CR_NO_MEM; + rsp.status = L2CAP_CS_NO_INFO; + + l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP, + sizeof(rsp), &rsp); + + return 0; +} + +static inline int l2cap_create_channel_rsp(struct l2cap_conn *conn, + struct l2cap_cmd_hdr *cmd, void *data) +{ + BT_DBG("conn %p", conn); + + return l2cap_connect_rsp(conn, cmd, data); +} + static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, u16 to_multiplier) { @@ -3216,6 +3255,14 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, err = l2cap_information_rsp(conn, cmd, data); break; + case L2CAP_CREATE_CHAN_REQ: + err = l2cap_create_channel_req(conn, cmd, cmd_len, data); + break; + + case L2CAP_CREATE_CHAN_RSP: + err = l2cap_create_channel_rsp(conn, cmd, data); + break; + default: BT_ERR("Unknown BR/EDR signaling command 0x%2.2x", cmd->code); err = -EINVAL; -- cgit v0.10.2 From d835ac0fc73276893af63a478317027787a3ac1f Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:33 -0700 Subject: Bluetooth: Add definitions for L2CAP fixed channels Symbolic fixed channel IDs will be used instead of magic numbers. Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 88d462a..9280bff 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -119,6 +119,10 @@ struct l2cap_conninfo { #define L2CAP_FCS_NONE 0x00 #define L2CAP_FCS_CRC16 0x01 +/* L2CAP fixed channels */ +#define L2CAP_FC_L2CAP 0x02 +#define L2CAP_FC_A2MP 0x08 + /* L2CAP Control Field bit masks */ #define L2CAP_CTRL_SAR 0xC000 #define L2CAP_CTRL_REQSEQ 0x3F00 -- cgit v0.10.2 From 50a147cd9c7523d1b11d0284a0be7891631517dd Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:34 -0700 Subject: Bluetooth: Use symbolic values for the fixed channel map The A2MP fixed channel bit is only set when high-speed mode is enabled. Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index cf48330..0272cd1 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -60,7 +60,7 @@ int disable_ertm; int enable_hs; static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN; -static u8 l2cap_fixed_chan[8] = { 0x02, }; +static u8 l2cap_fixed_chan[8] = { L2CAP_FC_L2CAP, }; static LIST_HEAD(chan_list); static DEFINE_RWLOCK(chan_list_lock); @@ -3035,6 +3035,12 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm } else if (type == L2CAP_IT_FIXED_CHAN) { u8 buf[12]; struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; + + if (enable_hs) + l2cap_fixed_chan[0] |= L2CAP_FC_A2MP; + else + l2cap_fixed_chan[0] &= ~L2CAP_FC_A2MP; + rsp->type = cpu_to_le16(L2CAP_IT_FIXED_CHAN); rsp->result = cpu_to_le16(L2CAP_IR_SUCCESS); memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); -- cgit v0.10.2 From 8d5a04a130e3493c17eae7a881102ab1a4283736 Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:35 -0700 Subject: Bluetooth: Add signal handlers for channel moves AMP channels can be moved between BR/EDR and AMP controllers using a sequence of signals. Every attempted channel move involves a series of four signals: Move Initiator Move Responder | | | Move Channel Request | | ----------------------------> | | | | Move Channel Response | | <---------------------------- | | | | Move Channel Confirm | | ----------------------------> | | | | Move Channel Confirm Response | | <---------------------------- | All four signals are sent even if the move fails. Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0272cd1..335dc6f 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3149,6 +3149,126 @@ static inline int l2cap_create_channel_rsp(struct l2cap_conn *conn, return l2cap_connect_rsp(conn, cmd, data); } +static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident, + u16 icid, u16 result) +{ + struct l2cap_move_chan_rsp rsp; + + BT_DBG("icid %d, result %d", icid, result); + + rsp.icid = cpu_to_le16(icid); + rsp.result = cpu_to_le16(result); + + l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_RSP, sizeof(rsp), &rsp); +} + +static void l2cap_send_move_chan_cfm(struct l2cap_conn *conn, + struct l2cap_chan *chan, u16 icid, u16 result) +{ + struct l2cap_move_chan_cfm cfm; + u8 ident; + + BT_DBG("icid %d, result %d", icid, result); + + ident = l2cap_get_ident(conn); + if (chan) + chan->ident = ident; + + cfm.icid = cpu_to_le16(icid); + cfm.result = cpu_to_le16(result); + + l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM, sizeof(cfm), &cfm); +} + +static void l2cap_send_move_chan_cfm_rsp(struct l2cap_conn *conn, u8 ident, + u16 icid) +{ + struct l2cap_move_chan_cfm_rsp rsp; + + BT_DBG("icid %d", icid); + + rsp.icid = cpu_to_le16(icid); + l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM_RSP, sizeof(rsp), &rsp); +} + +static inline int l2cap_move_channel_req(struct l2cap_conn *conn, + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) +{ + struct l2cap_move_chan_req *req = data; + u16 icid = 0; + u16 result = L2CAP_MR_NOT_ALLOWED; + + if (cmd_len != sizeof(*req)) + return -EPROTO; + + icid = le16_to_cpu(req->icid); + + BT_DBG("icid %d, dest_amp_id %d", icid, req->dest_amp_id); + + if (!enable_hs) + return -EINVAL; + + /* Placeholder: Always refuse */ + l2cap_send_move_chan_rsp(conn, cmd->ident, icid, result); + + return 0; +} + +static inline int l2cap_move_channel_rsp(struct l2cap_conn *conn, + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) +{ + struct l2cap_move_chan_rsp *rsp = data; + u16 icid, result; + + if (cmd_len != sizeof(*rsp)) + return -EPROTO; + + icid = le16_to_cpu(rsp->icid); + result = le16_to_cpu(rsp->result); + + BT_DBG("icid %d, result %d", icid, result); + + /* Placeholder: Always unconfirmed */ + l2cap_send_move_chan_cfm(conn, NULL, icid, L2CAP_MC_UNCONFIRMED); + + return 0; +} + +static inline int l2cap_move_channel_confirm(struct l2cap_conn *conn, + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) +{ + struct l2cap_move_chan_cfm *cfm = data; + u16 icid, result; + + if (cmd_len != sizeof(*cfm)) + return -EPROTO; + + icid = le16_to_cpu(cfm->icid); + result = le16_to_cpu(cfm->result); + + BT_DBG("icid %d, result %d", icid, result); + + l2cap_send_move_chan_cfm_rsp(conn, cmd->ident, icid); + + return 0; +} + +static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) +{ + struct l2cap_move_chan_cfm_rsp *rsp = data; + u16 icid; + + if (cmd_len != sizeof(*rsp)) + return -EPROTO; + + icid = le16_to_cpu(rsp->icid); + + BT_DBG("icid %d", icid); + + return 0; +} + static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, u16 to_multiplier) { @@ -3269,6 +3389,22 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, err = l2cap_create_channel_rsp(conn, cmd, data); break; + case L2CAP_MOVE_CHAN_REQ: + err = l2cap_move_channel_req(conn, cmd, cmd_len, data); + break; + + case L2CAP_MOVE_CHAN_RSP: + err = l2cap_move_channel_rsp(conn, cmd, cmd_len, data); + break; + + case L2CAP_MOVE_CHAN_CFM: + err = l2cap_move_channel_confirm(conn, cmd, cmd_len, data); + break; + + case L2CAP_MOVE_CHAN_CFM_RSP: + err = l2cap_move_channel_confirm_rsp(conn, cmd, cmd_len, data); + break; + default: BT_ERR("Unknown BR/EDR signaling command 0x%2.2x", cmd->code); err = -EINVAL; -- cgit v0.10.2 From 08add513caa8930b8f7b9d5837a7dda624741745 Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Wed, 2 Nov 2011 16:18:36 -0700 Subject: Bluetooth: Guarantee BR-EDR device will be registered as hci0 It's convenient to use the HCI device index the AMP controller id, but the spec requires that an AMP controller never has id 0. Signed-off-by: Mat Martineau Acked-by: Marcel Holtmann Acked-by: Andrei Emeltchenko Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 4221fd5..b7f6b5b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1410,7 +1410,7 @@ int hci_add_adv_entry(struct hci_dev *hdev, int hci_register_dev(struct hci_dev *hdev) { struct list_head *head = &hci_dev_list, *p; - int i, id = 0, error; + int i, id, error; BT_DBG("%p name %s bus %d owner %p", hdev, hdev->name, hdev->bus, hdev->owner); @@ -1418,6 +1418,11 @@ int hci_register_dev(struct hci_dev *hdev) if (!hdev->open || !hdev->close || !hdev->destruct) return -EINVAL; + /* Do not allow HCI_AMP devices to register at index 0, + * so the index can be used as the AMP controller ID. + */ + id = (hdev->dev_type == HCI_BREDR) ? 0 : 1; + write_lock_bh(&hci_dev_list_lock); /* Find first available device id */ -- cgit v0.10.2 From b24752fe655e9427240a5fe840914b94e5f9c2bc Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 3 Nov 2011 14:40:33 +0200 Subject: Bluetooth: Fix mgmt response when adapter goes down or is removed When an adapter gets powered off or is removed any pending commands should receive a ENETDOWN or ENODEV status response. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cbc8a6d..747366a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -262,7 +262,7 @@ static void mgmt_pending_foreach(u16 opcode, int index, cmd = list_entry(p, struct pending_cmd, list); - if (cmd->opcode != opcode) + if (opcode > 0 && cmd->opcode != opcode) continue; if (index >= 0 && cmd->index != index) @@ -1949,6 +1949,14 @@ done: return err; } +static void cmd_status_rsp(struct pending_cmd *cmd, void *data) +{ + u8 *status = data; + + cmd_status(cmd->sk, cmd->index, cmd->opcode, *status); + mgmt_pending_remove(cmd); +} + int mgmt_index_added(u16 index) { return mgmt_event(MGMT_EV_INDEX_ADDED, index, NULL, 0, NULL); @@ -1956,6 +1964,10 @@ int mgmt_index_added(u16 index) int mgmt_index_removed(u16 index) { + u8 status = ENODEV; + + mgmt_pending_foreach(0, index, cmd_status_rsp, &status); + return mgmt_event(MGMT_EV_INDEX_REMOVED, index, NULL, 0, NULL); } @@ -1992,6 +2004,11 @@ int mgmt_powered(u16 index, u8 powered) mgmt_pending_foreach(MGMT_OP_SET_POWERED, index, mode_rsp, &match); + if (!powered) { + u8 status = ENETDOWN; + mgmt_pending_foreach(0, index, cmd_status_rsp, &status); + } + ev.val = powered; ret = mgmt_event(MGMT_EV_POWERED, index, &ev, sizeof(ev), match.sk); -- cgit v0.10.2 From abc545b8efe3d50d649590df4b88cc652fd057f1 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Thu, 3 Nov 2011 16:05:44 +0100 Subject: Bluetooth: Add debug print to l2cap_chan_create Signed-off-by: Szymon Janc Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 335dc6f..fe5666e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -294,6 +294,8 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk) atomic_set(&chan->refcnt, 1); + BT_DBG("sk %p chan %p", sk, chan); + return chan; } -- cgit v0.10.2 From 36f7fc7e9ac72507ab7bf6caf77ad252c12ab37e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 4 Nov 2011 00:17:45 +0200 Subject: Bluetooth: Clean up logic in hci_cc_write_scan_enable This patch adds a new label to hci_cc_write_scan_enable to avoid unnecessary indentation. This will be convenient especially when new code for the discoverable timeout gets added. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d8fa657..8c81a75 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -274,7 +274,8 @@ static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb) static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) { - __u8 status = *((__u8 *) skb->data); + __u8 param, status = *((__u8 *) skb->data); + int old_pscan, old_iscan; void *sent; BT_DBG("%s status 0x%x", hdev->name, status); @@ -283,28 +284,29 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) if (!sent) return; - if (!status) { - __u8 param = *((__u8 *) sent); - int old_pscan, old_iscan; + if (status != 0) + goto done; - old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); - old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); + param = *((__u8 *) sent); - if (param & SCAN_INQUIRY) { - set_bit(HCI_ISCAN, &hdev->flags); - if (!old_iscan) - mgmt_discoverable(hdev->id, 1); - } else if (old_iscan) - mgmt_discoverable(hdev->id, 0); + old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); + old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); - if (param & SCAN_PAGE) { - set_bit(HCI_PSCAN, &hdev->flags); - if (!old_pscan) - mgmt_connectable(hdev->id, 1); - } else if (old_pscan) - mgmt_connectable(hdev->id, 0); - } + if (param & SCAN_INQUIRY) { + set_bit(HCI_ISCAN, &hdev->flags); + if (!old_iscan) + mgmt_discoverable(hdev->id, 1); + } else if (old_iscan) + mgmt_discoverable(hdev->id, 0); + + if (param & SCAN_PAGE) { + set_bit(HCI_PSCAN, &hdev->flags); + if (!old_pscan) + mgmt_connectable(hdev->id, 1); + } else if (old_pscan) + mgmt_connectable(hdev->id, 0); +done: hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status); } -- cgit v0.10.2 From 5698eb4eda657fd4a74612a65cd5d583f35a5bdb Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Mon, 7 Nov 2011 15:58:40 -0800 Subject: ARM: OMAP3: CPUidle: include The CPUidle use THIS_MODULE, so needs Signed-off-by: Kevin Hilman Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c index 4bf6e6e..2e0fa5a 100644 --- a/arch/arm/mach-omap2/cpuidle34xx.c +++ b/arch/arm/mach-omap2/cpuidle34xx.c @@ -24,6 +24,7 @@ #include #include +#include #include #include -- cgit v0.10.2 From e7cbb5b56911308b6d148db6c2d69e1a8004cbc9 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Tue, 8 Nov 2011 10:16:03 +0100 Subject: Doc: cpufreq: Fix typo and outdated line 'sampling_rate_max' was removed with commit ef598549 ("[...] Remove deprecated sysfs file sampling_rate_max"), so its line can be dropped from governors.txt. And 'show_sampling_rate_min' is a typo: the sysfs file is called 'sampling_rate_min'. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt index d221781..c7a2eb8 100644 --- a/Documentation/cpu-freq/governors.txt +++ b/Documentation/cpu-freq/governors.txt @@ -127,7 +127,7 @@ in the bash (as said, 1000 is default), do: echo `$(($(cat cpuinfo_transition_latency) * 750 / 1000)) \ >ondemand/sampling_rate -show_sampling_rate_min: +sampling_rate_min: The sampling rate is limited by the HW transition latency: transition_latency * 100 Or by kernel restrictions: @@ -140,8 +140,6 @@ HZ=100: min=200000us (200ms) The highest value of kernel and HW latency restrictions is shown and used as the minimum sampling rate. -show_sampling_rate_max: THIS INTERFACE IS DEPRECATED, DON'T USE IT. - up_threshold: defines what the average CPU usage between the samplings of 'sampling_rate' needs to be for the kernel to make a decision on whether it should increase the frequency. For example when it is set -- cgit v0.10.2 From 830d7f5e8d83b987e5c3e1328070efe1eea4c0ec Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 7 Nov 2011 14:28:22 +0100 Subject: Doc: 53c700: drop never defined (Kconfig) macros Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/Documentation/scsi/53c700.txt b/Documentation/scsi/53c700.txt index 0da681d..e31aceb 100644 --- a/Documentation/scsi/53c700.txt +++ b/Documentation/scsi/53c700.txt @@ -16,32 +16,13 @@ fill in to get the driver working. Compile Time Flags ================== -The driver may be either io mapped or memory mapped. This is -selectable by configuration flags: - -CONFIG_53C700_MEM_MAPPED - -define if the driver is memory mapped. - -CONFIG_53C700_IO_MAPPED - -define if the driver is to be io mapped. - -One or other of the above flags *must* be defined. - -Other flags are: +A compile time flag is: CONFIG_53C700_LE_ON_BE define if the chipset must be supported in little endian mode on a big endian architecture (used for the 700 on parisc). -CONFIG_53C700_USE_CONSISTENT - -allocate consistent memory (should only be used if your architecture -has a mixture of consistent and inconsistent memory). Fully -consistent or fully inconsistent architectures should not define this. - Using the Chip Core Driver ========================== -- cgit v0.10.2 From 20ed0535d35b74c9e4fa5777766d6e836fe3c90c Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 31 Oct 2011 09:52:02 +0000 Subject: GFS2: Fix up REQ flags Christoph has split up REQ_PRIO from REQ_META. That means that we can drop REQ_PRIO from places where is it not needed. I'm not at all sure that the combination WRITE_FLUSH_FUA | REQ_PRIO makes any kind of sense, anyway. In addition, I've added REQ_META to one place in the code where it was missing. REQ_PRIO has been left for read/writes triggered by glock acquisition and writeback only. We can adjust it again if required, but these are the most important points from a performance perspective. Signed-off-by: Steven Whitehouse Cc: Christoph Hellwig diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 5986464..2731e65 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -626,7 +626,7 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull) if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh); else - submit_bh(WRITE_FLUSH_FUA | REQ_META | REQ_PRIO, bh); + submit_bh(WRITE_FLUSH_FUA | REQ_META, bh); wait_on_buffer(bh); if (!buffer_uptodate(bh)) diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index be29858..181586e 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -435,7 +435,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen) if (buffer_uptodate(first_bh)) goto out; if (!buffer_locked(first_bh)) - ll_rw_block(READ_SYNC | REQ_META | REQ_PRIO, 1, &first_bh); + ll_rw_block(READ_SYNC | REQ_META, 1, &first_bh); dblock++; extlen--; @@ -444,7 +444,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen) bh = gfs2_getbuf(gl, dblock, CREATE); if (!buffer_uptodate(bh) && !buffer_locked(bh)) - ll_rw_block(READA, 1, &bh); + ll_rw_block(READA | REQ_META, 1, &bh); brelse(bh); dblock++; extlen--; diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index cb23c2b..fe72e79 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -224,7 +224,7 @@ static int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector, int silent) bio->bi_end_io = end_bio_io_page; bio->bi_private = page; - submit_bio(READ_SYNC | REQ_META | REQ_PRIO, bio); + submit_bio(READ_SYNC | REQ_META, bio); wait_on_page_locked(page); bio_put(bio); if (!PageUptodate(page)) { diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 7e528dc..d1962b2 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -712,7 +712,7 @@ get_a_page: set_buffer_uptodate(bh); if (!buffer_uptodate(bh)) { - ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh); + ll_rw_block(READ | REQ_META, 1, &bh); wait_on_buffer(bh); if (!buffer_uptodate(bh)) goto unlock_out; -- cgit v0.10.2 From dfe4d34b39b80faff52489f950a18523da7581bf Mon Sep 17 00:00:00 2001 From: Bob Peterson Date: Thu, 27 Oct 2011 12:16:06 -0400 Subject: GFS2: Add readahead to sequential directory traversal This patch adds read-ahead capability to GFS2's directory hash table management. It greatly improves performance for some directory operations. For example: In one of my file systems that has 1000 directories, each of which has 1000 files, time to execute a recursive ls (time ls -fR /mnt/gfs2 > /dev/null) was reduced from 2m2.814s on a stock kernel to 0m45.938s. Signed-off-by: Bob Peterson Signed-off-by: Steven Whitehouse diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 8ccad24..9144117 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -76,6 +76,8 @@ #define IS_LEAF 1 /* Hashed (leaf) directory */ #define IS_DINODE 2 /* Linear (stuffed dinode block) directory */ +#define MAX_RA_BLOCKS 32 /* max read-ahead blocks */ + #define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1) #define gfs2_dir_offset2hash(p) ((u32)(((u64)(p)) << 1)) @@ -1376,6 +1378,50 @@ out: return error; } +/* gfs2_dir_readahead - Issue read-ahead requests for leaf blocks. + * + * Note: we can't calculate each index like dir_e_read can because we don't + * have the leaf, and therefore we don't have the depth, and therefore we + * don't have the length. So we have to just read enough ahead to make up + * for the loss of information. */ +static void gfs2_dir_readahead(struct inode *inode, unsigned hsize, u32 index, + struct file_ra_state *f_ra) +{ + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_glock *gl = ip->i_gl; + struct buffer_head *bh; + u64 blocknr = 0, last; + unsigned count; + + /* First check if we've already read-ahead for the whole range. */ + if (!f_ra || index + MAX_RA_BLOCKS < f_ra->start) + return; + + f_ra->start = max((pgoff_t)index, f_ra->start); + for (count = 0; count < MAX_RA_BLOCKS; count++) { + if (f_ra->start >= hsize) /* if exceeded the hash table */ + break; + + last = blocknr; + blocknr = be64_to_cpu(ip->i_hash_cache[f_ra->start]); + f_ra->start++; + if (blocknr == last) + continue; + + bh = gfs2_getbuf(gl, blocknr, 1); + if (trylock_buffer(bh)) { + if (buffer_uptodate(bh)) { + unlock_buffer(bh); + brelse(bh); + continue; + } + bh->b_end_io = end_buffer_read_sync; + submit_bh(READA | REQ_META, bh); + continue; + } + brelse(bh); + } +} /** * dir_e_read - Reads the entries from a directory into a filldir buffer @@ -1388,7 +1434,7 @@ out: */ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, - filldir_t filldir) + filldir_t filldir, struct file_ra_state *f_ra) { struct gfs2_inode *dip = GFS2_I(inode); u32 hsize, len = 0; @@ -1402,10 +1448,14 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, hash = gfs2_dir_offset2hash(*offset); index = hash >> (32 - dip->i_depth); + if (f_ra && dip->i_hash_cache == NULL) + f_ra->start = 0; lp = gfs2_dir_get_hash_table(dip); if (IS_ERR(lp)) return PTR_ERR(lp); + gfs2_dir_readahead(inode, hsize, index, f_ra); + while (index < hsize) { error = gfs2_dir_read_leaf(inode, offset, opaque, filldir, &copied, &depth, @@ -1423,7 +1473,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, } int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, - filldir_t filldir) + filldir_t filldir, struct file_ra_state *f_ra) { struct gfs2_inode *dip = GFS2_I(inode); struct gfs2_sbd *sdp = GFS2_SB(inode); @@ -1437,7 +1487,7 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, return 0; if (dip->i_diskflags & GFS2_DIF_EXHASH) - return dir_e_read(inode, offset, opaque, filldir); + return dir_e_read(inode, offset, opaque, filldir, f_ra); if (!gfs2_is_stuffed(dip)) { gfs2_consist_inode(dip); diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h index ff5772f..98c960b 100644 --- a/fs/gfs2/dir.h +++ b/fs/gfs2/dir.h @@ -25,7 +25,7 @@ extern int gfs2_dir_add(struct inode *inode, const struct qstr *filename, const struct gfs2_inode *ip); extern int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry); extern int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, - filldir_t filldir); + filldir_t filldir, struct file_ra_state *f_ra); extern int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, const struct gfs2_inode *nip, unsigned int new_type); diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c index fe9945f..70ba891 100644 --- a/fs/gfs2/export.c +++ b/fs/gfs2/export.c @@ -99,6 +99,7 @@ static int gfs2_get_name(struct dentry *parent, char *name, struct gfs2_holder gh; u64 offset = 0; int error; + struct file_ra_state f_ra = { .start = 0 }; if (!dir) return -EINVAL; @@ -118,7 +119,7 @@ static int gfs2_get_name(struct dentry *parent, char *name, if (error) return error; - error = gfs2_dir_read(dir, &offset, &gnfd, get_name_filldir); + error = gfs2_dir_read(dir, &offset, &gnfd, get_name_filldir, &f_ra); gfs2_glock_dq_uninit(&gh); diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index ce36a56..46f6f9a 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -105,7 +105,7 @@ static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir) return error; } - error = gfs2_dir_read(dir, &offset, dirent, filldir); + error = gfs2_dir_read(dir, &offset, dirent, filldir, &file->f_ra); gfs2_glock_dq_uninit(&d_gh); -- cgit v0.10.2 From 1258ea596fe0422272525d9ec8a25b703de4623f Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:09 -0700 Subject: ARM: OMAP2xxx: HWMOD: Fix DSS reset DSS needs all DSS clocks to be enabled to be able to finish reset properly. Before v3.1-rc1 the omapdss driver was managing clocks and resets correctly. However, when omapdss started using runtime PM at v3.1-rc1, the responsibility for the reset moved to HWMOD framework. HWMOD framework does not currently enable all the DSS clocks when resetting the DSS hardware. This hasn't caused any problems so far, but we may just have been lucky. This patch sets HWMOD_CONTROL_OPT_CLKS_IN_RESET for dss_core in OMAP2xxx HWMOD data, fixing the issue. Signed-off-by: Tomi Valkeinen [paul@pwsan.com: merged duplicate .flags fields] Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c index 6d72062..5160e35 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c @@ -875,6 +875,10 @@ static struct omap_hwmod_ocp_if *omap2420_dss_slaves[] = { }; static struct omap_hwmod_opt_clk dss_opt_clks[] = { + /* + * The DSS HW needs all DSS clocks enabled during reset. The dss_core + * driver does not use these clocks. + */ { .role = "tv_clk", .clk = "dss_54m_fck" }, { .role = "sys_clk", .clk = "dss2_fck" }, }; @@ -899,7 +903,7 @@ static struct omap_hwmod omap2420_dss_core_hwmod = { .slaves_cnt = ARRAY_SIZE(omap2420_dss_slaves), .masters = omap2420_dss_masters, .masters_cnt = ARRAY_SIZE(omap2420_dss_masters), - .flags = HWMOD_NO_IDLEST, + .flags = HWMOD_NO_IDLEST | HWMOD_CONTROL_OPT_CLKS_IN_RESET, }; /* l4_core -> dss_dispc */ diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c index a2580d0..d02a44e 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c @@ -942,6 +942,10 @@ static struct omap_hwmod_ocp_if *omap2430_dss_slaves[] = { }; static struct omap_hwmod_opt_clk dss_opt_clks[] = { + /* + * The DSS HW needs all DSS clocks enabled during reset. The dss_core + * driver does not use these clocks. + */ { .role = "tv_clk", .clk = "dss_54m_fck" }, { .role = "sys_clk", .clk = "dss2_fck" }, }; @@ -966,7 +970,7 @@ static struct omap_hwmod omap2430_dss_core_hwmod = { .slaves_cnt = ARRAY_SIZE(omap2430_dss_slaves), .masters = omap2430_dss_masters, .masters_cnt = ARRAY_SIZE(omap2430_dss_masters), - .flags = HWMOD_NO_IDLEST, + .flags = HWMOD_NO_IDLEST | HWMOD_CONTROL_OPT_CLKS_IN_RESET, }; /* l4_core -> dss_dispc */ -- cgit v0.10.2 From b8ac10d8b75843c9ddd6aadf70a0cdf8aa783659 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:09 -0700 Subject: ARM: OMAP2xxx: HWMOD: fix DSS clock data The OMAP2xxx HWMOD data currently contains two errors with DSS clocks: - dss_rfbi is missing ick opt-clock, which is needed for RFBI to calculate timings - dss_venc's interface and main clocks are wrong, causing VENC to fail to start These problems were temporarily fixed with a DSS patch 9ede365aa6f74428a1f69c21ca1cf21213167576 ("HACK: OMAP: DSS2: clk hack for OMAP2/3"), which can be reverted after this patch (and the similar patches for other OMAPs). Signed-off-by: Tomi Valkeinen Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c index 5160e35..74037a5 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c @@ -965,6 +965,10 @@ static struct omap_hwmod_ocp_if *omap2420_dss_rfbi_slaves[] = { &omap2420_l4_core__dss_rfbi, }; +static struct omap_hwmod_opt_clk dss_rfbi_opt_clks[] = { + { .role = "ick", .clk = "dss_ick" }, +}; + static struct omap_hwmod omap2420_dss_rfbi_hwmod = { .name = "dss_rfbi", .class = &omap2_rfbi_hwmod_class, @@ -976,6 +980,8 @@ static struct omap_hwmod omap2420_dss_rfbi_hwmod = { .module_offs = CORE_MOD, }, }, + .opt_clks = dss_rfbi_opt_clks, + .opt_clks_cnt = ARRAY_SIZE(dss_rfbi_opt_clks), .slaves = omap2420_dss_rfbi_slaves, .slaves_cnt = ARRAY_SIZE(omap2420_dss_rfbi_slaves), .flags = HWMOD_NO_IDLEST, @@ -985,7 +991,7 @@ static struct omap_hwmod omap2420_dss_rfbi_hwmod = { static struct omap_hwmod_ocp_if omap2420_l4_core__dss_venc = { .master = &omap2420_l4_core_hwmod, .slave = &omap2420_dss_venc_hwmod, - .clk = "dss_54m_fck", + .clk = "dss_ick", .addr = omap2_dss_venc_addrs, .fw = { .omap2 = { @@ -1005,7 +1011,7 @@ static struct omap_hwmod_ocp_if *omap2420_dss_venc_slaves[] = { static struct omap_hwmod omap2420_dss_venc_hwmod = { .name = "dss_venc", .class = &omap2_venc_hwmod_class, - .main_clk = "dss1_fck", + .main_clk = "dss_54m_fck", .prcm = { .omap2 = { .prcm_reg_id = 1, diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c index d02a44e..6f03653 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c @@ -1020,6 +1020,10 @@ static struct omap_hwmod_ocp_if *omap2430_dss_rfbi_slaves[] = { &omap2430_l4_core__dss_rfbi, }; +static struct omap_hwmod_opt_clk dss_rfbi_opt_clks[] = { + { .role = "ick", .clk = "dss_ick" }, +}; + static struct omap_hwmod omap2430_dss_rfbi_hwmod = { .name = "dss_rfbi", .class = &omap2_rfbi_hwmod_class, @@ -1031,6 +1035,8 @@ static struct omap_hwmod omap2430_dss_rfbi_hwmod = { .module_offs = CORE_MOD, }, }, + .opt_clks = dss_rfbi_opt_clks, + .opt_clks_cnt = ARRAY_SIZE(dss_rfbi_opt_clks), .slaves = omap2430_dss_rfbi_slaves, .slaves_cnt = ARRAY_SIZE(omap2430_dss_rfbi_slaves), .flags = HWMOD_NO_IDLEST, @@ -1040,7 +1046,7 @@ static struct omap_hwmod omap2430_dss_rfbi_hwmod = { static struct omap_hwmod_ocp_if omap2430_l4_core__dss_venc = { .master = &omap2430_l4_core_hwmod, .slave = &omap2430_dss_venc_hwmod, - .clk = "dss_54m_fck", + .clk = "dss_ick", .addr = omap2_dss_venc_addrs, .flags = OCPIF_SWSUP_IDLE, .user = OCP_USER_MPU | OCP_USER_SDMA, @@ -1054,7 +1060,7 @@ static struct omap_hwmod_ocp_if *omap2430_dss_venc_slaves[] = { static struct omap_hwmod omap2430_dss_venc_hwmod = { .name = "dss_venc", .class = &omap2_venc_hwmod_class, - .main_clk = "dss1_fck", + .main_clk = "dss_54m_fck", .prcm = { .omap2 = { .prcm_reg_id = 1, -- cgit v0.10.2 From 8c3105ca1a42783b13930fbd375484ec8c72e608 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:10 -0700 Subject: ARM: OMAP3: HWMOD: Fix DSS reset DSS needs all DSS clocks to be enabled to be able to finish reset properly. Before v3.1-rc1 the omapdss driver was managing clocks and resets correctly. However, when omapdss started using runtime PM at v3.1-rc1, the responsibility for the reset moved to HWMOD framework. HWMOD framework does not currently enable all the DSS clocks when resetting the DSS hardware. This hasn't caused any problems so far, but we may just have been lucky. dss_core's opt-clocks is also missing dss_96m_fck, which is a DSS clock present only on OMAP3430, and thus required on OMAP3430 to finish the reset. This patch sets HWMOD_CONTROL_OPT_CLKS_IN_RESET and adds the dss_96m_fck opt-clock for dss_core in OMAP3 HWMOD data, fixing the issue. Signed-off-by: Tomi Valkeinen [paul@pwsan.com: merged duplicate .flags fields] Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index bc9035e..45ccd4f 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c @@ -1369,9 +1369,14 @@ static struct omap_hwmod_ocp_if *omap3xxx_dss_slaves[] = { }; static struct omap_hwmod_opt_clk dss_opt_clks[] = { - { .role = "tv_clk", .clk = "dss_tv_fck" }, - { .role = "video_clk", .clk = "dss_96m_fck" }, + /* + * The DSS HW needs all DSS clocks enabled during reset. The dss_core + * driver does not use these clocks. + */ { .role = "sys_clk", .clk = "dss2_alwon_fck" }, + { .role = "tv_clk", .clk = "dss_tv_fck" }, + /* required only on OMAP3430 */ + { .role = "tv_dac_clk", .clk = "dss_96m_fck" }, }; static struct omap_hwmod omap3430es1_dss_core_hwmod = { @@ -1394,11 +1399,12 @@ static struct omap_hwmod omap3430es1_dss_core_hwmod = { .slaves_cnt = ARRAY_SIZE(omap3430es1_dss_slaves), .masters = omap3xxx_dss_masters, .masters_cnt = ARRAY_SIZE(omap3xxx_dss_masters), - .flags = HWMOD_NO_IDLEST, + .flags = HWMOD_NO_IDLEST | HWMOD_CONTROL_OPT_CLKS_IN_RESET, }; static struct omap_hwmod omap3xxx_dss_core_hwmod = { .name = "dss_core", + .flags = HWMOD_CONTROL_OPT_CLKS_IN_RESET, .class = &omap2_dss_hwmod_class, .main_clk = "dss1_alwon_fck", /* instead of dss_fck */ .sdma_reqs = omap3xxx_dss_sdma_chs, -- cgit v0.10.2 From 6c3d7e34d68ffae888d33bf364f447e0b415591f Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:10 -0700 Subject: ARM: OMAP3: HWMOD: fix DSS clock data The OMAP3 HWMOD data currently contains these errors with DSS clocks: - dss_rfbi is missing ick opt-clock, which is needed for RFBI to calculate timings - dss_dsi is missing ick and sys_clk - dss_venc is missing dss_96m_fck opt-clock, which is required on OMAP3430 - dss_venc's interface and main clocks are wrong, causing VENC to fail to start These problems were temporarily fixed with a DSS patch 9ede365aa6f74428a1f69c21ca1cf21213167576 ("HACK: OMAP: DSS2: clk hack for OMAP2/3"), which can be reverted after this patch (and the similar patches for other OMAPs). Signed-off-by: Tomi Valkeinen Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index 45ccd4f..4aaf0ca 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c @@ -1492,6 +1492,7 @@ static struct omap_hwmod_addr_space omap3xxx_dss_dsi1_addrs[] = { static struct omap_hwmod_ocp_if omap3xxx_l4_core__dss_dsi1 = { .master = &omap3xxx_l4_core_hwmod, .slave = &omap3xxx_dss_dsi1_hwmod, + .clk = "dss_ick", .addr = omap3xxx_dss_dsi1_addrs, .fw = { .omap2 = { @@ -1508,6 +1509,10 @@ static struct omap_hwmod_ocp_if *omap3xxx_dss_dsi1_slaves[] = { &omap3xxx_l4_core__dss_dsi1, }; +static struct omap_hwmod_opt_clk dss_dsi1_opt_clks[] = { + { .role = "sys_clk", .clk = "dss2_alwon_fck" }, +}; + static struct omap_hwmod omap3xxx_dss_dsi1_hwmod = { .name = "dss_dsi1", .class = &omap3xxx_dsi_hwmod_class, @@ -1520,6 +1525,8 @@ static struct omap_hwmod omap3xxx_dss_dsi1_hwmod = { .module_offs = OMAP3430_DSS_MOD, }, }, + .opt_clks = dss_dsi1_opt_clks, + .opt_clks_cnt = ARRAY_SIZE(dss_dsi1_opt_clks), .slaves = omap3xxx_dss_dsi1_slaves, .slaves_cnt = ARRAY_SIZE(omap3xxx_dss_dsi1_slaves), .flags = HWMOD_NO_IDLEST, @@ -1546,6 +1553,10 @@ static struct omap_hwmod_ocp_if *omap3xxx_dss_rfbi_slaves[] = { &omap3xxx_l4_core__dss_rfbi, }; +static struct omap_hwmod_opt_clk dss_rfbi_opt_clks[] = { + { .role = "ick", .clk = "dss_ick" }, +}; + static struct omap_hwmod omap3xxx_dss_rfbi_hwmod = { .name = "dss_rfbi", .class = &omap2_rfbi_hwmod_class, @@ -1557,6 +1568,8 @@ static struct omap_hwmod omap3xxx_dss_rfbi_hwmod = { .module_offs = OMAP3430_DSS_MOD, }, }, + .opt_clks = dss_rfbi_opt_clks, + .opt_clks_cnt = ARRAY_SIZE(dss_rfbi_opt_clks), .slaves = omap3xxx_dss_rfbi_slaves, .slaves_cnt = ARRAY_SIZE(omap3xxx_dss_rfbi_slaves), .flags = HWMOD_NO_IDLEST, @@ -1566,7 +1579,7 @@ static struct omap_hwmod omap3xxx_dss_rfbi_hwmod = { static struct omap_hwmod_ocp_if omap3xxx_l4_core__dss_venc = { .master = &omap3xxx_l4_core_hwmod, .slave = &omap3xxx_dss_venc_hwmod, - .clk = "dss_tv_fck", + .clk = "dss_ick", .addr = omap2_dss_venc_addrs, .fw = { .omap2 = { @@ -1584,10 +1597,15 @@ static struct omap_hwmod_ocp_if *omap3xxx_dss_venc_slaves[] = { &omap3xxx_l4_core__dss_venc, }; +static struct omap_hwmod_opt_clk dss_venc_opt_clks[] = { + /* required only on OMAP3430 */ + { .role = "tv_dac_clk", .clk = "dss_96m_fck" }, +}; + static struct omap_hwmod omap3xxx_dss_venc_hwmod = { .name = "dss_venc", .class = &omap2_venc_hwmod_class, - .main_clk = "dss1_alwon_fck", + .main_clk = "dss_tv_fck", .prcm = { .omap2 = { .prcm_reg_id = 1, @@ -1595,6 +1613,8 @@ static struct omap_hwmod omap3xxx_dss_venc_hwmod = { .module_offs = OMAP3430_DSS_MOD, }, }, + .opt_clks = dss_venc_opt_clks, + .opt_clks_cnt = ARRAY_SIZE(dss_venc_opt_clks), .slaves = omap3xxx_dss_venc_slaves, .slaves_cnt = ARRAY_SIZE(omap3xxx_dss_venc_slaves), .flags = HWMOD_NO_IDLEST, -- cgit v0.10.2 From 4247878efca76143aa015ed1142652056052abb8 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:11 -0700 Subject: ARM: OMAP4: HWMOD: remove extra clocks Remove the dss_dss_clk from dss_core's opt-clocks. dss_dss_clk already defined as the dss main_clk, and thus is not needed as an opt-clock. Remove opt-clocks for dss_dispc, as dispc only uses the main_clk. Signed-off-by: Tomi Valkeinen Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c index 7695e5d..3b9f2d9 100644 --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c @@ -1240,7 +1240,6 @@ static struct omap_hwmod_ocp_if *omap44xx_dss_slaves[] = { static struct omap_hwmod_opt_clk dss_opt_clks[] = { { .role = "sys_clk", .clk = "dss_sys_clk" }, { .role = "tv_clk", .clk = "dss_tv_clk" }, - { .role = "dss_clk", .clk = "dss_dss_clk" }, { .role = "video_clk", .clk = "dss_48mhz_clk" }, }; @@ -1340,12 +1339,6 @@ static struct omap_hwmod_ocp_if *omap44xx_dss_dispc_slaves[] = { &omap44xx_l4_per__dss_dispc, }; -static struct omap_hwmod_opt_clk dss_dispc_opt_clks[] = { - { .role = "sys_clk", .clk = "dss_sys_clk" }, - { .role = "tv_clk", .clk = "dss_tv_clk" }, - { .role = "hdmi_clk", .clk = "dss_48mhz_clk" }, -}; - static struct omap_hwmod omap44xx_dss_dispc_hwmod = { .name = "dss_dispc", .class = &omap44xx_dispc_hwmod_class, @@ -1359,8 +1352,6 @@ static struct omap_hwmod omap44xx_dss_dispc_hwmod = { .context_offs = OMAP4_RM_DSS_DSS_CONTEXT_OFFSET, }, }, - .opt_clks = dss_dispc_opt_clks, - .opt_clks_cnt = ARRAY_SIZE(dss_dispc_opt_clks), .slaves = omap44xx_dss_dispc_slaves, .slaves_cnt = ARRAY_SIZE(omap44xx_dss_dispc_slaves), }; -- cgit v0.10.2 From 37ad085527860397438f27c81a2cb13272378458 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:11 -0700 Subject: ARM: OMAP4: HWMOD: Add HWMOD_CONTROL_OPT_CLKS_IN_RESET for dss_core DSS needs all DSS clocks to be enabled to be able to finish reset properly. Before v3.1-rc1 the omapdss driver was managing clocks and resets correctly. However, when omapdss started using runtime PM at v3.1-rc1, the responsibility for the reset moved to HWMOD framework. HWMOD framework does not currently enable all the DSS clocks when resetting the DSS hardware. This causes the HWMOD frameworks boot-time reset to fail, possibly leaving the DSS hardware in undefined state. This patch sets HWMOD_CONTROL_OPT_CLKS_IN_RESET for dss_core. The flag is actually not used on OMAP4, because dss_core hardware does not have soft-reset functionality and thus the HWMOD framework never resets nor waits for the reset to finish. However, while the flag is not strictly needed currently, I think it represents the HW correctly: all the DSS clocks should be enabled after power-on to allow DSS hardware to finish its reset. A custom reset function will be added in the following patches which manages this correctly for OMAP4. Signed-off-by: Tomi Valkeinen Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c index 3b9f2d9..b82720a 100644 --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c @@ -1245,6 +1245,7 @@ static struct omap_hwmod_opt_clk dss_opt_clks[] = { static struct omap_hwmod omap44xx_dss_hwmod = { .name = "dss_core", + .flags = HWMOD_CONTROL_OPT_CLKS_IN_RESET, .class = &omap44xx_dss_hwmod_class, .clkdm_name = "l3_dss_clkdm", .main_clk = "dss_dss_clk", -- cgit v0.10.2 From 4d0698d98f501b86d3bef38c46a54a702e0469a0 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:12 -0700 Subject: ARM: OMAP4: HWMOD: fix DSS clock data The OMAP4 HWMOD data currently contains errors with DSS clocks: dss_hdmi and dss_venc have their main_clks wrong. The clocks should be dss_48mhz_clk and dss_tv_clk, respectively. These problems were temporarily fixed with the DSS patches 9ede365aa6f74428a1f69c21ca1cf21213167576 ("HACK: OMAP: DSS2: clk hack for OMAP2/3"), and df5d3ed23cf73ee0763a8963003bda9b69d9620f ("OMAP: DSS2: HDMI: fix hdmi clock name"), which can be reverted after this patch. Signed-off-by: Tomi Valkeinen Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c index b82720a..cadf0bb 100644 --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c @@ -1240,7 +1240,7 @@ static struct omap_hwmod_ocp_if *omap44xx_dss_slaves[] = { static struct omap_hwmod_opt_clk dss_opt_clks[] = { { .role = "sys_clk", .clk = "dss_sys_clk" }, { .role = "tv_clk", .clk = "dss_tv_clk" }, - { .role = "video_clk", .clk = "dss_48mhz_clk" }, + { .role = "hdmi_clk", .clk = "dss_48mhz_clk" }, }; static struct omap_hwmod omap44xx_dss_hwmod = { @@ -1616,7 +1616,7 @@ static struct omap_hwmod omap44xx_dss_hdmi_hwmod = { .clkdm_name = "l3_dss_clkdm", .mpu_irqs = omap44xx_dss_hdmi_irqs, .sdma_reqs = omap44xx_dss_hdmi_sdma_reqs, - .main_clk = "dss_dss_clk", + .main_clk = "dss_48mhz_clk", .prcm = { .omap4 = { .clkctrl_offs = OMAP4_CM_DSS_DSS_CLKCTRL_OFFSET, @@ -1777,7 +1777,7 @@ static struct omap_hwmod omap44xx_dss_venc_hwmod = { .name = "dss_venc", .class = &omap44xx_venc_hwmod_class, .clkdm_name = "l3_dss_clkdm", - .main_clk = "dss_dss_clk", + .main_clk = "dss_tv_clk", .prcm = { .omap4 = { .clkctrl_offs = OMAP4_CM_DSS_DSS_CLKCTRL_OFFSET, -- cgit v0.10.2 From 3ce32676bb355420ceeda57b73dd84df0ff5ad6f Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:12 -0700 Subject: ARM: OMAP2/3: HWMOD: Add SYSS_HAS_RESET_STATUS for dss OMAP2/3 dss_core has a reset status flag in sysstatus register. Add SYSS_HAS_RESET_STATUS flag to HWMOD data so it can be used. Signed-off-by: Tomi Valkeinen Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c index c451729..d78c132 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c @@ -43,7 +43,8 @@ static struct omap_hwmod_class_sysconfig omap2_dss_sysc = { .rev_offs = 0x0000, .sysc_offs = 0x0010, .syss_offs = 0x0014, - .sysc_flags = (SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE), + .sysc_flags = (SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE | + SYSS_HAS_RESET_STATUS), .sysc_fields = &omap_hwmod_sysc_type1, }; -- cgit v0.10.2 From 13662dc5b177d68885695ef513dd4ae0e4d2a099 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 8 Nov 2011 03:16:13 -0700 Subject: ARM: OMAP: HWMOD: Unify DSS resets for OMAPs This patch adds a custom DSS reset function used on OMAPs from OMAP2 forward. The function doesn't actually do a reset, it only waits for the reset to complete. The reason for this is that on OMAP4 there is no possibility to do a SW reset, and on OMAP2/3 doing a SW reset for dss_core resets all the other DSS modules also, thus breaking the HWMOD model where every DSS module is handled independently. This fixes the problem with DSS reset on OMAP4, caused by the fact that because there's no SW reset for dss_core on OMAP4, the HWMOD framework doesn't try to reset dss_core and thus the DSS clocks were never enabled at the same time. This causes causes the HWMOD reset to fail for dss_dispc and dss_rfbi. The common reset function will also allow us to fix another problem in the future: before doing a reset we need to disable DSS outputs, which are in some cases enabled by the bootloader, as otherwise DSS HW seems to get more or less stuck, requiring a power reset to recover. Signed-off-by: Tomi Valkeinen [paul@pwsan.com: modified to build arch/arm/mach-omap2/display.o unconditionally to avoid an error when !CONFIG_OMAP2_DSS] Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 69ab1c0..b009f17 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -4,7 +4,7 @@ # Common support obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer.o pm.o \ - common.o gpio.o dma.o wd_timer.o + common.o gpio.o dma.o wd_timer.o display.o omap-2-3-common = irq.o sdrc.o hwmod-common = omap_hwmod.o \ @@ -264,7 +264,4 @@ smsc911x-$(CONFIG_SMSC911X) := gpmc-smsc911x.o obj-y += $(smsc911x-m) $(smsc911x-y) obj-$(CONFIG_ARCH_OMAP4) += hwspinlock.o -disp-$(CONFIG_OMAP2_DSS) := display.o -obj-y += $(disp-m) $(disp-y) - obj-y += common-board-devices.o twl-common.o diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c index adb2756..941b545 100644 --- a/arch/arm/mach-omap2/display.c +++ b/arch/arm/mach-omap2/display.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "control.h" @@ -172,3 +173,37 @@ int __init omap_display_init(struct omap_dss_board_info *board_data) return r; } + +#define MAX_MODULE_SOFTRESET_WAIT 10000 +int omap_dss_reset(struct omap_hwmod *oh) +{ + struct omap_hwmod_opt_clk *oc; + int c = 0; + int i, r; + + if (!(oh->class->sysc->sysc_flags & SYSS_HAS_RESET_STATUS)) { + pr_err("dss_core: hwmod data doesn't contain reset data\n"); + return -EINVAL; + } + + for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) + if (oc->_clk) + clk_enable(oc->_clk); + + omap_test_timeout((omap_hwmod_read(oh, oh->class->sysc->syss_offs) + & SYSS_RESETDONE_MASK), + MAX_MODULE_SOFTRESET_WAIT, c); + + if (c == MAX_MODULE_SOFTRESET_WAIT) + pr_warning("dss_core: waiting for reset to finish failed\n"); + else + pr_debug("dss_core: softreset done\n"); + + for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) + if (oc->_clk) + clk_disable(oc->_clk); + + r = (c == MAX_MODULE_SOFTRESET_WAIT) ? -ETIMEDOUT : 0; + + return r; +} diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c index d78c132..c11273d 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_3xxx_ipblock_data.c @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -51,6 +52,7 @@ static struct omap_hwmod_class_sysconfig omap2_dss_sysc = { struct omap_hwmod_class omap2_dss_hwmod_class = { .name = "dss", .sysc = &omap2_dss_sysc, + .reset = omap_dss_reset, }; /* diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c index cadf0bb..3b04d63 100644 --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "omap_hwmod_common_data.h" @@ -1187,6 +1188,7 @@ static struct omap_hwmod_class_sysconfig omap44xx_dss_sysc = { static struct omap_hwmod_class omap44xx_dss_hwmod_class = { .name = "dss", .sysc = &omap44xx_dss_sysc, + .reset = omap_dss_reset, }; /* dss */ diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h index c50df48..3ff3e36 100644 --- a/arch/arm/plat-omap/include/plat/common.h +++ b/arch/arm/plat-omap/include/plat/common.h @@ -30,6 +30,7 @@ #include #include +#include struct sys_timer; @@ -55,6 +56,8 @@ void am35xx_init_early(void); void ti816x_init_early(void); void omap4430_init_early(void); +extern int omap_dss_reset(struct omap_hwmod *); + void omap_sram_init(void); /* diff --git a/include/video/omapdss.h b/include/video/omapdss.h index b66ebb2..378c7ed 100644 --- a/include/video/omapdss.h +++ b/include/video/omapdss.h @@ -307,15 +307,8 @@ struct omap_dss_board_info { void (*dsi_disable_pads)(int dsi_id, unsigned lane_mask); }; -#if defined(CONFIG_OMAP2_DSS_MODULE) || defined(CONFIG_OMAP2_DSS) /* Init with the board info */ extern int omap_display_init(struct omap_dss_board_info *board_data); -#else -static inline int omap_display_init(struct omap_dss_board_info *board_data) -{ - return 0; -} -#endif struct omap_display_platform_data { struct omap_dss_board_info *board_data; -- cgit v0.10.2 From b923d40dd4211c4ef7d4efa2bd81b7ca1d8744c1 Mon Sep 17 00:00:00 2001 From: Archit Taneja Date: Thu, 6 Oct 2011 18:04:08 -0600 Subject: ARM: OMAP2PLUS: DSS: Ensure DSS works correctly if display is enabled in bootloader Resetting DISPC when a DISPC output is enabled causes the DSS to go into an inconsistent state. Thus if the bootloader has enabled a display, the hwmod code cannot reset the DISPC module just like that, but the outputs need to be disabled first. Add function dispc_disable_outputs() which disables all active overlay manager and ensure all frame transfers are completed. Modify omap_dss_reset() to call this function and clear DSS_CONTROL, DSS_SDI_CONTROL and DSS_PLL_CONTROL so that DSS is in a clean state when the DSS2 driver starts. This resolves the hang issue(caused by a L3 error during boot) seen on the beagle board C3, which has a factory bootloader that enables display. The issue is resolved with this patch. Thanks to Tomi and Sricharan for some additional testing. Acked-by: Tomi Valkeinen Tested-by: R, Sricharan Signed-off-by: Archit Taneja [paul@pwsan.com: restructured code, removed omap_{read,write}l(), removed cpu_is_omap*() calls and converted to dev_attr] Signed-off-by: Paul Walmsley diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c index 941b545..dce9905 100644 --- a/arch/arm/mach-omap2/display.c +++ b/arch/arm/mach-omap2/display.c @@ -30,6 +30,32 @@ #include #include "control.h" +#include "display.h" + +#define DISPC_CONTROL 0x0040 +#define DISPC_CONTROL2 0x0238 +#define DISPC_IRQSTATUS 0x0018 + +#define DSS_SYSCONFIG 0x10 +#define DSS_SYSSTATUS 0x14 +#define DSS_CONTROL 0x40 +#define DSS_SDI_CONTROL 0x44 +#define DSS_PLL_CONTROL 0x48 + +#define LCD_EN_MASK (0x1 << 0) +#define DIGIT_EN_MASK (0x1 << 1) + +#define FRAMEDONE_IRQ_SHIFT 0 +#define EVSYNC_EVEN_IRQ_SHIFT 2 +#define EVSYNC_ODD_IRQ_SHIFT 3 +#define FRAMEDONE2_IRQ_SHIFT 22 +#define FRAMEDONETV_IRQ_SHIFT 24 + +/* + * FRAMEDONE_IRQ_TIMEOUT: how long (in milliseconds) to wait during DISPC + * reset before deciding that something has gone wrong + */ +#define FRAMEDONE_IRQ_TIMEOUT 100 static struct platform_device omap_display_device = { .name = "omapdss", @@ -174,6 +200,90 @@ int __init omap_display_init(struct omap_dss_board_info *board_data) return r; } +static void dispc_disable_outputs(void) +{ + u32 v, irq_mask = 0; + bool lcd_en, digit_en, lcd2_en = false; + int i; + struct omap_dss_dispc_dev_attr *da; + struct omap_hwmod *oh; + + oh = omap_hwmod_lookup("dss_dispc"); + if (!oh) { + WARN(1, "display: could not disable outputs during reset - could not find dss_dispc hwmod\n"); + return; + } + + if (!oh->dev_attr) { + pr_err("display: could not disable outputs during reset due to missing dev_attr\n"); + return; + } + + da = (struct omap_dss_dispc_dev_attr *)oh->dev_attr; + + /* store value of LCDENABLE and DIGITENABLE bits */ + v = omap_hwmod_read(oh, DISPC_CONTROL); + lcd_en = v & LCD_EN_MASK; + digit_en = v & DIGIT_EN_MASK; + + /* store value of LCDENABLE for LCD2 */ + if (da->manager_count > 2) { + v = omap_hwmod_read(oh, DISPC_CONTROL2); + lcd2_en = v & LCD_EN_MASK; + } + + if (!(lcd_en | digit_en | lcd2_en)) + return; /* no managers currently enabled */ + + /* + * If any manager was enabled, we need to disable it before + * DSS clocks are disabled or DISPC module is reset + */ + if (lcd_en) + irq_mask |= 1 << FRAMEDONE_IRQ_SHIFT; + + if (digit_en) { + if (da->has_framedonetv_irq) { + irq_mask |= 1 << FRAMEDONETV_IRQ_SHIFT; + } else { + irq_mask |= 1 << EVSYNC_EVEN_IRQ_SHIFT | + 1 << EVSYNC_ODD_IRQ_SHIFT; + } + } + + if (lcd2_en) + irq_mask |= 1 << FRAMEDONE2_IRQ_SHIFT; + + /* + * clear any previous FRAMEDONE, FRAMEDONETV, + * EVSYNC_EVEN/ODD or FRAMEDONE2 interrupts + */ + omap_hwmod_write(irq_mask, oh, DISPC_IRQSTATUS); + + /* disable LCD and TV managers */ + v = omap_hwmod_read(oh, DISPC_CONTROL); + v &= ~(LCD_EN_MASK | DIGIT_EN_MASK); + omap_hwmod_write(v, oh, DISPC_CONTROL); + + /* disable LCD2 manager */ + if (da->manager_count > 2) { + v = omap_hwmod_read(oh, DISPC_CONTROL2); + v &= ~LCD_EN_MASK; + omap_hwmod_write(v, oh, DISPC_CONTROL2); + } + + i = 0; + while ((omap_hwmod_read(oh, DISPC_IRQSTATUS) & irq_mask) != + irq_mask) { + i++; + if (i > FRAMEDONE_IRQ_TIMEOUT) { + pr_err("didn't get FRAMEDONE1/2 or TV interrupt\n"); + break; + } + mdelay(1); + } +} + #define MAX_MODULE_SOFTRESET_WAIT 10000 int omap_dss_reset(struct omap_hwmod *oh) { @@ -190,6 +300,20 @@ int omap_dss_reset(struct omap_hwmod *oh) if (oc->_clk) clk_enable(oc->_clk); + dispc_disable_outputs(); + + /* clear SDI registers */ + if (cpu_is_omap3430()) { + omap_hwmod_write(0x0, oh, DSS_SDI_CONTROL); + omap_hwmod_write(0x0, oh, DSS_PLL_CONTROL); + } + + /* + * clear DSS_CONTROL register to switch DSS clock sources to + * PRCM clock, if any + */ + omap_hwmod_write(0x0, oh, DSS_CONTROL); + omap_test_timeout((omap_hwmod_read(oh, oh->class->sysc->syss_offs) & SYSS_RESETDONE_MASK), MAX_MODULE_SOFTRESET_WAIT, c); diff --git a/arch/arm/mach-omap2/display.h b/arch/arm/mach-omap2/display.h new file mode 100644 index 0000000..b871b017 --- /dev/null +++ b/arch/arm/mach-omap2/display.h @@ -0,0 +1,29 @@ +/* + * display.h - OMAP2+ integration-specific DSS header + * + * Copyright (C) 2011 Texas Instruments, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef __ARCH_ARM_MACH_OMAP2_DISPLAY_H +#define __ARCH_ARM_MACH_OMAP2_DISPLAY_H + +#include + +struct omap_dss_dispc_dev_attr { + u8 manager_count; + bool has_framedonetv_irq; +}; + +#endif diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c index 74037a5..a5409ce 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c @@ -943,6 +943,7 @@ static struct omap_hwmod omap2420_dss_dispc_hwmod = { .slaves = omap2420_dss_dispc_slaves, .slaves_cnt = ARRAY_SIZE(omap2420_dss_dispc_slaves), .flags = HWMOD_NO_IDLEST, + .dev_attr = &omap2_3_dss_dispc_dev_attr }; /* l4_core -> dss_rfbi */ diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c index 6f03653..c4f56cb 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c @@ -1004,6 +1004,7 @@ static struct omap_hwmod omap2430_dss_dispc_hwmod = { .slaves = omap2430_dss_dispc_slaves, .slaves_cnt = ARRAY_SIZE(omap2430_dss_dispc_slaves), .flags = HWMOD_NO_IDLEST, + .dev_attr = &omap2_3_dss_dispc_dev_attr }; /* l4_core -> dss_rfbi */ diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index 4aaf0ca..7f8915a 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c @@ -1462,6 +1462,7 @@ static struct omap_hwmod omap3xxx_dss_dispc_hwmod = { .slaves = omap3xxx_dss_dispc_slaves, .slaves_cnt = ARRAY_SIZE(omap3xxx_dss_dispc_slaves), .flags = HWMOD_NO_IDLEST, + .dev_attr = &omap2_3_dss_dispc_dev_attr }; /* diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c index 3b04d63..daaf165 100644 --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c @@ -1327,6 +1327,11 @@ static struct omap_hwmod_addr_space omap44xx_dss_dispc_addrs[] = { { } }; +static struct omap_dss_dispc_dev_attr omap44xx_dss_dispc_dev_attr = { + .manager_count = 3, + .has_framedonetv_irq = 1 +}; + /* l4_per -> dss_dispc */ static struct omap_hwmod_ocp_if omap44xx_l4_per__dss_dispc = { .master = &omap44xx_l4_per_hwmod, @@ -1357,6 +1362,7 @@ static struct omap_hwmod omap44xx_dss_dispc_hwmod = { }, .slaves = omap44xx_dss_dispc_slaves, .slaves_cnt = ARRAY_SIZE(omap44xx_dss_dispc_slaves), + .dev_attr = &omap44xx_dss_dispc_dev_attr }; /* diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.c b/arch/arm/mach-omap2/omap_hwmod_common_data.c index de832eb..51e5418 100644 --- a/arch/arm/mach-omap2/omap_hwmod_common_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_common_data.c @@ -49,3 +49,7 @@ struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2 = { .srst_shift = SYSC_TYPE2_SOFTRESET_SHIFT, }; +struct omap_dss_dispc_dev_attr omap2_3_dss_dispc_dev_attr = { + .manager_count = 2, + .has_framedonetv_irq = 0 +}; diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.h b/arch/arm/mach-omap2/omap_hwmod_common_data.h index 39a7c37..ad5d8f0 100644 --- a/arch/arm/mach-omap2/omap_hwmod_common_data.h +++ b/arch/arm/mach-omap2/omap_hwmod_common_data.h @@ -16,6 +16,8 @@ #include +#include "display.h" + /* Common address space across OMAP2xxx */ extern struct omap_hwmod_addr_space omap2xxx_uart1_addr_space[]; extern struct omap_hwmod_addr_space omap2xxx_uart2_addr_space[]; @@ -111,4 +113,6 @@ extern struct omap_hwmod_class omap2xxx_dma_hwmod_class; extern struct omap_hwmod_class omap2xxx_mailbox_hwmod_class; extern struct omap_hwmod_class omap2xxx_mcspi_class; +extern struct omap_dss_dispc_dev_attr omap2_3_dss_dispc_dev_attr; + #endif -- cgit v0.10.2 From f8beab2bb611d735767871e0e1a12dc6a0def7b1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 28 Oct 2011 23:50:49 +0200 Subject: regmap: Add a reusable irq_chip for regmap based interrupt controllers There seem to be lots of regmap-using devices with very similar interrupt controllers with a small bank of interrupt registers and mask registers with an interrupt per bit. This won't cover everything but it's a good start. Each chip supplies a base for the status registers, a base for the mask registers, an optional base for writing acknowledgements (which may be the same as the status registers) and an array of bits within each of these register banks which indicate the interrupt. There is an assumption that the bit for each interrupt will be the same in each of the register bank. Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig index 2fc6a66..0f6c7fb 100644 --- a/drivers/base/regmap/Kconfig +++ b/drivers/base/regmap/Kconfig @@ -13,3 +13,6 @@ config REGMAP_I2C config REGMAP_SPI tristate + +config REGMAP_IRQ + bool diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile index 0573c8a..ce2d18a 100644 --- a/drivers/base/regmap/Makefile +++ b/drivers/base/regmap/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_REGMAP) += regmap.o regcache.o regcache-indexed.o regcache-rbtree.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o +obj-$(CONFIG_REGMAP_IRQ) += regmap-irq.o diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c new file mode 100644 index 0000000..bd54f63 --- /dev/null +++ b/drivers/base/regmap/regmap-irq.c @@ -0,0 +1,284 @@ +/* + * regmap based irq_chip + * + * Copyright 2011 Wolfson Microelectronics plc + * + * Author: Mark Brown + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include "internal.h" + +struct regmap_irq_chip_data { + struct mutex lock; + + struct regmap *map; + struct regmap_irq_chip *chip; + + int irq_base; + + void *status_reg_buf; + unsigned int *status_buf; + unsigned int *mask_buf; + unsigned int *mask_buf_def; +}; + +static inline const +struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data, + int irq) +{ + return &data->chip->irqs[irq - data->irq_base]; +} + +static void regmap_irq_lock(struct irq_data *data) +{ + struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); + + mutex_lock(&d->lock); +} + +static void regmap_irq_sync_unlock(struct irq_data *data) +{ + struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); + int i, ret; + + /* + * If there's been a change in the mask write it back to the + * hardware. We rely on the use of the regmap core cache to + * suppress pointless writes. + */ + for (i = 0; i < d->chip->num_regs; i++) { + ret = regmap_update_bits(d->map, d->chip->mask_base + i, + d->mask_buf_def[i], d->mask_buf[i]); + if (ret != 0) + dev_err(d->map->dev, "Failed to sync masks in %x\n", + d->chip->mask_base + i); + } + + mutex_unlock(&d->lock); +} + +static void regmap_irq_enable(struct irq_data *data) +{ + struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); + const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->irq); + + d->mask_buf[irq_data->reg_offset] &= ~irq_data->mask; +} + +static void regmap_irq_disable(struct irq_data *data) +{ + struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); + const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->irq); + + d->mask_buf[irq_data->reg_offset] |= irq_data->mask; +} + +static struct irq_chip regmap_irq_chip = { + .name = "regmap", + .irq_bus_lock = regmap_irq_lock, + .irq_bus_sync_unlock = regmap_irq_sync_unlock, + .irq_disable = regmap_irq_disable, + .irq_enable = regmap_irq_enable, +}; + +static irqreturn_t regmap_irq_thread(int irq, void *d) +{ + struct regmap_irq_chip_data *data = d; + struct regmap_irq_chip *chip = data->chip; + struct regmap *map = data->map; + int ret, i; + u8 *buf8 = data->status_reg_buf; + u16 *buf16 = data->status_reg_buf; + u32 *buf32 = data->status_reg_buf; + + ret = regmap_bulk_read(map, chip->status_base, data->status_reg_buf, + chip->num_regs); + if (ret != 0) { + dev_err(map->dev, "Failed to read IRQ status: %d\n", ret); + return IRQ_NONE; + } + + /* + * Ignore masked IRQs and ack if we need to; we ack early so + * there is no race between handling and acknowleding the + * interrupt. We assume that typically few of the interrupts + * will fire simultaneously so don't worry about overhead from + * doing a write per register. + */ + for (i = 0; i < data->chip->num_regs; i++) { + switch (map->format.val_bytes) { + case 1: + data->status_buf[i] = buf8[i]; + break; + case 2: + data->status_buf[i] = buf16[i]; + break; + case 4: + data->status_buf[i] = buf32[i]; + break; + default: + BUG(); + return IRQ_NONE; + } + + data->status_buf[i] &= ~data->mask_buf[i]; + + if (data->status_buf[i] && chip->ack_base) { + ret = regmap_write(map, chip->ack_base + i, + data->status_buf[i]); + if (ret != 0) + dev_err(map->dev, "Failed to ack 0x%x: %d\n", + chip->ack_base + i, ret); + } + } + + for (i = 0; i < chip->num_irqs; i++) { + if (data->status_buf[chip->irqs[i].reg_offset] & + chip->irqs[i].mask) { + handle_nested_irq(data->irq_base + i); + } + } + + return IRQ_HANDLED; +} + +/** + * regmap_add_irq_chip(): Use standard regmap IRQ controller handling + * + * map: The regmap for the device. + * irq: The IRQ the device uses to signal interrupts + * irq_flags: The IRQF_ flags to use for the primary interrupt. + * chip: Configuration for the interrupt controller. + * data: Runtime data structure for the controller, allocated on success + * + * Returns 0 on success or an errno on failure. + * + * In order for this to be efficient the chip really should use a + * register cache. The chip driver is responsible for restoring the + * register values used by the IRQ controller over suspend and resume. + */ +int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, + int irq_base, struct regmap_irq_chip *chip, + struct regmap_irq_chip_data **data) +{ + struct regmap_irq_chip_data *d; + int cur_irq, i; + int ret = -ENOMEM; + + irq_base = irq_alloc_descs(irq_base, 0, chip->num_irqs, 0); + if (irq_base < 0) { + dev_warn(map->dev, "Failed to allocate IRQs: %d\n", + irq_base); + return irq_base; + } + + d = kzalloc(sizeof(*d), GFP_KERNEL); + if (!d) + return -ENOMEM; + + d->status_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, + GFP_KERNEL); + if (!d->status_buf) + goto err_alloc; + + d->status_reg_buf = kzalloc(map->format.val_bytes * chip->num_regs, + GFP_KERNEL); + if (!d->status_reg_buf) + goto err_alloc; + + d->mask_buf = kzalloc(sizeof(unsigned int) * chip->num_regs, + GFP_KERNEL); + if (!d->mask_buf) + goto err_alloc; + + d->mask_buf_def = kzalloc(sizeof(unsigned int) * chip->num_regs, + GFP_KERNEL); + if (!d->mask_buf_def) + goto err_alloc; + + d->map = map; + d->chip = chip; + d->irq_base = irq_base; + mutex_init(&d->lock); + + for (i = 0; i < chip->num_irqs; i++) + d->mask_buf_def[chip->irqs[i].reg_offset] + |= chip->irqs[i].mask; + + /* Mask all the interrupts by default */ + for (i = 0; i < chip->num_regs; i++) { + d->mask_buf[i] = d->mask_buf_def[i]; + ret = regmap_write(map, chip->mask_base + i, d->mask_buf[i]); + if (ret != 0) { + dev_err(map->dev, "Failed to set masks in 0x%x: %d\n", + chip->mask_base + i, ret); + goto err_alloc; + } + } + + /* Register them with genirq */ + for (cur_irq = irq_base; + cur_irq < chip->num_irqs + irq_base; + cur_irq++) { + irq_set_chip_data(cur_irq, d); + irq_set_chip_and_handler(cur_irq, ®map_irq_chip, + handle_edge_irq); + irq_set_nested_thread(cur_irq, 1); + + /* ARM needs us to explicitly flag the IRQ as valid + * and will set them noprobe when we do so. */ +#ifdef CONFIG_ARM + set_irq_flags(cur_irq, IRQF_VALID); +#else + irq_set_noprobe(cur_irq); +#endif + } + + ret = request_threaded_irq(irq, NULL, regmap_irq_thread, irq_flags, + chip->name, d); + if (ret != 0) { + dev_err(map->dev, "Failed to request IRQ %d: %d\n", irq, ret); + goto err_alloc; + } + + return 0; + +err_alloc: + kfree(d->mask_buf_def); + kfree(d->mask_buf); + kfree(d->status_reg_buf); + kfree(d->status_buf); + kfree(d); + return ret; +} +EXPORT_SYMBOL_GPL(regmap_add_irq_chip); + +/** + * regmap_del_irq_chip(): Stop interrupt handling for a regmap IRQ chip + * + * @irq: Primary IRQ for the device + * @d: regmap_irq_chip_data allocated by regmap_add_irq_chip() + */ +void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *d) +{ + if (!d) + return; + + free_irq(irq, d); + kfree(d->mask_buf_def); + kfree(d->mask_buf); + kfree(d->status_reg_buf); + kfree(d->status_buf); + kfree(d); +} +EXPORT_SYMBOL_GPL(regmap_del_irq_chip); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 690276a..bd54cec 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -144,4 +144,51 @@ int regcache_sync(struct regmap *map); void regcache_cache_only(struct regmap *map, bool enable); void regcache_cache_bypass(struct regmap *map, bool enable); +/** + * Description of an IRQ for the generic regmap irq_chip. + * + * @reg_offset: Offset of the status/mask register within the bank + * @mask: Mask used to flag/control the register. + */ +struct regmap_irq { + unsigned int reg_offset; + unsigned int mask; +}; + +/** + * Description of a generic regmap irq_chip. This is not intended to + * handle every possible interrupt controller, but it should handle a + * substantial proportion of those that are found in the wild. + * + * @name: Descriptive name for IRQ controller. + * + * @status_base: Base status register address. + * @mask_base: Base mask register address. + * @ack_base: Base ack address. If zero then the chip is clear on read. + * + * @num_regs: Number of registers in each control bank. + * @irqs: Descriptors for individual IRQs. Interrupt numbers are + * assigned based on the index in the array of the interrupt. + * @num_irqs: Number of descriptors. + */ +struct regmap_irq_chip { + const char *name; + + unsigned int status_base; + unsigned int mask_base; + unsigned int ack_base; + + int num_regs; + + const struct regmap_irq *irqs; + int num_irqs; +}; + +struct regmap_irq_chip_data; + +int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags, + int irq_base, struct regmap_irq_chip *chip, + struct regmap_irq_chip_data **data); +void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data); + #endif -- cgit v0.10.2 From 82732bdd663ee9dc1ad4b0409881fe89a9d827ca Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 18 Oct 2011 00:37:00 +0100 Subject: regmap: Prepare LZO cache for variable block sizes Give regcache_lzo_block_count() a copy of the map so that when we decide we want to make the LZO cache more controllable we can more easily do so. Signed-off-by: Mark Brown Acked-by: Dimitris Papastamos diff --git a/drivers/base/regmap/regcache-lzo.c b/drivers/base/regmap/regcache-lzo.c index 066aeec..0075690 100644 --- a/drivers/base/regmap/regcache-lzo.c +++ b/drivers/base/regmap/regcache-lzo.c @@ -27,7 +27,7 @@ struct regcache_lzo_ctx { }; #define LZO_BLOCK_NUM 8 -static int regcache_lzo_block_count(void) +static int regcache_lzo_block_count(struct regmap *map) { return LZO_BLOCK_NUM; } @@ -106,19 +106,22 @@ static inline int regcache_lzo_get_blkindex(struct regmap *map, unsigned int reg) { return (reg * map->cache_word_size) / - DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()); + DIV_ROUND_UP(map->cache_size_raw, + regcache_lzo_block_count(map)); } static inline int regcache_lzo_get_blkpos(struct regmap *map, unsigned int reg) { - return reg % (DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()) / + return reg % (DIV_ROUND_UP(map->cache_size_raw, + regcache_lzo_block_count(map)) / map->cache_word_size); } static inline int regcache_lzo_get_blksize(struct regmap *map) { - return DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()); + return DIV_ROUND_UP(map->cache_size_raw, + regcache_lzo_block_count(map)); } static int regcache_lzo_init(struct regmap *map) @@ -131,7 +134,7 @@ static int regcache_lzo_init(struct regmap *map) ret = 0; - blkcount = regcache_lzo_block_count(); + blkcount = regcache_lzo_block_count(map); map->cache = kzalloc(blkcount * sizeof *lzo_blocks, GFP_KERNEL); if (!map->cache) @@ -203,7 +206,7 @@ static int regcache_lzo_exit(struct regmap *map) if (!lzo_blocks) return 0; - blkcount = regcache_lzo_block_count(); + blkcount = regcache_lzo_block_count(map); /* * the pointer to the bitmap used for syncing the cache * is shared amongst all lzo_blocks. Ensure it is freed -- cgit v0.10.2 From 7ea75801830082f68e4eb7f2e82283b9b2367461 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 23 Oct 2011 16:54:07 +0200 Subject: regmap: Fix word wrap in Makefile 80 columns FTW. Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile index 0573c8a..f331a90 100644 --- a/drivers/base/regmap/Makefile +++ b/drivers/base/regmap/Makefile @@ -1,4 +1,5 @@ -obj-$(CONFIG_REGMAP) += regmap.o regcache.o regcache-indexed.o regcache-rbtree.o regcache-lzo.o +obj-$(CONFIG_REGMAP) += regmap.o regcache.o regcache-indexed.o +obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o -- cgit v0.10.2 From b973aa3624a531c7d2b4d8d199142299488f573e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 28 Oct 2011 23:46:18 +0200 Subject: regmap: Fix typo in kerneldoc for regmap_update_bits() Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index bf441db..6ef4518 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -547,7 +547,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, EXPORT_SYMBOL_GPL(regmap_bulk_read); /** - * remap_update_bits: Perform a read/modify/write cycle on the register map + * regmap_update_bits: Perform a read/modify/write cycle on the register map * * @map: Register map to update * @reg: Register to update -- cgit v0.10.2 From 8ae0d7e8a918e9603748abe9b31984fc5d96abb3 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 26 Oct 2011 10:34:22 +0200 Subject: regmap: Track if the register cache is dirty and suppress unneeded syncs Allow drivers to optimise out the register cache sync if they didn't need to do one. If the hardware is desynced from the register cache (by power loss for example) then the driver should call regcache_mark_dirty() to let the core know about this. Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 348ff02..6483e0b 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -74,6 +74,7 @@ struct regmap { struct reg_default *reg_defaults; const void *reg_defaults_raw; void *cache; + bool cache_dirty; }; struct regcache_ops { diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 666f6f5..6ab9f03 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -241,6 +241,8 @@ int regcache_sync(struct regmap *map) map->cache_ops->name); name = map->cache_ops->name; trace_regcache_sync(map->dev, name, "start"); + if (!map->cache_dirty) + goto out; if (map->cache_ops->sync) { ret = map->cache_ops->sync(map); } else { @@ -291,6 +293,23 @@ void regcache_cache_only(struct regmap *map, bool enable) EXPORT_SYMBOL_GPL(regcache_cache_only); /** + * regcache_mark_dirty: Mark the register cache as dirty + * + * @map: map to mark + * + * Mark the register cache as dirty, for example due to the device + * having been powered down for suspend. If the cache is not marked + * as dirty then the cache sync will be suppressed. + */ +void regcache_mark_dirty(struct regmap *map) +{ + mutex_lock(&map->lock); + map->cache_dirty = true; + mutex_unlock(&map->lock); +} +EXPORT_SYMBOL_GPL(regcache_mark_dirty); + +/** * regcache_cache_bypass: Put a register map into cache bypass mode * * @map: map to configure diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index bf441db..3aca18d 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -306,8 +306,10 @@ int _regmap_write(struct regmap *map, unsigned int reg, ret = regcache_write(map, reg, val); if (ret != 0) return ret; - if (map->cache_only) + if (map->cache_only) { + map->cache_dirty = true; return 0; + } } trace_regmap_reg_write(map->dev, reg, val); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 690276a..32043a9 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -143,5 +143,6 @@ int regmap_update_bits(struct regmap *map, unsigned int reg, int regcache_sync(struct regmap *map); void regcache_cache_only(struct regmap *map, bool enable); void regcache_cache_bypass(struct regmap *map, bool enable); +void regcache_mark_dirty(struct regmap *map); #endif -- cgit v0.10.2 From 679a673414473239d189b5b41ea4014b088be7b9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 11:55:44 +0200 Subject: wl12xx: couple role_start_dev with roc Device role is always started along with ROC. Couple them together by introducing new wl12xx_start_dev and wl12xx_stop_dev functions. By using these functions, we solve a bug that occured during channel switch - we started the dev role on one channel, and ROCed on a different one. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 2413c43..afd5973 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -468,7 +468,8 @@ static int wl12xx_get_new_session_id(struct wl1271 *wl, return wlvif->session_counter; } -int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +static int wl12xx_cmd_role_start_dev(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; int ret; @@ -516,7 +517,8 @@ out: return ret; } -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +static int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -1776,3 +1778,50 @@ out_free: out: return ret; } + +/* start dev role and roc on its channel */ +int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +{ + int ret; + + if (WARN_ON(!(wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS))) + return -EINVAL; + + ret = wl12xx_cmd_role_start_dev(wl, wlvif); + if (ret < 0) + goto out; + + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + if (ret < 0) + goto out_stop; + + return 0; + +out_stop: + wl12xx_cmd_role_stop_dev(wl, wlvif); +out: + return ret; +} + +/* croc dev hlid, and stop the role */ +int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +{ + int ret; + + if (WARN_ON(!(wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS))) + return -EINVAL; + + if (test_bit(wlvif->dev_role_id, wl->roc_map)) { + ret = wl12xx_croc(wl, wlvif->dev_role_id); + if (ret < 0) + goto out; + } + + ret = wl12xx_cmd_role_stop_dev(wl, wlvif); + if (ret < 0) + goto out; +out: + return ret; +} diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 968d5bd..3f7d0b9 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -39,13 +39,13 @@ int wl1271_cmd_ext_radio_parms(struct wl1271 *wl); int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, u8 *role_id); int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); -int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f76be5a..44070e6 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2429,11 +2429,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (idle) { /* no need to croc if we weren't busy (e.g. during boot) */ if (wl12xx_is_roc(wl)) { - ret = wl12xx_croc(wl, wlvif->dev_role_id); - if (ret < 0) - goto out; - - ret = wl12xx_cmd_role_stop_dev(wl, wlvif); + ret = wl12xx_stop_dev(wl, wlvif); if (ret < 0) goto out; } @@ -2455,11 +2451,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, ieee80211_sched_scan_stopped(wl->hw); } - ret = wl12xx_cmd_role_start_dev(wl, wlvif); - if (ret < 0) - goto out; - - ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + ret = wl12xx_start_dev(wl, wlvif); if (ret < 0) goto out; clear_bit(WL1271_FLAG_IDLE, &wl->flags); @@ -2525,16 +2517,13 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, */ if (wl12xx_is_roc(wl) && !(conf->flags & IEEE80211_CONF_IDLE)) { - ret = wl12xx_croc(wl, - wlvif->dev_role_id); + ret = wl12xx_stop_dev(wl, wlvif); if (ret < 0) return ret; - ret = wl12xx_roc(wl, wlvif, - wlvif->dev_role_id); + ret = wl12xx_start_dev(wl, wlvif); if (ret < 0) - wl1271_warning("roc failed %d", - ret); + return ret; } } } @@ -3087,8 +3076,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, ret = -EBUSY; goto out_sleep; } - wl12xx_croc(wl, wlvif->dev_role_id); - wl12xx_cmd_role_stop_dev(wl, wlvif); + wl12xx_stop_dev(wl, wlvif); } ret = wl1271_scan(hw->priv, vif, ssid, len, req); @@ -3599,8 +3587,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (test_and_clear_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) { wl1271_unjoin(wl, wlvif); - wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + wl12xx_start_dev(wl, wlvif); } } } @@ -3776,11 +3763,8 @@ sta_not_found: } wl1271_unjoin(wl, wlvif); - if (!(conf_flags & IEEE80211_CONF_IDLE)) { - wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif, - wlvif->dev_role_id); - } + if (!(conf_flags & IEEE80211_CONF_IDLE)) + wl12xx_start_dev(wl, wlvif); } } } @@ -3859,11 +3843,7 @@ sta_not_found: * STA role). TODO: make it better. */ if (wlvif->dev_role_id != WL12XX_INVALID_ROLE_ID) { - ret = wl12xx_croc(wl, wlvif->dev_role_id); - if (ret < 0) - goto out; - - ret = wl12xx_cmd_role_stop_dev(wl, wlvif); + ret = wl12xx_stop_dev(wl, wlvif); if (ret < 0) goto out; } diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index fb2c431..898d03d 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -77,8 +77,7 @@ void wl1271_scan_complete_work(struct work_struct *work) (is_ibss && !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags))) && !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ - wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + wl12xx_start_dev(wl, wlvif); } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index c7ad4f5..3a9d2a6 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -99,11 +99,7 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, goto out; wl1271_debug(DEBUG_CMD, "starting device role for roaming"); - ret = wl12xx_cmd_role_start_dev(wl, wlvif); - if (ret < 0) - goto out; - - ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + ret = wl12xx_start_dev(wl, wlvif); if (ret < 0) goto out; out: -- cgit v0.10.2 From d6fa37c9ffa2a613943dd1c32f220a3e6e9eb77c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 11:57:39 +0200 Subject: wl12xx: reconfigure rate policies on set_bitrate_mask The rate policies are configured only after association, resulting in auth req being sent in wrong rates. Reconfigure rate policies on bitrate mask change. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 44070e6..c05be03 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4318,7 +4318,7 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271 *wl = hw->priv; - int i; + int i, ret = 0; wl1271_debug(DEBUG_MAC80211, "mac80211 set_bitrate_mask 0x%x 0x%x", mask->control[NL80211_BAND_2GHZ].legacy, @@ -4331,9 +4331,28 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, wl1271_tx_enabled_rates_get(wl, mask->control[i].legacy, i); + + if (unlikely(wl->state == WL1271_STATE_OFF)) + goto out; + + if (wlvif->bss_type == BSS_TYPE_STA_BSS && + !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + + wl1271_set_band_rate(wl, wlvif); + wlvif->basic_rate = + wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); + + wl1271_ps_elp_sleep(wl); + } +out: mutex_unlock(&wl->mutex); - return 0; + return ret; } static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, -- cgit v0.10.2 From a693534b1a46ee934606cec52b12baeaebba0342 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Mon, 24 Oct 2011 17:25:20 +0200 Subject: wl12xx: keep beacon-filtering enabled during STA operation Enable beacon filtering on STA init, and don't disable it when entering active mode. Otherwise dynamic-PS supports means we receive beacons from the current AP during any Tx/Rx performed by the driver. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index e22df6c..00ce794 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -137,11 +137,6 @@ static int wl1271_event_ps_report(struct wl1271 *wl, case EVENT_ENTER_POWER_SAVE_SUCCESS: wlvif->psm_entry_retry = 0; - /* enable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); - if (ret < 0) - break; - /* * BET has only a minor effect in 5GHz and masks * channel switch IEs, so we only enable BET on 2.4GHz diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index c6084f8..14ff01e 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -254,17 +254,17 @@ static int wl12xx_init_phy_vif_config(struct wl1271 *wl, return 0; } -static int wl1271_init_beacon_filter(struct wl1271 *wl, - struct wl12xx_vif *wlvif) +static int wl1271_init_sta_beacon_filter(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; - /* disable beacon filtering at this stage */ - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); + ret = wl1271_acx_beacon_filter_table(wl, wlvif); if (ret < 0) return ret; - ret = wl1271_acx_beacon_filter_table(wl, wlvif); + /* enable beacon filtering */ + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); if (ret < 0) return ret; @@ -529,7 +529,7 @@ static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) return ret; /* Beacon filtering */ - ret = wl1271_init_beacon_filter(wl, wlvif); + ret = wl1271_init_sta_beacon_filter(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 9f4e8c0..a7a1108 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -185,11 +185,6 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, return ret; } - /* disable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); - if (ret < 0) - return ret; - ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_ACTIVE_MODE); if (ret < 0) return ret; -- cgit v0.10.2 From fa5e13756ad5112842bd5e765d66b6c6074b74b7 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 31 Oct 2011 12:24:49 +0200 Subject: wl12xx: add vifs_state debugfs key Add debugfs key to dump information regarding the active vifs (similar to the driver_state debugfs key) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index a9e0b73..2e14b43 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -385,6 +385,115 @@ static const struct file_operations driver_state_ops = { .llseek = default_llseek, }; +static ssize_t vifs_state_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; + int ret, res = 0; + const int buf_size = 4096; + char *buf; + char tmp_buf[64]; + + buf = kzalloc(buf_size, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + mutex_lock(&wl->mutex); + +#define VIF_STATE_PRINT(x, fmt) \ + (res += scnprintf(buf + res, buf_size - res, \ + #x " = " fmt "\n", wlvif->x)) + +#define VIF_STATE_PRINT_LONG(x) VIF_STATE_PRINT(x, "%ld") +#define VIF_STATE_PRINT_INT(x) VIF_STATE_PRINT(x, "%d") +#define VIF_STATE_PRINT_STR(x) VIF_STATE_PRINT(x, "%s") +#define VIF_STATE_PRINT_LHEX(x) VIF_STATE_PRINT(x, "0x%lx") +#define VIF_STATE_PRINT_LLHEX(x) VIF_STATE_PRINT(x, "0x%llx") +#define VIF_STATE_PRINT_HEX(x) VIF_STATE_PRINT(x, "0x%x") + +#define VIF_STATE_PRINT_NSTR(x, len) \ + do { \ + memset(tmp_buf, 0, sizeof(tmp_buf)); \ + memcpy(tmp_buf, wlvif->x, \ + min_t(u8, len, sizeof(tmp_buf) - 1)); \ + res += scnprintf(buf + res, buf_size - res, \ + #x " = %s\n", tmp_buf); \ + } while (0) + + wl12xx_for_each_wlvif(wl, wlvif) { + VIF_STATE_PRINT_INT(role_id); + VIF_STATE_PRINT_INT(bss_type); + VIF_STATE_PRINT_LHEX(flags); + VIF_STATE_PRINT_INT(p2p); + VIF_STATE_PRINT_INT(dev_role_id); + VIF_STATE_PRINT_INT(dev_hlid); + + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + VIF_STATE_PRINT_INT(sta.hlid); + VIF_STATE_PRINT_INT(sta.ba_rx_bitmap); + VIF_STATE_PRINT_INT(sta.basic_rate_idx); + VIF_STATE_PRINT_INT(sta.ap_rate_idx); + VIF_STATE_PRINT_INT(sta.p2p_rate_idx); + } else { + VIF_STATE_PRINT_INT(ap.global_hlid); + VIF_STATE_PRINT_INT(ap.bcast_hlid); + VIF_STATE_PRINT_LHEX(ap.sta_hlid_map[0]); + VIF_STATE_PRINT_INT(ap.mgmt_rate_idx); + VIF_STATE_PRINT_INT(ap.bcast_rate_idx); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[0]); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[1]); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[2]); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[3]); + } + VIF_STATE_PRINT_INT(last_tx_hlid); + VIF_STATE_PRINT_LHEX(links_map[0]); + VIF_STATE_PRINT_NSTR(ssid, wlvif->ssid_len); + VIF_STATE_PRINT_INT(band); + VIF_STATE_PRINT_INT(channel); + VIF_STATE_PRINT_HEX(bitrate_masks[0]); + VIF_STATE_PRINT_HEX(bitrate_masks[1]); + VIF_STATE_PRINT_HEX(basic_rate_set); + VIF_STATE_PRINT_HEX(basic_rate); + VIF_STATE_PRINT_HEX(rate_set); + VIF_STATE_PRINT_INT(beacon_int); + VIF_STATE_PRINT_INT(default_key); + VIF_STATE_PRINT_INT(aid); + VIF_STATE_PRINT_INT(session_counter); + VIF_STATE_PRINT_INT(ps_poll_failures); + VIF_STATE_PRINT_INT(psm_entry_retry); + VIF_STATE_PRINT_INT(power_level); + VIF_STATE_PRINT_INT(rssi_thold); + VIF_STATE_PRINT_INT(last_rssi_event); + VIF_STATE_PRINT_INT(ba_support); + VIF_STATE_PRINT_INT(ba_allowed); + VIF_STATE_PRINT_LLHEX(tx_security_seq); + VIF_STATE_PRINT_INT(tx_security_last_seq_lsb); + } + +#undef VIF_STATE_PRINT_INT +#undef VIF_STATE_PRINT_LONG +#undef VIF_STATE_PRINT_HEX +#undef VIF_STATE_PRINT_LHEX +#undef VIF_STATE_PRINT_LLHEX +#undef VIF_STATE_PRINT_STR +#undef VIF_STATE_PRINT_NSTR +#undef VIF_STATE_PRINT + + mutex_unlock(&wl->mutex); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, res); + kfree(buf); + return ret; +} + +static const struct file_operations vifs_state_ops = { + .read = vifs_state_read, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + static ssize_t dtim_interval_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -765,6 +874,7 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(gpio_power, rootdir); DEBUGFS_ADD(start_recovery, rootdir); DEBUGFS_ADD(driver_state, rootdir); + DEBUGFS_ADD(vifs_state, rootdir); DEBUGFS_ADD(dtim_interval, rootdir); DEBUGFS_ADD(beacon_interval, rootdir); DEBUGFS_ADD(beacon_filtering, rootdir); -- cgit v0.10.2 From 2f8e81ad42cee6e1503462105f540214b1fb3e54 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 1 Nov 2011 15:12:50 +0200 Subject: wl12xx: clear wl->vif on remove_interface wl->vif should be cleared on remove_interface() (rather than on stop()) even when only a single vif is supported, because during vif mode change stop() might not get called (e.g. because of monitor interface existence) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index c05be03..51d519f 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1859,7 +1859,6 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl->tx_results_count = 0; wl->tx_packets_count = 0; wl->time_offset = 0; - wl->vif = NULL; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; @@ -2211,6 +2210,8 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) return; + wl->vif = NULL; + /* because of hardware recovery, we may get here twice */ if (wl->state != WL1271_STATE_ON) return; -- cgit v0.10.2 From ce39defb5c6312a89a0c7be48797d6fb8fe9abad Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 3 Nov 2011 08:44:41 +0200 Subject: wl12xx: change blocksize alignment quirk to negative SDIO blocksize alignment support is now the rule, not the exception. To simplify the code in patches to come, invert the meaning of the quirk to be negative (ie. the quirk is set if the device does _not_ support blocksize alignment). Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 14ff01e..c413abd 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -501,7 +501,7 @@ int wl1271_chip_specific_init(struct wl1271 *wl) if (wl->chip.id == CHIP_ID_1283_PG20) { u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE; - if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) + if (!(wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT)) /* Enable SDIO padding */ host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 51d519f..b9a3fe4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1323,7 +1323,9 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) ret = wl1271_setup(wl); if (ret < 0) goto out; + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; + case CHIP_ID_1271_PG20: wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1271 PG20)", wl->chip.id); @@ -1331,7 +1333,9 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) ret = wl1271_setup(wl); if (ret < 0) goto out; + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; + case CHIP_ID_1283_PG20: wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1283 PG20)", wl->chip.id); @@ -1340,8 +1344,8 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) if (ret < 0) goto out; - if (wl1271_set_block_size(wl)) - wl->quirks |= WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT; + if (!wl1271_set_block_size(wl)) + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; case CHIP_ID_1283_PG10: default: diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 3a9d2a6..a07ee82 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -201,10 +201,10 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, unsigned int packet_length) { - if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) - return ALIGN(packet_length, WL12XX_BUS_BLOCK_SIZE); - else + if (wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT) return ALIGN(packet_length, WL1271_TX_ALIGN_TO); + else + return ALIGN(packet_length, WL12XX_BUS_BLOCK_SIZE); } static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b7036df..e58e801 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -669,8 +669,8 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); /* Each RX/TX transaction requires an end-of-transaction transfer */ #define WL12XX_QUIRK_END_OF_TRANSACTION BIT(0) -/* WL128X requires aggregated packets to be aligned to the SDIO block size */ -#define WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT BIT(2) +/* wl127x and SPI don't support SDIO block size alignment */ +#define WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT BIT(2) /* Older firmwares did not implement the FW logger over bus feature */ #define WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4) -- cgit v0.10.2 From e62c9ce4a4c0e0ffd5718e962ba4606cd5d0d600 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 3 Nov 2011 08:44:42 +0200 Subject: wl12xx: use the same SDIO block size for all different chips The sdio driver uses a block size of 512 bytes by default. With our card, this doesn't work correctly because it sets the block size FBR in the chip too early (ie. before the chip is powered on). Thus, if we don't set it explicitly, block mode remains disabled in the chip. If we try to send more data than fits in one block, the sdio driver will split it into separate blocks before sending to the chip. This causes problems because the chip is not expecting multiple blocks. At the moment this is not a problem, because we use chunks of 512 bytes for firmware upload and the data is always sent in byte mode. In the next patch, we will change the chunk size to a bigger value, so this patch is a preparation for that. Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b9a3fe4..aa1c0f3 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1313,7 +1313,16 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) /* 0. read chip id from CHIP_ID */ wl->chip.id = wl1271_read32(wl, CHIP_ID_B); - /* 1. check if chip id is valid */ + /* + * For wl127x based devices we could use the default block + * size (512 bytes), but due to a bug in the sdio driver, we + * need to set it explicitly after the chip is powered on. To + * simplify the code and since the performance impact is + * negligible, we use the same block size for all different + * chip types. + */ + if (!wl1271_set_block_size(wl)) + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; switch (wl->chip.id) { case CHIP_ID_1271_PG10: @@ -1343,9 +1352,6 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) ret = wl1271_setup(wl); if (ret < 0) goto out; - - if (!wl1271_set_block_size(wl)) - wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; case CHIP_ID_1283_PG10: default: -- cgit v0.10.2 From 3f3fd78e33213b1684ac1e4deacbcf7ed1828e3c Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 3 Nov 2011 08:44:43 +0200 Subject: wl12xx: increase firmware upload chunk size The chunk size used during firmware upload was set to 512, which is the size of a single SDIO block (or two). This is very inneficient because we send one or two blocks only per SDIO transaction and don't get the full benefits of sdio block transfers. This patch increases the chunk size to 16K. This more than doubles the transfer speed both in wl127x and wl128x chips, with greater impact on the latter: wl127x: 512 bytes chunk -> ~132ms 16384 bytes chunk -> ~57ms wl128x: 512 bytes chunk -> ~216ms 16384 bytes chunk -> ~37ms Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/reg.h b/drivers/net/wireless/wl12xx/reg.h index 3f570f3..df34d59 100644 --- a/drivers/net/wireless/wl12xx/reg.h +++ b/drivers/net/wireless/wl12xx/reg.h @@ -408,7 +408,7 @@ /* Firmware image load chunk size */ -#define CHUNK_SIZE 512 +#define CHUNK_SIZE 16384 /* Firmware image header size */ #define FW_HDR_SIZE 8 -- cgit v0.10.2 From bfafba8a4c61841ab850887d6dfe2741ad037ab6 Mon Sep 17 00:00:00 2001 From: Guy Eilam Date: Tue, 1 Nov 2011 09:23:51 +0200 Subject: wl12xx: set scan probe requests rate according to the no_cck flag Set the TX rate of probe requests during scanning according to the no_cck flag in the scan request struct. Signed-off-by: Guy Eilam Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 04bb8fb..1bcfb01 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -440,6 +440,10 @@ struct conf_rx_settings { CONF_HW_BIT_RATE_36MBPS | CONF_HW_BIT_RATE_48MBPS | \ CONF_HW_BIT_RATE_54MBPS) +#define CONF_TX_CCK_RATES (CONF_HW_BIT_RATE_1MBPS | \ + CONF_HW_BIT_RATE_2MBPS | CONF_HW_BIT_RATE_5_5MBPS | \ + CONF_HW_BIT_RATE_11MBPS) + #define CONF_TX_OFDM_RATES (CONF_HW_BIT_RATE_6MBPS | \ CONF_HW_BIT_RATE_12MBPS | CONF_HW_BIT_RATE_24MBPS | \ CONF_HW_BIT_RATE_36MBPS | CONF_HW_BIT_RATE_48MBPS | \ diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 898d03d..a13c49e 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -202,7 +202,6 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, cmd->params.tx_rate = cpu_to_le32(basic_rate); cmd->params.n_probe_reqs = wl->conf.scan.num_probe_reqs; - cmd->params.tx_rate = cpu_to_le32(basic_rate); cmd->params.tid_trigger = 0; cmd->params.scan_tag = WL1271_SCAN_DEFAULT_TAG; @@ -254,7 +253,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; enum ieee80211_band band; - u32 rate; + u32 rate, mask; switch (wl->scan.state) { case WL1271_SCAN_STATE_IDLE: @@ -262,7 +261,13 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_ACTIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); + mask = wlvif->bitrate_masks[band]; + if (wl->scan.req->no_cck) { + mask &= ~CONF_TX_CCK_RATES; + if (!mask) + mask = CONF_TX_RATE_MASK_BASIC_P2P; + } + rate = wl1271_tx_min_rate_get(wl, mask); ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE; @@ -273,7 +278,13 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_PASSIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); + mask = wlvif->bitrate_masks[band]; + if (wl->scan.req->no_cck) { + mask &= ~CONF_TX_CCK_RATES; + if (!mask) + mask = CONF_TX_RATE_MASK_BASIC_P2P; + } + rate = wl1271_tx_min_rate_get(wl, mask); ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { if (wl->enable_11a) -- cgit v0.10.2 From 8a0f2ee37810aa4a4f46baf08b2ad587e138eb58 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 1 Nov 2011 09:23:52 +0200 Subject: wl12xx: use p2p rate index when the skb has the NO_CCK flag If the skb contains the NO_CCK flag, use the p2p rate index (which contains only the OFDM rates) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index a07ee82..fa518a5 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -336,7 +336,9 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, /* if the packets are destined for AP (have a STA entry) send them with AP rate policies, otherwise use default basic rates */ - if (control->control.sta) + if (control->flags & IEEE80211_TX_CTL_NO_CCK_RATE) + rate_idx = wlvif->sta.p2p_rate_idx; + else if (control->control.sta) rate_idx = wlvif->sta.ap_rate_idx; else rate_idx = wlvif->sta.basic_rate_idx; -- cgit v0.10.2 From c31e494689128203ef04fb946f05a72d33eee948 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 23 Oct 2011 08:21:55 +0200 Subject: wl12xx: handle idle changes per-interface Idle changes are currently handled per hardware. However, some operations should be done only per-interface. Signed-off-by: Eliad Peller Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index aa1c0f3..dbb088e 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2540,13 +2540,6 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, } } - if (changed & IEEE80211_CONF_CHANGE_IDLE && !is_ap) { - ret = wl1271_sta_handle_idle(wl, wlvif, - conf->flags & IEEE80211_CONF_IDLE); - if (ret < 0) - wl1271_warning("idle mode change failed %d", ret); - } - /* * if mac80211 changes the PSM mode, make sure the mode is not * incorrectly changed after the pspoll failure active window. @@ -3617,6 +3610,12 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, do_join = true; } + if (changed & BSS_CHANGED_IDLE) { + ret = wl1271_sta_handle_idle(wl, wlvif, bss_conf->idle); + if (ret < 0) + wl1271_warning("idle mode change failed %d", ret); + } + if ((changed & BSS_CHANGED_CQM)) { bool enable = false; if (bss_conf->cqm_rssi_thold) -- cgit v0.10.2 From b693289406f0b8ca70ab77e745be6196d5740eb0 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 8 Nov 2011 15:56:55 +0200 Subject: wl12xx: fix SDIO suspend/resume wl1271_suspend/resume() accessed the wrong struct and not wl1271 which caused it to think that wow was enabled when it wasn't. Signed-off-by: Eyal Shapira Signed-off-by: Luciano Coelho diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index ed97f9c..468a505 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -289,7 +289,8 @@ static int wl1271_suspend(struct device *dev) /* Tell MMC/SDIO core it's OK to power down the card * (if it isn't already), but not to remove it completely */ struct sdio_func *func = dev_to_sdio_func(dev); - struct wl1271 *wl = sdio_get_drvdata(func); + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); + struct wl1271 *wl = platform_get_drvdata(glue->core); mmc_pm_flag_t sdio_flags; int ret = 0; @@ -324,7 +325,8 @@ out: static int wl1271_resume(struct device *dev) { struct sdio_func *func = dev_to_sdio_func(dev); - struct wl1271 *wl = sdio_get_drvdata(func); + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); + struct wl1271 *wl = platform_get_drvdata(glue->core); dev_dbg(dev, "wl1271 resume\n"); if (wl->wow_enabled) { -- cgit v0.10.2 From 87654896ca619ff64f94d3881d6bd0ec7b29e25f Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Tue, 8 Nov 2011 14:04:20 +0000 Subject: GFS2: More automated code analysis fixes A potentially uninitialised variable, some unreachable code, and the main part of this, fixing the error path in the unlink function. Signed-off-by: Steven Whitehouse diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 41d494d..f6be14f 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -743,9 +743,6 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, else if (ip->i_depth) revokes = sdp->sd_inptrs; - if (error) - return error; - memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); bstart = 0; blen = 0; diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 46f6f9a..6336bc6 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -609,7 +609,7 @@ static int gfs2_fsync(struct file *file, loff_t start, loff_t end, struct inode *inode = mapping->host; int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); struct gfs2_inode *ip = GFS2_I(inode); - int ret, ret1 = 0; + int ret = 0, ret1 = 0; if (mapping->nrpages) { ret1 = filemap_fdatawrite_range(mapping, start, end); diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index cfd4959..377920d 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1037,12 +1037,14 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) struct buffer_head *bh; struct gfs2_holder ghs[3]; struct gfs2_rgrpd *rgd; - int error; + int error = -EROFS; gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr); + if (!rgd) + goto out_inodes; gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2); @@ -1088,12 +1090,13 @@ out_end_trans: out_gunlock: gfs2_glock_dq(ghs + 2); out_rgrp: - gfs2_holder_uninit(ghs + 2); gfs2_glock_dq(ghs + 1); out_child: - gfs2_holder_uninit(ghs + 1); gfs2_glock_dq(ghs); out_parent: + gfs2_holder_uninit(ghs + 2); +out_inodes: + gfs2_holder_uninit(ghs + 1); gfs2_holder_uninit(ghs); return error; } -- cgit v0.10.2 From 50b776fc71c13663eb7434f634f2b796de5c9885 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 2 Nov 2011 15:00:03 +0000 Subject: regmap: Rename LZO cache type to compressed Users probably don't care about the specific compression algorithm and we might want to use a different algorithm (snappy being the one I'm thinking of right now) so update the public interface to have a more generic name. Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regcache-lzo.c b/drivers/base/regmap/regcache-lzo.c index 066aeec..854448d 100644 --- a/drivers/base/regmap/regcache-lzo.c +++ b/drivers/base/regmap/regcache-lzo.c @@ -351,7 +351,7 @@ static int regcache_lzo_sync(struct regmap *map) } struct regcache_ops regcache_lzo_ops = { - .type = REGCACHE_LZO, + .type = REGCACHE_COMPRESSED, .name = "lzo", .init = regcache_lzo_init, .exit = regcache_lzo_exit, diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 32043a9..bebda14 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -25,7 +25,7 @@ enum regcache_type { REGCACHE_NONE, REGCACHE_INDEXED, REGCACHE_RBTREE, - REGCACHE_LZO + REGCACHE_COMPRESSED }; /** -- cgit v0.10.2 From 9f5a0d7bf079e9e26771ad13ff1c2cb3adf80963 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 7 Nov 2011 14:20:25 +0200 Subject: Bluetooth: Define HCI reasons instead of magic number Use HCI error reasons instead of magic numbers. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index c5fcd13..139ce2a 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -264,6 +264,13 @@ enum { #define HCI_LK_SMP_IRK 0x82 #define HCI_LK_SMP_CSRK 0x83 +/* ---- HCI Error Codes ---- */ +#define HCI_ERROR_AUTH_FAILURE 0x05 +#define HCI_ERROR_REJ_BAD_ADDR 0x0f +#define HCI_ERROR_REMOTE_USER_TERM 0x13 +#define HCI_ERROR_LOCAL_HOST_TERM 0x16 +#define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 + /* ----- HCI Commands ---- */ #define HCI_OP_NOP 0x0000 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index f97792c..006a769 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -730,7 +730,7 @@ static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) static inline int hci_proto_disconn_ind(struct hci_conn *conn) { register struct hci_proto *hp; - int reason = 0x13; + int reason = HCI_ERROR_REMOTE_USER_TERM; hp = hci_proto[HCI_PROTO_L2CAP]; if (hp && hp->disconn_ind) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index e545376..ac94367 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -820,7 +820,7 @@ void hci_conn_hash_flush(struct hci_dev *hdev) c->state = BT_CLOSED; - hci_proto_disconn_cfm(c, 0x16); + hci_proto_disconn_cfm(c, HCI_ERROR_LOCAL_HOST_TERM); hci_conn_del(c); } } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8c81a75..9dc54db 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1559,7 +1559,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk struct hci_cp_reject_conn_req cp; bacpy(&cp.bdaddr, &ev->bdaddr); - cp.reason = 0x0f; + cp.reason = HCI_ERROR_REJ_BAD_ADDR; hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp); } } @@ -2646,7 +2646,7 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff struct hci_cp_io_capability_neg_reply cp; bacpy(&cp.bdaddr, &ev->bdaddr); - cp.reason = 0x18; /* Pairing not allowed */ + cp.reason = HCI_ERROR_PAIRING_NOT_ALLOWED; hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY, sizeof(cp), &cp); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index fe5666e..a50610b 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -313,7 +313,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, chan->psm, chan->dcid); - conn->disc_reason = 0x13; + conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM; chan->conn = conn; @@ -1082,7 +1082,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) setup_timer(&conn->info_timer, l2cap_info_timeout, (unsigned long) conn); - conn->disc_reason = 0x13; + conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM; return conn; } @@ -2535,7 +2535,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd /* Check if the ACL is secure enough (if not SDP) */ if (psm != cpu_to_le16(0x0001) && !hci_conn_check_link_mode(conn->hcon)) { - conn->disc_reason = 0x05; + conn->disc_reason = HCI_ERROR_AUTH_FAILURE; result = L2CAP_CR_SEC_BLOCK; goto response; } @@ -4411,7 +4411,7 @@ static int l2cap_disconn_ind(struct hci_conn *hcon) BT_DBG("hcon %p", hcon); if ((hcon->type != ACL_LINK && hcon->type != LE_LINK) || !conn) - return 0x13; + return HCI_ERROR_REMOTE_USER_TERM; return conn->disc_reason; } -- cgit v0.10.2 From 66af7aaf9edff55b7995bbe1ff508513666d0671 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 7 Nov 2011 14:20:33 +0200 Subject: Bluetooth: EFS: parse L2CAP config response Add parsing Extended Flow Specification in L2CAP Config Response. Based upon haijun.liu series of patches (sent Sun, 22 Aug 2010) Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a50610b..f850684 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -2351,6 +2351,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi int type, olen; unsigned long val; struct l2cap_conf_rfc rfc; + struct l2cap_conf_efs efs; BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data); @@ -2393,6 +2394,19 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, chan->tx_win); break; + + case L2CAP_CONF_EFS: + if (olen == sizeof(efs)) + memcpy(&efs, (void *)val, olen); + + if (chan->local_stype != L2CAP_SERV_NOTRAFIC && + efs.stype != L2CAP_SERV_NOTRAFIC && + efs.stype != chan->local_stype) + return -ECONNREFUSED; + + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, + sizeof(efs), (unsigned long) &efs); + break; } } @@ -2407,7 +2421,17 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi chan->retrans_timeout = le16_to_cpu(rfc.retrans_timeout); chan->monitor_timeout = le16_to_cpu(rfc.monitor_timeout); chan->mps = le16_to_cpu(rfc.max_pdu_size); + + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { + chan->local_msdu = le16_to_cpu(efs.msdu); + chan->local_sdu_itime = + le32_to_cpu(efs.sdu_itime); + chan->local_acc_lat = le32_to_cpu(efs.acc_lat); + chan->local_flush_to = + le32_to_cpu(efs.flush_to); + } break; + case L2CAP_MODE_STREAMING: chan->mps = le16_to_cpu(rfc.max_pdu_size); } -- cgit v0.10.2 From 2519a1fc82490eb13d69610f81fe84930f3b0e3f Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Mon, 7 Nov 2011 11:45:24 -0300 Subject: Bluetooth: Create hci_do_inquiry() This patch adds a function to hci_core to carry out inquiry. All inquiry code from start_discovery() were replaced by a hci_do_inquiry() call. Signed-off-by: Andre Guedes Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 006a769..32f3053 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -970,4 +970,6 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); void hci_le_ltk_neg_reply(struct hci_conn *conn); +int hci_do_inquiry(struct hci_dev *hdev, u8 length); + #endif /* __HCI_CORE_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index b7f6b5b..e6e9913 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2560,3 +2560,21 @@ static void hci_cmd_task(unsigned long arg) } } } + +int hci_do_inquiry(struct hci_dev *hdev, u8 length) +{ + /* General inquiry access code (GIAC) */ + u8 lap[3] = { 0x33, 0x8b, 0x9e }; + struct hci_cp_inquiry cp; + + BT_DBG("%s", hdev->name); + + if (test_bit(HCI_INQUIRY, &hdev->flags)) + return -EINPROGRESS; + + memset(&cp, 0, sizeof(cp)); + memcpy(&cp.lap, lap, sizeof(cp.lap)); + cp.length = length; + + return hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); +} diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 747366a..17c7fbb 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -32,6 +32,8 @@ #define MGMT_VERSION 0 #define MGMT_REVISION 1 +#define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ + struct pending_cmd { struct list_head list; __u16 opcode; @@ -1598,8 +1600,6 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, static int start_discovery(struct sock *sk, u16 index) { - u8 lap[3] = { 0x33, 0x8b, 0x9e }; - struct hci_cp_inquiry cp; struct pending_cmd *cmd; struct hci_dev *hdev; int err; @@ -1618,12 +1618,7 @@ static int start_discovery(struct sock *sk, u16 index) goto failed; } - memset(&cp, 0, sizeof(cp)); - memcpy(&cp.lap, lap, 3); - cp.length = 0x08; - cp.num_rsp = 0x00; - - err = hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); + err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); if (err < 0) mgmt_pending_remove(cmd); -- cgit v0.10.2 From 023d50498d04c77b73eed11d849e436ef5639ed2 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 4 Nov 2011 14:16:52 -0300 Subject: Bluetooth: Create hci_cancel_inquiry() This patch adds a function to hci_core to cancel an ongoing inquiry. According to the Bluetooth spec, the inquiry cancel command should only be issued after the inquiry command has been issued, a command status event has been received for the inquiry command, and before the inquiry complete event occurs. As HCI_INQUIRY flag is only set just after an inquiry command status event occurs and it is cleared just after an inquiry complete event occurs, the inquiry cancel command should be issued only if HCI_INQUIRY flag is set. Additionally, cancel inquiry related code from stop_discovery() were replaced by a hci_cancel_inquiry() call. Signed-off-by: Andre Guedes Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 32f3053..20db034 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -971,5 +971,6 @@ void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); void hci_le_ltk_neg_reply(struct hci_conn *conn); int hci_do_inquiry(struct hci_dev *hdev, u8 length); +int hci_cancel_inquiry(struct hci_dev *hdev); #endif /* __HCI_CORE_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e6e9913..6a4bd2d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2578,3 +2578,13 @@ int hci_do_inquiry(struct hci_dev *hdev, u8 length) return hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); } + +int hci_cancel_inquiry(struct hci_dev *hdev) +{ + BT_DBG("%s", hdev->name); + + if (!test_bit(HCI_INQUIRY, &hdev->flags)) + return -EPERM; + + return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); +} diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 17c7fbb..0f9ef94 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1649,7 +1649,7 @@ static int stop_discovery(struct sock *sk, u16 index) goto failed; } - err = hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); + err = hci_cancel_inquiry(hdev); if (err < 0) mgmt_pending_remove(cmd); -- cgit v0.10.2 From 89352e7d3ab372ffad8efe2aa070e0b63df42b85 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 4 Nov 2011 14:16:53 -0300 Subject: Bluetooth: Periodic Inquiry and Discovery By using periodic inquiry command we're not able to detect correctly when the controller has started inquiry. Today we have this workaround in inquiry result event handler to set the HCI_INQUIRY flag when it sees the first inquiry result event. This workaround isn't enough because the device may be performing an inquiry but the HCI_INQUIRY flag is not set. For instance, if there is no device in range, no inquiry result event is generated, consequently, the HCI_INQUIRY flags isn't set when it should so. We rely on HCI_INQUIRY flag to implement the discovery procedure properly. So, as we aren't able to clear/set the HCI_INQUIRY flag in a reliable manner, periodic inquiry events shouldn't change the HCI_INQUIRY flag. Thus, due to that issue and in order to keep compatibility with userspace, periodic inquiry events shouldn't send mgmt discovering events. In future, we might track if periodic inquiry is enabled or not. By tracking this state we'll be able to do some improvements in Discovery such as failing MGMT_OP_START_DISCOVERY command in case periodic inquiry is on. We can also send no mgmt_device_found event if periodic inquiry is on. Signed-off-by: Andre Guedes Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9dc54db..0c11203 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -58,9 +58,9 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) if (status) return; - if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) && - test_bit(HCI_MGMT, &hdev->flags)) - mgmt_discovering(hdev->id, 0); + clear_bit(HCI_INQUIRY, &hdev->flags); + + mgmt_discovering(hdev->id, 0); hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); @@ -76,10 +76,6 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb) if (status) return; - if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) && - test_bit(HCI_MGMT, &hdev->flags)) - mgmt_discovering(hdev->id, 0); - hci_conn_check_pending(hdev); } @@ -986,9 +982,9 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) return; } - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags) && - test_bit(HCI_MGMT, &hdev->flags)) - mgmt_discovering(hdev->id, 1); + set_bit(HCI_INQUIRY, &hdev->flags); + + mgmt_discovering(hdev->id, 1); } static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) @@ -1367,13 +1363,14 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff BT_DBG("%s status %d", hdev->name, status); - if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) && - test_bit(HCI_MGMT, &hdev->flags)) - mgmt_discovering(hdev->id, 0); - hci_req_complete(hdev, HCI_OP_INQUIRY, status); hci_conn_check_pending(hdev); + + if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) + return; + + mgmt_discovering(hdev->id, 0); } static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) @@ -1389,12 +1386,6 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * hci_dev_lock(hdev); - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { - - if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_discovering(hdev->id, 1); - } - for (; num_rsp; num_rsp--, info++) { bacpy(&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; @@ -2395,12 +2386,6 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct hci_dev_lock(hdev); - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { - - if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_discovering(hdev->id, 1); - } - if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { struct inquiry_info_with_rssi_and_pscan_mode *info; info = (void *) (skb->data + 1); @@ -2563,12 +2548,6 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct if (!num_rsp) return; - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { - - if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_discovering(hdev->id, 1); - } - hci_dev_lock(hdev); for (; num_rsp; num_rsp--, info++) { -- cgit v0.10.2 From 16ab91ab48287aa4fc757f3618820f728ee4412f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 7 Nov 2011 22:16:02 +0200 Subject: Bluetooth: Add timeout field to mgmt_set_discoverable Based on the revised mgmt API set_discoverable has a timeout parameter to specify how long the adapter will remain discoverable. A value of 0 means "indefinitively". Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 20db034..5803c1e 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -196,6 +196,9 @@ struct hci_dev { struct work_struct power_off; struct timer_list off_timer; + __u16 discov_timeout; + struct delayed_work discov_off; + struct timer_list cmd_timer; struct tasklet_struct cmd_task; struct tasklet_struct rx_task; diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 3062fd3..b5320aa 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -69,6 +69,10 @@ struct mgmt_mode { #define MGMT_OP_SET_POWERED 0x0005 #define MGMT_OP_SET_DISCOVERABLE 0x0006 +struct mgmt_cp_set_discoverable { + __u8 val; + __u16 timeout; +} __packed; #define MGMT_OP_SET_CONNECTABLE 0x0007 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 6a4bd2d..2da3f90 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -595,6 +595,11 @@ static int hci_dev_do_close(struct hci_dev *hdev) tasklet_kill(&hdev->rx_task); tasklet_kill(&hdev->tx_task); + if (hdev->discov_timeout > 0) { + cancel_delayed_work_sync(&hdev->discov_off); + hdev->discov_timeout = 0; + } + hci_dev_lock_bh(hdev); inquiry_cache_flush(hdev); hci_conn_hash_flush(hdev); @@ -968,6 +973,24 @@ void hci_del_off_timer(struct hci_dev *hdev) del_timer(&hdev->off_timer); } +static void hci_discov_off(struct work_struct *work) +{ + struct hci_dev *hdev; + u8 scan = SCAN_PAGE; + + hdev = container_of(work, struct hci_dev, discov_off.work); + + BT_DBG("%s", hdev->name); + + hci_dev_lock_bh(hdev); + + hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, sizeof(scan), &scan); + + hdev->discov_timeout = 0; + + hci_dev_unlock_bh(hdev); +} + int hci_uuids_clear(struct hci_dev *hdev) { struct list_head *p, *n; @@ -1485,6 +1508,8 @@ int hci_register_dev(struct hci_dev *hdev) INIT_WORK(&hdev->power_off, hci_power_off); setup_timer(&hdev->off_timer, hci_auto_off, (unsigned long) hdev); + INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off); + memset(&hdev->stat, 0, sizeof(struct hci_dev_stats)); atomic_set(&hdev->promisc, 0); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0c11203..cf9926565 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -292,6 +292,11 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) set_bit(HCI_ISCAN, &hdev->flags); if (!old_iscan) mgmt_discoverable(hdev->id, 1); + if (hdev->discov_timeout > 0) { + int to = msecs_to_jiffies(hdev->discov_timeout * 1000); + queue_delayed_work(hdev->workqueue, &hdev->discov_off, + to); + } } else if (old_iscan) mgmt_discoverable(hdev->id, 0); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0f9ef94..724d4fe 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -350,7 +350,7 @@ failed: static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, u16 len) { - struct mgmt_mode *cp; + struct mgmt_cp_set_discoverable *cp; struct hci_dev *hdev; struct pending_cmd *cmd; u8 scan; @@ -396,11 +396,16 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, if (cp->val) scan |= SCAN_INQUIRY; + else + cancel_delayed_work_sync(&hdev->discov_off); err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); if (err < 0) mgmt_pending_remove(cmd); + if (cp->val) + hdev->discov_timeout = get_unaligned_le16(&cp->timeout); + failed: hci_dev_unlock_bh(hdev); hci_dev_put(hdev); -- cgit v0.10.2 From 2d7cee5836d6d466829b255b1290c9386d4e884f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 7 Nov 2011 22:16:03 +0200 Subject: Bluetooth: Fix mgmt response when HCI_Write_Scan_Enable fails A proper mgmt_command_status should be returned to user-space if either discoverable or connectable enabling fails. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5803c1e..c233bce 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -911,6 +911,7 @@ int mgmt_index_removed(u16 index); int mgmt_powered(u16 index, u8 powered); int mgmt_discoverable(u16 index, u8 discoverable); int mgmt_connectable(u16 index, u8 connectable); +int mgmt_write_scan_failed(u16 index, u8 scan, u8 status); int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type); int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index cf9926565..176ceca 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -280,11 +280,14 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) if (!sent) return; - if (status != 0) - goto done; - param = *((__u8 *) sent); + if (status != 0) { + mgmt_write_scan_failed(hdev->id, param, status); + hdev->discov_timeout = 0; + goto done; + } + old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 724d4fe..0cb023e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2056,6 +2056,19 @@ int mgmt_connectable(u16 index, u8 connectable) return ret; } +int mgmt_write_scan_failed(u16 index, u8 scan, u8 status) +{ + if (scan & SCAN_PAGE) + mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, index, + cmd_status_rsp, &status); + + if (scan & SCAN_INQUIRY) + mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, index, + cmd_status_rsp, &status); + + return 0; +} + int mgmt_new_key(u16 index, struct link_key *key, u8 persistent) { struct mgmt_ev_new_key ev; -- cgit v0.10.2 From 3243553fdc108a0ef49b9e25bdea9c87b341413e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 7 Nov 2011 22:16:04 +0200 Subject: Bluetooth: Convert power off mechanism to use delayed_work The power off code doesn't need to use its own custom timer since the delayed_work API provides the exact same functionality. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index c233bce..bca53aa 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -193,8 +193,7 @@ struct hci_dev { struct workqueue_struct *workqueue; struct work_struct power_on; - struct work_struct power_off; - struct timer_list off_timer; + struct delayed_work power_off; __u16 discov_timeout; struct delayed_work discov_off; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2da3f90..e4ddf36 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -600,6 +600,9 @@ static int hci_dev_do_close(struct hci_dev *hdev) hdev->discov_timeout = 0; } + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + cancel_delayed_work_sync(&hdev->power_off); + hci_dev_lock_bh(hdev); inquiry_cache_flush(hdev); hci_conn_hash_flush(hdev); @@ -819,7 +822,8 @@ int hci_get_dev_list(void __user *arg) read_lock_bh(&hci_dev_list_lock); list_for_each_entry(hdev, &hci_dev_list, list) { - hci_del_off_timer(hdev); + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + cancel_delayed_work_sync(&hdev->power_off); if (!test_bit(HCI_MGMT, &hdev->flags)) set_bit(HCI_PAIRABLE, &hdev->flags); @@ -854,7 +858,8 @@ int hci_get_dev_info(void __user *arg) if (!hdev) return -ENODEV; - hci_del_off_timer(hdev); + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + cancel_delayed_work_sync(&hdev->power_off); if (!test_bit(HCI_MGMT, &hdev->flags)) set_bit(HCI_PAIRABLE, &hdev->flags); @@ -938,8 +943,8 @@ static void hci_power_on(struct work_struct *work) return; if (test_bit(HCI_AUTO_OFF, &hdev->flags)) - mod_timer(&hdev->off_timer, - jiffies + msecs_to_jiffies(AUTO_OFF_TIMEOUT)); + queue_delayed_work(hdev->workqueue, &hdev->power_off, + msecs_to_jiffies(AUTO_OFF_TIMEOUT)); if (test_and_clear_bit(HCI_SETUP, &hdev->flags)) mgmt_index_added(hdev->id); @@ -947,30 +952,14 @@ static void hci_power_on(struct work_struct *work) static void hci_power_off(struct work_struct *work) { - struct hci_dev *hdev = container_of(work, struct hci_dev, power_off); - - BT_DBG("%s", hdev->name); - - hci_dev_close(hdev->id); -} - -static void hci_auto_off(unsigned long data) -{ - struct hci_dev *hdev = (struct hci_dev *) data; + struct hci_dev *hdev = container_of(work, struct hci_dev, + power_off.work); BT_DBG("%s", hdev->name); clear_bit(HCI_AUTO_OFF, &hdev->flags); - queue_work(hdev->workqueue, &hdev->power_off); -} - -void hci_del_off_timer(struct hci_dev *hdev) -{ - BT_DBG("%s", hdev->name); - - clear_bit(HCI_AUTO_OFF, &hdev->flags); - del_timer(&hdev->off_timer); + hci_dev_close(hdev->id); } static void hci_discov_off(struct work_struct *work) @@ -1505,8 +1494,7 @@ int hci_register_dev(struct hci_dev *hdev) (unsigned long) hdev); INIT_WORK(&hdev->power_on, hci_power_on); - INIT_WORK(&hdev->power_off, hci_power_off); - setup_timer(&hdev->off_timer, hci_auto_off, (unsigned long) hdev); + INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off); @@ -1583,7 +1571,6 @@ void hci_unregister_dev(struct hci_dev *hdev) hci_del_sysfs(hdev); - hci_del_off_timer(hdev); del_timer(&hdev->adv_timer); destroy_workqueue(hdev->workqueue); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0cb023e..6f9e3cd 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -150,7 +150,8 @@ static int read_index_list(struct sock *sk) i = 0; list_for_each_entry(d, &hci_dev_list, list) { - hci_del_off_timer(d); + if (test_and_clear_bit(HCI_AUTO_OFF, &d->flags)) + cancel_delayed_work_sync(&d->power_off); if (test_bit(HCI_SETUP, &d->flags)) continue; @@ -180,7 +181,8 @@ static int read_controller_info(struct sock *sk, u16 index) if (!hdev) return cmd_status(sk, index, MGMT_OP_READ_INFO, ENODEV); - hci_del_off_timer(hdev); + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + cancel_delayed_work_sync(&hdev->power_off); hci_dev_lock_bh(hdev); @@ -337,7 +339,7 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len) if (cp->val) queue_work(hdev->workqueue, &hdev->power_on); else - queue_work(hdev->workqueue, &hdev->power_off); + queue_work(hdev->workqueue, &hdev->power_off.work); err = 0; -- cgit v0.10.2 From 889d07ee57e950790cbec81df7b4f9d8691ee0b4 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 8 Nov 2011 12:25:52 +0200 Subject: Bluetooth: Remove redundant code from mgmt_block & mgmt_unblock There's no need to deal with mgmt_pending_cmd when blocking and unblocking devices since these actions are synchronous. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 6f9e3cd..e33b12e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1671,7 +1671,6 @@ static int block_device(struct sock *sk, u16 index, unsigned char *data, u16 len) { struct hci_dev *hdev; - struct pending_cmd *cmd; struct mgmt_cp_block_device *cp = (void *) data; int err; @@ -1688,23 +1687,13 @@ static int block_device(struct sock *sk, u16 index, unsigned char *data, hci_dev_lock_bh(hdev); - cmd = mgmt_pending_add(sk, MGMT_OP_BLOCK_DEVICE, index, NULL, 0); - if (!cmd) { - err = -ENOMEM; - goto failed; - } - err = hci_blacklist_add(hdev, &cp->bdaddr); - if (err < 0) err = cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, -err); else err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, NULL, 0); - mgmt_pending_remove(cmd); - -failed: hci_dev_unlock_bh(hdev); hci_dev_put(hdev); @@ -1715,7 +1704,6 @@ static int unblock_device(struct sock *sk, u16 index, unsigned char *data, u16 len) { struct hci_dev *hdev; - struct pending_cmd *cmd; struct mgmt_cp_unblock_device *cp = (void *) data; int err; @@ -1732,12 +1720,6 @@ static int unblock_device(struct sock *sk, u16 index, unsigned char *data, hci_dev_lock_bh(hdev); - cmd = mgmt_pending_add(sk, MGMT_OP_UNBLOCK_DEVICE, index, NULL, 0); - if (!cmd) { - err = -ENOMEM; - goto failed; - } - err = hci_blacklist_del(hdev, &cp->bdaddr); if (err < 0) @@ -1746,9 +1728,6 @@ static int unblock_device(struct sock *sk, u16 index, unsigned char *data, err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, NULL, 0); - mgmt_pending_remove(cmd); - -failed: hci_dev_unlock_bh(hdev); hci_dev_put(hdev); -- cgit v0.10.2 From bd2d1334e1dd64765b29f9e1b592777c410ed121 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 7 Nov 2011 23:13:37 +0200 Subject: Bluetooth: Fix response for mgmt_start_discovery when powered off We should return a ENETDOWN status response if the adapter is powered off (i.e. the HCI_UP flag isn't set). Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e33b12e..af077ab 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1619,6 +1619,11 @@ static int start_discovery(struct sock *sk, u16 index) hci_dev_lock_bh(hdev); + if (!test_bit(HCI_UP, &hdev->flags)) { + err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, ENETDOWN); + goto failed; + } + cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, index, NULL, 0); if (!cmd) { err = -ENOMEM; -- cgit v0.10.2 From 86742e1eca319069490f6f20c2892baafc2a6922 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 7 Nov 2011 23:13:38 +0200 Subject: Bluetooth: Update link key mgmt APIs to match latest spec. BR/EDR link keys have their own commands and events (separate from SMP) and the remove_keys command (previously remove_key) removes keys of any kind for the specified remote address. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index bca53aa..4ebc882 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -911,7 +911,7 @@ int mgmt_powered(u16 index, u8 powered); int mgmt_discoverable(u16 index, u8 discoverable); int mgmt_connectable(u16 index, u8 connectable); int mgmt_write_scan_failed(u16 index, u8 scan, u8 status); -int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); +int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent); int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type); int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); int mgmt_disconnect_failed(u16 index); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index b5320aa..fa33bc6 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -100,22 +100,22 @@ struct mgmt_cp_set_service_cache { __u8 enable; } __packed; -struct mgmt_key_info { +struct mgmt_link_key_info { bdaddr_t bdaddr; u8 type; u8 val[16]; u8 pin_len; } __packed; -#define MGMT_OP_LOAD_KEYS 0x000D -struct mgmt_cp_load_keys { +#define MGMT_OP_LOAD_LINK_KEYS 0x000D +struct mgmt_cp_load_link_keys { __u8 debug_keys; __le16 key_count; - struct mgmt_key_info keys[0]; + struct mgmt_link_key_info keys[0]; } __packed; -#define MGMT_OP_REMOVE_KEY 0x000E -struct mgmt_cp_remove_key { +#define MGMT_OP_REMOVE_KEYS 0x000E +struct mgmt_cp_remove_keys { bdaddr_t bdaddr; __u8 disconnect; } __packed; @@ -247,10 +247,10 @@ struct mgmt_ev_controller_error { #define MGMT_EV_PAIRABLE 0x0009 -#define MGMT_EV_NEW_KEY 0x000A -struct mgmt_ev_new_key { +#define MGMT_EV_NEW_LINK_KEY 0x000A +struct mgmt_ev_new_link_key { __u8 store_hint; - struct mgmt_key_info key; + struct mgmt_link_key_info key; } __packed; #define MGMT_EV_CONNECTED 0x000B diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e4ddf36..693c0df 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1140,7 +1140,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, persistent = hci_persistent_key(hdev, conn, type, old_key_type); - mgmt_new_key(hdev->id, key, persistent); + mgmt_new_link_key(hdev->id, key, persistent); if (!persistent) { list_del(&key->list); @@ -1183,7 +1183,7 @@ int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, memcpy(id->rand, rand, sizeof(id->rand)); if (new_key) - mgmt_new_key(hdev->id, key, old_key_type); + mgmt_new_link_key(hdev->id, key, old_key_type); return 0; } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index af077ab..1939053 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -908,30 +908,32 @@ static int set_service_cache(struct sock *sk, u16 index, unsigned char *data, return err; } -static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len) +static int load_link_keys(struct sock *sk, u16 index, unsigned char *data, + u16 len) { struct hci_dev *hdev; - struct mgmt_cp_load_keys *cp; + struct mgmt_cp_load_link_keys *cp; u16 key_count, expected_len; int i; cp = (void *) data; if (len < sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_LOAD_KEYS, EINVAL); + return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, EINVAL); key_count = get_unaligned_le16(&cp->key_count); - expected_len = sizeof(*cp) + key_count * sizeof(struct mgmt_key_info); + expected_len = sizeof(*cp) + key_count * + sizeof(struct mgmt_link_key_info); if (expected_len != len) { - BT_ERR("load_keys: expected %u bytes, got %u bytes", + BT_ERR("load_link_keys: expected %u bytes, got %u bytes", len, expected_len); - return cmd_status(sk, index, MGMT_OP_LOAD_KEYS, EINVAL); + return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, EINVAL); } hdev = hci_dev_get(index); if (!hdev) - return cmd_status(sk, index, MGMT_OP_LOAD_KEYS, ENODEV); + return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, ENODEV); BT_DBG("hci%u debug_keys %u key_count %u", index, cp->debug_keys, key_count); @@ -948,7 +950,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len) clear_bit(HCI_DEBUG_KEYS, &hdev->flags); for (i = 0; i < key_count; i++) { - struct mgmt_key_info *key = &cp->keys[i]; + struct mgmt_link_key_info *key = &cp->keys[i]; hci_add_link_key(hdev, NULL, 0, &key->bdaddr, key->val, key->type, key->pin_len); @@ -960,27 +962,28 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len) return 0; } -static int remove_key(struct sock *sk, u16 index, unsigned char *data, u16 len) +static int remove_keys(struct sock *sk, u16 index, unsigned char *data, + u16 len) { struct hci_dev *hdev; - struct mgmt_cp_remove_key *cp; + struct mgmt_cp_remove_keys *cp; struct hci_conn *conn; int err; cp = (void *) data; if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_REMOVE_KEY, EINVAL); + return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, EINVAL); hdev = hci_dev_get(index); if (!hdev) - return cmd_status(sk, index, MGMT_OP_REMOVE_KEY, ENODEV); + return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, ENODEV); hci_dev_lock_bh(hdev); err = hci_remove_link_key(hdev, &cp->bdaddr); if (err < 0) { - err = cmd_status(sk, index, MGMT_OP_REMOVE_KEY, -err); + err = cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, -err); goto unlock; } @@ -1860,11 +1863,11 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_SET_SERVICE_CACHE: err = set_service_cache(sk, index, buf + sizeof(*hdr), len); break; - case MGMT_OP_LOAD_KEYS: - err = load_keys(sk, index, buf + sizeof(*hdr), len); + case MGMT_OP_LOAD_LINK_KEYS: + err = load_link_keys(sk, index, buf + sizeof(*hdr), len); break; - case MGMT_OP_REMOVE_KEY: - err = remove_key(sk, index, buf + sizeof(*hdr), len); + case MGMT_OP_REMOVE_KEYS: + err = remove_keys(sk, index, buf + sizeof(*hdr), len); break; case MGMT_OP_DISCONNECT: err = disconnect(sk, index, buf + sizeof(*hdr), len); @@ -2055,9 +2058,9 @@ int mgmt_write_scan_failed(u16 index, u8 scan, u8 status) return 0; } -int mgmt_new_key(u16 index, struct link_key *key, u8 persistent) +int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent) { - struct mgmt_ev_new_key ev; + struct mgmt_ev_new_link_key ev; memset(&ev, 0, sizeof(ev)); @@ -2067,7 +2070,7 @@ int mgmt_new_key(u16 index, struct link_key *key, u8 persistent) memcpy(ev.key.val, key->val, 16); ev.key.pin_len = key->pin_len; - return mgmt_event(MGMT_EV_NEW_KEY, index, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_NEW_LINK_KEY, index, &ev, sizeof(ev), NULL); } int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type) -- cgit v0.10.2 From 4c659c3976e81f9def48993cd00988d53d7379f2 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 7 Nov 2011 23:13:39 +0200 Subject: Bluetooth: Add address type fields to mgmt messages that need them This patch adds address type info (typically BR/EDR vs LE) to management messages that need this. This also ensures conformance to the latest management API specification. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4ebc882..e6071d0 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -912,10 +912,10 @@ int mgmt_discoverable(u16 index, u8 discoverable); int mgmt_connectable(u16 index, u8 connectable); int mgmt_write_scan_failed(u16 index, u8 scan, u8 status); int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent); -int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type); -int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); +int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 type); +int mgmt_disconnected(u16 index, bdaddr_t *bdaddr, u8 type); int mgmt_disconnect_failed(u16 index); -int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); +int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 type, u8 status); int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); @@ -928,8 +928,8 @@ int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, u8 status); -int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, - u8 *eir); +int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 type, u8 *dev_class, + s8 rssi, u8 *eir); int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); int mgmt_inquiry_failed(u16 index, u8 status); int mgmt_discovering(u16 index, u8 discovering); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index fa33bc6..3e320c9 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -128,10 +128,20 @@ struct mgmt_rp_disconnect { bdaddr_t bdaddr; } __packed; +#define MGMT_ADDR_BREDR 0x00 +#define MGMT_ADDR_LE 0x01 +#define MGMT_ADDR_BREDR_LE 0x02 +#define MGMT_ADDR_INVALID 0xff + +struct mgmt_addr_info { + bdaddr_t bdaddr; + __u8 type; +} __packed; + #define MGMT_OP_GET_CONNECTIONS 0x0010 struct mgmt_rp_get_connections { __le16 conn_count; - bdaddr_t conn[0]; + struct mgmt_addr_info addr[0]; } __packed; #define MGMT_OP_PIN_CODE_REPLY 0x0011 @@ -254,19 +264,12 @@ struct mgmt_ev_new_link_key { } __packed; #define MGMT_EV_CONNECTED 0x000B -struct mgmt_ev_connected { - bdaddr_t bdaddr; - __u8 link_type; -} __packed; #define MGMT_EV_DISCONNECTED 0x000C -struct mgmt_ev_disconnected { - bdaddr_t bdaddr; -} __packed; #define MGMT_EV_CONNECT_FAILED 0x000D struct mgmt_ev_connect_failed { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 status; } __packed; @@ -296,7 +299,7 @@ struct mgmt_ev_local_name_changed { #define MGMT_EV_DEVICE_FOUND 0x0012 struct mgmt_ev_device_found { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 dev_class[3]; __s8 rssi; __u8 eir[HCI_MAX_EIR_LENGTH]; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 176ceca..2fced8c 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1404,8 +1404,8 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.rssi = 0x00; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, 0, - NULL); + mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, + info->dev_class, 0, NULL); } hci_dev_unlock(hdev); @@ -1471,7 +1471,8 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s } else { conn->state = BT_CLOSED; if (conn->type == ACL_LINK) - mgmt_connect_failed(hdev->id, &ev->bdaddr, ev->status); + mgmt_connect_failed(hdev->id, &ev->bdaddr, conn->type, + ev->status); } if (conn->type == ACL_LINK) @@ -1584,7 +1585,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff conn->state = BT_CLOSED; if (conn->type == ACL_LINK || conn->type == LE_LINK) - mgmt_disconnected(hdev->id, &conn->dst); + mgmt_disconnected(hdev->id, &conn->dst, conn->type); hci_proto_disconn_cfm(conn, ev->reason); hci_conn_del(conn); @@ -2408,7 +2409,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, + mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, info->dev_class, info->rssi, NULL); } @@ -2425,7 +2426,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, + mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, info->dev_class, info->rssi, NULL); } @@ -2568,8 +2569,8 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x01; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, - info->rssi, info->data); + mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, + info->dev_class, info->rssi, info->data); } hci_dev_unlock(hdev); @@ -2832,7 +2833,8 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff } if (ev->status) { - mgmt_connect_failed(hdev->id, &ev->bdaddr, ev->status); + mgmt_connect_failed(hdev->id, &ev->bdaddr, conn->type, + ev->status); hci_proto_connect_cfm(conn, ev->status); conn->state = BT_CLOSED; hci_conn_del(conn); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 1939053..4cb2f958 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1069,6 +1069,18 @@ failed: return err; } +static u8 link_to_mgmt(u8 link_type) +{ + switch (link_type) { + case LE_LINK: + return MGMT_ADDR_LE; + case ACL_LINK: + return MGMT_ADDR_BREDR; + default: + return MGMT_ADDR_INVALID; + } +} + static int get_connections(struct sock *sk, u16 index) { struct mgmt_rp_get_connections *rp; @@ -1092,7 +1104,7 @@ static int get_connections(struct sock *sk, u16 index) count++; } - rp_len = sizeof(*rp) + (count * sizeof(bdaddr_t)); + rp_len = sizeof(*rp) + (count * sizeof(struct mgmt_addr_info)); rp = kmalloc(rp_len, GFP_ATOMIC); if (!rp) { err = -ENOMEM; @@ -1102,8 +1114,16 @@ static int get_connections(struct sock *sk, u16 index) put_unaligned_le16(count, &rp->conn_count); i = 0; - list_for_each_entry(c, &hdev->conn_hash.list, list) - bacpy(&rp->conn[i++], &c->dst); + list_for_each_entry(c, &hdev->conn_hash.list, list) { + bacpy(&rp->addr[i].bdaddr, &c->dst); + rp->addr[i].type = link_to_mgmt(c->type); + if (rp->addr[i].type == MGMT_ADDR_INVALID) + continue; + i++; + } + + /* Recalculate length in case of filtered SCO connections, etc */ + rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); @@ -2075,10 +2095,10 @@ int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent) int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type) { - struct mgmt_ev_connected ev; + struct mgmt_addr_info ev; bacpy(&ev.bdaddr, bdaddr); - ev.link_type = link_type; + ev.type = link_to_mgmt(link_type); return mgmt_event(MGMT_EV_CONNECTED, index, &ev, sizeof(ev), NULL); } @@ -2099,15 +2119,16 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_remove(cmd); } -int mgmt_disconnected(u16 index, bdaddr_t *bdaddr) +int mgmt_disconnected(u16 index, bdaddr_t *bdaddr, u8 type) { - struct mgmt_ev_disconnected ev; + struct mgmt_addr_info ev; struct sock *sk = NULL; int err; mgmt_pending_foreach(MGMT_OP_DISCONNECT, index, disconnect_rsp, &sk); bacpy(&ev.bdaddr, bdaddr); + ev.type = link_to_mgmt(type); err = mgmt_event(MGMT_EV_DISCONNECTED, index, &ev, sizeof(ev), sk); @@ -2133,11 +2154,12 @@ int mgmt_disconnect_failed(u16 index) return err; } -int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status) +int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 type, u8 status) { struct mgmt_ev_connect_failed ev; - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = link_to_mgmt(type); ev.status = status; return mgmt_event(MGMT_EV_CONNECT_FAILED, index, &ev, sizeof(ev), NULL); @@ -2325,14 +2347,15 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, return err; } -int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, - u8 *eir) +int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 type, u8 *dev_class, + s8 rssi, u8 *eir) { struct mgmt_ev_device_found ev; memset(&ev, 0, sizeof(ev)); - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = link_to_mgmt(type); ev.rssi = rssi; if (eir) -- cgit v0.10.2 From 042f36e1560cedfe524607791fa44607a3121f63 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Tue, 8 Nov 2011 13:27:31 -0500 Subject: IB/qib: Don't use schedule_work() It was mistakenly introduced by dde05cbdf8b1 ("IB/qib: Hold links until tuning data is available"). Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index 5bd2162..8b46b60 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -5241,7 +5241,7 @@ static int qib_7322_ib_updown(struct qib_pportdata *ppd, int ibup, u64 ibcs) off */ if (ppd->dd->flags & QIB_HAS_QSFP) { qd->t_insert = get_jiffies_64(); - schedule_work(&qd->work); + queue_work(ib_wq, &qd->work); } spin_lock_irqsave(&ppd->sdma_lock, flags); if (__qib_sdma_running(ppd)) -- cgit v0.10.2 From 8ce120f11898c921329a5f618d01dcc1e8e69cac Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Fri, 4 Nov 2011 23:19:28 +0000 Subject: net: better pcpu data alignment Tunnels can force an alignment of their percpu data to reduce number of cache lines used in fast path, or read in .ndo_get_stats() percpu_alloc() is a very fine grained allocator, so any small hole will be used anyway. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller diff --git a/drivers/net/veth.c b/drivers/net/veth.c index ef883e9..726c790 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -27,8 +27,8 @@ struct veth_net_stats { u64 rx_packets; - u64 tx_packets; u64 rx_bytes; + u64 tx_packets; u64 tx_bytes; u64 rx_dropped; struct u64_stats_sync syncp; diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index d55110e..38f7c07 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -171,7 +171,7 @@ struct pcpu_tstats { unsigned long rx_bytes; unsigned long tx_packets; unsigned long tx_bytes; -}; +} __attribute__((aligned(4*sizeof(unsigned long)))); static struct net_device_stats *ipgre_get_stats(struct net_device *dev) { diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 065effd..9490690 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -148,7 +148,7 @@ struct pcpu_tstats { unsigned long rx_bytes; unsigned long tx_packets; unsigned long tx_bytes; -}; +} __attribute__((aligned(4*sizeof(unsigned long)))); static struct net_device_stats *ipip_get_stats(struct net_device *dev) { diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index bdc15c9..f36ca13 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -93,7 +93,7 @@ struct pcpu_tstats { unsigned long rx_bytes; unsigned long tx_packets; unsigned long tx_bytes; -}; +} __attribute__((aligned(4*sizeof(unsigned long)))); static struct net_device_stats *ip6_get_stats(struct net_device *dev) { diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index a7a1860..cec0938 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -91,7 +91,7 @@ struct pcpu_tstats { unsigned long rx_bytes; unsigned long tx_packets; unsigned long tx_bytes; -}; +} __attribute__((aligned(4*sizeof(unsigned long)))); static struct net_device_stats *ipip6_get_stats(struct net_device *dev) { -- cgit v0.10.2 From ddc4bbee6ef1ed20314be3888dd39ceefe233e79 Mon Sep 17 00:00:00 2001 From: Michio Honda Date: Fri, 17 Jun 2011 11:03:23 +0900 Subject: sctp: fasthandoff with ASCONF at mobile-node Fast retransmission after changing the last address with ASCONF negotiation Signed-off-by: Michio Honda Signed-off-by: David S. Miller diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index e90e7a9..3382615 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -1085,6 +1085,7 @@ void sctp_transport_burst_reset(struct sctp_transport *); unsigned long sctp_transport_timeout(struct sctp_transport *); void sctp_transport_reset(struct sctp_transport *); void sctp_transport_update_pmtu(struct sctp_transport *, u32); +void sctp_transport_immediate_rtx(struct sctp_transport *); /* This is the structure we use to queue packets as they come into diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 0121e0a..a85eeeb 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -3400,8 +3400,10 @@ int sctp_process_asconf_ack(struct sctp_association *asoc, asconf_len -= length; } - if (no_err && asoc->src_out_of_asoc_ok) + if (no_err && asoc->src_out_of_asoc_ok) { asoc->src_out_of_asoc_ok = 0; + sctp_transport_immediate_rtx(asoc->peer.primary_path); + } /* Free the cached last sent asconf chunk. */ list_del_init(&asconf->transmitted_list); diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 394c57c..3889330 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c @@ -641,3 +641,19 @@ void sctp_transport_reset(struct sctp_transport *t) t->cacc.next_tsn_at_change = 0; t->cacc.cacc_saw_newack = 0; } + +/* Schedule retransmission on the given transport */ +void sctp_transport_immediate_rtx(struct sctp_transport *t) +{ + /* Stop pending T3_rtx_timer */ + if (timer_pending(&t->T3_rtx_timer)) { + (void)del_timer(&t->T3_rtx_timer); + sctp_transport_put(t); + } + sctp_retransmit(&t->asoc->outqueue, t, SCTP_RTXR_T3_RTX); + if (!timer_pending(&t->T3_rtx_timer)) { + if (!mod_timer(&t->T3_rtx_timer, jiffies + t->rto)) + sctp_transport_hold(t); + } + return; +} -- cgit v0.10.2 From 34d2d89f2d7da3b72b3157e778bbf709047ded97 Mon Sep 17 00:00:00 2001 From: Michio Honda Date: Fri, 17 Jun 2011 11:22:35 +0900 Subject: sctp: fasthandoff with ASCONF at server-node Retransmit chunks to newly confirmed destination when ASCONF and HEARTBEAT negotiation has success with a single-homed peer. Signed-off-by: Michio Honda Signed-off-by: David S. Miller diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 76388b0..1ff51c9 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -666,6 +666,7 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds, struct sctp_chunk *chunk) { sctp_sender_hb_info_t *hbinfo; + int was_unconfirmed = 0; /* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of the * HEARTBEAT should clear the error counter of the destination @@ -692,9 +693,11 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds, /* Mark the destination transport address as active if it is not so * marked. */ - if ((t->state == SCTP_INACTIVE) || (t->state == SCTP_UNCONFIRMED)) + if ((t->state == SCTP_INACTIVE) || (t->state == SCTP_UNCONFIRMED)) { + was_unconfirmed = 1; sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP, SCTP_HEARTBEAT_SUCCESS); + } /* The receiver of the HEARTBEAT ACK should also perform an * RTT measurement for that destination transport address @@ -712,6 +715,9 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds, /* Update the heartbeat timer. */ if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t))) sctp_transport_hold(t); + + if (was_unconfirmed && asoc->peer.transport_count == 1) + sctp_transport_immediate_rtx(t); } -- cgit v0.10.2 From 68aad78c5023b8aa82da99b47f9d8cf40e8ca453 Mon Sep 17 00:00:00 2001 From: Rick Jones Date: Mon, 7 Nov 2011 13:29:27 +0000 Subject: sweep the floors and convert some .get_drvinfo routines to strlcpy Per the mention made by Ben Hutchings that strlcpy is now the preferred string copy routine for a .get_drvinfo routine, do a bit of floor sweeping and convert some of the as-yet unconverted ethernet drivers to it. Signed-off-by: Rick Jones Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/3com/3c589_cs.c b/drivers/net/ethernet/3com/3c589_cs.c index 972f80e..da410f0 100644 --- a/drivers/net/ethernet/3com/3c589_cs.c +++ b/drivers/net/ethernet/3com/3c589_cs.c @@ -468,9 +468,10 @@ static void tc589_reset(struct net_device *dev) static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + snprintf(info->bus_info, sizeof(info->bus_info), + "PCMCIA 0x%lx", dev->base_addr); } static const struct ethtool_ops netdev_ethtool_ops = { diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c index b42c06b..8153a3e 100644 --- a/drivers/net/ethernet/3com/3c59x.c +++ b/drivers/net/ethernet/3com/3c59x.c @@ -2929,15 +2929,17 @@ static void vortex_get_drvinfo(struct net_device *dev, { struct vortex_private *vp = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); if (VORTEX_PCI(vp)) { - strcpy(info->bus_info, pci_name(VORTEX_PCI(vp))); + strlcpy(info->bus_info, pci_name(VORTEX_PCI(vp)), + sizeof(info->bus_info)); } else { if (VORTEX_EISA(vp)) - strcpy(info->bus_info, dev_name(vp->gendev)); + strlcpy(info->bus_info, dev_name(vp->gendev), + sizeof(info->bus_info)); else - sprintf(info->bus_info, "EISA 0x%lx %d", - dev->base_addr, dev->irq); + snprintf(info->bus_info, sizeof(info->bus_info), + "EISA 0x%lx %d", dev->base_addr, dev->irq); } } diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c index 20ea075..6d6bc75 100644 --- a/drivers/net/ethernet/3com/typhoon.c +++ b/drivers/net/ethernet/3com/typhoon.c @@ -988,21 +988,23 @@ typhoon_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) smp_rmb(); if(tp->card_state == Sleeping) { - strcpy(info->fw_version, "Sleep image"); + strlcpy(info->fw_version, "Sleep image", + sizeof(info->fw_version)); } else { INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS); if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) { - strcpy(info->fw_version, "Unknown runtime"); + strlcpy(info->fw_version, "Unknown runtime", + sizeof(info->fw_version)); } else { u32 sleep_ver = le32_to_cpu(xp_resp[0].parm2); - snprintf(info->fw_version, 32, "%02x.%03x.%03x", - sleep_ver >> 24, (sleep_ver >> 12) & 0xfff, - sleep_ver & 0xfff); + snprintf(info->fw_version, sizeof(info->fw_version), + "%02x.%03x.%03x", sleep_ver >> 24, + (sleep_ver >> 12) & 0xfff, sleep_ver & 0xfff); } } - strcpy(info->driver, KBUILD_MODNAME); - strcpy(info->bus_info, pci_name(pci_dev)); + strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); + strlcpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); } static int diff --git a/drivers/net/ethernet/8390/ne2k-pci.c b/drivers/net/ethernet/8390/ne2k-pci.c index 3992342..3fab04a 100644 --- a/drivers/net/ethernet/8390/ne2k-pci.c +++ b/drivers/net/ethernet/8390/ne2k-pci.c @@ -639,9 +639,9 @@ static void ne2k_pci_get_drvinfo(struct net_device *dev, struct ei_device *ei = netdev_priv(dev); struct pci_dev *pci_dev = (struct pci_dev *) ei->priv; - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); } static const struct ethtool_ops ne2k_pci_ethtool_ops = { diff --git a/drivers/net/ethernet/adaptec/starfire.c b/drivers/net/ethernet/adaptec/starfire.c index 6d9f691..a446e25 100644 --- a/drivers/net/ethernet/adaptec/starfire.c +++ b/drivers/net/ethernet/adaptec/starfire.c @@ -1842,9 +1842,9 @@ static int check_if_running(struct net_device *dev) static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct netdev_private *np = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(np->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); } static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c index 6269438..6e61f9f 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c @@ -310,10 +310,12 @@ static void atl1e_get_drvinfo(struct net_device *netdev, { struct atl1e_adapter *adapter = netdev_priv(netdev); - strncpy(drvinfo->driver, atl1e_driver_name, 32); - strncpy(drvinfo->version, atl1e_driver_version, 32); - strncpy(drvinfo->fw_version, "L1e", 32); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); + strlcpy(drvinfo->driver, atl1e_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, atl1e_driver_version, + sizeof(drvinfo->version)); + strlcpy(drvinfo->fw_version, "L1e", sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = 0; drvinfo->testinfo_len = 0; drvinfo->regdump_len = atl1e_get_regs_len(netdev); diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c index 1feae59..db3f430 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/drivers/net/ethernet/atheros/atlx/atl2.c @@ -2049,10 +2049,12 @@ static void atl2_get_drvinfo(struct net_device *netdev, { struct atl2_adapter *adapter = netdev_priv(netdev); - strncpy(drvinfo->driver, atl2_driver_name, 32); - strncpy(drvinfo->version, atl2_driver_version, 32); - strncpy(drvinfo->fw_version, "L2", 32); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); + strlcpy(drvinfo->driver, atl2_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, atl2_driver_version, + sizeof(drvinfo->version)); + strlcpy(drvinfo->fw_version, "L2", sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = 0; drvinfo->testinfo_len = 0; drvinfo->regdump_len = atl2_get_regs_len(netdev); diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 965c723..32d1f92 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -6873,10 +6873,10 @@ bnx2_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct bnx2 *bp = netdev_priv(dev); - strcpy(info->driver, DRV_MODULE_NAME); - strcpy(info->version, DRV_MODULE_VERSION); - strcpy(info->bus_info, pci_name(bp->pdev)); - strcpy(info->fw_version, bp->fw_version); + strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); + strlcpy(info->fw_version, bp->fw_version, sizeof(info->fw_version)); } #define BNX2_REGDUMP_LEN (32 * 1024) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index f0ca8b2..f6402fa 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -761,8 +761,8 @@ static void bnx2x_get_drvinfo(struct net_device *dev, struct bnx2x *bp = netdev_priv(dev); u8 phy_fw_ver[PHY_FW_VER_LEN]; - strcpy(info->driver, DRV_MODULE_NAME); - strcpy(info->version, DRV_MODULE_VERSION); + strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); phy_fw_ver[0] = '\0'; if (bp->port.pmf) { @@ -773,14 +773,14 @@ static void bnx2x_get_drvinfo(struct net_device *dev, bnx2x_release_phy_lock(bp); } - strncpy(info->fw_version, bp->fw_ver, 32); + strlcpy(info->fw_version, bp->fw_ver, sizeof(info->fw_version)); snprintf(info->fw_version + strlen(bp->fw_ver), 32 - strlen(bp->fw_ver), "bc %d.%d.%d%s%s", (bp->common.bc_ver & 0xff0000) >> 16, (bp->common.bc_ver & 0xff00) >> 8, (bp->common.bc_ver & 0xff), ((phy_fw_ver[0] != '\0') ? " phy " : ""), phy_fw_ver); - strcpy(info->bus_info, pci_name(bp->pdev)); + strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); info->n_stats = BNX2X_NUM_STATS; info->testinfo_len = BNX2X_NUM_TESTS; info->eedump_len = bp->common.flash_size; diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index bf40741..cd36234 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -10428,10 +10428,10 @@ static void tg3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info { struct tg3 *tp = netdev_priv(dev); - strcpy(info->driver, DRV_MODULE_NAME); - strcpy(info->version, DRV_MODULE_VERSION); - strcpy(info->fw_version, tp->fw_ver); - strcpy(info->bus_info, pci_name(tp->pdev)); + strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); + strlcpy(info->fw_version, tp->fw_ver, sizeof(info->fw_version)); + strlcpy(info->bus_info, pci_name(tp->pdev), sizeof(info->bus_info)); } static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c index fd3dcc1..38d5c66 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c +++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c @@ -296,8 +296,8 @@ bnad_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) struct bfa_ioc_attr *ioc_attr; unsigned long flags; - strcpy(drvinfo->driver, BNAD_NAME); - strcpy(drvinfo->version, BNAD_VERSION); + strlcpy(drvinfo->driver, BNAD_NAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, BNAD_VERSION, sizeof(drvinfo->version)); ioc_attr = kzalloc(sizeof(*ioc_attr), GFP_KERNEL); if (ioc_attr) { @@ -305,12 +305,13 @@ bnad_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) bfa_nw_ioc_get_attr(&bnad->bna.ioceth.ioc, ioc_attr); spin_unlock_irqrestore(&bnad->bna_lock, flags); - strncpy(drvinfo->fw_version, ioc_attr->adapter_attr.fw_ver, - sizeof(drvinfo->fw_version) - 1); + strlcpy(drvinfo->fw_version, ioc_attr->adapter_attr.fw_ver, + sizeof(drvinfo->fw_version)); kfree(ioc_attr); } - strncpy(drvinfo->bus_info, pci_name(bnad->pcidev), ETHTOOL_BUSINFO_LEN); + strlcpy(drvinfo->bus_info, pci_name(bnad->pcidev), + sizeof(drvinfo->bus_info)); } static void diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c index 1427739..1eb46a0 100644 --- a/drivers/net/ethernet/dec/tulip/de2104x.c +++ b/drivers/net/ethernet/dec/tulip/de2104x.c @@ -1598,9 +1598,9 @@ static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) { struct de_private *de = netdev_priv(dev); - strcpy (info->driver, DRV_NAME); - strcpy (info->version, DRV_VERSION); - strcpy (info->bus_info, pci_name(de->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(de->pdev), sizeof(info->bus_info)); info->eedump_len = DE_EEPROM_SIZE; } diff --git a/drivers/net/ethernet/dec/tulip/dmfe.c b/drivers/net/ethernet/dec/tulip/dmfe.c index 17b11ee..51f7542 100644 --- a/drivers/net/ethernet/dec/tulip/dmfe.c +++ b/drivers/net/ethernet/dec/tulip/dmfe.c @@ -1085,10 +1085,11 @@ static void dmfe_ethtool_get_drvinfo(struct net_device *dev, { struct dmfe_board_info *np = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); if (np->pdev) - strcpy(info->bus_info, pci_name(np->pdev)); + strlcpy(info->bus_info, pci_name(np->pdev), + sizeof(info->bus_info)); else sprintf(info->bus_info, "EISA 0x%lx %d", dev->base_addr, dev->irq); diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c index 9656dd0..4eb0d761 100644 --- a/drivers/net/ethernet/dec/tulip/tulip_core.c +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c @@ -871,9 +871,9 @@ static struct net_device_stats *tulip_get_stats(struct net_device *dev) static void tulip_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct tulip_private *np = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(np->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info)); } diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c index 7a44a7a..48b0b65 100644 --- a/drivers/net/ethernet/dec/tulip/uli526x.c +++ b/drivers/net/ethernet/dec/tulip/uli526x.c @@ -960,10 +960,11 @@ static void netdev_get_drvinfo(struct net_device *dev, { struct uli526x_board_info *np = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); if (np->pdev) - strcpy(info->bus_info, pci_name(np->pdev)); + strlcpy(info->bus_info, pci_name(np->pdev), + sizeof(info->bus_info)); else sprintf(info->bus_info, "EISA 0x%lx %d", dev->base_addr, dev->irq); diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c index 4d01219..52da7b2 100644 --- a/drivers/net/ethernet/dec/tulip/winbond-840.c +++ b/drivers/net/ethernet/dec/tulip/winbond-840.c @@ -1390,9 +1390,9 @@ static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo * { struct netdev_private *np = netdev_priv(dev); - strcpy (info->driver, DRV_NAME); - strcpy (info->version, DRV_VERSION); - strcpy (info->bus_info, pci_name(np->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); } static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c index dcd7f7a..28a3a9b 100644 --- a/drivers/net/ethernet/dlink/sundance.c +++ b/drivers/net/ethernet/dlink/sundance.c @@ -1634,9 +1634,9 @@ static int check_if_running(struct net_device *dev) static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct netdev_private *np = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(np->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); } static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c index c1063d1..d94b968 100644 --- a/drivers/net/ethernet/dnet.c +++ b/drivers/net/ethernet/dnet.c @@ -804,9 +804,9 @@ static int dnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static void dnet_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, "0"); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, "0", sizeof(info->bus_info)); } static const struct ethtool_ops dnet_ethtool_ops = { diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c index bf8153e..1ad7a28 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -127,8 +127,8 @@ static void be_get_drvinfo(struct net_device *netdev, memset(fw_on_flash, 0 , sizeof(fw_on_flash)); be_cmd_get_fw_ver(adapter, adapter->fw_ver, fw_on_flash); - strcpy(drvinfo->driver, DRV_NAME); - strcpy(drvinfo->version, DRV_VER); + strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, DRV_VER, sizeof(drvinfo->version)); strncpy(drvinfo->fw_version, adapter->fw_ver, FW_VER_LEN); if (memcmp(adapter->fw_ver, fw_on_flash, FW_VER_LEN) != 0) { strcat(drvinfo->fw_version, " ["); @@ -136,7 +136,8 @@ static void be_get_drvinfo(struct net_device *netdev, strcat(drvinfo->fw_version, "]"); } - strcpy(drvinfo->bus_info, pci_name(adapter->pdev)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->testinfo_len = 0; drvinfo->regdump_len = 0; drvinfo->eedump_len = 0; diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c index 61d2bdd..c82d444 100644 --- a/drivers/net/ethernet/fealnx.c +++ b/drivers/net/ethernet/fealnx.c @@ -1818,9 +1818,9 @@ static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i { struct netdev_private *np = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(np->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); } static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) diff --git a/drivers/net/ethernet/i825xx/eepro.c b/drivers/net/ethernet/i825xx/eepro.c index 067c460..114cda77 100644 --- a/drivers/net/ethernet/i825xx/eepro.c +++ b/drivers/net/ethernet/i825xx/eepro.c @@ -1726,9 +1726,10 @@ static int eepro_ethtool_get_settings(struct net_device *dev, static void eepro_ethtool_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) { - strcpy(drvinfo->driver, DRV_NAME); - strcpy(drvinfo->version, DRV_VERSION); - sprintf(drvinfo->bus_info, "ISA 0x%lx", dev->base_addr); + strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); + snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), + "ISA 0x%lx", dev->base_addr); } static const struct ethtool_ops eepro_ethtool_ops = { diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 194a031..f6b4304 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -1502,10 +1502,11 @@ mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) static void mv643xx_eth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) { - strncpy(drvinfo->driver, mv643xx_eth_driver_name, 32); - strncpy(drvinfo->version, mv643xx_eth_driver_version, 32); - strncpy(drvinfo->fw_version, "N/A", 32); - strncpy(drvinfo->bus_info, "platform", 32); + strlcpy(drvinfo->driver, mv643xx_eth_driver_name, sizeof(info->driver)); + strlcpy(drvinfo->version, mv643xx_eth_driver_version, + sizeof(info->version)); + strlcpy(drvinfo->fw_version, "N/A", sizeof(info->fw_version)); + strlcpy(drvinfo->bus_info, "platform", sizeof(info->bus_info)); drvinfo->n_stats = ARRAY_SIZE(mv643xx_eth_stats); } diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c index c7b6083..3943f5f 100644 --- a/drivers/net/ethernet/marvell/skge.c +++ b/drivers/net/ethernet/marvell/skge.c @@ -394,10 +394,11 @@ static void skge_get_drvinfo(struct net_device *dev, { struct skge_port *skge = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->fw_version, "N/A"); - strcpy(info->bus_info, pci_name(skge->hw->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); + strlcpy(info->bus_info, pci_name(skge->hw->pdev), + sizeof(info->bus_info)); } static const struct skge_stat { diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index fdc6c39..553d1a3 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -3623,10 +3623,11 @@ static void sky2_get_drvinfo(struct net_device *dev, { struct sky2_port *sky2 = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->fw_version, "N/A"); - strcpy(info->bus_info, pci_name(sky2->hw->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); + strlcpy(info->bus_info, pci_name(sky2->hw->pdev), + sizeof(info->bus_info)); } static const struct sky2_stat { diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c index 6ca047a..ac7b16b 100644 --- a/drivers/net/ethernet/natsemi/natsemi.c +++ b/drivers/net/ethernet/natsemi/natsemi.c @@ -2555,9 +2555,9 @@ static void set_rx_mode(struct net_device *dev) static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct netdev_private *np = netdev_priv(dev); - strncpy(info->driver, DRV_NAME, ETHTOOL_BUSINFO_LEN); - strncpy(info->version, DRV_VERSION, ETHTOOL_BUSINFO_LEN); - strncpy(info->bus_info, pci_name(np->pci_dev), ETHTOOL_BUSINFO_LEN); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); } static int get_regs_len(struct net_device *dev) diff --git a/drivers/net/ethernet/natsemi/ns83820.c b/drivers/net/ethernet/natsemi/ns83820.c index 2b8f64d..c24b46c 100644 --- a/drivers/net/ethernet/natsemi/ns83820.c +++ b/drivers/net/ethernet/natsemi/ns83820.c @@ -1364,9 +1364,9 @@ static int ns83820_set_settings(struct net_device *ndev, static void ns83820_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) { struct ns83820 *dev = PRIV(ndev); - strcpy(info->driver, "ns83820"); - strcpy(info->version, VERSION); - strcpy(info->bus_info, pci_name(dev->pci_dev)); + strlcpy(info->driver, "ns83820", sizeof(info->driver)); + strlcpy(info->version, VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(dev->pci_dev), sizeof(info->bus_info)); } static u32 ns83820_get_link(struct net_device *ndev) diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c index c27fb3d..e6c90a5 100644 --- a/drivers/net/ethernet/neterion/s2io.c +++ b/drivers/net/ethernet/neterion/s2io.c @@ -5391,10 +5391,10 @@ static void s2io_ethtool_gdrvinfo(struct net_device *dev, { struct s2io_nic *sp = netdev_priv(dev); - strncpy(info->driver, s2io_driver_name, sizeof(info->driver)); - strncpy(info->version, s2io_driver_version, sizeof(info->version)); - strncpy(info->fw_version, "", sizeof(info->fw_version)); - strncpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info)); + strlcpy(info->driver, s2io_driver_name, sizeof(info->driver)); + strlcpy(info->version, s2io_driver_version, sizeof(info->version)); + strlcpy(info->fw_version, "", sizeof(info->fw_version)); + strlcpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info)); info->regdump_len = XENA_REG_SPACE; info->eedump_len = XENA_EEPROM_SPACE; } diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 1dca570..d24c45b 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -3900,9 +3900,9 @@ static void nv_do_stats_poll(unsigned long data) static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct fe_priv *np = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, FORCEDETH_VERSION); - strcpy(info->bus_info, pci_name(np->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, FORCEDETH_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); } static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c index e09ea83..8a37198 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c @@ -83,14 +83,18 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) u32 fw_minor = 0; u32 fw_build = 0; - strncpy(drvinfo->driver, netxen_nic_driver_name, 32); - strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); + strlcpy(drvinfo->driver, netxen_nic_driver_name, + sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, + sizeof(drvinfo->version)); fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); - sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%d.%d.%d", fw_major, fw_minor, fw_build); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev); } diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c index a4bdff4..9416f29 100644 --- a/drivers/net/ethernet/qlogic/qla3xxx.c +++ b/drivers/net/ethernet/qlogic/qla3xxx.c @@ -1735,10 +1735,12 @@ static void ql_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *drvinfo) { struct ql3_adapter *qdev = netdev_priv(ndev); - strncpy(drvinfo->driver, ql3xxx_driver_name, 32); - strncpy(drvinfo->version, ql3xxx_driver_version, 32); - strncpy(drvinfo->fw_version, "N/A", 32); - strncpy(drvinfo->bus_info, pci_name(qdev->pdev), 32); + strlcpy(drvinfo->driver, ql3xxx_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, ql3xxx_driver_version, + sizeof(drvinfo->version)); + strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(qdev->pdev), + sizeof(drvinfo->bus_info)); drvinfo->regdump_len = 0; drvinfo->eedump_len = 0; } diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 8aa1c6e..cc228cf 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c @@ -140,11 +140,14 @@ qlcnic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); fw_build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB); - sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); - - strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); - strlcpy(drvinfo->driver, qlcnic_driver_name, 32); - strlcpy(drvinfo->version, QLCNIC_LINUX_VERSIONID, 32); + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%d.%d.%d", fw_major, fw_minor, fw_build); + + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); + strlcpy(drvinfo->driver, qlcnic_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, QLCNIC_LINUX_VERSIONID, + sizeof(drvinfo->version)); } static int diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c b/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c index 9b67bfe..8e2c2a7 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c @@ -366,13 +366,16 @@ static void ql_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *drvinfo) { struct ql_adapter *qdev = netdev_priv(ndev); - strncpy(drvinfo->driver, qlge_driver_name, 32); - strncpy(drvinfo->version, qlge_driver_version, 32); - snprintf(drvinfo->fw_version, 32, "v%d.%d.%d", + strlcpy(drvinfo->driver, qlge_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, qlge_driver_version, + sizeof(drvinfo->version)); + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "v%d.%d.%d", (qdev->fw_rev_id & 0x00ff0000) >> 16, (qdev->fw_rev_id & 0x0000ff00) >> 8, (qdev->fw_rev_id & 0x000000ff)); - strncpy(drvinfo->bus_info, pci_name(qdev->pdev), 32); + strlcpy(drvinfo->bus_info, pci_name(qdev->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = 0; drvinfo->testinfo_len = 0; if (!test_bit(QL_FRC_COREDUMP, &qdev->flags)) diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index ee5da92..6cfc5dc 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c @@ -1319,9 +1319,9 @@ static void cp_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info { struct cp_private *cp = netdev_priv(dev); - strcpy (info->driver, DRV_NAME); - strcpy (info->version, DRV_VERSION); - strcpy (info->bus_info, pci_name(cp->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(cp->pdev), sizeof(info->bus_info)); } static void cp_get_ringparam(struct net_device *dev, diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index 4d6b254..d9c7227 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c @@ -2330,9 +2330,9 @@ static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct rtl8139_private *tp = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(tp->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(tp->pci_dev), sizeof(info->bus_info)); info->regdump_len = tp->regs_len; } diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 6f06aa1..cdf66d6 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -1404,12 +1404,12 @@ static void rtl8169_get_drvinfo(struct net_device *dev, struct rtl8169_private *tp = netdev_priv(dev); struct rtl_fw *rtl_fw = tp->rtl_fw; - strcpy(info->driver, MODULENAME); - strcpy(info->version, RTL8169_VERSION); - strcpy(info->bus_info, pci_name(tp->pci_dev)); + strlcpy(info->driver, MODULENAME, sizeof(info->driver)); + strlcpy(info->version, RTL8169_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(tp->pci_dev), sizeof(info->bus_info)); BUILD_BUG_ON(sizeof(info->fw_version) < sizeof(rtl_fw->version)); - strcpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" : - rtl_fw->version); + strlcpy(info->fw_version, IS_ERR_OR_NULL(rtl_fw) ? "N/A" : + rtl_fw->version, sizeof(info->fw_version)); } static int rtl8169_get_regs_len(struct net_device *dev) diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c index 0a5dfb8..2c077ce 100644 --- a/drivers/net/ethernet/smsc/epic100.c +++ b/drivers/net/ethernet/smsc/epic100.c @@ -1414,9 +1414,9 @@ static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo * { struct epic_private *np = netdev_priv(dev); - strcpy (info->driver, DRV_NAME); - strcpy (info->version, DRV_VERSION); - strcpy (info->bus_info, pci_name(np->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); } static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c index edb24b0..a9efbdf 100644 --- a/drivers/net/ethernet/smsc/smsc9420.c +++ b/drivers/net/ethernet/smsc/smsc9420.c @@ -279,9 +279,10 @@ static void smsc9420_ethtool_get_drvinfo(struct net_device *netdev, { struct smsc9420_pdata *pd = netdev_priv(netdev); - strcpy(drvinfo->driver, DRV_NAME); - strcpy(drvinfo->bus_info, pci_name(pd->pdev)); - strcpy(drvinfo->version, DRV_VERSION); + strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->bus_info, pci_name(pd->pdev), + sizeof(drvinfo->bus_info)); + strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); } static u32 smsc9420_ethtool_get_msglevel(struct net_device *netdev) diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c index bbe8b7d..33979c3 100644 --- a/drivers/net/ethernet/xircom/xirc2ps_cs.c +++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c @@ -1411,7 +1411,7 @@ do_open(struct net_device *dev) static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { - strcpy(info->driver, "xirc2ps_cs"); + strlcpy(info->driver, "xirc2ps_cs", sizeof(info->driver)); sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); } -- cgit v0.10.2 From f74024d9f05caa570dcf7582b498bbf011943491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Mon, 7 Nov 2011 14:57:21 +0000 Subject: net: make ipv6 bind honour freebind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes native ipv6 bind follow the precedent set by: - native ipv4 bind behaviour - dual stack ipv4-mapped ipv6 bind behaviour. This does allow an unpriviledged process to spoof its source IPv6 address, just like it currently can spoof its source IPv4 address (for example when using UDP). Signed-off-by: Maciej Å»enczykowski Signed-off-by: David S. Miller diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index d27c797..1040424 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -347,7 +347,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) */ v4addr = LOOPBACK4_IPV6; if (!(addr_type & IPV6_ADDR_MULTICAST)) { - if (!inet->transparent && + if (!(inet->freebind || inet->transparent) && !ipv6_chk_addr(net, &addr->sin6_addr, dev, 0)) { err = -EADDRNOTAVAIL; -- cgit v0.10.2 From 2563fa595447bba6a73e6c58c4bbf11ac0f28931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Mon, 7 Nov 2011 14:57:22 +0000 Subject: net: make ipv6 PKTINFO honour freebind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This just makes it possible to spoof source IPv6 address on a socket without having to create and bind a new socket for every source IP we wish to spoof. Signed-off-by: Maciej Å»enczykowski Signed-off-by: David S. Miller diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index e248069..83037af 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -654,7 +654,7 @@ int datagram_send_ctl(struct net *net, struct sock *sk, if (addr_type != IPV6_ADDR_ANY) { int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL; - if (!inet_sk(sk)->transparent && + if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) && !ipv6_chk_addr(net, &src_info->ipi6_addr, strict ? dev : NULL, 0)) err = -EINVAL; -- cgit v0.10.2 From 8d8bdfe8034399357df58b5f3e4da638a9e9a257 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Mon, 7 Nov 2011 23:47:45 +0000 Subject: ll_temac: Add support for phy_mii_ioctl This patch enables the ioctl support for the driver. So userspace programs like mii-tool can work. Resend in merge window Signed-off-by: Ricardo Ribalda Delgado Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index caf3659..bbfcb59 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -915,12 +915,26 @@ temac_poll_controller(struct net_device *ndev) } #endif +static int temac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) +{ + struct temac_local *lp = netdev_priv(ndev); + + if (!netif_running(ndev)) + return -EINVAL; + + if (!lp->phy_dev) + return -EINVAL; + + return phy_mii_ioctl(lp->phy_dev, rq, cmd); +} + static const struct net_device_ops temac_netdev_ops = { .ndo_open = temac_open, .ndo_stop = temac_stop, .ndo_start_xmit = temac_start_xmit, .ndo_set_mac_address = netdev_set_mac_address, .ndo_validate_addr = eth_validate_addr, + .ndo_do_ioctl = temac_ioctl, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = temac_poll_controller, #endif -- cgit v0.10.2 From 560124095f467c9920c25fa215ab1397dc37d0d6 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 14 Oct 2011 12:54:43 -0700 Subject: iwlagn: update wowlan API The WoWLAN API changed due to netdetect and we now have a more generic "D3 configuration" command that enables the sysassert & rfkill wakeup triggers. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ccba69b..47dbcca 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -2028,6 +2028,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, .tkip = &tkip_cmd, .use_tkip = false, }; + struct iwlagn_d3_config_cmd d3_cfg_cmd = {}; int ret, i; u16 seq; @@ -2085,13 +2086,14 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, if (wowlan->four_way_handshake) wakeup_filter_cmd.enabled |= cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); - if (wowlan->rfkill_release) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_RFKILL); if (wowlan->n_patterns) wakeup_filter_cmd.enabled |= cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); + if (wowlan->rfkill_release) + d3_cfg_cmd.wakeup_flags |= + cpu_to_le32(IWLAGN_D3_WAKEUP_RFKILL); + iwl_scan_cancel_timeout(priv, 200); memcpy(&rxon, &ctx->active, sizeof(rxon)); @@ -2179,6 +2181,11 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, } } + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, + sizeof(d3_cfg_cmd), &d3_cfg_cmd); + if (ret) + goto error; + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, CMD_SYNC, sizeof(wakeup_filter_cmd), &wakeup_filter_cmd); diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 69d5f85..f4eccf5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -198,6 +198,7 @@ enum { REPLY_WOWLAN_TKIP_PARAMS = 0xe3, REPLY_WOWLAN_KEK_KCK_MATERIAL = 0xe4, REPLY_WOWLAN_GET_STATUS = 0xe5, + REPLY_D3_CONFIG = 0xd3, REPLY_MAX = 0xff }; @@ -3801,6 +3802,19 @@ struct iwl_bt_coex_prot_env_cmd { } __attribute__((packed)); /* + * REPLY_D3_CONFIG + */ +enum iwlagn_d3_wakeup_filters { + IWLAGN_D3_WAKEUP_RFKILL = BIT(0), + IWLAGN_D3_WAKEUP_SYSASSERT = BIT(1), +}; + +struct iwlagn_d3_config_cmd { + __le32 min_sleep_time; + __le32 wakeup_flags; +} __packed; + +/* * REPLY_WOWLAN_PATTERNS */ #define IWLAGN_WOWLAN_MIN_PATTERN_LEN 16 @@ -3830,19 +3844,16 @@ enum iwlagn_wowlan_wakeup_filters { IWLAGN_WOWLAN_WAKEUP_BEACON_MISS = BIT(2), IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE = BIT(3), IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL = BIT(4), - IWLAGN_WOWLAN_WAKEUP_RFKILL = BIT(5), - IWLAGN_WOWLAN_WAKEUP_UCODE_ERROR = BIT(6), - IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(7), - IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(8), - IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(9), - IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(10), + IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(5), + IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(6), + IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(7), + IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(8), }; struct iwlagn_wowlan_wakeup_filter_cmd { __le32 enabled; __le16 non_qos_seq; - u8 min_sleep_seconds; - u8 reserved; + __le16 reserved; __le16 qos_seq[8]; }; -- cgit v0.10.2 From 5510697515fad6fe53d1f845ce21a13900339d82 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Fri, 14 Oct 2011 12:54:44 -0700 Subject: iwlagn: remove unnecessary type for tracing operations The device tracing routines only use the priv pointer as an opaque value. Change from a typed iwl_priv pointer to a null pointer and eliminate the need to include iwl_priv.h. CMD_ASYNC is defined in iwl_shared.h which is the only reason it is included. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/iwlwifi/iwl-devtrace.c index a635a7e..2a2c8de 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.c +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.c @@ -28,7 +28,7 @@ /* sparse doesn't like tracepoint macros */ #ifndef __CHECKER__ -#include "iwl-dev.h" +#include "iwl-trans.h" #define CREATE_TRACE_POINTS #include "iwl-devtrace.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h index 8a51c5c..f9d3319 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h @@ -29,7 +29,6 @@ #include -struct iwl_priv; #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__) #undef TRACE_EVENT @@ -37,14 +36,14 @@ struct iwl_priv; static inline void trace_ ## name(proto) {} #endif -#define PRIV_ENTRY __field(struct iwl_priv *, priv) +#define PRIV_ENTRY __field(void *, priv) #define PRIV_ASSIGN __entry->priv = priv #undef TRACE_SYSTEM #define TRACE_SYSTEM iwlwifi_io TRACE_EVENT(iwlwifi_dev_ioread32, - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), + TP_PROTO(void *priv, u32 offs, u32 val), TP_ARGS(priv, offs, val), TP_STRUCT__entry( PRIV_ENTRY @@ -60,7 +59,7 @@ TRACE_EVENT(iwlwifi_dev_ioread32, ); TRACE_EVENT(iwlwifi_dev_iowrite8, - TP_PROTO(struct iwl_priv *priv, u32 offs, u8 val), + TP_PROTO(void *priv, u32 offs, u8 val), TP_ARGS(priv, offs, val), TP_STRUCT__entry( PRIV_ENTRY @@ -76,7 +75,7 @@ TRACE_EVENT(iwlwifi_dev_iowrite8, ); TRACE_EVENT(iwlwifi_dev_iowrite32, - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), + TP_PROTO(void *priv, u32 offs, u32 val), TP_ARGS(priv, offs, val), TP_STRUCT__entry( PRIV_ENTRY @@ -95,7 +94,7 @@ TRACE_EVENT(iwlwifi_dev_iowrite32, #define TRACE_SYSTEM iwlwifi_ucode TRACE_EVENT(iwlwifi_dev_ucode_cont_event, - TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), + TP_PROTO(void *priv, u32 time, u32 data, u32 ev), TP_ARGS(priv, time, data, ev), TP_STRUCT__entry( PRIV_ENTRY @@ -115,7 +114,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_cont_event, ); TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, - TP_PROTO(struct iwl_priv *priv, u32 wraps, u32 n_entry, u32 p_entry), + TP_PROTO(void *priv, u32 wraps, u32 n_entry, u32 p_entry), TP_ARGS(priv, wraps, n_entry, p_entry), TP_STRUCT__entry( PRIV_ENTRY @@ -139,7 +138,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, #define TRACE_SYSTEM iwlwifi TRACE_EVENT(iwlwifi_dev_hcmd, - TP_PROTO(struct iwl_priv *priv, u32 flags, + TP_PROTO(void *priv, u32 flags, const void *hcmd0, size_t len0, const void *hcmd1, size_t len1, const void *hcmd2, size_t len2), @@ -164,7 +163,7 @@ TRACE_EVENT(iwlwifi_dev_hcmd, ); TRACE_EVENT(iwlwifi_dev_rx, - TP_PROTO(struct iwl_priv *priv, void *rxbuf, size_t len), + TP_PROTO(void *priv, void *rxbuf, size_t len), TP_ARGS(priv, rxbuf, len), TP_STRUCT__entry( PRIV_ENTRY @@ -179,7 +178,7 @@ TRACE_EVENT(iwlwifi_dev_rx, ); TRACE_EVENT(iwlwifi_dev_tx, - TP_PROTO(struct iwl_priv *priv, void *tfd, size_t tfdlen, + TP_PROTO(void *priv, void *tfd, size_t tfdlen, void *buf0, size_t buf0_len, void *buf1, size_t buf1_len), TP_ARGS(priv, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len), @@ -211,7 +210,7 @@ TRACE_EVENT(iwlwifi_dev_tx, ); TRACE_EVENT(iwlwifi_dev_ucode_error, - TP_PROTO(struct iwl_priv *priv, u32 desc, u32 tsf_low, + TP_PROTO(void *priv, u32 desc, u32 tsf_low, u32 data1, u32 data2, u32 line, u32 blink1, u32 blink2, u32 ilink1, u32 ilink2, u32 bcon_time, u32 gp1, u32 gp2, u32 gp3, u32 ucode_ver, u32 hw_ver, @@ -271,7 +270,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_error, ); TRACE_EVENT(iwlwifi_dev_ucode_event, - TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), + TP_PROTO(void *priv, u32 time, u32 data, u32 ev), TP_ARGS(priv, time, data, ev), TP_STRUCT__entry( PRIV_ENTRY -- cgit v0.10.2 From 8c3d11617d61c0b69e029fd4087370bc8cb2218d Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 14 Oct 2011 12:54:45 -0700 Subject: iwlwifi: HW rev for 105 and 135 series Set the HW rev. for both 105 and 135 series Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h index b9f3267..fbc3095 100644 --- a/drivers/net/wireless/iwlwifi/iwl-csr.h +++ b/drivers/net/wireless/iwlwifi/iwl-csr.h @@ -284,8 +284,8 @@ #define CSR_HW_REV_TYPE_6x35 CSR_HW_REV_TYPE_6x05 #define CSR_HW_REV_TYPE_2x30 (0x00000C0) #define CSR_HW_REV_TYPE_2x00 (0x0000100) -#define CSR_HW_REV_TYPE_200 (0x0000110) -#define CSR_HW_REV_TYPE_230 (0x0000120) +#define CSR_HW_REV_TYPE_105 (0x0000110) +#define CSR_HW_REV_TYPE_135 (0x0000120) #define CSR_HW_REV_TYPE_NONE (0x00001F0) /* EEPROM REG */ -- cgit v0.10.2 From fa06ec7944897e0b9d10097e8d8b140357af1845 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Fri, 14 Oct 2011 12:54:46 -0700 Subject: iwlagn: simplify iwl_alloc_all The iwl_alloc_all routine is only called once. Delete the argument and print an error in the calling routine if needed. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 47dbcca..9d463cf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -3178,7 +3178,7 @@ static int iwl_set_hw_params(struct iwl_priv *priv) } /* This function both allocates and initializes hw and priv. */ -static struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg) +static struct ieee80211_hw *iwl_alloc_all(void) { struct iwl_priv *priv; /* mac80211 allocates memory for this device instance, including @@ -3186,11 +3186,8 @@ static struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg) struct ieee80211_hw *hw; hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); - if (hw == NULL) { - pr_err("%s: Can not allocate network device\n", - cfg->name); + if (!hw) goto out; - } priv = hw->priv; priv->hw = hw; @@ -3211,8 +3208,9 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /************************ * 1. Allocating HW data ************************/ - hw = iwl_alloc_all(cfg); + hw = iwl_alloc_all(); if (!hw) { + pr_err("%s: Cannot allocate network device\n", cfg->name); err = -ENOMEM; goto out; } -- cgit v0.10.2 From 3a8aea098c8ebe3437d877542d138085be33346c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 14 Oct 2011 12:54:48 -0700 Subject: iwlagn: use 6 Mbps rate for no-CCK scans When userspace requested that a scan not be done with CCK rates, use 6 Mbps. This is used for example for P2P scanning. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index e5d727f..a26fbd3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -678,7 +678,8 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) priv->contexts[IWL_RXON_CTX_BSS].active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; - if (chan_mod == CHANNEL_MODE_PURE_40) { + if ((priv->scan_request && priv->scan_request->no_cck) || + chan_mod == CHANNEL_MODE_PURE_40) { rate = IWL_RATE_6M_PLCP; } else { rate = IWL_RATE_1M_PLCP; -- cgit v0.10.2 From 59034591029e9f3b691fe02ff60938556dba5683 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 16 Oct 2011 10:57:31 +0200 Subject: mac80211: call set_wmm_default only for valid vifs mac80211 calls ieee80211_set_wmm_default (which in turn calls drv_conf_tx()) for every new interface, including "internal" ones (e.g. monitor interface, which the low-level driver doesn't know about). Limit this call only to valid interfaces. Reported-by: Johannes Berg Signed-off-by: Eliad Peller Signed-off-by: John W. Linville diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 30d7355..33a9746 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -286,6 +286,13 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) netif_carrier_off(dev); else netif_carrier_on(dev); + + /* + * set default queue parameters so drivers don't + * need to initialise the hardware if the hardware + * doesn't start up with sane defaults + */ + ieee80211_set_wmm_default(sdata); } set_bit(SDATA_STATE_RUNNING, &sdata->state); @@ -329,15 +336,8 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) if (coming_up) local->open_count++; - if (hw_reconf_flags) { + if (hw_reconf_flags) ieee80211_hw_config(local, hw_reconf_flags); - /* - * set default queue parameters so drivers don't - * need to initialise the hardware if the hardware - * doesn't start up with sane defaults - */ - ieee80211_set_wmm_default(sdata); - } ieee80211_recalc_ps(local, -1); -- cgit v0.10.2 From 48ef5c427ac2cfd12c150b38263d3ebb0d989647 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 17 Oct 2011 10:28:23 +0300 Subject: ath9k_hw: min_t() casts u32 to int The code here treats very large values of "limit" as less than MAX_POWER_RATE because of the cast to int. We should do the compare as u32 instead. Signed-off-by: Dan Carpenter Reviewed-by: Pavel Roskin Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index f16d203..e1dc084 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2579,7 +2579,7 @@ void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test) struct ath9k_channel *chan = ah->curchan; struct ieee80211_channel *channel = chan->chan; - reg->power_limit = min_t(int, limit, MAX_RATE_POWER); + reg->power_limit = min_t(u32, limit, MAX_RATE_POWER); if (test) channel->max_power = MAX_RATE_POWER / 2; -- cgit v0.10.2 From ec3cbb9ce241da90b9d43e49996fae5082c6b6f7 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 18 Oct 2011 09:47:29 +0300 Subject: rndis_wlan: add range check in del_key() Wifi drivers can have up to 6 keys but the rndis_wlan only has 4 so it needs to have its own checks to make sure we don't go out of bounds. The add_key() function already checks but I added some checks to del_key() and set_default_key(). Signed-off-by: Dan Carpenter Acked-by: Jussi Kivilinna Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 0c13840..83f3e52 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -414,6 +414,7 @@ struct ndis_80211_pmkid { #define RNDIS_WLAN_ALG_TKIP (1<<1) #define RNDIS_WLAN_ALG_CCMP (1<<2) +#define RNDIS_WLAN_NUM_KEYS 4 #define RNDIS_WLAN_KEY_MGMT_NONE 0 #define RNDIS_WLAN_KEY_MGMT_802_1X (1<<0) #define RNDIS_WLAN_KEY_MGMT_PSK (1<<1) @@ -516,7 +517,7 @@ struct rndis_wlan_private { /* encryption stuff */ int encr_tx_key_index; - struct rndis_wlan_encr_key encr_keys[4]; + struct rndis_wlan_encr_key encr_keys[RNDIS_WLAN_NUM_KEYS]; int wpa_version; u8 command_buffer[COMMAND_BUFFER_SIZE]; @@ -1535,6 +1536,9 @@ static int remove_key(struct usbnet *usbdev, int index, const u8 *bssid) bool is_wpa; int ret; + if (index >= RNDIS_WLAN_NUM_KEYS) + return -ENOENT; + if (priv->encr_keys[index].len == 0) return 0; @@ -2451,6 +2455,9 @@ static int rndis_set_default_key(struct wiphy *wiphy, struct net_device *netdev, netdev_dbg(usbdev->net, "%s(%i)\n", __func__, key_index); + if (key_index >= RNDIS_WLAN_NUM_KEYS) + return -ENOENT; + priv->encr_tx_key_index = key_index; if (is_wpa_key(priv, key_index)) -- cgit v0.10.2 From 5a5ee76e09b1f5a3a550127aecc2ea4d59f17963 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 18 Oct 2011 09:50:43 +0300 Subject: iwmc3200wifi: add some more range checks My previous patch added a check to get_key() but missed a couple other places which need range checks. The problem here is that wifi drivers have different numbers of keys. The lower levels assume that they can have up to 4 default keys and 2 management keys but this driver only has the default keys so we could go past the end of the ->keys[] array. Signed-off-by: Dan Carpenter Acked-by: Samuel Ortiz Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c index c42be81..48e8218 100644 --- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c +++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c @@ -165,11 +165,15 @@ static int iwm_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, struct key_params *params) { struct iwm_priv *iwm = ndev_to_iwm(ndev); - struct iwm_key *key = &iwm->keys[key_index]; + struct iwm_key *key; int ret; IWM_DBG_WEXT(iwm, DBG, "Adding key for %pM\n", mac_addr); + if (key_index >= IWM_NUM_KEYS) + return -ENOENT; + + key = &iwm->keys[key_index]; memset(key, 0, sizeof(struct iwm_key)); ret = iwm_key_init(key, key_index, mac_addr, params); if (ret < 0) { @@ -214,8 +218,12 @@ static int iwm_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_index, bool pairwise, const u8 *mac_addr) { struct iwm_priv *iwm = ndev_to_iwm(ndev); - struct iwm_key *key = &iwm->keys[key_index]; + struct iwm_key *key; + if (key_index >= IWM_NUM_KEYS) + return -ENOENT; + + key = &iwm->keys[key_index]; if (!iwm->keys[key_index].key_len) { IWM_DBG_WEXT(iwm, DBG, "Key %d not used\n", key_index); return 0; @@ -236,6 +244,9 @@ static int iwm_cfg80211_set_default_key(struct wiphy *wiphy, IWM_DBG_WEXT(iwm, DBG, "Default key index is: %d\n", key_index); + if (key_index >= IWM_NUM_KEYS) + return -ENOENT; + if (!iwm->keys[key_index].key_len) { IWM_ERR(iwm, "Key %d not used\n", key_index); return -EINVAL; -- cgit v0.10.2 From ef5af74707e1921f9462e2cfeb336a21af6ae902 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 18 Oct 2011 13:39:14 +0200 Subject: mac80211: fix confusing parentheses There's an extra pair of parentheses here that is simply confusing because it implies a nesting that doesn't actually exist. Just remove it. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index ebd7fb1..000a8ba 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1394,7 +1394,7 @@ static int ieee80211_set_channel(struct wiphy *wiphy, (old_oper_type != local->_oper_channel_type)) ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); - if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) && + if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR && old_vif_oper_type != sdata->vif.bss_conf.channel_type) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); -- cgit v0.10.2 From 73ffc2fcd53a041fdee1bade5ae471ce704be26d Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 18 Oct 2011 14:02:57 +0200 Subject: brcm80211: cleanup defines in main.c Signed-off-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 510e9bb..77261ea 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -35,39 +35,25 @@ * Indication for txflowcontrol that all priority bits in * TXQ_STOP_FOR_PRIOFC_MASK are to be considered. */ -#define ALLPRIO -1 - -/* - * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. - */ -#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) +#define ALLPRIO -1 /* watchdog timer, in unit of ms */ -#define TIMER_INTERVAL_WATCHDOG 1000 +#define TIMER_INTERVAL_WATCHDOG 1000 /* radio monitor timer, in unit of ms */ -#define TIMER_INTERVAL_RADIOCHK 800 +#define TIMER_INTERVAL_RADIOCHK 800 /* Max MPC timeout, in unit of watchdog */ #ifndef BRCMS_MPC_MAX_DELAYCNT -#define BRCMS_MPC_MAX_DELAYCNT 10 +#define BRCMS_MPC_MAX_DELAYCNT 10 #endif /* Min MPC timeout, in unit of watchdog */ -#define BRCMS_MPC_MIN_DELAYCNT 1 -#define BRCMS_MPC_THRESHOLD 3 /* MPC count threshold level */ +#define BRCMS_MPC_MIN_DELAYCNT 1 +/* MPC count threshold level */ +#define BRCMS_MPC_THRESHOLD 3 /* beacon interval, in unit of 1024TU */ -#define BEACON_INTERVAL_DEFAULT 100 -/* DTIM interval, in unit of beacon interval */ -#define DTIM_INTERVAL_DEFAULT 3 - -/* Scale down delays to accommodate QT slow speed */ -/* beacon interval, in unit of 1024TU */ -#define BEACON_INTERVAL_DEF_QT 20 -/* DTIM interval, in unit of beacon interval */ -#define DTIM_INTERVAL_DEF_QT 1 - -#define TBTT_ALIGN_LEEWAY_US 100 /* min leeway before first TBTT in us */ +#define BEACON_INTERVAL_DEFAULT 100 /* n-mode support capability */ /* 2x2 includes both 1x1 & 2x2 devices @@ -78,113 +64,76 @@ #define WL_11N_3x3 3 #define WL_11N_4x4 4 -/* define 11n feature disable flags */ -#define WLFEATURE_DISABLE_11N 0x00000001 -#define WLFEATURE_DISABLE_11N_STBC_TX 0x00000002 -#define WLFEATURE_DISABLE_11N_STBC_RX 0x00000004 -#define WLFEATURE_DISABLE_11N_SGI_TX 0x00000008 -#define WLFEATURE_DISABLE_11N_SGI_RX 0x00000010 -#define WLFEATURE_DISABLE_11N_AMPDU_TX 0x00000020 -#define WLFEATURE_DISABLE_11N_AMPDU_RX 0x00000040 -#define WLFEATURE_DISABLE_11N_GF 0x00000080 - -#define EDCF_ACI_MASK 0x60 -#define EDCF_ACI_SHIFT 5 -#define EDCF_ECWMIN_MASK 0x0f -#define EDCF_ECWMAX_SHIFT 4 -#define EDCF_AIFSN_MASK 0x0f -#define EDCF_AIFSN_MAX 15 -#define EDCF_ECWMAX_MASK 0xf0 - -#define EDCF_AC_BE_TXOP_STA 0x0000 -#define EDCF_AC_BK_TXOP_STA 0x0000 -#define EDCF_AC_VO_ACI_STA 0x62 -#define EDCF_AC_VO_ECW_STA 0x32 -#define EDCF_AC_VI_ACI_STA 0x42 -#define EDCF_AC_VI_ECW_STA 0x43 -#define EDCF_AC_BK_ECW_STA 0xA4 -#define EDCF_AC_VI_TXOP_STA 0x005e -#define EDCF_AC_VO_TXOP_STA 0x002f -#define EDCF_AC_BE_ACI_STA 0x03 -#define EDCF_AC_BE_ECW_STA 0xA4 -#define EDCF_AC_BK_ACI_STA 0x27 -#define EDCF_AC_VO_TXOP_AP 0x002f - -#define EDCF_TXOP2USEC(txop) ((txop) << 5) -#define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) - -#define APHY_SYMBOL_TIME 4 -#define APHY_PREAMBLE_TIME 16 -#define APHY_SIGNAL_TIME 4 -#define APHY_SIFS_TIME 16 -#define APHY_SERVICE_NBITS 16 -#define APHY_TAIL_NBITS 6 -#define BPHY_SIFS_TIME 10 -#define BPHY_PLCP_SHORT_TIME 96 - -#define PREN_PREAMBLE 24 -#define PREN_MM_EXT 12 -#define PREN_PREAMBLE_EXT 4 +#define EDCF_ACI_MASK 0x60 +#define EDCF_ACI_SHIFT 5 +#define EDCF_ECWMIN_MASK 0x0f +#define EDCF_ECWMAX_SHIFT 4 +#define EDCF_AIFSN_MASK 0x0f +#define EDCF_AIFSN_MAX 15 +#define EDCF_ECWMAX_MASK 0xf0 + +#define EDCF_AC_BE_TXOP_STA 0x0000 +#define EDCF_AC_BK_TXOP_STA 0x0000 +#define EDCF_AC_VO_ACI_STA 0x62 +#define EDCF_AC_VO_ECW_STA 0x32 +#define EDCF_AC_VI_ACI_STA 0x42 +#define EDCF_AC_VI_ECW_STA 0x43 +#define EDCF_AC_BK_ECW_STA 0xA4 +#define EDCF_AC_VI_TXOP_STA 0x005e +#define EDCF_AC_VO_TXOP_STA 0x002f +#define EDCF_AC_BE_ACI_STA 0x03 +#define EDCF_AC_BE_ECW_STA 0xA4 +#define EDCF_AC_BK_ACI_STA 0x27 +#define EDCF_AC_VO_TXOP_AP 0x002f + +#define EDCF_TXOP2USEC(txop) ((txop) << 5) +#define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) + +#define APHY_SYMBOL_TIME 4 +#define APHY_PREAMBLE_TIME 16 +#define APHY_SIGNAL_TIME 4 +#define APHY_SIFS_TIME 16 +#define APHY_SERVICE_NBITS 16 +#define APHY_TAIL_NBITS 6 +#define BPHY_SIFS_TIME 10 +#define BPHY_PLCP_SHORT_TIME 96 + +#define PREN_PREAMBLE 24 +#define PREN_MM_EXT 12 +#define PREN_PREAMBLE_EXT 4 #define DOT11_MAC_HDR_LEN 24 -#define DOT11_ACK_LEN 10 -#define DOT11_BA_LEN 4 +#define DOT11_ACK_LEN 10 +#define DOT11_BA_LEN 4 #define DOT11_OFDM_SIGNAL_EXTENSION 6 #define DOT11_MIN_FRAG_LEN 256 -#define DOT11_RTS_LEN 16 -#define DOT11_CTS_LEN 10 +#define DOT11_RTS_LEN 16 +#define DOT11_CTS_LEN 10 #define DOT11_BA_BITMAP_LEN 128 #define DOT11_MIN_BEACON_PERIOD 1 #define DOT11_MAX_BEACON_PERIOD 0xFFFF -#define DOT11_MAXNUMFRAGS 16 +#define DOT11_MAXNUMFRAGS 16 #define DOT11_MAX_FRAG_LEN 2346 -#define BPHY_PLCP_TIME 192 -#define RIFS_11N_TIME 2 - -#define WME_VER 1 -#define WME_SUBTYPE_PARAM_IE 1 -#define WME_TYPE 2 -#define WME_OUI "\x00\x50\xf2" +#define BPHY_PLCP_TIME 192 +#define RIFS_11N_TIME 2 -#define AC_BE 0 -#define AC_BK 1 -#define AC_VI 2 -#define AC_VO 3 +#define AC_BE 0 +#define AC_BK 1 +#define AC_VI 2 +#define AC_VO 3 -#define BCN_TMPL_LEN 512 /* length of the BCN template area */ +/* length of the BCN template area */ +#define BCN_TMPL_LEN 512 /* brcms_bss_info flag bit values */ -#define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ +#define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ -/* Flags used in brcms_c_txq_info.stopped */ -/* per prio flow control bits */ -#define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF -/* stop txq enqueue for packet drain */ -#define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 -/* stop txq enqueue for ampdu flow control */ -#define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 - -#define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ - -/* Find basic rate for a given rate */ -static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) -{ - if (is_mcs_rate(rspec)) - return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] - .leg_ofdm]; - return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; -} - -static u16 frametype(u32 rspec, u8 mimoframe) -{ - if (is_mcs_rate(rspec)) - return mimoframe; - return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; -} +/* chip rx buffer offset */ +#define BRCMS_HWRXOFF 38 /* rfdisable delay timer 500 ms, runs of ALP clock */ -#define RFDISABLE_DEFAULT 10000000 +#define RFDISABLE_DEFAULT 10000000 #define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ @@ -194,87 +143,83 @@ static u16 frametype(u32 rspec, u8 mimoframe) * These constants are used ONLY by wlc_prio2prec_map. Do not use them * elsewhere. */ -#define _BRCMS_PREC_NONE 0 /* None = - */ -#define _BRCMS_PREC_BK 2 /* BK - Background */ -#define _BRCMS_PREC_BE 4 /* BE - Best-effort */ -#define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */ -#define _BRCMS_PREC_CL 8 /* CL - Controlled Load */ -#define _BRCMS_PREC_VI 10 /* Vi - Video */ -#define _BRCMS_PREC_VO 12 /* Vo - Voice */ -#define _BRCMS_PREC_NC 14 /* NC - Network Control */ - -/* The BSS is generating beacons in HW */ -#define BRCMS_BSSCFG_HW_BCN 0x20 - -#define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ -#define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us */ -#define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us */ -#define SYNTHPU_DLY_LPPHY_US 300 /* lpphy synthpu_dly time in us */ - -#define SYNTHPU_DLY_PHY_US_QT 100 /* QT synthpu_dly time in us */ - -#define ANTCNT 10 /* vanilla M_MAX_ANTCNT value */ +#define _BRCMS_PREC_NONE 0 /* None = - */ +#define _BRCMS_PREC_BK 2 /* BK - Background */ +#define _BRCMS_PREC_BE 4 /* BE - Best-effort */ +#define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */ +#define _BRCMS_PREC_CL 8 /* CL - Controlled Load */ +#define _BRCMS_PREC_VI 10 /* Vi - Video */ +#define _BRCMS_PREC_VO 12 /* Vo - Voice */ +#define _BRCMS_PREC_NC 14 /* NC - Network Control */ + +/* synthpu_dly times in us */ +#define SYNTHPU_DLY_APHY_US 3700 +#define SYNTHPU_DLY_BPHY_US 1050 +#define SYNTHPU_DLY_NPHY_US 2048 +#define SYNTHPU_DLY_LPPHY_US 300 + +#define ANTCNT 10 /* vanilla M_MAX_ANTCNT val */ /* Per-AC retry limit register definitions; uses defs.h bitfield macros */ -#define EDCF_SHORT_S 0 -#define EDCF_SFB_S 4 -#define EDCF_LONG_S 8 -#define EDCF_LFB_S 12 -#define EDCF_SHORT_M BITFIELD_MASK(4) -#define EDCF_SFB_M BITFIELD_MASK(4) -#define EDCF_LONG_M BITFIELD_MASK(4) -#define EDCF_LFB_M BITFIELD_MASK(4) +#define EDCF_SHORT_S 0 +#define EDCF_SFB_S 4 +#define EDCF_LONG_S 8 +#define EDCF_LFB_S 12 +#define EDCF_SHORT_M BITFIELD_MASK(4) +#define EDCF_SFB_M BITFIELD_MASK(4) +#define EDCF_LONG_M BITFIELD_MASK(4) +#define EDCF_LFB_M BITFIELD_MASK(4) -#define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ -#define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ -#define RETRY_LONG_DEF 4 /* Default Long retry count */ -#define RETRY_SHORT_FB 3 /* Short count for fallback rate */ -#define RETRY_LONG_FB 2 /* Long count for fallback rate */ +#define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ +#define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ +#define RETRY_LONG_DEF 4 /* Default Long retry count */ +#define RETRY_SHORT_FB 3 /* Short count for fb rate */ +#define RETRY_LONG_FB 2 /* Long count for fb rate */ -#define APHY_CWMIN 15 -#define PHY_CWMAX 1023 +#define APHY_CWMIN 15 +#define PHY_CWMAX 1023 -#define EDCF_AIFSN_MIN 1 +#define EDCF_AIFSN_MIN 1 -#define FRAGNUM_MASK 0xF +#define FRAGNUM_MASK 0xF -#define APHY_SLOT_TIME 9 -#define BPHY_SLOT_TIME 20 +#define APHY_SLOT_TIME 9 +#define BPHY_SLOT_TIME 20 -#define WL_SPURAVOID_OFF 0 -#define WL_SPURAVOID_ON1 1 -#define WL_SPURAVOID_ON2 2 +#define WL_SPURAVOID_OFF 0 +#define WL_SPURAVOID_ON1 1 +#define WL_SPURAVOID_ON2 2 /* invalid core flags, use the saved coreflags */ -#define BRCMS_USE_COREFLAGS 0xffffffff +#define BRCMS_USE_COREFLAGS 0xffffffff /* values for PLCPHdr_override */ -#define BRCMS_PLCP_AUTO -1 -#define BRCMS_PLCP_SHORT 0 -#define BRCMS_PLCP_LONG 1 +#define BRCMS_PLCP_AUTO -1 +#define BRCMS_PLCP_SHORT 0 +#define BRCMS_PLCP_LONG 1 /* values for g_protection_override and n_protection_override */ #define BRCMS_PROTECTION_AUTO -1 #define BRCMS_PROTECTION_OFF 0 #define BRCMS_PROTECTION_ON 1 #define BRCMS_PROTECTION_MMHDR_ONLY 2 -#define BRCMS_PROTECTION_CTS_ONLY 3 +#define BRCMS_PROTECTION_CTS_ONLY 3 /* values for g_protection_control and n_protection_control */ -#define BRCMS_PROTECTION_CTL_OFF 0 +#define BRCMS_PROTECTION_CTL_OFF 0 #define BRCMS_PROTECTION_CTL_LOCAL 1 #define BRCMS_PROTECTION_CTL_OVERLAP 2 /* values for n_protection */ #define BRCMS_N_PROTECTION_OFF 0 #define BRCMS_N_PROTECTION_OPTIONAL 1 -#define BRCMS_N_PROTECTION_20IN40 2 +#define BRCMS_N_PROTECTION_20IN40 2 #define BRCMS_N_PROTECTION_MIXEDMODE 3 /* values for band specific 40MHz capabilities */ -#define BRCMS_N_BW_20ALL 0 -#define BRCMS_N_BW_40ALL 1 -#define BRCMS_N_BW_20IN2G_40IN5G 2 +#define BRCMS_N_BW_20ALL 0 +#define BRCMS_N_BW_40ALL 1 +#define BRCMS_N_BW_20IN2G_40IN5G 2 /* bitflags for SGI support (sgi_rx iovar) */ #define BRCMS_N_SGI_20 0x01 @@ -282,48 +227,42 @@ static u16 frametype(u32 rspec, u8 mimoframe) /* defines used by the nrate iovar */ /* MSC in use,indicates b0-6 holds an mcs */ -#define NRATE_MCS_INUSE 0x00000080 +#define NRATE_MCS_INUSE 0x00000080 /* rate/mcs value */ -#define NRATE_RATE_MASK 0x0000007f +#define NRATE_RATE_MASK 0x0000007f /* stf mode mask: siso, cdd, stbc, sdm */ -#define NRATE_STF_MASK 0x0000ff00 +#define NRATE_STF_MASK 0x0000ff00 /* stf mode shift */ -#define NRATE_STF_SHIFT 8 -/* bit indicates override both rate & mode */ -#define NRATE_OVERRIDE 0x80000000 +#define NRATE_STF_SHIFT 8 /* bit indicate to override mcs only */ -#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 -#define NRATE_SGI_MASK 0x00800000 /* sgi mode */ -#define NRATE_SGI_SHIFT 23 /* sgi mode */ -#define NRATE_LDPC_CODING 0x00400000 /* bit indicates adv coding in use */ -#define NRATE_LDPC_SHIFT 22 /* ldpc shift */ +#define NRATE_OVERRIDE_MCS_ONLY 0x40000000 +#define NRATE_SGI_MASK 0x00800000 /* sgi mode */ +#define NRATE_SGI_SHIFT 23 /* sgi mode */ +#define NRATE_LDPC_CODING 0x00400000 /* adv coding in use */ +#define NRATE_LDPC_SHIFT 22 /* ldpc shift */ -#define NRATE_STF_SISO 0 /* stf mode SISO */ -#define NRATE_STF_CDD 1 /* stf mode CDD */ -#define NRATE_STF_STBC 2 /* stf mode STBC */ -#define NRATE_STF_SDM 3 /* stf mode SDM */ +#define NRATE_STF_SISO 0 /* stf mode SISO */ +#define NRATE_STF_CDD 1 /* stf mode CDD */ +#define NRATE_STF_STBC 2 /* stf mode STBC */ +#define NRATE_STF_SDM 3 /* stf mode SDM */ -#define MAX_DMA_SEGS 4 +#define MAX_DMA_SEGS 4 /* Max # of entries in Tx FIFO based on 4kb page size */ -#define NTXD 256 +#define NTXD 256 /* Max # of entries in Rx FIFO based on 4kb page size */ -#define NRXD 256 +#define NRXD 256 /* try to keep this # rbufs posted to the chip */ -#define NRXBUFPOST 32 +#define NRXBUFPOST 32 /* data msg txq hiwat mark */ -#define BRCMS_DATAHIWAT 50 +#define BRCMS_DATAHIWAT 50 -/* bounded rx loops */ -#define RXBND 8 /* max # frames to process in brcms_c_recv() */ -#define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ - -/* - * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. - */ -#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) +/* max # frames to process in brcms_c_recv() */ +#define RXBND 8 +/* max # tx status to process in wlc_txstatus() */ +#define TXSBND 8 /* brcmu_format_flags() bit description structure */ struct brcms_c_bit_desc { @@ -405,13 +344,6 @@ static const u16 xmtfifo_sz[][NFIFO] = { {9, 58, 22, 14, 14, 5}, }; -static const u8 acbitmap2maxprio[] = { - PRIO_8021D_BE, PRIO_8021D_BE, PRIO_8021D_BK, PRIO_8021D_BK, - PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO -}; - #ifdef BCMDBG static const char * const fifo_names[] = { "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; @@ -424,6 +356,22 @@ static const char fifo_names[6][0]; static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); #endif +/* Find basic rate for a given rate */ +static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) +{ + if (is_mcs_rate(rspec)) + return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] + .leg_ofdm]; + return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; +} + +static u16 frametype(u32 rspec, u8 mimoframe) +{ + if (is_mcs_rate(rspec)) + return mimoframe; + return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; +} + /* currently the best mechanism for determining SIFS is the band in use */ static u16 get_sifs(struct brcms_band *band) { -- cgit v0.10.2 From 230382140e043903aa1138bb7ca095d7d23fd164 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 18 Oct 2011 14:02:58 +0200 Subject: brcm80211: removed duplicate defines Removed defines from aiutils.h also present in soc.h. Reported-by: Hauke Mehrtens Reviewed-by: Arend van Spriel Signed-off-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 106a742..b51d1e4 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -38,88 +38,12 @@ /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ #define SI_PCIE_DMA_H32 0x80000000 -/* core codes */ -#define NODEV_CORE_ID 0x700 /* Invalid coreid */ -#define CC_CORE_ID 0x800 /* chipcommon core */ -#define ILINE20_CORE_ID 0x801 /* iline20 core */ -#define SRAM_CORE_ID 0x802 /* sram core */ -#define SDRAM_CORE_ID 0x803 /* sdram core */ -#define PCI_CORE_ID 0x804 /* pci core */ -#define MIPS_CORE_ID 0x805 /* mips core */ -#define ENET_CORE_ID 0x806 /* enet mac core */ -#define CODEC_CORE_ID 0x807 /* v90 codec core */ -#define USB_CORE_ID 0x808 /* usb 1.1 host/device core */ -#define ADSL_CORE_ID 0x809 /* ADSL core */ -#define ILINE100_CORE_ID 0x80a /* iline100 core */ -#define IPSEC_CORE_ID 0x80b /* ipsec core */ -#define UTOPIA_CORE_ID 0x80c /* utopia core */ -#define PCMCIA_CORE_ID 0x80d /* pcmcia core */ -#define SOCRAM_CORE_ID 0x80e /* internal memory core */ -#define MEMC_CORE_ID 0x80f /* memc sdram core */ -#define OFDM_CORE_ID 0x810 /* OFDM phy core */ -#define EXTIF_CORE_ID 0x811 /* external interface core */ -#define D11_CORE_ID 0x812 /* 802.11 MAC core */ -#define APHY_CORE_ID 0x813 /* 802.11a phy core */ -#define BPHY_CORE_ID 0x814 /* 802.11b phy core */ -#define GPHY_CORE_ID 0x815 /* 802.11g phy core */ -#define MIPS33_CORE_ID 0x816 /* mips3302 core */ -#define USB11H_CORE_ID 0x817 /* usb 1.1 host core */ -#define USB11D_CORE_ID 0x818 /* usb 1.1 device core */ -#define USB20H_CORE_ID 0x819 /* usb 2.0 host core */ -#define USB20D_CORE_ID 0x81a /* usb 2.0 device core */ -#define SDIOH_CORE_ID 0x81b /* sdio host core */ -#define ROBO_CORE_ID 0x81c /* roboswitch core */ -#define ATA100_CORE_ID 0x81d /* parallel ATA core */ -#define SATAXOR_CORE_ID 0x81e /* serial ATA & XOR DMA core */ -#define GIGETH_CORE_ID 0x81f /* gigabit ethernet core */ -#define PCIE_CORE_ID 0x820 /* pci express core */ -#define NPHY_CORE_ID 0x821 /* 802.11n 2x2 phy core */ -#define SRAMC_CORE_ID 0x822 /* SRAM controller core */ -#define MINIMAC_CORE_ID 0x823 /* MINI MAC/phy core */ -#define ARM11_CORE_ID 0x824 /* ARM 1176 core */ -#define ARM7S_CORE_ID 0x825 /* ARM7tdmi-s core */ -#define LPPHY_CORE_ID 0x826 /* 802.11a/b/g phy core */ -#define PMU_CORE_ID 0x827 /* PMU core */ -#define SSNPHY_CORE_ID 0x828 /* 802.11n single-stream phy core */ -#define SDIOD_CORE_ID 0x829 /* SDIO device core */ -#define ARMCM3_CORE_ID 0x82a /* ARM Cortex M3 core */ -#define HTPHY_CORE_ID 0x82b /* 802.11n 4x4 phy core */ -#define MIPS74K_CORE_ID 0x82c /* mips 74k core */ -#define GMAC_CORE_ID 0x82d /* Gigabit MAC core */ -#define DMEMC_CORE_ID 0x82e /* DDR1/2 memory controller core */ -#define PCIERC_CORE_ID 0x82f /* PCIE Root Complex core */ -#define OCP_CORE_ID 0x830 /* OCP2OCP bridge core */ -#define SC_CORE_ID 0x831 /* shared common core */ -#define AHB_CORE_ID 0x832 /* OCP2AHB bridge core */ -#define SPIH_CORE_ID 0x833 /* SPI host core */ -#define I2S_CORE_ID 0x834 /* I2S core */ -#define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ -#define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ -#define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ -#define DEF_AI_COMP 0xfff /* Default component, in ai chips it - * maps all unused address ranges - */ - /* chipcommon being the first core: */ #define SI_CC_IDX 0 /* SOC Interconnect types (aka chip types) */ #define SOCI_AI 1 -/* Common core control flags */ -#define SICF_BIST_EN 0x8000 -#define SICF_PME_EN 0x4000 -#define SICF_CORE_BITS 0x3ffc -#define SICF_FGC 0x0002 -#define SICF_CLOCK_EN 0x0001 - -/* Common core status flags */ -#define SISF_BIST_DONE 0x8000 -#define SISF_BIST_ERROR 0x4000 -#define SISF_GATED_CLK 0x2000 -#define SISF_DMA64 0x1000 -#define SISF_CORE_BITS 0x0fff - /* A register that is common to all cores to * communicate w/PMU regarding clock control. */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index b56a302..08960ce 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -22,6 +22,7 @@ #include #include "types.h" #include "dma.h" +#include "soc.h" /* * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 77261ea..84f32b6 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -30,6 +30,7 @@ #include "mac80211_if.h" #include "ucode_loader.h" #include "main.h" +#include "soc.h" /* * Indication for txflowcontrol that all priority bits in diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index cd19c2f..db612f8 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -29,6 +29,7 @@ #include "phy_radio.h" #include "phyreg_n.h" #include "phytbl_n.h" +#include "soc.h" #define READ_RADIO_REG2(pi, radio_type, jspace, core, reg_name) \ read_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c index 3b36e3a..12ba575 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c @@ -23,6 +23,7 @@ #include "pub.h" #include "aiutils.h" #include "pmu.h" +#include "soc.h" /* * external LPO crystal frequency diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 99f7910..b52b0d2 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -28,6 +28,7 @@ #include "aiutils.h" #include "otp.h" #include "srom.h" +#include "soc.h" /* * SROM CRC8 polynomial value: diff --git a/drivers/net/wireless/brcm80211/include/soc.h b/drivers/net/wireless/brcm80211/include/soc.h index 4fcb956..4e9b7e4 100644 --- a/drivers/net/wireless/brcm80211/include/soc.h +++ b/drivers/net/wireless/brcm80211/include/soc.h @@ -77,8 +77,9 @@ #define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ #define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ #define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ -/* Default component, in ai chips it maps all unused address ranges */ -#define DEF_AI_COMP 0xfff +#define DEF_AI_COMP 0xfff /* Default component, in ai chips it + * maps all unused address ranges + */ /* Common core control flags */ #define SICF_BIST_EN 0x8000 @@ -87,4 +88,11 @@ #define SICF_FGC 0x0002 #define SICF_CLOCK_EN 0x0001 +/* Common core status flags */ +#define SISF_BIST_DONE 0x8000 +#define SISF_BIST_ERROR 0x4000 +#define SISF_GATED_CLK 0x2000 +#define SISF_DMA64 0x1000 +#define SISF_CORE_BITS 0x0fff + #endif /* _BRCM_SOC_H */ -- cgit v0.10.2 From 6b1a89afbf97f40797255b9543d441ce361dbb52 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 18 Oct 2011 14:02:59 +0200 Subject: brcm80211: smac: drop "40MHz intolerant" flag from HT capability info The brcmsmac driver registered with mac80211 with HT capability info set to 40MHz intolerant. This cause any other station on the channel to be forced to use 20MHz. This flag has been removed. Reported-by: Johannes Berg Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index ac8d02b..538b504 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -215,8 +215,7 @@ static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = { .ht_cap = { /* from include/linux/ieee80211.h */ .cap = IEEE80211_HT_CAP_GRN_FLD | - IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, + IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40, .ht_supported = true, .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, .ampdu_density = AMPDU_DEF_MPDU_DENSITY, @@ -237,8 +236,7 @@ static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = { BRCMS_LEGACY_5G_RATE_OFFSET, .ht_cap = { .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | - IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ + IEEE80211_HT_CAP_SGI_40, .ht_supported = true, .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, .ampdu_density = AMPDU_DEF_MPDU_DENSITY, -- cgit v0.10.2 From 3b64bd3e4d0ae667062893a6ef30326f7103144e Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 18 Oct 2011 14:03:00 +0200 Subject: brcm80211: smac: removed support for SROM rev < 8 Supported chips contain SROM rev 8 and upwards. Reported-by: Hauke Mehrtens Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index b52b0d2..a884fe0 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -63,9 +63,6 @@ #define SROM_MACHI_ET1 42 #define SROM_MACMID_ET1 43 #define SROM_MACLO_ET1 44 -#define SROM3_MACHI 37 -#define SROM3_MACMID 38 -#define SROM3_MACLO 39 #define SROM_BXARSSI2G 40 #define SROM_BXARSSI5G 41 @@ -102,7 +99,6 @@ #define SROM_BFL 57 #define SROM_BFL2 28 -#define SROM3_BFL2 61 #define SROM_AG10 58 @@ -110,99 +106,16 @@ #define SROM_OPO 60 -#define SROM3_LEDDC 62 - #define SROM_CRCREV 63 -/* SROM Rev 4: Reallocate the software part of the srom to accommodate - * MIMO features. It assumes up to two PCIE functions and 440 bytes - * of usable srom i.e. the usable storage in chips with OTP that - * implements hardware redundancy. - */ - #define SROM4_WORDS 220 -#define SROM4_SIGN 32 -#define SROM4_SIGNATURE 0x5372 - -#define SROM4_BREV 33 - -#define SROM4_BFL0 34 -#define SROM4_BFL1 35 -#define SROM4_BFL2 36 -#define SROM4_BFL3 37 -#define SROM5_BFL0 37 -#define SROM5_BFL1 38 -#define SROM5_BFL2 39 -#define SROM5_BFL3 40 - -#define SROM4_MACHI 38 -#define SROM4_MACMID 39 -#define SROM4_MACLO 40 -#define SROM5_MACHI 41 -#define SROM5_MACMID 42 -#define SROM5_MACLO 43 - -#define SROM4_CCODE 41 -#define SROM4_REGREV 42 -#define SROM5_CCODE 34 -#define SROM5_REGREV 35 - -#define SROM4_LEDBH10 43 -#define SROM4_LEDBH32 44 -#define SROM5_LEDBH10 59 -#define SROM5_LEDBH32 60 - -#define SROM4_LEDDC 45 -#define SROM5_LEDDC 45 - -#define SROM4_AA 46 - -#define SROM4_AG10 47 -#define SROM4_AG32 48 - -#define SROM4_TXPID2G 49 -#define SROM4_TXPID5G 51 -#define SROM4_TXPID5GL 53 -#define SROM4_TXPID5GH 55 - -#define SROM4_TXRXC 61 #define SROM4_TXCHAIN_MASK 0x000f -#define SROM4_TXCHAIN_SHIFT 0 #define SROM4_RXCHAIN_MASK 0x00f0 -#define SROM4_RXCHAIN_SHIFT 4 #define SROM4_SWITCH_MASK 0xff00 -#define SROM4_SWITCH_SHIFT 8 /* Per-path fields */ #define MAX_PATH_SROM 4 -#define SROM4_PATH0 64 -#define SROM4_PATH1 87 -#define SROM4_PATH2 110 -#define SROM4_PATH3 133 - -#define SROM4_2G_ITT_MAXP 0 -#define SROM4_2G_PA 1 -#define SROM4_5G_ITT_MAXP 5 -#define SROM4_5GLH_MAXP 6 -#define SROM4_5G_PA 7 -#define SROM4_5GL_PA 11 -#define SROM4_5GH_PA 15 - -/* All the miriad power offsets */ -#define SROM4_2G_CCKPO 156 -#define SROM4_2G_OFDMPO 157 -#define SROM4_5G_OFDMPO 159 -#define SROM4_5GL_OFDMPO 161 -#define SROM4_5GH_OFDMPO 163 -#define SROM4_2G_MCSPO 165 -#define SROM4_5G_MCSPO 173 -#define SROM4_5GL_MCSPO 181 -#define SROM4_5GH_MCSPO 189 -#define SROM4_CDDPO 197 -#define SROM4_STBCPO 198 -#define SROM4_BW40PO 199 -#define SROM4_BWDUPPO 200 #define SROM4_CRCREV 219 @@ -425,103 +338,32 @@ struct brcms_varbuf { static const struct brcms_sromvar pci_sromvars[] = { {BRCMS_SROM_DEVID, 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, 0xffff}, - {BRCMS_SROM_BOARDREV, 0x0000000e, SRFL_PRHEX, SROM_AABREV, - SROM_BR_MASK}, - {BRCMS_SROM_BOARDREV, 0x000000f0, SRFL_PRHEX, SROM4_BREV, 0xffff}, {BRCMS_SROM_BOARDREV, 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000002, SRFL_PRHEX, SROM_BFL, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000004, SRFL_PRHEX | SRFL_MORE, SROM_BFL, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM_BFL2, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000008, SRFL_PRHEX | SRFL_MORE, SROM_BFL, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM3_BFL2, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL0, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_BFL1, 0xffff}, - {BRCMS_SROM_BOARDFLAGS, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL0, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM5_BFL1, 0xffff}, {BRCMS_SROM_BOARDFLAGS, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0, 0xffff}, {BRCMS_SROM_CONT, 0, 0, SROM8_BFL1, 0xffff}, - {BRCMS_SROM_BOARDFLAGS2, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL2, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_BFL3, 0xffff}, - {BRCMS_SROM_BOARDFLAGS2, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL2, - 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM5_BFL3, 0xffff}, {BRCMS_SROM_BOARDFLAGS2, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2, 0xffff}, {BRCMS_SROM_CONT, 0, 0, SROM8_BFL3, 0xffff}, {BRCMS_SROM_BOARDTYPE, 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x00000006, 0, SROM_MACLO_IL0, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x00000008, 0, SROM3_MACLO, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x00000010, 0, SROM4_MACLO, 0xffff}, - {BRCMS_SROM_BOARDNUM, 0x000000e0, 0, SROM5_MACLO, 0xffff}, {BRCMS_SROM_BOARDNUM, 0xffffff00, 0, SROM8_MACLO, 0xffff}, - {BRCMS_SROM_CC, 0x00000002, 0, SROM_AABREV, SROM_CC_MASK}, - {BRCMS_SROM_REGREV, 0x00000008, 0, SROM_OPO, 0xff00}, - {BRCMS_SROM_REGREV, 0x00000010, 0, SROM4_REGREV, 0x00ff}, - {BRCMS_SROM_REGREV, 0x000000e0, 0, SROM5_REGREV, 0x00ff}, {BRCMS_SROM_REGREV, 0xffffff00, 0, SROM8_REGREV, 0x00ff}, - {BRCMS_SROM_LEDBH0, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0x00ff}, - {BRCMS_SROM_LEDBH1, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0xff00}, - {BRCMS_SROM_LEDBH2, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0x00ff}, - {BRCMS_SROM_LEDBH3, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0xff00}, - {BRCMS_SROM_LEDBH0, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0x00ff}, - {BRCMS_SROM_LEDBH1, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0xff00}, - {BRCMS_SROM_LEDBH2, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0x00ff}, - {BRCMS_SROM_LEDBH3, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0xff00}, - {BRCMS_SROM_LEDBH0, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0x00ff}, - {BRCMS_SROM_LEDBH1, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0xff00}, - {BRCMS_SROM_LEDBH2, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0x00ff}, - {BRCMS_SROM_LEDBH3, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0xff00}, {BRCMS_SROM_LEDBH0, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff}, {BRCMS_SROM_LEDBH1, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00}, {BRCMS_SROM_LEDBH2, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff}, {BRCMS_SROM_LEDBH3, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00}, - {BRCMS_SROM_PA0B0, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB0, 0xffff}, - {BRCMS_SROM_PA0B1, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB1, 0xffff}, - {BRCMS_SROM_PA0B2, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB2, 0xffff}, - {BRCMS_SROM_PA0ITSSIT, 0x0000000e, 0, SROM_ITT, 0x00ff}, - {BRCMS_SROM_PA0MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0x00ff}, {BRCMS_SROM_PA0B0, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff}, {BRCMS_SROM_PA0B1, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff}, {BRCMS_SROM_PA0B2, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff}, {BRCMS_SROM_PA0ITSSIT, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00}, {BRCMS_SROM_PA0MAXPWR, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff}, - {BRCMS_SROM_OPO, 0x0000000c, 0, SROM_OPO, 0x00ff}, {BRCMS_SROM_OPO, 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff}, - {BRCMS_SROM_AA2G, 0x0000000e, 0, SROM_AABREV, SROM_AA0_MASK}, - {BRCMS_SROM_AA2G, 0x000000f0, 0, SROM4_AA, 0x00ff}, {BRCMS_SROM_AA2G, 0xffffff00, 0, SROM8_AA, 0x00ff}, - {BRCMS_SROM_AA5G, 0x0000000e, 0, SROM_AABREV, SROM_AA1_MASK}, - {BRCMS_SROM_AA5G, 0x000000f0, 0, SROM4_AA, 0xff00}, {BRCMS_SROM_AA5G, 0xffffff00, 0, SROM8_AA, 0xff00}, - {BRCMS_SROM_AG0, 0x0000000e, 0, SROM_AG10, 0x00ff}, - {BRCMS_SROM_AG1, 0x0000000e, 0, SROM_AG10, 0xff00}, - {BRCMS_SROM_AG0, 0x000000f0, 0, SROM4_AG10, 0x00ff}, - {BRCMS_SROM_AG1, 0x000000f0, 0, SROM4_AG10, 0xff00}, - {BRCMS_SROM_AG2, 0x000000f0, 0, SROM4_AG32, 0x00ff}, - {BRCMS_SROM_AG3, 0x000000f0, 0, SROM4_AG32, 0xff00}, {BRCMS_SROM_AG0, 0xffffff00, 0, SROM8_AG10, 0x00ff}, {BRCMS_SROM_AG1, 0xffffff00, 0, SROM8_AG10, 0xff00}, {BRCMS_SROM_AG2, 0xffffff00, 0, SROM8_AG32, 0x00ff}, {BRCMS_SROM_AG3, 0xffffff00, 0, SROM8_AG32, 0xff00}, - {BRCMS_SROM_PA1B0, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB0, 0xffff}, - {BRCMS_SROM_PA1B1, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB1, 0xffff}, - {BRCMS_SROM_PA1B2, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB2, 0xffff}, - {BRCMS_SROM_PA1LOB0, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB0, 0xffff}, - {BRCMS_SROM_PA1LOB1, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB1, 0xffff}, - {BRCMS_SROM_PA1LOB2, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB2, 0xffff}, - {BRCMS_SROM_PA1HIB0, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB0, 0xffff}, - {BRCMS_SROM_PA1HIB1, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB1, 0xffff}, - {BRCMS_SROM_PA1HIB2, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB2, 0xffff}, - {BRCMS_SROM_PA1ITSSIT, 0x0000000e, 0, SROM_ITT, 0xff00}, - {BRCMS_SROM_PA1MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0xff00}, - {BRCMS_SROM_PA1LOMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0xff00}, - {BRCMS_SROM_PA1HIMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0x00ff}, {BRCMS_SROM_PA1B0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff}, {BRCMS_SROM_PA1B1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff}, {BRCMS_SROM_PA1B2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff}, @@ -535,40 +377,20 @@ static const struct brcms_sromvar pci_sromvars[] = { {BRCMS_SROM_PA1MAXPWR, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff}, {BRCMS_SROM_PA1LOMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00}, {BRCMS_SROM_PA1HIMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff}, - {BRCMS_SROM_BXA2G, 0x00000008, 0, SROM_BXARSSI2G, 0x1800}, - {BRCMS_SROM_RSSISAV2G, 0x00000008, 0, SROM_BXARSSI2G, 0x0700}, - {BRCMS_SROM_RSSISMC2G, 0x00000008, 0, SROM_BXARSSI2G, 0x00f0}, - {BRCMS_SROM_RSSISMF2G, 0x00000008, 0, SROM_BXARSSI2G, 0x000f}, {BRCMS_SROM_BXA2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800}, {BRCMS_SROM_RSSISAV2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700}, {BRCMS_SROM_RSSISMC2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0}, {BRCMS_SROM_RSSISMF2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f}, - {BRCMS_SROM_BXA5G, 0x00000008, 0, SROM_BXARSSI5G, 0x1800}, - {BRCMS_SROM_RSSISAV5G, 0x00000008, 0, SROM_BXARSSI5G, 0x0700}, - {BRCMS_SROM_RSSISMC5G, 0x00000008, 0, SROM_BXARSSI5G, 0x00f0}, - {BRCMS_SROM_RSSISMF5G, 0x00000008, 0, SROM_BXARSSI5G, 0x000f}, {BRCMS_SROM_BXA5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800}, {BRCMS_SROM_RSSISAV5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700}, {BRCMS_SROM_RSSISMC5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0}, {BRCMS_SROM_RSSISMF5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f}, - {BRCMS_SROM_TRI2G, 0x00000008, 0, SROM_TRI52G, 0x00ff}, - {BRCMS_SROM_TRI5G, 0x00000008, 0, SROM_TRI52G, 0xff00}, - {BRCMS_SROM_TRI5GL, 0x00000008, 0, SROM_TRI5GHL, 0x00ff}, - {BRCMS_SROM_TRI5GH, 0x00000008, 0, SROM_TRI5GHL, 0xff00}, {BRCMS_SROM_TRI2G, 0xffffff00, 0, SROM8_TRI52G, 0x00ff}, {BRCMS_SROM_TRI5G, 0xffffff00, 0, SROM8_TRI52G, 0xff00}, {BRCMS_SROM_TRI5GL, 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff}, {BRCMS_SROM_TRI5GH, 0xffffff00, 0, SROM8_TRI5GHL, 0xff00}, - {BRCMS_SROM_RXPO2G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0x00ff}, - {BRCMS_SROM_RXPO5G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0xff00}, {BRCMS_SROM_RXPO2G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff}, {BRCMS_SROM_RXPO5G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00}, - {BRCMS_SROM_TXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, - SROM4_TXCHAIN_MASK}, - {BRCMS_SROM_RXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, - SROM4_RXCHAIN_MASK}, - {BRCMS_SROM_ANTSWITCH, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, - SROM4_SWITCH_MASK}, {BRCMS_SROM_TXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, SROM4_TXCHAIN_MASK}, {BRCMS_SROM_RXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, @@ -595,43 +417,11 @@ static const struct brcms_sromvar pci_sromvars[] = { SROM8_FEM_ANTSWLUT_MASK}, {BRCMS_SROM_TEMPTHRESH, 0xffffff00, 0, SROM8_THERMAL, 0xff00}, {BRCMS_SROM_TEMPOFFSET, 0xffffff00, 0, SROM8_THERMAL, 0x00ff}, - {BRCMS_SROM_TXPID2GA0, 0x000000f0, 0, SROM4_TXPID2G, 0x00ff}, - {BRCMS_SROM_TXPID2GA1, 0x000000f0, 0, SROM4_TXPID2G, 0xff00}, - {BRCMS_SROM_TXPID2GA2, 0x000000f0, 0, SROM4_TXPID2G + 1, 0x00ff}, - {BRCMS_SROM_TXPID2GA3, 0x000000f0, 0, SROM4_TXPID2G + 1, 0xff00}, - {BRCMS_SROM_TXPID5GA0, 0x000000f0, 0, SROM4_TXPID5G, 0x00ff}, - {BRCMS_SROM_TXPID5GA1, 0x000000f0, 0, SROM4_TXPID5G, 0xff00}, - {BRCMS_SROM_TXPID5GA2, 0x000000f0, 0, SROM4_TXPID5G + 1, 0x00ff}, - {BRCMS_SROM_TXPID5GA3, 0x000000f0, 0, SROM4_TXPID5G + 1, 0xff00}, - {BRCMS_SROM_TXPID5GLA0, 0x000000f0, 0, SROM4_TXPID5GL, 0x00ff}, - {BRCMS_SROM_TXPID5GLA1, 0x000000f0, 0, SROM4_TXPID5GL, 0xff00}, - {BRCMS_SROM_TXPID5GLA2, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0x00ff}, - {BRCMS_SROM_TXPID5GLA3, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0xff00}, - {BRCMS_SROM_TXPID5GHA0, 0x000000f0, 0, SROM4_TXPID5GH, 0x00ff}, - {BRCMS_SROM_TXPID5GHA1, 0x000000f0, 0, SROM4_TXPID5GH, 0xff00}, - {BRCMS_SROM_TXPID5GHA2, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0x00ff}, - {BRCMS_SROM_TXPID5GHA3, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0xff00}, - - {BRCMS_SROM_CCODE, 0x0000000f, SRFL_CCODE, SROM_CCODE, 0xffff}, - {BRCMS_SROM_CCODE, 0x00000010, SRFL_CCODE, SROM4_CCODE, 0xffff}, - {BRCMS_SROM_CCODE, 0x000000e0, SRFL_CCODE, SROM5_CCODE, 0xffff}, + {BRCMS_SROM_CCODE, 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff}, {BRCMS_SROM_MACADDR, 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff}, - {BRCMS_SROM_MACADDR, 0x000000e0, SRFL_ETHADDR, SROM5_MACHI, 0xffff}, - {BRCMS_SROM_MACADDR, 0x00000010, SRFL_ETHADDR, SROM4_MACHI, 0xffff}, - {BRCMS_SROM_MACADDR, 0x00000008, SRFL_ETHADDR, SROM3_MACHI, 0xffff}, - {BRCMS_SROM_IL0MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_IL0, - 0xffff}, - {BRCMS_SROM_ET1MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_ET1, - 0xffff}, {BRCMS_SROM_LEDDC, 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC, 0xffff}, - {BRCMS_SROM_LEDDC, 0x000000e0, SRFL_NOFFS | SRFL_LEDDC, SROM5_LEDDC, - 0xffff}, - {BRCMS_SROM_LEDDC, 0x00000010, SRFL_NOFFS | SRFL_LEDDC, SROM4_LEDDC, - 0xffff}, - {BRCMS_SROM_LEDDC, 0x00000008, SRFL_NOFFS | SRFL_LEDDC, SROM3_LEDDC, - 0xffff}, {BRCMS_SROM_RAWTEMPSENSE, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, 0x01ff}, {BRCMS_SROM_MEASPOWER, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, @@ -651,16 +441,7 @@ static const struct brcms_sromvar pci_sromvars[] = { {BRCMS_SROM_PHYCAL_TEMPDELTA, 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA, 0x00ff}, - {BRCMS_SROM_CCK2GPO, 0x000000f0, 0, SROM4_2G_CCKPO, 0xffff}, {BRCMS_SROM_CCK2GPO, 0x00000100, 0, SROM8_2G_CCKPO, 0xffff}, - {BRCMS_SROM_OFDM2GPO, 0x000000f0, SRFL_MORE, SROM4_2G_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_2G_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GPO, 0x000000f0, SRFL_MORE, SROM4_5G_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_5G_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GLPO, 0x000000f0, SRFL_MORE, SROM4_5GL_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_5GL_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_OFDM5GHPO, 0x000000f0, SRFL_MORE, SROM4_5GH_OFDMPO, 0xffff}, - {BRCMS_SROM_CONT, 0, 0, SROM4_5GH_OFDMPO + 1, 0xffff}, {BRCMS_SROM_OFDM2GPO, 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff}, {BRCMS_SROM_CONT, 0, 0, SROM8_2G_OFDMPO + 1, 0xffff}, {BRCMS_SROM_OFDM5GPO, 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff}, @@ -669,38 +450,6 @@ static const struct brcms_sromvar pci_sromvars[] = { {BRCMS_SROM_CONT, 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff}, {BRCMS_SROM_OFDM5GHPO, 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff}, {BRCMS_SROM_CONT, 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff}, - {BRCMS_SROM_MCS2GPO0, 0x000000f0, 0, SROM4_2G_MCSPO, 0xffff}, - {BRCMS_SROM_MCS2GPO1, 0x000000f0, 0, SROM4_2G_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS2GPO2, 0x000000f0, 0, SROM4_2G_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS2GPO3, 0x000000f0, 0, SROM4_2G_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS2GPO4, 0x000000f0, 0, SROM4_2G_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS2GPO5, 0x000000f0, 0, SROM4_2G_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS2GPO6, 0x000000f0, 0, SROM4_2G_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS2GPO7, 0x000000f0, 0, SROM4_2G_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GPO0, 0x000000f0, 0, SROM4_5G_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GPO1, 0x000000f0, 0, SROM4_5G_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GPO2, 0x000000f0, 0, SROM4_5G_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GPO3, 0x000000f0, 0, SROM4_5G_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GPO4, 0x000000f0, 0, SROM4_5G_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GPO5, 0x000000f0, 0, SROM4_5G_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GPO6, 0x000000f0, 0, SROM4_5G_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GPO7, 0x000000f0, 0, SROM4_5G_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GLPO0, 0x000000f0, 0, SROM4_5GL_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GLPO1, 0x000000f0, 0, SROM4_5GL_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GLPO2, 0x000000f0, 0, SROM4_5GL_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GLPO3, 0x000000f0, 0, SROM4_5GL_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GLPO4, 0x000000f0, 0, SROM4_5GL_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GLPO5, 0x000000f0, 0, SROM4_5GL_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GLPO6, 0x000000f0, 0, SROM4_5GL_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GLPO7, 0x000000f0, 0, SROM4_5GL_MCSPO + 7, 0xffff}, - {BRCMS_SROM_MCS5GHPO0, 0x000000f0, 0, SROM4_5GH_MCSPO, 0xffff}, - {BRCMS_SROM_MCS5GHPO1, 0x000000f0, 0, SROM4_5GH_MCSPO + 1, 0xffff}, - {BRCMS_SROM_MCS5GHPO2, 0x000000f0, 0, SROM4_5GH_MCSPO + 2, 0xffff}, - {BRCMS_SROM_MCS5GHPO3, 0x000000f0, 0, SROM4_5GH_MCSPO + 3, 0xffff}, - {BRCMS_SROM_MCS5GHPO4, 0x000000f0, 0, SROM4_5GH_MCSPO + 4, 0xffff}, - {BRCMS_SROM_MCS5GHPO5, 0x000000f0, 0, SROM4_5GH_MCSPO + 5, 0xffff}, - {BRCMS_SROM_MCS5GHPO6, 0x000000f0, 0, SROM4_5GH_MCSPO + 6, 0xffff}, - {BRCMS_SROM_MCS5GHPO7, 0x000000f0, 0, SROM4_5GH_MCSPO + 7, 0xffff}, {BRCMS_SROM_MCS2GPO0, 0x00000100, 0, SROM8_2G_MCSPO, 0xffff}, {BRCMS_SROM_MCS2GPO1, 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff}, {BRCMS_SROM_MCS2GPO2, 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff}, @@ -733,10 +482,6 @@ static const struct brcms_sromvar pci_sromvars[] = { {BRCMS_SROM_MCS5GHPO5, 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff}, {BRCMS_SROM_MCS5GHPO6, 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff}, {BRCMS_SROM_MCS5GHPO7, 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff}, - {BRCMS_SROM_CDDPO, 0x000000f0, 0, SROM4_CDDPO, 0xffff}, - {BRCMS_SROM_STBCPO, 0x000000f0, 0, SROM4_STBCPO, 0xffff}, - {BRCMS_SROM_BW40PO, 0x000000f0, 0, SROM4_BW40PO, 0xffff}, - {BRCMS_SROM_BWDUPPO, 0x000000f0, 0, SROM4_BWDUPPO, 0xffff}, {BRCMS_SROM_CDDPO, 0x00000100, 0, SROM8_CDDPO, 0xffff}, {BRCMS_SROM_STBCPO, 0x00000100, 0, SROM8_STBCPO, 0xffff}, {BRCMS_SROM_BW40PO, 0x00000100, 0, SROM8_BW40PO, 0xffff}, @@ -812,34 +557,6 @@ static const struct brcms_sromvar pci_sromvars[] = { }; static const struct brcms_sromvar perpath_pci_sromvars[] = { - {BRCMS_SROM_MAXP2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0x00ff}, - {BRCMS_SROM_ITT2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0xff00}, - {BRCMS_SROM_ITT5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0xff00}, - {BRCMS_SROM_PA2GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA, 0xffff}, - {BRCMS_SROM_PA2GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 1, 0xffff}, - {BRCMS_SROM_PA2GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 2, 0xffff}, - {BRCMS_SROM_PA2GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 3, 0xffff}, - {BRCMS_SROM_MAXP5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0x00ff}, - {BRCMS_SROM_MAXP5GHA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0x00ff}, - {BRCMS_SROM_MAXP5GLA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0xff00}, - {BRCMS_SROM_PA5GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA, 0xffff}, - {BRCMS_SROM_PA5GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 1, 0xffff}, - {BRCMS_SROM_PA5GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 2, 0xffff}, - {BRCMS_SROM_PA5GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 3, 0xffff}, - {BRCMS_SROM_PA5GLW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA, 0xffff}, - {BRCMS_SROM_PA5GLW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 1, - 0xffff}, - {BRCMS_SROM_PA5GLW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 2, - 0xffff}, - {BRCMS_SROM_PA5GLW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 3, - 0xffff}, - {BRCMS_SROM_PA5GHW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA, 0xffff}, - {BRCMS_SROM_PA5GHW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 1, - 0xffff}, - {BRCMS_SROM_PA5GHW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 2, - 0xffff}, - {BRCMS_SROM_PA5GHW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 3, - 0xffff}, {BRCMS_SROM_MAXP2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff}, {BRCMS_SROM_ITT2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00}, {BRCMS_SROM_ITT5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00}, @@ -881,12 +598,6 @@ srom_window_address(struct si_pub *sih, u8 __iomem *curmap) return NULL; } -/* Parse SROM and create name=value pairs. 'srom' points to - * the SROM word array. 'off' specifies the offset of the - * first word 'srom' points to, which should be either 0 or - * SROM3_SWRG_OFF (full SROM or software region). - */ - static uint mask_shift(u16 mask) { uint i; @@ -935,6 +646,9 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) uint width; uint flags; u32 sr = (1 << sromrev); + uint p; + uint pb = SROM8_PATH0; + const uint psz = SROM8_PATH1 - SROM8_PATH0; /* first store the srom revision */ entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); @@ -1032,47 +746,34 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) list_add(&entry->var_list, var_list); } - if (sromrev >= 4) { - /* Do per-path variables */ - uint p, pb, psz; - - if (sromrev >= 8) { - pb = SROM8_PATH0; - psz = SROM8_PATH1 - SROM8_PATH0; - } else { - pb = SROM4_PATH0; - psz = SROM4_PATH1 - SROM4_PATH0; - } - - for (p = 0; p < MAX_PATH_SROM; p++) { - for (srv = perpath_pci_sromvars; - srv->varid != BRCMS_SROM_NULL; srv++) { - if ((srv->revmask & sr) == 0) - continue; + for (p = 0; p < MAX_PATH_SROM; p++) { + for (srv = perpath_pci_sromvars; + srv->varid != BRCMS_SROM_NULL; srv++) { + if ((srv->revmask & sr) == 0) + continue; - if (srv->flags & SRFL_NOVAR) - continue; + if (srv->flags & SRFL_NOVAR) + continue; - w = srom[pb + srv->off]; - val = (w & srv->mask) >> mask_shift(srv->mask); - width = mask_width(srv->mask); + w = srom[pb + srv->off]; + val = (w & srv->mask) >> mask_shift(srv->mask); + width = mask_width(srv->mask); - /* Cheating: no per-path var is more than - * 1 word */ - if ((srv->flags & SRFL_NOFFS) - && ((int)val == (1 << width) - 1)) - continue; + /* Cheating: no per-path var is more than + * 1 word */ + if ((srv->flags & SRFL_NOFFS) + && ((int)val == (1 << width) - 1)) + continue; - entry = - kzalloc(sizeof(struct brcms_srom_list_head), - GFP_KERNEL); - entry->varid = srv->varid+p; - entry->var_type = BRCMS_SROM_UNUMBER; - entry->uval = val; - list_add(&entry->var_list, var_list); - } - pb += psz; + entry = + kzalloc(sizeof(struct brcms_srom_list_head), + GFP_KERNEL); + entry->varid = srv->varid+p; + entry->var_type = BRCMS_SROM_UNUMBER; + entry->uval = val; + list_add(&entry->var_list, var_list); } + pb += psz; } } @@ -1177,22 +878,14 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, true); - if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || - (((sih->buscoretype == PCIE_CORE_ID) - && (sih->buscorerev >= 6)) - || ((sih->buscoretype == PCI_CORE_ID) - && (sih->buscorerev >= 0xe)))) { - /* sromrev >= 4, read more */ + if ((sih->buscoretype == PCIE_CORE_ID && sih->buscorerev >= 6) + || (sih->buscoretype == PCI_CORE_ID && + sih->buscorerev >= 0xe)) { err = sprom_read_pci(sih, sromwindow, 0, srom, SROM4_WORDS, true); sromrev = srom[SROM4_CRCREV] & 0xff; - } else if (err == 0) { - /* srom is good and is rev < 4 */ - /* top word of sprom contains version and crc8 */ - sromrev = srom[SROM_CRCREV] & 0xff; - /* bcm4401 sroms misprogrammed */ - if (sromrev == 0x10) - sromrev = 1; + } else { + err = -EIO; } } else { /* Use OTP if SPROM not available */ @@ -1209,10 +902,9 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) sr = 1 << sromrev; /* - * srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, - * 9 + * srom version check: Current valid versions: 8, 9 */ - if ((sr & 0x33e) == 0) { + if ((sr & 0x300) == 0) { err = -EINVAL; goto errout; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.h b/drivers/net/wireless/brcm80211/brcmsmac/srom.h index 708c43f..c81df97 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.h @@ -26,9 +26,4 @@ extern void srom_free_vars(struct si_pub *sih); extern int srom_read(struct si_pub *sih, uint bus, void *curmap, uint byteoff, uint nbytes, u16 *buf, bool check_crc); -/* parse standard PCMCIA cis, normally used by SB/PCMCIA/SDIO/SPI/OTP - * and extract from it into name=value pairs - */ -extern int srom_parsecis(u8 **pcis, uint ciscnt, - char **vars, uint *count); #endif /* _BRCM_SROM_H_ */ -- cgit v0.10.2 From d34bf64fd32abfe8141c7206ca6da92832b4fe94 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 18 Oct 2011 14:03:01 +0200 Subject: brcm80211: fmac: annotated little endian struct with _le Made code more readable. Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 4645766..cf7cc9a 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -87,7 +87,7 @@ #define TOE_TX_CSUM_OL 0x00000001 #define TOE_RX_CSUM_OL 0x00000002 -#define BRCMF_BSS_INFO_VERSION 108 /* current ver of brcmf_bss_info struct */ +#define BRCMF_BSS_INFO_VERSION 108 /* curr ver of brcmf_bss_info_le struct */ /* size of brcmf_scan_params not including variable length array */ #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64 @@ -365,7 +365,7 @@ struct brcmf_pkt_filter_enable_le { * Applications MUST CHECK ie_offset field and length field to access IEs and * next bss_info structure in a vector (in struct brcmf_scan_results) */ -struct brcmf_bss_info { +struct brcmf_bss_info_le { __le32 version; /* version field */ __le32 length; /* byte length of data in this record, * starting at version and including IEs @@ -466,14 +466,14 @@ struct brcmf_scan_results { u32 buflen; u32 version; u32 count; - struct brcmf_bss_info bss_info[1]; + struct brcmf_bss_info_le bss_info_le[1]; }; struct brcmf_scan_results_le { __le32 buflen; __le32 version; __le32 count; - struct brcmf_bss_info bss_info[1]; + struct brcmf_bss_info_le bss_info_le[1]; }; /* used for association with a specific BSSID and chanspec list */ @@ -495,7 +495,7 @@ struct brcmf_join_params { /* size of brcmf_scan_results not including variable length array */ #define BRCMF_SCAN_RESULTS_FIXED_SIZE \ - (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info)) + (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info_le)) /* incremental scan results struct */ struct brcmf_iscan_results { diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 5eddabe..7f89bad 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -1997,7 +1997,7 @@ done: } static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, - struct brcmf_bss_info *bi) + struct brcmf_bss_info_le *bi) { struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); struct ieee80211_channel *notify_channel; @@ -2060,7 +2060,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) { struct brcmf_scan_results *bss_list; - struct brcmf_bss_info *bi = NULL; /* must be initialized */ + struct brcmf_bss_info_le *bi = NULL; /* must be initialized */ s32 err = 0; int i; @@ -2085,7 +2085,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, { struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); struct ieee80211_channel *notify_channel; - struct brcmf_bss_info *bi = NULL; + struct brcmf_bss_info_le *bi = NULL; struct ieee80211_supported_band *band; u8 *buf = NULL; s32 err = 0; @@ -2114,7 +2114,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, goto CleanUp; } - bi = (struct brcmf_bss_info *)(buf + 4); + bi = (struct brcmf_bss_info_le *)(buf + 4); channel = bi->ctl_ch ? bi->ctl_ch : CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); @@ -2188,7 +2188,7 @@ static struct brcmf_tlv *brcmf_parse_tlvs(void *buf, int buflen, uint key) static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) { - struct brcmf_bss_info *bi; + struct brcmf_bss_info_le *bi; struct brcmf_ssid *ssid; struct brcmf_tlv *tim; u16 beacon_interval; @@ -2211,7 +2211,7 @@ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) goto update_bss_info_out; } - bi = (struct brcmf_bss_info *)(cfg_priv->extra_buf + 4); + bi = (struct brcmf_bss_info_le *)(cfg_priv->extra_buf + 4); err = brcmf_inform_single_bss(cfg_priv, bi); if (err) goto update_bss_info_out; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h index 62dc461..bec30e3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h @@ -352,13 +352,13 @@ brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_priv *cfg) return &cfg->conn_info; } -static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, - struct brcmf_bss_info *bss) +static inline struct brcmf_bss_info_le * +next_bss(struct brcmf_scan_results *list, struct brcmf_bss_info_le *bss) { return bss = bss ? - (struct brcmf_bss_info *)((unsigned long)bss + + (struct brcmf_bss_info_le *)((unsigned long)bss + le32_to_cpu(bss->length)) : - list->bss_info; + list->bss_info_le; } extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, -- cgit v0.10.2 From 6f09be0ad534160a1931f0c0f92e18a48bd888f9 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 18 Oct 2011 14:03:02 +0200 Subject: brmc80211: fmac: reworked next_bss() Moved function to where it is called and made it more readable. Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 7f89bad..73be2c8 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -2057,6 +2057,15 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, return err; } +static struct brcmf_bss_info_le * +next_bss_le(struct brcmf_scan_results *list, struct brcmf_bss_info_le *bss) +{ + if (bss == NULL) + return list->bss_info_le; + return (struct brcmf_bss_info_le *)((unsigned long)bss + + le32_to_cpu(bss->length)); +} + static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) { struct brcmf_scan_results *bss_list; @@ -2072,7 +2081,7 @@ static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) } WL_SCAN("scanned AP count (%d)\n", bss_list->count); for (i = 0; i < bss_list->count && i < WL_AP_MAX; i++) { - bi = next_bss(bss_list, bi); + bi = next_bss_le(bss_list, bi); err = brcmf_inform_single_bss(cfg_priv, bi); if (err) break; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h index bec30e3..a613b49 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h @@ -352,15 +352,6 @@ brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_priv *cfg) return &cfg->conn_info; } -static inline struct brcmf_bss_info_le * -next_bss(struct brcmf_scan_results *list, struct brcmf_bss_info_le *bss) -{ - return bss = bss ? - (struct brcmf_bss_info_le *)((unsigned long)bss + - le32_to_cpu(bss->length)) : - list->bss_info_le; -} - extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, struct device *busdev, void *data); -- cgit v0.10.2 From 0527781eb00550226d638b9be23d246c7ba796f6 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 18 Oct 2011 14:03:03 +0200 Subject: brcm80211: fmac: changed two scan related structures struct brcmf_scan_results contained a 1 element array, but in reality the number of scan results can be 0 or more, as indicated by the count field in the same struct. Array has be redefined to be 0 elements length to indicate the array is purely for reference. Reported-by: Johannes Berg Reviewed-by: Arend van Spriel Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index cf7cc9a..54b055b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -466,14 +466,13 @@ struct brcmf_scan_results { u32 buflen; u32 version; u32 count; - struct brcmf_bss_info_le bss_info_le[1]; + struct brcmf_bss_info_le bss_info_le[]; }; struct brcmf_scan_results_le { __le32 buflen; __le32 version; __le32 count; - struct brcmf_bss_info_le bss_info_le[1]; }; /* used for association with a specific BSSID and chanspec list */ @@ -493,10 +492,6 @@ struct brcmf_join_params { struct brcmf_assoc_params_le params_le; }; -/* size of brcmf_scan_results not including variable length array */ -#define BRCMF_SCAN_RESULTS_FIXED_SIZE \ - (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info_le)) - /* incremental scan results struct */ struct brcmf_iscan_results { union { @@ -511,7 +506,7 @@ struct brcmf_iscan_results { /* size of brcmf_iscan_results not including variable length array */ #define BRCMF_ISCAN_RESULTS_FIXED_SIZE \ - (BRCMF_SCAN_RESULTS_FIXED_SIZE + \ + (sizeof(struct brcmf_scan_results) + \ offsetof(struct brcmf_iscan_results, results)) struct brcmf_wsec_key { -- cgit v0.10.2 From c261bdf8acad56717cae233709808d8d9291ce36 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Tue, 18 Oct 2011 14:03:04 +0200 Subject: brcm80211: smac: indicate severe problems to Mac80211 In case the hardware crashes, a reinitialization internal to the driver was performed. Since Mac80211 must be in the know of such an event as well, ieee80211_restart_hw() is now called. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 538b504..7a24a83 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1334,6 +1334,14 @@ uint brcms_reset(struct brcms_info *wl) return 0; } +void brcms_fatal_error(struct brcms_info *wl) +{ + wiphy_err(wl->wlc->wiphy, "wl%d: fatal error, reinitializing\n", + wl->wlc->pub->unit); + brcms_reset(wl); + ieee80211_restart_hw(wl->pub->ieee_hw); +} + /* * These are interrupt on/off entry points. Disable interrupts * during interrupt state transition. diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h index 177f0e4..5c279c0 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h @@ -104,5 +104,6 @@ extern bool brcms_del_timer(struct brcms_timer *timer); extern void brcms_msleep(struct brcms_info *wl, uint ms); extern void brcms_dpc(unsigned long data); extern void brcms_timer(struct brcms_timer *t); +extern void brcms_fatal_error(struct brcms_info *wl); #endif /* _BRCM_MAC80211_IF_H_ */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 84f32b6..2e1a20b 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -2301,13 +2301,6 @@ void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type) wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); } -static void brcms_c_fatal_error(struct brcms_c_info *wlc) -{ - wiphy_err(wlc->wiphy, "wl%d: fatal error, reinitializing\n", - wlc->pub->unit); - brcms_init(wlc->wl); -} - static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) { bool fatal = false; @@ -2363,7 +2356,7 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) } if (fatal) { - brcms_c_fatal_error(wlc_hw->wlc); /* big hammer */ + brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ break; } else W_REG(®s->intctrlregs[idx].intstatus, @@ -8397,8 +8390,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", __func__, wlc_hw->sih->chip, wlc_hw->sih->chiprev); - /* big hammer */ - brcms_init(wlc->wl); + brcms_fatal_error(wlc_hw->wlc->wl); } /* gptimer timeout */ @@ -8419,7 +8411,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) return wlc->macintstatus != 0; fatal: - brcms_init(wlc->wl); + brcms_fatal_error(wlc_hw->wlc->wl); return wlc->macintstatus != 0; } -- cgit v0.10.2 From 32cb68bf57b726f4b9161cdc110ffe45134aab69 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 18 Oct 2011 14:03:05 +0200 Subject: brcm80211: smac: remove obsolete srom variables from n-phy The n-phy requested some srom variables that are no longer needed and consequently not present in the srom revision 8 and higher that this driver support. This code has been removed from the n-phy. Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h index bea8524..5f9478b 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h @@ -774,11 +774,6 @@ struct brcms_phy { s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ]; u8 nphy_noise_index; - u8 nphy_txpid2g[PHY_CORE_NUM_2]; - u8 nphy_txpid5g[PHY_CORE_NUM_2]; - u8 nphy_txpid5gl[PHY_CORE_NUM_2]; - u8 nphy_txpid5gh[PHY_CORE_NUM_2]; - bool nphy_gain_boost; bool nphy_elna_gain_config; u16 old_bphy_test; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index db612f8..ec9b566 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -14418,12 +14418,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) switch (band_num) { case 0: - pi->nphy_txpid2g[PHY_CORE_0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID2GA0); - pi->nphy_txpid2g[PHY_CORE_1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID2GA1); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP2GA0); @@ -14487,12 +14481,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) break; case 1: - pi->nphy_txpid5g[PHY_CORE_0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GA0); - pi->nphy_txpid5g[PHY_CORE_1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GA1); pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GA0); pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = @@ -14552,12 +14540,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) break; case 2: - pi->nphy_txpid5gl[0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GLA0); - pi->nphy_txpid5gl[1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GLA1); pi->nphy_pwrctrl_info[0].max_pwr_5gl = (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GLA0); @@ -14616,12 +14598,6 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) break; case 3: - pi->nphy_txpid5gh[0] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GHA0); - pi->nphy_txpid5gh[1] = - (u8) wlapi_getintvar(shim, - BRCMS_SROM_TXPID5GHA1); pi->nphy_pwrctrl_info[0].max_pwr_5gh = (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GHA0); @@ -27995,20 +27971,11 @@ void wlc_phy_txpwr_fixpower_nphy(struct brcms_phy *pi) chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); switch (chan_freq_range) { case WL_CHAN_FREQ_RANGE_2G: - txpi[0] = pi->nphy_txpid2g[0]; - txpi[1] = pi->nphy_txpid2g[1]; - break; case WL_CHAN_FREQ_RANGE_5GL: - txpi[0] = pi->nphy_txpid5gl[0]; - txpi[1] = pi->nphy_txpid5gl[1]; - break; case WL_CHAN_FREQ_RANGE_5GM: - txpi[0] = pi->nphy_txpid5g[0]; - txpi[1] = pi->nphy_txpid5g[1]; - break; case WL_CHAN_FREQ_RANGE_5GH: - txpi[0] = pi->nphy_txpid5gh[0]; - txpi[1] = pi->nphy_txpid5gh[1]; + txpi[0] = 0; + txpi[1] = 0; break; default: txpi[0] = txpi[1] = 91; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 37bb2dc..d20116a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -170,22 +170,6 @@ enum brcms_srom_id { BRCMS_SROM_TSSIPOS2G, BRCMS_SROM_TSSIPOS5G, BRCMS_SROM_TXCHAIN, - BRCMS_SROM_TXPID2GA0, - BRCMS_SROM_TXPID2GA1, - BRCMS_SROM_TXPID2GA2, - BRCMS_SROM_TXPID2GA3, - BRCMS_SROM_TXPID5GA0, - BRCMS_SROM_TXPID5GA1, - BRCMS_SROM_TXPID5GA2, - BRCMS_SROM_TXPID5GA3, - BRCMS_SROM_TXPID5GHA0, - BRCMS_SROM_TXPID5GHA1, - BRCMS_SROM_TXPID5GHA2, - BRCMS_SROM_TXPID5GHA3, - BRCMS_SROM_TXPID5GLA0, - BRCMS_SROM_TXPID5GLA1, - BRCMS_SROM_TXPID5GLA2, - BRCMS_SROM_TXPID5GLA3, /* * per-path identifiers (see srom.c) */ @@ -225,10 +209,6 @@ enum brcms_srom_id { BRCMS_SROM_PA2GW2A1, BRCMS_SROM_PA2GW2A2, BRCMS_SROM_PA2GW2A3, - BRCMS_SROM_PA2GW3A0, - BRCMS_SROM_PA2GW3A1, - BRCMS_SROM_PA2GW3A2, - BRCMS_SROM_PA2GW3A3, BRCMS_SROM_PA5GHW0A0, BRCMS_SROM_PA5GHW0A1, BRCMS_SROM_PA5GHW0A2, @@ -241,10 +221,6 @@ enum brcms_srom_id { BRCMS_SROM_PA5GHW2A1, BRCMS_SROM_PA5GHW2A2, BRCMS_SROM_PA5GHW2A3, - BRCMS_SROM_PA5GHW3A0, - BRCMS_SROM_PA5GHW3A1, - BRCMS_SROM_PA5GHW3A2, - BRCMS_SROM_PA5GHW3A3, BRCMS_SROM_PA5GLW0A0, BRCMS_SROM_PA5GLW0A1, BRCMS_SROM_PA5GLW0A2, @@ -257,10 +233,6 @@ enum brcms_srom_id { BRCMS_SROM_PA5GLW2A1, BRCMS_SROM_PA5GLW2A2, BRCMS_SROM_PA5GLW2A3, - BRCMS_SROM_PA5GLW3A0, - BRCMS_SROM_PA5GLW3A1, - BRCMS_SROM_PA5GLW3A2, - BRCMS_SROM_PA5GLW3A3, BRCMS_SROM_PA5GW0A0, BRCMS_SROM_PA5GW0A1, BRCMS_SROM_PA5GW0A2, @@ -273,10 +245,6 @@ enum brcms_srom_id { BRCMS_SROM_PA5GW2A1, BRCMS_SROM_PA5GW2A2, BRCMS_SROM_PA5GW2A3, - BRCMS_SROM_PA5GW3A0, - BRCMS_SROM_PA5GW3A1, - BRCMS_SROM_PA5GW3A2, - BRCMS_SROM_PA5GW3A3, }; #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ -- cgit v0.10.2 From 888153b3db3fb10a048768c0c262951e2bc19719 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 18 Oct 2011 14:03:06 +0200 Subject: brcm80211: smac: avoid sprom endianess conversions for crc8 check The data from the sprom consists of u16 values stored in little endian notation over which a crc8 was determined. To validate this the buffer needed to be converted for big-endian systems. Reading the sprom data is now done per byte so conversion is only done after a successful crc8 check. Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index a884fe0..66aa0e7 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -586,14 +586,13 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { * shared between devices. */ static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; -static u16 __iomem * +static u8 __iomem * srom_window_address(struct si_pub *sih, u8 __iomem *curmap) { if (sih->ccrev < 32) - return (u16 __iomem *)(curmap + PCI_BAR0_SPROM_OFFSET); + return curmap + PCI_BAR0_SPROM_OFFSET; if (sih->cccaps & CC_CAP_SROM) - return (u16 __iomem *) - (curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); + return curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP; return NULL; } @@ -782,37 +781,34 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) * Return 0 on success, nonzero on error. */ static int -sprom_read_pci(struct si_pub *sih, u16 __iomem *sprom, uint wordoff, +sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, u16 *buf, uint nwords, bool check_crc) { int err = 0; uint i; + u8 *bbuf = (u8 *)buf; /* byte buffer */ + uint nbytes = nwords << 1; - /* read the sprom */ - for (i = 0; i < nwords; i++) - buf[i] = R_REG(&sprom[wordoff + i]); + /* read the sprom in bytes */ + for (i = 0; i < nbytes; i++) + bbuf[i] = readb(sprom+i); - if (check_crc) { - - if (buf[0] == 0xffff) - /* - * The hardware thinks that an srom that starts with - * 0xffff is blank, regardless of the rest of the - * content, so declare it bad. - */ - return -ENODATA; - - /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, nwords * 2); - if (crc8(brcms_srom_crc8_table, (u8 *) buf, nwords * 2, - CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE(brcms_srom_crc8_table)) - /* DBG only pci always read srom4 first, then srom8/9 */ - err = -EIO; + if (buf[0] == 0xffff) + /* + * The hardware thinks that an srom that starts with + * 0xffff is blank, regardless of the rest of the + * content, so declare it bad. + */ + return -ENODATA; + if (check_crc && + crc8(brcms_srom_crc8_table, bbuf, nbytes, CRC8_INIT_VALUE) != + CRC8_GOOD_VALUE(brcms_srom_crc8_table)) + err = -EIO; + else /* now correct the endianness of the byte array */ - ltoh16_buf(buf, nwords * 2); - } + ltoh16_buf(buf, nbytes); + return err; } @@ -859,7 +855,7 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) { u16 *srom; - u16 __iomem *sromwindow; + u8 __iomem *sromwindow; u8 sromrev = 0; u32 sr; int err = 0; @@ -875,18 +871,13 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); if (ai_is_sprom_available(sih)) { - err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, - true); - - if ((sih->buscoretype == PCIE_CORE_ID && sih->buscorerev >= 6) - || (sih->buscoretype == PCI_CORE_ID && - sih->buscorerev >= 0xe)) { - err = sprom_read_pci(sih, sromwindow, 0, srom, - SROM4_WORDS, true); + err = sprom_read_pci(sih, sromwindow, 0, srom, + SROM4_WORDS, true); + + if (err == 0) + /* srom read and passed crc */ + /* top word of sprom contains version and crc8 */ sromrev = srom[SROM4_CRCREV] & 0xff; - } else { - err = -EIO; - } } else { /* Use OTP if SPROM not available */ err = otp_read_pci(sih, srom, SROM_MAX); -- cgit v0.10.2 From 094b199bf707a41bc6748f0c2f0a23ecf5d2ccd6 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 18 Oct 2011 14:03:07 +0200 Subject: brcm80211: smac: some local function made static in main.c In main.c a couple of functions were not static although they were only locally used. Sparse gave warnings on them and these functions have been made static. Reviewed-by: Alwin Beukers Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 2e1a20b..abb49fc 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -618,9 +618,8 @@ static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, * calculate frame duration of a given rate and length, return * time in usec unit */ -uint -brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, - u8 preamble_type, uint mac_len) +static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, + u8 preamble_type, uint mac_len) { uint nsyms, dur = 0, Ndps, kNdps; uint rate = rspec2rate(ratespec); @@ -4184,7 +4183,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, } } -void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) +static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) { u16 aci; int i_ac; @@ -6100,9 +6099,9 @@ void brcms_c_print_txdesc(struct d11txh *txh) #endif /* defined(BCMDBG) */ #if defined(BCMDBG) -int +static int brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, - int len) + int len) { int i; char *p = buf; -- cgit v0.10.2 From 1433c59bcc404cd4bd54333d23ce06242d8e32b7 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 18 Oct 2011 14:03:08 +0200 Subject: brcm80211: smac: remove phy api bypass in rate.h Obviously the phy api should be used to interface with the phy. In rate.h a table within phy was accessed directly by declaring the table extern in rate.h itself. This patch fixes this using the provided api function to obtain the table reference. This bypass was found by a sparse warning on the table not being defined static. Reviewed-by: Alwin Beukers Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index a314925..2faea50 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -112,7 +112,7 @@ static const struct chan_info_basic chan_info_all[] = { {216, 50800} }; -const u8 ofdm_rate_lookup[] = { +static const u8 ofdm_rate_lookup[] = { BRCM_RATE_48M, BRCM_RATE_24M, diff --git a/drivers/net/wireless/brcm80211/brcmsmac/rate.h b/drivers/net/wireless/brcm80211/brcmsmac/rate.h index e7b9dc2..980d578 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/rate.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/rate.h @@ -19,6 +19,7 @@ #include "types.h" #include "d11.h" +#include "phy_hal.h" extern const u8 rate_info[]; extern const struct brcms_c_rateset cck_ofdm_mimo_rates; @@ -198,11 +199,9 @@ static inline u8 cck_rspec(u8 cck) /* Convert encoded rate value in plcp header to numerical rates in 500 KHz * increments */ -extern const u8 ofdm_rate_lookup[]; - static inline u8 ofdm_phy2mac_rate(u8 rlpt) { - return ofdm_rate_lookup[rlpt & 0x7]; + return wlc_phy_get_ofdm_rate_lookup()[rlpt & 0x7]; } static inline u8 cck_phy2mac_rate(u8 signal) -- cgit v0.10.2 From 20e5ca16397648811a9e1ad531360c843e005a57 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 18 Oct 2011 14:03:09 +0200 Subject: brcm80211: util: move brcmu_pktfrombuf() function to brcmfmac The function brcmu_pktfrombuf was only used in the brcmfmac source and has been moved there. It has been refactored to match its use. Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 313b8bf..5ca7ae2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -1222,6 +1222,28 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) bus->drvr->busstate = BRCMF_BUS_DOWN; } +/* copy a buffer into a pkt buffer chain */ +static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_bus *bus, uint len) +{ + uint n, ret = 0; + struct sk_buff *p; + u8 *buf; + + p = bus->glom; + buf = bus->dataptr; + + /* copy the data */ + for (; p && len; p = p->next) { + n = min_t(uint, p->len, len); + memcpy(p->data, buf, n); + buf += n; + len -= n; + ret += n; + } + + return ret; +} + static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) { u16 dlen, totlen; @@ -1354,8 +1376,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) SDIO_FUNC_2, F2SYNC, bus->dataptr, dlen, NULL); - sublen = (u16) brcmu_pktfrombuf(pfirst, 0, dlen, - bus->dataptr); + sublen = (u16) brcmf_sdbrcm_glom_from_buf(bus, dlen); if (sublen != dlen) { brcmf_dbg(ERROR, "FAILED TO COPY, dlen %d sublen %d\n", dlen, sublen); diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index f27c489..11cfbdee 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -16,6 +16,7 @@ #include #include + #include MODULE_AUTHOR("Broadcom Corporation"); @@ -66,36 +67,6 @@ void brcmu_pkt_buf_free_skb(struct sk_buff *skb) EXPORT_SYMBOL(brcmu_pkt_buf_free_skb); -/* copy a buffer into a pkt buffer chain */ -uint brcmu_pktfrombuf(struct sk_buff *p, uint offset, int len, - unsigned char *buf) -{ - uint n, ret = 0; - - /* skip 'offset' bytes */ - for (; p && offset; p = p->next) { - if (offset < (uint) (p->len)) - break; - offset -= p->len; - } - - if (!p) - return 0; - - /* copy the data */ - for (; p && len; p = p->next) { - n = min((uint) (p->len) - offset, (uint) len); - memcpy(p->data + offset, buf, n); - buf += n; - len -= n; - ret += n; - offset = 0; - } - - return ret; -} -EXPORT_SYMBOL(brcmu_pktfrombuf); - /* return total length of buffer chain */ uint brcmu_pkttotlen(struct sk_buff *p) { diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index 7d0f46e..e5eac87 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h @@ -173,8 +173,6 @@ extern void brcmu_pktq_flush(struct pktq *pq, bool dir, /* externs */ /* packet */ -extern uint brcmu_pktfrombuf(struct sk_buff *p, - uint offset, int len, unsigned char *buf); extern uint brcmu_pkttotlen(struct sk_buff *p); /* ip address */ -- cgit v0.10.2 From 09c7dfa0f01e906671f303061babb7e6ddce2c92 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 18 Oct 2011 14:03:10 +0200 Subject: brcm80211: util: remove function brcmu_format_hex() from brcmutil The function brcmu_format_hex() filled a string buffer with byte values from a data buffer. The calling function used this string buffer in a printk. Now the calling function uses the kernel function print_hex_dump_bytes(). Reported-by: Johannes Berg Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index abb49fc..4f1d6e4 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -6044,7 +6044,6 @@ void brcms_c_print_txdesc(struct d11txh *txh) u8 *rtsph = txh->RTSPhyHeader; struct ieee80211_rts rts = txh->rts_frame; - char hexbuf[256]; /* add plcp header along with txh descriptor */ printk(KERN_DEBUG "Raw TxDesc + plcp header:\n"); @@ -6065,17 +6064,16 @@ void brcms_c_print_txdesc(struct d11txh *txh) printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); printk(KERN_DEBUG "\n"); - brcmu_format_hex(hexbuf, iv, sizeof(txh->IV)); - printk(KERN_DEBUG "SecIV: %s\n", hexbuf); - brcmu_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA)); - printk(KERN_DEBUG "RA: %s\n", hexbuf); + print_hex_dump_bytes("SecIV:", DUMP_PREFIX_OFFSET, iv, sizeof(txh->IV)); + print_hex_dump_bytes("RA:", DUMP_PREFIX_OFFSET, + ra, sizeof(txh->TxFrameRA)); printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); - brcmu_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback)); - printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); + print_hex_dump_bytes("Fb RTS PLCP:", DUMP_PREFIX_OFFSET, + rtspfb, sizeof(txh->RTSPLCPFallback)); printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); - brcmu_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback)); - printk(KERN_DEBUG "PLCP: %s ", hexbuf); + print_hex_dump_bytes("PLCP:", DUMP_PREFIX_OFFSET, + fragpfb, sizeof(txh->FragPLCPFallback)); printk(KERN_DEBUG "DUR: %04x", fragdfb); printk(KERN_DEBUG "\n"); @@ -6090,10 +6088,10 @@ void brcms_c_print_txdesc(struct d11txh *txh) printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); - brcmu_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader)); - printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); - brcmu_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame)); - printk(KERN_DEBUG "RTS Frame: %s", hexbuf); + print_hex_dump_bytes("RTS PLCP:", DUMP_PREFIX_OFFSET, + rtsph, sizeof(txh->RTSPhyHeader)); + print_hex_dump_bytes("RTS Frame:", DUMP_PREFIX_OFFSET, + (u8 *)&rts, sizeof(txh->rts_frame)); printk(KERN_DEBUG "\n"); } #endif /* defined(BCMDBG) */ diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index 11cfbdee..12b795f 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -335,23 +335,3 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0) } EXPORT_SYMBOL(brcmu_prpkt); #endif /* defined(BCMDBG) */ - -#if defined(BCMDBG) -/* - * print bytes formatted as hex to a string. return the resulting - * string length - */ -int brcmu_format_hex(char *str, const void *bytes, int len) -{ - int i; - char *p = str; - const u8 *src = (const u8 *)bytes; - - for (i = 0; i < len; i++) { - p += snprintf(p, 3, "%02X", *src); - src++; - } - return (int)(p - str); -} -EXPORT_SYMBOL(brcmu_format_hex); -#endif /* defined(BCMDBG) */ diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index e5eac87..ccf6015 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h @@ -178,16 +178,13 @@ extern uint brcmu_pkttotlen(struct sk_buff *p); /* ip address */ struct ipv4_addr; + +/* externs */ +/* format/print */ #ifdef BCMDBG extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); #else #define brcmu_prpkt(a, b) #endif /* BCMDBG */ -/* externs */ -/* format/print */ -#if defined(BCMDBG) -extern int brcmu_format_hex(char *str, const void *bytes, int len); -#endif - #endif /* _BRCMU_UTILS_H_ */ -- cgit v0.10.2 From 6cddafab54e9a17b2efefe982547865955a5ff3a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 18 Oct 2011 17:52:01 -0500 Subject: rtl8192cu: Add new device IDs The latest vendor (non-mac80211) driver of 9/22/2011 shows some new device IDs for rtl8192cu. In addition, some typos in the table are fixed and one duplicate is removed. Signed-off-by: Larry Finger Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index feed1ed..b9a158e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -274,6 +274,8 @@ static struct usb_device_id rtl8192c_usb_ids[] = { {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8191, rtl92cu_hal_cfg)}, /****** 8188CU ********/ + /* RTL8188CTV */ + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x018a, rtl92cu_hal_cfg)}, /* 8188CE-VAU USB minCard */ {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8170, rtl92cu_hal_cfg)}, /* 8188cu 1*1 dongle */ @@ -290,14 +292,14 @@ static struct usb_device_id rtl8192c_usb_ids[] = { {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817e, rtl92cu_hal_cfg)}, /* 8188RU in Alfa AWUS036NHR */ {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817f, rtl92cu_hal_cfg)}, + /* RTL8188CUS-VL */ + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x818a, rtl92cu_hal_cfg)}, /* 8188 Combo for BC4 */ {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8754, rtl92cu_hal_cfg)}, /****** 8192CU ********/ - /* 8191cu 1*2 */ - {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8177, rtl92cu_hal_cfg)}, /* 8192cu 2*2 */ - {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817b, rtl92cu_hal_cfg)}, + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8178, rtl92cu_hal_cfg)}, /* 8192CE-VAU USB minCard */ {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817c, rtl92cu_hal_cfg)}, @@ -308,13 +310,17 @@ static struct usb_device_id rtl8192c_usb_ids[] = { {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ {RTL_USB_DEVICE(0x0846, 0x9041, rtl92cu_hal_cfg)}, /*NetGear WNA1000M*/ - {RTL_USB_DEVICE(0x0Df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ + {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ + {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/ /* HP - Lite-On ,8188CUS Slim Combo */ {RTL_USB_DEVICE(0x103c, 0x1629, rtl92cu_hal_cfg)}, {RTL_USB_DEVICE(0x13d3, 0x3357, rtl92cu_hal_cfg)}, /* AzureWave */ {RTL_USB_DEVICE(0x2001, 0x3308, rtl92cu_hal_cfg)}, /*D-Link - Alpha*/ + {RTL_USB_DEVICE(0x2019, 0x4902, rtl92cu_hal_cfg)}, /*Planex - Etop*/ {RTL_USB_DEVICE(0x2019, 0xab2a, rtl92cu_hal_cfg)}, /*Planex - Abocom*/ + /*SW-WF02-AD15 -Abocom*/ + {RTL_USB_DEVICE(0x2019, 0xab2e, rtl92cu_hal_cfg)}, {RTL_USB_DEVICE(0x2019, 0xed17, rtl92cu_hal_cfg)}, /*PCI - Edimax*/ {RTL_USB_DEVICE(0x20f4, 0x648b, rtl92cu_hal_cfg)}, /*TRENDnet - Cameo*/ {RTL_USB_DEVICE(0x7392, 0x7811, rtl92cu_hal_cfg)}, /*Edimax - Edimax*/ @@ -325,14 +331,36 @@ static struct usb_device_id rtl8192c_usb_ids[] = { {RTL_USB_DEVICE(0x4855, 0x0091, rtl92cu_hal_cfg)}, /* NetweeN-Feixun */ {RTL_USB_DEVICE(0x9846, 0x9041, rtl92cu_hal_cfg)}, /* Netgear Cameo */ + /****** 8188 RU ********/ + /* Netcore */ + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x317f, rtl92cu_hal_cfg)}, + + /****** 8188CUS Slim Solo********/ + {RTL_USB_DEVICE(0x04f2, 0xaff7, rtl92cu_hal_cfg)}, /*Xavi*/ + {RTL_USB_DEVICE(0x04f2, 0xaff9, rtl92cu_hal_cfg)}, /*Xavi*/ + {RTL_USB_DEVICE(0x04f2, 0xaffa, rtl92cu_hal_cfg)}, /*Xavi*/ + + /****** 8188CUS Slim Combo ********/ + {RTL_USB_DEVICE(0x04f2, 0xaff8, rtl92cu_hal_cfg)}, /*Xavi*/ + {RTL_USB_DEVICE(0x04f2, 0xaffb, rtl92cu_hal_cfg)}, /*Xavi*/ + {RTL_USB_DEVICE(0x04f2, 0xaffc, rtl92cu_hal_cfg)}, /*Xavi*/ + {RTL_USB_DEVICE(0x2019, 0x1201, rtl92cu_hal_cfg)}, /*Planex-Vencer*/ + /****** 8192CU ********/ + {RTL_USB_DEVICE(0x050d, 0x2102, rtl92cu_hal_cfg)}, /*Belcom-Sercomm*/ + {RTL_USB_DEVICE(0x050d, 0x2103, rtl92cu_hal_cfg)}, /*Belcom-Edimax*/ {RTL_USB_DEVICE(0x0586, 0x341f, rtl92cu_hal_cfg)}, /*Zyxel -Abocom*/ {RTL_USB_DEVICE(0x07aa, 0x0056, rtl92cu_hal_cfg)}, /*ATKK-Gemtek*/ {RTL_USB_DEVICE(0x07b8, 0x8178, rtl92cu_hal_cfg)}, /*Funai -Abocom*/ + {RTL_USB_DEVICE(0x0846, 0x9021, rtl92cu_hal_cfg)}, /*Netgear-Sercomm*/ + {RTL_USB_DEVICE(0x0b05, 0x17ab, rtl92cu_hal_cfg)}, /*ASUS-Edimax*/ + {RTL_USB_DEVICE(0x0df6, 0x0061, rtl92cu_hal_cfg)}, /*Sitecom-Edimax*/ + {RTL_USB_DEVICE(0x0e66, 0x0019, rtl92cu_hal_cfg)}, /*Hawking-Edimax*/ {RTL_USB_DEVICE(0x2001, 0x3307, rtl92cu_hal_cfg)}, /*D-Link-Cameo*/ {RTL_USB_DEVICE(0x2001, 0x3309, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ {RTL_USB_DEVICE(0x2001, 0x330a, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ {RTL_USB_DEVICE(0x2019, 0xab2b, rtl92cu_hal_cfg)}, /*Planex -Abocom*/ + {RTL_USB_DEVICE(0x20f4, 0x624d, rtl92cu_hal_cfg)}, /*TRENDNet*/ {RTL_USB_DEVICE(0x7392, 0x7822, rtl92cu_hal_cfg)}, /*Edimax -Edimax*/ {} }; -- cgit v0.10.2 From b83db862ffb871e3131e5d2160c741b288eea9aa Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Wed, 19 Oct 2011 12:51:09 +0200 Subject: brcm80211: fmac: use sk_buff list for handling frames in receive path The functions in the receive patch of the fullmac now use sk_buff list and skb_queue_xx() functions instead of dealing with list pointers in the sk_buff directly. Reported-by: Johannes Berg Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 5ca7ae2..c6825f2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -574,7 +574,7 @@ struct brcmf_bus { uint txminmax; struct sk_buff *glomd; /* Packet containing glomming descriptor */ - struct sk_buff *glom; /* Packet chain for glommed superframe */ + struct sk_buff_head glom; /* Packet list for glommed superframe */ uint glomerr; /* Glom packet read errors */ u8 *rxbuf; /* Buffer for receiving control packets */ @@ -1229,16 +1229,17 @@ static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_bus *bus, uint len) struct sk_buff *p; u8 *buf; - p = bus->glom; buf = bus->dataptr; /* copy the data */ - for (; p && len; p = p->next) { + skb_queue_walk(&bus->glom, p) { n = min_t(uint, p->len, len); memcpy(p->data, buf, n); buf += n; len -= n; ret += n; + if (!len) + break; } return ret; @@ -1262,7 +1263,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* If packets, issue read(s) and send up packet chain */ /* Return sequence numbers consumed? */ - brcmf_dbg(TRACE, "start: glomd %p glom %p\n", bus->glomd, bus->glom); + brcmf_dbg(TRACE, "start: glomd %p glom %p\n", + bus->glomd, skb_peek(&bus->glom)); /* If there's a descriptor, generate the packet chain */ if (bus->glomd) { @@ -1309,12 +1311,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) num, sublen); break; } - if (!pfirst) { - pfirst = plast = pnext; - } else { - plast->next = pnext; - plast = pnext; - } + skb_queue_tail(&bus->glom, pnext); /* Adhere to start alignment requirements */ pkt_align(pnext, sublen, BRCMF_SDALIGN); @@ -1330,12 +1327,13 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", bus->nextlen, totlen, rxseq); } - bus->glom = pfirst; pfirst = pnext = NULL; } else { - if (pfirst) - brcmu_pkt_buf_free_skb(pfirst); - bus->glom = NULL; + if (!skb_queue_empty(&bus->glom)) + skb_queue_walk_safe(&bus->glom, pfirst, pnext) { + skb_unlink(pfirst, &bus->glom); + brcmu_pkt_buf_free_skb(pfirst); + } num = 0; } @@ -1347,17 +1345,17 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* Ok -- either we just generated a packet chain, or had one from before */ - if (bus->glom) { + if (!skb_queue_empty(&bus->glom)) { if (BRCMF_GLOM_ON()) { brcmf_dbg(GLOM, "try superframe read, packet chain:\n"); - for (pnext = bus->glom; pnext; pnext = pnext->next) { + skb_queue_walk(&bus->glom, pnext) { brcmf_dbg(GLOM, " %p: %p len 0x%04x (%d)\n", pnext, (u8 *) (pnext->data), pnext->len, pnext->len); } } - pfirst = bus->glom; + pfirst = skb_peek(&bus->glom); dlen = (u16) brcmu_pkttotlen(pfirst); /* Do an SDIO read for the superframe. Configurable iovar to @@ -1401,9 +1399,11 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) } else { bus->glomerr = 0; brcmf_sdbrcm_rxfail(bus, true, false); - brcmu_pkt_buf_free_skb(bus->glom); bus->rxglomfail++; - bus->glom = NULL; + skb_queue_walk_safe(&bus->glom, pfirst, pnext) { + skb_unlink(pfirst, &bus->glom); + brcmu_pkt_buf_free_skb(pfirst); + } } return 0; } @@ -1524,9 +1524,11 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) } else { bus->glomerr = 0; brcmf_sdbrcm_rxfail(bus, true, false); - brcmu_pkt_buf_free_skb(bus->glom); bus->rxglomfail++; - bus->glom = NULL; + skb_queue_walk_safe(&bus->glom, pfirst, pnext) { + skb_unlink(pfirst, &bus->glom); + brcmu_pkt_buf_free_skb(pfirst); + } } bus->nextlen = 0; return 0; @@ -1534,7 +1536,6 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* Basic SD framing looks ok - process each packet (header) */ save_pfirst = pfirst; - bus->glom = NULL; plast = NULL; for (num = 0; pfirst; rxseq++, pfirst = pnext) { @@ -1871,10 +1872,10 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) rxseq++, rxleft--) { /* Handle glomming separately */ - if (bus->glom || bus->glomd) { + if (bus->glomd || !skb_queue_empty(&bus->glom)) { u8 cnt; brcmf_dbg(GLOM, "calling rxglom: glomd %p, glom %p\n", - bus->glomd, bus->glom); + bus->glomd, skb_peek(&bus->glom)); cnt = brcmf_sdbrcm_rxglom(bus, rxseq); brcmf_dbg(GLOM, "rxglom returned %d\n", cnt); rxseq += cnt - 1; @@ -3623,6 +3624,8 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) u8 saveclk; uint retries; int err; + struct sk_buff *cur; + struct sk_buff *next; brcmf_dbg(TRACE, "Enter\n"); @@ -3682,11 +3685,11 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) /* Clear any held glomming stuff */ if (bus->glomd) brcmu_pkt_buf_free_skb(bus->glomd); - - if (bus->glom) - brcmu_pkt_buf_free_skb(bus->glom); - - bus->glom = bus->glomd = NULL; + if (!skb_queue_empty(&bus->glom)) + skb_queue_walk_safe(&bus->glom, cur, next) { + skb_unlink(cur, &bus->glom); + brcmu_pkt_buf_free_skb(cur); + } /* Clear rx control and wake any waiters */ bus->rxlen = 0; @@ -4461,6 +4464,7 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, bus->sdiodev = sdiodev; sdiodev->bus = bus; + skb_queue_head_init(&bus->glom); bus->txbound = BRCMF_TXBOUND; bus->rxbound = BRCMF_RXBOUND; bus->txminmax = BRCMF_TXMINMAX; -- cgit v0.10.2 From 152c477aa3eb8046b35aa7cde2782230064041d8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 21 Oct 2011 10:22:22 +0200 Subject: mac80211: exit cooked monitor RX early if there are none If there are no cooked monitor interfaces, there's no point in building the radiotap RX header for the frame and iterating the interface list. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index b867bd5..c74e542 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2489,6 +2489,10 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, goto out_free_skb; rx->flags |= IEEE80211_RX_CMNTR; + /* If there are no cooked monitor interfaces, just free the SKB */ + if (!local->cooked_mntrs) + goto out_free_skb; + if (skb_headroom(skb) < sizeof(*rthdr) && pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) goto out_free_skb; -- cgit v0.10.2 From ece960eae81c604aa14a1bf431eda34f4fe71c0c Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 21 Oct 2011 16:16:19 +0200 Subject: brcm80211: fmac: allow wd timer to be disabled when bus down Watchdog timer should be able to be stopped even firmware is not loaded. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index c6825f2..785ab08 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -4579,10 +4579,6 @@ struct device *brcmf_bus_get_device(struct brcmf_bus *bus) void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) { - /* don't start the wd until fw is loaded */ - if (bus->drvr->busstate == BRCMF_BUS_DOWN) - return; - /* Totally stop the timer */ if (!wdtick && bus->wd_timer_valid == true) { del_timer_sync(&bus->timer); @@ -4591,6 +4587,10 @@ brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) return; } + /* don't start the wd until fw is loaded */ + if (bus->drvr->busstate == BRCMF_BUS_DOWN) + return; + if (wdtick) { if (bus->save_ms != BRCMF_WD_POLL_MS) { if (bus->wd_timer_valid == true) -- cgit v0.10.2 From dfded557d8c0ff9f66c6d6c4959596148db05c8e Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 21 Oct 2011 16:16:20 +0200 Subject: brcm80211: fmac: use brcmf_del_if for all net devices Use brcmf_del_if for primary and virtual net device interfaces. This is part of the net device interface clean up for fullmac. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 4acbac5..6739ece 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -893,6 +893,16 @@ static int brcmf_netdev_open(struct net_device *ndev) return ret; } +static const struct net_device_ops brcmf_netdev_ops_pri = { + .ndo_open = brcmf_netdev_open, + .ndo_stop = brcmf_netdev_stop, + .ndo_get_stats = brcmf_netdev_get_stats, + .ndo_do_ioctl = brcmf_netdev_ioctl_entry, + .ndo_start_xmit = brcmf_netdev_start_xmit, + .ndo_set_mac_address = brcmf_netdev_set_mac_address, + .ndo_set_rx_mode = brcmf_netdev_set_multicast_list +}; + int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, char *name, u8 *mac_addr, u32 flags, u8 bssidx) @@ -977,14 +987,23 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) brcmf_dbg(ERROR, "Null interface\n"); return; } - ifp->state = BRCMF_E_IF_DEL; - ifp->idx = ifidx; - if (ifp->ndev != NULL) { - netif_stop_queue(ifp->ndev); + if (ifp->ndev) { + if (ifidx == 0) { + if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { + rtnl_lock(); + brcmf_netdev_stop(ifp->ndev); + rtnl_unlock(); + } + } else { + netif_stop_queue(ifp->ndev); + } + unregister_netdev(ifp->ndev); - free_netdev(ifp->ndev); drvr_priv->iflist[ifidx] = NULL; + if (ifidx == 0) + brcmf_cfg80211_detach(drvr_priv->pub.config); + free_netdev(ifp->ndev); kfree(ifp); } } @@ -1123,16 +1142,6 @@ int brcmf_bus_start(struct brcmf_pub *drvr) return 0; } -static struct net_device_ops brcmf_netdev_ops_pri = { - .ndo_open = brcmf_netdev_open, - .ndo_stop = brcmf_netdev_stop, - .ndo_get_stats = brcmf_netdev_get_stats, - .ndo_do_ioctl = brcmf_netdev_ioctl_entry, - .ndo_start_xmit = brcmf_netdev_start_xmit, - .ndo_set_mac_address = brcmf_netdev_set_mac_address, - .ndo_set_rx_mode = brcmf_netdev_set_multicast_list -}; - int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) { struct brcmf_info *drvr_priv = drvr->info; @@ -1210,21 +1219,13 @@ void brcmf_detach(struct brcmf_pub *drvr) if (drvr) { drvr_priv = drvr->info; if (drvr_priv) { - struct brcmf_if *ifp; int i; - for (i = 1; i < BRCMF_MAX_IFS; i++) + /* make sure primary interface removed last */ + for (i = BRCMF_MAX_IFS-1; i > -1; i--) if (drvr_priv->iflist[i]) brcmf_del_if(drvr_priv, i); - ifp = drvr_priv->iflist[0]; - if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { - rtnl_lock(); - brcmf_netdev_stop(ifp->ndev); - rtnl_unlock(); - unregister_netdev(ifp->ndev); - } - cancel_work_sync(&drvr_priv->setmacaddr_work); cancel_work_sync(&drvr_priv->multicast_work); @@ -1233,10 +1234,6 @@ void brcmf_detach(struct brcmf_pub *drvr) if (drvr->prot) brcmf_proto_detach(drvr); - brcmf_cfg80211_detach(drvr->config); - - free_netdev(ifp->ndev); - kfree(ifp); kfree(drvr_priv); } } -- cgit v0.10.2 From 0bf1f883fd0ad0b6f55974aad6682de43f7305dd Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:21 +0200 Subject: brcm80211: smac: removed MPC related code The chip init sequence enables MPC (Minimum Power Consumption), but the driver disables it after that. As there are no interfaces to enable this mode the related code is unused (member variable wlc->mpc is false). Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 7a24a83..1781157 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1079,7 +1079,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, wl->pub->ieee_hw = hw; /* disable mpc */ - brcms_c_set_radio_mpc(wl->wlc, false); + brcms_c_set_radio_mpc(wl->wlc); /* register our interrupt handler */ if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 4f1d6e4..4687983 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -419,20 +419,6 @@ static int brcms_chspec_bw(u16 chanspec) return BRCMS_10_MHZ; } -/* - * return true if Minimum Power Consumption should - * be entered, false otherwise - */ -static bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc) -{ - return false; -} - -static bool brcms_c_ismpc(struct brcms_c_info *wlc) -{ - return (wlc->mpc_delay_off == 0) && (brcms_c_is_non_delay_mpc(wlc)); -} - static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) { if (cfg == NULL) @@ -4350,56 +4336,18 @@ static void brcms_b_watchdog(void *arg) static void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) { - bool mpc_radio, radio_state; - /* * Clear the WL_RADIO_MPC_DISABLE bit when mpc feature is disabled * in case the WL_RADIO_MPC_DISABLE bit was set. Stop the radio * monitor also when WL_RADIO_MPC_DISABLE is the only reason that * the radio is going down. */ - if (!wlc->mpc) { - if (!wlc->pub->radio_disabled) - return; - mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); - brcms_c_radio_upd(wlc); - if (!wlc->pub->radio_disabled) - brcms_c_radio_monitor_stop(wlc); + if (!wlc->pub->radio_disabled) return; - } - - /* - * sync ismpc logic with WL_RADIO_MPC_DISABLE bit in - * wlc->pub->radio_disabled to go ON, always call radio_upd - * synchronously to go OFF, postpone radio_upd to later when - * context is safe(e.g. watchdog) - */ - radio_state = - (mboolisset(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE) ? OFF : - ON); - mpc_radio = (brcms_c_ismpc(wlc) == true) ? OFF : ON; - - if (radio_state == ON && mpc_radio == OFF) - wlc->mpc_delay_off = wlc->mpc_dlycnt; - else if (radio_state == OFF && mpc_radio == ON) { - mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); - brcms_c_radio_upd(wlc); - if (wlc->mpc_offcnt < BRCMS_MPC_THRESHOLD) - wlc->mpc_dlycnt = BRCMS_MPC_MAX_DELAYCNT; - else - wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; - } - /* - * Below logic is meant to capture the transition from mpc off - * to mpc on for reasons other than wlc->mpc_delay_off keeping - * the mpc off. In that case reset wlc->mpc_delay_off to - * wlc->mpc_dlycnt, so that we restart the countdown of mpc_delay_off - */ - if ((wlc->prev_non_delay_mpc == false) && - (brcms_c_is_non_delay_mpc(wlc) == true) && wlc->mpc_delay_off) - wlc->mpc_delay_off = wlc->mpc_dlycnt; - - wlc->prev_non_delay_mpc = brcms_c_is_non_delay_mpc(wlc); + mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); + brcms_c_radio_upd(wlc); + if (!wlc->pub->radio_disabled) + brcms_c_radio_monitor_stop(wlc); } /* common watchdog code */ @@ -4427,8 +4375,6 @@ static void brcms_c_watchdog(void *arg) if (--wlc->mpc_delay_off == 0) { mboolset(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); - if (wlc->mpc && brcms_c_ismpc(wlc)) - wlc->mpc_offcnt = 0; } } @@ -5200,9 +5146,6 @@ static void brcms_c_ap_upd(struct brcms_c_info *wlc) { /* STA-BSS; short capable */ wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; - - /* fixup mpc */ - wlc->mpc = true; } /* Initialize just the hardware when coming out of POR or S3/S5 system states */ @@ -8192,9 +8135,8 @@ int brcms_c_get_tx_power(struct brcms_c_info *wlc) return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); } -void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc) +void brcms_c_set_radio_mpc(struct brcms_c_info *wlc) { - wlc->mpc = mpc; brcms_c_radio_mpc_upd(wlc); } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index c0e0fcf..37c55fd 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -427,7 +427,6 @@ struct brcms_txq_info { * bandinit_pending: track band init in auto band. * radio_monitor: radio timer is running. * going_down: down path intermediate variable. - * mpc: enable minimum power consumption. * mpc_dlycnt: # of watchdog cnt before turn disable radio. * mpc_offcnt: # of watchdog cnt that radio is disabled. * mpc_delay_off: delay radio disable by # of watchdog cnt. @@ -522,7 +521,6 @@ struct brcms_c_info { bool radio_monitor; bool going_down; - bool mpc; u8 mpc_dlycnt; u8 mpc_offcnt; u8 mpc_delay_off; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index d20116a..2e09216 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -596,7 +596,7 @@ extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval); extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); extern int brcms_c_get_tx_power(struct brcms_c_info *wlc); -extern void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc); +extern void brcms_c_set_radio_mpc(struct brcms_c_info *wlc); extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); #endif /* _BRCM_PUB_H_ */ -- cgit v0.10.2 From 4412953061def953a6458f9f1b277e442f83c919 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:22 +0200 Subject: brcm80211: smac: removed MPC related variables Several member variables were never read. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 4687983..e7d14e4 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -4303,10 +4303,6 @@ static void brcms_c_radio_timer(void *arg) return; } - /* cap mpc off count */ - if (wlc->mpc_offcnt < BRCMS_MPC_MAX_DELAYCNT) - wlc->mpc_offcnt++; - brcms_c_radio_hwdisable_upd(wlc); brcms_c_radio_upd(wlc); } @@ -4488,7 +4484,7 @@ static void brcms_c_info_init(struct brcms_c_info *wlc, int unit) wlc->pub->bcmerror = 0; /* initialize mpc delay */ - wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; + wlc->mpc_delay_off = BRCMS_MPC_MIN_DELAYCNT; } static uint brcms_c_attach_module(struct brcms_c_info *wlc) @@ -8447,7 +8443,7 @@ void brcms_c_init(struct brcms_c_info *wlc) W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); /* initialize mpc delay */ - wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; + wlc->mpc_delay_off = BRCMS_MPC_MIN_DELAYCNT; /* * Initialize WME parameters; if they haven't been set by some other diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index 37c55fd..fc5852f 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -427,10 +427,7 @@ struct brcms_txq_info { * bandinit_pending: track band init in auto band. * radio_monitor: radio timer is running. * going_down: down path intermediate variable. - * mpc_dlycnt: # of watchdog cnt before turn disable radio. - * mpc_offcnt: # of watchdog cnt that radio is disabled. * mpc_delay_off: delay radio disable by # of watchdog cnt. - * prev_non_delay_mpc: prev state brcms_c_is_non_delay_mpc. * wdtimer: timer for watchdog routine. * radio_timer: timer for hw radio button monitor routine. * monitor: monitor (MPDU sniffing) mode. @@ -521,10 +518,7 @@ struct brcms_c_info { bool radio_monitor; bool going_down; - u8 mpc_dlycnt; - u8 mpc_offcnt; u8 mpc_delay_off; - u8 prev_non_delay_mpc; struct brcms_timer *wdtimer; struct brcms_timer *radio_timer; -- cgit v0.10.2 From 28237002e726bfaeb3ab682ec5574d697a15e00d Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:23 +0200 Subject: brcm80211: smac: removed down-on-watchdog MPC functionality Softmac would bring its interface down on a certain Minimum Power Save related condition, without Mac80211 intervention. Because Mac80211 should be the only party initiating interfaces going up and down, this functionality has been removed. All notions of 'MPC' have been removed in the code as well. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 1781157..fe8f1ec 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1078,8 +1078,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, wl->pub->ieee_hw = hw; - /* disable mpc */ - brcms_c_set_radio_mpc(wl->wlc); + brcms_c_set_radio_mon(wl->wlc); /* register our interrupt handler */ if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index e7d14e4..d185eed 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -43,16 +43,6 @@ /* radio monitor timer, in unit of ms */ #define TIMER_INTERVAL_RADIOCHK 800 -/* Max MPC timeout, in unit of watchdog */ -#ifndef BRCMS_MPC_MAX_DELAYCNT -#define BRCMS_MPC_MAX_DELAYCNT 10 -#endif - -/* Min MPC timeout, in unit of watchdog */ -#define BRCMS_MPC_MIN_DELAYCNT 1 -/* MPC count threshold level */ -#define BRCMS_MPC_THRESHOLD 3 - /* beacon interval, in unit of 1024TU */ #define BEACON_INTERVAL_DEFAULT 100 @@ -4330,17 +4320,13 @@ static void brcms_b_watchdog(void *arg) wlc_phy_watchdog(wlc_hw->band->pi); } -static void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) +static void brcms_c_radio_mon_upd(struct brcms_c_info *wlc) { /* - * Clear the WL_RADIO_MPC_DISABLE bit when mpc feature is disabled - * in case the WL_RADIO_MPC_DISABLE bit was set. Stop the radio - * monitor also when WL_RADIO_MPC_DISABLE is the only reason that - * the radio is going down. + * Stop the radio monitor when the radio is going down. */ if (!wlc->pub->radio_disabled) return; - mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); brcms_c_radio_upd(wlc); if (!wlc->pub->radio_disabled) brcms_c_radio_monitor_stop(wlc); @@ -4366,17 +4352,8 @@ static void brcms_c_watchdog(void *arg) /* increment second count */ wlc->pub->now++; - /* delay radio disable */ - if (wlc->mpc_delay_off) { - if (--wlc->mpc_delay_off == 0) { - mboolset(wlc->pub->radio_disabled, - WL_RADIO_MPC_DISABLE); - } - } - - /* mpc sync */ - brcms_c_radio_mpc_upd(wlc); - /* radio sync: sw/hw/mpc --> radio_disable/radio_enable */ + brcms_c_radio_mon_upd(wlc); + /* radio sync: sw/hw --> radio_disable/radio_enable */ brcms_c_radio_hwdisable_upd(wlc); brcms_c_radio_upd(wlc); /* if radio is disable, driver may be down, quit here */ @@ -4482,9 +4459,6 @@ static void brcms_c_info_init(struct brcms_c_info *wlc, int unit) /* WME QoS mode is Auto by default */ wlc->pub->_ampdu = AMPDU_AGG_HOST; wlc->pub->bcmerror = 0; - - /* initialize mpc delay */ - wlc->mpc_delay_off = BRCMS_MPC_MIN_DELAYCNT; } static uint brcms_c_attach_module(struct brcms_c_info *wlc) @@ -5455,7 +5429,6 @@ uint brcms_c_down(struct brcms_c_info *wlc) if (!wlc->pub->up) return callbacks; - /* in between, mpc could try to bring down again.. */ wlc->going_down = true; callbacks += brcms_b_bmac_down_prep(wlc->hw); @@ -8131,9 +8104,9 @@ int brcms_c_get_tx_power(struct brcms_c_info *wlc) return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); } -void brcms_c_set_radio_mpc(struct brcms_c_info *wlc) +void brcms_c_set_radio_mon(struct brcms_c_info *wlc) { - brcms_c_radio_mpc_upd(wlc); + brcms_c_radio_mon_upd(wlc); } /* Process received frames */ @@ -8442,9 +8415,6 @@ void brcms_c_init(struct brcms_c_info *wlc) /* enable the RF Disable Delay timer */ W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); - /* initialize mpc delay */ - wlc->mpc_delay_off = BRCMS_MPC_MIN_DELAYCNT; - /* * Initialize WME parameters; if they haven't been set by some other * mechanism (IOVar, etc) then read them from the hardware. @@ -8630,8 +8600,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, brcms_c_ht_update_sgi_rx(wlc, 0); } - /* initialize radio_mpc_disable according to wlc->mpc */ - brcms_c_radio_mpc_upd(wlc); + brcms_c_radio_mon_upd(wlc); brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); if (perr) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index fc5852f..9a7535d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -427,7 +427,6 @@ struct brcms_txq_info { * bandinit_pending: track band init in auto band. * radio_monitor: radio timer is running. * going_down: down path intermediate variable. - * mpc_delay_off: delay radio disable by # of watchdog cnt. * wdtimer: timer for watchdog routine. * radio_timer: timer for hw radio button monitor routine. * monitor: monitor (MPDU sniffing) mode. @@ -518,8 +517,6 @@ struct brcms_c_info { bool radio_monitor; bool going_down; - u8 mpc_delay_off; - struct brcms_timer *wdtimer; struct brcms_timer *radio_timer; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 2e09216..4f8e859 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -596,7 +596,7 @@ extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval); extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); extern int brcms_c_get_tx_power(struct brcms_c_info *wlc); -extern void brcms_c_set_radio_mpc(struct brcms_c_info *wlc); +extern void brcms_c_set_radio_mon(struct brcms_c_info *wlc); extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); #endif /* _BRCM_PUB_H_ */ diff --git a/drivers/net/wireless/brcm80211/include/defs.h b/drivers/net/wireless/brcm80211/include/defs.h index 1e5f310..f0d8c04 100644 --- a/drivers/net/wireless/brcm80211/include/defs.h +++ b/drivers/net/wireless/brcm80211/include/defs.h @@ -62,7 +62,6 @@ #define WL_RADIO_SW_DISABLE (1<<0) #define WL_RADIO_HW_DISABLE (1<<1) -#define WL_RADIO_MPC_DISABLE (1<<2) /* some countries don't support any channel */ #define WL_RADIO_COUNTRY_DISABLE (1<<3) -- cgit v0.10.2 From 43ac09722f8e8f69cb528877c4b853cf9b96d9d7 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:24 +0200 Subject: brcm80211: smac: removed down-on-rf-kill functionality Softmac would bring its interface down on an RF kill switch condition, without Mac80211 intervention. Because Mac80211 should be the only party initiating interfaces going up and down, this functionality has been removed. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index fe8f1ec..915b741 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1078,8 +1078,6 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, wl->pub->ieee_hw = hw; - brcms_c_set_radio_mon(wl->wlc); - /* register our interrupt handler */ if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index d185eed..2fecf06 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -4194,17 +4194,6 @@ static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) } } -/* maintain LED behavior in down state */ -static void brcms_c_down_led_upd(struct brcms_c_info *wlc) -{ - /* - * maintain LEDs while in down state, turn on sbclk if - * not available yet. Turn on sbclk if necessary - */ - brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_FLIP); - brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_FLIP); -} - static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) { /* Don't start the timer if HWRADIO feature is disabled */ @@ -4216,28 +4205,6 @@ static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); } -static void brcms_c_radio_disable(struct brcms_c_info *wlc) -{ - if (!wlc->pub->up) { - brcms_c_down_led_upd(wlc); - return; - } - - brcms_c_radio_monitor_start(wlc); - brcms_down(wlc->wl); -} - -static void brcms_c_radio_enable(struct brcms_c_info *wlc) -{ - if (wlc->pub->up) - return; - - if (brcms_deviceremoved(wlc)) - return; - - brcms_up(wlc->wl); -} - static bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) { if (!wlc->radio_monitor) @@ -4260,18 +4227,6 @@ static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); } -/* - * centralized radio disable/enable function, - * invoke radio enable/disable after updating hwradio status - */ -static void brcms_c_radio_upd(struct brcms_c_info *wlc) -{ - if (wlc->pub->radio_disabled) - brcms_c_radio_disable(wlc); - else - brcms_c_radio_enable(wlc); -} - /* update hwradio status and return it */ bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) { @@ -4294,7 +4249,6 @@ static void brcms_c_radio_timer(void *arg) } brcms_c_radio_hwdisable_upd(wlc); - brcms_c_radio_upd(wlc); } /* common low-level watchdog code */ @@ -4320,18 +4274,6 @@ static void brcms_b_watchdog(void *arg) wlc_phy_watchdog(wlc_hw->band->pi); } -static void brcms_c_radio_mon_upd(struct brcms_c_info *wlc) -{ - /* - * Stop the radio monitor when the radio is going down. - */ - if (!wlc->pub->radio_disabled) - return; - brcms_c_radio_upd(wlc); - if (!wlc->pub->radio_disabled) - brcms_c_radio_monitor_stop(wlc); -} - /* common watchdog code */ static void brcms_c_watchdog(void *arg) { @@ -4352,10 +4294,7 @@ static void brcms_c_watchdog(void *arg) /* increment second count */ wlc->pub->now++; - brcms_c_radio_mon_upd(wlc); - /* radio sync: sw/hw --> radio_disable/radio_enable */ brcms_c_radio_hwdisable_upd(wlc); - brcms_c_radio_upd(wlc); /* if radio is disable, driver may be down, quit here */ if (wlc->pub->radio_disabled) return; @@ -8104,11 +8043,6 @@ int brcms_c_get_tx_power(struct brcms_c_info *wlc) return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); } -void brcms_c_set_radio_mon(struct brcms_c_info *wlc) -{ - brcms_c_radio_mon_upd(wlc); -} - /* Process received frames */ /* * Return true if more frames need to be processed. false otherwise. @@ -8600,7 +8534,6 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, brcms_c_ht_update_sgi_rx(wlc, 0); } - brcms_c_radio_mon_upd(wlc); brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); if (perr) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 4f8e859..97b9cce 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -596,7 +596,6 @@ extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval); extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); extern int brcms_c_get_tx_power(struct brcms_c_info *wlc); -extern void brcms_c_set_radio_mon(struct brcms_c_info *wlc); extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); #endif /* _BRCM_PUB_H_ */ -- cgit v0.10.2 From a8bc4917ed6bd6101569630708baaac14504ab8c Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:25 +0200 Subject: brcm80211: smac: bugfix for tx mute in brcms_b_init() Transmit can only be muted if the mac core is enabled. When brcms_b_init() is called, the mac core is suspended. Brcms_b_init() calls a transmit mute function that requires an enabled mac core. This code path is never taken, but would have been taken in subsequent patches. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 2fecf06..8eb665e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -2452,6 +2452,7 @@ static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, } } +/* precondition: requires the mac core to be enabled */ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) { static const u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; @@ -3354,8 +3355,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) } void -static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, - bool mute) { +static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec) { u32 macintmask; bool fastclk; struct brcms_c_info *wlc = wlc_hw->wlc; @@ -3380,10 +3380,6 @@ static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, /* core-specific initialization */ brcms_b_coreinit(wlc); - /* suspend the tx fifos and mute the phy for preism cac time */ - if (mute) - brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); - /* band-specific inits */ brcms_b_bsinit(wlc, chanspec); @@ -8261,7 +8257,7 @@ void brcms_c_init(struct brcms_c_info *wlc) { struct d11regs __iomem *regs; u16 chanspec; - bool mute = false; + bool mute_tx = false; BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); @@ -8277,7 +8273,7 @@ void brcms_c_init(struct brcms_c_info *wlc) else chanspec = brcms_c_init_chanspec(wlc); - brcms_b_init(wlc->hw, chanspec, mute); + brcms_b_init(wlc->hw, chanspec); /* update beacon listen interval */ brcms_c_bcn_li_upd(wlc); @@ -8343,6 +8339,10 @@ void brcms_c_init(struct brcms_c_info *wlc) /* ..now really unleash hell (allow the MAC out of suspend) */ brcms_c_enable_mac(wlc); + /* suspend the tx fifos and mute the phy for preism cac time */ + if (mute_tx) + brcms_b_mute(wlc->hw, ON, PHY_MUTE_FOR_PREISM); + /* clear tx flow control */ brcms_c_txflowcontrol_reset(wlc); -- cgit v0.10.2 From c6c44893c864429a7c6a4f7942dfb3ee182b4ad1 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:26 +0200 Subject: brcm80211: smac: fixed inconsistency in transmit mute Transmit was muted in two ways: full mute and a partial mute called 'pre ism cac time' mute. But, this 'pre ism cac time' mute was done at one place in the code (when tx_mute == false), and overridden later on in another place in code. To fix this, the 'pre ism cac time' mute has been replaced by a non mute. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 8eb665e..cc74205 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -2453,11 +2453,11 @@ static void brcms_b_tx_fifo_resume(struct brcms_hardware *wlc_hw, } /* precondition: requires the mac core to be enabled */ -static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) +static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool mute_tx) { static const u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; - if (on) { + if (mute_tx) { /* suspend tx fifos */ brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); @@ -2479,9 +2479,9 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) wlc_hw->etheraddr); } - wlc_phy_mute_upd(wlc_hw->band->pi, on, flags); + wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); - if (on) + if (mute_tx) brcms_c_ucode_mute_override_set(wlc_hw); else brcms_c_ucode_mute_override_clear(wlc_hw); @@ -3892,7 +3892,7 @@ static void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, - bool mute, struct txpwr_limits *txpwr) + bool mute_tx, struct txpwr_limits *txpwr) { uint bandunit; @@ -3918,7 +3918,7 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, } } - wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); + wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); if (!wlc_hw->up) { if (wlc_hw->clk) @@ -3930,7 +3930,7 @@ brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); /* Update muting of the channel */ - brcms_b_mute(wlc_hw, mute, 0); + brcms_b_mute(wlc_hw, mute_tx); } } @@ -8341,7 +8341,7 @@ void brcms_c_init(struct brcms_c_info *wlc) /* suspend the tx fifos and mute the phy for preism cac time */ if (mute_tx) - brcms_b_mute(wlc->hw, ON, PHY_MUTE_FOR_PREISM); + brcms_b_mute(wlc->hw, true); /* clear tx flow control */ brcms_c_txflowcontrol_reset(wlc); -- cgit v0.10.2 From 2646c46d56792bdb370784d1cd6e696a7b3bbf67 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:27 +0200 Subject: brcm80211: smac: modified Mac80211 callback interface Upon ops_start(), a Mac80211 driver should enable receive functionality to support monitor mode. Also, upon ops_stop(), it should disable rx. Driver did not follow this rule so code has been changed. Reported-by: Johannes Berg Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 915b741..f38ba17 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -284,6 +284,7 @@ static int brcms_ops_start(struct ieee80211_hw *hw) { struct brcms_info *wl = hw->priv; bool blocked; + int err; ieee80211_wake_queues(hw); spin_lock_bh(&wl->lock); @@ -292,20 +293,48 @@ static int brcms_ops_start(struct ieee80211_hw *hw) if (!blocked) wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); - return 0; + spin_lock_bh(&wl->lock); + if (!wl->pub->up) + err = brcms_up(wl); + else + err = -ENODEV; + spin_unlock_bh(&wl->lock); + + if (err != 0) + wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, + err); + return err; } static void brcms_ops_stop(struct ieee80211_hw *hw) { + struct brcms_info *wl = hw->priv; + int status; + ieee80211_stop_queues(hw); + + if (wl->wlc == NULL) + return; + + spin_lock_bh(&wl->lock); + status = brcms_c_chipmatch(wl->wlc->hw->vendorid, + wl->wlc->hw->deviceid); + spin_unlock_bh(&wl->lock); + if (!status) { + wiphy_err(wl->wiphy, + "wl: brcms_ops_stop: chipmatch failed\n"); + return; + } + + /* put driver in down state */ + spin_lock_bh(&wl->lock); + brcms_down(wl); + spin_unlock_bh(&wl->lock); } static int brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct brcms_info *wl; - int err; - /* Just STA for now */ if (vif->type != NL80211_IFTYPE_AP && vif->type != NL80211_IFTYPE_MESH_POINT && @@ -317,32 +346,12 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) return -EOPNOTSUPP; } - wl = hw->priv; - spin_lock_bh(&wl->lock); - if (!wl->pub->up) - err = brcms_up(wl); - else - err = -ENODEV; - spin_unlock_bh(&wl->lock); - - if (err != 0) - wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, - err); - - return err; + return 0; } static void brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct brcms_info *wl; - - wl = hw->priv; - - /* put driver in down state */ - spin_lock_bh(&wl->lock); - brcms_down(wl); - spin_unlock_bh(&wl->lock); } static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) @@ -874,37 +883,18 @@ static void brcms_free(struct brcms_info *wl) } /* -* called from both kernel as from this kernel module. +* called from both kernel as from this kernel module (error flow on attach) * precondition: perimeter lock is not acquired. */ static void brcms_remove(struct pci_dev *pdev) { - struct brcms_info *wl; - struct ieee80211_hw *hw; - int status; - - hw = pci_get_drvdata(pdev); - wl = hw->priv; - if (!wl) { - pr_err("wl: brcms_remove: pci_get_drvdata failed\n"); - return; - } + struct ieee80211_hw *hw = pci_get_drvdata(pdev); + struct brcms_info *wl = hw->priv; - spin_lock_bh(&wl->lock); - status = brcms_c_chipmatch(pdev->vendor, pdev->device); - spin_unlock_bh(&wl->lock); - if (!status) { - wiphy_err(wl->wiphy, "wl: brcms_remove: chipmatch " - "failed\n"); - return; - } if (wl->wlc) { wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); ieee80211_unregister_hw(hw); - spin_lock_bh(&wl->lock); - brcms_down(wl); - spin_unlock_bh(&wl->lock); } pci_disable_device(pdev); -- cgit v0.10.2 From dc460127898cab9014fb06281e0bad37b198bd83 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:28 +0200 Subject: brcm80211: smac: mute transmit on ops_start Monitor mode functionality (not functional yet) requires transmit to be muted after ops_start() is called, transmit is unmuted when the first interface is added. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index f38ba17..824c608 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -294,6 +294,9 @@ static int brcms_ops_start(struct ieee80211_hw *hw) wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); spin_lock_bh(&wl->lock); + /* avoid acknowledging frames before a non-monitor device is added */ + wl->mute_tx = true; + if (!wl->pub->up) err = brcms_up(wl); else @@ -335,6 +338,8 @@ static void brcms_ops_stop(struct ieee80211_hw *hw) static int brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { + struct brcms_info *wl = hw->priv; + /* Just STA for now */ if (vif->type != NL80211_IFTYPE_AP && vif->type != NL80211_IFTYPE_MESH_POINT && @@ -346,6 +351,9 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) return -EOPNOTSUPP; } + wl->mute_tx = false; + brcms_c_mute(wl->wlc, false); + return 0; } @@ -1303,8 +1311,7 @@ void brcms_init(struct brcms_info *wl) { BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); brcms_reset(wl); - - brcms_c_init(wl->wlc); + brcms_c_init(wl->wlc, wl->mute_tx); } /* diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h index 5c279c0..6242f18 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h @@ -80,6 +80,7 @@ struct brcms_info { struct brcms_firmware fw; struct wiphy *wiphy; struct brcms_ucode ucode; + bool mute_tx; }; /* misc callbacks */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index cc74205..3f8a6c7 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -2396,6 +2396,7 @@ void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); } +/* assumes that the d11 MAC is enabled */ static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, uint tx_fifo) { @@ -2487,6 +2488,12 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool mute_tx) brcms_c_ucode_mute_override_clear(wlc_hw); } +void +brcms_c_mute(struct brcms_c_info *wlc, bool mute_tx) +{ + brcms_b_mute(wlc->hw, mute_tx); +} + /* * Read and clear macintmask and macintstatus and intstatus registers. * This routine should be called with interrupts off @@ -8253,11 +8260,10 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) return wlc->macintstatus != 0; } -void brcms_c_init(struct brcms_c_info *wlc) +void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) { struct d11regs __iomem *regs; u16 chanspec; - bool mute_tx = false; BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 97b9cce..022523a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -540,7 +540,7 @@ extern int brcms_c_up(struct brcms_c_info *wlc); extern uint brcms_c_down(struct brcms_c_info *wlc); extern bool brcms_c_chipmatch(u16 vendor, u16 device); -extern void brcms_c_init(struct brcms_c_info *wlc); +extern void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx); extern void brcms_c_reset(struct brcms_c_info *wlc); extern void brcms_c_intrson(struct brcms_c_info *wlc); @@ -597,5 +597,6 @@ extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); extern int brcms_c_get_tx_power(struct brcms_c_info *wlc); extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); +extern void brcms_c_mute(struct brcms_c_info *wlc, bool on); #endif /* _BRCM_PUB_H_ */ -- cgit v0.10.2 From 1525662ac280e61feb1af7778881241b542dc075 Mon Sep 17 00:00:00 2001 From: Roland Vossen Date: Fri, 21 Oct 2011 16:16:29 +0200 Subject: brcm80211: smac: changed check to confirm STA only support The driver currently only supports STA operation. However, in brcms_ops_add_interface() also AP and SSID mode were accepted. Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 824c608..8e35c62 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -341,11 +341,7 @@ brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct brcms_info *wl = hw->priv; /* Just STA for now */ - if (vif->type != NL80211_IFTYPE_AP && - vif->type != NL80211_IFTYPE_MESH_POINT && - vif->type != NL80211_IFTYPE_STATION && - vif->type != NL80211_IFTYPE_WDS && - vif->type != NL80211_IFTYPE_ADHOC) { + if (vif->type != NL80211_IFTYPE_STATION) { wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only" " STA for now\n", __func__, vif->type); return -EOPNOTSUPP; -- cgit v0.10.2 From 81d2e2d148c2263f29a971d027f04c6e2c87e0d2 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 21 Oct 2011 16:16:30 +0200 Subject: brcm80211: smac: rename buffer endianess conversion functions The functions ltoh16_buf() and htol16_buf() have been renamed to le16_to_cpu_buf() and cpu_to_le16_buf() for more clarity what it does. Reported-by: Joe Perches Reported-by: Larry Finger Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 66aa0e7..8f1cf2f 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -617,14 +617,14 @@ static uint mask_width(u16 mask) return 0; } -static inline void ltoh16_buf(u16 *buf, unsigned int size) +static inline void le16_to_cpu_buf(u16 *buf, unsigned int size) { size /= 2; while (size--) *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); } -static inline void htol16_buf(u16 *buf, unsigned int size) +static inline void cpu_to_le16_buf(u16 *buf, unsigned int size) { size /= 2; while (size--) @@ -807,7 +807,7 @@ sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, err = -EIO; else /* now correct the endianness of the byte array */ - ltoh16_buf(buf, nbytes); + le16_to_cpu_buf(buf, nbytes); return err; } @@ -837,13 +837,13 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) return -ENODATA; /* fixup the endianness so crc8 will pass */ - htol16_buf(buf, bufsz); + cpu_to_le16_buf(buf, bufsz); if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) err = -EIO; /* now correct the endianness of the byte array */ - ltoh16_buf(buf, bufsz); + le16_to_cpu_buf(buf, bufsz); return err; } -- cgit v0.10.2 From 3fd172d30b59d9b73cb35ab263a1f0173dae974c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 21 Oct 2011 16:16:31 +0200 Subject: brcm80211: smac: use sk_buff list for handling frames in receive path In the receive path the frames are obtained from the dma using multiple sk_buff that were linked using the skb next pointer. This has been changed and it now used sk_buff lists and skb_queue functions instead. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 08960ce..ae541fb 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -14,7 +14,6 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include -#include #include #include @@ -901,7 +900,7 @@ static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) /* * !! rx entry routine - * returns a pointer to the next frame received, or NULL if there are no more + * returns the number packages in the next frame, or 0 if there are no more * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is * supported with pkts chain * otherwise, it's treated as giant pkt and will be tossed. @@ -909,38 +908,40 @@ static struct sk_buff *_dma_getnextrxp(struct dma_info *di, bool forceall) * buffer data. After it reaches the max size of buffer, the data continues * in next DMA descriptor buffer WITHOUT DMA header */ -struct sk_buff *dma_rx(struct dma_pub *pub) +int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list) { struct dma_info *di = (struct dma_info *)pub; - struct sk_buff *p, *head, *tail; + struct sk_buff_head dma_frames; + struct sk_buff *p, *next; uint len; uint pkt_len; int resid = 0; + int pktcnt = 1; + skb_queue_head_init(&dma_frames); next_frame: - head = _dma_getnextrxp(di, false); - if (head == NULL) - return NULL; + p = _dma_getnextrxp(di, false); + if (p == NULL) + return 0; - len = le16_to_cpu(*(__le16 *) (head->data)); + len = le16_to_cpu(*(__le16 *) (p->data)); DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); - dma_spin_for_len(len, head); + dma_spin_for_len(len, p); /* set actual length */ pkt_len = min((di->rxoffset + len), di->rxbufsize); - __skb_trim(head, pkt_len); + __skb_trim(p, pkt_len); + skb_queue_tail(&dma_frames, p); resid = len - (di->rxbufsize - di->rxoffset); /* check for single or multi-buffer rx */ if (resid > 0) { - tail = head; while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { - tail->next = p; pkt_len = min_t(uint, resid, di->rxbufsize); __skb_trim(p, pkt_len); - - tail = p; + skb_queue_tail(&dma_frames, p); resid -= di->rxbufsize; + pktcnt++; } #ifdef BCMDBG @@ -959,13 +960,18 @@ struct sk_buff *dma_rx(struct dma_pub *pub) if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len)); - brcmu_pkt_buf_free_skb(head); + skb_queue_walk_safe(&dma_frames, p, next) { + skb_unlink(p, &dma_frames); + brcmu_pkt_buf_free_skb(p); + } di->dma.rxgiants++; + pktcnt = 1; goto next_frame; } } - return head; + skb_queue_splice_tail(&dma_frames, skb_list); + return pktcnt; } static bool dma64_rxidle(struct dma_info *di) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.h b/drivers/net/wireless/brcm80211/brcmsmac/dma.h index ebc5bc5..d317c7c 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.h @@ -18,6 +18,7 @@ #define _BRCM_DMA_H_ #include +#include #include "types.h" /* forward structure declarations */ /* map/unmap direction */ @@ -80,7 +81,7 @@ extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, uint nrxpost, uint rxoffset, uint *msg_level); void dma_rxinit(struct dma_pub *pub); -struct sk_buff *dma_rx(struct dma_pub *pub); +int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list); bool dma_rxfill(struct dma_pub *pub); bool dma_rxreset(struct dma_pub *pub); bool dma_txreset(struct dma_pub *pub); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 3f8a6c7..f193fab 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -8115,21 +8115,17 @@ static bool brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) { struct sk_buff *p; - struct sk_buff *head = NULL; - struct sk_buff *tail = NULL; + struct sk_buff *next = NULL; + struct sk_buff_head recv_frames; + uint n = 0; uint bound_limit = bound ? RXBND : -1; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - /* gather received frames */ - while ((p = dma_rx(wlc_hw->di[fifo]))) { + skb_queue_head_init(&recv_frames); - if (!tail) - head = tail = p; - else { - tail->prev = p; - tail = p; - } + /* gather received frames */ + while (dma_rx(wlc_hw->di[fifo], &recv_frames)) { /* !give others some time to run! */ if (++n >= bound_limit) @@ -8140,12 +8136,11 @@ brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) dma_rxfill(wlc_hw->di[fifo]); /* process each frame */ - while ((p = head) != NULL) { + skb_queue_walk_safe(&recv_frames, p, next) { struct d11rxhdr_le *rxh_le; struct d11rxhdr *rxh; - head = head->prev; - p->prev = NULL; + skb_unlink(p, &recv_frames); rxh_le = (struct d11rxhdr_le *)p->data; rxh = (struct d11rxhdr *)p->data; -- cgit v0.10.2 From 15d45b6fbd01ecebc5a77b1e06ae7ebffad8018a Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 21 Oct 2011 16:16:32 +0200 Subject: brcm80211: fmac: use brcmf_add_if for all net devices Use brcmf_add_if for primary and virtual net device interfaces. This is part of the net device interface clean up for fullmac. Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 54b055b..2cf22e0 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -729,8 +729,7 @@ extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, extern void brcmf_c_init(void); extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, - struct net_device *ndev, char *name, u8 *mac_addr, - u32 flags, u8 bssidx); + char *name, u8 *mac_addr); extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); /* Send packet to dongle via data channel */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c index 8918261..40928e5 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c @@ -488,10 +488,9 @@ brcmf_c_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata, if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { if (ifevent->action == BRCMF_E_IF_ADD) - brcmf_add_if(drvr_priv, ifevent->ifidx, NULL, + brcmf_add_if(drvr_priv, ifevent->ifidx, event->ifname, - pvt_data->eth.h_dest, - ifevent->flags, ifevent->bssidx); + pvt_data->eth.h_dest); else brcmf_del_if(drvr_priv, ifevent->ifidx); } else { diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 6739ece..14ac210 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -904,30 +904,21 @@ static const struct net_device_ops brcmf_netdev_ops_pri = { }; int -brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, - char *name, u8 *mac_addr, u32 flags, u8 bssidx) +brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) { struct brcmf_if *ifp; - int ret = 0, err = 0; + int err = 0; - brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, ndev); + brcmf_dbg(TRACE, "idx %d\n", ifidx); ifp = drvr_priv->iflist[ifidx]; if (!ifp) { ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); if (!ifp) return -ENOMEM; - } - memset(ifp, 0, sizeof(struct brcmf_if)); - ifp->info = drvr_priv; - drvr_priv->iflist[ifidx] = ifp; - if (mac_addr != NULL) - memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); - - if (ndev == NULL) { - ifp->state = BRCMF_E_IF_ADD; - ifp->idx = ifidx; + drvr_priv->iflist[ifidx] = ifp; + } else { /* * Delete the existing interface before overwriting it * in case we missed the BRCMF_E_IF_DEL event. @@ -939,41 +930,42 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, unregister_netdev(ifp->ndev); free_netdev(ifp->ndev); } + } + memset(ifp, 0, sizeof(struct brcmf_if)); + ifp->info = drvr_priv; + drvr_priv->iflist[ifidx] = ifp; + ifp->state = BRCMF_E_IF_ADD; + ifp->idx = ifidx; - /* Allocate netdev, including space for private structure */ - ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", - ether_setup); - if (!ifp->ndev) { - brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); - ret = -ENOMEM; - } + /* Allocate netdev, including space for private structure */ + ifp->ndev = alloc_netdev(sizeof(drvr_priv), name, ether_setup); + if (!ifp->ndev) { + brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); + err = -ENOMEM; + goto errout; + } - if (ret == 0) { - memcpy(netdev_priv(ifp->ndev), &drvr_priv, - sizeof(drvr_priv)); - err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); - if (err != 0) { - brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", - err); - ret = -EOPNOTSUPP; - } else { - brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", - current->pid, ifp->ndev->name); - ifp->state = 0; - } - } + if (mac_addr != NULL) + memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); - if (ret < 0) { - if (ifp->ndev) - free_netdev(ifp->ndev); + memcpy(netdev_priv(ifp->ndev), &drvr_priv, sizeof(drvr_priv)); + if (brcmf_net_attach(&drvr_priv->pub, ifp->idx)) { + brcmf_dbg(ERROR, "brcmf_net_attach failed"); + free_netdev(ifp->ndev); + err = -EOPNOTSUPP; + goto errout; + } - drvr_priv->iflist[ifp->idx] = NULL; - kfree(ifp); - } - } else - ifp->ndev = ndev; + brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", + current->pid, ifp->ndev->name); + ifp->state = 0; return 0; + +errout: + kfree(ifp); + drvr_priv->iflist[ifidx] = NULL; + return err; } void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) @@ -1011,32 +1003,14 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) { struct brcmf_info *drvr_priv = NULL; - struct net_device *ndev; brcmf_dbg(TRACE, "Enter\n"); - /* Allocate netdev, including space for private structure */ - ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); - if (!ndev) { - brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); - goto fail; - } - /* Allocate primary brcmf_info */ drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); if (!drvr_priv) goto fail; - /* - * Save the brcmf_info into the priv - */ - memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); - - if (brcmf_add_if(drvr_priv, 0, ndev, ndev->name, NULL, 0, 0) == - BRCMF_BAD_IF) - goto fail; - - ndev->netdev_ops = NULL; mutex_init(&drvr_priv->proto_block); /* Link to info module */ @@ -1052,29 +1026,12 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) goto fail; } - /* Attach and link in the cfg80211 */ - drvr_priv->pub.config = - brcmf_cfg80211_attach(ndev, - brcmf_bus_get_device(bus), - &drvr_priv->pub); - if (drvr_priv->pub.config == NULL) { - brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); - goto fail; - } - INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); - /* - * Save the brcmf_info into the priv - */ - memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); - return &drvr_priv->pub; fail: - if (ndev) - free_netdev(ndev); if (drvr_priv) brcmf_detach(&drvr_priv->pub); @@ -1178,6 +1135,18 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); + /* attach to cfg80211 for primary interface */ + if (!ifidx) { + drvr->config = + brcmf_cfg80211_attach(ndev, + brcmf_bus_get_device(drvr->bus), + drvr); + if (drvr->config == NULL) { + brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); + goto fail; + } + } + if (register_netdev(ndev) != 0) { brcmf_dbg(ERROR, "couldn't register the net device\n"); goto fail; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 785ab08..6de489b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -4546,9 +4546,10 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, goto fail; } } - /* Ok, have the per-port tell the stack we're open for business */ - if (brcmf_net_attach(bus->drvr, 0) != 0) { - brcmf_dbg(ERROR, "Net attach failed!!\n"); + + /* add interface and open for business */ + if (brcmf_add_if((struct brcmf_info *)bus->drvr, 0, "wlan%d", NULL)) { + brcmf_dbg(ERROR, "Add primary net device interface failed!!\n"); goto fail; } -- cgit v0.10.2 From e1b835865c58e44ad16e5c85d1dc727991e2b0b3 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 21 Oct 2011 16:16:33 +0200 Subject: brcm80211: fmac: store brcmf_if in net device private data Make a proper use of private data area of net device by storing interface related data structure instead of generic driver data Reported-by: Johannes Berg Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 2cf22e0..a96a91f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -123,7 +123,6 @@ /* For supporting multiple interfaces */ #define BRCMF_MAX_IFS 16 #define BRCMF_DEL_IF -0xe -#define BRCMF_BAD_IF -0xf #define DOT11_BSSTYPE_ANY 2 #define DOT11_MAX_DEFAULT_KEYS 4 diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 14ac210..394577a 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -80,20 +80,6 @@ struct brcmf_info { /* Error bits */ module_param(brcmf_msg_level, int, 0); - -static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *ndev) -{ - int i = 0; - - while (i < BRCMF_MAX_IFS) { - if (drvr_priv->iflist[i] && drvr_priv->iflist[i]->ndev == ndev) - return i; - i++; - } - - return BRCMF_BAD_IF; -} - int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) { int i = BRCMF_MAX_IFS; @@ -285,14 +271,9 @@ _brcmf_set_mac_address(struct work_struct *work) static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; struct sockaddr *sa = (struct sockaddr *)addr; - int ifidx; - - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) - return -1; memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); schedule_work(&drvr_priv->setmacaddr_work); @@ -301,13 +282,8 @@ static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) static void brcmf_netdev_set_multicast_list(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; - - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) - return; + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; schedule_work(&drvr_priv->multicast_work); } @@ -341,9 +317,8 @@ int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) { int ret; - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; brcmf_dbg(TRACE, "Enter\n"); @@ -355,9 +330,8 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) return -ENODEV; } - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) { - brcmf_dbg(ERROR, "bad ifidx %d\n", ifidx); + if (!drvr_priv->iflist[ifp->idx]) { + brcmf_dbg(ERROR, "bad ifidx %d\n", ifp->idx); netif_stop_queue(ndev); return -ENODEV; } @@ -367,20 +341,20 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) struct sk_buff *skb2; brcmf_dbg(INFO, "%s: insufficient headroom\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); + brcmf_ifname(&drvr_priv->pub, ifp->idx)); drvr_priv->pub.tx_realloc++; skb2 = skb_realloc_headroom(skb, drvr_priv->pub.hdrlen); dev_kfree_skb(skb); skb = skb2; if (skb == NULL) { brcmf_dbg(ERROR, "%s: skb_realloc_headroom failed\n", - brcmf_ifname(&drvr_priv->pub, ifidx)); + brcmf_ifname(&drvr_priv->pub, ifp->idx)); ret = -ENOMEM; goto done; } } - ret = brcmf_sendpkt(&drvr_priv->pub, ifidx, skb); + ret = brcmf_sendpkt(&drvr_priv->pub, ifp->idx, skb); done: if (ret) @@ -524,19 +498,11 @@ void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp, bool success) static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - struct brcmf_if *ifp; - int ifidx; + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; brcmf_dbg(TRACE, "Enter\n"); - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (ifidx == BRCMF_BAD_IF) - return NULL; - - ifp = drvr_priv->iflist[ifidx]; - if (drvr_priv->pub.up) /* Use the protocol to get dongle stats */ brcmf_proto_dstats(&drvr_priv->pub); @@ -637,8 +603,8 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol) static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; sprintf(info->driver, KBUILD_MODNAME); sprintf(info->version, "%lu", drvr_priv->pub.drv_version); @@ -765,14 +731,12 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void __user *uaddr) static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, int cmd) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; - ifidx = brcmf_net2idx(drvr_priv, ndev); - brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifidx, cmd); + brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifp->idx, cmd); - if (ifidx == BRCMF_BAD_IF) + if (!drvr_priv->iflist[ifp->idx]) return -1; if (cmd == SIOCETHTOOL) @@ -788,17 +752,14 @@ s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len) s32 err = 0; int buflen = 0; bool is_set_key_cmd; - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); - int ifidx; + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; memset(&dcmd, 0, sizeof(dcmd)); dcmd.cmd = cmd; dcmd.buf = arg; dcmd.len = len; - ifidx = brcmf_net2idx(drvr_priv, ndev); - if (dcmd.buf != NULL) buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN); @@ -826,7 +787,7 @@ s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len) if (is_set_key_cmd) brcmf_netdev_wait_pend8021x(ndev); - err = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, buflen); + err = brcmf_proto_dcmd(&drvr_priv->pub, ifp->idx, &dcmd, buflen); done: if (err > 0) @@ -837,7 +798,8 @@ done: static int brcmf_netdev_stop(struct net_device *ndev) { - struct brcmf_pub *drvr = *(struct brcmf_pub **) netdev_priv(ndev); + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_pub *drvr = &ifp->info->pub; brcmf_dbg(TRACE, "Enter\n"); brcmf_cfg80211_down(drvr->config); @@ -853,16 +815,14 @@ static int brcmf_netdev_stop(struct net_device *ndev) static int brcmf_netdev_open(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **) - netdev_priv(ndev); + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; u32 toe_ol; - int ifidx = brcmf_net2idx(drvr_priv, ndev); s32 ret = 0; - brcmf_dbg(TRACE, "ifidx %d\n", ifidx); - - if (ifidx == 0) { /* do it only for primary eth0 */ + brcmf_dbg(TRACE, "ifidx %d\n", ifp->idx); + if (ifp->idx == 0) { /* do it only for primary eth0 */ /* try to bring up bus */ ret = brcmf_bus_start(&drvr_priv->pub); if (ret != 0) { @@ -874,12 +834,12 @@ static int brcmf_netdev_open(struct net_device *ndev) memcpy(ndev->dev_addr, drvr_priv->pub.mac, ETH_ALEN); /* Get current TOE mode from dongle */ - if (brcmf_toe_get(drvr_priv, ifidx, &toe_ol) >= 0 + if (brcmf_toe_get(drvr_priv, ifp->idx, &toe_ol) >= 0 && (toe_ol & TOE_TX_CSUM_OL) != 0) - drvr_priv->iflist[ifidx]->ndev->features |= + drvr_priv->iflist[ifp->idx]->ndev->features |= NETIF_F_IP_CSUM; else - drvr_priv->iflist[ifidx]->ndev->features &= + drvr_priv->iflist[ifp->idx]->ndev->features &= ~NETIF_F_IP_CSUM; } /* Allow transmit calls */ @@ -907,53 +867,45 @@ int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) { struct brcmf_if *ifp; - int err = 0; + struct net_device *ndev; brcmf_dbg(TRACE, "idx %d\n", ifidx); ifp = drvr_priv->iflist[ifidx]; - if (!ifp) { - ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); - if (!ifp) - return -ENOMEM; - - drvr_priv->iflist[ifidx] = ifp; - } else { - /* - * Delete the existing interface before overwriting it - * in case we missed the BRCMF_E_IF_DEL event. - */ - if (ifp->ndev != NULL) { - brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", - ifp->ndev->name); - netif_stop_queue(ifp->ndev); - unregister_netdev(ifp->ndev); - free_netdev(ifp->ndev); - } + /* + * Delete the existing interface before overwriting it + * in case we missed the BRCMF_E_IF_DEL event. + */ + if (ifp) { + brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", + ifp->ndev->name); + netif_stop_queue(ifp->ndev); + unregister_netdev(ifp->ndev); + free_netdev(ifp->ndev); + drvr_priv->iflist[ifidx] = NULL; } - memset(ifp, 0, sizeof(struct brcmf_if)); - ifp->info = drvr_priv; - drvr_priv->iflist[ifidx] = ifp; - ifp->state = BRCMF_E_IF_ADD; - ifp->idx = ifidx; /* Allocate netdev, including space for private structure */ - ifp->ndev = alloc_netdev(sizeof(drvr_priv), name, ether_setup); - if (!ifp->ndev) { + ndev = alloc_netdev(sizeof(struct brcmf_if), name, ether_setup); + if (!ndev) { brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); - err = -ENOMEM; - goto errout; + return -ENOMEM; } + ifp = netdev_priv(ndev); + ifp->ndev = ndev; + ifp->info = drvr_priv; + drvr_priv->iflist[ifidx] = ifp; + ifp->state = BRCMF_E_IF_ADD; + ifp->idx = ifidx; if (mac_addr != NULL) memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); - memcpy(netdev_priv(ifp->ndev), &drvr_priv, sizeof(drvr_priv)); if (brcmf_net_attach(&drvr_priv->pub, ifp->idx)) { brcmf_dbg(ERROR, "brcmf_net_attach failed"); free_netdev(ifp->ndev); - err = -EOPNOTSUPP; - goto errout; + drvr_priv->iflist[ifidx] = NULL; + return -EOPNOTSUPP; } brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", @@ -961,11 +913,6 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) ifp->state = 0; return 0; - -errout: - kfree(ifp); - drvr_priv->iflist[ifidx] = NULL; - return err; } void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) @@ -996,7 +943,6 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) if (ifidx == 0) brcmf_cfg80211_detach(drvr_priv->pub.config); free_netdev(ifp->ndev); - kfree(ifp); } } @@ -1268,7 +1214,8 @@ static int brcmf_get_pend_8021x_cnt(struct brcmf_info *drvr_priv) int brcmf_netdev_wait_pend8021x(struct net_device *ndev) { - struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(ndev); + struct brcmf_if *ifp = netdev_priv(ndev); + struct brcmf_info *drvr_priv = ifp->info; int timeout = 10 * HZ / 1000; int ntimes = MAX_WAIT_FOR_8021X_TX; int pend = brcmf_get_pend_8021x_cnt(drvr_priv); -- cgit v0.10.2 From d1a5b6fbecc52323acf05fa7881267071933c92e Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 21 Oct 2011 16:16:34 +0200 Subject: brcm80211: fmac: remove state from brcmf_if in fullmac The usage of state decrease readability. Optimize the code flow to get rid of it Reviewed-by: Roland Vossen Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index a96a91f..6da519e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -122,7 +122,6 @@ /* For supporting multiple interfaces */ #define BRCMF_MAX_IFS 16 -#define BRCMF_DEL_IF -0xe #define DOT11_BSSTYPE_ANY 2 #define DOT11_MAX_DEFAULT_KEYS 4 diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 394577a..719fd93 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -58,7 +58,6 @@ struct brcmf_if { struct net_device *ndev; struct net_device_stats stats; int idx; /* iface idx in dongle */ - int state; /* interface state */ u8 mac_addr[ETH_ALEN]; /* assigned MAC address */ }; @@ -456,12 +455,10 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, skb_mac_header(skb), &event, &data); - if (drvr_priv->iflist[ifidx] && - !drvr_priv->iflist[ifidx]->state) + if (drvr_priv->iflist[ifidx]) { ifp = drvr_priv->iflist[ifidx]; - - if (ifp->ndev) ifp->ndev->last_rx = jiffies; + } drvr->dstats.rx_bytes += skb->len; drvr->rx_packets++; /* Local count */ @@ -896,7 +893,6 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) ifp->ndev = ndev; ifp->info = drvr_priv; drvr_priv->iflist[ifidx] = ifp; - ifp->state = BRCMF_E_IF_ADD; ifp->idx = ifidx; if (mac_addr != NULL) memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); @@ -910,7 +906,6 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", current->pid, ifp->ndev->name); - ifp->state = 0; return 0; } @@ -926,7 +921,6 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) brcmf_dbg(ERROR, "Null interface\n"); return; } - ifp->state = BRCMF_E_IF_DEL; if (ifp->ndev) { if (ifidx == 0) { if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { -- cgit v0.10.2 From 028f78d43d80dcb8b1142ea38606067151dd3d51 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 21 Oct 2011 16:16:35 +0200 Subject: brcm80211: smac: change buffer endianess convert function interface The buffer endianess conversion functions in srom.c had a size argument giving number of bytes but the function converts words. Providing the number of words to the function is more sensible so that is done in this patch. Reported-by: Pavel Roskin Reported-by: Larry Finger Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 8f1cf2f..0539a6a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -617,18 +617,16 @@ static uint mask_width(u16 mask) return 0; } -static inline void le16_to_cpu_buf(u16 *buf, unsigned int size) +static inline void le16_to_cpu_buf(u16 *buf, uint nwords) { - size /= 2; - while (size--) - *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); + while (nwords--) + *(buf + nwords) = le16_to_cpu(*(__le16 *)(buf + nwords)); } -static inline void cpu_to_le16_buf(u16 *buf, unsigned int size) +static inline void cpu_to_le16_buf(u16 *buf, uint nwords) { - size /= 2; - while (size--) - *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); + while (nwords--) + *(__le16 *)(buf + nwords) = cpu_to_le16(*(buf + nwords)); } /* @@ -807,12 +805,12 @@ sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, err = -EIO; else /* now correct the endianness of the byte array */ - le16_to_cpu_buf(buf, nbytes); + le16_to_cpu_buf(buf, nwords); return err; } -static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) +static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords) { u8 *otp; uint sz = OTP_SZ_MAX / 2; /* size in words */ @@ -824,7 +822,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); - memcpy(buf, otp, bufsz); + sz = min_t(uint, sz, nwords); + memcpy(buf, otp, sz * 2); kfree(otp); @@ -836,14 +835,12 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) */ return -ENODATA; - /* fixup the endianness so crc8 will pass */ - cpu_to_le16_buf(buf, bufsz); - if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, + if (crc8(brcms_srom_crc8_table, (u8 *) buf, sz * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) err = -EIO; - - /* now correct the endianness of the byte array */ - le16_to_cpu_buf(buf, bufsz); + else + /* now correct the endianness of the byte array */ + le16_to_cpu_buf(buf, sz); return err; } @@ -880,7 +877,7 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) sromrev = srom[SROM4_CRCREV] & 0xff; } else { /* Use OTP if SPROM not available */ - err = otp_read_pci(sih, srom, SROM_MAX); + err = otp_read_pci(sih, srom, SROM4_WORDS); if (err == 0) /* OTP only contain SROM rev8/rev9 for now */ sromrev = srom[SROM4_CRCREV] & 0xff; -- cgit v0.10.2 From 3b7b72eed19684824806b3fbefef653a180ef2b0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 22 Oct 2011 19:05:51 +0200 Subject: nl80211: clean up genlmsg_end uses genlmsg_end() cannot fail, it just returns the length of the message. Thus, error handling for it is useless. While removing it, I also noticed a useless variable and removed this it as well. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 48260c2..337be50 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -6634,10 +6634,7 @@ void nl80211_send_reg_change_event(struct regulatory_request *request) if (wiphy_idx_valid(request->wiphy_idx)) NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); rcu_read_lock(); genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, @@ -6673,10 +6670,7 @@ static void nl80211_send_mlme_event(struct cfg80211_registered_device *rdev, NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -6757,10 +6751,7 @@ static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev, NLA_PUT_FLAG(msg, NL80211_ATTR_TIMED_OUT); NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -6816,10 +6807,7 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev, if (resp_ie) NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -6857,10 +6845,7 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev, if (resp_ie) NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -6898,10 +6883,7 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev, if (ie) NLA_PUT(msg, NL80211_ATTR_IE, ie_len, ie); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, GFP_KERNEL); @@ -6934,10 +6916,7 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev, NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -6972,10 +6951,7 @@ void nl80211_send_new_peer_candidate(struct cfg80211_registered_device *rdev, if (ie_len && ie) NLA_PUT(msg, NL80211_ATTR_IE, ie_len , ie); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -7014,10 +6990,7 @@ void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, if (tsc) NLA_PUT(msg, NL80211_ATTR_KEY_SEQ, 6, tsc); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -7068,10 +7041,7 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy, goto nla_put_failure; nla_nest_end(msg, nl_freq); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); rcu_read_lock(); genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, @@ -7114,10 +7084,7 @@ static void nl80211_send_remain_on_chan_event( if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL) NLA_PUT_U32(msg, NL80211_ATTR_DURATION, duration); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -7188,10 +7155,7 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -7208,7 +7172,6 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, { struct sk_buff *msg; void *hdr; - int err; msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); if (!msg) @@ -7225,16 +7188,9 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); - err = genlmsg_end(msg, hdr); - if (err < 0) { - nlmsg_free(msg); - return err; - } + genlmsg_end(msg, hdr); - err = genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); - if (err < 0) - return err; - return 0; + return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); nla_put_failure: genlmsg_cancel(msg, hdr); @@ -7267,10 +7223,7 @@ void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, if (ack) NLA_PUT_FLAG(msg, NL80211_ATTR_ACK); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp); return; @@ -7312,10 +7265,7 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, nla_nest_end(msg, pinfoattr); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -7357,10 +7307,7 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, nla_nest_end(msg, rekey_attr); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -7403,10 +7350,7 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, nla_nest_end(msg, attr); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); @@ -7448,10 +7392,7 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, nla_nest_end(msg, pinfoattr); - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } + genlmsg_end(msg, hdr); genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, nl80211_mlme_mcgrp.id, gfp); -- cgit v0.10.2 From 077a9154898b374f20555adc3f620cccd02581d6 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Sun, 23 Oct 2011 08:21:41 +0200 Subject: mac80211: support adding IV-room in the skb for CCMP keys Some cards can generate CCMP IVs in HW, but require the space for the IV to be pre-allocated in the frame at the correct offset. Add a key flag that allows us to achieve this. Signed-off-by: Arik Nemtsov Signed-off-by: John W. Linville diff --git a/include/net/mac80211.h b/include/net/mac80211.h index dc1123a..f4e0ab4 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -901,6 +901,10 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a * CCMP key if it requires CCMP encryption of management frames (MFP) to * be done in software. + * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver + * for a CCMP key if space should be prepared for the IV, but the IV + * itself should not be generated. Do not set together with + * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. */ enum ieee80211_key_flags { IEEE80211_KEY_FLAG_WMM_STA = 1<<0, @@ -908,6 +912,7 @@ enum ieee80211_key_flags { IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, IEEE80211_KEY_FLAG_SW_MGMT = 1<<4, + IEEE80211_KEY_FLAG_PUT_IV_SPACE = 1<<5, }; /** diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 756b157..17a5220 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -133,9 +133,13 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || - (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))) + (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) || + (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))) sdata->crypto_tx_tailroom_needed_cnt--; + WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && + (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); + return 0; } @@ -178,7 +182,8 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) sdata = key->sdata; if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || - (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))) + (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) || + (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))) increment_tailroom_need_count(sdata); if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index f614ce7..13efab5 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c @@ -390,7 +390,8 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) u8 scratch[6 * AES_BLOCK_SIZE]; if (info->control.hw_key && - !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { + !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) && + !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { /* * hwaccel has no need for preallocated room for CCMP * header or MIC fields @@ -412,6 +413,11 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) pos = skb_push(skb, CCMP_HDR_LEN); memmove(pos, pos + CCMP_HDR_LEN, hdrlen); + + /* the HW only needs room for the IV, but not the actual IV */ + if (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) + return 0; + hdr = (struct ieee80211_hdr *) pos; pos += hdrlen; -- cgit v0.10.2 From 43bc3e89cf3d2ad2ec827212ef0e69a21c0421b9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 23 Oct 2011 22:45:27 +0300 Subject: mac80211_hwsim: Claim support for TDLS Signed-off-by: Jouni Malinen Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 68455a2..477100d 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -1747,6 +1747,8 @@ static int __init init_mac80211_hwsim(void) IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_AMPDU_AGGREGATION; + hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; + /* ask mac80211 to reserve space for magic */ hw->vif_data_size = sizeof(struct hwsim_vif_priv); hw->sta_data_size = sizeof(struct hwsim_sta_priv); -- cgit v0.10.2 From 38df2f07b7bc5309ebb159438b435d1f25f31e35 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Mon, 24 Oct 2011 18:14:39 +0530 Subject: ath9k_hw: Update CCK spur mitigation for AR9462 To improve CCK sensitivity for AR9462 chips, performing spur mitigation at 2440, 2464 frequencies alone is sufficient. Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c index fe96997..04b060a 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c @@ -198,12 +198,14 @@ static void ar9003_hw_spur_mitigate_mrc_cck(struct ath_hw *ah, synth_freq = chan->channel; } } else { - range = 10; + range = AR_SREV_9462(ah) ? 5 : 10; max_spur_cnts = 4; synth_freq = chan->channel; } for (i = 0; i < max_spur_cnts; i++) { + if (AR_SREV_9462(ah) && (i == 0 || i == 3)) + continue; negative = 0; if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah)) cur_bb_spur = FBIN2FREQ(spur_fbin_ptr[i], -- cgit v0.10.2 From 7dc181c273861c4d96991f59a4fdcda3a3eaccae Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Mon, 24 Oct 2011 18:19:49 +0530 Subject: ath9k: Add btcoex profile management support for AR9462 AR9462 chips have the capabilities to provoide bluetooth profile information. For non-AR9462 btcoex chips, the BT priority traffic was identified by periodically polling the respective registers and updated dutycycle, stomptype, etc. As AR9462 chip offers the BT profile informations, let us make use of that to update aggregation limit, dutycycle, stomptype and wieghtages. Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 908fdbc..fe4bf4d 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -240,6 +240,7 @@ enum ATH_DEBUG { ATH_DBG_BTCOEX = 0x00002000, ATH_DBG_WMI = 0x00004000, ATH_DBG_BSTUCK = 0x00008000, + ATH_DBG_MCI = 0x00010000, ATH_DBG_ANY = 0xffffffff }; diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile index 36ed3c4..49d3f25 100644 --- a/drivers/net/wireless/ath/ath9k/Makefile +++ b/drivers/net/wireless/ath/ath9k/Makefile @@ -4,6 +4,7 @@ ath9k-y += beacon.o \ main.o \ recv.o \ xmit.o \ + mci.o \ ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o ath9k-$(CONFIG_ATH9K_PCI) += pci.o diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 1c269f5..4415e89 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -25,6 +25,7 @@ #include "debug.h" #include "common.h" +#include "mci.h" /* * Header for the ath9k.ko driver core *only* -- hw code nor any other driver @@ -443,7 +444,9 @@ struct ath_btcoex { u32 btcoex_no_stomp; /* in usec */ u32 btcoex_period; /* in usec */ u32 btscan_no_stomp; /* in usec */ + u32 duty_cycle; struct ath_gen_timer *no_stomp_timer; /* Timer for no BT stomping */ + struct ath_mci_profile mci; }; int ath_init_btcoex_timer(struct ath_softc *sc); diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 655576c..2c279dc 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -189,8 +189,8 @@ static void ath_btcoex_period_timer(unsigned long data) bool is_btscan; ath9k_ps_wakeup(sc); - ath_detect_bt_priority(sc); - + if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) + ath_detect_bt_priority(sc); is_btscan = sc->sc_flags & SC_OP_BT_SCAN; spin_lock_bh(&btcoex->btcoex_lock); @@ -212,8 +212,9 @@ static void ath_btcoex_period_timer(unsigned long data) } ath9k_ps_restore(sc); + timer_period = btcoex->btcoex_period / 1000; mod_timer(&btcoex->period_timer, jiffies + - msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD)); + msecs_to_jiffies(timer_period)); } /* diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index e1dc084..96b8b99 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2331,7 +2331,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) ah->enabled_cals |= TX_IQ_ON_AGC_CAL; } if (AR_SREV_9462(ah)) - pCap->hw_caps |= ATH9K_HW_CAP_RTT; + pCap->hw_caps |= ATH9K_HW_CAP_RTT | ATH9K_HW_CAP_MCI; return 0; } diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index f389b3c..33e8f2f 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -203,6 +203,7 @@ enum ath9k_hw_caps { ATH9K_HW_CAP_5GHZ = BIT(14), ATH9K_HW_CAP_APM = BIT(15), ATH9K_HW_CAP_RTT = BIT(16), + ATH9K_HW_CAP_MCI = BIT(17), }; struct ath9k_hw_capabilities { @@ -419,6 +420,16 @@ enum ath9k_rx_qtype { ATH9K_RX_QUEUE_MAX, }; +enum ath_mci_gpm_coex_profile_type { + MCI_GPM_COEX_PROFILE_UNKNOWN, + MCI_GPM_COEX_PROFILE_RFCOMM, + MCI_GPM_COEX_PROFILE_A2DP, + MCI_GPM_COEX_PROFILE_HID, + MCI_GPM_COEX_PROFILE_BNEP, + MCI_GPM_COEX_PROFILE_VOICE, + MCI_GPM_COEX_PROFILE_MAX +}; + struct ath9k_beacon_state { u32 bs_nexttbtt; u32 bs_nextdtim; diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index af1b325..e8af582 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -423,6 +423,8 @@ static int ath9k_init_btcoex(struct ath_softc *sc) txq = sc->tx.txq_map[WME_AC_BE]; ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum); sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; + sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; + INIT_LIST_HEAD(&sc->btcoex.mci.info); break; default: WARN_ON(1); diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 93fbe6f..e1e006d 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1133,8 +1133,9 @@ static int ath9k_start(struct ieee80211_hw *hw) if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) && !ah->btcoex_hw.enabled) { - ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, - AR_STOMP_LOW_WLAN_WGHT); + if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) + ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, + AR_STOMP_LOW_WLAN_WGHT); ath9k_hw_btcoex_enable(ah); if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) @@ -1237,6 +1238,7 @@ static void ath9k_stop(struct ieee80211_hw *hw) ath9k_hw_btcoex_disable(ah); if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) ath9k_btcoex_timer_pause(sc); + ath_mci_flush_profile(&sc->btcoex.mci); } spin_lock_bh(&sc->sc_pcu_lock); diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c new file mode 100644 index 0000000..0fbb141 --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/mci.c @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2010-2011 Atheros Communications Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ath9k.h" +#include "mci.h" + +u8 ath_mci_duty_cycle[] = { 0, 50, 60, 70, 80, 85, 90, 95, 98 }; + +static struct ath_mci_profile_info* +ath_mci_find_profile(struct ath_mci_profile *mci, + struct ath_mci_profile_info *info) +{ + struct ath_mci_profile_info *entry; + + list_for_each_entry(entry, &mci->info, list) { + if (entry->conn_handle == info->conn_handle) + break; + } + return entry; +} + +static bool ath_mci_add_profile(struct ath_common *common, + struct ath_mci_profile *mci, + struct ath_mci_profile_info *info) +{ + struct ath_mci_profile_info *entry; + + if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) && + (info->type == MCI_GPM_COEX_PROFILE_VOICE)) { + ath_dbg(common, ATH_DBG_MCI, + "Too many SCO profile, failed to add new profile\n"); + return false; + } + + if (((NUM_PROF(mci) - mci->num_sco) == ATH_MCI_MAX_ACL_PROFILE) && + (info->type != MCI_GPM_COEX_PROFILE_VOICE)) { + ath_dbg(common, ATH_DBG_MCI, + "Too many ACL profile, failed to add new profile\n"); + return false; + } + + entry = ath_mci_find_profile(mci, info); + + if (entry) + memcpy(entry, info, 10); + else { + entry = kzalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) + return false; + + memcpy(entry, info, 10); + INC_PROF(mci, info); + list_add_tail(&info->list, &mci->info); + } + return true; +} + +static void ath_mci_del_profile(struct ath_common *common, + struct ath_mci_profile *mci, + struct ath_mci_profile_info *info) +{ + struct ath_mci_profile_info *entry; + + entry = ath_mci_find_profile(mci, info); + + if (!entry) { + ath_dbg(common, ATH_DBG_MCI, + "Profile to be deleted not found\n"); + return; + } + DEC_PROF(mci, entry); + list_del(&entry->list); + kfree(entry); +} + +void ath_mci_flush_profile(struct ath_mci_profile *mci) +{ + struct ath_mci_profile_info *info, *tinfo; + + list_for_each_entry_safe(info, tinfo, &mci->info, list) { + list_del(&info->list); + DEC_PROF(mci, info); + kfree(info); + } + mci->aggr_limit = 0; +} + +static void ath_mci_adjust_aggr_limit(struct ath_btcoex *btcoex) +{ + struct ath_mci_profile *mci = &btcoex->mci; + u32 wlan_airtime = btcoex->btcoex_period * + (100 - btcoex->duty_cycle) / 100; + + /* + * Scale: wlan_airtime is in ms, aggr_limit is in 0.25 ms. + * When wlan_airtime is less than 4ms, aggregation limit has to be + * adjusted half of wlan_airtime to ensure that the aggregation can fit + * without collision with BT traffic. + */ + if ((wlan_airtime <= 4) && + (!mci->aggr_limit || (mci->aggr_limit > (2 * wlan_airtime)))) + mci->aggr_limit = 2 * wlan_airtime; +} + +static void ath_mci_update_scheme(struct ath_softc *sc) +{ + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + struct ath_btcoex *btcoex = &sc->btcoex; + struct ath_mci_profile *mci = &btcoex->mci; + struct ath_mci_profile_info *info; + u32 num_profile = NUM_PROF(mci); + + if (num_profile == 1) { + info = list_first_entry(&mci->info, + struct ath_mci_profile_info, + list); + if (mci->num_sco && info->T == 12) { + mci->aggr_limit = 8; + ath_dbg(common, ATH_DBG_MCI, + "Single SCO, aggregation limit 2 ms\n"); + } else if ((info->type == MCI_GPM_COEX_PROFILE_BNEP) && + !info->master) { + btcoex->btcoex_period = 60; + ath_dbg(common, ATH_DBG_MCI, + "Single slave PAN/FTP, bt period 60 ms\n"); + } else if ((info->type == MCI_GPM_COEX_PROFILE_HID) && + (info->T > 0 && info->T < 50) && + (info->A > 1 || info->W > 1)) { + btcoex->duty_cycle = 30; + mci->aggr_limit = 8; + ath_dbg(common, ATH_DBG_MCI, + "Multiple attempt/timeout single HID " + "aggregation limit 2 ms dutycycle 30%%\n"); + } + } else if ((num_profile == 2) && (mci->num_hid == 2)) { + btcoex->duty_cycle = 30; + mci->aggr_limit = 8; + ath_dbg(common, ATH_DBG_MCI, + "Two HIDs aggregation limit 2 ms dutycycle 30%%\n"); + } else if (num_profile > 3) { + mci->aggr_limit = 6; + ath_dbg(common, ATH_DBG_MCI, + "Three or more profiles aggregation limit 1.5 ms\n"); + } + + if (IS_CHAN_2GHZ(sc->sc_ah->curchan)) { + if (IS_CHAN_HT(sc->sc_ah->curchan)) + ath_mci_adjust_aggr_limit(btcoex); + else + btcoex->btcoex_period >>= 1; + } + + ath9k_hw_btcoex_disable(sc->sc_ah); + ath9k_btcoex_timer_pause(sc); + + if (IS_CHAN_5GHZ(sc->sc_ah->curchan)) + return; + + btcoex->duty_cycle += (mci->num_bdr ? ATH_MCI_MAX_DUTY_CYCLE : 0); + if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE) + btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE; + + btcoex->btcoex_period *= 1000; + btcoex->btcoex_no_stomp = btcoex->btcoex_period * + (100 - btcoex->duty_cycle) / 100; + + ath9k_hw_btcoex_enable(sc->sc_ah); + ath9k_btcoex_timer_resume(sc); +} + +void ath_mci_process_profile(struct ath_softc *sc, + struct ath_mci_profile_info *info) +{ + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + struct ath_btcoex *btcoex = &sc->btcoex; + struct ath_mci_profile *mci = &btcoex->mci; + + if (info->start) { + if (!ath_mci_add_profile(common, mci, info)) + return; + } else + ath_mci_del_profile(common, mci, info); + + btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD; + mci->aggr_limit = mci->num_sco ? 6 : 0; + if (NUM_PROF(mci)) { + btcoex->bt_stomp_type = ATH_BTCOEX_STOMP_LOW; + btcoex->duty_cycle = ath_mci_duty_cycle[NUM_PROF(mci)]; + } else { + btcoex->bt_stomp_type = mci->num_mgmt ? ATH_BTCOEX_STOMP_ALL : + ATH_BTCOEX_STOMP_LOW; + btcoex->duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; + } + + ath_mci_update_scheme(sc); +} + +void ath_mci_process_status(struct ath_softc *sc, + struct ath_mci_profile_status *status) +{ + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + struct ath_btcoex *btcoex = &sc->btcoex; + struct ath_mci_profile *mci = &btcoex->mci; + struct ath_mci_profile_info info; + int i = 0, old_num_mgmt = mci->num_mgmt; + + /* Link status type are not handled */ + if (status->is_link) { + ath_dbg(common, ATH_DBG_MCI, + "Skip link type status update\n"); + return; + } + + memset(&info, 0, sizeof(struct ath_mci_profile_info)); + + info.conn_handle = status->conn_handle; + if (ath_mci_find_profile(mci, &info)) { + ath_dbg(common, ATH_DBG_MCI, + "Skip non link state update for existing profile %d\n", + status->conn_handle); + return; + } + if (status->conn_handle >= ATH_MCI_MAX_PROFILE) { + ath_dbg(common, ATH_DBG_MCI, + "Ignore too many non-link update\n"); + return; + } + if (status->is_critical) + __set_bit(status->conn_handle, mci->status); + else + __clear_bit(status->conn_handle, mci->status); + + mci->num_mgmt = 0; + do { + if (test_bit(i, mci->status)) + mci->num_mgmt++; + } while (++i < ATH_MCI_MAX_PROFILE); + + if (old_num_mgmt != mci->num_mgmt) + ath_mci_update_scheme(sc); +} diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h new file mode 100644 index 0000000..9590c61 --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/mci.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2010-2011 Atheros Communications Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MCI_H +#define MCI_H + +#define ATH_MCI_DEF_BT_PERIOD 40 +#define ATH_MCI_BDR_DUTY_CYCLE 20 +#define ATH_MCI_MAX_DUTY_CYCLE 90 + +#define ATH_MCI_DEF_AGGR_LIMIT 6 /* in 0.24 ms */ +#define ATH_MCI_MAX_ACL_PROFILE 7 +#define ATH_MCI_MAX_SCO_PROFILE 1 +#define ATH_MCI_MAX_PROFILE (ATH_MCI_MAX_ACL_PROFILE +\ + ATH_MCI_MAX_SCO_PROFILE) + +#define INC_PROF(_mci, _info) do { \ + switch (_info->type) { \ + case MCI_GPM_COEX_PROFILE_RFCOMM:\ + _mci->num_other_acl++; \ + break; \ + case MCI_GPM_COEX_PROFILE_A2DP: \ + _mci->num_a2dp++; \ + if (!_info->edr) \ + _mci->num_bdr++; \ + break; \ + case MCI_GPM_COEX_PROFILE_HID: \ + _mci->num_hid++; \ + break; \ + case MCI_GPM_COEX_PROFILE_BNEP: \ + _mci->num_pan++; \ + break; \ + case MCI_GPM_COEX_PROFILE_VOICE: \ + _mci->num_sco++; \ + break; \ + default: \ + break; \ + } \ + } while (0) + +#define DEC_PROF(_mci, _info) do { \ + switch (_info->type) { \ + case MCI_GPM_COEX_PROFILE_RFCOMM:\ + _mci->num_other_acl--; \ + break; \ + case MCI_GPM_COEX_PROFILE_A2DP: \ + _mci->num_a2dp--; \ + if (!_info->edr) \ + _mci->num_bdr--; \ + break; \ + case MCI_GPM_COEX_PROFILE_HID: \ + _mci->num_hid--; \ + break; \ + case MCI_GPM_COEX_PROFILE_BNEP: \ + _mci->num_pan--; \ + break; \ + case MCI_GPM_COEX_PROFILE_VOICE: \ + _mci->num_sco--; \ + break; \ + default: \ + break; \ + } \ + } while (0) + +#define NUM_PROF(_mci) (_mci->num_other_acl + _mci->num_a2dp + \ + _mci->num_hid + _mci->num_pan + _mci->num_sco) + +struct ath_mci_profile_info { + u8 type; + u8 conn_handle; + bool start; + bool master; + bool edr; + u8 voice_type; + u16 T; /* Voice: Tvoice, HID: Tsniff, in slots */ + u8 W; /* Voice: Wvoice, HID: Sniff timeout, in slots */ + u8 A; /* HID: Sniff attempt, in slots */ + struct list_head list; +}; + +struct ath_mci_profile_status { + bool is_critical; + bool is_link; + u8 conn_handle; +}; + +struct ath_mci_profile { + struct list_head info; + DECLARE_BITMAP(status, ATH_MCI_MAX_PROFILE); + u16 aggr_limit; + u8 num_mgmt; + u8 num_sco; + u8 num_a2dp; + u8 num_hid; + u8 num_pan; + u8 num_other_acl; + u8 num_bdr; +}; + +void ath_mci_flush_profile(struct ath_mci_profile *mci); +void ath_mci_process_profile(struct ath_softc *sc, + struct ath_mci_profile_info *info); +void ath_mci_process_status(struct ath_softc *sc, + struct ath_mci_profile_status *status); +#endif diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 03b0a65..55d077e 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -601,6 +601,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, struct sk_buff *skb; struct ieee80211_tx_info *tx_info; struct ieee80211_tx_rate *rates; + struct ath_mci_profile *mci = &sc->btcoex.mci; u32 max_4ms_framelen, frmlen; u16 aggr_limit, legacy = 0; int i; @@ -645,7 +646,9 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy) return 0; - if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit) + aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4; + else if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) aggr_limit = min((max_4ms_framelen * 3) / 8, (u32)ATH_AMPDU_LIMIT_MAX); else -- cgit v0.10.2 From c63749d347afcb5c4790d1cbe27d9b66e585b9ff Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Tue, 25 Oct 2011 12:40:38 +0530 Subject: ath9k_hw: Updated AR9462 initval table to improve rx performance The initval tables are updated as per system team input to improve rx performance and power accuracy at 5GHz. Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h index 9c51b39..259a6f3 100644 --- a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h @@ -43,16 +43,16 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011}, {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, - {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, - {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, + {0x00009824, 0x5ac640de, 0x5ac640d0, 0x5ac640d0, 0x5ac640de}, + {0x00009828, 0x0796be89, 0x0696b081, 0x0696b881, 0x0796be89}, {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c}, {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4}, {0x00009e00, 0x0372111a, 0x0372111a, 0x037216a0, 0x037216a0}, {0x00009e04, 0x001c2020, 0x001c2020, 0x001c2020, 0x001c2020}, {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, - {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e}, - {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3039605e, 0x33795d5e}, + {0x00009e10, 0x92c88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x92c84d2e}, + {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e}, {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, @@ -688,8 +688,8 @@ static const u32 ar9462_2p0_mac_postamble_emulation[][5] = { static const u32 ar9462_2p0_radio_postamble_sys3ant[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, - {0x00016140, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, - {0x00016540, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, + {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, + {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, }; static const u32 ar9462_2p0_baseband_postamble_emulation[][5] = { @@ -717,8 +717,8 @@ static const u32 ar9462_2p0_baseband_postamble_emulation[][5] = { static const u32 ar9462_2p0_radio_postamble_sys2ant[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, - {0x00016140, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, - {0x00016540, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, + {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, + {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, }; static const u32 ar9462_common_wo_xlna_rx_gain_table_2p0[][2] = { @@ -1059,7 +1059,7 @@ static const u32 ar9462_modes_low_ob_db_tx_gain_table_2p0[][5] = { static const u32 ar9462_2p0_soc_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00007010, 0x00002233, 0x00002233, 0x00002233, 0x00002233}, + {0x00007010, 0x00000033, 0x00000033, 0x00000033, 0x00000033}, }; static const u32 ar9462_2p0_baseband_core[][2] = { @@ -1257,8 +1257,8 @@ static const u32 ar9462_modes_high_ob_db_tx_gain_table_2p0[][5] = { {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, - {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83}, - {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84}, + {0x0000a54c, 0x59025eb6, 0x59025eb6, 0x42001a83, 0x42001a83}, + {0x0000a550, 0x5d025ef6, 0x5d025ef6, 0x44001c84, 0x44001c84}, {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, @@ -1850,8 +1850,8 @@ static const u32 ar9462_modes_green_ob_db_tx_gain_table_2p0[][5] = { {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, - {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83}, - {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84}, + {0x0000a54c, 0x59025eb6, 0x59025eb6, 0x42001a83, 0x42001a83}, + {0x0000a550, 0x5d025ef6, 0x5d025ef6, 0x44001c84, 0x44001c84}, {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, -- cgit v0.10.2 From 3b69a9c5f264d62a0cf46ea61ed3da732c1f88c2 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Wed, 26 Oct 2011 14:47:25 -0700 Subject: mac80211: comment allocation of mesh frames Remove most references to magic numbers, save a few bytes and hopefully improve readability. Signed-off-by: Thomas Pedersen Signed-off-by: John W. Linville diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 174040a..9a1f8bb 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -113,20 +113,20 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, struct ieee80211_sub_if_data *sdata) { struct ieee80211_local *local = sdata->local; - struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); + struct sk_buff *skb; struct ieee80211_mgmt *mgmt; - u8 *pos; - int ie_len; + u8 *pos, ie_len; + int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) + + sizeof(mgmt->u.action.u.mesh_action); + skb = dev_alloc_skb(local->hw.extra_tx_headroom + + hdr_len + + 2 + 37); /* max HWMP IE */ if (!skb) return -1; skb_reserve(skb, local->hw.extra_tx_headroom); - /* 25 is the size of the common mgmt part (24) plus the size of the - * common action part (1) - */ - mgmt = (struct ieee80211_mgmt *) - skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action)); - memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action)); + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); + memset(mgmt, 0, hdr_len); mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); @@ -240,20 +240,20 @@ int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, struct ieee80211_sub_if_data *sdata) { struct ieee80211_local *local = sdata->local; - struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); + struct sk_buff *skb; struct ieee80211_mgmt *mgmt; - u8 *pos; - int ie_len; + u8 *pos, ie_len; + int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) + + sizeof(mgmt->u.action.u.mesh_action); + skb = dev_alloc_skb(local->hw.extra_tx_headroom + + hdr_len + + 2 + 15 /* PERR IE */); if (!skb) return -1; skb_reserve(skb, local->tx_headroom + local->hw.extra_tx_headroom); - /* 25 is the size of the common mgmt part (24) plus the size of the - * common action part (1) - */ - mgmt = (struct ieee80211_mgmt *) - skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action)); - memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action)); + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); + memset(mgmt, 0, hdr_len); mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 7e57f5d..351e48c 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -153,23 +153,29 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, enum ieee80211_self_protected_actioncode action, u8 *da, __le16 llid, __le16 plid, __le16 reason) { struct ieee80211_local *local = sdata->local; - struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 + - sdata->u.mesh.ie_len); + struct sk_buff *skb; struct ieee80211_mgmt *mgmt; bool include_plid = false; - int ie_len = 4; u16 peering_proto = 0; - u8 *pos; - + u8 *pos, ie_len = 4; + int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) + + sizeof(mgmt->u.action.u.self_prot); + + skb = dev_alloc_skb(local->hw.extra_tx_headroom + + hdr_len + + 2 + /* capability info */ + 2 + /* AID */ + 2 + 8 + /* supported rates */ + 2 + (IEEE80211_MAX_SUPP_RATES - 8) + + 2 + sdata->u.mesh.mesh_id_len + + 2 + sizeof(struct ieee80211_meshconf_ie) + + 2 + 8 + /* peering IE */ + sdata->u.mesh.ie_len); if (!skb) return -1; skb_reserve(skb, local->hw.extra_tx_headroom); - /* 25 is the size of the common mgmt part (24) plus the size of the - * common action part (1) - */ - mgmt = (struct ieee80211_mgmt *) - skb_put(skb, 25 + sizeof(mgmt->u.action.u.self_prot)); - memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.self_prot)); + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); + memset(mgmt, 0, hdr_len); mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); memcpy(mgmt->da, da, ETH_ALEN); diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 48bbb96..f4dd339 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2278,22 +2278,29 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, } else if (ieee80211_vif_is_mesh(&sdata->vif)) { struct ieee80211_mgmt *mgmt; u8 *pos; + int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) + + sizeof(mgmt->u.beacon); #ifdef CONFIG_MAC80211_MESH if (!sdata->u.mesh.mesh_id_len) goto out; #endif - /* headroom, head length, tail length and maximum TIM length */ - skb = dev_alloc_skb(local->tx_headroom + 400 + - sdata->u.mesh.ie_len); + skb = dev_alloc_skb(local->tx_headroom + + hdr_len + + 2 + /* NULL SSID */ + 2 + 8 + /* supported rates */ + 2 + 3 + /* DS params */ + 2 + (IEEE80211_MAX_SUPP_RATES - 8) + + 2 + sdata->u.mesh.mesh_id_len + + 2 + sizeof(struct ieee80211_meshconf_ie) + + sdata->u.mesh.ie_len); if (!skb) goto out; skb_reserve(skb, local->hw.extra_tx_headroom); - mgmt = (struct ieee80211_mgmt *) - skb_put(skb, 24 + sizeof(mgmt->u.beacon)); - memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); + memset(mgmt, 0, hdr_len); mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); memset(mgmt->da, 0xff, ETH_ALEN); -- cgit v0.10.2 From 42e7aa771196d8129d9deaee950b3177a443b8cf Mon Sep 17 00:00:00 2001 From: Alexander Simon Date: Wed, 26 Oct 2011 14:47:26 -0700 Subject: mac80211: Add HT helper functions Some refactoring for IBSS HT. Move HT info and capability IEs building code into separate functions. Add function to get the channel type from an HT info IE. Signed-off-by: Alexander Simon Signed-off-by: John W. Linville diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4c3d1f5..30fc9e7 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1333,6 +1333,12 @@ void ieee80211_recalc_smps(struct ieee80211_local *local); size_t ieee80211_ie_split(const u8 *ies, size_t ielen, const u8 *ids, int n_ids, size_t offset); size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset); +u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_supported_band *sband, + u16 cap); +u8 *ieee80211_ie_build_ht_info(u8 *pos, + struct ieee80211_sta_ht_cap *ht_cap, + struct ieee80211_channel *channel, + enum nl80211_channel_type channel_type); /* internal work items */ void ieee80211_work_init(struct ieee80211_local *local); @@ -1361,6 +1367,8 @@ ieee80211_get_channel_mode(struct ieee80211_local *local, bool ieee80211_set_channel_type(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, enum nl80211_channel_type chantype); +enum nl80211_channel_type +ieee80211_ht_info_to_channel_type(struct ieee80211_ht_info *ht_info); #ifdef CONFIG_MAC80211_NOINLINE #define debug_noinline noinline diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 7439d26..72b3a2e 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -811,23 +811,8 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, offset = noffset; } - if (sband->ht_cap.ht_supported) { - u16 cap = sband->ht_cap.cap; - __le16 tmp; - - *pos++ = WLAN_EID_HT_CAPABILITY; - *pos++ = sizeof(struct ieee80211_ht_cap); - memset(pos, 0, sizeof(struct ieee80211_ht_cap)); - tmp = cpu_to_le16(cap); - memcpy(pos, &tmp, sizeof(u16)); - pos += sizeof(u16); - *pos++ = sband->ht_cap.ampdu_factor | - (sband->ht_cap.ampdu_density << - IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); - memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); - pos += sizeof(sband->ht_cap.mcs); - pos += 2 + 4 + 1; /* ext info, BF cap, antsel */ - } + if (sband->ht_cap.ht_supported) + pos = ieee80211_ie_build_ht_cap(pos, sband, sband->ht_cap.cap); /* * If adding more here, adjust code in main.c @@ -1362,6 +1347,103 @@ void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif) } EXPORT_SYMBOL(ieee80211_disable_rssi_reports); +u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_supported_band *sband, + u16 cap) +{ + __le16 tmp; + + *pos++ = WLAN_EID_HT_CAPABILITY; + *pos++ = sizeof(struct ieee80211_ht_cap); + memset(pos, 0, sizeof(struct ieee80211_ht_cap)); + + /* capability flags */ + tmp = cpu_to_le16(cap); + memcpy(pos, &tmp, sizeof(u16)); + pos += sizeof(u16); + + /* AMPDU parameters */ + *pos++ = sband->ht_cap.ampdu_factor | + (sband->ht_cap.ampdu_density << + IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); + + /* MCS set */ + memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); + pos += sizeof(sband->ht_cap.mcs); + + /* extended capabilities */ + pos += sizeof(__le16); + + /* BF capabilities */ + pos += sizeof(__le32); + + /* antenna selection */ + pos += sizeof(u8); + + return pos; +} + +u8 *ieee80211_ie_build_ht_info(u8 *pos, + struct ieee80211_sta_ht_cap *ht_cap, + struct ieee80211_channel *channel, + enum nl80211_channel_type channel_type) +{ + struct ieee80211_ht_info *ht_info; + /* Build HT Information */ + *pos++ = WLAN_EID_HT_INFORMATION; + *pos++ = sizeof(struct ieee80211_ht_info); + ht_info = (struct ieee80211_ht_info *)pos; + ht_info->control_chan = + ieee80211_frequency_to_channel(channel->center_freq); + switch (channel_type) { + case NL80211_CHAN_HT40MINUS: + ht_info->ht_param = IEEE80211_HT_PARAM_CHA_SEC_BELOW; + break; + case NL80211_CHAN_HT40PLUS: + ht_info->ht_param = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + break; + case NL80211_CHAN_HT20: + default: + ht_info->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE; + break; + } + if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) + ht_info->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; + ht_info->operation_mode = 0x0000; + ht_info->stbc_param = 0x0000; + + /* It seems that Basic MCS set and Supported MCS set + are identical for the first 10 bytes */ + memset(&ht_info->basic_set, 0, 16); + memcpy(&ht_info->basic_set, &ht_cap->mcs, 10); + + return pos + sizeof(struct ieee80211_ht_info); +} + +enum nl80211_channel_type +ieee80211_ht_info_to_channel_type(struct ieee80211_ht_info *ht_info) +{ + enum nl80211_channel_type channel_type; + + if (!ht_info) + return NL80211_CHAN_NO_HT; + + switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { + case IEEE80211_HT_PARAM_CHA_SEC_NONE: + channel_type = NL80211_CHAN_HT20; + break; + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: + channel_type = NL80211_CHAN_HT40PLUS; + break; + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: + channel_type = NL80211_CHAN_HT40MINUS; + break; + default: + channel_type = NL80211_CHAN_NO_HT; + } + + return channel_type; +} + int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb) { struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); diff --git a/net/mac80211/work.c b/net/mac80211/work.c index 94472eb..fab5092 100644 --- a/net/mac80211/work.c +++ b/net/mac80211/work.c @@ -103,7 +103,6 @@ static void ieee80211_add_ht_ie(struct sk_buff *skb, const u8 *ht_info_ie, u8 *pos; u32 flags = channel->flags; u16 cap = sband->ht_cap.cap; - __le16 tmp; if (!sband->ht_cap.ht_supported) return; @@ -154,34 +153,8 @@ static void ieee80211_add_ht_ie(struct sk_buff *skb, const u8 *ht_info_ie, } /* reserve and fill IE */ - pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2); - *pos++ = WLAN_EID_HT_CAPABILITY; - *pos++ = sizeof(struct ieee80211_ht_cap); - memset(pos, 0, sizeof(struct ieee80211_ht_cap)); - - /* capability flags */ - tmp = cpu_to_le16(cap); - memcpy(pos, &tmp, sizeof(u16)); - pos += sizeof(u16); - - /* AMPDU parameters */ - *pos++ = sband->ht_cap.ampdu_factor | - (sband->ht_cap.ampdu_density << - IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); - - /* MCS set */ - memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); - pos += sizeof(sband->ht_cap.mcs); - - /* extended capabilities */ - pos += sizeof(__le16); - - /* BF capabilities */ - pos += sizeof(__le32); - - /* antenna selection */ - pos += sizeof(u8); + ieee80211_ie_build_ht_cap(pos, sband, cap); } static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, -- cgit v0.10.2 From 176f36086e8a00bdf701dc6e4c5a8784ef6529df Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Wed, 26 Oct 2011 14:47:27 -0700 Subject: mac80211: add HT IEs to mesh frames Signed-off-by: Thomas Pedersen Signed-off-by: Ashok Nagarajan Signed-off-by: John W. Linville diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index a7078fd..2dc76a9 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -341,6 +341,49 @@ int mesh_add_ds_params_ie(struct sk_buff *skb, return 0; } +int mesh_add_ht_cap_ie(struct sk_buff *skb, + struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_supported_band *sband; + u8 *pos; + + sband = local->hw.wiphy->bands[local->oper_channel->band]; + if (!sband->ht_cap.ht_supported || + local->_oper_channel_type == NL80211_CHAN_NO_HT) + return 0; + + if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap)) + return -ENOMEM; + + pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_cap)); + ieee80211_ie_build_ht_cap(pos, sband, sband->ht_cap.cap); + + return 0; +} + +int mesh_add_ht_info_ie(struct sk_buff *skb, + struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_channel *channel = local->oper_channel; + enum nl80211_channel_type channel_type = local->_oper_channel_type; + struct ieee80211_supported_band *sband = + local->hw.wiphy->bands[channel->band]; + struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; + u8 *pos; + + if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT) + return 0; + + if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_info)) + return -ENOMEM; + + pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_info)); + ieee80211_ie_build_ht_info(pos, ht_cap, channel, channel_type); + + return 0; +} static void ieee80211_mesh_path_timer(unsigned long data) { struct ieee80211_sub_if_data *sdata = diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 8c00e2d..0f2c4e6 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h @@ -212,6 +212,10 @@ int mesh_add_vendor_ies(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata); int mesh_add_ds_params_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata); +int mesh_add_ht_cap_ie(struct sk_buff *skb, + struct ieee80211_sub_if_data *sdata); +int mesh_add_ht_info_ie(struct sk_buff *skb, + struct ieee80211_sub_if_data *sdata); void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); void ieee80211s_init(void); diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 351e48c..986af8a 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -169,6 +169,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, 2 + (IEEE80211_MAX_SUPP_RATES - 8) + 2 + sdata->u.mesh.mesh_id_len + 2 + sizeof(struct ieee80211_meshconf_ie) + + 2 + sizeof(struct ieee80211_ht_cap) + + 2 + sizeof(struct ieee80211_ht_info) + 2 + 8 + /* peering IE */ sdata->u.mesh.ie_len); if (!skb) @@ -241,6 +243,13 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, memcpy(pos, &reason, 2); pos += 2; } + + if (action != WLAN_SP_MESH_PEERING_CLOSE) { + if (mesh_add_ht_cap_ie(skb, sdata) || + mesh_add_ht_info_ie(skb, sdata)) + return -1; + } + if (mesh_add_vendor_ies(skb, sdata)) return -1; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f4dd339..a543d26 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2292,6 +2292,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, 2 + 8 + /* supported rates */ 2 + 3 + /* DS params */ 2 + (IEEE80211_MAX_SUPP_RATES - 8) + + 2 + sizeof(struct ieee80211_ht_cap) + + 2 + sizeof(struct ieee80211_ht_info) + 2 + sdata->u.mesh.mesh_id_len + 2 + sizeof(struct ieee80211_meshconf_ie) + sdata->u.mesh.ie_len); @@ -2319,6 +2321,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, mesh_add_ds_params_ie(skb, sdata) || ieee80211_add_ext_srates_ie(&sdata->vif, skb) || mesh_add_rsn_ie(skb, sdata) || + mesh_add_ht_cap_ie(skb, sdata) || + mesh_add_ht_info_ie(skb, sdata) || mesh_add_meshid_ie(skb, sdata) || mesh_add_meshconf_ie(skb, sdata) || mesh_add_vendor_ies(skb, sdata)) { -- cgit v0.10.2 From 739522baa1d6804a3ff33e8c135db0e6b2165f75 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Wed, 26 Oct 2011 14:47:28 -0700 Subject: mac80211: set HT capabilities for mesh peer Set peer's HT capabilities, and disallow peering if we're on a different channel type. Signed-off-by: Thomas Pedersen Signed-off-by: Ashok Nagarajan Signed-off-by: John W. Linville diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 2dc76a9..b3a125f 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -76,6 +76,7 @@ static void ieee80211_mesh_housekeeping_timer(unsigned long data) bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_data *sdata) { struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; + struct ieee80211_local *local = sdata->local; /* * As support for each feature is added, check for matching @@ -87,15 +88,23 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_dat * - MDA enabled * - Power management control on fc */ - if (ifmsh->mesh_id_len == ie->mesh_id_len && - memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && - (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) && - (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) && - (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) && - (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) && - (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)) - return true; - + if (!(ifmsh->mesh_id_len == ie->mesh_id_len && + memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && + (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) && + (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) && + (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) && + (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) && + (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) + goto mismatch; + + /* disallow peering with mismatched channel types for now */ + if (ie->ht_info_elem && + (local->_oper_channel_type != + ieee80211_ht_info_to_channel_type(ie->ht_info_elem))) + goto mismatch; + + return true; +mismatch: return false; } diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 986af8a..0140e88 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -80,11 +80,15 @@ static inline void mesh_plink_fsm_restart(struct sta_info *sta) * on it in the lifecycle management section! */ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, - u8 *hw_addr, u32 rates) + u8 *hw_addr, u32 rates, + struct ieee802_11_elems *elems) { struct ieee80211_local *local = sdata->local; + struct ieee80211_supported_band *sband; struct sta_info *sta; + sband = local->hw.wiphy->bands[local->oper_channel->band]; + if (local->num_sta >= MESH_MAX_PLINKS) return NULL; @@ -96,6 +100,9 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, set_sta_flag(sta, WLAN_STA_AUTHORIZED); set_sta_flag(sta, WLAN_STA_WME); sta->sta.supp_rates[local->hw.conf.channel->band] = rates; + if (elems->ht_cap_elem) + ieee80211_ht_cap_ie_to_sta_ht_cap(sband, elems->ht_cap_elem, + &sta->sta.ht_cap); rate_control_rate_init(sta); return sta; @@ -276,7 +283,7 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, elems->ie_start, elems->total_len, GFP_KERNEL); else - sta = mesh_plink_alloc(sdata, hw_addr, rates); + sta = mesh_plink_alloc(sdata, hw_addr, rates, elems); if (!sta) return; if (sta_info_insert_rcu(sta)) { @@ -567,7 +574,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m } rates = ieee80211_sta_get_rates(local, &elems, rx_status->band); - sta = mesh_plink_alloc(sdata, mgmt->sa, rates); + sta = mesh_plink_alloc(sdata, mgmt->sa, rates, &elems); if (!sta) { mpl_dbg("Mesh plink error: plink table full\n"); return; -- cgit v0.10.2 From ae2772b313b98a14f69b5bc67135c9fee48771be Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Wed, 26 Oct 2011 14:47:29 -0700 Subject: mac80211: allow frame aggregation for mesh Signed-off-by: Thomas Pedersen Signed-off-by: Ashok Nagarajan Signed-off-by: John W. Linville diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c index 97f3358..f9ec0d9 100644 --- a/net/mac80211/agg-rx.c +++ b/net/mac80211/agg-rx.c @@ -176,7 +176,8 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d memcpy(mgmt->da, da, ETH_ALEN); memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); if (sdata->vif.type == NL80211_IFTYPE_AP || - sdata->vif.type == NL80211_IFTYPE_AP_VLAN) + sdata->vif.type == NL80211_IFTYPE_AP_VLAN || + sdata->vif.type == NL80211_IFTYPE_MESH_POINT) memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); else if (sdata->vif.type == NL80211_IFTYPE_STATION) memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c index 2ac0339..fefc7e5 100644 --- a/net/mac80211/agg-tx.c +++ b/net/mac80211/agg-tx.c @@ -77,7 +77,8 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, memcpy(mgmt->da, da, ETH_ALEN); memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); if (sdata->vif.type == NL80211_IFTYPE_AP || - sdata->vif.type == NL80211_IFTYPE_AP_VLAN) + sdata->vif.type == NL80211_IFTYPE_AP_VLAN || + sdata->vif.type == NL80211_IFTYPE_MESH_POINT) memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); else if (sdata->vif.type == NL80211_IFTYPE_STATION) memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); @@ -371,13 +372,8 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid, pubsta->addr, tid); #endif /* CONFIG_MAC80211_HT_DEBUG */ - /* - * The aggregation code is not prepared to handle - * anything but STA/AP due to the BSSID handling. - * IBSS could work in the code but isn't supported - * by drivers or the standard. - */ if (sdata->vif.type != NL80211_IFTYPE_STATION && + sdata->vif.type != NL80211_IFTYPE_MESH_POINT && sdata->vif.type != NL80211_IFTYPE_AP_VLAN && sdata->vif.type != NL80211_IFTYPE_AP) return -EINVAL; diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c index f80a35c..988c7ec 100644 --- a/net/mac80211/ht.c +++ b/net/mac80211/ht.c @@ -195,7 +195,8 @@ void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, memcpy(mgmt->da, da, ETH_ALEN); memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); if (sdata->vif.type == NL80211_IFTYPE_AP || - sdata->vif.type == NL80211_IFTYPE_AP_VLAN) + sdata->vif.type == NL80211_IFTYPE_AP_VLAN || + sdata->vif.type == NL80211_IFTYPE_MESH_POINT) memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); else if (sdata->vif.type == NL80211_IFTYPE_STATION) memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index c74e542..3173dcf 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2203,13 +2203,8 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) switch (mgmt->u.action.category) { case WLAN_CATEGORY_BACK: - /* - * The aggregation code is not prepared to handle - * anything but STA/AP due to the BSSID handling; - * IBSS could work in the code but isn't supported - * by drivers or the standard. - */ if (sdata->vif.type != NL80211_IFTYPE_STATION && + sdata->vif.type != NL80211_IFTYPE_MESH_POINT && sdata->vif.type != NL80211_IFTYPE_AP_VLAN && sdata->vif.type != NL80211_IFTYPE_AP) break; -- cgit v0.10.2 From 9ecd04bc04af7df98b3a93c571e31b6ef6a90681 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 8 Nov 2011 10:45:04 +0000 Subject: sch_choke: use skb_header_pointer() Remove the assumption that skb_get_rxhash() makes IP header and ports linear, and use skb_header_pointer() instead in choke_match_flow() This permits __skb_get_rxhash() to use skb_header_pointer() eventually. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c index 3422b25..061bcb7 100644 --- a/net/sched/sch_choke.c +++ b/net/sched/sch_choke.c @@ -152,15 +152,14 @@ static bool choke_match_flow(struct sk_buff *skb1, { int off1, off2, poff; const u32 *ports1, *ports2; + u32 _ports1, _ports2; u8 ip_proto; __u32 hash1; if (skb1->protocol != skb2->protocol) return false; - /* Use hash value as quick check - * Assumes that __skb_get_rxhash makes IP header and ports linear - */ + /* Use rxhash value as quick check */ hash1 = skb_get_rxhash(skb1); if (!hash1 || hash1 != skb_get_rxhash(skb2)) return false; @@ -172,10 +171,12 @@ static bool choke_match_flow(struct sk_buff *skb1, switch (skb1->protocol) { case __constant_htons(ETH_P_IP): { const struct iphdr *ip1, *ip2; + struct iphdr _ip1, _ip2; - ip1 = (const struct iphdr *) (skb1->data + off1); - ip2 = (const struct iphdr *) (skb2->data + off2); - + ip1 = skb_header_pointer(skb1, off1, sizeof(_ip1), &_ip1); + ip2 = skb_header_pointer(skb2, off2, sizeof(_ip2), &_ip2); + if (!ip1 || !ip2) + return false; ip_proto = ip1->protocol; if (ip_proto != ip2->protocol || ip1->saddr != ip2->saddr || ip1->daddr != ip2->daddr) @@ -190,9 +191,12 @@ static bool choke_match_flow(struct sk_buff *skb1, case __constant_htons(ETH_P_IPV6): { const struct ipv6hdr *ip1, *ip2; + struct ipv6hdr _ip1, _ip2; - ip1 = (const struct ipv6hdr *) (skb1->data + off1); - ip2 = (const struct ipv6hdr *) (skb2->data + off2); + ip1 = skb_header_pointer(skb1, off1, sizeof(_ip1), &_ip1); + ip2 = skb_header_pointer(skb2, off2, sizeof(_ip2), &_ip2); + if (!ip1 || !ip2) + return false; ip_proto = ip1->nexthdr; if (ip_proto != ip2->nexthdr || @@ -214,8 +218,11 @@ static bool choke_match_flow(struct sk_buff *skb1, off1 += poff; off2 += poff; - ports1 = (__force u32 *)(skb1->data + off1); - ports2 = (__force u32 *)(skb2->data + off2); + ports1 = skb_header_pointer(skb1, off1, sizeof(_ports1), &_ports1); + ports2 = skb_header_pointer(skb2, off2, sizeof(_ports2), &_ports2); + if (!ports1 || !ports2) + return false; + return *ports1 == *ports2; } -- cgit v0.10.2 From e56c57d0d3fdbbdf583d3af96bfb803b8dfa713e Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 8 Nov 2011 17:07:07 -0500 Subject: net: rename sk_clone to sk_clone_lock Make clear that sk_clone() and inet_csk_clone() return a locked socket. Add _lock() prefix and kerneldoc. Suggested-by: Linus Torvalds Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index e6db62e..dbf9aab 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -143,9 +143,9 @@ static inline void *inet_csk_ca(const struct sock *sk) return (void *)inet_csk(sk)->icsk_ca_priv; } -extern struct sock *inet_csk_clone(struct sock *sk, - const struct request_sock *req, - const gfp_t priority); +extern struct sock *inet_csk_clone_lock(const struct sock *sk, + const struct request_sock *req, + const gfp_t priority); enum inet_csk_ack_state_t { ICSK_ACK_SCHED = 1, diff --git a/include/net/sock.h b/include/net/sock.h index abb6e0f..67cd458 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1089,8 +1089,8 @@ extern struct sock *sk_alloc(struct net *net, int family, struct proto *prot); extern void sk_free(struct sock *sk); extern void sk_release_kernel(struct sock *sk); -extern struct sock *sk_clone(const struct sock *sk, - const gfp_t priority); +extern struct sock *sk_clone_lock(const struct sock *sk, + const gfp_t priority); extern struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, diff --git a/net/core/sock.c b/net/core/sock.c index 4ed7b1d..2de9dc2 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1204,7 +1204,14 @@ void sk_release_kernel(struct sock *sk) } EXPORT_SYMBOL(sk_release_kernel); -struct sock *sk_clone(const struct sock *sk, const gfp_t priority) +/** + * sk_clone_lock - clone a socket, and lock its clone + * @sk: the socket to clone + * @priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc) + * + * Caller must unlock socket even in error path (bh_unlock_sock(newsk)) + */ +struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) { struct sock *newsk; @@ -1297,7 +1304,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) out: return newsk; } -EXPORT_SYMBOL_GPL(sk_clone); +EXPORT_SYMBOL_GPL(sk_clone_lock); void sk_setup_caps(struct sock *sk, struct dst_entry *dst) { diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index d7041a0..563b7c7 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -100,7 +100,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk, * (* Generate a new socket and switch to that socket *) * Set S := new socket for this port pair */ - struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC); + struct sock *newsk = inet_csk_clone_lock(sk, req, GFP_ATOMIC); if (newsk != NULL) { struct dccp_request_sock *dreq = dccp_rsk(req); diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index c14d88a..a598768 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -588,10 +588,19 @@ void inet_csk_reqsk_queue_prune(struct sock *parent, } EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_prune); -struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req, - const gfp_t priority) +/** + * inet_csk_clone_lock - clone an inet socket, and lock its clone + * @sk: the socket to clone + * @req: request_sock + * @priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc) + * + * Caller must unlock socket even in error path (bh_unlock_sock(newsk)) + */ +struct sock *inet_csk_clone_lock(const struct sock *sk, + const struct request_sock *req, + const gfp_t priority) { - struct sock *newsk = sk_clone(sk, priority); + struct sock *newsk = sk_clone_lock(sk, priority); if (newsk != NULL) { struct inet_connection_sock *newicsk = inet_csk(newsk); @@ -615,7 +624,7 @@ struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req, } return newsk; } -EXPORT_SYMBOL_GPL(inet_csk_clone); +EXPORT_SYMBOL_GPL(inet_csk_clone_lock); /* * At this point, there should be no process reference to this diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 66363b6..0a7e339 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -425,7 +425,7 @@ static inline void TCP_ECN_openreq_child(struct tcp_sock *tp, */ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, struct sk_buff *skb) { - struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC); + struct sock *newsk = inet_csk_clone_lock(sk, req, GFP_ATOMIC); if (newsk != NULL) { const struct inet_request_sock *ireq = inet_rsk(req); -- cgit v0.10.2 From 82cd9965c37be7e2cbcb79ad991a6b9860f855d8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 8 Nov 2011 18:37:25 +0100 Subject: regmap: Add helper function for checking if a register range is volatile We already have the same code for checking whether a register range is volatile in two different places. Instead of duplicating it once more add a small helper function for checking whether a register range is voltaile. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index f7cfff2..5c4e76d 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -64,6 +64,18 @@ bool regmap_precious(struct regmap *map, unsigned int reg) return false; } +static bool regmap_volatile_range(struct regmap *map, unsigned int reg, + unsigned int num) +{ + unsigned int i; + + for (i = 0; i < num; i++) + if (!regmap_volatile(map, reg + i)) + return false; + + return true; +} + static void regmap_format_4_12_write(struct regmap *map, unsigned int reg, unsigned int val) { @@ -483,15 +495,11 @@ EXPORT_SYMBOL_GPL(regmap_read); int regmap_raw_read(struct regmap *map, unsigned int reg, void *val, size_t val_len) { + size_t val_count = val_len / map->format.val_bytes; int ret; - int i; - bool vol = true; - - for (i = 0; i < val_len / map->format.val_bytes; i++) - if (!regmap_volatile(map, reg + i)) - vol = false; - WARN_ON(!vol && map->cache_type != REGCACHE_NONE); + WARN_ON(!regmap_volatile_range(map, reg, val_count) && + map->cache_type != REGCACHE_NONE); mutex_lock(&map->lock); @@ -519,16 +527,11 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, { int ret, i; size_t val_bytes = map->format.val_bytes; - bool vol = true; + bool vol = regmap_volatile_range(map, reg, val_count); if (!map->format.parse_val) return -EINVAL; - /* Is this a block of volatile registers? */ - for (i = 0; i < val_count; i++) - if (!regmap_volatile(map, reg + i)) - vol = false; - if (vol || map->cache_type == REGCACHE_NONE) { ret = regmap_raw_read(map, reg, val, val_bytes * val_count); if (ret != 0) -- cgit v0.10.2 From c48a9d74926c83f62b0251eff0a3dde259923856 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 8 Nov 2011 18:37:26 +0100 Subject: regmap: Support some more block operations on cached devices Commit 10a08d9f ("regmap: Support some block operations on cached devices") allowed raw read operations without throwing a warning when using caches if all registers are volatile. This patch does the same for raw write operations. This is for example useful when loading a firmware in a predefined volatile region on a chip where we otherwise want registers to be cached. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 5c4e76d..3e30d16 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -389,9 +389,11 @@ EXPORT_SYMBOL_GPL(regmap_write); int regmap_raw_write(struct regmap *map, unsigned int reg, const void *val, size_t val_len) { + size_t val_count = val_len / map->format.val_bytes; int ret; - WARN_ON(map->cache_type != REGCACHE_NONE); + WARN_ON(!regmap_volatile_range(map, reg, val_count) && + map->cache_type != REGCACHE_NONE); mutex_lock(&map->lock); -- cgit v0.10.2 From 76ee4557137ce12a60a1e1a070ed341182163a64 Mon Sep 17 00:00:00 2001 From: Kyungmin Park Date: Tue, 8 Nov 2011 19:57:59 +0900 Subject: ARM: EXYNOS: Fix compiler error with THIS_MODULE CC arch/arm/mach-exynos/cpuidle.o arch/arm/mach-exynos/cpuidle.c:36: error: 'THIS_MODULE' undeclared here (not in a function) arch/arm/mach-exynos/cpuidle.c: In function 'exynos4_enter_idle': arch/arm/mach-exynos/cpuidle.c:42: error: storage size of 'before' isn't known arch/arm/mach-exynos/cpuidle.c:42: error: storage size of 'after' isn't known arch/arm/mach-exynos/cpuidle.c:46: error: implicit declaration of function 'do_gettimeofday' arch/arm/mach-exynos/cpuidle.c:52: error: 'USEC_PER_SEC' undeclared (first use in this function) arch/arm/mach-exynos/cpuidle.c:52: error: (Each undeclared identifier is reported only once arch/arm/mach-exynos/cpuidle.c:52: error: for each function it appears in.) arch/arm/mach-exynos/cpuidle.c:42: warning: unused variable 'after' arch/arm/mach-exynos/cpuidle.c:42: warning: unused variable 'before' make[1]: *** [arch/arm/mach-exynos/cpuidle.o] Error 1 Signed-off-by: Kyungmin Park [kgene.kim@samsung.com: Fixed as per Stephen's suggestion] Signed-off-by: Kukjin Kim diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c index 35f6502..4ebb382 100644 --- a/arch/arm/mach-exynos/cpuidle.c +++ b/arch/arm/mach-exynos/cpuidle.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include -- cgit v0.10.2 From 114b80ce2c05f91f10fffbf303080357d73c0675 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 9 Nov 2011 12:54:43 +0000 Subject: GFS2: Fix very unlikley memory leak in ACL xattr code This was spotted by automated code analysis. In case reading an ACL xattr failed (only likely to happen if there is an I/O error for example, and even then only with unstuffed xattrs, so pretty difficult to trigger) a small amount of memory could potentially be leaked. This patch adds a kfree to the error path, and also removes a test which is no longer required (gfs2_ea_get_copy always returns either a negative error, or a length) Signed-off-by: Steven Whitehouse diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index 71d7bf8..a201a1d 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c @@ -549,9 +549,10 @@ int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **ppdata) goto out; error = gfs2_ea_get_copy(ip, &el, data, len); - if (error == 0) - error = len; - *ppdata = data; + if (error < 0) + kfree(data); + else + *ppdata = data; out: brelse(el.el_bh); return error; -- cgit v0.10.2 From 79c4c379c8f16a12c28ea2084db5138e33d17ebd Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 9 Nov 2011 13:46:06 +0000 Subject: GFS2: f_ra is always valid in dir readahead function As a result, we don't need to test it each time. Signed-off-by: Steven Whitehouse Cc: Bob Peterson diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 9144117..946b6f8 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -1378,12 +1378,14 @@ out: return error; } -/* gfs2_dir_readahead - Issue read-ahead requests for leaf blocks. +/** + * gfs2_dir_readahead - Issue read-ahead requests for leaf blocks. * * Note: we can't calculate each index like dir_e_read can because we don't * have the leaf, and therefore we don't have the depth, and therefore we * don't have the length. So we have to just read enough ahead to make up - * for the loss of information. */ + * for the loss of information. + */ static void gfs2_dir_readahead(struct inode *inode, unsigned hsize, u32 index, struct file_ra_state *f_ra) { @@ -1394,7 +1396,7 @@ static void gfs2_dir_readahead(struct inode *inode, unsigned hsize, u32 index, unsigned count; /* First check if we've already read-ahead for the whole range. */ - if (!f_ra || index + MAX_RA_BLOCKS < f_ra->start) + if (index + MAX_RA_BLOCKS < f_ra->start) return; f_ra->start = max((pgoff_t)index, f_ra->start); @@ -1448,7 +1450,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, hash = gfs2_dir_offset2hash(*offset); index = hash >> (32 - dip->i_depth); - if (f_ra && dip->i_hash_cache == NULL) + if (dip->i_hash_cache == NULL) f_ra->start = 0; lp = gfs2_dir_get_hash_table(dip); if (IS_ERR(lp)) -- cgit v0.10.2 From 744cf19eadcf4de914394e0eb227f94f4318f5e4 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 8 Nov 2011 20:40:14 +0200 Subject: Bluetooth: Pass full hci_dev struct to mgmt callbacks The current global pending command list in mgmt.c is racy. Possibly the simplest way to fix it is to have per-hci dev lists instead of a global one (all commands that need a pending struct are hci_dev specific). This way the list can be protected using the already existing per-hci dev lock. To enable this refactoring the first thing that needs to be done is to ensure that the mgmt functions have access to the hci_dev struct (instead of just the dev id). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index e6071d0..0f35a39 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -905,36 +905,41 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, /* Management interface */ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); -int mgmt_index_added(u16 index); -int mgmt_index_removed(u16 index); -int mgmt_powered(u16 index, u8 powered); -int mgmt_discoverable(u16 index, u8 discoverable); -int mgmt_connectable(u16 index, u8 connectable); -int mgmt_write_scan_failed(u16 index, u8 scan, u8 status); -int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent); -int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 type); -int mgmt_disconnected(u16 index, bdaddr_t *bdaddr, u8 type); -int mgmt_disconnect_failed(u16 index); -int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 type, u8 status); -int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); -int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); -int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); -int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, - u8 confirm_hint); -int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); -int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, +int mgmt_index_added(struct hci_dev *hdev); +int mgmt_index_removed(struct hci_dev *hdev); +int mgmt_powered(struct hci_dev *hdev, u8 powered); +int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); +int mgmt_connectable(struct hci_dev *hdev, u8 connectable); +int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); +int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, + u8 persistent); +int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); +int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); +int mgmt_disconnect_failed(struct hci_dev *hdev); +int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, u8 status); -int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); -int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); -int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, +int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); +int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); -int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 type, u8 *dev_class, - s8 rssi, u8 *eir); -int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); -int mgmt_inquiry_failed(u16 index, u8 status); -int mgmt_discovering(u16 index, u8 discovering); -int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr); -int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr); +int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 status); +int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, + __le32 value, u8 confirm_hint); +int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 status); +int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, + bdaddr_t *bdaddr, u8 status); +int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); +int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); +int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, + u8 *randomizer, u8 status); +int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, + u8 *dev_class, s8 rssi, u8 *eir); +int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); +int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status); +int mgmt_discovering(struct hci_dev *hdev, u8 discovering); +int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr); +int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr); /* HCI info for socket */ #define hci_pi(sk) ((struct hci_pinfo *) sk) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 693c0df..e4b5c63 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -550,7 +550,7 @@ int hci_dev_open(__u16 dev) set_bit(HCI_UP, &hdev->flags); hci_notify(hdev, HCI_DEV_UP); if (!test_bit(HCI_SETUP, &hdev->flags)) - mgmt_powered(hdev->id, 1); + mgmt_powered(hdev, 1); } else { /* Init failed, cleanup */ tasklet_kill(&hdev->rx_task); @@ -642,7 +642,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) * and no tasks are scheduled. */ hdev->close(hdev); - mgmt_powered(hdev->id, 0); + mgmt_powered(hdev, 0); /* Clear flags */ hdev->flags = 0; @@ -947,7 +947,7 @@ static void hci_power_on(struct work_struct *work) msecs_to_jiffies(AUTO_OFF_TIMEOUT)); if (test_and_clear_bit(HCI_SETUP, &hdev->flags)) - mgmt_index_added(hdev->id); + mgmt_index_added(hdev); } static void hci_power_off(struct work_struct *work) @@ -1140,7 +1140,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, persistent = hci_persistent_key(hdev, conn, type, old_key_type); - mgmt_new_link_key(hdev->id, key, persistent); + mgmt_new_link_key(hdev, key, persistent); if (!persistent) { list_del(&key->list); @@ -1183,7 +1183,7 @@ int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, memcpy(id->rand, rand, sizeof(id->rand)); if (new_key) - mgmt_new_link_key(hdev->id, key, old_key_type); + mgmt_new_link_key(hdev, key, old_key_type); return 0; } @@ -1324,7 +1324,7 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) list_add(&entry->list, &hdev->blacklist); - return mgmt_device_blocked(hdev->id, bdaddr); + return mgmt_device_blocked(hdev, bdaddr); } int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) @@ -1343,7 +1343,7 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) list_del(&entry->list); kfree(entry); - return mgmt_device_unblocked(hdev->id, bdaddr); + return mgmt_device_unblocked(hdev, bdaddr); } static void hci_clear_adv_cache(unsigned long arg) @@ -1560,7 +1560,7 @@ void hci_unregister_dev(struct hci_dev *hdev) if (!test_bit(HCI_INIT, &hdev->flags) && !test_bit(HCI_SETUP, &hdev->flags)) - mgmt_index_removed(hdev->id); + mgmt_index_removed(hdev); hci_notify(hdev, HCI_DEV_UNREG); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2fced8c..8303f8f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -60,7 +60,7 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) clear_bit(HCI_INQUIRY, &hdev->flags); - mgmt_discovering(hdev->id, 0); + mgmt_discovering(hdev, 0); hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); @@ -202,7 +202,7 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) return; if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_set_local_name_complete(hdev->id, sent, status); + mgmt_set_local_name_complete(hdev, sent, status); if (status) return; @@ -283,7 +283,7 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) param = *((__u8 *) sent); if (status != 0) { - mgmt_write_scan_failed(hdev->id, param, status); + mgmt_write_scan_failed(hdev, param, status); hdev->discov_timeout = 0; goto done; } @@ -294,21 +294,21 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) if (param & SCAN_INQUIRY) { set_bit(HCI_ISCAN, &hdev->flags); if (!old_iscan) - mgmt_discoverable(hdev->id, 1); + mgmt_discoverable(hdev, 1); if (hdev->discov_timeout > 0) { int to = msecs_to_jiffies(hdev->discov_timeout * 1000); queue_delayed_work(hdev->workqueue, &hdev->discov_off, to); } } else if (old_iscan) - mgmt_discoverable(hdev->id, 0); + mgmt_discoverable(hdev, 0); if (param & SCAN_PAGE) { set_bit(HCI_PSCAN, &hdev->flags); if (!old_pscan) - mgmt_connectable(hdev->id, 1); + mgmt_connectable(hdev, 1); } else if (old_pscan) - mgmt_connectable(hdev->id, 0); + mgmt_connectable(hdev, 0); done: hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status); @@ -835,7 +835,7 @@ static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, rp->status); if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_pin_code_reply_complete(hdev->id, &rp->bdaddr, rp->status); + mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); if (rp->status != 0) return; @@ -856,7 +856,7 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, rp->status); if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_pin_code_neg_reply_complete(hdev->id, &rp->bdaddr, + mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, rp->status); } static void hci_cc_le_read_buffer_size(struct hci_dev *hdev, @@ -886,7 +886,7 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, rp->status); if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_user_confirm_reply_complete(hdev->id, &rp->bdaddr, + mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, rp->status); } @@ -898,7 +898,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, BT_DBG("%s status 0x%x", hdev->name, rp->status); if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_user_confirm_neg_reply_complete(hdev->id, &rp->bdaddr, + mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, rp->status); } @@ -909,7 +909,7 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev, BT_DBG("%s status 0x%x", hdev->name, rp->status); - mgmt_read_local_oob_data_reply_complete(hdev->id, rp->hash, + mgmt_read_local_oob_data_reply_complete(hdev, rp->hash, rp->randomizer, rp->status); } @@ -986,13 +986,13 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) hci_req_complete(hdev, HCI_OP_INQUIRY, status); hci_conn_check_pending(hdev); if (test_bit(HCI_MGMT, &hdev->flags)) - mgmt_inquiry_failed(hdev->id, status); + mgmt_inquiry_failed(hdev, status); return; } set_bit(HCI_INQUIRY, &hdev->flags); - mgmt_discovering(hdev->id, 1); + mgmt_discovering(hdev, 1); } static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) @@ -1378,7 +1378,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) return; - mgmt_discovering(hdev->id, 0); + mgmt_discovering(hdev, 0); } static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) @@ -1404,7 +1404,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.rssi = 0x00; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, info->dev_class, 0, NULL); } @@ -1439,7 +1439,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->state = BT_CONFIG; hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; - mgmt_connected(hdev->id, &ev->bdaddr, conn->type); + mgmt_connected(hdev, &ev->bdaddr, conn->type); } else conn->state = BT_CONNECTED; @@ -1471,7 +1471,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s } else { conn->state = BT_CLOSED; if (conn->type == ACL_LINK) - mgmt_connect_failed(hdev->id, &ev->bdaddr, conn->type, + mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, ev->status); } @@ -1572,7 +1572,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff BT_DBG("%s status %d", hdev->name, ev->status); if (ev->status) { - mgmt_disconnect_failed(hdev->id); + mgmt_disconnect_failed(hdev); return; } @@ -1585,7 +1585,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff conn->state = BT_CLOSED; if (conn->type == ACL_LINK || conn->type == LE_LINK) - mgmt_disconnected(hdev->id, &conn->dst, conn->type); + mgmt_disconnected(hdev, &conn->dst, conn->type); hci_proto_disconn_cfm(conn, ev->reason); hci_conn_del(conn); @@ -1616,7 +1616,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->sec_level = conn->pending_sec_level; } } else { - mgmt_auth_failed(hdev->id, &conn->dst, ev->status); + mgmt_auth_failed(hdev, &conn->dst, ev->status); } clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); @@ -1671,7 +1671,7 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb hci_dev_lock(hdev); if (ev->status == 0 && test_bit(HCI_MGMT, &hdev->flags)) - mgmt_remote_name(hdev->id, &ev->bdaddr, ev->name); + mgmt_remote_name(hdev, &ev->bdaddr, ev->name); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (!conn) @@ -2061,7 +2061,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) case HCI_OP_DISCONNECT: if (ev->status != 0) - mgmt_disconnect_failed(hdev->id); + mgmt_disconnect_failed(hdev); break; case HCI_OP_LE_CREATE_CONN: @@ -2226,7 +2226,7 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff else secure = 0; - mgmt_pin_code_request(hdev->id, &ev->bdaddr, secure); + mgmt_pin_code_request(hdev, &ev->bdaddr, secure); } unlock: @@ -2409,7 +2409,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, info->dev_class, info->rssi, NULL); } @@ -2426,7 +2426,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, info->dev_class, info->rssi, NULL); } @@ -2569,7 +2569,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x01; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev->id, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, info->dev_class, info->rssi, info->data); } @@ -2726,7 +2726,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev, } confirm: - mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey, + mgmt_user_confirm_request(hdev, &ev->bdaddr, ev->passkey, confirm_hint); unlock: @@ -2752,7 +2752,7 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_ * event gets always produced as initiator and is also mapped to * the mgmt_auth_failed event */ if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend) && ev->status != 0) - mgmt_auth_failed(hdev->id, &conn->dst, ev->status); + mgmt_auth_failed(hdev, &conn->dst, ev->status); hci_conn_put(conn); @@ -2833,15 +2833,14 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff } if (ev->status) { - mgmt_connect_failed(hdev->id, &ev->bdaddr, conn->type, - ev->status); + mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, ev->status); hci_proto_connect_cfm(conn, ev->status); conn->state = BT_CLOSED; hci_conn_del(conn); goto unlock; } - mgmt_connected(hdev->id, &ev->bdaddr, conn->type); + mgmt_connected(hdev, &ev->bdaddr, conn->type); conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4cb2f958..2ca7b44 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -255,7 +255,7 @@ static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, return cmd; } -static void mgmt_pending_foreach(u16 opcode, int index, +static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, void (*cb)(struct pending_cmd *cmd, void *data), void *data) { @@ -269,7 +269,7 @@ static void mgmt_pending_foreach(u16 opcode, int index, if (opcode > 0 && cmd->opcode != opcode) continue; - if (index >= 0 && cmd->index != index) + if (hdev && cmd->index != hdev->id) continue; cb(cmd, data); @@ -475,8 +475,8 @@ failed: return err; } -static int mgmt_event(u16 event, u16 index, void *data, u16 data_len, - struct sock *skip_sk) +static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, + u16 data_len, struct sock *skip_sk) { struct sk_buff *skb; struct mgmt_hdr *hdr; @@ -489,7 +489,10 @@ static int mgmt_event(u16 event, u16 index, void *data, u16 data_len, hdr = (void *) skb_put(skb, sizeof(*hdr)); hdr->opcode = cpu_to_le16(event); - hdr->index = cpu_to_le16(index); + if (hdev) + hdr->index = cpu_to_le16(hdev->id); + else + hdr->index = cpu_to_le16(MGMT_INDEX_NONE); hdr->len = cpu_to_le16(data_len); if (data) @@ -541,7 +544,7 @@ static int set_pairable(struct sock *sk, u16 index, unsigned char *data, ev.val = cp->val; - err = mgmt_event(MGMT_EV_PAIRABLE, index, &ev, sizeof(ev), sk); + err = mgmt_event(MGMT_EV_PAIRABLE, hdev, &ev, sizeof(ev), sk); failed: hci_dev_unlock_bh(hdev); @@ -1966,18 +1969,18 @@ static void cmd_status_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_remove(cmd); } -int mgmt_index_added(u16 index) +int mgmt_index_added(struct hci_dev *hdev) { - return mgmt_event(MGMT_EV_INDEX_ADDED, index, NULL, 0, NULL); + return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL); } -int mgmt_index_removed(u16 index) +int mgmt_index_removed(struct hci_dev *hdev) { u8 status = ENODEV; - mgmt_pending_foreach(0, index, cmd_status_rsp, &status); + mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); - return mgmt_event(MGMT_EV_INDEX_REMOVED, index, NULL, 0, NULL); + return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); } struct cmd_lookup { @@ -2005,22 +2008,22 @@ static void mode_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_free(cmd); } -int mgmt_powered(u16 index, u8 powered) +int mgmt_powered(struct hci_dev *hdev, u8 powered) { struct mgmt_mode ev; struct cmd_lookup match = { powered, NULL }; int ret; - mgmt_pending_foreach(MGMT_OP_SET_POWERED, index, mode_rsp, &match); + mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, mode_rsp, &match); if (!powered) { u8 status = ENETDOWN; - mgmt_pending_foreach(0, index, cmd_status_rsp, &status); + mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); } ev.val = powered; - ret = mgmt_event(MGMT_EV_POWERED, index, &ev, sizeof(ev), match.sk); + ret = mgmt_event(MGMT_EV_POWERED, hdev, &ev, sizeof(ev), match.sk); if (match.sk) sock_put(match.sk); @@ -2028,17 +2031,17 @@ int mgmt_powered(u16 index, u8 powered) return ret; } -int mgmt_discoverable(u16 index, u8 discoverable) +int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) { struct mgmt_mode ev; struct cmd_lookup match = { discoverable, NULL }; int ret; - mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, index, mode_rsp, &match); + mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, mode_rsp, &match); ev.val = discoverable; - ret = mgmt_event(MGMT_EV_DISCOVERABLE, index, &ev, sizeof(ev), + ret = mgmt_event(MGMT_EV_DISCOVERABLE, hdev, &ev, sizeof(ev), match.sk); if (match.sk) @@ -2047,17 +2050,17 @@ int mgmt_discoverable(u16 index, u8 discoverable) return ret; } -int mgmt_connectable(u16 index, u8 connectable) +int mgmt_connectable(struct hci_dev *hdev, u8 connectable) { struct mgmt_mode ev; struct cmd_lookup match = { connectable, NULL }; int ret; - mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, index, mode_rsp, &match); + mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, mode_rsp, &match); ev.val = connectable; - ret = mgmt_event(MGMT_EV_CONNECTABLE, index, &ev, sizeof(ev), match.sk); + ret = mgmt_event(MGMT_EV_CONNECTABLE, hdev, &ev, sizeof(ev), match.sk); if (match.sk) sock_put(match.sk); @@ -2065,20 +2068,21 @@ int mgmt_connectable(u16 index, u8 connectable) return ret; } -int mgmt_write_scan_failed(u16 index, u8 scan, u8 status) +int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status) { if (scan & SCAN_PAGE) - mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, index, + mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, cmd_status_rsp, &status); if (scan & SCAN_INQUIRY) - mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, index, + mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, cmd_status_rsp, &status); return 0; } -int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent) +int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, + u8 persistent) { struct mgmt_ev_new_link_key ev; @@ -2090,17 +2094,17 @@ int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent) memcpy(ev.key.val, key->val, 16); ev.key.pin_len = key->pin_len; - return mgmt_event(MGMT_EV_NEW_LINK_KEY, index, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); } -int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type) +int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type) { struct mgmt_addr_info ev; bacpy(&ev.bdaddr, bdaddr); ev.type = link_to_mgmt(link_type); - return mgmt_event(MGMT_EV_CONNECTED, index, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_CONNECTED, hdev, &ev, sizeof(ev), NULL); } static void disconnect_rsp(struct pending_cmd *cmd, void *data) @@ -2119,18 +2123,18 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_remove(cmd); } -int mgmt_disconnected(u16 index, bdaddr_t *bdaddr, u8 type) +int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) { struct mgmt_addr_info ev; struct sock *sk = NULL; int err; - mgmt_pending_foreach(MGMT_OP_DISCONNECT, index, disconnect_rsp, &sk); + mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk); bacpy(&ev.bdaddr, bdaddr); ev.type = link_to_mgmt(type); - err = mgmt_event(MGMT_EV_DISCONNECTED, index, &ev, sizeof(ev), sk); + err = mgmt_event(MGMT_EV_DISCONNECTED, hdev, &ev, sizeof(ev), sk); if (sk) sock_put(sk); @@ -2138,23 +2142,24 @@ int mgmt_disconnected(u16 index, bdaddr_t *bdaddr, u8 type) return err; } -int mgmt_disconnect_failed(u16 index) +int mgmt_disconnect_failed(struct hci_dev *hdev) { struct pending_cmd *cmd; int err; - cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, index); + cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev->id); if (!cmd) return -ENOENT; - err = cmd_status(cmd->sk, index, MGMT_OP_DISCONNECT, EIO); + err = cmd_status(cmd->sk, hdev->id, MGMT_OP_DISCONNECT, EIO); mgmt_pending_remove(cmd); return err; } -int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 type, u8 status) +int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, + u8 status) { struct mgmt_ev_connect_failed ev; @@ -2162,34 +2167,35 @@ int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 type, u8 status) ev.addr.type = link_to_mgmt(type); ev.status = status; - return mgmt_event(MGMT_EV_CONNECT_FAILED, index, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_CONNECT_FAILED, hdev, &ev, sizeof(ev), NULL); } -int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure) +int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure) { struct mgmt_ev_pin_code_request ev; bacpy(&ev.bdaddr, bdaddr); ev.secure = secure; - return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, index, &ev, sizeof(ev), + return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev), NULL); } -int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) +int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 status) { struct pending_cmd *cmd; struct mgmt_rp_pin_code_reply rp; int err; - cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, index); + cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, hdev->id); if (!cmd) return -ENOENT; bacpy(&rp.bdaddr, bdaddr); rp.status = status; - err = cmd_complete(cmd->sk, index, MGMT_OP_PIN_CODE_REPLY, &rp, + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -2197,20 +2203,21 @@ int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) return err; } -int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) +int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 status) { struct pending_cmd *cmd; struct mgmt_rp_pin_code_reply rp; int err; - cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, index); + cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, hdev->id); if (!cmd) return -ENOENT; bacpy(&rp.bdaddr, bdaddr); rp.status = status; - err = cmd_complete(cmd->sk, index, MGMT_OP_PIN_CODE_NEG_REPLY, &rp, + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -2218,97 +2225,95 @@ int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) return err; } -int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, - u8 confirm_hint) +int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, + __le32 value, u8 confirm_hint) { struct mgmt_ev_user_confirm_request ev; - BT_DBG("hci%u", index); + BT_DBG("%s", hdev->name); bacpy(&ev.bdaddr, bdaddr); ev.confirm_hint = confirm_hint; put_unaligned_le32(value, &ev.value); - return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, index, &ev, sizeof(ev), + return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, hdev, &ev, sizeof(ev), NULL); } -static int confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status, - u8 opcode) +static int confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 status, u8 opcode) { struct pending_cmd *cmd; struct mgmt_rp_user_confirm_reply rp; int err; - cmd = mgmt_pending_find(opcode, index); + cmd = mgmt_pending_find(opcode, hdev->id); if (!cmd) return -ENOENT; bacpy(&rp.bdaddr, bdaddr); rp.status = status; - err = cmd_complete(cmd->sk, index, opcode, &rp, sizeof(rp)); + err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp)); mgmt_pending_remove(cmd); return err; } -int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) +int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 status) { - return confirm_reply_complete(index, bdaddr, status, + return confirm_reply_complete(hdev, bdaddr, status, MGMT_OP_USER_CONFIRM_REPLY); } -int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) +int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, + bdaddr_t *bdaddr, u8 status) { - return confirm_reply_complete(index, bdaddr, status, + return confirm_reply_complete(hdev, bdaddr, status, MGMT_OP_USER_CONFIRM_NEG_REPLY); } -int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status) +int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) { struct mgmt_ev_auth_failed ev; bacpy(&ev.bdaddr, bdaddr); ev.status = status; - return mgmt_event(MGMT_EV_AUTH_FAILED, index, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_AUTH_FAILED, hdev, &ev, sizeof(ev), NULL); } -int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status) +int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) { struct pending_cmd *cmd; - struct hci_dev *hdev; struct mgmt_cp_set_local_name ev; int err; memset(&ev, 0, sizeof(ev)); memcpy(ev.name, name, HCI_MAX_NAME_LENGTH); - cmd = mgmt_pending_find(MGMT_OP_SET_LOCAL_NAME, index); + cmd = mgmt_pending_find(MGMT_OP_SET_LOCAL_NAME, hdev->id); if (!cmd) goto send_event; if (status) { - err = cmd_status(cmd->sk, index, MGMT_OP_SET_LOCAL_NAME, EIO); + err = cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, + EIO); goto failed; } - hdev = hci_dev_get(index); - if (hdev) { - hci_dev_lock_bh(hdev); - update_eir(hdev); - hci_dev_unlock_bh(hdev); - hci_dev_put(hdev); - } + hci_dev_lock_bh(hdev); + update_eir(hdev); + hci_dev_unlock_bh(hdev); - err = cmd_complete(cmd->sk, index, MGMT_OP_SET_LOCAL_NAME, &ev, + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, &ev, sizeof(ev)); if (err < 0) goto failed; send_event: - err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, index, &ev, sizeof(ev), + err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, sizeof(ev), cmd ? cmd->sk : NULL); failed: @@ -2317,29 +2322,30 @@ failed: return err; } -int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, - u8 status) +int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, + u8 *randomizer, u8 status) { struct pending_cmd *cmd; int err; - BT_DBG("hci%u status %u", index, status); + BT_DBG("%s status %u", hdev->name, status); - cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, index); + cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev->id); if (!cmd) return -ENOENT; if (status) { - err = cmd_status(cmd->sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, - EIO); + err = cmd_status(cmd->sk, hdev->id, + MGMT_OP_READ_LOCAL_OOB_DATA, EIO); } else { struct mgmt_rp_read_local_oob_data rp; memcpy(rp.hash, hash, sizeof(rp.hash)); memcpy(rp.randomizer, randomizer, sizeof(rp.randomizer)); - err = cmd_complete(cmd->sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, - &rp, sizeof(rp)); + err = cmd_complete(cmd->sk, hdev->id, + MGMT_OP_READ_LOCAL_OOB_DATA, + &rp, sizeof(rp)); } mgmt_pending_remove(cmd); @@ -2347,8 +2353,8 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, return err; } -int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 type, u8 *dev_class, - s8 rssi, u8 *eir) +int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, + u8 *dev_class, s8 rssi, u8 *eir) { struct mgmt_ev_device_found ev; @@ -2364,10 +2370,10 @@ int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 type, u8 *dev_class, if (dev_class) memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class)); - return mgmt_event(MGMT_EV_DEVICE_FOUND, index, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL); } -int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name) +int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name) { struct mgmt_ev_remote_name ev; @@ -2376,64 +2382,64 @@ int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name) bacpy(&ev.bdaddr, bdaddr); memcpy(ev.name, name, HCI_MAX_NAME_LENGTH); - return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_REMOTE_NAME, hdev, &ev, sizeof(ev), NULL); } -int mgmt_inquiry_failed(u16 index, u8 status) +int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status) { struct pending_cmd *cmd; int err; - cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, index); + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev->id); if (!cmd) return -ENOENT; - err = cmd_status(cmd->sk, index, cmd->opcode, status); + err = cmd_status(cmd->sk, hdev->id, cmd->opcode, status); mgmt_pending_remove(cmd); return err; } -int mgmt_discovering(u16 index, u8 discovering) +int mgmt_discovering(struct hci_dev *hdev, u8 discovering) { struct pending_cmd *cmd; if (discovering) - cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, index); + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev->id); else - cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index); + cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev->id); if (cmd != NULL) { - cmd_complete(cmd->sk, index, cmd->opcode, NULL, 0); + cmd_complete(cmd->sk, hdev->id, cmd->opcode, NULL, 0); mgmt_pending_remove(cmd); } - return mgmt_event(MGMT_EV_DISCOVERING, index, &discovering, + return mgmt_event(MGMT_EV_DISCOVERING, hdev, &discovering, sizeof(discovering), NULL); } -int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr) +int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr) { struct pending_cmd *cmd; struct mgmt_ev_device_blocked ev; - cmd = mgmt_pending_find(MGMT_OP_BLOCK_DEVICE, index); + cmd = mgmt_pending_find(MGMT_OP_BLOCK_DEVICE, hdev->id); bacpy(&ev.bdaddr, bdaddr); - return mgmt_event(MGMT_EV_DEVICE_BLOCKED, index, &ev, sizeof(ev), - cmd ? cmd->sk : NULL); + return mgmt_event(MGMT_EV_DEVICE_BLOCKED, hdev, &ev, sizeof(ev), + cmd ? cmd->sk : NULL); } -int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr) +int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr) { struct pending_cmd *cmd; struct mgmt_ev_device_unblocked ev; - cmd = mgmt_pending_find(MGMT_OP_UNBLOCK_DEVICE, index); + cmd = mgmt_pending_find(MGMT_OP_UNBLOCK_DEVICE, hdev->id); bacpy(&ev.bdaddr, bdaddr); - return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, index, &ev, sizeof(ev), - cmd ? cmd->sk : NULL); + return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &ev, sizeof(ev), + cmd ? cmd->sk : NULL); } -- cgit v0.10.2 From 2e58ef3e11d0775795345a20185b5a7c4bdae194 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 8 Nov 2011 20:40:15 +0200 Subject: Bluetooth: Move pending management command list into struct hci_dev This patch moves the pending management command list (previously global to mgmt.c) into struct hci_dev. This makes it possible to do proper locking when accessing it (through the existing hci_dev locks) and thereby avoid race conditions. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 0f35a39..0a5a05d 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -217,6 +217,8 @@ struct hci_dev { __u16 init_last_cmd; + struct list_head mgmt_pending; + struct inquiry_cache inq_cache; struct hci_conn_hash conn_hash; struct list_head blacklist; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e4b5c63..e5cf013 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1481,6 +1481,8 @@ int hci_register_dev(struct hci_dev *hdev) hci_conn_hash_init(hdev); + INIT_LIST_HEAD(&hdev->mgmt_pending); + INIT_LIST_HEAD(&hdev->blacklist); INIT_LIST_HEAD(&hdev->uuids); @@ -1562,6 +1564,10 @@ void hci_unregister_dev(struct hci_dev *hdev) !test_bit(HCI_SETUP, &hdev->flags)) mgmt_index_removed(hdev); + /* mgmt_index_removed should take care of emptying the + * pending list */ + BUG_ON(!list_empty(&hdev->mgmt_pending)); + hci_notify(hdev, HCI_DEV_UNREG); if (hdev->rfkill) { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 2ca7b44..be198f3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -43,8 +43,6 @@ struct pending_cmd { void *user_data; }; -static LIST_HEAD(cmd_list); - static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) { struct sk_buff *skb; @@ -227,7 +225,8 @@ static void mgmt_pending_free(struct pending_cmd *cmd) } static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, - u16 index, void *data, u16 len) + struct hci_dev *hdev, + void *data, u16 len) { struct pending_cmd *cmd; @@ -236,7 +235,7 @@ static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, return NULL; cmd->opcode = opcode; - cmd->index = index; + cmd->index = hdev->id; cmd->param = kmalloc(len, GFP_ATOMIC); if (!cmd->param) { @@ -250,7 +249,7 @@ static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, cmd->sk = sk; sock_hold(sk); - list_add(&cmd->list, &cmd_list); + list_add(&cmd->list, &hdev->mgmt_pending); return cmd; } @@ -261,7 +260,7 @@ static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, { struct list_head *p, *n; - list_for_each_safe(p, n, &cmd_list) { + list_for_each_safe(p, n, &hdev->mgmt_pending) { struct pending_cmd *cmd; cmd = list_entry(p, struct pending_cmd, list); @@ -276,15 +275,15 @@ static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, } } -static struct pending_cmd *mgmt_pending_find(u16 opcode, int index) +static struct pending_cmd *mgmt_pending_find(u16 opcode, struct hci_dev *hdev) { struct pending_cmd *cmd; - list_for_each_entry(cmd, &cmd_list, list) { + list_for_each_entry(cmd, &hdev->mgmt_pending, list) { if (cmd->opcode != opcode) continue; - if (index >= 0 && cmd->index != index) + if (hdev && cmd->index != hdev->id) continue; return cmd; @@ -325,12 +324,12 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len) goto failed; } - if (mgmt_pending_find(MGMT_OP_SET_POWERED, index)) { + if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_POWERED, EBUSY); goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_SET_POWERED, index, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_SET_POWERED, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -376,8 +375,8 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, goto failed; } - if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, index) || - mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, index)) { + if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || + mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, EBUSY); goto failed; } @@ -388,7 +387,7 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_SET_DISCOVERABLE, index, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_SET_DISCOVERABLE, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -442,8 +441,8 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data, goto failed; } - if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, index) || - mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, index)) { + if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || + mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, EBUSY); goto failed; } @@ -453,7 +452,7 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data, goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_SET_CONNECTABLE, index, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_SET_CONNECTABLE, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -1038,7 +1037,7 @@ static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len) goto failed; } - if (mgmt_pending_find(MGMT_OP_DISCONNECT, index)) { + if (mgmt_pending_find(MGMT_OP_DISCONNECT, hdev)) { err = cmd_status(sk, index, MGMT_OP_DISCONNECT, EBUSY); goto failed; } @@ -1052,7 +1051,7 @@ static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len) goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_DISCONNECT, index, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_DISCONNECT, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -1143,7 +1142,7 @@ static int send_pin_code_neg_reply(struct sock *sk, u16 index, struct pending_cmd *cmd; int err; - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, index, cp, + cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, hdev, cp, sizeof(*cp)); if (!cmd) return -ENOMEM; @@ -1204,7 +1203,7 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, index, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -1297,7 +1296,7 @@ static inline struct pending_cmd *find_pairing(struct hci_conn *conn) struct hci_dev *hdev = conn->hdev; struct pending_cmd *cmd; - list_for_each_entry(cmd, &cmd_list, list) { + list_for_each_entry(cmd, &hdev->mgmt_pending, list) { if (cmd->opcode != MGMT_OP_PAIR_DEVICE) continue; @@ -1396,7 +1395,7 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len) goto unlock; } - cmd = mgmt_pending_add(sk, MGMT_OP_PAIR_DEVICE, index, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_PAIR_DEVICE, hdev, data, len); if (!cmd) { err = -ENOMEM; hci_conn_put(conn); @@ -1458,7 +1457,7 @@ static int user_confirm_reply(struct sock *sk, u16 index, unsigned char *data, goto failed; } - cmd = mgmt_pending_add(sk, mgmt_op, index, data, len); + cmd = mgmt_pending_add(sk, mgmt_op, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -1495,7 +1494,7 @@ static int set_local_name(struct sock *sk, u16 index, unsigned char *data, hci_dev_lock_bh(hdev); - cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, index, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -1541,12 +1540,12 @@ static int read_local_oob_data(struct sock *sk, u16 index) goto unlock; } - if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, index)) { + if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev)) { err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, EBUSY); goto unlock; } - cmd = mgmt_pending_add(sk, MGMT_OP_READ_LOCAL_OOB_DATA, index, NULL, 0); + cmd = mgmt_pending_add(sk, MGMT_OP_READ_LOCAL_OOB_DATA, hdev, NULL, 0); if (!cmd) { err = -ENOMEM; goto unlock; @@ -1650,7 +1649,7 @@ static int start_discovery(struct sock *sk, u16 index) goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, index, NULL, 0); + cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, hdev, NULL, 0); if (!cmd) { err = -ENOMEM; goto failed; @@ -1681,7 +1680,7 @@ static int stop_discovery(struct sock *sk, u16 index) hci_dev_lock_bh(hdev); - cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, index, NULL, 0); + cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, hdev, NULL, 0); if (!cmd) { err = -ENOMEM; goto failed; @@ -2147,7 +2146,7 @@ int mgmt_disconnect_failed(struct hci_dev *hdev) struct pending_cmd *cmd; int err; - cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev); if (!cmd) return -ENOENT; @@ -2188,7 +2187,7 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, struct mgmt_rp_pin_code_reply rp; int err; - cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, hdev); if (!cmd) return -ENOENT; @@ -2210,7 +2209,7 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, struct mgmt_rp_pin_code_reply rp; int err; - cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, hdev); if (!cmd) return -ENOENT; @@ -2247,7 +2246,7 @@ static int confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, struct mgmt_rp_user_confirm_reply rp; int err; - cmd = mgmt_pending_find(opcode, hdev->id); + cmd = mgmt_pending_find(opcode, hdev); if (!cmd) return -ENOENT; @@ -2293,7 +2292,7 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) memset(&ev, 0, sizeof(ev)); memcpy(ev.name, name, HCI_MAX_NAME_LENGTH); - cmd = mgmt_pending_find(MGMT_OP_SET_LOCAL_NAME, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_SET_LOCAL_NAME, hdev); if (!cmd) goto send_event; @@ -2330,7 +2329,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, BT_DBG("%s status %u", hdev->name, status); - cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev); if (!cmd) return -ENOENT; @@ -2390,7 +2389,7 @@ int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status) struct pending_cmd *cmd; int err; - cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev); if (!cmd) return -ENOENT; @@ -2405,9 +2404,9 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) struct pending_cmd *cmd; if (discovering) - cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev); else - cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev); if (cmd != NULL) { cmd_complete(cmd->sk, hdev->id, cmd->opcode, NULL, 0); @@ -2423,7 +2422,7 @@ int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr) struct pending_cmd *cmd; struct mgmt_ev_device_blocked ev; - cmd = mgmt_pending_find(MGMT_OP_BLOCK_DEVICE, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_BLOCK_DEVICE, hdev); bacpy(&ev.bdaddr, bdaddr); @@ -2436,7 +2435,7 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr) struct pending_cmd *cmd; struct mgmt_ev_device_unblocked ev; - cmd = mgmt_pending_find(MGMT_OP_UNBLOCK_DEVICE, hdev->id); + cmd = mgmt_pending_find(MGMT_OP_UNBLOCK_DEVICE, hdev); bacpy(&ev.bdaddr, bdaddr); -- cgit v0.10.2 From 56e5cb86eb377970825486a5861f5926d65e64c1 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 8 Nov 2011 20:40:16 +0200 Subject: Bluetooth: Add missing hci_dev locking when calling mgmt functions Now that the pending commands are within struct hci_dev we can properly control access to them throught the hci_dev locking mechanism. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e5cf013..f87bf24 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -549,8 +549,11 @@ int hci_dev_open(__u16 dev) hci_dev_hold(hdev); set_bit(HCI_UP, &hdev->flags); hci_notify(hdev, HCI_DEV_UP); - if (!test_bit(HCI_SETUP, &hdev->flags)) + if (!test_bit(HCI_SETUP, &hdev->flags)) { + hci_dev_lock_bh(hdev); mgmt_powered(hdev, 1); + hci_dev_unlock_bh(hdev); + } } else { /* Init failed, cleanup */ tasklet_kill(&hdev->rx_task); @@ -642,7 +645,9 @@ static int hci_dev_do_close(struct hci_dev *hdev) * and no tasks are scheduled. */ hdev->close(hdev); + hci_dev_lock_bh(hdev); mgmt_powered(hdev, 0); + hci_dev_unlock_bh(hdev); /* Clear flags */ hdev->flags = 0; @@ -1561,8 +1566,11 @@ void hci_unregister_dev(struct hci_dev *hdev) kfree_skb(hdev->reassembly[i]); if (!test_bit(HCI_INIT, &hdev->flags) && - !test_bit(HCI_SETUP, &hdev->flags)) + !test_bit(HCI_SETUP, &hdev->flags)) { + hci_dev_lock_bh(hdev); mgmt_index_removed(hdev); + hci_dev_unlock_bh(hdev); + } /* mgmt_index_removed should take care of emptying the * pending list */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8303f8f..a89cf1f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -60,7 +60,9 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) clear_bit(HCI_INQUIRY, &hdev->flags); + hci_dev_lock(hdev); mgmt_discovering(hdev, 0); + hci_dev_unlock(hdev); hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); @@ -201,13 +203,15 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) if (!sent) return; + hci_dev_lock(hdev); + if (test_bit(HCI_MGMT, &hdev->flags)) mgmt_set_local_name_complete(hdev, sent, status); - if (status) - return; + if (status == 0) + memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); - memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); + hci_dev_unlock(hdev); } static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) @@ -282,6 +286,8 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) param = *((__u8 *) sent); + hci_dev_lock(hdev); + if (status != 0) { mgmt_write_scan_failed(hdev, param, status); hdev->discov_timeout = 0; @@ -311,6 +317,7 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) mgmt_connectable(hdev, 0); done: + hci_dev_unlock(hdev); hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status); } @@ -834,19 +841,24 @@ static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, rp->status); + hci_dev_lock(hdev); + if (test_bit(HCI_MGMT, &hdev->flags)) mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); if (rp->status != 0) - return; + goto unlock; cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY); if (!cp) - return; + goto unlock; conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); if (conn) conn->pin_length = cp->pin_len; + +unlock: + hci_dev_unlock(hdev); } static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) @@ -855,10 +867,15 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, rp->status); + hci_dev_lock(hdev); + if (test_bit(HCI_MGMT, &hdev->flags)) mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, rp->status); + + hci_dev_unlock(hdev); } + static void hci_cc_le_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) { @@ -885,9 +902,13 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, rp->status); + hci_dev_lock(hdev); + if (test_bit(HCI_MGMT, &hdev->flags)) mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, rp->status); + + hci_dev_unlock(hdev); } static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, @@ -897,9 +918,13 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, BT_DBG("%s status 0x%x", hdev->name, rp->status); + hci_dev_lock(hdev); + if (test_bit(HCI_MGMT, &hdev->flags)) mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, rp->status); + + hci_dev_unlock(hdev); } static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev, @@ -909,8 +934,10 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev, BT_DBG("%s status 0x%x", hdev->name, rp->status); + hci_dev_lock(hdev); mgmt_read_local_oob_data_reply_complete(hdev, rp->hash, rp->randomizer, rp->status); + hci_dev_unlock(hdev); } static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, @@ -985,14 +1012,18 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) if (status) { hci_req_complete(hdev, HCI_OP_INQUIRY, status); hci_conn_check_pending(hdev); + hci_dev_lock(hdev); if (test_bit(HCI_MGMT, &hdev->flags)) mgmt_inquiry_failed(hdev, status); + hci_dev_unlock(hdev); return; } set_bit(HCI_INQUIRY, &hdev->flags); + hci_dev_lock(hdev); mgmt_discovering(hdev, 1); + hci_dev_unlock(hdev); } static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) @@ -1378,7 +1409,9 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) return; + hci_dev_lock(hdev); mgmt_discovering(hdev, 0); + hci_dev_unlock(hdev); } static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) @@ -1572,7 +1605,9 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff BT_DBG("%s status %d", hdev->name, ev->status); if (ev->status) { + hci_dev_lock(hdev); mgmt_disconnect_failed(hdev); + hci_dev_unlock(hdev); return; } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index be198f3..be4c3d0 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1335,16 +1335,19 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) static void pairing_complete_cb(struct hci_conn *conn, u8 status) { struct pending_cmd *cmd; + struct hci_dev *hdev = conn->hdev; BT_DBG("status %u", status); + hci_dev_lock_bh(hdev); + cmd = find_pairing(conn); - if (!cmd) { + if (!cmd) BT_DBG("Unable to find a pending command"); - return; - } + else + pairing_complete(cmd, status); - pairing_complete(cmd, status); + hci_dev_unlock_bh(hdev); } static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len) @@ -2302,9 +2305,7 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) goto failed; } - hci_dev_lock_bh(hdev); update_eir(hdev); - hci_dev_unlock_bh(hdev); err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, &ev, sizeof(ev)); -- cgit v0.10.2 From e0f9309f371096b82ad35aa2c27d7f848f37e696 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 9 Nov 2011 01:44:22 +0200 Subject: Bluetooth: Fix cancel_delayed_work_sync usage with locks The cancel_delayed_work_sync function should not be used if we hold any locks. Luckily all places where this is the case it is also safe to use the non-sync version. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f87bf24..fb3feeb 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -599,12 +599,12 @@ static int hci_dev_do_close(struct hci_dev *hdev) tasklet_kill(&hdev->tx_task); if (hdev->discov_timeout > 0) { - cancel_delayed_work_sync(&hdev->discov_off); + cancel_delayed_work(&hdev->discov_off); hdev->discov_timeout = 0; } if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) - cancel_delayed_work_sync(&hdev->power_off); + cancel_delayed_work(&hdev->power_off); hci_dev_lock_bh(hdev); inquiry_cache_flush(hdev); @@ -828,7 +828,7 @@ int hci_get_dev_list(void __user *arg) read_lock_bh(&hci_dev_list_lock); list_for_each_entry(hdev, &hci_dev_list, list) { if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) - cancel_delayed_work_sync(&hdev->power_off); + cancel_delayed_work(&hdev->power_off); if (!test_bit(HCI_MGMT, &hdev->flags)) set_bit(HCI_PAIRABLE, &hdev->flags); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index be4c3d0..263fa27 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -149,7 +149,7 @@ static int read_index_list(struct sock *sk) i = 0; list_for_each_entry(d, &hci_dev_list, list) { if (test_and_clear_bit(HCI_AUTO_OFF, &d->flags)) - cancel_delayed_work_sync(&d->power_off); + cancel_delayed_work(&d->power_off); if (test_bit(HCI_SETUP, &d->flags)) continue; @@ -398,7 +398,7 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, if (cp->val) scan |= SCAN_INQUIRY; else - cancel_delayed_work_sync(&hdev->discov_off); + cancel_delayed_work(&hdev->discov_off); err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); if (err < 0) -- cgit v0.10.2 From fc2f4b13d8c91713efb972be42566f7f3625f5ed Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 9 Nov 2011 13:58:56 +0200 Subject: Bluetooth: Fix consistency with u16 integer type in mgmt pending_cmd For consistency the integer type should be u16 and not __u16. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 263fa27..a849428 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -36,7 +36,7 @@ struct pending_cmd { struct list_head list; - __u16 opcode; + u16 opcode; int index; void *param; struct sock *sk; -- cgit v0.10.2 From 2aeabcbedd51aef94b61d05b57246d1db4984453 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 9 Nov 2011 13:58:57 +0200 Subject: Bluetooth: Remove redundant hci_dev comparisons in mgmt lookups Now that pending commands are hci_dev specific there's no need to check whether a command matches hci_dev when iterating through them. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a849428..a6720c6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -268,9 +268,6 @@ static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, if (opcode > 0 && cmd->opcode != opcode) continue; - if (hdev && cmd->index != hdev->id) - continue; - cb(cmd, data); } } @@ -280,13 +277,8 @@ static struct pending_cmd *mgmt_pending_find(u16 opcode, struct hci_dev *hdev) struct pending_cmd *cmd; list_for_each_entry(cmd, &hdev->mgmt_pending, list) { - if (cmd->opcode != opcode) - continue; - - if (hdev && cmd->index != hdev->id) - continue; - - return cmd; + if (cmd->opcode == opcode) + return cmd; } return NULL; @@ -1300,9 +1292,6 @@ static inline struct pending_cmd *find_pairing(struct hci_conn *conn) if (cmd->opcode != MGMT_OP_PAIR_DEVICE) continue; - if (cmd->index != hdev->id) - continue; - if (cmd->user_data != conn) continue; -- cgit v0.10.2 From fa5e91bc7715c772342b197269a85aa3ced16900 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Wed, 9 Nov 2011 15:25:18 -0500 Subject: wireless: cleanup brcm80211 bits in drivers/net/wireless/Makefile Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile index 0a304b0..c1c0678 100644 --- a/drivers/net/wireless/Makefile +++ b/drivers/net/wireless/Makefile @@ -58,6 +58,6 @@ obj-$(CONFIG_WL12XX_PLATFORM_DATA) += wl12xx/ obj-$(CONFIG_IWM) += iwmc3200wifi/ obj-$(CONFIG_MWIFIEX) += mwifiex/ -obj-$(CONFIG_BRCMFMAC) += brcm80211/ -obj-$(CONFIG_BRCMUMAC) += brcm80211/ -obj-$(CONFIG_BRCMSMAC) += brcm80211/ + +obj-$(CONFIG_BRCMFMAC) += brcm80211/ +obj-$(CONFIG_BRCMSMAC) += brcm80211/ -- cgit v0.10.2 From c74d084f914e16e42730bcf625ab3f37a4cae8d4 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 15 Oct 2011 00:14:49 +0200 Subject: mac80211: handle HT PHY BSS membership selector value correctly 802.11n-2009 extends the supported rates element with a magic value which can be used to prevent legacy stations from joining the BSS. However, this magic value is not a rate like the others and the magic can simply be ignored/skipped at this late stage. Signed-off-by: Christian Lamparter --- Signed-off-by: John W. Linville diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 48363c3..9789aed 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -770,6 +770,9 @@ struct ieee80211_mgmt { } u; } __attribute__ ((packed)); +/* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */ +#define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 + /* mgmt header + 1 byte category code */ #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index d3b408c..b25567a 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1466,6 +1466,47 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, return RX_MGMT_CFG80211_DISASSOC; } +static void ieee80211_get_rates(struct ieee80211_supported_band *sband, + u8 *supp_rates, unsigned int supp_rates_len, + u32 *rates, u32 *basic_rates, + bool *have_higher_than_11mbit, + int *min_rate, int *min_rate_index) +{ + int i, j; + + for (i = 0; i < supp_rates_len; i++) { + int rate = (supp_rates[i] & 0x7f) * 5; + bool is_basic = !!(supp_rates[i] & 0x80); + + if (rate > 110) + *have_higher_than_11mbit = true; + + /* + * BSS_MEMBERSHIP_SELECTOR_HT_PHY is defined in 802.11n-2009 + * 7.3.2.2 as a magic value instead of a rate. Hence, skip it. + * + * Note: Even through the membership selector and the basic + * rate flag share the same bit, they are not exactly + * the same. + */ + if (!!(supp_rates[i] & 0x80) && + (supp_rates[i] & 0x7f) == BSS_MEMBERSHIP_SELECTOR_HT_PHY) + continue; + + for (j = 0; j < sband->n_bitrates; j++) { + if (sband->bitrates[j].bitrate == rate) { + *rates |= BIT(j); + if (is_basic) + *basic_rates |= BIT(j); + if (rate < *min_rate) { + *min_rate = rate; + *min_rate_index = j; + } + break; + } + } + } +} static bool ieee80211_assoc_success(struct ieee80211_work *wk, struct ieee80211_mgmt *mgmt, size_t len) @@ -1482,7 +1523,7 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, struct ieee802_11_elems elems; struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; u32 changed = 0; - int i, j, err; + int err; bool have_higher_than_11mbit = false; u16 ap_ht_cap_flags; int min_rate = INT_MAX, min_rate_index = -1; @@ -1540,47 +1581,14 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, basic_rates = 0; sband = local->hw.wiphy->bands[wk->chan->band]; - for (i = 0; i < elems.supp_rates_len; i++) { - int rate = (elems.supp_rates[i] & 0x7f) * 5; - bool is_basic = !!(elems.supp_rates[i] & 0x80); - - if (rate > 110) - have_higher_than_11mbit = true; + ieee80211_get_rates(sband, elems.supp_rates, elems.supp_rates_len, + &rates, &basic_rates, &have_higher_than_11mbit, + &min_rate, &min_rate_index); - for (j = 0; j < sband->n_bitrates; j++) { - if (sband->bitrates[j].bitrate == rate) { - rates |= BIT(j); - if (is_basic) - basic_rates |= BIT(j); - if (rate < min_rate) { - min_rate = rate; - min_rate_index = j; - } - break; - } - } - } - - for (i = 0; i < elems.ext_supp_rates_len; i++) { - int rate = (elems.ext_supp_rates[i] & 0x7f) * 5; - bool is_basic = !!(elems.ext_supp_rates[i] & 0x80); - - if (rate > 110) - have_higher_than_11mbit = true; - - for (j = 0; j < sband->n_bitrates; j++) { - if (sband->bitrates[j].bitrate == rate) { - rates |= BIT(j); - if (is_basic) - basic_rates |= BIT(j); - if (rate < min_rate) { - min_rate = rate; - min_rate_index = j; - } - break; - } - } - } + ieee80211_get_rates(sband, elems.ext_supp_rates, + elems.ext_supp_rates_len, &rates, &basic_rates, + &have_higher_than_11mbit, + &min_rate, &min_rate_index); /* * some buggy APs don't advertise basic_rates. use the lowest -- cgit v0.10.2 From ef100682814c429709f0904b757595e25019cb31 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 27 Oct 2011 14:45:02 +0200 Subject: cfg80211: annotate cfg80211_inform_bss This function returns a referenced BSS struct (or NULL), annotate with __must_check. It seems that a lot of drivers get this completely wrong and leak all BSS structs as a result. Reported-by: Adam Mikuta Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 95852e3..0c71d4a 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -2636,8 +2636,10 @@ void cfg80211_sched_scan_stopped(struct wiphy *wiphy); * * This informs cfg80211 that BSS information was found and * the BSS should be updated/added. + * + * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! */ -struct cfg80211_bss* +struct cfg80211_bss * __must_check cfg80211_inform_bss_frame(struct wiphy *wiphy, struct ieee80211_channel *channel, struct ieee80211_mgmt *mgmt, size_t len, @@ -2659,8 +2661,10 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, * * This informs cfg80211 that BSS information was found and * the BSS should be updated/added. + * + * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! */ -struct cfg80211_bss* +struct cfg80211_bss * __must_check cfg80211_inform_bss(struct wiphy *wiphy, struct ieee80211_channel *channel, const u8 *bssid, -- cgit v0.10.2 From a64e2e2354679ad1742b4c43ac665ffa075ef8a0 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Fri, 28 Oct 2011 08:05:58 +0300 Subject: rndis_wlan: release BSS structures returned by cfg80211_inform_bss() Patch fixes rndis_wlan to release referenced BSS structure returned by cfg80211_inform_bss(). Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 83f3e52..620e3c0 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1976,11 +1976,12 @@ static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, return ret; } -static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev, - struct ndis_80211_bssid_ex *bssid) +static bool rndis_bss_info_update(struct usbnet *usbdev, + struct ndis_80211_bssid_ex *bssid) { struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); struct ieee80211_channel *channel; + struct cfg80211_bss *bss; s32 signal; u64 timestamp; u16 capability; @@ -2019,9 +2020,12 @@ static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev, capability = le16_to_cpu(fixed->capabilities); beacon_interval = le16_to_cpu(fixed->beacon_interval); - return cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid->mac, + bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid->mac, timestamp, capability, beacon_interval, ie, ie_len, signal, GFP_KERNEL); + cfg80211_put_bss(bss); + + return (bss != NULL); } static struct ndis_80211_bssid_ex *next_bssid_list_item( @@ -2648,6 +2652,7 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, struct ieee80211_channel *channel; struct ndis_80211_conf config; struct ndis_80211_ssid ssid; + struct cfg80211_bss *bss; s32 signal; u64 timestamp; u16 capability; @@ -2721,9 +2726,10 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, bssid, (u32)timestamp, capability, beacon_interval, ie_len, ssid.essid, signal); - cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid, + bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid, timestamp, capability, beacon_interval, ie_buf, ie_len, signal, GFP_KERNEL); + cfg80211_put_bss(bss); } /* -- cgit v0.10.2 From 9236b2a848cac9cac8d7df74baeb6c335081890a Mon Sep 17 00:00:00 2001 From: David Kilroy Date: Fri, 28 Oct 2011 12:47:56 +0100 Subject: orinoco: release BSS structures returned by cfg80211_inform_bss() The pointer returned by cfg80211_inform_bss is a referenced struct. The orinoco driver does not need to keep the struct, so we just release it. Signed-off-by: David Kilroy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/orinoco/scan.c b/drivers/net/wireless/orinoco/scan.c index e99ca1c..96e39ed 100644 --- a/drivers/net/wireless/orinoco/scan.c +++ b/drivers/net/wireless/orinoco/scan.c @@ -76,6 +76,7 @@ static void orinoco_add_hostscan_result(struct orinoco_private *priv, { struct wiphy *wiphy = priv_to_wiphy(priv); struct ieee80211_channel *channel; + struct cfg80211_bss *cbss; u8 *ie; u8 ie_buf[46]; u64 timestamp; @@ -121,9 +122,10 @@ static void orinoco_add_hostscan_result(struct orinoco_private *priv, beacon_interval = le16_to_cpu(bss->a.beacon_interv); signal = SIGNAL_TO_MBM(le16_to_cpu(bss->a.level)); - cfg80211_inform_bss(wiphy, channel, bss->a.bssid, timestamp, - capability, beacon_interval, ie_buf, ie_len, - signal, GFP_KERNEL); + cbss = cfg80211_inform_bss(wiphy, channel, bss->a.bssid, timestamp, + capability, beacon_interval, ie_buf, ie_len, + signal, GFP_KERNEL); + cfg80211_put_bss(cbss); } void orinoco_add_extscan_result(struct orinoco_private *priv, @@ -132,6 +134,7 @@ void orinoco_add_extscan_result(struct orinoco_private *priv, { struct wiphy *wiphy = priv_to_wiphy(priv); struct ieee80211_channel *channel; + struct cfg80211_bss *cbss; const u8 *ie; u64 timestamp; s32 signal; @@ -152,9 +155,10 @@ void orinoco_add_extscan_result(struct orinoco_private *priv, ie = bss->data; signal = SIGNAL_TO_MBM(bss->level); - cfg80211_inform_bss(wiphy, channel, bss->bssid, timestamp, - capability, beacon_interval, ie, ie_len, - signal, GFP_KERNEL); + cbss = cfg80211_inform_bss(wiphy, channel, bss->bssid, timestamp, + capability, beacon_interval, ie, ie_len, + signal, GFP_KERNEL); + cfg80211_put_bss(cbss); } void orinoco_add_hostscan_results(struct orinoco_private *priv, -- cgit v0.10.2 From fd6562344dea2b8b2a5d644cf971f4e56004500a Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 27 Oct 2011 17:31:50 +0300 Subject: ath9k: Advertise support for TDLS Based on a quick test, TDLS seemed to be working fine with ath9k, so let's start advertising support for this in the driver. Signed-off-by: Jouni Malinen Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index e8af582..5cb0599 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -696,6 +696,7 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; + hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; hw->queues = 4; hw->max_rates = 4; -- cgit v0.10.2 From 6e6ae9ddf0bc19ce066ed2f66f7a52b827e4514e Mon Sep 17 00:00:00 2001 From: Stanislav Yakovlev Date: Sun, 30 Oct 2011 02:47:50 -0400 Subject: ipw2x00: remove unused function libipw_ratelimit_debug. Looks like no one uses it. Signed-off-by: Stanislav Yakovlev Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ipw2x00/libipw.h b/drivers/net/wireless/ipw2x00/libipw.h index 70f5586..3d5821e 100644 --- a/drivers/net/wireless/ipw2x00/libipw.h +++ b/drivers/net/wireless/ipw2x00/libipw.h @@ -66,16 +66,8 @@ extern u32 libipw_debug_level; do { if (libipw_debug_level & (level)) \ printk(KERN_DEBUG "libipw: %c %s " fmt, \ in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0) -static inline bool libipw_ratelimit_debug(u32 level) -{ - return (libipw_debug_level & level) && net_ratelimit(); -} #else #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0) -static inline bool libipw_ratelimit_debug(u32 level) -{ - return false; -} #endif /* CONFIG_LIBIPW_DEBUG */ /* -- cgit v0.10.2 From 55de47f65f661a229a982293a43739e57ec935a5 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 1 Nov 2011 15:16:55 +0200 Subject: mac80211: set BSS_CHANGED_IDLE on vif reconfig The vif might be busy while reconfiguring (e.g. associated), so indicate BSS_CHANGED_IDLE as well. Reported-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: John W. Linville diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 72b3a2e..83c4821 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1057,7 +1057,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) BSS_CHANGED_BEACON_INT | BSS_CHANGED_BSSID | BSS_CHANGED_CQM | - BSS_CHANGED_QOS; + BSS_CHANGED_QOS | + BSS_CHANGED_IDLE; switch (sdata->vif.type) { case NL80211_IFTYPE_STATION: -- cgit v0.10.2 From c2e889a7f7947bc346e0a341e793fd5cb471d884 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 2 Nov 2011 23:34:56 +0200 Subject: ieee80211: Define cipher suite selector for WPI-SMS4 This value is used for WPI-SMS4 in ISO/IEC JTC 1 N 9880. Signed-off-by: Jouni Malinen Signed-off-by: John W. Linville diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 9789aed..ffc073a 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -1555,6 +1555,8 @@ enum ieee80211_sa_query_action { #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05 #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06 +#define WLAN_CIPHER_SUITE_SMS4 0x00147201 + /* AKM suite selectors */ #define WLAN_AKM_SUITE_8021X 0x000FAC01 #define WLAN_AKM_SUITE_PSK 0x000FAC02 -- cgit v0.10.2 From 819622678ed7011b4d785ca174de5d4bf179bf83 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 2 Nov 2011 23:36:31 +0200 Subject: nl80211: Increase maximum NL80211_ATTR_KEY_SEQ length to 16 WPI-SMS4 uses 16-octet PN field, so we need to allow longer key sequence values to be configured. Signed-off-by: Jouni Malinen Signed-off-by: John W. Linville diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index e97827b..2bcaa57 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -98,7 +98,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { [NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 }, [NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 }, [NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG }, - [NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 8 }, + [NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 }, [NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32 }, [NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 }, @@ -203,7 +203,7 @@ static const struct nla_policy nl80211_key_policy[NL80211_KEY_MAX + 1] = { [NL80211_KEY_DATA] = { .type = NLA_BINARY, .len = WLAN_MAX_KEY_LEN }, [NL80211_KEY_IDX] = { .type = NLA_U8 }, [NL80211_KEY_CIPHER] = { .type = NLA_U32 }, - [NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 8 }, + [NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 }, [NL80211_KEY_DEFAULT] = { .type = NLA_FLAG }, [NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG }, [NL80211_KEY_TYPE] = { .type = NLA_U32 }, -- cgit v0.10.2 From 68629c6133304f286a1f0c12d9aa8071a639f076 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 3 Nov 2011 09:59:39 +0100 Subject: mac80211: preserve EOSP in QoS header Janusz reported that the EOSP bit in mac80211 was getting cleared all the time. I had not found this since I tested uAPSD with a device that always set the bit itself. Preserve the bit when building the QoS header. Reported-by: Janusz Dziedzic Tested-by: Janusz Dziedzic Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index fd52e69..d0240bb 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c @@ -143,10 +143,13 @@ void ieee80211_set_qos_hdr(struct ieee80211_sub_if_data *sdata, /* Fill in the QoS header if there is one. */ if (ieee80211_is_data_qos(hdr->frame_control)) { u8 *p = ieee80211_get_qos_ctl(hdr); - u8 ack_policy = 0, tid; + u8 ack_policy, tid; tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; + /* preserve EOSP bit */ + ack_policy = *p & IEEE80211_QOS_CTL_EOSP; + if (unlikely(sdata->local->wifi_wme_noack_test)) ack_policy |= IEEE80211_QOS_CTL_ACK_POLICY_NOACK; /* qos header is 2 bytes */ -- cgit v0.10.2 From 5e5202a406896fb6d656d0e7d3f2f1cbfdda6384 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Thu, 3 Nov 2011 10:40:45 +0100 Subject: mac80211: remove uneeded scan_chan variable Signed-off-by: Stanislaw Gruszka Reviewed-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/main.c b/net/mac80211/main.c index d999bf3..094fd57 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -100,7 +100,7 @@ static void ieee80211_reconfig_filter(struct work_struct *work) */ bool ieee80211_cfg_on_oper_channel(struct ieee80211_local *local) { - struct ieee80211_channel *chan, *scan_chan; + struct ieee80211_channel *chan; enum nl80211_channel_type channel_type; /* This logic needs to match logic in ieee80211_hw_config */ @@ -114,7 +114,7 @@ bool ieee80211_cfg_on_oper_channel(struct ieee80211_local *local) else channel_type = NL80211_CHAN_NO_HT; } else if (local->tmp_channel) { - chan = scan_chan = local->tmp_channel; + chan = local->tmp_channel; channel_type = local->tmp_channel_type; } else { chan = local->oper_channel; @@ -135,7 +135,7 @@ bool ieee80211_cfg_on_oper_channel(struct ieee80211_local *local) int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) { - struct ieee80211_channel *chan, *scan_chan; + struct ieee80211_channel *chan; int ret = 0; int power; enum nl80211_channel_type channel_type; @@ -143,14 +143,12 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) might_sleep(); - scan_chan = local->scan_channel; - /* If this off-channel logic ever changes, ieee80211_on_oper_channel * may need to change as well. */ offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; - if (scan_chan) { - chan = scan_chan; + if (local->scan_channel) { + chan = local->scan_channel; /* If scanning on oper channel, use whatever channel-type * is currently in use. */ @@ -159,7 +157,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) else channel_type = NL80211_CHAN_NO_HT; } else if (local->tmp_channel) { - chan = scan_chan = local->tmp_channel; + chan = local->tmp_channel; channel_type = local->tmp_channel_type; } else { chan = local->oper_channel; -- cgit v0.10.2 From 0b62ffb53c9732e02ec77ae795f1e03cb2f2d406 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Thu, 3 Nov 2011 10:40:46 +0100 Subject: mac80211: remove useless brackets in ieee80211_cfg_on_oper_channel Signed-off-by: Stanislaw Gruszka Reviewed-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 094fd57..7217019 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -126,8 +126,8 @@ bool ieee80211_cfg_on_oper_channel(struct ieee80211_local *local) return false; /* Check current hardware-config against oper_channel. */ - if ((local->oper_channel != local->hw.conf.channel) || - (local->_oper_channel_type != local->hw.conf.channel_type)) + if (local->oper_channel != local->hw.conf.channel || + local->_oper_channel_type != local->hw.conf.channel_type) return false; return true; -- cgit v0.10.2 From 4fdbff0770bea059621bc4906fb7c7f5879f3ae1 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Thu, 3 Nov 2011 10:40:47 +0100 Subject: mac80211: simplify ieee80211_work_work Since local->tmp_channel is always NULL in one branch, some code paths will newer be taken in that branch, so remove them. Signed-off-by: Stanislaw Gruszka Reviewed-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/work.c b/net/mac80211/work.c index 30da4e3..3dd5a89 100644 --- a/net/mac80211/work.c +++ b/net/mac80211/work.c @@ -942,10 +942,9 @@ static void ieee80211_work_work(struct work_struct *work) } if (!started && !local->tmp_channel) { - bool on_oper_chan; - bool tmp_chan_changed = false; - bool on_oper_chan2; + bool on_oper_chan, on_oper_chan2; enum nl80211_channel_type wk_ct; + on_oper_chan = ieee80211_cfg_on_oper_channel(local); /* Work with existing channel type if possible. */ @@ -954,11 +953,6 @@ static void ieee80211_work_work(struct work_struct *work) wk_ct = ieee80211_calc_ct(wk->chan_type, local->hw.conf.channel_type); - if (local->tmp_channel) - if ((local->tmp_channel != wk->chan) || - (local->tmp_channel_type != wk_ct)) - tmp_chan_changed = true; - local->tmp_channel = wk->chan; local->tmp_channel_type = wk_ct; /* @@ -981,12 +975,7 @@ static void ieee80211_work_work(struct work_struct *work) true, false); } - } else if (tmp_chan_changed) - /* Still off-channel, but on some other - * channel, so update hardware. - * PS should already be off-channel. - */ - ieee80211_hw_config(local, 0); + } started = true; wk->timeout = jiffies; -- cgit v0.10.2 From 6e3e939f3b1bf8534b32ad09ff199d88800835a0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 9 Nov 2011 10:15:42 +0100 Subject: net: add wireless TX status socket option The 802.1X EAPOL handshake hostapd does requires knowing whether the frame was ack'ed by the peer. Currently, we fudge this pretty badly by not even transmitting the frame as a normal data frame but injecting it with radiotap and getting the status out of radiotap monitor as well. This is rather complex, confuses users (mon.wlan0 presence) and doesn't work with all hardware. To get rid of that hack, introduce a real wifi TX status option for data frame transmissions. This works similar to the existing TX timestamping in that it reflects the SKB back to the socket's error queue with a SCM_WIFI_STATUS cmsg that has an int indicating ACK status (0/1). Since it is possible that at some point we will want to have TX timestamping and wifi status in a single errqueue SKB (there's little point in not doing that), redefine SO_EE_ORIGIN_TIMESTAMPING to SO_EE_ORIGIN_TXSTATUS which can collect more than just the timestamp; keep the old constant as an alias of course. Currently the internal APIs don't make that possible, but it wouldn't be hard to split them up in a way that makes it possible. Thanks to Neil Horman for helping me figure out the functions that add the control messages. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h index 06edfef..082355f 100644 --- a/arch/alpha/include/asm/socket.h +++ b/arch/alpha/include/asm/socket.h @@ -69,6 +69,9 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + /* O_NONBLOCK clashes with the bits used for socket types. Therefore we * have to define SOCK_NONBLOCK to a different value here. */ diff --git a/arch/arm/include/asm/socket.h b/arch/arm/include/asm/socket.h index 90ffd04..dec6f9a 100644 --- a/arch/arm/include/asm/socket.h +++ b/arch/arm/include/asm/socket.h @@ -62,4 +62,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_SOCKET_H */ diff --git a/arch/avr32/include/asm/socket.h b/arch/avr32/include/asm/socket.h index c8d1fae..247b88c 100644 --- a/arch/avr32/include/asm/socket.h +++ b/arch/avr32/include/asm/socket.h @@ -62,4 +62,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* __ASM_AVR32_SOCKET_H */ diff --git a/arch/cris/include/asm/socket.h b/arch/cris/include/asm/socket.h index 1a4a619..e269264 100644 --- a/arch/cris/include/asm/socket.h +++ b/arch/cris/include/asm/socket.h @@ -64,6 +64,9 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_SOCKET_H */ diff --git a/arch/frv/include/asm/socket.h b/arch/frv/include/asm/socket.h index a6b2688..ce80fda 100644 --- a/arch/frv/include/asm/socket.h +++ b/arch/frv/include/asm/socket.h @@ -62,5 +62,8 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_SOCKET_H */ diff --git a/arch/h8300/include/asm/socket.h b/arch/h8300/include/asm/socket.h index 04c0f45..cf1daab 100644 --- a/arch/h8300/include/asm/socket.h +++ b/arch/h8300/include/asm/socket.h @@ -62,4 +62,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_SOCKET_H */ diff --git a/arch/ia64/include/asm/socket.h b/arch/ia64/include/asm/socket.h index 51427ea..4b03664 100644 --- a/arch/ia64/include/asm/socket.h +++ b/arch/ia64/include/asm/socket.h @@ -71,4 +71,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_IA64_SOCKET_H */ diff --git a/arch/m32r/include/asm/socket.h b/arch/m32r/include/asm/socket.h index 469787c3..e8b8c5b 100644 --- a/arch/m32r/include/asm/socket.h +++ b/arch/m32r/include/asm/socket.h @@ -62,4 +62,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_M32R_SOCKET_H */ diff --git a/arch/m68k/include/asm/socket.h b/arch/m68k/include/asm/socket.h index 9bf49c8..d4708ce 100644 --- a/arch/m68k/include/asm/socket.h +++ b/arch/m68k/include/asm/socket.h @@ -62,4 +62,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_SOCKET_H */ diff --git a/arch/mips/include/asm/socket.h b/arch/mips/include/asm/socket.h index 9de5190..ad5c0a7 100644 --- a/arch/mips/include/asm/socket.h +++ b/arch/mips/include/asm/socket.h @@ -82,6 +82,9 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #ifdef __KERNEL__ /** sock_type - Socket types diff --git a/arch/mn10300/include/asm/socket.h b/arch/mn10300/include/asm/socket.h index 4e60c42..876356d 100644 --- a/arch/mn10300/include/asm/socket.h +++ b/arch/mn10300/include/asm/socket.h @@ -62,4 +62,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_SOCKET_H */ diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/asm/socket.h index 225b7d6..d28c51b 100644 --- a/arch/parisc/include/asm/socket.h +++ b/arch/parisc/include/asm/socket.h @@ -61,6 +61,9 @@ #define SO_RXQ_OVFL 0x4021 +#define SO_WIFI_STATUS 0x4022 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + /* O_NONBLOCK clashes with the bits used for socket types. Therefore we * have to define SOCK_NONBLOCK to a different value here. */ diff --git a/arch/powerpc/include/asm/socket.h b/arch/powerpc/include/asm/socket.h index 866f760..2fc2af8 100644 --- a/arch/powerpc/include/asm/socket.h +++ b/arch/powerpc/include/asm/socket.h @@ -69,4 +69,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_POWERPC_SOCKET_H */ diff --git a/arch/s390/include/asm/socket.h b/arch/s390/include/asm/socket.h index fdff1e9..67b5c1b 100644 --- a/arch/s390/include/asm/socket.h +++ b/arch/s390/include/asm/socket.h @@ -70,4 +70,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _ASM_SOCKET_H */ diff --git a/arch/sparc/include/asm/socket.h b/arch/sparc/include/asm/socket.h index 9d3fefc..8af1b64 100644 --- a/arch/sparc/include/asm/socket.h +++ b/arch/sparc/include/asm/socket.h @@ -58,6 +58,9 @@ #define SO_RXQ_OVFL 0x0024 +#define SO_WIFI_STATUS 0x0025 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + /* Security levels - as per NRL IPv6 - don't actually do anything */ #define SO_SECURITY_AUTHENTICATION 0x5001 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 diff --git a/arch/xtensa/include/asm/socket.h b/arch/xtensa/include/asm/socket.h index cbdf2ff..bb06968 100644 --- a/arch/xtensa/include/asm/socket.h +++ b/arch/xtensa/include/asm/socket.h @@ -73,4 +73,7 @@ #define SO_RXQ_OVFL 40 +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS + #endif /* _XTENSA_SOCKET_H */ diff --git a/include/asm-generic/socket.h b/include/asm-generic/socket.h index 9a6115e..49c1704 100644 --- a/include/asm-generic/socket.h +++ b/include/asm-generic/socket.h @@ -64,4 +64,7 @@ #define SO_DOMAIN 39 #define SO_RXQ_OVFL 40 + +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS #endif /* __ASM_GENERIC_SOCKET_H */ diff --git a/include/linux/errqueue.h b/include/linux/errqueue.h index 034072c..c9f522b 100644 --- a/include/linux/errqueue.h +++ b/include/linux/errqueue.h @@ -17,7 +17,8 @@ struct sock_extended_err { #define SO_EE_ORIGIN_LOCAL 1 #define SO_EE_ORIGIN_ICMP 2 #define SO_EE_ORIGIN_ICMP6 3 -#define SO_EE_ORIGIN_TIMESTAMPING 4 +#define SO_EE_ORIGIN_TXSTATUS 4 +#define SO_EE_ORIGIN_TIMESTAMPING SO_EE_ORIGIN_TXSTATUS #define SO_EE_OFFENDER(ee) ((struct sockaddr*)((ee)+1)) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 6a6b352..ff7e130 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -218,6 +218,9 @@ enum { /* device driver supports TX zero-copy buffers */ SKBTX_DEV_ZEROCOPY = 1 << 4, + + /* generate wifi status information (where possible) */ + SKBTX_WIFI_STATUS = 1 << 5, }; /* @@ -352,6 +355,8 @@ typedef unsigned char *sk_buff_data_t; * @ooo_okay: allow the mapping of a socket to a queue to be changed * @l4_rxhash: indicate rxhash is a canonical 4-tuple hash over transport * ports. + * @wifi_acked_valid: wifi_acked was set + * @wifi_acked: whether frame was acked on wifi or not * @dma_cookie: a cookie to one of several possible DMA operations * done by skb DMA functions * @secmark: security marking @@ -445,10 +450,11 @@ struct sk_buff { #endif __u8 ooo_okay:1; __u8 l4_rxhash:1; + __u8 wifi_acked_valid:1; + __u8 wifi_acked:1; + /* 10/12 bit hole (depending on ndisc_nodetype presence) */ kmemcheck_bitfield_end(flags2); - /* 0/13 bit hole */ - #ifdef CONFIG_NET_DMA dma_cookie_t dma_cookie; #endif @@ -2263,6 +2269,15 @@ static inline void skb_tx_timestamp(struct sk_buff *skb) sw_tx_timestamp(skb); } +/** + * skb_complete_wifi_ack - deliver skb with wifi status + * + * @skb: the original outgoing packet + * @acked: ack status + * + */ +void skb_complete_wifi_ack(struct sk_buff *skb, bool acked); + extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); extern __sum16 __skb_checksum_complete(struct sk_buff *skb); diff --git a/include/net/sock.h b/include/net/sock.h index 5ac682f..fa6f538 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -564,6 +564,7 @@ enum sock_flags { SOCK_FASYNC, /* fasync() active */ SOCK_RXQ_OVFL, SOCK_ZEROCOPY, /* buffers from userspace */ + SOCK_WIFI_STATUS, /* push wifi status to userspace */ }; static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) @@ -1714,6 +1715,8 @@ static inline int sock_intr_errno(long timeo) extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb); +extern void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, + struct sk_buff *skb); static __inline__ void sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) @@ -1741,6 +1744,9 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) __sock_recv_timestamp(msg, sk, skb); else sk->sk_stamp = kt; + + if (sock_flag(sk, SOCK_WIFI_STATUS) && skb->wifi_acked_valid) + __sock_recv_wifi_status(msg, sk, skb); } extern void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index ca4db40..2f6babd 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3168,6 +3168,26 @@ void skb_tstamp_tx(struct sk_buff *orig_skb, } EXPORT_SYMBOL_GPL(skb_tstamp_tx); +void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) +{ + struct sock *sk = skb->sk; + struct sock_exterr_skb *serr; + int err; + + skb->wifi_acked_valid = 1; + skb->wifi_acked = acked; + + serr = SKB_EXT_ERR(skb); + memset(serr, 0, sizeof(*serr)); + serr->ee.ee_errno = ENOMSG; + serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS; + + err = sock_queue_err_skb(sk, skb); + if (err) + kfree_skb(skb); +} +EXPORT_SYMBOL_GPL(skb_complete_wifi_ack); + /** * skb_partial_csum_set - set up and verify partial csum values for packet diff --git a/net/core/sock.c b/net/core/sock.c index 4ed7b1d..cbdf51c 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -740,6 +740,11 @@ set_rcvbuf: case SO_RXQ_OVFL: sock_valbool_flag(sk, SOCK_RXQ_OVFL, valbool); break; + + case SO_WIFI_STATUS: + sock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool); + break; + default: ret = -ENOPROTOOPT; break; @@ -961,6 +966,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname, v.val = !!sock_flag(sk, SOCK_RXQ_OVFL); break; + case SO_WIFI_STATUS: + v.val = !!sock_flag(sk, SOCK_WIFI_STATUS); + break; + default: return -ENOPROTOOPT; } diff --git a/net/socket.c b/net/socket.c index 2877647..425ef42 100644 --- a/net/socket.c +++ b/net/socket.c @@ -538,6 +538,8 @@ int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags) *tx_flags |= SKBTX_HW_TSTAMP; if (sock_flag(sk, SOCK_TIMESTAMPING_TX_SOFTWARE)) *tx_flags |= SKBTX_SW_TSTAMP; + if (sock_flag(sk, SOCK_WIFI_STATUS)) + *tx_flags |= SKBTX_WIFI_STATUS; return 0; } EXPORT_SYMBOL(sock_tx_timestamp); @@ -674,6 +676,22 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, } EXPORT_SYMBOL_GPL(__sock_recv_timestamp); +void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, + struct sk_buff *skb) +{ + int ack; + + if (!sock_flag(sk, SOCK_WIFI_STATUS)) + return; + if (!skb->wifi_acked_valid) + return; + + ack = skb->wifi_acked; + + put_cmsg(msg, SOL_SOCKET, SCM_WIFI_STATUS, sizeof(ack), &ack); +} +EXPORT_SYMBOL_GPL(__sock_recv_wifi_status); + static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) { -- cgit v0.10.2 From 7b7eab6fc1bc8852d9649541b59283cd89cc526f Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 3 Nov 2011 14:41:13 +0100 Subject: mac80211: verify virtual interfaces in driver API The driver is never informed about monitor or AP_VLAN interfaces, so whenever we pass those to it later this is a bug. Verify we don't as there are some cases where this could happen. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 5f165d7..b12ed52 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -5,6 +5,11 @@ #include "ieee80211_i.h" #include "driver-trace.h" +static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) +{ + WARN_ON(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER)); +} + static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb) { local->ops->tx(&local->hw, skb); @@ -69,15 +74,23 @@ static inline int drv_resume(struct ieee80211_local *local) #endif static inline int drv_add_interface(struct ieee80211_local *local, - struct ieee80211_vif *vif) + struct ieee80211_sub_if_data *sdata) { int ret; might_sleep(); - trace_drv_add_interface(local, vif_to_sdata(vif)); - ret = local->ops->add_interface(&local->hw, vif); + if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN || + sdata->vif.type == NL80211_IFTYPE_MONITOR)) + return -EINVAL; + + trace_drv_add_interface(local, sdata); + ret = local->ops->add_interface(&local->hw, &sdata->vif); trace_drv_return_int(local, ret); + + if (ret == 0) + sdata->flags |= IEEE80211_SDATA_IN_DRIVER; + return ret; } @@ -89,6 +102,8 @@ static inline int drv_change_interface(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_change_interface(local, sdata, type, p2p); ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); trace_drv_return_int(local, ret); @@ -96,12 +111,15 @@ static inline int drv_change_interface(struct ieee80211_local *local, } static inline void drv_remove_interface(struct ieee80211_local *local, - struct ieee80211_vif *vif) + struct ieee80211_sub_if_data *sdata) { might_sleep(); - trace_drv_remove_interface(local, vif_to_sdata(vif)); - local->ops->remove_interface(&local->hw, vif); + check_sdata_in_driver(sdata); + + trace_drv_remove_interface(local, sdata); + local->ops->remove_interface(&local->hw, &sdata->vif); + sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; trace_drv_return_void(local); } @@ -124,6 +142,8 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local, { might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_bss_info_changed(local, sdata, info, changed); if (local->ops->bss_info_changed) local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); @@ -139,6 +159,8 @@ static inline int drv_tx_sync(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_tx_sync(local, sdata, bssid, type); if (local->ops->tx_sync) ret = local->ops->tx_sync(&local->hw, &sdata->vif, @@ -154,6 +176,8 @@ static inline void drv_finish_tx_sync(struct ieee80211_local *local, { might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_finish_tx_sync(local, sdata, bssid, type); if (local->ops->finish_tx_sync) local->ops->finish_tx_sync(&local->hw, &sdata->vif, @@ -211,6 +235,8 @@ static inline int drv_set_key(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_set_key(local, cmd, sdata, sta, key); ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); trace_drv_return_int(local, ret); @@ -228,6 +254,8 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local, if (sta) ista = &sta->sta; + check_sdata_in_driver(sdata); + trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); if (local->ops->update_tkip_key) local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, @@ -243,6 +271,8 @@ static inline int drv_hw_scan(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_hw_scan(local, sdata); ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); trace_drv_return_int(local, ret); @@ -254,6 +284,8 @@ static inline void drv_cancel_hw_scan(struct ieee80211_local *local, { might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_cancel_hw_scan(local, sdata); local->ops->cancel_hw_scan(&local->hw, &sdata->vif); trace_drv_return_void(local); @@ -269,6 +301,8 @@ drv_sched_scan_start(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_sched_scan_start(local, sdata); ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, req, ies); @@ -281,6 +315,8 @@ static inline void drv_sched_scan_stop(struct ieee80211_local *local, { might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_sched_scan_stop(local, sdata); local->ops->sched_scan_stop(&local->hw, &sdata->vif); trace_drv_return_void(local); @@ -377,6 +413,8 @@ static inline void drv_sta_notify(struct ieee80211_local *local, enum sta_notify_cmd cmd, struct ieee80211_sta *sta) { + check_sdata_in_driver(sdata); + trace_drv_sta_notify(local, sdata, cmd, sta); if (local->ops->sta_notify) local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); @@ -391,6 +429,8 @@ static inline int drv_sta_add(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_sta_add(local, sdata, sta); if (local->ops->sta_add) ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); @@ -406,6 +446,8 @@ static inline void drv_sta_remove(struct ieee80211_local *local, { might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_sta_remove(local, sdata, sta); if (local->ops->sta_remove) local->ops->sta_remove(&local->hw, &sdata->vif, sta); @@ -421,6 +463,8 @@ static inline int drv_conf_tx(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_conf_tx(local, sdata, queue, params); if (local->ops->conf_tx) ret = local->ops->conf_tx(&local->hw, &sdata->vif, @@ -436,6 +480,8 @@ static inline u64 drv_get_tsf(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_get_tsf(local, sdata); if (local->ops->get_tsf) ret = local->ops->get_tsf(&local->hw, &sdata->vif); @@ -449,6 +495,8 @@ static inline void drv_set_tsf(struct ieee80211_local *local, { might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_set_tsf(local, sdata, tsf); if (local->ops->set_tsf) local->ops->set_tsf(&local->hw, &sdata->vif, tsf); @@ -460,6 +508,8 @@ static inline void drv_reset_tsf(struct ieee80211_local *local, { might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_reset_tsf(local, sdata); if (local->ops->reset_tsf) local->ops->reset_tsf(&local->hw, &sdata->vif); @@ -489,6 +539,8 @@ static inline int drv_ampdu_action(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); if (local->ops->ampdu_action) @@ -644,6 +696,8 @@ static inline int drv_set_bitrate_mask(struct ieee80211_local *local, might_sleep(); + check_sdata_in_driver(sdata); + trace_drv_set_bitrate_mask(local, sdata, mask); if (local->ops->set_bitrate_mask) ret = local->ops->set_bitrate_mask(&local->hw, @@ -657,6 +711,8 @@ static inline void drv_set_rekey_data(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, struct cfg80211_gtk_rekey_data *data) { + check_sdata_in_driver(sdata); + trace_drv_set_rekey_data(local, sdata, data); if (local->ops->set_rekey_data) local->ops->set_rekey_data(&local->hw, &sdata->vif, data); diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index e244709..386330c 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -543,6 +543,7 @@ struct ieee80211_if_mesh { * associated stations and deliver multicast frames both * back to wireless media and to the local net stack. * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume. + * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver */ enum ieee80211_sub_if_data_flags { IEEE80211_SDATA_ALLMULTI = BIT(0), @@ -550,6 +551,7 @@ enum ieee80211_sub_if_data_flags { IEEE80211_SDATA_OPERATING_GMODE = BIT(2), IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(3), IEEE80211_SDATA_DISCONNECT_RESUME = BIT(4), + IEEE80211_SDATA_IN_DRIVER = BIT(5), }; /** diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 33a9746..4ee624c 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -265,7 +265,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) break; default: if (coming_up) { - res = drv_add_interface(local, &sdata->vif); + res = drv_add_interface(local, sdata); if (res) goto err_stop; } @@ -345,7 +345,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) return 0; err_del_interface: - drv_remove_interface(local, &sdata->vif); + drv_remove_interface(local, sdata); err_stop: if (!local->open_count) drv_stop(local); @@ -520,7 +520,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, ieee80211_free_keys(sdata); if (going_down) - drv_remove_interface(local, &sdata->vif); + drv_remove_interface(local, sdata); } sdata->bss = NULL; diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 9ee7164..596efaf 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c @@ -125,7 +125,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); - drv_remove_interface(local, &sdata->vif); + drv_remove_interface(local, sdata); } /* stop hardware - this must stop RX */ diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 83c4821..98ca547 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1006,7 +1006,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && sdata->vif.type != NL80211_IFTYPE_MONITOR && ieee80211_sdata_running(sdata)) - res = drv_add_interface(local, &sdata->vif); + res = drv_add_interface(local, sdata); } /* add STAs back */ -- cgit v0.10.2 From 7e1e386421e2ec7804b77f2c1c8e2517e82ecb7e Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 3 Nov 2011 11:33:13 -0700 Subject: ath9k: Improve debugfs printout for stations. Add interface address so it can be mapped to a local interface. Add max-ampdu and mpdu-density. Print out the tid->baw_size Signed-off-by: Ben Greear Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 4415e89..93b45b4 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -253,6 +253,7 @@ struct ath_node { #ifdef CONFIG_ATH9K_DEBUGFS struct list_head list; /* for sc->nodes */ struct ieee80211_sta *sta; /* station struct we're part of */ + struct ieee80211_vif *vif; /* interface with which we're associated */ #endif struct ath_atx_tid tid[WME_NUM_TID]; struct ath_atx_ac ac[WME_NUM_AC]; diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 327aa28..8e7e57c 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -708,24 +708,29 @@ static ssize_t read_file_stations(struct file *file, char __user *user_buf, len += snprintf(buf + len, size - len, "Stations:\n" - " tid: addr sched paused buf_q-empty an ac\n" + " tid: addr sched paused buf_q-empty an ac baw\n" " ac: addr sched tid_q-empty txq\n"); spin_lock(&sc->nodes_lock); list_for_each_entry(an, &sc->nodes, list) { + unsigned short ma = an->maxampdu; + if (ma == 0) + ma = 65535; /* see ath_lookup_rate */ len += snprintf(buf + len, size - len, - "%pM\n", an->sta->addr); + "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n", + an->vif->addr, an->sta->addr, ma, + (unsigned int)(an->mpdudensity)); if (len >= size) goto done; for (q = 0; q < WME_NUM_TID; q++) { struct ath_atx_tid *tid = &(an->tid[q]); len += snprintf(buf + len, size - len, - " tid: %p %s %s %i %p %p\n", + " tid: %p %s %s %i %p %p %hu\n", tid, tid->sched ? "sched" : "idle", tid->paused ? "paused" : "running", skb_queue_empty(&tid->buf_q), - tid->an, tid->ac); + tid->an, tid->ac, tid->baw_size); if (len >= size) goto done; } diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index e1e006d..e43c41c 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -630,7 +630,8 @@ set_timer: } } -static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta) +static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, + struct ieee80211_vif *vif) { struct ath_node *an; an = (struct ath_node *)sta->drv_priv; @@ -640,6 +641,7 @@ static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta) list_add(&an->list, &sc->nodes); spin_unlock(&sc->nodes_lock); an->sta = sta; + an->vif = vif; #endif if (sc->sc_flags & SC_OP_TXAGGR) { ath_tx_node_init(sc, an); @@ -1800,7 +1802,7 @@ static int ath9k_sta_add(struct ieee80211_hw *hw, struct ath_node *an = (struct ath_node *) sta->drv_priv; struct ieee80211_key_conf ps_key = { }; - ath_node_attach(sc, sta); + ath_node_attach(sc, sta, vif); if (vif->type != NL80211_IFTYPE_AP && vif->type != NL80211_IFTYPE_AP_VLAN) -- cgit v0.10.2 From f3011cf9deb689bd68279c728c501a4166983c19 Mon Sep 17 00:00:00 2001 From: Javier Cardona Date: Thu, 3 Nov 2011 21:11:10 -0700 Subject: mac80211: Avoid filling up mesh preq queue with redundant requests Don't accept redundant PREQs for a given destination. This fixes a problem under high load: kernel: [20386.250913] mesh_queue_preq: 235 callbacks suppressed kernel: [20386.253335] Mesh HWMP (mesh0): PREQ node queue full kernel: [20386.253352] Mesh HWMP (mesh0): PREQ node queue full (...) The 802.11s protocol has a provision to limit the rate of path requests (PREQs) are transmitted (dot11MeshHWMPpreqMinInterval) but there was no limit on the rate at which PREQs were being queued up. There is a valid reason for queuing PREQs: this way we can even out PREQ bursts. But queueing multiple PREQs for the same destination is useless. Reported-by: Pedro Larbig Signed-off-by: Javier Cardona Signed-off-by: John W. Linville diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 0f2c4e6..622cc96 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h @@ -31,6 +31,8 @@ * @MESH_PATH_FIXED: the mesh path has been manually set and should not be * modified * @MESH_PATH_RESOLVED: the mesh path can has been resolved + * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination + * already queued up, waiting for the discovery process to start. * * MESH_PATH_RESOLVED is used by the mesh path timer to * decide when to stop or cancel the mesh path discovery. @@ -41,6 +43,7 @@ enum mesh_path_flags { MESH_PATH_SN_VALID = BIT(2), MESH_PATH_FIXED = BIT(3), MESH_PATH_RESOLVED = BIT(4), + MESH_PATH_REQ_QUEUED = BIT(5), }; /** diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 9a1f8bb..b22b223 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -867,9 +867,19 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags) return; } + spin_lock_bh(&mpath->state_lock); + if (mpath->flags & MESH_PATH_REQ_QUEUED) { + spin_unlock_bh(&mpath->state_lock); + spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); + return; + } + memcpy(preq_node->dst, mpath->dst, ETH_ALEN); preq_node->flags = flags; + mpath->flags |= MESH_PATH_REQ_QUEUED; + spin_unlock_bh(&mpath->state_lock); + list_add_tail(&preq_node->list, &ifmsh->preq_queue.list); ++ifmsh->preq_queue_len; spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); @@ -921,6 +931,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) goto enddiscovery; spin_lock_bh(&mpath->state_lock); + mpath->flags &= ~MESH_PATH_REQ_QUEUED; if (preq_node->flags & PREQ_Q_F_START) { if (mpath->flags & MESH_PATH_RESOLVING) { spin_unlock_bh(&mpath->state_lock); @@ -1028,8 +1039,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, mesh_queue_preq(mpath, PREQ_Q_F_START); } - if (skb_queue_len(&mpath->frame_queue) >= - MESH_FRAME_QUEUE_LEN) + if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN) skb_to_free = skb_dequeue(&mpath->frame_queue); info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; @@ -1061,6 +1071,7 @@ void mesh_path_timer(unsigned long data) } else if (mpath->discovery_retries < max_preq_retries(sdata)) { ++mpath->discovery_retries; mpath->discovery_timeout *= 2; + mpath->flags &= ~MESH_PATH_REQ_QUEUED; spin_unlock_bh(&mpath->state_lock); mesh_queue_preq(mpath, 0); } else { -- cgit v0.10.2 From acb32ba3dee66d58704caeeb8c6ff95f60efdc66 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 8 Nov 2011 13:04:43 +0000 Subject: ipv4: reduce percpu needs for icmpmsg mibs Reading /proc/net/snmp on a machine with a lot of cpus is very expensive (can be ~88000 us). This is because ICMPMSG MIB uses 4096 bytes per cpu, and folding values for all possible cpus can read 16 Mbytes of memory. ICMP messages are not considered as fast path on a typical server, and eventually few cpus handle them anyway. We can afford an atomic operation instead of using percpu data. This saves 4096 bytes per cpu and per network namespace. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller diff --git a/include/net/icmp.h b/include/net/icmp.h index f0698b9..75d6156 100644 --- a/include/net/icmp.h +++ b/include/net/icmp.h @@ -31,8 +31,8 @@ struct icmp_err { extern const struct icmp_err icmp_err_convert[]; #define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field) #define ICMP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field) -#define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmpmsg_statistics, field+256) -#define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmpmsg_statistics, field) +#define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field+256) +#define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field) struct dst_entry; struct net_proto_family; diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h index 0b44112..f360135 100644 --- a/include/net/netns/mib.h +++ b/include/net/netns/mib.h @@ -10,7 +10,7 @@ struct netns_mib { DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); - DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics); + DEFINE_SNMP_STAT_ATOMIC(struct icmpmsg_mib, icmpmsg_statistics); #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) struct proc_dir_entry *proc_net_devsnmp6; diff --git a/include/net/snmp.h b/include/net/snmp.h index 8f0f9ac..0feafa6 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -67,7 +67,7 @@ struct icmp_mib { #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX struct icmpmsg_mib { - unsigned long mibs[ICMPMSG_MIB_MAX]; + atomic_long_t mibs[ICMPMSG_MIB_MAX]; }; /* ICMP6 (IPv6-ICMP) */ diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 1b5096a..b2bbcd0 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1572,9 +1572,9 @@ static __net_init int ipv4_mib_init_net(struct net *net) sizeof(struct icmp_mib), __alignof__(struct icmp_mib)) < 0) goto err_icmp_mib; - if (snmp_mib_init((void __percpu **)net->mib.icmpmsg_statistics, - sizeof(struct icmpmsg_mib), - __alignof__(struct icmpmsg_mib)) < 0) + net->mib.icmpmsg_statistics = kzalloc(sizeof(struct icmpmsg_mib), + GFP_KERNEL); + if (!net->mib.icmpmsg_statistics) goto err_icmpmsg_mib; tcp_mib_init(net); @@ -1598,7 +1598,7 @@ err_tcp_mib: static __net_exit void ipv4_mib_exit_net(struct net *net) { - snmp_mib_free((void __percpu **)net->mib.icmpmsg_statistics); + kfree(net->mib.icmpmsg_statistics); snmp_mib_free((void __percpu **)net->mib.icmp_statistics); snmp_mib_free((void __percpu **)net->mib.udplite_statistics); snmp_mib_free((void __percpu **)net->mib.udp_statistics); diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 466ea8b..961eed4 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -288,7 +288,7 @@ static void icmpmsg_put(struct seq_file *seq) count = 0; for (i = 0; i < ICMPMSG_MIB_MAX; i++) { - val = snmp_fold_field((void __percpu **) net->mib.icmpmsg_statistics, i); + val = atomic_long_read(&net->mib.icmpmsg_statistics->mibs[i]); if (val) { type[count] = i; vals[count++] = val; @@ -307,6 +307,7 @@ static void icmp_put(struct seq_file *seq) { int i; struct net *net = seq->private; + atomic_long_t *ptr = net->mib.icmpmsg_statistics->mibs; seq_puts(seq, "\nIcmp: InMsgs InErrors"); for (i=0; icmpmibmap[i].name != NULL; i++) @@ -319,15 +320,13 @@ static void icmp_put(struct seq_file *seq) snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_INERRORS)); for (i=0; icmpmibmap[i].name != NULL; i++) seq_printf(seq, " %lu", - snmp_fold_field((void __percpu **) net->mib.icmpmsg_statistics, - icmpmibmap[i].index)); + atomic_long_read(ptr + icmpmibmap[i].index)); seq_printf(seq, " %lu %lu", snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTMSGS), snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTERRORS)); for (i=0; icmpmibmap[i].name != NULL; i++) seq_printf(seq, " %lu", - snmp_fold_field((void __percpu **) net->mib.icmpmsg_statistics, - icmpmibmap[i].index | 0x100)); + atomic_long_read(ptr + (icmpmibmap[i].index | 0x100))); } /* -- cgit v0.10.2 From 6cc00d545a21ed26696f3bda865ebf11eccbf2b5 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Thu, 3 Nov 2011 21:11:11 -0700 Subject: mac80211: QoS multicast frames have No Ack policy Previously QoS multicast frames had the Normal Acknowledgment QoS control bits set. This would cause broadcast frames to be discarded by peers with which we have a BA session, since their sequence number would fall outside the allowed range. Set No Ack QoS control bits on multicast QoS frames and filter these in de-aggregation code. Signed-off-by: Thomas Pedersen v2: Use proper QoS Ack Policy ctl field mask (Christian) v3: Clean up conditional (Johannes) Signed-off-by: John W. Linville diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index ffc073a..66cedf6 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -128,6 +128,7 @@ #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020 #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040 #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060 +#define IEEE80211_QOS_CTL_ACK_POLICY_MASK 0x0060 /* A-MSDU 802.11n */ #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080 /* Mesh Control 802.11s */ diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 3173dcf..72c1eb4 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -747,7 +747,7 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx) struct sta_info *sta = rx->sta; struct tid_ampdu_rx *tid_agg_rx; u16 sc; - int tid; + u8 tid, ack_policy; if (!ieee80211_is_data_qos(hdr->frame_control)) goto dont_reorder; @@ -760,6 +760,8 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx) if (!sta) goto dont_reorder; + ack_policy = *ieee80211_get_qos_ctl(hdr) & + IEEE80211_QOS_CTL_ACK_POLICY_MASK; tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]); @@ -770,6 +772,11 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx) if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC))) goto dont_reorder; + /* not part of a BA session */ + if (ack_policy != IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK && + ack_policy != IEEE80211_QOS_CTL_ACK_POLICY_NORMAL) + goto dont_reorder; + /* new, potentially un-ordered, ampdu frame - process it */ /* reset session timer */ diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index d0240bb..d4f789a 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c @@ -150,7 +150,8 @@ void ieee80211_set_qos_hdr(struct ieee80211_sub_if_data *sdata, /* preserve EOSP bit */ ack_policy = *p & IEEE80211_QOS_CTL_EOSP; - if (unlikely(sdata->local->wifi_wme_noack_test)) + if (unlikely(sdata->local->wifi_wme_noack_test) || + is_multicast_ether_addr(hdr->addr1)) ack_policy |= IEEE80211_QOS_CTL_ACK_POLICY_NOACK; /* qos header is 2 bytes */ *p++ = ack_policy | tid; -- cgit v0.10.2 From 660c6a449a714cf770641134124f2aae49ed8ab0 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Thu, 3 Nov 2011 21:11:12 -0700 Subject: mac80211: check if frame is really part of this BA There was an an implicit assumption that any QoS data frame received from a STA/TID with an active BA session was sent to this vif as part of a BA. This is not true if IFF_PROMISC is enabled and the frame was destined for a different peer, for example. Don't treat these frames as part of a BA from the sending STA. Signed-off-by: Thomas Pedersen Signed-off-by: John W. Linville diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 72c1eb4..04c1b05 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -744,6 +744,7 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx) struct ieee80211_local *local = rx->local; struct ieee80211_hw *hw = &local->hw; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); struct sta_info *sta = rx->sta; struct tid_ampdu_rx *tid_agg_rx; u16 sc; @@ -777,6 +778,10 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx) ack_policy != IEEE80211_QOS_CTL_ACK_POLICY_NORMAL) goto dont_reorder; + /* not actually part of this BA session */ + if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) + goto dont_reorder; + /* new, potentially un-ordered, ampdu frame - process it */ /* reset session timer */ -- cgit v0.10.2 From d0ce1855eab098c6257f1321b02b70f916064aaa Mon Sep 17 00:00:00 2001 From: Javier Cardona Date: Thu, 3 Nov 2011 21:11:13 -0700 Subject: mac80211: simplify mesh frame queue mapping and QoS We only need to set the skb queue twice: 1. by the netdev, on local TX. 2. when forwarding a mesh frame. We only need to set the qos header twice: 1. by mac80211, on local TX. 2. when putting a frame on the mpath->frame_queue We also don't need the RA in order to set the proper queue mapping since all mesh STAs are QoS, indicate this and do it once when the frame is received. Also fixes an issue where the QoS header and queue mapping was not set for unicast forwarded frames. Signed-off-by: Javier Cardona Signed-off-by: Thomas Pedersen Signed-off-by: John W. Linville diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index b22b223..a7afb2d 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -1043,6 +1043,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, skb_to_free = skb_dequeue(&mpath->frame_queue); info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; + ieee80211_set_qos_hdr(sdata, skb); skb_queue_tail(&mpath->frame_queue, skb); if (skb_to_free) mesh_path_discard_frame(skb_to_free, sdata); diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 7f54c50..4fc23d1 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -213,7 +213,6 @@ void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) struct ieee80211_hdr *hdr; struct sk_buff_head tmpq; unsigned long flags; - struct ieee80211_sub_if_data *sdata = mpath->sdata; rcu_assign_pointer(mpath->next_hop, sta); @@ -224,8 +223,6 @@ void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) while ((skb = __skb_dequeue(&mpath->frame_queue)) != NULL) { hdr = (struct ieee80211_hdr *) skb->data; memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); - skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, skb)); - ieee80211_set_qos_hdr(sdata, skb); __skb_queue_tail(&tmpq, skb); } diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 04c1b05..c8a7076 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1941,6 +1941,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) compare_ether_addr(sdata->vif.addr, hdr->addr3) == 0) return RX_CONTINUE; + skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, skb)); mesh_hdr->ttl--; if (status->rx_flags & IEEE80211_RX_RA_MATCH) { @@ -1965,12 +1966,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) memset(info, 0, sizeof(*info)); info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; info->control.vif = &rx->sdata->vif; + info->control.jiffies = jiffies; if (is_multicast_ether_addr(fwd_hdr->addr1)) { IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, fwded_mcast); - skb_set_queue_mapping(fwd_skb, - ieee80211_select_queue(sdata, fwd_skb)); - ieee80211_set_qos_hdr(sdata, fwd_skb); } else { int err; /* diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index d4f789a..4332711 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c @@ -83,7 +83,7 @@ u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata, break; #ifdef CONFIG_MAC80211_MESH case NL80211_IFTYPE_MESH_POINT: - ra = skb->data; + qos = true; break; #endif case NL80211_IFTYPE_STATION: -- cgit v0.10.2 From 6096de7fd4eeda305e114e7d74e6f47404590425 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:10 +0100 Subject: mac80211: add helper to free TX skb Drivers that need to drop a frame before it can be transmitted will usually simply free that frame. This is currently fine, but in the future it'll be needed to tell mac80211 about this case, so add a new routine that frees a TX skb. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/net/mac80211.h b/include/net/mac80211.h index eddf492..b9b9c94 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1309,6 +1309,16 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, } /** + * ieee80211_free_txskb - free TX skb + * @hw: the hardware + * @skb: the skb + * + * Free a transmit skb. Use this funtion when some failure + * to transmit happened and thus status cannot be reported. + */ +void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); + +/** * DOC: Hardware crypto acceleration * * mac80211 is capable of taking advantage of many hardware diff --git a/net/mac80211/status.c b/net/mac80211/status.c index df643ce..e1f6954 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -609,3 +609,9 @@ void ieee80211_report_low_ack(struct ieee80211_sta *pubsta, u32 num_packets) num_packets, GFP_ATOMIC); } EXPORT_SYMBOL(ieee80211_report_low_ack); + +void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + dev_kfree_skb_any(skb); +} +EXPORT_SYMBOL(ieee80211_free_txskb); -- cgit v0.10.2 From 665c93a93e35cafcd8c84073824f1ef1b19f0a7d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:11 +0100 Subject: mac80211: add support for control port protocol in AP mode This will allow us to support dynamic WEP with 802.1X properly in mac80211 by not encrypting outgoing and accepting unencrypted incoming frames. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 65b72ae..1f10561 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -594,6 +594,8 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, { struct ieee80211_sub_if_data *sdata; struct beacon_data *old; + struct ieee80211_sub_if_data *vlan; + int ret; sdata = IEEE80211_DEV_TO_SUB_IF(dev); @@ -601,7 +603,24 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, if (old) return -EALREADY; - return ieee80211_config_beacon(sdata, params); + ret = ieee80211_config_beacon(sdata, params); + if (ret) + return ret; + + /* + * Apply control port protocol, this allows us to + * not encrypt dynamic WEP control frames. + */ + sdata->control_port_protocol = params->crypto.control_port_ethertype; + sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt; + list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { + vlan->control_port_protocol = + params->crypto.control_port_ethertype; + vlan->control_port_no_encrypt = + params->crypto.control_port_no_encrypt; + } + + return 0; } static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 4ee624c..b7bc4b7 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -188,11 +188,22 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) if (!is_valid_ether_addr(sdata->u.wds.remote_addr)) return -ENOLINK; break; - case NL80211_IFTYPE_AP_VLAN: + case NL80211_IFTYPE_AP_VLAN: { + struct ieee80211_sub_if_data *master; + if (!sdata->bss) return -ENOLINK; + list_add(&sdata->u.vlan.list, &sdata->bss->vlans); + + master = container_of(sdata->bss, + struct ieee80211_sub_if_data, u.ap); + sdata->control_port_protocol = + master->control_port_protocol; + sdata->control_port_no_encrypt = + master->control_port_no_encrypt; break; + } case NL80211_IFTYPE_AP: sdata->bss = &sdata->u.ap; break; -- cgit v0.10.2 From 28946da763e8b8d8ffd01ab861b684a4afb4bc3b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:12 +0100 Subject: nl80211: allow subscribing to unexpected class3 frames To implement AP mode without monitor interfaces we need to be able to send a deauth to stations that send frames without being associated. Enable this by adding a new nl80211 event for such frames that an application can subscribe to. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 8049bf7..9107adc 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -509,6 +509,16 @@ * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup). * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame. * + * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP + * (or GO) interface (i.e. hostapd) to ask for unexpected frames to + * implement sending deauth to stations that send unexpected class 3 + * frames. Also used as the event sent by the kernel when such a frame + * is received. + * For the event, the %NL80211_ATTR_MAC attribute carries the TA and + * other attributes like the interface index are present. + * If used as the command it must have an interface index and you can + * only unsubscribe from the event by closing the socket. + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -638,6 +648,8 @@ enum nl80211_commands { NL80211_CMD_TDLS_OPER, NL80211_CMD_TDLS_MGMT, + NL80211_CMD_UNEXPECTED_FRAME, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 0c71d4a..ef118e4 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -2183,6 +2183,8 @@ struct wireless_dev { int beacon_interval; + u32 ap_unexpected_nlpid; + #ifdef CONFIG_CFG80211_WEXT /* wext data */ struct { @@ -3193,6 +3195,21 @@ void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, const u8 *bssid, bool preauth, gfp_t gfp); +/** + * cfg80211_rx_spurious_frame - inform userspace about a spurious frame + * @dev: The device the frame matched to + * @addr: the transmitter address + * @gfp: context flags + * + * This function is used in AP mode (only!) to inform userspace that + * a spurious class 3 frame was received, to be able to deauth the + * sender. + * Returns %true if the frame was passed to userspace (or this failed + * for a reason other than not having a subscription.) + */ +bool cfg80211_rx_spurious_frame(struct net_device *dev, + const u8 *addr, gfp_t gfp); + /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 21fc970..f4d868b 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -879,6 +879,9 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid) } spin_unlock_bh(&wdev->mgmt_registrations_lock); + + if (nlpid == wdev->ap_unexpected_nlpid) + wdev->ap_unexpected_nlpid = 0; } void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev) @@ -1107,3 +1110,16 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); } EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); + +bool cfg80211_rx_spurious_frame(struct net_device *dev, + const u8 *addr, gfp_t gfp) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && + wdev->iftype != NL80211_IFTYPE_P2P_GO)) + return false; + + return nl80211_unexpected_frame(dev, addr, gfp); +} +EXPORT_SYMBOL(cfg80211_rx_spurious_frame); diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 2bcaa57..9910c3c 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5832,6 +5832,23 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info) return err; } +static int nl80211_register_unexpected_frame(struct sk_buff *skb, + struct genl_info *info) +{ + struct net_device *dev = info->user_ptr[1]; + struct wireless_dev *wdev = dev->ieee80211_ptr; + + if (wdev->iftype != NL80211_IFTYPE_AP && + wdev->iftype != NL80211_IFTYPE_P2P_GO) + return -EINVAL; + + if (wdev->ap_unexpected_nlpid) + return -EBUSY; + + wdev->ap_unexpected_nlpid = info->snd_pid; + return 0; +} + #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -6387,6 +6404,14 @@ static struct genl_ops nl80211_ops[] = { .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | NL80211_FLAG_NEED_RTNL, }, + { + .cmd = NL80211_CMD_UNEXPECTED_FRAME, + .doit = nl80211_register_unexpected_frame, + .policy = nl80211_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = NL80211_FLAG_NEED_NETDEV | + NL80211_FLAG_NEED_RTNL, + }, }; static struct genl_multicast_group nl80211_mlme_mcgrp = { @@ -7171,6 +7196,47 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, nlmsg_free(msg); } +bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); + struct sk_buff *msg; + void *hdr; + int err; + u32 nlpid = ACCESS_ONCE(wdev->ap_unexpected_nlpid); + + if (!nlpid) + return false; + + msg = nlmsg_new(100, gfp); + if (!msg) + return true; + + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_UNEXPECTED_FRAME); + if (!hdr) { + nlmsg_free(msg); + return true; + } + + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + + err = genlmsg_end(msg, hdr); + if (err < 0) { + nlmsg_free(msg); + return true; + } + + genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); + return true; + + nla_put_failure: + genlmsg_cancel(msg, hdr); + nlmsg_free(msg); + return true; +} + int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, struct net_device *netdev, u32 nlpid, int freq, const u8 *buf, size_t len, gfp_t gfp) diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index f24a1fb..d94456e 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h @@ -117,4 +117,7 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, struct net_device *netdev, int index, const u8 *bssid, bool preauth, gfp_t gfp); +bool nl80211_unexpected_frame(struct net_device *dev, + const u8 *addr, gfp_t gfp); + #endif /* __NET_WIRELESS_NL80211_H */ -- cgit v0.10.2 From 21fc756087d7659d86c344c0b38229313afc6c7c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:13 +0100 Subject: mac80211: support spurious class3 event Add support for the spurious class3 frame event to mac80211 to enable AP w/o monitor mode. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index c8a7076..e832e0d 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -866,6 +866,13 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) rx->sdata->control_port_protocol) return RX_CONTINUE; } + + if (rx->sdata->vif.type == NL80211_IFTYPE_AP && + cfg80211_rx_spurious_frame(rx->sdata->dev, + hdr->addr2, + GFP_ATOMIC)) + return RX_DROP_UNUSABLE; + return RX_DROP_MONITOR; } -- cgit v0.10.2 From 562a74803f4881772ba2375ec4e5aa0ad90f4caa Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 7 Nov 2011 12:39:33 +0100 Subject: nl80211: advertise device AP SME Add the ability to advertise that the device contains the AP SME and what features it can support. There are currently no features in the bitmap -- probe response offload will be advertised by a few patches Arik is working on now (who took over from Guy Eilam) and a device with AP SME will typically implement and require response offload. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index c1d2366..81e0031 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1548,7 +1548,8 @@ static int ath6kl_init(struct net_device *dev) ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; - ar->wdev->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; + ar->wdev->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | + WIPHY_FLAG_HAVE_AP_SME; status = ath6kl_target_config_wlan_params(ar); if (!status) diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 9107adc..ff39e4b 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -1121,6 +1121,11 @@ enum nl80211_commands { * %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be * used for asking the driver to perform a TDLS operation. * + * @NL80211_ATTR_DEVICE_AP_SME: This u32 attribute may be listed for devices + * that have AP support to indicate that they have the AP SME integrated + * with support for the features listed in this attribute, see + * &enum nl80211_ap_sme_features. + * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1349,6 +1354,8 @@ enum nl80211_attrs { NL80211_ATTR_TDLS_SUPPORT, NL80211_ATTR_TDLS_EXTERNAL_SETUP, + NL80211_ATTR_DEVICE_AP_SME, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -2662,4 +2669,12 @@ enum nl80211_tdls_operation { NL80211_TDLS_DISABLE_LINK, }; +/* + * enum nl80211_ap_sme_features - device-integrated AP features + * Reserved for future use, no bits are defined in + * NL80211_ATTR_DEVICE_AP_SME yet. +enum nl80211_ap_sme_features { +}; + */ + #endif /* __LINUX_NL80211_H */ diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index ef118e4..86d207d 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1679,6 +1679,7 @@ struct cfg80211_ops { * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be * used for asking the driver/firmware to perform a TDLS operation. + * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME */ enum wiphy_flags { WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), @@ -1697,6 +1698,7 @@ enum wiphy_flags { WIPHY_FLAG_AP_UAPSD = BIT(14), WIPHY_FLAG_SUPPORTS_TDLS = BIT(15), WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16), + WIPHY_FLAG_HAVE_AP_SME = BIT(17), }; /** @@ -1907,6 +1909,8 @@ struct wiphy_wowlan_support { * may request, if implemented. * * @wowlan: WoWLAN support information + * + * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features. */ struct wiphy { /* assign these fields before you register the wiphy */ @@ -1930,6 +1934,8 @@ struct wiphy { u32 flags; + u32 ap_sme_capa; + enum cfg80211_signal_type signal_type; int bss_priv_size; diff --git a/net/wireless/core.c b/net/wireless/core.c index 220f3bd..ccdfed8 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -492,6 +492,10 @@ int wiphy_register(struct wiphy *wiphy) !(wiphy->wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY))) return -EINVAL; + if (WARN_ON(wiphy->ap_sme_capa && + !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME))) + return -EINVAL; + if (WARN_ON(wiphy->addresses && !wiphy->n_addresses)) return -EINVAL; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 9910c3c..2094c84 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1007,6 +1007,10 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, if (nl80211_put_iface_combinations(&dev->wiphy, msg)) goto nla_put_failure; + if (dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) + NLA_PUT_U32(msg, NL80211_ATTR_DEVICE_AP_SME, + dev->wiphy.ap_sme_capa); + return genlmsg_end(msg, hdr); nla_put_failure: -- cgit v0.10.2 From 7f6cf311a594c1e7ca8120367dd1d4c685aabff1 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:15 +0100 Subject: nl80211: add API to probe a client When the AP SME in hostapd is used it wants to probe the clients when they have been idle for some time. Add explicit API to support this. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index ff39e4b..901a70d 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -519,6 +519,14 @@ * If used as the command it must have an interface index and you can * only unsubscribe from the event by closing the socket. * + * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface + * by sending a null data frame to it and reporting when the frame is + * acknowleged. This is used to allow timing out inactive clients. Uses + * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a + * direct reply with an %NL80211_ATTR_COOKIE that is later used to match + * up the event with the request. The event includes the same data and + * has %NL80211_ATTR_ACK set if the frame was ACKed. + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -650,6 +658,8 @@ enum nl80211_commands { NL80211_CMD_UNEXPECTED_FRAME, + NL80211_CMD_PROBE_CLIENT, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 86d207d..389e85e 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1432,6 +1432,9 @@ struct cfg80211_gtk_rekey_data { * * @tdls_mgmt: Transmit a TDLS management frame. * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup). + * + * @probe_client: probe an associated client, must return a cookie that it + * later passes to cfg80211_probe_status(). */ struct cfg80211_ops { int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); @@ -1621,6 +1624,9 @@ struct cfg80211_ops { u16 status_code, const u8 *buf, size_t len); int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev, u8 *peer, enum nl80211_tdls_operation oper); + + int (*probe_client)(struct wiphy *wiphy, struct net_device *dev, + const u8 *peer, u64 *cookie); }; /* @@ -3216,6 +3222,17 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, bool cfg80211_rx_spurious_frame(struct net_device *dev, const u8 *addr, gfp_t gfp); +/** + * cfg80211_probe_status - notify userspace about probe status + * @dev: the device the probe was sent on + * @addr: the address of the peer + * @cookie: the cookie filled in @probe_client previously + * @acked: indicates whether probe was acked or not + * @gfp: allocation flags + */ +void cfg80211_probe_status(struct net_device *dev, const u8 *addr, + u64 cookie, bool acked, gfp_t gfp); + /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 2094c84..a8eda12 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -890,6 +890,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, } if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) CMD(sched_scan_start, START_SCHED_SCAN); + CMD(probe_client, PROBE_CLIENT); #undef CMD @@ -5853,6 +5854,59 @@ static int nl80211_register_unexpected_frame(struct sk_buff *skb, return 0; } +static int nl80211_probe_client(struct sk_buff *skb, + struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + struct net_device *dev = info->user_ptr[1]; + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct sk_buff *msg; + void *hdr; + const u8 *addr; + u64 cookie; + int err; + + if (wdev->iftype != NL80211_IFTYPE_AP && + wdev->iftype != NL80211_IFTYPE_P2P_GO) + return -EOPNOTSUPP; + + if (!info->attrs[NL80211_ATTR_MAC]) + return -EINVAL; + + if (!rdev->ops->probe_client) + return -EOPNOTSUPP; + + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; + + hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, + NL80211_CMD_PROBE_CLIENT); + + if (IS_ERR(hdr)) { + err = PTR_ERR(hdr); + goto free_msg; + } + + addr = nla_data(info->attrs[NL80211_ATTR_MAC]); + + err = rdev->ops->probe_client(&rdev->wiphy, dev, addr, &cookie); + if (err) + goto free_msg; + + NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); + + genlmsg_end(msg, hdr); + + return genlmsg_reply(msg, info); + + nla_put_failure: + err = -ENOBUFS; + free_msg: + nlmsg_free(msg); + return err; +} + #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -6416,6 +6470,14 @@ static struct genl_ops nl80211_ops[] = { .internal_flags = NL80211_FLAG_NEED_NETDEV | NL80211_FLAG_NEED_RTNL, }, + { + .cmd = NL80211_CMD_PROBE_CLIENT, + .doit = nl80211_probe_client, + .policy = nl80211_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = NL80211_FLAG_NEED_NETDEV | + NL80211_FLAG_NEED_RTNL, + }, }; static struct genl_multicast_group nl80211_mlme_mcgrp = { @@ -7478,6 +7540,48 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, nlmsg_free(msg); } +void cfg80211_probe_status(struct net_device *dev, const u8 *addr, + u64 cookie, bool acked, gfp_t gfp) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); + struct sk_buff *msg; + void *hdr; + int err; + + msg = nlmsg_new(NLMSG_GOODSIZE, gfp); + if (!msg) + return; + + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PROBE_CLIENT); + if (!hdr) { + nlmsg_free(msg); + return; + } + + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); + NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); + if (acked) + NLA_PUT_FLAG(msg, NL80211_ATTR_ACK); + + err = genlmsg_end(msg, hdr); + if (err < 0) { + nlmsg_free(msg); + return; + } + + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, + nl80211_mlme_mcgrp.id, gfp); + return; + + nla_put_failure: + genlmsg_cancel(msg, hdr); + nlmsg_free(msg); +} +EXPORT_SYMBOL(cfg80211_probe_status); + static int nl80211_netlink_notify(struct notifier_block * nb, unsigned long state, void *_notify) -- cgit v0.10.2 From 06500736c5d26bff93a4f358713689073e66d0f5 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:16 +0100 Subject: mac80211: support client probe Support probing clients with null data frames in AP mode. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 1f10561..e072fea 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2507,6 +2507,73 @@ static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, return 0; } +static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, + const u8 *peer, u64 *cookie) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct ieee80211_local *local = sdata->local; + struct ieee80211_qos_hdr *nullfunc; + struct sk_buff *skb; + int size = sizeof(*nullfunc); + __le16 fc; + bool qos; + struct ieee80211_tx_info *info; + struct sta_info *sta; + + rcu_read_lock(); + sta = sta_info_get(sdata, peer); + if (sta) + qos = test_sta_flag(sta, WLAN_STA_WME); + rcu_read_unlock(); + + if (!sta) + return -ENOLINK; + + if (qos) { + fc = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_QOS_NULLFUNC | + IEEE80211_FCTL_FROMDS); + } else { + size -= 2; + fc = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC | + IEEE80211_FCTL_FROMDS); + } + + skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); + if (!skb) + return -ENOMEM; + + skb->dev = dev; + + skb_reserve(skb, local->hw.extra_tx_headroom); + + nullfunc = (void *) skb_put(skb, size); + nullfunc->frame_control = fc; + nullfunc->duration_id = 0; + memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); + memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); + memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); + nullfunc->seq_ctrl = 0; + + info = IEEE80211_SKB_CB(skb); + + info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | + IEEE80211_TX_INTFL_NL80211_FRAME_TX; + + skb_set_queue_mapping(skb, IEEE80211_AC_VO); + skb->priority = 7; + if (qos) + nullfunc->qos_ctrl = cpu_to_le16(7); + + local_bh_disable(); + ieee80211_xmit(sdata, skb); + local_bh_enable(); + + *cookie = (unsigned long) skb; + return 0; +} + struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface, @@ -2572,4 +2639,5 @@ struct cfg80211_ops mac80211_config_ops = { .set_rekey_data = ieee80211_set_rekey_data, .tdls_oper = ieee80211_tdls_oper, .tdls_mgmt = ieee80211_tdls_mgmt, + .probe_client = ieee80211_probe_client, }; diff --git a/net/mac80211/status.c b/net/mac80211/status.c index e1f6954..94702f1 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -516,27 +516,36 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) } if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) { - struct ieee80211_work *wk; u64 cookie = (unsigned long)skb; - rcu_read_lock(); - list_for_each_entry_rcu(wk, &local->work_list, list) { - if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX) - continue; - if (wk->offchan_tx.frame != skb) - continue; - wk->offchan_tx.status = true; - break; - } - rcu_read_unlock(); - if (local->hw_roc_skb_for_status == skb) { - cookie = local->hw_roc_cookie ^ 2; - local->hw_roc_skb_for_status = NULL; - } + if (ieee80211_is_nullfunc(hdr->frame_control) || + ieee80211_is_qos_nullfunc(hdr->frame_control)) { + bool acked = info->flags & IEEE80211_TX_STAT_ACK; + cfg80211_probe_status(skb->dev, hdr->addr1, + cookie, acked, GFP_ATOMIC); + } else { + struct ieee80211_work *wk; + + rcu_read_lock(); + list_for_each_entry_rcu(wk, &local->work_list, list) { + if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX) + continue; + if (wk->offchan_tx.frame != skb) + continue; + wk->offchan_tx.status = true; + break; + } + rcu_read_unlock(); + if (local->hw_roc_skb_for_status == skb) { + cookie = local->hw_roc_cookie ^ 2; + local->hw_roc_skb_for_status = NULL; + } - cfg80211_mgmt_tx_status( - skb->dev, cookie, skb->data, skb->len, - !!(info->flags & IEEE80211_TX_STAT_ACK), GFP_ATOMIC); + cfg80211_mgmt_tx_status( + skb->dev, cookie, skb->data, skb->len, + !!(info->flags & IEEE80211_TX_STAT_ACK), + GFP_ATOMIC); + } } /* this was a transmitted frame, but now we want to reuse it */ -- cgit v0.10.2 From 5e760230e42cf759bd923457ca2753aacf2e656e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:17 +0100 Subject: cfg80211: allow registering to beacons Add the ability to register to received beacon frames to allow implementing OLBC logic in userspace. The registration is per wiphy since there's no point in receiving the same frame multiple times. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 901a70d..c29a284 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -527,6 +527,11 @@ * up the event with the request. The event includes the same data and * has %NL80211_ATTR_ACK set if the frame was ACKed. * + * @NL80211_CMD_REGISTER_BEACONS: Register this socket to receive beacons from + * other BSSes when any interfaces are in AP mode. This helps implement + * OLBC handling in hostapd. Beacons are reported in %NL80211_CMD_FRAME + * messages. Note that per PHY only one application may register. + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -660,6 +665,8 @@ enum nl80211_commands { NL80211_CMD_PROBE_CLIENT, + NL80211_CMD_REGISTER_BEACONS, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 389e85e..d01307f 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1686,6 +1686,9 @@ struct cfg80211_ops { * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be * used for asking the driver/firmware to perform a TDLS operation. * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME + * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes + * when there are virtual interfaces in AP mode by calling + * cfg80211_report_obss_beacon(). */ enum wiphy_flags { WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), @@ -1705,6 +1708,7 @@ enum wiphy_flags { WIPHY_FLAG_SUPPORTS_TDLS = BIT(15), WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16), WIPHY_FLAG_HAVE_AP_SME = BIT(17), + WIPHY_FLAG_REPORTS_OBSS = BIT(18), }; /** @@ -3233,6 +3237,22 @@ bool cfg80211_rx_spurious_frame(struct net_device *dev, void cfg80211_probe_status(struct net_device *dev, const u8 *addr, u64 cookie, bool acked, gfp_t gfp); +/** + * cfg80211_report_obss_beacon - report beacon from other APs + * @wiphy: The wiphy that received the beacon + * @frame: the frame + * @len: length of the frame + * @freq: frequency the frame was received on + * @gfp: allocation flags + * + * Use this function to report to userspace when a beacon was + * received. It is not useful to call this when there is no + * netdev that is in AP/GO mode. + */ +void cfg80211_report_obss_beacon(struct wiphy *wiphy, + const u8 *frame, size_t len, + int freq, gfp_t gfp); + /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ diff --git a/net/wireless/core.h b/net/wireless/core.h index b9ec306..4c6ff40 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -54,6 +54,8 @@ struct cfg80211_registered_device { int opencount; /* also protected by devlist_mtx */ wait_queue_head_t dev_wait; + u32 ap_beacons_nlpid; + /* BSSes/scanning */ spinlock_t bss_lock; struct list_head bss_list; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a8eda12..68b6708 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -891,6 +891,10 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) CMD(sched_scan_start, START_SCHED_SCAN); CMD(probe_client, PROBE_CLIENT); + if (dev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) { + i++; + NLA_PUT_U32(msg, i, NL80211_CMD_REGISTER_BEACONS); + } #undef CMD @@ -5907,6 +5911,21 @@ static int nl80211_probe_client(struct sk_buff *skb, return err; } +static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + + if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS)) + return -EOPNOTSUPP; + + if (rdev->ap_beacons_nlpid) + return -EBUSY; + + rdev->ap_beacons_nlpid = info->snd_pid; + + return 0; +} + #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -6478,6 +6497,14 @@ static struct genl_ops nl80211_ops[] = { .internal_flags = NL80211_FLAG_NEED_NETDEV | NL80211_FLAG_NEED_RTNL, }, + { + .cmd = NL80211_CMD_REGISTER_BEACONS, + .doit = nl80211_register_beacons, + .policy = nl80211_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = NL80211_FLAG_NEED_WIPHY | + NL80211_FLAG_NEED_RTNL, + }, }; static struct genl_multicast_group nl80211_mlme_mcgrp = { @@ -7582,6 +7609,44 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, } EXPORT_SYMBOL(cfg80211_probe_status); +void cfg80211_report_obss_beacon(struct wiphy *wiphy, + const u8 *frame, size_t len, + int freq, gfp_t gfp) +{ + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); + struct sk_buff *msg; + void *hdr; + u32 nlpid = ACCESS_ONCE(rdev->ap_beacons_nlpid); + + if (!nlpid) + return; + + msg = nlmsg_new(len + 100, gfp); + if (!msg) + return; + + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME); + if (!hdr) { + nlmsg_free(msg); + return; + } + + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); + if (freq) + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); + NLA_PUT(msg, NL80211_ATTR_FRAME, len, frame); + + genlmsg_end(msg, hdr); + + genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); + return; + + nla_put_failure: + genlmsg_cancel(msg, hdr); + nlmsg_free(msg); +} +EXPORT_SYMBOL(cfg80211_report_obss_beacon); + static int nl80211_netlink_notify(struct notifier_block * nb, unsigned long state, void *_notify) @@ -7595,9 +7660,12 @@ static int nl80211_netlink_notify(struct notifier_block * nb, rcu_read_lock(); - list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) + list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { list_for_each_entry_rcu(wdev, &rdev->netdev_list, list) cfg80211_mlme_unregister_socket(wdev, notify->pid); + if (rdev->ap_beacons_nlpid == notify->pid) + rdev->ap_beacons_nlpid = 0; + } rcu_read_unlock(); -- cgit v0.10.2 From ee971924543fe82f279d3e97f6f6d02320b381b7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:18 +0100 Subject: mac80211: report OBSS beacons If there's an interface in AP mode, OBSS beacons are needed by hostapd/wpa_s to implement logic to enable/disable protection etc. Report the frames and set the capability flag. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 386330c..4bef6ec 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -184,12 +184,15 @@ enum ieee80211_packet_rx_flags { * enum ieee80211_rx_flags - RX data flags * * @IEEE80211_RX_CMNTR: received on cooked monitor already + * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported + * to cfg80211_report_obss_beacon(). * * These flags are used across handling multiple interfaces * for a single frame. */ enum ieee80211_rx_flags { IEEE80211_RX_CMNTR = BIT(0), + IEEE80211_RX_BEACON_REPORTED = BIT(1), }; struct ieee80211_rx_data { diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 7217019..8e9327b 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -593,7 +593,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, wiphy->flags |= WIPHY_FLAG_NETNS_OK | WIPHY_FLAG_4ADDR_AP | - WIPHY_FLAG_4ADDR_STATION; + WIPHY_FLAG_4ADDR_STATION | + WIPHY_FLAG_REPORTS_OBSS; if (!ops->set_key) wiphy->flags |= WIPHY_FLAG_IBSS_RSN; diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index e832e0d..2ed882f 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2188,6 +2188,18 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx) if (!ieee80211_is_mgmt(mgmt->frame_control)) return RX_DROP_MONITOR; + if (rx->sdata->vif.type == NL80211_IFTYPE_AP && + ieee80211_is_beacon(mgmt->frame_control) && + !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { + struct ieee80211_rx_status *status; + + status = IEEE80211_SKB_RXCB(rx->skb); + cfg80211_report_obss_beacon(rx->local->hw.wiphy, + rx->skb->data, rx->skb->len, + status->freq, GFP_ATOMIC); + rx->flags |= IEEE80211_RX_BEACON_REPORTED; + } + if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) return RX_DROP_MONITOR; -- cgit v0.10.2 From b92ab5d86dafc2b3733c5fdd5def40c8fe7ea7c9 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:19 +0100 Subject: cfg80211: add event for unexpected 4addr frames The frames are used by AP/STA WDS mode, and hostapd needs to know when such a frame was received to set up the VLAN appropriately to allow using it. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index c29a284..09474ab 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -517,7 +517,13 @@ * For the event, the %NL80211_ATTR_MAC attribute carries the TA and * other attributes like the interface index are present. * If used as the command it must have an interface index and you can - * only unsubscribe from the event by closing the socket. + * only unsubscribe from the event by closing the socket. Subscription + * is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events. + * + * @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the + * associated station identified by %NL80211_ATTR_MAC sent a 4addr frame + * and wasn't already in a 4-addr VLAN. The event will be sent similarly + * to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener. * * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface * by sending a null data frame to it and reporting when the frame is @@ -667,6 +673,8 @@ enum nl80211_commands { NL80211_CMD_REGISTER_BEACONS, + NL80211_CMD_UNEXPECTED_4ADDR_FRAME, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index d01307f..be3535f 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -3227,6 +3227,22 @@ bool cfg80211_rx_spurious_frame(struct net_device *dev, const u8 *addr, gfp_t gfp); /** + * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame + * @dev: The device the frame matched to + * @addr: the transmitter address + * @gfp: context flags + * + * This function is used in AP mode (only!) to inform userspace that + * an associated station sent a 4addr frame but that wasn't expected. + * It is allowed and desirable to send this event only once for each + * station to avoid event flooding. + * Returns %true if the frame was passed to userspace (or this failed + * for a reason other than not having a subscription.) + */ +bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, + const u8 *addr, gfp_t gfp); + +/** * cfg80211_probe_status - notify userspace about probe status * @dev: the device the probe was sent on * @addr: the address of the peer diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index f4d868b..34891e0 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -1123,3 +1123,17 @@ bool cfg80211_rx_spurious_frame(struct net_device *dev, return nl80211_unexpected_frame(dev, addr, gfp); } EXPORT_SYMBOL(cfg80211_rx_spurious_frame); + +bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, + const u8 *addr, gfp_t gfp) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && + wdev->iftype != NL80211_IFTYPE_P2P_GO && + wdev->iftype != NL80211_IFTYPE_AP_VLAN)) + return false; + + return nl80211_unexpected_4addr_frame(dev, addr, gfp); +} +EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame); diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 68b6708..5b65906 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -7289,7 +7289,8 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, nlmsg_free(msg); } -bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) +static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd, + const u8 *addr, gfp_t gfp) { struct wireless_dev *wdev = dev->ieee80211_ptr; struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); @@ -7305,7 +7306,7 @@ bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) if (!msg) return true; - hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_UNEXPECTED_FRAME); + hdr = nl80211hdr_put(msg, 0, 0, 0, cmd); if (!hdr) { nlmsg_free(msg); return true; @@ -7330,6 +7331,20 @@ bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) return true; } +bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) +{ + return __nl80211_unexpected_frame(dev, NL80211_CMD_UNEXPECTED_FRAME, + addr, gfp); +} + +bool nl80211_unexpected_4addr_frame(struct net_device *dev, + const u8 *addr, gfp_t gfp) +{ + return __nl80211_unexpected_frame(dev, + NL80211_CMD_UNEXPECTED_4ADDR_FRAME, + addr, gfp); +} + int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, struct net_device *netdev, u32 nlpid, int freq, const u8 *buf, size_t len, gfp_t gfp) diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index d94456e..12bf4d1 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h @@ -119,5 +119,7 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp); +bool nl80211_unexpected_4addr_frame(struct net_device *dev, + const u8 *addr, gfp_t gfp); #endif /* __NET_WIRELESS_NL80211_H */ -- cgit v0.10.2 From e7f4a940bb5eecd07cf0039e7d9201badc332ae0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:20 +0100 Subject: mac80211: send unexpected 4addr event Implement the cfg80211 notification but only send one event per associated station to avoid having tons of events if the station thinks it should be allowed to use 4addr frames but it isn't. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 2ed882f..5f6751a 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1342,15 +1342,20 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) /* * If we receive a 4-addr nullfunc frame from a STA - * that was not moved to a 4-addr STA vlan yet, drop - * the frame to the monitor interface, to make sure - * that hostapd sees it + * that was not moved to a 4-addr STA vlan yet send + * the event to userspace and for older hostapd drop + * the frame to the monitor interface. */ if (ieee80211_has_a4(hdr->frame_control) && (rx->sdata->vif.type == NL80211_IFTYPE_AP || (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && - !rx->sdata->u.vlan.sta))) + !rx->sdata->u.vlan.sta))) { + if (!test_and_set_sta_flag(sta, WLAN_STA_4ADDR_EVENT)) + cfg80211_rx_unexpected_4addr_frame( + rx->sdata->dev, sta->sta.addr, + GFP_ATOMIC); return RX_DROP_MONITOR; + } /* * Update counter and free packet here to avoid * counting this as a dropped packed. @@ -2028,12 +2033,17 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx) return RX_DROP_MONITOR; /* - * Allow the cooked monitor interface of an AP to see 4-addr frames so - * that a 4-addr station can be detected and moved into a separate VLAN + * Send unexpected-4addr-frame event to hostapd. For older versions, + * also drop the frame to cooked monitor interfaces. */ if (ieee80211_has_a4(hdr->frame_control) && - sdata->vif.type == NL80211_IFTYPE_AP) + sdata->vif.type == NL80211_IFTYPE_AP) { + if (rx->sta && + !test_and_set_sta_flag(rx->sta, WLAN_STA_4ADDR_EVENT)) + cfg80211_rx_unexpected_4addr_frame( + rx->sdata->dev, rx->sta->sta.addr, GFP_ATOMIC); return RX_DROP_MONITOR; + } err = __ieee80211_data_to_8023(rx, &port_control); if (unlikely(err)) diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 8c8ce05..c5923ab 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -52,6 +52,7 @@ * unblocks the station. * @WLAN_STA_SP: Station is in a service period, so don't try to * reply to other uAPSD trigger frames or PS-Poll. + * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame. */ enum ieee80211_sta_info_flags { WLAN_STA_AUTH, @@ -71,6 +72,7 @@ enum ieee80211_sta_info_flags { WLAN_STA_TDLS_PEER_AUTH, WLAN_STA_UAPSD, WLAN_STA_SP, + WLAN_STA_4ADDR_EVENT, }; #define STA_TID_NUM 16 @@ -390,6 +392,12 @@ static inline int test_and_clear_sta_flag(struct sta_info *sta, return test_and_clear_bit(flag, &sta->_flags); } +static inline int test_and_set_sta_flag(struct sta_info *sta, + enum ieee80211_sta_info_flags flag) +{ + return test_and_set_bit(flag, &sta->_flags); +} + void ieee80211_assign_tid_tx(struct sta_info *sta, int tid, struct tid_ampdu_tx *tid_tx); -- cgit v0.10.2 From e247bd9068e3e86c3571147c128883596ace9d05 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 4 Nov 2011 11:18:21 +0100 Subject: cfg80211/mac80211: allow management TX to not wait for ACK For probe responses it can be useful to not wait for ACK to avoid retransmissions if the station that sent the probe is already on the next channel, so allow userspace to request not caring about the ACK with a new nl80211 flag. Since mac80211 needs to be updated for the new function prototype anyway implement it right away -- it's just a few lines of code. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 3aff36b..daf444b 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1732,7 +1732,8 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan, bool offchan, enum nl80211_channel_type channel_type, bool channel_type_valid, unsigned int wait, - const u8 *buf, size_t len, bool no_cck, u64 *cookie) + const u8 *buf, size_t len, bool no_cck, + bool dont_wait_for_ack, u64 *cookie) { struct ath6kl *ar = ath6kl_priv(dev); u32 id; diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 09474ab..165e16f 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -1151,6 +1151,11 @@ enum nl80211_commands { * with support for the features listed in this attribute, see * &enum nl80211_ap_sme_features. * + * @NL80211_ATTR_DONT_WAIT_FOR_ACK: Used with %NL80211_CMD_FRAME, this tells + * the driver to not wait for an acknowledgement. Note that due to this, + * it will also not give a status callback nor return a cookie. This is + * mostly useful for probe responses to save airtime. + * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1381,6 +1386,8 @@ enum nl80211_attrs { NL80211_ATTR_DEVICE_AP_SME, + NL80211_ATTR_DONT_WAIT_FOR_ACK, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index be3535f..00287bd 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1588,7 +1588,7 @@ struct cfg80211_ops { enum nl80211_channel_type channel_type, bool channel_type_valid, unsigned int wait, const u8 *buf, size_t len, bool no_cck, - u64 *cookie); + bool dont_wait_for_ack, u64 *cookie); int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy, struct net_device *dev, u64 cookie); diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index e072fea..ab3258a 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1936,7 +1936,7 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, enum nl80211_channel_type channel_type, bool channel_type_valid, unsigned int wait, const u8 *buf, size_t len, bool no_cck, - u64 *cookie) + bool dont_wait_for_ack, u64 *cookie) { struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); struct ieee80211_local *local = sdata->local; @@ -1944,10 +1944,15 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, struct sta_info *sta; struct ieee80211_work *wk; const struct ieee80211_mgmt *mgmt = (void *)buf; - u32 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | - IEEE80211_TX_CTL_REQ_TX_STATUS; + u32 flags; bool is_offchan = false; + if (dont_wait_for_ack) + flags = IEEE80211_TX_CTL_NO_ACK; + else + flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | + IEEE80211_TX_CTL_REQ_TX_STATUS; + /* Check that we are on the requested channel for transmission */ if (chan != local->tmp_channel && chan != local->oper_channel) diff --git a/net/wireless/core.h b/net/wireless/core.h index 4c6ff40..1c7d4df 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -378,7 +378,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, enum nl80211_channel_type channel_type, bool channel_type_valid, unsigned int wait, const u8 *buf, size_t len, bool no_cck, - u64 *cookie); + bool dont_wait_for_ack, u64 *cookie); /* SME */ int __cfg80211_connect(struct cfg80211_registered_device *rdev, diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 34891e0..6c1bafd 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -904,7 +904,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, enum nl80211_channel_type channel_type, bool channel_type_valid, unsigned int wait, const u8 *buf, size_t len, bool no_cck, - u64 *cookie) + bool dont_wait_for_ack, u64 *cookie) { struct wireless_dev *wdev = dev->ieee80211_ptr; const struct ieee80211_mgmt *mgmt; @@ -995,7 +995,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, /* Transmit the Action frame as requested by user space */ return rdev->ops->mgmt_tx(&rdev->wiphy, dev, chan, offchan, channel_type, channel_type_valid, - wait, buf, len, no_cck, cookie); + wait, buf, len, no_cck, dont_wait_for_ack, + cookie); } bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 5b65906..0ef0941 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -196,6 +196,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { [NL80211_ATTR_TDLS_OPERATION] = { .type = NLA_U8 }, [NL80211_ATTR_TDLS_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_TDLS_EXTERNAL_SETUP] = { .type = NLA_FLAG }, + [NL80211_ATTR_DONT_WAIT_FOR_ACK] = { .type = NLA_FLAG }, }; /* policy for the key attributes */ @@ -5282,10 +5283,11 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) int err; void *hdr; u64 cookie; - struct sk_buff *msg; + struct sk_buff *msg = NULL; unsigned int wait = 0; - bool offchan; - bool no_cck; + bool offchan, no_cck, dont_wait_for_ack; + + dont_wait_for_ack = info->attrs[NL80211_ATTR_DONT_WAIT_FOR_ACK]; if (!info->attrs[NL80211_ATTR_FRAME] || !info->attrs[NL80211_ATTR_WIPHY_FREQ]) @@ -5329,29 +5331,36 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) if (chan == NULL) return -EINVAL; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; + if (!dont_wait_for_ack) { + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; - hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, - NL80211_CMD_FRAME); + hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, + NL80211_CMD_FRAME); - if (IS_ERR(hdr)) { - err = PTR_ERR(hdr); - goto free_msg; + if (IS_ERR(hdr)) { + err = PTR_ERR(hdr); + goto free_msg; + } } + err = cfg80211_mlme_mgmt_tx(rdev, dev, chan, offchan, channel_type, channel_type_valid, wait, nla_data(info->attrs[NL80211_ATTR_FRAME]), nla_len(info->attrs[NL80211_ATTR_FRAME]), - no_cck, &cookie); + no_cck, dont_wait_for_ack, &cookie); if (err) goto free_msg; - NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); + if (msg) { + NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); - genlmsg_end(msg, hdr); - return genlmsg_reply(msg, info); + genlmsg_end(msg, hdr); + return genlmsg_reply(msg, info); + } + + return 0; nla_put_failure: err = -ENOBUFS; -- cgit v0.10.2 From 718897eb3f90a47a56acb504762d521388a3231c Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:27 +0100 Subject: brcm80211: fmac: remove unnecessary 4329 chip specific code 4329 with chiprev 0 can not be found on any product. The code can be removed. Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 6de489b..2c409ca 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -812,10 +812,6 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) clkreq = bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; - if ((bus->ci->chip == BCM4329_CHIP_ID) - && (bus->ci->chiprev == 0)) - clkreq |= SBSDIO_FORCE_ALP; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); if (err) { @@ -1034,11 +1030,9 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); /* Isolate the bus */ - if (bus->ci->chip != BCM4329_CHIP_ID) { - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, - SBSDIO_DEVCTL_PADS_ISO, NULL); - } + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, + SBSDIO_DEVICE_CTL, + SBSDIO_DEVCTL_PADS_ISO, NULL); /* Change state */ bus->sleeping = true; -- cgit v0.10.2 From a83369b6e1e7285edd5217601a0618b9a43bdc4b Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:28 +0100 Subject: brcm80211: fmac: move chip recognition function to sdio_chip.c Currently backplane handle code is scatterd around dhd_sdio.c which is not good for maintenance and adding new backplane interconnect type support. This patch and the follow up patches are going to abstract all chip backplane control code specific for sdio bus into this new sdio_chip.c Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/Makefile b/drivers/net/wireless/brcm80211/brcmfmac/Makefile index b44e309..d58aa1b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/Makefile +++ b/drivers/net/wireless/brcm80211/brcmfmac/Makefile @@ -26,7 +26,8 @@ DHDOFILES = \ dhd_sdio.o \ dhd_linux.o \ bcmsdh.o \ - bcmsdh_sdmmc.o + bcmsdh_sdmmc.o \ + sdio_chip.o obj-$(CONFIG_BRCMFMAC) += brcmfmac.o brcmfmac-objs += $(DHDOFILES) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h b/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h index d7d3afd..cecb5e5 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h @@ -18,13 +18,6 @@ #define _bcmchip_h_ /* bcm4329 */ -/* SDIO device core, ID 0x829 */ -#define BCM4329_CORE_BUS_BASE 0x18011000 -/* internal memory core, ID 0x80e */ -#define BCM4329_CORE_SOCRAM_BASE 0x18003000 -/* ARM Cortex M3 core, ID 0x82a */ -#define BCM4329_CORE_ARM_BASE 0x18002000 -#define BCM4329_RAMSIZE 0x48000 /* firmware name */ #define BCM4329_FW_NAME "brcm/bcm4329-fullmac-4.bin" #define BCM4329_NV_NAME "brcm/bcm4329-fullmac-4.txt" diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 2c409ca..e12e99b7 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -35,6 +35,7 @@ #include #include #include "sdio_host.h" +#include "sdio_chip.h" #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ @@ -367,18 +368,6 @@ struct rte_console { /* sbidlow */ #define SBIDL_INIT 0x80 /* initiator */ -/* sbidhigh */ -#define SBIDH_RC_MASK 0x000f /* revision code */ -#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ -#define SBIDH_RCE_SHIFT 8 -#define SBCOREREV(sbidh) \ - ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ - ((sbidh) & SBIDH_RC_MASK)) -#define SBIDH_CC_MASK 0x8ff0 /* core code */ -#define SBIDH_CC_SHIFT 4 -#define SBIDH_VC_MASK 0xffff0000 /* vendor code */ -#define SBIDH_VC_SHIFT 16 - /* * Conversion of 802.1D priority to precedence level */ @@ -388,17 +377,6 @@ static uint prio2prec(u32 prio) (prio^2) : prio; } -/* - * Core reg address translation. - * Both macro's returns a 32 bits byte address on the backplane bus. - */ -#define CORE_CC_REG(base, field) \ - (base + offsetof(struct chipcregs, field)) -#define CORE_BUS_REG(base, field) \ - (base + offsetof(struct sdpcmd_regs, field)) -#define CORE_SB(base, field) \ - (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) - /* core registers */ struct sdpcmd_regs { u32 corecontrol; /* 0x00, rev8 */ @@ -524,21 +502,6 @@ struct sdpcm_shared_le { /* misc chip info needed by some of the routines */ -struct chip_info { - u32 chip; - u32 chiprev; - u32 cccorebase; - u32 ccrev; - u32 cccaps; - u32 buscorebase; /* 32 bits backplane bus address */ - u32 buscorerev; - u32 buscoretype; - u32 ramcorebase; - u32 armcorebase; - u32 pmurev; - u32 ramsize; -}; - /* Private data for SDIO bus interaction */ struct brcmf_bus { struct brcmf_pub *drvr; @@ -663,46 +626,6 @@ struct brcmf_bus { u32 fw_ptr; }; -struct sbconfig { - u32 PAD[2]; - u32 sbipsflag; /* initiator port ocp slave flag */ - u32 PAD[3]; - u32 sbtpsflag; /* target port ocp slave flag */ - u32 PAD[11]; - u32 sbtmerrloga; /* (sonics >= 2.3) */ - u32 PAD; - u32 sbtmerrlog; /* (sonics >= 2.3) */ - u32 PAD[3]; - u32 sbadmatch3; /* address match3 */ - u32 PAD; - u32 sbadmatch2; /* address match2 */ - u32 PAD; - u32 sbadmatch1; /* address match1 */ - u32 PAD[7]; - u32 sbimstate; /* initiator agent state */ - u32 sbintvec; /* interrupt mask */ - u32 sbtmstatelow; /* target state */ - u32 sbtmstatehigh; /* target state */ - u32 sbbwa0; /* bandwidth allocation table0 */ - u32 PAD; - u32 sbimconfiglow; /* initiator configuration */ - u32 sbimconfighigh; /* initiator configuration */ - u32 sbadmatch0; /* address match0 */ - u32 PAD; - u32 sbtmconfiglow; /* target configuration */ - u32 sbtmconfighigh; /* target configuration */ - u32 sbbconfig; /* broadcast configuration */ - u32 PAD; - u32 sbbstate; /* broadcast state */ - u32 PAD[3]; - u32 sbactcnfg; /* activate configuration */ - u32 PAD[3]; - u32 sbflagst; /* current sbflags */ - u32 PAD[3]; - u32 sbidlow; /* identification */ - u32 sbidhigh; /* identification */ -}; - /* clkstate */ #define CLK_NONE 0 #define CLK_SDONLY 1 @@ -4083,62 +4006,6 @@ static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, } static int -brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, - struct chip_info *ci, u32 regs) -{ - u32 regdata; - - /* - * Get CC core rev - * Chipid is assume to be at offset 0 from regs arg - * For different chiptypes or old sdio hosts w/o chipcommon, - * other ways of recognition should be added here. - */ - ci->cccorebase = regs; - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, chipid), 4); - ci->chip = regdata & CID_ID_MASK; - ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; - - brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); - - /* Address of cores for new chips should be added here */ - switch (ci->chip) { - case BCM4329_CHIP_ID: - ci->buscorebase = BCM4329_CORE_BUS_BASE; - ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; - ci->armcorebase = BCM4329_CORE_ARM_BASE; - ci->ramsize = BCM4329_RAMSIZE; - break; - default: - brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); - return -ENODEV; - } - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->cccorebase, sbidhigh), 4); - ci->ccrev = SBCOREREV(regdata); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); - ci->pmurev = regdata & PCAP_REV_MASK; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->buscorebase, sbidhigh), 4); - ci->buscorerev = SBCOREREV(regdata); - ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; - - brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", - ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); - - /* get chipcommon capabilites */ - ci->cccaps = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, capabilities), 4); - - return 0; -} - -static int brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) { struct chip_info *ci; @@ -4196,7 +4063,7 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); - err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); + err = brcmf_sdio_chip_attach(bus->sdiodev, ci, regs); if (err) goto fail; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c new file mode 100644 index 0000000..7f01a9b --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +/* ***** SDIO interface chip backplane handle functions ***** */ + +#include +#include +#include +#include +#include +#include +#include +#include "dhd.h" +#include "dhd_dbg.h" +#include "sdio_host.h" +#include "sdio_chip.h" + +/* chip core base & ramsize */ +/* bcm4329 */ +/* SDIO device core, ID 0x829 */ +#define BCM4329_CORE_BUS_BASE 0x18011000 +/* internal memory core, ID 0x80e */ +#define BCM4329_CORE_SOCRAM_BASE 0x18003000 +/* ARM Cortex M3 core, ID 0x82a */ +#define BCM4329_CORE_ARM_BASE 0x18002000 +#define BCM4329_RAMSIZE 0x48000 + + +/* SB regs */ +/* sbidhigh */ +#define SBIDH_RC_MASK 0x000f /* revision code */ +#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ +#define SBIDH_RCE_SHIFT 8 +#define SBCOREREV(sbidh) \ + ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ + ((sbidh) & SBIDH_RC_MASK)) +#define SBIDH_CC_MASK 0x8ff0 /* core code */ +#define SBIDH_CC_SHIFT 4 +#define SBIDH_VC_MASK 0xffff0000 /* vendor code */ +#define SBIDH_VC_SHIFT 16 + +static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u32 regs) +{ + u32 regdata; + + /* + * Get CC core rev + * Chipid is assume to be at offset 0 from regs arg + * For different chiptypes or old sdio hosts w/o chipcommon, + * other ways of recognition should be added here. + */ + ci->cccorebase = regs; + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, chipid), 4); + ci->chip = regdata & CID_ID_MASK; + ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; + + brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); + + /* Address of cores for new chips should be added here */ + switch (ci->chip) { + case BCM4329_CHIP_ID: + ci->buscorebase = BCM4329_CORE_BUS_BASE; + ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; + ci->armcorebase = BCM4329_CORE_ARM_BASE; + ci->ramsize = BCM4329_RAMSIZE; + break; + default: + brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); + return -ENODEV; + } + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->cccorebase, sbidhigh), 4); + ci->ccrev = SBCOREREV(regdata); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); + ci->pmurev = regdata & PCAP_REV_MASK; + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->buscorebase, sbidhigh), 4); + ci->buscorerev = SBCOREREV(regdata); + ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; + + brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", + ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); + + /* get chipcommon capabilites */ + ci->cccaps = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, capabilities), 4); + + return 0; +} + +int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u32 regs) +{ + int ret = 0; + + ret = brcmf_sdio_chip_recognition(sdiodev, ci, regs); + if (ret != 0) + return ret; + + return ret; +} diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h new file mode 100644 index 0000000..9595186 --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _BRCMFMAC_SDIO_CHIP_H_ +#define _BRCMFMAC_SDIO_CHIP_H_ + +/* + * Core reg address translation. + * Both macro's returns a 32 bits byte address on the backplane bus. + */ +#define CORE_CC_REG(base, field) \ + (base + offsetof(struct chipcregs, field)) +#define CORE_BUS_REG(base, field) \ + (base + offsetof(struct sdpcmd_regs, field)) +#define CORE_SB(base, field) \ + (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) + +struct chip_info { + u32 chip; + u32 chiprev; + u32 cccorebase; + u32 ccrev; + u32 cccaps; + u32 buscorebase; /* 32 bits backplane bus address */ + u32 buscorerev; + u32 buscoretype; + u32 ramcorebase; + u32 armcorebase; + u32 pmurev; + u32 ramsize; +}; + +struct sbconfig { + u32 PAD[2]; + u32 sbipsflag; /* initiator port ocp slave flag */ + u32 PAD[3]; + u32 sbtpsflag; /* target port ocp slave flag */ + u32 PAD[11]; + u32 sbtmerrloga; /* (sonics >= 2.3) */ + u32 PAD; + u32 sbtmerrlog; /* (sonics >= 2.3) */ + u32 PAD[3]; + u32 sbadmatch3; /* address match3 */ + u32 PAD; + u32 sbadmatch2; /* address match2 */ + u32 PAD; + u32 sbadmatch1; /* address match1 */ + u32 PAD[7]; + u32 sbimstate; /* initiator agent state */ + u32 sbintvec; /* interrupt mask */ + u32 sbtmstatelow; /* target state */ + u32 sbtmstatehigh; /* target state */ + u32 sbbwa0; /* bandwidth allocation table0 */ + u32 PAD; + u32 sbimconfiglow; /* initiator configuration */ + u32 sbimconfighigh; /* initiator configuration */ + u32 sbadmatch0; /* address match0 */ + u32 PAD; + u32 sbtmconfiglow; /* target configuration */ + u32 sbtmconfighigh; /* target configuration */ + u32 sbbconfig; /* broadcast configuration */ + u32 PAD; + u32 sbbstate; /* broadcast state */ + u32 PAD[3]; + u32 sbactcnfg; /* activate configuration */ + u32 PAD[3]; + u32 sbflagst; /* current sbflags */ + u32 PAD[3]; + u32 sbidlow; /* identification */ + u32 sbidhigh; /* identification */ +}; + +extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u32 regs); + + +#endif /* _BRCMFMAC_SDIO_CHIP_H_ */ -- cgit v0.10.2 From e63ac6b888eed345f5b93751649515d6436abed2 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:29 +0100 Subject: brcm80211: fmac: move bus core prep code to sdio_chip.c This patch is part of abstracting chip backplane handle code series. Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index e12e99b7..9a78cc3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -135,33 +135,6 @@ struct rte_console { /* Force no backplane reset */ #define SBSDIO_DEVCTL_RST_NOBPRESET 0x20 -/* SBSDIO_FUNC1_CHIPCLKCSR */ - -/* Force ALP request to backplane */ -#define SBSDIO_FORCE_ALP 0x01 -/* Force HT request to backplane */ -#define SBSDIO_FORCE_HT 0x02 -/* Force ILP request to backplane */ -#define SBSDIO_FORCE_ILP 0x04 -/* Make ALP ready (power up xtal) */ -#define SBSDIO_ALP_AVAIL_REQ 0x08 -/* Make HT ready (power up PLL) */ -#define SBSDIO_HT_AVAIL_REQ 0x10 -/* Squelch clock requests from HW */ -#define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 -/* Status: ALP is ready */ -#define SBSDIO_ALP_AVAIL 0x40 -/* Status: HT is ready */ -#define SBSDIO_HT_AVAIL 0x80 - -#define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) -#define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) -#define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) -#define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) - -#define SBSDIO_CLKAV(regval, alponly) \ - (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) - /* direct(mapped) cis space */ /* MAPPED common CIS address */ @@ -4010,7 +3983,7 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) { struct chip_info *ci; int err; - u8 clkval, clkset; + u8 clkval; brcmf_dbg(TRACE, "Enter\n"); @@ -4019,50 +3992,6 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) if (NULL == ci) return -ENOMEM; - /* bus/core/clk setup for register access */ - /* Try forcing SDIO core to do ALPAvail request only */ - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); - if (err) { - brcmf_dbg(ERROR, "error writing for HT off\n"); - goto fail; - } - - /* If register supported, wait for ALPAvail and then force ALP */ - /* This may take up to 15 milliseconds */ - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, NULL); - if ((clkval & ~SBSDIO_AVBITS) == clkset) { - SPINWAIT(((clkval = - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - NULL)), - !SBSDIO_ALPAV(clkval)), - PMU_MAX_TRANSITION_DLY); - if (!SBSDIO_ALPAV(clkval)) { - brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", - clkval); - err = -EBUSY; - goto fail; - } - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | - SBSDIO_FORCE_ALP; - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, - clkset, &err); - udelay(65); - } else { - brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", - clkset, clkval); - err = -EACCES; - goto fail; - } - - /* Also, disable the extra SDIO pull-ups */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); - err = brcmf_sdio_chip_attach(bus->sdiodev, ci, regs); if (err) goto fail; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 7f01a9b..7bf9778 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -106,11 +106,63 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, return 0; } +static int +brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) +{ + int err = 0; + u8 clkval, clkset; + + /* Try forcing SDIO core to do ALPAvail request only */ + clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); + if (err) { + brcmf_dbg(ERROR, "error writing for HT off\n"); + return err; + } + + /* If register supported, wait for ALPAvail and then force ALP */ + /* This may take up to 15 milliseconds */ + clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, NULL); + + if ((clkval & ~SBSDIO_AVBITS) != clkset) { + brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", + clkset, clkval); + return -EACCES; + } + + SPINWAIT(((clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, NULL)), + !SBSDIO_ALPAV(clkval)), + PMU_MAX_TRANSITION_DLY); + if (!SBSDIO_ALPAV(clkval)) { + brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", + clkval); + return -EBUSY; + } + + clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_FORCE_ALP; + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); + udelay(65); + + /* Also, disable the extra SDIO pull-ups */ + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, + SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); + + return 0; +} + int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u32 regs) { int ret = 0; + ret = brcmf_sdio_chip_buscoreprep(sdiodev); + if (ret != 0) + return ret; + ret = brcmf_sdio_chip_recognition(sdiodev, ci, regs); if (ret != 0) return ret; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 9595186..2d75b8c5 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -28,6 +28,30 @@ #define CORE_SB(base, field) \ (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) +/* SDIO function 1 register CHIPCLKCSR */ +/* Force ALP request to backplane */ +#define SBSDIO_FORCE_ALP 0x01 +/* Force HT request to backplane */ +#define SBSDIO_FORCE_HT 0x02 +/* Force ILP request to backplane */ +#define SBSDIO_FORCE_ILP 0x04 +/* Make ALP ready (power up xtal) */ +#define SBSDIO_ALP_AVAIL_REQ 0x08 +/* Make HT ready (power up PLL) */ +#define SBSDIO_HT_AVAIL_REQ 0x10 +/* Squelch clock requests from HW */ +#define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 +/* Status: ALP is ready */ +#define SBSDIO_ALP_AVAIL 0x40 +/* Status: HT is ready */ +#define SBSDIO_HT_AVAIL 0x80 +#define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) +#define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) +#define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) +#define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) +#define SBSDIO_CLKAV(regval, alponly) \ + (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) + struct chip_info { u32 chip; u32 chiprev; -- cgit v0.10.2 From 5b45e54e77cc29a760461ca64cf143ffa49493b6 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:30 +0100 Subject: brcm80211: fmac: abstract chip buscore setup function This patch is part of the abstracting chip backplane handle code series. Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 7bf9778..1e01ae2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -83,26 +83,6 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, return -ENODEV; } - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->cccorebase, sbidhigh), 4); - ci->ccrev = SBCOREREV(regdata); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); - ci->pmurev = regdata & PCAP_REV_MASK; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->buscorebase, sbidhigh), 4); - ci->buscorerev = SBCOREREV(regdata); - ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; - - brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", - ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); - - /* get chipcommon capabilites */ - ci->cccaps = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, capabilities), 4); - return 0; } @@ -154,6 +134,37 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) return 0; } +static void +brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci) +{ + u32 regdata; + + /* get chipcommon rev */ + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->cccorebase, sbidhigh), 4); + ci->ccrev = SBCOREREV(regdata); + + /* get chipcommon capabilites */ + ci->cccaps = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, capabilities), 4); + + /* get pmu caps & rev */ + if (ci->cccaps & CC_CAP_PMU) { + ci->pmucaps = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); + ci->pmurev = ci->pmucaps & PCAP_REV_MASK; + } + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->buscorebase, sbidhigh), 4); + ci->buscorerev = SBCOREREV(regdata); + ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; + + brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", + ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); +} + int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u32 regs) { @@ -167,5 +178,7 @@ int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, if (ret != 0) return ret; + brcmf_sdio_chip_buscoresetup(sdiodev, ci); + return ret; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 2d75b8c5..1985e36 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -64,6 +64,7 @@ struct chip_info { u32 ramcorebase; u32 armcorebase; u32 pmurev; + u32 pmucaps; u32 ramsize; }; -- cgit v0.10.2 From 2d4a9af172814b76bf2ad5da2213ea42d111893b Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:31 +0100 Subject: brcm80211: fmac: move core disable function to sdio_chip.c This patch is part of the abstracting chip backplane handle code series. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 9a78cc3..af0d5c9 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -309,38 +309,6 @@ struct rte_console { /* Flags for SDH calls */ #define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED) -/* sbimstate */ -#define SBIM_IBE 0x20000 /* inbanderror */ -#define SBIM_TO 0x40000 /* timeout */ -#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */ -#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */ - -/* sbtmstatelow */ - -/* reset */ -#define SBTML_RESET 0x0001 -/* reject field */ -#define SBTML_REJ_MASK 0x0006 -/* reject */ -#define SBTML_REJ 0x0002 -/* temporary reject, for error recovery */ -#define SBTML_TMPREJ 0x0004 - -/* Shift to locate the SI control flags in sbtml */ -#define SBTML_SICF_SHIFT 16 - -/* sbtmstatehigh */ -#define SBTMH_SERR 0x0001 /* serror */ -#define SBTMH_INT 0x0002 /* interrupt */ -#define SBTMH_BUSY 0x0004 /* busy */ -#define SBTMH_TO 0x0020 /* timeout (sonics >= 2.3) */ - -/* Shift to locate the SI status flags in sbtmh */ -#define SBTMH_SISF_SHIFT 16 - -/* sbidlow */ -#define SBIDL_INIT 0x80 /* initiator */ - /* * Conversion of 802.1D priority to precedence level */ @@ -3123,85 +3091,6 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) } static void -brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) -{ - u32 regdata; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - if (regdata & SBTML_RESET) - return; - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { - /* - * set target reject and spin until busy is clear - * (preserve core-specific bits) - */ - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), - 4, regdata | SBTML_REJ); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4) & - SBTMH_BUSY), 100000); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_BUSY) - brcmf_dbg(ERROR, "ARM core still busy\n"); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) | - SBIM_RJ; - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, - regdata); - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); - udelay(1); - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & - SBIM_BY), 100000); - } - - /* set reset and reject while enabling the clocks */ - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4, - (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_REJ | SBTML_RESET)); - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - udelay(10); - - /* clear the initiator reject bit */ - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & - ~SBIM_RJ; - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, - regdata); - } - } - - /* leave reset and reject asserted */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SBTML_REJ | SBTML_RESET)); - udelay(1); -} - -static void brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) { u32 regdata; @@ -3210,7 +3099,7 @@ brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) * Must do the disable sequence first to work for * arbitrary current core state. */ - brcmf_sdbrcm_chip_disablecore(sdiodev, corebase); + brcmf_sdio_chip_coredisable(sdiodev, corebase); /* * Now do the initialization sequence. @@ -3258,7 +3147,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) if (enter) { bus->alp_only = true; - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, + brcmf_sdio_chip_coredisable(bus->sdiodev, bus->ci->armcorebase); brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); @@ -4000,7 +3889,7 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) * Make sure any on-chip ARM is off (in case strapping is wrong), * or downloaded code was already running. */ - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, ci->armcorebase); + brcmf_sdio_chip_coredisable(bus->sdiodev, ci->armcorebase); brcmf_sdcard_reg_write(bus->sdiodev, CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 1e01ae2..f198a48 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "dhd.h" #include "dhd_dbg.h" #include "sdio_host.h" @@ -51,6 +52,85 @@ #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ #define SBIDH_VC_SHIFT 16 +void +brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) +{ + u32 regdata; + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + if (regdata & SBTML_RESET) + return; + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { + /* + * set target reject and spin until busy is clear + * (preserve core-specific bits) + */ + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), + 4, regdata | SBTML_REJ); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + udelay(1); + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4) & + SBTMH_BUSY), 100000); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4); + if (regdata & SBTMH_BUSY) + brcmf_dbg(ERROR, "core state still busy\n"); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbidlow), 4); + if (regdata & SBIDL_INIT) { + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4) | + SBIM_RJ; + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbimstate), 4, + regdata); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4); + udelay(1); + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4) & + SBIM_BY), 100000); + } + + /* set reset and reject while enabling the clocks */ + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4, + (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | + SBTML_REJ | SBTML_RESET)); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + udelay(10); + + /* clear the initiator reject bit */ + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbidlow), 4); + if (regdata & SBIDL_INIT) { + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4) & + ~SBIM_RJ; + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbimstate), 4, + regdata); + } + } + + /* leave reset and reject asserted */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + (SBTML_REJ | SBTML_RESET)); + udelay(1); +} + static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u32 regs) { diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 1985e36..17007bd 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -52,6 +52,31 @@ #define SBSDIO_CLKAV(regval, alponly) \ (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) +/* sbimstate */ +#define SBIM_IBE 0x20000 /* inbanderror */ +#define SBIM_TO 0x40000 /* timeout */ +#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */ +#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */ + +/* sbtmstatelow */ +#define SBTML_RESET 0x0001 /* reset */ +#define SBTML_REJ_MASK 0x0006 /* reject field */ +#define SBTML_REJ 0x0002 /* reject */ +#define SBTML_TMPREJ 0x0004 /* temporary reject(error recovery) */ +/* Shift to locate the SI control flags in sbtml */ +#define SBTML_SICF_SHIFT 16 + +/* sbtmstatehigh */ +#define SBTMH_SERR 0x0001 /* serror */ +#define SBTMH_INT 0x0002 /* interrupt */ +#define SBTMH_BUSY 0x0004 /* busy */ +#define SBTMH_TO 0x0020 /* timeout (sonics >= 2.3) */ +/* Shift to locate the SI status flags in sbtmh */ +#define SBTMH_SISF_SHIFT 16 + +/* sbidlow */ +#define SBIDL_INIT 0x80 /* initiator */ + struct chip_info { u32 chip; u32 chiprev; @@ -108,6 +133,9 @@ struct sbconfig { u32 sbidhigh; /* identification */ }; + +extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, + u32 corebase); extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u32 regs); -- cgit v0.10.2 From 966414da2d5a0c957d331e3f06255ec2277acb65 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:32 +0100 Subject: brcm80211: fmac: disable dongle arm core in bus core setup function This will provide a better code flow that fits the logic Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index af0d5c9..c98986f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3885,12 +3885,6 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) if (err) goto fail; - /* - * Make sure any on-chip ARM is off (in case strapping is wrong), - * or downloaded code was already running. - */ - brcmf_sdio_chip_coredisable(bus->sdiodev, ci->armcorebase); - brcmf_sdcard_reg_write(bus->sdiodev, CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); brcmf_sdcard_reg_write(bus->sdiodev, diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index f198a48..486f145 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -243,6 +243,12 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); + + /* + * Make sure any on-chip ARM is off (in case strapping is wrong), + * or downloaded code was already running. + */ + brcmf_sdio_chip_coredisable(sdiodev, ci->armcorebase); } int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, -- cgit v0.10.2 From 960908dceabf40d7335170d26dbf13f63b240c67 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:33 +0100 Subject: brcm80211: fmac: move dongle gpio reset code to chip attach function This patch is part of the abstracting chip backplane handle code series. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index c98986f..30187c1 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3885,11 +3885,6 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) if (err) goto fail; - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); - /* Disable F2 to clear any intermediate frame state on the dongle */ brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 486f145..002157f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -266,5 +266,10 @@ int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, brcmf_sdio_chip_buscoresetup(sdiodev, ci); + brcmf_sdcard_reg_write(sdiodev, + CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); + brcmf_sdcard_reg_write(sdiodev, + CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); + return ret; } -- cgit v0.10.2 From 98ce903519b4874673e75ba80657c4114b933bac Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:34 +0100 Subject: brcm80211: fmac: remove duplicate regiter set in chip attach path Same register writes have been done in brcmf_sdbrcm_probe_init which is earlier in the same code path. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 30187c1..5e7b70e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3872,7 +3872,6 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) { struct chip_info *ci; int err; - u8 clkval; brcmf_dbg(TRACE, "Enter\n"); @@ -3885,18 +3884,6 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) if (err) goto fail; - /* Disable F2 to clear any intermediate frame state on the dongle */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, - SDIO_FUNC_ENABLE_1, NULL); - - /* WAR: cmd52 backplane read so core HW will drop ALPReq */ - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, - 0, NULL); - - /* Done with backplane-dependent accesses, can drop clock... */ - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); - bus->ci = ci; return 0; fail: -- cgit v0.10.2 From a97e4fc5ae4b00187b25a8216a61b2105efa9c60 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:35 +0100 Subject: brcm80211: fmac: chip attach code flow clean up Merged brcmf_sdbrcm_chip_attach into brcmf_sdio_chip_attach for better readability. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 5e7b70e..868cb9d 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3867,31 +3867,6 @@ static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, } } -static int -brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) -{ - struct chip_info *ci; - int err; - - brcmf_dbg(TRACE, "Enter\n"); - - /* alloc chip_info_t */ - ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); - if (NULL == ci) - return -ENOMEM; - - err = brcmf_sdio_chip_attach(bus->sdiodev, ci, regs); - if (err) - goto fail; - - bus->ci = ci; - return 0; -fail: - bus->ci = NULL; - kfree(ci); - return err; -} - static bool brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) { @@ -3913,7 +3888,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) #endif /* BCMDBG */ /* - * Force PLL off until brcmf_sdbrcm_chip_attach() + * Force PLL off until brcmf_sdio_chip_attach() * programs PLL control regs */ @@ -3931,8 +3906,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) goto fail; } - if (brcmf_sdbrcm_chip_attach(bus, regsva)) { - brcmf_dbg(ERROR, "brcmf_sdbrcm_chip_attach failed!\n"); + if (brcmf_sdio_chip_attach(bus->sdiodev, &bus->ci, regsva)) { + brcmf_dbg(ERROR, "brcmf_sdio_chip_attach failed!\n"); goto fail; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 002157f..10befbf 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -252,17 +252,25 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, } int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, - struct chip_info *ci, u32 regs) + struct chip_info **ci_ptr, u32 regs) { - int ret = 0; + int ret; + struct chip_info *ci; + + brcmf_dbg(TRACE, "Enter\n"); + + /* alloc chip_info_t */ + ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); + if (!ci) + return -ENOMEM; ret = brcmf_sdio_chip_buscoreprep(sdiodev); if (ret != 0) - return ret; + goto err; ret = brcmf_sdio_chip_recognition(sdiodev, ci, regs); if (ret != 0) - return ret; + goto err; brcmf_sdio_chip_buscoresetup(sdiodev, ci); @@ -271,5 +279,10 @@ int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, brcmf_sdcard_reg_write(sdiodev, CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); + *ci_ptr = ci; + return 0; + +err: + kfree(ci); return ret; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 17007bd..25ac385 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -137,7 +137,6 @@ struct sbconfig { extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase); extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, - struct chip_info *ci, u32 regs); - + struct chip_info **ci_ptr, u32 regs); #endif /* _BRCMFMAC_SDIO_CHIP_H_ */ -- cgit v0.10.2 From d8f64a425b3a79e7d276e438ad7246c916a4b195 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:36 +0100 Subject: brcm80211: fmac: abstract chip iscoreup function Prepare for adding backplane interconnect type support Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 868cb9d..30802a0 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3138,7 +3138,6 @@ brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) { uint retries; - u32 regdata; int bcmerror = 0; /* To enter download state, disable ARM and reset SOCRAM. @@ -3159,11 +3158,8 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) (u8 *)&zeros, 4); } } else { - regdata = brcmf_sdcard_reg_read(bus->sdiodev, - CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); - regdata &= (SBTML_RESET | SBTML_REJ_MASK | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) { + if (!brcmf_sdio_chip_iscoreup(bus->sdiodev, + bus->ci->ramcorebase)) { brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); bcmerror = -EBADE; goto fail; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 10befbf..e0c22c4 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -52,6 +52,19 @@ #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ #define SBIDH_VC_SHIFT 16 +bool +brcmf_sdio_chip_iscoreup(struct brcmf_sdio_dev *sdiodev, + u32 corebase) +{ + u32 regdata; + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatelow), 4); + regdata &= (SBTML_RESET | SBTML_REJ_MASK | + (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + return ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) == regdata); +} + void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) { diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 25ac385..9c43e1d 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -133,7 +133,8 @@ struct sbconfig { u32 sbidhigh; /* identification */ }; - +extern bool brcmf_sdio_chip_iscoreup(struct brcmf_sdio_dev *sdiodev, + u32 corebase); extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase); extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, -- cgit v0.10.2 From 454d2a8816d6bc6594d3d475392290623af63656 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:37 +0100 Subject: brcm80211: fmac: abstract chip core revision function Prepare for adding backplane interconnect type support Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 30802a0..84b10f1 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3914,9 +3914,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) brcmf_sdbrcm_sdiod_drive_strength_init(bus, SDIO_DRIVE_STRENGTH); - /* Get info on the ARM and SOCRAM cores... */ - brcmf_sdcard_reg_read(bus->sdiodev, - CORE_SB(bus->ci->armcorebase, sbidhigh), 4); + /* Get info on the SOCRAM cores... */ bus->ramsize = bus->ci->ramsize; if (!(bus->ramsize)) { brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index e0c22c4..5d788a6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -52,6 +52,17 @@ #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ #define SBIDH_VC_SHIFT 16 +static u32 +brcmf_sdio_chip_corerev(struct brcmf_sdio_dev *sdiodev, + u32 corebase) +{ + u32 regdata; + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbidhigh), 4); + return SBCOREREV(regdata); +} + bool brcmf_sdio_chip_iscoreup(struct brcmf_sdio_dev *sdiodev, u32 corebase) @@ -234,9 +245,7 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, u32 regdata; /* get chipcommon rev */ - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->cccorebase, sbidhigh), 4); - ci->ccrev = SBCOREREV(regdata); + ci->ccrev = brcmf_sdio_chip_corerev(sdiodev, ci->cccorebase); /* get chipcommon capabilites */ ci->cccaps = brcmf_sdcard_reg_read(sdiodev, @@ -249,9 +258,10 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, ci->pmurev = ci->pmucaps & PCAP_REV_MASK; } + + ci->buscorerev = brcmf_sdio_chip_corerev(sdiodev, ci->buscorebase); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(ci->buscorebase, sbidhigh), 4); - ci->buscorerev = SBCOREREV(regdata); ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", -- cgit v0.10.2 From 2bc78e10d841f81ea7a2b25bc0481ea4af06437e Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:38 +0100 Subject: brcm80211: fmac: move chip reset core function to sdio_chip.c This patch is part of the abstracting chip backplane handle code series. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 84b10f1..af6f3a4 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3090,51 +3090,6 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) return bcmerror; } -static void -brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) -{ - u32 regdata; - - /* - * Must do the disable sequence first to work for - * arbitrary current core state. - */ - brcmf_sdio_chip_coredisable(sdiodev, corebase); - - /* - * Now do the initialization sequence. - * set reset while enabling the clock and - * forcing them on throughout the core - */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_RESET); - udelay(1); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_SERR) - brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4, 0); - - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); - if (regdata & (SBIM_IBE | SBIM_TO)) - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, - regdata & ~(SBIM_IBE | SBIM_TO)); - - /* clear reset and allow it to propagate throughout the core */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_FGC << SBTML_SICF_SHIFT) | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - udelay(1); - - /* leave clock enabled */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - udelay(1); -} - static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) { uint retries; @@ -3149,7 +3104,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) brcmf_sdio_chip_coredisable(bus->sdiodev, bus->ci->armcorebase); - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); + brcmf_sdio_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); /* Clear the top bit of memory */ if (bus->ramsize) { @@ -3174,7 +3129,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) w_sdreg32(bus, 0xFFFFFFFF, offsetof(struct sdpcmd_regs, intstatus), &retries); - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); + brcmf_sdio_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); /* Allow HT Clock now that the ARM is running. */ bus->alp_only = false; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 5d788a6..4acdda1 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -155,6 +155,51 @@ brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) udelay(1); } +void +brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) +{ + u32 regdata; + + /* + * Must do the disable sequence first to work for + * arbitrary current core state. + */ + brcmf_sdio_chip_coredisable(sdiodev, corebase); + + /* + * Now do the initialization sequence. + * set reset while enabling the clock and + * forcing them on throughout the core + */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | + SBTML_RESET); + udelay(1); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4); + if (regdata & SBTMH_SERR) + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(corebase, sbtmstatehigh), 4, 0); + + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(corebase, sbimstate), 4); + if (regdata & (SBIM_IBE | SBIM_TO)) + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, + regdata & ~(SBIM_IBE | SBIM_TO)); + + /* clear reset and allow it to propagate throughout the core */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + (SICF_FGC << SBTML_SICF_SHIFT) | + (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + udelay(1); + + /* leave clock enabled */ + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + udelay(1); +} + static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u32 regs) { diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 9c43e1d..6ad5ea6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -133,6 +133,8 @@ struct sbconfig { u32 sbidhigh; /* identification */ }; +extern void brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, + u32 corebase); extern bool brcmf_sdio_chip_iscoreup(struct brcmf_sdio_dev *sdiodev, u32 corebase); extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, -- cgit v0.10.2 From a8a6c04586233e12551552c292797cb56b31dade Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:39 +0100 Subject: brcm80211: fmac: move chip detach function to sdio_chip.c This patch is part of the abstracting chip backplane handle code series. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index af6f3a4..e05c784 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3967,15 +3967,6 @@ brcmf_sdbrcm_watchdog(unsigned long data) } } -static void -brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus) -{ - brcmf_dbg(TRACE, "Enter\n"); - - kfree(bus->ci); - bus->ci = NULL; -} - static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) { brcmf_dbg(TRACE, "Enter\n"); @@ -3983,7 +3974,7 @@ static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) if (bus->ci) { brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); - brcmf_sdbrcm_chip_detach(bus); + brcmf_sdio_chip_detach(&bus->ci); if (bus->vars && bus->varsz) kfree(bus->vars); bus->vars = NULL; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 4acdda1..ea12a4c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -354,3 +354,12 @@ err: kfree(ci); return ret; } + +void +brcmf_sdio_chip_detach(struct chip_info **ci_ptr) +{ + brcmf_dbg(TRACE, "Enter\n"); + + kfree(*ci_ptr); + *ci_ptr = NULL; +} diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 6ad5ea6..13b09a4 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -141,5 +141,6 @@ extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase); extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, struct chip_info **ci_ptr, u32 regs); +extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); #endif /* _BRCMFMAC_SDIO_CHIP_H_ */ -- cgit v0.10.2 From e12afb6c5d13ebff64d4a2feb97cce0c2d7e1128 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:40 +0100 Subject: brcm80211: fmac: move chip drive strength related code to sdio_chip.c This patch is part of the abstracting chip backplane handle code series. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index e05c784..d45fa32a 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3704,120 +3704,6 @@ fail: return false; } -/* SDIO Pad drive strength to select value mappings */ -struct sdiod_drive_str { - u8 strength; /* Pad Drive Strength in mA */ - u8 sel; /* Chip-specific select value */ -}; - -/* SDIO Drive Strength to sel value table for PMU Rev 1 */ -static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { - { - 4, 0x2}, { - 2, 0x3}, { - 1, 0x0}, { - 0, 0x0} - }; - -/* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ -static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { - { - 12, 0x7}, { - 10, 0x6}, { - 8, 0x5}, { - 6, 0x4}, { - 4, 0x2}, { - 2, 0x1}, { - 0, 0x0} - }; - -/* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ -static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { - { - 32, 0x7}, { - 26, 0x6}, { - 22, 0x5}, { - 16, 0x4}, { - 12, 0x3}, { - 8, 0x2}, { - 4, 0x1}, { - 0, 0x0} - }; - -#define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) - -static char *brcmf_chipname(uint chipid, char *buf, uint len) -{ - const char *fmt; - - fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; - snprintf(buf, len, fmt, chipid); - return buf; -} - -static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, - u32 drivestrength) { - struct sdiod_drive_str *str_tab = NULL; - u32 str_mask = 0; - u32 str_shift = 0; - char chn[8]; - - if (!(bus->ci->cccaps & CC_CAP_PMU)) - return; - - switch (SDIOD_DRVSTR_KEY(bus->ci->chip, bus->ci->pmurev)) { - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; - str_mask = 0x30000000; - str_shift = 28; - break; - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; - str_mask = 0x00003800; - str_shift = 11; - break; - case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; - str_mask = 0x00003800; - str_shift = 11; - break; - default: - brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", - brcmf_chipname(bus->ci->chip, chn, 8), - bus->ci->chiprev, bus->ci->pmurev); - break; - } - - if (str_tab != NULL) { - u32 drivestrength_sel = 0; - u32 cc_data_temp; - int i; - - for (i = 0; str_tab[i].strength != 0; i++) { - if (drivestrength >= str_tab[i].strength) { - drivestrength_sel = str_tab[i].sel; - break; - } - } - - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), - 4, 1); - cc_data_temp = brcmf_sdcard_reg_read(bus->sdiodev, - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4); - cc_data_temp &= ~str_mask; - drivestrength_sel <<= str_shift; - cc_data_temp |= drivestrength_sel; - brcmf_sdcard_reg_write(bus->sdiodev, - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), - 4, cc_data_temp); - - brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", - drivestrength, cc_data_temp); - } -} - static bool brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) { @@ -3867,7 +3753,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) goto fail; } - brcmf_sdbrcm_sdiod_drive_strength_init(bus, SDIO_DRIVE_STRENGTH); + brcmf_sdio_chip_drivestrengthinit(bus->sdiodev, bus->ci, + SDIO_DRIVE_STRENGTH); /* Get info on the SOCRAM cores... */ bus->ramsize = bus->ci->ramsize; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index ea12a4c..e068107 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -52,6 +52,44 @@ #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ #define SBIDH_VC_SHIFT 16 +#define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) +/* SDIO Pad drive strength to select value mappings */ +struct sdiod_drive_str { + u8 strength; /* Pad Drive Strength in mA */ + u8 sel; /* Chip-specific select value */ +}; +/* SDIO Drive Strength to sel value table for PMU Rev 1 */ +static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { + { + 4, 0x2}, { + 2, 0x3}, { + 1, 0x0}, { + 0, 0x0} + }; +/* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ +static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { + { + 12, 0x7}, { + 10, 0x6}, { + 8, 0x5}, { + 6, 0x4}, { + 4, 0x2}, { + 2, 0x1}, { + 0, 0x0} + }; +/* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ +static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { + { + 32, 0x7}, { + 26, 0x6}, { + 22, 0x5}, { + 16, 0x4}, { + 12, 0x3}, { + 8, 0x2}, { + 4, 0x1}, { + 0, 0x0} + }; + static u32 brcmf_sdio_chip_corerev(struct brcmf_sdio_dev *sdiodev, u32 corebase) @@ -363,3 +401,77 @@ brcmf_sdio_chip_detach(struct chip_info **ci_ptr) kfree(*ci_ptr); *ci_ptr = NULL; } + +static char *brcmf_sdio_chip_name(uint chipid, char *buf, uint len) +{ + const char *fmt; + + fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; + snprintf(buf, len, fmt, chipid); + return buf; +} + +void +brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u32 drivestrength) +{ + struct sdiod_drive_str *str_tab = NULL; + u32 str_mask = 0; + u32 str_shift = 0; + char chn[8]; + + if (!(ci->cccaps & CC_CAP_PMU)) + return; + + switch (SDIOD_DRVSTR_KEY(ci->chip, ci->pmurev)) { + case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): + str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; + str_mask = 0x30000000; + str_shift = 28; + break; + case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): + case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): + str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; + str_mask = 0x00003800; + str_shift = 11; + break; + case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): + str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; + str_mask = 0x00003800; + str_shift = 11; + break; + default: + brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", + brcmf_sdio_chip_name(ci->chip, chn, 8), + ci->chiprev, ci->pmurev); + break; + } + + if (str_tab != NULL) { + u32 drivestrength_sel = 0; + u32 cc_data_temp; + int i; + + for (i = 0; str_tab[i].strength != 0; i++) { + if (drivestrength >= str_tab[i].strength) { + drivestrength_sel = str_tab[i].sel; + break; + } + } + + brcmf_sdcard_reg_write(sdiodev, + CORE_CC_REG(ci->cccorebase, chipcontrol_addr), + 4, 1); + cc_data_temp = brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->cccorebase, chipcontrol_addr), 4); + cc_data_temp &= ~str_mask; + drivestrength_sel <<= str_shift; + cc_data_temp |= drivestrength_sel; + brcmf_sdcard_reg_write(sdiodev, + CORE_CC_REG(ci->cccorebase, chipcontrol_addr), + 4, cc_data_temp); + + brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", + drivestrength, cc_data_temp); + } +} diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 13b09a4..e816bb6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -142,5 +142,8 @@ extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, struct chip_info **ci_ptr, u32 regs); extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); +extern void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, + u32 drivestrength); #endif /* _BRCMFMAC_SDIO_CHIP_H_ */ -- cgit v0.10.2 From 61213be4cc2201b58786464000113ecbfc9d2c99 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:41 +0100 Subject: brcm80211: fmac: replace private SB macros with ssb_regs version Use SSB macros in order to clean up brcmfmac code Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index e068107..62c4621 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -18,6 +18,8 @@ #include #include #include +#include + #include #include #include @@ -38,19 +40,9 @@ #define BCM4329_CORE_ARM_BASE 0x18002000 #define BCM4329_RAMSIZE 0x48000 - -/* SB regs */ -/* sbidhigh */ -#define SBIDH_RC_MASK 0x000f /* revision code */ -#define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ -#define SBIDH_RCE_SHIFT 8 #define SBCOREREV(sbidh) \ - ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ - ((sbidh) & SBIDH_RC_MASK)) -#define SBIDH_CC_MASK 0x8ff0 /* core code */ -#define SBIDH_CC_SHIFT 4 -#define SBIDH_VC_MASK 0xffff0000 /* vendor code */ -#define SBIDH_VC_SHIFT 16 + ((((sbidh) & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT) | \ + ((sbidh) & SSB_IDHIGH_RCLO)) #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) /* SDIO Pad drive strength to select value mappings */ @@ -109,9 +101,9 @@ brcmf_sdio_chip_iscoreup(struct brcmf_sdio_dev *sdiodev, regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); - regdata &= (SBTML_RESET | SBTML_REJ_MASK | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); - return ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) == regdata); + regdata &= (SSB_TMSLOW_RESET | SSB_TMSLOW_REJECT | + SSB_IMSTATE_REJECT | SSB_TMSLOW_CLOCK); + return (SSB_TMSLOW_CLOCK == regdata); } void @@ -121,12 +113,12 @@ brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); - if (regdata & SBTML_RESET) + if (regdata & SSB_TMSLOW_RESET) return; regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); - if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { + if ((regdata & SSB_TMSLOW_CLOCK) != 0) { /* * set target reject and spin until busy is clear * (preserve core-specific bits) @@ -134,26 +126,26 @@ brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), - 4, regdata | SBTML_REJ); + 4, regdata | SSB_TMSLOW_REJECT); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); udelay(1); SPINWAIT((brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatehigh), 4) & - SBTMH_BUSY), 100000); + SSB_TMSHIGH_BUSY), 100000); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_BUSY) + if (regdata & SSB_TMSHIGH_BUSY) brcmf_dbg(ERROR, "core state still busy\n"); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { + if (regdata & SSB_IDLOW_INITIATOR) { regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4) | - SBIM_RJ; + SSB_IMSTATE_REJECT; brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, regdata); @@ -162,14 +154,14 @@ brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) udelay(1); SPINWAIT((brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4) & - SBIM_BY), 100000); + SSB_IMSTATE_BUSY), 100000); } /* set reset and reject while enabling the clocks */ brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_REJ | SBTML_RESET)); + (SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | + SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatelow), 4); udelay(10); @@ -177,10 +169,10 @@ brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) /* clear the initiator reject bit */ regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbidlow), 4); - if (regdata & SBIDL_INIT) { + if (regdata & SSB_IDLOW_INITIATOR) { regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4) & - ~SBIM_RJ; + ~SSB_IMSTATE_REJECT; brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, regdata); @@ -189,7 +181,7 @@ brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) /* leave reset and reject asserted */ brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SBTML_REJ | SBTML_RESET)); + (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); udelay(1); } @@ -210,31 +202,29 @@ brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) * forcing them on throughout the core */ brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | - SBTML_RESET); + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET); udelay(1); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbtmstatehigh), 4); - if (regdata & SBTMH_SERR) + if (regdata & SSB_TMSHIGH_SERR) brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatehigh), 4, 0); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(corebase, sbimstate), 4); - if (regdata & (SBIM_IBE | SBIM_TO)) + if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO)) brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, - regdata & ~(SBIM_IBE | SBIM_TO)); + regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO)); /* clear reset and allow it to propagate throughout the core */ brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_FGC << SBTML_SICF_SHIFT) | - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK); udelay(1); /* leave clock enabled */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); + brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), + 4, SSB_TMSLOW_CLOCK); udelay(1); } @@ -345,7 +335,7 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, ci->buscorerev = brcmf_sdio_chip_corerev(sdiodev, ci->buscorebase); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(ci->buscorebase, sbidhigh), 4); - ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; + ci->buscoretype = (regdata & SSB_IDHIGH_CC) >> SSB_IDHIGH_CC_SHIFT; brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index e816bb6..6383746 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -52,31 +52,6 @@ #define SBSDIO_CLKAV(regval, alponly) \ (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) -/* sbimstate */ -#define SBIM_IBE 0x20000 /* inbanderror */ -#define SBIM_TO 0x40000 /* timeout */ -#define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */ -#define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */ - -/* sbtmstatelow */ -#define SBTML_RESET 0x0001 /* reset */ -#define SBTML_REJ_MASK 0x0006 /* reject field */ -#define SBTML_REJ 0x0002 /* reject */ -#define SBTML_TMPREJ 0x0004 /* temporary reject(error recovery) */ -/* Shift to locate the SI control flags in sbtml */ -#define SBTML_SICF_SHIFT 16 - -/* sbtmstatehigh */ -#define SBTMH_SERR 0x0001 /* serror */ -#define SBTMH_INT 0x0002 /* interrupt */ -#define SBTMH_BUSY 0x0004 /* busy */ -#define SBTMH_TO 0x0020 /* timeout (sonics >= 2.3) */ -/* Shift to locate the SI status flags in sbtmh */ -#define SBTMH_SISF_SHIFT 16 - -/* sbidlow */ -#define SBIDL_INIT 0x80 /* initiator */ - struct chip_info { u32 chip; u32 chiprev; -- cgit v0.10.2 From 99ba15cd75ed22e4ae86804ca2982a724e8102c2 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Fri, 4 Nov 2011 22:23:42 +0100 Subject: brcm80211: fmac: optimize chip core info management Prepare for adding backplane interconnect type support Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index d45fa32a..43b4496 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -614,10 +615,12 @@ static bool data_ok(struct brcmf_bus *bus) static void r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) { + u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); *retryvar = 0; do { *regvar = brcmf_sdcard_reg_read(bus->sdiodev, - bus->ci->buscorebase + reg_offset, sizeof(u32)); + bus->ci->c_inf[idx].base + reg_offset, + sizeof(u32)); } while (brcmf_sdcard_regfail(bus->sdiodev) && (++(*retryvar) <= retry_limit)); if (*retryvar) { @@ -632,10 +635,11 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) static void w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) { + u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); *retryvar = 0; do { brcmf_sdcard_reg_write(bus->sdiodev, - bus->ci->buscorebase + reg_offset, + bus->ci->c_inf[idx].base + reg_offset, sizeof(u32), regval); } while (brcmf_sdcard_regfail(bus->sdiodev) && (++(*retryvar) <= retry_limit)); @@ -683,8 +687,8 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) return -EBADE; } - if (pendok && ((bus->ci->buscoretype == PCMCIA_CORE_ID) - && (bus->ci->buscorerev == 9))) { + if (pendok && ((bus->ci->c_inf[1].id == PCMCIA_CORE_ID) + && (bus->ci->c_inf[1].rev == 9))) { u32 dummy, retries; r_sdreg32(bus, &dummy, offsetof(struct sdpcmd_regs, clockctlstatus), @@ -909,8 +913,8 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) /* Force pad isolation off if possible (in case power never toggled) */ - if ((bus->ci->buscoretype == PCMCIA_CORE_ID) - && (bus->ci->buscorerev >= 10)) + if ((bus->ci->c_inf[1].id == PCMCIA_CORE_ID) + && (bus->ci->c_inf[1].rev >= 10)) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, 0, NULL); @@ -3094,6 +3098,8 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) { uint retries; int bcmerror = 0; + u8 idx; + struct chip_info *ci = bus->ci; /* To enter download state, disable ARM and reset SOCRAM. * To exit download state, simply reset ARM (default is RAM boot). @@ -3101,10 +3107,11 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) if (enter) { bus->alp_only = true; - brcmf_sdio_chip_coredisable(bus->sdiodev, - bus->ci->armcorebase); + idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3); + brcmf_sdio_chip_coredisable(bus->sdiodev, ci->c_inf[idx].base); - brcmf_sdio_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); + idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_INTERNAL_MEM); + brcmf_sdio_chip_resetcore(bus->sdiodev, ci->c_inf[idx].base); /* Clear the top bit of memory */ if (bus->ramsize) { @@ -3113,8 +3120,9 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) (u8 *)&zeros, 4); } } else { + idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_INTERNAL_MEM); if (!brcmf_sdio_chip_iscoreup(bus->sdiodev, - bus->ci->ramcorebase)) { + ci->c_inf[idx].base)) { brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); bcmerror = -EBADE; goto fail; @@ -3129,7 +3137,8 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) w_sdreg32(bus, 0xFFFFFFFF, offsetof(struct sdpcmd_regs, intstatus), &retries); - brcmf_sdio_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); + idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3); + brcmf_sdio_chip_resetcore(bus->sdiodev, ci->c_inf[idx].base); /* Allow HT Clock now that the ARM is running. */ bus->alp_only = false; @@ -3711,6 +3720,7 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) int err = 0; int reg_addr; u32 reg_val; + u8 idx; bus->alp_only = true; @@ -3764,7 +3774,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) } /* Set core control so an SDIO reset does a backplane reset */ - reg_addr = bus->ci->buscorebase + + idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); + reg_addr = bus->ci->c_inf[idx].base + offsetof(struct sdpcmd_regs, corecontrol); reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 62c4621..99d00dd 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -82,6 +83,18 @@ static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { 0, 0x0} }; +u8 +brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid) +{ + u8 idx; + + for (idx = 0; idx < BRCMF_MAX_CORENUM; idx++) + if (coreid == ci->c_inf[idx].id) + return idx; + + return BRCMF_MAX_CORENUM; +} + static u32 brcmf_sdio_chip_corerev(struct brcmf_sdio_dev *sdiodev, u32 corebase) @@ -239,9 +252,10 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, * For different chiptypes or old sdio hosts w/o chipcommon, * other ways of recognition should be added here. */ - ci->cccorebase = regs; + ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON; + ci->c_inf[0].base = regs; regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, chipid), 4); + CORE_CC_REG(ci->c_inf[0].base, chipid), 4); ci->chip = regdata & CID_ID_MASK; ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; @@ -250,9 +264,12 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, /* Address of cores for new chips should be added here */ switch (ci->chip) { case BCM4329_CHIP_ID: - ci->buscorebase = BCM4329_CORE_BUS_BASE; - ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; - ci->armcorebase = BCM4329_CORE_ARM_BASE; + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; + ci->c_inf[1].base = BCM4329_CORE_BUS_BASE; + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; + ci->c_inf[2].base = BCM4329_CORE_SOCRAM_BASE; + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; + ci->c_inf[3].base = BCM4329_CORE_ARM_BASE; ci->ramsize = BCM4329_RAMSIZE; break; default: @@ -316,35 +333,39 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci) { u32 regdata; + u8 idx; /* get chipcommon rev */ - ci->ccrev = brcmf_sdio_chip_corerev(sdiodev, ci->cccorebase); + ci->c_inf[0].rev = + brcmf_sdio_chip_corerev(sdiodev, ci->c_inf[0].base); /* get chipcommon capabilites */ - ci->cccaps = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, capabilities), 4); + ci->c_inf[0].caps = + brcmf_sdcard_reg_read(sdiodev, + CORE_CC_REG(ci->c_inf[0].base, capabilities), 4); /* get pmu caps & rev */ - if (ci->cccaps & CC_CAP_PMU) { + if (ci->c_inf[0].caps & CC_CAP_PMU) { ci->pmucaps = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); + CORE_CC_REG(ci->c_inf[0].base, pmucapabilities), 4); ci->pmurev = ci->pmucaps & PCAP_REV_MASK; } - - ci->buscorerev = brcmf_sdio_chip_corerev(sdiodev, ci->buscorebase); + ci->c_inf[1].rev = brcmf_sdio_chip_corerev(sdiodev, ci->c_inf[1].base); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->buscorebase, sbidhigh), 4); - ci->buscoretype = (regdata & SSB_IDHIGH_CC) >> SSB_IDHIGH_CC_SHIFT; + CORE_SB(ci->c_inf[1].base, sbidhigh), 4); + ci->c_inf[1].id = (regdata & SSB_IDHIGH_CC) >> SSB_IDHIGH_CC_SHIFT; brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", - ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); + ci->c_inf[0].rev, ci->pmurev, + ci->c_inf[1].rev, ci->c_inf[1].id); /* * Make sure any on-chip ARM is off (in case strapping is wrong), * or downloaded code was already running. */ - brcmf_sdio_chip_coredisable(sdiodev, ci->armcorebase); + idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3); + brcmf_sdio_chip_coredisable(sdiodev, ci->c_inf[idx].base); } int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, @@ -371,9 +392,9 @@ int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, brcmf_sdio_chip_buscoresetup(sdiodev, ci); brcmf_sdcard_reg_write(sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); + CORE_CC_REG(ci->c_inf[0].base, gpiopullup), 4, 0); brcmf_sdcard_reg_write(sdiodev, - CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); + CORE_CC_REG(ci->c_inf[0].base, gpiopulldown), 4, 0); *ci_ptr = ci; return 0; @@ -410,7 +431,7 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, u32 str_shift = 0; char chn[8]; - if (!(ci->cccaps & CC_CAP_PMU)) + if (!(ci->c_inf[0].caps & CC_CAP_PMU)) return; switch (SDIOD_DRVSTR_KEY(ci->chip, ci->pmurev)) { @@ -450,15 +471,15 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, } brcmf_sdcard_reg_write(sdiodev, - CORE_CC_REG(ci->cccorebase, chipcontrol_addr), + CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 4, 1); cc_data_temp = brcmf_sdcard_reg_read(sdiodev, - CORE_CC_REG(ci->cccorebase, chipcontrol_addr), 4); + CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 4); cc_data_temp &= ~str_mask; drivestrength_sel <<= str_shift; cc_data_temp |= drivestrength_sel; brcmf_sdcard_reg_write(sdiodev, - CORE_CC_REG(ci->cccorebase, chipcontrol_addr), + CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 4, cc_data_temp); brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 6383746..0ee37ae 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -52,17 +52,22 @@ #define SBSDIO_CLKAV(regval, alponly) \ (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) +#define BRCMF_MAX_CORENUM 6 + +struct chip_core_info { + u16 id; + u16 rev; + u32 base; + u32 wrapbase; + u32 caps; +}; + struct chip_info { u32 chip; u32 chiprev; - u32 cccorebase; - u32 ccrev; - u32 cccaps; - u32 buscorebase; /* 32 bits backplane bus address */ - u32 buscorerev; - u32 buscoretype; - u32 ramcorebase; - u32 armcorebase; + /* core info */ + /* always put chipcommon core at 0, bus core at 1 */ + struct chip_core_info c_inf[BRCMF_MAX_CORENUM]; u32 pmurev; u32 pmucaps; u32 ramsize; @@ -120,5 +125,7 @@ extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); extern void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u32 drivestrength); +extern u8 brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid); + #endif /* _BRCMFMAC_SDIO_CHIP_H_ */ -- cgit v0.10.2 From e41215626607f2e9b2227504a8965389a1ba1a25 Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Sat, 5 Nov 2011 14:15:24 +0100 Subject: mac80211: Also report the STA's TDLS flag via nl80211 Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index ab3258a..02a4323 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -411,7 +411,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | BIT(NL80211_STA_FLAG_WME) | BIT(NL80211_STA_FLAG_MFP) | - BIT(NL80211_STA_FLAG_AUTHENTICATED); + BIT(NL80211_STA_FLAG_AUTHENTICATED) | + BIT(NL80211_STA_FLAG_TDLS_PEER); if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) @@ -422,6 +423,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); if (test_sta_flag(sta, WLAN_STA_AUTH)) sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); + if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); } -- cgit v0.10.2 From 1f074bd8eb7a4a210a5119cd7220f89da6c7a2c3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 6 Nov 2011 14:13:33 +0100 Subject: nl80211: advertise socket TX status capability The new wifi socket TX capability should be supported by wifi drivers, let them advertise whether they do or not. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 165e16f..3152ddf 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -695,6 +695,8 @@ enum nl80211_commands { #define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE #define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT +#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS + /* source-level API compatibility */ #define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG #define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG @@ -1156,6 +1158,9 @@ enum nl80211_commands { * it will also not give a status callback nor return a cookie. This is * mostly useful for probe responses to save airtime. * + * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from + * &enum nl80211_feature_flags and is advertised in wiphy information. + * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1388,6 +1393,8 @@ enum nl80211_attrs { NL80211_ATTR_DONT_WAIT_FOR_ACK, + NL80211_ATTR_FEATURE_FLAGS, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -1422,6 +1429,7 @@ enum nl80211_attrs { #define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES #define NL80211_ATTR_KEY NL80211_ATTR_KEY #define NL80211_ATTR_KEYS NL80211_ATTR_KEYS +#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS #define NL80211_MAX_SUPP_RATES 32 #define NL80211_MAX_SUPP_REG_RULES 32 @@ -2709,4 +2717,14 @@ enum nl80211_ap_sme_features { }; */ +/** + * enum nl80211_feature_flags - device/driver features + * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back + * TX status to the socket error queue when requested with the + * socket option. + */ +enum nl80211_feature_flags { + NL80211_FEATURE_SK_TX_STATUS = 1 << 0, +}; + #endif /* __LINUX_NL80211_H */ diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 00287bd..e1ee1416 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1881,6 +1881,7 @@ struct wiphy_wowlan_support { * @software_iftypes: bitmask of software interface types, these are not * subject to any restrictions since they are purely managed in SW. * @flags: wiphy flags, see &enum wiphy_flags + * @features: features advertised to nl80211, see &enum nl80211_feature_flags. * @bss_priv_size: each BSS struct has private data allocated with it, * this variable determines its size * @max_scan_ssids: maximum number of SSIDs the device can scan for in @@ -1942,7 +1943,7 @@ struct wiphy { /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ u16 interface_modes; - u32 flags; + u32 flags, features; u32 ap_sme_capa; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 0ef0941..864fcb6 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1017,6 +1017,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, NLA_PUT_U32(msg, NL80211_ATTR_DEVICE_AP_SME, dev->wiphy.ap_sme_capa); + NLA_PUT_U32(msg, NL80211_ATTR_FEATURE_FLAGS, dev->wiphy.features); + return genlmsg_end(msg, hdr); nla_put_failure: -- cgit v0.10.2 From a729cff8ad5120d0d5172ec28a3843d1cb458f79 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 6 Nov 2011 14:13:34 +0100 Subject: mac80211: implement wifi TX status Implement the socket wifi TX status error queue reflection in mac80211. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/net/mac80211.h b/include/net/mac80211.h index b9b9c94..2714646 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -518,7 +518,7 @@ struct ieee80211_tx_rate { * @flags: transmit info flags, defined above * @band: the band to transmit on (use for checking for races) * @antenna_sel_tx: antenna to use, 0 for automatic diversity - * @pad: padding, ignore + * @ack_frame_id: internal frame ID for TX status, used internally * @control: union for control data * @status: union for status data * @driver_data: array of driver_data pointers @@ -535,8 +535,7 @@ struct ieee80211_tx_info { u8 antenna_sel_tx; - /* 2 byte hole */ - u8 pad[2]; + u16 ack_frame_id; union { struct { diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4bef6ec..76e656b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -1017,6 +1018,9 @@ struct ieee80211_local { u32 hw_roc_cookie; bool hw_roc_for_tx; + struct idr ack_status_frames; + spinlock_t ack_status_lock; + /* dummy netdev for use w/ NAPI */ struct net_device napi_dev; diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 8e9327b..e323d4e 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -596,6 +596,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, WIPHY_FLAG_4ADDR_STATION | WIPHY_FLAG_REPORTS_OBSS; + wiphy->features = NL80211_FEATURE_SK_TX_STATUS; + if (!ops->set_key) wiphy->flags |= WIPHY_FLAG_IBSS_RSN; @@ -669,6 +671,11 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, INIT_WORK(&local->sched_scan_stopped_work, ieee80211_sched_scan_stopped_work); + spin_lock_init(&local->ack_status_lock); + idr_init(&local->ack_status_frames); + /* preallocate at least one entry */ + idr_pre_get(&local->ack_status_frames, GFP_KERNEL); + sta_info_init(local); for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { @@ -1044,6 +1051,13 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw) } EXPORT_SYMBOL(ieee80211_unregister_hw); +static int ieee80211_free_ack_frame(int id, void *p, void *data) +{ + WARN_ONCE(1, "Have pending ack frames!\n"); + kfree_skb(p); + return 0; +} + void ieee80211_free_hw(struct ieee80211_hw *hw) { struct ieee80211_local *local = hw_to_local(hw); @@ -1054,6 +1068,10 @@ void ieee80211_free_hw(struct ieee80211_hw *hw) if (local->wiphy_ciphers_allocated) kfree(local->hw.wiphy->cipher_suites); + idr_for_each(&local->ack_status_frames, + ieee80211_free_ack_frame, NULL); + idr_destroy(&local->ack_status_frames); + wiphy_free(local->hw.wiphy); } EXPORT_SYMBOL(ieee80211_free_hw); diff --git a/net/mac80211/status.c b/net/mac80211/status.c index 94702f1..83b800d 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -548,6 +548,24 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) } } + if (unlikely(info->ack_frame_id)) { + struct sk_buff *ack_skb; + unsigned long flags; + + spin_lock_irqsave(&local->ack_status_lock, flags); + ack_skb = idr_find(&local->ack_status_frames, + info->ack_frame_id); + if (ack_skb) + idr_remove(&local->ack_status_frames, + info->ack_frame_id); + spin_unlock_irqrestore(&local->ack_status_lock, flags); + + /* consumes ack_skb */ + if (ack_skb) + skb_complete_wifi_ack(ack_skb, + info->flags & IEEE80211_TX_STAT_ACK); + } + /* this was a transmitted frame, but now we want to reuse it */ skb_orphan(skb); @@ -621,6 +639,26 @@ EXPORT_SYMBOL(ieee80211_report_low_ack); void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb) { + struct ieee80211_local *local = hw_to_local(hw); + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + + if (unlikely(info->ack_frame_id)) { + struct sk_buff *ack_skb; + unsigned long flags; + + spin_lock_irqsave(&local->ack_status_lock, flags); + ack_skb = idr_find(&local->ack_status_frames, + info->ack_frame_id); + if (ack_skb) + idr_remove(&local->ack_status_frames, + info->ack_frame_id); + spin_unlock_irqrestore(&local->ack_status_lock, flags); + + /* consumes ack_skb */ + if (ack_skb) + dev_kfree_skb_any(ack_skb); + } + dev_kfree_skb_any(skb); } EXPORT_SYMBOL(ieee80211_free_txskb); diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index a543d26..ab6cb56 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1684,8 +1684,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, int nh_pos, h_pos; struct sta_info *sta = NULL; bool wme_sta = false, authorized = false, tdls_auth = false; - struct sk_buff *tmp_skb; bool tdls_direct = false; + bool multicast; + u32 info_flags = 0; + u16 info_id = 0; if (unlikely(skb->len < ETH_HLEN)) { ret = NETDEV_TX_OK; @@ -1872,7 +1874,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, * if it is a multicast address (which can only happen * in AP mode) */ - if (!is_multicast_ether_addr(hdr.addr1)) { + multicast = is_multicast_ether_addr(hdr.addr1); + if (!multicast) { rcu_read_lock(); sta = sta_info_get(sdata, hdr.addr1); if (sta) { @@ -1913,11 +1916,54 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, goto fail; } + if (unlikely(!multicast && skb->sk && + skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) { + struct sk_buff *orig_skb = skb; + + skb = skb_clone(skb, GFP_ATOMIC); + if (skb) { + unsigned long flags; + int id, r; + + spin_lock_irqsave(&local->ack_status_lock, flags); + r = idr_get_new_above(&local->ack_status_frames, + orig_skb, 1, &id); + if (r == -EAGAIN) { + idr_pre_get(&local->ack_status_frames, + GFP_ATOMIC); + r = idr_get_new_above(&local->ack_status_frames, + orig_skb, 1, &id); + } + if (WARN_ON(!id) || id > 0xffff) { + idr_remove(&local->ack_status_frames, id); + r = -ERANGE; + } + spin_unlock_irqrestore(&local->ack_status_lock, flags); + + if (!r) { + info_id = id; + info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; + } else if (skb_shared(skb)) { + kfree_skb(orig_skb); + } else { + kfree_skb(skb); + skb = orig_skb; + } + } else { + /* couldn't clone -- lose tx status ... */ + skb = orig_skb; + } + } + /* * If the skb is shared we need to obtain our own copy. */ if (skb_shared(skb)) { - tmp_skb = skb; + struct sk_buff *tmp_skb = skb; + + /* can't happen -- skb is a clone if info_id != 0 */ + WARN_ON(info_id); + skb = skb_clone(skb, GFP_ATOMIC); kfree_skb(tmp_skb); @@ -2018,6 +2064,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, memset(info, 0, sizeof(*info)); dev->trans_start = jiffies; + + info->flags = info_flags; + info->ack_frame_id = info_id; + ieee80211_xmit(sdata, skb); return NETDEV_TX_OK; -- cgit v0.10.2 From 61e3f32c11c35e5a54d37d98505cb29db639cfdb Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 6 Nov 2011 14:26:48 +0100 Subject: net/mac80211/debugfs.c: use kstrtoul, etc Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc. A semantic patch rule for the kstrtoul case is as follows: (http://coccinelle.lip6.fr/) // @@ expression a,b; {int,long} *c; @@ -strict_strtoul +kstrtoul (a,b,c) // Signed-off-by: Julia Lawall Signed-off-by: John W. Linville diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 883996b..00cefcb 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -190,7 +190,7 @@ static ssize_t uapsd_max_sp_len_write(struct file *file, return -EFAULT; buf[len] = '\0'; - ret = strict_strtoul(buf, 0, &val); + ret = kstrtoul(buf, 0, &val); if (ret) return -EINVAL; -- cgit v0.10.2 From 1bac92cac1d8417bf023571b1608b9793c4ecf86 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 6 Nov 2011 14:26:49 +0100 Subject: net/rfkill/core.c: use kstrtoul, etc Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc. A semantic patch rule for the kstrtoul case is as follows: (http://coccinelle.lip6.fr/) // @@ expression a,b; {int,long} *c; @@ -strict_strtoul +kstrtoul (a,b,c) // Signed-off-by: Julia Lawall Signed-off-by: John W. Linville diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 5be1957..354760e 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -644,7 +644,7 @@ static ssize_t rfkill_soft_store(struct device *dev, if (!capable(CAP_NET_ADMIN)) return -EPERM; - err = strict_strtoul(buf, 0, &state); + err = kstrtoul(buf, 0, &state); if (err) return err; @@ -688,7 +688,7 @@ static ssize_t rfkill_state_store(struct device *dev, if (!capable(CAP_NET_ADMIN)) return -EPERM; - err = strict_strtoul(buf, 0, &state); + err = kstrtoul(buf, 0, &state); if (err) return err; -- cgit v0.10.2 From fba6fe634787bb7ef95fb44682df71b4d4e8cb2d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 7 Nov 2011 19:31:44 -0800 Subject: mwifiex: remove unneeded kfree(NULL); The previous if statement means this that pointer is NULL so there is no need to free it. Signed-off-by: Dan Carpenter Acked-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index d34acf0..4466976 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c @@ -386,7 +386,6 @@ static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) card->txbd_ring_vbase = kzalloc(card->txbd_ring_size, GFP_KERNEL); if (!card->txbd_ring_vbase) { dev_err(adapter->dev, "Unable to allocate buffer for txbd ring.\n"); - kfree(card->txbd_ring_vbase); return -1; } card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase); -- cgit v0.10.2 From fa161cb7aa7da29018f7378ccbab6bb593be008c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 7 Nov 2011 19:31:45 -0800 Subject: mwifiex: remove an unneeded NULL check We dereference adapter in the error handling code so this needed to be fixed. This function is always called like: adapter->if_ops.host_to_card(adapter, ...); so adapter can never be NULL and I've removed the NULL check. Signed-off-by: Dan Carpenter Acked-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index 4466976..d12d440 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c @@ -1671,9 +1671,8 @@ static int mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type, struct sk_buff *skb, struct mwifiex_tx_param *tx_param) { - if (!adapter || !skb) { - dev_err(adapter->dev, "Invalid parameter in %s <%p, %p>\n", - __func__, adapter, skb); + if (!skb) { + dev_err(adapter->dev, "Passed NULL skb to %s\n", __func__); return -1; } -- cgit v0.10.2 From 7d7ab02204ae2af26944ccd8a4c599756bdf0fc3 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Mon, 7 Nov 2011 19:31:46 -0800 Subject: mwifiex: enable SDIO multiport aggregation By default SDIO multiport aggregation is disabled. It's useful to get good throughput results. This patch enables it. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 283171b..ffaf3f3 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -1630,14 +1630,14 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) card->mpa_tx.pkt_cnt = 0; card->mpa_tx.start_port = 0; - card->mpa_tx.enabled = 0; + card->mpa_tx.enabled = 1; card->mpa_tx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; card->mpa_rx.buf_len = 0; card->mpa_rx.pkt_cnt = 0; card->mpa_rx.start_port = 0; - card->mpa_rx.enabled = 0; + card->mpa_rx.enabled = 1; card->mpa_rx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; /* Allocate buffers for SDIO MP-A */ -- cgit v0.10.2 From 1eb54c8a0fa0061247f3bd327b320c3e20c97340 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 7 Nov 2011 19:31:47 -0800 Subject: mwifiex: prevent corruption instead of just warning Probably we never hit this condition, but in case we do, we may as well put a return here instead of just printing a warning message and then corrupting memory. The caller doesn't check the return code. Signed-off-by: Dan Carpenter Acked-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index d12d440..a2f3200 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c @@ -1228,9 +1228,12 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, if (!skb) return 0; - if (rdptr >= MWIFIEX_MAX_EVT_BD) + if (rdptr >= MWIFIEX_MAX_EVT_BD) { dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n", rdptr); + ret = -EINVAL; + goto done; + } /* Read the event ring write pointer set by firmware */ if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) { -- cgit v0.10.2 From d826eb14ecef3574b6b3be55e5f4329f4a76fbf3 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 9 Nov 2011 07:24:35 +0000 Subject: ipv4: PKTINFO doesnt need dst reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le lundi 07 novembre 2011 à 15:33 +0100, Eric Dumazet a écrit : > At least, in recent kernels we dont change dst->refcnt in forwarding > patch (usinf NOREF skb->dst) > > One particular point is the atomic_inc(dst->refcnt) we have to perform > when queuing an UDP packet if socket asked PKTINFO stuff (for example a > typical DNS server has to setup this option) > > I have one patch somewhere that stores the information in skb->cb[] and > avoid the atomic_{inc|dec}(dst->refcnt). > OK I found it, I did some extra tests and believe its ready. [PATCH net-next] ipv4: IP_PKTINFO doesnt need dst reference When a socket uses IP_PKTINFO notifications, we currently force a dst reference for each received skb. Reader has to access dst to get needed information (rt_iif & rt_spec_dst) and must release dst reference. We also forced a dst reference if skb was put in socket backlog, even without IP_PKTINFO handling. This happens under stress/load. We can instead store the needed information in skb->cb[], so that only softirq handler really access dst, improving cache hit ratios. This removes two atomic operations per packet, and false sharing as well. On a benchmark using a mono threaded receiver (doing only recvmsg() calls), I can reach 720.000 pps instead of 570.000 pps. IP_PKTINFO is typically used by DNS servers, and any multihomed aware UDP application. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller diff --git a/include/net/ip.h b/include/net/ip.h index eca0ef7..fd1561e 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -450,7 +450,7 @@ extern int ip_options_rcv_srr(struct sk_buff *skb); * Functions provided by ip_sockglue.c */ -extern int ip_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); +extern void ipv4_pktinfo_prepare(struct sk_buff *skb); extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); extern int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 09ff51b..80d5fa4 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -55,20 +55,13 @@ /* * SOL_IP control messages. */ +#define PKTINFO_SKB_CB(__skb) ((struct in_pktinfo *)((__skb)->cb)) static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb) { - struct in_pktinfo info; - struct rtable *rt = skb_rtable(skb); + struct in_pktinfo info = *PKTINFO_SKB_CB(skb); info.ipi_addr.s_addr = ip_hdr(skb)->daddr; - if (rt) { - info.ipi_ifindex = rt->rt_iif; - info.ipi_spec_dst.s_addr = rt->rt_spec_dst; - } else { - info.ipi_ifindex = 0; - info.ipi_spec_dst.s_addr = 0; - } put_cmsg(msg, SOL_IP, IP_PKTINFO, sizeof(info), &info); } @@ -992,20 +985,28 @@ e_inval: } /** - * ip_queue_rcv_skb - Queue an skb into sock receive queue + * ipv4_pktinfo_prepare - transfert some info from rtable to skb * @sk: socket * @skb: buffer * - * Queues an skb into socket receive queue. If IP_CMSG_PKTINFO option - * is not set, we drop skb dst entry now, while dst cache line is hot. + * To support IP_CMSG_PKTINFO option, we store rt_iif and rt_spec_dst + * in skb->cb[] before dst drop. + * This way, receiver doesnt make cache line misses to read rtable. */ -int ip_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +void ipv4_pktinfo_prepare(struct sk_buff *skb) { - if (!(inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO)) - skb_dst_drop(skb); - return sock_queue_rcv_skb(sk, skb); + struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb); + const struct rtable *rt = skb_rtable(skb); + + if (rt) { + pktinfo->ipi_ifindex = rt->rt_iif; + pktinfo->ipi_spec_dst.s_addr = rt->rt_spec_dst; + } else { + pktinfo->ipi_ifindex = 0; + pktinfo->ipi_spec_dst.s_addr = 0; + } + skb_dst_drop(skb); } -EXPORT_SYMBOL(ip_queue_rcv_skb); int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 007e2eb..7a8410d 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -292,7 +292,8 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb) { /* Charge it to the socket. */ - if (ip_queue_rcv_skb(sk, skb) < 0) { + ipv4_pktinfo_prepare(skb); + if (sock_queue_rcv_skb(sk, skb) < 0) { kfree_skb(skb); return NET_RX_DROP; } diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index ab0966d..6854f58 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1357,7 +1357,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) if (inet_sk(sk)->inet_daddr) sock_rps_save_rxhash(sk, skb); - rc = ip_queue_rcv_skb(sk, skb); + rc = sock_queue_rcv_skb(sk, skb); if (rc < 0) { int is_udplite = IS_UDPLITE(sk); @@ -1473,6 +1473,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) rc = 0; + ipv4_pktinfo_prepare(skb); bh_lock_sock(sk); if (!sock_owned_by_user(sk)) rc = __udp_queue_rcv_skb(sk, skb); diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 331af3b8..204f2e8 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -383,7 +383,8 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb) } /* Charge it to the socket. */ - if (ip_queue_rcv_skb(sk, skb) < 0) { + skb_dst_drop(skb); + if (sock_queue_rcv_skb(sk, skb) < 0) { kfree_skb(skb); return NET_RX_DROP; } diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 846f4757..b4a4a15f 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -538,7 +538,9 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) goto drop; } - if ((rc = ip_queue_rcv_skb(sk, skb)) < 0) { + skb_dst_drop(skb); + rc = sock_queue_rcv_skb(sk, skb); + if (rc < 0) { /* Note that an ENOMEM error is charged twice */ if (rc == -ENOMEM) UDP6_INC_STATS_BH(sock_net(sk), -- cgit v0.10.2 From 5bb01a991897d74295ff8de548d350400d7370a9 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Wed, 9 Nov 2011 15:29:31 -0800 Subject: ARM: OMAP: Fix map_io for Amstrad E3 Commit 7b88e62f5d219a86d81bdf4388012c97dc42e8f8 (ARM: OMAP1: Use generic map_io, init_early and init_irq) changed omap1 to use generic map_io. Looks like I missed one board though. Fix this by adding a custom map_io for Amstrad E3. Reported-by: Aaro Koskinen Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 51bae31..b0f15d2 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -302,8 +302,6 @@ static void __init ams_delta_init(void) omap_cfg_reg(J19_1610_CAM_D6); omap_cfg_reg(J18_1610_CAM_D7); - iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc)); - omap_board_config = ams_delta_config; omap_board_config_size = ARRAY_SIZE(ams_delta_config); omap_serial_init(); @@ -373,10 +371,16 @@ static int __init ams_delta_modem_init(void) } arch_initcall(ams_delta_modem_init); +static void __init ams_delta_map_io(void) +{ + omap15xx_map_io(); + iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc)); +} + MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)") /* Maintainer: Jonathan McDowell */ .atag_offset = 0x100, - .map_io = omap15xx_map_io, + .map_io = ams_delta_map_io, .init_early = omap1_init_early, .reserve = omap_reserve, .init_irq = omap1_init_irq, -- cgit v0.10.2 From c0a39151a4055332897cba615623d3de2f3896df Mon Sep 17 00:00:00 2001 From: Haojian Zhuang Date: Thu, 10 Nov 2011 07:13:07 +0800 Subject: ARM: pxa: fix inconsistent CONFIG_USB_PXA27X Since CONFIG_USB_GADGET_PXA27X and other macros are renamed to CONFIG_USB_PXA27X. Update them in arch/arm/mach-pxa and arch/arm/configs to keep consistent. Cc: stable@kernel.org Signed-off-by: Haojian Zhuang Acked-by: Felipe Balbi Signed-off-by: Eric Miao diff --git a/arch/arm/configs/ezx_defconfig b/arch/arm/configs/ezx_defconfig index 227a477..d95763d 100644 --- a/arch/arm/configs/ezx_defconfig +++ b/arch/arm/configs/ezx_defconfig @@ -287,7 +287,7 @@ CONFIG_USB=y # CONFIG_USB_DEVICE_CLASS is not set CONFIG_USB_OHCI_HCD=y CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_PXA27X=y +CONFIG_USB_PXA27X=y CONFIG_USB_ETH=m # CONFIG_USB_ETH_RNDIS is not set CONFIG_MMC=y diff --git a/arch/arm/configs/imote2_defconfig b/arch/arm/configs/imote2_defconfig index 176ec22..fd996bb 100644 --- a/arch/arm/configs/imote2_defconfig +++ b/arch/arm/configs/imote2_defconfig @@ -263,7 +263,7 @@ CONFIG_USB=y # CONFIG_USB_DEVICE_CLASS is not set CONFIG_USB_OHCI_HCD=y CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_PXA27X=y +CONFIG_USB_PXA27X=y CONFIG_USB_ETH=m # CONFIG_USB_ETH_RNDIS is not set CONFIG_MMC=y diff --git a/arch/arm/configs/magician_defconfig b/arch/arm/configs/magician_defconfig index a88e64d..443675d 100644 --- a/arch/arm/configs/magician_defconfig +++ b/arch/arm/configs/magician_defconfig @@ -132,7 +132,7 @@ CONFIG_USB_MON=m CONFIG_USB_OHCI_HCD=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_VBUS_DRAW=500 -CONFIG_USB_GADGET_PXA27X=y +CONFIG_USB_PXA27X=y CONFIG_USB_ETH=m # CONFIG_USB_ETH_RNDIS is not set CONFIG_USB_GADGETFS=m diff --git a/arch/arm/configs/zeus_defconfig b/arch/arm/configs/zeus_defconfig index 59577ad..547a3c1 100644 --- a/arch/arm/configs/zeus_defconfig +++ b/arch/arm/configs/zeus_defconfig @@ -140,7 +140,7 @@ CONFIG_USB_SERIAL=m CONFIG_USB_SERIAL_GENERIC=y CONFIG_USB_SERIAL_MCT_U232=m CONFIG_USB_GADGET=m -CONFIG_USB_GADGET_PXA27X=y +CONFIG_USB_PXA27X=y CONFIG_USB_ETH=m CONFIG_USB_GADGETFS=m CONFIG_USB_FILE_STORAGE=m diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c index fc0b854..4b81f59 100644 --- a/arch/arm/mach-pxa/balloon3.c +++ b/arch/arm/mach-pxa/balloon3.c @@ -307,7 +307,7 @@ static inline void balloon3_mmc_init(void) {} /****************************************************************************** * USB Gadget ******************************************************************************/ -#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) +#if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE) static void balloon3_udc_command(int cmd) { if (cmd == PXA2XX_UDC_CMD_CONNECT) diff --git a/arch/arm/mach-pxa/colibri-pxa320.c b/arch/arm/mach-pxa/colibri-pxa320.c index 692e1ff..d23b92b 100644 --- a/arch/arm/mach-pxa/colibri-pxa320.c +++ b/arch/arm/mach-pxa/colibri-pxa320.c @@ -146,7 +146,7 @@ static void __init colibri_pxa320_init_eth(void) static inline void __init colibri_pxa320_init_eth(void) {} #endif /* CONFIG_AX88796 */ -#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) +#if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE) static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = { .gpio_vbus = mfp_to_gpio(MFP_PIN_GPIO96), .gpio_pullup = -1, diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c index 9c8208c..ffdd70d 100644 --- a/arch/arm/mach-pxa/gumstix.c +++ b/arch/arm/mach-pxa/gumstix.c @@ -106,7 +106,7 @@ static void __init gumstix_mmc_init(void) } #endif -#ifdef CONFIG_USB_GADGET_PXA25X +#ifdef CONFIG_USB_PXA25X static struct gpio_vbus_mach_info gumstix_udc_info = { .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn, .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx, diff --git a/arch/arm/mach-pxa/include/mach/palm27x.h b/arch/arm/mach-pxa/include/mach/palm27x.h index f80bbe2..d4eac3d 100644 --- a/arch/arm/mach-pxa/include/mach/palm27x.h +++ b/arch/arm/mach-pxa/include/mach/palm27x.h @@ -37,8 +37,8 @@ extern void __init palm27x_lcd_init(int power, #define palm27x_lcd_init(power, mode) do {} while (0) #endif -#if defined(CONFIG_USB_GADGET_PXA27X) || \ - defined(CONFIG_USB_GADGET_PXA27X_MODULE) +#if defined(CONFIG_USB_PXA27X) || \ + defined(CONFIG_USB_PXA27X_MODULE) extern void __init palm27x_udc_init(int vbus, int pullup, int vbus_inverted); #else diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c index 325c245..fbc10d7 100644 --- a/arch/arm/mach-pxa/palm27x.c +++ b/arch/arm/mach-pxa/palm27x.c @@ -164,8 +164,8 @@ void __init palm27x_lcd_init(int power, struct pxafb_mode_info *mode) /****************************************************************************** * USB Gadget ******************************************************************************/ -#if defined(CONFIG_USB_GADGET_PXA27X) || \ - defined(CONFIG_USB_GADGET_PXA27X_MODULE) +#if defined(CONFIG_USB_PXA27X) || \ + defined(CONFIG_USB_PXA27X_MODULE) static struct gpio_vbus_mach_info palm27x_udc_info = { .gpio_vbus_inverted = 1, }; diff --git a/arch/arm/mach-pxa/palmtc.c b/arch/arm/mach-pxa/palmtc.c index 6ec7cae..2c24c67 100644 --- a/arch/arm/mach-pxa/palmtc.c +++ b/arch/arm/mach-pxa/palmtc.c @@ -338,7 +338,7 @@ static inline void palmtc_mkp_init(void) {} /****************************************************************************** * UDC ******************************************************************************/ -#if defined(CONFIG_USB_GADGET_PXA25X)||defined(CONFIG_USB_GADGET_PXA25X_MODULE) +#if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE) static struct gpio_vbus_mach_info palmtc_udc_info = { .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N, .gpio_vbus_inverted = 1, diff --git a/arch/arm/mach-pxa/vpac270.c b/arch/arm/mach-pxa/vpac270.c index a7539a6..ca0c661 100644 --- a/arch/arm/mach-pxa/vpac270.c +++ b/arch/arm/mach-pxa/vpac270.c @@ -343,7 +343,7 @@ static inline void vpac270_uhc_init(void) {} /****************************************************************************** * USB Gadget ******************************************************************************/ -#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) +#if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE) static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = { .gpio_vbus = GPIO41_VPAC270_UDC_DETECT, .gpio_pullup = -1, -- cgit v0.10.2 From 1ec454baf1245df4fdb5dae728da3363630ce6de Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Thu, 20 Oct 2011 23:01:09 +0900 Subject: x86, perf: Add a build-time sanity test to the x86 decoder Add a sanity test of x86 insn decoder against a stream of randomly generated input, at build time. This test is also able to reproduce any bug that might trigger by allowing the passing of random-seed and iteration-number to the test, or by passing input which has invalid byte code. Changes in V2: - Code cleanup. - Show how to reproduce the error by insn_sanity test. Signed-off-by: Masami Hiramatsu Cc: acme@redhat.com Cc: ming.m.lin@intel.com Cc: robert.richter@amd.com Cc: ravitillo@lbl.gov Cc: yrl.pp-manager.tt@hitachi.com Cc: Andi Kleen Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Andi Kleen Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20111020140109.20938.92572.stgit@localhost.localdomain Signed-off-by: Ingo Molnar diff --git a/arch/x86/include/asm/insn.h b/arch/x86/include/asm/insn.h index 88c765e..74df3f1 100644 --- a/arch/x86/include/asm/insn.h +++ b/arch/x86/include/asm/insn.h @@ -137,6 +137,13 @@ static inline int insn_is_avx(struct insn *insn) return (insn->vex_prefix.value != 0); } +/* Ensure this instruction is decoded completely */ +static inline int insn_complete(struct insn *insn) +{ + return insn->opcode.got && insn->modrm.got && insn->sib.got && + insn->displacement.got && insn->immediate.got; +} + static inline insn_byte_t insn_vex_m_bits(struct insn *insn) { if (insn->vex_prefix.nbytes == 2) /* 2 bytes VEX */ diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile index f820826..3255c3d 100644 --- a/arch/x86/tools/Makefile +++ b/arch/x86/tools/Makefile @@ -18,14 +18,22 @@ chkobjdump = $(srctree)/arch/x86/tools/chkobjdump.awk quiet_cmd_posttest = TEST $@ cmd_posttest = ($(OBJDUMP) -v | $(AWK) -f $(chkobjdump)) || $(OBJDUMP) -d -j .text $(objtree)/vmlinux | $(AWK) -f $(distill_awk) | $(obj)/test_get_len $(posttest_64bit) $(posttest_verbose) -posttest: $(obj)/test_get_len vmlinux +quiet_cmd_sanitytest = TEST $@ + cmd_sanitytest = $(obj)/insn_sanity $(posttest_64bit) -m 1000000 + +posttest: $(obj)/test_get_len vmlinux $(obj)/insn_sanity $(call cmd,posttest) + $(call cmd,sanitytest) hostprogs-y := test_get_len +hostprogs-y := insn_sanity # -I needed for generated C source and C source which in the kernel tree. HOSTCFLAGS_test_get_len.o := -Wall -I$(objtree)/arch/x86/lib/ -I$(srctree)/arch/x86/include/ -I$(srctree)/arch/x86/lib/ -I$(srctree)/include/ +HOSTCFLAGS_insn_sanity.o := -Wall -I$(objtree)/arch/x86/lib/ -I$(srctree)/arch/x86/include/ -I$(srctree)/arch/x86/lib/ -I$(srctree)/include/ + # Dependencies are also needed. $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c +$(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c diff --git a/arch/x86/tools/insn_sanity.c b/arch/x86/tools/insn_sanity.c new file mode 100644 index 0000000..334d9de --- /dev/null +++ b/arch/x86/tools/insn_sanity.c @@ -0,0 +1,275 @@ +/* + * x86 decoder sanity test - based on test_get_insn.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) IBM Corporation, 2009 + * Copyright (C) Hitachi, Ltd., 2011 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define unlikely(cond) (cond) +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) + +#include +#include +#include + +/* + * Test of instruction analysis against tampering. + * Feed random binary to instruction decoder and ensure not to + * access out-of-instruction-buffer. + */ + +#define DEFAULT_MAX_ITER 10000 +#define INSN_NOP 0x90 + +static const char *prog; /* Program name */ +static int verbose; /* Verbosity */ +static int x86_64; /* x86-64 bit mode flag */ +static unsigned int seed; /* Random seed */ +static unsigned long iter_start; /* Start of iteration number */ +static unsigned long iter_end = DEFAULT_MAX_ITER; /* End of iteration number */ +static FILE *input_file; /* Input file name */ + +static void usage(const char *err) +{ + if (err) + fprintf(stderr, "Error: %s\n\n", err); + fprintf(stderr, "Usage: %s [-y|-n|-v] [-s seed[,no]] [-m max] [-i input]\n", prog); + fprintf(stderr, "\t-y 64bit mode\n"); + fprintf(stderr, "\t-n 32bit mode\n"); + fprintf(stderr, "\t-v Verbose mode\n"); + fprintf(stderr, "\t-s Give a random seed (and iteration number)\n"); + fprintf(stderr, "\t-m Give a maximum iteration number\n"); + fprintf(stderr, "\t-i Give an input file with decoded binary\n"); + exit(1); +} + +static void dump_field(FILE *fp, const char *name, const char *indent, + struct insn_field *field) +{ + fprintf(fp, "%s.%s = {\n", indent, name); + fprintf(fp, "%s\t.value = %d, bytes[] = {%x, %x, %x, %x},\n", + indent, field->value, field->bytes[0], field->bytes[1], + field->bytes[2], field->bytes[3]); + fprintf(fp, "%s\t.got = %d, .nbytes = %d},\n", indent, + field->got, field->nbytes); +} + +static void dump_insn(FILE *fp, struct insn *insn) +{ + fprintf(fp, "Instruction = {\n"); + dump_field(fp, "prefixes", "\t", &insn->prefixes); + dump_field(fp, "rex_prefix", "\t", &insn->rex_prefix); + dump_field(fp, "vex_prefix", "\t", &insn->vex_prefix); + dump_field(fp, "opcode", "\t", &insn->opcode); + dump_field(fp, "modrm", "\t", &insn->modrm); + dump_field(fp, "sib", "\t", &insn->sib); + dump_field(fp, "displacement", "\t", &insn->displacement); + dump_field(fp, "immediate1", "\t", &insn->immediate1); + dump_field(fp, "immediate2", "\t", &insn->immediate2); + fprintf(fp, "\t.attr = %x, .opnd_bytes = %d, .addr_bytes = %d,\n", + insn->attr, insn->opnd_bytes, insn->addr_bytes); + fprintf(fp, "\t.length = %d, .x86_64 = %d, .kaddr = %p}\n", + insn->length, insn->x86_64, insn->kaddr); +} + +static void dump_stream(FILE *fp, const char *msg, unsigned long nr_iter, + unsigned char *insn_buf, struct insn *insn) +{ + int i; + + fprintf(fp, "%s:\n", msg); + + dump_insn(stderr, insn); + + fprintf(fp, "You can reproduce this with below command(s);\n"); + + /* Input a decoded instruction sequence directly */ + fprintf(fp, " $ echo "); + for (i = 0; i < MAX_INSN_SIZE; i++) + fprintf(fp, " %02x", insn_buf[i]); + fprintf(fp, " | %s -i -\n", prog); + + if (!input_file) { + fprintf(fp, "Or \n"); + /* Give a seed and iteration number */ + fprintf(fp, " $ %s -s 0x%x,%lu\n", prog, seed, nr_iter); + } +} + +static void init_random_seed(void) +{ + int fd; + + fd = open("/dev/urandom", O_RDONLY); + if (fd < 0) + goto fail; + + if (read(fd, &seed, sizeof(seed)) != sizeof(seed)) + goto fail; + + close(fd); + return; +fail: + usage("Failed to open /dev/urandom"); +} + +/* Read given instruction sequence from the input file */ +static int read_next_insn(unsigned char *insn_buf) +{ + char buf[256] = "", *tmp; + int i; + + tmp = fgets(buf, ARRAY_SIZE(buf), input_file); + if (tmp == NULL || feof(input_file)) + return 0; + + for (i = 0; i < MAX_INSN_SIZE; i++) { + insn_buf[i] = (unsigned char)strtoul(tmp, &tmp, 16); + if (*tmp != ' ') + break; + } + + return i; +} + +static int generate_insn(unsigned char *insn_buf) +{ + int i; + + if (input_file) + return read_next_insn(insn_buf); + + /* Fills buffer with random binary up to MAX_INSN_SIZE */ + for (i = 0; i < MAX_INSN_SIZE - 1; i += 2) + *(unsigned short *)(&insn_buf[i]) = random() & 0xffff; + + while (i < MAX_INSN_SIZE) + insn_buf[i++] = random() & 0xff; + + return i; +} + +static void parse_args(int argc, char **argv) +{ + int c; + char *tmp = NULL; + int set_seed = 0; + + prog = argv[0]; + while ((c = getopt(argc, argv, "ynvs:m:i:")) != -1) { + switch (c) { + case 'y': + x86_64 = 1; + break; + case 'n': + x86_64 = 0; + break; + case 'v': + verbose = 1; + break; + case 'i': + if (strcmp("-", optarg) == 0) + input_file = stdin; + else + input_file = fopen(optarg, "r"); + if (!input_file) + usage("Failed to open input file"); + break; + case 's': + seed = (unsigned int)strtoul(optarg, &tmp, 0); + if (*tmp == ',') { + optarg = tmp + 1; + iter_start = strtoul(optarg, &tmp, 0); + } + if (*tmp != '\0' || tmp == optarg) + usage("Failed to parse seed"); + set_seed = 1; + break; + case 'm': + iter_end = strtoul(optarg, &tmp, 0); + if (*tmp != '\0' || tmp == optarg) + usage("Failed to parse max_iter"); + break; + default: + usage(NULL); + } + } + + /* Check errors */ + if (iter_end < iter_start) + usage("Max iteration number must be bigger than iter-num"); + + if (set_seed && input_file) + usage("Don't use input file (-i) with random seed (-s)"); + + /* Initialize random seed */ + if (!input_file) { + if (!set_seed) /* No seed is given */ + init_random_seed(); + srand(seed); + } +} + +int main(int argc, char **argv) +{ + struct insn insn; + int insns = 0; + int errors = 0; + unsigned long i; + unsigned char insn_buf[MAX_INSN_SIZE * 2]; + + parse_args(argc, argv); + + /* Prepare stop bytes with NOPs */ + memset(insn_buf + MAX_INSN_SIZE, INSN_NOP, MAX_INSN_SIZE); + + for (i = 0; i < iter_end; i++) { + if (generate_insn(insn_buf) <= 0) + break; + + if (i < iter_start) /* Skip to given iteration number */ + continue; + + /* Decode an instruction */ + insn_init(&insn, insn_buf, x86_64); + insn_get_length(&insn); + + if (verbose && !insn_complete(&insn)) + dump_stream(stdout, "Info: Found an undecodable input", i, insn_buf, &insn); + + if (insn.next_byte <= insn.kaddr || + insn.kaddr + MAX_INSN_SIZE < insn.next_byte) { + /* Access out-of-range memory */ + dump_stream(stdout, "Error: Found an access violation", i, insn_buf, &insn); + errors++; + } + insns++; + } + + fprintf(stdout, "%s: decoded and checked %d %s instructions with %d errors (seed:0x%x)\n", (errors) ? "Failure" : "Success", insns, (input_file) ? "given" : "random", errors, seed); + + return errors ? 1 : 0; +} -- cgit v0.10.2 From 58072cbfc522c2520e34333a53c8f17bb1adb1a0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 10 Nov 2011 18:15:15 +0100 Subject: regmap: Fix memory leak in regmap_init error path If regcache initialization fails regmap_init will currently exit without freeing work_buf. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 3e30d16..b08df85 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -229,12 +229,14 @@ struct regmap *regmap_init(struct device *dev, ret = regcache_init(map); if (ret < 0) - goto err_map; + goto err_free_workbuf; regmap_debugfs_init(map); return map; +err_free_workbuf: + kfree(map->work_buf); err_map: kfree(map); err: -- cgit v0.10.2 From 48264f06943e2db2c971b752949606f070d9d292 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 9 Nov 2011 13:58:58 +0200 Subject: Bluetooth: Add public/random LE address information to mgmt messages It's necessary to know the distinction between public and random LE addresses so the mgmt interface also needs to distinguish between them. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 0a5a05d..5f401e7 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -915,11 +915,13 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable); int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent); -int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); -int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); +int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type); +int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type); int mgmt_disconnect_failed(struct hci_dev *hdev); -int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, - u8 status); +int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, u8 status); int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); @@ -935,8 +937,8 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); -int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, - u8 *dev_class, s8 rssi, u8 *eir); +int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir); int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status); int mgmt_discovering(struct hci_dev *hdev, u8 discovering); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 3e320c9..76a3f16 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -129,8 +129,8 @@ struct mgmt_rp_disconnect { } __packed; #define MGMT_ADDR_BREDR 0x00 -#define MGMT_ADDR_LE 0x01 -#define MGMT_ADDR_BREDR_LE 0x02 +#define MGMT_ADDR_LE_PUBLIC 0x01 +#define MGMT_ADDR_LE_RANDOM 0x02 #define MGMT_ADDR_INVALID 0xff struct mgmt_addr_info { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a89cf1f..bbfaaa8 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1437,7 +1437,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.rssi = 0x00; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, 0, NULL); } @@ -1472,7 +1472,8 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->state = BT_CONFIG; hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; - mgmt_connected(hdev, &ev->bdaddr, conn->type); + mgmt_connected(hdev, &ev->bdaddr, conn->type, + conn->dst_type); } else conn->state = BT_CONNECTED; @@ -1505,7 +1506,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->state = BT_CLOSED; if (conn->type == ACL_LINK) mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, - ev->status); + conn->dst_type, ev->status); } if (conn->type == ACL_LINK) @@ -1620,7 +1621,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff conn->state = BT_CLOSED; if (conn->type == ACL_LINK || conn->type == LE_LINK) - mgmt_disconnected(hdev, &conn->dst, conn->type); + mgmt_disconnected(hdev, &conn->dst, conn->type, + conn->dst_type); hci_proto_disconn_cfm(conn, ev->reason); hci_conn_del(conn); @@ -2444,7 +2446,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, NULL); } @@ -2461,7 +2463,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, NULL); } @@ -2604,7 +2606,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x01; hci_inquiry_cache_update(hdev, &data); - mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, info->data); } @@ -2868,14 +2870,15 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff } if (ev->status) { - mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, ev->status); + mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, + conn->dst_type, ev->status); hci_proto_connect_cfm(conn, ev->status); conn->state = BT_CLOSED; hci_conn_del(conn); goto unlock; } - mgmt_connected(hdev, &ev->bdaddr, conn->type); + mgmt_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type); conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a6720c6..d23a803 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1063,11 +1063,18 @@ failed: return err; } -static u8 link_to_mgmt(u8 link_type) +static u8 link_to_mgmt(u8 link_type, u8 addr_type) { switch (link_type) { case LE_LINK: - return MGMT_ADDR_LE; + switch (addr_type) { + case ADDR_LE_DEV_PUBLIC: + return MGMT_ADDR_LE_PUBLIC; + case ADDR_LE_DEV_RANDOM: + return MGMT_ADDR_LE_RANDOM; + default: + return MGMT_ADDR_INVALID; + } case ACL_LINK: return MGMT_ADDR_BREDR; default: @@ -1110,7 +1117,7 @@ static int get_connections(struct sock *sk, u16 index) i = 0; list_for_each_entry(c, &hdev->conn_hash.list, list) { bacpy(&rp->addr[i].bdaddr, &c->dst); - rp->addr[i].type = link_to_mgmt(c->type); + rp->addr[i].type = link_to_mgmt(c->type, c->dst_type); if (rp->addr[i].type == MGMT_ADDR_INVALID) continue; i++; @@ -2088,12 +2095,13 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); } -int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type) +int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type) { struct mgmt_addr_info ev; bacpy(&ev.bdaddr, bdaddr); - ev.type = link_to_mgmt(link_type); + ev.type = link_to_mgmt(link_type, addr_type); return mgmt_event(MGMT_EV_CONNECTED, hdev, &ev, sizeof(ev), NULL); } @@ -2114,7 +2122,8 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_remove(cmd); } -int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) +int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type) { struct mgmt_addr_info ev; struct sock *sk = NULL; @@ -2123,7 +2132,7 @@ int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk); bacpy(&ev.bdaddr, bdaddr); - ev.type = link_to_mgmt(type); + ev.type = link_to_mgmt(link_type, addr_type); err = mgmt_event(MGMT_EV_DISCONNECTED, hdev, &ev, sizeof(ev), sk); @@ -2149,13 +2158,13 @@ int mgmt_disconnect_failed(struct hci_dev *hdev) return err; } -int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, - u8 status) +int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, u8 status) { struct mgmt_ev_connect_failed ev; bacpy(&ev.addr.bdaddr, bdaddr); - ev.addr.type = link_to_mgmt(type); + ev.addr.type = link_to_mgmt(link_type, addr_type); ev.status = status; return mgmt_event(MGMT_EV_CONNECT_FAILED, hdev, &ev, sizeof(ev), NULL); @@ -2342,15 +2351,15 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, return err; } -int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, - u8 *dev_class, s8 rssi, u8 *eir) +int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir) { struct mgmt_ev_device_found ev; memset(&ev, 0, sizeof(ev)); bacpy(&ev.addr.bdaddr, bdaddr); - ev.addr.type = link_to_mgmt(type); + ev.addr.type = link_to_mgmt(link_type, addr_type); ev.rssi = rssi; if (eir) -- cgit v0.10.2 From c3f06755ca4279597cd58befd6c076ae2e3db480 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 10 Nov 2011 15:54:37 +0200 Subject: Bluetooth: Fix deadlock with mgmt_pair_device The hci_conn callbacks are called with the hci_dev lock already held so no locking should be attempted in them. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d23a803..c3d7852 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1331,19 +1331,14 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) static void pairing_complete_cb(struct hci_conn *conn, u8 status) { struct pending_cmd *cmd; - struct hci_dev *hdev = conn->hdev; BT_DBG("status %u", status); - hci_dev_lock_bh(hdev); - cmd = find_pairing(conn); if (!cmd) BT_DBG("Unable to find a pending command"); else pairing_complete(cmd, status); - - hci_dev_unlock_bh(hdev); } static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len) -- cgit v0.10.2 From a8a1d19e9d00e2ec6f28b89133137390b1d293bd Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 10 Nov 2011 15:54:38 +0200 Subject: Bluetooth: Add proper response to mgmt_remove_keys command Since the command can fail we need to have a proper response with the remote address and a failure status for it. This also updates it to conform to the latest mgmt API spec. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 76a3f16..e5a866a 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -119,6 +119,10 @@ struct mgmt_cp_remove_keys { bdaddr_t bdaddr; __u8 disconnect; } __packed; +struct mgmt_rp_remove_keys { + bdaddr_t bdaddr; + __u8 status; +}; #define MGMT_OP_DISCONNECT 0x000F struct mgmt_cp_disconnect { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c3d7852..dddb190 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -961,6 +961,9 @@ static int remove_keys(struct sock *sk, u16 index, unsigned char *data, { struct hci_dev *hdev; struct mgmt_cp_remove_keys *cp; + struct mgmt_rp_remove_keys rp; + struct hci_cp_disconnect dc; + struct pending_cmd *cmd; struct hci_conn *conn; int err; @@ -975,27 +978,44 @@ static int remove_keys(struct sock *sk, u16 index, unsigned char *data, hci_dev_lock_bh(hdev); + memset(&rp, 0, sizeof(rp)); + bacpy(&rp.bdaddr, &cp->bdaddr); + err = hci_remove_link_key(hdev, &cp->bdaddr); - if (err < 0) { - err = cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, -err); + if (err < 0) goto unlock; - } - - err = 0; - if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) + if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) { + err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, + sizeof(rp)); goto unlock; + } conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); - if (conn) { - struct hci_cp_disconnect dc; + if (!conn) { + err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, + sizeof(rp)); + goto unlock; + } - put_unaligned_le16(conn->handle, &dc.handle); - dc.reason = 0x13; /* Remote User Terminated Connection */ - err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc); + cmd = mgmt_pending_add(sk, MGMT_OP_REMOVE_KEYS, hdev, cp, sizeof(*cp)); + if (!cmd) { + err = -ENOMEM; + goto unlock; } + put_unaligned_le16(conn->handle, &dc.handle); + dc.reason = 0x13; /* Remote User Terminated Connection */ + err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc); + if (err < 0) + mgmt_pending_remove(cmd); + unlock: + if (err < 0) { + rp.status = -err; + err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, + sizeof(rp)); + } hci_dev_unlock_bh(hdev); hci_dev_put(hdev); @@ -2117,6 +2137,23 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_remove(cmd); } +static void remove_keys_rsp(struct pending_cmd *cmd, void *data) +{ + u8 *status = data; + struct mgmt_cp_remove_keys *cp = cmd->param; + struct mgmt_rp_remove_keys rp; + + memset(&rp, 0, sizeof(rp)); + bacpy(&rp.bdaddr, &cp->bdaddr); + if (status != NULL) + rp.status = *status; + + cmd_complete(cmd->sk, cmd->index, MGMT_OP_REMOVE_KEYS, &rp, + sizeof(rp)); + + mgmt_pending_remove(cmd); +} + int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type) { @@ -2134,6 +2171,8 @@ int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, if (sk) sock_put(sk); + mgmt_pending_foreach(MGMT_OP_REMOVE_KEYS, hdev, remove_keys_rsp, NULL); + return err; } -- cgit v0.10.2 From 37d9ef76c26092098e8fbd3fd540b7ac2181e6bf Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 10 Nov 2011 15:54:39 +0200 Subject: Bluetooth: Add status parameter to mgmt_disconnect response Since disconnecting may fail the status needs to be communicated to user space. This also updates the implementation to match the latest mgmt API specification. Signed-off-by: Johan Hedberg Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5f401e7..a67ff88 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -919,7 +919,7 @@ int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type); int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type); -int mgmt_disconnect_failed(struct hci_dev *hdev); +int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index e5a866a..8b07a83 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -130,6 +130,7 @@ struct mgmt_cp_disconnect { } __packed; struct mgmt_rp_disconnect { bdaddr_t bdaddr; + __u8 status; } __packed; #define MGMT_ADDR_BREDR 0x00 diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index bbfaaa8..0d55d00 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1605,27 +1605,27 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff BT_DBG("%s status %d", hdev->name, ev->status); - if (ev->status) { - hci_dev_lock(hdev); - mgmt_disconnect_failed(hdev); - hci_dev_unlock(hdev); - return; - } - hci_dev_lock(hdev); conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); if (!conn) goto unlock; - conn->state = BT_CLOSED; + if (ev->status == 0) + conn->state = BT_CLOSED; - if (conn->type == ACL_LINK || conn->type == LE_LINK) - mgmt_disconnected(hdev, &conn->dst, conn->type, + if (conn->type == ACL_LINK || conn->type == LE_LINK) { + if (ev->status != 0) + mgmt_disconnect_failed(hdev, &conn->dst, ev->status); + else + mgmt_disconnected(hdev, &conn->dst, conn->type, conn->dst_type); + } - hci_proto_disconn_cfm(conn, ev->reason); - hci_conn_del(conn); + if (ev->status == 0) { + hci_proto_disconn_cfm(conn, ev->reason); + hci_conn_del(conn); + } unlock: hci_dev_unlock(hdev); @@ -2098,7 +2098,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) case HCI_OP_DISCONNECT: if (ev->status != 0) - mgmt_disconnect_failed(hdev); + mgmt_disconnect_failed(hdev, NULL, ev->status); break; case HCI_OP_LE_CREATE_CONN: diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index dddb190..5562c21 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2128,6 +2128,7 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) struct mgmt_rp_disconnect rp; bacpy(&rp.bdaddr, &cp->bdaddr); + rp.status = 0; cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, &rp, sizeof(rp)); @@ -2176,7 +2177,7 @@ int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, return err; } -int mgmt_disconnect_failed(struct hci_dev *hdev) +int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) { struct pending_cmd *cmd; int err; @@ -2185,7 +2186,17 @@ int mgmt_disconnect_failed(struct hci_dev *hdev) if (!cmd) return -ENOENT; - err = cmd_status(cmd->sk, hdev->id, MGMT_OP_DISCONNECT, EIO); + if (bdaddr) { + struct mgmt_rp_disconnect rp; + + bacpy(&rp.bdaddr, bdaddr); + rp.status = status; + + err = cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, + &rp, sizeof(rp)); + } else + err = cmd_status(cmd->sk, hdev->id, MGMT_OP_DISCONNECT, + status); mgmt_pending_remove(cmd); -- cgit v0.10.2 From 7be620f79714b6598275bd5c71d89bb24dfe332e Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Thu, 10 Nov 2011 12:12:55 -0800 Subject: ARM: OMAP: Fix dpll_data compile error when omap2 only is selected Without this patch we get the following error: arch/arm/mach-omap2/clkt_dpll.c: In function '_dpll_test_fint': arch/arm/mach-omap2/clkt_dpll.c:98: error: 'struct dpll_data' has no member named 'flags' Signed-off-by: Tony Lindgren diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h index 197ca03..eb73ab4 100644 --- a/arch/arm/plat-omap/include/plat/clock.h +++ b/arch/arm/plat-omap/include/plat/clock.h @@ -165,8 +165,8 @@ struct dpll_data { u8 auto_recal_bit; u8 recal_en_bit; u8 recal_st_bit; - u8 flags; # endif + u8 flags; }; #endif -- cgit v0.10.2 From d45fc42323b7909829b8f27f26676c675f26551f Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Sat, 5 Nov 2011 19:54:24 -0200 Subject: Bluetooth: Rename l2cap_check_security() rename to l2cap_chan_check_security() to make it consistent with other l2cap_exported functions. This function will be exported in a later commit. Signed-off-by: Gustavo F. Padovan diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 875021a..1e6fda4 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -810,5 +810,6 @@ int l2cap_chan_connect(struct l2cap_chan *chan); int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u32 priority); void l2cap_chan_busy(struct l2cap_chan *chan, int busy); +int l2cap_chan_check_security(struct l2cap_chan *chan); #endif /* __L2CAP_H */ diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index e8a6837..4339508 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -518,7 +518,7 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan) } /* Service level security */ -static inline int l2cap_check_security(struct l2cap_chan *chan) +int l2cap_chan_check_security(struct l2cap_chan *chan) { struct l2cap_conn *conn = chan->conn; __u8 auth_type; @@ -664,7 +664,7 @@ static void l2cap_do_start(struct l2cap_chan *chan) if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)) return; - if (l2cap_check_security(chan) && + if (l2cap_chan_check_security(chan) && __l2cap_no_conn_pending(chan)) { struct l2cap_conn_req req; req.scid = cpu_to_le16(chan->scid); @@ -754,7 +754,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) if (chan->state == BT_CONNECT) { struct l2cap_conn_req req; - if (!l2cap_check_security(chan) || + if (!l2cap_chan_check_security(chan) || !__l2cap_no_conn_pending(chan)) { bh_unlock_sock(sk); continue; @@ -787,7 +787,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) rsp.scid = cpu_to_le16(chan->dcid); rsp.dcid = cpu_to_le16(chan->scid); - if (l2cap_check_security(chan)) { + if (l2cap_chan_check_security(chan)) { if (bt_sk(sk)->defer_setup) { struct sock *parent = bt_sk(sk)->parent; rsp.result = cpu_to_le16(L2CAP_CR_PEND); @@ -1181,7 +1181,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan) if (hcon->state == BT_CONNECTED) { if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { __clear_chan_timer(chan); - if (l2cap_check_security(chan)) + if (l2cap_chan_check_security(chan)) l2cap_state_change(chan, BT_CONNECTED); } else l2cap_do_start(chan); @@ -2606,7 +2606,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd chan->ident = cmd->ident; if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) { - if (l2cap_check_security(chan)) { + if (l2cap_chan_check_security(chan)) { if (bt_sk(sk)->defer_setup) { l2cap_state_change(chan, BT_CONNECT2); result = L2CAP_CR_PEND; -- cgit v0.10.2 From 0bee1d60cbad24288c75573511356d450c1fd45a Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Sat, 5 Nov 2011 19:58:31 -0200 Subject: Bluetooth: Allow L2CAP to increase the security level Some incomming connections needs to increase the security level by requesting encryption for example (HID keyboard case). This change allows the userspace to change it through setsockopt with defer_setup enabled. Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 567b585..b85e390 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -625,8 +625,13 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch chan->sec_level = sec.level; + if (!chan->conn) + break; + conn = chan->conn; - if (conn && chan->scid == L2CAP_CID_LE_DATA) { + + /*change security for LE channels */ + if (chan->scid == L2CAP_CID_LE_DATA) { if (!conn->hcon->out) { err = -EINVAL; break; @@ -634,9 +639,14 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch if (smp_conn_security(conn, sec.level)) break; - - err = 0; sk->sk_state = BT_CONFIG; + + /* or for ACL link, under defer_setup time */ + } else if (sk->sk_state == BT_CONNECT2 && + bt_sk(sk)->defer_setup) { + err = l2cap_chan_check_security(chan); + } else { + err = -EINVAL; } break; -- cgit v0.10.2 From a528721da08a793e0cec6ef6281d404eddd6e27b Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 4 Nov 2011 15:05:24 +0000 Subject: ARM: restart: add restart hook to machine_desc record Add a restart hook to the machine_desc record so we don't have to populate all platforms with init_early methods to initialize the arm_pm_restart function pointer. Acked-by: Nicolas Pitre Acked-by: Will Deacon Acked-by: H Hartley Sweeten Acked-by: Tony Lindgren Signed-off-by: Russell King diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index 7d19425..8aa397a 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h @@ -45,6 +45,7 @@ struct machine_desc { #ifdef CONFIG_MULTI_IRQ_HANDLER void (*handle_irq)(struct pt_regs *); #endif + void (*restart)(char, const char *); }; /* diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 7e7977a..4755e28 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -922,6 +922,9 @@ void __init setup_arch(char **cmdline_p) paging_init(mdesc); request_standard_resources(mdesc); + if (mdesc->restart) + arm_pm_restart = mdesc->restart; + unflatten_device_tree(); #ifdef CONFIG_SMP -- cgit v0.10.2 From b44c350d4104265cf3a6b4355dc1ee05c16aa5de Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 1 Nov 2011 14:27:33 +0000 Subject: ARM: restart: allow platforms more flexibility specifying restart mode Change 'soft_reboot' into a more generic 'restart_mode' variable, allowing the default restart mode to be specified. Acked-by: Nicolas Pitre Acked-by: Will Deacon Acked-by: H Hartley Sweeten Signed-off-by: Russell King diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index 8aa397a..6fe6cf0 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h @@ -30,10 +30,10 @@ struct machine_desc { unsigned int video_start; /* start of video RAM */ unsigned int video_end; /* end of video RAM */ - unsigned int reserve_lp0 :1; /* never has lp0 */ - unsigned int reserve_lp1 :1; /* never has lp1 */ - unsigned int reserve_lp2 :1; /* never has lp2 */ - unsigned int soft_reboot :1; /* soft reboot */ + unsigned char reserve_lp0 :1; /* never has lp0 */ + unsigned char reserve_lp1 :1; /* never has lp1 */ + unsigned char reserve_lp2 :1; /* never has lp2 */ + char restart_mode; /* default restart mode */ void (*fixup)(struct tag *, char **, struct meminfo *); void (*reserve)(void);/* reserve mem blocks */ diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 4755e28..a753880 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -902,8 +902,8 @@ void __init setup_arch(char **cmdline_p) machine_desc = mdesc; machine_name = mdesc->name; - if (mdesc->soft_reboot) - reboot_setup("s"); + if (mdesc->restart_mode) + reboot_setup(&mdesc->restart_mode); init_mm.start_code = (unsigned long) _text; init_mm.end_code = (unsigned long) _etext; diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c index d0ce8ab..ce3ed24 100644 --- a/arch/arm/mach-ebsa110/core.c +++ b/arch/arm/mach-ebsa110/core.c @@ -283,7 +283,7 @@ MACHINE_START(EBSA110, "EBSA110") .atag_offset = 0x400, .reserve_lp0 = 1, .reserve_lp2 = 1, - .soft_reboot = 1, + .restart_mode = 's', .map_io = ebsa110_map_io, .init_irq = ebsa110_init_irq, .timer = &ebsa110_timer, diff --git a/arch/arm/mach-footbridge/cats-hw.c b/arch/arm/mach-footbridge/cats-hw.c index d5f1785..60b6774 100644 --- a/arch/arm/mach-footbridge/cats-hw.c +++ b/arch/arm/mach-footbridge/cats-hw.c @@ -86,7 +86,7 @@ fixup_cats(struct tag *tags, char **cmdline, struct meminfo *mi) MACHINE_START(CATS, "Chalice-CATS") /* Maintainer: Philip Blundell */ .atag_offset = 0x100, - .soft_reboot = 1, + .restart_mode = 's', .fixup = fixup_cats, .map_io = footbridge_map_io, .init_irq = footbridge_init_irq, -- cgit v0.10.2 From 34adeda943e1fb10e8de022b834996e04241fa7d Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 1 Nov 2011 16:24:18 +0000 Subject: ARM: restart: add default restart modes for PXA mioa701, spitz and tosa Add a default restart mode to reflect the hard-coded restart mode found in these files. Acked-by: Nicolas Pitre Acked-by: Will Deacon Acked-by: H Hartley Sweeten Acked-by: Robert Jarzmik Signed-off-by: Russell King diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c index b938fc2..4f47a76 100644 --- a/arch/arm/mach-pxa/mioa701.c +++ b/arch/arm/mach-pxa/mioa701.c @@ -752,6 +752,7 @@ static void mioa701_machine_exit(void) MACHINE_START(MIOA701, "MIO A701") .atag_offset = 0x100, + .restart_mode = 's', .map_io = &pxa27x_map_io, .init_irq = &pxa27x_init_irq, .handle_irq = &pxa27x_handle_irq, diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 953a919..2f57d94 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -982,6 +982,7 @@ static void __init spitz_fixup(struct tag *tags, char **cmdline, #ifdef CONFIG_MACH_SPITZ MACHINE_START(SPITZ, "SHARP Spitz") + .restart_mode = 'g', .fixup = spitz_fixup, .map_io = pxa27x_map_io, .init_irq = pxa27x_init_irq, @@ -993,6 +994,7 @@ MACHINE_END #ifdef CONFIG_MACH_BORZOI MACHINE_START(BORZOI, "SHARP Borzoi") + .restart_mode = 'g', .fixup = spitz_fixup, .map_io = pxa27x_map_io, .init_irq = pxa27x_init_irq, @@ -1004,6 +1006,7 @@ MACHINE_END #ifdef CONFIG_MACH_AKITA MACHINE_START(AKITA, "SHARP Akita") + .restart_mode = 'g', .fixup = spitz_fixup, .map_io = pxa27x_map_io, .init_irq = pxa27x_init_irq, diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c index 402b0c9..ef64530 100644 --- a/arch/arm/mach-pxa/tosa.c +++ b/arch/arm/mach-pxa/tosa.c @@ -970,6 +970,7 @@ static void __init fixup_tosa(struct tag *tags, char **cmdline, } MACHINE_START(TOSA, "SHARP Tosa") + .restart_mode = 'g', .fixup = fixup_tosa, .map_io = pxa25x_map_io, .nr_irqs = TOSA_NR_IRQS, -- cgit v0.10.2 From ac15e00b1efe705b66a36d1a6a9db7f6ed524c43 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 31 Oct 2011 09:22:22 +0000 Subject: ARM: restart: move reboot failure handing into machine_restart() Move the failure to reboot into machine_restart() to always catch this condition, even if a platform decides to hook the restarting via arm_pm_restart(). Acked-by: Nicolas Pitre Acked-by: Will Deacon Acked-by: H Hartley Sweeten Acked-by: Tony Lindgren Signed-off-by: Russell King diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 75316f0..3bda1c3 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -114,18 +114,8 @@ void arm_machine_restart(char mode, const char *cmd) /* Push out any further dirty data, and ensure cache is empty */ flush_cache_all(); - /* - * Now call the architecture specific reboot code. - */ + /* Now call the architecture specific reboot code. */ arch_reset(mode, cmd); - - /* - * Whoops - the architecture was unable to reboot. - * Tell the user! - */ - mdelay(1000); - printk("Reboot failed -- System halted\n"); - while (1); } /* @@ -250,7 +240,15 @@ void machine_power_off(void) void machine_restart(char *cmd) { machine_shutdown(); + arm_pm_restart(reboot_mode, cmd); + + /* Give a grace period for failure to restart of 1s */ + mdelay(1000); + + /* Whoops - the platform was unable to reboot. Tell the user! */ + printk("Reboot failed -- System halted\n"); + while (1); } void __show_regs(struct pt_regs *regs) -- cgit v0.10.2 From 5aafec15bdc54cf0722696c95091d7bd674bfcad Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 1 Nov 2011 10:15:27 +0000 Subject: ARM: restart: remove argument to setup_mm_for_reboot() setup_mm_for_reboot() doesn't make use of its argument, so remove it. Acked-by: Nicolas Pitre Acked-by: Will Deacon Acked-by: H Hartley Sweeten Acked-by: Tony Lindgren Signed-off-by: Russell King diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index c1b4463..cc40b96 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c @@ -16,7 +16,7 @@ extern const unsigned char relocate_new_kernel[]; extern const unsigned int relocate_new_kernel_size; -extern void setup_mm_for_reboot(char mode); +extern void setup_mm_for_reboot(void); extern unsigned long kexec_start_address; extern unsigned long kexec_indirection_page; @@ -114,7 +114,7 @@ void machine_kexec(struct kimage *image) kexec_reinit(); local_irq_disable(); local_fiq_disable(); - setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/ + setup_mm_for_reboot(); flush_cache_all(); outer_flush_all(); outer_disable(); diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 3bda1c3..4181738 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -57,7 +57,7 @@ static const char *isa_modes[] = { "ARM" , "Thumb" , "Jazelle", "ThumbEE" }; -extern void setup_mm_for_reboot(char mode); +extern void setup_mm_for_reboot(void); static volatile int hlt_counter; @@ -103,7 +103,7 @@ void arm_machine_restart(char mode, const char *cmd) * we may need it to insert some 1:1 mappings so that * soft boot works. */ - setup_mm_for_reboot(mode); + setup_mm_for_reboot(); /* Clean and invalidate caches */ flush_cache_all(); diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c index 2be9139..296ad2e 100644 --- a/arch/arm/mm/idmap.c +++ b/arch/arm/mm/idmap.c @@ -78,7 +78,7 @@ void identity_mapping_del(pgd_t *pgd, unsigned long addr, unsigned long end) * the user-mode pages. This will then ensure that we have predictable * results when turning the mmu off */ -void setup_mm_for_reboot(char mode) +void setup_mm_for_reboot(void) { /* * We need to access to user-mode page tables here. For kernel threads diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index 941a98c..8841751 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c @@ -43,7 +43,7 @@ void __init paging_init(struct machine_desc *mdesc) /* * We don't need to do anything here for nommu machines. */ -void setup_mm_for_reboot(char mode) +void setup_mm_for_reboot(void) { } -- cgit v0.10.2 From 4d611e4d3dc78efcba514d235b5f0a6df0828372 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 23 Jun 2011 19:30:48 -0300 Subject: Bluetooth: Only set ack_timer if we didn't send and ack Signed-off-by: Gustavo F. Padovan diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 4339508..1790ce3 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3928,11 +3928,12 @@ expected: l2cap_retransmit_frames(chan); } - __set_ack_timer(chan); chan->num_acked = (chan->num_acked + 1) % num_to_ack; if (chan->num_acked == num_to_ack - 1) l2cap_send_ack(chan); + else + __set_ack_timer(chan); return 0; -- cgit v0.10.2 From f1f9217926b2180237fd38b3f7fc6e932bcb1827 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 1 Oct 2011 16:12:36 +0530 Subject: ath6kl: Enable force foreground scan in connected state This was disabled beacause there was a network stall issue when scan is issued. This issue does not happen with the new firmware (3.1.1.609), enable it back. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index daf444b..f03cc4a 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -639,6 +639,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, s8 n_channels = 0; u16 *channels = NULL; int ret = 0; + u32 force_fg_scan = 0; if (!ath6kl_cfg80211_ready(ar)) return -EIO; @@ -700,7 +701,10 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, channels[i] = request->channels[i]->center_freq; } - ret = ath6kl_wmi_startscan_cmd(ar->wmi, WMI_LONG_SCAN, 0, + if (test_bit(CONNECTED, &ar->flag)) + force_fg_scan = 1; + + ret = ath6kl_wmi_startscan_cmd(ar->wmi, WMI_LONG_SCAN, force_fg_scan, false, 0, 0, n_channels, channels); if (ret) ath6kl_err("wmi_startscan_cmd failed\n"); -- cgit v0.10.2 From 1555f7339db57987487e2bd849bca9a104109c18 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 30 Sep 2011 19:18:42 +0530 Subject: ath6kl: Fix sparse warning "symbol 'conn' shadows an earlier one" Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index a711707..bcf7b01 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1235,7 +1235,6 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) * frame to it on the air else send the * frame up the stack. */ - struct ath6kl_sta *conn = NULL; conn = ath6kl_find_sta(ar, datap->h_dest); if (conn && ar->intra_bss) { -- cgit v0.10.2 From 151bd30bdf88551d68a743b7f7504ca0f3ff2796 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 30 Sep 2011 19:18:43 +0530 Subject: ath6kl: Replace spin_lock_irqsave with spin_lock_bh It is not necessary to use spinlock primitive to protect data which is accessed in hard irq context as nothing is running in hard irq with this driver. The spinlock primitive meant to protect data in softirq context is more appropriate. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 30b5a53..adb1635 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1025,8 +1025,6 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, u8 assoc_req_len, u8 assoc_resp_len, u8 *assoc_info) { - unsigned long flags; - ath6kl_cfg80211_connect_event(ar, channel, bssid, listen_int, beacon_int, net_type, beacon_ie_len, @@ -1043,11 +1041,11 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, netif_wake_queue(ar->net_dev); /* Update connect & link status atomically */ - spin_lock_irqsave(&ar->lock, flags); + spin_lock_bh(&ar->lock); set_bit(CONNECTED, &ar->flag); clear_bit(CONNECT_PEND, &ar->flag); netif_carrier_on(ar->net_dev); - spin_unlock_irqrestore(&ar->lock, flags); + spin_unlock_bh(&ar->lock); aggr_reset_state(ar->aggr_cntxt); ar->reconnect_flag = 0; @@ -1330,8 +1328,6 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 prot_reason_status) { - unsigned long flags; - if (ar->nw_type == AP_NETWORK) { if (!ath6kl_remove_sta(ar, bssid, prot_reason_status)) return; @@ -1390,10 +1386,10 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, } /* update connect & link status atomically */ - spin_lock_irqsave(&ar->lock, flags); + spin_lock_bh(&ar->lock); clear_bit(CONNECTED, &ar->flag); netif_carrier_off(ar->net_dev); - spin_unlock_irqrestore(&ar->lock, flags); + spin_unlock_bh(&ar->lock); if ((reason != CSERV_DISCONNECT) || (ar->reconnect_flag != 1)) ar->reconnect_flag = 0; @@ -1411,9 +1407,8 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, static int ath6kl_open(struct net_device *dev) { struct ath6kl *ar = ath6kl_priv(dev); - unsigned long flags; - spin_lock_irqsave(&ar->lock, flags); + spin_lock_bh(&ar->lock); set_bit(WLAN_ENABLED, &ar->flag); @@ -1423,7 +1418,7 @@ static int ath6kl_open(struct net_device *dev) } else netif_carrier_off(dev); - spin_unlock_irqrestore(&ar->lock, flags); + spin_unlock_bh(&ar->lock); return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index f1dc311..2dd7a88 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -166,12 +166,11 @@ static int ath6kl_sdio_io(struct sdio_func *func, u32 request, u32 addr, static struct bus_request *ath6kl_sdio_alloc_busreq(struct ath6kl_sdio *ar_sdio) { struct bus_request *bus_req; - unsigned long flag; - spin_lock_irqsave(&ar_sdio->lock, flag); + spin_lock_bh(&ar_sdio->lock); if (list_empty(&ar_sdio->bus_req_freeq)) { - spin_unlock_irqrestore(&ar_sdio->lock, flag); + spin_unlock_bh(&ar_sdio->lock); return NULL; } @@ -179,7 +178,7 @@ static struct bus_request *ath6kl_sdio_alloc_busreq(struct ath6kl_sdio *ar_sdio) struct bus_request, list); list_del(&bus_req->list); - spin_unlock_irqrestore(&ar_sdio->lock, flag); + spin_unlock_bh(&ar_sdio->lock); ath6kl_dbg(ATH6KL_DBG_SCATTER, "%s: bus request 0x%p\n", __func__, bus_req); @@ -189,14 +188,12 @@ static struct bus_request *ath6kl_sdio_alloc_busreq(struct ath6kl_sdio *ar_sdio) static void ath6kl_sdio_free_bus_req(struct ath6kl_sdio *ar_sdio, struct bus_request *bus_req) { - unsigned long flag; - ath6kl_dbg(ATH6KL_DBG_SCATTER, "%s: bus request 0x%p\n", __func__, bus_req); - spin_lock_irqsave(&ar_sdio->lock, flag); + spin_lock_bh(&ar_sdio->lock); list_add_tail(&bus_req->list, &ar_sdio->bus_req_freeq); - spin_unlock_irqrestore(&ar_sdio->lock, flag); + spin_unlock_bh(&ar_sdio->lock); } static void ath6kl_sdio_setup_scat_data(struct hif_scatter_req *scat_req, @@ -424,20 +421,19 @@ static void __ath6kl_sdio_write_async(struct ath6kl_sdio *ar_sdio, static void ath6kl_sdio_write_async_work(struct work_struct *work) { struct ath6kl_sdio *ar_sdio; - unsigned long flags; struct bus_request *req, *tmp_req; ar_sdio = container_of(work, struct ath6kl_sdio, wr_async_work); sdio_claim_host(ar_sdio->func); - spin_lock_irqsave(&ar_sdio->wr_async_lock, flags); + spin_lock_bh(&ar_sdio->wr_async_lock); list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) { list_del(&req->list); - spin_unlock_irqrestore(&ar_sdio->wr_async_lock, flags); + spin_unlock_bh(&ar_sdio->wr_async_lock); __ath6kl_sdio_write_async(ar_sdio, req); - spin_lock_irqsave(&ar_sdio->wr_async_lock, flags); + spin_lock_bh(&ar_sdio->wr_async_lock); } - spin_unlock_irqrestore(&ar_sdio->wr_async_lock, flags); + spin_unlock_bh(&ar_sdio->wr_async_lock); sdio_release_host(ar_sdio->func); } @@ -520,7 +516,6 @@ static int ath6kl_sdio_write_async(struct ath6kl *ar, u32 address, u8 *buffer, { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct bus_request *bus_req; - unsigned long flags; bus_req = ath6kl_sdio_alloc_busreq(ar_sdio); @@ -533,9 +528,9 @@ static int ath6kl_sdio_write_async(struct ath6kl *ar, u32 address, u8 *buffer, bus_req->request = request; bus_req->packet = packet; - spin_lock_irqsave(&ar_sdio->wr_async_lock, flags); + spin_lock_bh(&ar_sdio->wr_async_lock); list_add_tail(&bus_req->list, &ar_sdio->wr_asyncq); - spin_unlock_irqrestore(&ar_sdio->wr_async_lock, flags); + spin_unlock_bh(&ar_sdio->wr_async_lock); queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work); return 0; @@ -581,9 +576,8 @@ static struct hif_scatter_req *ath6kl_sdio_scatter_req_get(struct ath6kl *ar) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct hif_scatter_req *node = NULL; - unsigned long flag; - spin_lock_irqsave(&ar_sdio->scat_lock, flag); + spin_lock_bh(&ar_sdio->scat_lock); if (!list_empty(&ar_sdio->scat_req)) { node = list_first_entry(&ar_sdio->scat_req, @@ -591,7 +585,7 @@ static struct hif_scatter_req *ath6kl_sdio_scatter_req_get(struct ath6kl *ar) list_del(&node->list); } - spin_unlock_irqrestore(&ar_sdio->scat_lock, flag); + spin_unlock_bh(&ar_sdio->scat_lock); return node; } @@ -600,13 +594,12 @@ static void ath6kl_sdio_scatter_req_add(struct ath6kl *ar, struct hif_scatter_req *s_req) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); - unsigned long flag; - spin_lock_irqsave(&ar_sdio->scat_lock, flag); + spin_lock_bh(&ar_sdio->scat_lock); list_add_tail(&s_req->list, &ar_sdio->scat_req); - spin_unlock_irqrestore(&ar_sdio->scat_lock, flag); + spin_unlock_bh(&ar_sdio->scat_lock); } @@ -617,7 +610,6 @@ static int ath6kl_sdio_async_rw_scatter(struct ath6kl *ar, struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); u32 request = scat_req->req; int status = 0; - unsigned long flags; if (!scat_req->len) return -EINVAL; @@ -631,9 +623,9 @@ static int ath6kl_sdio_async_rw_scatter(struct ath6kl *ar, status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest); sdio_release_host(ar_sdio->func); } else { - spin_lock_irqsave(&ar_sdio->wr_async_lock, flags); + spin_lock_bh(&ar_sdio->wr_async_lock); list_add_tail(&scat_req->busrequest->list, &ar_sdio->wr_asyncq); - spin_unlock_irqrestore(&ar_sdio->wr_async_lock, flags); + spin_unlock_bh(&ar_sdio->wr_async_lock); queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work); } @@ -645,13 +637,12 @@ static void ath6kl_sdio_cleanup_scatter(struct ath6kl *ar) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct hif_scatter_req *s_req, *tmp_req; - unsigned long flag; /* empty the free list */ - spin_lock_irqsave(&ar_sdio->scat_lock, flag); + spin_lock_bh(&ar_sdio->scat_lock); list_for_each_entry_safe(s_req, tmp_req, &ar_sdio->scat_req, list) { list_del(&s_req->list); - spin_unlock_irqrestore(&ar_sdio->scat_lock, flag); + spin_unlock_bh(&ar_sdio->scat_lock); if (s_req->busrequest) ath6kl_sdio_free_bus_req(ar_sdio, s_req->busrequest); @@ -659,9 +650,9 @@ static void ath6kl_sdio_cleanup_scatter(struct ath6kl *ar) kfree(s_req->sgentries); kfree(s_req); - spin_lock_irqsave(&ar_sdio->scat_lock, flag); + spin_lock_bh(&ar_sdio->scat_lock); } - spin_unlock_irqrestore(&ar_sdio->scat_lock, flag); + spin_unlock_bh(&ar_sdio->scat_lock); } /* setup of HIF scatter resources */ -- cgit v0.10.2 From 861dd058f495973c7ad2a44b8f68f3cc05733eab Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 30 Sep 2011 21:46:59 +0530 Subject: ath6kl: Claim sdio function only at appropriate places There are places where tx_complete callbacks are called with claiming the sdio function. It is not necessary to hold the sdio func for longer. This may even affect the host side power save, if it is supported by the controller. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 2dd7a88..7695c29 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -134,6 +134,8 @@ static int ath6kl_sdio_io(struct sdio_func *func, u32 request, u32 addr, { int ret = 0; + sdio_claim_host(func); + if (request & HIF_WRITE) { /* FIXME: looks like ugly workaround for something */ if (addr >= HIF_MBOX_BASE_ADDR && @@ -155,6 +157,8 @@ static int ath6kl_sdio_io(struct sdio_func *func, u32 request, u32 addr, ret = sdio_memcpy_fromio(func, buf, addr, len); } + sdio_release_host(func); + ath6kl_dbg(ATH6KL_DBG_SDIO, "%s addr 0x%x%s buf 0x%p len %d\n", request & HIF_WRITE ? "wr" : "rd", addr, request & HIF_FIXED_ADDRESS ? " (fixed)" : "", buf, len); @@ -287,10 +291,14 @@ static int ath6kl_sdio_scat_rw(struct ath6kl_sdio *ar_sdio, mmc_req.cmd = &cmd; mmc_req.data = &data; + sdio_claim_host(ar_sdio->func); + mmc_set_data_timeout(&data, ar_sdio->func->card); /* synchronous call to process request */ mmc_wait_for_req(ar_sdio->func->card->host, &mmc_req); + sdio_release_host(ar_sdio->func); + status = cmd.error ? cmd.error : data.error; scat_complete: @@ -391,11 +399,9 @@ static int ath6kl_sdio_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf, } else tbuf = buf; - sdio_claim_host(ar_sdio->func); ret = ath6kl_sdio_io(ar_sdio->func, request, addr, tbuf, len); if ((request & HIF_READ) && bounced) memcpy(buf, tbuf, len); - sdio_release_host(ar_sdio->func); return ret; } @@ -424,7 +430,6 @@ static void ath6kl_sdio_write_async_work(struct work_struct *work) struct bus_request *req, *tmp_req; ar_sdio = container_of(work, struct ath6kl_sdio, wr_async_work); - sdio_claim_host(ar_sdio->func); spin_lock_bh(&ar_sdio->wr_async_lock); list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) { @@ -434,8 +439,6 @@ static void ath6kl_sdio_write_async_work(struct work_struct *work) spin_lock_bh(&ar_sdio->wr_async_lock); } spin_unlock_bh(&ar_sdio->wr_async_lock); - - sdio_release_host(ar_sdio->func); } static void ath6kl_sdio_irq_handler(struct sdio_func *func) @@ -618,11 +621,9 @@ static int ath6kl_sdio_async_rw_scatter(struct ath6kl *ar, "hif-scatter: total len: %d scatter entries: %d\n", scat_req->len, scat_req->scat_entries); - if (request & HIF_SYNCHRONOUS) { - sdio_claim_host(ar_sdio->func); + if (request & HIF_SYNCHRONOUS) status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest); - sdio_release_host(ar_sdio->func); - } else { + else { spin_lock_bh(&ar_sdio->wr_async_lock); list_add_tail(&scat_req->busrequest->list, &ar_sdio->wr_asyncq); spin_unlock_bh(&ar_sdio->wr_async_lock); -- cgit v0.10.2 From 4159cc935a7ed119e5f824db06defaa34d992b56 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Mon, 3 Oct 2011 17:28:07 +0530 Subject: ath6kl: Fix htc_packet leak in ath6kl_htc_rx_process_packets() Packet is not reclaimed when ath6kl_htc_rx_process_hdr() fails. Fix this by deferring the packet deletion from comp_pktq till ath6kl_htc_rx_process_hdr() returns success. This bug is found in code review, impact is not easily visible as the leak happens only in failure cases. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index f88a7c9..7bc9884 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -1643,7 +1643,6 @@ static int ath6kl_htc_rx_process_packets(struct htc_target *target, int status = 0; list_for_each_entry_safe(packet, tmp_pkt, comp_pktq, list) { - list_del(&packet->list); ep = &target->endpoint[packet->endpoint]; /* process header for each of the recv packet */ @@ -1652,6 +1651,8 @@ static int ath6kl_htc_rx_process_packets(struct htc_target *target, if (status) return status; + list_del(&packet->list); + if (list_empty(comp_pktq)) { /* * Last packet's more packet flag is set -- cgit v0.10.2 From b8d5d5ff0305f07061f672c91f63479433451af5 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Mon, 3 Oct 2011 17:28:25 +0530 Subject: ath6kl: Fix htc_packet leak in ath6kl_htc_rx_fetch() It is found during the code review. As the leak would happen only in failure case, the imapct is not easily visible. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 7bc9884..4a03dac 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -1715,12 +1715,10 @@ static int ath6kl_htc_rx_fetch(struct htc_target *target, packet = list_first_entry(rx_pktq, struct htc_packet, list); - list_del(&packet->list); - /* fully synchronous */ packet->completion = NULL; - if (!list_empty(rx_pktq)) + if (!list_is_singular(rx_pktq)) /* * look_aheads in all packet * except the last one in the @@ -1735,7 +1733,7 @@ static int ath6kl_htc_rx_fetch(struct htc_target *target, if (status) return status; - list_add_tail(&packet->list, comp_pktq); + list_move_tail(&packet->list, comp_pktq); } } -- cgit v0.10.2 From 99f54299b973fd436dd9b4b1dd638c16f3d3deb4 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Mon, 3 Oct 2011 17:26:26 +0530 Subject: ath6kl: Avoid processing failed rx packets It is not necessary to process an htc_packet which is allocated for rx but failed in sdio rx. Though it does not fix any real issue, it does not make much sense to process the failed frame. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 4a03dac..ca3d084 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -1687,11 +1687,15 @@ static int ath6kl_htc_rx_fetch(struct htc_target *target, int fetched_pkts; bool part_bundle = false; int status = 0; + struct list_head tmp_rxq; + struct htc_packet *packet, *tmp_pkt; /* now go fetch the list of HTC packets */ while (!list_empty(rx_pktq)) { fetched_pkts = 0; + INIT_LIST_HEAD(&tmp_rxq); + if (target->rx_bndl_enable && (get_queue_depth(rx_pktq) > 1)) { /* * There are enough packets to attempt a @@ -1699,18 +1703,19 @@ static int ath6kl_htc_rx_fetch(struct htc_target *target, * allowed. */ status = ath6kl_htc_rx_bundle(target, rx_pktq, - comp_pktq, + &tmp_rxq, &fetched_pkts, part_bundle); if (status) - return status; + goto fail_rx; if (!list_empty(rx_pktq)) part_bundle = true; + + list_splice_tail_init(&tmp_rxq, comp_pktq); } if (!fetched_pkts) { - struct htc_packet *packet; packet = list_first_entry(rx_pktq, struct htc_packet, list); @@ -1730,13 +1735,37 @@ static int ath6kl_htc_rx_fetch(struct htc_target *target, /* go fetch the packet */ status = ath6kl_htc_rx_packet(target, packet, packet->act_len); + + list_move_tail(&packet->list, &tmp_rxq); + if (status) - return status; + goto fail_rx; - list_move_tail(&packet->list, comp_pktq); + list_splice_tail_init(&tmp_rxq, comp_pktq); } } + return 0; + +fail_rx: + + /* + * Cleanup any packets we allocated but didn't use to + * actually fetch any packets. + */ + + list_for_each_entry_safe(packet, tmp_pkt, rx_pktq, list) { + list_del(&packet->list); + htc_reclaim_rxbuf(target, packet, + &target->endpoint[packet->endpoint]); + } + + list_for_each_entry_safe(packet, tmp_pkt, &tmp_rxq, list) { + list_del(&packet->list); + htc_reclaim_rxbuf(target, packet, + &target->endpoint[packet->endpoint]); + } + return status; } @@ -1826,15 +1855,6 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, if (status) { ath6kl_err("failed to get pending recv messages: %d\n", status); - /* - * Cleanup any packets we allocated but didn't use to - * actually fetch any packets. - */ - list_for_each_entry_safe(packets, tmp_pkt, &rx_pktq, list) { - list_del(&packets->list); - htc_reclaim_rxbuf(target, packets, - &target->endpoint[packets->endpoint]); - } /* cleanup any packets in sync completion queue */ list_for_each_entry_safe(packets, tmp_pkt, &comp_pktq, list) { -- cgit v0.10.2 From 4533d901a4a78542544b91ad620fffd3307ade04 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Mon, 3 Oct 2011 17:26:27 +0530 Subject: ath6kl: Minor cleanup in msg_look_ahead parameter in ath6kl_htc_rxmsg_pending_handler() It is just a four byte information of the received message from ath6kl_htc_rxmsg_pending_handler(). Remove unnecessary array representaion. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index ca3d084..9a9eae5 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -1770,7 +1770,7 @@ fail_rx: } int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, - u32 msg_look_ahead[], int *num_pkts) + u32 msg_look_ahead, int *num_pkts) { struct htc_packet *packets, *tmp_pkt; struct htc_endpoint *endpoint; @@ -1787,7 +1787,7 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, * On first entry copy the look_aheads into our temp array for * processing */ - memcpy(look_aheads, msg_look_ahead, sizeof(look_aheads)); + look_aheads[0] = msg_look_ahead; while (true) { diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 8ce0c2c..69d44e3 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -563,7 +563,7 @@ int ath6kl_htc_get_rxbuf_num(struct htc_target *target, int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, struct list_head *pktq); int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, - u32 msg_look_ahead[], int *n_pkts); + u32 msg_look_ahead, int *n_pkts); static inline void set_htc_pkt_info(struct htc_packet *packet, void *context, u8 *buf, unsigned int len, diff --git a/drivers/net/wireless/ath/ath6kl/htc_hif.c b/drivers/net/wireless/ath/ath6kl/htc_hif.c index 86b1cc7..37a13f0 100644 --- a/drivers/net/wireless/ath/ath6kl/htc_hif.c +++ b/drivers/net/wireless/ath/ath6kl/htc_hif.c @@ -417,7 +417,7 @@ static int proc_pending_irqs(struct ath6kl_device *dev, bool *done) * we rapidly pull packets. */ status = ath6kl_htc_rxmsg_pending_handler(dev->htc_cnxt, - &lk_ahd, &fetched); + lk_ahd, &fetched); if (status) goto out; -- cgit v0.10.2 From aa6cffc1a275a9369ca83e13cebc4b09e4f23954 Mon Sep 17 00:00:00 2001 From: Chilam Ng Date: Wed, 5 Oct 2011 10:12:52 +0300 Subject: ath6kl: make sure WLAN power save is enabled during suspend Power save is enabled during ath6kl init. But when user space disables power save, the system will go into suspend with power save disabled. The ath6kl driver will now explicitly enable power save prior to entering suspend and restore its previous setting upon resume Signed-off-by: Chilam Ng Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index f03cc4a..2acfa7f 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1421,6 +1421,13 @@ static int ar6k_cfg80211_suspend(struct wiphy *wiphy, return ath6kl_hif_suspend(ar); } + +static int ar6k_cfg80211_resume(struct wiphy *wiphy) +{ + struct ath6kl *ar = wiphy_priv(wiphy); + + return ath6kl_hif_resume(ar); +} #endif static int ath6kl_set_channel(struct wiphy *wiphy, struct net_device *dev, @@ -1832,6 +1839,7 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = { CFG80211_TESTMODE_CMD(ath6kl_tm_cmd) #ifdef CONFIG_PM .suspend = ar6k_cfg80211_suspend, + .resume = ar6k_cfg80211_resume, #endif .set_channel = ath6kl_set_channel, .add_beacon = ath6kl_add_beacon, diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index d6c898f..21b1575 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -74,4 +74,8 @@ static inline int ath6kl_hif_suspend(struct ath6kl *ar) return ar->hif_ops->suspend(ar); } +static inline int ath6kl_hif_resume(struct ath6kl *ar) +{ + return ar->hif_ops->resume(ar); +} #endif diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 797e2d1..906fde9 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -203,6 +203,7 @@ struct ath6kl_hif_ops { struct hif_scatter_req *scat_req); void (*cleanup_scatter)(struct ath6kl *ar); int (*suspend)(struct ath6kl *ar); + int (*resume)(struct ath6kl *ar); }; #endif diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index adb1635..e693756 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -959,6 +959,13 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) "during suspend\n"); ath6kl_cfg80211_scan_complete_event(ar, -ECANCELED); + + /* save the current power mode before enabling power save */ + ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; + + if (ath6kl_wmi_powermode_cmd(ar->wmi, REC_POWER) != 0) + ath6kl_warn("ath6kl_deep_sleep_enable: " + "wmi_powermode_cmd failed\n"); } /* WMI Event handlers */ diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 7695c29..9b8ee1f 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -743,6 +743,18 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) return 0; } +static int ath6kl_sdio_resume(struct ath6kl *ar) +{ + if (ar->wmi->pwr_mode != ar->wmi->saved_pwr_mode) { + if (ath6kl_wmi_powermode_cmd(ar->wmi, + ar->wmi->saved_pwr_mode) != 0) + ath6kl_warn("ath6kl_sdio_resume: " + "wmi_powermode_cmd failed\n"); + } + + return 0; +} + static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .read_write_sync = ath6kl_sdio_read_write_sync, .write_async = ath6kl_sdio_write_async, @@ -754,6 +766,7 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .scat_req_rw = ath6kl_sdio_async_rw_scatter, .cleanup_scatter = ath6kl_sdio_cleanup_scatter, .suspend = ath6kl_sdio_suspend, + .resume = ath6kl_sdio_resume, }; static int ath6kl_sdio_probe(struct sdio_func *func, diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index f8e644d..1600e7c8 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -132,6 +132,7 @@ struct wmi { u8 *last_mgmt_tx_frame; size_t last_mgmt_tx_frame_len; + u8 saved_pwr_mode; }; struct host_app_area { -- cgit v0.10.2 From a7f0c58b893e29b377e7d453883fb4f3793105cf Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 5 Oct 2011 12:23:05 +0300 Subject: ath6kl: remove unused parameters from struct wmi There's no use for these, at least right now, so better to remove them. If some of them are ever needed, we can always add them back. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index a7de23c..ab782d7 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -262,7 +262,12 @@ int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, usr_pri = layer2_priority & 0x7; } - /* workaround for WMM S5 */ + /* + * workaround for WMM S5 + * + * FIXME: wmi->traffic_class is always 100 so this test doesn't + * make sense + */ if ((wmi->traffic_class == WMM_AC_VI) && ((usr_pri == 5) || (usr_pri == 4))) usr_pri = 1; @@ -641,7 +646,6 @@ static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) if (len < sizeof(struct wmi_ready_event_2)) return -EINVAL; - wmi->ready = true; ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, le32_to_cpu(ev->sw_version), le32_to_cpu(ev->abi_version)); @@ -857,8 +861,6 @@ static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) ev->disconn_reason, ev->assoc_resp_len); wmi->is_wmm_enabled = false; - wmi->pair_crypto_type = NONE_CRYPT; - wmi->grp_crypto_type = NONE_CRYPT; ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, ev->bssid, ev->assoc_resp_len, ev->assoc_info, @@ -1639,9 +1641,6 @@ int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, if (bssid != NULL) memcpy(cc->bssid, bssid, ETH_ALEN); - wmi->pair_crypto_type = pairwise_crypto; - wmi->grp_crypto_type = group_crypto; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); return ret; @@ -2477,7 +2476,6 @@ int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) cmd = (struct wmi_set_keepalive_cmd *) skb->data; cmd->keep_alive_intvl = keep_alive_intvl; - wmi->keep_alive_intvl = keep_alive_intvl; ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, NO_SYNC_WMIFLAG); @@ -2818,7 +2816,6 @@ static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) if (skb->len < sizeof(struct wmix_cmd_hdr)) { ath6kl_err("bad packet 1\n"); - wmi->stat.cmd_len_err++; return -EINVAL; } @@ -2840,7 +2837,6 @@ static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) break; default: ath6kl_warn("unknown cmd id 0x%x\n", id); - wmi->stat.cmd_id_err++; ret = -EINVAL; break; } @@ -2863,7 +2859,6 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) if (skb->len < sizeof(struct wmi_cmd_hdr)) { ath6kl_err("bad packet 1\n"); dev_kfree_skb(skb); - wmi->stat.cmd_len_err++; return -EINVAL; } @@ -3068,7 +3063,6 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; default: ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); - wmi->stat.cmd_id_err++; ret = -EINVAL; break; } @@ -3103,16 +3097,9 @@ void *ath6kl_wmi_init(struct ath6kl *dev) wmi->parent_dev = dev; - ath6kl_wmi_qos_state_init(wmi); - wmi->pwr_mode = REC_POWER; - wmi->phy_mode = WMI_11G_MODE; - wmi->pair_crypto_type = NONE_CRYPT; - wmi->grp_crypto_type = NONE_CRYPT; - - wmi->ht_allowed[A_BAND_24GHZ] = 1; - wmi->ht_allowed[A_BAND_5GHZ] = 1; + ath6kl_wmi_qos_state_init(wmi); return wmi; } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 1600e7c8..5166f05 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -93,11 +93,6 @@ struct sq_threshold_params { u8 last_rssi_poll_event; }; -struct wmi_stats { - u32 cmd_len_err; - u32 cmd_id_err; -}; - struct wmi_data_sync_bufs { u8 traffic_class; struct sk_buff *skb; @@ -111,22 +106,15 @@ struct wmi_data_sync_bufs { #define WMM_AC_VO 3 /* voice */ struct wmi { - bool ready; u16 stream_exist_for_ac[WMM_NUM_AC]; u8 fat_pipe_exist; struct ath6kl *parent_dev; - struct wmi_stats stat; u8 pwr_mode; - u8 phy_mode; - u8 keep_alive_intvl; spinlock_t lock; enum htc_endpoint_id ep_id; struct sq_threshold_params sq_threshld[SIGNAL_QUALITY_METRICS_NUM_MAX]; - enum crypto_type pair_crypto_type; - enum crypto_type grp_crypto_type; bool is_wmm_enabled; - u8 ht_allowed[A_NUM_BANDS]; u8 traffic_class; bool is_probe_ssid; -- cgit v0.10.2 From cbf49a6fff1d87510f36afe7e7cec188e452f1db Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 5 Oct 2011 12:23:17 +0300 Subject: ath6kl: fix struct host_app_area endian handling It was missing endian annotation. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 81e0031..aa4dfd5 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -120,7 +120,7 @@ static int ath6kl_set_host_app_area(struct ath6kl *ar) return -EIO; address = TARG_VTOP(ar->target_type, data); - host_app_area.wmi_protocol_ver = WMI_PROTOCOL_VERSION; + host_app_area.wmi_protocol_ver = cpu_to_le32(WMI_PROTOCOL_VERSION); if (ath6kl_diag_write(ar, address, (u8 *) &host_app_area, sizeof(struct host_app_area))) return -EIO; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 5166f05..96102c6 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -124,8 +124,8 @@ struct wmi { }; struct host_app_area { - u32 wmi_protocol_ver; -}; + __le32 wmi_protocol_ver; +} __packed; enum wmi_msg_type { DATA_MSGTYPE = 0x0, -- cgit v0.10.2 From b4be8959c2cca0a0d3136f9d3bf06a52252911f4 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 5 Oct 2011 12:23:25 +0300 Subject: ath6kl: return error block size is not power of 2 Currently only a warning is emitted but no error is returned. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc_hif.c b/drivers/net/wireless/ath/ath6kl/htc_hif.c index 37a13f0..e9d3450 100644 --- a/drivers/net/wireless/ath/ath6kl/htc_hif.c +++ b/drivers/net/wireless/ath/ath6kl/htc_hif.c @@ -621,6 +621,7 @@ int ath6kldev_setup(struct ath6kl_device *dev) /* must be a power of 2 */ if ((dev->htc_cnxt->block_sz & (dev->htc_cnxt->block_sz - 1)) != 0) { WARN_ON(1); + status = -EINVAL; goto fail_setup; } -- cgit v0.10.2 From 8e8ddb2b8d19a952e1dff7a2a8a9d606e52fc3e3 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 5 Oct 2011 12:23:33 +0300 Subject: ath6kl: move htc_hif to hif.c Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile index 8f7a0d1..7070693 100644 --- a/drivers/net/wireless/ath/ath6kl/Makefile +++ b/drivers/net/wireless/ath/ath6kl/Makefile @@ -23,7 +23,7 @@ obj-$(CONFIG_ATH6KL) := ath6kl.o ath6kl-y += debug.o -ath6kl-y += htc_hif.o +ath6kl-y += hif.o ath6kl-y += htc.o ath6kl-y += bmi.o ath6kl-y += cfg80211.o diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c new file mode 100644 index 0000000..629e16c --- /dev/null +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -0,0 +1,643 @@ +/* + * Copyright (c) 2007-2011 Atheros Communications Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "core.h" +#include "target.h" +#include "hif-ops.h" +#include "htc_hif.h" +#include "debug.h" + +#define MAILBOX_FOR_BLOCK_SIZE 1 + +#define ATH6KL_TIME_QUANTUM 10 /* in ms */ + +static int ath6kl_hif_cp_scat_dma_buf(struct hif_scatter_req *req, + bool from_dma) +{ + u8 *buf; + int i; + + buf = req->virt_dma_buf; + + for (i = 0; i < req->scat_entries; i++) { + + if (from_dma) + memcpy(req->scat_list[i].buf, buf, + req->scat_list[i].len); + else + memcpy(buf, req->scat_list[i].buf, + req->scat_list[i].len); + + buf += req->scat_list[i].len; + } + + return 0; +} + +int ath6kl_hif_rw_comp_handler(void *context, int status) +{ + struct htc_packet *packet = context; + + ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + "ath6kl_hif_rw_comp_handler (pkt:0x%p , status: %d\n", + packet, status); + + packet->status = status; + packet->completion(packet->context, packet); + + return 0; +} + +static int ath6kl_hif_proc_dbg_intr(struct ath6kl_device *dev) +{ + u32 dummy; + int status; + + ath6kl_err("target debug interrupt\n"); + + ath6kl_target_failure(dev->ar); + + /* + * read counter to clear the interrupt, the debug error interrupt is + * counter 0. + */ + status = hif_read_write_sync(dev->ar, COUNT_DEC_ADDRESS, + (u8 *)&dummy, 4, HIF_RD_SYNC_BYTE_INC); + if (status) + WARN_ON(1); + + return status; +} + +/* mailbox recv message polling */ +int ath6kl_hif_poll_mboxmsg_rx(struct ath6kl_device *dev, u32 *lk_ahd, + int timeout) +{ + struct ath6kl_irq_proc_registers *rg; + int status = 0, i; + u8 htc_mbox = 1 << HTC_MAILBOX; + + for (i = timeout / ATH6KL_TIME_QUANTUM; i > 0; i--) { + /* this is the standard HIF way, load the reg table */ + status = hif_read_write_sync(dev->ar, HOST_INT_STATUS_ADDRESS, + (u8 *) &dev->irq_proc_reg, + sizeof(dev->irq_proc_reg), + HIF_RD_SYNC_BYTE_INC); + + if (status) { + ath6kl_err("failed to read reg table\n"); + return status; + } + + /* check for MBOX data and valid lookahead */ + if (dev->irq_proc_reg.host_int_status & htc_mbox) { + if (dev->irq_proc_reg.rx_lkahd_valid & + htc_mbox) { + /* + * Mailbox has a message and the look ahead + * is valid. + */ + rg = &dev->irq_proc_reg; + *lk_ahd = + le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]); + break; + } + } + + /* delay a little */ + mdelay(ATH6KL_TIME_QUANTUM); + ath6kl_dbg(ATH6KL_DBG_HTC_RECV, "retry mbox poll : %d\n", i); + } + + if (i == 0) { + ath6kl_err("timeout waiting for recv message\n"); + status = -ETIME; + /* check if the target asserted */ + if (dev->irq_proc_reg.counter_int_status & + ATH6KL_TARGET_DEBUG_INTR_MASK) + /* + * Target failure handler will be called in case of + * an assert. + */ + ath6kl_hif_proc_dbg_intr(dev); + } + + return status; +} + +/* + * Disable packet reception (used in case the host runs out of buffers) + * using the interrupt enable registers through the host I/F + */ +int ath6kl_hif_rx_control(struct ath6kl_device *dev, bool enable_rx) +{ + struct ath6kl_irq_enable_reg regs; + int status = 0; + + /* take the lock to protect interrupt enable shadows */ + spin_lock_bh(&dev->lock); + + if (enable_rx) + dev->irq_en_reg.int_status_en |= + SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01); + else + dev->irq_en_reg.int_status_en &= + ~SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01); + + memcpy(®s, &dev->irq_en_reg, sizeof(regs)); + + spin_unlock_bh(&dev->lock); + + status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS, + ®s.int_status_en, + sizeof(struct ath6kl_irq_enable_reg), + HIF_WR_SYNC_BYTE_INC); + + return status; +} + +int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev, + struct hif_scatter_req *scat_req, bool read) +{ + int status = 0; + + if (read) { + scat_req->req = HIF_RD_SYNC_BLOCK_FIX; + scat_req->addr = dev->ar->mbox_info.htc_addr; + } else { + scat_req->req = HIF_WR_ASYNC_BLOCK_INC; + + scat_req->addr = + (scat_req->len > HIF_MBOX_WIDTH) ? + dev->ar->mbox_info.htc_ext_addr : + dev->ar->mbox_info.htc_addr; + } + + ath6kl_dbg((ATH6KL_DBG_HTC_RECV | ATH6KL_DBG_HTC_SEND), + "ath6kl_hif_submit_scat_req, entries: %d, total len: %d mbox:0x%X (mode: %s : %s)\n", + scat_req->scat_entries, scat_req->len, + scat_req->addr, !read ? "async" : "sync", + (read) ? "rd" : "wr"); + + if (!read && scat_req->virt_scat) { + status = ath6kl_hif_cp_scat_dma_buf(scat_req, false); + if (status) { + scat_req->status = status; + scat_req->complete(dev->ar->htc_target, scat_req); + return 0; + } + } + + status = ath6kl_hif_scat_req_rw(dev->ar, scat_req); + + if (read) { + /* in sync mode, we can touch the scatter request */ + scat_req->status = status; + if (!status && scat_req->virt_scat) + scat_req->status = + ath6kl_hif_cp_scat_dma_buf(scat_req, true); + } + + return status; +} + +static int ath6kl_hif_proc_counter_intr(struct ath6kl_device *dev) +{ + u8 counter_int_status; + + ath6kl_dbg(ATH6KL_DBG_IRQ, "counter interrupt\n"); + + counter_int_status = dev->irq_proc_reg.counter_int_status & + dev->irq_en_reg.cntr_int_status_en; + + ath6kl_dbg(ATH6KL_DBG_IRQ, + "valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n", + counter_int_status); + + /* + * NOTE: other modules like GMBOX may use the counter interrupt for + * credit flow control on other counters, we only need to check for + * the debug assertion counter interrupt. + */ + if (counter_int_status & ATH6KL_TARGET_DEBUG_INTR_MASK) + return ath6kl_hif_proc_dbg_intr(dev); + + return 0; +} + +static int ath6kl_hif_proc_err_intr(struct ath6kl_device *dev) +{ + int status; + u8 error_int_status; + u8 reg_buf[4]; + + ath6kl_dbg(ATH6KL_DBG_IRQ, "error interrupt\n"); + + error_int_status = dev->irq_proc_reg.error_int_status & 0x0F; + if (!error_int_status) { + WARN_ON(1); + return -EIO; + } + + ath6kl_dbg(ATH6KL_DBG_IRQ, + "valid interrupt source(s) in ERROR_INT_STATUS: 0x%x\n", + error_int_status); + + if (MS(ERROR_INT_STATUS_WAKEUP, error_int_status)) + ath6kl_dbg(ATH6KL_DBG_IRQ, "error : wakeup\n"); + + if (MS(ERROR_INT_STATUS_RX_UNDERFLOW, error_int_status)) + ath6kl_err("rx underflow\n"); + + if (MS(ERROR_INT_STATUS_TX_OVERFLOW, error_int_status)) + ath6kl_err("tx overflow\n"); + + /* Clear the interrupt */ + dev->irq_proc_reg.error_int_status &= ~error_int_status; + + /* set W1C value to clear the interrupt, this hits the register first */ + reg_buf[0] = error_int_status; + reg_buf[1] = 0; + reg_buf[2] = 0; + reg_buf[3] = 0; + + status = hif_read_write_sync(dev->ar, ERROR_INT_STATUS_ADDRESS, + reg_buf, 4, HIF_WR_SYNC_BYTE_FIX); + + if (status) + WARN_ON(1); + + return status; +} + +static int ath6kl_hif_proc_cpu_intr(struct ath6kl_device *dev) +{ + int status; + u8 cpu_int_status; + u8 reg_buf[4]; + + ath6kl_dbg(ATH6KL_DBG_IRQ, "cpu interrupt\n"); + + cpu_int_status = dev->irq_proc_reg.cpu_int_status & + dev->irq_en_reg.cpu_int_status_en; + if (!cpu_int_status) { + WARN_ON(1); + return -EIO; + } + + ath6kl_dbg(ATH6KL_DBG_IRQ, + "valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n", + cpu_int_status); + + /* Clear the interrupt */ + dev->irq_proc_reg.cpu_int_status &= ~cpu_int_status; + + /* + * Set up the register transfer buffer to hit the register 4 times , + * this is done to make the access 4-byte aligned to mitigate issues + * with host bus interconnects that restrict bus transfer lengths to + * be a multiple of 4-bytes. + */ + + /* set W1C value to clear the interrupt, this hits the register first */ + reg_buf[0] = cpu_int_status; + /* the remaining are set to zero which have no-effect */ + reg_buf[1] = 0; + reg_buf[2] = 0; + reg_buf[3] = 0; + + status = hif_read_write_sync(dev->ar, CPU_INT_STATUS_ADDRESS, + reg_buf, 4, HIF_WR_SYNC_BYTE_FIX); + + if (status) + WARN_ON(1); + + return status; +} + +/* process pending interrupts synchronously */ +static int proc_pending_irqs(struct ath6kl_device *dev, bool *done) +{ + struct ath6kl_irq_proc_registers *rg; + int status = 0; + u8 host_int_status = 0; + u32 lk_ahd = 0; + u8 htc_mbox = 1 << HTC_MAILBOX; + + ath6kl_dbg(ATH6KL_DBG_IRQ, "proc_pending_irqs: (dev: 0x%p)\n", dev); + + /* + * NOTE: HIF implementation guarantees that the context of this + * call allows us to perform SYNCHRONOUS I/O, that is we can block, + * sleep or call any API that can block or switch thread/task + * contexts. This is a fully schedulable context. + */ + + /* + * Process pending intr only when int_status_en is clear, it may + * result in unnecessary bus transaction otherwise. Target may be + * unresponsive at the time. + */ + if (dev->irq_en_reg.int_status_en) { + /* + * Read the first 28 bytes of the HTC register table. This + * will yield us the value of different int status + * registers and the lookahead registers. + * + * length = sizeof(int_status) + sizeof(cpu_int_status) + * + sizeof(error_int_status) + + * sizeof(counter_int_status) + + * sizeof(mbox_frame) + sizeof(rx_lkahd_valid) + * + sizeof(hole) + sizeof(rx_lkahd) + + * sizeof(int_status_en) + + * sizeof(cpu_int_status_en) + + * sizeof(err_int_status_en) + + * sizeof(cntr_int_status_en); + */ + status = hif_read_write_sync(dev->ar, HOST_INT_STATUS_ADDRESS, + (u8 *) &dev->irq_proc_reg, + sizeof(dev->irq_proc_reg), + HIF_RD_SYNC_BYTE_INC); + if (status) + goto out; + + if (AR_DBG_LVL_CHECK(ATH6KL_DBG_IRQ)) + ath6kl_dump_registers(dev, &dev->irq_proc_reg, + &dev->irq_en_reg); + + /* Update only those registers that are enabled */ + host_int_status = dev->irq_proc_reg.host_int_status & + dev->irq_en_reg.int_status_en; + + /* Look at mbox status */ + if (host_int_status & htc_mbox) { + /* + * Mask out pending mbox value, we use "lookAhead as + * the real flag for mbox processing. + */ + host_int_status &= ~htc_mbox; + if (dev->irq_proc_reg.rx_lkahd_valid & + htc_mbox) { + rg = &dev->irq_proc_reg; + lk_ahd = le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]); + if (!lk_ahd) + ath6kl_err("lookAhead is zero!\n"); + } + } + } + + if (!host_int_status && !lk_ahd) { + *done = true; + goto out; + } + + if (lk_ahd) { + int fetched = 0; + + ath6kl_dbg(ATH6KL_DBG_IRQ, + "pending mailbox msg, lk_ahd: 0x%X\n", lk_ahd); + /* + * Mailbox Interrupt, the HTC layer may issue async + * requests to empty the mailbox. When emptying the recv + * mailbox we use the async handler above called from the + * completion routine of the callers read request. This can + * improve performance by reducing context switching when + * we rapidly pull packets. + */ + status = ath6kl_htc_rxmsg_pending_handler(dev->htc_cnxt, + lk_ahd, &fetched); + if (status) + goto out; + + if (!fetched) + /* + * HTC could not pull any messages out due to lack + * of resources. + */ + dev->htc_cnxt->chk_irq_status_cnt = 0; + } + + /* now handle the rest of them */ + ath6kl_dbg(ATH6KL_DBG_IRQ, + "valid interrupt source(s) for other interrupts: 0x%x\n", + host_int_status); + + if (MS(HOST_INT_STATUS_CPU, host_int_status)) { + /* CPU Interrupt */ + status = ath6kl_hif_proc_cpu_intr(dev); + if (status) + goto out; + } + + if (MS(HOST_INT_STATUS_ERROR, host_int_status)) { + /* Error Interrupt */ + status = ath6kl_hif_proc_err_intr(dev); + if (status) + goto out; + } + + if (MS(HOST_INT_STATUS_COUNTER, host_int_status)) + /* Counter Interrupt */ + status = ath6kl_hif_proc_counter_intr(dev); + +out: + /* + * An optimization to bypass reading the IRQ status registers + * unecessarily which can re-wake the target, if upper layers + * determine that we are in a low-throughput mode, we can rely on + * taking another interrupt rather than re-checking the status + * registers which can re-wake the target. + * + * NOTE : for host interfaces that makes use of detecting pending + * mbox messages at hif can not use this optimization due to + * possible side effects, SPI requires the host to drain all + * messages from the mailbox before exiting the ISR routine. + */ + + ath6kl_dbg(ATH6KL_DBG_IRQ, + "bypassing irq status re-check, forcing done\n"); + + if (!dev->htc_cnxt->chk_irq_status_cnt) + *done = true; + + ath6kl_dbg(ATH6KL_DBG_IRQ, + "proc_pending_irqs: (done:%d, status=%d\n", *done, status); + + return status; +} + +/* interrupt handler, kicks off all interrupt processing */ +int ath6kl_hif_intr_bh_handler(struct ath6kl *ar) +{ + struct ath6kl_device *dev = ar->htc_target->dev; + int status = 0; + bool done = false; + + /* + * Reset counter used to flag a re-scan of IRQ status registers on + * the target. + */ + dev->htc_cnxt->chk_irq_status_cnt = 0; + + /* + * IRQ processing is synchronous, interrupt status registers can be + * re-read. + */ + while (!done) { + status = proc_pending_irqs(dev, &done); + if (status) + break; + } + + return status; +} + +static int ath6kl_hif_enable_intrs(struct ath6kl_device *dev) +{ + struct ath6kl_irq_enable_reg regs; + int status; + + spin_lock_bh(&dev->lock); + + /* Enable all but ATH6KL CPU interrupts */ + dev->irq_en_reg.int_status_en = + SM(INT_STATUS_ENABLE_ERROR, 0x01) | + SM(INT_STATUS_ENABLE_CPU, 0x01) | + SM(INT_STATUS_ENABLE_COUNTER, 0x01); + + /* + * NOTE: There are some cases where HIF can do detection of + * pending mbox messages which is disabled now. + */ + dev->irq_en_reg.int_status_en |= SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01); + + /* Set up the CPU Interrupt status Register */ + dev->irq_en_reg.cpu_int_status_en = 0; + + /* Set up the Error Interrupt status Register */ + dev->irq_en_reg.err_int_status_en = + SM(ERROR_STATUS_ENABLE_RX_UNDERFLOW, 0x01) | + SM(ERROR_STATUS_ENABLE_TX_OVERFLOW, 0x1); + + /* + * Enable Counter interrupt status register to get fatal errors for + * debugging. + */ + dev->irq_en_reg.cntr_int_status_en = SM(COUNTER_INT_STATUS_ENABLE_BIT, + ATH6KL_TARGET_DEBUG_INTR_MASK); + memcpy(®s, &dev->irq_en_reg, sizeof(regs)); + + spin_unlock_bh(&dev->lock); + + status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS, + ®s.int_status_en, sizeof(regs), + HIF_WR_SYNC_BYTE_INC); + + if (status) + ath6kl_err("failed to update interrupt ctl reg err: %d\n", + status); + + return status; +} + +int ath6kl_hif_disable_intrs(struct ath6kl_device *dev) +{ + struct ath6kl_irq_enable_reg regs; + + spin_lock_bh(&dev->lock); + /* Disable all interrupts */ + dev->irq_en_reg.int_status_en = 0; + dev->irq_en_reg.cpu_int_status_en = 0; + dev->irq_en_reg.err_int_status_en = 0; + dev->irq_en_reg.cntr_int_status_en = 0; + memcpy(®s, &dev->irq_en_reg, sizeof(regs)); + spin_unlock_bh(&dev->lock); + + return hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS, + ®s.int_status_en, sizeof(regs), + HIF_WR_SYNC_BYTE_INC); +} + +/* enable device interrupts */ +int ath6kl_hif_unmask_intrs(struct ath6kl_device *dev) +{ + int status = 0; + + /* + * Make sure interrupt are disabled before unmasking at the HIF + * layer. The rationale here is that between device insertion + * (where we clear the interrupts the first time) and when HTC + * is finally ready to handle interrupts, other software can perform + * target "soft" resets. The ATH6KL interrupt enables reset back to an + * "enabled" state when this happens. + */ + ath6kl_hif_disable_intrs(dev); + + /* unmask the host controller interrupts */ + ath6kl_hif_irq_enable(dev->ar); + status = ath6kl_hif_enable_intrs(dev); + + return status; +} + +/* disable all device interrupts */ +int ath6kl_hif_mask_intrs(struct ath6kl_device *dev) +{ + /* + * Mask the interrupt at the HIF layer to avoid any stray interrupt + * taken while we zero out our shadow registers in + * ath6kl_hif_disable_intrs(). + */ + ath6kl_hif_irq_disable(dev->ar); + + return ath6kl_hif_disable_intrs(dev); +} + +int ath6kl_hif_setup(struct ath6kl_device *dev) +{ + int status = 0; + + spin_lock_init(&dev->lock); + + /* + * NOTE: we actually get the block size of a mailbox other than 0, + * for SDIO the block size on mailbox 0 is artificially set to 1. + * So we use the block size that is set for the other 3 mailboxes. + */ + dev->htc_cnxt->block_sz = dev->ar->mbox_info.block_size; + + /* must be a power of 2 */ + if ((dev->htc_cnxt->block_sz & (dev->htc_cnxt->block_sz - 1)) != 0) { + WARN_ON(1); + status = -EINVAL; + goto fail_setup; + } + + /* assemble mask, used for padding to a block */ + dev->htc_cnxt->block_mask = dev->htc_cnxt->block_sz - 1; + + ath6kl_dbg(ATH6KL_DBG_TRC, "block size: %d, mbox addr:0x%X\n", + dev->htc_cnxt->block_sz, dev->ar->mbox_info.htc_addr); + + ath6kl_dbg(ATH6KL_DBG_TRC, + "hif interrupt processing is sync only\n"); + + status = ath6kl_hif_disable_intrs(dev); + +fail_setup: + return status; + +} diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 9a9eae5..b296708 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -482,7 +482,7 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "send scatter total bytes: %d , entries: %d\n", scat_req->len, scat_req->scat_entries); - ath6kldev_submit_scat_req(target->dev, scat_req, false); + ath6kl_hif_submit_scat_req(target->dev, scat_req, false); if (status) break; @@ -1620,7 +1620,7 @@ static int ath6kl_htc_rx_bundle(struct htc_target *target, scat_req->len = len; scat_req->scat_entries = i; - status = ath6kldev_submit_scat_req(target->dev, scat_req, true); + status = ath6kl_hif_submit_scat_req(target->dev, scat_req, true); if (!status) *n_pkt_fetched = i; @@ -1865,7 +1865,7 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, if (target->htc_flags & HTC_OP_STATE_STOPPING) { ath6kl_warn("host is going to stop blocking receiver for htc_stop\n"); - ath6kldev_rx_control(target->dev, false); + ath6kl_hif_rx_control(target->dev, false); } } @@ -1875,7 +1875,7 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, */ if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { ath6kl_warn("host has no rx buffers blocking receiver to prevent overrun\n"); - ath6kldev_rx_control(target->dev, false); + ath6kl_hif_rx_control(target->dev, false); } *num_pkts = n_fetched; @@ -1893,7 +1893,7 @@ static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target) struct htc_frame_hdr *htc_hdr; u32 look_ahead; - if (ath6kldev_poll_mboxmsg_rx(target->dev, &look_ahead, + if (ath6kl_hif_poll_mboxmsg_rx(target->dev, &look_ahead, HTC_TARGET_RESPONSE_TIMEOUT)) return NULL; @@ -2001,7 +2001,7 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, if (rx_unblock && !(target->htc_flags & HTC_OP_STATE_STOPPING)) /* TODO : implement a buffer threshold count? */ - ath6kldev_rx_control(target->dev, true); + ath6kl_hif_rx_control(target->dev, true); return status; } @@ -2340,7 +2340,7 @@ int ath6kl_htc_start(struct htc_target *target) int status; /* Disable interrupts at the chip level */ - ath6kldev_disable_intrs(target->dev); + ath6kl_hif_disable_intrs(target->dev); target->htc_flags = 0; target->rx_st_flags = 0; @@ -2365,7 +2365,7 @@ int ath6kl_htc_start(struct htc_target *target) return status; /* unmask interrupts */ - status = ath6kldev_unmask_intrs(target->dev); + status = ath6kl_hif_unmask_intrs(target->dev); if (status) ath6kl_htc_stop(target); @@ -2385,7 +2385,7 @@ void ath6kl_htc_stop(struct htc_target *target) * function returns all pending HIF I/O has completed, we can * safely flush the queues. */ - ath6kldev_mask_intrs(target->dev); + ath6kl_hif_mask_intrs(target->dev); ath6kl_htc_flush_txep_all(target); @@ -2428,7 +2428,7 @@ void *ath6kl_htc_create(struct ath6kl *ar) reset_ep_state(target); - status = ath6kldev_setup(target->dev); + status = ath6kl_hif_setup(target->dev); if (status) goto fail_create_htc; diff --git a/drivers/net/wireless/ath/ath6kl/htc_hif.c b/drivers/net/wireless/ath/ath6kl/htc_hif.c deleted file mode 100644 index e9d3450..0000000 --- a/drivers/net/wireless/ath/ath6kl/htc_hif.c +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright (c) 2007-2011 Atheros Communications Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "core.h" -#include "target.h" -#include "hif-ops.h" -#include "htc_hif.h" -#include "debug.h" - -#define MAILBOX_FOR_BLOCK_SIZE 1 - -#define ATH6KL_TIME_QUANTUM 10 /* in ms */ - -static int ath6kldev_cp_scat_dma_buf(struct hif_scatter_req *req, bool from_dma) -{ - u8 *buf; - int i; - - buf = req->virt_dma_buf; - - for (i = 0; i < req->scat_entries; i++) { - - if (from_dma) - memcpy(req->scat_list[i].buf, buf, - req->scat_list[i].len); - else - memcpy(buf, req->scat_list[i].buf, - req->scat_list[i].len); - - buf += req->scat_list[i].len; - } - - return 0; -} - -int ath6kldev_rw_comp_handler(void *context, int status) -{ - struct htc_packet *packet = context; - - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, - "ath6kldev_rw_comp_handler (pkt:0x%p , status: %d\n", - packet, status); - - packet->status = status; - packet->completion(packet->context, packet); - - return 0; -} - -static int ath6kldev_proc_dbg_intr(struct ath6kl_device *dev) -{ - u32 dummy; - int status; - - ath6kl_err("target debug interrupt\n"); - - ath6kl_target_failure(dev->ar); - - /* - * read counter to clear the interrupt, the debug error interrupt is - * counter 0. - */ - status = hif_read_write_sync(dev->ar, COUNT_DEC_ADDRESS, - (u8 *)&dummy, 4, HIF_RD_SYNC_BYTE_INC); - if (status) - WARN_ON(1); - - return status; -} - -/* mailbox recv message polling */ -int ath6kldev_poll_mboxmsg_rx(struct ath6kl_device *dev, u32 *lk_ahd, - int timeout) -{ - struct ath6kl_irq_proc_registers *rg; - int status = 0, i; - u8 htc_mbox = 1 << HTC_MAILBOX; - - for (i = timeout / ATH6KL_TIME_QUANTUM; i > 0; i--) { - /* this is the standard HIF way, load the reg table */ - status = hif_read_write_sync(dev->ar, HOST_INT_STATUS_ADDRESS, - (u8 *) &dev->irq_proc_reg, - sizeof(dev->irq_proc_reg), - HIF_RD_SYNC_BYTE_INC); - - if (status) { - ath6kl_err("failed to read reg table\n"); - return status; - } - - /* check for MBOX data and valid lookahead */ - if (dev->irq_proc_reg.host_int_status & htc_mbox) { - if (dev->irq_proc_reg.rx_lkahd_valid & - htc_mbox) { - /* - * Mailbox has a message and the look ahead - * is valid. - */ - rg = &dev->irq_proc_reg; - *lk_ahd = - le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]); - break; - } - } - - /* delay a little */ - mdelay(ATH6KL_TIME_QUANTUM); - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, "retry mbox poll : %d\n", i); - } - - if (i == 0) { - ath6kl_err("timeout waiting for recv message\n"); - status = -ETIME; - /* check if the target asserted */ - if (dev->irq_proc_reg.counter_int_status & - ATH6KL_TARGET_DEBUG_INTR_MASK) - /* - * Target failure handler will be called in case of - * an assert. - */ - ath6kldev_proc_dbg_intr(dev); - } - - return status; -} - -/* - * Disable packet reception (used in case the host runs out of buffers) - * using the interrupt enable registers through the host I/F - */ -int ath6kldev_rx_control(struct ath6kl_device *dev, bool enable_rx) -{ - struct ath6kl_irq_enable_reg regs; - int status = 0; - - /* take the lock to protect interrupt enable shadows */ - spin_lock_bh(&dev->lock); - - if (enable_rx) - dev->irq_en_reg.int_status_en |= - SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01); - else - dev->irq_en_reg.int_status_en &= - ~SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01); - - memcpy(®s, &dev->irq_en_reg, sizeof(regs)); - - spin_unlock_bh(&dev->lock); - - status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS, - ®s.int_status_en, - sizeof(struct ath6kl_irq_enable_reg), - HIF_WR_SYNC_BYTE_INC); - - return status; -} - -int ath6kldev_submit_scat_req(struct ath6kl_device *dev, - struct hif_scatter_req *scat_req, bool read) -{ - int status = 0; - - if (read) { - scat_req->req = HIF_RD_SYNC_BLOCK_FIX; - scat_req->addr = dev->ar->mbox_info.htc_addr; - } else { - scat_req->req = HIF_WR_ASYNC_BLOCK_INC; - - scat_req->addr = - (scat_req->len > HIF_MBOX_WIDTH) ? - dev->ar->mbox_info.htc_ext_addr : - dev->ar->mbox_info.htc_addr; - } - - ath6kl_dbg((ATH6KL_DBG_HTC_RECV | ATH6KL_DBG_HTC_SEND), - "ath6kldev_submit_scat_req, entries: %d, total len: %d mbox:0x%X (mode: %s : %s)\n", - scat_req->scat_entries, scat_req->len, - scat_req->addr, !read ? "async" : "sync", - (read) ? "rd" : "wr"); - - if (!read && scat_req->virt_scat) { - status = ath6kldev_cp_scat_dma_buf(scat_req, false); - if (status) { - scat_req->status = status; - scat_req->complete(dev->ar->htc_target, scat_req); - return 0; - } - } - - status = ath6kl_hif_scat_req_rw(dev->ar, scat_req); - - if (read) { - /* in sync mode, we can touch the scatter request */ - scat_req->status = status; - if (!status && scat_req->virt_scat) - scat_req->status = - ath6kldev_cp_scat_dma_buf(scat_req, true); - } - - return status; -} - -static int ath6kldev_proc_counter_intr(struct ath6kl_device *dev) -{ - u8 counter_int_status; - - ath6kl_dbg(ATH6KL_DBG_IRQ, "counter interrupt\n"); - - counter_int_status = dev->irq_proc_reg.counter_int_status & - dev->irq_en_reg.cntr_int_status_en; - - ath6kl_dbg(ATH6KL_DBG_IRQ, - "valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n", - counter_int_status); - - /* - * NOTE: other modules like GMBOX may use the counter interrupt for - * credit flow control on other counters, we only need to check for - * the debug assertion counter interrupt. - */ - if (counter_int_status & ATH6KL_TARGET_DEBUG_INTR_MASK) - return ath6kldev_proc_dbg_intr(dev); - - return 0; -} - -static int ath6kldev_proc_err_intr(struct ath6kl_device *dev) -{ - int status; - u8 error_int_status; - u8 reg_buf[4]; - - ath6kl_dbg(ATH6KL_DBG_IRQ, "error interrupt\n"); - - error_int_status = dev->irq_proc_reg.error_int_status & 0x0F; - if (!error_int_status) { - WARN_ON(1); - return -EIO; - } - - ath6kl_dbg(ATH6KL_DBG_IRQ, - "valid interrupt source(s) in ERROR_INT_STATUS: 0x%x\n", - error_int_status); - - if (MS(ERROR_INT_STATUS_WAKEUP, error_int_status)) - ath6kl_dbg(ATH6KL_DBG_IRQ, "error : wakeup\n"); - - if (MS(ERROR_INT_STATUS_RX_UNDERFLOW, error_int_status)) - ath6kl_err("rx underflow\n"); - - if (MS(ERROR_INT_STATUS_TX_OVERFLOW, error_int_status)) - ath6kl_err("tx overflow\n"); - - /* Clear the interrupt */ - dev->irq_proc_reg.error_int_status &= ~error_int_status; - - /* set W1C value to clear the interrupt, this hits the register first */ - reg_buf[0] = error_int_status; - reg_buf[1] = 0; - reg_buf[2] = 0; - reg_buf[3] = 0; - - status = hif_read_write_sync(dev->ar, ERROR_INT_STATUS_ADDRESS, - reg_buf, 4, HIF_WR_SYNC_BYTE_FIX); - - if (status) - WARN_ON(1); - - return status; -} - -static int ath6kldev_proc_cpu_intr(struct ath6kl_device *dev) -{ - int status; - u8 cpu_int_status; - u8 reg_buf[4]; - - ath6kl_dbg(ATH6KL_DBG_IRQ, "cpu interrupt\n"); - - cpu_int_status = dev->irq_proc_reg.cpu_int_status & - dev->irq_en_reg.cpu_int_status_en; - if (!cpu_int_status) { - WARN_ON(1); - return -EIO; - } - - ath6kl_dbg(ATH6KL_DBG_IRQ, - "valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n", - cpu_int_status); - - /* Clear the interrupt */ - dev->irq_proc_reg.cpu_int_status &= ~cpu_int_status; - - /* - * Set up the register transfer buffer to hit the register 4 times , - * this is done to make the access 4-byte aligned to mitigate issues - * with host bus interconnects that restrict bus transfer lengths to - * be a multiple of 4-bytes. - */ - - /* set W1C value to clear the interrupt, this hits the register first */ - reg_buf[0] = cpu_int_status; - /* the remaining are set to zero which have no-effect */ - reg_buf[1] = 0; - reg_buf[2] = 0; - reg_buf[3] = 0; - - status = hif_read_write_sync(dev->ar, CPU_INT_STATUS_ADDRESS, - reg_buf, 4, HIF_WR_SYNC_BYTE_FIX); - - if (status) - WARN_ON(1); - - return status; -} - -/* process pending interrupts synchronously */ -static int proc_pending_irqs(struct ath6kl_device *dev, bool *done) -{ - struct ath6kl_irq_proc_registers *rg; - int status = 0; - u8 host_int_status = 0; - u32 lk_ahd = 0; - u8 htc_mbox = 1 << HTC_MAILBOX; - - ath6kl_dbg(ATH6KL_DBG_IRQ, "proc_pending_irqs: (dev: 0x%p)\n", dev); - - /* - * NOTE: HIF implementation guarantees that the context of this - * call allows us to perform SYNCHRONOUS I/O, that is we can block, - * sleep or call any API that can block or switch thread/task - * contexts. This is a fully schedulable context. - */ - - /* - * Process pending intr only when int_status_en is clear, it may - * result in unnecessary bus transaction otherwise. Target may be - * unresponsive at the time. - */ - if (dev->irq_en_reg.int_status_en) { - /* - * Read the first 28 bytes of the HTC register table. This - * will yield us the value of different int status - * registers and the lookahead registers. - * - * length = sizeof(int_status) + sizeof(cpu_int_status) - * + sizeof(error_int_status) + - * sizeof(counter_int_status) + - * sizeof(mbox_frame) + sizeof(rx_lkahd_valid) - * + sizeof(hole) + sizeof(rx_lkahd) + - * sizeof(int_status_en) + - * sizeof(cpu_int_status_en) + - * sizeof(err_int_status_en) + - * sizeof(cntr_int_status_en); - */ - status = hif_read_write_sync(dev->ar, HOST_INT_STATUS_ADDRESS, - (u8 *) &dev->irq_proc_reg, - sizeof(dev->irq_proc_reg), - HIF_RD_SYNC_BYTE_INC); - if (status) - goto out; - - if (AR_DBG_LVL_CHECK(ATH6KL_DBG_IRQ)) - ath6kl_dump_registers(dev, &dev->irq_proc_reg, - &dev->irq_en_reg); - - /* Update only those registers that are enabled */ - host_int_status = dev->irq_proc_reg.host_int_status & - dev->irq_en_reg.int_status_en; - - /* Look at mbox status */ - if (host_int_status & htc_mbox) { - /* - * Mask out pending mbox value, we use "lookAhead as - * the real flag for mbox processing. - */ - host_int_status &= ~htc_mbox; - if (dev->irq_proc_reg.rx_lkahd_valid & - htc_mbox) { - rg = &dev->irq_proc_reg; - lk_ahd = le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]); - if (!lk_ahd) - ath6kl_err("lookAhead is zero!\n"); - } - } - } - - if (!host_int_status && !lk_ahd) { - *done = true; - goto out; - } - - if (lk_ahd) { - int fetched = 0; - - ath6kl_dbg(ATH6KL_DBG_IRQ, - "pending mailbox msg, lk_ahd: 0x%X\n", lk_ahd); - /* - * Mailbox Interrupt, the HTC layer may issue async - * requests to empty the mailbox. When emptying the recv - * mailbox we use the async handler above called from the - * completion routine of the callers read request. This can - * improve performance by reducing context switching when - * we rapidly pull packets. - */ - status = ath6kl_htc_rxmsg_pending_handler(dev->htc_cnxt, - lk_ahd, &fetched); - if (status) - goto out; - - if (!fetched) - /* - * HTC could not pull any messages out due to lack - * of resources. - */ - dev->htc_cnxt->chk_irq_status_cnt = 0; - } - - /* now handle the rest of them */ - ath6kl_dbg(ATH6KL_DBG_IRQ, - "valid interrupt source(s) for other interrupts: 0x%x\n", - host_int_status); - - if (MS(HOST_INT_STATUS_CPU, host_int_status)) { - /* CPU Interrupt */ - status = ath6kldev_proc_cpu_intr(dev); - if (status) - goto out; - } - - if (MS(HOST_INT_STATUS_ERROR, host_int_status)) { - /* Error Interrupt */ - status = ath6kldev_proc_err_intr(dev); - if (status) - goto out; - } - - if (MS(HOST_INT_STATUS_COUNTER, host_int_status)) - /* Counter Interrupt */ - status = ath6kldev_proc_counter_intr(dev); - -out: - /* - * An optimization to bypass reading the IRQ status registers - * unecessarily which can re-wake the target, if upper layers - * determine that we are in a low-throughput mode, we can rely on - * taking another interrupt rather than re-checking the status - * registers which can re-wake the target. - * - * NOTE : for host interfaces that makes use of detecting pending - * mbox messages at hif can not use this optimization due to - * possible side effects, SPI requires the host to drain all - * messages from the mailbox before exiting the ISR routine. - */ - - ath6kl_dbg(ATH6KL_DBG_IRQ, - "bypassing irq status re-check, forcing done\n"); - - if (!dev->htc_cnxt->chk_irq_status_cnt) - *done = true; - - ath6kl_dbg(ATH6KL_DBG_IRQ, - "proc_pending_irqs: (done:%d, status=%d\n", *done, status); - - return status; -} - -/* interrupt handler, kicks off all interrupt processing */ -int ath6kldev_intr_bh_handler(struct ath6kl *ar) -{ - struct ath6kl_device *dev = ar->htc_target->dev; - int status = 0; - bool done = false; - - /* - * Reset counter used to flag a re-scan of IRQ status registers on - * the target. - */ - dev->htc_cnxt->chk_irq_status_cnt = 0; - - /* - * IRQ processing is synchronous, interrupt status registers can be - * re-read. - */ - while (!done) { - status = proc_pending_irqs(dev, &done); - if (status) - break; - } - - return status; -} - -static int ath6kldev_enable_intrs(struct ath6kl_device *dev) -{ - struct ath6kl_irq_enable_reg regs; - int status; - - spin_lock_bh(&dev->lock); - - /* Enable all but ATH6KL CPU interrupts */ - dev->irq_en_reg.int_status_en = - SM(INT_STATUS_ENABLE_ERROR, 0x01) | - SM(INT_STATUS_ENABLE_CPU, 0x01) | - SM(INT_STATUS_ENABLE_COUNTER, 0x01); - - /* - * NOTE: There are some cases where HIF can do detection of - * pending mbox messages which is disabled now. - */ - dev->irq_en_reg.int_status_en |= SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01); - - /* Set up the CPU Interrupt status Register */ - dev->irq_en_reg.cpu_int_status_en = 0; - - /* Set up the Error Interrupt status Register */ - dev->irq_en_reg.err_int_status_en = - SM(ERROR_STATUS_ENABLE_RX_UNDERFLOW, 0x01) | - SM(ERROR_STATUS_ENABLE_TX_OVERFLOW, 0x1); - - /* - * Enable Counter interrupt status register to get fatal errors for - * debugging. - */ - dev->irq_en_reg.cntr_int_status_en = SM(COUNTER_INT_STATUS_ENABLE_BIT, - ATH6KL_TARGET_DEBUG_INTR_MASK); - memcpy(®s, &dev->irq_en_reg, sizeof(regs)); - - spin_unlock_bh(&dev->lock); - - status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS, - ®s.int_status_en, sizeof(regs), - HIF_WR_SYNC_BYTE_INC); - - if (status) - ath6kl_err("failed to update interrupt ctl reg err: %d\n", - status); - - return status; -} - -int ath6kldev_disable_intrs(struct ath6kl_device *dev) -{ - struct ath6kl_irq_enable_reg regs; - - spin_lock_bh(&dev->lock); - /* Disable all interrupts */ - dev->irq_en_reg.int_status_en = 0; - dev->irq_en_reg.cpu_int_status_en = 0; - dev->irq_en_reg.err_int_status_en = 0; - dev->irq_en_reg.cntr_int_status_en = 0; - memcpy(®s, &dev->irq_en_reg, sizeof(regs)); - spin_unlock_bh(&dev->lock); - - return hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS, - ®s.int_status_en, sizeof(regs), - HIF_WR_SYNC_BYTE_INC); -} - -/* enable device interrupts */ -int ath6kldev_unmask_intrs(struct ath6kl_device *dev) -{ - int status = 0; - - /* - * Make sure interrupt are disabled before unmasking at the HIF - * layer. The rationale here is that between device insertion - * (where we clear the interrupts the first time) and when HTC - * is finally ready to handle interrupts, other software can perform - * target "soft" resets. The ATH6KL interrupt enables reset back to an - * "enabled" state when this happens. - */ - ath6kldev_disable_intrs(dev); - - /* unmask the host controller interrupts */ - ath6kl_hif_irq_enable(dev->ar); - status = ath6kldev_enable_intrs(dev); - - return status; -} - -/* disable all device interrupts */ -int ath6kldev_mask_intrs(struct ath6kl_device *dev) -{ - /* - * Mask the interrupt at the HIF layer to avoid any stray interrupt - * taken while we zero out our shadow registers in - * ath6kldev_disable_intrs(). - */ - ath6kl_hif_irq_disable(dev->ar); - - return ath6kldev_disable_intrs(dev); -} - -int ath6kldev_setup(struct ath6kl_device *dev) -{ - int status = 0; - - spin_lock_init(&dev->lock); - - /* - * NOTE: we actually get the block size of a mailbox other than 0, - * for SDIO the block size on mailbox 0 is artificially set to 1. - * So we use the block size that is set for the other 3 mailboxes. - */ - dev->htc_cnxt->block_sz = dev->ar->mbox_info.block_size; - - /* must be a power of 2 */ - if ((dev->htc_cnxt->block_sz & (dev->htc_cnxt->block_sz - 1)) != 0) { - WARN_ON(1); - status = -EINVAL; - goto fail_setup; - } - - /* assemble mask, used for padding to a block */ - dev->htc_cnxt->block_mask = dev->htc_cnxt->block_sz - 1; - - ath6kl_dbg(ATH6KL_DBG_TRC, "block size: %d, mbox addr:0x%X\n", - dev->htc_cnxt->block_sz, dev->ar->mbox_info.htc_addr); - - ath6kl_dbg(ATH6KL_DBG_TRC, - "hif interrupt processing is sync only\n"); - - status = ath6kldev_disable_intrs(dev); - -fail_setup: - return status; - -} diff --git a/drivers/net/wireless/ath/ath6kl/htc_hif.h b/drivers/net/wireless/ath/ath6kl/htc_hif.h index 171ad63..5572c23 100644 --- a/drivers/net/wireless/ath/ath6kl/htc_hif.h +++ b/drivers/net/wireless/ath/ath6kl/htc_hif.h @@ -74,19 +74,19 @@ struct ath6kl_device { struct ath6kl *ar; }; -int ath6kldev_setup(struct ath6kl_device *dev); -int ath6kldev_unmask_intrs(struct ath6kl_device *dev); -int ath6kldev_mask_intrs(struct ath6kl_device *dev); -int ath6kldev_poll_mboxmsg_rx(struct ath6kl_device *dev, - u32 *lk_ahd, int timeout); -int ath6kldev_rx_control(struct ath6kl_device *dev, bool enable_rx); -int ath6kldev_disable_intrs(struct ath6kl_device *dev); +int ath6kl_hif_setup(struct ath6kl_device *dev); +int ath6kl_hif_unmask_intrs(struct ath6kl_device *dev); +int ath6kl_hif_mask_intrs(struct ath6kl_device *dev); +int ath6kl_hif_poll_mboxmsg_rx(struct ath6kl_device *dev, + u32 *lk_ahd, int timeout); +int ath6kl_hif_rx_control(struct ath6kl_device *dev, bool enable_rx); +int ath6kl_hif_disable_intrs(struct ath6kl_device *dev); -int ath6kldev_rw_comp_handler(void *context, int status); -int ath6kldev_intr_bh_handler(struct ath6kl *ar); +int ath6kl_hif_rw_comp_handler(void *context, int status); +int ath6kl_hif_intr_bh_handler(struct ath6kl *ar); /* Scatter Function and Definitions */ -int ath6kldev_submit_scat_req(struct ath6kl_device *dev, - struct hif_scatter_req *scat_req, bool read); +int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev, + struct hif_scatter_req *scat_req, bool read); #endif /*ATH6KL_H_ */ diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 9b8ee1f..5b1df82 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -420,7 +420,7 @@ static void __ath6kl_sdio_write_async(struct ath6kl_sdio *ar_sdio, req->request); context = req->packet; ath6kl_sdio_free_bus_req(ar_sdio, req); - ath6kldev_rw_comp_handler(context, status); + ath6kl_hif_rw_comp_handler(context, status); } } @@ -457,7 +457,7 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func) */ sdio_release_host(ar_sdio->func); - status = ath6kldev_intr_bh_handler(ar_sdio->ar); + status = ath6kl_hif_intr_bh_handler(ar_sdio->ar); sdio_claim_host(ar_sdio->func); atomic_set(&ar_sdio->irq_handling, 0); WARN_ON(status && status != -ECANCELED); -- cgit v0.10.2 From 533cbbb686684dcf9915e5890df29f5cca05d173 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 5 Oct 2011 12:23:42 +0300 Subject: ath6kl: remove unused values from htc_hif.h Also remove some cache line optimisation. It was using hardcoded values which is wrong. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc_hif.h b/drivers/net/wireless/ath/ath6kl/htc_hif.h index 5572c23..a8a6de5 100644 --- a/drivers/net/wireless/ath/ath6kl/htc_hif.h +++ b/drivers/net/wireless/ath/ath6kl/htc_hif.h @@ -20,29 +20,16 @@ #include "htc.h" #include "hif.h" -#define ATH6KL_MAILBOXES 4 - /* HTC runs over mailbox 0 */ #define HTC_MAILBOX 0 #define ATH6KL_TARGET_DEBUG_INTR_MASK 0x01 -#define OTHER_INTS_ENABLED (INT_STATUS_ENABLE_ERROR_MASK | \ - INT_STATUS_ENABLE_CPU_MASK | \ - INT_STATUS_ENABLE_COUNTER_MASK) - -#define ATH6KL_REG_IO_BUFFER_SIZE 32 -#define ATH6KL_MAX_REG_IO_BUFFERS 8 +/* FIXME: are these duplicates with MAX_SCATTER_ values in hif.h? */ #define ATH6KL_SCATTER_ENTRIES_PER_REQ 16 #define ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER (16 * 1024) #define ATH6KL_SCATTER_REQS 4 -#ifndef A_CACHE_LINE_PAD -#define A_CACHE_LINE_PAD 128 -#endif -#define ATH6KL_MIN_SCATTER_ENTRIES_PER_REQ 2 -#define ATH6KL_MIN_TRANSFER_SIZE_PER_SCATTER (4 * 1024) - struct ath6kl_irq_proc_registers { u8 host_int_status; u8 cpu_int_status; @@ -65,11 +52,8 @@ struct ath6kl_irq_enable_reg { struct ath6kl_device { spinlock_t lock; - u8 pad1[A_CACHE_LINE_PAD]; struct ath6kl_irq_proc_registers irq_proc_reg; - u8 pad2[A_CACHE_LINE_PAD]; struct ath6kl_irq_enable_reg irq_en_reg; - u8 pad3[A_CACHE_LINE_PAD]; struct htc_target *htc_cnxt; struct ath6kl *ar; }; -- cgit v0.10.2 From 2e1cb23c5e3c38b25a678a8a14d7464341e8207f Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 5 Oct 2011 12:23:49 +0300 Subject: ath6kl: move remaining content from htc_hif.h to hif.h Now htc_hif.h can be removed. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 9288a3c..e3740b0 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -17,7 +17,7 @@ #ifndef DEBUG_H #define DEBUG_H -#include "htc_hif.h" +#include "hif.h" enum ATH6K_DEBUG_MASK { ATH6KL_DBG_WLAN_CONNECT = BIT(0), /* wlan connect */ diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index 629e16c..57c9aff 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -13,11 +13,11 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "hif.h" #include "core.h" #include "target.h" #include "hif-ops.h" -#include "htc_hif.h" #include "debug.h" #define MAILBOX_FOR_BLOCK_SIZE 1 diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 906fde9..93d2912 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -59,6 +59,16 @@ /* mode to enable special 4-bit interrupt assertion without clock */ #define SDIO_IRQ_MODE_ASYNC_4BIT_IRQ (1 << 0) +/* HTC runs over mailbox 0 */ +#define HTC_MAILBOX 0 + +#define ATH6KL_TARGET_DEBUG_INTR_MASK 0x01 + +/* FIXME: are these duplicates with MAX_SCATTER_ values in hif.h? */ +#define ATH6KL_SCATTER_ENTRIES_PER_REQ 16 +#define ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER (16 * 1024) +#define ATH6KL_SCATTER_REQS 4 + struct bus_request { struct list_head list; @@ -186,6 +196,34 @@ struct hif_scatter_req { struct hif_scatter_item scat_list[1]; }; +struct ath6kl_irq_proc_registers { + u8 host_int_status; + u8 cpu_int_status; + u8 error_int_status; + u8 counter_int_status; + u8 mbox_frame; + u8 rx_lkahd_valid; + u8 host_int_status2; + u8 gmbox_rx_avail; + __le32 rx_lkahd[2]; + __le32 rx_gmbox_lkahd_alias[2]; +} __packed; + +struct ath6kl_irq_enable_reg { + u8 int_status_en; + u8 cpu_int_status_en; + u8 err_int_status_en; + u8 cntr_int_status_en; +} __packed; + +struct ath6kl_device { + spinlock_t lock; + struct ath6kl_irq_proc_registers irq_proc_reg; + struct ath6kl_irq_enable_reg irq_en_reg; + struct htc_target *htc_cnxt; + struct ath6kl *ar; +}; + struct ath6kl_hif_ops { int (*read_write_sync)(struct ath6kl *ar, u32 addr, u8 *buf, u32 len, u32 request); @@ -206,4 +244,19 @@ struct ath6kl_hif_ops { int (*resume)(struct ath6kl *ar); }; +int ath6kl_hif_setup(struct ath6kl_device *dev); +int ath6kl_hif_unmask_intrs(struct ath6kl_device *dev); +int ath6kl_hif_mask_intrs(struct ath6kl_device *dev); +int ath6kl_hif_poll_mboxmsg_rx(struct ath6kl_device *dev, + u32 *lk_ahd, int timeout); +int ath6kl_hif_rx_control(struct ath6kl_device *dev, bool enable_rx); +int ath6kl_hif_disable_intrs(struct ath6kl_device *dev); + +int ath6kl_hif_rw_comp_handler(void *context, int status); +int ath6kl_hif_intr_bh_handler(struct ath6kl *ar); + +/* Scatter Function and Definitions */ +int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev, + struct hif_scatter_req *scat_req, bool read); + #endif diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index b296708..9b8cb22 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -15,7 +15,7 @@ */ #include "core.h" -#include "htc_hif.h" +#include "hif.h" #include "debug.h" #include "hif-ops.h" #include diff --git a/drivers/net/wireless/ath/ath6kl/htc_hif.h b/drivers/net/wireless/ath/ath6kl/htc_hif.h deleted file mode 100644 index a8a6de5..0000000 --- a/drivers/net/wireless/ath/ath6kl/htc_hif.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2007-2011 Atheros Communications Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef HTC_HIF_H -#define HTC_HIF_H - -#include "htc.h" -#include "hif.h" - -/* HTC runs over mailbox 0 */ -#define HTC_MAILBOX 0 - -#define ATH6KL_TARGET_DEBUG_INTR_MASK 0x01 - -/* FIXME: are these duplicates with MAX_SCATTER_ values in hif.h? */ -#define ATH6KL_SCATTER_ENTRIES_PER_REQ 16 -#define ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER (16 * 1024) -#define ATH6KL_SCATTER_REQS 4 - -struct ath6kl_irq_proc_registers { - u8 host_int_status; - u8 cpu_int_status; - u8 error_int_status; - u8 counter_int_status; - u8 mbox_frame; - u8 rx_lkahd_valid; - u8 host_int_status2; - u8 gmbox_rx_avail; - __le32 rx_lkahd[2]; - __le32 rx_gmbox_lkahd_alias[2]; -} __packed; - -struct ath6kl_irq_enable_reg { - u8 int_status_en; - u8 cpu_int_status_en; - u8 err_int_status_en; - u8 cntr_int_status_en; -} __packed; - -struct ath6kl_device { - spinlock_t lock; - struct ath6kl_irq_proc_registers irq_proc_reg; - struct ath6kl_irq_enable_reg irq_en_reg; - struct htc_target *htc_cnxt; - struct ath6kl *ar; -}; - -int ath6kl_hif_setup(struct ath6kl_device *dev); -int ath6kl_hif_unmask_intrs(struct ath6kl_device *dev); -int ath6kl_hif_mask_intrs(struct ath6kl_device *dev); -int ath6kl_hif_poll_mboxmsg_rx(struct ath6kl_device *dev, - u32 *lk_ahd, int timeout); -int ath6kl_hif_rx_control(struct ath6kl_device *dev, bool enable_rx); -int ath6kl_hif_disable_intrs(struct ath6kl_device *dev); - -int ath6kl_hif_rw_comp_handler(void *context, int status); -int ath6kl_hif_intr_bh_handler(struct ath6kl *ar); - -/* Scatter Function and Definitions */ -int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev, - struct hif_scatter_req *scat_req, bool read); - -#endif /*ATH6KL_H_ */ diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 5b1df82..2394c17 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -21,7 +21,7 @@ #include #include #include -#include "htc_hif.h" +#include "hif.h" #include "hif-ops.h" #include "target.h" #include "debug.h" -- cgit v0.10.2 From ad3f78b99e5cd74e9d9643ac8356206f57e796c9 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 6 Oct 2011 14:32:32 +0300 Subject: ath6kl: fix null skb dereference in ath6kl_rx() smatch found that skb might be null in some cases in ath6kl_rx(): ath6kl/txrx.c +1252 ath6kl_rx(222) error: potential null derefence 'skb'. This will happen when ath6kl is in AP mode and two clients send traffic to each other. Reported-by: Dan Carpenter Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index bcf7b01..a9dff01 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1247,6 +1247,11 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) } if (skb1) ath6kl_data_tx(skb1, ar->net_dev); + + if (skb == NULL) { + /* nothing to deliver up the stack */ + return; + } } datap = (struct ethhdr *) skb->data; -- cgit v0.10.2 From 6981ffdc2f5d59aac75c8446363c474e33f18b31 Mon Sep 17 00:00:00 2001 From: Kevin Fang Date: Fri, 7 Oct 2011 08:51:19 +0800 Subject: ath6kl: Add WSC IE on the associate message For some WPS test items, such as item "5.1.14" STAUT must include the WSC IE in the 802.11 Association Request frame. Therefore, add the corresponding IE in association message. Signed-off-by: Kevin Fang Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2acfa7f..40a2d7a 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -237,6 +237,53 @@ static bool ath6kl_cfg80211_ready(struct ath6kl *ar) return true; } +static bool ath6kl_is_wpa_ie(const u8 *pos) +{ + return pos[0] == WLAN_EID_WPA && pos[1] >= 4 && + pos[2] == 0x00 && pos[3] == 0x50 && + pos[4] == 0xf2 && pos[5] == 0x01; +} + +static bool ath6kl_is_rsn_ie(const u8 *pos) +{ + return pos[0] == WLAN_EID_RSN; +} + +static int ath6kl_set_assoc_req_ies(struct ath6kl *ar, const u8 *ies, + size_t ies_len) +{ + const u8 *pos; + u8 *buf = NULL; + size_t len = 0; + int ret; + + /* + * Filter out RSN/WPA IE(s) + */ + + if (ies && ies_len) { + buf = kmalloc(ies_len, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + pos = ies; + + while (pos + 1 < ies + ies_len) { + if (pos + 2 + pos[1] > ies + ies_len) + break; + if (!(ath6kl_is_wpa_ie(pos) || ath6kl_is_rsn_ie(pos))) { + memcpy(buf + len, pos, 2 + pos[1]); + len += 2 + pos[1]; + } + pos += 2 + pos[1]; + } + } + + ret = ath6kl_wmi_set_appie_cmd(ar->wmi, WMI_FRAME_ASSOC_REQ, + buf, len); + kfree(buf); + return ret; +} + static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { @@ -285,6 +332,12 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } } + if (sme->ie && (sme->ie_len > 0)) { + status = ath6kl_set_assoc_req_ies(ar, sme->ie, sme->ie_len); + if (status) + return status; + } + if (test_bit(CONNECTED, &ar->flag) && ar->ssid_len == sme->ssid_len && !memcmp(ar->ssid, sme->ssid, ar->ssid_len)) { -- cgit v0.10.2 From e8091281f588812b128e102307e13acd9e917a5b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 11 Oct 2011 17:31:53 +0300 Subject: ath6kl: Add endpoint_stats debugfs file This file can be used to fetch endpoint statistics counters and to clear them by writing 0 to it. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index ba3f23d..b9bf28d 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -595,6 +595,105 @@ static const struct file_operations fops_credit_dist_stats = { .llseek = default_llseek, }; +static unsigned int print_endpoint_stat(struct htc_target *target, char *buf, + unsigned int buf_len, unsigned int len, + int offset, const char *name) +{ + int i; + struct htc_endpoint_stats *ep_st; + u32 *counter; + + len += scnprintf(buf + len, buf_len - len, "%s:", name); + for (i = 0; i < ENDPOINT_MAX; i++) { + ep_st = &target->endpoint[i].ep_st; + counter = ((u32 *) ep_st) + (offset / 4); + len += scnprintf(buf + len, buf_len - len, " %u", *counter); + } + len += scnprintf(buf + len, buf_len - len, "\n"); + + return len; +} + +static ssize_t ath6kl_endpoint_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + struct htc_target *target = ar->htc_target; + char *buf; + unsigned int buf_len, len = 0; + ssize_t ret_cnt; + + buf_len = 1000 + ENDPOINT_MAX * 100; + buf = kzalloc(buf_len, GFP_KERNEL); + if (!buf) + return -ENOMEM; + +#define EPSTAT(name) \ + len = print_endpoint_stat(target, buf, buf_len, len, \ + offsetof(struct htc_endpoint_stats, name), \ + #name) + EPSTAT(cred_low_indicate); + EPSTAT(tx_issued); + EPSTAT(tx_pkt_bundled); + EPSTAT(tx_bundles); + EPSTAT(tx_dropped); + EPSTAT(tx_cred_rpt); + EPSTAT(cred_rpt_from_rx); + EPSTAT(cred_rpt_ep0); + EPSTAT(cred_from_rx); + EPSTAT(cred_from_other); + EPSTAT(cred_from_ep0); + EPSTAT(cred_cosumd); + EPSTAT(cred_retnd); + EPSTAT(rx_pkts); + EPSTAT(rx_lkahds); + EPSTAT(rx_bundl); + EPSTAT(rx_bundle_lkahd); + EPSTAT(rx_bundle_from_hdr); + EPSTAT(rx_alloc_thresh_hit); + EPSTAT(rxalloc_thresh_byte); +#undef EPSTAT + + if (len > buf_len) + len = buf_len; + + ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); + kfree(buf); + return ret_cnt; +} + +static ssize_t ath6kl_endpoint_stats_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + struct htc_target *target = ar->htc_target; + int ret, i; + u32 val; + struct htc_endpoint_stats *ep_st; + + ret = kstrtou32_from_user(user_buf, count, 0, &val); + if (ret) + return ret; + if (val == 0) { + for (i = 0; i < ENDPOINT_MAX; i++) { + ep_st = &target->endpoint[i].ep_st; + memset(ep_st, 0, sizeof(*ep_st)); + } + } + + return count; +} + +static const struct file_operations fops_endpoint_stats = { + .open = ath6kl_debugfs_open, + .read = ath6kl_endpoint_stats_read, + .write = ath6kl_endpoint_stats_write, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + static unsigned long ath6kl_get_num_reg(void) { int i; @@ -901,6 +1000,9 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("credit_dist_stats", S_IRUSR, ar->debugfs_phy, ar, &fops_credit_dist_stats); + debugfs_create_file("endpoint_stats", S_IRUSR | S_IWUSR, + ar->debugfs_phy, ar, &fops_endpoint_stats); + debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar, &fops_fwlog); -- cgit v0.10.2 From 4b28a80dd6713c404f4f0084007456b769aba553 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 11 Oct 2011 17:31:54 +0300 Subject: ath6kl: Add debugfs file for target roam table The new roam_table debugfs file can be used to display the current roam table from the target. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 6d8a484..c58cfad 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -397,6 +397,7 @@ struct ath6kl_req_key { #define TESTMODE 13 #define CLEAR_BSSFILTER_ON_BEACON 14 #define DTIM_PERIOD_AVAIL 15 +#define ROAM_TBL_PEND 16 struct ath6kl { struct device *dev; @@ -529,6 +530,9 @@ struct ath6kl { struct { unsigned int invalid_rate; } war_stats; + + u8 *roam_tbl; + unsigned int roam_tbl_len; } debug; #endif /* CONFIG_ATH6KL_DEBUG */ }; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index b9bf28d..cec958a 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -966,6 +966,111 @@ static const struct file_operations fops_diag_reg_write = { .llseek = default_llseek, }; +int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf, + size_t len) +{ + const struct wmi_target_roam_tbl *tbl; + u16 num_entries; + + if (len < sizeof(*tbl)) + return -EINVAL; + + tbl = (const struct wmi_target_roam_tbl *) buf; + num_entries = le16_to_cpu(tbl->num_entries); + if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) > + len) + return -EINVAL; + + if (ar->debug.roam_tbl == NULL || + ar->debug.roam_tbl_len < (unsigned int) len) { + kfree(ar->debug.roam_tbl); + ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC); + if (ar->debug.roam_tbl == NULL) + return -ENOMEM; + } + + memcpy(ar->debug.roam_tbl, buf, len); + ar->debug.roam_tbl_len = len; + + if (test_bit(ROAM_TBL_PEND, &ar->flag)) { + clear_bit(ROAM_TBL_PEND, &ar->flag); + wake_up(&ar->event_wq); + } + + return 0; +} + +static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + int ret; + long left; + struct wmi_target_roam_tbl *tbl; + u16 num_entries, i; + char *buf; + unsigned int len, buf_len; + ssize_t ret_cnt; + + if (down_interruptible(&ar->sem)) + return -EBUSY; + + set_bit(ROAM_TBL_PEND, &ar->flag); + + ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi); + if (ret) { + up(&ar->sem); + return ret; + } + + left = wait_event_interruptible_timeout( + ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT); + up(&ar->sem); + + if (left <= 0) + return -ETIMEDOUT; + + if (ar->debug.roam_tbl == NULL) + return -ENOMEM; + + tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl; + num_entries = le16_to_cpu(tbl->num_entries); + + buf_len = 100 + num_entries * 100; + buf = kzalloc(buf_len, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + len = 0; + len += scnprintf(buf + len, buf_len - len, + "roam_mode=%u\n\n" + "# roam_util bssid rssi rssidt last_rssi util bias\n", + le16_to_cpu(tbl->roam_mode)); + + for (i = 0; i < num_entries; i++) { + struct wmi_bss_roam_info *info = &tbl->info[i]; + len += scnprintf(buf + len, buf_len - len, + "%d %pM %d %d %d %d %d\n", + a_sle32_to_cpu(info->roam_util), info->bssid, + info->rssi, info->rssidt, info->last_rssi, + info->util, info->bias); + } + + if (len > buf_len) + len = buf_len; + + ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); + + kfree(buf); + return ret_cnt; +} + +static const struct file_operations fops_roam_table = { + .read = ath6kl_roam_table_read, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + int ath6kl_debug_init(struct ath6kl *ar) { ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); @@ -1024,6 +1129,9 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar, &fops_war_stats); + debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar, + &fops_roam_table); + return 0; } @@ -1031,6 +1139,7 @@ void ath6kl_debug_cleanup(struct ath6kl *ar) { vfree(ar->debug.fwlog_buf.buf); kfree(ar->debug.fwlog_tmp); + kfree(ar->debug.roam_tbl); } #endif diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index e3740b0..f73bf15 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -90,6 +90,8 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, void dump_cred_dist_stats(struct htc_target *target); void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len); void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war); +int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf, + size_t len); int ath6kl_debug_init(struct ath6kl *ar); void ath6kl_debug_cleanup(struct ath6kl *ar); @@ -125,6 +127,12 @@ static inline void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war) { } +static inline int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, + const void *buf, size_t len) +{ + return 0; +} + static inline int ath6kl_debug_init(struct ath6kl *ar) { return 0; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index ab782d7..4021527 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2407,6 +2407,11 @@ int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); } +int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) +{ + return ath6kl_wmi_simple_cmd(wmi, WMI_GET_ROAM_TBL_CMDID); +} + int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) { struct sk_buff *skb; @@ -2844,6 +2849,11 @@ static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) return ret; } +static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) +{ + return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len); +} + /* Control Path */ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) { @@ -2948,6 +2958,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_REPORT_ROAM_TBL_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); + ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len); break; case WMI_EXTENSION_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 96102c6..f986da1 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1624,6 +1624,12 @@ struct wmi_bss_roam_info { u8 reserved; } __packed; +struct wmi_target_roam_tbl { + __le16 roam_mode; + __le16 num_entries; + struct wmi_bss_roam_info info[]; +} __packed; + /* WMI_CAC_EVENTID */ enum cac_indication { CAC_INDICATION_ADMISSION = 0x00, @@ -2221,6 +2227,7 @@ int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, const u8 *pmkid, bool set); int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM); int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi); +int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi); int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg); int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl); -- cgit v0.10.2 From 1261875f7a0a22d0d47bd400b9e9a5cf99909bbf Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 11 Oct 2011 17:31:55 +0300 Subject: ath6kl: Add debugfs files for roaming control Roaming mode can be changed by writing roam mode (default, bssbias, or lock) to roam_mode. Forced roam can be requested by writing the BSSID into force_roam. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index cec958a..41161ca72 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1071,6 +1071,84 @@ static const struct file_operations fops_roam_table = { .llseek = default_llseek, }; +static ssize_t ath6kl_force_roam_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + int ret; + char buf[20]; + size_t len; + u8 bssid[ETH_ALEN]; + int i; + int addr[ETH_ALEN]; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + buf[len] = '\0'; + + if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", + &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) + != ETH_ALEN) + return -EINVAL; + for (i = 0; i < ETH_ALEN; i++) + bssid[i] = addr[i]; + + ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid); + if (ret) + return ret; + + return count; +} + +static const struct file_operations fops_force_roam = { + .write = ath6kl_force_roam_write, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t ath6kl_roam_mode_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + int ret; + char buf[20]; + size_t len; + enum wmi_roam_mode mode; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + buf[len] = '\0'; + if (len > 0 && buf[len - 1] == '\n') + buf[len - 1] = '\0'; + + if (strcasecmp(buf, "default") == 0) + mode = WMI_DEFAULT_ROAM_MODE; + else if (strcasecmp(buf, "bssbias") == 0) + mode = WMI_HOST_BIAS_ROAM_MODE; + else if (strcasecmp(buf, "lock") == 0) + mode = WMI_LOCK_BSS_MODE; + else + return -EINVAL; + + ret = ath6kl_wmi_set_roam_mode_cmd(ar->wmi, mode); + if (ret) + return ret; + + return count; +} + +static const struct file_operations fops_roam_mode = { + .write = ath6kl_roam_mode_write, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + int ath6kl_debug_init(struct ath6kl *ar) { ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); @@ -1132,6 +1210,12 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar, &fops_roam_table); + debugfs_create_file("force_roam", S_IWUSR, ar->debugfs_phy, ar, + &fops_force_roam); + + debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar, + &fops_roam_mode); + return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 4021527..3fb2702 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -682,6 +682,46 @@ int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) return 0; } +int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) +{ + struct sk_buff *skb; + struct roam_ctrl_cmd *cmd; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct roam_ctrl_cmd *) skb->data; + memset(cmd, 0, sizeof(*cmd)); + + memcpy(cmd->info.bssid, bssid, ETH_ALEN); + cmd->roam_ctrl = WMI_FORCE_ROAM; + + ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid); + return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, + NO_SYNC_WMIFLAG); +} + +int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) +{ + struct sk_buff *skb; + struct roam_ctrl_cmd *cmd; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct roam_ctrl_cmd *) skb->data; + memset(cmd, 0, sizeof(*cmd)); + + cmd->info.roam_mode = mode; + cmd->roam_ctrl = WMI_SET_ROAM_MODE; + + ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode); + return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, + NO_SYNC_WMIFLAG); +} + static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) { struct wmi_connect_event *ev; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index f986da1..f0ca899 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1354,14 +1354,20 @@ enum wmi_roam_ctrl { WMI_SET_LRSSI_SCAN_PARAMS, }; +enum wmi_roam_mode { + WMI_DEFAULT_ROAM_MODE = 1, /* RSSI based roam */ + WMI_HOST_BIAS_ROAM_MODE = 2, /* Host bias based roam */ + WMI_LOCK_BSS_MODE = 3, /* Lock to the current BSS */ +}; + struct bss_bias { u8 bssid[ETH_ALEN]; - u8 bias; + s8 bias; } __packed; struct bss_bias_info { u8 num_bss; - struct bss_bias bss_bias[1]; + struct bss_bias bss_bias[0]; } __packed; struct low_rssi_scan_params { @@ -1374,10 +1380,11 @@ struct low_rssi_scan_params { struct roam_ctrl_cmd { union { - u8 bssid[ETH_ALEN]; - u8 roam_mode; - struct bss_bias_info bss; - struct low_rssi_scan_params params; + u8 bssid[ETH_ALEN]; /* WMI_FORCE_ROAM */ + u8 roam_mode; /* WMI_SET_ROAM_MODE */ + struct bss_bias_info bss; /* WMI_SET_HOST_BIAS */ + struct low_rssi_scan_params params; /* WMI_SET_LRSSI_SCAN_PARAMS + */ } __packed info; u8 roam_ctrl; } __packed; @@ -2237,6 +2244,8 @@ s32 ath6kl_wmi_get_rate(s8 rate_index); int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd); int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi); +int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid); +int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode); /* AP mode */ int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p); -- cgit v0.10.2 From ff0b007573c70be88c4efd3c1d8b41e9ba9710b3 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 11 Oct 2011 17:31:56 +0300 Subject: ath6kl: Add debugfs control for keepalive and disconnection timeout The new debugfs files keepalive and disconnect_timeout can be used to fetch the current values and to change the values for keepalive and disconnect event timeout (both in seconds). Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index c58cfad..31e5c7e 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -533,6 +533,9 @@ struct ath6kl { u8 *roam_tbl; unsigned int roam_tbl_len; + + u8 keepalive; + u8 disc_timeout; } debug; #endif /* CONFIG_ATH6KL_DEBUG */ }; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 41161ca72..7b1c9ae 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1149,6 +1149,95 @@ static const struct file_operations fops_roam_mode = { .llseek = default_llseek, }; +void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive) +{ + ar->debug.keepalive = keepalive; +} + +static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + char buf[16]; + int len; + + len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t ath6kl_keepalive_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + int ret; + u8 val; + + ret = kstrtou8_from_user(user_buf, count, 0, &val); + if (ret) + return ret; + + ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, val); + if (ret) + return ret; + + return count; +} + +static const struct file_operations fops_keepalive = { + .open = ath6kl_debugfs_open, + .read = ath6kl_keepalive_read, + .write = ath6kl_keepalive_write, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout) +{ + ar->debug.disc_timeout = timeout; +} + +static ssize_t ath6kl_disconnect_timeout_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + char buf[16]; + int len; + + len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t ath6kl_disconnect_timeout_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + int ret; + u8 val; + + ret = kstrtou8_from_user(user_buf, count, 0, &val); + if (ret) + return ret; + + ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, val); + if (ret) + return ret; + + return count; +} + +static const struct file_operations fops_disconnect_timeout = { + .open = ath6kl_debugfs_open, + .read = ath6kl_disconnect_timeout_read, + .write = ath6kl_disconnect_timeout_write, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + int ath6kl_debug_init(struct ath6kl *ar) { ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); @@ -1216,6 +1305,12 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar, &fops_roam_mode); + debugfs_create_file("keepalive", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar, + &fops_keepalive); + + debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR, + ar->debugfs_phy, ar, &fops_disconnect_timeout); + return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index f73bf15..7d5323d 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -92,6 +92,8 @@ void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len); void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war); int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf, size_t len); +void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive); +void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout); int ath6kl_debug_init(struct ath6kl *ar); void ath6kl_debug_cleanup(struct ath6kl *ar); @@ -133,6 +135,15 @@ static inline int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, return 0; } +static inline void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive) +{ +} + +static inline void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, + u8 timeout) +{ +} + static inline int ath6kl_debug_init(struct ath6kl *ar) { return 0; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 3fb2702..7b6bfdd 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -1940,6 +1940,8 @@ int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, NO_SYNC_WMIFLAG); + if (ret == 0) + ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); return ret; } @@ -2524,6 +2526,8 @@ int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, NO_SYNC_WMIFLAG); + if (ret == 0) + ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl); return ret; } -- cgit v0.10.2 From 837cb97e5b72fb315e46d137d514720c62f371bf Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 11 Oct 2011 17:31:57 +0300 Subject: ath6kl: Allow CCKM AKM and KRK to be configured Use vendor-specific suite selectors to allow CCKM to be configured. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 40a2d7a..16258c2 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -121,6 +121,8 @@ static struct ieee80211_supported_band ath6kl_band_5ghz = { .bitrates = ath6kl_a_rates, }; +#define CCKM_KRK_CIPHER_SUITE 0x004096ff /* use for KRK */ + static int ath6kl_set_wpa_version(struct ath6kl *ar, enum nl80211_wpa_versions wpa_version) { @@ -217,6 +219,11 @@ static void ath6kl_set_key_mgmt(struct ath6kl *ar, u32 key_mgmt) ar->auth_mode = WPA_PSK_AUTH; else if (ar->auth_mode == WPA2_AUTH) ar->auth_mode = WPA2_PSK_AUTH; + } else if (key_mgmt == 0x00409600) { + if (ar->auth_mode == WPA_AUTH) + ar->auth_mode = WPA_AUTH_CCKM; + else if (ar->auth_mode == WPA2_AUTH) + ar->auth_mode = WPA2_AUTH_CCKM; } else if (key_mgmt != WLAN_AKM_SUITE_8021X) { ar->auth_mode = NONE_AUTH; } @@ -811,6 +818,12 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, if (!ath6kl_cfg80211_ready(ar)) return -EIO; + if (params->cipher == CCKM_KRK_CIPHER_SUITE) { + if (params->key_len != WMI_KRK_LEN) + return -EINVAL; + return ath6kl_wmi_add_krk_cmd(ar->wmi, params->key); + } + if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: key index %d out of bounds\n", __func__, @@ -1281,6 +1294,7 @@ static const u32 cipher_suites[] = { WLAN_CIPHER_SUITE_WEP104, WLAN_CIPHER_SUITE_TKIP, WLAN_CIPHER_SUITE_CCMP, + CCKM_KRK_CIPHER_SUITE, }; static bool is_rate_legacy(s32 rate) -- cgit v0.10.2 From bef26a7fcaa228c8bc591d975b4b0a2b76fcdecf Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 12 Oct 2011 09:58:28 +0300 Subject: ath6kl: fix firmware start address for ar6003 hw2.0 Sangwook found out that commit 639d0b89 ("ath6kl: read firmware start address from hardware") broke firmware boot on ar6003 hw2.0 as it seems it's not posible to automatically query the address from hardware. So we need to hardcode the address for hw2.0. Reported-by: Sangwook Lee Tested-by: Sangwook Lee Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index aa4dfd5..51ac626 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1182,6 +1182,7 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) static int ath6kl_upload_otp(struct ath6kl *ar) { u32 address, param; + bool from_hw = false; int ret; if (WARN_ON(ar->fw_otp == NULL)) @@ -1210,15 +1211,20 @@ static int ath6kl_upload_otp(struct ath6kl *ar) return ret; } - ar->hw.app_start_override_addr = address; + if (ar->hw.app_start_override_addr == 0) { + ar->hw.app_start_override_addr = address; + from_hw = true; + } - ath6kl_dbg(ATH6KL_DBG_BOOT, "app_start_override_addr 0x%x\n", + ath6kl_dbg(ATH6KL_DBG_BOOT, "app_start_override_addr%s 0x%x\n", + from_hw ? " (from hw)" : "", ar->hw.app_start_override_addr); /* execute the OTP code */ - ath6kl_dbg(ATH6KL_DBG_BOOT, "executing OTP at 0x%x\n", address); + ath6kl_dbg(ATH6KL_DBG_BOOT, "executing OTP at 0x%x\n", + ar->hw.app_start_override_addr); param = 0; - ath6kl_bmi_execute(ar, address, ¶m); + ath6kl_bmi_execute(ar, ar->hw.app_start_override_addr, ¶m); return ret; } @@ -1420,6 +1426,10 @@ static int ath6kl_init_hw_params(struct ath6kl *ar) ar->hw.app_load_addr = AR6003_REV2_APP_LOAD_ADDRESS; ar->hw.board_ext_data_addr = AR6003_REV2_BOARD_EXT_DATA_ADDRESS; ar->hw.reserved_ram_size = AR6003_REV2_RAM_RESERVE_SIZE; + + /* hw2.0 needs override address hardcoded */ + ar->hw.app_start_override_addr = 0x944C00; + break; case AR6003_REV3_VERSION: ar->hw.dataset_patch_addr = AR6003_REV3_DATASET_PATCH_ADDRESS; -- cgit v0.10.2 From 17380859a8fae40f7420d8fcc4be7a041a370659 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Thu, 13 Oct 2011 13:20:32 +0300 Subject: ath6kl: unbreak suspend Add missing {}'s that caused ath6kl_sdio_suspend to always return -EINVAL causing suspend to be aborted. kvalo: I broke this in commit f7325b85e ("ath6kl: add sdio debug messages") Signed-off-by: Sam Leffler Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 2394c17..58e31f6 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -724,12 +724,13 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) flags = sdio_get_host_pm_caps(func); - if (!(flags & MMC_PM_KEEP_POWER)) + if (!(flags & MMC_PM_KEEP_POWER)) { /* as host doesn't support keep power we need to bail out */ ath6kl_dbg(ATH6KL_DBG_SDIO, "func %d doesn't support MMC_PM_KEEP_POWER\n", func->num); return -EINVAL; + } ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); if (ret) { -- cgit v0.10.2 From 171693292ec733ecb96734370ddfe0d9f73e920f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 11 Oct 2011 22:08:21 +0300 Subject: ath6kl: Fix endpoint_stats debugfs buffer length calculation The previous version did not really make much sense and the theoretical maximum length would be a bit longer. Calculate the length more accurately. In addition, there is no need to clear the buffer, so use kmalloc instead of kzalloc. For bonus points, add the forgotten cred_rpt_from_other value to the file. Reported-by: Joe Perches Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 7b1c9ae..dd37785 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -624,8 +624,9 @@ static ssize_t ath6kl_endpoint_stats_read(struct file *file, unsigned int buf_len, len = 0; ssize_t ret_cnt; - buf_len = 1000 + ENDPOINT_MAX * 100; - buf = kzalloc(buf_len, GFP_KERNEL); + buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) * + (25 + ENDPOINT_MAX * 11); + buf = kmalloc(buf_len, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -640,6 +641,7 @@ static ssize_t ath6kl_endpoint_stats_read(struct file *file, EPSTAT(tx_dropped); EPSTAT(tx_cred_rpt); EPSTAT(cred_rpt_from_rx); + EPSTAT(cred_rpt_from_other); EPSTAT(cred_rpt_ep0); EPSTAT(cred_from_rx); EPSTAT(cred_from_other); -- cgit v0.10.2 From 8fffd9e5ec9ea046ff45c7974395ffbcb4bbef14 Mon Sep 17 00:00:00 2001 From: Rishi Panjwani Date: Fri, 14 Oct 2011 17:48:07 -0700 Subject: ath6kl: Implement support for QOS-enable and QOS-disable from userspace In order to allow user space based QOS control we use the available debugfs infrastructure. With this feature, user can make changes to qos parameters, thereby allowing creation and deletion of user defined priority streams and features like uapsd. This feature has been added for testing purposes. All 21 parameters for the create_qos command are mandatory in the correct order. They have to be written to the create_qos file in the ath6kl debug directory. These parameters(in order) are: 1)user priority 2)direction 3)traffic class 4)traffic type 5)voice PS capability 6)min service intvl 7)max service intvl 8)inactivity intvl 9)suspension intvl 10)serv start time 11)tsid 12)nominal msdu 13)max msdu 14)min data rate 15)mean data rate 16)peak data rate 17)max burst size 18)delay bound 19)min phy rate 20)surplus bw allowance 21)medium time To create a qos stream: echo "6 2 3 1 1 9999999 9999999 9999999 7777777 0 6 45000 200 56789000 56789000 5678900 0 0 9999999 20000 0" > create_qos delete_qos requires 2 parameters: 1)traffic class 2)tsid To delete a qos stream: echo "3 1" > delete_qos kvalo: minor commit log cleanup Signed-off-by: Rishi Panjwani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index dd37785..460f211 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1240,6 +1240,220 @@ static const struct file_operations fops_disconnect_timeout = { .llseek = default_llseek, }; +static ssize_t ath6kl_create_qos_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + + struct ath6kl *ar = file->private_data; + char buf[100]; + ssize_t len; + char *sptr, *token; + struct wmi_create_pstream_cmd pstream; + u32 val32; + u16 val16; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + buf[len] = '\0'; + sptr = buf; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &pstream.user_pri)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &pstream.traffic_direc)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &pstream.traffic_class)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &pstream.traffic_type)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &pstream.voice_psc_cap)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.min_service_int = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.max_service_int = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.inactivity_int = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.suspension_int = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.service_start_time = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &pstream.tsid)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou16(token, 0, &val16)) + return -EINVAL; + pstream.nominal_msdu = cpu_to_le16(val16); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou16(token, 0, &val16)) + return -EINVAL; + pstream.max_msdu = cpu_to_le16(val16); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.min_data_rate = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.mean_data_rate = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.peak_data_rate = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.max_burst_size = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.delay_bound = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.min_phy_rate = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.sba = cpu_to_le32(val32); + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou32(token, 0, &val32)) + return -EINVAL; + pstream.medium_time = cpu_to_le32(val32); + + ath6kl_wmi_create_pstream_cmd(ar->wmi, &pstream); + + return count; +} + +static const struct file_operations fops_create_qos = { + .write = ath6kl_create_qos_write, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +static ssize_t ath6kl_delete_qos_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + + struct ath6kl *ar = file->private_data; + char buf[100]; + ssize_t len; + char *sptr, *token; + u8 traffic_class; + u8 tsid; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + buf[len] = '\0'; + sptr = buf; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &traffic_class)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou8(token, 0, &tsid)) + return -EINVAL; + + ath6kl_wmi_delete_pstream_cmd(ar->wmi, traffic_class, tsid); + + return count; +} + +static const struct file_operations fops_delete_qos = { + .write = ath6kl_delete_qos_write, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + int ath6kl_debug_init(struct ath6kl *ar) { ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); @@ -1313,6 +1527,12 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar, &fops_disconnect_timeout); + debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar, + &fops_create_qos); + + debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar, + &fops_delete_qos); + return 0; } -- cgit v0.10.2 From ebf29c95cfc6f7309ce999af4aa91ba22323f80d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 13 Oct 2011 15:21:15 +0300 Subject: ath6kl: merge htc debug levels It's not really necessary to have separate debug levels for htc tx and rx so combine them. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 460f211..e109f29 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -180,9 +180,10 @@ void dump_cred_dist_stats(struct htc_target *target) list_for_each_entry(ep_list, &target->cred_dist_list, list) dump_cred_dist(ep_list); - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "ctxt:%p dist:%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:%p dist:%p\n", target->cred_dist_cntxt, NULL); - ath6kl_dbg(ATH6KL_DBG_TRC, "credit distribution, total : %d, free : %d\n", + ath6kl_dbg(ATH6KL_DBG_HTC, + "credit distribution, total : %d, free : %d\n", target->cred_dist_cntxt->total_avail_credits, target->cred_dist_cntxt->cur_free_credits); } diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 7d5323d..01f4015 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -25,8 +25,8 @@ enum ATH6K_DEBUG_MASK { ATH6KL_DBG_WLAN_TX = BIT(2), /* wlan tx */ ATH6KL_DBG_WLAN_RX = BIT(3), /* wlan rx */ ATH6KL_DBG_BMI = BIT(4), /* bmi tracing */ - ATH6KL_DBG_HTC_SEND = BIT(5), /* htc send */ - ATH6KL_DBG_HTC_RECV = BIT(6), /* htc recv */ + ATH6KL_DBG_HTC = BIT(5), + /* hole */ ATH6KL_DBG_IRQ = BIT(7), /* interrupt processing */ ATH6KL_DBG_PM = BIT(8), /* power management */ ATH6KL_DBG_WLAN_NODE = BIT(9), /* general wlan node tracing */ diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index 57c9aff..7cc6cec 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -51,7 +51,7 @@ int ath6kl_hif_rw_comp_handler(void *context, int status) { struct htc_packet *packet = context; - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "ath6kl_hif_rw_comp_handler (pkt:0x%p , status: %d\n", packet, status); @@ -119,7 +119,7 @@ int ath6kl_hif_poll_mboxmsg_rx(struct ath6kl_device *dev, u32 *lk_ahd, /* delay a little */ mdelay(ATH6KL_TIME_QUANTUM); - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, "retry mbox poll : %d\n", i); + ath6kl_dbg(ATH6KL_DBG_HTC, "retry mbox poll : %d\n", i); } if (i == 0) { @@ -186,7 +186,7 @@ int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev, dev->ar->mbox_info.htc_addr; } - ath6kl_dbg((ATH6KL_DBG_HTC_RECV | ATH6KL_DBG_HTC_SEND), + ath6kl_dbg(ATH6KL_DBG_HTC, "ath6kl_hif_submit_scat_req, entries: %d, total len: %d mbox:0x%X (mode: %s : %s)\n", scat_req->scat_entries, scat_req->len, scat_req->addr, !read ? "async" : "sync", diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 9b8cb22..241a7ce 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -102,7 +102,7 @@ static void htc_tx_comp_update(struct htc_target *target, packet->info.tx.cred_used; endpoint->cred_dist.txq_depth = get_queue_depth(&endpoint->txq); - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); ath6k_credit_distribute(target->cred_dist_cntxt, @@ -118,7 +118,7 @@ static void htc_tx_complete(struct htc_endpoint *endpoint, if (list_empty(txq)) return; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "send complete ep %d, (%d pkts)\n", endpoint->eid, get_queue_depth(txq)); @@ -148,7 +148,7 @@ static void htc_async_tx_scat_complete(struct htc_target *target, INIT_LIST_HEAD(&tx_compq); - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc_async_tx_scat_complete total len: %d entries: %d\n", scat_req->len, scat_req->scat_entries); @@ -190,12 +190,12 @@ static int ath6kl_htc_tx_issue(struct htc_target *target, send_len = packet->act_len + HTC_HDR_LENGTH; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "%s: transmit len : %d (%s)\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "%s: transmit len : %d (%s)\n", __func__, send_len, sync ? "sync" : "async"); padded_len = CALC_TXRX_PADDED_LEN(target, send_len); - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "DevSendPacket, padded len: %d mbox:0x%X (mode:%s)\n", padded_len, target->dev->ar->mbox_info.htc_addr, @@ -227,7 +227,7 @@ static int htc_check_credits(struct htc_target *target, *req_cred = (len > target->tgt_cred_sz) ? DIV_ROUND_UP(len, target->tgt_cred_sz) : 1; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "creds required:%d got:%d\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "creds required:%d got:%d\n", *req_cred, ep->cred_dist.credits); if (ep->cred_dist.credits < *req_cred) { @@ -237,7 +237,7 @@ static int htc_check_credits(struct htc_target *target, /* Seek more credits */ ep->cred_dist.seek_cred = *req_cred - ep->cred_dist.credits; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", target->cred_dist_cntxt, &ep->cred_dist); ath6k_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); @@ -245,7 +245,7 @@ static int htc_check_credits(struct htc_target *target, ep->cred_dist.seek_cred = 0; if (ep->cred_dist.credits < *req_cred) { - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "not enough credits for ep %d - leaving packet in queue\n", eid); return -EINVAL; @@ -260,7 +260,7 @@ static int htc_check_credits(struct htc_target *target, ep->cred_dist.seek_cred = ep->cred_dist.cred_per_msg - ep->cred_dist.credits; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", target->cred_dist_cntxt, &ep->cred_dist); ath6k_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); @@ -270,7 +270,7 @@ static int htc_check_credits(struct htc_target *target, /* tell the target we need credits ASAP! */ *flags |= HTC_FLAGS_NEED_CREDIT_UPDATE; ep->ep_st.cred_low_indicate += 1; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "host needs credits\n"); + ath6kl_dbg(ATH6KL_DBG_HTC, "host needs credits\n"); } } @@ -295,7 +295,7 @@ static void ath6kl_htc_tx_pkts_get(struct htc_target *target, packet = list_first_entry(&endpoint->txq, struct htc_packet, list); - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "got head pkt:0x%p , queue depth: %d\n", packet, get_queue_depth(&endpoint->txq)); @@ -404,7 +404,7 @@ static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, scat_req->len += len; scat_req->scat_entries++; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "%d, adding pkt : 0x%p len:%d (remaining space:%d)\n", i, packet, len, rem_scat); } @@ -455,12 +455,12 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, if (!scat_req) { /* no scatter resources */ - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "no more scatter resources\n"); break; } - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "pkts to scatter: %d\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "pkts to scatter: %d\n", n_scat); scat_req->len = 0; @@ -479,7 +479,7 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, n_sent_bundle++; tot_pkts_bundle += scat_req->scat_entries; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "send scatter total bytes: %d , entries: %d\n", scat_req->len, scat_req->scat_entries); ath6kl_hif_submit_scat_req(target->dev, scat_req, false); @@ -490,7 +490,7 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, *sent_bundle = n_sent_bundle; *n_bundle_pkts = tot_pkts_bundle; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "%s (sent:%d)\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "%s (sent:%d)\n", __func__, n_sent_bundle); return; @@ -510,7 +510,7 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, if (endpoint->tx_proc_cnt > 1) { endpoint->tx_proc_cnt--; spin_unlock_bh(&target->tx_lock); - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "htc_try_send (busy)\n"); + ath6kl_dbg(ATH6KL_DBG_HTC, "htc_try_send (busy)\n"); return; } @@ -588,13 +588,13 @@ static bool ath6kl_htc_tx_try(struct htc_target *target, overflow = true; if (overflow) - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "ep %d, tx queue will overflow :%d , tx depth:%d, max:%d\n", endpoint->eid, overflow, txq_depth, endpoint->max_txq_depth); if (overflow && ep_cb.tx_full) { - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "indicating overflowed tx packet: 0x%p\n", tx_pkt); if (ep_cb.tx_full(endpoint->target, tx_pkt) == @@ -629,7 +629,7 @@ static void htc_chk_ep_txq(struct htc_target *target) spin_lock_bh(&target->tx_lock); if (!list_empty(&endpoint->txq)) { - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "ep %d has %d credits and %d packets in tx queue\n", cred_dist->endpoint, endpoint->cred_dist.credits, @@ -736,7 +736,7 @@ int ath6kl_htc_tx(struct htc_target *target, struct htc_packet *packet) struct htc_endpoint *endpoint; struct list_head queue; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc_tx: ep id: %d, buf: 0x%p, len: %d\n", packet->endpoint, packet->buf, packet->act_len); @@ -787,7 +787,7 @@ void ath6kl_htc_flush_txep(struct htc_target *target, list_for_each_entry_safe(packet, tmp_pkt, &discard_q, list) { packet->status = -ECANCELED; list_del(&packet->list); - ath6kl_dbg(ATH6KL_DBG_TRC, + ath6kl_dbg(ATH6KL_DBG_HTC, "flushing tx pkt:0x%p, len:%d, ep:%d tag:0x%X\n", packet, packet->act_len, packet->endpoint, packet->info.tx.tag); @@ -844,7 +844,7 @@ void ath6kl_htc_indicate_activity_change(struct htc_target *target, endpoint->cred_dist.txq_depth = get_queue_depth(&endpoint->txq); - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); ath6k_credit_distribute(target->cred_dist_cntxt, @@ -924,7 +924,7 @@ static int ath6kl_htc_rx_packet(struct htc_target *target, return -ENOMEM; } - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "dev_rx_pkt (0x%p : hdr:0x%X) padded len: %d mbox:0x%X (mode:%s)\n", packet, packet->info.rx.exp_hdr, padded_len, dev->ar->mbox_info.htc_addr, "sync"); @@ -1137,7 +1137,7 @@ static int ath6kl_htc_rx_alloc(struct htc_target *target, } endpoint->ep_st.rx_bundle_from_hdr += 1; - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc hdr indicates :%d msg can be fetched as a bundle\n", n_msg); } else @@ -1209,7 +1209,7 @@ static void htc_proc_cred_rpt(struct htc_target *target, int tot_credits = 0, i; bool dist = false; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc_proc_cred_rpt, credit report entries:%d\n", n_entries); spin_lock_bh(&target->tx_lock); @@ -1223,7 +1223,7 @@ static void htc_proc_cred_rpt(struct htc_target *target, endpoint = &target->endpoint[rpt->eid]; - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, " ep %d got %d credits\n", + ath6kl_dbg(ATH6KL_DBG_HTC, " ep %d got %d credits\n", rpt->eid, rpt->credits); endpoint->ep_st.tx_cred_rpt += 1; @@ -1264,7 +1264,7 @@ static void htc_proc_cred_rpt(struct htc_target *target, tot_credits += rpt->credits; } - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, + ath6kl_dbg(ATH6KL_DBG_HTC, "report indicated %d credits to distribute\n", tot_credits); @@ -1273,7 +1273,7 @@ static void htc_proc_cred_rpt(struct htc_target *target, * This was a credit return based on a completed send * operations note, this is done with the lock held */ - ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); ath6k_credit_distribute(target->cred_dist_cntxt, @@ -1320,7 +1320,7 @@ static int htc_parse_trailer(struct htc_target *target, if ((lk_ahd->pre_valid == ((~lk_ahd->post_valid) & 0xFF)) && next_lk_ahds) { - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "lk_ahd report found (pre valid:0x%X, post valid:0x%X)\n", lk_ahd->pre_valid, lk_ahd->post_valid); @@ -1378,7 +1378,7 @@ static int htc_proc_trailer(struct htc_target *target, u8 *record_buf; u8 *orig_buf; - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, "+htc_proc_trailer (len:%d)\n", len); + ath6kl_dbg(ATH6KL_DBG_HTC, "+htc_proc_trailer (len:%d)\n", len); ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Recv Trailer", "", buf, len); @@ -1534,7 +1534,7 @@ fail_rx: static void ath6kl_htc_rx_complete(struct htc_endpoint *endpoint, struct htc_packet *packet) { - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc calling ep %d recv callback on packet 0x%p\n", endpoint->eid, packet); endpoint->ep_cb.rx(endpoint->target, packet); @@ -1571,7 +1571,7 @@ static int ath6kl_htc_rx_bundle(struct htc_target *target, len = 0; - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "%s(): (numpackets: %d , actual : %d)\n", __func__, get_queue_depth(rxq), n_scat_pkt); @@ -1897,7 +1897,7 @@ static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target) HTC_TARGET_RESPONSE_TIMEOUT)) return NULL; - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc_wait_for_ctrl_msg: look_ahead : 0x%X\n", look_ahead); htc_hdr = (struct htc_frame_hdr *)&look_ahead; @@ -1962,7 +1962,7 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, depth = get_queue_depth(pkt_queue); - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc_add_rxbuf_multiple: ep id: %d, cnt:%d, len: %d\n", first_pkt->endpoint, depth, first_pkt->buf_len); @@ -1988,7 +1988,7 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, /* check if we are blocked waiting for a new buffer */ if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { if (target->ep_waiting == first_pkt->endpoint) { - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "receiver was blocked on ep:%d, unblocking.\n", target->ep_waiting); target->rx_st_flags &= ~HTC_RECV_WAIT_BUFFERS; @@ -2023,7 +2023,7 @@ void ath6kl_htc_flush_rx_buf(struct htc_target *target) &endpoint->rx_bufq, list) { list_del(&packet->list); spin_unlock_bh(&target->rx_lock); - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "flushing rx pkt:0x%p, len:%d, ep:%d\n", packet, packet->buf_len, packet->endpoint); @@ -2047,7 +2047,7 @@ int ath6kl_htc_conn_service(struct htc_target *target, unsigned int max_msg_sz = 0; int status = 0; - ath6kl_dbg(ATH6KL_DBG_TRC, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc_conn_service, target:0x%p service id:0x%X\n", target, conn_req->svc_id); @@ -2220,7 +2220,7 @@ static void htc_setup_msg_bndl(struct htc_target *target) target->msg_per_bndl_max = min(target->max_scat_entries, target->msg_per_bndl_max); - ath6kl_dbg(ATH6KL_DBG_TRC, + ath6kl_dbg(ATH6KL_DBG_HTC, "htc bundling allowed. max msg per htc bundle: %d\n", target->msg_per_bndl_max); @@ -2230,7 +2230,7 @@ static void htc_setup_msg_bndl(struct htc_target *target) target->max_tx_bndl_sz = min(HIF_MBOX0_EXT_WIDTH, target->max_xfer_szper_scatreq); - ath6kl_dbg(ATH6KL_DBG_ANY, "max recv: %d max send: %d\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "max recv: %d max send: %d\n", target->max_rx_bndl_sz, target->max_tx_bndl_sz); if (target->max_tx_bndl_sz) @@ -2284,7 +2284,7 @@ int ath6kl_htc_wait_target(struct htc_target *target) target->tgt_creds = le16_to_cpu(rdy_msg->ver2_0_info.cred_cnt); target->tgt_cred_sz = le16_to_cpu(rdy_msg->ver2_0_info.cred_sz); - ath6kl_dbg(ATH6KL_DBG_HTC_RECV, + ath6kl_dbg(ATH6KL_DBG_HTC, "target ready: credits: %d credit size: %d\n", target->tgt_creds, target->tgt_cred_sz); @@ -2299,7 +2299,7 @@ int ath6kl_htc_wait_target(struct htc_target *target) target->msg_per_bndl_max = 0; } - ath6kl_dbg(ATH6KL_DBG_TRC, "using htc protocol version : %s (%d)\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "using htc protocol version : %s (%d)\n", (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", target->htc_tgt_ver); -- cgit v0.10.2 From 471e92fdfb33dee27ad56ca0e0eec5c1b781af5d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 13 Oct 2011 15:21:37 +0300 Subject: ath6kl: cleanup htc debug messages Unify debug message format and other minor changes. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 241a7ce..840f1b3 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -102,7 +102,7 @@ static void htc_tx_comp_update(struct htc_target *target, packet->info.tx.cred_used; endpoint->cred_dist.txq_depth = get_queue_depth(&endpoint->txq); - ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); ath6k_credit_distribute(target->cred_dist_cntxt, @@ -119,7 +119,7 @@ static void htc_tx_complete(struct htc_endpoint *endpoint, return; ath6kl_dbg(ATH6KL_DBG_HTC, - "send complete ep %d, (%d pkts)\n", + "htc tx complete ep %d pkts %d\n", endpoint->eid, get_queue_depth(txq)); ath6kl_tx_complete(endpoint->target->dev->ar, txq); @@ -149,7 +149,7 @@ static void htc_async_tx_scat_complete(struct htc_target *target, INIT_LIST_HEAD(&tx_compq); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc_async_tx_scat_complete total len: %d entries: %d\n", + "htc tx scat complete len %d entries %d\n", scat_req->len, scat_req->scat_entries); if (scat_req->status) @@ -190,16 +190,13 @@ static int ath6kl_htc_tx_issue(struct htc_target *target, send_len = packet->act_len + HTC_HDR_LENGTH; - ath6kl_dbg(ATH6KL_DBG_HTC, "%s: transmit len : %d (%s)\n", - __func__, send_len, sync ? "sync" : "async"); - padded_len = CALC_TXRX_PADDED_LEN(target, send_len); ath6kl_dbg(ATH6KL_DBG_HTC, - "DevSendPacket, padded len: %d mbox:0x%X (mode:%s)\n", - padded_len, - target->dev->ar->mbox_info.htc_addr, - sync ? "sync" : "async"); + "htc tx issue len %d padded_len %d mbox 0x%X %s\n", + send_len, padded_len, + target->dev->ar->mbox_info.htc_addr, + sync ? "sync" : "async"); if (sync) { status = hif_read_write_sync(target->dev->ar, @@ -227,7 +224,7 @@ static int htc_check_credits(struct htc_target *target, *req_cred = (len > target->tgt_cred_sz) ? DIV_ROUND_UP(len, target->tgt_cred_sz) : 1; - ath6kl_dbg(ATH6KL_DBG_HTC, "creds required:%d got:%d\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds required %d got %d\n", *req_cred, ep->cred_dist.credits); if (ep->cred_dist.credits < *req_cred) { @@ -237,7 +234,7 @@ static int htc_check_credits(struct htc_target *target, /* Seek more credits */ ep->cred_dist.seek_cred = *req_cred - ep->cred_dist.credits; - ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &ep->cred_dist); ath6k_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); @@ -246,7 +243,7 @@ static int htc_check_credits(struct htc_target *target, if (ep->cred_dist.credits < *req_cred) { ath6kl_dbg(ATH6KL_DBG_HTC, - "not enough credits for ep %d - leaving packet in queue\n", + "htc creds not enough credits for ep %d\n", eid); return -EINVAL; } @@ -260,7 +257,7 @@ static int htc_check_credits(struct htc_target *target, ep->cred_dist.seek_cred = ep->cred_dist.cred_per_msg - ep->cred_dist.credits; - ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &ep->cred_dist); ath6k_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); @@ -270,7 +267,7 @@ static int htc_check_credits(struct htc_target *target, /* tell the target we need credits ASAP! */ *flags |= HTC_FLAGS_NEED_CREDIT_UPDATE; ep->ep_st.cred_low_indicate += 1; - ath6kl_dbg(ATH6KL_DBG_HTC, "host needs credits\n"); + ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds host needs credits\n"); } } @@ -296,7 +293,7 @@ static void ath6kl_htc_tx_pkts_get(struct htc_target *target, list); ath6kl_dbg(ATH6KL_DBG_HTC, - "got head pkt:0x%p , queue depth: %d\n", + "htc tx got packet 0x%p queue depth %d\n", packet, get_queue_depth(&endpoint->txq)); len = CALC_TXRX_PADDED_LEN(target, @@ -405,7 +402,7 @@ static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, scat_req->len += len; scat_req->scat_entries++; ath6kl_dbg(ATH6KL_DBG_HTC, - "%d, adding pkt : 0x%p len:%d (remaining space:%d)\n", + "htc tx adding (%d) pkt 0x%p len %d remaining %d\n", i, packet, len, rem_scat); } @@ -456,11 +453,11 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, if (!scat_req) { /* no scatter resources */ ath6kl_dbg(ATH6KL_DBG_HTC, - "no more scatter resources\n"); + "htc tx no more scatter resources\n"); break; } - ath6kl_dbg(ATH6KL_DBG_HTC, "pkts to scatter: %d\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx pkts to scatter: %d\n", n_scat); scat_req->len = 0; @@ -480,7 +477,7 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, tot_pkts_bundle += scat_req->scat_entries; ath6kl_dbg(ATH6KL_DBG_HTC, - "send scatter total bytes: %d , entries: %d\n", + "htc tx scatter bytes %d entries %d\n", scat_req->len, scat_req->scat_entries); ath6kl_hif_submit_scat_req(target->dev, scat_req, false); @@ -490,8 +487,8 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, *sent_bundle = n_sent_bundle; *n_bundle_pkts = tot_pkts_bundle; - ath6kl_dbg(ATH6KL_DBG_HTC, "%s (sent:%d)\n", - __func__, n_sent_bundle); + ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx bundle sent %d pkts\n", + n_sent_bundle); return; } @@ -510,7 +507,7 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, if (endpoint->tx_proc_cnt > 1) { endpoint->tx_proc_cnt--; spin_unlock_bh(&target->tx_lock); - ath6kl_dbg(ATH6KL_DBG_HTC, "htc_try_send (busy)\n"); + ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx busy\n"); return; } @@ -589,14 +586,11 @@ static bool ath6kl_htc_tx_try(struct htc_target *target, if (overflow) ath6kl_dbg(ATH6KL_DBG_HTC, - "ep %d, tx queue will overflow :%d , tx depth:%d, max:%d\n", - endpoint->eid, overflow, txq_depth, + "htc tx overflow ep %d depth %d max %d\n", + endpoint->eid, txq_depth, endpoint->max_txq_depth); if (overflow && ep_cb.tx_full) { - ath6kl_dbg(ATH6KL_DBG_HTC, - "indicating overflowed tx packet: 0x%p\n", tx_pkt); - if (ep_cb.tx_full(endpoint->target, tx_pkt) == HTC_SEND_FULL_DROP) { endpoint->ep_st.tx_dropped += 1; @@ -630,7 +624,7 @@ static void htc_chk_ep_txq(struct htc_target *target) spin_lock_bh(&target->tx_lock); if (!list_empty(&endpoint->txq)) { ath6kl_dbg(ATH6KL_DBG_HTC, - "ep %d has %d credits and %d packets in tx queue\n", + "htc creds ep %d credits %d pkts %d\n", cred_dist->endpoint, endpoint->cred_dist.credits, get_queue_depth(&endpoint->txq)); @@ -737,7 +731,7 @@ int ath6kl_htc_tx(struct htc_target *target, struct htc_packet *packet) struct list_head queue; ath6kl_dbg(ATH6KL_DBG_HTC, - "htc_tx: ep id: %d, buf: 0x%p, len: %d\n", + "htc tx ep id %d buf 0x%p len %d\n", packet->endpoint, packet->buf, packet->act_len); if (packet->endpoint >= ENDPOINT_MAX) { @@ -788,7 +782,7 @@ void ath6kl_htc_flush_txep(struct htc_target *target, packet->status = -ECANCELED; list_del(&packet->list); ath6kl_dbg(ATH6KL_DBG_HTC, - "flushing tx pkt:0x%p, len:%d, ep:%d tag:0x%X\n", + "htc tx flushing pkt 0x%p len %d ep %d tag 0x%x\n", packet, packet->act_len, packet->endpoint, packet->info.tx.tag); @@ -844,7 +838,8 @@ void ath6kl_htc_indicate_activity_change(struct htc_target *target, endpoint->cred_dist.txq_depth = get_queue_depth(&endpoint->txq); - ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, + "htc tx activity ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); ath6k_credit_distribute(target->cred_dist_cntxt, @@ -919,15 +914,15 @@ static int ath6kl_htc_rx_packet(struct htc_target *target, padded_len = CALC_TXRX_PADDED_LEN(target, rx_len); if (padded_len > packet->buf_len) { - ath6kl_err("not enough receive space for packet - padlen:%d recvlen:%d bufferlen:%d\n", + ath6kl_err("not enough receive space for packet - padlen %d recvlen %d bufferlen %d\n", padded_len, rx_len, packet->buf_len); return -ENOMEM; } ath6kl_dbg(ATH6KL_DBG_HTC, - "dev_rx_pkt (0x%p : hdr:0x%X) padded len: %d mbox:0x%X (mode:%s)\n", + "htc rx 0x%p hdr x%x len %d mbox 0x%x\n", packet, packet->info.rx.exp_hdr, - padded_len, dev->ar->mbox_info.htc_addr, "sync"); + padded_len, dev->ar->mbox_info.htc_addr); status = hif_read_write_sync(dev->ar, dev->ar->mbox_info.htc_addr, @@ -1138,7 +1133,7 @@ static int ath6kl_htc_rx_alloc(struct htc_target *target, endpoint->ep_st.rx_bundle_from_hdr += 1; ath6kl_dbg(ATH6KL_DBG_HTC, - "htc hdr indicates :%d msg can be fetched as a bundle\n", + "htc rx bundle pkts %d\n", n_msg); } else /* HTC header only indicates 1 message to fetch */ @@ -1191,8 +1186,8 @@ static void htc_ctrl_rx(struct htc_target *context, struct htc_packet *packets) ath6kl_err("htc_ctrl_rx, got message with len:%zu\n", packets->act_len + HTC_HDR_LENGTH); - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, - "Unexpected ENDPOINT 0 Message", "", + ath6kl_dbg_dump(ATH6KL_DBG_HTC, + "htc rx unexpected endpoint 0 message", "", packets->buf - HTC_HDR_LENGTH, packets->act_len + HTC_HDR_LENGTH); } @@ -1210,7 +1205,7 @@ static void htc_proc_cred_rpt(struct htc_target *target, bool dist = false; ath6kl_dbg(ATH6KL_DBG_HTC, - "htc_proc_cred_rpt, credit report entries:%d\n", n_entries); + "htc creds report entries %d\n", n_entries); spin_lock_bh(&target->tx_lock); @@ -1223,8 +1218,9 @@ static void htc_proc_cred_rpt(struct htc_target *target, endpoint = &target->endpoint[rpt->eid]; - ath6kl_dbg(ATH6KL_DBG_HTC, " ep %d got %d credits\n", - rpt->eid, rpt->credits); + ath6kl_dbg(ATH6KL_DBG_HTC, + "htc creds report ep %d credits %d\n", + rpt->eid, rpt->credits); endpoint->ep_st.tx_cred_rpt += 1; endpoint->ep_st.cred_retnd += rpt->credits; @@ -1265,7 +1261,7 @@ static void htc_proc_cred_rpt(struct htc_target *target, } ath6kl_dbg(ATH6KL_DBG_HTC, - "report indicated %d credits to distribute\n", + "htc creds report tot_credits %d\n", tot_credits); if (dist) { @@ -1273,7 +1269,7 @@ static void htc_proc_cred_rpt(struct htc_target *target, * This was a credit return based on a completed send * operations note, this is done with the lock held */ - ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:0x%p dist:0x%p\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); ath6k_credit_distribute(target->cred_dist_cntxt, @@ -1321,13 +1317,14 @@ static int htc_parse_trailer(struct htc_target *target, && next_lk_ahds) { ath6kl_dbg(ATH6KL_DBG_HTC, - "lk_ahd report found (pre valid:0x%X, post valid:0x%X)\n", + "htc rx lk_ahd found pre_valid 0x%x post_valid 0x%x\n", lk_ahd->pre_valid, lk_ahd->post_valid); /* look ahead bytes are valid, copy them over */ memcpy((u8 *)&next_lk_ahds[0], lk_ahd->lk_ahd, 4); - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Next Look Ahead", + ath6kl_dbg_dump(ATH6KL_DBG_HTC, + "htc rx next look ahead", "", next_lk_ahds, 4); *n_lk_ahds = 1; @@ -1346,7 +1343,7 @@ static int htc_parse_trailer(struct htc_target *target, bundle_lkahd_rpt = (struct htc_bundle_lkahd_rpt *) record_buf; - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Bundle lk_ahd", + ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx bundle lk_ahd", "", record_buf, record->len); for (i = 0; i < len; i++) { @@ -1378,10 +1375,8 @@ static int htc_proc_trailer(struct htc_target *target, u8 *record_buf; u8 *orig_buf; - ath6kl_dbg(ATH6KL_DBG_HTC, "+htc_proc_trailer (len:%d)\n", len); - - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Recv Trailer", "", - buf, len); + ath6kl_dbg(ATH6KL_DBG_HTC, "htc rx trailer len %d\n", len); + ath6kl_dbg_dump(ATH6KL_DBG_HTC, NULL, "", buf, len); orig_buf = buf; orig_len = len; @@ -1418,7 +1413,7 @@ static int htc_proc_trailer(struct htc_target *target, } if (status) - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "BAD Recv Trailer", + ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx bad trailer", "", orig_buf, orig_len); return status; @@ -1436,7 +1431,8 @@ static int ath6kl_htc_rx_process_hdr(struct htc_target *target, if (n_lkahds != NULL) *n_lkahds = 0; - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "HTC Recv PKT", "htc ", + /* FIXME: is this needed? */ + ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx", "htc rx", packet->buf, packet->act_len); /* @@ -1480,9 +1476,9 @@ static int ath6kl_htc_rx_process_hdr(struct htc_target *target, if (lk_ahd != packet->info.rx.exp_hdr) { ath6kl_err("%s(): lk_ahd mismatch! (pPkt:0x%p flags:0x%X)\n", __func__, packet, packet->info.rx.rx_flags); - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Expected Message lk_ahd", + ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx expected lk_ahd", "", &packet->info.rx.exp_hdr, 4); - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Current Frame Header", + ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx current header", "", (u8 *)&lk_ahd, sizeof(lk_ahd)); status = -ENOMEM; goto fail_rx; @@ -1518,13 +1514,13 @@ static int ath6kl_htc_rx_process_hdr(struct htc_target *target, fail_rx: if (status) - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "BAD HTC Recv PKT", - "", packet->buf, - packet->act_len < 256 ? packet->act_len : 256); + ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx bad packet", + "", packet->buf, packet->act_len); else { + /* FIXME: is this needed? */ if (packet->act_len > 0) - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, - "HTC - Application Msg", "", + ath6kl_dbg_dump(ATH6KL_DBG_HTC, + "htc rx application message", "", packet->buf, packet->act_len); } @@ -1535,7 +1531,7 @@ static void ath6kl_htc_rx_complete(struct htc_endpoint *endpoint, struct htc_packet *packet) { ath6kl_dbg(ATH6KL_DBG_HTC, - "htc calling ep %d recv callback on packet 0x%p\n", + "htc rx complete ep %d packet 0x%p\n", endpoint->eid, packet); endpoint->ep_cb.rx(endpoint->target, packet); } @@ -1572,8 +1568,8 @@ static int ath6kl_htc_rx_bundle(struct htc_target *target, len = 0; ath6kl_dbg(ATH6KL_DBG_HTC, - "%s(): (numpackets: %d , actual : %d)\n", - __func__, get_queue_depth(rxq), n_scat_pkt); + "htc rx bundle depth %d pkts %d\n", + get_queue_depth(rxq), n_scat_pkt); scat_req = hif_scatter_req_get(target->dev->ar); @@ -1898,7 +1894,7 @@ static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target) return NULL; ath6kl_dbg(ATH6KL_DBG_HTC, - "htc_wait_for_ctrl_msg: look_ahead : 0x%X\n", look_ahead); + "htc rx wait ctrl look_ahead 0x%X\n", look_ahead); htc_hdr = (struct htc_frame_hdr *)&look_ahead; @@ -1963,7 +1959,7 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, depth = get_queue_depth(pkt_queue); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc_add_rxbuf_multiple: ep id: %d, cnt:%d, len: %d\n", + "htc rx add multiple ep id %d cnt %d len %d\n", first_pkt->endpoint, depth, first_pkt->buf_len); endpoint = &target->endpoint[first_pkt->endpoint]; @@ -1989,7 +1985,7 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { if (target->ep_waiting == first_pkt->endpoint) { ath6kl_dbg(ATH6KL_DBG_HTC, - "receiver was blocked on ep:%d, unblocking.\n", + "htc rx blocked on ep %d, unblocking\n", target->ep_waiting); target->rx_st_flags &= ~HTC_RECV_WAIT_BUFFERS; target->ep_waiting = ENDPOINT_MAX; @@ -2024,7 +2020,7 @@ void ath6kl_htc_flush_rx_buf(struct htc_target *target) list_del(&packet->list); spin_unlock_bh(&target->rx_lock); ath6kl_dbg(ATH6KL_DBG_HTC, - "flushing rx pkt:0x%p, len:%d, ep:%d\n", + "htc rx flush pkt 0x%p len %d ep %d\n", packet, packet->buf_len, packet->endpoint); dev_kfree_skb(packet->pkt_cntxt); @@ -2048,7 +2044,7 @@ int ath6kl_htc_conn_service(struct htc_target *target, int status = 0; ath6kl_dbg(ATH6KL_DBG_HTC, - "htc_conn_service, target:0x%p service id:0x%X\n", + "htc connect service target 0x%p service id 0x%x\n", target, conn_req->svc_id); if (conn_req->svc_id == HTC_CTRL_RSVD_SVC) { @@ -2221,7 +2217,7 @@ static void htc_setup_msg_bndl(struct htc_target *target) target->msg_per_bndl_max); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc bundling allowed. max msg per htc bundle: %d\n", + "htc bundling allowed msg_per_bndl_max %d\n", target->msg_per_bndl_max); /* Max rx bundle size is limited by the max tx bundle size */ @@ -2230,7 +2226,7 @@ static void htc_setup_msg_bndl(struct htc_target *target) target->max_tx_bndl_sz = min(HIF_MBOX0_EXT_WIDTH, target->max_xfer_szper_scatreq); - ath6kl_dbg(ATH6KL_DBG_HTC, "max recv: %d max send: %d\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc max_rx_bndl_sz %d max_tx_bndl_sz %d\n", target->max_rx_bndl_sz, target->max_tx_bndl_sz); if (target->max_tx_bndl_sz) @@ -2285,7 +2281,7 @@ int ath6kl_htc_wait_target(struct htc_target *target) target->tgt_cred_sz = le16_to_cpu(rdy_msg->ver2_0_info.cred_sz); ath6kl_dbg(ATH6KL_DBG_HTC, - "target ready: credits: %d credit size: %d\n", + "htc target ready credits %d size %d\n", target->tgt_creds, target->tgt_cred_sz); /* check if this is an extended ready message */ @@ -2299,7 +2295,7 @@ int ath6kl_htc_wait_target(struct htc_target *target) target->msg_per_bndl_max = 0; } - ath6kl_dbg(ATH6KL_DBG_HTC, "using htc protocol version : %s (%d)\n", + ath6kl_dbg(ATH6KL_DBG_HTC, "htc using protocol %s (%d)\n", (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", target->htc_tgt_ver); -- cgit v0.10.2 From b1e03f8acf51aa5e911a25ded72141148ef2d41a Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 13 Oct 2011 15:21:45 +0300 Subject: ath6kl: don't dump full htc packets It's currently possible to dump full sdio packets, so dumping htc packets is not strictly needed. So remove it, we can always add it back if there ever comes a need for that. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 840f1b3..3cd3ef5 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -1431,10 +1431,6 @@ static int ath6kl_htc_rx_process_hdr(struct htc_target *target, if (n_lkahds != NULL) *n_lkahds = 0; - /* FIXME: is this needed? */ - ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx", "htc rx", - packet->buf, packet->act_len); - /* * NOTE: we cannot assume the alignment of buf, so we use the safe * macros to retrieve 16 bit fields. @@ -1516,13 +1512,6 @@ fail_rx: if (status) ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx bad packet", "", packet->buf, packet->act_len); - else { - /* FIXME: is this needed? */ - if (packet->act_len > 0) - ath6kl_dbg_dump(ATH6KL_DBG_HTC, - "htc rx application message", "", - packet->buf, packet->act_len); - } return status; } -- cgit v0.10.2 From 83973e0357e2b3792480aa02b672902b2aa774b0 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 13 Oct 2011 15:21:53 +0300 Subject: ath6kl: add debug level for hif That way we htc level debug messages can be removed from hif files. Also add few new messages and remove useless debug message about using synchrous irq processing (we don't support anything else). Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 01f4015..cbabc25 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -26,7 +26,7 @@ enum ATH6K_DEBUG_MASK { ATH6KL_DBG_WLAN_RX = BIT(3), /* wlan rx */ ATH6KL_DBG_BMI = BIT(4), /* bmi tracing */ ATH6KL_DBG_HTC = BIT(5), - /* hole */ + ATH6KL_DBG_HIF = BIT(6), ATH6KL_DBG_IRQ = BIT(7), /* interrupt processing */ ATH6KL_DBG_PM = BIT(8), /* power management */ ATH6KL_DBG_WLAN_NODE = BIT(9), /* general wlan node tracing */ diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index 21b1575..95e7303 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -18,10 +18,16 @@ #define HIF_OPS_H #include "hif.h" +#include "debug.h" static inline int hif_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf, u32 len, u32 request) { + ath6kl_dbg(ATH6KL_DBG_HIF, + "hif %s sync addr 0x%x buf 0x%p len %d request 0x%x\n", + (request & HIF_WRITE) ? "write" : "read", + addr, buf, len, request); + return ar->hif_ops->read_write_sync(ar, addr, buf, len, request); } @@ -29,16 +35,24 @@ static inline int hif_write_async(struct ath6kl *ar, u32 address, u8 *buffer, u32 length, u32 request, struct htc_packet *packet) { + ath6kl_dbg(ATH6KL_DBG_HIF, + "hif write async addr 0x%x buf 0x%p len %d request 0x%x\n", + address, buffer, length, request); + return ar->hif_ops->write_async(ar, address, buffer, length, request, packet); } static inline void ath6kl_hif_irq_enable(struct ath6kl *ar) { + ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq enable\n"); + return ar->hif_ops->irq_enable(ar); } static inline void ath6kl_hif_irq_disable(struct ath6kl *ar) { + ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq disable\n"); + return ar->hif_ops->irq_disable(ar); } @@ -71,11 +85,15 @@ static inline void ath6kl_hif_cleanup_scatter(struct ath6kl *ar) static inline int ath6kl_hif_suspend(struct ath6kl *ar) { + ath6kl_dbg(ATH6KL_DBG_HIF, "hif suspend\n"); + return ar->hif_ops->suspend(ar); } static inline int ath6kl_hif_resume(struct ath6kl *ar) { + ath6kl_dbg(ATH6KL_DBG_HIF, "hif resume\n"); + return ar->hif_ops->resume(ar); } #endif diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index 7cc6cec..e2d8088 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -51,8 +51,7 @@ int ath6kl_hif_rw_comp_handler(void *context, int status) { struct htc_packet *packet = context; - ath6kl_dbg(ATH6KL_DBG_HTC, - "ath6kl_hif_rw_comp_handler (pkt:0x%p , status: %d\n", + ath6kl_dbg(ATH6KL_DBG_HIF, "hif rw completion pkt 0x%p status %d\n", packet, status); packet->status = status; @@ -119,7 +118,7 @@ int ath6kl_hif_poll_mboxmsg_rx(struct ath6kl_device *dev, u32 *lk_ahd, /* delay a little */ mdelay(ATH6KL_TIME_QUANTUM); - ath6kl_dbg(ATH6KL_DBG_HTC, "retry mbox poll : %d\n", i); + ath6kl_dbg(ATH6KL_DBG_HIF, "hif retry mbox poll try %d\n", i); } if (i == 0) { @@ -147,6 +146,9 @@ int ath6kl_hif_rx_control(struct ath6kl_device *dev, bool enable_rx) struct ath6kl_irq_enable_reg regs; int status = 0; + ath6kl_dbg(ATH6KL_DBG_HIF, "hif rx %s\n", + enable_rx ? "enable" : "disable"); + /* take the lock to protect interrupt enable shadows */ spin_lock_bh(&dev->lock); @@ -186,8 +188,8 @@ int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev, dev->ar->mbox_info.htc_addr; } - ath6kl_dbg(ATH6KL_DBG_HTC, - "ath6kl_hif_submit_scat_req, entries: %d, total len: %d mbox:0x%X (mode: %s : %s)\n", + ath6kl_dbg(ATH6KL_DBG_HIF, + "hif submit scatter request entries %d len %d mbox 0x%x %s %s\n", scat_req->scat_entries, scat_req->len, scat_req->addr, !read ? "async" : "sync", (read) ? "rd" : "wr"); @@ -629,12 +631,9 @@ int ath6kl_hif_setup(struct ath6kl_device *dev) /* assemble mask, used for padding to a block */ dev->htc_cnxt->block_mask = dev->htc_cnxt->block_sz - 1; - ath6kl_dbg(ATH6KL_DBG_TRC, "block size: %d, mbox addr:0x%X\n", + ath6kl_dbg(ATH6KL_DBG_HIF, "hif block size %d mbox addr 0x%x\n", dev->htc_cnxt->block_sz, dev->ar->mbox_info.htc_addr); - ath6kl_dbg(ATH6KL_DBG_TRC, - "hif interrupt processing is sync only\n"); - status = ath6kl_hif_disable_intrs(dev); fail_setup: -- cgit v0.10.2 From 116b3a2e0fb79fbc2367f69167a7a84a4c864a2d Mon Sep 17 00:00:00 2001 From: Rishi Panjwani Date: Tue, 18 Oct 2011 17:20:06 -0700 Subject: ath6kl: Implement support for background scan control from userspace In order to allow user space based control of background scan interval, we use available debugfs infrastructure. The feature has been added for testing purposes. The user has to write the bgscan interval (in secs) to the bgscan_interval file in ath6kl debug directory. To disable bgscan, a '0' is to be written to the bgscan_interval file. Example: echo "2" > bgscan_interval This will make the background scan interval as 2 seconds kvalo: changed implementation so that there's only one call to ath6kl_wmi_scanparams_cmd() Signed-off-by: Rishi Panjwani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index e109f29..bafc810 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1455,6 +1455,39 @@ static const struct file_operations fops_delete_qos = { .llseek = default_llseek, }; +static ssize_t ath6kl_bgscan_int_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + u16 bgscan_int; + char buf[32]; + ssize_t len; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + + buf[len] = '\0'; + if (kstrtou16(buf, 0, &bgscan_int)) + return -EINVAL; + + if (bgscan_int == 0) + bgscan_int = 0xffff; + + ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, bgscan_int, 0, 0, 0, 3, + 0, 0, 0); + + return count; +} + +static const struct file_operations fops_bgscan_int = { + .write = ath6kl_bgscan_int_write, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + int ath6kl_debug_init(struct ath6kl *ar) { ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); @@ -1534,6 +1567,9 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar, &fops_delete_qos); + debugfs_create_file("bgscan_interval", S_IWUSR, + ar->debugfs_phy, ar, &fops_bgscan_int); + return 0; } -- cgit v0.10.2 From 521dffcc8ae90ad08e9d9f12d9f9acc9db562194 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:33:56 +0530 Subject: ath6kl: Pass ath6kl structure to ath6kl_init() instead of net_device ar is again taken from private area of net_device in ath6kl_init(), pass ar directly. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 51ac626..2534e88 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1461,9 +1461,8 @@ static int ath6kl_init_hw_params(struct ath6kl *ar) return 0; } -static int ath6kl_init(struct net_device *dev) +static int ath6kl_init(struct ath6kl *ar) { - struct ath6kl *ar = ath6kl_priv(dev); int status = 0; s32 timeleft; @@ -1632,7 +1631,7 @@ int ath6kl_core_init(struct ath6kl *ar) if (ret) goto err_htc_cleanup; - ret = ath6kl_init(ar->net_dev); + ret = ath6kl_init(ar); if (ret) goto err_htc_cleanup; -- cgit v0.10.2 From be98e3a48cb9b9e63da8537a378f656af2a9f2c6 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:33:57 +0530 Subject: ath6kl: Keep wiphy reference in ath6kl structure This is to avoid using ar->wdev to get wiphy pointer, this may need further cleanup for multi vif support. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 16258c2..4fee927 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -481,7 +481,7 @@ static int ath6kl_add_bss_if_needed(struct ath6kl *ar, const u8 *bssid, struct cfg80211_bss *bss; u8 *ie; - bss = cfg80211_get_bss(ar->wdev->wiphy, chan, bssid, + bss = cfg80211_get_bss(ar->wiphy, chan, bssid, ar->ssid, ar->ssid_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); if (bss == NULL) { @@ -500,7 +500,7 @@ static int ath6kl_add_bss_if_needed(struct ath6kl *ar, const u8 *bssid, ie[1] = ar->ssid_len; memcpy(ie + 2, ar->ssid, ar->ssid_len); memcpy(ie + 2 + ar->ssid_len, beacon_ie, beacon_ie_len); - bss = cfg80211_inform_bss(ar->wdev->wiphy, chan, + bss = cfg80211_inform_bss(ar->wiphy, chan, bssid, 0, WLAN_CAPABILITY_ESS, 100, ie, 2 + ar->ssid_len + beacon_ie_len, 0, GFP_KERNEL); @@ -567,7 +567,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, } } - chan = ieee80211_get_channel(ar->wdev->wiphy, (int) channel); + chan = ieee80211_get_channel(ar->wiphy, (int) channel); if (nw_type & ADHOC_NETWORK) { @@ -1924,6 +1924,7 @@ struct wireless_dev *ath6kl_cfg80211_init(struct device *dev) int ret = 0; struct wireless_dev *wdev; struct ath6kl *ar; + struct wiphy *wiphy; wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); if (!wdev) { @@ -1932,43 +1933,45 @@ struct wireless_dev *ath6kl_cfg80211_init(struct device *dev) } /* create a new wiphy for use with cfg80211 */ - wdev->wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl)); - if (!wdev->wiphy) { + wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl)); + if (!wiphy) { ath6kl_err("couldn't allocate wiphy device\n"); kfree(wdev); return NULL; } - ar = wiphy_priv(wdev->wiphy); + ar = wiphy_priv(wiphy); ar->p2p = !!ath6kl_p2p; + ar->wiphy = wiphy; + wdev->wiphy = wiphy; - wdev->wiphy->mgmt_stypes = ath6kl_mgmt_stypes; + wiphy->mgmt_stypes = ath6kl_mgmt_stypes; - wdev->wiphy->max_remain_on_channel_duration = 5000; + wiphy->max_remain_on_channel_duration = 5000; /* set device pointer for wiphy */ - set_wiphy_dev(wdev->wiphy, dev); + set_wiphy_dev(wiphy, dev); - wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP); if (ar->p2p) { - wdev->wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_GO) | + wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_GO) | BIT(NL80211_IFTYPE_P2P_CLIENT); } /* max num of ssids that can be probed during scanning */ - wdev->wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX; - wdev->wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */ - wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &ath6kl_band_2ghz; - wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &ath6kl_band_5ghz; - wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; + wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX; + wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */ + wiphy->bands[IEEE80211_BAND_2GHZ] = &ath6kl_band_2ghz; + wiphy->bands[IEEE80211_BAND_5GHZ] = &ath6kl_band_5ghz; + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - wdev->wiphy->cipher_suites = cipher_suites; - wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); + wiphy->cipher_suites = cipher_suites; + wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); - ret = wiphy_register(wdev->wiphy); + ret = wiphy_register(wiphy); if (ret < 0) { ath6kl_err("couldn't register wiphy device\n"); - wiphy_free(wdev->wiphy); + wiphy_free(wiphy); kfree(wdev); return NULL; } @@ -1985,10 +1988,7 @@ void ath6kl_cfg80211_deinit(struct ath6kl *ar) ar->scan_req = NULL; } - if (!wdev) - return; - - wiphy_unregister(wdev->wiphy); - wiphy_free(wdev->wiphy); + wiphy_unregister(ar->wiphy); + wiphy_free(ar->wiphy); kfree(wdev); } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 31e5c7e..fb5a322 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -402,6 +402,7 @@ struct ath6kl_req_key { struct ath6kl { struct device *dev; struct net_device *net_dev; + struct wiphy *wiphy; struct ath6kl_bmi bmi; const struct ath6kl_hif_ops *hif_ops; struct wmi *wmi; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index bafc810..f067c7b 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1509,7 +1509,7 @@ int ath6kl_debug_init(struct ath6kl *ar) ar->debug.fwlog_mask = 0; ar->debugfs_phy = debugfs_create_dir("ath6kl", - ar->wdev->wiphy->debugfsdir); + ar->wiphy->debugfsdir); if (!ar->debugfs_phy) { vfree(ar->debug.fwlog_buf.buf); kfree(ar->debug.fwlog_tmp); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 2534e88..1f1ed28 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -584,7 +584,7 @@ struct ath6kl *ath6kl_core_alloc(struct device *sdev) } dev->ieee80211_ptr = wdev; - SET_NETDEV_DEV(dev, wiphy_dev(wdev->wiphy)); + SET_NETDEV_DEV(dev, wiphy_dev(ar->wiphy)); wdev->netdev = dev; ar->sme_state = SME_DISCONNECTED; @@ -1557,8 +1557,8 @@ static int ath6kl_init(struct ath6kl *ar) ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; - ar->wdev->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | - WIPHY_FLAG_HAVE_AP_SME; + ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | + WIPHY_FLAG_HAVE_AP_SME; status = ath6kl_target_config_wlan_params(ar); if (!status) @@ -1599,7 +1599,7 @@ int ath6kl_core_init(struct ath6kl *ar) ar->version.target_ver = le32_to_cpu(targ_info.version); ar->target_type = le32_to_cpu(targ_info.type); - ar->wdev->wiphy->hw_version = le32_to_cpu(targ_info.version); + ar->wiphy->hw_version = le32_to_cpu(targ_info.version); ret = ath6kl_init_hw_params(ar); if (ret) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index e693756..4470f6ed 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -996,8 +996,8 @@ void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) ar->version.wlan_ver = sw_ver; ar->version.abi_ver = abi_ver; - snprintf(ar->wdev->wiphy->fw_version, - sizeof(ar->wdev->wiphy->fw_version), + snprintf(ar->wiphy->fw_version, + sizeof(ar->wiphy->fw_version), "%u.%u.%u.%u", (ar->version.wlan_ver & 0xf0000000) >> 28, (ar->version.wlan_ver & 0x0f000000) >> 24, @@ -1009,8 +1009,8 @@ void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) wake_up(&ar->event_wq); ath6kl_info("hw %s fw %s%s\n", - get_hw_id_string(ar->wdev->wiphy->hw_version), - ar->wdev->wiphy->fw_version, + get_hw_id_string(ar->wiphy->hw_version), + ar->wiphy->fw_version, test_bit(TESTMODE, &ar->flag) ? " testmode" : ""); } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 7b6bfdd..7f4c2c2a 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -431,7 +431,7 @@ static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, dur = le32_to_cpu(ev->duration); ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", freq, dur); - chan = ieee80211_get_channel(ar->wdev->wiphy, freq); + chan = ieee80211_get_channel(ar->wiphy, freq); if (!chan) { ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " "(freq=%u)\n", freq); @@ -460,7 +460,7 @@ static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, dur = le32_to_cpu(ev->duration); ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " "status=%u\n", freq, dur, ev->status); - chan = ieee80211_get_channel(ar->wdev->wiphy, freq); + chan = ieee80211_get_channel(ar->wiphy, freq); if (!chan) { ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " "channel (freq=%u)\n", freq); @@ -878,7 +878,7 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) alpha2[0] = country->isoName[0]; alpha2[1] = country->isoName[1]; - regulatory_hint(wmi->parent_dev->wdev->wiphy, alpha2); + regulatory_hint(wmi->parent_dev->wiphy, alpha2); ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n", alpha2[0], alpha2[1]); @@ -974,7 +974,7 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); } - channel = ieee80211_get_channel(ar->wdev->wiphy, le16_to_cpu(bih->ch)); + channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch)); if (channel == NULL) return -EINVAL; @@ -1021,7 +1021,7 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) memcpy(&mgmt->u.beacon, buf, len); - bss = cfg80211_inform_bss_frame(ar->wdev->wiphy, channel, mgmt, + bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt, 24 + len, (bih->snr - 95) * 100, GFP_ATOMIC); kfree(mgmt); -- cgit v0.10.2 From 8dafb70edc7151bdb319b6d22895d9886c7172eb Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:33:58 +0530 Subject: ath6kl: Refactor wiphy dev and net dev init functions This refactoring is done in a manner that it can be used for multiple virtual interface. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 4fee927..c827ced 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1919,45 +1919,83 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = { .mgmt_frame_register = ath6kl_mgmt_frame_register, }; -struct wireless_dev *ath6kl_cfg80211_init(struct device *dev) +struct ath6kl *ath6kl_core_alloc(struct device *dev) { - int ret = 0; - struct wireless_dev *wdev; struct ath6kl *ar; struct wiphy *wiphy; - - wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); - if (!wdev) { - ath6kl_err("couldn't allocate wireless device\n"); - return NULL; - } + u8 ctr; /* create a new wiphy for use with cfg80211 */ wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl)); + if (!wiphy) { ath6kl_err("couldn't allocate wiphy device\n"); - kfree(wdev); return NULL; } ar = wiphy_priv(wiphy); ar->p2p = !!ath6kl_p2p; ar->wiphy = wiphy; - wdev->wiphy = wiphy; + ar->dev = dev; + + spin_lock_init(&ar->lock); + spin_lock_init(&ar->mcastpsq_lock); + + init_waitqueue_head(&ar->event_wq); + sema_init(&ar->sem, 1); + + INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue); + + clear_bit(WMI_ENABLED, &ar->flag); + clear_bit(SKIP_SCAN, &ar->flag); + clear_bit(DESTROY_IN_PROGRESS, &ar->flag); + + ar->listen_intvl_t = A_DEFAULT_LISTEN_INTERVAL; + ar->listen_intvl_b = 0; + ar->tx_pwr = 0; + + ar->intra_bss = 1; + memset(&ar->sc_params, 0, sizeof(ar->sc_params)); + ar->sc_params.short_scan_ratio = WMI_SHORTSCANRATIO_DEFAULT; + ar->sc_params.scan_ctrl_flags = DEFAULT_SCAN_CTRL_FLAGS; + ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD; + + memset((u8 *)ar->sta_list, 0, + AP_MAX_NUM_STA * sizeof(struct ath6kl_sta)); + + /* Init the PS queues */ + for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) { + spin_lock_init(&ar->sta_list[ctr].psq_lock); + skb_queue_head_init(&ar->sta_list[ctr].psq); + } + + skb_queue_head_init(&ar->mcastpsq); + + memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3); + + return ar; +} + +int ath6kl_register_ieee80211_hw(struct ath6kl *ar) +{ + struct wiphy *wiphy = ar->wiphy; + int ret; wiphy->mgmt_stypes = ath6kl_mgmt_stypes; wiphy->max_remain_on_channel_duration = 5000; /* set device pointer for wiphy */ - set_wiphy_dev(wiphy, dev); + set_wiphy_dev(wiphy, ar->dev); wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP); + BIT(NL80211_IFTYPE_ADHOC) | + BIT(NL80211_IFTYPE_AP); if (ar->p2p) { wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_GO) | - BIT(NL80211_IFTYPE_P2P_CLIENT); + BIT(NL80211_IFTYPE_P2P_CLIENT); } + /* max num of ssids that can be probed during scanning */ wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX; wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */ @@ -1971,18 +2009,85 @@ struct wireless_dev *ath6kl_cfg80211_init(struct device *dev) ret = wiphy_register(wiphy); if (ret < 0) { ath6kl_err("couldn't register wiphy device\n"); - wiphy_free(wiphy); - kfree(wdev); - return NULL; + return ret; } - return wdev; + return 0; } -void ath6kl_cfg80211_deinit(struct ath6kl *ar) +static int ath6kl_init_if_data(struct ath6kl *ar, struct net_device *ndev) { - struct wireless_dev *wdev = ar->wdev; + ar->aggr_cntxt = aggr_init(ndev); + if (!ar->aggr_cntxt) { + ath6kl_err("failed to initialize aggr\n"); + return -ENOMEM; + } + + setup_timer(&ar->disconnect_timer, disconnect_timer_handler, + (unsigned long) ndev); + return 0; +} + +void ath6kl_deinit_if_data(struct ath6kl *ar, struct net_device *ndev) +{ + aggr_module_destroy(ar->aggr_cntxt); + + ar->aggr_cntxt = NULL; + + if (test_bit(NETDEV_REGISTERED, &ar->flag)) { + unregister_netdev(ndev); + clear_bit(NETDEV_REGISTERED, &ar->flag); + } + + free_netdev(ndev); +} + +struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, + enum nl80211_iftype type) +{ + struct net_device *ndev; + struct wireless_dev *wdev; + + ndev = alloc_netdev(sizeof(*wdev), "wlan%d", ether_setup); + if (!ndev) + return NULL; + + wdev = netdev_priv(ndev); + ndev->ieee80211_ptr = wdev; + wdev->wiphy = ar->wiphy; + SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); + wdev->netdev = ndev; + wdev->iftype = type; + ar->wdev = wdev; + ar->net_dev = ndev; + + init_netdev(ndev); + + ath6kl_init_control_info(ar); + + /* TODO: Pass interface specific pointer instead of ar */ + if (ath6kl_init_if_data(ar, ndev)) + goto err; + + if (register_netdev(ndev)) + goto err; + + ar->sme_state = SME_DISCONNECTED; + set_bit(WLAN_ENABLED, &ar->flag); + ar->wlan_pwr_state = WLAN_POWER_STATE_ON; + set_bit(NETDEV_REGISTERED, &ar->flag); + + return ndev; + +err: + ath6kl_deinit_if_data(ar, ndev); + + return NULL; +} + +void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar) +{ if (ar->scan_req) { cfg80211_scan_done(ar->scan_req, true); ar->scan_req = NULL; @@ -1990,5 +2095,4 @@ void ath6kl_cfg80211_deinit(struct ath6kl *ar) wiphy_unregister(ar->wiphy); wiphy_free(ar->wiphy); - kfree(wdev); } diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index a84adc2..5daf685 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -17,8 +17,11 @@ #ifndef ATH6KL_CFG80211_H #define ATH6KL_CFG80211_H -struct wireless_dev *ath6kl_cfg80211_init(struct device *dev); -void ath6kl_cfg80211_deinit(struct ath6kl *ar); +struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, + enum nl80211_iftype type); +int ath6kl_register_ieee80211_hw(struct ath6kl *ar); +struct ath6kl *ath6kl_core_alloc(struct device *dev); +void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar); void ath6kl_cfg80211_scan_complete_event(struct ath6kl *ar, int status); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index fb5a322..f1b3c47 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -642,4 +642,7 @@ void aggr_recv_addba_req_evt(struct ath6kl *ar, u8 tid, u16 seq_no, void ath6kl_wakeup_event(void *dev); void ath6kl_target_failure(struct ath6kl *ar); +void ath6kl_init_control_info(struct ath6kl *ar); +void ath6kl_deinit_if_data(struct ath6kl *ar, struct net_device *ndev); +void ath6kl_core_free(struct ath6kl *ar); #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 1f1ed28..0b8d695 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -258,40 +258,12 @@ static int ath6kl_init_service_ep(struct ath6kl *ar) return 0; } -static void ath6kl_init_control_info(struct ath6kl *ar) +void ath6kl_init_control_info(struct ath6kl *ar) { - u8 ctr; - - clear_bit(WMI_ENABLED, &ar->flag); ath6kl_init_profile_info(ar); ar->def_txkey_index = 0; memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); ar->ch_hint = 0; - ar->listen_intvl_t = A_DEFAULT_LISTEN_INTERVAL; - ar->listen_intvl_b = 0; - ar->tx_pwr = 0; - clear_bit(SKIP_SCAN, &ar->flag); - set_bit(WMM_ENABLED, &ar->flag); - ar->intra_bss = 1; - memset(&ar->sc_params, 0, sizeof(ar->sc_params)); - ar->sc_params.short_scan_ratio = WMI_SHORTSCANRATIO_DEFAULT; - ar->sc_params.scan_ctrl_flags = DEFAULT_SCAN_CTRL_FLAGS; - ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD; - - memset((u8 *)ar->sta_list, 0, - AP_MAX_NUM_STA * sizeof(struct ath6kl_sta)); - - spin_lock_init(&ar->mcastpsq_lock); - - /* Init the PS queues */ - for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) { - spin_lock_init(&ar->sta_list[ctr].psq_lock); - skb_queue_head_init(&ar->sta_list[ctr].psq); - } - - skb_queue_head_init(&ar->mcastpsq); - - memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3); } /* @@ -553,61 +525,9 @@ int ath6kl_configure_target(struct ath6kl *ar) return 0; } -struct ath6kl *ath6kl_core_alloc(struct device *sdev) +void ath6kl_core_free(struct ath6kl *ar) { - struct net_device *dev; - struct ath6kl *ar; - struct wireless_dev *wdev; - - wdev = ath6kl_cfg80211_init(sdev); - if (!wdev) { - ath6kl_err("ath6kl_cfg80211_init failed\n"); - return NULL; - } - - ar = wdev_priv(wdev); - ar->dev = sdev; - ar->wdev = wdev; - wdev->iftype = NL80211_IFTYPE_STATION; - - if (ath6kl_debug_init(ar)) { - ath6kl_err("Failed to initialize debugfs\n"); - ath6kl_cfg80211_deinit(ar); - return NULL; - } - - dev = alloc_netdev(0, "wlan%d", ether_setup); - if (!dev) { - ath6kl_err("no memory for network device instance\n"); - ath6kl_cfg80211_deinit(ar); - return NULL; - } - - dev->ieee80211_ptr = wdev; - SET_NETDEV_DEV(dev, wiphy_dev(ar->wiphy)); - wdev->netdev = dev; - ar->sme_state = SME_DISCONNECTED; - - init_netdev(dev); - - ar->net_dev = dev; - set_bit(WLAN_ENABLED, &ar->flag); - - ar->wlan_pwr_state = WLAN_POWER_STATE_ON; - - spin_lock_init(&ar->lock); - - ath6kl_init_control_info(ar); - init_waitqueue_head(&ar->event_wq); - sema_init(&ar->sem, 1); - clear_bit(DESTROY_IN_PROGRESS, &ar->flag); - - INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue); - - setup_timer(&ar->disconnect_timer, disconnect_timer_handler, - (unsigned long) dev); - - return ar; + wiphy_free(ar->wiphy); } int ath6kl_unavail_ev(struct ath6kl *ar) @@ -1465,6 +1385,7 @@ static int ath6kl_init(struct ath6kl *ar) { int status = 0; s32 timeleft; + struct net_device *ndev; if (!ar) return -EIO; @@ -1486,6 +1407,29 @@ static int ath6kl_init(struct ath6kl *ar) ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi); + status = ath6kl_register_ieee80211_hw(ar); + if (status) + goto err_node_cleanup; + + status = ath6kl_debug_init(ar); + if (status) { + wiphy_unregister(ar->wiphy); + goto err_node_cleanup; + } + + /* Add an initial station interface */ + ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION); + if (!ndev) { + ath6kl_err("Failed to instantiate a network device\n"); + status = -ENOMEM; + wiphy_unregister(ar->wiphy); + goto err_debug_init; + } + + + ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", + __func__, ar->net_dev->name, ar->net_dev, ar); + /* * The reason we have to wait for the target here is that the * driver layer has to init BMI in order to set the host block @@ -1493,7 +1437,7 @@ static int ath6kl_init(struct ath6kl *ar) */ if (ath6kl_htc_wait_target(ar->htc_target)) { status = -EIO; - goto err_node_cleanup; + goto err_if_deinit; } if (ath6kl_init_service_ep(ar)) { @@ -1571,6 +1515,11 @@ err_rxbuf_cleanup: ath6kl_cleanup_amsdu_rxbufs(ar); err_cleanup_scatter: ath6kl_hif_cleanup_scatter(ar); +err_if_deinit: + ath6kl_deinit_if_data(ar, ndev); + wiphy_unregister(ar->wiphy); +err_debug_init: + ath6kl_debug_cleanup(ar); err_node_cleanup: ath6kl_wmi_shutdown(ar->wmi); clear_bit(WMI_ENABLED, &ar->flag); @@ -1616,13 +1565,6 @@ int ath6kl_core_init(struct ath6kl *ar) goto err_bmi_cleanup; } - ar->aggr_cntxt = aggr_init(ar->net_dev); - if (!ar->aggr_cntxt) { - ath6kl_err("failed to initialize aggr\n"); - ret = -ENOMEM; - goto err_htc_cleanup; - } - ret = ath6kl_fetch_firmwares(ar); if (ret) goto err_htc_cleanup; @@ -1635,19 +1577,6 @@ int ath6kl_core_init(struct ath6kl *ar) if (ret) goto err_htc_cleanup; - /* This runs the init function if registered */ - ret = register_netdev(ar->net_dev); - if (ret) { - ath6kl_err("register_netdev failed\n"); - ath6kl_destroy(ar->net_dev, 0); - return ret; - } - - set_bit(NETDEV_REGISTERED, &ar->flag); - - ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", - __func__, ar->net_dev->name, ar->net_dev, ar); - return ret; err_htc_cleanup: @@ -1656,6 +1585,7 @@ err_bmi_cleanup: ath6kl_bmi_cleanup(ar); err_wq: destroy_workqueue(ar->ath6kl_wq); + return ret; } @@ -1711,8 +1641,6 @@ void ath6kl_destroy(struct net_device *dev, unsigned int unregister) if (ar->htc_target) ath6kl_htc_cleanup(ar->htc_target); - aggr_module_destroy(ar->aggr_cntxt); - ath6kl_cookie_cleanup(ar); ath6kl_cleanup_amsdu_rxbufs(ar); @@ -1721,17 +1649,12 @@ void ath6kl_destroy(struct net_device *dev, unsigned int unregister) ath6kl_debug_cleanup(ar); - if (unregister && test_bit(NETDEV_REGISTERED, &ar->flag)) { - unregister_netdev(dev); - clear_bit(NETDEV_REGISTERED, &ar->flag); - } - - free_netdev(dev); + ath6kl_deinit_if_data(ar, dev); kfree(ar->fw_board); kfree(ar->fw_otp); kfree(ar->fw); kfree(ar->fw_patch); - ath6kl_cfg80211_deinit(ar); + ath6kl_deinit_ieee80211_hw(ar); } diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 58e31f6..4e43878 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -837,7 +837,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ath6kl_err("Failed to enable 4-bit async irq mode %d\n", ret); sdio_release_host(func); - goto err_cfg80211; + goto err_core_alloc; } ath6kl_dbg(ATH6KL_DBG_SDIO, "4-bit async irq mode enabled\n"); @@ -850,7 +850,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ret = ath6kl_sdio_power_on(ar_sdio); if (ret) - goto err_cfg80211; + goto err_core_alloc; sdio_claim_host(func); @@ -874,8 +874,8 @@ static int ath6kl_sdio_probe(struct sdio_func *func, err_off: ath6kl_sdio_power_off(ar_sdio); -err_cfg80211: - ath6kl_cfg80211_deinit(ar_sdio->ar); +err_core_alloc: + ath6kl_core_free(ar_sdio->ar); err_dma: kfree(ar_sdio->dma_buffer); err_hif: -- cgit v0.10.2 From dd3751f7b1036c24e0d44167482bbf4d60935d24 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:33:59 +0530 Subject: ath6kl: Cleanup fw interface type setting It is not necessary to use ath6kl_get_fw_iftype() to find out the firmware interface type during initialization because the type of the initial interface in INFRA_NETWORK. Hardcode the fw interface type corresponding to INFRA_BSS instead of using ath6kl_get_fw_iftype(). Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 0b8d695..8adfc42 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -91,21 +91,6 @@ void ath6kl_init_profile_info(struct ath6kl *ar) ar->nw_type = ar->next_mode = INFRA_NETWORK; } -static u8 ath6kl_get_fw_iftype(struct ath6kl *ar) -{ - switch (ar->nw_type) { - case INFRA_NETWORK: - return HI_OPTION_FW_MODE_BSS_STA; - case ADHOC_NETWORK: - return HI_OPTION_FW_MODE_IBSS; - case AP_NETWORK: - return HI_OPTION_FW_MODE_AP; - default: - ath6kl_err("Unsupported interface type :%d\n", ar->nw_type); - return 0xff; - } -} - static int ath6kl_set_host_app_area(struct ath6kl *ar) { u32 address, data; @@ -446,9 +431,7 @@ int ath6kl_configure_target(struct ath6kl *ar) u32 param, ram_reserved_size; u8 fw_iftype; - fw_iftype = ath6kl_get_fw_iftype(ar); - if (fw_iftype == 0xff) - return -EINVAL; + fw_iftype = HI_OPTION_FW_MODE_BSS_STA; /* Tell target which HTC version it is used*/ param = HTC_PROTOCOL_VERSION; -- cgit v0.10.2 From 108438bc6ad16b3962aa5009123cd810d1c1f643 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:00 +0530 Subject: ath6kl: Define an initial vif structure and use it vif specific information need to be moved from struct ath6kl. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index c827ced..b6b3112 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2015,51 +2015,58 @@ int ath6kl_register_ieee80211_hw(struct ath6kl *ar) return 0; } -static int ath6kl_init_if_data(struct ath6kl *ar, struct net_device *ndev) +static int ath6kl_init_if_data(struct ath6kl_vif *vif) { - ar->aggr_cntxt = aggr_init(ndev); + struct ath6kl *ar = vif->ar; + + ar->aggr_cntxt = aggr_init(vif->ndev); if (!ar->aggr_cntxt) { ath6kl_err("failed to initialize aggr\n"); return -ENOMEM; } setup_timer(&ar->disconnect_timer, disconnect_timer_handler, - (unsigned long) ndev); + (unsigned long) vif->ndev); return 0; } -void ath6kl_deinit_if_data(struct ath6kl *ar, struct net_device *ndev) +void ath6kl_deinit_if_data(struct ath6kl_vif *vif) { + struct ath6kl *ar = vif->ar; + aggr_module_destroy(ar->aggr_cntxt); ar->aggr_cntxt = NULL; if (test_bit(NETDEV_REGISTERED, &ar->flag)) { - unregister_netdev(ndev); + unregister_netdev(vif->ndev); clear_bit(NETDEV_REGISTERED, &ar->flag); } - free_netdev(ndev); + free_netdev(vif->ndev); } struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, enum nl80211_iftype type) { struct net_device *ndev; - struct wireless_dev *wdev; + struct ath6kl_vif *vif; - ndev = alloc_netdev(sizeof(*wdev), "wlan%d", ether_setup); + ndev = alloc_netdev(sizeof(*vif), "wlan%d", ether_setup); if (!ndev) return NULL; - wdev = netdev_priv(ndev); - ndev->ieee80211_ptr = wdev; - wdev->wiphy = ar->wiphy; - SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); - wdev->netdev = ndev; - wdev->iftype = type; - ar->wdev = wdev; + vif = netdev_priv(ndev); + ndev->ieee80211_ptr = &vif->wdev; + vif->wdev.wiphy = ar->wiphy; + vif->ar = ar; + ar->vif = vif; + vif->ndev = ndev; + SET_NETDEV_DEV(ndev, wiphy_dev(vif->wdev.wiphy)); + vif->wdev.netdev = ndev; + vif->wdev.iftype = type; + ar->wdev = &vif->wdev; ar->net_dev = ndev; init_netdev(ndev); @@ -2067,7 +2074,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, ath6kl_init_control_info(ar); /* TODO: Pass interface specific pointer instead of ar */ - if (ath6kl_init_if_data(ar, ndev)) + if (ath6kl_init_if_data(vif)) goto err; if (register_netdev(ndev)) @@ -2081,7 +2088,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, return ndev; err: - ath6kl_deinit_if_data(ar, ndev); + ath6kl_deinit_if_data(vif); return NULL; } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f1b3c47..0c1dee0 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -380,6 +380,12 @@ struct ath6kl_req_key { u8 key_len; }; +struct ath6kl_vif { + struct wireless_dev wdev; + struct net_device *ndev; + struct ath6kl *ar; +}; + /* Flag info */ #define WMI_ENABLED 0 #define WMI_READY 1 @@ -410,6 +416,7 @@ struct ath6kl { int total_tx_data_pend; struct htc_target *htc_target; void *hif_priv; + struct ath6kl_vif *vif; spinlock_t lock; struct semaphore sem; int ssid_len; @@ -543,7 +550,7 @@ struct ath6kl { static inline void *ath6kl_priv(struct net_device *dev) { - return wdev_priv(dev->ieee80211_ptr); + return ((struct ath6kl_vif *) netdev_priv(dev))->ar; } static inline void ath6kl_deposit_credit_to_ep(struct htc_credit_state_info @@ -643,6 +650,6 @@ void ath6kl_wakeup_event(void *dev); void ath6kl_target_failure(struct ath6kl *ar); void ath6kl_init_control_info(struct ath6kl *ar); -void ath6kl_deinit_if_data(struct ath6kl *ar, struct net_device *ndev); +void ath6kl_deinit_if_data(struct ath6kl_vif *vif); void ath6kl_core_free(struct ath6kl *ar); #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 8adfc42..f21224c 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1499,7 +1499,7 @@ err_rxbuf_cleanup: err_cleanup_scatter: ath6kl_hif_cleanup_scatter(ar); err_if_deinit: - ath6kl_deinit_if_data(ar, ndev); + ath6kl_deinit_if_data(netdev_priv(ndev)); wiphy_unregister(ar->wiphy); err_debug_init: ath6kl_debug_cleanup(ar); @@ -1632,7 +1632,7 @@ void ath6kl_destroy(struct net_device *dev, unsigned int unregister) ath6kl_debug_cleanup(ar); - ath6kl_deinit_if_data(ar, dev); + ath6kl_deinit_if_data(netdev_priv(dev)); kfree(ar->fw_board); kfree(ar->fw_otp); -- cgit v0.10.2 From 59c98449b8af405aa6245ea9f640c5847f42d26e Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:01 +0530 Subject: ath6kl: Define interface specific states Currently ar->flag maintains interface stats. Move interface specific states from ar->flag to vif->flags. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index b6b3112..4d56a34 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -231,12 +231,14 @@ static void ath6kl_set_key_mgmt(struct ath6kl *ar, u32 key_mgmt) static bool ath6kl_cfg80211_ready(struct ath6kl *ar) { + struct ath6kl_vif *vif = ar->vif; + if (!test_bit(WMI_READY, &ar->flag)) { ath6kl_err("wmi is not ready\n"); return false; } - if (!test_bit(WLAN_ENABLED, &ar->flag)) { + if (!test_bit(WLAN_ENABLED, &vif->flags)) { ath6kl_err("wlan disabled\n"); return false; } @@ -295,6 +297,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); int status; ar->sme_state = SME_CONNECTING; @@ -345,7 +348,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return status; } - if (test_bit(CONNECTED, &ar->flag) && + if (test_bit(CONNECTED, &vif->flags) && ar->ssid_len == sme->ssid_len && !memcmp(ar->ssid, sme->ssid, ar->ssid_len)) { ar->reconnect_flag = true; @@ -420,7 +423,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } if (!ar->usr_bss_filter) { - clear_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag); + clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); if (ath6kl_wmi_bssfilter_cmd(ar->wmi, ALL_BSS_FILTER, 0) != 0) { ath6kl_err("couldn't set bss filtering\n"); up(&ar->sem); @@ -469,7 +472,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } ar->connect_ctrl_flags &= ~CONNECT_DO_WPA_OFFLOAD; - set_bit(CONNECT_PEND, &ar->flag); + set_bit(CONNECT_PEND, &vif->flags); return 0; } @@ -529,6 +532,8 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, u8 assoc_resp_len, u8 *assoc_info) { struct ieee80211_channel *chan; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; /* capinfo + listen interval */ u8 assoc_req_ie_offset = sizeof(u16) + sizeof(u16); @@ -548,7 +553,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, * a Beacon frame from the AP is seen. */ ar->assoc_bss_beacon_int = beacon_intvl; - clear_bit(DTIM_PERIOD_AVAIL, &ar->flag); + clear_bit(DTIM_PERIOD_AVAIL, &vif->flags); if (nw_type & ADHOC_NETWORK) { if (ar->wdev->iftype != NL80211_IFTYPE_ADHOC) { @@ -637,6 +642,9 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 proto_reason) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + if (ar->scan_req) { cfg80211_scan_done(ar->scan_req, true); ar->scan_req = NULL; @@ -676,7 +684,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, return; } - clear_bit(CONNECT_PEND, &ar->flag); + clear_bit(CONNECT_PEND, &vif->flags); if (ar->sme_state == SME_CONNECTING) { cfg80211_connect_result(ar->net_dev, @@ -696,6 +704,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_scan_request *request) { struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev); + struct ath6kl_vif *vif = netdev_priv(ndev); s8 n_channels = 0; u16 *channels = NULL; int ret = 0; @@ -705,10 +714,10 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, return -EIO; if (!ar->usr_bss_filter) { - clear_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag); + clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); ret = ath6kl_wmi_bssfilter_cmd( ar->wmi, - (test_bit(CONNECTED, &ar->flag) ? + (test_bit(CONNECTED, &vif->flags) ? ALL_BUT_BSS_FILTER : ALL_BSS_FILTER), 0); if (ret) { ath6kl_err("couldn't set bss filtering\n"); @@ -761,7 +770,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, channels[i] = request->channels[i]->center_freq; } - if (test_bit(CONNECTED, &ar->flag)) + if (test_bit(CONNECTED, &vif->flags)) force_fg_scan = 1; ret = ath6kl_wmi_startscan_cmd(ar->wmi, WMI_LONG_SCAN, force_fg_scan, @@ -810,6 +819,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, struct key_params *params) { struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev); + struct ath6kl_vif *vif = netdev_priv(ndev); struct ath6kl_key *key = NULL; u8 key_usage; u8 key_type; @@ -888,7 +898,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, ar->ap_mode_bkey.key_type = key_type; ar->ap_mode_bkey.key_len = key->key_len; memcpy(ar->ap_mode_bkey.key, key->key, key->key_len); - if (!test_bit(CONNECTED, &ar->flag)) { + if (!test_bit(CONNECTED, &vif->flags)) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delay initial group " "key configuration until AP mode has been " "started\n"); @@ -901,7 +911,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, } if (ar->next_mode == AP_NETWORK && key_type == WEP_CRYPT && - !test_bit(CONNECTED, &ar->flag)) { + !test_bit(CONNECTED, &vif->flags)) { /* * Store the key locally so that it can be re-configured after * the AP mode has properly started @@ -995,6 +1005,7 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, bool multicast) { struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev); + struct ath6kl_vif *vif = netdev_priv(ndev); struct ath6kl_key *key = NULL; int status = 0; u8 key_usage; @@ -1028,7 +1039,7 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, if (multicast) key_type = ar->grp_crypto; - if (ar->next_mode == AP_NETWORK && !test_bit(CONNECTED, &ar->flag)) + if (ar->next_mode == AP_NETWORK && !test_bit(CONNECTED, &vif->flags)) return 0; /* Delay until AP mode has been started */ status = ath6kl_wmi_addkey_cmd(ar->wmi, ar->def_txkey_index, @@ -1113,11 +1124,12 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy, static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) { struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy); + struct ath6kl_vif *vif = ar->vif; if (!ath6kl_cfg80211_ready(ar)) return -EIO; - if (test_bit(CONNECTED, &ar->flag)) { + if (test_bit(CONNECTED, &vif->flags)) { ar->tx_pwr = 0; if (ath6kl_wmi_get_tx_pwr_cmd(ar->wmi) != 0) { @@ -1211,6 +1223,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, struct cfg80211_ibss_params *ibss_param) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); int status; if (!ath6kl_cfg80211_ready(ar)) @@ -1269,7 +1282,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, ar->ssid_len, ar->ssid, ar->req_bssid, ar->ch_hint, ar->connect_ctrl_flags); - set_bit(CONNECT_PEND, &ar->flag); + set_bit(CONNECT_PEND, &vif->flags); return 0; } @@ -1362,6 +1375,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, u8 *mac, struct station_info *sinfo) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); long left; bool sgi; s32 rate; @@ -1444,8 +1458,8 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, sinfo->filled |= STATION_INFO_TX_BITRATE; - if (test_bit(CONNECTED, &ar->flag) && - test_bit(DTIM_PERIOD_AVAIL, &ar->flag) && + if (test_bit(CONNECTED, &vif->flags) && + test_bit(DTIM_PERIOD_AVAIL, &vif->flags) && ar->nw_type == INFRA_NETWORK) { sinfo->filled |= STATION_INFO_BSS_PARAM; sinfo->bss_param.flags = 0; @@ -1475,7 +1489,9 @@ static int ath6kl_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) { struct ath6kl *ar = ath6kl_priv(netdev); - if (test_bit(CONNECTED, &ar->flag)) + struct ath6kl_vif *vif = netdev_priv(netdev); + + if (test_bit(CONNECTED, &vif->flags)) return ath6kl_wmi_setpmkid_cmd(ar->wmi, ar->bssid, NULL, false); return 0; } @@ -1711,14 +1727,15 @@ static int ath6kl_set_beacon(struct wiphy *wiphy, struct net_device *dev, static int ath6kl_del_beacon(struct wiphy *wiphy, struct net_device *dev) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); if (ar->nw_type != AP_NETWORK) return -EOPNOTSUPP; - if (!test_bit(CONNECTED, &ar->flag)) + if (!test_bit(CONNECTED, &vif->flags)) return -ENOTCONN; ath6kl_wmi_disconnect_cmd(ar->wmi); - clear_bit(CONNECTED, &ar->flag); + clear_bit(CONNECTED, &vif->flags); return 0; } @@ -1814,12 +1831,13 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, bool dont_wait_for_ack, u64 *cookie) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); u32 id; const struct ieee80211_mgmt *mgmt; mgmt = (const struct ieee80211_mgmt *) buf; if (buf + len >= mgmt->u.probe_resp.variable && - ar->nw_type == AP_NETWORK && test_bit(CONNECTED, &ar->flag) && + ar->nw_type == AP_NETWORK && test_bit(CONNECTED, &vif->flags) && ieee80211_is_probe_resp(mgmt->frame_control)) { /* * Send Probe Response frame in AP mode using a separate WMI @@ -2039,9 +2057,9 @@ void ath6kl_deinit_if_data(struct ath6kl_vif *vif) ar->aggr_cntxt = NULL; - if (test_bit(NETDEV_REGISTERED, &ar->flag)) { + if (test_bit(NETDEV_REGISTERED, &vif->flags)) { unregister_netdev(vif->ndev); - clear_bit(NETDEV_REGISTERED, &ar->flag); + clear_bit(NETDEV_REGISTERED, &vif->flags); } free_netdev(vif->ndev); @@ -2081,9 +2099,9 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, goto err; ar->sme_state = SME_DISCONNECTED; - set_bit(WLAN_ENABLED, &ar->flag); + set_bit(WLAN_ENABLED, &vif->flags); ar->wlan_pwr_state = WLAN_POWER_STATE_ON; - set_bit(NETDEV_REGISTERED, &ar->flag); + set_bit(NETDEV_REGISTERED, &vif->flags); return ndev; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 0c1dee0..4777171 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -380,30 +380,37 @@ struct ath6kl_req_key { u8 key_len; }; +/* vif flags info */ +enum ath6kl_vif_state { + CONNECTED, + CONNECT_PEND, + WMM_ENABLED, + NETQ_STOPPED, + DTIM_EXPIRED, + NETDEV_REGISTERED, + CLEAR_BSSFILTER_ON_BEACON, + DTIM_PERIOD_AVAIL, + WLAN_ENABLED, +}; + struct ath6kl_vif { struct wireless_dev wdev; struct net_device *ndev; struct ath6kl *ar; + unsigned long flags; }; /* Flag info */ -#define WMI_ENABLED 0 -#define WMI_READY 1 -#define CONNECTED 2 -#define STATS_UPDATE_PEND 3 -#define CONNECT_PEND 4 -#define WMM_ENABLED 5 -#define NETQ_STOPPED 6 -#define WMI_CTRL_EP_FULL 7 -#define DTIM_EXPIRED 8 -#define DESTROY_IN_PROGRESS 9 -#define NETDEV_REGISTERED 10 -#define SKIP_SCAN 11 -#define WLAN_ENABLED 12 -#define TESTMODE 13 -#define CLEAR_BSSFILTER_ON_BEACON 14 -#define DTIM_PERIOD_AVAIL 15 -#define ROAM_TBL_PEND 16 +enum ath6kl_dev_state { + WMI_ENABLED, + WMI_READY, + WMI_CTRL_EP_FULL, + TESTMODE, + DESTROY_IN_PROGRESS, + SKIP_SCAN, + STATS_UPDATE_PEND, + ROAM_TBL_PEND, +}; struct ath6kl { struct device *dev; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index f21224c..365f7b9 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1575,6 +1575,7 @@ err_wq: void ath6kl_stop_txrx(struct ath6kl *ar) { struct net_device *ndev = ar->net_dev; + struct ath6kl_vif *vif = ar->vif; if (!ndev) return; @@ -1589,7 +1590,7 @@ void ath6kl_stop_txrx(struct ath6kl *ar) if (ar->wlan_pwr_state != WLAN_POWER_STATE_CUT_PWR) ath6kl_stop_endpoint(ndev, false, true); - clear_bit(WLAN_ENABLED, &ar->flag); + clear_bit(WLAN_ENABLED, &vif->flags); } /* diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 4470f6ed..6a0eaea 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -429,6 +429,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, bool get_dbglogs) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; bool discon_issued; @@ -436,8 +437,8 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, /* disable the target and the interrupts associated with it */ if (test_bit(WMI_READY, &ar->flag)) { - discon_issued = (test_bit(CONNECTED, &ar->flag) || - test_bit(CONNECT_PEND, &ar->flag)); + discon_issued = (test_bit(CONNECTED, &vif->flags) || + test_bit(CONNECT_PEND, &vif->flags)); ath6kl_disconnect(ar); if (!keep_profile) ath6kl_init_profile_info(ar); @@ -524,6 +525,8 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel) struct ath6kl_req_key *ik; int res; u8 key_rsc[ATH6KL_KEY_SEQ_LEN]; + /* TODO: Pass vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; ik = &ar->ap_mode_bkey; @@ -555,7 +558,7 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel) } ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); - set_bit(CONNECTED, &ar->flag); + set_bit(CONNECTED, &vif->flags); netif_carrier_on(ar->net_dev); } @@ -914,20 +917,26 @@ void disconnect_timer_handler(unsigned long ptr) void ath6kl_disconnect(struct ath6kl *ar) { - if (test_bit(CONNECTED, &ar->flag) || - test_bit(CONNECT_PEND, &ar->flag)) { + /* TODO: Pass vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; + + if (test_bit(CONNECTED, &vif->flags) || + test_bit(CONNECT_PEND, &vif->flags)) { ath6kl_wmi_disconnect_cmd(ar->wmi); /* * Disconnect command is issued, clear the connect pending * flag. The connected flag will be cleared in * disconnect event notification. */ - clear_bit(CONNECT_PEND, &ar->flag); + clear_bit(CONNECT_PEND, &vif->flags); } } void ath6kl_deep_sleep_enable(struct ath6kl *ar) { + /* TODO: Pass vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; + switch (ar->sme_state) { case SME_CONNECTING: cfg80211_connect_result(ar->net_dev, ar->bssid, NULL, 0, @@ -946,8 +955,8 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) break; } - if (test_bit(CONNECTED, &ar->flag) || - test_bit(CONNECT_PEND, &ar->flag)) + if (test_bit(CONNECTED, &vif->flags) || + test_bit(CONNECT_PEND, &vif->flags)) ath6kl_wmi_disconnect_cmd(ar->wmi); ar->sme_state = SME_DISCONNECTED; @@ -1016,10 +1025,13 @@ void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) void ath6kl_scan_complete_evt(struct ath6kl *ar, int status) { + /* TODO: Pass vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; + ath6kl_cfg80211_scan_complete_event(ar, status); if (!ar->usr_bss_filter) { - clear_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag); + clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); } @@ -1032,6 +1044,9 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, u8 assoc_req_len, u8 assoc_resp_len, u8 *assoc_info) { + /* TODO: findout vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; + ath6kl_cfg80211_connect_event(ar, channel, bssid, listen_int, beacon_int, net_type, beacon_ie_len, @@ -1049,8 +1064,8 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, /* Update connect & link status atomically */ spin_lock_bh(&ar->lock); - set_bit(CONNECTED, &ar->flag); - clear_bit(CONNECT_PEND, &ar->flag); + set_bit(CONNECTED, &vif->flags); + clear_bit(CONNECT_PEND, &vif->flags); netif_carrier_on(ar->net_dev); spin_unlock_bh(&ar->lock); @@ -1064,7 +1079,7 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, } if (!ar->usr_bss_filter) { - set_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag); + set_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); ath6kl_wmi_bssfilter_cmd(ar->wmi, CURRENT_BSS_FILTER, 0); } } @@ -1292,6 +1307,8 @@ void ath6kl_dtimexpiry_event(struct ath6kl *ar) { bool mcastq_empty = false; struct sk_buff *skb; + /* TODO: Pass vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; /* * If there are no associated STAs, ignore the DTIM expiry event. @@ -1313,7 +1330,7 @@ void ath6kl_dtimexpiry_event(struct ath6kl *ar) return; /* set the STA flag to dtim_expired for the frame to go out */ - set_bit(DTIM_EXPIRED, &ar->flag); + set_bit(DTIM_EXPIRED, &vif->flags); spin_lock_bh(&ar->mcastpsq_lock); while ((skb = skb_dequeue(&ar->mcastpsq)) != NULL) { @@ -1325,7 +1342,7 @@ void ath6kl_dtimexpiry_event(struct ath6kl *ar) } spin_unlock_bh(&ar->mcastpsq_lock); - clear_bit(DTIM_EXPIRED, &ar->flag); + clear_bit(DTIM_EXPIRED, &vif->flags); /* clear the LSB of the BitMapCtl field of the TIM IE */ ath6kl_wmi_set_pvb_cmd(ar->wmi, MCAST_AID, 0); @@ -1335,6 +1352,9 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 prot_reason_status) { + /* TODO: Findout vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; + if (ar->nw_type == AP_NETWORK) { if (!ath6kl_remove_sta(ar, bssid, prot_reason_status)) return; @@ -1357,7 +1377,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, if (memcmp(ar->net_dev->dev_addr, bssid, ETH_ALEN) == 0) { memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); - clear_bit(CONNECTED, &ar->flag); + clear_bit(CONNECTED, &vif->flags); } return; } @@ -1382,19 +1402,19 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, if (!ar->usr_bss_filter && test_bit(WMI_READY, &ar->flag)) ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); } else { - set_bit(CONNECT_PEND, &ar->flag); + set_bit(CONNECT_PEND, &vif->flags); if (((reason == ASSOC_FAILED) && (prot_reason_status == 0x11)) || ((reason == ASSOC_FAILED) && (prot_reason_status == 0x0) && (ar->reconnect_flag == 1))) { - set_bit(CONNECTED, &ar->flag); + set_bit(CONNECTED, &vif->flags); return; } } /* update connect & link status atomically */ spin_lock_bh(&ar->lock); - clear_bit(CONNECTED, &ar->flag); + clear_bit(CONNECTED, &vif->flags); netif_carrier_off(ar->net_dev); spin_unlock_bh(&ar->lock); @@ -1414,12 +1434,13 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, static int ath6kl_open(struct net_device *dev) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); spin_lock_bh(&ar->lock); - set_bit(WLAN_ENABLED, &ar->flag); + set_bit(WLAN_ENABLED, &vif->flags); - if (test_bit(CONNECTED, &ar->flag)) { + if (test_bit(CONNECTED, &vif->flags)) { netif_carrier_on(dev); netif_wake_queue(dev); } else @@ -1433,6 +1454,7 @@ static int ath6kl_open(struct net_device *dev) static int ath6kl_close(struct net_device *dev) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); netif_stop_queue(dev); @@ -1443,7 +1465,7 @@ static int ath6kl_close(struct net_device *dev) 0, 0, 0)) return -EIO; - clear_bit(WLAN_ENABLED, &ar->flag); + clear_bit(WLAN_ENABLED, &vif->flags); } ath6kl_cfg80211_scan_complete_event(ar, -ECANCELED); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index a9dff01..d1652bd 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -83,6 +83,8 @@ static bool ath6kl_powersave_ap(struct ath6kl *ar, struct sk_buff *skb, struct ethhdr *datap = (struct ethhdr *) skb->data; struct ath6kl_sta *conn = NULL; bool ps_queued = false, is_psq_empty = false; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; if (is_multicast_ether_addr(datap->h_dest)) { u8 ctr = 0; @@ -100,7 +102,7 @@ static bool ath6kl_powersave_ap(struct ath6kl *ar, struct sk_buff *skb, * If this transmit is not because of a Dtim Expiry * q it. */ - if (!test_bit(DTIM_EXPIRED, &ar->flag)) { + if (!test_bit(DTIM_EXPIRED, &vif->flags)) { bool is_mcastq_empty = false; spin_lock_bh(&ar->mcastpsq_lock); @@ -235,6 +237,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_cookie *cookie = NULL; enum htc_endpoint_id eid = ENDPOINT_UNUSED; + struct ath6kl_vif *vif = netdev_priv(dev); u32 map_no = 0; u16 htc_tag = ATH6KL_DATA_PKT_TAG; u8 ac = 99 ; /* initialize to unmapped ac */ @@ -246,7 +249,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) skb, skb->data, skb->len); /* If target is not associated */ - if (!test_bit(CONNECTED, &ar->flag)) { + if (!test_bit(CONNECTED, &vif->flags)) { dev_kfree_skb(skb); return 0; } @@ -278,12 +281,12 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) } if ((ar->nw_type == ADHOC_NETWORK) && - ar->ibss_ps_enable && test_bit(CONNECTED, &ar->flag)) + ar->ibss_ps_enable && test_bit(CONNECTED, &vif->flags)) chk_adhoc_ps_mapping = true; else { /* get the stream mapping */ ret = ath6kl_wmi_implicit_create_pstream(ar->wmi, skb, - 0, test_bit(WMM_ENABLED, &ar->flag), &ac); + 0, test_bit(WMM_ENABLED, &vif->flags), &ac); if (ret) goto fail_tx; } @@ -426,6 +429,8 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, struct htc_packet *packet) { struct ath6kl *ar = target->dev->ar; + /* TODO: Findout vif properly */ + struct ath6kl_vif *vif = ar->vif; enum htc_endpoint_id endpoint = packet->endpoint; if (endpoint == ar->ctrl_ep) { @@ -468,7 +473,7 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, stop_net_queues: spin_lock_bh(&ar->lock); - set_bit(NETQ_STOPPED, &ar->flag); + set_bit(NETQ_STOPPED, &vif->flags); spin_unlock_bh(&ar->lock); netif_stop_queue(ar->net_dev); @@ -524,6 +529,8 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) enum htc_endpoint_id eid; bool wake_event = false; bool flushing = false; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; skb_queue_head_init(&skb_queue); @@ -597,15 +604,15 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) ath6kl_free_cookie(ar, ath6kl_cookie); - if (test_bit(NETQ_STOPPED, &ar->flag)) - clear_bit(NETQ_STOPPED, &ar->flag); + if (test_bit(NETQ_STOPPED, &vif->flags)) + clear_bit(NETQ_STOPPED, &vif->flags); } spin_unlock_bh(&ar->lock); __skb_queue_purge(&skb_queue); - if (test_bit(CONNECTED, &ar->flag)) { + if (test_bit(CONNECTED, &vif->flags)) { if (!flushing) netif_wake_queue(ar->net_dev); } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 7f4c2c2a..a71d773 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -950,6 +950,8 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) struct ath6kl *ar = wmi->parent_dev; struct ieee80211_mgmt *mgmt; struct cfg80211_bss *bss; + /*TODO: Findout vif properly */ + struct ath6kl_vif *vif = ar->vif; if (len <= sizeof(struct wmi_bss_info_hdr2)) return -EINVAL; @@ -969,8 +971,8 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) return 0; /* Only update BSS table for now */ if (bih->frame_type == BEACON_FTYPE && - test_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag)) { - clear_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag); + test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) { + clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); } @@ -981,14 +983,14 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) if (len < 8 + 2 + 2) return -EINVAL; - if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &ar->flag) && - memcmp(bih->bssid, ar->bssid, ETH_ALEN) == 0) { + if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags) + && memcmp(bih->bssid, ar->bssid, ETH_ALEN) == 0) { const u8 *tim; tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, len - 8 - 2 - 2); if (tim && tim[1] >= 2) { ar->assoc_bss_dtim_period = tim[3]; - set_bit(DTIM_PERIOD_AVAIL, &ar->flag); + set_bit(DTIM_PERIOD_AVAIL, &vif->flags); } } -- cgit v0.10.2 From 3450334f392bca1fccbf04a90020161ec4404a1e Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:02 +0530 Subject: ath6kl: Move ssid and crypto information to vif structure Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 4d56a34..2b6f09a8 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -126,14 +126,17 @@ static struct ieee80211_supported_band ath6kl_band_5ghz = { static int ath6kl_set_wpa_version(struct ath6kl *ar, enum nl80211_wpa_versions wpa_version) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: %u\n", __func__, wpa_version); if (!wpa_version) { - ar->auth_mode = NONE_AUTH; + vif->auth_mode = NONE_AUTH; } else if (wpa_version & NL80211_WPA_VERSION_2) { - ar->auth_mode = WPA2_AUTH; + vif->auth_mode = WPA2_AUTH; } else if (wpa_version & NL80211_WPA_VERSION_1) { - ar->auth_mode = WPA_AUTH; + vif->auth_mode = WPA_AUTH; } else { ath6kl_err("%s: %u not supported\n", __func__, wpa_version); return -ENOTSUPP; @@ -145,22 +148,24 @@ static int ath6kl_set_wpa_version(struct ath6kl *ar, static int ath6kl_set_auth_type(struct ath6kl *ar, enum nl80211_auth_type auth_type) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: 0x%x\n", __func__, auth_type); switch (auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: - ar->dot11_auth_mode = OPEN_AUTH; + vif->dot11_auth_mode = OPEN_AUTH; break; case NL80211_AUTHTYPE_SHARED_KEY: - ar->dot11_auth_mode = SHARED_AUTH; + vif->dot11_auth_mode = SHARED_AUTH; break; case NL80211_AUTHTYPE_NETWORK_EAP: - ar->dot11_auth_mode = LEAP_AUTH; + vif->dot11_auth_mode = LEAP_AUTH; break; case NL80211_AUTHTYPE_AUTOMATIC: - ar->dot11_auth_mode = OPEN_AUTH | SHARED_AUTH; + vif->dot11_auth_mode = OPEN_AUTH | SHARED_AUTH; break; default: @@ -173,9 +178,12 @@ static int ath6kl_set_auth_type(struct ath6kl *ar, static int ath6kl_set_cipher(struct ath6kl *ar, u32 cipher, bool ucast) { - u8 *ar_cipher = ucast ? &ar->prwise_crypto : &ar->grp_crypto; - u8 *ar_cipher_len = ucast ? &ar->prwise_crypto_len : - &ar->grp_crypto_len; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + + u8 *ar_cipher = ucast ? &vif->prwise_crypto : &vif->grp_crypto; + u8 *ar_cipher_len = ucast ? &vif->prwise_crypto_len : + &vif->grp_crypto_len; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: cipher 0x%x, ucast %u\n", __func__, cipher, ucast); @@ -212,20 +220,23 @@ static int ath6kl_set_cipher(struct ath6kl *ar, u32 cipher, bool ucast) static void ath6kl_set_key_mgmt(struct ath6kl *ar, u32 key_mgmt) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: 0x%x\n", __func__, key_mgmt); if (key_mgmt == WLAN_AKM_SUITE_PSK) { - if (ar->auth_mode == WPA_AUTH) - ar->auth_mode = WPA_PSK_AUTH; - else if (ar->auth_mode == WPA2_AUTH) - ar->auth_mode = WPA2_PSK_AUTH; + if (vif->auth_mode == WPA_AUTH) + vif->auth_mode = WPA_PSK_AUTH; + else if (vif->auth_mode == WPA2_AUTH) + vif->auth_mode = WPA2_PSK_AUTH; } else if (key_mgmt == 0x00409600) { - if (ar->auth_mode == WPA_AUTH) - ar->auth_mode = WPA_AUTH_CCKM; - else if (ar->auth_mode == WPA2_AUTH) - ar->auth_mode = WPA2_AUTH_CCKM; + if (vif->auth_mode == WPA_AUTH) + vif->auth_mode = WPA_AUTH_CCKM; + else if (vif->auth_mode == WPA2_AUTH) + vif->auth_mode = WPA2_AUTH_CCKM; } else if (key_mgmt != WLAN_AKM_SUITE_8021X) { - ar->auth_mode = NONE_AUTH; + vif->auth_mode = NONE_AUTH; } } @@ -349,8 +360,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } if (test_bit(CONNECTED, &vif->flags) && - ar->ssid_len == sme->ssid_len && - !memcmp(ar->ssid, sme->ssid, ar->ssid_len)) { + vif->ssid_len == sme->ssid_len && + !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { ar->reconnect_flag = true; status = ath6kl_wmi_reconnect_cmd(ar->wmi, ar->req_bssid, ar->ch_hint); @@ -361,14 +372,14 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return -EIO; } return 0; - } else if (ar->ssid_len == sme->ssid_len && - !memcmp(ar->ssid, sme->ssid, ar->ssid_len)) { + } else if (vif->ssid_len == sme->ssid_len && + !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { ath6kl_disconnect(ar); } - memset(ar->ssid, 0, sizeof(ar->ssid)); - ar->ssid_len = sme->ssid_len; - memcpy(ar->ssid, sme->ssid, sme->ssid_len); + memset(vif->ssid, 0, sizeof(vif->ssid)); + vif->ssid_len = sme->ssid_len; + memcpy(vif->ssid, sme->ssid, sme->ssid_len); if (sme->channel) ar->ch_hint = sme->channel->center_freq; @@ -396,7 +407,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, ath6kl_set_key_mgmt(ar, sme->crypto.akm_suites[0]); if ((sme->key_len) && - (ar->auth_mode == NONE_AUTH) && (ar->prwise_crypto == WEP_CRYPT)) { + (vif->auth_mode == NONE_AUTH) && + (vif->prwise_crypto == WEP_CRYPT)) { struct ath6kl_key *key = NULL; if (sme->key_idx < WMI_MIN_KEY_INDEX || @@ -410,11 +422,11 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, key = &ar->keys[sme->key_idx]; key->key_len = sme->key_len; memcpy(key->key, sme->key, key->key_len); - key->cipher = ar->prwise_crypto; - ar->def_txkey_index = sme->key_idx; + key->cipher = vif->prwise_crypto; + vif->def_txkey_index = sme->key_idx; ath6kl_wmi_addkey_cmd(ar->wmi, sme->key_idx, - ar->prwise_crypto, + vif->prwise_crypto, GROUP_USAGE | TX_USAGE, key->key_len, NULL, @@ -438,25 +450,25 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, " PW crypto %d PW crypto len %d GRP crypto %d" " GRP crypto len %d channel hint %u\n", __func__, - ar->auth_mode, ar->dot11_auth_mode, ar->prwise_crypto, - ar->prwise_crypto_len, ar->grp_crypto, - ar->grp_crypto_len, ar->ch_hint); + vif->auth_mode, vif->dot11_auth_mode, vif->prwise_crypto, + vif->prwise_crypto_len, vif->grp_crypto, + vif->grp_crypto_len, ar->ch_hint); ar->reconnect_flag = 0; status = ath6kl_wmi_connect_cmd(ar->wmi, ar->nw_type, - ar->dot11_auth_mode, ar->auth_mode, - ar->prwise_crypto, - ar->prwise_crypto_len, - ar->grp_crypto, ar->grp_crypto_len, - ar->ssid_len, ar->ssid, + vif->dot11_auth_mode, vif->auth_mode, + vif->prwise_crypto, + vif->prwise_crypto_len, + vif->grp_crypto, vif->grp_crypto_len, + vif->ssid_len, vif->ssid, ar->req_bssid, ar->ch_hint, ar->connect_ctrl_flags); up(&ar->sem); if (status == -EINVAL) { - memset(ar->ssid, 0, sizeof(ar->ssid)); - ar->ssid_len = 0; + memset(vif->ssid, 0, sizeof(vif->ssid)); + vif->ssid_len = 0; ath6kl_err("invalid request\n"); return -ENOENT; } else if (status) { @@ -465,8 +477,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } if ((!(ar->connect_ctrl_flags & CONNECT_DO_WPA_OFFLOAD)) && - ((ar->auth_mode == WPA_PSK_AUTH) - || (ar->auth_mode == WPA2_PSK_AUTH))) { + ((vif->auth_mode == WPA_PSK_AUTH) + || (vif->auth_mode == WPA2_PSK_AUTH))) { mod_timer(&ar->disconnect_timer, jiffies + msecs_to_jiffies(DISCON_TIMER_INTVAL)); } @@ -481,11 +493,13 @@ static int ath6kl_add_bss_if_needed(struct ath6kl *ar, const u8 *bssid, struct ieee80211_channel *chan, const u8 *beacon_ie, size_t beacon_ie_len) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; struct cfg80211_bss *bss; u8 *ie; bss = cfg80211_get_bss(ar->wiphy, chan, bssid, - ar->ssid, ar->ssid_len, WLAN_CAPABILITY_ESS, + vif->ssid, vif->ssid_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); if (bss == NULL) { /* @@ -496,16 +510,16 @@ static int ath6kl_add_bss_if_needed(struct ath6kl *ar, const u8 *bssid, * Prepend SSID element since it is not included in the Beacon * IEs from the target. */ - ie = kmalloc(2 + ar->ssid_len + beacon_ie_len, GFP_KERNEL); + ie = kmalloc(2 + vif->ssid_len + beacon_ie_len, GFP_KERNEL); if (ie == NULL) return -ENOMEM; ie[0] = WLAN_EID_SSID; - ie[1] = ar->ssid_len; - memcpy(ie + 2, ar->ssid, ar->ssid_len); - memcpy(ie + 2 + ar->ssid_len, beacon_ie, beacon_ie_len); + ie[1] = vif->ssid_len; + memcpy(ie + 2, vif->ssid, vif->ssid_len); + memcpy(ie + 2 + vif->ssid_len, beacon_ie, beacon_ie_len); bss = cfg80211_inform_bss(ar->wiphy, chan, bssid, 0, WLAN_CAPABILITY_ESS, 100, - ie, 2 + ar->ssid_len + beacon_ie_len, + ie, 2 + vif->ssid_len + beacon_ie_len, 0, GFP_KERNEL); if (bss) ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "added dummy bss for " @@ -606,6 +620,7 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) { struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: reason=%u\n", __func__, reason_code); @@ -625,8 +640,8 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, ar->reconnect_flag = 0; ath6kl_disconnect(ar); - memset(ar->ssid, 0, sizeof(ar->ssid)); - ar->ssid_len = 0; + memset(vif->ssid, 0, sizeof(vif->ssid)); + vif->ssid_len = 0; if (!test_bit(SKIP_SCAN, &ar->flag)) memset(ar->req_bssid, 0, sizeof(ar->req_bssid)); @@ -879,8 +894,8 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, return -ENOTSUPP; } - if (((ar->auth_mode == WPA_PSK_AUTH) - || (ar->auth_mode == WPA2_PSK_AUTH)) + if (((vif->auth_mode == WPA_PSK_AUTH) + || (vif->auth_mode == WPA2_PSK_AUTH)) && (key_usage & GROUP_USAGE)) del_timer(&ar->disconnect_timer); @@ -889,7 +904,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, __func__, key_index, key->key_len, key_type, key_usage, key->seq_len); - ar->def_txkey_index = key_index; + vif->def_txkey_index = key_index; if (ar->nw_type == AP_NETWORK && !pairwise && (key_type == TKIP_CRYPT || key_type == AES_CRYPT) && params) { @@ -924,7 +939,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, return 0; } - status = ath6kl_wmi_addkey_cmd(ar->wmi, ar->def_txkey_index, + status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->def_txkey_index, key_type, key_usage, key->key_len, key->seq, key->key, KEY_OP_INIT_VAL, (u8 *) mac_addr, SYNC_BOTH_WMIFLAG); @@ -1029,20 +1044,20 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, return -EINVAL; } - ar->def_txkey_index = key_index; - key = &ar->keys[ar->def_txkey_index]; + vif->def_txkey_index = key_index; + key = &ar->keys[vif->def_txkey_index]; key_usage = GROUP_USAGE; - if (ar->prwise_crypto == WEP_CRYPT) + if (vif->prwise_crypto == WEP_CRYPT) key_usage |= TX_USAGE; if (unicast) - key_type = ar->prwise_crypto; + key_type = vif->prwise_crypto; if (multicast) - key_type = ar->grp_crypto; + key_type = vif->grp_crypto; if (ar->next_mode == AP_NETWORK && !test_bit(CONNECTED, &vif->flags)) return 0; /* Delay until AP mode has been started */ - status = ath6kl_wmi_addkey_cmd(ar->wmi, ar->def_txkey_index, + status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->def_txkey_index, key_type, key_usage, key->key_len, key->seq, key->key, KEY_OP_INIT_VAL, NULL, @@ -1229,8 +1244,8 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, if (!ath6kl_cfg80211_ready(ar)) return -EIO; - ar->ssid_len = ibss_param->ssid_len; - memcpy(ar->ssid, ibss_param->ssid, ar->ssid_len); + vif->ssid_len = ibss_param->ssid_len; + memcpy(vif->ssid, ibss_param->ssid, vif->ssid_len); if (ibss_param->channel) ar->ch_hint = ibss_param->channel->center_freq; @@ -1270,16 +1285,16 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, " PW crypto %d PW crypto len %d GRP crypto %d" " GRP crypto len %d channel hint %u\n", __func__, - ar->auth_mode, ar->dot11_auth_mode, ar->prwise_crypto, - ar->prwise_crypto_len, ar->grp_crypto, - ar->grp_crypto_len, ar->ch_hint); + vif->auth_mode, vif->dot11_auth_mode, vif->prwise_crypto, + vif->prwise_crypto_len, vif->grp_crypto, + vif->grp_crypto_len, ar->ch_hint); status = ath6kl_wmi_connect_cmd(ar->wmi, ar->nw_type, - ar->dot11_auth_mode, ar->auth_mode, - ar->prwise_crypto, - ar->prwise_crypto_len, - ar->grp_crypto, ar->grp_crypto_len, - ar->ssid_len, ar->ssid, + vif->dot11_auth_mode, vif->auth_mode, + vif->prwise_crypto, + vif->prwise_crypto_len, + vif->grp_crypto, vif->grp_crypto_len, + vif->ssid_len, vif->ssid, ar->req_bssid, ar->ch_hint, ar->connect_ctrl_flags); set_bit(CONNECT_PEND, &vif->flags); @@ -1291,13 +1306,14 @@ static int ath6kl_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) { struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); if (!ath6kl_cfg80211_ready(ar)) return -EIO; ath6kl_disconnect(ar); - memset(ar->ssid, 0, sizeof(ar->ssid)); - ar->ssid_len = 0; + memset(vif->ssid, 0, sizeof(vif->ssid)); + vif->ssid_len = 0; return 0; } @@ -1575,6 +1591,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, struct beacon_parameters *info, bool add) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); struct ieee80211_mgmt *mgmt; u8 *ies; int ies_len; @@ -1631,12 +1648,12 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, if (info->ssid == NULL) return -EINVAL; - memcpy(ar->ssid, info->ssid, info->ssid_len); - ar->ssid_len = info->ssid_len; + memcpy(vif->ssid, info->ssid, info->ssid_len); + vif->ssid_len = info->ssid_len; if (info->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) return -EOPNOTSUPP; /* TODO */ - ar->dot11_auth_mode = OPEN_AUTH; + vif->dot11_auth_mode = OPEN_AUTH; memset(&p, 0, sizeof(p)); @@ -1658,7 +1675,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, } if (p.auth_mode == 0) p.auth_mode = NONE_AUTH; - ar->auth_mode = p.auth_mode; + vif->auth_mode = p.auth_mode; for (i = 0; i < info->crypto.n_ciphers_pairwise; i++) { switch (info->crypto.ciphers_pairwise[i]) { @@ -1700,9 +1717,9 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, p.nw_type = AP_NETWORK; ar->nw_type = ar->next_mode; - p.ssid_len = ar->ssid_len; - memcpy(p.ssid, ar->ssid, ar->ssid_len); - p.dot11_auth_mode = ar->dot11_auth_mode; + p.ssid_len = vif->ssid_len; + memcpy(p.ssid, vif->ssid, vif->ssid_len); + p.dot11_auth_mode = vif->dot11_auth_mode; p.ch = cpu_to_le16(ar->next_chan); res = ath6kl_wmi_ap_profile_commit(ar->wmi, &p); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 4777171..f401715 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -398,6 +398,15 @@ struct ath6kl_vif { struct net_device *ndev; struct ath6kl *ar; unsigned long flags; + int ssid_len; + u8 ssid[IEEE80211_MAX_SSID_LEN]; + u8 dot11_auth_mode; + u8 auth_mode; + u8 prwise_crypto; + u8 prwise_crypto_len; + u8 grp_crypto; + u8 grp_crypto_len; + u8 def_txkey_index; }; /* Flag info */ @@ -426,17 +435,8 @@ struct ath6kl { struct ath6kl_vif *vif; spinlock_t lock; struct semaphore sem; - int ssid_len; - u8 ssid[IEEE80211_MAX_SSID_LEN]; u8 next_mode; u8 nw_type; - u8 dot11_auth_mode; - u8 auth_mode; - u8 prwise_crypto; - u8 prwise_crypto_len; - u8 grp_crypto; - u8 grp_crypto_len; - u8 def_txkey_index; struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; u8 bssid[ETH_ALEN]; u8 req_bssid[ETH_ALEN]; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 365f7b9..d9dd182 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -75,15 +75,18 @@ struct sk_buff *ath6kl_buf_alloc(int size) void ath6kl_init_profile_info(struct ath6kl *ar) { - ar->ssid_len = 0; - memset(ar->ssid, 0, sizeof(ar->ssid)); - - ar->dot11_auth_mode = OPEN_AUTH; - ar->auth_mode = NONE_AUTH; - ar->prwise_crypto = NONE_CRYPT; - ar->prwise_crypto_len = 0; - ar->grp_crypto = NONE_CRYPT; - ar->grp_crypto_len = 0; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + + vif->ssid_len = 0; + memset(vif->ssid, 0, sizeof(vif->ssid)); + + vif->dot11_auth_mode = OPEN_AUTH; + vif->auth_mode = NONE_AUTH; + vif->prwise_crypto = NONE_CRYPT; + vif->prwise_crypto_len = 0; + vif->grp_crypto = NONE_CRYPT; + vif->grp_crypto_len = 0; memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); memset(ar->req_bssid, 0, sizeof(ar->req_bssid)); memset(ar->bssid, 0, sizeof(ar->bssid)); @@ -245,8 +248,10 @@ static int ath6kl_init_service_ep(struct ath6kl *ar) void ath6kl_init_control_info(struct ath6kl *ar) { + struct ath6kl_vif *vif = ar->vif; + ath6kl_init_profile_info(ar); - ar->def_txkey_index = 0; + vif->def_txkey_index = 0; memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); ar->ch_hint = 0; } diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 6a0eaea..a207377 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -498,13 +498,15 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, static void ath6kl_install_static_wep_keys(struct ath6kl *ar) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; u8 index; u8 keyusage; for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) { if (ar->wep_key_list[index].key_len) { keyusage = GROUP_USAGE; - if (index == ar->def_txkey_index) + if (index == vif->def_txkey_index) keyusage |= TX_USAGE; ath6kl_wmi_addkey_cmd(ar->wmi, @@ -532,9 +534,9 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel) ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "AP mode started on %u MHz\n", channel); - switch (ar->auth_mode) { + switch (vif->auth_mode) { case NONE_AUTH: - if (ar->prwise_crypto == WEP_CRYPT) + if (vif->prwise_crypto == WEP_CRYPT) ath6kl_install_static_wep_keys(ar); break; case WPA_PSK_AUTH: -- cgit v0.10.2 From f5938f249a08a4e6c9046fa095be00db664158cc Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:03 +0530 Subject: ath6kl: Move nw_type to vif structure Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2b6f09a8..37be03b 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -443,7 +443,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } } - ar->nw_type = ar->next_mode; + vif->nw_type = vif->next_mode; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: connect called with authmode %d dot11 auth %d" @@ -455,7 +455,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->grp_crypto_len, ar->ch_hint); ar->reconnect_flag = 0; - status = ath6kl_wmi_connect_cmd(ar->wmi, ar->nw_type, + status = ath6kl_wmi_connect_cmd(ar->wmi, vif->nw_type, vif->dot11_auth_mode, vif->auth_mode, vif->prwise_crypto, vif->prwise_crypto_len, @@ -665,7 +665,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, ar->scan_req = NULL; } - if (ar->nw_type & ADHOC_NETWORK) { + if (vif->nw_type & ADHOC_NETWORK) { if (ar->wdev->iftype != NL80211_IFTYPE_ADHOC) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: ath6k not in ibss mode\n", __func__); @@ -676,7 +676,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, return; } - if (ar->nw_type & INFRA_NETWORK) { + if (vif->nw_type & INFRA_NETWORK) { if (ar->wdev->iftype != NL80211_IFTYPE_STATION && ar->wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, @@ -906,7 +906,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, vif->def_txkey_index = key_index; - if (ar->nw_type == AP_NETWORK && !pairwise && + if (vif->nw_type == AP_NETWORK && !pairwise && (key_type == TKIP_CRYPT || key_type == AES_CRYPT) && params) { ar->ap_mode_bkey.valid = true; ar->ap_mode_bkey.key_index = key_index; @@ -925,7 +925,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, } } - if (ar->next_mode == AP_NETWORK && key_type == WEP_CRYPT && + if (vif->next_mode == AP_NETWORK && key_type == WEP_CRYPT && !test_bit(CONNECTED, &vif->flags)) { /* * Store the key locally so that it can be re-configured after @@ -1054,7 +1054,7 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, if (multicast) key_type = vif->grp_crypto; - if (ar->next_mode == AP_NETWORK && !test_bit(CONNECTED, &vif->flags)) + if (vif->next_mode == AP_NETWORK && !test_bit(CONNECTED, &vif->flags)) return 0; /* Delay until AP mode has been started */ status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->def_txkey_index, @@ -1201,6 +1201,7 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy, { struct ath6kl *ar = ath6kl_priv(ndev); struct wireless_dev *wdev = ar->wdev; + struct ath6kl_vif *vif = netdev_priv(ndev); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type %u\n", __func__, type); @@ -1209,19 +1210,19 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy, switch (type) { case NL80211_IFTYPE_STATION: - ar->next_mode = INFRA_NETWORK; + vif->next_mode = INFRA_NETWORK; break; case NL80211_IFTYPE_ADHOC: - ar->next_mode = ADHOC_NETWORK; + vif->next_mode = ADHOC_NETWORK; break; case NL80211_IFTYPE_AP: - ar->next_mode = AP_NETWORK; + vif->next_mode = AP_NETWORK; break; case NL80211_IFTYPE_P2P_CLIENT: - ar->next_mode = INFRA_NETWORK; + vif->next_mode = INFRA_NETWORK; break; case NL80211_IFTYPE_P2P_GO: - ar->next_mode = AP_NETWORK; + vif->next_mode = AP_NETWORK; break; default: ath6kl_err("invalid interface type %u\n", type); @@ -1278,7 +1279,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, ath6kl_set_cipher(ar, 0, false); } - ar->nw_type = ar->next_mode; + vif->nw_type = vif->next_mode; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: connect called with authmode %d dot11 auth %d" @@ -1289,7 +1290,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, vif->prwise_crypto_len, vif->grp_crypto, vif->grp_crypto_len, ar->ch_hint); - status = ath6kl_wmi_connect_cmd(ar->wmi, ar->nw_type, + status = ath6kl_wmi_connect_cmd(ar->wmi, vif->nw_type, vif->dot11_auth_mode, vif->auth_mode, vif->prwise_crypto, vif->prwise_crypto_len, @@ -1476,7 +1477,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, if (test_bit(CONNECTED, &vif->flags) && test_bit(DTIM_PERIOD_AVAIL, &vif->flags) && - ar->nw_type == INFRA_NETWORK) { + vif->nw_type == INFRA_NETWORK) { sinfo->filled |= STATION_INFO_BSS_PARAM; sinfo->bss_param.flags = 0; sinfo->bss_param.dtim_period = ar->assoc_bss_dtim_period; @@ -1604,7 +1605,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, if (!ath6kl_cfg80211_ready(ar)) return -EIO; - if (ar->next_mode != AP_NETWORK) + if (vif->next_mode != AP_NETWORK) return -EOPNOTSUPP; if (info->beacon_ies) { @@ -1715,7 +1716,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, ath6kl_set_cipher(ar, info->crypto.cipher_group, false); p.nw_type = AP_NETWORK; - ar->nw_type = ar->next_mode; + vif->nw_type = vif->next_mode; p.ssid_len = vif->ssid_len; memcpy(p.ssid, vif->ssid, vif->ssid_len); @@ -1746,7 +1747,7 @@ static int ath6kl_del_beacon(struct wiphy *wiphy, struct net_device *dev) struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); - if (ar->nw_type != AP_NETWORK) + if (vif->nw_type != AP_NETWORK) return -EOPNOTSUPP; if (!test_bit(CONNECTED, &vif->flags)) return -ENOTCONN; @@ -1761,8 +1762,9 @@ static int ath6kl_change_station(struct wiphy *wiphy, struct net_device *dev, u8 *mac, struct station_parameters *params) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); - if (ar->nw_type != AP_NETWORK) + if (vif->nw_type != AP_NETWORK) return -EOPNOTSUPP; /* Use this only for authorizing/unauthorizing a station */ @@ -1854,7 +1856,7 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, mgmt = (const struct ieee80211_mgmt *) buf; if (buf + len >= mgmt->u.probe_resp.variable && - ar->nw_type == AP_NETWORK && test_bit(CONNECTED, &vif->flags) && + vif->nw_type == AP_NETWORK && test_bit(CONNECTED, &vif->flags) && ieee80211_is_probe_resp(mgmt->frame_control)) { /* * Send Probe Response frame in AP mode using a separate WMI diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f401715..714092a 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -407,6 +407,8 @@ struct ath6kl_vif { u8 grp_crypto; u8 grp_crypto_len; u8 def_txkey_index; + u8 next_mode; + u8 nw_type; }; /* Flag info */ @@ -435,8 +437,6 @@ struct ath6kl { struct ath6kl_vif *vif; spinlock_t lock; struct semaphore sem; - u8 next_mode; - u8 nw_type; struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; u8 bssid[ETH_ALEN]; u8 req_bssid[ETH_ALEN]; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index d9dd182..39cd6c7 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -91,7 +91,7 @@ void ath6kl_init_profile_info(struct ath6kl *ar) memset(ar->req_bssid, 0, sizeof(ar->req_bssid)); memset(ar->bssid, 0, sizeof(ar->bssid)); ar->bss_ch = 0; - ar->nw_type = ar->next_mode = INFRA_NETWORK; + vif->nw_type = vif->next_mode = INFRA_NETWORK; } static int ath6kl_set_host_app_area(struct ath6kl *ar) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index a207377..4add0ef 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -22,10 +22,12 @@ struct ath6kl_sta *ath6kl_find_sta(struct ath6kl *ar, u8 *node_addr) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; struct ath6kl_sta *conn = NULL; u8 i, max_conn; - max_conn = (ar->nw_type == AP_NETWORK) ? AP_MAX_NUM_STA : 0; + max_conn = (vif->nw_type == AP_NETWORK) ? AP_MAX_NUM_STA : 0; for (i = 0; i < max_conn; i++) { if (memcmp(node_addr, ar->sta_list[i].mac, ETH_ALEN) == 0) { @@ -461,7 +463,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, */ if (discon_issued) ath6kl_disconnect_event(ar, DISCONNECT_CMD, - (ar->nw_type & AP_NETWORK) ? + (vif->nw_type & AP_NETWORK) ? bcast_mac : ar->bssid, 0, NULL, 0); @@ -1058,7 +1060,7 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, memcpy(ar->bssid, bssid, sizeof(ar->bssid)); ar->bss_ch = channel; - if ((ar->nw_type == INFRA_NETWORK)) + if ((vif->nw_type == INFRA_NETWORK)) ath6kl_wmi_listeninterval_cmd(ar->wmi, ar->listen_intvl_t, ar->listen_intvl_b); @@ -1074,7 +1076,7 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, aggr_reset_state(ar->aggr_cntxt); ar->reconnect_flag = 0; - if ((ar->nw_type == ADHOC_NETWORK) && ar->ibss_ps_enable) { + if ((vif->nw_type == ADHOC_NETWORK) && ar->ibss_ps_enable) { memset(ar->node_map, 0, sizeof(ar->node_map)); ar->node_num = 0; ar->next_ep_id = ENDPOINT_2; @@ -1089,12 +1091,14 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, void ath6kl_tkip_micerr_event(struct ath6kl *ar, u8 keyid, bool ismcast) { struct ath6kl_sta *sta; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; u8 tsc[6]; /* * For AP case, keyid will have aid of STA which sent pkt with * MIC error. Use this aid to get MAC & send it to hostapd. */ - if (ar->nw_type == AP_NETWORK) { + if (vif->nw_type == AP_NETWORK) { sta = ath6kl_find_sta_by_aid(ar, (keyid >> 2)); if (!sta) return; @@ -1227,9 +1231,11 @@ void ath6kl_tgt_stats_event(struct ath6kl *ar, u8 *ptr, u32 len) struct wmi_ap_mode_stat *p = (struct wmi_ap_mode_stat *) ptr; struct wmi_ap_mode_stat *ap = &ar->ap_stats; struct wmi_per_sta_stat *st_ap, *st_p; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; u8 ac; - if (ar->nw_type == AP_NETWORK) { + if (vif->nw_type == AP_NETWORK) { if (len < sizeof(*p)) return; @@ -1357,7 +1363,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, /* TODO: Findout vif instead of taking it from ar */ struct ath6kl_vif *vif = ar->vif; - if (ar->nw_type == AP_NETWORK) { + if (vif->nw_type == AP_NETWORK) { if (!ath6kl_remove_sta(ar, bssid, prot_reason_status)) return; diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index d1652bd..6b1795c 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -258,7 +258,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) goto fail_tx; /* AP mode Power saving processing */ - if (ar->nw_type == AP_NETWORK) { + if (vif->nw_type == AP_NETWORK) { if (ath6kl_powersave_ap(ar, skb, &more_data)) return 0; } @@ -280,7 +280,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) goto fail_tx; } - if ((ar->nw_type == ADHOC_NETWORK) && + if ((vif->nw_type == ADHOC_NETWORK) && ar->ibss_ps_enable && test_bit(CONNECTED, &vif->flags)) chk_adhoc_ps_mapping = true; else { @@ -450,7 +450,7 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, if (packet->info.tx.tag == ATH6KL_CONTROL_PKT_TAG) return HTC_SEND_FULL_KEEP; - if (ar->nw_type == ADHOC_NETWORK) + if (vif->nw_type == ADHOC_NETWORK) /* * In adhoc mode, we cannot differentiate traffic * priorities so there is no need to continue, however we @@ -484,9 +484,11 @@ stop_net_queues: static void ath6kl_tx_clear_node_map(struct ath6kl *ar, enum htc_endpoint_id eid, u32 map_no) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; u32 i; - if (ar->nw_type != ADHOC_NETWORK) + if (vif->nw_type != ADHOC_NETWORK) return; if (!ar->ibss_ps_enable) @@ -1048,6 +1050,8 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) struct ath6kl_sta *conn = NULL; struct sk_buff *skb1 = NULL; struct ethhdr *datap = NULL; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; u16 seq_no, offset; u8 tid; @@ -1103,7 +1107,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) * that do not have LLC hdr. They are 16 bytes in size. * Allow these frames in the AP mode. */ - if (ar->nw_type != AP_NETWORK && + if (vif->nw_type != AP_NETWORK && ((packet->act_len < min_hdr_len) || (packet->act_len > WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))) { ath6kl_info("frame len is too short or too long\n"); @@ -1114,7 +1118,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) } /* Get the Power save state of the STA */ - if (ar->nw_type == AP_NETWORK) { + if (vif->nw_type == AP_NETWORK) { meta_type = wmi_data_hdr_get_meta(dhdr); ps_state = !!((dhdr->info >> WMI_DATA_HDR_PS_SHIFT) & @@ -1227,7 +1231,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) return; } - if (ar->nw_type == AP_NETWORK) { + if (vif->nw_type == AP_NETWORK) { datap = (struct ethhdr *) skb->data; if (is_multicast_ether_addr(datap->h_dest)) /* diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index a71d773..701d26d 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -504,6 +504,8 @@ static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) u32 freq; u16 dlen; struct ath6kl *ar = wmi->parent_dev; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; if (len < sizeof(*ev)) return -EINVAL; @@ -520,7 +522,7 @@ static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) "probe_req_report=%d\n", dlen, freq, ar->probe_req_report); - if (ar->probe_req_report || ar->nw_type == AP_NETWORK) + if (ar->probe_req_report || vif->nw_type == AP_NETWORK) cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); return 0; @@ -727,13 +729,15 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) struct wmi_connect_event *ev; u8 *pie, *peie; struct ath6kl *ar = wmi->parent_dev; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; if (len < sizeof(struct wmi_connect_event)) return -EINVAL; ev = (struct wmi_connect_event *) datap; - if (ar->nw_type == AP_NETWORK) { + if (vif->nw_type == AP_NETWORK) { /* AP mode start/STA connected event */ struct net_device *dev = ar->net_dev; if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { -- cgit v0.10.2 From 8c8b65e3e3b81d28d185f0a8b6543e42b50a812d Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:04 +0530 Subject: ath6kl: Move bssid information to vif structure Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 37be03b..6671c7b 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -363,7 +363,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->ssid_len == sme->ssid_len && !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { ar->reconnect_flag = true; - status = ath6kl_wmi_reconnect_cmd(ar->wmi, ar->req_bssid, + status = ath6kl_wmi_reconnect_cmd(ar->wmi, vif->req_bssid, ar->ch_hint); up(&ar->sem); @@ -384,9 +384,9 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, if (sme->channel) ar->ch_hint = sme->channel->center_freq; - memset(ar->req_bssid, 0, sizeof(ar->req_bssid)); + memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); if (sme->bssid && !is_broadcast_ether_addr(sme->bssid)) - memcpy(ar->req_bssid, sme->bssid, sizeof(ar->req_bssid)); + memcpy(vif->req_bssid, sme->bssid, sizeof(vif->req_bssid)); ath6kl_set_wpa_version(ar, sme->crypto.wpa_versions); @@ -461,7 +461,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->prwise_crypto_len, vif->grp_crypto, vif->grp_crypto_len, vif->ssid_len, vif->ssid, - ar->req_bssid, ar->ch_hint, + vif->req_bssid, ar->ch_hint, ar->connect_ctrl_flags); up(&ar->sem); @@ -644,7 +644,7 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, vif->ssid_len = 0; if (!test_bit(SKIP_SCAN, &ar->flag)) - memset(ar->req_bssid, 0, sizeof(ar->req_bssid)); + memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); up(&ar->sem); @@ -1071,10 +1071,13 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl *ar, u8 keyid, bool ismcast) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: keyid %d, ismcast %d\n", __func__, keyid, ismcast); - cfg80211_michael_mic_failure(ar->net_dev, ar->bssid, + cfg80211_michael_mic_failure(ar->net_dev, vif->bssid, (ismcast ? NL80211_KEYTYPE_GROUP : NL80211_KEYTYPE_PAIRWISE), keyid, NULL, GFP_KERNEL); @@ -1261,9 +1264,10 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, return -EOPNOTSUPP; } - memset(ar->req_bssid, 0, sizeof(ar->req_bssid)); + memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); if (ibss_param->bssid && !is_broadcast_ether_addr(ibss_param->bssid)) - memcpy(ar->req_bssid, ibss_param->bssid, sizeof(ar->req_bssid)); + memcpy(vif->req_bssid, ibss_param->bssid, + sizeof(vif->req_bssid)); ath6kl_set_wpa_version(ar, 0); @@ -1296,7 +1300,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, vif->prwise_crypto_len, vif->grp_crypto, vif->grp_crypto_len, vif->ssid_len, vif->ssid, - ar->req_bssid, ar->ch_hint, + vif->req_bssid, ar->ch_hint, ar->connect_ctrl_flags); set_bit(CONNECT_PEND, &vif->flags); @@ -1399,7 +1403,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, int ret; u8 mcs; - if (memcmp(mac, ar->bssid, ETH_ALEN) != 0) + if (memcmp(mac, vif->bssid, ETH_ALEN) != 0) return -ENOENT; if (down_interruptible(&ar->sem)) @@ -1509,7 +1513,8 @@ static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) struct ath6kl_vif *vif = netdev_priv(netdev); if (test_bit(CONNECTED, &vif->flags)) - return ath6kl_wmi_setpmkid_cmd(ar->wmi, ar->bssid, NULL, false); + return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->bssid, + NULL, false); return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 714092a..298b339 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -409,6 +409,8 @@ struct ath6kl_vif { u8 def_txkey_index; u8 next_mode; u8 nw_type; + u8 bssid[ETH_ALEN]; + u8 req_bssid[ETH_ALEN]; }; /* Flag info */ @@ -438,8 +440,6 @@ struct ath6kl { spinlock_t lock; struct semaphore sem; struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; - u8 bssid[ETH_ALEN]; - u8 req_bssid[ETH_ALEN]; u16 ch_hint; u16 bss_ch; u16 listen_intvl_b; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 39cd6c7..0819dbd 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -88,8 +88,8 @@ void ath6kl_init_profile_info(struct ath6kl *ar) vif->grp_crypto = NONE_CRYPT; vif->grp_crypto_len = 0; memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); - memset(ar->req_bssid, 0, sizeof(ar->req_bssid)); - memset(ar->bssid, 0, sizeof(ar->bssid)); + memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); + memset(vif->bssid, 0, sizeof(vif->bssid)); ar->bss_ch = 0; vif->nw_type = vif->next_mode = INFRA_NETWORK; } diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 4add0ef..bdefb89 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -464,7 +464,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, if (discon_issued) ath6kl_disconnect_event(ar, DISCONNECT_CMD, (vif->nw_type & AP_NETWORK) ? - bcast_mac : ar->bssid, + bcast_mac : vif->bssid, 0, NULL, 0); ar->user_key_ctrl = 0; @@ -943,7 +943,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) switch (ar->sme_state) { case SME_CONNECTING: - cfg80211_connect_result(ar->net_dev, ar->bssid, NULL, 0, + cfg80211_connect_result(ar->net_dev, vif->bssid, NULL, 0, NULL, 0, WLAN_STATUS_UNSPECIFIED_FAILURE, GFP_KERNEL); @@ -1057,7 +1057,7 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, assoc_req_len, assoc_resp_len, assoc_info); - memcpy(ar->bssid, bssid, sizeof(ar->bssid)); + memcpy(vif->bssid, bssid, sizeof(vif->bssid)); ar->bss_ch = channel; if ((vif->nw_type == INFRA_NETWORK)) @@ -1433,7 +1433,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, ar->user_key_ctrl = 0; netif_stop_queue(ar->net_dev); - memset(ar->bssid, 0, sizeof(ar->bssid)); + memset(vif->bssid, 0, sizeof(vif->bssid)); ar->bss_ch = 0; ath6kl_tx_data_cleanup(ar); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 701d26d..2f4e8b5 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -988,7 +988,7 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) return -EINVAL; if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags) - && memcmp(bih->bssid, ar->bssid, ETH_ALEN) == 0) { + && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { const u8 *tim; tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, len - 8 - 2 - 2); -- cgit v0.10.2 From f74bac54a507a1b71be352d422b25cb5fd38db54 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:05 +0530 Subject: ath6kl: Move channel information to vif structure Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 6671c7b..33da58c 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -364,7 +364,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { ar->reconnect_flag = true; status = ath6kl_wmi_reconnect_cmd(ar->wmi, vif->req_bssid, - ar->ch_hint); + vif->ch_hint); up(&ar->sem); if (status) { @@ -382,7 +382,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, memcpy(vif->ssid, sme->ssid, sme->ssid_len); if (sme->channel) - ar->ch_hint = sme->channel->center_freq; + vif->ch_hint = sme->channel->center_freq; memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); if (sme->bssid && !is_broadcast_ether_addr(sme->bssid)) @@ -452,7 +452,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, __func__, vif->auth_mode, vif->dot11_auth_mode, vif->prwise_crypto, vif->prwise_crypto_len, vif->grp_crypto, - vif->grp_crypto_len, ar->ch_hint); + vif->grp_crypto_len, vif->ch_hint); ar->reconnect_flag = 0; status = ath6kl_wmi_connect_cmd(ar->wmi, vif->nw_type, @@ -461,7 +461,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->prwise_crypto_len, vif->grp_crypto, vif->grp_crypto_len, vif->ssid_len, vif->ssid, - vif->req_bssid, ar->ch_hint, + vif->req_bssid, vif->ch_hint, ar->connect_ctrl_flags); up(&ar->sem); @@ -1252,7 +1252,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, memcpy(vif->ssid, ibss_param->ssid, vif->ssid_len); if (ibss_param->channel) - ar->ch_hint = ibss_param->channel->center_freq; + vif->ch_hint = ibss_param->channel->center_freq; if (ibss_param->channel_fixed) { /* @@ -1292,7 +1292,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, __func__, vif->auth_mode, vif->dot11_auth_mode, vif->prwise_crypto, vif->prwise_crypto_len, vif->grp_crypto, - vif->grp_crypto_len, ar->ch_hint); + vif->grp_crypto_len, vif->ch_hint); status = ath6kl_wmi_connect_cmd(ar->wmi, vif->nw_type, vif->dot11_auth_mode, vif->auth_mode, @@ -1300,7 +1300,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, vif->prwise_crypto_len, vif->grp_crypto, vif->grp_crypto_len, vif->ssid_len, vif->ssid, - vif->req_bssid, ar->ch_hint, + vif->req_bssid, vif->ch_hint, ar->connect_ctrl_flags); set_bit(CONNECT_PEND, &vif->flags); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 298b339..ab33244 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -411,6 +411,8 @@ struct ath6kl_vif { u8 nw_type; u8 bssid[ETH_ALEN]; u8 req_bssid[ETH_ALEN]; + u16 ch_hint; + u16 bss_ch; }; /* Flag info */ @@ -440,8 +442,6 @@ struct ath6kl { spinlock_t lock; struct semaphore sem; struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; - u16 ch_hint; - u16 bss_ch; u16 listen_intvl_b; u16 listen_intvl_t; u8 lrssi_roam_threshold; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 0819dbd..cab43c2 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -90,7 +90,7 @@ void ath6kl_init_profile_info(struct ath6kl *ar) memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); memset(vif->bssid, 0, sizeof(vif->bssid)); - ar->bss_ch = 0; + vif->bss_ch = 0; vif->nw_type = vif->next_mode = INFRA_NETWORK; } @@ -253,7 +253,7 @@ void ath6kl_init_control_info(struct ath6kl *ar) ath6kl_init_profile_info(ar); vif->def_txkey_index = 0; memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); - ar->ch_hint = 0; + vif->ch_hint = 0; } /* diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index bdefb89..15838de 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1058,7 +1058,7 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, assoc_info); memcpy(vif->bssid, bssid, sizeof(vif->bssid)); - ar->bss_ch = channel; + vif->bss_ch = channel; if ((vif->nw_type == INFRA_NETWORK)) ath6kl_wmi_listeninterval_cmd(ar->wmi, ar->listen_intvl_t, @@ -1434,7 +1434,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, netif_stop_queue(ar->net_dev); memset(vif->bssid, 0, sizeof(vif->bssid)); - ar->bss_ch = 0; + vif->bss_ch = 0; ath6kl_tx_data_cleanup(ar); } -- cgit v0.10.2 From 6f2a73f9e5c7013e14cf898fead81a363cdf0548 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:06 +0530 Subject: ath6kl: Move key information to vif structure Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 33da58c..a5c0a58 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -419,7 +419,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return -ENOENT; } - key = &ar->keys[sme->key_idx]; + key = &vif->keys[sme->key_idx]; key->key_len = sme->key_len; memcpy(key->key, sme->key, key->key_len); key->cipher = vif->prwise_crypto; @@ -856,7 +856,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, return -ENOENT; } - key = &ar->keys[key_index]; + key = &vif->keys[key_index]; memset(key, 0, sizeof(struct ath6kl_key)); if (pairwise) @@ -934,8 +934,9 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, */ ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delay WEP key configuration " "until AP mode has been started\n"); - ar->wep_key_list[key_index].key_len = key->key_len; - memcpy(ar->wep_key_list[key_index].key, key->key, key->key_len); + vif->wep_key_list[key_index].key_len = key->key_len; + memcpy(vif->wep_key_list[key_index].key, key->key, + key->key_len); return 0; } @@ -955,6 +956,7 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, const u8 *mac_addr) { struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev); + struct ath6kl_vif *vif = netdev_priv(ndev); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index); @@ -968,13 +970,13 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, return -ENOENT; } - if (!ar->keys[key_index].key_len) { + if (!vif->keys[key_index].key_len) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d is empty\n", __func__, key_index); return 0; } - ar->keys[key_index].key_len = 0; + vif->keys[key_index].key_len = 0; return ath6kl_wmi_deletekey_cmd(ar->wmi, key_index); } @@ -986,6 +988,7 @@ static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, struct key_params *)) { struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev); + struct ath6kl_vif *vif = netdev_priv(ndev); struct ath6kl_key *key = NULL; struct key_params params; @@ -1001,7 +1004,7 @@ static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, return -ENOENT; } - key = &ar->keys[key_index]; + key = &vif->keys[key_index]; memset(¶ms, 0, sizeof(params)); params.cipher = key->cipher; params.key_len = key->key_len; @@ -1038,14 +1041,14 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, return -ENOENT; } - if (!ar->keys[key_index].key_len) { + if (!vif->keys[key_index].key_len) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: invalid key index %d\n", __func__, key_index); return -EINVAL; } vif->def_txkey_index = key_index; - key = &ar->keys[vif->def_txkey_index]; + key = &vif->keys[vif->def_txkey_index]; key_usage = GROUP_USAGE; if (vif->prwise_crypto == WEP_CRYPT) key_usage |= TX_USAGE; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index ab33244..dc21d7a 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -413,6 +413,8 @@ struct ath6kl_vif { u8 req_bssid[ETH_ALEN]; u16 ch_hint; u16 bss_ch; + struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; + struct ath6kl_key keys[WMI_MAX_KEY_INDEX + 1]; }; /* Flag info */ @@ -441,7 +443,6 @@ struct ath6kl { struct ath6kl_vif *vif; spinlock_t lock; struct semaphore sem; - struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; u16 listen_intvl_b; u16 listen_intvl_t; u8 lrssi_roam_threshold; @@ -480,7 +481,6 @@ struct ath6kl { u8 rx_meta_ver; struct wireless_dev *wdev; struct cfg80211_scan_request *scan_req; - struct ath6kl_key keys[WMI_MAX_KEY_INDEX + 1]; enum sme_state sme_state; enum wlan_low_pwr_state wlan_pwr_state; struct wmi_scan_params_cmd sc_params; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index cab43c2..dd63408 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -87,7 +87,7 @@ void ath6kl_init_profile_info(struct ath6kl *ar) vif->prwise_crypto_len = 0; vif->grp_crypto = NONE_CRYPT; vif->grp_crypto_len = 0; - memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); + memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list)); memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); memset(vif->bssid, 0, sizeof(vif->bssid)); vif->bss_ch = 0; @@ -248,11 +248,12 @@ static int ath6kl_init_service_ep(struct ath6kl *ar) void ath6kl_init_control_info(struct ath6kl *ar) { + /* TODO: Findout vif */ struct ath6kl_vif *vif = ar->vif; ath6kl_init_profile_info(ar); vif->def_txkey_index = 0; - memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); + memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list)); vif->ch_hint = 0; } diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 15838de..eb2137c 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -506,7 +506,7 @@ static void ath6kl_install_static_wep_keys(struct ath6kl *ar) u8 keyusage; for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) { - if (ar->wep_key_list[index].key_len) { + if (vif->wep_key_list[index].key_len) { keyusage = GROUP_USAGE; if (index == vif->def_txkey_index) keyusage |= TX_USAGE; @@ -515,9 +515,9 @@ static void ath6kl_install_static_wep_keys(struct ath6kl *ar) index, WEP_CRYPT, keyusage, - ar->wep_key_list[index].key_len, + vif->wep_key_list[index].key_len, NULL, - ar->wep_key_list[index].key, + vif->wep_key_list[index].key, KEY_OP_INIT_VAL, NULL, NO_SYNC_WMIFLAG); } @@ -1384,7 +1384,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, } if (memcmp(ar->net_dev->dev_addr, bssid, ETH_ALEN) == 0) { - memset(ar->wep_key_list, 0, sizeof(ar->wep_key_list)); + memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list)); clear_bit(CONNECTED, &vif->flags); } return; -- cgit v0.10.2 From 2132c69cb9efaf2b7300f6da916ab5f96c9c95b7 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:07 +0530 Subject: ath6kl: Move aggregation information to vif structure Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index a5c0a58..d08f755 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2064,8 +2064,8 @@ static int ath6kl_init_if_data(struct ath6kl_vif *vif) { struct ath6kl *ar = vif->ar; - ar->aggr_cntxt = aggr_init(vif->ndev); - if (!ar->aggr_cntxt) { + vif->aggr_cntxt = aggr_init(vif->ndev); + if (!vif->aggr_cntxt) { ath6kl_err("failed to initialize aggr\n"); return -ENOMEM; } @@ -2078,11 +2078,9 @@ static int ath6kl_init_if_data(struct ath6kl_vif *vif) void ath6kl_deinit_if_data(struct ath6kl_vif *vif) { - struct ath6kl *ar = vif->ar; - - aggr_module_destroy(ar->aggr_cntxt); + aggr_module_destroy(vif->aggr_cntxt); - ar->aggr_cntxt = NULL; + vif->aggr_cntxt = NULL; if (test_bit(NETDEV_REGISTERED, &vif->flags)) { unregister_netdev(vif->ndev); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index dc21d7a..f15dd6d 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -415,6 +415,7 @@ struct ath6kl_vif { u16 bss_ch; struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; struct ath6kl_key keys[WMI_MAX_KEY_INDEX + 1]; + struct aggr_info *aggr_cntxt; }; /* Flag info */ @@ -473,7 +474,6 @@ struct ath6kl { struct sk_buff_head mcastpsq; spinlock_t mcastpsq_lock; u8 intra_bss; - struct aggr_info *aggr_cntxt; struct wmi_ap_mode_stat ap_stats; u8 ap_country_code[3]; struct list_head amsdu_rx_buffer_queue; diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index eb2137c..0bdb73c 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1073,7 +1073,7 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, netif_carrier_on(ar->net_dev); spin_unlock_bh(&ar->lock); - aggr_reset_state(ar->aggr_cntxt); + aggr_reset_state(vif->aggr_cntxt); ar->reconnect_flag = 0; if ((vif->nw_type == ADHOC_NETWORK) && ar->ibss_ps_enable) { @@ -1394,7 +1394,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, assoc_resp_len, assoc_info, prot_reason_status); - aggr_reset_state(ar->aggr_cntxt); + aggr_reset_state(vif->aggr_cntxt); del_timer(&ar->disconnect_timer); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 6b1795c..ba1678e 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1268,7 +1268,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) datap = (struct ethhdr *) skb->data; if (is_unicast_ether_addr(datap->h_dest) && - aggr_process_recv_frm(ar->aggr_cntxt, tid, seq_no, + aggr_process_recv_frm(vif->aggr_cntxt, tid, seq_no, is_amsdu, skb)) /* aggregation code will handle the skb */ return; @@ -1353,7 +1353,9 @@ static void aggr_delete_tid_state(struct aggr_info *p_aggr, u8 tid) void aggr_recv_addba_req_evt(struct ath6kl *ar, u8 tid, u16 seq_no, u8 win_sz) { - struct aggr_info *p_aggr = ar->aggr_cntxt; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + struct aggr_info *p_aggr = vif->aggr_cntxt; struct rxtid *rxtid; struct rxtid_stats *stats; u16 hold_q_size; @@ -1422,7 +1424,9 @@ struct aggr_info *aggr_init(struct net_device *dev) void aggr_recv_delba_req_evt(struct ath6kl *ar, u8 tid) { - struct aggr_info *p_aggr = ar->aggr_cntxt; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + struct aggr_info *p_aggr = vif->aggr_cntxt; struct rxtid *rxtid; if (!p_aggr) -- cgit v0.10.2 From de3ad7138c853fb3f5c239a40e0228bd94d583e7 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:08 +0530 Subject: ath6kl: Move disconnect timer to vif structure Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d08f755..48a70bc 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -479,7 +479,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, if ((!(ar->connect_ctrl_flags & CONNECT_DO_WPA_OFFLOAD)) && ((vif->auth_mode == WPA_PSK_AUTH) || (vif->auth_mode == WPA2_PSK_AUTH))) { - mod_timer(&ar->disconnect_timer, + mod_timer(&vif->disconnect_timer, jiffies + msecs_to_jiffies(DISCON_TIMER_INTVAL)); } @@ -897,7 +897,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, if (((vif->auth_mode == WPA_PSK_AUTH) || (vif->auth_mode == WPA2_PSK_AUTH)) && (key_usage & GROUP_USAGE)) - del_timer(&ar->disconnect_timer); + del_timer(&vif->disconnect_timer); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d, key_len %d, key_type 0x%x, key_usage 0x%x, seq_len %d\n", @@ -2062,16 +2062,15 @@ int ath6kl_register_ieee80211_hw(struct ath6kl *ar) static int ath6kl_init_if_data(struct ath6kl_vif *vif) { - struct ath6kl *ar = vif->ar; - vif->aggr_cntxt = aggr_init(vif->ndev); if (!vif->aggr_cntxt) { ath6kl_err("failed to initialize aggr\n"); return -ENOMEM; } - setup_timer(&ar->disconnect_timer, disconnect_timer_handler, + setup_timer(&vif->disconnect_timer, disconnect_timer_handler, (unsigned long) vif->ndev); + set_bit(WMM_ENABLED, &vif->flags); return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f15dd6d..5403116 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -416,6 +416,7 @@ struct ath6kl_vif { struct ath6kl_wep_key wep_key_list[WMI_MAX_KEY_INDEX + 1]; struct ath6kl_key keys[WMI_MAX_KEY_INDEX + 1]; struct aggr_info *aggr_cntxt; + struct timer_list disconnect_timer; }; /* Flag info */ @@ -477,7 +478,6 @@ struct ath6kl { struct wmi_ap_mode_stat ap_stats; u8 ap_country_code[3]; struct list_head amsdu_rx_buffer_queue; - struct timer_list disconnect_timer; u8 rx_meta_ver; struct wireless_dev *wdev; struct cfg80211_scan_request *scan_req; diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 0bdb73c..d292e17 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -445,7 +445,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, if (!keep_profile) ath6kl_init_profile_info(ar); - del_timer(&ar->disconnect_timer); + del_timer(&vif->disconnect_timer); clear_bit(WMI_READY, &ar->flag); ath6kl_wmi_shutdown(ar->wmi); @@ -1396,7 +1396,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, aggr_reset_state(vif->aggr_cntxt); - del_timer(&ar->disconnect_timer); + del_timer(&vif->disconnect_timer); ath6kl_dbg(ATH6KL_DBG_WLAN_CONNECT, "disconnect reason is %d\n", reason); -- cgit v0.10.2 From 14ee6f6b7db968229edb7524588e71182c843080 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:09 +0530 Subject: ath6kl: Move scan_req info and sme_state to vif Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 48a70bc..803fb63 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -311,7 +311,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct ath6kl_vif *vif = netdev_priv(dev); int status; - ar->sme_state = SME_CONNECTING; + vif->sme_state = SME_CONNECTING; if (!ath6kl_cfg80211_ready(ar)) return -EIO; @@ -601,14 +601,14 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, return; } - if (ar->sme_state == SME_CONNECTING) { + if (vif->sme_state == SME_CONNECTING) { /* inform connect result to cfg80211 */ - ar->sme_state = SME_CONNECTED; + vif->sme_state = SME_CONNECTED; cfg80211_connect_result(ar->net_dev, bssid, assoc_req_ie, assoc_req_len, assoc_resp_ie, assoc_resp_len, WLAN_STATUS_SUCCESS, GFP_KERNEL); - } else if (ar->sme_state == SME_CONNECTED) { + } else if (vif->sme_state == SME_CONNECTED) { /* inform roam event to cfg80211 */ cfg80211_roamed(ar->net_dev, chan, bssid, assoc_req_ie, assoc_req_len, @@ -648,7 +648,7 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, up(&ar->sem); - ar->sme_state = SME_DISCONNECTED; + vif->sme_state = SME_DISCONNECTED; return 0; } @@ -660,9 +660,9 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, /* TODO: Findout vif */ struct ath6kl_vif *vif = ar->vif; - if (ar->scan_req) { - cfg80211_scan_done(ar->scan_req, true); - ar->scan_req = NULL; + if (vif->scan_req) { + cfg80211_scan_done(vif->scan_req, true); + vif->scan_req = NULL; } if (vif->nw_type & ADHOC_NETWORK) { @@ -701,18 +701,18 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, clear_bit(CONNECT_PEND, &vif->flags); - if (ar->sme_state == SME_CONNECTING) { + if (vif->sme_state == SME_CONNECTING) { cfg80211_connect_result(ar->net_dev, bssid, NULL, 0, NULL, 0, WLAN_STATUS_UNSPECIFIED_FAILURE, GFP_KERNEL); - } else if (ar->sme_state == SME_CONNECTED) { + } else if (vif->sme_state == SME_CONNECTED) { cfg80211_disconnected(ar->net_dev, reason, NULL, 0, GFP_KERNEL); } - ar->sme_state = SME_DISCONNECTED; + vif->sme_state = SME_DISCONNECTED; } static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, @@ -793,7 +793,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, if (ret) ath6kl_err("wmi_startscan_cmd failed\n"); else - ar->scan_req = request; + vif->scan_req = request; kfree(channels); @@ -802,22 +802,24 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, void ath6kl_cfg80211_scan_complete_event(struct ath6kl *ar, int status) { + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; int i; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: status %d\n", __func__, status); - if (!ar->scan_req) + if (!vif->scan_req) return; if ((status == -ECANCELED) || (status == -EBUSY)) { - cfg80211_scan_done(ar->scan_req, true); + cfg80211_scan_done(vif->scan_req, true); goto out; } - cfg80211_scan_done(ar->scan_req, false); + cfg80211_scan_done(vif->scan_req, false); - if (ar->scan_req->n_ssids && ar->scan_req->ssids[0].ssid_len) { - for (i = 0; i < ar->scan_req->n_ssids; i++) { + if (vif->scan_req->n_ssids && vif->scan_req->ssids[0].ssid_len) { + for (i = 0; i < vif->scan_req->n_ssids; i++) { ath6kl_wmi_probedssid_cmd(ar->wmi, i + 1, DISABLE_SSID_FLAG, 0, NULL); @@ -825,7 +827,7 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl *ar, int status) } out: - ar->scan_req = NULL; + vif->scan_req = NULL; } static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, @@ -2122,7 +2124,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, if (register_netdev(ndev)) goto err; - ar->sme_state = SME_DISCONNECTED; + vif->sme_state = SME_DISCONNECTED; set_bit(WLAN_ENABLED, &vif->flags); ar->wlan_pwr_state = WLAN_POWER_STATE_ON; set_bit(NETDEV_REGISTERED, &vif->flags); @@ -2137,9 +2139,12 @@ err: void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar) { - if (ar->scan_req) { - cfg80211_scan_done(ar->scan_req, true); - ar->scan_req = NULL; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + + if (vif->scan_req) { + cfg80211_scan_done(vif->scan_req, true); + vif->scan_req = NULL; } wiphy_unregister(ar->wiphy); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 5403116..e949a3b 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -417,6 +417,8 @@ struct ath6kl_vif { struct ath6kl_key keys[WMI_MAX_KEY_INDEX + 1]; struct aggr_info *aggr_cntxt; struct timer_list disconnect_timer; + struct cfg80211_scan_request *scan_req; + enum sme_state sme_state; }; /* Flag info */ @@ -480,8 +482,6 @@ struct ath6kl { struct list_head amsdu_rx_buffer_queue; u8 rx_meta_ver; struct wireless_dev *wdev; - struct cfg80211_scan_request *scan_req; - enum sme_state sme_state; enum wlan_low_pwr_state wlan_pwr_state; struct wmi_scan_params_cmd sc_params; #define AR_MCAST_FILTER_MAC_ADDR_SIZE 4 diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index d292e17..204901d 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -941,7 +941,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) /* TODO: Pass vif instead of taking it from ar */ struct ath6kl_vif *vif = ar->vif; - switch (ar->sme_state) { + switch (vif->sme_state) { case SME_CONNECTING: cfg80211_connect_result(ar->net_dev, vif->bssid, NULL, 0, NULL, 0, @@ -963,7 +963,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) test_bit(CONNECT_PEND, &vif->flags)) ath6kl_wmi_disconnect_cmd(ar->wmi); - ar->sme_state = SME_DISCONNECTED; + vif->sme_state = SME_DISCONNECTED; /* disable scanning */ if (ath6kl_wmi_scanparams_cmd(ar->wmi, 0xFFFF, 0, 0, 0, 0, 0, 0, 0, -- cgit v0.10.2 From cf5333d70f822d950f0c2f4bec7a8939871d9b6a Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:10 +0530 Subject: ath6kl: Move few more vif specific information to struct ath6kl_vif Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 803fb63..06a7c4f 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -362,7 +362,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, if (test_bit(CONNECTED, &vif->flags) && vif->ssid_len == sme->ssid_len && !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { - ar->reconnect_flag = true; + vif->reconnect_flag = true; status = ath6kl_wmi_reconnect_cmd(ar->wmi, vif->req_bssid, vif->ch_hint); @@ -454,7 +454,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->prwise_crypto_len, vif->grp_crypto, vif->grp_crypto_len, vif->ch_hint); - ar->reconnect_flag = 0; + vif->reconnect_flag = 0; status = ath6kl_wmi_connect_cmd(ar->wmi, vif->nw_type, vif->dot11_auth_mode, vif->auth_mode, vif->prwise_crypto, @@ -566,7 +566,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, * Store Beacon interval here; DTIM period will be available only once * a Beacon frame from the AP is seen. */ - ar->assoc_bss_beacon_int = beacon_intvl; + vif->assoc_bss_beacon_int = beacon_intvl; clear_bit(DTIM_PERIOD_AVAIL, &vif->flags); if (nw_type & ADHOC_NETWORK) { @@ -638,7 +638,7 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, return -ERESTARTSYS; } - ar->reconnect_flag = 0; + vif->reconnect_flag = 0; ath6kl_disconnect(ar); memset(vif->ssid, 0, sizeof(vif->ssid)); vif->ssid_len = 0; @@ -1489,8 +1489,8 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, vif->nw_type == INFRA_NETWORK) { sinfo->filled |= STATION_INFO_BSS_PARAM; sinfo->bss_param.flags = 0; - sinfo->bss_param.dtim_period = ar->assoc_bss_dtim_period; - sinfo->bss_param.beacon_interval = ar->assoc_bss_beacon_int; + sinfo->bss_param.dtim_period = vif->assoc_bss_dtim_period; + sinfo->bss_param.beacon_interval = vif->assoc_bss_beacon_int; } return 0; @@ -1545,13 +1545,14 @@ static int ath6kl_set_channel(struct wiphy *wiphy, struct net_device *dev, enum nl80211_channel_type channel_type) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); if (!ath6kl_cfg80211_ready(ar)) return -EIO; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: center_freq=%u hw_value=%u\n", __func__, chan->center_freq, chan->hw_value); - ar->next_chan = chan->center_freq; + vif->next_chan = chan->center_freq; return 0; } @@ -1731,7 +1732,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, p.ssid_len = vif->ssid_len; memcpy(p.ssid, vif->ssid, vif->ssid_len); p.dot11_auth_mode = vif->dot11_auth_mode; - p.ch = cpu_to_le16(ar->next_chan); + p.ch = cpu_to_le16(vif->next_chan); res = ath6kl_wmi_ap_profile_commit(ar->wmi, &p); if (res < 0) @@ -1877,13 +1878,13 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, chan->center_freq); } - id = ar->send_action_id++; + id = vif->send_action_id++; if (id == 0) { /* * 0 is a reserved value in the WMI command and shall not be * used for the command. */ - id = ar->send_action_id++; + id = vif->send_action_id++; } *cookie = id; @@ -1895,7 +1896,7 @@ static void ath6kl_mgmt_frame_register(struct wiphy *wiphy, struct net_device *dev, u16 frame_type, bool reg) { - struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: frame_type=0x%x reg=%d\n", __func__, frame_type, reg); @@ -1905,7 +1906,7 @@ static void ath6kl_mgmt_frame_register(struct wiphy *wiphy, * we cannot send WMI_PROBE_REQ_REPORT_CMD here. Instead, we * hardcode target to report Probe Request frames all the time. */ - ar->probe_req_report = reg; + vif->probe_req_report = reg; } } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index e949a3b..ba780eb 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -419,6 +419,12 @@ struct ath6kl_vif { struct timer_list disconnect_timer; struct cfg80211_scan_request *scan_req; enum sme_state sme_state; + int reconnect_flag; + u32 send_action_id; + bool probe_req_report; + u16 next_chan; + u16 assoc_bss_beacon_int; + u8 assoc_bss_dtim_period; }; /* Flag info */ @@ -503,7 +509,6 @@ struct ath6kl { struct ath6kl_mbox_info mbox_info; struct ath6kl_cookie cookie_mem[MAX_COOKIE_NUM]; - int reconnect_flag; unsigned long flag; u8 *fw_board; @@ -524,13 +529,7 @@ struct ath6kl { struct dentry *debugfs_phy; - u32 send_action_id; - bool probe_req_report; - u16 next_chan; - bool p2p; - u16 assoc_bss_beacon_int; - u8 assoc_bss_dtim_period; #ifdef CONFIG_ATH6KL_DEBUG struct { diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 204901d..b91ac7e 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1074,7 +1074,7 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, spin_unlock_bh(&ar->lock); aggr_reset_state(vif->aggr_cntxt); - ar->reconnect_flag = 0; + vif->reconnect_flag = 0; if ((vif->nw_type == ADHOC_NETWORK) && ar->ibss_ps_enable) { memset(ar->node_map, 0, sizeof(ar->node_map)); @@ -1414,7 +1414,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, if (((reason == ASSOC_FAILED) && (prot_reason_status == 0x11)) || ((reason == ASSOC_FAILED) && (prot_reason_status == 0x0) - && (ar->reconnect_flag == 1))) { + && (vif->reconnect_flag == 1))) { set_bit(CONNECTED, &vif->flags); return; } @@ -1426,8 +1426,8 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, netif_carrier_off(ar->net_dev); spin_unlock_bh(&ar->lock); - if ((reason != CSERV_DISCONNECT) || (ar->reconnect_flag != 1)) - ar->reconnect_flag = 0; + if ((reason != CSERV_DISCONNECT) || (vif->reconnect_flag != 1)) + vif->reconnect_flag = 0; if (reason != CSERV_DISCONNECT) ar->user_key_ctrl = 0; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 2f4e8b5..8e7e7b5 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -520,9 +520,9 @@ static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) } ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " "probe_req_report=%d\n", - dlen, freq, ar->probe_req_report); + dlen, freq, vif->probe_req_report); - if (ar->probe_req_report || vif->nw_type == AP_NETWORK) + if (vif->probe_req_report || vif->nw_type == AP_NETWORK) cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); return 0; @@ -993,7 +993,7 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, len - 8 - 2 - 2); if (tim && tim[1] >= 2) { - ar->assoc_bss_dtim_period = tim[3]; + vif->assoc_bss_dtim_period = tim[3]; set_bit(DTIM_PERIOD_AVAIL, &vif->flags); } } -- cgit v0.10.2 From b95907a744fb2afe282cebd9b58371533818fbae Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:11 +0530 Subject: ath6kl: Make net and target stats vif specific Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 06a7c4f..aa40d39 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1414,7 +1414,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, if (down_interruptible(&ar->sem)) return -EBUSY; - set_bit(STATS_UPDATE_PEND, &ar->flag); + set_bit(STATS_UPDATE_PEND, &vif->flags); ret = ath6kl_wmi_get_stats_cmd(ar->wmi); @@ -1425,7 +1425,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, left = wait_event_interruptible_timeout(ar->event_wq, !test_bit(STATS_UPDATE_PEND, - &ar->flag), + &vif->flags), WMI_TIMEOUT); up(&ar->sem); @@ -1435,24 +1435,24 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, else if (left < 0) return left; - if (ar->target_stats.rx_byte) { - sinfo->rx_bytes = ar->target_stats.rx_byte; + if (vif->target_stats.rx_byte) { + sinfo->rx_bytes = vif->target_stats.rx_byte; sinfo->filled |= STATION_INFO_RX_BYTES; - sinfo->rx_packets = ar->target_stats.rx_pkt; + sinfo->rx_packets = vif->target_stats.rx_pkt; sinfo->filled |= STATION_INFO_RX_PACKETS; } - if (ar->target_stats.tx_byte) { - sinfo->tx_bytes = ar->target_stats.tx_byte; + if (vif->target_stats.tx_byte) { + sinfo->tx_bytes = vif->target_stats.tx_byte; sinfo->filled |= STATION_INFO_TX_BYTES; - sinfo->tx_packets = ar->target_stats.tx_pkt; + sinfo->tx_packets = vif->target_stats.tx_pkt; sinfo->filled |= STATION_INFO_TX_PACKETS; } - sinfo->signal = ar->target_stats.cs_rssi; + sinfo->signal = vif->target_stats.cs_rssi; sinfo->filled |= STATION_INFO_SIGNAL; - rate = ar->target_stats.tx_ucast_rate; + rate = vif->target_stats.tx_ucast_rate; if (is_rate_legacy(rate)) { sinfo->txrate.legacy = rate / 100; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index ba780eb..41d6ae0 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -391,6 +391,7 @@ enum ath6kl_vif_state { CLEAR_BSSFILTER_ON_BEACON, DTIM_PERIOD_AVAIL, WLAN_ENABLED, + STATS_UPDATE_PEND, }; struct ath6kl_vif { @@ -425,6 +426,8 @@ struct ath6kl_vif { u16 next_chan; u16 assoc_bss_beacon_int; u8 assoc_bss_dtim_period; + struct net_device_stats net_stats; + struct target_stats target_stats; }; /* Flag info */ @@ -435,7 +438,6 @@ enum ath6kl_dev_state { TESTMODE, DESTROY_IN_PROGRESS, SKIP_SCAN, - STATS_UPDATE_PEND, ROAM_TBL_PEND, }; @@ -459,8 +461,6 @@ struct ath6kl { struct ath6kl_version version; u32 target_type; u8 tx_pwr; - struct net_device_stats net_stats; - struct target_stats target_stats; struct ath6kl_node_mapping node_map[MAX_NODE_NUM]; u8 ibss_ps_enable; u8 node_num; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index f067c7b..9a89b42 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -397,7 +397,9 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct ath6kl *ar = file->private_data; - struct target_stats *tgt_stats = &ar->target_stats; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + struct target_stats *tgt_stats = &vif->target_stats; char *buf; unsigned int len = 0, buf_len = 1500; int i; @@ -413,7 +415,7 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf, return -EBUSY; } - set_bit(STATS_UPDATE_PEND, &ar->flag); + set_bit(STATS_UPDATE_PEND, &vif->flags); if (ath6kl_wmi_get_stats_cmd(ar->wmi)) { up(&ar->sem); @@ -423,7 +425,7 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf, left = wait_event_interruptible_timeout(ar->event_wq, !test_bit(STATS_UPDATE_PEND, - &ar->flag), WMI_TIMEOUT); + &vif->flags), WMI_TIMEOUT); up(&ar->sem); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index b91ac7e..fff1f4a 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1119,7 +1119,9 @@ static void ath6kl_update_target_stats(struct ath6kl *ar, u8 *ptr, u32 len) { struct wmi_target_stats *tgt_stats = (struct wmi_target_stats *) ptr; - struct target_stats *stats = &ar->target_stats; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; + struct target_stats *stats = &vif->target_stats; struct tkip_ccmp_stats *ccmp_stats; u8 ac; @@ -1215,8 +1217,8 @@ static void ath6kl_update_target_stats(struct ath6kl *ar, u8 *ptr, u32 len) stats->wow_evt_discarded += le16_to_cpu(tgt_stats->wow_stats.wow_evt_discarded); - if (test_bit(STATS_UPDATE_PEND, &ar->flag)) { - clear_bit(STATS_UPDATE_PEND, &ar->flag); + if (test_bit(STATS_UPDATE_PEND, &vif->flags)) { + clear_bit(STATS_UPDATE_PEND, &vif->flags); wake_up(&ar->event_wq); } } @@ -1483,9 +1485,9 @@ static int ath6kl_close(struct net_device *dev) static struct net_device_stats *ath6kl_get_stats(struct net_device *dev) { - struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); - return &ar->net_stats; + return &vif->net_stats; } static struct net_device_ops ath6kl_netdev_ops = { diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index ba1678e..cada197 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -357,8 +357,8 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) fail_tx: dev_kfree_skb(skb); - ar->net_stats.tx_dropped++; - ar->net_stats.tx_aborted_errors++; + vif->net_stats.tx_dropped++; + vif->net_stats.tx_aborted_errors++; return 0; } @@ -583,7 +583,7 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) /* a packet was flushed */ flushing = true; - ar->net_stats.tx_errors++; + vif->net_stats.tx_errors++; if (status != -ENOSPC) ath6kl_err("tx error, status: 0x%x\n", status); @@ -598,8 +598,8 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) eid, "OK"); flushing = false; - ar->net_stats.tx_packets++; - ar->net_stats.tx_bytes += skb->len; + vif->net_stats.tx_packets++; + vif->net_stats.tx_bytes += skb->len; } ath6kl_tx_clear_node_map(ar, eid, map_no); @@ -1061,7 +1061,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) packet->act_len, status); if (status || !(skb->data + HTC_HDR_LENGTH)) { - ar->net_stats.rx_errors++; + vif->net_stats.rx_errors++; dev_kfree_skb(skb); return; } @@ -1072,8 +1072,8 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) */ spin_lock_bh(&ar->lock); - ar->net_stats.rx_packets++; - ar->net_stats.rx_bytes += packet->act_len; + vif->net_stats.rx_packets++; + vif->net_stats.rx_bytes += packet->act_len; spin_unlock_bh(&ar->lock); @@ -1111,8 +1111,8 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) ((packet->act_len < min_hdr_len) || (packet->act_len > WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))) { ath6kl_info("frame len is too short or too long\n"); - ar->net_stats.rx_errors++; - ar->net_stats.rx_length_errors++; + vif->net_stats.rx_errors++; + vif->net_stats.rx_length_errors++; dev_kfree_skb(skb); return; } -- cgit v0.10.2 From 334234b51453fe5def250bd60ea63b1f04a8e0d2 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:12 +0530 Subject: ath6kl: Maintain firmware interface index in struct ath6kl_vif Pass this index to target in wmi commands to specify the interface for which the command needs to be handled. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index aa40d39..54679f2 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -269,9 +269,10 @@ static bool ath6kl_is_rsn_ie(const u8 *pos) return pos[0] == WLAN_EID_RSN; } -static int ath6kl_set_assoc_req_ies(struct ath6kl *ar, const u8 *ies, - size_t ies_len) +static int ath6kl_set_assoc_req_ies(struct ath6kl_vif *vif, const u8 *ies, + size_t ies_len) { + struct ath6kl *ar = vif->ar; const u8 *pos; u8 *buf = NULL; size_t len = 0; @@ -298,8 +299,8 @@ static int ath6kl_set_assoc_req_ies(struct ath6kl *ar, const u8 *ies, } } - ret = ath6kl_wmi_set_appie_cmd(ar->wmi, WMI_FRAME_ASSOC_REQ, - buf, len); + ret = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_ASSOC_REQ, buf, len); kfree(buf); return ret; } @@ -354,7 +355,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } if (sme->ie && (sme->ie_len > 0)) { - status = ath6kl_set_assoc_req_ies(ar, sme->ie, sme->ie_len); + status = ath6kl_set_assoc_req_ies(vif, sme->ie, sme->ie_len); if (status) return status; } @@ -363,7 +364,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->ssid_len == sme->ssid_len && !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { vif->reconnect_flag = true; - status = ath6kl_wmi_reconnect_cmd(ar->wmi, vif->req_bssid, + status = ath6kl_wmi_reconnect_cmd(ar->wmi, vif->fw_vif_idx, + vif->req_bssid, vif->ch_hint); up(&ar->sem); @@ -374,7 +376,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return 0; } else if (vif->ssid_len == sme->ssid_len && !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { - ath6kl_disconnect(ar); + ath6kl_disconnect(ar, vif->fw_vif_idx); } memset(vif->ssid, 0, sizeof(vif->ssid)); @@ -425,7 +427,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, key->cipher = vif->prwise_crypto; vif->def_txkey_index = sme->key_idx; - ath6kl_wmi_addkey_cmd(ar->wmi, sme->key_idx, + ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, sme->key_idx, vif->prwise_crypto, GROUP_USAGE | TX_USAGE, key->key_len, @@ -455,7 +457,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->grp_crypto_len, vif->ch_hint); vif->reconnect_flag = 0; - status = ath6kl_wmi_connect_cmd(ar->wmi, vif->nw_type, + status = ath6kl_wmi_connect_cmd(ar->wmi, vif->fw_vif_idx, vif->nw_type, vif->dot11_auth_mode, vif->auth_mode, vif->prwise_crypto, vif->prwise_crypto_len, @@ -639,7 +641,7 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, } vif->reconnect_flag = 0; - ath6kl_disconnect(ar); + ath6kl_disconnect(ar, vif->fw_vif_idx); memset(vif->ssid, 0, sizeof(vif->ssid)); vif->ssid_len = 0; @@ -695,7 +697,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, */ if (reason != DISCONNECT_CMD) { - ath6kl_wmi_disconnect_cmd(ar->wmi); + ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx); return; } @@ -747,14 +749,15 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, request->n_ssids = MAX_PROBED_SSID_INDEX - 1; for (i = 0; i < request->n_ssids; i++) - ath6kl_wmi_probedssid_cmd(ar->wmi, i + 1, - SPECIFIC_SSID_FLAG, + ath6kl_wmi_probedssid_cmd(ar->wmi, vif->fw_vif_idx, + i + 1, SPECIFIC_SSID_FLAG, request->ssids[i].ssid_len, request->ssids[i].ssid); } if (request->ie) { - ret = ath6kl_wmi_set_appie_cmd(ar->wmi, WMI_FRAME_PROBE_REQ, + ret = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_PROBE_REQ, request->ie, request->ie_len); if (ret) { ath6kl_err("failed to set Probe Request appie for " @@ -788,8 +791,9 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, if (test_bit(CONNECTED, &vif->flags)) force_fg_scan = 1; - ret = ath6kl_wmi_startscan_cmd(ar->wmi, WMI_LONG_SCAN, force_fg_scan, - false, 0, 0, n_channels, channels); + ret = ath6kl_wmi_startscan_cmd(ar->wmi, vif->fw_vif_idx, WMI_LONG_SCAN, + force_fg_scan, false, 0, 0, n_channels, + channels); if (ret) ath6kl_err("wmi_startscan_cmd failed\n"); else @@ -820,8 +824,8 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl *ar, int status) if (vif->scan_req->n_ssids && vif->scan_req->ssids[0].ssid_len) { for (i = 0; i < vif->scan_req->n_ssids; i++) { - ath6kl_wmi_probedssid_cmd(ar->wmi, i + 1, - DISABLE_SSID_FLAG, + ath6kl_wmi_probedssid_cmd(ar->wmi, vif->fw_vif_idx, + i + 1, DISABLE_SSID_FLAG, 0, NULL); } } @@ -942,7 +946,8 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, return 0; } - status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->def_txkey_index, + status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, + vif->def_txkey_index, key_type, key_usage, key->key_len, key->seq, key->key, KEY_OP_INIT_VAL, (u8 *) mac_addr, SYNC_BOTH_WMIFLAG); @@ -980,7 +985,7 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, vif->keys[key_index].key_len = 0; - return ath6kl_wmi_deletekey_cmd(ar->wmi, key_index); + return ath6kl_wmi_deletekey_cmd(ar->wmi, vif->fw_vif_idx, key_index); } static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, @@ -1062,7 +1067,8 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, if (vif->next_mode == AP_NETWORK && !test_bit(CONNECTED, &vif->flags)) return 0; /* Delay until AP mode has been started */ - status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->def_txkey_index, + status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, + vif->def_txkey_index, key_type, key_usage, key->key_len, key->seq, key->key, KEY_OP_INIT_VAL, NULL, @@ -1179,6 +1185,7 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy, { struct ath6kl *ar = ath6kl_priv(dev); struct wmi_power_mode_cmd mode; + struct ath6kl_vif *vif = netdev_priv(dev); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: pmgmt %d, timeout %d\n", __func__, pmgmt, timeout); @@ -1194,7 +1201,8 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy, mode.pwr_mode = MAX_PERF_POWER; } - if (ath6kl_wmi_powermode_cmd(ar->wmi, mode.pwr_mode) != 0) { + if (ath6kl_wmi_powermode_cmd(ar->wmi, vif->fw_vif_idx, + mode.pwr_mode) != 0) { ath6kl_err("wmi_powermode_cmd failed\n"); return -EIO; } @@ -1299,7 +1307,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, vif->prwise_crypto_len, vif->grp_crypto, vif->grp_crypto_len, vif->ch_hint); - status = ath6kl_wmi_connect_cmd(ar->wmi, vif->nw_type, + status = ath6kl_wmi_connect_cmd(ar->wmi, vif->fw_vif_idx, vif->nw_type, vif->dot11_auth_mode, vif->auth_mode, vif->prwise_crypto, vif->prwise_crypto_len, @@ -1321,7 +1329,7 @@ static int ath6kl_cfg80211_leave_ibss(struct wiphy *wiphy, if (!ath6kl_cfg80211_ready(ar)) return -EIO; - ath6kl_disconnect(ar); + ath6kl_disconnect(ar, vif->fw_vif_idx); memset(vif->ssid, 0, sizeof(vif->ssid)); vif->ssid_len = 0; @@ -1416,7 +1424,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, set_bit(STATS_UPDATE_PEND, &vif->flags); - ret = ath6kl_wmi_get_stats_cmd(ar->wmi); + ret = ath6kl_wmi_get_stats_cmd(ar->wmi, vif->fw_vif_idx); if (ret != 0) { up(&ar->sem); @@ -1500,7 +1508,9 @@ static int ath6kl_set_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { struct ath6kl *ar = ath6kl_priv(netdev); - return ath6kl_wmi_setpmkid_cmd(ar->wmi, pmksa->bssid, + struct ath6kl_vif *vif = netdev_priv(netdev); + + return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->fw_vif_idx, pmksa->bssid, pmksa->pmkid, true); } @@ -1508,7 +1518,9 @@ static int ath6kl_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { struct ath6kl *ar = ath6kl_priv(netdev); - return ath6kl_wmi_setpmkid_cmd(ar->wmi, pmksa->bssid, + struct ath6kl_vif *vif = netdev_priv(netdev); + + return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->fw_vif_idx, pmksa->bssid, pmksa->pmkid, false); } @@ -1518,8 +1530,8 @@ static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) struct ath6kl_vif *vif = netdev_priv(netdev); if (test_bit(CONNECTED, &vif->flags)) - return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->bssid, - NULL, false); + return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->fw_vif_idx, + vif->bssid, NULL, false); return 0; } @@ -1564,9 +1576,10 @@ static bool ath6kl_is_p2p_ie(const u8 *pos) pos[4] == 0x9a && pos[5] == 0x09; } -static int ath6kl_set_ap_probe_resp_ies(struct ath6kl *ar, const u8 *ies, - size_t ies_len) +static int ath6kl_set_ap_probe_resp_ies(struct ath6kl_vif *vif, + const u8 *ies, size_t ies_len) { + struct ath6kl *ar = vif->ar; const u8 *pos; u8 *buf = NULL; size_t len = 0; @@ -1593,8 +1606,8 @@ static int ath6kl_set_ap_probe_resp_ies(struct ath6kl *ar, const u8 *ies, } } - ret = ath6kl_wmi_set_appie_cmd(ar->wmi, WMI_FRAME_PROBE_RESP, - buf, len); + ret = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_PROBE_RESP, buf, len); kfree(buf); return ret; } @@ -1620,20 +1633,22 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, return -EOPNOTSUPP; if (info->beacon_ies) { - res = ath6kl_wmi_set_appie_cmd(ar->wmi, WMI_FRAME_BEACON, + res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_BEACON, info->beacon_ies, info->beacon_ies_len); if (res) return res; } if (info->proberesp_ies) { - res = ath6kl_set_ap_probe_resp_ies(ar, info->proberesp_ies, + res = ath6kl_set_ap_probe_resp_ies(vif, info->proberesp_ies, info->proberesp_ies_len); if (res) return res; } if (info->assocresp_ies) { - res = ath6kl_wmi_set_appie_cmd(ar->wmi, WMI_FRAME_ASSOC_RESP, + res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_ASSOC_RESP, info->assocresp_ies, info->assocresp_ies_len); if (res) @@ -1734,7 +1749,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, p.dot11_auth_mode = vif->dot11_auth_mode; p.ch = cpu_to_le16(vif->next_chan); - res = ath6kl_wmi_ap_profile_commit(ar->wmi, &p); + res = ath6kl_wmi_ap_profile_commit(ar->wmi, vif->fw_vif_idx, &p); if (res < 0) return res; @@ -1763,7 +1778,7 @@ static int ath6kl_del_beacon(struct wiphy *wiphy, struct net_device *dev) if (!test_bit(CONNECTED, &vif->flags)) return -ENOTCONN; - ath6kl_wmi_disconnect_cmd(ar->wmi); + ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx); clear_bit(CONNECTED, &vif->flags); return 0; @@ -1783,10 +1798,10 @@ static int ath6kl_change_station(struct wiphy *wiphy, struct net_device *dev, return -EOPNOTSUPP; if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) - return ath6kl_wmi_ap_set_mlme(ar->wmi, WMI_AP_MLME_AUTHORIZE, - mac, 0); - return ath6kl_wmi_ap_set_mlme(ar->wmi, WMI_AP_MLME_UNAUTHORIZE, mac, - 0); + return ath6kl_wmi_ap_set_mlme(ar->wmi, vif->fw_vif_idx, + WMI_AP_MLME_AUTHORIZE, mac, 0); + return ath6kl_wmi_ap_set_mlme(ar->wmi, vif->fw_vif_idx, + WMI_AP_MLME_UNAUTHORIZE, mac, 0); } static int ath6kl_remain_on_channel(struct wiphy *wiphy, @@ -1797,13 +1812,14 @@ static int ath6kl_remain_on_channel(struct wiphy *wiphy, u64 *cookie) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); /* TODO: if already pending or ongoing remain-on-channel, * return -EBUSY */ *cookie = 1; /* only a single pending request is supported */ - return ath6kl_wmi_remain_on_chnl_cmd(ar->wmi, chan->center_freq, - duration); + return ath6kl_wmi_remain_on_chnl_cmd(ar->wmi, vif->fw_vif_idx, + chan->center_freq, duration); } static int ath6kl_cancel_remain_on_channel(struct wiphy *wiphy, @@ -1811,16 +1827,19 @@ static int ath6kl_cancel_remain_on_channel(struct wiphy *wiphy, u64 cookie) { struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); if (cookie != 1) return -ENOENT; - return ath6kl_wmi_cancel_remain_on_chnl_cmd(ar->wmi); + return ath6kl_wmi_cancel_remain_on_chnl_cmd(ar->wmi, vif->fw_vif_idx); } -static int ath6kl_send_go_probe_resp(struct ath6kl *ar, const u8 *buf, - size_t len, unsigned int freq) +static int ath6kl_send_go_probe_resp(struct ath6kl_vif *vif, + const u8 *buf, size_t len, + unsigned int freq) { + struct ath6kl *ar = vif->ar; const u8 *pos; u8 *p2p; int p2p_len; @@ -1847,8 +1866,8 @@ static int ath6kl_send_go_probe_resp(struct ath6kl *ar, const u8 *buf, pos += 2 + pos[1]; } - ret = ath6kl_wmi_send_probe_response_cmd(ar->wmi, freq, mgmt->da, - p2p, p2p_len); + ret = ath6kl_wmi_send_probe_response_cmd(ar->wmi, vif->fw_vif_idx, freq, + mgmt->da, p2p, p2p_len); kfree(p2p); return ret; } @@ -1874,7 +1893,7 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, * command to allow the target to fill in the generic IEs. */ *cookie = 0; /* TX status not supported */ - return ath6kl_send_go_probe_resp(ar, buf, len, + return ath6kl_send_go_probe_resp(vif, buf, len, chan->center_freq); } @@ -1888,7 +1907,8 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, } *cookie = id; - return ath6kl_wmi_send_action_cmd(ar->wmi, id, chan->center_freq, wait, + return ath6kl_wmi_send_action_cmd(ar->wmi, vif->fw_vif_idx, id, + chan->center_freq, wait, buf, len); } @@ -2093,7 +2113,7 @@ void ath6kl_deinit_if_data(struct ath6kl_vif *vif) } struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, - enum nl80211_iftype type) + enum nl80211_iftype type, u8 fw_vif_idx) { struct net_device *ndev; struct ath6kl_vif *vif; @@ -2111,6 +2131,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, SET_NETDEV_DEV(ndev, wiphy_dev(vif->wdev.wiphy)); vif->wdev.netdev = ndev; vif->wdev.iftype = type; + vif->fw_vif_idx = fw_vif_idx; ar->wdev = &vif->wdev; ar->net_dev = ndev; diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 5daf685..033e742 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -18,7 +18,8 @@ #define ATH6KL_CFG80211_H struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, - enum nl80211_iftype type); + enum nl80211_iftype type, + u8 fw_vif_idx); int ath6kl_register_ieee80211_hw(struct ath6kl *ar); struct ath6kl *ath6kl_core_alloc(struct device *dev); void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 41d6ae0..f21d777 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -380,6 +380,8 @@ struct ath6kl_req_key { u8 key_len; }; +#define MAX_NUM_VIF 1 + /* vif flags info */ enum ath6kl_vif_state { CONNECTED, @@ -398,6 +400,7 @@ struct ath6kl_vif { struct wireless_dev wdev; struct net_device *ndev; struct ath6kl *ar; + u8 fw_vif_idx; unsigned long flags; int ssid_len; u8 ssid[IEEE80211_MAX_SSID_LEN]; @@ -647,7 +650,7 @@ enum htc_endpoint_id ath6kl_ac2_endpoint_id(void *devt, u8 ac); void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid); void ath6kl_dtimexpiry_event(struct ath6kl *ar); -void ath6kl_disconnect(struct ath6kl *ar); +void ath6kl_disconnect(struct ath6kl *ar, u8 if_idx); void ath6kl_deep_sleep_enable(struct ath6kl *ar); void aggr_recv_delba_req_evt(struct ath6kl *ar, u8 tid); void aggr_recv_addba_req_evt(struct ath6kl *ar, u8 tid, u16 seq_no, diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 9a89b42..870e9b1 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -417,7 +417,7 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf, set_bit(STATS_UPDATE_PEND, &vif->flags); - if (ath6kl_wmi_get_stats_cmd(ar->wmi)) { + if (ath6kl_wmi_get_stats_cmd(ar->wmi, 0)) { up(&ar->sem); kfree(buf); return -EIO; @@ -1477,7 +1477,7 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file, if (bgscan_int == 0) bgscan_int = 0xffff; - ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, bgscan_int, 0, 0, 0, 3, + ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3, 0, 0, 0); return count; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index dd63408..957bfb0 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1407,7 +1407,7 @@ static int ath6kl_init(struct ath6kl *ar) } /* Add an initial station interface */ - ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION); + ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0); if (!ndev) { ath6kl_err("Failed to instantiate a network device\n"); status = -ENOMEM; diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index fff1f4a..9929901 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -441,7 +441,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, if (test_bit(WMI_READY, &ar->flag)) { discon_issued = (test_bit(CONNECTED, &vif->flags) || test_bit(CONNECT_PEND, &vif->flags)); - ath6kl_disconnect(ar); + ath6kl_disconnect(ar, vif->fw_vif_idx); if (!keep_profile) ath6kl_init_profile_info(ar); @@ -511,7 +511,7 @@ static void ath6kl_install_static_wep_keys(struct ath6kl *ar) if (index == vif->def_txkey_index) keyusage |= TX_USAGE; - ath6kl_wmi_addkey_cmd(ar->wmi, + ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, index, WEP_CRYPT, keyusage, @@ -551,7 +551,7 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel) "the initial group key for AP mode\n"); memset(key_rsc, 0, sizeof(key_rsc)); res = ath6kl_wmi_addkey_cmd( - ar->wmi, ik->key_index, ik->key_type, + ar->wmi, vif->fw_vif_idx, ik->key_index, ik->key_type, GROUP_USAGE, ik->key_len, key_rsc, ik->key, KEY_OP_INIT_VAL, NULL, SYNC_BOTH_WMIFLAG); if (res) { @@ -913,20 +913,20 @@ void ath6k_credit_distribute(struct htc_credit_state_info *cred_info, void disconnect_timer_handler(unsigned long ptr) { struct net_device *dev = (struct net_device *)ptr; - struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); - ath6kl_init_profile_info(ar); - ath6kl_disconnect(ar); + ath6kl_init_profile_info(vif->ar); + ath6kl_disconnect(vif->ar, vif->fw_vif_idx); } -void ath6kl_disconnect(struct ath6kl *ar) +void ath6kl_disconnect(struct ath6kl *ar, u8 if_idx) { /* TODO: Pass vif instead of taking it from ar */ struct ath6kl_vif *vif = ar->vif; if (test_bit(CONNECTED, &vif->flags) || test_bit(CONNECT_PEND, &vif->flags)) { - ath6kl_wmi_disconnect_cmd(ar->wmi); + ath6kl_wmi_disconnect_cmd(ar->wmi, if_idx); /* * Disconnect command is issued, clear the connect pending * flag. The connected flag will be cleared in @@ -961,13 +961,13 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) if (test_bit(CONNECTED, &vif->flags) || test_bit(CONNECT_PEND, &vif->flags)) - ath6kl_wmi_disconnect_cmd(ar->wmi); + ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx); vif->sme_state = SME_DISCONNECTED; /* disable scanning */ - if (ath6kl_wmi_scanparams_cmd(ar->wmi, 0xFFFF, 0, 0, 0, 0, 0, 0, 0, - 0, 0) != 0) + if (ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, 0xFFFF, 0, 0, + 0, 0, 0, 0, 0, 0, 0) != 0) printk(KERN_WARNING "ath6kl: failed to disable scan " "during suspend\n"); @@ -976,7 +976,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) /* save the current power mode before enabling power save */ ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; - if (ath6kl_wmi_powermode_cmd(ar->wmi, REC_POWER) != 0) + if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER) != 0) ath6kl_warn("ath6kl_deep_sleep_enable: " "wmi_powermode_cmd failed\n"); } @@ -1061,7 +1061,8 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, vif->bss_ch = channel; if ((vif->nw_type == INFRA_NETWORK)) - ath6kl_wmi_listeninterval_cmd(ar->wmi, ar->listen_intvl_t, + ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, + ar->listen_intvl_t, ar->listen_intvl_b); netif_wake_queue(ar->net_dev); @@ -1280,6 +1281,8 @@ void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid) struct ath6kl_sta *conn; struct sk_buff *skb; bool psq_empty = false; + /* TODO: Pass vif instead of taking it from ar */ + struct ath6kl_vif *vif = ar->vif; conn = ath6kl_find_sta_by_aid(ar, aid); @@ -1310,7 +1313,7 @@ void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid) spin_unlock_bh(&conn->psq_lock); if (psq_empty) - ath6kl_wmi_set_pvb_cmd(ar->wmi, conn->aid, 0); + ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, conn->aid, 0); } void ath6kl_dtimexpiry_event(struct ath6kl *ar) @@ -1355,7 +1358,7 @@ void ath6kl_dtimexpiry_event(struct ath6kl *ar) clear_bit(DTIM_EXPIRED, &vif->flags); /* clear the LSB of the BitMapCtl field of the TIM IE */ - ath6kl_wmi_set_pvb_cmd(ar->wmi, MCAST_AID, 0); + ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, MCAST_AID, 0); } void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, @@ -1377,7 +1380,8 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, /* clear the LSB of the TIM IE's BitMapCtl field */ if (test_bit(WMI_READY, &ar->flag)) - ath6kl_wmi_set_pvb_cmd(ar->wmi, MCAST_AID, 0); + ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, + MCAST_AID, 0); } if (!is_broadcast_ether_addr(bssid)) { @@ -1468,11 +1472,11 @@ static int ath6kl_close(struct net_device *dev) netif_stop_queue(dev); - ath6kl_disconnect(ar); + ath6kl_disconnect(ar, vif->fw_vif_idx); if (test_bit(WMI_READY, &ar->flag)) { - if (ath6kl_wmi_scanparams_cmd(ar->wmi, 0xFFFF, 0, 0, 0, 0, 0, 0, - 0, 0, 0)) + if (ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, 0xFFFF, + 0, 0, 0, 0, 0, 0, 0, 0, 0)) return -EIO; clear_bit(WLAN_ENABLED, &vif->flags); diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 4e43878..f73e14f 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -747,7 +747,7 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) static int ath6kl_sdio_resume(struct ath6kl *ar) { if (ar->wmi->pwr_mode != ar->wmi->saved_pwr_mode) { - if (ath6kl_wmi_powermode_cmd(ar->wmi, + if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, ar->wmi->saved_pwr_mode) != 0) ath6kl_warn("ath6kl_sdio_resume: " "wmi_powermode_cmd failed\n"); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index cada197..c54f1a9 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -118,6 +118,7 @@ static bool ath6kl_powersave_ap(struct ath6kl *ar, struct sk_buff *skb, */ if (is_mcastq_empty) ath6kl_wmi_set_pvb_cmd(ar->wmi, + vif->fw_vif_idx, MCAST_AID, 1); ps_queued = true; @@ -156,6 +157,7 @@ static bool ath6kl_powersave_ap(struct ath6kl *ar, struct sk_buff *skb, */ if (is_psq_empty) ath6kl_wmi_set_pvb_cmd(ar->wmi, + vif->fw_vif_idx, conn->aid, 1); ps_queued = true; @@ -1176,7 +1178,8 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) } spin_unlock_bh(&conn->psq_lock); /* Clear the PVB for this STA */ - ath6kl_wmi_set_pvb_cmd(ar->wmi, conn->aid, 0); + ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, + conn->aid, 0); } } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 8e7e7b5..a4ad7cb 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -627,7 +627,8 @@ static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) } /* Send a "simple" wmi command -- one with no arguments */ -static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) +static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx, + enum wmi_cmd_id cmd_id) { struct sk_buff *skb; int ret; @@ -636,7 +637,7 @@ static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) if (!skb) return -ENOMEM; - ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG); return ret; } @@ -679,7 +680,8 @@ int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; - ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); + ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, + NO_SYNC_WMIFLAG); return 0; } @@ -700,7 +702,7 @@ int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) cmd->roam_ctrl = WMI_FORCE_ROAM; ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); } @@ -720,7 +722,7 @@ int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) cmd->roam_ctrl = WMI_SET_ROAM_MODE; ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); } @@ -1270,7 +1272,7 @@ static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, NO_SYNC_WMIFLAG); } @@ -1451,7 +1453,7 @@ static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, NO_SYNC_WMIFLAG); } @@ -1576,14 +1578,15 @@ static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) return 0; } -int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, +int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) { struct wmi_cmd_hdr *cmd_hdr; enum htc_endpoint_id ep_id = wmi->ep_id; int ret; + u16 info1; - if (WARN_ON(skb == NULL)) + if (WARN_ON(skb == NULL || (if_idx > (MAX_NUM_VIF - 1)))) return -EINVAL; ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n", @@ -1609,7 +1612,8 @@ int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, cmd_hdr = (struct wmi_cmd_hdr *) skb->data; cmd_hdr->cmd_id = cpu_to_le16(cmd_id); - cmd_hdr->info1 = 0; /* added for virtual interface */ + info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK; + cmd_hdr->info1 = cpu_to_le16(info1); /* Only for OPT_TX_CMD, use BE endpoint. */ if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { @@ -1636,7 +1640,8 @@ int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, return 0; } -int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, +int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx, + enum network_type nw_type, enum dot11_auth_mode dot11_auth_mode, enum auth_mode auth_mode, enum crypto_type pairwise_crypto, @@ -1687,12 +1692,14 @@ int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, if (bssid != NULL) memcpy(cc->bssid, bssid, ETH_ALEN); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID, + NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) +int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid, + u16 channel) { struct sk_buff *skb; struct wmi_reconnect_cmd *cc; @@ -1713,13 +1720,13 @@ int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) if (bssid != NULL) memcpy(cc->bssid, bssid, ETH_ALEN); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) +int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx) { int ret; @@ -1728,12 +1735,13 @@ int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) wmi->traffic_class = 100; /* Disconnect command does not need to do a SYNC before. */ - ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); + ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID); return ret; } -int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, +int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx, + enum wmi_scan_type scan_type, u32 force_fgscan, u32 is_legacy, u32 home_dwell_time, u32 force_scan_interval, s8 num_chan, u16 *ch_list) @@ -1769,13 +1777,14 @@ int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, for (i = 0; i < num_chan; i++) sc->ch_list[i] = cpu_to_le16(ch_list[i]); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, +int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, + u16 fg_start_sec, u16 fg_end_sec, u16 bg_sec, u16 minact_chdw_msec, u16 maxact_chdw_msec, u16 pas_chdw_msec, u8 short_scan_ratio, @@ -1802,7 +1811,7 @@ int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -1824,12 +1833,12 @@ int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) cmd->bss_filter = filter; cmd->ie_mask = cpu_to_le32(ie_mask); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_BSS_FILTER_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, +int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, u8 ssid_len, u8 *ssid) { struct sk_buff *skb; @@ -1861,12 +1870,13 @@ int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, cmd->ssid_len = ssid_len; memcpy(cmd->ssid, ssid, ssid_len); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, +int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, + u16 listen_interval, u16 listen_beacons) { struct sk_buff *skb; @@ -1881,12 +1891,12 @@ int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, cmd->listen_intvl = cpu_to_le16(listen_interval); cmd->num_beacons = cpu_to_le16(listen_beacons); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) +int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode) { struct sk_buff *skb; struct wmi_power_mode_cmd *cmd; @@ -1900,7 +1910,7 @@ int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) cmd->pwr_mode = pwr_mode; wmi->pwr_mode = pwr_mode; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -1926,7 +1936,7 @@ int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_POWER_PARAMS_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -1944,14 +1954,16 @@ int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) cmd = (struct wmi_disc_timeout_cmd *) skb->data; cmd->discon_timeout = timeout; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_DISC_TIMEOUT_CMDID, NO_SYNC_WMIFLAG); + if (ret == 0) ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); + return ret; } -int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, +int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, enum crypto_type key_type, u8 key_usage, u8 key_len, u8 *key_rsc, u8 *key_material, @@ -1992,7 +2004,7 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, if (mac_addr) memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID, sync_flag); return ret; @@ -2011,12 +2023,13 @@ int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) cmd = (struct wmi_add_krk_cmd *) skb->data; memcpy(cmd->krk, krk, WMI_KRK_LEN); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_ADD_KRK_CMDID, + NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) +int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index) { struct sk_buff *skb; struct wmi_delete_cipher_key_cmd *cmd; @@ -2032,13 +2045,13 @@ int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; cmd->key_index = key_index; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, +int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, const u8 *pmkid, bool set) { struct sk_buff *skb; @@ -2065,7 +2078,7 @@ int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, cmd->enable = PMKID_DISABLE; } - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID, NO_SYNC_WMIFLAG); return ret; @@ -2147,7 +2160,7 @@ static int ath6kl_wmi_sync_point(struct wmi *wmi) * Send sync cmd followed by sync data messages on all * endpoints being used */ - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SYNCHRONIZE_CMDID, NO_SYNC_WMIFLAG); if (ret) @@ -2278,7 +2291,7 @@ int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, ath6kl_indicate_tx_activity(wmi->parent_dev, params->traffic_class, true); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_CREATE_PSTREAM_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -2319,7 +2332,7 @@ int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", traffic_class, tsid); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DELETE_PSTREAM_CMDID, SYNC_BEFORE_WMIFLAG); spin_lock_bh(&wmi->lock); @@ -2358,7 +2371,8 @@ int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) cmd = (struct wmi_set_ip_cmd *) skb->data; memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_IP_CMDID, + NO_SYNC_WMIFLAG); return ret; } @@ -2383,7 +2397,7 @@ static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, cmd_hdr = (struct wmix_cmd_hdr *) skb->data; cmd_hdr->cmd_id = cpu_to_le32(cmd_id); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag); return ret; } @@ -2426,9 +2440,9 @@ int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) return ret; } -int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) +int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx) { - return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); + return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID); } int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) @@ -2444,7 +2458,7 @@ int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; cmd->dbM = dbM; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_TX_PWR_CMDID, NO_SYNC_WMIFLAG); return ret; @@ -2452,12 +2466,12 @@ int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) { - return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); + return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_TX_PWR_CMDID); } int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) { - return ath6kl_wmi_simple_cmd(wmi, WMI_GET_ROAM_TBL_CMDID); + return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID); } int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) @@ -2474,7 +2488,7 @@ int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) cmd->status = status; cmd->preamble_policy = preamble_policy; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_LPREAMBLE_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -2492,7 +2506,8 @@ int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) cmd = (struct wmi_set_rts_cmd *) skb->data; cmd->threshold = cpu_to_le16(threshold); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID, + NO_SYNC_WMIFLAG); return ret; } @@ -2512,7 +2527,7 @@ int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; cmd->txop_enable = cfg; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_WMM_TXOP_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -2530,10 +2545,12 @@ int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) cmd = (struct wmi_set_keepalive_cmd *) skb->data; cmd->keep_alive_intvl = keep_alive_intvl; - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_KEEPALIVE_CMDID, NO_SYNC_WMIFLAG); + if (ret == 0) ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl); + return ret; } @@ -2548,7 +2565,7 @@ int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) memcpy(skb->data, buf, len); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -2602,7 +2619,8 @@ static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) /* AP mode functions */ -int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) +int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, + struct wmi_connect_cmd *p) { struct sk_buff *skb; struct wmi_connect_cmd *cm; @@ -2615,7 +2633,7 @@ int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) cm = (struct wmi_connect_cmd *) skb->data; memcpy(cm, p, sizeof(*cm)); - res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, + res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID, NO_SYNC_WMIFLAG); ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " "ctrl_flags=0x%x-> res=%d\n", @@ -2624,7 +2642,8 @@ int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) return res; } -int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) +int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, + u16 reason) { struct sk_buff *skb; struct wmi_ap_set_mlme_cmd *cm; @@ -2638,7 +2657,7 @@ int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) cm->reason = cpu_to_le16(reason); cm->cmd = cmd; - return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID, + return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID, NO_SYNC_WMIFLAG); } @@ -2663,7 +2682,8 @@ static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) return 0; } -int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) +int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, + bool flag) { struct sk_buff *skb; struct wmi_ap_set_pvb_cmd *cmd; @@ -2678,7 +2698,7 @@ int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) cmd->rsvd = cpu_to_le16(0); cmd->flag = cpu_to_le32(flag); - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID, NO_SYNC_WMIFLAG); return 0; @@ -2701,14 +2721,14 @@ int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, cmd->meta_ver = rx_meta_ver; /* Delete the local aggr state, on host */ - ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RX_FRAME_FORMAT_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, - u8 ie_len) +int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, + const u8 *ie, u8 ie_len) { struct sk_buff *skb; struct wmi_set_appie_cmd *p; @@ -2723,7 +2743,7 @@ int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, p->mgmt_frm_type = mgmt_frm_type; p->ie_len = ie_len; memcpy(p->ie_info, ie, ie_len); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID, NO_SYNC_WMIFLAG); } @@ -2741,11 +2761,11 @@ int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; cmd->disable = disable ? 1 : 0; - return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID, NO_SYNC_WMIFLAG); } -int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) +int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur) { struct sk_buff *skb; struct wmi_remain_on_chnl_cmd *p; @@ -2759,12 +2779,12 @@ int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) p = (struct wmi_remain_on_chnl_cmd *) skb->data; p->freq = cpu_to_le32(freq); p->duration = cpu_to_le32(dur); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID, + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID, NO_SYNC_WMIFLAG); } -int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, - const u8 *data, u16 data_len) +int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, + u32 wait, const u8 *data, u16 data_len) { struct sk_buff *skb; struct wmi_send_action_cmd *p; @@ -2795,13 +2815,13 @@ int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, p->wait = cpu_to_le32(wait); p->len = cpu_to_le16(data_len); memcpy(p->data, data, data_len); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID, + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID, NO_SYNC_WMIFLAG); } -int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, - const u8 *dst, - const u8 *data, u16 data_len) +int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, + const u8 *dst, const u8 *data, + u16 data_len) { struct sk_buff *skb; struct wmi_p2p_probe_response_cmd *p; @@ -2817,7 +2837,8 @@ int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, memcpy(p->destination_addr, dst, ETH_ALEN); p->len = cpu_to_le16(data_len); memcpy(p->data, data, data_len); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID, + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, + WMI_SEND_PROBE_RESPONSE_CMDID, NO_SYNC_WMIFLAG); } @@ -2834,7 +2855,7 @@ int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) enable); p = (struct wmi_probe_req_report_cmd *) skb->data; p->enable = enable ? 1 : 0; - return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_PROBE_REQ_REPORT_CMDID, NO_SYNC_WMIFLAG); } @@ -2851,14 +2872,15 @@ int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) info_req_flags); p = (struct wmi_get_p2p_info *) skb->data; p->info_req_flags = cpu_to_le32(info_req_flags); - return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID, + return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_GET_P2P_INFO_CMDID, NO_SYNC_WMIFLAG); } -int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi) +int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx) { ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); - return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID); + return ath6kl_wmi_simple_cmd(wmi, if_idx, + WMI_CANCEL_REMAIN_ON_CHNL_CMDID); } static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index f0ca899..83bf46c 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -288,6 +288,8 @@ struct wmi_rx_meta_v2 { u8 csum_flags; } __packed; +#define WMI_CMD_HDR_IF_ID_MASK 0xF + /* Control Path */ struct wmi_cmd_hdr { __le16 cmd_id; @@ -2175,10 +2177,11 @@ int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb); -int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, +int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag); -int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, +int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx, + enum network_type nw_type, enum dot11_auth_mode dot11_auth_mode, enum auth_mode auth_mode, enum crypto_type pairwise_crypto, @@ -2187,24 +2190,27 @@ int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, u8 group_crypto_len, int ssid_len, u8 *ssid, u8 *bssid, u16 channel, u32 ctrl_flags); -int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel); -int ath6kl_wmi_disconnect_cmd(struct wmi *wmi); -int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, +int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid, + u16 channel); +int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx); +int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx, + enum wmi_scan_type scan_type, u32 force_fgscan, u32 is_legacy, u32 home_dwell_time, u32 force_scan_interval, s8 num_chan, u16 *ch_list); -int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, +int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, u16 fg_start_sec, u16 fg_end_sec, u16 bg_sec, u16 minact_chdw_msec, u16 maxact_chdw_msec, u16 pas_chdw_msec, u8 short_scan_ratio, u8 scan_ctrl_flag, u32 max_dfsch_act_time, u16 maxact_scan_per_ssid); int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask); -int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, +int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, u8 ssid_len, u8 *ssid); -int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, +int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, + u16 listen_interval, u16 listen_beacons); -int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode); +int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode); int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, u16 ps_poll_num, u16 dtim_policy, u16 tx_wakup_policy, u16 num_tx_to_wakeup, @@ -2221,16 +2227,16 @@ int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source); int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config); -int ath6kl_wmi_get_stats_cmd(struct wmi *wmi); -int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, +int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx); +int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, enum crypto_type key_type, u8 key_usage, u8 key_len, u8 *key_rsc, u8 *key_material, u8 key_op_ctrl, u8 *mac_addr, enum wmi_sync_flag sync_flag); int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk); -int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index); -int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, +int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index); +int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, const u8 *pmkid, bool set); int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM); int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi); @@ -2248,38 +2254,41 @@ int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid); int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode); /* AP mode */ -int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p); +int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, + struct wmi_connect_cmd *p); -int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason); +int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, + const u8 *mac, u16 reason); -int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag); +int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, bool flag); int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_version, bool rx_dot11_hdr, bool defrag_on_host); -int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, - u8 ie_len); +int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, + const u8 *ie, u8 ie_len); /* P2P */ int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable); -int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur); +int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, + u32 dur); -int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, - const u8 *data, u16 data_len); +int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, + u32 wait, const u8 *data, u16 data_len); -int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, - const u8 *dst, - const u8 *data, u16 data_len); +int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, + const u8 *dst, const u8 *data, + u16 data_len); int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable); int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags); -int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi); +int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx); -int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, - u8 ie_len); +int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, + const u8 *ie, u8 ie_len); void *ath6kl_wmi_init(struct ath6kl *devt); void ath6kl_wmi_shutdown(struct wmi *wmi); -- cgit v0.10.2 From 240d279940ef496e9456db2287b7989f6521e2e2 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:13 +0530 Subject: ath6kl: Take vif information from wmi event Interface index is passed in wmi command header from target. Use this index to get the appropriate vif. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 54679f2..2925463 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -123,12 +123,9 @@ static struct ieee80211_supported_band ath6kl_band_5ghz = { #define CCKM_KRK_CIPHER_SUITE 0x004096ff /* use for KRK */ -static int ath6kl_set_wpa_version(struct ath6kl *ar, +static int ath6kl_set_wpa_version(struct ath6kl_vif *vif, enum nl80211_wpa_versions wpa_version) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: %u\n", __func__, wpa_version); if (!wpa_version) { @@ -145,12 +142,9 @@ static int ath6kl_set_wpa_version(struct ath6kl *ar, return 0; } -static int ath6kl_set_auth_type(struct ath6kl *ar, +static int ath6kl_set_auth_type(struct ath6kl_vif *vif, enum nl80211_auth_type auth_type) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: 0x%x\n", __func__, auth_type); switch (auth_type) { @@ -176,11 +170,8 @@ static int ath6kl_set_auth_type(struct ath6kl *ar, return 0; } -static int ath6kl_set_cipher(struct ath6kl *ar, u32 cipher, bool ucast) +static int ath6kl_set_cipher(struct ath6kl_vif *vif, u32 cipher, bool ucast) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - u8 *ar_cipher = ucast ? &vif->prwise_crypto : &vif->grp_crypto; u8 *ar_cipher_len = ucast ? &vif->prwise_crypto_len : &vif->grp_crypto_len; @@ -218,11 +209,8 @@ static int ath6kl_set_cipher(struct ath6kl *ar, u32 cipher, bool ucast) return 0; } -static void ath6kl_set_key_mgmt(struct ath6kl *ar, u32 key_mgmt) +static void ath6kl_set_key_mgmt(struct ath6kl_vif *vif, u32 key_mgmt) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: 0x%x\n", __func__, key_mgmt); if (key_mgmt == WLAN_AKM_SUITE_PSK) { @@ -376,7 +364,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return 0; } else if (vif->ssid_len == sme->ssid_len && !memcmp(vif->ssid, sme->ssid, vif->ssid_len)) { - ath6kl_disconnect(ar, vif->fw_vif_idx); + ath6kl_disconnect(vif); } memset(vif->ssid, 0, sizeof(vif->ssid)); @@ -390,23 +378,23 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, if (sme->bssid && !is_broadcast_ether_addr(sme->bssid)) memcpy(vif->req_bssid, sme->bssid, sizeof(vif->req_bssid)); - ath6kl_set_wpa_version(ar, sme->crypto.wpa_versions); + ath6kl_set_wpa_version(vif, sme->crypto.wpa_versions); - status = ath6kl_set_auth_type(ar, sme->auth_type); + status = ath6kl_set_auth_type(vif, sme->auth_type); if (status) { up(&ar->sem); return status; } if (sme->crypto.n_ciphers_pairwise) - ath6kl_set_cipher(ar, sme->crypto.ciphers_pairwise[0], true); + ath6kl_set_cipher(vif, sme->crypto.ciphers_pairwise[0], true); else - ath6kl_set_cipher(ar, 0, true); + ath6kl_set_cipher(vif, 0, true); - ath6kl_set_cipher(ar, sme->crypto.cipher_group, false); + ath6kl_set_cipher(vif, sme->crypto.cipher_group, false); if (sme->crypto.n_akm_suites) - ath6kl_set_key_mgmt(ar, sme->crypto.akm_suites[0]); + ath6kl_set_key_mgmt(vif, sme->crypto.akm_suites[0]); if ((sme->key_len) && (vif->auth_mode == NONE_AUTH) && @@ -438,7 +426,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, if (!ar->usr_bss_filter) { clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); - if (ath6kl_wmi_bssfilter_cmd(ar->wmi, ALL_BSS_FILTER, 0) != 0) { + if (ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, + ALL_BSS_FILTER, 0) != 0) { ath6kl_err("couldn't set bss filtering\n"); up(&ar->sem); return -EIO; @@ -491,12 +480,11 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return 0; } -static int ath6kl_add_bss_if_needed(struct ath6kl *ar, const u8 *bssid, +static int ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, const u8 *bssid, struct ieee80211_channel *chan, const u8 *beacon_ie, size_t beacon_ie_len) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; struct cfg80211_bss *bss; u8 *ie; @@ -540,7 +528,7 @@ static int ath6kl_add_bss_if_needed(struct ath6kl *ar, const u8 *bssid, return 0; } -void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, +void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, u16 listen_intvl, u16 beacon_intvl, enum network_type nw_type, @@ -548,8 +536,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, u8 assoc_resp_len, u8 *assoc_info) { struct ieee80211_channel *chan; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; /* capinfo + listen interval */ u8 assoc_req_ie_offset = sizeof(u16) + sizeof(u16); @@ -592,11 +579,11 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, if (nw_type & ADHOC_NETWORK) { - cfg80211_ibss_joined(ar->net_dev, bssid, GFP_KERNEL); + cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL); return; } - if (ath6kl_add_bss_if_needed(ar, bssid, chan, assoc_info, + if (ath6kl_add_bss_if_needed(vif, bssid, chan, assoc_info, beacon_ie_len) < 0) { ath6kl_err("could not add cfg80211 bss entry for " "connect/roamed notification\n"); @@ -606,13 +593,13 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, if (vif->sme_state == SME_CONNECTING) { /* inform connect result to cfg80211 */ vif->sme_state = SME_CONNECTED; - cfg80211_connect_result(ar->net_dev, bssid, + cfg80211_connect_result(vif->ndev, bssid, assoc_req_ie, assoc_req_len, assoc_resp_ie, assoc_resp_len, WLAN_STATUS_SUCCESS, GFP_KERNEL); } else if (vif->sme_state == SME_CONNECTED) { /* inform roam event to cfg80211 */ - cfg80211_roamed(ar->net_dev, chan, bssid, + cfg80211_roamed(vif->ndev, chan, bssid, assoc_req_ie, assoc_req_len, assoc_resp_ie, assoc_resp_len, GFP_KERNEL); } @@ -641,7 +628,7 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, } vif->reconnect_flag = 0; - ath6kl_disconnect(ar, vif->fw_vif_idx); + ath6kl_disconnect(vif); memset(vif->ssid, 0, sizeof(vif->ssid)); vif->ssid_len = 0; @@ -655,12 +642,11 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, return 0; } -void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, +void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 proto_reason) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; if (vif->scan_req) { cfg80211_scan_done(vif->scan_req, true); @@ -674,7 +660,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, return; } memset(bssid, 0, ETH_ALEN); - cfg80211_ibss_joined(ar->net_dev, bssid, GFP_KERNEL); + cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL); return; } @@ -704,13 +690,13 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, clear_bit(CONNECT_PEND, &vif->flags); if (vif->sme_state == SME_CONNECTING) { - cfg80211_connect_result(ar->net_dev, + cfg80211_connect_result(vif->ndev, bssid, NULL, 0, NULL, 0, WLAN_STATUS_UNSPECIFIED_FAILURE, GFP_KERNEL); } else if (vif->sme_state == SME_CONNECTED) { - cfg80211_disconnected(ar->net_dev, reason, + cfg80211_disconnected(vif->ndev, reason, NULL, 0, GFP_KERNEL); } @@ -733,7 +719,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, if (!ar->usr_bss_filter) { clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); ret = ath6kl_wmi_bssfilter_cmd( - ar->wmi, + ar->wmi, vif->fw_vif_idx, (test_bit(CONNECTED, &vif->flags) ? ALL_BUT_BSS_FILTER : ALL_BSS_FILTER), 0); if (ret) { @@ -804,10 +790,9 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, return ret; } -void ath6kl_cfg80211_scan_complete_event(struct ath6kl *ar, int status) +void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; int i; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: status %d\n", __func__, status); @@ -852,7 +837,8 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, if (params->cipher == CCKM_KRK_CIPHER_SUITE) { if (params->key_len != WMI_KRK_LEN) return -EINVAL; - return ath6kl_wmi_add_krk_cmd(ar->wmi, params->key); + return ath6kl_wmi_add_krk_cmd(ar->wmi, vif->fw_vif_idx, + params->key); } if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { @@ -1079,16 +1065,13 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, return 0; } -void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl *ar, u8 keyid, +void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: keyid %d, ismcast %d\n", __func__, keyid, ismcast); - cfg80211_michael_mic_failure(ar->net_dev, vif->bssid, + cfg80211_michael_mic_failure(vif->ndev, vif->bssid, (ismcast ? NL80211_KEYTYPE_GROUP : NL80211_KEYTYPE_PAIRWISE), keyid, NULL, GFP_KERNEL); @@ -1282,18 +1265,18 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, memcpy(vif->req_bssid, ibss_param->bssid, sizeof(vif->req_bssid)); - ath6kl_set_wpa_version(ar, 0); + ath6kl_set_wpa_version(vif, 0); - status = ath6kl_set_auth_type(ar, NL80211_AUTHTYPE_OPEN_SYSTEM); + status = ath6kl_set_auth_type(vif, NL80211_AUTHTYPE_OPEN_SYSTEM); if (status) return status; if (ibss_param->privacy) { - ath6kl_set_cipher(ar, WLAN_CIPHER_SUITE_WEP40, true); - ath6kl_set_cipher(ar, WLAN_CIPHER_SUITE_WEP40, false); + ath6kl_set_cipher(vif, WLAN_CIPHER_SUITE_WEP40, true); + ath6kl_set_cipher(vif, WLAN_CIPHER_SUITE_WEP40, false); } else { - ath6kl_set_cipher(ar, 0, true); - ath6kl_set_cipher(ar, 0, false); + ath6kl_set_cipher(vif, 0, true); + ath6kl_set_cipher(vif, 0, false); } vif->nw_type = vif->next_mode; @@ -1329,7 +1312,7 @@ static int ath6kl_cfg80211_leave_ibss(struct wiphy *wiphy, if (!ath6kl_cfg80211_ready(ar)) return -EIO; - ath6kl_disconnect(ar, vif->fw_vif_idx); + ath6kl_disconnect(vif); memset(vif->ssid, 0, sizeof(vif->ssid)); vif->ssid_len = 0; @@ -1720,9 +1703,9 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, } if (p.prwise_crypto_type == 0) { p.prwise_crypto_type = NONE_CRYPT; - ath6kl_set_cipher(ar, 0, true); + ath6kl_set_cipher(vif, 0, true); } else if (info->crypto.n_ciphers_pairwise == 1) - ath6kl_set_cipher(ar, info->crypto.ciphers_pairwise[0], true); + ath6kl_set_cipher(vif, info->crypto.ciphers_pairwise[0], true); switch (info->crypto.cipher_group) { case WLAN_CIPHER_SUITE_WEP40: @@ -1739,7 +1722,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, p.grp_crypto_type = NONE_CRYPT; break; } - ath6kl_set_cipher(ar, info->crypto.cipher_group, false); + ath6kl_set_cipher(vif, info->crypto.cipher_group, false); p.nw_type = AP_NETWORK; vif->nw_type = vif->next_mode; diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 033e742..66042f2 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -24,20 +24,20 @@ int ath6kl_register_ieee80211_hw(struct ath6kl *ar); struct ath6kl *ath6kl_core_alloc(struct device *dev); void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar); -void ath6kl_cfg80211_scan_complete_event(struct ath6kl *ar, int status); +void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status); -void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel, +void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, u16 listen_intvl, u16 beacon_intvl, enum network_type nw_type, u8 beacon_ie_len, u8 assoc_req_len, u8 assoc_resp_len, u8 *assoc_info); -void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason, +void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 proto_reason); -void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl *ar, u8 keyid, +void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast); #endif /* ATH6KL_CFG80211_H */ diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f21d777..3fb8898 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -628,32 +628,32 @@ struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid); void ath6kl_ready_event(void *devt, u8 * datap, u32 sw_ver, u32 abi_ver); int ath6kl_control_tx(void *devt, struct sk_buff *skb, enum htc_endpoint_id eid); -void ath6kl_connect_event(struct ath6kl *ar, u16 channel, +void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, u16 listen_int, u16 beacon_int, enum network_type net_type, u8 beacon_ie_len, u8 assoc_req_len, u8 assoc_resp_len, u8 *assoc_info); -void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel); -void ath6kl_connect_ap_mode_sta(struct ath6kl *ar, u16 aid, u8 *mac_addr, +void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel); +void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, u8 keymgmt, u8 ucipher, u8 auth, u8 assoc_req_len, u8 *assoc_info); -void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, +void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 prot_reason_status); -void ath6kl_tkip_micerr_event(struct ath6kl *ar, u8 keyid, bool ismcast); +void ath6kl_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast); void ath6kl_txpwr_rx_evt(void *devt, u8 tx_pwr); -void ath6kl_scan_complete_evt(struct ath6kl *ar, int status); -void ath6kl_tgt_stats_event(struct ath6kl *ar, u8 *ptr, u32 len); +void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status); +void ath6kl_tgt_stats_event(struct ath6kl_vif *vif, u8 *ptr, u32 len); void ath6kl_indicate_tx_activity(void *devt, u8 traffic_class, bool active); enum htc_endpoint_id ath6kl_ac2_endpoint_id(void *devt, u8 ac); -void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid); +void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid); -void ath6kl_dtimexpiry_event(struct ath6kl *ar); -void ath6kl_disconnect(struct ath6kl *ar, u8 if_idx); +void ath6kl_dtimexpiry_event(struct ath6kl_vif *vif); +void ath6kl_disconnect(struct ath6kl_vif *vif); void ath6kl_deep_sleep_enable(struct ath6kl *ar); -void aggr_recv_delba_req_evt(struct ath6kl *ar, u8 tid); -void aggr_recv_addba_req_evt(struct ath6kl *ar, u8 tid, u16 seq_no, +void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid); +void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, u8 win_sz); void ath6kl_wakeup_event(void *dev); void ath6kl_target_failure(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 870e9b1..54faa6b 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1249,6 +1249,8 @@ static ssize_t ath6kl_create_qos_write(struct file *file, { struct ath6kl *ar = file->private_data; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; char buf[100]; ssize_t len; char *sptr, *token; @@ -1403,7 +1405,7 @@ static ssize_t ath6kl_create_qos_write(struct file *file, return -EINVAL; pstream.medium_time = cpu_to_le32(val32); - ath6kl_wmi_create_pstream_cmd(ar->wmi, &pstream); + ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream); return count; } @@ -1421,6 +1423,8 @@ static ssize_t ath6kl_delete_qos_write(struct file *file, { struct ath6kl *ar = file->private_data; + /* TODO: Findout vif */ + struct ath6kl_vif *vif = ar->vif; char buf[100]; ssize_t len; char *sptr, *token; @@ -1445,7 +1449,8 @@ static ssize_t ath6kl_delete_qos_write(struct file *file, if (kstrtou8(token, 0, &tsid)) return -EINVAL; - ath6kl_wmi_delete_pstream_cmd(ar->wmi, traffic_class, tsid); + ath6kl_wmi_delete_pstream_cmd(ar->wmi, vif->fw_vif_idx, + traffic_class, tsid); return count; } diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 9929901..19b64ae 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -441,7 +441,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, if (test_bit(WMI_READY, &ar->flag)) { discon_issued = (test_bit(CONNECTED, &vif->flags) || test_bit(CONNECT_PEND, &vif->flags)); - ath6kl_disconnect(ar, vif->fw_vif_idx); + ath6kl_disconnect(vif); if (!keep_profile) ath6kl_init_profile_info(ar); @@ -462,7 +462,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, * are collected. */ if (discon_issued) - ath6kl_disconnect_event(ar, DISCONNECT_CMD, + ath6kl_disconnect_event(vif, DISCONNECT_CMD, (vif->nw_type & AP_NETWORK) ? bcast_mac : vif->bssid, 0, NULL, 0); @@ -498,10 +498,8 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, ath6kl_reset_device(ar, ar->target_type, true, true); } -static void ath6kl_install_static_wep_keys(struct ath6kl *ar) +static void ath6kl_install_static_wep_keys(struct ath6kl_vif *vif) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; u8 index; u8 keyusage; @@ -511,7 +509,7 @@ static void ath6kl_install_static_wep_keys(struct ath6kl *ar) if (index == vif->def_txkey_index) keyusage |= TX_USAGE; - ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, + ath6kl_wmi_addkey_cmd(vif->ar->wmi, vif->fw_vif_idx, index, WEP_CRYPT, keyusage, @@ -524,13 +522,12 @@ static void ath6kl_install_static_wep_keys(struct ath6kl *ar) } } -void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel) +void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel) { + struct ath6kl *ar = vif->ar; struct ath6kl_req_key *ik; int res; u8 key_rsc[ATH6KL_KEY_SEQ_LEN]; - /* TODO: Pass vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; ik = &ar->ap_mode_bkey; @@ -539,7 +536,7 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel) switch (vif->auth_mode) { case NONE_AUTH: if (vif->prwise_crypto == WEP_CRYPT) - ath6kl_install_static_wep_keys(ar); + ath6kl_install_static_wep_keys(vif); break; case WPA_PSK_AUTH: case WPA2_PSK_AUTH: @@ -561,15 +558,16 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl *ar, u16 channel) break; } - ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); + ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, NONE_BSS_FILTER, 0); set_bit(CONNECTED, &vif->flags); - netif_carrier_on(ar->net_dev); + netif_carrier_on(vif->ndev); } -void ath6kl_connect_ap_mode_sta(struct ath6kl *ar, u16 aid, u8 *mac_addr, +void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, u8 keymgmt, u8 ucipher, u8 auth, u8 assoc_req_len, u8 *assoc_info) { + struct ath6kl *ar = vif->ar; u8 *ies = NULL, *wpa_ie = NULL, *pos; size_t ies_len = 0; struct station_info sinfo; @@ -624,9 +622,9 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl *ar, u16 aid, u8 *mac_addr, sinfo.assoc_req_ies_len = ies_len; sinfo.filled |= STATION_INFO_ASSOC_REQ_IES; - cfg80211_new_sta(ar->net_dev, mac_addr, &sinfo, GFP_KERNEL); + cfg80211_new_sta(vif->ndev, mac_addr, &sinfo, GFP_KERNEL); - netif_wake_queue(ar->net_dev); + netif_wake_queue(vif->ndev); } /* Functions for Tx credit handling */ @@ -916,17 +914,14 @@ void disconnect_timer_handler(unsigned long ptr) struct ath6kl_vif *vif = netdev_priv(dev); ath6kl_init_profile_info(vif->ar); - ath6kl_disconnect(vif->ar, vif->fw_vif_idx); + ath6kl_disconnect(vif); } -void ath6kl_disconnect(struct ath6kl *ar, u8 if_idx) +void ath6kl_disconnect(struct ath6kl_vif *vif) { - /* TODO: Pass vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; - if (test_bit(CONNECTED, &vif->flags) || test_bit(CONNECT_PEND, &vif->flags)) { - ath6kl_wmi_disconnect_cmd(ar->wmi, if_idx); + ath6kl_wmi_disconnect_cmd(vif->ar->wmi, vif->fw_vif_idx); /* * Disconnect command is issued, clear the connect pending * flag. The connected flag will be cleared in @@ -971,7 +966,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) printk(KERN_WARNING "ath6kl: failed to disable scan " "during suspend\n"); - ath6kl_cfg80211_scan_complete_event(ar, -ECANCELED); + ath6kl_cfg80211_scan_complete_event(vif, -ECANCELED); /* save the current power mode before enabling power save */ ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; @@ -1027,31 +1022,30 @@ void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) test_bit(TESTMODE, &ar->flag) ? " testmode" : ""); } -void ath6kl_scan_complete_evt(struct ath6kl *ar, int status) +void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status) { - /* TODO: Pass vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; - ath6kl_cfg80211_scan_complete_event(ar, status); + ath6kl_cfg80211_scan_complete_event(vif, status); if (!ar->usr_bss_filter) { clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); - ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); + ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, + NONE_BSS_FILTER, 0); } ath6kl_dbg(ATH6KL_DBG_WLAN_SCAN, "scan complete: %d\n", status); } -void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, +void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, u16 listen_int, u16 beacon_int, enum network_type net_type, u8 beacon_ie_len, u8 assoc_req_len, u8 assoc_resp_len, u8 *assoc_info) { - /* TODO: findout vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; - ath6kl_cfg80211_connect_event(ar, channel, bssid, + ath6kl_cfg80211_connect_event(vif, channel, bssid, listen_int, beacon_int, net_type, beacon_ie_len, assoc_req_len, assoc_resp_len, @@ -1065,13 +1059,13 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, ar->listen_intvl_t, ar->listen_intvl_b); - netif_wake_queue(ar->net_dev); + netif_wake_queue(vif->ndev); /* Update connect & link status atomically */ spin_lock_bh(&ar->lock); set_bit(CONNECTED, &vif->flags); clear_bit(CONNECT_PEND, &vif->flags); - netif_carrier_on(ar->net_dev); + netif_carrier_on(vif->ndev); spin_unlock_bh(&ar->lock); aggr_reset_state(vif->aggr_cntxt); @@ -1085,16 +1079,17 @@ void ath6kl_connect_event(struct ath6kl *ar, u16 channel, u8 *bssid, if (!ar->usr_bss_filter) { set_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); - ath6kl_wmi_bssfilter_cmd(ar->wmi, CURRENT_BSS_FILTER, 0); + ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, + CURRENT_BSS_FILTER, 0); } } -void ath6kl_tkip_micerr_event(struct ath6kl *ar, u8 keyid, bool ismcast) +void ath6kl_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast) { struct ath6kl_sta *sta; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; u8 tsc[6]; + /* * For AP case, keyid will have aid of STA which sent pkt with * MIC error. Use this aid to get MAC & send it to hostapd. @@ -1108,20 +1103,19 @@ void ath6kl_tkip_micerr_event(struct ath6kl *ar, u8 keyid, bool ismcast) "ap tkip mic error received from aid=%d\n", keyid); memset(tsc, 0, sizeof(tsc)); /* FIX: get correct TSC */ - cfg80211_michael_mic_failure(ar->net_dev, sta->mac, + cfg80211_michael_mic_failure(vif->ndev, sta->mac, NL80211_KEYTYPE_PAIRWISE, keyid, tsc, GFP_KERNEL); } else - ath6kl_cfg80211_tkip_micerr_event(ar, keyid, ismcast); + ath6kl_cfg80211_tkip_micerr_event(vif, keyid, ismcast); } -static void ath6kl_update_target_stats(struct ath6kl *ar, u8 *ptr, u32 len) +static void ath6kl_update_target_stats(struct ath6kl_vif *vif, u8 *ptr, u32 len) { struct wmi_target_stats *tgt_stats = (struct wmi_target_stats *) ptr; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; struct target_stats *stats = &vif->target_stats; struct tkip_ccmp_stats *ccmp_stats; u8 ac; @@ -1229,13 +1223,12 @@ static void ath6kl_add_le32(__le32 *var, __le32 val) *var = cpu_to_le32(le32_to_cpu(*var) + le32_to_cpu(val)); } -void ath6kl_tgt_stats_event(struct ath6kl *ar, u8 *ptr, u32 len) +void ath6kl_tgt_stats_event(struct ath6kl_vif *vif, u8 *ptr, u32 len) { struct wmi_ap_mode_stat *p = (struct wmi_ap_mode_stat *) ptr; + struct ath6kl *ar = vif->ar; struct wmi_ap_mode_stat *ap = &ar->ap_stats; struct wmi_per_sta_stat *st_ap, *st_p; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; u8 ac; if (vif->nw_type == AP_NETWORK) { @@ -1257,7 +1250,7 @@ void ath6kl_tgt_stats_event(struct ath6kl *ar, u8 *ptr, u32 len) } } else { - ath6kl_update_target_stats(ar, ptr, len); + ath6kl_update_target_stats(vif, ptr, len); } } @@ -1276,13 +1269,12 @@ void ath6kl_txpwr_rx_evt(void *devt, u8 tx_pwr) wake_up(&ar->event_wq); } -void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid) +void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid) { struct ath6kl_sta *conn; struct sk_buff *skb; bool psq_empty = false; - /* TODO: Pass vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; conn = ath6kl_find_sta_by_aid(ar, aid); @@ -1305,7 +1297,7 @@ void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid) spin_unlock_bh(&conn->psq_lock); conn->sta_flags |= STA_PS_POLLED; - ath6kl_data_tx(skb, ar->net_dev); + ath6kl_data_tx(skb, vif->ndev); conn->sta_flags &= ~STA_PS_POLLED; spin_lock_bh(&conn->psq_lock); @@ -1316,12 +1308,11 @@ void ath6kl_pspoll_event(struct ath6kl *ar, u8 aid) ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, conn->aid, 0); } -void ath6kl_dtimexpiry_event(struct ath6kl *ar) +void ath6kl_dtimexpiry_event(struct ath6kl_vif *vif) { bool mcastq_empty = false; struct sk_buff *skb; - /* TODO: Pass vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; /* * If there are no associated STAs, ignore the DTIM expiry event. @@ -1349,7 +1340,7 @@ void ath6kl_dtimexpiry_event(struct ath6kl *ar) while ((skb = skb_dequeue(&ar->mcastpsq)) != NULL) { spin_unlock_bh(&ar->mcastpsq_lock); - ath6kl_data_tx(skb, ar->net_dev); + ath6kl_data_tx(skb, vif->ndev); spin_lock_bh(&ar->mcastpsq_lock); } @@ -1361,12 +1352,11 @@ void ath6kl_dtimexpiry_event(struct ath6kl *ar) ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, MCAST_AID, 0); } -void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, +void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 prot_reason_status) { - /* TODO: Findout vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; if (vif->nw_type == AP_NETWORK) { if (!ath6kl_remove_sta(ar, bssid, prot_reason_status)) @@ -1386,17 +1376,17 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, if (!is_broadcast_ether_addr(bssid)) { /* send event to application */ - cfg80211_del_sta(ar->net_dev, bssid, GFP_KERNEL); + cfg80211_del_sta(vif->ndev, bssid, GFP_KERNEL); } - if (memcmp(ar->net_dev->dev_addr, bssid, ETH_ALEN) == 0) { + if (memcmp(vif->ndev->dev_addr, bssid, ETH_ALEN) == 0) { memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list)); clear_bit(CONNECTED, &vif->flags); } return; } - ath6kl_cfg80211_disconnect_event(ar, reason, bssid, + ath6kl_cfg80211_disconnect_event(vif, reason, bssid, assoc_resp_len, assoc_info, prot_reason_status); @@ -1414,7 +1404,8 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, */ if (reason == DISCONNECT_CMD) { if (!ar->usr_bss_filter && test_bit(WMI_READY, &ar->flag)) - ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); + ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, + NONE_BSS_FILTER, 0); } else { set_bit(CONNECT_PEND, &vif->flags); if (((reason == ASSOC_FAILED) && @@ -1429,7 +1420,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, /* update connect & link status atomically */ spin_lock_bh(&ar->lock); clear_bit(CONNECTED, &vif->flags); - netif_carrier_off(ar->net_dev); + netif_carrier_off(vif->ndev); spin_unlock_bh(&ar->lock); if ((reason != CSERV_DISCONNECT) || (vif->reconnect_flag != 1)) @@ -1438,7 +1429,7 @@ void ath6kl_disconnect_event(struct ath6kl *ar, u8 reason, u8 *bssid, if (reason != CSERV_DISCONNECT) ar->user_key_ctrl = 0; - netif_stop_queue(ar->net_dev); + netif_stop_queue(vif->ndev); memset(vif->bssid, 0, sizeof(vif->bssid)); vif->bss_ch = 0; @@ -1472,7 +1463,7 @@ static int ath6kl_close(struct net_device *dev) netif_stop_queue(dev); - ath6kl_disconnect(ar, vif->fw_vif_idx); + ath6kl_disconnect(vif); if (test_bit(WMI_READY, &ar->flag)) { if (ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, 0xFFFF, @@ -1482,7 +1473,7 @@ static int ath6kl_close(struct net_device *dev) clear_bit(WLAN_ENABLED, &vif->flags); } - ath6kl_cfg80211_scan_complete_event(ar, -ECANCELED); + ath6kl_cfg80211_scan_complete_event(vif, -ECANCELED); return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index c54f1a9..50ff9a4 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -287,7 +287,8 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) chk_adhoc_ps_mapping = true; else { /* get the stream mapping */ - ret = ath6kl_wmi_implicit_create_pstream(ar->wmi, skb, + ret = ath6kl_wmi_implicit_create_pstream(ar->wmi, + vif->fw_vif_idx, skb, 0, test_bit(WMM_ENABLED, &vif->flags), &ac); if (ret) goto fail_tx; @@ -1354,10 +1355,9 @@ static void aggr_delete_tid_state(struct aggr_info *p_aggr, u8 tid) memset(stats, 0, sizeof(struct rxtid_stats)); } -void aggr_recv_addba_req_evt(struct ath6kl *ar, u8 tid, u16 seq_no, u8 win_sz) +void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, + u8 win_sz) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; struct aggr_info *p_aggr = vif->aggr_cntxt; struct rxtid *rxtid; struct rxtid_stats *stats; @@ -1425,10 +1425,8 @@ struct aggr_info *aggr_init(struct net_device *dev) return p_aggr; } -void aggr_recv_delba_req_evt(struct ath6kl *ar, u8 tid) +void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; struct aggr_info *p_aggr = vif->aggr_cntxt; struct rxtid *rxtid; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index a4ad7cb..ed092b7 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -21,7 +21,7 @@ #include "../regd.h" #include "../regd_common.h" -static int ath6kl_wmi_sync_point(struct wmi *wmi); +static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx); static const s32 wmi_rate_tbl[][2] = { /* {W/O SGI, with SGI} */ @@ -81,6 +81,14 @@ enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) return wmi->ep_id; } +static struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) +{ + if (WARN_ON(if_idx > (MAX_NUM_VIF - 1))) + return NULL; + + return ar->vif; +} + /* Performs DIX to 802.3 encapsulation for transmit packets. * Assumes the entire DIX header is contigous and that there is * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. @@ -216,7 +224,8 @@ static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) return ip_pri; } -int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, +int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, + struct sk_buff *skb, u32 layer2_priority, bool wmm_enabled, u8 *ac) { @@ -289,7 +298,7 @@ int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); /* Implicit streams are created with TSID 0xFF */ cmd.tsid = WMI_IMPLICIT_PSTREAM; - ath6kl_wmi_create_pstream_cmd(wmi, &cmd); + ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd); } *ac = traffic_class; @@ -415,7 +424,7 @@ static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) } static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, - int len) + int len, struct ath6kl_vif *vif) { struct wmi_remain_on_chnl_event *ev; u32 freq; @@ -437,14 +446,15 @@ static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, "(freq=%u)\n", freq); return -EINVAL; } - cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT, + cfg80211_ready_on_channel(vif->ndev, 1, chan, NL80211_CHAN_NO_HT, dur, GFP_ATOMIC); return 0; } static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, - u8 *datap, int len) + u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_cancel_remain_on_chnl_event *ev; u32 freq; @@ -466,17 +476,17 @@ static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, "channel (freq=%u)\n", freq); return -EINVAL; } - cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan, + cfg80211_remain_on_channel_expired(vif->ndev, 1, chan, NL80211_CHAN_NO_HT, GFP_ATOMIC); return 0; } -static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_tx_status_event *ev; u32 id; - struct ath6kl *ar = wmi->parent_dev; if (len < sizeof(*ev)) return -EINVAL; @@ -486,7 +496,7 @@ static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", id, ev->ack_status); if (wmi->last_mgmt_tx_frame) { - cfg80211_mgmt_tx_status(ar->net_dev, id, + cfg80211_mgmt_tx_status(vif->ndev, id, wmi->last_mgmt_tx_frame, wmi->last_mgmt_tx_frame_len, !!ev->ack_status, GFP_ATOMIC); @@ -498,14 +508,12 @@ static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) return 0; } -static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_p2p_rx_probe_req_event *ev; u32 freq; u16 dlen; - struct ath6kl *ar = wmi->parent_dev; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; if (len < sizeof(*ev)) return -EINVAL; @@ -523,7 +531,7 @@ static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) dlen, freq, vif->probe_req_report); if (vif->probe_req_report || vif->nw_type == AP_NETWORK) - cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); + cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); return 0; } @@ -543,12 +551,12 @@ static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) return 0; } -static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_rx_action_event *ev; u32 freq; u16 dlen; - struct ath6kl *ar = wmi->parent_dev; if (len < sizeof(*ev)) return -EINVAL; @@ -562,7 +570,7 @@ static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len) return -EINVAL; } ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); - cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); + cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); return 0; } @@ -726,13 +734,11 @@ int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) NO_SYNC_WMIFLAG); } -static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_connect_event *ev; u8 *pie, *peie; - struct ath6kl *ar = wmi->parent_dev; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; if (len < sizeof(struct wmi_connect_event)) return -EINVAL; @@ -741,14 +747,14 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) if (vif->nw_type == AP_NETWORK) { /* AP mode start/STA connected event */ - struct net_device *dev = ar->net_dev; + struct net_device *dev = vif->ndev; if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM " "(AP started)\n", __func__, le16_to_cpu(ev->u.ap_bss.ch), ev->u.ap_bss.bssid); ath6kl_connect_ap_mode_bss( - ar, le16_to_cpu(ev->u.ap_bss.ch)); + vif, le16_to_cpu(ev->u.ap_bss.ch)); } else { ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM " "auth=%u keymgmt=%u cipher=%u apsd_info=%u " @@ -760,7 +766,7 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) le16_to_cpu(ev->u.ap_sta.cipher), ev->u.ap_sta.apsd_info); ath6kl_connect_ap_mode_sta( - ar, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, + vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, ev->u.ap_sta.keymgmt, le16_to_cpu(ev->u.ap_sta.cipher), ev->u.ap_sta.auth, ev->assoc_req_len, @@ -805,7 +811,7 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) pie += pie[1] + 2; } - ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->u.sta.ch), + ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid, le16_to_cpu(ev->u.sta.listen_intvl), le16_to_cpu(ev->u.sta.beacon_intvl), @@ -891,7 +897,8 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) } } -static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_disconnect_event *ev; wmi->traffic_class = 100; @@ -908,7 +915,7 @@ static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) wmi->is_wmm_enabled = false; - ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, + ath6kl_disconnect_event(vif, ev->disconn_reason, ev->bssid, ev->assoc_resp_len, ev->assoc_info, le16_to_cpu(ev->proto_reason_status)); @@ -934,7 +941,8 @@ static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) return 0; } -static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_tkip_micerr_event *ev; @@ -943,12 +951,13 @@ static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) ev = (struct wmi_tkip_micerr_event *) datap; - ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); + ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast); return 0; } -static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_bss_info_hdr2 *bih; u8 *buf; @@ -956,8 +965,6 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) struct ath6kl *ar = wmi->parent_dev; struct ieee80211_mgmt *mgmt; struct cfg80211_bss *bss; - /*TODO: Findout vif properly */ - struct ath6kl_vif *vif = ar->vif; if (len <= sizeof(struct wmi_bss_info_hdr2)) return -EINVAL; @@ -979,7 +986,8 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) if (bih->frame_type == BEACON_FTYPE && test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) { clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); - ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); + ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, + NONE_BSS_FILTER, 0); } channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch)); @@ -1016,7 +1024,7 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) IEEE80211_STYPE_BEACON); memset(mgmt->da, 0xff, ETH_ALEN); } else { - struct net_device *dev = ar->net_dev; + struct net_device *dev = vif->ndev; mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); @@ -1144,20 +1152,21 @@ static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) return 0; } -static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_scan_complete_event *ev; ev = (struct wmi_scan_complete_event *) datap; - ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); + ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status)); wmi->is_probe_ssid = false; return 0; } static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, - int len) + int len, struct ath6kl_vif *vif) { struct wmi_neighbor_report_event *ev; u8 i; @@ -1175,7 +1184,7 @@ static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n", i + 1, ev->num_neighbors, ev->neighbor[i].bssid, ev->neighbor[i].bss_flags); - cfg80211_pmksa_candidate_notify(wmi->parent_dev->net_dev, i, + cfg80211_pmksa_candidate_notify(vif->ndev, i, ev->neighbor[i].bssid, !!(ev->neighbor[i].bss_flags & WMI_PREAUTH_CAPABLE_BSS), @@ -1216,9 +1225,10 @@ static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) return 0; } -static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { - ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); + ath6kl_tgt_stats_event(vif, datap, len); return 0; } @@ -1372,7 +1382,8 @@ static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, return 0; } -static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_cac_event *reply; struct ieee80211_tspec_ie *ts; @@ -1393,7 +1404,8 @@ static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & IEEE80211_WMM_IE_TSPEC_TID_MASK; - ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); + ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, + reply->ac, tsid); } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { /* * Following assumes that there is only one outstanding @@ -1408,7 +1420,8 @@ static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) break; } if (index < (sizeof(active_tsids) * 8)) - ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); + ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, + reply->ac, index); } /* @@ -1605,7 +1618,7 @@ int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, * Make sure all data currently queued is transmitted before * the cmd execution. Establish a new sync point. */ - ath6kl_wmi_sync_point(wmi); + ath6kl_wmi_sync_point(wmi, if_idx); } skb_push(skb, sizeof(struct wmi_cmd_hdr)); @@ -1634,7 +1647,7 @@ int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, * Make sure all new data queued waits for the command to * execute. Establish a new sync point. */ - ath6kl_wmi_sync_point(wmi); + ath6kl_wmi_sync_point(wmi, if_idx); } return 0; @@ -1816,7 +1829,7 @@ int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, return ret; } -int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) +int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask) { struct sk_buff *skb; struct wmi_bss_filter_cmd *cmd; @@ -1833,7 +1846,7 @@ int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) cmd->bss_filter = filter; cmd->ie_mask = cpu_to_le32(ie_mask); - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_BSS_FILTER_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -2010,7 +2023,7 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, return ret; } -int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) +int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk) { struct sk_buff *skb; struct wmi_add_krk_cmd *cmd; @@ -2023,7 +2036,7 @@ int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) cmd = (struct wmi_add_krk_cmd *) skb->data; memcpy(cmd->krk, krk, WMI_KRK_LEN); - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_ADD_KRK_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); return ret; @@ -2104,7 +2117,7 @@ static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, return ret; } -static int ath6kl_wmi_sync_point(struct wmi *wmi) +static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx) { struct sk_buff *skb; struct wmi_sync_cmd *cmd; @@ -2160,7 +2173,7 @@ static int ath6kl_wmi_sync_point(struct wmi *wmi) * Send sync cmd followed by sync data messages on all * endpoints being used */ - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SYNCHRONIZE_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID, NO_SYNC_WMIFLAG); if (ret) @@ -2202,7 +2215,7 @@ free_skb: return ret; } -int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, +int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx, struct wmi_create_pstream_cmd *params) { struct sk_buff *skb; @@ -2291,12 +2304,13 @@ int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, ath6kl_indicate_tx_activity(wmi->parent_dev, params->traffic_class, true); - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_CREATE_PSTREAM_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) +int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, + u8 tsid) { struct sk_buff *skb; struct wmi_delete_pstream_cmd *cmd; @@ -2332,7 +2346,7 @@ int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", traffic_class, tsid); - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DELETE_PSTREAM_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID, SYNC_BEFORE_WMIFLAG); spin_lock_bh(&wmi->lock); @@ -2598,21 +2612,23 @@ static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, return 0; } -static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; - aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, + aggr_recv_addba_req_evt(vif, cmd->tid, le16_to_cpu(cmd->st_seq_no), cmd->win_sz); return 0; } -static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; - aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); + aggr_recv_delba_req_evt(vif, cmd->tid); return 0; } @@ -2661,7 +2677,8 @@ int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, NO_SYNC_WMIFLAG); } -static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { struct wmi_pspoll_event *ev; @@ -2670,14 +2687,15 @@ static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) ev = (struct wmi_pspoll_event *) datap; - ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); + ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid)); return 0; } -static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len, + struct ath6kl_vif *vif) { - ath6kl_dtimexpiry_event(wmi->parent_dev); + ath6kl_dtimexpiry_event(vif); return 0; } @@ -2930,8 +2948,10 @@ static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) { struct wmi_cmd_hdr *cmd; + struct ath6kl_vif *vif; u32 len; u16 id; + u8 if_idx; u8 *datap; int ret = 0; @@ -2946,6 +2966,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) cmd = (struct wmi_cmd_hdr *) skb->data; id = le16_to_cpu(cmd->cmd_id); + if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK; skb_pull(skb, sizeof(struct wmi_cmd_hdr)); @@ -2956,6 +2977,15 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ", datap, len); + vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx); + if (!vif) { + ath6kl_dbg(ATH6KL_DBG_WMI, + "Wmi event for unavailable vif, vif_index:%d\n", + if_idx); + dev_kfree_skb(skb); + return -EINVAL; + } + switch (id) { case WMI_GET_BITRATE_CMDID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); @@ -2975,11 +3005,11 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_CONNECT_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); - ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); + ret = ath6kl_wmi_connect_event_rx(wmi, datap, len, vif); break; case WMI_DISCONNECT_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); - ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); + ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif); break; case WMI_PEER_NODE_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); @@ -2987,11 +3017,11 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_TKIP_MICERR_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); - ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); + ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif); break; case WMI_BSSINFO_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); - ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len); + ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif); break; case WMI_REGDOMAIN_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); @@ -3003,11 +3033,12 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_NEIGHBOR_REPORT_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); - ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len); + ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len, + vif); break; case WMI_SCAN_COMPLETE_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); - ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); + ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif); break; case WMI_CMDERROR_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); @@ -3015,7 +3046,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_REPORT_STATISTICS_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); - ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); + ret = ath6kl_wmi_stats_event_rx(wmi, datap, len, vif); break; case WMI_RSSI_THRESHOLD_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); @@ -3038,7 +3069,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_CAC_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); - ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); + ret = ath6kl_wmi_cac_event_rx(wmi, datap, len, vif); break; case WMI_CHANNEL_CHANGE_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); @@ -3082,25 +3113,25 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_PSPOLL_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); - ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); + ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif); break; case WMI_DTIMEXPIRY_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); - ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); + ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif); break; case WMI_SET_PARAMS_REPLY_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); break; case WMI_ADDBA_REQ_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); - ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); + ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif); break; case WMI_ADDBA_RESP_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); break; case WMI_DELBA_REQ_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); - ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); + ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif); break; case WMI_REPORT_BTCOEX_CONFIG_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, @@ -3116,21 +3147,21 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_REMAIN_ON_CHNL_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); - ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len); + ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); break; case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, - len); + len, vif); break; case WMI_TX_STATUS_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); - ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len); + ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif); break; case WMI_RX_PROBE_REQ_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); - ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len); + ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif); break; case WMI_P2P_CAPABILITIES_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); @@ -3138,7 +3169,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_RX_ACTION_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); - ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len); + ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif); break; case WMI_P2P_INFO_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 83bf46c..d2c9510 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2171,9 +2171,9 @@ int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb); int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb); -int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, - u32 layer2_priority, bool wmm_enabled, - u8 *ac); +int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, + struct sk_buff *skb, u32 layer2_priority, + bool wmm_enabled, u8 *ac); int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb); @@ -2204,7 +2204,8 @@ int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, u16 fg_start_sec, u16 pas_chdw_msec, u8 short_scan_ratio, u8 scan_ctrl_flag, u32 max_dfsch_act_time, u16 maxact_scan_per_ssid); -int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask); +int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, + u32 ie_mask); int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, u8 ssid_len, u8 *ssid); int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, @@ -2216,9 +2217,10 @@ int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, u16 tx_wakup_policy, u16 num_tx_to_wakeup, u16 ps_fail_event_policy); int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout); -int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, +int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx, struct wmi_create_pstream_cmd *pstream); -int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid); +int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, + u8 tsid); int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold); int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, @@ -2234,7 +2236,7 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, u8 *key_rsc, u8 *key_material, u8 key_op_ctrl, u8 *mac_addr, enum wmi_sync_flag sync_flag); -int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk); +int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk); int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index); int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, const u8 *pmkid, bool set); -- cgit v0.10.2 From 28ae58dd1f55f55dabf02fbc76a76f0809eee937 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:14 +0530 Subject: ath6kl: Remove net_device from ath6kl Use one which is available in vif structure instead. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2925463..9d8557e 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2116,7 +2116,6 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, vif->wdev.iftype = type; vif->fw_vif_idx = fw_vif_idx; ar->wdev = &vif->wdev; - ar->net_dev = ndev; init_netdev(ndev); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 3fb8898..4db0b15 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -446,7 +446,6 @@ enum ath6kl_dev_state { struct ath6kl { struct device *dev; - struct net_device *net_dev; struct wiphy *wiphy; struct ath6kl_bmi bmi; const struct ath6kl_hif_ops *hif_ops; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 957bfb0..6573957 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -521,7 +521,7 @@ void ath6kl_core_free(struct ath6kl *ar) int ath6kl_unavail_ev(struct ath6kl *ar) { - ath6kl_destroy(ar->net_dev, 1); + ath6kl_destroy(ar->vif->ndev, 1); return 0; } @@ -1417,7 +1417,7 @@ static int ath6kl_init(struct ath6kl *ar) ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", - __func__, ar->net_dev->name, ar->net_dev, ar); + __func__, ndev->name, ndev, ar); /* * The reason we have to wait for the target here is that the @@ -1580,8 +1580,8 @@ err_wq: void ath6kl_stop_txrx(struct ath6kl *ar) { - struct net_device *ndev = ar->net_dev; struct ath6kl_vif *vif = ar->vif; + struct net_device *ndev = vif->ndev; if (!ndev) return; diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 19b64ae..023624d 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -938,7 +938,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) switch (vif->sme_state) { case SME_CONNECTING: - cfg80211_connect_result(ar->net_dev, vif->bssid, NULL, 0, + cfg80211_connect_result(vif->ndev, vif->bssid, NULL, 0, NULL, 0, WLAN_STATUS_UNSPECIFIED_FAILURE, GFP_KERNEL); @@ -950,7 +950,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) * suspend, why? Need to send disconnected event in that * state. */ - cfg80211_disconnected(ar->net_dev, 0, NULL, 0, GFP_KERNEL); + cfg80211_disconnected(vif->ndev, 0, NULL, 0, GFP_KERNEL); break; } @@ -995,7 +995,7 @@ static const char *get_hw_id_string(u32 id) void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) { struct ath6kl *ar = devt; - struct net_device *dev = ar->net_dev; + struct net_device *dev = ar->vif->ndev; memcpy(dev->dev_addr, datap, ETH_ALEN); ath6kl_dbg(ATH6KL_DBG_TRC, "%s: mac addr = %pM\n", diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 50ff9a4..7e2d601 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -478,7 +478,7 @@ stop_net_queues: spin_lock_bh(&ar->lock); set_bit(NETQ_STOPPED, &vif->flags); spin_unlock_bh(&ar->lock); - netif_stop_queue(ar->net_dev); + netif_stop_queue(vif->ndev); return HTC_SEND_FULL_KEEP; } @@ -619,7 +619,7 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) if (test_bit(CONNECTED, &vif->flags)) { if (!flushing) - netif_wake_queue(ar->net_dev); + netif_wake_queue(vif->ndev); } if (wake_event) @@ -1086,12 +1086,12 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, __func__, "rx ", skb->data, skb->len); - skb->dev = ar->net_dev; + skb->dev = vif->ndev; if (!test_bit(WMI_ENABLED, &ar->flag)) { if (EPPING_ALIGNMENT_PAD > 0) skb_pull(skb, EPPING_ALIGNMENT_PAD); - ath6kl_deliver_frames_to_nw_stack(ar->net_dev, skb); + ath6kl_deliver_frames_to_nw_stack(vif->ndev, skb); return; } @@ -1174,7 +1174,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) while ((skbuff = skb_dequeue(&conn->psq)) != NULL) { spin_unlock_bh(&conn->psq_lock); - ath6kl_data_tx(skbuff, ar->net_dev); + ath6kl_data_tx(skbuff, vif->ndev); spin_lock_bh(&conn->psq_lock); } spin_unlock_bh(&conn->psq_lock); @@ -1230,7 +1230,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) return; } - if (!(ar->net_dev->flags & IFF_UP)) { + if (!(vif->ndev->flags & IFF_UP)) { dev_kfree_skb(skb); return; } @@ -1261,7 +1261,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) } } if (skb1) - ath6kl_data_tx(skb1, ar->net_dev); + ath6kl_data_tx(skb1, vif->ndev); if (skb == NULL) { /* nothing to deliver up the stack */ @@ -1277,7 +1277,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) /* aggregation code will handle the skb */ return; - ath6kl_deliver_frames_to_nw_stack(ar->net_dev, skb); + ath6kl_deliver_frames_to_nw_stack(vif->ndev, skb); } static void aggr_timeout(unsigned long arg) -- cgit v0.10.2 From e29f25f5cd23d705b3a186e53cfddd3663875c45 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:15 +0530 Subject: ath6kl: Cleanup parameters in ath6kl_init_control_info() and ath6kl_init_profile_info() Pass vif structure to those functions instead of ath6kl because these functions do vif specific information initialization. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 9d8557e..1a29fec 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2119,7 +2119,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, init_netdev(ndev); - ath6kl_init_control_info(ar); + ath6kl_init_control_info(vif); /* TODO: Pass interface specific pointer instead of ar */ if (ath6kl_init_if_data(vif)) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 4db0b15..de288ff 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -602,7 +602,7 @@ int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length); int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value); int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length); int ath6kl_read_fwlogs(struct ath6kl *ar); -void ath6kl_init_profile_info(struct ath6kl *ar); +void ath6kl_init_profile_info(struct ath6kl_vif *vif); void ath6kl_tx_data_cleanup(struct ath6kl *ar); void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, bool get_dbglogs); @@ -657,7 +657,7 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, void ath6kl_wakeup_event(void *dev); void ath6kl_target_failure(struct ath6kl *ar); -void ath6kl_init_control_info(struct ath6kl *ar); +void ath6kl_init_control_info(struct ath6kl_vif *vif); void ath6kl_deinit_if_data(struct ath6kl_vif *vif); void ath6kl_core_free(struct ath6kl *ar); #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 6573957..7968c2b 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -73,11 +73,8 @@ struct sk_buff *ath6kl_buf_alloc(int size) return skb; } -void ath6kl_init_profile_info(struct ath6kl *ar) +void ath6kl_init_profile_info(struct ath6kl_vif *vif) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - vif->ssid_len = 0; memset(vif->ssid, 0, sizeof(vif->ssid)); @@ -246,12 +243,9 @@ static int ath6kl_init_service_ep(struct ath6kl *ar) return 0; } -void ath6kl_init_control_info(struct ath6kl *ar) +void ath6kl_init_control_info(struct ath6kl_vif *vif) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - - ath6kl_init_profile_info(ar); + ath6kl_init_profile_info(vif); vif->def_txkey_index = 0; memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list)); vif->ch_hint = 0; diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 023624d..08af257 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -443,7 +443,7 @@ void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, test_bit(CONNECT_PEND, &vif->flags)); ath6kl_disconnect(vif); if (!keep_profile) - ath6kl_init_profile_info(ar); + ath6kl_init_profile_info(vif); del_timer(&vif->disconnect_timer); @@ -913,7 +913,7 @@ void disconnect_timer_handler(unsigned long ptr) struct net_device *dev = (struct net_device *)ptr; struct ath6kl_vif *vif = netdev_priv(dev); - ath6kl_init_profile_info(vif->ar); + ath6kl_init_profile_info(vif); ath6kl_disconnect(vif); } -- cgit v0.10.2 From 6db8fa53ad4fa6d4b390e9bdd68f1238a01070ee Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:16 +0530 Subject: ath6kl: Refactor ath6kl_destroy() So that the deinitialization of ath6kl and vif are separated. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 1a29fec..b242b31 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2143,14 +2143,6 @@ err: void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - - if (vif->scan_req) { - cfg80211_scan_done(vif->scan_req, true); - vif->scan_req = NULL; - } - wiphy_unregister(ar->wiphy); wiphy_free(ar->wiphy); } diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index b92f0e5..877cb70 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -92,6 +92,6 @@ void ath6k_seek_credits(struct htc_credit_state_info *cred_inf, struct htc_endpoint_credit_dist *ep_dist); struct ath6kl *ath6kl_core_alloc(struct device *sdev); int ath6kl_core_init(struct ath6kl *ar); -int ath6kl_unavail_ev(struct ath6kl *ar); +void ath6kl_core_cleanup(struct ath6kl *ar); struct sk_buff *ath6kl_buf_alloc(int size); #endif /* COMMON_H */ diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index de288ff..498b626 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -584,7 +584,6 @@ static inline u32 ath6kl_get_hi_item_addr(struct ath6kl *ar, return addr; } -void ath6kl_destroy(struct net_device *dev, unsigned int unregister); int ath6kl_configure_target(struct ath6kl *ar); void ath6kl_detect_error(unsigned long ptr); void disconnect_timer_handler(unsigned long ptr); @@ -604,8 +603,6 @@ int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length); int ath6kl_read_fwlogs(struct ath6kl *ar); void ath6kl_init_profile_info(struct ath6kl_vif *vif); void ath6kl_tx_data_cleanup(struct ath6kl *ar); -void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, - bool get_dbglogs); struct ath6kl_cookie *ath6kl_alloc_cookie(struct ath6kl *ar); void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie); @@ -657,6 +654,8 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, void ath6kl_wakeup_event(void *dev); void ath6kl_target_failure(struct ath6kl *ar); +void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, + bool wait_fot_compltn, bool cold_reset); void ath6kl_init_control_info(struct ath6kl_vif *vif); void ath6kl_deinit_if_data(struct ath6kl_vif *vif); void ath6kl_core_free(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 7968c2b..05d54bc 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -513,11 +513,27 @@ void ath6kl_core_free(struct ath6kl *ar) wiphy_free(ar->wiphy); } -int ath6kl_unavail_ev(struct ath6kl *ar) +void ath6kl_core_cleanup(struct ath6kl *ar) { - ath6kl_destroy(ar->vif->ndev, 1); + destroy_workqueue(ar->ath6kl_wq); - return 0; + if (ar->htc_target) + ath6kl_htc_cleanup(ar->htc_target); + + ath6kl_cookie_cleanup(ar); + + ath6kl_cleanup_amsdu_rxbufs(ar); + + ath6kl_bmi_cleanup(ar); + + ath6kl_debug_cleanup(ar); + + kfree(ar->fw_board); + kfree(ar->fw_otp); + kfree(ar->fw); + kfree(ar->fw_patch); + + ath6kl_deinit_ieee80211_hw(ar); } /* firmware upload */ @@ -1572,6 +1588,36 @@ err_wq: return ret; } +static void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) +{ + static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + bool discon_issued; + + netif_stop_queue(vif->ndev); + + clear_bit(WLAN_ENABLED, &vif->flags); + + if (wmi_ready) { + discon_issued = test_bit(CONNECTED, &vif->flags) || + test_bit(CONNECT_PEND, &vif->flags); + ath6kl_disconnect(vif); + del_timer(&vif->disconnect_timer); + + if (discon_issued) + ath6kl_disconnect_event(vif, DISCONNECT_CMD, + (vif->nw_type & AP_NETWORK) ? + bcast_mac : vif->bssid, + 0, NULL, 0); + } + + if (vif->scan_req) { + cfg80211_scan_done(vif->scan_req, true); + vif->scan_req = NULL; + } + + ath6kl_deinit_if_data(vif); +} + void ath6kl_stop_txrx(struct ath6kl *ar) { struct ath6kl_vif *vif = ar->vif; @@ -1587,58 +1633,34 @@ void ath6kl_stop_txrx(struct ath6kl *ar) return; } - if (ar->wlan_pwr_state != WLAN_POWER_STATE_CUT_PWR) - ath6kl_stop_endpoint(ndev, false, true); + ath6kl_cleanup_vif(ar->vif, test_bit(WMI_READY, &ar->flag)); - clear_bit(WLAN_ENABLED, &vif->flags); -} + clear_bit(WMI_READY, &ar->flag); -/* - * We need to differentiate between the surprise and planned removal of the - * device because of the following consideration: - * - * - In case of surprise removal, the hcd already frees up the pending - * for the device and hence there is no need to unregister the function - * driver inorder to get these requests. For planned removal, the function - * driver has to explicitly unregister itself to have the hcd return all the - * pending requests before the data structures for the devices are freed up. - * Note that as per the current implementation, the function driver will - * end up releasing all the devices since there is no API to selectively - * release a particular device. - * - * - Certain commands issued to the target can be skipped for surprise - * removal since they will anyway not go through. - */ -void ath6kl_destroy(struct net_device *dev, unsigned int unregister) -{ - struct ath6kl *ar; + /* + * After wmi_shudown all WMI events will be dropped. We + * need to cleanup the buffers allocated in AP mode and + * give disconnect notification to stack, which usually + * happens in the disconnect_event. Simulate the disconnect + * event by calling the function directly. Sometimes + * disconnect_event will be received when the debug logs + * are collected. + */ + ath6kl_wmi_shutdown(ar->wmi); - if (!dev || !ath6kl_priv(dev)) { - ath6kl_err("failed to get device structure\n"); - return; + clear_bit(WMI_ENABLED, &ar->flag); + if (ar->htc_target) { + ath6kl_dbg(ATH6KL_DBG_TRC, "%s: shut down htc\n", __func__); + ath6kl_htc_stop(ar->htc_target); } - ar = ath6kl_priv(dev); - - destroy_workqueue(ar->ath6kl_wq); - - if (ar->htc_target) - ath6kl_htc_cleanup(ar->htc_target); - - ath6kl_cookie_cleanup(ar); - - ath6kl_cleanup_amsdu_rxbufs(ar); - - ath6kl_bmi_cleanup(ar); - - ath6kl_debug_cleanup(ar); - - ath6kl_deinit_if_data(netdev_priv(dev)); - - kfree(ar->fw_board); - kfree(ar->fw_otp); - kfree(ar->fw); - kfree(ar->fw_patch); + /* + * Try to reset the device if we can. The driver may have been + * configure NOT to reset the target during a debug session. + */ + ath6kl_dbg(ATH6KL_DBG_TRC, + "attempting to reset target on instance destroy\n"); + ath6kl_reset_device(ar, ar->target_type, true, true); - ath6kl_deinit_ieee80211_hw(ar); + clear_bit(WLAN_ENABLED, &ar->flag); } diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 08af257..a10002d 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -395,8 +395,8 @@ out: #define AR6003_RESET_CONTROL_ADDRESS 0x00004000 #define AR6004_RESET_CONTROL_ADDRESS 0x00004000 -static void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, - bool wait_fot_compltn, bool cold_reset) +void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, + bool wait_fot_compltn, bool cold_reset) { int status = 0; u32 address; @@ -427,77 +427,6 @@ static void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, ath6kl_err("failed to reset target\n"); } -void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, - bool get_dbglogs) -{ - struct ath6kl *ar = ath6kl_priv(dev); - struct ath6kl_vif *vif = netdev_priv(dev); - static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - bool discon_issued; - - netif_stop_queue(dev); - - /* disable the target and the interrupts associated with it */ - if (test_bit(WMI_READY, &ar->flag)) { - discon_issued = (test_bit(CONNECTED, &vif->flags) || - test_bit(CONNECT_PEND, &vif->flags)); - ath6kl_disconnect(vif); - if (!keep_profile) - ath6kl_init_profile_info(vif); - - del_timer(&vif->disconnect_timer); - - clear_bit(WMI_READY, &ar->flag); - ath6kl_wmi_shutdown(ar->wmi); - clear_bit(WMI_ENABLED, &ar->flag); - ar->wmi = NULL; - - /* - * After wmi_shudown all WMI events will be dropped. We - * need to cleanup the buffers allocated in AP mode and - * give disconnect notification to stack, which usually - * happens in the disconnect_event. Simulate the disconnect - * event by calling the function directly. Sometimes - * disconnect_event will be received when the debug logs - * are collected. - */ - if (discon_issued) - ath6kl_disconnect_event(vif, DISCONNECT_CMD, - (vif->nw_type & AP_NETWORK) ? - bcast_mac : vif->bssid, - 0, NULL, 0); - - ar->user_key_ctrl = 0; - - } else { - ath6kl_dbg(ATH6KL_DBG_TRC, - "%s: wmi is not ready 0x%p 0x%p\n", - __func__, ar, ar->wmi); - - /* Shut down WMI if we have started it */ - if (test_bit(WMI_ENABLED, &ar->flag)) { - ath6kl_dbg(ATH6KL_DBG_TRC, - "%s: shut down wmi\n", __func__); - ath6kl_wmi_shutdown(ar->wmi); - clear_bit(WMI_ENABLED, &ar->flag); - ar->wmi = NULL; - } - } - - if (ar->htc_target) { - ath6kl_dbg(ATH6KL_DBG_TRC, "%s: shut down htc\n", __func__); - ath6kl_htc_stop(ar->htc_target); - } - - /* - * Try to reset the device if we can. The driver may have been - * configure NOT to reset the target during a debug session. - */ - ath6kl_dbg(ATH6KL_DBG_TRC, - "attempting to reset target on instance destroy\n"); - ath6kl_reset_device(ar, ar->target_type, true, true); -} - static void ath6kl_install_static_wep_keys(struct ath6kl_vif *vif) { u8 index; diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index f73e14f..b7c0566 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -897,7 +897,7 @@ static void ath6kl_sdio_remove(struct sdio_func *func) ath6kl_stop_txrx(ar_sdio->ar); cancel_work_sync(&ar_sdio->wr_async_work); - ath6kl_unavail_ev(ar_sdio->ar); + ath6kl_core_cleanup(ar_sdio->ar); ath6kl_sdio_power_off(ar_sdio); -- cgit v0.10.2 From 6765d0aa5ff5b92098f5e571f26904106eae6ff3 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:17 +0530 Subject: ath6kl: Use interface index from wmi data headr Interface index is passed in wmi data header as well, use it to get the corresponding vif structure. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 498b626..466f6e1 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -618,7 +618,7 @@ struct htc_packet *ath6kl_alloc_amsdu_rxbuf(struct htc_target *target, void aggr_module_destroy(struct aggr_info *aggr_info); void aggr_reset_state(struct aggr_info *aggr_info); -struct ath6kl_sta *ath6kl_find_sta(struct ath6kl *ar, u8 * node_addr); +struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 * node_addr); struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid); void ath6kl_ready_event(void *devt, u8 * datap, u32 sw_ver, u32 abi_ver); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index a10002d..cc3e3c8 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -20,10 +20,9 @@ #include "target.h" #include "debug.h" -struct ath6kl_sta *ath6kl_find_sta(struct ath6kl *ar, u8 *node_addr) +struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 *node_addr) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; struct ath6kl_sta *conn = NULL; u8 i, max_conn; diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 7e2d601..e4a6d8f 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -77,14 +77,13 @@ static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, return ar->node_map[ep_map].ep_id; } -static bool ath6kl_powersave_ap(struct ath6kl *ar, struct sk_buff *skb, +static bool ath6kl_powersave_ap(struct ath6kl_vif *vif, struct sk_buff *skb, bool *more_data) { struct ethhdr *datap = (struct ethhdr *) skb->data; struct ath6kl_sta *conn = NULL; bool ps_queued = false, is_psq_empty = false; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; if (is_multicast_ether_addr(datap->h_dest)) { u8 ctr = 0; @@ -134,7 +133,7 @@ static bool ath6kl_powersave_ap(struct ath6kl *ar, struct sk_buff *skb, } } } else { - conn = ath6kl_find_sta(ar, datap->h_dest); + conn = ath6kl_find_sta(vif, datap->h_dest); if (!conn) { dev_kfree_skb(skb); @@ -261,7 +260,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) /* AP mode Power saving processing */ if (vif->nw_type == AP_NETWORK) { - if (ath6kl_powersave_ap(ar, skb, &more_data)) + if (ath6kl_powersave_ap(vif, skb, &more_data)) return 0; } @@ -277,7 +276,8 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) } if (ath6kl_wmi_data_hdr_add(ar->wmi, skb, DATA_MSGTYPE, - more_data, 0, 0, NULL)) { + more_data, 0, 0, NULL, + vif->fw_vif_idx)) { ath6kl_err("wmi_data_hdr_add failed\n"); goto fail_tx; } @@ -534,6 +534,7 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) enum htc_endpoint_id eid; bool wake_event = false; bool flushing = false; + u8 if_idx; /* TODO: Findout vif */ struct ath6kl_vif *vif = ar->vif; @@ -581,6 +582,20 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) wake_event = true; } + if (eid == ar->ctrl_ep) { + if_idx = wmi_cmd_hdr_get_if_idx( + (struct wmi_cmd_hdr *) skb->data); + } else { + if_idx = wmi_data_hdr_get_if_idx( + (struct wmi_data_hdr *) skb->data); + } + + vif = ath6kl_get_vif_by_index(ar, if_idx); + if (!vif) { + ath6kl_free_cookie(ar, ath6kl_cookie); + continue; + } + if (status) { if (status == -ECANCELED) /* a packet was flushed */ @@ -1053,10 +1068,9 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) struct ath6kl_sta *conn = NULL; struct sk_buff *skb1 = NULL; struct ethhdr *datap = NULL; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl_vif *vif; u16 seq_no, offset; - u8 tid; + u8 tid, if_idx; ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: ar=0x%p eid=%d, skb=0x%p, data=0x%p, len=0x%x status:%d", @@ -1064,7 +1078,23 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) packet->act_len, status); if (status || !(skb->data + HTC_HDR_LENGTH)) { - vif->net_stats.rx_errors++; + dev_kfree_skb(skb); + return; + } + + skb_put(skb, packet->act_len + HTC_HDR_LENGTH); + skb_pull(skb, HTC_HDR_LENGTH); + + if (ept == ar->ctrl_ep) { + if_idx = + wmi_cmd_hdr_get_if_idx((struct wmi_cmd_hdr *) skb->data); + } else { + if_idx = + wmi_data_hdr_get_if_idx((struct wmi_data_hdr *) skb->data); + } + + vif = ath6kl_get_vif_by_index(ar, if_idx); + if (!vif) { dev_kfree_skb(skb); return; } @@ -1080,8 +1110,6 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) spin_unlock_bh(&ar->lock); - skb_put(skb, packet->act_len + HTC_HDR_LENGTH); - skb_pull(skb, HTC_HDR_LENGTH); ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, __func__, "rx ", skb->data, skb->len); @@ -1143,7 +1171,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) } datap = (struct ethhdr *) (skb->data + offset); - conn = ath6kl_find_sta(ar, datap->h_source); + conn = ath6kl_find_sta(vif, datap->h_source); if (!conn) { dev_kfree_skb(skb); @@ -1250,7 +1278,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) * frame to it on the air else send the * frame up the stack. */ - conn = ath6kl_find_sta(ar, datap->h_dest); + conn = ath6kl_find_sta(vif, datap->h_dest); if (conn && ar->intra_bss) { skb1 = skb; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index ed092b7..ed95c2a 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -81,7 +81,7 @@ enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) return wmi->ep_id; } -static struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) +struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) { if (WARN_ON(if_idx > (MAX_NUM_VIF - 1))) return NULL; @@ -170,12 +170,12 @@ static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, u8 msg_type, bool more_data, enum wmi_data_hdr_data_type data_type, - u8 meta_ver, void *tx_meta_info) + u8 meta_ver, void *tx_meta_info, u8 if_idx) { struct wmi_data_hdr *data_hdr; int ret; - if (WARN_ON(skb == NULL)) + if (WARN_ON(skb == NULL || (if_idx > MAX_NUM_VIF - 1))) return -EINVAL; if (tx_meta_info) { @@ -197,7 +197,7 @@ int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); - data_hdr->info3 = 0; + data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); return 0; } @@ -1631,7 +1631,7 @@ int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, /* Only for OPT_TX_CMD, use BE endpoint. */ if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, - false, false, 0, NULL); + false, false, 0, NULL, if_idx); if (ret) { dev_kfree_skb(skb); return ret; @@ -2098,7 +2098,7 @@ int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, } static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, - enum htc_endpoint_id ep_id) + enum htc_endpoint_id ep_id, u8 if_idx) { struct wmi_data_hdr *data_hdr; int ret; @@ -2110,7 +2110,7 @@ static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, data_hdr = (struct wmi_data_hdr *) skb->data; data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; - data_hdr->info3 = 0; + data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); @@ -2192,7 +2192,7 @@ static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx) traffic_class); ret = ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, - ep_id); + ep_id, if_idx); if (ret) break; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index d2c9510..621189b7 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -173,6 +173,8 @@ enum wmi_data_hdr_data_type { #define WMI_DATA_HDR_META_MASK 0x7 #define WMI_DATA_HDR_META_SHIFT 13 +#define WMI_DATA_HDR_IF_IDX_MASK 0xF + struct wmi_data_hdr { s8 rssi; @@ -197,6 +199,12 @@ struct wmi_data_hdr { * b15:b13 - META_DATA_VERSION 0 - 7 */ __le16 info2; + + /* + * usage of info3, 16-bit: + * b3:b0 - Interface index + * b15:b4 - Reserved + */ __le16 info3; } __packed; @@ -239,6 +247,11 @@ static inline u8 wmi_data_hdr_get_meta(struct wmi_data_hdr *dhdr) WMI_DATA_HDR_META_MASK; } +static inline u8 wmi_data_hdr_get_if_idx(struct wmi_data_hdr *dhdr) +{ + return le16_to_cpu(dhdr->info3) & WMI_DATA_HDR_IF_IDX_MASK; +} + /* Tx meta version definitions */ #define WMI_MAX_TX_META_SZ 12 #define WMI_META_VERSION_1 0x01 @@ -303,6 +316,11 @@ struct wmi_cmd_hdr { __le16 reserved; } __packed; +static inline u8 wmi_cmd_hdr_get_if_idx(struct wmi_cmd_hdr *chdr) +{ + return le16_to_cpu(chdr->info1) & WMI_CMD_HDR_IF_ID_MASK; +} + /* List of WMI commands */ enum wmi_cmd_id { WMI_CONNECT_CMDID = 0x0001, @@ -2167,7 +2185,7 @@ int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb); int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, u8 msg_type, bool more_data, enum wmi_data_hdr_data_type data_type, - u8 meta_ver, void *tx_meta_info); + u8 meta_ver, void *tx_meta_info, u8 if_idx); int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb); int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb); @@ -2292,6 +2310,7 @@ int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx); int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, const u8 *ie, u8 ie_len); +struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx); void *ath6kl_wmi_init(struct ath6kl *devt); void ath6kl_wmi_shutdown(struct wmi *wmi); -- cgit v0.10.2 From d66ea4f9d63732790ae260eccb6c991dfa7a3b32 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:18 +0530 Subject: ath6kl: Store hw mac address in struct ath6kl WMI ready event gives the mac address, cache this mac address in struct ath6kl so that it can be used to compute the mac address for other vif in case of multi vif. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 466f6e1..747e5a7 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -492,6 +492,7 @@ struct ath6kl { struct wireless_dev *wdev; enum wlan_low_pwr_state wlan_pwr_state; struct wmi_scan_params_cmd sc_params; + u8 mac_addr[ETH_ALEN]; #define AR_MCAST_FILTER_MAC_ADDR_SIZE 4 struct { void *rx_report; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 05d54bc..99e4a49 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1504,8 +1504,16 @@ static int ath6kl_init(struct ath6kl *ar) WIPHY_FLAG_HAVE_AP_SME; status = ath6kl_target_config_wlan_params(ar); - if (!status) - goto ath6kl_init_done; + if (status) + goto err_htc_stop; + + /* + * Set mac address which is received in ready event + * FIXME: Move to ath6kl_interface_add() + */ + memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); + + return status; err_htc_stop: ath6kl_htc_stop(ar->htc_target); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index cc3e3c8..6bf9402 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -923,11 +923,10 @@ static const char *get_hw_id_string(u32 id) void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) { struct ath6kl *ar = devt; - struct net_device *dev = ar->vif->ndev; - memcpy(dev->dev_addr, datap, ETH_ALEN); + memcpy(ar->mac_addr, datap, ETH_ALEN); ath6kl_dbg(ATH6KL_DBG_TRC, "%s: mac addr = %pM\n", - __func__, dev->dev_addr); + __func__, ar->mac_addr); ar->version.wlan_ver = sw_ver; ar->version.abi_ver = abi_ver; -- cgit v0.10.2 From 478ac0272154023abb813db7ae12dc380caeb68e Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:19 +0530 Subject: ath6kl: Introduce spinlock to protect vif specific information Use this spinlock to protect the vif's data instead of one from ath6kl. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index b242b31..d5957b3 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2077,6 +2077,7 @@ static int ath6kl_init_if_data(struct ath6kl_vif *vif) setup_timer(&vif->disconnect_timer, disconnect_timer_handler, (unsigned long) vif->ndev); set_bit(WMM_ENABLED, &vif->flags); + spin_lock_init(&vif->if_lock); return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 747e5a7..2c64652 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -400,6 +400,8 @@ struct ath6kl_vif { struct wireless_dev wdev; struct net_device *ndev; struct ath6kl *ar; + /* Lock to protect vif specific net_stats and flags */ + spinlock_t if_lock; u8 fw_vif_idx; unsigned long flags; int ssid_len; diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 6bf9402..ca86ed3 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -989,11 +989,11 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, netif_wake_queue(vif->ndev); /* Update connect & link status atomically */ - spin_lock_bh(&ar->lock); + spin_lock_bh(&vif->if_lock); set_bit(CONNECTED, &vif->flags); clear_bit(CONNECT_PEND, &vif->flags); netif_carrier_on(vif->ndev); - spin_unlock_bh(&ar->lock); + spin_unlock_bh(&vif->if_lock); aggr_reset_state(vif->aggr_cntxt); vif->reconnect_flag = 0; @@ -1345,10 +1345,10 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, } /* update connect & link status atomically */ - spin_lock_bh(&ar->lock); + spin_lock_bh(&vif->if_lock); clear_bit(CONNECTED, &vif->flags); netif_carrier_off(vif->ndev); - spin_unlock_bh(&ar->lock); + spin_unlock_bh(&vif->if_lock); if ((reason != CSERV_DISCONNECT) || (vif->reconnect_flag != 1)) vif->reconnect_flag = 0; @@ -1365,11 +1365,8 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, static int ath6kl_open(struct net_device *dev) { - struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); - spin_lock_bh(&ar->lock); - set_bit(WLAN_ENABLED, &vif->flags); if (test_bit(CONNECTED, &vif->flags)) { @@ -1378,8 +1375,6 @@ static int ath6kl_open(struct net_device *dev) } else netif_carrier_off(dev); - spin_unlock_bh(&ar->lock); - return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index e4a6d8f..ff288da 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -475,9 +475,9 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, return HTC_SEND_FULL_DROP; stop_net_queues: - spin_lock_bh(&ar->lock); + spin_lock_bh(&vif->if_lock); set_bit(NETQ_STOPPED, &vif->flags); - spin_unlock_bh(&ar->lock); + spin_unlock_bh(&vif->if_lock); netif_stop_queue(vif->ndev); return HTC_SEND_FULL_KEEP; @@ -1103,12 +1103,12 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) * Take lock to protect buffer counts and adaptive power throughput * state. */ - spin_lock_bh(&ar->lock); + spin_lock_bh(&vif->if_lock); vif->net_stats.rx_packets++; vif->net_stats.rx_bytes += packet->act_len; - spin_unlock_bh(&ar->lock); + spin_unlock_bh(&vif->if_lock); ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, __func__, "rx ", -- cgit v0.10.2 From 990bd9151927ad55c7e3da3b05cf13ecfe7a31bf Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:20 +0530 Subject: ath6kl: Maintain virtual interface in a list This patch removes all references to ar->vif and takes vif from a list. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d5957b3..da4e46d 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -228,9 +228,9 @@ static void ath6kl_set_key_mgmt(struct ath6kl_vif *vif, u32 key_mgmt) } } -static bool ath6kl_cfg80211_ready(struct ath6kl *ar) +static bool ath6kl_cfg80211_ready(struct ath6kl_vif *vif) { - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; if (!test_bit(WMI_READY, &ar->flag)) { ath6kl_err("wmi is not ready\n"); @@ -302,7 +302,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->sme_state = SME_CONNECTING; - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) { @@ -614,7 +614,7 @@ static int ath6kl_cfg80211_disconnect(struct wiphy *wiphy, ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: reason=%u\n", __func__, reason_code); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) { @@ -713,7 +713,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, int ret = 0; u32 force_fg_scan = 0; - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (!ar->usr_bss_filter) { @@ -831,7 +831,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_type; int status = 0; - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (params->cipher == CCKM_KRK_CIPHER_SUITE) { @@ -953,7 +953,7 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { @@ -980,14 +980,13 @@ static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, void (*callback) (void *cookie, struct key_params *)) { - struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev); struct ath6kl_vif *vif = netdev_priv(ndev); struct ath6kl_key *key = NULL; struct key_params params; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { @@ -1024,7 +1023,7 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { @@ -1080,12 +1079,17 @@ void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, static int ath6kl_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) { struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy); + struct ath6kl_vif *vif; int ret; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: changed 0x%x\n", __func__, changed); - if (!ath6kl_cfg80211_ready(ar)) + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (changed & WIPHY_PARAM_RTS_THRESHOLD) { @@ -1108,12 +1112,17 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy, int dbm) { struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy); + struct ath6kl_vif *vif; u8 ath6kl_dbm; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type 0x%x, dbm %d\n", __func__, type, dbm); - if (!ath6kl_cfg80211_ready(ar)) + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + + if (!ath6kl_cfg80211_ready(vif)) return -EIO; switch (type) { @@ -1128,7 +1137,7 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy, return -EOPNOTSUPP; } - ath6kl_wmi_set_tx_pwr_cmd(ar->wmi, ath6kl_dbm); + ath6kl_wmi_set_tx_pwr_cmd(ar->wmi, vif->fw_vif_idx, ath6kl_dbm); return 0; } @@ -1136,15 +1145,19 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy, static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) { struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy); - struct ath6kl_vif *vif = ar->vif; + struct ath6kl_vif *vif; + + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (test_bit(CONNECTED, &vif->flags)) { ar->tx_pwr = 0; - if (ath6kl_wmi_get_tx_pwr_cmd(ar->wmi) != 0) { + if (ath6kl_wmi_get_tx_pwr_cmd(ar->wmi, vif->fw_vif_idx) != 0) { ath6kl_err("ath6kl_wmi_get_tx_pwr_cmd failed\n"); return -EIO; } @@ -1173,7 +1186,7 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy, ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: pmgmt %d, timeout %d\n", __func__, pmgmt, timeout); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (pmgmt) { @@ -1204,7 +1217,7 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy, ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type %u\n", __func__, type); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; switch (type) { @@ -1241,7 +1254,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, struct ath6kl_vif *vif = netdev_priv(dev); int status; - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; vif->ssid_len = ibss_param->ssid_len; @@ -1306,10 +1319,9 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy, static int ath6kl_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) { - struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; ath6kl_disconnect(vif); @@ -1539,10 +1551,9 @@ static int ath6kl_set_channel(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan, enum nl80211_channel_type channel_type) { - struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: center_freq=%u hw_value=%u\n", @@ -1609,7 +1620,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: add=%d\n", __func__, add); - if (!ath6kl_cfg80211_ready(ar)) + if (!ath6kl_cfg80211_ready(vif)) return -EIO; if (vif->next_mode != AP_NETWORK) @@ -1991,11 +2002,13 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev) spin_lock_init(&ar->lock); spin_lock_init(&ar->mcastpsq_lock); + spin_lock_init(&ar->list_lock); init_waitqueue_head(&ar->event_wq); sema_init(&ar->sem, 1); INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue); + INIT_LIST_HEAD(&ar->vif_list); clear_bit(WMI_ENABLED, &ar->flag); clear_bit(SKIP_SCAN, &ar->flag); @@ -2110,7 +2123,6 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, ndev->ieee80211_ptr = &vif->wdev; vif->wdev.wiphy = ar->wiphy; vif->ar = ar; - ar->vif = vif; vif->ndev = ndev; SET_NETDEV_DEV(ndev, wiphy_dev(vif->wdev.wiphy)); vif->wdev.netdev = ndev; @@ -2134,6 +2146,10 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, ar->wlan_pwr_state = WLAN_POWER_STATE_ON; set_bit(NETDEV_REGISTERED, &vif->flags); + spin_lock(&ar->list_lock); + list_add_tail(&vif->list, &ar->vif_list); + spin_unlock(&ar->list_lock); + return ndev; err: diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 2c64652..29bb235 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -397,6 +397,7 @@ enum ath6kl_vif_state { }; struct ath6kl_vif { + struct list_head list; struct wireless_dev wdev; struct net_device *ndev; struct ath6kl *ar; @@ -456,7 +457,9 @@ struct ath6kl { int total_tx_data_pend; struct htc_target *htc_target; void *hif_priv; - struct ath6kl_vif *vif; + struct list_head vif_list; + /* Lock to avoid race in vif_list entries among add/del/traverse */ + spinlock_t list_lock; spinlock_t lock; struct semaphore sem; u16 listen_intvl_b; @@ -662,4 +665,5 @@ void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, void ath6kl_init_control_info(struct ath6kl_vif *vif); void ath6kl_deinit_if_data(struct ath6kl_vif *vif); void ath6kl_core_free(struct ath6kl *ar); +struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar); #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 54faa6b..e515c83 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -397,15 +397,20 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct ath6kl *ar = file->private_data; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; - struct target_stats *tgt_stats = &vif->target_stats; + struct ath6kl_vif *vif; + struct target_stats *tgt_stats; char *buf; unsigned int len = 0, buf_len = 1500; int i; long left; ssize_t ret_cnt; + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + + tgt_stats = &vif->target_stats; + buf = kzalloc(buf_len, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -1249,8 +1254,7 @@ static ssize_t ath6kl_create_qos_write(struct file *file, { struct ath6kl *ar = file->private_data; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl_vif *vif; char buf[100]; ssize_t len; char *sptr, *token; @@ -1258,6 +1262,10 @@ static ssize_t ath6kl_create_qos_write(struct file *file, u32 val32; u16 val16; + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; @@ -1423,14 +1431,17 @@ static ssize_t ath6kl_delete_qos_write(struct file *file, { struct ath6kl *ar = file->private_data; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl_vif *vif; char buf[100]; ssize_t len; char *sptr, *token; u8 traffic_class; u8 tsid; + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 99e4a49..61a941d 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1628,11 +1628,7 @@ static void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) void ath6kl_stop_txrx(struct ath6kl *ar) { - struct ath6kl_vif *vif = ar->vif; - struct net_device *ndev = vif->ndev; - - if (!ndev) - return; + struct ath6kl_vif *vif, *tmp_vif; set_bit(DESTROY_IN_PROGRESS, &ar->flag); @@ -1641,7 +1637,14 @@ void ath6kl_stop_txrx(struct ath6kl *ar) return; } - ath6kl_cleanup_vif(ar->vif, test_bit(WMI_READY, &ar->flag)); + spin_lock(&ar->list_lock); + list_for_each_entry_safe(vif, tmp_vif, &ar->vif_list, list) { + list_del(&vif->list); + spin_unlock(&ar->list_lock); + ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag)); + spin_lock(&ar->list_lock); + } + spin_unlock(&ar->list_lock); clear_bit(WMI_READY, &ar->flag); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index ca86ed3..17cabdc 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -861,8 +861,19 @@ void ath6kl_disconnect(struct ath6kl_vif *vif) void ath6kl_deep_sleep_enable(struct ath6kl *ar) { - /* TODO: Pass vif instead of taking it from ar */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl_vif *vif; + + /* FIXME: for multi vif */ + vif = ath6kl_vif_first(ar); + if (!vif) { + /* save the current power mode before enabling power save */ + ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; + + if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER) != 0) + ath6kl_warn("ath6kl_deep_sleep_enable: " + "wmi_powermode_cmd failed\n"); + return; + } switch (vif->sme_state) { case SME_CONNECTING: @@ -1363,6 +1374,23 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, ath6kl_tx_data_cleanup(ar); } +struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar) +{ + struct ath6kl_vif *vif; + + spin_lock(&ar->list_lock); + if (list_empty(&ar->vif_list)) { + spin_unlock(&ar->list_lock); + return NULL; + } + + vif = list_first_entry(&ar->vif_list, struct ath6kl_vif, list); + + spin_unlock(&ar->list_lock); + + return vif; +} + static int ath6kl_open(struct net_device *dev) { struct ath6kl_vif *vif = netdev_priv(dev); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index ff288da..ab9a5c1 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -432,9 +432,9 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, struct htc_packet *packet) { struct ath6kl *ar = target->dev->ar; - /* TODO: Findout vif properly */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl_vif *vif; enum htc_endpoint_id endpoint = packet->endpoint; + enum htc_send_full_action action = HTC_SEND_FULL_KEEP; if (endpoint == ar->ctrl_ep) { /* @@ -447,19 +447,11 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, set_bit(WMI_CTRL_EP_FULL, &ar->flag); spin_unlock_bh(&ar->lock); ath6kl_err("wmi ctrl ep is full\n"); - return HTC_SEND_FULL_KEEP; + goto stop_adhoc_netq; } if (packet->info.tx.tag == ATH6KL_CONTROL_PKT_TAG) - return HTC_SEND_FULL_KEEP; - - if (vif->nw_type == ADHOC_NETWORK) - /* - * In adhoc mode, we cannot differentiate traffic - * priorities so there is no need to continue, however we - * should stop the network. - */ - goto stop_net_queues; + goto stop_adhoc_netq; /* * The last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for @@ -467,28 +459,40 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, */ if (ar->ac_stream_pri_map[ar->ep2ac_map[endpoint]] < ar->hiac_stream_active_pri && - ar->cookie_count <= MAX_HI_COOKIE_NUM) + ar->cookie_count <= MAX_HI_COOKIE_NUM) { /* * Give preference to the highest priority stream by * dropping the packets which overflowed. */ - return HTC_SEND_FULL_DROP; + action = HTC_SEND_FULL_DROP; + goto stop_adhoc_netq; + } -stop_net_queues: - spin_lock_bh(&vif->if_lock); - set_bit(NETQ_STOPPED, &vif->flags); - spin_unlock_bh(&vif->if_lock); - netif_stop_queue(vif->ndev); +stop_adhoc_netq: + /* FIXME: Locking */ + spin_lock(&ar->list_lock); + list_for_each_entry(vif, &ar->vif_list, list) { + if (vif->nw_type == ADHOC_NETWORK) { + spin_unlock(&ar->list_lock); - return HTC_SEND_FULL_KEEP; + spin_lock_bh(&vif->if_lock); + set_bit(NETQ_STOPPED, &vif->flags); + spin_unlock_bh(&vif->if_lock); + netif_stop_queue(vif->ndev); + + return action; + } + } + spin_unlock(&ar->list_lock); + + return action; } /* TODO this needs to be looked at */ -static void ath6kl_tx_clear_node_map(struct ath6kl *ar, +static void ath6kl_tx_clear_node_map(struct ath6kl_vif *vif, enum htc_endpoint_id eid, u32 map_no) { - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl *ar = vif->ar; u32 i; if (vif->nw_type != ADHOC_NETWORK) @@ -533,10 +537,9 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) int status; enum htc_endpoint_id eid; bool wake_event = false; - bool flushing = false; + bool flushing[MAX_NUM_VIF] = {false}; u8 if_idx; - /* TODO: Findout vif */ - struct ath6kl_vif *vif = ar->vif; + struct ath6kl_vif *vif; skb_queue_head_init(&skb_queue); @@ -599,7 +602,7 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) if (status) { if (status == -ECANCELED) /* a packet was flushed */ - flushing = true; + flushing[if_idx] = true; vif->net_stats.tx_errors++; @@ -615,12 +618,12 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) __func__, skb, packet->buf, packet->act_len, eid, "OK"); - flushing = false; + flushing[if_idx] = false; vif->net_stats.tx_packets++; vif->net_stats.tx_bytes += skb->len; } - ath6kl_tx_clear_node_map(ar, eid, map_no); + ath6kl_tx_clear_node_map(vif, eid, map_no); ath6kl_free_cookie(ar, ath6kl_cookie); @@ -632,10 +635,17 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) __skb_queue_purge(&skb_queue); - if (test_bit(CONNECTED, &vif->flags)) { - if (!flushing) + /* FIXME: Locking */ + spin_lock(&ar->list_lock); + list_for_each_entry(vif, &ar->vif_list, list) { + if (test_bit(CONNECTED, &vif->flags) && + !flushing[vif->fw_vif_idx]) { + spin_unlock(&ar->list_lock); netif_wake_queue(vif->ndev); + spin_lock(&ar->list_lock); + } } + spin_unlock(&ar->list_lock); if (wake_event) wake_up(&ar->event_wq); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index ed95c2a..1fada31 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -83,10 +83,22 @@ enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) { + struct ath6kl_vif *vif, *found = NULL; + if (WARN_ON(if_idx > (MAX_NUM_VIF - 1))) return NULL; - return ar->vif; + /* FIXME: Locking */ + spin_lock(&ar->list_lock); + list_for_each_entry(vif, &ar->vif_list, list) { + if (vif->fw_vif_idx == if_idx) { + found = vif; + break; + } + } + spin_unlock(&ar->list_lock); + + return found; } /* Performs DIX to 802.3 encapsulation for transmit packets. @@ -2459,7 +2471,7 @@ int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx) return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID); } -int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) +int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM) { struct sk_buff *skb; struct wmi_set_tx_pwr_cmd *cmd; @@ -2472,15 +2484,15 @@ int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; cmd->dbM = dbM; - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_TX_PWR_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) +int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx) { - return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_TX_PWR_CMDID); + return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID); } int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 621189b7..e2f3304 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2258,8 +2258,8 @@ int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk); int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index); int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, const u8 *pmkid, bool set); -int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM); -int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi); +int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM); +int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx); int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi); int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg); -- cgit v0.10.2 From 2792972395356254252f12205915a32dce9f50e4 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:21 +0530 Subject: ath6kl: Use the other variant of netdev (un)register APIs Use replace (un)register_netdev() with (un)register_netdevice() so that the same ath6kl function can be used with add_virtual_intf()/del_virtual_intf(). Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index da4e46d..893bd2c 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2099,14 +2099,7 @@ void ath6kl_deinit_if_data(struct ath6kl_vif *vif) { aggr_module_destroy(vif->aggr_cntxt); - vif->aggr_cntxt = NULL; - - if (test_bit(NETDEV_REGISTERED, &vif->flags)) { - unregister_netdev(vif->ndev); - clear_bit(NETDEV_REGISTERED, &vif->flags); - } - - free_netdev(vif->ndev); + unregister_netdevice(vif->ndev); } struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, @@ -2138,7 +2131,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, if (ath6kl_init_if_data(vif)) goto err; - if (register_netdev(ndev)) + if (register_netdevice(ndev)) goto err; vif->sme_state = SME_DISCONNECTED; @@ -2153,8 +2146,8 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, return ndev; err: - ath6kl_deinit_if_data(vif); - + aggr_module_destroy(vif->aggr_cntxt); + free_netdev(ndev); return NULL; } diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 61a941d..83ad008 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1416,8 +1416,13 @@ static int ath6kl_init(struct ath6kl *ar) goto err_node_cleanup; } + rtnl_lock(); + /* Add an initial station interface */ ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0); + + rtnl_unlock(); + if (!ndev) { ath6kl_err("Failed to instantiate a network device\n"); status = -ENOMEM; @@ -1523,7 +1528,9 @@ err_rxbuf_cleanup: err_cleanup_scatter: ath6kl_hif_cleanup_scatter(ar); err_if_deinit: + rtnl_lock(); ath6kl_deinit_if_data(netdev_priv(ndev)); + rtnl_unlock(); wiphy_unregister(ar->wiphy); err_debug_init: ath6kl_debug_cleanup(ar); @@ -1622,8 +1629,6 @@ static void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) cfg80211_scan_done(vif->scan_req, true); vif->scan_req = NULL; } - - ath6kl_deinit_if_data(vif); } void ath6kl_stop_txrx(struct ath6kl *ar) @@ -1642,6 +1647,9 @@ void ath6kl_stop_txrx(struct ath6kl *ar) list_del(&vif->list); spin_unlock(&ar->list_lock); ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag)); + rtnl_lock(); + ath6kl_deinit_if_data(vif); + rtnl_unlock(); spin_lock(&ar->list_lock); } spin_unlock(&ar->list_lock); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 17cabdc..9ccdc4d 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1445,6 +1445,7 @@ static struct net_device_ops ath6kl_netdev_ops = { void init_netdev(struct net_device *dev) { dev->netdev_ops = &ath6kl_netdev_ops; + dev->destructor = free_netdev; dev->watchdog_timeo = ATH6KL_TX_TIMEOUT; dev->needed_headroom = ETH_HLEN; -- cgit v0.10.2 From 7b85832dfbfaf09e793755041302d9e6d67cd39e Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:22 +0530 Subject: ath6kl: Configure inteface information at init time Virtual interface information need to be configured during init time to the target. With MAX_NUM_VIF is restricted to 1, currently only a single vif is being configured. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 83ad008..60dbf72 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -429,11 +429,42 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar) int ath6kl_configure_target(struct ath6kl *ar) { u32 param, ram_reserved_size; - u8 fw_iftype; + u8 fw_iftype, fw_mode = 0, fw_submode; + int i; + /* + * Note: Even though the firmware interface type is + * chosen as BSS_STA for all three interfaces, can + * be configured to IBSS/AP as long as the fw submode + * remains normal mode (0 - AP, STA and IBSS). But + * due to an target assert in firmware only one interface is + * configured for now. + */ fw_iftype = HI_OPTION_FW_MODE_BSS_STA; - /* Tell target which HTC version it is used*/ + for (i = 0; i < MAX_NUM_VIF; i++) + fw_mode |= fw_iftype << (i * HI_OPTION_FW_MODE_BITS); + + /* + * submodes : vif[0] - AP/STA/IBSS + * vif[1] - "P2P dev"/"P2P GO"/"P2P Client" + * vif[2] - "P2P dev"/"P2P GO"/"P2P Client" + */ + fw_submode = HI_OPTION_FW_SUBMODE_NONE | + (HI_OPTION_FW_SUBMODE_P2PDEV << + (1 * HI_OPTION_FW_SUBMODE_BITS)) | + (HI_OPTION_FW_SUBMODE_P2PDEV << + (2 * HI_OPTION_FW_SUBMODE_BITS)); + + /* + * FIXME: This needs to be removed once the multivif + * support is enabled. + */ + if (ar->p2p) + fw_submode = HI_OPTION_FW_SUBMODE_P2PDEV; + else + fw_submode = HI_OPTION_FW_SUBMODE_NONE; + param = HTC_PROTOCOL_VERSION; if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, @@ -454,12 +485,10 @@ int ath6kl_configure_target(struct ath6kl *ar) return -EIO; } - param |= (1 << HI_OPTION_NUM_DEV_SHIFT); - param |= (fw_iftype << HI_OPTION_FW_MODE_SHIFT); - if (ar->p2p && fw_iftype == HI_OPTION_FW_MODE_BSS_STA) { - param |= HI_OPTION_FW_SUBMODE_P2PDEV << - HI_OPTION_FW_SUBMODE_SHIFT; - } + param |= (MAX_NUM_VIF << HI_OPTION_NUM_DEV_SHIFT); + param |= fw_mode << HI_OPTION_FW_MODE_SHIFT; + param |= fw_submode << HI_OPTION_FW_SUBMODE_SHIFT; + param |= (0 << HI_OPTION_MAC_ADDR_METHOD_SHIFT); param |= (0 << HI_OPTION_FW_BRIDGE_SHIFT); diff --git a/drivers/net/wireless/ath/ath6kl/target.h b/drivers/net/wireless/ath/ath6kl/target.h index c9a7605..687e2b3 100644 --- a/drivers/net/wireless/ath/ath6kl/target.h +++ b/drivers/net/wireless/ath/ath6kl/target.h @@ -320,7 +320,10 @@ struct host_interest { | (2) | (2) | (2) | (2) | (2) | (2) | (2) | (2) |------------------------------------------------------------------------------| */ +#define HI_OPTION_FW_MODE_BITS 0x2 #define HI_OPTION_FW_MODE_SHIFT 0xC + +#define HI_OPTION_FW_SUBMODE_BITS 0x2 #define HI_OPTION_FW_SUBMODE_SHIFT 0x14 /* Convert a Target virtual address into a Target physical address */ -- cgit v0.10.2 From 55055976fe15f450aded0a6f2ed2996411bd3e2e Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:23 +0530 Subject: ath6kl: Implement add_virtual_intf() and del_virtual_intf() Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 893bd2c..87ede62 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -293,6 +293,57 @@ static int ath6kl_set_assoc_req_ies(struct ath6kl_vif *vif, const u8 *ies, return ret; } +static int ath6kl_nliftype_to_drv_iftype(enum nl80211_iftype type, u8 *nw_type) +{ + switch (type) { + case NL80211_IFTYPE_STATION: + *nw_type = INFRA_NETWORK; + break; + case NL80211_IFTYPE_ADHOC: + *nw_type = ADHOC_NETWORK; + break; + case NL80211_IFTYPE_AP: + *nw_type = AP_NETWORK; + break; + case NL80211_IFTYPE_P2P_CLIENT: + *nw_type = INFRA_NETWORK; + break; + case NL80211_IFTYPE_P2P_GO: + *nw_type = AP_NETWORK; + break; + default: + ath6kl_err("invalid interface type %u\n", type); + return -ENOTSUPP; + } + + return 0; +} + +static bool ath6kl_is_valid_iftype(struct ath6kl *ar, enum nl80211_iftype type, + u8 *if_idx, u8 *nw_type) +{ + int i; + + if (ath6kl_nliftype_to_drv_iftype(type, nw_type)) + return false; + + if (ar->ibss_if_active || ((type == NL80211_IFTYPE_ADHOC) && + ar->num_vif)) + return false; + + if (type == NL80211_IFTYPE_STATION || + type == NL80211_IFTYPE_AP || type == NL80211_IFTYPE_ADHOC) { + for (i = 0; i < MAX_NUM_VIF; i++) { + if ((ar->avail_idx_map >> i) & BIT(0)) { + *if_idx = i; + return true; + } + } + } + + return false; +} + static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { @@ -1206,6 +1257,52 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy, return 0; } +static struct net_device *ath6kl_cfg80211_add_iface(struct wiphy *wiphy, + char *name, + enum nl80211_iftype type, + u32 *flags, + struct vif_params *params) +{ + struct ath6kl *ar = wiphy_priv(wiphy); + struct net_device *ndev; + u8 if_idx, nw_type; + + if (ar->num_vif == MAX_NUM_VIF) { + ath6kl_err("Reached maximum number of supported vif\n"); + return ERR_PTR(-EINVAL); + } + + if (!ath6kl_is_valid_iftype(ar, type, &if_idx, &nw_type)) { + ath6kl_err("Not a supported interface type\n"); + return ERR_PTR(-EINVAL); + } + + ndev = ath6kl_interface_add(ar, name, type, if_idx, nw_type); + if (!ndev) + return ERR_PTR(-ENOMEM); + + ar->num_vif++; + + return ndev; +} + +static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy, + struct net_device *ndev) +{ + struct ath6kl *ar = wiphy_priv(wiphy); + struct ath6kl_vif *vif = netdev_priv(ndev); + + spin_lock(&ar->list_lock); + list_del(&vif->list); + spin_unlock(&ar->list_lock); + + ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag)); + + ath6kl_deinit_if_data(vif); + + return 0; +} + static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, enum nl80211_iftype type, u32 *flags, @@ -1947,6 +2044,8 @@ ath6kl_mgmt_stypes[NUM_NL80211_IFTYPES] = { }; static struct cfg80211_ops ath6kl_cfg80211_ops = { + .add_virtual_intf = ath6kl_cfg80211_add_iface, + .del_virtual_intf = ath6kl_cfg80211_del_iface, .change_virtual_intf = ath6kl_cfg80211_change_iface, .scan = ath6kl_cfg80211_scan, .connect = ath6kl_cfg80211_connect, @@ -2097,18 +2196,28 @@ static int ath6kl_init_if_data(struct ath6kl_vif *vif) void ath6kl_deinit_if_data(struct ath6kl_vif *vif) { + struct ath6kl *ar = vif->ar; + aggr_module_destroy(vif->aggr_cntxt); + ar->avail_idx_map |= BIT(vif->fw_vif_idx); + + if (vif->nw_type == ADHOC_NETWORK) + ar->ibss_if_active = false; + unregister_netdevice(vif->ndev); + + ar->num_vif--; } struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, - enum nl80211_iftype type, u8 fw_vif_idx) + enum nl80211_iftype type, u8 fw_vif_idx, + u8 nw_type) { struct net_device *ndev; struct ath6kl_vif *vif; - ndev = alloc_netdev(sizeof(*vif), "wlan%d", ether_setup); + ndev = alloc_netdev(sizeof(*vif), name, ether_setup); if (!ndev) return NULL; @@ -2121,8 +2230,14 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, vif->wdev.netdev = ndev; vif->wdev.iftype = type; vif->fw_vif_idx = fw_vif_idx; + vif->nw_type = vif->next_mode = nw_type; ar->wdev = &vif->wdev; + memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); + if (fw_vif_idx != 0) + ndev->dev_addr[0] = (ndev->dev_addr[0] ^ (1 << fw_vif_idx)) | + 0x2; + init_netdev(ndev); ath6kl_init_control_info(vif); @@ -2134,11 +2249,15 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, if (register_netdevice(ndev)) goto err; + ar->avail_idx_map &= ~BIT(fw_vif_idx); vif->sme_state = SME_DISCONNECTED; set_bit(WLAN_ENABLED, &vif->flags); ar->wlan_pwr_state = WLAN_POWER_STATE_ON; set_bit(NETDEV_REGISTERED, &vif->flags); + if (type == NL80211_IFTYPE_ADHOC) + ar->ibss_if_active = true; + spin_lock(&ar->list_lock); list_add_tail(&vif->list, &ar->vif_list); spin_unlock(&ar->list_lock); diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 66042f2..d1a0216 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -19,7 +19,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, enum nl80211_iftype type, - u8 fw_vif_idx); + u8 fw_vif_idx, u8 nw_type); int ath6kl_register_ieee80211_hw(struct ath6kl *ar); struct ath6kl *ath6kl_core_alloc(struct device *dev); void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 29bb235..6933fb6 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -460,6 +460,8 @@ struct ath6kl { struct list_head vif_list; /* Lock to avoid race in vif_list entries among add/del/traverse */ spinlock_t list_lock; + u8 num_vif; + u8 avail_idx_map; spinlock_t lock; struct semaphore sem; u16 listen_intvl_b; @@ -470,6 +472,7 @@ struct ath6kl { u8 tx_pwr; struct ath6kl_node_mapping node_map[MAX_NODE_NUM]; u8 ibss_ps_enable; + bool ibss_if_active; u8 node_num; u8 next_ep_id; struct ath6kl_cookie *cookie_list; @@ -666,4 +669,5 @@ void ath6kl_init_control_info(struct ath6kl_vif *vif); void ath6kl_deinit_if_data(struct ath6kl_vif *vif); void ath6kl_core_free(struct ath6kl *ar); struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar); +void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready); #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 60dbf72..ce34fff 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -88,7 +88,6 @@ void ath6kl_init_profile_info(struct ath6kl_vif *vif) memset(vif->req_bssid, 0, sizeof(vif->req_bssid)); memset(vif->bssid, 0, sizeof(vif->bssid)); vif->bss_ch = 0; - vif->nw_type = vif->next_mode = INFRA_NETWORK; } static int ath6kl_set_host_app_area(struct ath6kl *ar) @@ -1414,6 +1413,7 @@ static int ath6kl_init(struct ath6kl *ar) int status = 0; s32 timeleft; struct net_device *ndev; + int i; if (!ar) return -EIO; @@ -1445,10 +1445,14 @@ static int ath6kl_init(struct ath6kl *ar) goto err_node_cleanup; } + for (i = 0; i < MAX_NUM_VIF; i++) + ar->avail_idx_map |= BIT(i); + rtnl_lock(); /* Add an initial station interface */ - ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0); + ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0, + INFRA_NETWORK); rtnl_unlock(); @@ -1632,7 +1636,7 @@ err_wq: return ret; } -static void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) +void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) { static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; bool discon_issued; -- cgit v0.10.2 From 3226f68af4fe74932677db271b4ac4f26556954d Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:24 +0530 Subject: ath6kl: Add a modparam to enable multi normal interface support This option lets operate more than one vif in normal mode (AP/STA/IBSS) when support for multiple vif is enabled. This modparam needs to be used as modprobe ath6kl multi_norm_if_support=1 Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 87ede62..2c09704 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -21,8 +21,10 @@ #include "testmode.h" static unsigned int ath6kl_p2p; +static unsigned int multi_norm_if_support; module_param(ath6kl_p2p, uint, 0644); +module_param(multi_norm_if_support, uint, 0644); #define RATETAB_ENT(_rate, _rateid, _flags) { \ .bitrate = (_rate), \ @@ -341,6 +343,16 @@ static bool ath6kl_is_valid_iftype(struct ath6kl *ar, enum nl80211_iftype type, } } + if (type == NL80211_IFTYPE_P2P_CLIENT || + type == NL80211_IFTYPE_P2P_GO) { + for (i = ar->max_norm_iface; i < MAX_NUM_VIF; i++) { + if ((ar->avail_idx_map >> i) & BIT(0)) { + *if_idx = i; + return true; + } + } + } + return false; } @@ -2095,10 +2107,19 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev) } ar = wiphy_priv(wiphy); - ar->p2p = !!ath6kl_p2p; + if (!multi_norm_if_support) + ar->p2p = !!ath6kl_p2p; ar->wiphy = wiphy; ar->dev = dev; + if (multi_norm_if_support) + ar->max_norm_iface = 2; + else + ar->max_norm_iface = 1; + + /* FIXME: Remove this once the multivif support is enabled */ + ar->max_norm_iface = 1; + spin_lock_init(&ar->lock); spin_lock_init(&ar->mcastpsq_lock); spin_lock_init(&ar->list_lock); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 6933fb6..427db08 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -461,6 +461,7 @@ struct ath6kl { /* Lock to avoid race in vif_list entries among add/del/traverse */ spinlock_t list_lock; u8 num_vif; + u8 max_norm_iface; u8 avail_idx_map; spinlock_t lock; struct semaphore sem; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index ce34fff..7784b2c 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -428,7 +428,7 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar) int ath6kl_configure_target(struct ath6kl *ar) { u32 param, ram_reserved_size; - u8 fw_iftype, fw_mode = 0, fw_submode; + u8 fw_iftype, fw_mode = 0, fw_submode = 0; int i; /* @@ -445,15 +445,19 @@ int ath6kl_configure_target(struct ath6kl *ar) fw_mode |= fw_iftype << (i * HI_OPTION_FW_MODE_BITS); /* - * submodes : vif[0] - AP/STA/IBSS - * vif[1] - "P2P dev"/"P2P GO"/"P2P Client" - * vif[2] - "P2P dev"/"P2P GO"/"P2P Client" + * By default, submodes : + * vif[0] - AP/STA/IBSS + * vif[1] - "P2P dev"/"P2P GO"/"P2P Client" + * vif[2] - "P2P dev"/"P2P GO"/"P2P Client" */ - fw_submode = HI_OPTION_FW_SUBMODE_NONE | - (HI_OPTION_FW_SUBMODE_P2PDEV << - (1 * HI_OPTION_FW_SUBMODE_BITS)) | - (HI_OPTION_FW_SUBMODE_P2PDEV << - (2 * HI_OPTION_FW_SUBMODE_BITS)); + + for (i = 0; i < ar->max_norm_iface; i++) + fw_submode |= HI_OPTION_FW_SUBMODE_NONE << + (i * HI_OPTION_FW_SUBMODE_BITS); + + for (i = ar->max_norm_iface; i < MAX_NUM_VIF; i++) + fw_submode |= HI_OPTION_FW_SUBMODE_P2PDEV << + (i * HI_OPTION_FW_SUBMODE_BITS); /* * FIXME: This needs to be removed once the multivif @@ -461,8 +465,6 @@ int ath6kl_configure_target(struct ath6kl *ar) */ if (ar->p2p) fw_submode = HI_OPTION_FW_SUBMODE_P2PDEV; - else - fw_submode = HI_OPTION_FW_SUBMODE_NONE; param = HTC_PROTOCOL_VERSION; if (ath6kl_bmi_write(ar, -- cgit v0.10.2 From 0ce5944552d87fe6e007a0338059a75525142dd3 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:25 +0530 Subject: ath6kl: Initialize target wlan values for every vif Wlan parameters need to be configured for every vif in target. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index e515c83..725d598 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1188,7 +1188,7 @@ static ssize_t ath6kl_keepalive_write(struct file *file, if (ret) return ret; - ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, val); + ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, 0, val); if (ret) return ret; @@ -1233,7 +1233,7 @@ static ssize_t ath6kl_disconnect_timeout_write(struct file *file, if (ret) return ret; - ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, val); + ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, 0, val); if (ret) return ret; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 7784b2c..1dad985 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -352,7 +352,7 @@ void ath6kl_target_failure(struct ath6kl *ar) } -static int ath6kl_target_config_wlan_params(struct ath6kl *ar) +static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) { int status = 0; int ret; @@ -362,46 +362,50 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar) * default values. Required if checksum offload is needed. Set * RxMetaVersion to 2. */ - if (ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, + if (ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, idx, ar->rx_meta_ver, 0, 0)) { ath6kl_err("unable to set the rx frame format\n"); status = -EIO; } if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN) - if ((ath6kl_wmi_pmparams_cmd(ar->wmi, 0, 1, 0, 0, 1, + if ((ath6kl_wmi_pmparams_cmd(ar->wmi, idx, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) { ath6kl_err("unable to set power save fail event policy\n"); status = -EIO; } if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER)) - if ((ath6kl_wmi_set_lpreamble_cmd(ar->wmi, 0, + if ((ath6kl_wmi_set_lpreamble_cmd(ar->wmi, idx, 0, WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) { ath6kl_err("unable to set barker preamble policy\n"); status = -EIO; } - if (ath6kl_wmi_set_keepalive_cmd(ar->wmi, + if (ath6kl_wmi_set_keepalive_cmd(ar->wmi, idx, WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) { ath6kl_err("unable to set keep alive interval\n"); status = -EIO; } - if (ath6kl_wmi_disctimeout_cmd(ar->wmi, + if (ath6kl_wmi_disctimeout_cmd(ar->wmi, idx, WLAN_CONFIG_DISCONNECT_TIMEOUT)) { ath6kl_err("unable to set disconnect timeout\n"); status = -EIO; } if (!(ar->conf_flags & ATH6KL_CONF_ENABLE_TX_BURST)) - if (ath6kl_wmi_set_wmm_txop(ar->wmi, WMI_TXOP_DISABLED)) { + if (ath6kl_wmi_set_wmm_txop(ar->wmi, idx, WMI_TXOP_DISABLED)) { ath6kl_err("unable to set txop bursting\n"); status = -EIO; } + /* + * FIXME: Make sure p2p configurations are not applied to + * non-p2p capable interfaces when multivif support is enabled. + */ if (ar->p2p) { - ret = ath6kl_wmi_info_req_cmd(ar->wmi, + ret = ath6kl_wmi_info_req_cmd(ar->wmi, idx, P2P_FLAG_CAPABILITIES_REQ | P2P_FLAG_MACADDR_REQ | P2P_FLAG_HMODEL_REQ); @@ -413,9 +417,13 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar) } } + /* + * FIXME: Make sure p2p configurations are not applied to + * non-p2p capable interfaces when multivif support is enabled. + */ if (ar->p2p) { /* Enable Probe Request reporting for P2P */ - ret = ath6kl_wmi_probe_report_req_cmd(ar->wmi, true); + ret = ath6kl_wmi_probe_report_req_cmd(ar->wmi, idx, true); if (ret) { ath6kl_dbg(ATH6KL_DBG_TRC, "failed to enable Probe " "Request reporting (%d)\n", ret); @@ -1543,9 +1551,11 @@ static int ath6kl_init(struct ath6kl *ar) ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAVE_AP_SME; - status = ath6kl_target_config_wlan_params(ar); - if (status) - goto err_htc_stop; + for (i = 0; i < MAX_NUM_VIF; i++) { + status = ath6kl_target_config_wlan_params(ar, i); + if (status) + goto err_htc_stop; + } /* * Set mac address which is received in ready event diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 1fada31..e6b0960 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -1940,7 +1940,7 @@ int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode) return ret; } -int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, +int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period, u16 ps_poll_num, u16 dtim_policy, u16 tx_wakeup_policy, u16 num_tx_to_wakeup, u16 ps_fail_event_policy) @@ -1961,12 +1961,12 @@ int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_POWER_PARAMS_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) +int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout) { struct sk_buff *skb; struct wmi_disc_timeout_cmd *cmd; @@ -1979,7 +1979,7 @@ int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) cmd = (struct wmi_disc_timeout_cmd *) skb->data; cmd->discon_timeout = timeout; - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_DISC_TIMEOUT_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID, NO_SYNC_WMIFLAG); if (ret == 0) @@ -2500,7 +2500,8 @@ int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID); } -int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) +int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status, + u8 preamble_policy) { struct sk_buff *skb; struct wmi_set_lpreamble_cmd *cmd; @@ -2514,7 +2515,7 @@ int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) cmd->status = status; cmd->preamble_policy = preamble_policy; - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_LPREAMBLE_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID, NO_SYNC_WMIFLAG); return ret; } @@ -2537,7 +2538,7 @@ int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) return ret; } -int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) +int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg) { struct sk_buff *skb; struct wmi_set_wmm_txop_cmd *cmd; @@ -2553,12 +2554,13 @@ int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; cmd->txop_enable = cfg; - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_WMM_TXOP_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID, NO_SYNC_WMIFLAG); return ret; } -int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) +int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx, + u8 keep_alive_intvl) { struct sk_buff *skb; struct wmi_set_keepalive_cmd *cmd; @@ -2571,7 +2573,7 @@ int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) cmd = (struct wmi_set_keepalive_cmd *) skb->data; cmd->keep_alive_intvl = keep_alive_intvl; - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_KEEPALIVE_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID, NO_SYNC_WMIFLAG); if (ret == 0) @@ -2734,7 +2736,8 @@ int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, return 0; } -int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, +int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx, + u8 rx_meta_ver, bool rx_dot11_hdr, bool defrag_on_host) { struct sk_buff *skb; @@ -2751,7 +2754,7 @@ int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, cmd->meta_ver = rx_meta_ver; /* Delete the local aggr state, on host */ - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RX_FRAME_FORMAT_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID, NO_SYNC_WMIFLAG); return ret; @@ -2872,7 +2875,7 @@ int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, NO_SYNC_WMIFLAG); } -int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) +int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable) { struct sk_buff *skb; struct wmi_probe_req_report_cmd *p; @@ -2885,11 +2888,11 @@ int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) enable); p = (struct wmi_probe_req_report_cmd *) skb->data; p->enable = enable ? 1 : 0; - return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_PROBE_REQ_REPORT_CMDID, + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID, NO_SYNC_WMIFLAG); } -int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) +int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags) { struct sk_buff *skb; struct wmi_get_p2p_info *p; @@ -2902,7 +2905,7 @@ int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) info_req_flags); p = (struct wmi_get_p2p_info *) skb->data; p->info_req_flags = cpu_to_le32(info_req_flags); - return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_GET_P2P_INFO_CMDID, + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID, NO_SYNC_WMIFLAG); } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index e2f3304..495d2e5 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2230,18 +2230,18 @@ int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, u16 listen_interval, u16 listen_beacons); int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode); -int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, +int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period, u16 ps_poll_num, u16 dtim_policy, u16 tx_wakup_policy, u16 num_tx_to_wakeup, u16 ps_fail_event_policy); -int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout); int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx, struct wmi_create_pstream_cmd *pstream); int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, u8 tsid); +int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout); int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold); -int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, +int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status, u8 preamble_policy); int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source); @@ -2262,8 +2262,9 @@ int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM); int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx); int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi); -int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg); -int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl); +int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg); +int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx, + u8 keep_alive_intvl); int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len); s32 ath6kl_wmi_get_rate(s8 rate_index); @@ -2282,7 +2283,8 @@ int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, bool flag); -int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_version, +int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx, + u8 rx_meta_version, bool rx_dot11_hdr, bool defrag_on_host); int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, @@ -2301,9 +2303,9 @@ int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, const u8 *dst, const u8 *data, u16 data_len); -int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable); +int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable); -int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags); +int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags); int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx); -- cgit v0.10.2 From 551959d84d22b891e93d54fe43a4c7181581e8c4 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 25 Oct 2011 19:34:26 +0530 Subject: ath6kl: Use appropriate wdev from vif Remove the wdev reference in struct ath6kl. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2c09704..3380dd9 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -622,7 +622,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, clear_bit(DTIM_PERIOD_AVAIL, &vif->flags); if (nw_type & ADHOC_NETWORK) { - if (ar->wdev->iftype != NL80211_IFTYPE_ADHOC) { + if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: ath6k not in ibss mode\n", __func__); return; @@ -630,8 +630,8 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, } if (nw_type & INFRA_NETWORK) { - if (ar->wdev->iftype != NL80211_IFTYPE_STATION && - ar->wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) { + if (vif->wdev.iftype != NL80211_IFTYPE_STATION && + vif->wdev.iftype != NL80211_IFTYPE_P2P_CLIENT) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: ath6k not in station mode\n", __func__); return; @@ -717,7 +717,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, } if (vif->nw_type & ADHOC_NETWORK) { - if (ar->wdev->iftype != NL80211_IFTYPE_ADHOC) { + if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: ath6k not in ibss mode\n", __func__); return; @@ -728,8 +728,8 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, } if (vif->nw_type & INFRA_NETWORK) { - if (ar->wdev->iftype != NL80211_IFTYPE_STATION && - ar->wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) { + if (vif->wdev.iftype != NL80211_IFTYPE_STATION && + vif->wdev.iftype != NL80211_IFTYPE_P2P_CLIENT) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: ath6k not in station mode\n", __func__); return; @@ -1320,8 +1320,6 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy, enum nl80211_iftype type, u32 *flags, struct vif_params *params) { - struct ath6kl *ar = ath6kl_priv(ndev); - struct wireless_dev *wdev = ar->wdev; struct ath6kl_vif *vif = netdev_priv(ndev); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type %u\n", __func__, type); @@ -1350,7 +1348,7 @@ static int ath6kl_cfg80211_change_iface(struct wiphy *wiphy, return -EOPNOTSUPP; } - wdev->iftype = type; + vif->wdev.iftype = type; return 0; } @@ -2252,7 +2250,6 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, vif->wdev.iftype = type; vif->fw_vif_idx = fw_vif_idx; vif->nw_type = vif->next_mode = nw_type; - ar->wdev = &vif->wdev; memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); if (fw_vif_idx != 0) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 427db08..0d0f80a 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -498,7 +498,6 @@ struct ath6kl { u8 ap_country_code[3]; struct list_head amsdu_rx_buffer_queue; u8 rx_meta_ver; - struct wireless_dev *wdev; enum wlan_low_pwr_state wlan_pwr_state; struct wmi_scan_params_cmd sc_params; u8 mac_addr[ETH_ALEN]; -- cgit v0.10.2 From a9ab6ccf2db68c5d7ca93ff00e33644f66f35cdb Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:16:44 +0300 Subject: ath6kl: remove unused A_CACHE_LINE_PAD Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index 877cb70..7968371 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -23,8 +23,6 @@ extern int ath6kl_printk(const char *level, const char *fmt, ...); -#define A_CACHE_LINE_PAD 128 - /* * Reflects the version of binary interface exposed by ATH6KL target * firmware. Needs to be incremented by 1 for any change in the firmware -- cgit v0.10.2 From fa99e963b1976374db1d89aea854e8740b92796d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:16:55 +0300 Subject: ath6kl: use ath6kl prefix in credit functions This is to follow the common style in the driver. Also add braces to fix a style issue. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index 7968371..cffd7d1 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -78,16 +78,16 @@ struct ath6kl; enum htc_credit_dist_reason; struct htc_credit_state_info; -int ath6k_setup_credit_dist(void *htc_handle, - struct htc_credit_state_info *cred_info); -void ath6k_credit_distribute(struct htc_credit_state_info *cred_inf, - struct list_head *epdist_list, - enum htc_credit_dist_reason reason); -void ath6k_credit_init(struct htc_credit_state_info *cred_inf, - struct list_head *ep_list, - int tot_credits); -void ath6k_seek_credits(struct htc_credit_state_info *cred_inf, - struct htc_endpoint_credit_dist *ep_dist); +int ath6kl_setup_credit_dist(void *htc_handle, + struct htc_credit_state_info *cred_info); +void ath6kl_credit_distribute(struct htc_credit_state_info *cred_inf, + struct list_head *epdist_list, + enum htc_credit_dist_reason reason); +void ath6kl_credit_init(struct htc_credit_state_info *cred_inf, + struct list_head *ep_list, + int tot_credits); +void ath6kl_seek_credits(struct htc_credit_state_info *cred_inf, + struct htc_endpoint_credit_dist *ep_dist); struct ath6kl *ath6kl_core_alloc(struct device *sdev); int ath6kl_core_init(struct ath6kl *ar); void ath6kl_core_cleanup(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 3cd3ef5..b861fa1 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -105,7 +105,7 @@ static void htc_tx_comp_update(struct htc_target *target, ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); - ath6k_credit_distribute(target->cred_dist_cntxt, + ath6kl_credit_distribute(target->cred_dist_cntxt, &target->cred_dist_list, HTC_CREDIT_DIST_SEND_COMPLETE); @@ -237,7 +237,7 @@ static int htc_check_credits(struct htc_target *target, ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &ep->cred_dist); - ath6k_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); + ath6kl_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); ep->cred_dist.seek_cred = 0; @@ -260,7 +260,7 @@ static int htc_check_credits(struct htc_target *target, ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &ep->cred_dist); - ath6k_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); + ath6kl_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); /* see if we were successful in getting more */ if (ep->cred_dist.credits < ep->cred_dist.cred_per_msg) { @@ -842,9 +842,9 @@ void ath6kl_htc_indicate_activity_change(struct htc_target *target, "htc tx activity ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); - ath6k_credit_distribute(target->cred_dist_cntxt, - &target->cred_dist_list, - HTC_CREDIT_DIST_ACTIVITY_CHANGE); + ath6kl_credit_distribute(target->cred_dist_cntxt, + &target->cred_dist_list, + HTC_CREDIT_DIST_ACTIVITY_CHANGE); } spin_unlock_bh(&target->tx_lock); @@ -1272,9 +1272,9 @@ static void htc_proc_cred_rpt(struct htc_target *target, ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->cred_dist_cntxt, &target->cred_dist_list); - ath6k_credit_distribute(target->cred_dist_cntxt, - &target->cred_dist_list, - HTC_CREDIT_DIST_SEND_COMPLETE); + ath6kl_credit_distribute(target->cred_dist_cntxt, + &target->cred_dist_list, + HTC_CREDIT_DIST_SEND_COMPLETE); } spin_unlock_bh(&target->tx_lock); @@ -2338,8 +2338,8 @@ int ath6kl_htc_start(struct htc_target *target) } /* NOTE: the first entry in the distribution list is ENDPOINT_0 */ - ath6k_credit_init(target->cred_dist_cntxt, &target->cred_dist_list, - target->tgt_creds); + ath6kl_credit_init(target->cred_dist_cntxt, &target->cred_dist_list, + target->tgt_creds); dump_cred_dist_stats(target); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 1dad985..1cfe16f 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1506,7 +1506,7 @@ static int ath6kl_init(struct ath6kl *ar) ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS); /* setup credit distribution */ - ath6k_setup_credit_dist(ar->htc_target, &ar->credit_state_info); + ath6kl_setup_credit_dist(ar->htc_target, &ar->credit_state_info); ath6kl_cookie_init(ar); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 9ccdc4d..993b637 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -556,9 +556,9 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, } /* Functions for Tx credit handling */ -void ath6k_credit_init(struct htc_credit_state_info *cred_info, - struct list_head *ep_list, - int tot_credits) +void ath6kl_credit_init(struct htc_credit_state_info *cred_info, + struct list_head *ep_list, + int tot_credits) { struct htc_endpoint_credit_dist *cur_ep_dist; int count; @@ -572,7 +572,7 @@ void ath6k_credit_init(struct htc_credit_state_info *cred_info, cur_ep_dist->cred_min = cur_ep_dist->cred_per_msg; - if (tot_credits > 4) + if (tot_credits > 4) { if ((cur_ep_dist->svc_id == WMI_DATA_BK_SVC) || (cur_ep_dist->svc_id == WMI_DATA_BE_SVC)) { ath6kl_deposit_credit_to_ep(cred_info, @@ -580,6 +580,7 @@ void ath6k_credit_init(struct htc_credit_state_info *cred_info, cur_ep_dist->cred_min); cur_ep_dist->dist_flags |= HTC_EP_ACTIVE; } + } if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) { ath6kl_deposit_credit_to_ep(cred_info, cur_ep_dist, @@ -634,8 +635,8 @@ void ath6k_credit_init(struct htc_credit_state_info *cred_info, } /* initialize and setup credit distribution */ -int ath6k_setup_credit_dist(void *htc_handle, - struct htc_credit_state_info *cred_info) +int ath6kl_setup_credit_dist(void *htc_handle, + struct htc_credit_state_info *cred_info) { u16 servicepriority[5]; @@ -654,9 +655,9 @@ int ath6k_setup_credit_dist(void *htc_handle, } /* reduce an ep's credits back to a set limit */ -static void ath6k_reduce_credits(struct htc_credit_state_info *cred_info, - struct htc_endpoint_credit_dist *ep_dist, - int limit) +static void ath6kl_reduce_credits(struct htc_credit_state_info *cred_info, + struct htc_endpoint_credit_dist *ep_dist, + int limit) { int credits; @@ -670,8 +671,8 @@ static void ath6k_reduce_credits(struct htc_credit_state_info *cred_info, cred_info->cur_free_credits += credits; } -static void ath6k_credit_update(struct htc_credit_state_info *cred_info, - struct list_head *epdist_list) +static void ath6kl_credit_update(struct htc_credit_state_info *cred_info, + struct list_head *epdist_list) { struct htc_endpoint_credit_dist *cur_dist_list; @@ -685,19 +686,19 @@ static void ath6k_credit_update(struct htc_credit_state_info *cred_info, cur_dist_list->cred_to_dist = 0; if (cur_dist_list->credits > cur_dist_list->cred_assngd) - ath6k_reduce_credits(cred_info, + ath6kl_reduce_credits(cred_info, cur_dist_list, cur_dist_list->cred_assngd); if (cur_dist_list->credits > cur_dist_list->cred_norm) - ath6k_reduce_credits(cred_info, cur_dist_list, - cur_dist_list->cred_norm); + ath6kl_reduce_credits(cred_info, cur_dist_list, + cur_dist_list->cred_norm); if (!(cur_dist_list->dist_flags & HTC_EP_ACTIVE)) { if (cur_dist_list->txq_depth == 0) - ath6k_reduce_credits(cred_info, - cur_dist_list, 0); + ath6kl_reduce_credits(cred_info, + cur_dist_list, 0); } } } @@ -707,8 +708,8 @@ static void ath6k_credit_update(struct htc_credit_state_info *cred_info, * HTC has an endpoint that needs credits, ep_dist is the endpoint in * question. */ -void ath6k_seek_credits(struct htc_credit_state_info *cred_info, - struct htc_endpoint_credit_dist *ep_dist) +void ath6kl_seek_credits(struct htc_credit_state_info *cred_info, + struct htc_endpoint_credit_dist *ep_dist) { struct htc_endpoint_credit_dist *curdist_list; int credits = 0; @@ -760,8 +761,8 @@ void ath6k_seek_credits(struct htc_credit_state_info *cred_info, * above it's minimum to fulfill our need try to * take away just enough to fulfill our need. */ - ath6k_reduce_credits(cred_info, curdist_list, - curdist_list->cred_assngd - need); + ath6kl_reduce_credits(cred_info, curdist_list, + curdist_list->cred_assngd - need); if (cred_info->cur_free_credits >= ep_dist->seek_cred) @@ -783,8 +784,8 @@ out: } /* redistribute credits based on activity change */ -static void ath6k_redistribute_credits(struct htc_credit_state_info *info, - struct list_head *ep_dist_list) +static void ath6kl_redistribute_credits(struct htc_credit_state_info *info, + struct list_head *ep_dist_list) { struct htc_endpoint_credit_dist *curdist_list; @@ -799,10 +800,9 @@ static void ath6k_redistribute_credits(struct htc_credit_state_info *info, if ((curdist_list->svc_id != WMI_CONTROL_SVC) && !(curdist_list->dist_flags & HTC_EP_ACTIVE)) { if (curdist_list->txq_depth == 0) - ath6k_reduce_credits(info, - curdist_list, 0); + ath6kl_reduce_credits(info, curdist_list, 0); else - ath6k_reduce_credits(info, + ath6kl_reduce_credits(info, curdist_list, curdist_list->cred_min); } @@ -817,16 +817,16 @@ static void ath6k_redistribute_credits(struct htc_credit_state_info *info, * structures in prioritized order as defined by the call to the * htc_set_credit_dist() api. */ -void ath6k_credit_distribute(struct htc_credit_state_info *cred_info, - struct list_head *ep_dist_list, - enum htc_credit_dist_reason reason) +void ath6kl_credit_distribute(struct htc_credit_state_info *cred_info, + struct list_head *ep_dist_list, + enum htc_credit_dist_reason reason) { switch (reason) { case HTC_CREDIT_DIST_SEND_COMPLETE: - ath6k_credit_update(cred_info, ep_dist_list); + ath6kl_credit_update(cred_info, ep_dist_list); break; case HTC_CREDIT_DIST_ACTIVITY_CHANGE: - ath6k_redistribute_credits(cred_info, ep_dist_list); + ath6kl_redistribute_credits(cred_info, ep_dist_list); break; default: break; -- cgit v0.10.2 From e8c39790d00c0f9498da84f0efb61efa5664068c Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:17:04 +0300 Subject: ath6kl: rename struct htc_endpoint_credit_dist.htc_rsvd to htc_ep No need to use void pointer here. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 725d598..a560ed3 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -164,8 +164,7 @@ static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist) ath6kl_dbg(ATH6KL_DBG_ANY, " cred_to_dist : %d\n", ep_dist->cred_to_dist); ath6kl_dbg(ATH6KL_DBG_ANY, " txq_depth : %d\n", - get_queue_depth(&((struct htc_endpoint *) - ep_dist->htc_rsvd)->txq)); + get_queue_depth(&ep_dist->htc_ep->txq)); ath6kl_dbg(ATH6KL_DBG_ANY, "----------------------------------\n"); } @@ -584,8 +583,7 @@ static ssize_t read_file_credit_dist_stats(struct file *file, print_credit_info("%9d", cred_per_msg); print_credit_info("%14d", cred_to_dist); len += scnprintf(buf + len, buf_len - len, "%12d\n", - get_queue_depth(&((struct htc_endpoint *) - ep_list->htc_rsvd)->txq)); + get_queue_depth(&ep_list->htc_ep->txq)); } if (len > buf_len) diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index b861fa1..4685a1b 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -619,7 +619,7 @@ static void htc_chk_ep_txq(struct htc_target *target) * are not modifying any state. */ list_for_each_entry(cred_dist, &target->cred_dist_list, list) { - endpoint = (struct htc_endpoint *)cred_dist->htc_rsvd; + endpoint = cred_dist->htc_ep; spin_lock_bh(&target->tx_lock); if (!list_empty(&endpoint->txq)) { @@ -2119,7 +2119,7 @@ int ath6kl_htc_conn_service(struct htc_target *target, endpoint->len_max = max_msg_sz; endpoint->ep_cb = conn_req->ep_cb; endpoint->cred_dist.svc_id = conn_req->svc_id; - endpoint->cred_dist.htc_rsvd = endpoint; + endpoint->cred_dist.htc_ep = endpoint; endpoint->cred_dist.endpoint = assigned_ep; endpoint->cred_dist.cred_sz = target->tgt_cred_sz; diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 69d44e3..5db4294 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -393,7 +393,7 @@ struct htc_endpoint_credit_dist { int cred_per_msg; /* reserved for HTC use */ - void *htc_rsvd; + struct htc_endpoint *htc_ep; /* * current depth of TX queue , i.e. messages waiting for credits -- cgit v0.10.2 From 3c3703987a43b969e2f1e54c4e28f1fc8594c9d8 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:17:12 +0300 Subject: ath6kl: rename struct htc_credit_state_info to ath6kl_htc_credit_info Also rename cred_dist_cntxt to credit_info in struct htc_target. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index cffd7d1..7d13403 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -76,17 +76,17 @@ enum crypto_type { struct htc_endpoint_credit_dist; struct ath6kl; enum htc_credit_dist_reason; -struct htc_credit_state_info; +struct ath6kl_htc_credit_info; int ath6kl_setup_credit_dist(void *htc_handle, - struct htc_credit_state_info *cred_info); -void ath6kl_credit_distribute(struct htc_credit_state_info *cred_inf, + struct ath6kl_htc_credit_info *cred_info); +void ath6kl_credit_distribute(struct ath6kl_htc_credit_info *cred_inf, struct list_head *epdist_list, enum htc_credit_dist_reason reason); -void ath6kl_credit_init(struct htc_credit_state_info *cred_inf, +void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_inf, struct list_head *ep_list, int tot_credits); -void ath6kl_seek_credits(struct htc_credit_state_info *cred_inf, +void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_inf, struct htc_endpoint_credit_dist *ep_dist); struct ath6kl *ath6kl_core_alloc(struct device *sdev); int ath6kl_core_init(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 0d0f80a..280cd53 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -484,7 +484,7 @@ struct ath6kl { u8 hiac_stream_active_pri; u8 ep2ac_map[ENDPOINT_MAX]; enum htc_endpoint_id ctrl_ep; - struct htc_credit_state_info credit_state_info; + struct ath6kl_htc_credit_info credit_state_info; u32 connect_ctrl_flags; u32 user_key_ctrl; u8 usr_bss_filter; @@ -570,7 +570,7 @@ static inline void *ath6kl_priv(struct net_device *dev) return ((struct ath6kl_vif *) netdev_priv(dev))->ar; } -static inline void ath6kl_deposit_credit_to_ep(struct htc_credit_state_info +static inline void ath6kl_deposit_credit_to_ep(struct ath6kl_htc_credit_info *cred_info, struct htc_endpoint_credit_dist *ep_dist, int credits) diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index a560ed3..c1b822b 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -180,11 +180,11 @@ void dump_cred_dist_stats(struct htc_target *target) dump_cred_dist(ep_list); ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:%p dist:%p\n", - target->cred_dist_cntxt, NULL); + target->credit_info, NULL); ath6kl_dbg(ATH6KL_DBG_HTC, "credit distribution, total : %d, free : %d\n", - target->cred_dist_cntxt->total_avail_credits, - target->cred_dist_cntxt->cur_free_credits); + target->credit_info->total_avail_credits, + target->credit_info->cur_free_credits); } static int ath6kl_debugfs_open(struct inode *inode, struct file *file) @@ -561,10 +561,10 @@ static ssize_t read_file_credit_dist_stats(struct file *file, len += scnprintf(buf + len, buf_len - len, "%25s%5d\n", "Total Avail Credits: ", - target->cred_dist_cntxt->total_avail_credits); + target->credit_info->total_avail_credits); len += scnprintf(buf + len, buf_len - len, "%25s%5d\n", "Free credits :", - target->cred_dist_cntxt->cur_free_credits); + target->credit_info->cur_free_credits); len += scnprintf(buf + len, buf_len - len, " Epid Flags Cred_norm Cred_min Credits Cred_assngd" diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 4685a1b..24dfc02 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -103,11 +103,11 @@ static void htc_tx_comp_update(struct htc_target *target, endpoint->cred_dist.txq_depth = get_queue_depth(&endpoint->txq); ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx ctxt 0x%p dist 0x%p\n", - target->cred_dist_cntxt, &target->cred_dist_list); + target->credit_info, &target->cred_dist_list); - ath6kl_credit_distribute(target->cred_dist_cntxt, - &target->cred_dist_list, - HTC_CREDIT_DIST_SEND_COMPLETE); + ath6kl_credit_distribute(target->credit_info, + &target->cred_dist_list, + HTC_CREDIT_DIST_SEND_COMPLETE); spin_unlock_bh(&target->tx_lock); } @@ -235,9 +235,9 @@ static int htc_check_credits(struct htc_target *target, ep->cred_dist.seek_cred = *req_cred - ep->cred_dist.credits; ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", - target->cred_dist_cntxt, &ep->cred_dist); + target->credit_info, &ep->cred_dist); - ath6kl_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); + ath6kl_seek_credits(target->credit_info, &ep->cred_dist); ep->cred_dist.seek_cred = 0; @@ -258,9 +258,9 @@ static int htc_check_credits(struct htc_target *target, ep->cred_dist.cred_per_msg - ep->cred_dist.credits; ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", - target->cred_dist_cntxt, &ep->cred_dist); + target->credit_info, &ep->cred_dist); - ath6kl_seek_credits(target->cred_dist_cntxt, &ep->cred_dist); + ath6kl_seek_credits(target->credit_info, &ep->cred_dist); /* see if we were successful in getting more */ if (ep->cred_dist.credits < ep->cred_dist.cred_per_msg) { @@ -698,13 +698,13 @@ static int htc_setup_tx_complete(struct htc_target *target) } void ath6kl_htc_set_credit_dist(struct htc_target *target, - struct htc_credit_state_info *cred_dist_cntxt, + struct ath6kl_htc_credit_info *credit_info, u16 srvc_pri_order[], int list_len) { struct htc_endpoint *endpoint; int i, ep; - target->cred_dist_cntxt = cred_dist_cntxt; + target->credit_info = credit_info; list_add_tail(&target->endpoint[ENDPOINT_0].cred_dist.list, &target->cred_dist_list); @@ -840,9 +840,9 @@ void ath6kl_htc_indicate_activity_change(struct htc_target *target, ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx activity ctxt 0x%p dist 0x%p\n", - target->cred_dist_cntxt, &target->cred_dist_list); + target->credit_info, &target->cred_dist_list); - ath6kl_credit_distribute(target->cred_dist_cntxt, + ath6kl_credit_distribute(target->credit_info, &target->cred_dist_list, HTC_CREDIT_DIST_ACTIVITY_CHANGE); } @@ -1270,9 +1270,9 @@ static void htc_proc_cred_rpt(struct htc_target *target, * operations note, this is done with the lock held */ ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", - target->cred_dist_cntxt, &target->cred_dist_list); + target->credit_info, &target->cred_dist_list); - ath6kl_credit_distribute(target->cred_dist_cntxt, + ath6kl_credit_distribute(target->credit_info, &target->cred_dist_list, HTC_CREDIT_DIST_SEND_COMPLETE); } @@ -2176,6 +2176,7 @@ static void reset_ep_state(struct htc_target *target) } /* reset distribution list */ + /* FIXME: free existing entries */ INIT_LIST_HEAD(&target->cred_dist_list); } @@ -2338,7 +2339,7 @@ int ath6kl_htc_start(struct htc_target *target) } /* NOTE: the first entry in the distribution list is ENDPOINT_0 */ - ath6kl_credit_init(target->cred_dist_cntxt, &target->cred_dist_list, + ath6kl_credit_init(target->credit_info, &target->cred_dist_list, target->tgt_creds); dump_cred_dist_stats(target); diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 5db4294..47a588c 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -414,9 +414,11 @@ enum htc_credit_dist_reason { HTC_CREDIT_DIST_SEEK_CREDITS, }; -struct htc_credit_state_info { +struct ath6kl_htc_credit_info { int total_avail_credits; int cur_free_credits; + + /* list of lowest priority endpoints */ struct list_head lowestpri_ep_dist; }; @@ -508,10 +510,13 @@ struct ath6kl_device; /* our HTC target state */ struct htc_target { struct htc_endpoint endpoint[ENDPOINT_MAX]; + + /* contains struct htc_endpoint_credit_dist */ struct list_head cred_dist_list; + struct list_head free_ctrl_txbuf; struct list_head free_ctrl_rxbuf; - struct htc_credit_state_info *cred_dist_cntxt; + struct ath6kl_htc_credit_info *credit_info; int tgt_creds; unsigned int tgt_cred_sz; spinlock_t htc_lock; @@ -542,7 +547,7 @@ struct htc_target { void *ath6kl_htc_create(struct ath6kl *ar); void ath6kl_htc_set_credit_dist(struct htc_target *target, - struct htc_credit_state_info *cred_info, + struct ath6kl_htc_credit_info *cred_info, u16 svc_pri_order[], int len); int ath6kl_htc_wait_target(struct htc_target *target); int ath6kl_htc_start(struct htc_target *target); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 993b637..7295490 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -556,7 +556,7 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, } /* Functions for Tx credit handling */ -void ath6kl_credit_init(struct htc_credit_state_info *cred_info, +void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, struct list_head *ep_list, int tot_credits) { @@ -592,6 +592,7 @@ void ath6kl_credit_init(struct htc_credit_state_info *cred_info, cur_ep_dist->dist_flags |= HTC_EP_ACTIVE; } else if (cur_ep_dist->svc_id == WMI_DATA_BK_SVC) /* this is the lowest priority data endpoint */ + /* FIXME: this looks fishy, check */ cred_info->lowestpri_ep_dist = cur_ep_dist->list; /* @@ -636,11 +637,11 @@ void ath6kl_credit_init(struct htc_credit_state_info *cred_info, /* initialize and setup credit distribution */ int ath6kl_setup_credit_dist(void *htc_handle, - struct htc_credit_state_info *cred_info) + struct ath6kl_htc_credit_info *cred_info) { u16 servicepriority[5]; - memset(cred_info, 0, sizeof(struct htc_credit_state_info)); + memset(cred_info, 0, sizeof(struct ath6kl_htc_credit_info)); servicepriority[0] = WMI_CONTROL_SVC; /* highest */ servicepriority[1] = WMI_DATA_VO_SVC; @@ -655,7 +656,7 @@ int ath6kl_setup_credit_dist(void *htc_handle, } /* reduce an ep's credits back to a set limit */ -static void ath6kl_reduce_credits(struct htc_credit_state_info *cred_info, +static void ath6kl_reduce_credits(struct ath6kl_htc_credit_info *cred_info, struct htc_endpoint_credit_dist *ep_dist, int limit) { @@ -671,7 +672,7 @@ static void ath6kl_reduce_credits(struct htc_credit_state_info *cred_info, cred_info->cur_free_credits += credits; } -static void ath6kl_credit_update(struct htc_credit_state_info *cred_info, +static void ath6kl_credit_update(struct ath6kl_htc_credit_info *cred_info, struct list_head *epdist_list) { struct htc_endpoint_credit_dist *cur_dist_list; @@ -708,7 +709,7 @@ static void ath6kl_credit_update(struct htc_credit_state_info *cred_info, * HTC has an endpoint that needs credits, ep_dist is the endpoint in * question. */ -void ath6kl_seek_credits(struct htc_credit_state_info *cred_info, +void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_info, struct htc_endpoint_credit_dist *ep_dist) { struct htc_endpoint_credit_dist *curdist_list; @@ -784,7 +785,7 @@ out: } /* redistribute credits based on activity change */ -static void ath6kl_redistribute_credits(struct htc_credit_state_info *info, +static void ath6kl_redistribute_credits(struct ath6kl_htc_credit_info *info, struct list_head *ep_dist_list) { struct htc_endpoint_credit_dist *curdist_list; @@ -817,7 +818,7 @@ static void ath6kl_redistribute_credits(struct htc_credit_state_info *info, * structures in prioritized order as defined by the call to the * htc_set_credit_dist() api. */ -void ath6kl_credit_distribute(struct htc_credit_state_info *cred_info, +void ath6kl_credit_distribute(struct ath6kl_htc_credit_info *cred_info, struct list_head *ep_dist_list, enum htc_credit_dist_reason reason) { -- cgit v0.10.2 From f2f921950d6a066f6e4a84c52fc69292bc877aa7 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:17:20 +0300 Subject: ath6kl: move all credit distribution code to htc.c As htc is the only user there's no reason to keep it in main.c. No functional changes. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index 7d13403..41e465f 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -78,16 +78,6 @@ struct ath6kl; enum htc_credit_dist_reason; struct ath6kl_htc_credit_info; -int ath6kl_setup_credit_dist(void *htc_handle, - struct ath6kl_htc_credit_info *cred_info); -void ath6kl_credit_distribute(struct ath6kl_htc_credit_info *cred_inf, - struct list_head *epdist_list, - enum htc_credit_dist_reason reason); -void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_inf, - struct list_head *ep_list, - int tot_credits); -void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_inf, - struct htc_endpoint_credit_dist *ep_dist); struct ath6kl *ath6kl_core_alloc(struct device *sdev); int ath6kl_core_init(struct ath6kl *ar); void ath6kl_core_cleanup(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 280cd53..97d7f11 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -570,16 +570,6 @@ static inline void *ath6kl_priv(struct net_device *dev) return ((struct ath6kl_vif *) netdev_priv(dev))->ar; } -static inline void ath6kl_deposit_credit_to_ep(struct ath6kl_htc_credit_info - *cred_info, - struct htc_endpoint_credit_dist - *ep_dist, int credits) -{ - ep_dist->credits += credits; - ep_dist->cred_assngd += credits; - cred_info->cur_free_credits -= credits; -} - static inline u32 ath6kl_get_hi_item_addr(struct ath6kl *ar, u32 item_offset) { diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 24dfc02..5cb0327 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -22,6 +22,298 @@ #define CALC_TXRX_PADDED_LEN(dev, len) (__ALIGN_MASK((len), (dev)->block_mask)) +/* Functions for Tx credit handling */ +static void ath6kl_deposit_credit_to_ep(struct ath6kl_htc_credit_info + *cred_info, + struct htc_endpoint_credit_dist + *ep_dist, int credits) +{ + ep_dist->credits += credits; + ep_dist->cred_assngd += credits; + cred_info->cur_free_credits -= credits; +} + +static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, + struct list_head *ep_list, + int tot_credits) +{ + struct htc_endpoint_credit_dist *cur_ep_dist; + int count; + + cred_info->cur_free_credits = tot_credits; + cred_info->total_avail_credits = tot_credits; + + list_for_each_entry(cur_ep_dist, ep_list, list) { + if (cur_ep_dist->endpoint == ENDPOINT_0) + continue; + + cur_ep_dist->cred_min = cur_ep_dist->cred_per_msg; + + if (tot_credits > 4) { + if ((cur_ep_dist->svc_id == WMI_DATA_BK_SVC) || + (cur_ep_dist->svc_id == WMI_DATA_BE_SVC)) { + ath6kl_deposit_credit_to_ep(cred_info, + cur_ep_dist, + cur_ep_dist->cred_min); + cur_ep_dist->dist_flags |= HTC_EP_ACTIVE; + } + } + + if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) { + ath6kl_deposit_credit_to_ep(cred_info, cur_ep_dist, + cur_ep_dist->cred_min); + /* + * Control service is always marked active, it + * never goes inactive EVER. + */ + cur_ep_dist->dist_flags |= HTC_EP_ACTIVE; + } else if (cur_ep_dist->svc_id == WMI_DATA_BK_SVC) + /* this is the lowest priority data endpoint */ + /* FIXME: this looks fishy, check */ + cred_info->lowestpri_ep_dist = cur_ep_dist->list; + + /* + * Streams have to be created (explicit | implicit) for all + * kinds of traffic. BE endpoints are also inactive in the + * beginning. When BE traffic starts it creates implicit + * streams that redistributes credits. + * + * Note: all other endpoints have minimums set but are + * initially given NO credits. credits will be distributed + * as traffic activity demands + */ + } + + WARN_ON(cred_info->cur_free_credits <= 0); + + list_for_each_entry(cur_ep_dist, ep_list, list) { + if (cur_ep_dist->endpoint == ENDPOINT_0) + continue; + + if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) + cur_ep_dist->cred_norm = cur_ep_dist->cred_per_msg; + else { + /* + * For the remaining data endpoints, we assume that + * each cred_per_msg are the same. We use a simple + * calculation here, we take the remaining credits + * and determine how many max messages this can + * cover and then set each endpoint's normal value + * equal to 3/4 this amount. + */ + count = (cred_info->cur_free_credits / + cur_ep_dist->cred_per_msg) + * cur_ep_dist->cred_per_msg; + count = (count * 3) >> 2; + count = max(count, cur_ep_dist->cred_per_msg); + cur_ep_dist->cred_norm = count; + + } + } +} + +/* initialize and setup credit distribution */ +int ath6kl_setup_credit_dist(void *htc_handle, + struct ath6kl_htc_credit_info *cred_info) +{ + u16 servicepriority[5]; + + memset(cred_info, 0, sizeof(struct ath6kl_htc_credit_info)); + + servicepriority[0] = WMI_CONTROL_SVC; /* highest */ + servicepriority[1] = WMI_DATA_VO_SVC; + servicepriority[2] = WMI_DATA_VI_SVC; + servicepriority[3] = WMI_DATA_BE_SVC; + servicepriority[4] = WMI_DATA_BK_SVC; /* lowest */ + + /* set priority list */ + ath6kl_htc_set_credit_dist(htc_handle, cred_info, servicepriority, 5); + + return 0; +} + +/* reduce an ep's credits back to a set limit */ +static void ath6kl_reduce_credits(struct ath6kl_htc_credit_info *cred_info, + struct htc_endpoint_credit_dist *ep_dist, + int limit) +{ + int credits; + + ep_dist->cred_assngd = limit; + + if (ep_dist->credits <= limit) + return; + + credits = ep_dist->credits - limit; + ep_dist->credits -= credits; + cred_info->cur_free_credits += credits; +} + +static void ath6kl_credit_update(struct ath6kl_htc_credit_info *cred_info, + struct list_head *epdist_list) +{ + struct htc_endpoint_credit_dist *cur_dist_list; + + list_for_each_entry(cur_dist_list, epdist_list, list) { + if (cur_dist_list->endpoint == ENDPOINT_0) + continue; + + if (cur_dist_list->cred_to_dist > 0) { + cur_dist_list->credits += + cur_dist_list->cred_to_dist; + cur_dist_list->cred_to_dist = 0; + if (cur_dist_list->credits > + cur_dist_list->cred_assngd) + ath6kl_reduce_credits(cred_info, + cur_dist_list, + cur_dist_list->cred_assngd); + + if (cur_dist_list->credits > + cur_dist_list->cred_norm) + ath6kl_reduce_credits(cred_info, cur_dist_list, + cur_dist_list->cred_norm); + + if (!(cur_dist_list->dist_flags & HTC_EP_ACTIVE)) { + if (cur_dist_list->txq_depth == 0) + ath6kl_reduce_credits(cred_info, + cur_dist_list, 0); + } + } + } +} + +/* + * HTC has an endpoint that needs credits, ep_dist is the endpoint in + * question. + */ +static void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_info, + struct htc_endpoint_credit_dist *ep_dist) +{ + struct htc_endpoint_credit_dist *curdist_list; + int credits = 0; + int need; + + if (ep_dist->svc_id == WMI_CONTROL_SVC) + goto out; + + if ((ep_dist->svc_id == WMI_DATA_VI_SVC) || + (ep_dist->svc_id == WMI_DATA_VO_SVC)) + if ((ep_dist->cred_assngd >= ep_dist->cred_norm)) + goto out; + + /* + * For all other services, we follow a simple algorithm of: + * + * 1. checking the free pool for credits + * 2. checking lower priority endpoints for credits to take + */ + + credits = min(cred_info->cur_free_credits, ep_dist->seek_cred); + + if (credits >= ep_dist->seek_cred) + goto out; + + /* + * We don't have enough in the free pool, try taking away from + * lower priority services The rule for taking away credits: + * + * 1. Only take from lower priority endpoints + * 2. Only take what is allocated above the minimum (never + * starve an endpoint completely) + * 3. Only take what you need. + */ + + list_for_each_entry_reverse(curdist_list, + &cred_info->lowestpri_ep_dist, + list) { + if (curdist_list == ep_dist) + break; + + need = ep_dist->seek_cred - cred_info->cur_free_credits; + + if ((curdist_list->cred_assngd - need) >= + curdist_list->cred_min) { + /* + * The current one has been allocated more than + * it's minimum and it has enough credits assigned + * above it's minimum to fulfill our need try to + * take away just enough to fulfill our need. + */ + ath6kl_reduce_credits(cred_info, curdist_list, + curdist_list->cred_assngd - need); + + if (cred_info->cur_free_credits >= + ep_dist->seek_cred) + break; + } + + if (curdist_list->endpoint == ENDPOINT_0) + break; + } + + credits = min(cred_info->cur_free_credits, ep_dist->seek_cred); + +out: + /* did we find some credits? */ + if (credits) + ath6kl_deposit_credit_to_ep(cred_info, ep_dist, credits); + + ep_dist->seek_cred = 0; +} + +/* redistribute credits based on activity change */ +static void ath6kl_redistribute_credits(struct ath6kl_htc_credit_info *info, + struct list_head *ep_dist_list) +{ + struct htc_endpoint_credit_dist *curdist_list; + + list_for_each_entry(curdist_list, ep_dist_list, list) { + if (curdist_list->endpoint == ENDPOINT_0) + continue; + + if ((curdist_list->svc_id == WMI_DATA_BK_SVC) || + (curdist_list->svc_id == WMI_DATA_BE_SVC)) + curdist_list->dist_flags |= HTC_EP_ACTIVE; + + if ((curdist_list->svc_id != WMI_CONTROL_SVC) && + !(curdist_list->dist_flags & HTC_EP_ACTIVE)) { + if (curdist_list->txq_depth == 0) + ath6kl_reduce_credits(info, curdist_list, 0); + else + ath6kl_reduce_credits(info, + curdist_list, + curdist_list->cred_min); + } + } +} + +/* + * + * This function is invoked whenever endpoints require credit + * distributions. A lock is held while this function is invoked, this + * function shall NOT block. The ep_dist_list is a list of distribution + * structures in prioritized order as defined by the call to the + * htc_set_credit_dist() api. + */ +static void ath6kl_credit_distribute(struct ath6kl_htc_credit_info *cred_info, + struct list_head *ep_dist_list, + enum htc_credit_dist_reason reason) +{ + switch (reason) { + case HTC_CREDIT_DIST_SEND_COMPLETE: + ath6kl_credit_update(cred_info, ep_dist_list); + break; + case HTC_CREDIT_DIST_ACTIVITY_CHANGE: + ath6kl_redistribute_credits(cred_info, ep_dist_list); + break; + default: + break; + } + + WARN_ON(cred_info->cur_free_credits > cred_info->total_avail_credits); + WARN_ON(cred_info->cur_free_credits < 0); +} + static void ath6kl_htc_tx_buf_align(u8 **buf, unsigned long len) { u8 *align_addr; diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 47a588c..c68e834 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -570,6 +570,9 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, u32 msg_look_ahead, int *n_pkts); +int ath6kl_setup_credit_dist(void *htc_handle, + struct ath6kl_htc_credit_info *cred_info); + static inline void set_htc_pkt_info(struct htc_packet *packet, void *context, u8 *buf, unsigned int len, enum htc_endpoint_id eid, u16 tag) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 7295490..16451a4 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -555,288 +555,6 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, netif_wake_queue(vif->ndev); } -/* Functions for Tx credit handling */ -void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, - struct list_head *ep_list, - int tot_credits) -{ - struct htc_endpoint_credit_dist *cur_ep_dist; - int count; - - cred_info->cur_free_credits = tot_credits; - cred_info->total_avail_credits = tot_credits; - - list_for_each_entry(cur_ep_dist, ep_list, list) { - if (cur_ep_dist->endpoint == ENDPOINT_0) - continue; - - cur_ep_dist->cred_min = cur_ep_dist->cred_per_msg; - - if (tot_credits > 4) { - if ((cur_ep_dist->svc_id == WMI_DATA_BK_SVC) || - (cur_ep_dist->svc_id == WMI_DATA_BE_SVC)) { - ath6kl_deposit_credit_to_ep(cred_info, - cur_ep_dist, - cur_ep_dist->cred_min); - cur_ep_dist->dist_flags |= HTC_EP_ACTIVE; - } - } - - if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) { - ath6kl_deposit_credit_to_ep(cred_info, cur_ep_dist, - cur_ep_dist->cred_min); - /* - * Control service is always marked active, it - * never goes inactive EVER. - */ - cur_ep_dist->dist_flags |= HTC_EP_ACTIVE; - } else if (cur_ep_dist->svc_id == WMI_DATA_BK_SVC) - /* this is the lowest priority data endpoint */ - /* FIXME: this looks fishy, check */ - cred_info->lowestpri_ep_dist = cur_ep_dist->list; - - /* - * Streams have to be created (explicit | implicit) for all - * kinds of traffic. BE endpoints are also inactive in the - * beginning. When BE traffic starts it creates implicit - * streams that redistributes credits. - * - * Note: all other endpoints have minimums set but are - * initially given NO credits. credits will be distributed - * as traffic activity demands - */ - } - - WARN_ON(cred_info->cur_free_credits <= 0); - - list_for_each_entry(cur_ep_dist, ep_list, list) { - if (cur_ep_dist->endpoint == ENDPOINT_0) - continue; - - if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) - cur_ep_dist->cred_norm = cur_ep_dist->cred_per_msg; - else { - /* - * For the remaining data endpoints, we assume that - * each cred_per_msg are the same. We use a simple - * calculation here, we take the remaining credits - * and determine how many max messages this can - * cover and then set each endpoint's normal value - * equal to 3/4 this amount. - */ - count = (cred_info->cur_free_credits / - cur_ep_dist->cred_per_msg) - * cur_ep_dist->cred_per_msg; - count = (count * 3) >> 2; - count = max(count, cur_ep_dist->cred_per_msg); - cur_ep_dist->cred_norm = count; - - } - } -} - -/* initialize and setup credit distribution */ -int ath6kl_setup_credit_dist(void *htc_handle, - struct ath6kl_htc_credit_info *cred_info) -{ - u16 servicepriority[5]; - - memset(cred_info, 0, sizeof(struct ath6kl_htc_credit_info)); - - servicepriority[0] = WMI_CONTROL_SVC; /* highest */ - servicepriority[1] = WMI_DATA_VO_SVC; - servicepriority[2] = WMI_DATA_VI_SVC; - servicepriority[3] = WMI_DATA_BE_SVC; - servicepriority[4] = WMI_DATA_BK_SVC; /* lowest */ - - /* set priority list */ - ath6kl_htc_set_credit_dist(htc_handle, cred_info, servicepriority, 5); - - return 0; -} - -/* reduce an ep's credits back to a set limit */ -static void ath6kl_reduce_credits(struct ath6kl_htc_credit_info *cred_info, - struct htc_endpoint_credit_dist *ep_dist, - int limit) -{ - int credits; - - ep_dist->cred_assngd = limit; - - if (ep_dist->credits <= limit) - return; - - credits = ep_dist->credits - limit; - ep_dist->credits -= credits; - cred_info->cur_free_credits += credits; -} - -static void ath6kl_credit_update(struct ath6kl_htc_credit_info *cred_info, - struct list_head *epdist_list) -{ - struct htc_endpoint_credit_dist *cur_dist_list; - - list_for_each_entry(cur_dist_list, epdist_list, list) { - if (cur_dist_list->endpoint == ENDPOINT_0) - continue; - - if (cur_dist_list->cred_to_dist > 0) { - cur_dist_list->credits += - cur_dist_list->cred_to_dist; - cur_dist_list->cred_to_dist = 0; - if (cur_dist_list->credits > - cur_dist_list->cred_assngd) - ath6kl_reduce_credits(cred_info, - cur_dist_list, - cur_dist_list->cred_assngd); - - if (cur_dist_list->credits > - cur_dist_list->cred_norm) - ath6kl_reduce_credits(cred_info, cur_dist_list, - cur_dist_list->cred_norm); - - if (!(cur_dist_list->dist_flags & HTC_EP_ACTIVE)) { - if (cur_dist_list->txq_depth == 0) - ath6kl_reduce_credits(cred_info, - cur_dist_list, 0); - } - } - } -} - -/* - * HTC has an endpoint that needs credits, ep_dist is the endpoint in - * question. - */ -void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_info, - struct htc_endpoint_credit_dist *ep_dist) -{ - struct htc_endpoint_credit_dist *curdist_list; - int credits = 0; - int need; - - if (ep_dist->svc_id == WMI_CONTROL_SVC) - goto out; - - if ((ep_dist->svc_id == WMI_DATA_VI_SVC) || - (ep_dist->svc_id == WMI_DATA_VO_SVC)) - if ((ep_dist->cred_assngd >= ep_dist->cred_norm)) - goto out; - - /* - * For all other services, we follow a simple algorithm of: - * - * 1. checking the free pool for credits - * 2. checking lower priority endpoints for credits to take - */ - - credits = min(cred_info->cur_free_credits, ep_dist->seek_cred); - - if (credits >= ep_dist->seek_cred) - goto out; - - /* - * We don't have enough in the free pool, try taking away from - * lower priority services The rule for taking away credits: - * - * 1. Only take from lower priority endpoints - * 2. Only take what is allocated above the minimum (never - * starve an endpoint completely) - * 3. Only take what you need. - */ - - list_for_each_entry_reverse(curdist_list, - &cred_info->lowestpri_ep_dist, - list) { - if (curdist_list == ep_dist) - break; - - need = ep_dist->seek_cred - cred_info->cur_free_credits; - - if ((curdist_list->cred_assngd - need) >= - curdist_list->cred_min) { - /* - * The current one has been allocated more than - * it's minimum and it has enough credits assigned - * above it's minimum to fulfill our need try to - * take away just enough to fulfill our need. - */ - ath6kl_reduce_credits(cred_info, curdist_list, - curdist_list->cred_assngd - need); - - if (cred_info->cur_free_credits >= - ep_dist->seek_cred) - break; - } - - if (curdist_list->endpoint == ENDPOINT_0) - break; - } - - credits = min(cred_info->cur_free_credits, ep_dist->seek_cred); - -out: - /* did we find some credits? */ - if (credits) - ath6kl_deposit_credit_to_ep(cred_info, ep_dist, credits); - - ep_dist->seek_cred = 0; -} - -/* redistribute credits based on activity change */ -static void ath6kl_redistribute_credits(struct ath6kl_htc_credit_info *info, - struct list_head *ep_dist_list) -{ - struct htc_endpoint_credit_dist *curdist_list; - - list_for_each_entry(curdist_list, ep_dist_list, list) { - if (curdist_list->endpoint == ENDPOINT_0) - continue; - - if ((curdist_list->svc_id == WMI_DATA_BK_SVC) || - (curdist_list->svc_id == WMI_DATA_BE_SVC)) - curdist_list->dist_flags |= HTC_EP_ACTIVE; - - if ((curdist_list->svc_id != WMI_CONTROL_SVC) && - !(curdist_list->dist_flags & HTC_EP_ACTIVE)) { - if (curdist_list->txq_depth == 0) - ath6kl_reduce_credits(info, curdist_list, 0); - else - ath6kl_reduce_credits(info, - curdist_list, - curdist_list->cred_min); - } - } -} - -/* - * - * This function is invoked whenever endpoints require credit - * distributions. A lock is held while this function is invoked, this - * function shall NOT block. The ep_dist_list is a list of distribution - * structures in prioritized order as defined by the call to the - * htc_set_credit_dist() api. - */ -void ath6kl_credit_distribute(struct ath6kl_htc_credit_info *cred_info, - struct list_head *ep_dist_list, - enum htc_credit_dist_reason reason) -{ - switch (reason) { - case HTC_CREDIT_DIST_SEND_COMPLETE: - ath6kl_credit_update(cred_info, ep_dist_list); - break; - case HTC_CREDIT_DIST_ACTIVITY_CHANGE: - ath6kl_redistribute_credits(cred_info, ep_dist_list); - break; - default: - break; - } - - WARN_ON(cred_info->cur_free_credits > cred_info->total_avail_credits); - WARN_ON(cred_info->cur_free_credits < 0); -} - void disconnect_timer_handler(unsigned long ptr) { struct net_device *dev = (struct net_device *)ptr; -- cgit v0.10.2 From cb64a6105bbc36e660a5198c7d425f75e4b33820 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:17:28 +0300 Subject: ath6kl: use ath6kl_credit prefix consistently Not all credit functions used that prefix, fix that. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 5cb0327..511eebd 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -23,10 +23,9 @@ #define CALC_TXRX_PADDED_LEN(dev, len) (__ALIGN_MASK((len), (dev)->block_mask)) /* Functions for Tx credit handling */ -static void ath6kl_deposit_credit_to_ep(struct ath6kl_htc_credit_info - *cred_info, - struct htc_endpoint_credit_dist - *ep_dist, int credits) +static void ath6kl_credit_deposit(struct ath6kl_htc_credit_info *cred_info, + struct htc_endpoint_credit_dist *ep_dist, + int credits) { ep_dist->credits += credits; ep_dist->cred_assngd += credits; @@ -52,16 +51,16 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, if (tot_credits > 4) { if ((cur_ep_dist->svc_id == WMI_DATA_BK_SVC) || (cur_ep_dist->svc_id == WMI_DATA_BE_SVC)) { - ath6kl_deposit_credit_to_ep(cred_info, - cur_ep_dist, - cur_ep_dist->cred_min); + ath6kl_credit_deposit(cred_info, + cur_ep_dist, + cur_ep_dist->cred_min); cur_ep_dist->dist_flags |= HTC_EP_ACTIVE; } } if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) { - ath6kl_deposit_credit_to_ep(cred_info, cur_ep_dist, - cur_ep_dist->cred_min); + ath6kl_credit_deposit(cred_info, cur_ep_dist, + cur_ep_dist->cred_min); /* * Control service is always marked active, it * never goes inactive EVER. @@ -113,8 +112,8 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, } /* initialize and setup credit distribution */ -int ath6kl_setup_credit_dist(void *htc_handle, - struct ath6kl_htc_credit_info *cred_info) +int ath6kl_credit_setup(void *htc_handle, + struct ath6kl_htc_credit_info *cred_info) { u16 servicepriority[5]; @@ -133,9 +132,9 @@ int ath6kl_setup_credit_dist(void *htc_handle, } /* reduce an ep's credits back to a set limit */ -static void ath6kl_reduce_credits(struct ath6kl_htc_credit_info *cred_info, - struct htc_endpoint_credit_dist *ep_dist, - int limit) +static void ath6kl_credit_reduce(struct ath6kl_htc_credit_info *cred_info, + struct htc_endpoint_credit_dist *ep_dist, + int limit) { int credits; @@ -164,19 +163,19 @@ static void ath6kl_credit_update(struct ath6kl_htc_credit_info *cred_info, cur_dist_list->cred_to_dist = 0; if (cur_dist_list->credits > cur_dist_list->cred_assngd) - ath6kl_reduce_credits(cred_info, + ath6kl_credit_reduce(cred_info, cur_dist_list, cur_dist_list->cred_assngd); if (cur_dist_list->credits > cur_dist_list->cred_norm) - ath6kl_reduce_credits(cred_info, cur_dist_list, - cur_dist_list->cred_norm); + ath6kl_credit_reduce(cred_info, cur_dist_list, + cur_dist_list->cred_norm); if (!(cur_dist_list->dist_flags & HTC_EP_ACTIVE)) { if (cur_dist_list->txq_depth == 0) - ath6kl_reduce_credits(cred_info, - cur_dist_list, 0); + ath6kl_credit_reduce(cred_info, + cur_dist_list, 0); } } } @@ -186,7 +185,7 @@ static void ath6kl_credit_update(struct ath6kl_htc_credit_info *cred_info, * HTC has an endpoint that needs credits, ep_dist is the endpoint in * question. */ -static void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_info, +static void ath6kl_credit_seek(struct ath6kl_htc_credit_info *cred_info, struct htc_endpoint_credit_dist *ep_dist) { struct htc_endpoint_credit_dist *curdist_list; @@ -239,8 +238,8 @@ static void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_info, * above it's minimum to fulfill our need try to * take away just enough to fulfill our need. */ - ath6kl_reduce_credits(cred_info, curdist_list, - curdist_list->cred_assngd - need); + ath6kl_credit_reduce(cred_info, curdist_list, + curdist_list->cred_assngd - need); if (cred_info->cur_free_credits >= ep_dist->seek_cred) @@ -256,14 +255,14 @@ static void ath6kl_seek_credits(struct ath6kl_htc_credit_info *cred_info, out: /* did we find some credits? */ if (credits) - ath6kl_deposit_credit_to_ep(cred_info, ep_dist, credits); + ath6kl_credit_deposit(cred_info, ep_dist, credits); ep_dist->seek_cred = 0; } /* redistribute credits based on activity change */ -static void ath6kl_redistribute_credits(struct ath6kl_htc_credit_info *info, - struct list_head *ep_dist_list) +static void ath6kl_credit_redistribute(struct ath6kl_htc_credit_info *info, + struct list_head *ep_dist_list) { struct htc_endpoint_credit_dist *curdist_list; @@ -278,11 +277,11 @@ static void ath6kl_redistribute_credits(struct ath6kl_htc_credit_info *info, if ((curdist_list->svc_id != WMI_CONTROL_SVC) && !(curdist_list->dist_flags & HTC_EP_ACTIVE)) { if (curdist_list->txq_depth == 0) - ath6kl_reduce_credits(info, curdist_list, 0); + ath6kl_credit_reduce(info, curdist_list, 0); else - ath6kl_reduce_credits(info, - curdist_list, - curdist_list->cred_min); + ath6kl_credit_reduce(info, + curdist_list, + curdist_list->cred_min); } } } @@ -304,7 +303,7 @@ static void ath6kl_credit_distribute(struct ath6kl_htc_credit_info *cred_info, ath6kl_credit_update(cred_info, ep_dist_list); break; case HTC_CREDIT_DIST_ACTIVITY_CHANGE: - ath6kl_redistribute_credits(cred_info, ep_dist_list); + ath6kl_credit_redistribute(cred_info, ep_dist_list); break; default: break; @@ -529,7 +528,7 @@ static int htc_check_credits(struct htc_target *target, ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->credit_info, &ep->cred_dist); - ath6kl_seek_credits(target->credit_info, &ep->cred_dist); + ath6kl_credit_seek(target->credit_info, &ep->cred_dist); ep->cred_dist.seek_cred = 0; @@ -552,7 +551,7 @@ static int htc_check_credits(struct htc_target *target, ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", target->credit_info, &ep->cred_dist); - ath6kl_seek_credits(target->credit_info, &ep->cred_dist); + ath6kl_credit_seek(target->credit_info, &ep->cred_dist); /* see if we were successful in getting more */ if (ep->cred_dist.credits < ep->cred_dist.cred_per_msg) { diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index c68e834..57672e1 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -570,8 +570,8 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, u32 msg_look_ahead, int *n_pkts); -int ath6kl_setup_credit_dist(void *htc_handle, - struct ath6kl_htc_credit_info *cred_info); +int ath6kl_credit_setup(void *htc_handle, + struct ath6kl_htc_credit_info *cred_info); static inline void set_htc_pkt_info(struct htc_packet *packet, void *context, u8 *buf, unsigned int len, diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 1cfe16f..c638aab 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1506,7 +1506,7 @@ static int ath6kl_init(struct ath6kl *ar) ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS); /* setup credit distribution */ - ath6kl_setup_credit_dist(ar->htc_target, &ar->credit_state_info); + ath6kl_credit_setup(ar->htc_target, &ar->credit_state_info); ath6kl_cookie_init(ar); -- cgit v0.10.2 From d23ace77e2d90a093ead65a03d97c36ec261ce71 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:17:51 +0300 Subject: ath6kl: remove unused debug levels Few levels had only one user so I changed them to use WLAN_CFG. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index cbabc25..afb747b 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -20,16 +20,16 @@ #include "hif.h" enum ATH6K_DEBUG_MASK { - ATH6KL_DBG_WLAN_CONNECT = BIT(0), /* wlan connect */ - ATH6KL_DBG_WLAN_SCAN = BIT(1), /* wlan scan */ + /* hole */ + /* hole */ ATH6KL_DBG_WLAN_TX = BIT(2), /* wlan tx */ ATH6KL_DBG_WLAN_RX = BIT(3), /* wlan rx */ ATH6KL_DBG_BMI = BIT(4), /* bmi tracing */ ATH6KL_DBG_HTC = BIT(5), ATH6KL_DBG_HIF = BIT(6), ATH6KL_DBG_IRQ = BIT(7), /* interrupt processing */ - ATH6KL_DBG_PM = BIT(8), /* power management */ - ATH6KL_DBG_WLAN_NODE = BIT(9), /* general wlan node tracing */ + /* hole */ + /* hole */ ATH6KL_DBG_WMI = BIT(10), /* wmi tracing */ ATH6KL_DBG_TRC = BIT(11), /* generic func tracing */ ATH6KL_DBG_SCATTER = BIT(12), /* hif scatter tracing */ diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 16451a4..3b2a7e8 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -691,7 +691,7 @@ void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status) NONE_BSS_FILTER, 0); } - ath6kl_dbg(ATH6KL_DBG_WLAN_SCAN, "scan complete: %d\n", status); + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "scan complete: %d\n", status); } void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, @@ -1051,8 +1051,7 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, del_timer(&vif->disconnect_timer); - ath6kl_dbg(ATH6KL_DBG_WLAN_CONNECT, - "disconnect reason is %d\n", reason); + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "disconnect reason is %d\n", reason); /* * If the event is due to disconnect cmd from the host, only they -- cgit v0.10.2 From 02f0d6fcab8980236694be78b3b1a1973897716e Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:17:59 +0300 Subject: ath6kl: add debug messages for credit handling Also take few from htc debug level which are more suitable for credit. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index c1b822b..d537ccf 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -142,47 +142,46 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist) { - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_CREDIT, "--- endpoint: %d svc_id: 0x%X ---\n", ep_dist->endpoint, ep_dist->svc_id); - ath6kl_dbg(ATH6KL_DBG_ANY, " dist_flags : 0x%X\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " dist_flags : 0x%X\n", ep_dist->dist_flags); - ath6kl_dbg(ATH6KL_DBG_ANY, " cred_norm : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_norm : %d\n", ep_dist->cred_norm); - ath6kl_dbg(ATH6KL_DBG_ANY, " cred_min : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_min : %d\n", ep_dist->cred_min); - ath6kl_dbg(ATH6KL_DBG_ANY, " credits : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " credits : %d\n", ep_dist->credits); - ath6kl_dbg(ATH6KL_DBG_ANY, " cred_assngd : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_assngd : %d\n", ep_dist->cred_assngd); - ath6kl_dbg(ATH6KL_DBG_ANY, " seek_cred : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " seek_cred : %d\n", ep_dist->seek_cred); - ath6kl_dbg(ATH6KL_DBG_ANY, " cred_sz : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_sz : %d\n", ep_dist->cred_sz); - ath6kl_dbg(ATH6KL_DBG_ANY, " cred_per_msg : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_per_msg : %d\n", ep_dist->cred_per_msg); - ath6kl_dbg(ATH6KL_DBG_ANY, " cred_to_dist : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_to_dist : %d\n", ep_dist->cred_to_dist); - ath6kl_dbg(ATH6KL_DBG_ANY, " txq_depth : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, " txq_depth : %d\n", get_queue_depth(&ep_dist->htc_ep->txq)); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_CREDIT, "----------------------------------\n"); } +/* FIXME: move to htc.c */ void dump_cred_dist_stats(struct htc_target *target) { struct htc_endpoint_credit_dist *ep_list; - if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_TRC)) + if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_CREDIT)) return; list_for_each_entry(ep_list, &target->cred_dist_list, list) dump_cred_dist(ep_list); - ath6kl_dbg(ATH6KL_DBG_HTC, "ctxt:%p dist:%p\n", - target->credit_info, NULL); - ath6kl_dbg(ATH6KL_DBG_HTC, - "credit distribution, total : %d, free : %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, + "credit distribution total %d free %d\n", target->credit_info->total_avail_credits, target->credit_info->cur_free_credits); } diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index afb747b..491485e 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -20,7 +20,7 @@ #include "hif.h" enum ATH6K_DEBUG_MASK { - /* hole */ + ATH6KL_DBG_CREDIT = BIT(0), /* hole */ ATH6KL_DBG_WLAN_TX = BIT(2), /* wlan tx */ ATH6KL_DBG_WLAN_RX = BIT(3), /* wlan rx */ diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 511eebd..a971c2f 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -27,6 +27,9 @@ static void ath6kl_credit_deposit(struct ath6kl_htc_credit_info *cred_info, struct htc_endpoint_credit_dist *ep_dist, int credits) { + ath6kl_dbg(ATH6KL_DBG_CREDIT, "credit deposit ep %d credits %d\n", + ep_dist->endpoint, credits); + ep_dist->credits += credits; ep_dist->cred_assngd += credits; cred_info->cur_free_credits -= credits; @@ -39,6 +42,8 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, struct htc_endpoint_credit_dist *cur_ep_dist; int count; + ath6kl_dbg(ATH6KL_DBG_CREDIT, "credit init total %d\n", tot_credits); + cred_info->cur_free_credits = tot_credits; cred_info->total_avail_credits = tot_credits; @@ -108,6 +113,15 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, cur_ep_dist->cred_norm = count; } + + ath6kl_dbg(ATH6KL_DBG_CREDIT, + "credit ep %d svc_id %d credits %d per_msg %d norm %d min %d\n", + cur_ep_dist->endpoint, + cur_ep_dist->svc_id, + cur_ep_dist->credits, + cur_ep_dist->cred_per_msg, + cur_ep_dist->cred_norm, + cur_ep_dist->cred_min); } } @@ -138,6 +152,9 @@ static void ath6kl_credit_reduce(struct ath6kl_htc_credit_info *cred_info, { int credits; + ath6kl_dbg(ATH6KL_DBG_CREDIT, "credit reduce ep %d limit %d\n", + ep_dist->endpoint, limit); + ep_dist->cred_assngd = limit; if (ep_dist->credits <= limit) @@ -515,7 +532,7 @@ static int htc_check_credits(struct htc_target *target, *req_cred = (len > target->tgt_cred_sz) ? DIV_ROUND_UP(len, target->tgt_cred_sz) : 1; - ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds required %d got %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, "credit check need %d got %d\n", *req_cred, ep->cred_dist.credits); if (ep->cred_dist.credits < *req_cred) { @@ -525,16 +542,13 @@ static int htc_check_credits(struct htc_target *target, /* Seek more credits */ ep->cred_dist.seek_cred = *req_cred - ep->cred_dist.credits; - ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", - target->credit_info, &ep->cred_dist); - ath6kl_credit_seek(target->credit_info, &ep->cred_dist); ep->cred_dist.seek_cred = 0; if (ep->cred_dist.credits < *req_cred) { - ath6kl_dbg(ATH6KL_DBG_HTC, - "htc creds not enough credits for ep %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, + "credit not found for ep %d\n", eid); return -EINVAL; } @@ -548,9 +562,6 @@ static int htc_check_credits(struct htc_target *target, ep->cred_dist.seek_cred = ep->cred_dist.cred_per_msg - ep->cred_dist.credits; - ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", - target->credit_info, &ep->cred_dist); - ath6kl_credit_seek(target->credit_info, &ep->cred_dist); /* see if we were successful in getting more */ @@ -558,7 +569,8 @@ static int htc_check_credits(struct htc_target *target, /* tell the target we need credits ASAP! */ *flags |= HTC_FLAGS_NEED_CREDIT_UPDATE; ep->ep_st.cred_low_indicate += 1; - ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds host needs credits\n"); + ath6kl_dbg(ATH6KL_DBG_CREDIT, + "credit we need credits asap\n"); } } @@ -1495,9 +1507,6 @@ static void htc_proc_cred_rpt(struct htc_target *target, int tot_credits = 0, i; bool dist = false; - ath6kl_dbg(ATH6KL_DBG_HTC, - "htc creds report entries %d\n", n_entries); - spin_lock_bh(&target->tx_lock); for (i = 0; i < n_entries; i++, rpt++) { @@ -1509,8 +1518,8 @@ static void htc_proc_cred_rpt(struct htc_target *target, endpoint = &target->endpoint[rpt->eid]; - ath6kl_dbg(ATH6KL_DBG_HTC, - "htc creds report ep %d credits %d\n", + ath6kl_dbg(ATH6KL_DBG_CREDIT, + "credit report ep %d credits %d\n", rpt->eid, rpt->credits); endpoint->ep_st.tx_cred_rpt += 1; @@ -1551,18 +1560,11 @@ static void htc_proc_cred_rpt(struct htc_target *target, tot_credits += rpt->credits; } - ath6kl_dbg(ATH6KL_DBG_HTC, - "htc creds report tot_credits %d\n", - tot_credits); - if (dist) { /* * This was a credit return based on a completed send * operations note, this is done with the lock held */ - ath6kl_dbg(ATH6KL_DBG_HTC, "htc creds ctxt 0x%p dist 0x%p\n", - target->credit_info, &target->cred_dist_list); - ath6kl_credit_distribute(target->credit_info, &target->cred_dist_list, HTC_CREDIT_DIST_SEND_COMPLETE); -- cgit v0.10.2 From 3ef987bee7d56604bcbdbaebf85c51ca2ad87503 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 24 Oct 2011 12:18:07 +0300 Subject: ath6kl: add more boot debug messages Move some of the debug logs to boot level because they are more interesting when debugging boot issues. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index a971c2f..976e352 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2499,7 +2499,7 @@ static void htc_setup_msg_bndl(struct htc_target *target) target->msg_per_bndl_max = min(target->max_scat_entries, target->msg_per_bndl_max); - ath6kl_dbg(ATH6KL_DBG_HTC, + ath6kl_dbg(ATH6KL_DBG_BOOT, "htc bundling allowed msg_per_bndl_max %d\n", target->msg_per_bndl_max); @@ -2509,7 +2509,7 @@ static void htc_setup_msg_bndl(struct htc_target *target) target->max_tx_bndl_sz = min(HIF_MBOX0_EXT_WIDTH, target->max_xfer_szper_scatreq); - ath6kl_dbg(ATH6KL_DBG_HTC, "htc max_rx_bndl_sz %d max_tx_bndl_sz %d\n", + ath6kl_dbg(ATH6KL_DBG_BOOT, "htc max_rx_bndl_sz %d max_tx_bndl_sz %d\n", target->max_rx_bndl_sz, target->max_tx_bndl_sz); if (target->max_tx_bndl_sz) @@ -2563,7 +2563,7 @@ int ath6kl_htc_wait_target(struct htc_target *target) target->tgt_creds = le16_to_cpu(rdy_msg->ver2_0_info.cred_cnt); target->tgt_cred_sz = le16_to_cpu(rdy_msg->ver2_0_info.cred_sz); - ath6kl_dbg(ATH6KL_DBG_HTC, + ath6kl_dbg(ATH6KL_DBG_BOOT, "htc target ready credits %d size %d\n", target->tgt_creds, target->tgt_cred_sz); @@ -2578,7 +2578,7 @@ int ath6kl_htc_wait_target(struct htc_target *target) target->msg_per_bndl_max = 0; } - ath6kl_dbg(ATH6KL_DBG_HTC, "htc using protocol %s (%d)\n", + ath6kl_dbg(ATH6KL_DBG_BOOT, "htc using protocol %s (%d)\n", (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", target->htc_tgt_ver); diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index b7c0566..5ce0b8b 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -471,6 +471,8 @@ static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio) if (!ar_sdio->is_disabled) return 0; + ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power on\n"); + sdio_claim_host(func); ret = sdio_enable_func(func); @@ -500,6 +502,8 @@ static int ath6kl_sdio_power_off(struct ath6kl_sdio *ar_sdio) if (ar_sdio->is_disabled) return 0; + ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power off\n"); + /* Disable the card */ sdio_claim_host(ar_sdio->func); ret = sdio_disable_func(ar_sdio->func); @@ -678,8 +682,8 @@ static int ath6kl_sdio_enable_scatter(struct ath6kl *ar) MAX_SCATTER_REQUESTS, virt_scat); if (!ret) { - ath6kl_dbg(ATH6KL_DBG_SCATTER, - "hif-scatter enabled: max scatter req : %d entries: %d\n", + ath6kl_dbg(ATH6KL_DBG_BOOT, + "hif-scatter enabled requests %d entries %d\n", MAX_SCATTER_REQUESTS, MAX_SCATTER_ENTRIES_PER_REQ); @@ -703,8 +707,8 @@ static int ath6kl_sdio_enable_scatter(struct ath6kl *ar) return ret; } - ath6kl_dbg(ATH6KL_DBG_SCATTER, - "Vitual scatter enabled, max_scat_req:%d, entries:%d\n", + ath6kl_dbg(ATH6KL_DBG_BOOT, + "virtual scatter enabled requests %d entries %d\n", ATH6KL_SCATTER_REQS, ATH6KL_SCATTER_ENTRIES_PER_REQ); target->max_scat_entries = ATH6KL_SCATTER_ENTRIES_PER_REQ; @@ -778,8 +782,8 @@ static int ath6kl_sdio_probe(struct sdio_func *func, struct ath6kl *ar; int count; - ath6kl_dbg(ATH6KL_DBG_SDIO, - "new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n", + ath6kl_dbg(ATH6KL_DBG_BOOT, + "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n", func->num, func->vendor, func->device, func->max_blksize, func->cur_blksize); @@ -840,7 +844,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, goto err_core_alloc; } - ath6kl_dbg(ATH6KL_DBG_SDIO, "4-bit async irq mode enabled\n"); + ath6kl_dbg(ATH6KL_DBG_BOOT, "4-bit async irq mode enabled\n"); } /* give us some time to enable, in ms */ @@ -888,8 +892,8 @@ static void ath6kl_sdio_remove(struct sdio_func *func) { struct ath6kl_sdio *ar_sdio; - ath6kl_dbg(ATH6KL_DBG_SDIO, - "removed func %d vendor 0x%x device 0x%x\n", + ath6kl_dbg(ATH6KL_DBG_BOOT, + "sdio removed func %d vendor 0x%x device 0x%x\n", func->num, func->vendor, func->device); ar_sdio = sdio_get_drvdata(func); -- cgit v0.10.2 From 635412127e089cc401fdd793f4d3731450419231 Mon Sep 17 00:00:00 2001 From: Aarthi Thiruvengadam Date: Tue, 25 Oct 2011 11:25:52 -0700 Subject: ath6kl: add support for WPS Add control flag CONNECT_WPS_FLAG if a WPS IE is present in the Association Request IEs. This flag is needed when the station must connect to a WPS-enabled AP. Signed-off-by: Aarthi Thiruvengadam Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 3380dd9..a563fdf 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -259,6 +259,14 @@ static bool ath6kl_is_rsn_ie(const u8 *pos) return pos[0] == WLAN_EID_RSN; } +static bool ath6kl_is_wps_ie(const u8 *pos) +{ + return (pos[0] == WLAN_EID_VENDOR_SPECIFIC && + pos[1] >= 4 && + pos[2] == 0x00 && pos[3] == 0x50 && pos[4] == 0xf2 && + pos[5] == 0x04); +} + static int ath6kl_set_assoc_req_ies(struct ath6kl_vif *vif, const u8 *ies, size_t ies_len) { @@ -269,6 +277,12 @@ static int ath6kl_set_assoc_req_ies(struct ath6kl_vif *vif, const u8 *ies, int ret; /* + * Clear previously set flag + */ + + ar->connect_ctrl_flags &= ~CONNECT_WPS_FLAG; + + /* * Filter out RSN/WPA IE(s) */ @@ -285,6 +299,10 @@ static int ath6kl_set_assoc_req_ies(struct ath6kl_vif *vif, const u8 *ies, memcpy(buf + len, pos, 2 + pos[1]); len += 2 + pos[1]; } + + if (ath6kl_is_wps_ie(pos)) + ar->connect_ctrl_flags |= CONNECT_WPS_FLAG; + pos += 2 + pos[1]; } } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 495d2e5..9055c75 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -626,6 +626,7 @@ enum wmi_connect_ctrl_flags_bits { CONNECT_CSA_FOLLOW_BSS = 0x0020, CONNECT_DO_WPA_OFFLOAD = 0x0040, CONNECT_DO_NOT_DEAUTH = 0x0080, + CONNECT_WPS_FLAG = 0x0100, }; struct wmi_connect_cmd { -- cgit v0.10.2 From ef8f0eba5a35327a9968e2a4d2116195240512c6 Mon Sep 17 00:00:00 2001 From: Rishi Panjwani Date: Tue, 25 Oct 2011 17:26:29 -0700 Subject: ath6kl: Implement support for listen interval from userspace In order to allow user space based control of listen interval, we use available debugfs infrastructure. Listen interval implies how frequently we want the WLAN chip to wake up and synchronize the beacons in case it is in sleep mode. The command requires two parameters in the following order: 1) listen_interval_time 2) listen_interval_beacons The user has to write the listen interval_time (in msecs) and listen_interval_beacons (in no. of beacons) to the listen_interval file in ath6kl debug directory. Example: echo "30 1" > listen_interval Signed-off-by: Rishi Panjwani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index d537ccf..5214920 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1503,6 +1503,70 @@ static const struct file_operations fops_bgscan_int = { .llseek = default_llseek, }; +static ssize_t ath6kl_listen_int_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + u16 listen_int_t, listen_int_b; + char buf[32]; + char *sptr, *token; + ssize_t len; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + + buf[len] = '\0'; + sptr = buf; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + + if (kstrtou16(token, 0, &listen_int_t)) + return -EINVAL; + + if (kstrtou16(sptr, 0, &listen_int_b)) + return -EINVAL; + + if ((listen_int_t < 15) || (listen_int_t > 5000)) + return -EINVAL; + + if ((listen_int_b < 1) || (listen_int_b > 50)) + return -EINVAL; + + ar->listen_intvl_t = listen_int_t; + ar->listen_intvl_b = listen_int_b; + + ath6kl_wmi_listeninterval_cmd(ar->wmi, 0, ar->listen_intvl_t, + ar->listen_intvl_b); + + return count; +} + +static ssize_t ath6kl_listen_int_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + char buf[16]; + int len; + + len = snprintf(buf, sizeof(buf), "%u %u\n", ar->listen_intvl_t, + ar->listen_intvl_b); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static const struct file_operations fops_listen_int = { + .read = ath6kl_listen_int_read, + .write = ath6kl_listen_int_write, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + int ath6kl_debug_init(struct ath6kl *ar) { ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); -- cgit v0.10.2 From a24fc7c35324618ce5fe9c54baa4bc9a3881cc86 Mon Sep 17 00:00:00 2001 From: Rishi Panjwani Date: Tue, 25 Oct 2011 19:52:41 -0700 Subject: ath6kl: Implement support for power parameter control from userspace In order to allow user space based control of power parameters, we use available debugfs infrastructure. With these features user can control power consumption by adjusting various sleep/wake up related parameters. The feature has been added for testing purposes. All 5 parameters are mandatory in correct order. They have to be written to the power_params file. These are: 1) idle_period 2) no_of_pspoll 3) dtim_policy 4) tx_wakeup_policy 5) no_tx_to_wakeup Example: echo "200 1 0 1 1" > power_params Signed-off-by: Rishi Panjwani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 5214920..70ea137 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1567,6 +1567,66 @@ static const struct file_operations fops_listen_int = { .llseek = default_llseek, }; +static ssize_t ath6kl_power_params_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + u8 buf[100]; + unsigned int len = 0; + char *sptr, *token; + u16 idle_period, ps_poll_num, dtim, + tx_wakeup, num_tx; + + len = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, len)) + return -EFAULT; + buf[len] = '\0'; + sptr = buf; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou16(token, 0, &idle_period)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou16(token, 0, &ps_poll_num)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou16(token, 0, &dtim)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou16(token, 0, &tx_wakeup)) + return -EINVAL; + + token = strsep(&sptr, " "); + if (!token) + return -EINVAL; + if (kstrtou16(token, 0, &num_tx)) + return -EINVAL; + + ath6kl_wmi_pmparams_cmd(ar->wmi, 0, idle_period, ps_poll_num, + dtim, tx_wakeup, num_tx, 0); + + return count; +} + +static const struct file_operations fops_power_params = { + .write = ath6kl_power_params_write, + .open = ath6kl_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + int ath6kl_debug_init(struct ath6kl *ar) { ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); @@ -1649,6 +1709,9 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("bgscan_interval", S_IWUSR, ar->debugfs_phy, ar, &fops_bgscan_int); + debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar, + &fops_power_params); + return 0; } -- cgit v0.10.2 From f7830202c3ae934e2b978b750656626b203decb4 Mon Sep 17 00:00:00 2001 From: Sangwook Lee Date: Wed, 26 Oct 2011 16:28:38 +0100 Subject: ath6kl: Fix compilation error from of.h When compiling ath6kl for ARM with device tree tree compilation fails with errors like: include/linux/of.h: In function 'of_property_read_u32_array': include/linux/of.h:249:10: error: 'ENOSYS' undeclared Workaround this by including errno.h from init.c. kvalo: improved commit log Signed-off-by: Sangwook Lee Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index c638aab..6e6a141 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include "core.h" -- cgit v0.10.2 From 1052261e4bba9879c1d7d519c8e8606c5d4264d5 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 27 Oct 2011 16:00:13 +0300 Subject: ath6kl: Report unique remain-on-channel cookie values Even though only a single concurrent remain-on-channel operation is supported, there may be two pending remain-on-channel events (one to indicate end of a canceled operation and another to indicate start of a new operation). User space won't be able to distinguish these events unless unique cookies are used. The previous behavior resulted in wpa_supplicant getting quite confused about the driver's offchannel state in various sequences and this made the P2P state machine behave incorrectly. Use of more than a single remain-on-channel cookie value fixes this. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index a563fdf..940aeb6 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1932,10 +1932,16 @@ static int ath6kl_remain_on_channel(struct wiphy *wiphy, { struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); + u32 id; /* TODO: if already pending or ongoing remain-on-channel, * return -EBUSY */ - *cookie = 1; /* only a single pending request is supported */ + id = ++vif->last_roc_id; + if (id == 0) { + /* Do not use 0 as the cookie value */ + id = ++vif->last_roc_id; + } + *cookie = id; return ath6kl_wmi_remain_on_chnl_cmd(ar->wmi, vif->fw_vif_idx, chan->center_freq, duration); @@ -1948,8 +1954,9 @@ static int ath6kl_cancel_remain_on_channel(struct wiphy *wiphy, struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); - if (cookie != 1) + if (cookie != vif->last_roc_id) return -ENOENT; + vif->last_cancel_roc_id = cookie; return ath6kl_wmi_cancel_remain_on_chnl_cmd(ar->wmi, vif->fw_vif_idx); } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 97d7f11..5ac415e 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -427,6 +427,8 @@ struct ath6kl_vif { struct cfg80211_scan_request *scan_req; enum sme_state sme_state; int reconnect_flag; + u32 last_roc_id; + u32 last_cancel_roc_id; u32 send_action_id; bool probe_req_report; u16 next_chan; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index e6b0960..ddefc8e 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -443,6 +443,7 @@ static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, u32 dur; struct ieee80211_channel *chan; struct ath6kl *ar = wmi->parent_dev; + u32 id; if (len < sizeof(*ev)) return -EINVAL; @@ -458,7 +459,8 @@ static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, "(freq=%u)\n", freq); return -EINVAL; } - cfg80211_ready_on_channel(vif->ndev, 1, chan, NL80211_CHAN_NO_HT, + id = vif->last_roc_id; + cfg80211_ready_on_channel(vif->ndev, id, chan, NL80211_CHAN_NO_HT, dur, GFP_ATOMIC); return 0; @@ -473,6 +475,7 @@ static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, u32 dur; struct ieee80211_channel *chan; struct ath6kl *ar = wmi->parent_dev; + u32 id; if (len < sizeof(*ev)) return -EINVAL; @@ -488,7 +491,13 @@ static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, "channel (freq=%u)\n", freq); return -EINVAL; } - cfg80211_remain_on_channel_expired(vif->ndev, 1, chan, + if (vif->last_cancel_roc_id && + vif->last_cancel_roc_id + 1 == vif->last_roc_id) + id = vif->last_cancel_roc_id; /* event for cancel command */ + else + id = vif->last_roc_id; /* timeout on uncanceled r-o-c */ + vif->last_cancel_roc_id = 0; + cfg80211_remain_on_channel_expired(vif->ndev, id, chan, NL80211_CHAN_NO_HT, GFP_ATOMIC); return 0; -- cgit v0.10.2 From 3101edef5cc43034cd809e7105ea2b366e9c7c00 Mon Sep 17 00:00:00 2001 From: Aarthi Thiruvengadam Date: Thu, 27 Oct 2011 09:35:56 -0700 Subject: ath6kl: fix missing copy of action frame contents The wpa_supplicant was receiving incorrect frame contents in the callback function that indicates the status of the frame transmitted. This patch fixes a missing copy of the frame contents to a local buffer. The local buffer keeps track of the last sent management frame. Signed-off-by: Aarthi Thiruvengadam Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index ddefc8e..1426f61c 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2846,6 +2846,7 @@ int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, } kfree(wmi->last_mgmt_tx_frame); + memcpy(buf, data, data_len); wmi->last_mgmt_tx_frame = buf; wmi->last_mgmt_tx_frame_len = data_len; -- cgit v0.10.2 From cb93821a9eaf53fb60addd689d3fa9f106790be1 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:47:46 +0300 Subject: ath6kl: don't use cfg80211_scan_request after cfg80211_scan_done() Use of cfg80211_scan_request is not valid after calling cfg80211_scan_done() but ath6kl_cfg80211_scan_complete_event() was doing exactly that. Change the function to call cfg80211_scan_done() last. This was found during code review, I didn't see any visible problems due to this bug. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 940aeb6..01bb9ed 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -874,6 +874,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status) { struct ath6kl *ar = vif->ar; + bool aborted; int i; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: status %d\n", __func__, status); @@ -882,11 +883,11 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status) return; if ((status == -ECANCELED) || (status == -EBUSY)) { - cfg80211_scan_done(vif->scan_req, true); + aborted = true; goto out; } - cfg80211_scan_done(vif->scan_req, false); + aborted = false; if (vif->scan_req->n_ssids && vif->scan_req->ssids[0].ssid_len) { for (i = 0; i < vif->scan_req->n_ssids; i++) { @@ -897,6 +898,7 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status) } out: + cfg80211_scan_done(vif->scan_req, aborted); vif->scan_req = NULL; } -- cgit v0.10.2 From c89c591d19ace9904cfd658f54d7d72aa54b3371 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:48:00 +0300 Subject: ath6kl: rename ath6kl_wmi_qos_state_init() to _wmi_reset() Just to make it more clear that this function is supposed to reset wmi related variables. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 1426f61c..d3db5b3 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -3211,11 +3211,8 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) return ret; } -static void ath6kl_wmi_qos_state_init(struct wmi *wmi) +void ath6kl_wmi_reset(struct wmi *wmi) { - if (!wmi) - return; - spin_lock_bh(&wmi->lock); wmi->fat_pipe_exist = 0; @@ -3238,7 +3235,7 @@ void *ath6kl_wmi_init(struct ath6kl *dev) wmi->pwr_mode = REC_POWER; - ath6kl_wmi_qos_state_init(wmi); + ath6kl_wmi_reset(wmi); return wmi; } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 9055c75..ae514cb 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2316,5 +2316,6 @@ int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx); void *ath6kl_wmi_init(struct ath6kl *devt); void ath6kl_wmi_shutdown(struct wmi *wmi); +void ath6kl_wmi_reset(struct wmi *wmi); #endif /* WMI_H */ -- cgit v0.10.2 From b2e756989e9744d94f7cbae47586858c3efc8430 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:48:14 +0300 Subject: ath6kl: move power control from sdio to core In preparation for cutting down power from the chip on the fly. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index 95e7303..34adc77 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -96,4 +96,19 @@ static inline int ath6kl_hif_resume(struct ath6kl *ar) return ar->hif_ops->resume(ar); } + +static inline int ath6kl_hif_power_on(struct ath6kl *ar) +{ + ath6kl_dbg(ATH6KL_DBG_HIF, "hif power on\n"); + + return ar->hif_ops->power_on(ar); +} + +static inline int ath6kl_hif_power_off(struct ath6kl *ar) +{ + ath6kl_dbg(ATH6KL_DBG_HIF, "hif power off\n"); + + return ar->hif_ops->power_off(ar); +} + #endif diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 93d2912..ee7c31a 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -242,6 +242,8 @@ struct ath6kl_hif_ops { void (*cleanup_scatter)(struct ath6kl *ar); int (*suspend)(struct ath6kl *ar); int (*resume)(struct ath6kl *ar); + int (*power_on)(struct ath6kl *ar); + int (*power_off)(struct ath6kl *ar); }; int ath6kl_hif_setup(struct ath6kl_device *dev); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 6e6a141..e89c9a6 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -554,6 +554,8 @@ void ath6kl_core_free(struct ath6kl *ar) void ath6kl_core_cleanup(struct ath6kl *ar) { + ath6kl_hif_power_off(ar); + destroy_workqueue(ar->ath6kl_wq); if (ar->htc_target) @@ -1602,27 +1604,31 @@ int ath6kl_core_init(struct ath6kl *ar) if (ret) goto err_wq; - ret = ath6kl_bmi_get_target_info(ar, &targ_info); + ret = ath6kl_hif_power_on(ar); if (ret) goto err_bmi_cleanup; + ret = ath6kl_bmi_get_target_info(ar, &targ_info); + if (ret) + goto err_power_off; + ar->version.target_ver = le32_to_cpu(targ_info.version); ar->target_type = le32_to_cpu(targ_info.type); ar->wiphy->hw_version = le32_to_cpu(targ_info.version); ret = ath6kl_init_hw_params(ar); if (ret) - goto err_bmi_cleanup; + goto err_power_off; ret = ath6kl_configure_target(ar); if (ret) - goto err_bmi_cleanup; + goto err_power_off; ar->htc_target = ath6kl_htc_create(ar); if (!ar->htc_target) { ret = -ENOMEM; - goto err_bmi_cleanup; + goto err_power_off; } ret = ath6kl_fetch_firmwares(ar); @@ -1641,6 +1647,8 @@ int ath6kl_core_init(struct ath6kl *ar) err_htc_cleanup: ath6kl_htc_cleanup(ar->htc_target); +err_power_off: + ath6kl_hif_power_off(ar); err_bmi_cleanup: ath6kl_bmi_cleanup(ar); err_wq: diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 5ce0b8b..682c47c 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -463,8 +463,9 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func) WARN_ON(status && status != -ECANCELED); } -static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio) +static int ath6kl_sdio_power_on(struct ath6kl *ar) { + struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct sdio_func *func = ar_sdio->func; int ret = 0; @@ -495,8 +496,9 @@ static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio) return ret; } -static int ath6kl_sdio_power_off(struct ath6kl_sdio *ar_sdio) +static int ath6kl_sdio_power_off(struct ath6kl *ar) { + struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); int ret; if (ar_sdio->is_disabled) @@ -772,6 +774,8 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .cleanup_scatter = ath6kl_sdio_cleanup_scatter, .suspend = ath6kl_sdio_suspend, .resume = ath6kl_sdio_resume, + .power_on = ath6kl_sdio_power_on, + .power_off = ath6kl_sdio_power_off, }; static int ath6kl_sdio_probe(struct sdio_func *func, @@ -852,10 +856,6 @@ static int ath6kl_sdio_probe(struct sdio_func *func, sdio_release_host(func); - ret = ath6kl_sdio_power_on(ar_sdio); - if (ret) - goto err_core_alloc; - sdio_claim_host(func); ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE); @@ -863,7 +863,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ath6kl_err("Set sdio block size %d failed: %d)\n", HIF_MBOX_BLOCK_SIZE, ret); sdio_release_host(func); - goto err_off; + goto err_hif; } sdio_release_host(func); @@ -871,13 +871,11 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ret = ath6kl_core_init(ar); if (ret) { ath6kl_err("Failed to init ath6kl core\n"); - goto err_off; + goto err_hif; } return ret; -err_off: - ath6kl_sdio_power_off(ar_sdio); err_core_alloc: ath6kl_core_free(ar_sdio->ar); err_dma: @@ -903,8 +901,6 @@ static void ath6kl_sdio_remove(struct sdio_func *func) ath6kl_core_cleanup(ar_sdio->ar); - ath6kl_sdio_power_off(ar_sdio); - kfree(ar_sdio->dma_buffer); kfree(ar_sdio); } -- cgit v0.10.2 From 4e3d54c7abcaad35062540432ba5b72bf27876aa Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:48:22 +0300 Subject: ath6kl: add a fixme to ath6kl_htc_wait_target() This doesn't look right, but investigate it later. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 976e352..d03456b 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2598,6 +2598,10 @@ int ath6kl_htc_wait_target(struct htc_target *target) status = ath6kl_htc_conn_service((void *)target, &connect, &resp); if (status) + /* + * FIXME: this call doesn't make sense, the caller should + * call ath6kl_htc_cleanup() when it wants remove htc + */ ath6kl_hif_cleanup_scatter(target->dev->ar); fail_wait_target: -- cgit v0.10.2 From 61448a93efc26dc00e9684a9421394ca78142479 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:48:29 +0300 Subject: ath6kl: merge ath6kl_init() to ath6kl_core_init() In preparation for splitting module initialisation and hardware boot code from each other. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index e89c9a6..62e0f22 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1421,20 +1421,62 @@ static int ath6kl_init_hw_params(struct ath6kl *ar) return 0; } -static int ath6kl_init(struct ath6kl *ar) +int ath6kl_core_init(struct ath6kl *ar) { - int status = 0; + struct ath6kl_bmi_target_info targ_info; s32 timeleft; struct net_device *ndev; - int i; + int i, ret = 0; - if (!ar) - return -EIO; + ar->ath6kl_wq = create_singlethread_workqueue("ath6kl"); + if (!ar->ath6kl_wq) + return -ENOMEM; + + ret = ath6kl_bmi_init(ar); + if (ret) + goto err_wq; + + ret = ath6kl_hif_power_on(ar); + if (ret) + goto err_bmi_cleanup; + + ret = ath6kl_bmi_get_target_info(ar, &targ_info); + if (ret) + goto err_power_off; + + ar->version.target_ver = le32_to_cpu(targ_info.version); + ar->target_type = le32_to_cpu(targ_info.type); + ar->wiphy->hw_version = le32_to_cpu(targ_info.version); + + ret = ath6kl_init_hw_params(ar); + if (ret) + goto err_power_off; + + ret = ath6kl_configure_target(ar); + if (ret) + goto err_power_off; + + ar->htc_target = ath6kl_htc_create(ar); + + if (!ar->htc_target) { + ret = -ENOMEM; + goto err_power_off; + } + + ret = ath6kl_fetch_firmwares(ar); + if (ret) + goto err_htc_cleanup; + + /* FIXME: we should free all firmwares in the error cases below */ + + ret = ath6kl_init_upload(ar); + if (ret) + goto err_htc_cleanup; /* Do we need to finish the BMI phase */ if (ath6kl_bmi_done(ar)) { - status = -EIO; - goto ath6kl_init_done; + ret = -EIO; + goto err_htc_cleanup; } /* Indicate that WMI is enabled (although not ready yet) */ @@ -1442,18 +1484,18 @@ static int ath6kl_init(struct ath6kl *ar) ar->wmi = ath6kl_wmi_init(ar); if (!ar->wmi) { ath6kl_err("failed to initialize wmi\n"); - status = -EIO; - goto ath6kl_init_done; + ret = -EIO; + goto err_htc_cleanup; } ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi); - status = ath6kl_register_ieee80211_hw(ar); - if (status) + ret = ath6kl_register_ieee80211_hw(ar); + if (ret) goto err_node_cleanup; - status = ath6kl_debug_init(ar); - if (status) { + ret = ath6kl_debug_init(ar); + if (ret) { wiphy_unregister(ar->wiphy); goto err_node_cleanup; } @@ -1471,7 +1513,7 @@ static int ath6kl_init(struct ath6kl *ar) if (!ndev) { ath6kl_err("Failed to instantiate a network device\n"); - status = -ENOMEM; + ret = -ENOMEM; wiphy_unregister(ar->wiphy); goto err_debug_init; } @@ -1486,12 +1528,12 @@ static int ath6kl_init(struct ath6kl *ar) * size. */ if (ath6kl_htc_wait_target(ar->htc_target)) { - status = -EIO; + ret = -EIO; goto err_if_deinit; } if (ath6kl_init_service_ep(ar)) { - status = -EIO; + ret = -EIO; goto err_cleanup_scatter; } @@ -1514,9 +1556,8 @@ static int ath6kl_init(struct ath6kl *ar) ath6kl_cookie_init(ar); /* start HTC */ - status = ath6kl_htc_start(ar->htc_target); - - if (status) { + ret = ath6kl_htc_start(ar->htc_target); + if (ret) { ath6kl_cookie_cleanup(ar); goto err_rxbuf_cleanup; } @@ -1532,13 +1573,13 @@ static int ath6kl_init(struct ath6kl *ar) if (ar->version.abi_ver != ATH6KL_ABI_VERSION) { ath6kl_err("abi version mismatch: host(0x%x), target(0x%x)\n", ATH6KL_ABI_VERSION, ar->version.abi_ver); - status = -EIO; + ret = -EIO; goto err_htc_stop; } if (!timeleft || signal_pending(current)) { ath6kl_err("wmi is not ready or wait was interrupted\n"); - status = -EIO; + ret = -EIO; goto err_htc_stop; } @@ -1555,8 +1596,8 @@ static int ath6kl_init(struct ath6kl *ar) WIPHY_FLAG_HAVE_AP_SME; for (i = 0; i < MAX_NUM_VIF; i++) { - status = ath6kl_target_config_wlan_params(ar, i); - if (status) + ret = ath6kl_target_config_wlan_params(ar, i); + if (ret) goto err_htc_stop; } @@ -1566,7 +1607,7 @@ static int ath6kl_init(struct ath6kl *ar) */ memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); - return status; + return ret; err_htc_stop: ath6kl_htc_stop(ar->htc_target); @@ -1586,65 +1627,6 @@ err_node_cleanup: ath6kl_wmi_shutdown(ar->wmi); clear_bit(WMI_ENABLED, &ar->flag); ar->wmi = NULL; - -ath6kl_init_done: - return status; -} - -int ath6kl_core_init(struct ath6kl *ar) -{ - int ret = 0; - struct ath6kl_bmi_target_info targ_info; - - ar->ath6kl_wq = create_singlethread_workqueue("ath6kl"); - if (!ar->ath6kl_wq) - return -ENOMEM; - - ret = ath6kl_bmi_init(ar); - if (ret) - goto err_wq; - - ret = ath6kl_hif_power_on(ar); - if (ret) - goto err_bmi_cleanup; - - ret = ath6kl_bmi_get_target_info(ar, &targ_info); - if (ret) - goto err_power_off; - - ar->version.target_ver = le32_to_cpu(targ_info.version); - ar->target_type = le32_to_cpu(targ_info.type); - ar->wiphy->hw_version = le32_to_cpu(targ_info.version); - - ret = ath6kl_init_hw_params(ar); - if (ret) - goto err_power_off; - - ret = ath6kl_configure_target(ar); - if (ret) - goto err_power_off; - - ar->htc_target = ath6kl_htc_create(ar); - - if (!ar->htc_target) { - ret = -ENOMEM; - goto err_power_off; - } - - ret = ath6kl_fetch_firmwares(ar); - if (ret) - goto err_htc_cleanup; - - ret = ath6kl_init_upload(ar); - if (ret) - goto err_htc_cleanup; - - ret = ath6kl_init(ar); - if (ret) - goto err_htc_cleanup; - - return ret; - err_htc_cleanup: ath6kl_htc_cleanup(ar->htc_target); err_power_off: -- cgit v0.10.2 From 20459ee2744d0dc47849ff5791e68ec805aa0a88 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:48:37 +0300 Subject: ath6kl: separate hardware boot code from module initialisation code Refactor the code needed to boot the hardware to a separate function so that it will be easier boot and shutdown hardware. No functional changes (hopefully). Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 62e0f22..2ee6a5e 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1421,12 +1421,107 @@ static int ath6kl_init_hw_params(struct ath6kl *ar) return 0; } +static int ath6kl_hw_start(struct ath6kl *ar) +{ + long timeleft; + int ret, i; + + ret = ath6kl_hif_power_on(ar); + if (ret) + return ret; + + ret = ath6kl_configure_target(ar); + if (ret) + goto err_power_off; + + ret = ath6kl_init_upload(ar); + if (ret) + goto err_power_off; + + /* Do we need to finish the BMI phase */ + /* FIXME: return error from ath6kl_bmi_done() */ + if (ath6kl_bmi_done(ar)) { + ret = -EIO; + goto err_power_off; + } + + /* + * The reason we have to wait for the target here is that the + * driver layer has to init BMI in order to set the host block + * size. + */ + if (ath6kl_htc_wait_target(ar->htc_target)) { + ret = -EIO; + goto err_power_off; + } + + if (ath6kl_init_service_ep(ar)) { + ret = -EIO; + goto err_cleanup_scatter; + } + + /* setup credit distribution */ + ath6kl_credit_setup(ar->htc_target, &ar->credit_state_info); + + /* start HTC */ + ret = ath6kl_htc_start(ar->htc_target); + if (ret) { + /* FIXME: call this */ + ath6kl_cookie_cleanup(ar); + goto err_cleanup_scatter; + } + + /* Wait for Wmi event to be ready */ + timeleft = wait_event_interruptible_timeout(ar->event_wq, + test_bit(WMI_READY, + &ar->flag), + WMI_TIMEOUT); + + ath6kl_dbg(ATH6KL_DBG_BOOT, "firmware booted\n"); + + if (ar->version.abi_ver != ATH6KL_ABI_VERSION) { + ath6kl_err("abi version mismatch: host(0x%x), target(0x%x)\n", + ATH6KL_ABI_VERSION, ar->version.abi_ver); + ret = -EIO; + goto err_htc_stop; + } + + if (!timeleft || signal_pending(current)) { + ath6kl_err("wmi is not ready or wait was interrupted\n"); + ret = -EIO; + goto err_htc_stop; + } + + ath6kl_dbg(ATH6KL_DBG_TRC, "%s: wmi is ready\n", __func__); + + /* communicate the wmi protocol verision to the target */ + /* FIXME: return error */ + if ((ath6kl_set_host_app_area(ar)) != 0) + ath6kl_err("unable to set the host app area\n"); + + for (i = 0; i < MAX_NUM_VIF; i++) { + ret = ath6kl_target_config_wlan_params(ar, i); + if (ret) + goto err_htc_stop; + } + + return 0; + +err_htc_stop: + ath6kl_htc_stop(ar->htc_target); +err_cleanup_scatter: + ath6kl_hif_cleanup_scatter(ar); +err_power_off: + ath6kl_hif_power_off(ar); + + return ret; +} + int ath6kl_core_init(struct ath6kl *ar) { struct ath6kl_bmi_target_info targ_info; - s32 timeleft; struct net_device *ndev; - int i, ret = 0; + int ret = 0, i; ar->ath6kl_wq = create_singlethread_workqueue("ath6kl"); if (!ar->ath6kl_wq) @@ -1436,6 +1531,11 @@ int ath6kl_core_init(struct ath6kl *ar) if (ret) goto err_wq; + /* + * Turn on power to get hardware (target) version and leave power + * on delibrately as we will boot the hardware anyway within few + * seconds. + */ ret = ath6kl_hif_power_on(ar); if (ret) goto err_bmi_cleanup; @@ -1452,10 +1552,6 @@ int ath6kl_core_init(struct ath6kl *ar) if (ret) goto err_power_off; - ret = ath6kl_configure_target(ar); - if (ret) - goto err_power_off; - ar->htc_target = ath6kl_htc_create(ar); if (!ar->htc_target) { @@ -1469,16 +1565,6 @@ int ath6kl_core_init(struct ath6kl *ar) /* FIXME: we should free all firmwares in the error cases below */ - ret = ath6kl_init_upload(ar); - if (ret) - goto err_htc_cleanup; - - /* Do we need to finish the BMI phase */ - if (ath6kl_bmi_done(ar)) { - ret = -EIO; - goto err_htc_cleanup; - } - /* Indicate that WMI is enabled (although not ready yet) */ set_bit(WMI_ENABLED, &ar->flag); ar->wmi = ath6kl_wmi_init(ar); @@ -1522,21 +1608,6 @@ int ath6kl_core_init(struct ath6kl *ar) ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", __func__, ndev->name, ndev, ar); - /* - * The reason we have to wait for the target here is that the - * driver layer has to init BMI in order to set the host block - * size. - */ - if (ath6kl_htc_wait_target(ar->htc_target)) { - ret = -EIO; - goto err_if_deinit; - } - - if (ath6kl_init_service_ep(ar)) { - ret = -EIO; - goto err_cleanup_scatter; - } - /* setup access class priority mappings */ ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */ ar->ac_stream_pri_map[WMM_AC_BE] = 1; @@ -1550,55 +1621,18 @@ int ath6kl_core_init(struct ath6kl *ar) /* allocate some buffers that handle larger AMSDU frames */ ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS); - /* setup credit distribution */ - ath6kl_credit_setup(ar->htc_target, &ar->credit_state_info); - ath6kl_cookie_init(ar); - /* start HTC */ - ret = ath6kl_htc_start(ar->htc_target); - if (ret) { - ath6kl_cookie_cleanup(ar); - goto err_rxbuf_cleanup; - } - - /* Wait for Wmi event to be ready */ - timeleft = wait_event_interruptible_timeout(ar->event_wq, - test_bit(WMI_READY, - &ar->flag), - WMI_TIMEOUT); - - ath6kl_dbg(ATH6KL_DBG_BOOT, "firmware booted\n"); - - if (ar->version.abi_ver != ATH6KL_ABI_VERSION) { - ath6kl_err("abi version mismatch: host(0x%x), target(0x%x)\n", - ATH6KL_ABI_VERSION, ar->version.abi_ver); - ret = -EIO; - goto err_htc_stop; - } - - if (!timeleft || signal_pending(current)) { - ath6kl_err("wmi is not ready or wait was interrupted\n"); - ret = -EIO; - goto err_htc_stop; - } - - ath6kl_dbg(ATH6KL_DBG_TRC, "%s: wmi is ready\n", __func__); - - /* communicate the wmi protocol verision to the target */ - if ((ath6kl_set_host_app_area(ar)) != 0) - ath6kl_err("unable to set the host app area\n"); - ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAVE_AP_SME; - for (i = 0; i < MAX_NUM_VIF; i++) { - ret = ath6kl_target_config_wlan_params(ar, i); - if (ret) - goto err_htc_stop; + ret = ath6kl_hw_start(ar); + if (ret) { + ath6kl_err("Failed to boot hardware: %d\n", ret); + goto err_rxbuf_cleanup; } /* @@ -1609,14 +1643,9 @@ int ath6kl_core_init(struct ath6kl *ar) return ret; -err_htc_stop: - ath6kl_htc_stop(ar->htc_target); err_rxbuf_cleanup: ath6kl_htc_flush_rx_buf(ar->htc_target); ath6kl_cleanup_amsdu_rxbufs(ar); -err_cleanup_scatter: - ath6kl_hif_cleanup_scatter(ar); -err_if_deinit: rtnl_lock(); ath6kl_deinit_if_data(netdev_priv(ndev)); rtnl_unlock(); -- cgit v0.10.2 From 0c30295e4fd5436ad0bd78a6e0974dc4933e2ddb Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:48:45 +0300 Subject: ath6kl: remove useless cleanup call from ath6kl_bmi_done() aht6kl core code will call the cleanup function when the device is removed. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index c5d11cc..5a4c24d 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -196,8 +196,6 @@ int ath6kl_bmi_done(struct ath6kl *ar) return ret; } - ath6kl_bmi_cleanup(ar); - return 0; } -- cgit v0.10.2 From d60e8ab6b9bcbbb5eb7591c1989f8c79d6b3d964 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:48:52 +0300 Subject: ath6kl: add a timeout to ath6kl_hif_intr_bh_handler() It's possible to busyloop forever in ath6kl_hif_intr_bh_handler(). Add a check that it lasts only one second. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index e2d8088..309be98 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -485,6 +485,7 @@ out: int ath6kl_hif_intr_bh_handler(struct ath6kl *ar) { struct ath6kl_device *dev = ar->htc_target->dev; + unsigned long timeout; int status = 0; bool done = false; @@ -498,7 +499,8 @@ int ath6kl_hif_intr_bh_handler(struct ath6kl *ar) * IRQ processing is synchronous, interrupt status registers can be * re-read. */ - while (!done) { + timeout = jiffies + msecs_to_jiffies(ATH6KL_HIF_COMMUNICATION_TIMEOUT); + while (time_before(jiffies, timeout) && !done) { status = proc_pending_irqs(dev, &done); if (status) break; diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index ee7c31a..78a6c79 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -69,6 +69,8 @@ #define ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER (16 * 1024) #define ATH6KL_SCATTER_REQS 4 +#define ATH6KL_HIF_COMMUNICATION_TIMEOUT 1000 + struct bus_request { struct list_head list; -- cgit v0.10.2 From 8a8109169bcb3390a46c81a45fbfdd4801fb1adc Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:49:00 +0300 Subject: ath6kl: create ath6kl_htc_reset() When rebooting hardware we need to reset the htc state in ath6kl_htc_stop(). Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index d03456b..04b4070 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2656,6 +2656,44 @@ int ath6kl_htc_start(struct htc_target *target) return status; } +static int ath6kl_htc_reset(struct htc_target *target) +{ + u32 block_size, ctrl_bufsz; + struct htc_packet *packet; + int i; + + reset_ep_state(target); + + block_size = target->dev->ar->mbox_info.block_size; + + ctrl_bufsz = (block_size > HTC_MAX_CTRL_MSG_LEN) ? + (block_size + HTC_HDR_LENGTH) : + (HTC_MAX_CTRL_MSG_LEN + HTC_HDR_LENGTH); + + for (i = 0; i < NUM_CONTROL_BUFFERS; i++) { + packet = kzalloc(sizeof(*packet), GFP_KERNEL); + if (!packet) + return -ENOMEM; + + packet->buf_start = kzalloc(ctrl_bufsz, GFP_KERNEL); + if (!packet->buf_start) { + kfree(packet); + return -ENOMEM; + } + + packet->buf_len = ctrl_bufsz; + if (i < NUM_CONTROL_RX_BUFFERS) { + packet->act_len = 0; + packet->buf = packet->buf_start; + packet->endpoint = ENDPOINT_0; + list_add_tail(&packet->list, &target->free_ctrl_rxbuf); + } else + list_add_tail(&packet->list, &target->free_ctrl_txbuf); + } + + return 0; +} + /* htc_stop: stop interrupt reception, and flush all queued buffers */ void ath6kl_htc_stop(struct htc_target *target) { @@ -2674,15 +2712,13 @@ void ath6kl_htc_stop(struct htc_target *target) ath6kl_htc_flush_rx_buf(target); - reset_ep_state(target); + ath6kl_htc_reset(target); } void *ath6kl_htc_create(struct ath6kl *ar) { struct htc_target *target = NULL; - struct htc_packet *packet; - int status = 0, i = 0; - u32 block_size, ctrl_bufsz; + int status = 0; target = kzalloc(sizeof(*target), GFP_KERNEL); if (!target) { @@ -2694,7 +2730,7 @@ void *ath6kl_htc_create(struct ath6kl *ar) if (!target->dev) { ath6kl_err("unable to allocate memory\n"); status = -ENOMEM; - goto fail_create_htc; + goto err_htc_cleanup; } spin_lock_init(&target->htc_lock); @@ -2709,49 +2745,20 @@ void *ath6kl_htc_create(struct ath6kl *ar) target->dev->htc_cnxt = target; target->ep_waiting = ENDPOINT_MAX; - reset_ep_state(target); - status = ath6kl_hif_setup(target->dev); - if (status) - goto fail_create_htc; - - block_size = ar->mbox_info.block_size; - - ctrl_bufsz = (block_size > HTC_MAX_CTRL_MSG_LEN) ? - (block_size + HTC_HDR_LENGTH) : - (HTC_MAX_CTRL_MSG_LEN + HTC_HDR_LENGTH); + goto err_htc_cleanup; - for (i = 0; i < NUM_CONTROL_BUFFERS; i++) { - packet = kzalloc(sizeof(*packet), GFP_KERNEL); - if (!packet) - break; - - packet->buf_start = kzalloc(ctrl_bufsz, GFP_KERNEL); - if (!packet->buf_start) { - kfree(packet); - break; - } + status = ath6kl_htc_reset(target); + if (status) + goto err_htc_cleanup; - packet->buf_len = ctrl_bufsz; - if (i < NUM_CONTROL_RX_BUFFERS) { - packet->act_len = 0; - packet->buf = packet->buf_start; - packet->endpoint = ENDPOINT_0; - list_add_tail(&packet->list, &target->free_ctrl_rxbuf); - } else - list_add_tail(&packet->list, &target->free_ctrl_txbuf); - } + return target; -fail_create_htc: - if (i != NUM_CONTROL_BUFFERS || status) { - if (target) { - ath6kl_htc_cleanup(target); - target = NULL; - } - } +err_htc_cleanup: + ath6kl_htc_cleanup(target); - return target; + return NULL; } /* cleanup the HTC instance */ -- cgit v0.10.2 From 778e6502414a35e3db8f3637a600b6645ac0b815 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 27 Oct 2011 18:49:08 +0300 Subject: ath6kl: don't print an error for canceled packets ath6kl_tx_complete() was printing an error when packet was canceled. That causes unnecessary errors when hardware is powered off. Also change the error to a warning and cleanup the message. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index ab9a5c1..9dfd7f5 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -606,8 +606,9 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) vif->net_stats.tx_errors++; - if (status != -ENOSPC) - ath6kl_err("tx error, status: 0x%x\n", status); + if (status != -ENOSPC && status != -ECANCELED) + ath6kl_warn("tx complete error: %d\n", status); + ath6kl_dbg(ATH6KL_DBG_WLAN_TX, "%s: skb=0x%p data=0x%p len=0x%x eid=%d %s\n", __func__, skb, packet->buf, packet->act_len, -- cgit v0.10.2 From cd4b8b85800a47dc68b9282ffc3a88b82e77f242 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 28 Oct 2011 16:23:26 +0300 Subject: ath6kl: change name of sdio driver to ath6kl Currently the name of the driver in struct sdio_driver is "ath6kl_sdio", this is for example what uevent advertises. This is wrong as the module is named as ath6kl.ko. Change it to "ath6kl" so that the names match. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 682c47c..56f83c4 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -914,7 +914,7 @@ static const struct sdio_device_id ath6kl_sdio_devices[] = { MODULE_DEVICE_TABLE(sdio, ath6kl_sdio_devices); static struct sdio_driver ath6kl_sdio_driver = { - .name = "ath6kl_sdio", + .name = "ath6kl", .id_table = ath6kl_sdio_devices, .probe = ath6kl_sdio_probe, .remove = ath6kl_sdio_remove, -- cgit v0.10.2 From 32a07e4448f78158a75f7c1f0056289647d83946 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Sun, 30 Oct 2011 21:15:57 +0200 Subject: ath6kl: create ath6kl_hif_stop() This is to reset hif layer for powering down hw. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index 34adc77..50fd3e9 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -111,4 +111,11 @@ static inline int ath6kl_hif_power_off(struct ath6kl *ar) return ar->hif_ops->power_off(ar); } +static inline void ath6kl_hif_stop(struct ath6kl *ar) +{ + ath6kl_dbg(ATH6KL_DBG_HIF, "hif stop\n"); + + ar->hif_ops->stop(ar); +} + #endif diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 78a6c79..814386d 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -246,6 +246,7 @@ struct ath6kl_hif_ops { int (*resume)(struct ath6kl *ar); int (*power_on)(struct ath6kl *ar); int (*power_off)(struct ath6kl *ar); + void (*stop)(struct ath6kl *ar); }; int ath6kl_hif_setup(struct ath6kl_device *dev); diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 56f83c4..2d15557 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -45,6 +45,8 @@ struct ath6kl_sdio { struct list_head scat_req; spinlock_t scat_lock; + bool scatter_enabled; + bool is_disabled; atomic_t irq_handling; const struct sdio_device_id *id; @@ -651,6 +653,11 @@ static void ath6kl_sdio_cleanup_scatter(struct ath6kl *ar) list_del(&s_req->list); spin_unlock_bh(&ar_sdio->scat_lock); + /* + * FIXME: should we also call completion handler with + * ath6kl_hif_rw_comp_handler() with status -ECANCELED so + * that the packet is properly freed? + */ if (s_req->busrequest) ath6kl_sdio_free_bus_req(ar_sdio, s_req->busrequest); kfree(s_req->virt_dma_buf); @@ -670,6 +677,11 @@ static int ath6kl_sdio_enable_scatter(struct ath6kl *ar) int ret; bool virt_scat = false; + if (ar_sdio->scatter_enabled) + return 0; + + ar_sdio->scatter_enabled = true; + /* check if host supports scatter and it meets our requirements */ if (ar_sdio->func->card->host->max_segs < MAX_SCATTER_ENTRIES_PER_REQ) { ath6kl_err("host only supports scatter of :%d entries, need: %d\n", @@ -762,6 +774,38 @@ static int ath6kl_sdio_resume(struct ath6kl *ar) return 0; } +static void ath6kl_sdio_stop(struct ath6kl *ar) +{ + struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); + struct bus_request *req, *tmp_req; + void *context; + + /* FIXME: make sure that wq is not queued again */ + + cancel_work_sync(&ar_sdio->wr_async_work); + + spin_lock_bh(&ar_sdio->wr_async_lock); + + list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) { + list_del(&req->list); + + if (req->scat_req) { + /* this is a scatter gather request */ + req->scat_req->status = -ECANCELED; + req->scat_req->complete(ar_sdio->ar->htc_target, + req->scat_req); + } else { + context = req->packet; + ath6kl_sdio_free_bus_req(ar_sdio, req); + ath6kl_hif_rw_comp_handler(context, -ECANCELED); + } + } + + spin_unlock_bh(&ar_sdio->wr_async_lock); + + WARN_ON(get_queue_depth(&ar_sdio->scat_req) != 4); +} + static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .read_write_sync = ath6kl_sdio_read_write_sync, .write_async = ath6kl_sdio_write_async, @@ -776,6 +820,7 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .resume = ath6kl_sdio_resume, .power_on = ath6kl_sdio_power_on, .power_off = ath6kl_sdio_power_off, + .stop = ath6kl_sdio_stop, }; static int ath6kl_sdio_probe(struct sdio_func *func, -- cgit v0.10.2 From 5fe4dffbc12b22507d2416667720cbd4b27c693b Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Sun, 30 Oct 2011 21:16:15 +0200 Subject: ath6kl: power down hardware when interface is down The benefit from this is that user space can control hardware's power state by putting interface up and down. This is handy if firmware gets to some weird state. The downside will be that putting interface up takes a bit longer, I was measuring ~500 ms during interface up. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index 5a4c24d..a962fe4 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -670,6 +670,11 @@ int ath6kl_bmi_fast_download(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) return ret; } +void ath6kl_bmi_reset(struct ath6kl *ar) +{ + ar->bmi.done_sent = false; +} + int ath6kl_bmi_init(struct ath6kl *ar) { ar->bmi.cmd_buf = kzalloc(MAX_BMI_CMDBUF_SZ, GFP_ATOMIC); diff --git a/drivers/net/wireless/ath/ath6kl/bmi.h b/drivers/net/wireless/ath/ath6kl/bmi.h index 96851d5..009e8f6 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.h +++ b/drivers/net/wireless/ath/ath6kl/bmi.h @@ -230,6 +230,8 @@ struct ath6kl_bmi_target_info { int ath6kl_bmi_init(struct ath6kl *ar); void ath6kl_bmi_cleanup(struct ath6kl *ar); +void ath6kl_bmi_reset(struct ath6kl *ar); + int ath6kl_bmi_done(struct ath6kl *ar); int ath6kl_bmi_get_target_info(struct ath6kl *ar, struct ath6kl_bmi_target_info *targ_info); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 5ac415e..1ac0dd1 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -447,6 +447,7 @@ enum ath6kl_dev_state { DESTROY_IN_PROGRESS, SKIP_SCAN, ROAM_TBL_PEND, + FIRST_BOOT, }; struct ath6kl { @@ -662,4 +663,7 @@ void ath6kl_deinit_if_data(struct ath6kl_vif *vif); void ath6kl_core_free(struct ath6kl *ar); struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar); void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready); +int ath6kl_init_hw_start(struct ath6kl *ar); +int ath6kl_init_hw_stop(struct ath6kl *ar); + #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 04b4070..99220d4 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2622,6 +2622,9 @@ int ath6kl_htc_start(struct htc_target *target) struct htc_packet *packet; int status; + memset(&target->dev->irq_proc_reg, 0, + sizeof(target->dev->irq_proc_reg)); + /* Disable interrupts at the chip level */ ath6kl_hif_disable_intrs(target->dev); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 2ee6a5e..237b73c 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1421,11 +1421,13 @@ static int ath6kl_init_hw_params(struct ath6kl *ar) return 0; } -static int ath6kl_hw_start(struct ath6kl *ar) +int ath6kl_init_hw_start(struct ath6kl *ar) { long timeleft; int ret, i; + ath6kl_dbg(ATH6KL_DBG_BOOT, "hw start\n"); + ret = ath6kl_hif_power_on(ar); if (ret) return ret; @@ -1517,6 +1519,25 @@ err_power_off: return ret; } +int ath6kl_init_hw_stop(struct ath6kl *ar) +{ + int ret; + + ath6kl_dbg(ATH6KL_DBG_BOOT, "hw stop\n"); + + ath6kl_htc_stop(ar->htc_target); + + ath6kl_hif_stop(ar); + + ath6kl_bmi_reset(ar); + + ret = ath6kl_hif_power_off(ar); + if (ret) + ath6kl_warn("failed to power off hif: %d\n", ret); + + return 0; +} + int ath6kl_core_init(struct ath6kl *ar) { struct ath6kl_bmi_target_info targ_info; @@ -1629,9 +1650,11 @@ int ath6kl_core_init(struct ath6kl *ar) ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAVE_AP_SME; - ret = ath6kl_hw_start(ar); + set_bit(FIRST_BOOT, &ar->flag); + + ret = ath6kl_init_hw_start(ar); if (ret) { - ath6kl_err("Failed to boot hardware: %d\n", ret); + ath6kl_err("Failed to start hardware: %d\n", ret); goto err_rxbuf_cleanup; } @@ -1641,6 +1664,12 @@ int ath6kl_core_init(struct ath6kl *ar) */ memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); + ret = ath6kl_init_hw_stop(ar); + if (ret) { + ath6kl_err("Failed to stop hardware: %d\n", ret); + goto err_htc_cleanup; + } + return ret; err_rxbuf_cleanup: diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 3b2a7e8..717ed22 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -673,10 +673,12 @@ void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) set_bit(WMI_READY, &ar->flag); wake_up(&ar->event_wq); - ath6kl_info("hw %s fw %s%s\n", - get_hw_id_string(ar->wiphy->hw_version), - ar->wiphy->fw_version, - test_bit(TESTMODE, &ar->flag) ? " testmode" : ""); + if (test_and_clear_bit(FIRST_BOOT, &ar->flag)) { + ath6kl_info("hw %s fw %s%s\n", + get_hw_id_string(ar->wiphy->hw_version), + ar->wiphy->fw_version, + test_bit(TESTMODE, &ar->flag) ? " testmode" : ""); + } } void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status) @@ -1112,6 +1114,12 @@ struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar) static int ath6kl_open(struct net_device *dev) { struct ath6kl_vif *vif = netdev_priv(dev); + int ret; + + /* FIXME: how to handle multi vif support? */ + ret = ath6kl_init_hw_start(vif->ar); + if (ret) + return ret; set_bit(WLAN_ENABLED, &vif->flags); @@ -1128,6 +1136,7 @@ static int ath6kl_close(struct net_device *dev) { struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); + int ret; netif_stop_queue(dev); @@ -1143,6 +1152,11 @@ static int ath6kl_close(struct net_device *dev) ath6kl_cfg80211_scan_complete_event(vif, -ECANCELED); + /* FIXME: how to handle multi vif support? */ + ret = ath6kl_init_hw_stop(ar); + if (ret) + return ret; + return 0; } -- cgit v0.10.2 From 68469341f32b566481bfccb776ee03146b63bae5 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Sun, 30 Oct 2011 21:16:33 +0200 Subject: ath6kl: fix WLAN_ENABLE usage in ath6kl_close() If ath6kl_init_hw_stop() failed with an error WLAN_ENABLED would not be cleared. Found during code review and just a theoretical issue. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 717ed22..def0b7f 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1147,7 +1147,6 @@ static int ath6kl_close(struct net_device *dev) 0, 0, 0, 0, 0, 0, 0, 0, 0)) return -EIO; - clear_bit(WLAN_ENABLED, &vif->flags); } ath6kl_cfg80211_scan_complete_event(vif, -ECANCELED); @@ -1157,6 +1156,8 @@ static int ath6kl_close(struct net_device *dev) if (ret) return ret; + clear_bit(WLAN_ENABLED, &vif->flags); + return 0; } -- cgit v0.10.2 From 6250aac6dfc01a0e3e02a8e1eef41d7fbfedb6c7 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Sun, 30 Oct 2011 21:16:41 +0200 Subject: ath6kl: print firmware crashes always Currently firmware crash dump is printed only if debug is enabled. Change it so that the crash dump is always printed. Also move the code from init.c to hif.c. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 1ac0dd1..95aed7d 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -654,7 +654,6 @@ void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid); void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, u8 win_sz); void ath6kl_wakeup_event(void *dev); -void ath6kl_target_failure(struct ath6kl *ar); void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, bool wait_fot_compltn, bool cold_reset); diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index 309be98..e57da35 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -59,26 +59,79 @@ int ath6kl_hif_rw_comp_handler(void *context, int status) return 0; } +#define REG_DUMP_COUNT_AR6003 60 +#define REGISTER_DUMP_LEN_MAX 60 + +static void ath6kl_hif_dump_fw_crash(struct ath6kl *ar) +{ + __le32 regdump_val[REGISTER_DUMP_LEN_MAX]; + u32 i, address, regdump_addr = 0; + int ret; + + if (ar->target_type != TARGET_TYPE_AR6003) + return; + + /* the reg dump pointer is copied to the host interest area */ + address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_failure_state)); + address = TARG_VTOP(ar->target_type, address); + + /* read RAM location through diagnostic window */ + ret = ath6kl_diag_read32(ar, address, ®dump_addr); + + if (ret || !regdump_addr) { + ath6kl_warn("failed to get ptr to register dump area: %d\n", + ret); + return; + } + + ath6kl_dbg(ATH6KL_DBG_IRQ, "register dump data address 0x%x\n", + regdump_addr); + regdump_addr = TARG_VTOP(ar->target_type, regdump_addr); + + /* fetch register dump data */ + ret = ath6kl_diag_read(ar, regdump_addr, (u8 *)®dump_val[0], + REG_DUMP_COUNT_AR6003 * (sizeof(u32))); + if (ret) { + ath6kl_warn("failed to get register dump: %d\n", ret); + return; + } + + ath6kl_info("crash dump:\n"); + ath6kl_info("hw 0x%x fw %s\n", ar->wiphy->hw_version, + ar->wiphy->fw_version); + + BUILD_BUG_ON(REG_DUMP_COUNT_AR6003 % 4); + + for (i = 0; i < REG_DUMP_COUNT_AR6003 / 4; i++) { + ath6kl_info("%d: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x\n", + 4 * i, + le32_to_cpu(regdump_val[i]), + le32_to_cpu(regdump_val[i + 1]), + le32_to_cpu(regdump_val[i + 2]), + le32_to_cpu(regdump_val[i + 3])); + } + +} static int ath6kl_hif_proc_dbg_intr(struct ath6kl_device *dev) { u32 dummy; - int status; + int ret; - ath6kl_err("target debug interrupt\n"); - - ath6kl_target_failure(dev->ar); + ath6kl_warn("firmware crashed\n"); /* * read counter to clear the interrupt, the debug error interrupt is * counter 0. */ - status = hif_read_write_sync(dev->ar, COUNT_DEC_ADDRESS, + ret = hif_read_write_sync(dev->ar, COUNT_DEC_ADDRESS, (u8 *)&dummy, 4, HIF_RD_SYNC_BYTE_INC); - if (status) - WARN_ON(1); + if (ret) + ath6kl_warn("Failed to clear debug interrupt: %d\n", ret); - return status; + ath6kl_hif_dump_fw_crash(dev->ar); + + return ret; } /* mailbox recv message polling */ diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 237b73c..3f1f254 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -298,61 +298,6 @@ out: return status; } -#define REG_DUMP_COUNT_AR6003 60 -#define REGISTER_DUMP_LEN_MAX 60 - -static void ath6kl_dump_target_assert_info(struct ath6kl *ar) -{ - u32 address; - u32 regdump_loc = 0; - int status; - u32 regdump_val[REGISTER_DUMP_LEN_MAX]; - u32 i; - - if (ar->target_type != TARGET_TYPE_AR6003) - return; - - /* the reg dump pointer is copied to the host interest area */ - address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_failure_state)); - address = TARG_VTOP(ar->target_type, address); - - /* read RAM location through diagnostic window */ - status = ath6kl_diag_read32(ar, address, ®dump_loc); - - if (status || !regdump_loc) { - ath6kl_err("failed to get ptr to register dump area\n"); - return; - } - - ath6kl_dbg(ATH6KL_DBG_TRC, "location of register dump data: 0x%X\n", - regdump_loc); - regdump_loc = TARG_VTOP(ar->target_type, regdump_loc); - - /* fetch register dump data */ - status = ath6kl_diag_read(ar, regdump_loc, (u8 *)®dump_val[0], - REG_DUMP_COUNT_AR6003 * (sizeof(u32))); - - if (status) { - ath6kl_err("failed to get register dump\n"); - return; - } - ath6kl_dbg(ATH6KL_DBG_TRC, "Register Dump:\n"); - - for (i = 0; i < REG_DUMP_COUNT_AR6003; i++) - ath6kl_dbg(ATH6KL_DBG_TRC, " %d : 0x%8.8X\n", - i, regdump_val[i]); - -} - -void ath6kl_target_failure(struct ath6kl *ar) -{ - ath6kl_err("target asserted\n"); - - /* try dumping target assertion information (if any) */ - ath6kl_dump_target_assert_info(ar); - -} - static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) { int status = 0; -- cgit v0.10.2 From 2387f0dcd10abf8f867ebb9b22d213793510b4c6 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Sun, 30 Oct 2011 21:16:49 +0200 Subject: ath6kl: print seqno in htc debug logs Makes it easier to debug where frames are going. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 99220d4..f3b63ca25 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -439,6 +439,9 @@ static void htc_tx_comp_handler(struct htc_target *target, struct htc_endpoint *endpoint = &target->endpoint[packet->endpoint]; struct list_head container; + ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx complete seqno %d\n", + packet->info.tx.seqno); + htc_tx_comp_update(target, endpoint, packet); INIT_LIST_HEAD(&container); list_add_tail(&packet->list, &container); @@ -501,8 +504,8 @@ static int ath6kl_htc_tx_issue(struct htc_target *target, padded_len = CALC_TXRX_PADDED_LEN(target, send_len); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc tx issue len %d padded_len %d mbox 0x%X %s\n", - send_len, padded_len, + "htc tx issue len %d seqno %d padded_len %d mbox 0x%X %s\n", + send_len, packet->info.tx.seqno, padded_len, target->dev->ar->mbox_info.htc_addr, sync ? "sync" : "async"); @@ -705,8 +708,8 @@ static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, scat_req->len += len; scat_req->scat_entries++; ath6kl_dbg(ATH6KL_DBG_HTC, - "htc tx adding (%d) pkt 0x%p len %d remaining %d\n", - i, packet, len, rem_scat); + "htc tx adding (%d) pkt 0x%p seqno %d len %d remaining %d\n", + i, packet, packet->info.tx.seqno, len, rem_scat); } /* Roll back scatter setup in case of any failure */ -- cgit v0.10.2 From 1c17d313891c1477f5aad8d2e1da473bf8b9499d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 1 Nov 2011 08:43:56 +0200 Subject: ath6kl: add aborted parameter to ath6kl_cfg80211_scan_complete_event() Currently it takes an error code as status, but what we really want to tell is if the scan was aborted or not. Also fix a bug where we were comparing firmware scan status values with kernel error codes, which is obviously wrong. This meant that ath6kl didn't detect when firmware informed about failed scans. I doubt that this fix doesn't make any difference in practise but it still needs to be fixed. This is fixed by adding an enum for the success status code and checking for that. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 01bb9ed..e7203cf 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -871,23 +871,19 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, return ret; } -void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status) +void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted) { struct ath6kl *ar = vif->ar; - bool aborted; int i; - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: status %d\n", __func__, status); + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: status%s\n", __func__, + aborted ? " aborted" : ""); if (!vif->scan_req) return; - if ((status == -ECANCELED) || (status == -EBUSY)) { - aborted = true; + if (aborted) goto out; - } - - aborted = false; if (vif->scan_req->n_ssids && vif->scan_req->ssids[0].ssid_len) { for (i = 0; i < vif->scan_req->n_ssids; i++) { diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index d1a0216..f323a49 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -24,7 +24,7 @@ int ath6kl_register_ieee80211_hw(struct ath6kl *ar); struct ath6kl *ath6kl_core_alloc(struct device *dev); void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar); -void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status); +void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted); void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, u16 listen_intvl, diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index def0b7f..d2822d0 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -624,7 +624,7 @@ void ath6kl_deep_sleep_enable(struct ath6kl *ar) printk(KERN_WARNING "ath6kl: failed to disable scan " "during suspend\n"); - ath6kl_cfg80211_scan_complete_event(vif, -ECANCELED); + ath6kl_cfg80211_scan_complete_event(vif, true); /* save the current power mode before enabling power save */ ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; @@ -684,8 +684,12 @@ void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status) { struct ath6kl *ar = vif->ar; + bool aborted = false; - ath6kl_cfg80211_scan_complete_event(vif, status); + if (status != WMI_SCAN_STATUS_SUCCESS) + aborted = true; + + ath6kl_cfg80211_scan_complete_event(vif, aborted); if (!ar->usr_bss_filter) { clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); @@ -1149,7 +1153,7 @@ static int ath6kl_close(struct net_device *dev) } - ath6kl_cfg80211_scan_complete_event(vif, -ECANCELED); + ath6kl_cfg80211_scan_complete_event(vif, true); /* FIXME: how to handle multi vif support? */ ret = ath6kl_init_hw_stop(ar); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index ae514cb..cf0462a 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1472,6 +1472,10 @@ struct wmi_tkip_micerr_event { u8 is_mcast; } __packed; +enum wmi_scan_status { + WMI_SCAN_STATUS_SUCCESS = 0, +}; + /* WMI_SCAN_COMPLETE_EVENTID */ struct wmi_scan_complete_event { a_sle32 status; -- cgit v0.10.2 From ec4b7f602d24839a85131dc5b498e69c84ee8373 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 1 Nov 2011 08:44:04 +0200 Subject: ath6kl: create ath6kl_cfg80211_stop() Just take code from deep sleep for now, will be improved later. No functional changes. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index e7203cf..db75642 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2113,6 +2113,55 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = { .mgmt_frame_register = ath6kl_mgmt_frame_register, }; +void ath6kl_cfg80211_stop(struct ath6kl *ar) +{ + struct ath6kl_vif *vif; + + /* FIXME: for multi vif */ + vif = ath6kl_vif_first(ar); + if (!vif) { + /* save the current power mode before enabling power save */ + ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; + + if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER) != 0) + ath6kl_warn("ath6kl_deep_sleep_enable: " + "wmi_powermode_cmd failed\n"); + return; + } + + switch (vif->sme_state) { + case SME_CONNECTING: + cfg80211_connect_result(vif->ndev, vif->bssid, NULL, 0, + NULL, 0, + WLAN_STATUS_UNSPECIFIED_FAILURE, + GFP_KERNEL); + break; + case SME_CONNECTED: + default: + /* + * FIXME: oddly enough smeState is in DISCONNECTED during + * suspend, why? Need to send disconnected event in that + * state. + */ + cfg80211_disconnected(vif->ndev, 0, NULL, 0, GFP_KERNEL); + break; + } + + if (test_bit(CONNECTED, &vif->flags) || + test_bit(CONNECT_PEND, &vif->flags)) + ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx); + + vif->sme_state = SME_DISCONNECTED; + + /* disable scanning */ + if (ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, 0xFFFF, 0, 0, + 0, 0, 0, 0, 0, 0, 0) != 0) + printk(KERN_WARNING "ath6kl: failed to disable scan " + "during suspend\n"); + + ath6kl_cfg80211_scan_complete_event(vif, true); +} + struct ath6kl *ath6kl_core_alloc(struct device *dev) { struct ath6kl *ar; diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index f323a49..bb0ac22 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -40,4 +40,6 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast); +void ath6kl_cfg80211_stop(struct ath6kl *ar); + #endif /* ATH6KL_CFG80211_H */ diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index d2822d0..378dc8d 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -580,51 +580,7 @@ void ath6kl_disconnect(struct ath6kl_vif *vif) void ath6kl_deep_sleep_enable(struct ath6kl *ar) { - struct ath6kl_vif *vif; - - /* FIXME: for multi vif */ - vif = ath6kl_vif_first(ar); - if (!vif) { - /* save the current power mode before enabling power save */ - ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; - - if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER) != 0) - ath6kl_warn("ath6kl_deep_sleep_enable: " - "wmi_powermode_cmd failed\n"); - return; - } - - switch (vif->sme_state) { - case SME_CONNECTING: - cfg80211_connect_result(vif->ndev, vif->bssid, NULL, 0, - NULL, 0, - WLAN_STATUS_UNSPECIFIED_FAILURE, - GFP_KERNEL); - break; - case SME_CONNECTED: - default: - /* - * FIXME: oddly enough smeState is in DISCONNECTED during - * suspend, why? Need to send disconnected event in that - * state. - */ - cfg80211_disconnected(vif->ndev, 0, NULL, 0, GFP_KERNEL); - break; - } - - if (test_bit(CONNECTED, &vif->flags) || - test_bit(CONNECT_PEND, &vif->flags)) - ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx); - - vif->sme_state = SME_DISCONNECTED; - - /* disable scanning */ - if (ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, 0xFFFF, 0, 0, - 0, 0, 0, 0, 0, 0, 0) != 0) - printk(KERN_WARNING "ath6kl: failed to disable scan " - "during suspend\n"); - - ath6kl_cfg80211_scan_complete_event(vif, true); + ath6kl_cfg80211_stop(ar); /* save the current power mode before enabling power save */ ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; -- cgit v0.10.2 From 1f40525512ba8c68902b3c2f5c09692364cc6b6a Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 1 Nov 2011 08:44:13 +0200 Subject: ath6kl: reset CONNECT_PEND and CONNECTED flags in ath6kl_cfg80211_stop() Otherwise first connection establish after cutpower suspend will fail. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index db75642..96b5e9a 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2152,6 +2152,8 @@ void ath6kl_cfg80211_stop(struct ath6kl *ar) ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx); vif->sme_state = SME_DISCONNECTED; + clear_bit(CONNECTED, &vif->flags); + clear_bit(CONNECT_PEND, &vif->flags); /* disable scanning */ if (ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, 0xFFFF, 0, 0, -- cgit v0.10.2 From 52d81a6883fb36c4304fb5619bfa5f61eb7986ef Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 1 Nov 2011 08:44:21 +0200 Subject: ath6kl: implement ath6kl_cfg80211_suspend() This is in preparation for cutpower suspend feature. HIF layer makes the decision based on information provided by cfg80211 and what hardware actually supports. Then it calls ath6kl_cfg80211_suspend() to enable the chosen mode. Functionality should be the same, this is just preparation for more suspend modes (cutpower and wow). Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 96b5e9a..c62ebf1 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1653,8 +1653,46 @@ static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) return 0; } +int ath6kl_cfg80211_suspend(struct ath6kl *ar, + enum ath6kl_cfg_suspend_mode mode) +{ + int ret; + + ath6kl_cfg80211_stop(ar); + + switch (mode) { + case ATH6KL_CFG_SUSPEND_DEEPSLEEP: + /* save the current power mode before enabling power save */ + ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; + + ret = ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER); + if (ret) { + ath6kl_warn("wmi powermode command failed during suspend: %d\n", + ret); + } + + break; + } + + return 0; +} + +int ath6kl_cfg80211_resume(struct ath6kl *ar) +{ + if (ar->wmi->pwr_mode != ar->wmi->saved_pwr_mode) { + if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, + ar->wmi->saved_pwr_mode) != 0) + ath6kl_warn("ath6kl_sdio_resume: " + "wmi_powermode_cmd failed\n"); + } + + return 0; +} + #ifdef CONFIG_PM -static int ar6k_cfg80211_suspend(struct wiphy *wiphy, + +/* hif layer decides what suspend mode to use */ +static int __ath6kl_cfg80211_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow) { struct ath6kl *ar = wiphy_priv(wiphy); @@ -1662,7 +1700,7 @@ static int ar6k_cfg80211_suspend(struct wiphy *wiphy, return ath6kl_hif_suspend(ar); } -static int ar6k_cfg80211_resume(struct wiphy *wiphy) +static int __ath6kl_cfg80211_resume(struct wiphy *wiphy) { struct ath6kl *ar = wiphy_priv(wiphy); @@ -2099,8 +2137,8 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = { .flush_pmksa = ath6kl_flush_pmksa, CFG80211_TESTMODE_CMD(ath6kl_tm_cmd) #ifdef CONFIG_PM - .suspend = ar6k_cfg80211_suspend, - .resume = ar6k_cfg80211_resume, + .suspend = __ath6kl_cfg80211_suspend, + .resume = __ath6kl_cfg80211_resume, #endif .set_channel = ath6kl_set_channel, .add_beacon = ath6kl_add_beacon, diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index bb0ac22..3630c5e 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -17,6 +17,10 @@ #ifndef ATH6KL_CFG80211_H #define ATH6KL_CFG80211_H +enum ath6kl_cfg_suspend_mode { + ATH6KL_CFG_SUSPEND_DEEPSLEEP, +}; + struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, enum nl80211_iftype type, u8 fw_vif_idx, u8 nw_type); @@ -40,6 +44,10 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast); +int ath6kl_cfg80211_suspend(struct ath6kl *ar, + enum ath6kl_cfg_suspend_mode mode); +int ath6kl_cfg80211_resume(struct ath6kl *ar); + void ath6kl_cfg80211_stop(struct ath6kl *ar); #endif /* ATH6KL_CFG80211_H */ diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 95aed7d..00cc1db 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -649,7 +649,6 @@ void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid); void ath6kl_dtimexpiry_event(struct ath6kl_vif *vif); void ath6kl_disconnect(struct ath6kl_vif *vif); -void ath6kl_deep_sleep_enable(struct ath6kl *ar); void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid); void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, u8 win_sz); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 378dc8d..23da82e 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -578,18 +578,6 @@ void ath6kl_disconnect(struct ath6kl_vif *vif) } } -void ath6kl_deep_sleep_enable(struct ath6kl *ar) -{ - ath6kl_cfg80211_stop(ar); - - /* save the current power mode before enabling power save */ - ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; - - if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER) != 0) - ath6kl_warn("ath6kl_deep_sleep_enable: " - "wmi_powermode_cmd failed\n"); -} - /* WMI Event handlers */ static const char *get_hw_id_string(u32 id) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 2d15557..75b1eaa 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -757,19 +757,14 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) return ret; } - ath6kl_deep_sleep_enable(ar); + ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP); return 0; } static int ath6kl_sdio_resume(struct ath6kl *ar) { - if (ar->wmi->pwr_mode != ar->wmi->saved_pwr_mode) { - if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, - ar->wmi->saved_pwr_mode) != 0) - ath6kl_warn("ath6kl_sdio_resume: " - "wmi_powermode_cmd failed\n"); - } + ath6kl_cfg80211_resume(ar); return 0; } -- cgit v0.10.2 From 76a9fbe27ec04420844ddf49b9e7a2f872222983 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 1 Nov 2011 08:44:28 +0200 Subject: ath6kl: add state variable depicting hw/fw state This way it's easier to track state changes and in the future add more warnings about using hardware in wrong states. Currently there are few random flags for trying to do the same, those will be cleaned and removed in the future. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index c62ebf1..01e83c9 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1671,6 +1671,8 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, ret); } + ar->state = ATH6KL_STATE_DEEPSLEEP; + break; } @@ -1679,11 +1681,25 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, int ath6kl_cfg80211_resume(struct ath6kl *ar) { - if (ar->wmi->pwr_mode != ar->wmi->saved_pwr_mode) { - if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, - ar->wmi->saved_pwr_mode) != 0) - ath6kl_warn("ath6kl_sdio_resume: " - "wmi_powermode_cmd failed\n"); + int ret; + + switch (ar->state) { + case ATH6KL_STATE_DEEPSLEEP: + if (ar->wmi->pwr_mode != ar->wmi->saved_pwr_mode) { + ret = ath6kl_wmi_powermode_cmd(ar->wmi, 0, + ar->wmi->saved_pwr_mode); + if (ret) { + ath6kl_warn("wmi powermode command failed during resume: %d\n", + ret); + } + } + + ar->state = ATH6KL_STATE_ON; + + break; + + default: + break; } return 0; @@ -2254,6 +2270,8 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev) ar->sc_params.scan_ctrl_flags = DEFAULT_SCAN_CTRL_FLAGS; ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD; + ar->state = ATH6KL_STATE_OFF; + memset((u8 *)ar->sta_list, 0, AP_MAX_NUM_STA * sizeof(struct ath6kl_sta)); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 00cc1db..6613248 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -450,9 +450,18 @@ enum ath6kl_dev_state { FIRST_BOOT, }; +enum ath6kl_state { + ATH6KL_STATE_OFF, + ATH6KL_STATE_ON, + ATH6KL_STATE_DEEPSLEEP, +}; + struct ath6kl { struct device *dev; struct wiphy *wiphy; + + enum ath6kl_state state; + struct ath6kl_bmi bmi; const struct ath6kl_hif_ops *hif_ops; struct wmi *wmi; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 3f1f254..83b4f16 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1452,6 +1452,8 @@ int ath6kl_init_hw_start(struct ath6kl *ar) goto err_htc_stop; } + ar->state = ATH6KL_STATE_ON; + return 0; err_htc_stop: @@ -1480,6 +1482,8 @@ int ath6kl_init_hw_stop(struct ath6kl *ar) if (ret) ath6kl_warn("failed to power off hif: %d\n", ret); + ar->state = ATH6KL_STATE_OFF; + return 0; } -- cgit v0.10.2 From e28e810486a6826417e77e634666f0dfc2bfe548 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 1 Nov 2011 08:44:36 +0200 Subject: ath6kl: refactor sdio configuration to a separate function These commands are also needed after cutpower suspend so create a function for them. Also fix memory leaks in ath6kl_sdio_probe() error path. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 75b1eaa..b02ecea 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -733,6 +733,46 @@ static int ath6kl_sdio_enable_scatter(struct ath6kl *ar) return 0; } +static int ath6kl_sdio_config(struct ath6kl *ar) +{ + struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); + struct sdio_func *func = ar_sdio->func; + int ret; + + sdio_claim_host(func); + + if ((ar_sdio->id->device & MANUFACTURER_ID_ATH6KL_BASE_MASK) >= + MANUFACTURER_ID_AR6003_BASE) { + /* enable 4-bit ASYNC interrupt on AR6003 or later */ + ret = ath6kl_sdio_func0_cmd52_wr_byte(func->card, + CCCR_SDIO_IRQ_MODE_REG, + SDIO_IRQ_MODE_ASYNC_4BIT_IRQ); + if (ret) { + ath6kl_err("Failed to enable 4-bit async irq mode %d\n", + ret); + goto out; + } + + ath6kl_dbg(ATH6KL_DBG_BOOT, "4-bit async irq mode enabled\n"); + } + + /* give us some time to enable, in ms */ + func->enable_timeout = 100; + + ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE); + if (ret) { + ath6kl_err("Set sdio block size %d failed: %d)\n", + HIF_MBOX_BLOCK_SIZE, ret); + sdio_release_host(func); + goto out; + } + +out: + sdio_release_host(func); + + return ret; +} + static int ath6kl_sdio_suspend(struct ath6kl *ar) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); @@ -873,45 +913,16 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ath6kl_sdio_set_mbox_info(ar); - sdio_claim_host(func); - - if ((ar_sdio->id->device & MANUFACTURER_ID_ATH6KL_BASE_MASK) >= - MANUFACTURER_ID_AR6003_BASE) { - /* enable 4-bit ASYNC interrupt on AR6003 or later */ - ret = ath6kl_sdio_func0_cmd52_wr_byte(func->card, - CCCR_SDIO_IRQ_MODE_REG, - SDIO_IRQ_MODE_ASYNC_4BIT_IRQ); - if (ret) { - ath6kl_err("Failed to enable 4-bit async irq mode %d\n", - ret); - sdio_release_host(func); - goto err_core_alloc; - } - - ath6kl_dbg(ATH6KL_DBG_BOOT, "4-bit async irq mode enabled\n"); - } - - /* give us some time to enable, in ms */ - func->enable_timeout = 100; - - sdio_release_host(func); - - sdio_claim_host(func); - - ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE); + ret = ath6kl_sdio_config(ar); if (ret) { - ath6kl_err("Set sdio block size %d failed: %d)\n", - HIF_MBOX_BLOCK_SIZE, ret); - sdio_release_host(func); - goto err_hif; + ath6kl_err("Failed to config sdio: %d\n", ret); + goto err_core_alloc; } - sdio_release_host(func); - ret = ath6kl_core_init(ar); if (ret) { ath6kl_err("Failed to init ath6kl core\n"); - goto err_hif; + goto err_core_alloc; } return ret; -- cgit v0.10.2 From b4b2a0b116d79510640622a5f28f219065e61b03 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 1 Nov 2011 08:44:44 +0200 Subject: ath6kl: cut power during suspend If sdio controller doesn't support keep power, cut power from hardware during suspend and restart firmware during resume. If we are connected during suspend, send a disconnected event to user space. Earlier suspend failed with an error if sdio didn't support keep power. Now suspend will happen succesfully even with that case. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 01e83c9..5dab4f2 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1674,6 +1674,28 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, ar->state = ATH6KL_STATE_DEEPSLEEP; break; + + case ATH6KL_CFG_SUSPEND_CUTPOWER: + if (ar->state == ATH6KL_STATE_OFF) { + ath6kl_dbg(ATH6KL_DBG_SUSPEND, + "suspend hw off, no action for cutpower\n"); + break; + } + + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "suspend cutting power\n"); + + ret = ath6kl_init_hw_stop(ar); + if (ret) { + ath6kl_warn("failed to stop hw during suspend: %d\n", + ret); + } + + ar->state = ATH6KL_STATE_CUTPOWER; + + break; + + default: + break; } return 0; @@ -1698,6 +1720,15 @@ int ath6kl_cfg80211_resume(struct ath6kl *ar) break; + case ATH6KL_STATE_CUTPOWER: + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "resume restoring power\n"); + + ret = ath6kl_init_hw_start(ar); + if (ret) { + ath6kl_warn("Failed to boot hw in resume: %d\n", ret); + return ret; + } + default: break; } diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 3630c5e..72eadf8 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -19,6 +19,7 @@ enum ath6kl_cfg_suspend_mode { ATH6KL_CFG_SUSPEND_DEEPSLEEP, + ATH6KL_CFG_SUSPEND_CUTPOWER, }; struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 6613248..f301c32 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -454,6 +454,7 @@ enum ath6kl_state { ATH6KL_STATE_OFF, ATH6KL_STATE_ON, ATH6KL_STATE_DEEPSLEEP, + ATH6KL_STATE_CUTPOWER, }; struct ath6kl { diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 491485e..c24d120 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -40,6 +40,7 @@ enum ATH6K_DEBUG_MASK { ATH6KL_DBG_SDIO_DUMP = BIT(17), ATH6KL_DBG_BOOT = BIT(18), /* driver init and fw boot */ ATH6KL_DBG_WMI_DUMP = BIT(19), + ATH6KL_DBG_SUSPEND = BIT(20), ATH6KL_DBG_ANY = 0xffffffff /* enable all logs */ }; diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index b02ecea..ccb888b 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -782,12 +782,11 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) flags = sdio_get_host_pm_caps(func); + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio suspend pm_caps 0x%x\n", flags); + if (!(flags & MMC_PM_KEEP_POWER)) { - /* as host doesn't support keep power we need to bail out */ - ath6kl_dbg(ATH6KL_DBG_SDIO, - "func %d doesn't support MMC_PM_KEEP_POWER\n", - func->num); - return -EINVAL; + /* as host doesn't support keep power we need to cut power */ + return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER); } ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); @@ -797,13 +796,30 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) return ret; } - ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP); - - return 0; + return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP); } static int ath6kl_sdio_resume(struct ath6kl *ar) { + switch (ar->state) { + case ATH6KL_STATE_OFF: + case ATH6KL_STATE_CUTPOWER: + ath6kl_dbg(ATH6KL_DBG_SUSPEND, + "sdio resume configuring sdio\n"); + + /* need to set sdio settings after power is cut from sdio */ + ath6kl_sdio_config(ar); + break; + + case ATH6KL_STATE_ON: + /* we shouldn't be on this state during resume */ + WARN_ON(1); + break; + + case ATH6KL_STATE_DEEPSLEEP: + break; + } + ath6kl_cfg80211_resume(ar); return 0; @@ -858,6 +874,37 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .stop = ath6kl_sdio_stop, }; +#ifdef CONFIG_PM_SLEEP + +/* + * Empty handlers so that mmc subsystem doesn't remove us entirely during + * suspend. We instead follow cfg80211 suspend/resume handlers. + */ +static int ath6kl_sdio_pm_suspend(struct device *device) +{ + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm suspend\n"); + + return 0; +} + +static int ath6kl_sdio_pm_resume(struct device *device) +{ + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm resume\n"); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(ath6kl_sdio_pm_ops, ath6kl_sdio_pm_suspend, + ath6kl_sdio_pm_resume); + +#define ATH6KL_SDIO_PM_OPS (&ath6kl_sdio_pm_ops) + +#else + +#define ATH6KL_SDIO_PM_OPS NULL + +#endif /* CONFIG_PM_SLEEP */ + static int ath6kl_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { @@ -969,6 +1016,7 @@ static struct sdio_driver ath6kl_sdio_driver = { .id_table = ath6kl_sdio_devices, .probe = ath6kl_sdio_probe, .remove = ath6kl_sdio_remove, + .drv.pm = ATH6KL_SDIO_PM_OPS, }; static int __init ath6kl_sdio_init(void) -- cgit v0.10.2 From 11f6e40d9f21767a9090e4e559d3c63edf25e6c0 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 1 Nov 2011 16:38:50 +0530 Subject: ath6kl: Fix lockdep warning The following is the lockdep warning which detects possible deadlock condition with the way ar->lock and ar->list_lock are being used. (&(&ar->lock)->rlock){+.-...}, at: [] ath6kl_indicate_tx_activity+0x83/0x110 [ath6kl] but this lock took another, SOFTIRQ-unsafe lock in the past: (&(&ar->list_lock)->rlock){+.+...} and interrupts could create inverse lock ordering between them. other info that might help us debug this: Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&(&ar->list_lock)->rlock); local_irq_disable(); lock(&(&ar->lock)->rlock); lock(&(&ar->list_lock)->rlock); lock(&(&ar->lock)->rlock); *** DEADLOCK *** softirqs have to be disabled when acquiring ar->list_lock to avoid the above deadlock condition. When the above warning printed the interface is still up and running without issue. Reported-by: Kalle Valo Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 5dab4f2..4a880b4 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1320,9 +1320,9 @@ static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy, struct ath6kl *ar = wiphy_priv(wiphy); struct ath6kl_vif *vif = netdev_priv(ndev); - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); list_del(&vif->list); - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag)); @@ -2437,9 +2437,9 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, if (type == NL80211_IFTYPE_ADHOC) ar->ibss_if_active = true; - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); list_add_tail(&vif->list, &ar->vif_list); - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); return ndev; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 83b4f16..bb2254d 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1685,17 +1685,17 @@ void ath6kl_stop_txrx(struct ath6kl *ar) return; } - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); list_for_each_entry_safe(vif, tmp_vif, &ar->vif_list, list) { list_del(&vif->list); - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag)); rtnl_lock(); ath6kl_deinit_if_data(vif); rtnl_unlock(); - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); } - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); clear_bit(WMI_READY, &ar->flag); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 23da82e..f9410e4 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1046,15 +1046,15 @@ struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar) { struct ath6kl_vif *vif; - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); if (list_empty(&ar->vif_list)) { - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); return NULL; } vif = list_first_entry(&ar->vif_list, struct ath6kl_vif, list); - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); return vif; } diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 9dfd7f5..06e4912 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -470,10 +470,10 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, stop_adhoc_netq: /* FIXME: Locking */ - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); list_for_each_entry(vif, &ar->vif_list, list) { if (vif->nw_type == ADHOC_NETWORK) { - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); spin_lock_bh(&vif->if_lock); set_bit(NETQ_STOPPED, &vif->flags); @@ -483,7 +483,7 @@ stop_adhoc_netq: return action; } } - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); return action; } @@ -637,16 +637,16 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) __skb_queue_purge(&skb_queue); /* FIXME: Locking */ - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); list_for_each_entry(vif, &ar->vif_list, list) { if (test_bit(CONNECTED, &vif->flags) && !flushing[vif->fw_vif_idx]) { - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); netif_wake_queue(vif->ndev); - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); } } - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); if (wake_event) wake_up(&ar->event_wq); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index d3db5b3..ece67a5 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -89,14 +89,14 @@ struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) return NULL; /* FIXME: Locking */ - spin_lock(&ar->list_lock); + spin_lock_bh(&ar->list_lock); list_for_each_entry(vif, &ar->vif_list, list) { if (vif->fw_vif_idx == if_idx) { found = vif; break; } } - spin_unlock(&ar->list_lock); + spin_unlock_bh(&ar->list_lock); return found; } -- cgit v0.10.2 From cf97fa9fdf145bff2a0117d2ead4a92b132f69f6 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 3 Nov 2011 11:53:57 +0200 Subject: ath6kl: don't power down hardware when interface is down Jouni reported that my patch "ath6kl: power down hardware when interface is down" caused a regression on his x86 boxes and scan didn't work anymore. I was able to reproduce the problem by disabling all debug messages. So there has to be a race condition somewhere in the code and disable the functionality until the race is fixed. Now hardware is powered from the point where module is loaded until it's removed. Reported-by: Jouni Malinen Tested-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index bb2254d..abc1d8e 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1613,12 +1613,6 @@ int ath6kl_core_init(struct ath6kl *ar) */ memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); - ret = ath6kl_init_hw_stop(ar); - if (ret) { - ath6kl_err("Failed to stop hardware: %d\n", ret); - goto err_htc_cleanup; - } - return ret; err_rxbuf_cleanup: diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index f9410e4..021b2f6 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1062,12 +1062,6 @@ struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar) static int ath6kl_open(struct net_device *dev) { struct ath6kl_vif *vif = netdev_priv(dev); - int ret; - - /* FIXME: how to handle multi vif support? */ - ret = ath6kl_init_hw_start(vif->ar); - if (ret) - return ret; set_bit(WLAN_ENABLED, &vif->flags); @@ -1084,7 +1078,6 @@ static int ath6kl_close(struct net_device *dev) { struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); - int ret; netif_stop_queue(dev); @@ -1099,11 +1092,6 @@ static int ath6kl_close(struct net_device *dev) ath6kl_cfg80211_scan_complete_event(vif, true); - /* FIXME: how to handle multi vif support? */ - ret = ath6kl_init_hw_stop(ar); - if (ret) - return ret; - clear_bit(WLAN_ENABLED, &vif->flags); return 0; -- cgit v0.10.2 From 8277de15efb00a4796fb05824a28c20c3894256c Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Thu, 3 Nov 2011 12:18:31 +0200 Subject: ath6kl: add suspend_cutpower module parameter This is to force ath6kl to power off hardware during suspend even if sdio support keep power. This is needed, for example, when sdio controller is buggy or maximum powersaving is desired. Usage: insmod ath6kl.ko suspend_cutpower=1 Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f301c32..c30642e9 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -166,6 +166,7 @@ struct ath6kl_fw_ie { #define ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN BIT(1) #define ATH6KL_CONF_ENABLE_11N BIT(2) #define ATH6KL_CONF_ENABLE_TX_BURST BIT(3) +#define ATH6KL_CONF_SUSPEND_CUTPOWER BIT(4) enum wlan_low_pwr_state { WLAN_POWER_STATE_ON, diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index abc1d8e..57529ac 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -27,9 +27,11 @@ unsigned int debug_mask; static unsigned int testmode; +static bool suspend_cutpower; module_param(debug_mask, uint, 0644); module_param(testmode, uint, 0644); +module_param(suspend_cutpower, bool, 0444); /* * Include definitions here that can be used to tune the WLAN module @@ -1596,6 +1598,9 @@ int ath6kl_core_init(struct ath6kl *ar) ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; + if (suspend_cutpower) + ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER; + ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAVE_AP_SME; diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index ccb888b..a026dae 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -784,7 +784,8 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio suspend pm_caps 0x%x\n", flags); - if (!(flags & MMC_PM_KEEP_POWER)) { + if (!(flags & MMC_PM_KEEP_POWER) || + (ar->conf_flags & ATH6KL_CONF_SUSPEND_CUTPOWER)) { /* as host doesn't support keep power we need to cut power */ return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER); } -- cgit v0.10.2 From 1ddc3377e1f43b0bd62c7042cb2032824ebfb663 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 2 Nov 2011 23:44:14 +0200 Subject: ath6kl: Remove unused WMI crypto defines Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index cf0462a..c626c1e 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -585,9 +585,6 @@ enum auth_mode { WPA2_AUTH_CCKM = 0x40, }; -#define WMI_MIN_CRYPTO_TYPE NONE_CRYPT -#define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1) - #define WMI_MIN_KEY_INDEX 0 #define WMI_MAX_KEY_INDEX 3 -- cgit v0.10.2 From f4bb9a6fbc1f49058fc9eb6dcb4a3022d99013b4 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 2 Nov 2011 23:45:55 +0200 Subject: ath6kl: Fix key configuration to copy at most seq_len from seq There is no guarantee on the caller using 8-octet buffer for key->seq, so better follow the key->seq_len parameter on figuring out how many octets to copy. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 4a880b4..d7e0a8c 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -500,7 +500,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->prwise_crypto, GROUP_USAGE | TX_USAGE, key->key_len, - NULL, + NULL, 0, key->key, KEY_OP_INIT_VAL, NULL, NO_SYNC_WMIFLAG); } @@ -1014,7 +1014,8 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, vif->def_txkey_index, key_type, key_usage, key->key_len, - key->seq, key->key, KEY_OP_INIT_VAL, + key->seq, key->seq_len, key->key, + KEY_OP_INIT_VAL, (u8 *) mac_addr, SYNC_BOTH_WMIFLAG); if (status) @@ -1134,7 +1135,8 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, vif->def_txkey_index, key_type, key_usage, - key->key_len, key->seq, key->key, + key->key_len, key->seq, key->seq_len, + key->key, KEY_OP_INIT_VAL, NULL, SYNC_BOTH_WMIFLAG); if (status) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 021b2f6..5e5f4ca 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -442,7 +442,7 @@ static void ath6kl_install_static_wep_keys(struct ath6kl_vif *vif) WEP_CRYPT, keyusage, vif->wep_key_list[index].key_len, - NULL, + NULL, 0, vif->wep_key_list[index].key, KEY_OP_INIT_VAL, NULL, NO_SYNC_WMIFLAG); @@ -477,7 +477,8 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel) memset(key_rsc, 0, sizeof(key_rsc)); res = ath6kl_wmi_addkey_cmd( ar->wmi, vif->fw_vif_idx, ik->key_index, ik->key_type, - GROUP_USAGE, ik->key_len, key_rsc, ik->key, + GROUP_USAGE, ik->key_len, key_rsc, ATH6KL_KEY_SEQ_LEN, + ik->key, KEY_OP_INIT_VAL, NULL, SYNC_BOTH_WMIFLAG); if (res) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delayed " diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index ece67a5..612326d 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2000,7 +2000,8 @@ int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout) int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, enum crypto_type key_type, u8 key_usage, u8 key_len, - u8 *key_rsc, u8 *key_material, + u8 *key_rsc, unsigned int key_rsc_len, + u8 *key_material, u8 key_op_ctrl, u8 *mac_addr, enum wmi_sync_flag sync_flag) { @@ -2013,7 +2014,7 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, key_index, key_type, key_usage, key_len, key_op_ctrl); if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || - (key_material == NULL)) + (key_material == NULL) || key_rsc_len > 8) return -EINVAL; if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) @@ -2031,7 +2032,7 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, memcpy(cmd->key, key_material, key_len); if (key_rsc != NULL) - memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); + memcpy(cmd->key_rsc, key_rsc, key_rsc_len); cmd->key_op_ctrl = key_op_ctrl; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index c626c1e..1d458f0 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2253,7 +2253,8 @@ int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx); int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, enum crypto_type key_type, u8 key_usage, u8 key_len, - u8 *key_rsc, u8 *key_material, + u8 *key_rsc, unsigned int key_rsc_len, + u8 *key_material, u8 key_op_ctrl, u8 *mac_addr, enum wmi_sync_flag sync_flag); int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk); -- cgit v0.10.2 From f3e61eceb20a993ea2b375e82503ab8a1efa31d9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 2 Nov 2011 23:46:47 +0200 Subject: ath6kl: Do not hide ath6kl_wmi_addkey_cmd() error values Instead of converting any error to EIO, just return the real error value to upper layers. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d7e0a8c..44e2c76 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -908,7 +908,6 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, struct ath6kl_key *key = NULL; u8 key_usage; u8 key_type; - int status = 0; if (!ath6kl_cfg80211_ready(vif)) return -EIO; @@ -1011,17 +1010,12 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, return 0; } - status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, - vif->def_txkey_index, - key_type, key_usage, key->key_len, - key->seq, key->seq_len, key->key, - KEY_OP_INIT_VAL, - (u8 *) mac_addr, SYNC_BOTH_WMIFLAG); - - if (status) - return -EIO; - - return 0; + return ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, + vif->def_txkey_index, + key_type, key_usage, key->key_len, + key->seq, key->seq_len, key->key, + KEY_OP_INIT_VAL, + (u8 *) mac_addr, SYNC_BOTH_WMIFLAG); } static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, @@ -1097,7 +1091,6 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev); struct ath6kl_vif *vif = netdev_priv(ndev); struct ath6kl_key *key = NULL; - int status = 0; u8 key_usage; enum crypto_type key_type = NONE_CRYPT; @@ -1132,17 +1125,13 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, if (vif->next_mode == AP_NETWORK && !test_bit(CONNECTED, &vif->flags)) return 0; /* Delay until AP mode has been started */ - status = ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, - vif->def_txkey_index, - key_type, key_usage, - key->key_len, key->seq, key->seq_len, - key->key, - KEY_OP_INIT_VAL, NULL, - SYNC_BOTH_WMIFLAG); - if (status) - return -EIO; - - return 0; + return ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, + vif->def_txkey_index, + key_type, key_usage, + key->key_len, key->seq, key->seq_len, + key->key, + KEY_OP_INIT_VAL, NULL, + SYNC_BOTH_WMIFLAG); } void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, -- cgit v0.10.2 From 5c9b4fa19a488de48f1cc2268a7b7b247723568a Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:45 +0200 Subject: ath6kl: Add wmi functions to add/delete WOW patterns These commands will be used in WOW suspend/resume functions to configure WOW parameters like patterns to be matched and it's mask value, etc. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 612326d..925ef4c 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2412,6 +2412,62 @@ int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) return ret; } +int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, + u8 list_id, u8 filter_size, + u8 filter_offset, u8 *filter, u8 *mask) +{ + struct sk_buff *skb; + struct wmi_add_wow_pattern_cmd *cmd; + u16 size; + u8 *filter_mask; + int ret; + + /* + * Allocate additional memory in the buffer to hold + * filter and mask value, which is twice of filter_size. + */ + size = sizeof(*cmd) + (2 * filter_size); + + skb = ath6kl_wmi_get_new_buf(size); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_add_wow_pattern_cmd *) skb->data; + cmd->filter_list_id = list_id; + cmd->filter_size = filter_size; + cmd->filter_offset = filter_offset; + + memcpy(cmd->filter, filter, filter_size); + + filter_mask = (u8 *) (cmd->filter + filter_size); + memcpy(filter_mask, mask, filter_size); + + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID, + NO_SYNC_WMIFLAG); + + return ret; +} + +int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, + u16 list_id, u16 filter_id) +{ + struct sk_buff *skb; + struct wmi_del_wow_pattern_cmd *cmd; + int ret; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_del_wow_pattern_cmd *) skb->data; + cmd->filter_list_id = cpu_to_le16(list_id); + cmd->filter_id = cpu_to_le16(filter_id); + + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID, + NO_SYNC_WMIFLAG); + return ret; +} + static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, int len) { diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 1d458f0..df42e4b 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1818,6 +1818,18 @@ struct wmi_set_ip_cmd { __le32 ips[MAX_IP_ADDRS]; } __packed; +struct wmi_add_wow_pattern_cmd { + u8 filter_list_id; + u8 filter_size; + u8 filter_offset; + u8 filter[0]; +} __packed; + +struct wmi_del_wow_pattern_cmd { + __le16 filter_list_id; + __le16 filter_id; +} __packed; + /* WMI_GET_WOW_LIST_CMD reply */ struct wmi_get_wow_list_reply { /* number of patterns in reply */ @@ -2273,6 +2285,11 @@ int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len); s32 ath6kl_wmi_get_rate(s8 rate_index); int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd); +int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, + u8 list_id, u8 filter_size, + u8 filter_offset, u8 *filter, u8 *mask); +int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, + u16 list_id, u16 filter_id); int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi); int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid); int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode); -- cgit v0.10.2 From 45cf110b2b77914a9f02bbf1ba60796f17898be2 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:45 +0200 Subject: ath6kl: Add wmi functions to configure WOW mode and host sleep mode It will be used in WOW suspend/resume functions to active/deactivate WOW suspend mode. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 925ef4c..3da1fb5 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2412,6 +2412,114 @@ int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) return ret; } +static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi) +{ + u16 active_tsids; + u8 stream_exist; + int i; + + /* + * Relinquish credits from all implicitly created pstreams + * since when we go to sleep. If user created explicit + * thinstreams exists with in a fatpipe leave them intact + * for the user to delete. + */ + spin_lock_bh(&wmi->lock); + stream_exist = wmi->fat_pipe_exist; + spin_unlock_bh(&wmi->lock); + + for (i = 0; i < WMM_NUM_AC; i++) { + if (stream_exist & (1 << i)) { + + /* + * FIXME: Is this lock & unlock inside + * for loop correct? may need rework. + */ + spin_lock_bh(&wmi->lock); + active_tsids = wmi->stream_exist_for_ac[i]; + spin_unlock_bh(&wmi->lock); + + /* + * If there are no user created thin streams + * delete the fatpipe + */ + if (!active_tsids) { + stream_exist &= ~(1 << i); + /* + * Indicate inactivity to driver layer for + * this fatpipe (pstream) + */ + ath6kl_indicate_tx_activity(wmi->parent_dev, + i, false); + } + } + } + + /* FIXME: Can we do this assignment without locking ? */ + spin_lock_bh(&wmi->lock); + wmi->fat_pipe_exist = stream_exist; + spin_unlock_bh(&wmi->lock); +} + +int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx, + enum ath6kl_host_mode host_mode) +{ + struct sk_buff *skb; + struct wmi_set_host_sleep_mode_cmd *cmd; + int ret; + + if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) && + (host_mode != ATH6KL_HOST_MODE_AWAKE)) { + ath6kl_err("invalid host sleep mode: %d\n", host_mode); + return -EINVAL; + } + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data; + + if (host_mode == ATH6KL_HOST_MODE_ASLEEP) { + ath6kl_wmi_relinquish_implicit_pstream_credits(wmi); + cmd->asleep = cpu_to_le32(1); + } else + cmd->awake = cpu_to_le32(1); + + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, + WMI_SET_HOST_SLEEP_MODE_CMDID, + NO_SYNC_WMIFLAG); + return ret; +} + +int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, + enum ath6kl_wow_mode wow_mode, + u32 filter, u16 host_req_delay) +{ + struct sk_buff *skb; + struct wmi_set_wow_mode_cmd *cmd; + int ret; + + if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) && + wow_mode != ATH6KL_WOW_MODE_DISABLE) { + ath6kl_err("invalid wow mode: %d\n", wow_mode); + return -EINVAL; + } + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_set_wow_mode_cmd *) skb->data; + cmd->enable_wow = cpu_to_le32(wow_mode); + cmd->filter = cpu_to_le32(filter); + cmd->host_req_delay = cpu_to_le16(host_req_delay); + + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID, + NO_SYNC_WMIFLAG); + return ret; +} + int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, u8 list_id, u8 filter_size, u8 filter_offset, u8 *filter, u8 *mask) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index df42e4b..a65eee2 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1818,6 +1818,42 @@ struct wmi_set_ip_cmd { __le32 ips[MAX_IP_ADDRS]; } __packed; +enum ath6kl_wow_filters { + WOW_FILTER_SSID = BIT(0), + WOW_FILTER_OPTION_MAGIC_PACKET = BIT(2), + WOW_FILTER_OPTION_EAP_REQ = BIT(3), + WOW_FILTER_OPTION_PATTERNS = BIT(4), + WOW_FILTER_OPTION_OFFLOAD_ARP = BIT(5), + WOW_FILTER_OPTION_OFFLOAD_NS = BIT(6), + WOW_FILTER_OPTION_OFFLOAD_GTK = BIT(7), + WOW_FILTER_OPTION_8021X_4WAYHS = BIT(8), + WOW_FILTER_OPTION_NLO_DISCVRY = BIT(9), + WOW_FILTER_OPTION_NWK_DISASSOC = BIT(10), + WOW_FILTER_OPTION_GTK_ERROR = BIT(11), + WOW_FILTER_OPTION_TEST_MODE = BIT(15), +}; + +enum ath6kl_host_mode { + ATH6KL_HOST_MODE_AWAKE, + ATH6KL_HOST_MODE_ASLEEP, +}; + +struct wmi_set_host_sleep_mode_cmd { + __le32 awake; + __le32 asleep; +} __packed; + +enum ath6kl_wow_mode { + ATH6KL_WOW_MODE_DISABLE, + ATH6KL_WOW_MODE_ENABLE, +}; + +struct wmi_set_wow_mode_cmd { + __le32 enable_wow; + __le32 filter; + __le16 host_req_delay; +} __packed; + struct wmi_add_wow_pattern_cmd { u8 filter_list_id; u8 filter_size; @@ -2285,6 +2321,11 @@ int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len); s32 ath6kl_wmi_get_rate(s8 rate_index); int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd); +int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx, + enum ath6kl_host_mode host_mode); +int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, + enum ath6kl_wow_mode wow_mode, + u32 filter, u16 host_req_delay); int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, u8 list_id, u8 filter_size, u8 filter_offset, u8 *filter, u8 *mask); -- cgit v0.10.2 From 6cb3c714e75c6e70fa1c379b7f3af2f143f31c70 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:45 +0200 Subject: ath6kl: Add WOW suspend/resume implementation This is the core WOW suspend/resume functions will be called in PM suspend/resume path. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 44e2c76..2e12c6f 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1644,6 +1644,115 @@ static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) return 0; } +static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) +{ + struct ath6kl_vif *vif; + int ret, pos, left; + u32 filter = 0; + u16 i; + u8 mask[WOW_MASK_SIZE]; + + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + + if (!ath6kl_cfg80211_ready(vif)) + return -EIO; + + if (!test_bit(CONNECTED, &vif->flags)) + return -EINVAL; + + /* Clear existing WOW patterns */ + for (i = 0; i < WOW_MAX_FILTERS_PER_LIST; i++) + ath6kl_wmi_del_wow_pattern_cmd(ar->wmi, vif->fw_vif_idx, + WOW_LIST_ID, i); + /* Configure new WOW patterns */ + for (i = 0; i < wow->n_patterns; i++) { + + /* + * Convert given nl80211 specific mask value to equivalent + * driver specific mask value and send it to the chip along + * with patterns. For example, If the mask value defined in + * struct cfg80211_wowlan is 0xA (equivalent binary is 1010), + * then equivalent driver specific mask value is + * "0xFF 0x00 0xFF 0x00". + */ + memset(&mask, 0, sizeof(mask)); + for (pos = 0; pos < wow->patterns[i].pattern_len; pos++) { + if (wow->patterns[i].mask[pos / 8] & (0x1 << (pos % 8))) + mask[pos] = 0xFF; + } + /* + * Note: Pattern's offset is not passed as part of wowlan + * parameter from CFG layer. So it's always passed as ZERO + * to the firmware. It means, given WOW patterns are always + * matched from the first byte of received pkt in the firmware. + */ + ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, + vif->fw_vif_idx, WOW_LIST_ID, + wow->patterns[i].pattern_len, + 0 /* pattern offset */, + wow->patterns[i].pattern, mask); + if (ret) + return ret; + } + + if (wow->disconnect) + filter |= WOW_FILTER_OPTION_NWK_DISASSOC; + + if (wow->magic_pkt) + filter |= WOW_FILTER_OPTION_MAGIC_PACKET; + + if (wow->gtk_rekey_failure) + filter |= WOW_FILTER_OPTION_GTK_ERROR; + + if (wow->eap_identity_req) + filter |= WOW_FILTER_OPTION_EAP_REQ; + + if (wow->four_way_handshake) + filter |= WOW_FILTER_OPTION_8021X_4WAYHS; + + ret = ath6kl_wmi_set_wow_mode_cmd(ar->wmi, vif->fw_vif_idx, + ATH6KL_WOW_MODE_ENABLE, + filter, + WOW_HOST_REQ_DELAY); + if (ret) + return ret; + + ret = ath6kl_wmi_set_host_sleep_mode_cmd(ar->wmi, vif->fw_vif_idx, + ATH6KL_HOST_MODE_ASLEEP); + if (ret) + return ret; + + if (ar->tx_pending[ar->ctrl_ep]) { + left = wait_event_interruptible_timeout(ar->event_wq, + ar->tx_pending[ar->ctrl_ep] == 0, WMI_TIMEOUT); + if (left == 0) { + ath6kl_warn("clear wmi ctrl data timeout\n"); + ret = -ETIMEDOUT; + } else if (left < 0) { + ath6kl_warn("clear wmi ctrl data failed: %d\n", left); + ret = left; + } + } + + return ret; +} + +static int ath6kl_wow_resume(struct ath6kl *ar) +{ + struct ath6kl_vif *vif; + int ret; + + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + + ret = ath6kl_wmi_set_host_sleep_mode_cmd(ar->wmi, vif->fw_vif_idx, + ATH6KL_HOST_MODE_AWAKE); + return ret; +} + int ath6kl_cfg80211_suspend(struct ath6kl *ar, enum ath6kl_cfg_suspend_mode mode) { diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index c30642e9..b6442c1 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -439,6 +439,9 @@ struct ath6kl_vif { struct target_stats target_stats; }; +#define WOW_LIST_ID 0 +#define WOW_HOST_REQ_DELAY 500 /* ms */ + /* Flag info */ enum ath6kl_dev_state { WMI_ENABLED, -- cgit v0.10.2 From 0f60e9f4c239554ad75ab8e4d864030a7f0dd6f7 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:45 +0200 Subject: ath6kl: Include new parameter in suspend path for wowlan cfg80211 layer provides user defined wow parameters like Filter options, Patterns, Pattern's mask, etc via "struct cfg80211_wowlan *wow" to suspend function. Right now, this wowlan parameter is not handled in __ath6kl_cfg80211_suspend func. This parameter has to be passed to HIF layer, So that it can be passed back to ath6kl's cfg interface layer when WOW mode is selected. In case of deep sleep and cut power mode, it's not handled. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2e12c6f..e804ee9 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1754,7 +1754,8 @@ static int ath6kl_wow_resume(struct ath6kl *ar) } int ath6kl_cfg80211_suspend(struct ath6kl *ar, - enum ath6kl_cfg_suspend_mode mode) + enum ath6kl_cfg_suspend_mode mode, + struct cfg80211_wowlan *wow) { int ret; @@ -1844,7 +1845,7 @@ static int __ath6kl_cfg80211_suspend(struct wiphy *wiphy, { struct ath6kl *ar = wiphy_priv(wiphy); - return ath6kl_hif_suspend(ar); + return ath6kl_hif_suspend(ar, wow); } static int __ath6kl_cfg80211_resume(struct wiphy *wiphy) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 72eadf8..b4781e5 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -46,7 +46,9 @@ void ath6kl_cfg80211_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast); int ath6kl_cfg80211_suspend(struct ath6kl *ar, - enum ath6kl_cfg_suspend_mode mode); + enum ath6kl_cfg_suspend_mode mode, + struct cfg80211_wowlan *wow); + int ath6kl_cfg80211_resume(struct ath6kl *ar); void ath6kl_cfg80211_stop(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index 50fd3e9..eed2287 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -83,11 +83,12 @@ static inline void ath6kl_hif_cleanup_scatter(struct ath6kl *ar) return ar->hif_ops->cleanup_scatter(ar); } -static inline int ath6kl_hif_suspend(struct ath6kl *ar) +static inline int ath6kl_hif_suspend(struct ath6kl *ar, + struct cfg80211_wowlan *wow) { ath6kl_dbg(ATH6KL_DBG_HIF, "hif suspend\n"); - return ar->hif_ops->suspend(ar); + return ar->hif_ops->suspend(ar, wow); } static inline int ath6kl_hif_resume(struct ath6kl *ar) diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 814386d..f2dc3bc 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -242,7 +242,7 @@ struct ath6kl_hif_ops { int (*scat_req_rw) (struct ath6kl *ar, struct hif_scatter_req *scat_req); void (*cleanup_scatter)(struct ath6kl *ar); - int (*suspend)(struct ath6kl *ar); + int (*suspend)(struct ath6kl *ar, struct cfg80211_wowlan *wow); int (*resume)(struct ath6kl *ar); int (*power_on)(struct ath6kl *ar); int (*power_off)(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index a026dae..b576b76 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -773,7 +773,7 @@ out: return ret; } -static int ath6kl_sdio_suspend(struct ath6kl *ar) +static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct sdio_func *func = ar_sdio->func; @@ -787,7 +787,8 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) if (!(flags & MMC_PM_KEEP_POWER) || (ar->conf_flags & ATH6KL_CONF_SUSPEND_CUTPOWER)) { /* as host doesn't support keep power we need to cut power */ - return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER); + return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER, + NULL); } ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); @@ -797,7 +798,7 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar) return ret; } - return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP); + return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP, NULL); } static int ath6kl_sdio_resume(struct ath6kl *ar) -- cgit v0.10.2 From dd6c0c63b43afc3a99b6c69d0b509f0395bb4fe2 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:45 +0200 Subject: ath6kl: Add new state for WOW mode In addition to existing deep sleep and cut pwr mode, new state is added in ath6kl_cfg_suspend_mode as well as in ath6kl_state for WOW. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index b4781e5..59fa9d8 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -20,6 +20,7 @@ enum ath6kl_cfg_suspend_mode { ATH6KL_CFG_SUSPEND_DEEPSLEEP, ATH6KL_CFG_SUSPEND_CUTPOWER, + ATH6KL_CFG_SUSPEND_WOW }; struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index b6442c1..9e8b8e3 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -459,6 +459,7 @@ enum ath6kl_state { ATH6KL_STATE_ON, ATH6KL_STATE_DEEPSLEEP, ATH6KL_STATE_CUTPOWER, + ATH6KL_STATE_WOW, }; struct ath6kl { -- cgit v0.10.2 From 524441e3a7cadf12acbb409ad733d783ba1da459 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:46 +0200 Subject: ath6kl: Move ath6kl_cfg80211_stop() call specific to deep sleep and cut pwr ath6kl_cfg80211_stop() call is not applicable for WOW mode. Hence moving this call to deep sleep and cut pwr specific cases. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index e804ee9..8249a8c 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1759,10 +1759,11 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, { int ret; - ath6kl_cfg80211_stop(ar); - switch (mode) { case ATH6KL_CFG_SUSPEND_DEEPSLEEP: + + ath6kl_cfg80211_stop(ar); + /* save the current power mode before enabling power save */ ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode; @@ -1777,6 +1778,9 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, break; case ATH6KL_CFG_SUSPEND_CUTPOWER: + + ath6kl_cfg80211_stop(ar); + if (ar->state == ATH6KL_STATE_OFF) { ath6kl_dbg(ATH6KL_DBG_SUSPEND, "suspend hw off, no action for cutpower\n"); -- cgit v0.10.2 From d7c44e0ba5003c22a9ff3545fc2f51eaca8a95b1 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:46 +0200 Subject: ath6kl: Invoke WOW suspend/resume calls during PM operation Link ath6kl's wow suspend/resume functions with the actual suspend/resume path. WOW mode is selected when the host sdio controller supports both MMC_PM_KEEP_POWER and MMC_PM_WAKE_SDIO_IRQ capabilities. kvalo: also adds a missing break in ath6kl_cfg80211_resume(), luckily it didn't have any effect on functionality. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 8249a8c..0e3ecf8 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1760,6 +1760,21 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, int ret; switch (mode) { + case ATH6KL_CFG_SUSPEND_WOW: + + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "wow mode suspend\n"); + + /* Flush all non control pkts in TX path */ + ath6kl_tx_data_cleanup(ar); + + ret = ath6kl_wow_suspend(ar, wow); + if (ret) { + ath6kl_err("wow suspend failed: %d\n", ret); + return ret; + } + ar->state = ATH6KL_STATE_WOW; + break; + case ATH6KL_CFG_SUSPEND_DEEPSLEEP: ath6kl_cfg80211_stop(ar); @@ -1811,6 +1826,18 @@ int ath6kl_cfg80211_resume(struct ath6kl *ar) int ret; switch (ar->state) { + case ATH6KL_STATE_WOW: + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "wow mode resume\n"); + + ret = ath6kl_wow_resume(ar); + if (ret) { + ath6kl_warn("wow mode resume failed: %d\n", ret); + return ret; + } + + ar->state = ATH6KL_STATE_ON; + break; + case ATH6KL_STATE_DEEPSLEEP: if (ar->wmi->pwr_mode != ar->wmi->saved_pwr_mode) { ret = ath6kl_wmi_powermode_cmd(ar->wmi, 0, @@ -1833,6 +1860,7 @@ int ath6kl_cfg80211_resume(struct ath6kl *ar) ath6kl_warn("Failed to boot hw in resume: %d\n", ret); return ret; } + break; default: break; diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index b576b76..0586b3b 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -798,6 +798,23 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) return ret; } + if ((flags & MMC_PM_WAKE_SDIO_IRQ) && wow) { + /* + * The host sdio controller is capable of keep power and + * sdio irq wake up at this point. It's fine to continue + * wow suspend operation. + */ + ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_WOW, wow); + if (ret) + return ret; + + ret = sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ); + if (ret) + ath6kl_err("set sdio wake irq flag failed: %d\n", ret); + + return ret; + } + return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP, NULL); } @@ -820,6 +837,9 @@ static int ath6kl_sdio_resume(struct ath6kl *ar) case ATH6KL_STATE_DEEPSLEEP: break; + + case ATH6KL_STATE_WOW: + break; } ath6kl_cfg80211_resume(ar); -- cgit v0.10.2 From a918fb3cc6a58f918f36348c43c3170bb88bc599 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:46 +0200 Subject: ath6kl: Perform WOW resume in RX path in case of SDIO IRQ wake up The target triggers sdio data line to wake up the host when WOW pattern matches. This causes sdio irq handler is being executed in the host side which internally hits ath6kl's RX path. WOW resume should happen before start processing any data from the target. So it's required to perform WOW resume in RX path. This area needs bit rework to avoid WOW resume in RX path, As of now it's fine to have this model, rework will be done later. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 0e3ecf8..c981e13 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1886,6 +1886,34 @@ static int __ath6kl_cfg80211_resume(struct wiphy *wiphy) return ath6kl_hif_resume(ar); } + +/* + * FIXME: WOW suspend mode is selected if the host sdio controller supports + * both sdio irq wake up and keep power. The target pulls sdio data line to + * wake up the host when WOW pattern matches. This causes sdio irq handler + * is being called in the host side which internally hits ath6kl's RX path. + * + * Since sdio interrupt is not disabled, RX path executes even before + * the host executes the actual resume operation from PM module. + * + * In the current scenario, WOW resume should happen before start processing + * any data from the target. So It's required to perform WOW resume in RX path. + * Ideally we should perform WOW resume only in the actual platform + * resume path. This area needs bit rework to avoid WOW resume in RX path. + * + * ath6kl_check_wow_status() is called from ath6kl_rx(). + */ +void ath6kl_check_wow_status(struct ath6kl *ar) +{ + if (ar->state == ATH6KL_STATE_WOW) + ath6kl_cfg80211_resume(ar); +} + +#else + +void ath6kl_check_wow_status(struct ath6kl *ar) +{ +} #endif static int ath6kl_set_channel(struct wiphy *wiphy, struct net_device *dev, diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 9e8b8e3..e7e095e 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -678,5 +678,6 @@ struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar); void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready); int ath6kl_init_hw_start(struct ath6kl *ar); int ath6kl_init_hw_stop(struct ath6kl *ar); +void ath6kl_check_wow_status(struct ath6kl *ar); #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 06e4912..6f1de44 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1134,6 +1134,8 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) return; } + ath6kl_check_wow_status(ar); + if (ept == ar->ctrl_ep) { ath6kl_wmi_control_rx(ar->wmi, skb); return; -- cgit v0.10.2 From 0737237411235d7c48a993a62de01257cc4b004d Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:46 +0200 Subject: ath6kl: Remove WARN_ON msg in Suspend path In the current code, WOW resume is executed first from RX path and ar->state is moved to ATH6KL_STATE_ON. When platform calls ath6kl_sdio_resume() in CFG resume context, that time ar->state could have moved to ON state. Printing WARN_ON(1) is void in this context. Hence removing this. Once WOW resume is removed from RX path, This WARN_ON msg can be reverted. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 0586b3b..beb5f9b 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -831,8 +831,6 @@ static int ath6kl_sdio_resume(struct ath6kl *ar) break; case ATH6KL_STATE_ON: - /* we shouldn't be on this state during resume */ - WARN_ON(1); break; case ATH6KL_STATE_DEEPSLEEP: -- cgit v0.10.2 From eae9e0661b6fcac9ee5b14644516799912de7549 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:46 +0200 Subject: ath6kl: Expose ath6kl's WOW capabilities to cfg80211 Set the list of ath6kl's WOW trigger options in wiphy->wowlan.flags variable during wiphy registration. So that, those options can be configured via iw. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index c981e13..4d1394a 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2510,6 +2510,16 @@ int ath6kl_register_ieee80211_hw(struct ath6kl *ar) wiphy->cipher_suites = cipher_suites; wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); + wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | + WIPHY_WOWLAN_DISCONNECT | + WIPHY_WOWLAN_GTK_REKEY_FAILURE | + WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | + WIPHY_WOWLAN_EAP_IDENTITY_REQ | + WIPHY_WOWLAN_4WAY_HANDSHAKE; + wiphy->wowlan.n_patterns = WOW_MAX_FILTERS_PER_LIST; + wiphy->wowlan.pattern_min_len = 1; + wiphy->wowlan.pattern_max_len = WOW_PATTERN_SIZE; + ret = wiphy_register(wiphy); if (ret < 0) { ath6kl_err("couldn't register wiphy device\n"); -- cgit v0.10.2 From 902b46293ba6fe2320970bbd400e3201992059d0 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 7 Nov 2011 22:52:47 +0200 Subject: ath6kl: Remove few unused WMI stuff * Removed unused WOW_MAX_FILTER_LISTS macro. * Removed empty ath6kl_wmi_get_wow_list_event_rx() function. List of configured WOW patterns are maintained in CFG layer itself. No need to have this function in ath6kl to get configured WOW pattern list. It can added later if we need it for debugging. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 3da1fb5..922344d 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2576,15 +2576,6 @@ int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, return ret; } -static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, - int len) -{ - if (len < sizeof(struct wmi_get_wow_list_reply)) - return -EINVAL; - - return 0; -} - static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, enum wmix_command_id cmd_id, enum wmi_sync_flag sync_flag) @@ -3295,7 +3286,6 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_GET_WOW_LIST_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); - ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); break; case WMI_GET_PMKID_LIST_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index a65eee2..76342d5 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1795,7 +1795,6 @@ struct wmi_set_appie_cmd { #define WSC_REG_ACTIVE 1 #define WSC_REG_INACTIVE 0 -#define WOW_MAX_FILTER_LISTS 1 #define WOW_MAX_FILTERS_PER_LIST 4 #define WOW_PATTERN_SIZE 64 #define WOW_MASK_SIZE 64 @@ -1866,19 +1865,6 @@ struct wmi_del_wow_pattern_cmd { __le16 filter_id; } __packed; -/* WMI_GET_WOW_LIST_CMD reply */ -struct wmi_get_wow_list_reply { - /* number of patterns in reply */ - u8 num_filters; - - /* this is filter # x of total num_filters */ - u8 this_filter_num; - - u8 wow_mode; - u8 host_mode; - struct wow_filter wow_filters[1]; -} __packed; - /* WMI_SET_AKMP_PARAMS_CMD */ struct wmi_pmkid { -- cgit v0.10.2 From a29517ce40e128bdf0794110bb4b18a984da7fb7 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 4 Nov 2011 15:48:51 +0530 Subject: ath6kl: Fix tx packet drop in AP mode with bridge skb is dropped in ath6kl_data_tx() when the headroom in skb is insufficient. We hit this condition for every skb in AP mode which is used with bridge, so all tx packets are getting dropped when tried to send traffic to wireless client from bridge. Fix this by reallocating the headroom instead of dropping the skb when it has lesser headroom than needed. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 6f1de44..d9cff2b 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -266,8 +266,14 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) if (test_bit(WMI_ENABLED, &ar->flag)) { if (skb_headroom(skb) < dev->needed_headroom) { - WARN_ON(1); - goto fail_tx; + struct sk_buff *tmp_skb = skb; + + skb = skb_realloc_headroom(skb, dev->needed_headroom); + kfree_skb(tmp_skb); + if (skb == NULL) { + vif->net_stats.tx_dropped++; + return 0; + } } if (ath6kl_wmi_dix_2_dot3(ar->wmi, skb)) { -- cgit v0.10.2 From 8cb6d9915f77aa4a01181613a5882a7c04e571c3 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 4 Nov 2011 18:34:55 +0530 Subject: ath6kl: Fix error in writing create_qos debugfs 100 bytes are allocated to store the parameters which are needed to create a priority stream. These 100 bytes are not sufficiant and throws error when running the following command. echo "6 2 3 1 1 9999999 9999999 9999999 7777777 0 6 45000 200 56789000 56789000 5678900 0 0 9999999 20000 0" > create_qos 179 bytes are needed when the following vlaues are given so that a maximum possible value in that data type can be given in decimal. echo "255 255 255 255 255 4294967295 4294967295 4294967295 4294967295 4294967295 255 65535 65535 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295" > create_qos Following takes 187 bytes when given in hex echo "0xff 0xff 0xff 0xff 0xff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xff 0xffff 0xffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff" > create_qos Increase the size to 200 bytes so that it can hold upto the maximum value possible for that data type. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 70ea137..370664a 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1252,7 +1252,7 @@ static ssize_t ath6kl_create_qos_write(struct file *file, struct ath6kl *ar = file->private_data; struct ath6kl_vif *vif; - char buf[100]; + char buf[200]; ssize_t len; char *sptr, *token; struct wmi_create_pstream_cmd pstream; -- cgit v0.10.2 From 6a53fc531dcf4719e80d0152ca044e35b0f92591 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 25 Aug 2011 08:52:36 -0300 Subject: ARM: imx: Remove unused chip revision strings Since commit (167a19d2: ARM: imx: Introduce generic function for displaying silicon revision) we no longer need the chip revision strings, so remove them. Signed-off-by: Fabio Estevam Signed-off-by: Sascha Hauer diff --git a/arch/arm/plat-mxc/include/mach/mxc.h b/arch/arm/plat-mxc/include/mach/mxc.h index 00a7819..a4d36d6 100644 --- a/arch/arm/plat-mxc/include/mach/mxc.h +++ b/arch/arm/plat-mxc/include/mach/mxc.h @@ -50,20 +50,6 @@ #define IMX_CHIP_REVISION_3_3 0x33 #define IMX_CHIP_REVISION_UNKNOWN 0xff -#define IMX_CHIP_REVISION_1_0_STRING "1.0" -#define IMX_CHIP_REVISION_1_1_STRING "1.1" -#define IMX_CHIP_REVISION_1_2_STRING "1.2" -#define IMX_CHIP_REVISION_1_3_STRING "1.3" -#define IMX_CHIP_REVISION_2_0_STRING "2.0" -#define IMX_CHIP_REVISION_2_1_STRING "2.1" -#define IMX_CHIP_REVISION_2_2_STRING "2.2" -#define IMX_CHIP_REVISION_2_3_STRING "2.3" -#define IMX_CHIP_REVISION_3_0_STRING "3.0" -#define IMX_CHIP_REVISION_3_1_STRING "3.1" -#define IMX_CHIP_REVISION_3_2_STRING "3.2" -#define IMX_CHIP_REVISION_3_3_STRING "3.3" -#define IMX_CHIP_REVISION_UNKNOWN_STRING "unknown" - #ifndef __ASSEMBLY__ extern unsigned int __mxc_cpu_type; #endif -- cgit v0.10.2 From 8c6d8319eca370f804fb8e1fcf7070b587d1b81d Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Fri, 11 Nov 2011 13:09:18 +0800 Subject: arm/imx: remove imx_idle hook and use pm_idle instead The patch removes imx_idle hook and use pm_idle instead to get imx arch_idle prepared for the cleanup. It's suggested by Russel King as below. > The final removal of mach/system.h depends on getting rid of the arch_idle > thing. While going through these headers, I was dismayed to find these: > > arch/arm/mach-s3c2410/include/mach/system.h:void (*s3c24xx_idle)(void); > arch/arm/plat-mxc/include/mach/system.h:extern void (*imx_idle)(void); > > when we have a perfectly good pm_idle hook already in place - so there's > no excuse for these especially when other platforms are already using > pm_idle to hook their platform specific idle function into. This is > something that better be gone at the next merge window! Suggested-by: Russell King Signed-off-by: Shawn Guo Acked-by: Russell King Signed-off-by: Sascha Hauer diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c index 9f0e82e..6d01de3 100644 --- a/arch/arm/mach-imx/mm-imx3.c +++ b/arch/arm/mach-imx/mm-imx3.c @@ -33,29 +33,32 @@ static void imx3_idle(void) { unsigned long reg = 0; - __asm__ __volatile__( - /* disable I and D cache */ - "mrc p15, 0, %0, c1, c0, 0\n" - "bic %0, %0, #0x00001000\n" - "bic %0, %0, #0x00000004\n" - "mcr p15, 0, %0, c1, c0, 0\n" - /* invalidate I cache */ - "mov %0, #0\n" - "mcr p15, 0, %0, c7, c5, 0\n" - /* clear and invalidate D cache */ - "mov %0, #0\n" - "mcr p15, 0, %0, c7, c14, 0\n" - /* WFI */ - "mov %0, #0\n" - "mcr p15, 0, %0, c7, c0, 4\n" - "nop\n" "nop\n" "nop\n" "nop\n" - "nop\n" "nop\n" "nop\n" - /* enable I and D cache */ - "mrc p15, 0, %0, c1, c0, 0\n" - "orr %0, %0, #0x00001000\n" - "orr %0, %0, #0x00000004\n" - "mcr p15, 0, %0, c1, c0, 0\n" - : "=r" (reg)); + + if (!need_resched()) + __asm__ __volatile__( + /* disable I and D cache */ + "mrc p15, 0, %0, c1, c0, 0\n" + "bic %0, %0, #0x00001000\n" + "bic %0, %0, #0x00000004\n" + "mcr p15, 0, %0, c1, c0, 0\n" + /* invalidate I cache */ + "mov %0, #0\n" + "mcr p15, 0, %0, c7, c5, 0\n" + /* clear and invalidate D cache */ + "mov %0, #0\n" + "mcr p15, 0, %0, c7, c14, 0\n" + /* WFI */ + "mov %0, #0\n" + "mcr p15, 0, %0, c7, c0, 4\n" + "nop\n" "nop\n" "nop\n" "nop\n" + "nop\n" "nop\n" "nop\n" + /* enable I and D cache */ + "mrc p15, 0, %0, c1, c0, 0\n" + "orr %0, %0, #0x00001000\n" + "orr %0, %0, #0x00000004\n" + "mcr p15, 0, %0, c1, c0, 0\n" + : "=r" (reg)); + local_irq_enable(); } static void __iomem *imx3_ioremap(unsigned long phys_addr, size_t size, @@ -143,7 +146,7 @@ void __init imx31_init_early(void) { mxc_set_cpu_type(MXC_CPU_MX31); mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR)); - imx_idle = imx3_idle; + pm_idle = imx3_idle; imx_ioremap = imx3_ioremap; } @@ -152,7 +155,7 @@ void __init imx35_init_early(void) mxc_set_cpu_type(MXC_CPU_MX35); mxc_iomux_v3_init(MX35_IO_ADDRESS(MX35_IOMUXC_BASE_ADDR)); mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR)); - imx_idle = imx3_idle; + pm_idle = imx3_idle; imx_ioremap = imx3_ioremap; } diff --git a/arch/arm/mach-mx5/mm.c b/arch/arm/mach-mx5/mm.c index 26eacc9..df4a508f 100644 --- a/arch/arm/mach-mx5/mm.c +++ b/arch/arm/mach-mx5/mm.c @@ -23,7 +23,9 @@ static void imx5_idle(void) { - mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF); + if (!need_resched()) + mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF); + local_irq_enable(); } /* @@ -89,7 +91,7 @@ void __init imx51_init_early(void) mxc_set_cpu_type(MXC_CPU_MX51); mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR)); mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR)); - imx_idle = imx5_idle; + pm_idle = imx5_idle; } void __init imx53_init_early(void) diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h index 83b745a..7143d52 100644 --- a/arch/arm/plat-mxc/include/mach/common.h +++ b/arch/arm/plat-mxc/include/mach/common.h @@ -85,7 +85,6 @@ enum mxc_cpu_pwr_mode { }; extern void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode); -extern void (*imx_idle)(void); extern void imx_print_silicon_rev(const char *cpu, int srev); void avic_handle_irq(struct pt_regs *); diff --git a/arch/arm/plat-mxc/include/mach/system.h b/arch/arm/plat-mxc/include/mach/system.h index cf88b35..b9895d2 100644 --- a/arch/arm/plat-mxc/include/mach/system.h +++ b/arch/arm/plat-mxc/include/mach/system.h @@ -17,14 +17,9 @@ #ifndef __ASM_ARCH_MXC_SYSTEM_H__ #define __ASM_ARCH_MXC_SYSTEM_H__ -extern void (*imx_idle)(void); - static inline void arch_idle(void) { - if (imx_idle != NULL) - (imx_idle)(); - else - cpu_do_idle(); + cpu_do_idle(); } void arch_reset(char mode, const char *cmd); diff --git a/arch/arm/plat-mxc/system.c b/arch/arm/plat-mxc/system.c index 9dad8dc..a0bcccf 100644 --- a/arch/arm/plat-mxc/system.c +++ b/arch/arm/plat-mxc/system.c @@ -28,7 +28,6 @@ #include #include -void (*imx_idle)(void) = NULL; void __iomem *(*imx_ioremap)(unsigned long, size_t, unsigned int) = NULL; static void __iomem *wdog_base; -- cgit v0.10.2 From dd9dfb9f95e2141db672eb12a1d71892e9e481fb Mon Sep 17 00:00:00 2001 From: Dmitry Tarnyagin Date: Fri, 4 Nov 2011 17:12:07 +0100 Subject: cfg80211: merge in beacon ies of hidden bss. The problem with PSM when a hidden SSID was used was originally reported by Juuso Oikarinen. - When generally scanning, the AP is getting a bss entry with a zero SSID. - When associating, a probe-req is sent to the AP with the SSID, and as a result a probe-response is received with the hidden SSID in place. As a consequence, a second bss entry is created for the AP, now with the real SSID. - After association, mac80211 executes ieee80211_recalc_ps(), but does not switch to powersave because the beacon-ies are missing. As result, the STA does not ever enter PSM. The patch merges in beacon ies of hidden bss from beacon to the probe response, creating a consistent set of ies in place. Patch is depended on "cfg80211: fix cmp_ies" made by Johannes. Signed-off-by: Dmitry Tarnyagin Signed-off-by: John W. Linville diff --git a/net/wireless/scan.c b/net/wireless/scan.c index dc23b31..31119e3 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -355,8 +355,8 @@ static bool is_mesh(struct cfg80211_bss *a, sizeof(struct ieee80211_meshconf_ie) - 2) == 0; } -static int cmp_bss(struct cfg80211_bss *a, - struct cfg80211_bss *b) +static int cmp_bss_core(struct cfg80211_bss *a, + struct cfg80211_bss *b) { int r; @@ -378,7 +378,15 @@ static int cmp_bss(struct cfg80211_bss *a, b->len_information_elements); } - r = memcmp(a->bssid, b->bssid, ETH_ALEN); + return memcmp(a->bssid, b->bssid, ETH_ALEN); +} + +static int cmp_bss(struct cfg80211_bss *a, + struct cfg80211_bss *b) +{ + int r; + + r = cmp_bss_core(a, b); if (r) return r; @@ -389,6 +397,52 @@ static int cmp_bss(struct cfg80211_bss *a, b->len_information_elements); } +static int cmp_hidden_bss(struct cfg80211_bss *a, + struct cfg80211_bss *b) +{ + const u8 *ie1; + const u8 *ie2; + int i; + int r; + + r = cmp_bss_core(a, b); + if (r) + return r; + + ie1 = cfg80211_find_ie(WLAN_EID_SSID, + a->information_elements, + a->len_information_elements); + ie2 = cfg80211_find_ie(WLAN_EID_SSID, + b->information_elements, + b->len_information_elements); + + /* Key comparator must use same algorithm in any rb-tree + * search function (order is important), otherwise ordering + * of items in the tree is broken and search gives incorrect + * results. This code uses same order as cmp_ies() does. */ + + /* sort missing IE before (left of) present IE */ + if (!ie1) + return -1; + if (!ie2) + return 1; + + /* zero-size SSID is used as an indication of the hidden bss */ + if (!ie2[1]) + return 0; + + /* sort by length first, then by contents */ + if (ie1[1] != ie2[1]) + return ie2[1] - ie1[1]; + + /* zeroed SSID ie is another indication of a hidden bss */ + for (i = 0; i < ie2[1]; i++) + if (ie2[i + 2]) + return -1; + + return 0; +} + struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, struct ieee80211_channel *channel, const u8 *bssid, @@ -505,6 +559,48 @@ rb_find_bss(struct cfg80211_registered_device *dev, } static struct cfg80211_internal_bss * +rb_find_hidden_bss(struct cfg80211_registered_device *dev, + struct cfg80211_internal_bss *res) +{ + struct rb_node *n = dev->bss_tree.rb_node; + struct cfg80211_internal_bss *bss; + int r; + + while (n) { + bss = rb_entry(n, struct cfg80211_internal_bss, rbn); + r = cmp_hidden_bss(&res->pub, &bss->pub); + + if (r == 0) + return bss; + else if (r < 0) + n = n->rb_left; + else + n = n->rb_right; + } + + return NULL; +} + +static void +copy_hidden_ies(struct cfg80211_internal_bss *res, + struct cfg80211_internal_bss *hidden) +{ + if (unlikely(res->pub.beacon_ies)) + return; + if (WARN_ON(!hidden->pub.beacon_ies)) + return; + + res->pub.beacon_ies = kmalloc(hidden->pub.len_beacon_ies, GFP_ATOMIC); + if (unlikely(!res->pub.beacon_ies)) + return; + + res->beacon_ies_allocated = true; + res->pub.len_beacon_ies = hidden->pub.len_beacon_ies; + memcpy(res->pub.beacon_ies, hidden->pub.beacon_ies, + res->pub.len_beacon_ies); +} + +static struct cfg80211_internal_bss * cfg80211_bss_update(struct cfg80211_registered_device *dev, struct cfg80211_internal_bss *res) { @@ -607,6 +703,21 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev, kref_put(&res->ref, bss_release); } else { + struct cfg80211_internal_bss *hidden; + + /* First check if the beacon is a probe response from + * a hidden bss. If so, copy beacon ies (with nullified + * ssid) into the probe response bss entry (with real ssid). + * It is required basically for PSM implementation + * (probe responses do not contain tim ie) */ + + /* TODO: The code is not trying to update existing probe + * response bss entries when beacon ies are + * getting changed. */ + hidden = rb_find_hidden_bss(dev, res); + if (hidden) + copy_hidden_ies(res, hidden); + /* this "consumes" the reference */ list_add_tail(&res->list, &dev->bss_list); rb_insert_bss(dev, res); -- cgit v0.10.2 From d64cf63e062f6741f80c393f19c9706358489cc7 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Mon, 7 Nov 2011 23:24:39 +0200 Subject: mac80211: init rate-control for TDLS sta when supp-rates are known Initialize rate control algorithms only when supported rates are known for a TDLS peer sta. Direct Tx between peers is not allowed before the link is enabled. In turn, this only occurs after a change_station() call that sets supported rates. Signed-off-by: Arik Nemtsov Signed-off-by: John W. Linville diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 02a4323..eb54b6c 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -869,7 +869,12 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, sta_apply_parameters(local, sta, params); - rate_control_rate_init(sta); + /* + * for TDLS, rate control should be initialized only when supported + * rates are known. + */ + if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) + rate_control_rate_init(sta); layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || sdata->vif.type == NL80211_IFTYPE_AP; @@ -953,6 +958,9 @@ static int ieee80211_change_station(struct wiphy *wiphy, sta_apply_parameters(local, sta, params); + if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates) + rate_control_rate_init(sta); + rcu_read_unlock(); if (sdata->vif.type == NL80211_IFTYPE_STATION && -- cgit v0.10.2 From 33f38d425f65d767ac2f0f439465d1b3969c9a82 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 7 Nov 2011 21:41:06 -0800 Subject: mwifiex: fix ht_cap_info in ibss beacons A local variable is used to calculate ht_cap_info. Erroneously ht_cap.cap_info isn't updated in the ibss beacons after the calculation. This patch fixes it. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Kiran Divekar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index 62b4c29..062716cb 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -922,15 +922,15 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, cpu_to_le16(WLAN_EID_HT_CAPABILITY); ht_cap->header.len = cpu_to_le16(sizeof(struct ieee80211_ht_cap)); - ht_cap_info = le16_to_cpu(ht_cap->ht_cap.cap_info); - ht_cap_info |= IEEE80211_HT_CAP_SGI_20; + ht_cap_info = IEEE80211_HT_CAP_SGI_20; if (adapter->chan_offset) { ht_cap_info |= IEEE80211_HT_CAP_SGI_40; ht_cap_info |= IEEE80211_HT_CAP_DSSSCCK40; ht_cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask); } + ht_cap->ht_cap.cap_info = cpu_to_le16(ht_cap_info); ht_cap->ht_cap.ampdu_params_info = IEEE80211_HT_MAX_AMPDU_64K; -- cgit v0.10.2 From eedf15d34d3997051cc3a4bdd2adef68f3e36f57 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 7 Nov 2011 21:41:07 -0800 Subject: mwifiex: use existing helper function mwifiex_fill_cap_info Use existing helper function mwifiex_fill_cap_info to fill the HT CAP info for ibss beacons. Also removing extra parenthesis block for better readability. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index 062716cb..b27bd33 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -724,8 +724,8 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, u32 cmd_append_size = 0; u32 i; u16 tmp_cap; - uint16_t ht_cap_info; struct mwifiex_ie_types_chan_list_param_set *chan_tlv; + u8 radio_type; struct mwifiex_ie_types_htcap *ht_cap; struct mwifiex_ie_types_htinfo *ht_info; @@ -914,55 +914,40 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, } if (adapter->adhoc_11n_enabled) { - { - ht_cap = (struct mwifiex_ie_types_htcap *) pos; - memset(ht_cap, 0, - sizeof(struct mwifiex_ie_types_htcap)); - ht_cap->header.type = - cpu_to_le16(WLAN_EID_HT_CAPABILITY); - ht_cap->header.len = - cpu_to_le16(sizeof(struct ieee80211_ht_cap)); - - ht_cap_info = IEEE80211_HT_CAP_SGI_20; - if (adapter->chan_offset) { - ht_cap_info |= IEEE80211_HT_CAP_SGI_40; - ht_cap_info |= IEEE80211_HT_CAP_DSSSCCK40; - ht_cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; - SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask); - } - ht_cap->ht_cap.cap_info = cpu_to_le16(ht_cap_info); - - ht_cap->ht_cap.ampdu_params_info - = IEEE80211_HT_MAX_AMPDU_64K; - ht_cap->ht_cap.mcs.rx_mask[0] = 0xff; - pos += sizeof(struct mwifiex_ie_types_htcap); - cmd_append_size += - sizeof(struct mwifiex_ie_types_htcap); - } - { - ht_info = (struct mwifiex_ie_types_htinfo *) pos; - memset(ht_info, 0, - sizeof(struct mwifiex_ie_types_htinfo)); - ht_info->header.type = - cpu_to_le16(WLAN_EID_HT_INFORMATION); - ht_info->header.len = - cpu_to_le16(sizeof(struct ieee80211_ht_info)); - ht_info->ht_info.control_chan = - (u8) priv->curr_bss_params.bss_descriptor. - channel; - if (adapter->chan_offset) { - ht_info->ht_info.ht_param = - adapter->chan_offset; - ht_info->ht_info.ht_param |= + /* Fill HT CAPABILITY */ + ht_cap = (struct mwifiex_ie_types_htcap *) pos; + memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap)); + ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); + ht_cap->header.len = + cpu_to_le16(sizeof(struct ieee80211_ht_cap)); + radio_type = mwifiex_band_to_radio_type( + priv->adapter->config_bands); + mwifiex_fill_cap_info(priv, radio_type, ht_cap); + + pos += sizeof(struct mwifiex_ie_types_htcap); + cmd_append_size += + sizeof(struct mwifiex_ie_types_htcap); + + /* Fill HT INFORMATION */ + ht_info = (struct mwifiex_ie_types_htinfo *) pos; + memset(ht_info, 0, sizeof(struct mwifiex_ie_types_htinfo)); + ht_info->header.type = cpu_to_le16(WLAN_EID_HT_INFORMATION); + ht_info->header.len = + cpu_to_le16(sizeof(struct ieee80211_ht_info)); + + ht_info->ht_info.control_chan = + (u8) priv->curr_bss_params.bss_descriptor.channel; + if (adapter->chan_offset) { + ht_info->ht_info.ht_param = adapter->chan_offset; + ht_info->ht_info.ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; - } - ht_info->ht_info.operation_mode = - cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); - ht_info->ht_info.basic_set[0] = 0xff; - pos += sizeof(struct mwifiex_ie_types_htinfo); - cmd_append_size += - sizeof(struct mwifiex_ie_types_htinfo); } + ht_info->ht_info.operation_mode = + cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); + ht_info->ht_info.basic_set[0] = 0xff; + pos += sizeof(struct mwifiex_ie_types_htinfo); + cmd_append_size += + sizeof(struct mwifiex_ie_types_htinfo); } cmd->size = cpu_to_le16((u16) -- cgit v0.10.2 From ab581472c01d8533a801c96c00575694739cb94c Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 7 Nov 2011 21:41:08 -0800 Subject: mwifiex: change return types to void Functions mwifiex_11n_dispatch_pkt_until_start_win and mwifiex_11n_scan_and_dispatch used to always return value zero for all inputs. Changing these functions to void. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c index 7aa9aa0..681d3f2 100644 --- a/drivers/net/wireless/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c @@ -33,7 +33,7 @@ * Since the buffer is linear, the function uses rotation to simulate * circular buffer. */ -static int +static void mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr, int start_win) @@ -71,8 +71,6 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, rx_reor_tbl_ptr->start_win = start_win; spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); - - return 0; } /* @@ -83,7 +81,7 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, * Since the buffer is linear, the function uses rotation to simulate * circular buffer. */ -static int +static void mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr) { @@ -119,7 +117,6 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, rx_reor_tbl_ptr->start_win = (rx_reor_tbl_ptr->start_win + i) &(MAX_TID_VALUE - 1); spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); - return 0; } /* @@ -405,7 +402,7 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, u8 *ta, u8 pkt_type, void *payload) { struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; - int start_win, end_win, win_size, ret; + int start_win, end_win, win_size; u16 pkt_index; rx_reor_tbl_ptr = @@ -452,11 +449,8 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, start_win = (end_win - win_size) + 1; else start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1; - ret = mwifiex_11n_dispatch_pkt_until_start_win(priv, + mwifiex_11n_dispatch_pkt_until_start_win(priv, rx_reor_tbl_ptr, start_win); - - if (ret) - return ret; } if (pkt_type != PKT_TYPE_BAR) { @@ -475,9 +469,9 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, * Dispatch all packets sequentially from start_win until a * hole is found and adjust the start_win appropriately */ - ret = mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr); + mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr); - return ret; + return 0; } /* -- cgit v0.10.2 From 63af63330f4c8b4fdcc13dec082dea3b81d53b0a Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 7 Nov 2011 21:41:09 -0800 Subject: mwifiex: fix coding style Rename DataRate to data_rate and arrange 'for' loop for better readability. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h index 0cc5d73..35cb29c 100644 --- a/drivers/net/wireless/mwifiex/fw.h +++ b/drivers/net/wireless/mwifiex/fw.h @@ -673,7 +673,7 @@ struct host_cmd_ds_802_11_ad_hoc_start { union ieee_types_phy_param_set phy_param_set; u16 reserved1; __le16 cap_info_bitmap; - u8 DataRate[HOSTCMD_SUPPORTED_RATES]; + u8 data_rate[HOSTCMD_SUPPORTED_RATES]; } __packed; struct host_cmd_ds_802_11_ad_hoc_result { diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index b27bd33..1c49813 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -837,8 +837,8 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL; } - memset(adhoc_start->DataRate, 0, sizeof(adhoc_start->DataRate)); - mwifiex_get_active_data_rates(priv, adhoc_start->DataRate); + memset(adhoc_start->data_rate, 0, sizeof(adhoc_start->data_rate)); + mwifiex_get_active_data_rates(priv, adhoc_start->data_rate); if ((adapter->adhoc_start_band & BAND_G) && (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) { if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, @@ -850,20 +850,19 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, } } /* Find the last non zero */ - for (i = 0; i < sizeof(adhoc_start->DataRate) && - adhoc_start->DataRate[i]; - i++) - ; + for (i = 0; i < sizeof(adhoc_start->data_rate); i++) + if (!adhoc_start->data_rate[i]) + break; priv->curr_bss_params.num_of_rates = i; /* Copy the ad-hoc creating rates into Current BSS rate structure */ memcpy(&priv->curr_bss_params.data_rates, - &adhoc_start->DataRate, priv->curr_bss_params.num_of_rates); + &adhoc_start->data_rate, priv->curr_bss_params.num_of_rates); dev_dbg(adapter->dev, "info: ADHOC_S_CMD: rates=%02x %02x %02x %02x\n", - adhoc_start->DataRate[0], adhoc_start->DataRate[1], - adhoc_start->DataRate[2], adhoc_start->DataRate[3]); + adhoc_start->data_rate[0], adhoc_start->data_rate[1], + adhoc_start->data_rate[2], adhoc_start->data_rate[3]); dev_dbg(adapter->dev, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n"); -- cgit v0.10.2 From 8ed1303321914a70ad580c1d034898e43c39b065 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 7 Nov 2011 21:41:10 -0800 Subject: mwifiex: fix 'Smatch' warnings Following three warnings are fixed: >init.c +256 mwifiex_init_adapter(71) >warn: variable dereferenced before check 'adapter->sleep_cfm' >(see line 191) >sta_rx.c +193 mwifiex_process_sta_rx_packet(75) >warn: variable dereferenced before check 'priv' (see line 182) Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index d792b3f..2694045 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c @@ -187,8 +187,6 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) struct mwifiex_opt_sleep_confirm *sleep_cfm_buf = NULL; skb_put(adapter->sleep_cfm, sizeof(struct mwifiex_opt_sleep_confirm)); - sleep_cfm_buf = (struct mwifiex_opt_sleep_confirm *) - (adapter->sleep_cfm->data); adapter->cmd_sent = false; @@ -254,6 +252,8 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) mwifiex_wmm_init(adapter); if (adapter->sleep_cfm) { + sleep_cfm_buf = (struct mwifiex_opt_sleep_confirm *) + adapter->sleep_cfm->data; memset(sleep_cfm_buf, 0, adapter->sleep_cfm->len); sleep_cfm_buf->command = cpu_to_le16(HostCmd_CMD_802_11_PS_MODE_ENH); diff --git a/drivers/net/wireless/mwifiex/sta_rx.c b/drivers/net/wireless/mwifiex/sta_rx.c index 2743051..5e1ef7e 100644 --- a/drivers/net/wireless/mwifiex/sta_rx.c +++ b/drivers/net/wireless/mwifiex/sta_rx.c @@ -126,6 +126,9 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, u16 rx_pkt_type; struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; + if (!priv) + return -1; + local_rx_pd = (struct rxpd *) (skb->data); rx_pkt_type = local_rx_pd->rx_pkt_type; @@ -189,12 +192,11 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, (u8) local_rx_pd->rx_pkt_type, skb); - if (ret || (rx_pkt_type == PKT_TYPE_BAR)) { - if (priv && (ret == -1)) - priv->stats.rx_dropped++; - + if (ret || (rx_pkt_type == PKT_TYPE_BAR)) dev_kfree_skb_any(skb); - } + + if (ret) + priv->stats.rx_dropped++; return ret; } -- cgit v0.10.2 From f72fa45f7d3e3ec627b62fed2e3451f5a597914d Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Mon, 7 Nov 2011 21:41:11 -0800 Subject: mwifiex: remove unnecessary free_priv handler Cfg80211 stack allocates private area for driver use in struct cfg80211_bss. It will be freed by stack in bss_release(). Driver don't need to worry about it. In mwifiex driver, we use the private area just to store band information(u8). We don't allocate memory explicitly and store it's pointer in bss->priv. Hence we don't have any cleanup work to do in free_priv handler. Currently we try to free the allocated private area in free_priv handler which is not correct. This patch removes unnecessary free_priv handler. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 8a3f959..c650e60 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -1535,11 +1535,6 @@ done: return 0; } -static void mwifiex_free_bss_priv(struct cfg80211_bss *bss) -{ - kfree(bss->priv); -} - /* * This function handles the command response of scan. * @@ -1765,7 +1760,6 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, cap_info_bitmap, beacon_period, ie_buf, ie_len, rssi, GFP_KERNEL); *(u8 *)bss->priv = band; - bss->free_priv = mwifiex_free_bss_priv; if (priv->media_connected && !memcmp(bssid, priv->curr_bss_params.bss_descriptor -- cgit v0.10.2 From aa95a48d46328f35403f3b03e0cafb3c5883aaba Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Mon, 7 Nov 2011 21:41:12 -0800 Subject: mwifiex: release bss structure returned by cfg80211_inform_bss() Following compilation warning is fixed by releasing referenced BSS structure returned by cfg80211_inform_bss(). "warning: ignoring return value of cfg80211_inform_bss, declared with attribute warn_unused_result" Cc: Johannes Berg Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 462c710..e9ab9a3 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -780,6 +780,7 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv) { struct ieee80211_channel *chan; struct mwifiex_bss_info bss_info; + struct cfg80211_bss *bss; int ie_len; u8 ie_buf[IEEE80211_MAX_SSID_LEN + sizeof(struct ieee_types_header)]; enum ieee80211_band band; @@ -800,9 +801,10 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv) ieee80211_channel_to_frequency(bss_info.bss_chan, band)); - cfg80211_inform_bss(priv->wdev->wiphy, chan, + bss = cfg80211_inform_bss(priv->wdev->wiphy, chan, bss_info.bssid, 0, WLAN_CAPABILITY_IBSS, 0, ie_buf, ie_len, 0, GFP_KERNEL); + cfg80211_put_bss(bss); memcpy(priv->cfg_bssid, bss_info.bssid, ETH_ALEN); return 0; diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index c650e60..8a18bcc 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -1760,6 +1760,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, cap_info_bitmap, beacon_period, ie_buf, ie_len, rssi, GFP_KERNEL); *(u8 *)bss->priv = band; + cfg80211_put_bss(bss); if (priv->media_connected && !memcmp(bssid, priv->curr_bss_params.bss_descriptor -- cgit v0.10.2 From df222edc09a0219ea0c5c6cec6217abb334280c4 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Tue, 8 Nov 2011 14:19:32 +0530 Subject: ath9k_hw: Read and configure quick drop for AR9003 Read and configure quick drop feild from AR9003 eeprom inorder to help with strong signal. This patch also removes obsolate parameters ob, db_stage2, db_stage_3, db_stage4 from the eeprom templates. Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index 3b262ba..de103ef 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c @@ -121,10 +121,8 @@ static const struct ar9300_eeprom ar9300_default = { * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {1, 1, 1},/* 3 chain */ - .db_stage2 = {1, 1, 1}, /* 3 chain */ - .db_stage3 = {0, 0, 0}, - .db_stage4 = {0, 0, 0}, + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -144,7 +142,7 @@ static const struct ar9300_eeprom ar9300_default = { }, .base_ext1 = { .ant_div_control = 0, - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), @@ -323,10 +321,8 @@ static const struct ar9300_eeprom ar9300_default = { .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {3, 3, 3}, /* 3 chain */ - .db_stage2 = {3, 3, 3}, /* 3 chain */ - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -698,10 +694,8 @@ static const struct ar9300_eeprom ar9300_x113 = { * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {1, 1, 1},/* 3 chain */ - .db_stage2 = {1, 1, 1}, /* 3 chain */ - .db_stage3 = {0, 0, 0}, - .db_stage4 = {0, 0, 0}, + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -721,7 +715,7 @@ static const struct ar9300_eeprom ar9300_x113 = { }, .base_ext1 = { .ant_div_control = 0, - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), @@ -900,10 +894,8 @@ static const struct ar9300_eeprom ar9300_x113 = { .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {3, 3, 3}, /* 3 chain */ - .db_stage2 = {3, 3, 3}, /* 3 chain */ - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0xf, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -1276,10 +1268,8 @@ static const struct ar9300_eeprom ar9300_h112 = { * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {1, 1, 1},/* 3 chain */ - .db_stage2 = {1, 1, 1}, /* 3 chain */ - .db_stage3 = {0, 0, 0}, - .db_stage4 = {0, 0, 0}, + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -1299,7 +1289,7 @@ static const struct ar9300_eeprom ar9300_h112 = { }, .base_ext1 = { .ant_div_control = 0, - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), @@ -1478,10 +1468,8 @@ static const struct ar9300_eeprom ar9300_h112 = { .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {3, 3, 3}, /* 3 chain */ - .db_stage2 = {3, 3, 3}, /* 3 chain */ - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -1854,10 +1842,8 @@ static const struct ar9300_eeprom ar9300_x112 = { * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {1, 1, 1},/* 3 chain */ - .db_stage2 = {1, 1, 1}, /* 3 chain */ - .db_stage3 = {0, 0, 0}, - .db_stage4 = {0, 0, 0}, + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -1877,7 +1863,7 @@ static const struct ar9300_eeprom ar9300_x112 = { }, .base_ext1 = { .ant_div_control = 0, - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), @@ -2056,10 +2042,8 @@ static const struct ar9300_eeprom ar9300_x112 = { .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshch check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {3, 3, 3}, /* 3 chain */ - .db_stage2 = {3, 3, 3}, /* 3 chain */ - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -2431,10 +2415,8 @@ static const struct ar9300_eeprom ar9300_h116 = { * if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {1, 1, 1},/* 3 chain */ - .db_stage2 = {1, 1, 1}, /* 3 chain */ - .db_stage3 = {0, 0, 0}, - .db_stage4 = {0, 0, 0}, + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -2454,7 +2436,7 @@ static const struct ar9300_eeprom ar9300_h116 = { }, .base_ext1 = { .ant_div_control = 0, - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, .calFreqPier2G = { FREQ2FBIN(2412, 1), @@ -2633,10 +2615,8 @@ static const struct ar9300_eeprom ar9300_h116 = { .spurChans = {0, 0, 0, 0, 0}, /* noiseFloorThreshCh Check if the register is per chain */ .noiseFloorThreshCh = {-1, 0, 0}, - .ob = {3, 3, 3}, /* 3 chain */ - .db_stage2 = {3, 3, 3}, /* 3 chain */ - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + .quick_drop = 0, .xpaBiasLvl = 0, .txFrameToDataStart = 0x0e, .txFrameToPaOn = 0x0e, @@ -3023,6 +3003,8 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah, return eep->modalHeader5G.antennaGain; case EEP_ANTENNA_GAIN_2G: return eep->modalHeader2G.antennaGain; + case EEP_QUICK_DROP: + return pBase->miscConfiguration & BIT(1); default: return 0; } @@ -3428,25 +3410,13 @@ static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size, PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]); PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]); PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]); + PR_EEP("Quick Drop", modal_hdr->quick_drop); PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl); PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart); PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn); PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn); PR_EEP("txClip", modal_hdr->txClip); PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize); - PR_EEP("Chain0 ob", modal_hdr->ob[0]); - PR_EEP("Chain1 ob", modal_hdr->ob[1]); - PR_EEP("Chain2 ob", modal_hdr->ob[2]); - - PR_EEP("Chain0 db_stage2", modal_hdr->db_stage2[0]); - PR_EEP("Chain1 db_stage2", modal_hdr->db_stage2[1]); - PR_EEP("Chain2 db_stage2", modal_hdr->db_stage2[2]); - PR_EEP("Chain0 db_stage3", modal_hdr->db_stage3[0]); - PR_EEP("Chain1 db_stage3", modal_hdr->db_stage3[1]); - PR_EEP("Chain2 db_stage3", modal_hdr->db_stage3[2]); - PR_EEP("Chain0 db_stage4", modal_hdr->db_stage4[0]); - PR_EEP("Chain1 db_stage4", modal_hdr->db_stage4[1]); - PR_EEP("Chain2 db_stage4", modal_hdr->db_stage4[2]); return len; } @@ -3503,6 +3473,7 @@ static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr, PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4))); PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5))); PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0))); + PR_EEP("Quick Drop", !!(pBase->miscConfiguration & BIT(1))); PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1); PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio); PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio); @@ -3965,6 +3936,26 @@ static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah) } } +static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq) +{ + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; + int quick_drop = ath9k_hw_ar9300_get_eeprom(ah, EEP_QUICK_DROP); + s32 t[3], f[3] = {5180, 5500, 5785}; + + if (!quick_drop) + return; + + if (freq < 4000) + quick_drop = eep->modalHeader2G.quick_drop; + else { + t[0] = eep->base_ext1.quick_drop_low; + t[1] = eep->modalHeader5G.quick_drop; + t[2] = eep->base_ext1.quick_drop_high; + quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3); + } + REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop); +} + static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, struct ath9k_channel *chan) { @@ -3972,6 +3963,7 @@ static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan)); ar9003_hw_drive_strength_apply(ah); ar9003_hw_atten_apply(ah, chan); + ar9003_hw_quick_drop_apply(ah, chan->channel); if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah)) ar9003_hw_internal_regulator_apply(ah); if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h index 6335a86..bb223fe 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h @@ -216,10 +216,8 @@ struct ar9300_modal_eep_header { u8 spurChans[AR_EEPROM_MODAL_SPURS]; /* 3 Check if the register is per chain */ int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS]; - u8 ob[AR9300_MAX_CHAINS]; - u8 db_stage2[AR9300_MAX_CHAINS]; - u8 db_stage3[AR9300_MAX_CHAINS]; - u8 db_stage4[AR9300_MAX_CHAINS]; + u8 reserved[11]; + int8_t quick_drop; u8 xpaBiasLvl; u8 txFrameToDataStart; u8 txFrameToPaOn; @@ -269,7 +267,9 @@ struct cal_ctl_data_5g { struct ar9300_BaseExtension_1 { u8 ant_div_control; - u8 future[13]; + u8 future[11]; + int8_t quick_drop_low; + int8_t quick_drop_high; } __packed; struct ar9300_BaseExtension_2 { diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h index 4114fe7..497d746 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h @@ -389,6 +389,8 @@ #define AR_PHY_DAG_CTRLCCK_RSSI_THR_S 10 #define AR_PHY_RIFS_INIT_DELAY 0x3ff0000 +#define AR_PHY_AGC_QUICK_DROP 0x03c00000 +#define AR_PHY_AGC_QUICK_DROP_S 22 #define AR_PHY_AGC_COARSE_LOW 0x00007F80 #define AR_PHY_AGC_COARSE_LOW_S 7 #define AR_PHY_AGC_COARSE_HIGH 0x003F8000 diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h index 49abd34..5ff7ab9 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom.h +++ b/drivers/net/wireless/ath/ath9k/eeprom.h @@ -249,7 +249,8 @@ enum eeprom_param { EEP_ANT_DIV_CTL1, EEP_CHAIN_MASK_REDUCE, EEP_ANTENNA_GAIN_2G, - EEP_ANTENNA_GAIN_5G + EEP_ANTENNA_GAIN_5G, + EEP_QUICK_DROP }; enum ar5416_rates { -- cgit v0.10.2 From 202bff08bf8ed3769dd49e1890352c0b106df796 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Tue, 8 Nov 2011 14:19:33 +0530 Subject: ath9k_hw: Read and configure xpa timing field Configure xpa timing field while loading boad defaults to fix 11b CCK spur issue that was observed in EMI testing. Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index de103ef..5fb3f54 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c @@ -3411,6 +3411,7 @@ static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size, PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]); PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]); PR_EEP("Quick Drop", modal_hdr->quick_drop); + PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff); PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl); PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart); PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn); @@ -3956,6 +3957,20 @@ static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq) REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop); } +static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, u16 freq) +{ + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; + u32 value; + + value = (freq < 4000) ? eep->modalHeader2G.txEndToXpaOff : + eep->modalHeader5G.txEndToXpaOff; + + REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, + AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value); + REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, + AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value); +} + static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, struct ath9k_channel *chan) { @@ -3968,6 +3983,7 @@ static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, ar9003_hw_internal_regulator_apply(ah); if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) ar9003_hw_apply_tuning_caps(ah); + ar9003_hw_txend_to_xpa_off_apply(ah, chan->channel); } static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah, -- cgit v0.10.2 From 94e2ad9ee47025747d19620f288fb533d49c0475 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Tue, 8 Nov 2011 14:19:34 +0530 Subject: ath9k_hw: Fix channel list of CalFreqPeir for AR938x This patch sync up CalFreqPeir channel list and paprd rate mask of AR938x templates to the latest received from Systems team. Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index 5fb3f54..ee9c09b 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c @@ -1281,8 +1281,8 @@ static const struct ar9300_eeprom ar9300_h112 = { .txEndToRxOn = 0x2, .txFrameToXpaOn = 0xe, .thresh62 = 28, - .papdRateMaskHt20 = LE32(0x80c080), - .papdRateMaskHt40 = LE32(0x80c080), + .papdRateMaskHt20 = LE32(0x0c80c080), + .papdRateMaskHt40 = LE32(0x0080c080), .futureModal = { 0, 0, 0, 0, 0, 0, 0, 0, }, @@ -1294,7 +1294,7 @@ static const struct ar9300_eeprom ar9300_h112 = { .calFreqPier2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), - FREQ2FBIN(2472, 1), + FREQ2FBIN(2462, 1), }, /* ar9300_cal_data_per_freq_op_loop 2g */ .calPierData2G = { @@ -1304,7 +1304,7 @@ static const struct ar9300_eeprom ar9300_h112 = { }, .calTarget_freqbin_Cck = { FREQ2FBIN(2412, 1), - FREQ2FBIN(2484, 1), + FREQ2FBIN(2472, 1), }, .calTarget_freqbin_2G = { FREQ2FBIN(2412, 1), @@ -1503,7 +1503,7 @@ static const struct ar9300_eeprom ar9300_h112 = { FREQ2FBIN(5500, 0), FREQ2FBIN(5600, 0), FREQ2FBIN(5700, 0), - FREQ2FBIN(5825, 0) + FREQ2FBIN(5785, 0) }, .calPierData5G = { { @@ -2441,7 +2441,7 @@ static const struct ar9300_eeprom ar9300_h116 = { .calFreqPier2G = { FREQ2FBIN(2412, 1), FREQ2FBIN(2437, 1), - FREQ2FBIN(2472, 1), + FREQ2FBIN(2462, 1), }, /* ar9300_cal_data_per_freq_op_loop 2g */ .calPierData2G = { @@ -2643,7 +2643,7 @@ static const struct ar9300_eeprom ar9300_h116 = { .xatten1MarginHigh = {0, 0, 0} }, .calFreqPier5G = { - FREQ2FBIN(5180, 0), + FREQ2FBIN(5160, 0), FREQ2FBIN(5220, 0), FREQ2FBIN(5320, 0), FREQ2FBIN(5400, 0), -- cgit v0.10.2 From 86a2ea4134b48f6371103cfceb521bf2d2bf76cd Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 8 Nov 2011 15:36:59 +0200 Subject: mac80211: set carrier_on for ibss vifs only while joined mac80211 should set carrier_on for ibss vifs only while they are joined (similar to sta vifs) Signed-off-by: Eliad Peller Signed-off-by: John W. Linville diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index ede9a8b..7d84af7 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -97,6 +97,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, /* if merging, indicate to driver that we leave the old IBSS */ if (sdata->vif.bss_conf.ibss_joined) { sdata->vif.bss_conf.ibss_joined = false; + netif_carrier_off(sdata->dev); ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS); } @@ -207,6 +208,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, bss = cfg80211_inform_bss_frame(local->hw.wiphy, local->hw.conf.channel, mgmt, skb->len, 0, GFP_KERNEL); cfg80211_put_bss(bss); + netif_carrier_on(sdata->dev); cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL); } @@ -990,6 +992,7 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) } sta_info_flush(sdata->local, sdata); + netif_carrier_off(sdata->dev); /* remove beacon */ kfree(sdata->u.ibss.ie); diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index b7bc4b7..7b0c25b 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -293,7 +293,8 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) changed |= ieee80211_reset_erp_info(sdata); ieee80211_bss_info_change_notify(sdata, changed); - if (sdata->vif.type == NL80211_IFTYPE_STATION) + if (sdata->vif.type == NL80211_IFTYPE_STATION || + sdata->vif.type == NL80211_IFTYPE_ADHOC) netif_carrier_off(dev); else netif_carrier_on(dev); -- cgit v0.10.2 From 07ef03ee8b280a536b38ccfe512b9556996f0492 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 8 Nov 2011 16:21:21 +0100 Subject: mac80211: simplify scan state machine Attempting to micro-optimise the scan by going fully live again when scanning the operating channel just made the code extremely complex and has little gain in most use cases. Remove all that code and simplify the state machine again. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 76e656b..873d681 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -728,17 +728,16 @@ enum { * operating channel * @SCAN_SET_CHANNEL: Set the next channel to be scanned * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses - * @SCAN_LEAVE_OPER_CHANNEL: Leave the operating channel, notify the AP - * about us leaving the channel and stop all associated STA interfaces - * @SCAN_ENTER_OPER_CHANNEL: Enter the operating channel again, notify the - * AP about us being back and restart all associated STA interfaces + * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to + * send out data + * @SCAN_RESUME: Resume the scan and scan the next channel */ enum mac80211_scan_state { SCAN_DECISION, SCAN_SET_CHANNEL, SCAN_SEND_PROBE, - SCAN_LEAVE_OPER_CHANNEL, - SCAN_ENTER_OPER_CHANNEL, + SCAN_SUSPEND, + SCAN_RESUME, }; struct ieee80211_local { diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 83a0b05..7107159 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -212,12 +212,7 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) if (bss) ieee80211_rx_bss_put(sdata->local, bss); - /* If we are on-operating-channel, and this packet is for the - * current channel, pass the pkt on up the stack so that - * the rest of the stack can make use of it. - */ - if (ieee80211_cfg_on_oper_channel(sdata->local) - && (channel == sdata->local->oper_channel)) + if (channel == sdata->local->oper_channel) return RX_CONTINUE; dev_kfree_skb(skb); @@ -263,8 +258,6 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted, bool was_hw_scan) { struct ieee80211_local *local = hw_to_local(hw); - bool on_oper_chan; - bool enable_beacons = false; lockdep_assert_held(&local->mtx); @@ -297,25 +290,13 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted, local->scanning = 0; local->scan_channel = NULL; - on_oper_chan = ieee80211_cfg_on_oper_channel(local); - - if (was_hw_scan || !on_oper_chan) - ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); - else - /* Set power back to normal operating levels. */ - ieee80211_hw_config(local, 0); + /* Set power back to normal operating levels. */ + ieee80211_hw_config(local, 0); if (!was_hw_scan) { - bool on_oper_chan2; ieee80211_configure_filter(local); drv_sw_scan_complete(local); - on_oper_chan2 = ieee80211_cfg_on_oper_channel(local); - /* We should always be on-channel at this point. */ - WARN_ON(!on_oper_chan2); - if (on_oper_chan2 && (on_oper_chan != on_oper_chan2)) - enable_beacons = true; - - ieee80211_offchannel_return(local, enable_beacons, true); + ieee80211_offchannel_return(local, true, true); } ieee80211_recalc_idle(local); @@ -360,11 +341,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) local->next_scan_state = SCAN_DECISION; local->scan_channel_idx = 0; - /* We always want to use off-channel PS, even if we - * are not really leaving oper-channel. Don't - * tell the AP though, as long as we are on-channel. - */ - ieee80211_offchannel_enable_all_ps(local, false); + ieee80211_offchannel_stop_vifs(local, true); ieee80211_configure_filter(local); @@ -372,8 +349,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) ieee80211_hw_config(local, 0); ieee80211_queue_delayed_work(&local->hw, - &local->scan_work, - IEEE80211_CHANNEL_TIME); + &local->scan_work, 0); return 0; } @@ -509,96 +485,39 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local, next_chan = local->scan_req->channels[local->scan_channel_idx]; - if (ieee80211_cfg_on_oper_channel(local)) { - /* We're currently on operating channel. */ - if (next_chan == local->oper_channel) - /* We don't need to move off of operating channel. */ - local->next_scan_state = SCAN_SET_CHANNEL; - else - /* - * We do need to leave operating channel, as next - * scan is somewhere else. - */ - local->next_scan_state = SCAN_LEAVE_OPER_CHANNEL; - } else { - /* - * we're currently scanning a different channel, let's - * see if we can scan another channel without interfering - * with the current traffic situation. - * - * Since we don't know if the AP has pending frames for us - * we can only check for our tx queues and use the current - * pm_qos requirements for rx. Hence, if no tx traffic occurs - * at all we will scan as many channels in a row as the pm_qos - * latency allows us to. Additionally we also check for the - * currently negotiated listen interval to prevent losing - * frames unnecessarily. - * - * Otherwise switch back to the operating channel. - */ - - bad_latency = time_after(jiffies + - ieee80211_scan_get_channel_time(next_chan), - local->leave_oper_channel_time + - usecs_to_jiffies(pm_qos_request(PM_QOS_NETWORK_LATENCY))); - - listen_int_exceeded = time_after(jiffies + - ieee80211_scan_get_channel_time(next_chan), - local->leave_oper_channel_time + - usecs_to_jiffies(min_beacon_int * 1024) * - local->hw.conf.listen_interval); - - if (associated && ( !tx_empty || bad_latency || - listen_int_exceeded)) - local->next_scan_state = SCAN_ENTER_OPER_CHANNEL; - else - local->next_scan_state = SCAN_SET_CHANNEL; - } - - *next_delay = 0; -} - -static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *local, - unsigned long *next_delay) -{ - /* PS will already be in off-channel mode, - * we do that once at the beginning of scanning. - */ - ieee80211_offchannel_stop_vifs(local, false); - /* - * What if the nullfunc frames didn't arrive? + * we're currently scanning a different channel, let's + * see if we can scan another channel without interfering + * with the current traffic situation. + * + * Since we don't know if the AP has pending frames for us + * we can only check for our tx queues and use the current + * pm_qos requirements for rx. Hence, if no tx traffic occurs + * at all we will scan as many channels in a row as the pm_qos + * latency allows us to. Additionally we also check for the + * currently negotiated listen interval to prevent losing + * frames unnecessarily. + * + * Otherwise switch back to the operating channel. */ - drv_flush(local, false); - if (local->ops->flush) - *next_delay = 0; - else - *next_delay = HZ / 10; - /* remember when we left the operating channel */ - local->leave_oper_channel_time = jiffies; + bad_latency = time_after(jiffies + + ieee80211_scan_get_channel_time(next_chan), + local->leave_oper_channel_time + + usecs_to_jiffies(pm_qos_request(PM_QOS_NETWORK_LATENCY))); - /* advance to the next channel to be scanned */ - local->next_scan_state = SCAN_SET_CHANNEL; -} - -static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *local, - unsigned long *next_delay) -{ - /* switch back to the operating channel */ - local->scan_channel = NULL; - if (!ieee80211_cfg_on_oper_channel(local)) - ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); + listen_int_exceeded = time_after(jiffies + + ieee80211_scan_get_channel_time(next_chan), + local->leave_oper_channel_time + + usecs_to_jiffies(min_beacon_int * 1024) * + local->hw.conf.listen_interval); - /* - * Re-enable vifs and beaconing. Leave PS - * in off-channel state..will put that back - * on-channel at the end of scanning. - */ - ieee80211_offchannel_return(local, true, false); + if (associated && (!tx_empty || bad_latency || listen_int_exceeded)) + local->next_scan_state = SCAN_SUSPEND; + else + local->next_scan_state = SCAN_SET_CHANNEL; - *next_delay = HZ / 5; - local->next_scan_state = SCAN_DECISION; + *next_delay = 0; } static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, @@ -612,10 +531,8 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, local->scan_channel = chan; - /* Only call hw-config if we really need to change channels. */ - if (chan != local->hw.conf.channel) - if (ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL)) - skip = 1; + if (ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL)) + skip = 1; /* advance state machine to next channel/band */ local->scan_channel_idx++; @@ -672,6 +589,44 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local, local->next_scan_state = SCAN_DECISION; } +static void ieee80211_scan_state_suspend(struct ieee80211_local *local, + unsigned long *next_delay) +{ + /* switch back to the operating channel */ + local->scan_channel = NULL; + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); + + /* + * Re-enable vifs and beaconing. Leave PS + * in off-channel state..will put that back + * on-channel at the end of scanning. + */ + ieee80211_offchannel_return(local, true, false); + + *next_delay = HZ / 5; + /* afterwards, resume scan & go to next channel */ + local->next_scan_state = SCAN_RESUME; +} + +static void ieee80211_scan_state_resume(struct ieee80211_local *local, + unsigned long *next_delay) +{ + /* PS already is in off-channel mode */ + ieee80211_offchannel_stop_vifs(local, false); + + if (local->ops->flush) { + drv_flush(local, false); + *next_delay = 0; + } else + *next_delay = HZ / 10; + + /* remember when we left the operating channel */ + local->leave_oper_channel_time = jiffies; + + /* advance to the next channel to be scanned */ + local->next_scan_state = SCAN_DECISION; +} + void ieee80211_scan_work(struct work_struct *work) { struct ieee80211_local *local = @@ -742,11 +697,11 @@ void ieee80211_scan_work(struct work_struct *work) case SCAN_SEND_PROBE: ieee80211_scan_state_send_probe(local, &next_delay); break; - case SCAN_LEAVE_OPER_CHANNEL: - ieee80211_scan_state_leave_oper_channel(local, &next_delay); + case SCAN_SUSPEND: + ieee80211_scan_state_suspend(local, &next_delay); break; - case SCAN_ENTER_OPER_CHANNEL: - ieee80211_scan_state_enter_oper_channel(local, &next_delay); + case SCAN_RESUME: + ieee80211_scan_state_resume(local, &next_delay); break; } } while (next_delay == 0); -- cgit v0.10.2 From e999882a052a2959571989b2db2b51893d23c0bb Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 9 Nov 2011 10:30:21 +0100 Subject: mac80211/cfg80211: report monitor channel in wireless extensions Just add API to get the channel & report it. Trivial really. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index e1ee1416..50e3608f 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1342,6 +1342,9 @@ struct cfg80211_gtk_rekey_data { * doesn't verify much. Note, however, that the passed netdev may be * %NULL as well if the user requested changing the channel for the * device itself, or for a monitor interface. + * @get_channel: Get the current operating channel, should return %NULL if + * there's no single defined operating channel if for example the + * device implements channel hopping for multi-channel virtual interfaces. * * @scan: Request to do a scan. If returning zero, the scan request is given * the driver, and will be valid until passed to cfg80211_scan_done(). @@ -1627,6 +1630,8 @@ struct cfg80211_ops { int (*probe_client)(struct wiphy *wiphy, struct net_device *dev, const u8 *peer, u64 *cookie); + + struct ieee80211_channel *(*get_channel)(struct wiphy *wiphy); }; /* diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index eb54b6c..192f213 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2590,6 +2590,14 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, return 0; } +static struct ieee80211_channel * +ieee80211_wiphy_get_channel(struct wiphy *wiphy) +{ + struct ieee80211_local *local = wiphy_priv(wiphy); + + return local->oper_channel; +} + struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface, @@ -2656,4 +2664,5 @@ struct cfg80211_ops mac80211_config_ops = { .tdls_oper = ieee80211_tdls_oper, .tdls_mgmt = ieee80211_tdls_mgmt, .probe_client = ieee80211_probe_client, + .get_channel = ieee80211_wiphy_get_channel, }; diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 62f121d..db38c83 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c @@ -818,12 +818,24 @@ static int cfg80211_wext_giwfreq(struct net_device *dev, struct iw_freq *freq, char *extra) { struct wireless_dev *wdev = dev->ieee80211_ptr; + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); + struct ieee80211_channel *chan; switch (wdev->iftype) { case NL80211_IFTYPE_STATION: return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra); case NL80211_IFTYPE_ADHOC: return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); + case NL80211_IFTYPE_MONITOR: + if (!rdev->ops->get_channel) + return -EINVAL; + + chan = rdev->ops->get_channel(wdev->wiphy); + if (!chan) + return -EINVAL; + freq->m = chan->center_freq; + freq->e = 6; + return 0; default: if (!wdev->channel) return -EINVAL; -- cgit v0.10.2 From e8c0dacd9836dc2dcb28d236c9cc3cfaa9965a20 Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Wed, 9 Nov 2011 12:09:14 +0200 Subject: NFC: Update names and structs to NCI spec 1.0 d18 Addition, deletion and modification of NCI constants. Changes in NCI commands, responses and notifications structures. Signed-off-by: Ilan Elias Acked-by: Lauro Ramos Venancio Signed-off-by: John W. Linville diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h index 39b85bc..0ebf842 100644 --- a/include/net/nfc/nci.h +++ b/include/net/nfc/nci.h @@ -36,24 +36,23 @@ /* NCI Status Codes */ #define NCI_STATUS_OK 0x00 #define NCI_STATUS_REJECTED 0x01 -#define NCI_STATUS_MESSAGE_CORRUPTED 0x02 -#define NCI_STATUS_BUFFER_FULL 0x03 -#define NCI_STATUS_FAILED 0x04 -#define NCI_STATUS_NOT_INITIALIZED 0x05 -#define NCI_STATUS_SYNTAX_ERROR 0x06 -#define NCI_STATUS_SEMANTIC_ERROR 0x07 -#define NCI_STATUS_UNKNOWN_GID 0x08 -#define NCI_STATUS_UNKNOWN_OID 0x09 -#define NCI_STATUS_INVALID_PARAM 0x0a -#define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0b +#define NCI_STATUS_RF_FRAME_CORRUPTED 0x02 +#define NCI_STATUS_FAILED 0x03 +#define NCI_STATUS_NOT_INITIALIZED 0x04 +#define NCI_STATUS_SYNTAX_ERROR 0x05 +#define NCI_STATUS_SEMANTIC_ERROR 0x06 +#define NCI_STATUS_UNKNOWN_GID 0x07 +#define NCI_STATUS_UNKNOWN_OID 0x08 +#define NCI_STATUS_INVALID_PARAM 0x09 +#define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0a /* Discovery Specific Status Codes */ #define NCI_STATUS_DISCOVERY_ALREADY_STARTED 0xa0 #define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED 0xa1 +#define NCI_STATUS_DISCOVERY_TEAR_DOWN 0xa2 /* RF Interface Specific Status Codes */ #define NCI_STATUS_RF_TRANSMISSION_ERROR 0xb0 #define NCI_STATUS_RF_PROTOCOL_ERROR 0xb1 #define NCI_STATUS_RF_TIMEOUT_ERROR 0xb2 -#define NCI_STATUS_RF_LINK_LOSS_ERROR 0xb3 /* NFCEE Interface Specific Status Codes */ #define NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED 0xc0 #define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED 0xc1 @@ -73,6 +72,21 @@ #define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 #define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 +/* NCI RF Technologies */ +#define NCI_NFC_RF_TECHNOLOGY_A 0x00 +#define NCI_NFC_RF_TECHNOLOGY_B 0x01 +#define NCI_NFC_RF_TECHNOLOGY_F 0x02 +#define NCI_NFC_RF_TECHNOLOGY_15693 0x03 + +/* NCI Bit Rates */ +#define NCI_NFC_BIT_RATE_106 0x00 +#define NCI_NFC_BIT_RATE_212 0x01 +#define NCI_NFC_BIT_RATE_424 0x02 +#define NCI_NFC_BIT_RATE_848 0x03 +#define NCI_NFC_BIT_RATE_1696 0x04 +#define NCI_NFC_BIT_RATE_3392 0x05 +#define NCI_NFC_BIT_RATE_6784 0x06 + /* NCI RF Protocols */ #define NCI_RF_PROTOCOL_UNKNOWN 0x00 #define NCI_RF_PROTOCOL_T1T 0x01 @@ -82,11 +96,18 @@ #define NCI_RF_PROTOCOL_NFC_DEP 0x05 /* NCI RF Interfaces */ -#define NCI_RF_INTERFACE_RFU 0x00 +#define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00 #define NCI_RF_INTERFACE_FRAME 0x01 #define NCI_RF_INTERFACE_ISO_DEP 0x02 #define NCI_RF_INTERFACE_NFC_DEP 0x03 +/* NCI Reset types */ +#define NCI_RESET_TYPE_KEEP_CONFIG 0x00 +#define NCI_RESET_TYPE_RESET_CONFIG 0x01 + +/* NCI Static RF connection ID */ +#define NCI_STATIC_RF_CONN_ID 0x00 + /* NCI RF_DISCOVER_MAP_CMD modes */ #define NCI_DISC_MAP_MODE_POLL 0x01 #define NCI_DISC_MAP_MODE_LISTEN 0x02 @@ -98,8 +119,6 @@ #define NCI_DISCOVERY_TYPE_POLL_F_PASSIVE 0x02 #define NCI_DISCOVERY_TYPE_POLL_A_ACTIVE 0x03 #define NCI_DISCOVERY_TYPE_POLL_F_ACTIVE 0x05 -#define NCI_DISCOVERY_TYPE_WAKEUP_A_PASSIVE 0x06 -#define NCI_DISCOVERY_TYPE_WAKEUP_B_PASSIVE 0x07 #define NCI_DISCOVERY_TYPE_WAKEUP_A_ACTIVE 0x09 #define NCI_DISCOVERY_TYPE_LISTEN_A_PASSIVE 0x80 #define NCI_DISCOVERY_TYPE_LISTEN_B_PASSIVE 0x81 @@ -111,8 +130,7 @@ #define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00 #define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01 #define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE 0x02 -#define NCI_DEACTIVATE_TYPE_RF_LINK_LOSS 0x03 -#define NCI_DEACTIVATE_TYPE_DISCOVERY_ERROR 0x04 +#define NCI_DEACTIVATE_TYPE_DISCOVERY 0x03 /* Message Type (MT) */ #define NCI_MT_DATA_PKT 0x00 @@ -169,6 +187,9 @@ struct nci_data_hdr { /* ----- NCI Commands ---- */ /* ------------------------ */ #define NCI_OP_CORE_RESET_CMD nci_opcode_pack(NCI_GID_CORE, 0x00) +struct nci_core_reset_cmd { + __u8 reset_type; +} __packed; #define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) @@ -218,6 +239,7 @@ struct nci_rf_deactivate_cmd { struct nci_core_reset_rsp { __u8 status; __u8 nci_ver; + __u8 config_status; } __packed; #define NCI_OP_CORE_INIT_RSP nci_opcode_pack(NCI_GID_CORE, 0x01) @@ -232,10 +254,12 @@ struct nci_core_init_rsp_1 { struct nci_core_init_rsp_2 { __u8 max_logical_connections; __le16 max_routing_table_size; - __u8 max_control_packet_payload_length; - __le16 rf_sending_buffer_size; - __le16 rf_receiving_buffer_size; - __le16 manufacturer_id; + __u8 max_ctrl_pkt_payload_len; + __le16 max_size_for_large_params; + __u8 max_data_pkt_payload_size; + __u8 initial_num_credits; + __u8 manufact_id; + __le32 manufact_specific_info; } __packed; #define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02) @@ -275,7 +299,7 @@ struct nci_rf_field_info_ntf { __u8 rf_field_status; } __packed; -#define NCI_OP_RF_ACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) +#define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) struct rf_tech_specific_params_nfca_poll { __u16 sens_res; __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */ @@ -289,17 +313,20 @@ struct activation_params_nfca_poll_iso_dep { __u8 rats_res[20]; }; -struct nci_rf_activate_ntf { - __u8 target_handle; +struct nci_rf_intf_activated_ntf { + __u8 rf_discovery_id; + __u8 rf_interface_type; __u8 rf_protocol; - __u8 rf_tech_and_mode; + __u8 activation_rf_tech_and_mode; __u8 rf_tech_specific_params_len; union { struct rf_tech_specific_params_nfca_poll nfca_poll; } rf_tech_specific_params; - __u8 rf_interface_type; + __u8 data_exch_rf_tech_and_mode; + __u8 data_exch_tx_bit_rate; + __u8 data_exch_rx_bit_rate; __u8 activation_params_len; union { @@ -309,5 +336,9 @@ struct nci_rf_activate_ntf { } __packed; #define NCI_OP_RF_DEACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) +struct nci_rf_deactivate_ntf { + __u8 type; + __u8 reason; +} __packed; #endif /* __NCI_H */ diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index b8b4bbd..6e6a7be 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -109,14 +109,15 @@ struct nci_dev { [NCI_MAX_SUPPORTED_RF_INTERFACES]; __u8 max_logical_connections; __u16 max_routing_table_size; - __u8 max_control_packet_payload_length; - __u16 rf_sending_buffer_size; - __u16 rf_receiving_buffer_size; - __u16 manufacturer_id; + __u8 max_ctrl_pkt_payload_len; + __u16 max_size_for_large_params; + __u8 max_data_pkt_payload_size; + __u8 initial_num_credits; + __u8 manufact_id; + __u32 manufact_specific_info; /* received during NCI_OP_CORE_CONN_CREATE_RSP for static conn 0 */ __u8 max_pkt_payload_size; - __u8 initial_num_credits; __u8 conn_id; /* stored during nci_data_exchange */ diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 4047e29..557fe92 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -125,7 +125,10 @@ static inline int nci_request(struct nci_dev *ndev, static void nci_reset_req(struct nci_dev *ndev, unsigned long opt) { - nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 0, NULL); + struct nci_core_reset_cmd cmd; + + cmd.reset_type = NCI_RESET_TYPE_RESET_CONFIG; + nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 1, &cmd); } static void nci_init_req(struct nci_dev *ndev, unsigned long opt) @@ -469,7 +472,7 @@ static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx, ndev->data_exchange_cb = cb; ndev->data_exchange_cb_context = cb_context; - rc = nci_send_data(ndev, ndev->conn_id, skb); + rc = nci_send_data(ndev, NCI_STATIC_RF_CONN_ID, skb); if (rc) clear_bit(NCI_DATA_EXCHANGE, &ndev->flags); diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index e5ed90f..511fb96 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c @@ -95,7 +95,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev, __skb_queue_head_init(&frags_q); while (total_len) { - frag_len = min_t(int, total_len, ndev->max_pkt_payload_size); + frag_len = + min_t(int, total_len, ndev->max_data_pkt_payload_size); skb_frag = nci_skb_alloc(ndev, (NCI_DATA_HDR_SIZE + frag_len), @@ -151,7 +152,7 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb) nfc_dbg("entry, conn_id 0x%x, plen %d", conn_id, skb->len); /* check if the packet need to be fragmented */ - if (skb->len <= ndev->max_pkt_payload_size) { + if (skb->len <= ndev->max_data_pkt_payload_size) { /* no need to fragment packet */ nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST); diff --git a/net/nfc/nci/lib.c b/net/nfc/nci/lib.c index b19dc2f..e99adcf 100644 --- a/net/nfc/nci/lib.c +++ b/net/nfc/nci/lib.c @@ -42,12 +42,9 @@ int nci_to_errno(__u8 code) case NCI_STATUS_REJECTED: return -EBUSY; - case NCI_STATUS_MESSAGE_CORRUPTED: + case NCI_STATUS_RF_FRAME_CORRUPTED: return -EBADMSG; - case NCI_STATUS_BUFFER_FULL: - return -ENOBUFS; - case NCI_STATUS_NOT_INITIALIZED: return -EHOSTDOWN; @@ -80,9 +77,6 @@ int nci_to_errno(__u8 code) case NCI_STATUS_NFCEE_TIMEOUT_ERROR: return -ETIMEDOUT; - case NCI_STATUS_RF_LINK_LOSS_ERROR: - return -ENOLINK; - case NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED: return -EDQUOT; diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 96633f5..6789f482 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -54,7 +54,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, ntf->conn_entries[i].conn_id, ntf->conn_entries[i].credits); - if (ntf->conn_entries[i].conn_id == ndev->conn_id) { + if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) { /* found static rf connection */ atomic_add(ntf->conn_entries[i].credits, &ndev->credits_cnt); @@ -74,14 +74,12 @@ static void nci_rf_field_info_ntf_packet(struct nci_dev *ndev, nfc_dbg("entry, rf_field_status %d", ntf->rf_field_status); } -static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev, - struct nci_rf_activate_ntf *ntf, __u8 *data) +static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, + struct nci_rf_intf_activated_ntf *ntf, __u8 *data) { struct rf_tech_specific_params_nfca_poll *nfca_poll; - struct activation_params_nfca_poll_iso_dep *nfca_poll_iso_dep; nfca_poll = &ntf->rf_tech_specific_params.nfca_poll; - nfca_poll_iso_dep = &ntf->activation_params.nfca_poll_iso_dep; nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); data += 2; @@ -100,32 +98,32 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev, if (nfca_poll->sel_res_len != 0) nfca_poll->sel_res = *data++; - ntf->rf_interface_type = *data++; - ntf->activation_params_len = *data++; - - nfc_dbg("sel_res_len %d, sel_res 0x%x, rf_interface_type %d, activation_params_len %d", + nfc_dbg("sel_res_len %d, sel_res 0x%x", nfca_poll->sel_res_len, - nfca_poll->sel_res, - ntf->rf_interface_type, - ntf->activation_params_len); - - switch (ntf->rf_interface_type) { - case NCI_RF_INTERFACE_ISO_DEP: - nfca_poll_iso_dep->rats_res_len = *data++; - if (nfca_poll_iso_dep->rats_res_len > 0) { - memcpy(nfca_poll_iso_dep->rats_res, + nfca_poll->sel_res); + + return data; +} + +static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, + struct nci_rf_intf_activated_ntf *ntf, __u8 *data) +{ + struct activation_params_nfca_poll_iso_dep *nfca_poll; + + switch (ntf->activation_rf_tech_and_mode) { + case NCI_NFC_A_PASSIVE_POLL_MODE: + nfca_poll = &ntf->activation_params.nfca_poll_iso_dep; + nfca_poll->rats_res_len = *data++; + if (nfca_poll->rats_res_len > 0) { + memcpy(nfca_poll->rats_res, data, - nfca_poll_iso_dep->rats_res_len); + nfca_poll->rats_res_len); } break; - case NCI_RF_INTERFACE_FRAME: - /* no activation params */ - break; - default: - nfc_err("unsupported rf_interface_type 0x%x", - ntf->rf_interface_type); + nfc_err("unsupported activation_rf_tech_and_mode 0x%x", + ntf->activation_rf_tech_and_mode); return -EPROTO; } @@ -133,7 +131,7 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev, } static void nci_target_found(struct nci_dev *ndev, - struct nci_rf_activate_ntf *ntf) + struct nci_rf_intf_activated_ntf *ntf) { struct nfc_target nfc_tgt; @@ -141,6 +139,8 @@ static void nci_target_found(struct nci_dev *ndev, nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK; else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */ nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK; + else + nfc_tgt.supported_protocols = 0; nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res; nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res; @@ -158,49 +158,86 @@ static void nci_target_found(struct nci_dev *ndev, nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1); } -static void nci_rf_activate_ntf_packet(struct nci_dev *ndev, - struct sk_buff *skb) +static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, + struct sk_buff *skb) { - struct nci_rf_activate_ntf ntf; + struct nci_rf_intf_activated_ntf ntf; __u8 *data = skb->data; - int rc = -1; + int err = 0; clear_bit(NCI_DISCOVERY, &ndev->flags); set_bit(NCI_POLL_ACTIVE, &ndev->flags); - ntf.target_handle = *data++; + ntf.rf_discovery_id = *data++; + ntf.rf_interface_type = *data++; ntf.rf_protocol = *data++; - ntf.rf_tech_and_mode = *data++; + ntf.activation_rf_tech_and_mode = *data++; ntf.rf_tech_specific_params_len = *data++; - nfc_dbg("target_handle %d, rf_protocol 0x%x, rf_tech_and_mode 0x%x, rf_tech_specific_params_len %d", - ntf.target_handle, - ntf.rf_protocol, - ntf.rf_tech_and_mode, + nfc_dbg("rf_discovery_id %d", ntf.rf_discovery_id); + nfc_dbg("rf_interface_type 0x%x", ntf.rf_interface_type); + nfc_dbg("rf_protocol 0x%x", ntf.rf_protocol); + nfc_dbg("activation_rf_tech_and_mode 0x%x", + ntf.activation_rf_tech_and_mode); + nfc_dbg("rf_tech_specific_params_len %d", ntf.rf_tech_specific_params_len); - switch (ntf.rf_tech_and_mode) { - case NCI_NFC_A_PASSIVE_POLL_MODE: - rc = nci_rf_activate_nfca_passive_poll(ndev, &ntf, - data); - break; + if (ntf.rf_tech_specific_params_len > 0) { + switch (ntf.activation_rf_tech_and_mode) { + case NCI_NFC_A_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfca_passive_poll(ndev, + &ntf, data); + break; + + default: + nfc_err("unsupported activation_rf_tech_and_mode 0x%x", + ntf.activation_rf_tech_and_mode); + return; + } + } - default: - nfc_err("unsupported rf_tech_and_mode 0x%x", - ntf.rf_tech_and_mode); - return; + ntf.data_exch_rf_tech_and_mode = *data++; + ntf.data_exch_tx_bit_rate = *data++; + ntf.data_exch_rx_bit_rate = *data++; + ntf.activation_params_len = *data++; + + nfc_dbg("data_exch_rf_tech_and_mode 0x%x", + ntf.data_exch_rf_tech_and_mode); + nfc_dbg("data_exch_tx_bit_rate 0x%x", + ntf.data_exch_tx_bit_rate); + nfc_dbg("data_exch_rx_bit_rate 0x%x", + ntf.data_exch_rx_bit_rate); + nfc_dbg("activation_params_len %d", + ntf.activation_params_len); + + if (ntf.activation_params_len > 0) { + switch (ntf.rf_interface_type) { + case NCI_RF_INTERFACE_ISO_DEP: + err = nci_extract_activation_params_iso_dep(ndev, + &ntf, data); + break; + + case NCI_RF_INTERFACE_FRAME: + /* no activation params */ + break; + + default: + nfc_err("unsupported rf_interface_type 0x%x", + ntf.rf_interface_type); + return; + } } - if (!rc) + if (!err) nci_target_found(ndev, &ntf); } static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) { - __u8 type = skb->data[0]; + struct nci_rf_deactivate_ntf *ntf = (void *) skb->data; - nfc_dbg("entry, type 0x%x", type); + nfc_dbg("entry, type 0x%x, reason 0x%x", ntf->type, ntf->reason); clear_bit(NCI_POLL_ACTIVE, &ndev->flags); ndev->target_active_prot = 0; @@ -241,8 +278,8 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) nci_rf_field_info_ntf_packet(ndev, skb); break; - case NCI_OP_RF_ACTIVATE_NTF: - nci_rf_activate_ntf_packet(ndev, skb); + case NCI_OP_RF_INTF_ACTIVATED_NTF: + nci_rf_intf_activated_ntf_packet(ndev, skb); break; case NCI_OP_RF_DEACTIVATE_NTF: diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c index 0403d4c..64fc58a 100644 --- a/net/nfc/nci/rsp.c +++ b/net/nfc/nci/rsp.c @@ -42,10 +42,11 @@ static void nci_core_reset_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) nfc_dbg("entry, status 0x%x", rsp->status); - if (rsp->status == NCI_STATUS_OK) + if (rsp->status == NCI_STATUS_OK) { ndev->nci_ver = rsp->nci_ver; - - nfc_dbg("nci_ver 0x%x", ndev->nci_ver); + nfc_dbg("nci_ver 0x%x, config_status 0x%x", + rsp->nci_ver, rsp->config_status); + } nci_req_complete(ndev, rsp->status); } @@ -58,13 +59,13 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) nfc_dbg("entry, status 0x%x", rsp_1->status); if (rsp_1->status != NCI_STATUS_OK) - return; + goto exit; ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features); ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces; if (ndev->num_supported_rf_interfaces > - NCI_MAX_SUPPORTED_RF_INTERFACES) { + NCI_MAX_SUPPORTED_RF_INTERFACES) { ndev->num_supported_rf_interfaces = NCI_MAX_SUPPORTED_RF_INTERFACES; } @@ -73,20 +74,26 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) rsp_1->supported_rf_interfaces, ndev->num_supported_rf_interfaces); - rsp_2 = (void *) (skb->data + 6 + ndev->num_supported_rf_interfaces); + rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces); ndev->max_logical_connections = rsp_2->max_logical_connections; ndev->max_routing_table_size = __le16_to_cpu(rsp_2->max_routing_table_size); - ndev->max_control_packet_payload_length = - rsp_2->max_control_packet_payload_length; - ndev->rf_sending_buffer_size = - __le16_to_cpu(rsp_2->rf_sending_buffer_size); - ndev->rf_receiving_buffer_size = - __le16_to_cpu(rsp_2->rf_receiving_buffer_size); - ndev->manufacturer_id = - __le16_to_cpu(rsp_2->manufacturer_id); + ndev->max_ctrl_pkt_payload_len = + rsp_2->max_ctrl_pkt_payload_len; + ndev->max_size_for_large_params = + __le16_to_cpu(rsp_2->max_size_for_large_params); + ndev->max_data_pkt_payload_size = + rsp_2->max_data_pkt_payload_size; + ndev->initial_num_credits = + rsp_2->initial_num_credits; + ndev->manufact_id = + rsp_2->manufact_id; + ndev->manufact_specific_info = + __le32_to_cpu(rsp_2->manufact_specific_info); + + atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); nfc_dbg("nfcc_features 0x%x", ndev->nfcc_features); @@ -104,15 +111,20 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) ndev->max_logical_connections); nfc_dbg("max_routing_table_size %d", ndev->max_routing_table_size); - nfc_dbg("max_control_packet_payload_length %d", - ndev->max_control_packet_payload_length); - nfc_dbg("rf_sending_buffer_size %d", - ndev->rf_sending_buffer_size); - nfc_dbg("rf_receiving_buffer_size %d", - ndev->rf_receiving_buffer_size); - nfc_dbg("manufacturer_id 0x%x", - ndev->manufacturer_id); - + nfc_dbg("max_ctrl_pkt_payload_len %d", + ndev->max_ctrl_pkt_payload_len); + nfc_dbg("max_size_for_large_params %d", + ndev->max_size_for_large_params); + nfc_dbg("max_data_pkt_payload_size %d", + ndev->max_data_pkt_payload_size); + nfc_dbg("initial_num_credits %d", + ndev->initial_num_credits); + nfc_dbg("manufact_id 0x%x", + ndev->manufact_id); + nfc_dbg("manufact_specific_info 0x%x", + ndev->manufact_specific_info); + +exit: nci_req_complete(ndev, rsp_1->status); } -- cgit v0.10.2 From ee4c64fb984e652c0d49d41d19d1b8e4576c3203 Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Wed, 9 Nov 2011 12:09:15 +0200 Subject: NFC: Removal of unused operations for NCI spec 1.0 d18 Remove unused NCI operations, e.g. create static rf connection. Signed-off-by: Ilan Elias Acked-by: Lauro Ramos Venancio Signed-off-by: John W. Linville diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h index 0ebf842..0b34fde 100644 --- a/include/net/nfc/nci.h +++ b/include/net/nfc/nci.h @@ -193,16 +193,6 @@ struct nci_core_reset_cmd { #define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) -#define NCI_OP_CORE_SET_CONFIG_CMD nci_opcode_pack(NCI_GID_CORE, 0x02) - -#define NCI_OP_CORE_CONN_CREATE_CMD nci_opcode_pack(NCI_GID_CORE, 0x04) -struct nci_core_conn_create_cmd { - __u8 target_handle; - __u8 num_target_specific_params; -} __packed; - -#define NCI_OP_CORE_CONN_CLOSE_CMD nci_opcode_pack(NCI_GID_CORE, 0x06) - #define NCI_OP_RF_DISCOVER_MAP_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) struct disc_map_config { __u8 rf_protocol; @@ -262,18 +252,6 @@ struct nci_core_init_rsp_2 { __le32 manufact_specific_info; } __packed; -#define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02) - -#define NCI_OP_CORE_CONN_CREATE_RSP nci_opcode_pack(NCI_GID_CORE, 0x04) -struct nci_core_conn_create_rsp { - __u8 status; - __u8 max_pkt_payload_size; - __u8 initial_num_credits; - __u8 conn_id; -} __packed; - -#define NCI_OP_CORE_CONN_CLOSE_RSP nci_opcode_pack(NCI_GID_CORE, 0x06) - #define NCI_OP_RF_DISCOVER_MAP_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) #define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) @@ -294,11 +272,6 @@ struct nci_core_conn_credit_ntf { struct conn_credit_entry conn_entries[NCI_MAX_NUM_CONN]; } __packed; -#define NCI_OP_RF_FIELD_INFO_NTF nci_opcode_pack(NCI_GID_CORE, 0x08) -struct nci_rf_field_info_ntf { - __u8 rf_field_status; -} __packed; - #define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) struct rf_tech_specific_params_nfca_poll { __u16 sens_res; diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 6e6a7be..c92b69d 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -116,10 +116,6 @@ struct nci_dev { __u8 manufact_id; __u32 manufact_specific_info; - /* received during NCI_OP_CORE_CONN_CREATE_RSP for static conn 0 */ - __u8 max_pkt_payload_size; - __u8 conn_id; - /* stored during nci_data_exchange */ data_exchange_cb_t data_exchange_cb; void *data_exchange_cb_context; diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 557fe92..9d0b530 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -138,17 +138,11 @@ static void nci_init_req(struct nci_dev *ndev, unsigned long opt) static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt) { - struct nci_core_conn_create_cmd conn_cmd; struct nci_rf_disc_map_cmd cmd; struct disc_map_config *cfg = cmd.mapping_configs; __u8 *num = &cmd.num_mapping_configs; int i; - /* create static rf connection */ - conn_cmd.target_handle = 0; - conn_cmd.num_target_specific_params = 0; - nci_send_cmd(ndev, NCI_OP_CORE_CONN_CREATE_CMD, 2, &conn_cmd); - /* set rf mapping configurations */ *num = 0; diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 6789f482..c1bf541 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -66,14 +66,6 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, queue_work(ndev->tx_wq, &ndev->tx_work); } -static void nci_rf_field_info_ntf_packet(struct nci_dev *ndev, - struct sk_buff *skb) -{ - struct nci_rf_field_info_ntf *ntf = (void *) skb->data; - - nfc_dbg("entry, rf_field_status %d", ntf->rf_field_status); -} - static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, struct nci_rf_intf_activated_ntf *ntf, __u8 *data) { @@ -251,6 +243,9 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, ndev->rx_data_reassembly = 0; } + /* set the available credits to initial value */ + atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); + /* complete the data exchange transaction, if exists */ if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) nci_data_exchange_complete(ndev, NULL, -EIO); @@ -274,10 +269,6 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) nci_core_conn_credits_ntf_packet(ndev, skb); break; - case NCI_OP_RF_FIELD_INFO_NTF: - nci_rf_field_info_ntf_packet(ndev, skb); - break; - case NCI_OP_RF_INTF_ACTIVATED_NTF: nci_rf_intf_activated_ntf_packet(ndev, skb); break; diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c index 64fc58a..0591f5a 100644 --- a/net/nfc/nci/rsp.c +++ b/net/nfc/nci/rsp.c @@ -128,27 +128,6 @@ exit: nci_req_complete(ndev, rsp_1->status); } -static void nci_core_conn_create_rsp_packet(struct nci_dev *ndev, - struct sk_buff *skb) -{ - struct nci_core_conn_create_rsp *rsp = (void *) skb->data; - - nfc_dbg("entry, status 0x%x", rsp->status); - - if (rsp->status != NCI_STATUS_OK) - return; - - ndev->max_pkt_payload_size = rsp->max_pkt_payload_size; - ndev->initial_num_credits = rsp->initial_num_credits; - ndev->conn_id = rsp->conn_id; - - atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); - - nfc_dbg("max_pkt_payload_size %d", ndev->max_pkt_payload_size); - nfc_dbg("initial_num_credits %d", ndev->initial_num_credits); - nfc_dbg("conn_id %d", ndev->conn_id); -} - static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) { @@ -208,10 +187,6 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) nci_core_init_rsp_packet(ndev, skb); break; - case NCI_OP_CORE_CONN_CREATE_RSP: - nci_core_conn_create_rsp_packet(ndev, skb); - break; - case NCI_OP_RF_DISCOVER_MAP_RSP: nci_rf_disc_map_rsp_packet(ndev, skb); break; -- cgit v0.10.2 From db98c829b70e0a313e627d1c63cf5a7087290e5c Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Wed, 9 Nov 2011 12:09:16 +0200 Subject: NFC: Check if NCI data flow control is used Check if NCI data flow control is used in nci_tx_work. Signed-off-by: Ilan Elias Acked-by: Lauro Ramos Venancio Signed-off-by: John W. Linville diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h index 0b34fde..cdbe671 100644 --- a/include/net/nfc/nci.h +++ b/include/net/nfc/nci.h @@ -108,6 +108,9 @@ /* NCI Static RF connection ID */ #define NCI_STATIC_RF_CONN_ID 0x00 +/* NCI Data Flow Control */ +#define NCI_DATA_FLOW_CONTROL_NOT_USED 0xff + /* NCI RF_DISCOVER_MAP_CMD modes */ #define NCI_DISC_MAP_MODE_POLL 0x01 #define NCI_DISC_MAP_MODE_LISTEN 0x02 diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 9d0b530..3dffcb3 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -722,7 +722,10 @@ static void nci_tx_work(struct work_struct *work) if (!skb) return; - atomic_dec(&ndev->credits_cnt); + /* Check if data flow control is used */ + if (atomic_read(&ndev->credits_cnt) != + NCI_DATA_FLOW_CONTROL_NOT_USED) + atomic_dec(&ndev->credits_cnt); nfc_dbg("NCI TX: MT=data, PBF=%d, conn_id=%d, plen=%d", nci_pbf(skb->data), -- cgit v0.10.2 From 8e1b23b9ed427c3bd4c69503fed64231458d3edb Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Wed, 9 Nov 2011 12:29:06 +0200 Subject: mac80211: add recalc PS in ieee80211_reconfig() Driver should be instructed to enter PS AFTER reconfiguring ASSOCIATED (in STA case) using ieee80211_bss_info_change_notify same as it's being done in ieee80211_set_associated() Signed-off-by: Eyal Shapira Signed-off-by: John W. Linville diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 98ca547..6ed0aa4 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1093,6 +1093,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) } } + ieee80211_recalc_ps(local, -1); + /* * Clear the WLAN_STA_BLOCK_BA flag so new aggregation * sessions can be established after a resume. -- cgit v0.10.2 From 776d68f863b8fa3880595a958cf86b837427713a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 9 Nov 2011 21:33:45 +0100 Subject: wireless: move ieee80211chan2mhz macro The macro is only used in ipw2200 and we certainly don't want to encourage its use, so move it out of the radiotap header file and into the driver. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 99a710d..9957588 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c @@ -131,6 +131,14 @@ static struct ieee80211_rate ipw2200_rates[] = { #define ipw2200_bg_rates (ipw2200_rates + 0) #define ipw2200_num_bg_rates 12 +/* Ugly macro to convert literal channel numbers into their mhz equivalents + * There are certianly some conditions that will break this (like feeding it '30') + * but they shouldn't arise since nothing talks on channel 30. */ +#define ieee80211chan2mhz(x) \ + (((x) <= 14) ? \ + (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ + ((x) + 1000) * 5) + #ifdef CONFIG_IPW2200_QOS static int qos_enable = 0; static int qos_burst_enable = 0; diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h index 7e2c4d4..7139254 100644 --- a/include/net/ieee80211_radiotap.h +++ b/include/net/ieee80211_radiotap.h @@ -271,14 +271,6 @@ enum ieee80211_radiotap_type { #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 -/* Ugly macro to convert literal channel numbers into their mhz equivalents - * There are certianly some conditions that will break this (like feeding it '30') - * but they shouldn't arise since nothing talks on channel 30. */ -#define ieee80211chan2mhz(x) \ - (((x) <= 14) ? \ - (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ - ((x) + 1000) * 5) - /* helpers */ static inline int ieee80211_get_radiotap_len(unsigned char *data) { -- cgit v0.10.2 From fdacbcda7f21ba684cb4426daed67e23003d8311 Mon Sep 17 00:00:00 2001 From: Daniel Kuehn Date: Wed, 9 Nov 2011 23:57:57 +0100 Subject: ath9k: set ATH9K_PCI to y by default Most ath9k devices are PCI/PCIe based, therefor making PCI/PCIe support default y helps those porting a config from 2.6 kernel series from getting "non-functional" wireless drivers with 3.x kernel series. Signed-off-by: Daniel Kuehn Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig index d9c08c6..7b4c074 100644 --- a/drivers/net/wireless/ath/ath9k/Kconfig +++ b/drivers/net/wireless/ath/ath9k/Kconfig @@ -25,6 +25,7 @@ config ATH9K config ATH9K_PCI bool "Atheros ath9k PCI/PCIe bus support" + default y depends on ATH9K && PCI ---help--- This option enables the PCI bus support in ath9k. -- cgit v0.10.2 From e0830f71e7b8c2c58031c9692384819943162e9b Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Thu, 10 Nov 2011 09:35:13 +0200 Subject: mac80211: make sure hw_key exists before checking its flags Fixes a bug introduced in: commit 077a9154898b374f20555adc3f620cccd02581d6 Author: Arik Nemtsov Date: Sun Oct 23 08:21:41 2011 +0200 Reported-by: Arend van Spriel Reported-by: Johannes Berg Signed-off-by: Arik Nemtsov Signed-off-by: John W. Linville diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index 13efab5..106e15a 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c @@ -415,7 +415,8 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) memmove(pos, pos + CCMP_HDR_LEN, hdrlen); /* the HW only needs room for the IV, but not the actual IV */ - if (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) + if (info->control.hw_key && + (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) return 0; hdr = (struct ieee80211_hdr *) pos; -- cgit v0.10.2 From d64d373ffed925f29c3e68a8d6f45677a622054e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 10 Nov 2011 09:44:46 +0100 Subject: nl80211: fix compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit John reported the following warning: net/wireless/nl80211.c: In function ‘nl80211_tx_mgmt’: net/wireless/nl80211.c:5286:8: warning: ‘hdr’ may be used uninitialized in this function Evidently, his version of gcc isn't able to see that when "msg" is initialized, "hdr" must also be. My gcc, 4.6.1, can actually see that and doesn't warn. Simply initialize the variable to NULL. That means if the compiler was ever right we'll crash though so isn't really optimal since it may hide warnings from the compiler when somebody modifies this code in the future. Reported-by: John Linville Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 864fcb6..258fb88 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5283,7 +5283,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) bool channel_type_valid = false; u32 freq; int err; - void *hdr; + void *hdr = NULL; u64 cookie; struct sk_buff *msg = NULL; unsigned int wait = 0; -- cgit v0.10.2 From 87bbbe22f84b91d0bcd3a7fc638e4f5e8224cc4e Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Thu, 10 Nov 2011 11:28:55 +0200 Subject: nl80211: Add probe response offload attribute Notify user-space about probe-response offloading support in the driver. A wiphy flag is used to indicate support and a bitmap of protocols determines which protocols are supported. Signed-off-by: Guy Eilam Signed-off-by: Arik Nemtsov Signed-off-by: John W. Linville diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 3152ddf..be92333 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -1160,6 +1160,11 @@ enum nl80211_commands { * * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from * &enum nl80211_feature_flags and is advertised in wiphy information. + * @NL80211_ATTR_PROBE_RESP_OFFLOAD: Indicates that the HW responds to probe + * + * requests while operating in AP-mode. + * This attribute holds a bitmap of the supported protocols for + * offloading (see &enum nl80211_probe_resp_offload_support_attr). * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -1395,6 +1400,8 @@ enum nl80211_attrs { NL80211_ATTR_FEATURE_FLAGS, + NL80211_ATTR_PROBE_RESP_OFFLOAD, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -2727,4 +2734,25 @@ enum nl80211_feature_flags { NL80211_FEATURE_SK_TX_STATUS = 1 << 0, }; +/** + * enum nl80211_probe_resp_offload_support_attr - optional supported + * protocols for probe-response offloading by the driver/FW. + * To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute. + * Each enum value represents a bit in the bitmap of supported + * protocols. Typically a subset of probe-requests belonging to a + * supported protocol will be excluded from offload and uploaded + * to the host. + * + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1 + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2 + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U: Support for 802.11u + */ +enum nl80211_probe_resp_offload_support_attr { + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1<<0, + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1<<1, + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1<<2, + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3, +}; + #endif /* __LINUX_NL80211_H */ diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 50e3608f..093f538 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1694,6 +1694,8 @@ struct cfg80211_ops { * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes * when there are virtual interfaces in AP mode by calling * cfg80211_report_obss_beacon(). + * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device + * responds to probe-requests in hardware. */ enum wiphy_flags { WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), @@ -1714,6 +1716,7 @@ enum wiphy_flags { WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16), WIPHY_FLAG_HAVE_AP_SME = BIT(17), WIPHY_FLAG_REPORTS_OBSS = BIT(18), + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19), }; /** @@ -1982,6 +1985,13 @@ struct wiphy { u32 available_antennas_tx; u32 available_antennas_rx; + /* + * Bitmap of supported protocols for probe response offloading + * see &enum nl80211_probe_resp_offload_support_attr. Only valid + * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set. + */ + u32 probe_resp_offload; + /* If multiple wiphys are registered and you're handed e.g. * a regular netdev with assigned ieee80211_ptr, you won't * know whether it points to a wiphy your driver has registered diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 258fb88..f395a06 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -759,6 +759,10 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, dev->wiphy.available_antennas_rx); + if (dev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) + NLA_PUT_U32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD, + dev->wiphy.probe_resp_offload); + if ((dev->wiphy.available_antennas_tx || dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { u32 tx_ant = 0, rx_ant = 0; -- cgit v0.10.2 From 00f740e1a3b7abb51980371ee8fa113df22ae0b8 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Thu, 10 Nov 2011 11:28:56 +0200 Subject: nl80211: Pass probe response data to drivers Pass probe-response data from usermode via beacon parameters. Signed-off-by: Guy Eilam Signed-off-by: Arik Nemtsov Signed-off-by: John W. Linville diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index be92333..f9261c2 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -1166,6 +1166,10 @@ enum nl80211_commands { * This attribute holds a bitmap of the supported protocols for * offloading (see &enum nl80211_probe_resp_offload_support_attr). * + * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire + * probe-response frame. The DA field in the 802.11 header is zero-ed out, + * to be filled by the FW. + * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1402,6 +1406,8 @@ enum nl80211_attrs { NL80211_ATTR_PROBE_RESP_OFFLOAD, + NL80211_ATTR_PROBE_RESP, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 093f538..8d7ba09 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -391,6 +391,8 @@ struct cfg80211_crypto_settings { * @assocresp_ies: extra information element(s) to add into (Re)Association * Response frames or %NULL * @assocresp_ies_len: length of assocresp_ies in octets + * @probe_resp_len: length of probe response template (@probe_resp) + * @probe_resp: probe response template (AP mode only) */ struct beacon_parameters { u8 *head, *tail; @@ -408,6 +410,8 @@ struct beacon_parameters { size_t proberesp_ies_len; const u8 *assocresp_ies; size_t assocresp_ies_len; + int probe_resp_len; + u8 *probe_resp; }; /** diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index f395a06..6bc7c4b 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -197,6 +197,8 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { [NL80211_ATTR_TDLS_SUPPORT] = { .type = NLA_FLAG }, [NL80211_ATTR_TDLS_EXTERNAL_SETUP] = { .type = NLA_FLAG }, [NL80211_ATTR_DONT_WAIT_FOR_ACK] = { .type = NLA_FLAG }, + [NL80211_ATTR_PROBE_RESP] = { .type = NLA_BINARY, + .len = IEEE80211_MAX_DATA_LEN }, }; /* policy for the key attributes */ @@ -2171,6 +2173,13 @@ static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info) nla_len(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); } + if (info->attrs[NL80211_ATTR_PROBE_RESP]) { + params.probe_resp = + nla_data(info->attrs[NL80211_ATTR_PROBE_RESP]); + params.probe_resp_len = + nla_len(info->attrs[NL80211_ATTR_PROBE_RESP]); + } + err = call(&rdev->wiphy, dev, ¶ms); if (!err && params.interval) wdev->beacon_interval = params.interval; -- cgit v0.10.2 From 029458212604570eec4789049a8a74428484dbb4 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Thu, 10 Nov 2011 11:28:57 +0200 Subject: mac80211: Save probe response data for bss Allow setting a probe response template for an interface operating in AP mode. Low level drivers are notified about changes in the probe response template and are able to retrieve a copy of the current probe response. This data can, for example, be uploaded to hardware as a template. Signed-off-by: Guy Eilam Signed-off-by: Arik Nemtsov Signed-off-by: John W. Linville diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 2714646..0756049 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -166,6 +166,7 @@ struct ieee80211_low_level_stats { * that it is only ever disabled for station mode. * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode) + * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) */ enum ieee80211_bss_change { BSS_CHANGED_ASSOC = 1<<0, @@ -184,6 +185,7 @@ enum ieee80211_bss_change { BSS_CHANGED_QOS = 1<<13, BSS_CHANGED_IDLE = 1<<14, BSS_CHANGED_SSID = 1<<15, + BSS_CHANGED_AP_PROBE_RESP = 1<<16, /* when adding here, make sure to change ieee80211_reconfig */ }; @@ -2675,6 +2677,19 @@ static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, } /** + * ieee80211_proberesp_get - retrieve a Probe Response template + * @hw: pointer obtained from ieee80211_alloc_hw(). + * @vif: &struct ieee80211_vif pointer from the add_interface callback. + * + * Creates a Probe Response template which can, for example, be uploaded to + * hardware. The destination address should be set by the caller. + * + * Can only be called in AP mode. + */ +struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); + +/** * ieee80211_pspoll_get - retrieve a PS Poll template * @hw: pointer obtained from ieee80211_alloc_hw(). * @vif: &struct ieee80211_vif pointer from the add_interface callback. diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 192f213..c2416fb 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -491,6 +491,31 @@ static void ieee80211_config_ap_ssid(struct ieee80211_sub_if_data *sdata, (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); } +static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, + u8 *resp, size_t resp_len) +{ + struct sk_buff *new, *old; + + if (!resp || !resp_len) + return -EINVAL; + + old = sdata->u.ap.probe_resp; + + new = dev_alloc_skb(resp_len); + if (!new) + return -ENOMEM; + + memcpy(skb_put(new, resp_len), resp, resp_len); + + rcu_assign_pointer(sdata->u.ap.probe_resp, new); + synchronize_rcu(); + + if (old) + dev_kfree_skb(old); + + return 0; +} + /* * This handles both adding a beacon and setting new beacon info */ @@ -501,6 +526,7 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, int new_head_len, new_tail_len; int size; int err = -EINVAL; + u32 changed = 0; old = rtnl_dereference(sdata->u.ap.beacon); @@ -584,11 +610,17 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, kfree(old); + err = ieee80211_set_probe_resp(sdata, params->probe_resp, + params->probe_resp_len); + if (!err) + changed |= BSS_CHANGED_AP_PROBE_RESP; + ieee80211_config_ap_ssid(sdata, params); + changed |= BSS_CHANGED_BEACON_ENABLED | + BSS_CHANGED_BEACON | + BSS_CHANGED_SSID; - ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | - BSS_CHANGED_BEACON | - BSS_CHANGED_SSID); + ieee80211_bss_info_change_notify(sdata, changed); return 0; } diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 873d681..068cc92 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -232,6 +232,7 @@ struct beacon_data { struct ieee80211_if_ap { struct beacon_data __rcu *beacon; + struct sk_buff __rcu *probe_resp; struct list_head vlans; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 7b0c25b..12a6d4b 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -462,15 +462,19 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, struct ieee80211_sub_if_data *vlan, *tmpsdata; struct beacon_data *old_beacon = rtnl_dereference(sdata->u.ap.beacon); + struct sk_buff *old_probe_resp = + rtnl_dereference(sdata->u.ap.probe_resp); /* sdata_running will return false, so this will disable */ ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); - /* remove beacon */ + /* remove beacon and probe response */ RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); + RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL); synchronize_rcu(); kfree(old_beacon); + kfree(old_probe_resp); /* down all dependent devices, that is VLANs */ list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index ab6cb56..2b413d3 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2415,6 +2415,37 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, } EXPORT_SYMBOL(ieee80211_beacon_get_tim); +struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct ieee80211_if_ap *ap = NULL; + struct sk_buff *presp = NULL, *skb = NULL; + struct ieee80211_hdr *hdr; + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); + + if (sdata->vif.type != NL80211_IFTYPE_AP) + return NULL; + + rcu_read_lock(); + + ap = &sdata->u.ap; + presp = rcu_dereference(ap->probe_resp); + if (!presp) + goto out; + + skb = skb_copy(presp, GFP_ATOMIC); + if (!skb) + goto out; + + hdr = (struct ieee80211_hdr *) skb->data; + memset(hdr->addr1, 0, sizeof(hdr->addr1)); + +out: + rcu_read_unlock(); + return skb; +} +EXPORT_SYMBOL(ieee80211_proberesp_get); + struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 6ed0aa4..4cf25b0 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1071,7 +1071,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) changed |= BSS_CHANGED_IBSS; /* fall through */ case NL80211_IFTYPE_AP: - changed |= BSS_CHANGED_SSID; + changed |= BSS_CHANGED_SSID | + BSS_CHANGED_AP_PROBE_RESP; /* fall through */ case NL80211_IFTYPE_MESH_POINT: changed |= BSS_CHANGED_BEACON | -- cgit v0.10.2 From 8915f980c1b051b4ddc7d15e027a5896611e4029 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Thu, 10 Nov 2011 15:14:57 +0530 Subject: ath9k_hw: Fix tx power settings for AR9003 Retriving tx power for 2x2 and 3x3 chainmask is not handled properly. While calculating tx power for 2x2, 3 dBm was reduced and for 3x3, 5 dBm was reduced which should be added back when retriving. Cc: Paul Stewart Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index ee9c09b..a93bd63 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c @@ -5059,6 +5059,8 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, regulatory->max_power_level = targetPowerValT2[i]; } + ath9k_hw_update_regulatory_maxpower(ah); + if (test) return; -- cgit v0.10.2 From 868a5f719d730866564d9bd73a8f4a8d89bdc71a Mon Sep 17 00:00:00 2001 From: Patrick Kelle Date: Thu, 10 Nov 2011 15:13:11 +0100 Subject: minstrel: Remove unused function parameter in calc_rate_durations() Signed-off-by: Patrick Kelle Signed-off-by: John W. Linville diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c index 58a8955..b39dda5 100644 --- a/net/mac80211/rc80211_minstrel.c +++ b/net/mac80211/rc80211_minstrel.c @@ -334,8 +334,8 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, static void -calc_rate_durations(struct minstrel_sta_info *mi, struct ieee80211_local *local, - struct minstrel_rate *d, struct ieee80211_rate *rate) +calc_rate_durations(struct ieee80211_local *local, struct minstrel_rate *d, + struct ieee80211_rate *rate) { int erp = !!(rate->flags & IEEE80211_RATE_ERP_G); @@ -402,8 +402,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, mr->rix = i; mr->bitrate = sband->bitrates[i].bitrate / 5; - calc_rate_durations(mi, local, mr, - &sband->bitrates[i]); + calc_rate_durations(local, mr, &sband->bitrates[i]); /* calculate maximum number of retransmissions before * fallback (based on maximum segment size) */ -- cgit v0.10.2 From 79d3eef89190ee0a7ee585e3949873241bc382e3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 10 Nov 2011 06:55:01 -0800 Subject: iwlagn: add P2P NoA to probe responses Whether to use NoA or not is entire controlled by the uCode right now, and it also adds the attribute to beacons. We do need to add it to probe responses in the driver though. Keep track of the NoA notification from the uCode and add the data to probe responses when such are transmitted. Use RCU to manage the lifetime. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 5af9e62..f0d6d94 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1032,6 +1032,50 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv, return 0; } +static int iwlagn_rx_noa_notification(struct iwl_priv *priv, + struct iwl_rx_mem_buffer *rxb, + struct iwl_device_cmd *cmd) +{ + struct iwl_wipan_noa_data *new_data, *old_data; + struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->u.raw; + + /* no condition -- we're in softirq */ + old_data = rcu_dereference_protected(priv->noa_data, true); + + if (noa_notif->noa_active) { + u32 len = le16_to_cpu(noa_notif->noa_attribute.length); + u32 copylen = len; + + /* EID, len, OUI, subtype */ + len += 1 + 1 + 3 + 1; + /* P2P id, P2P length */ + len += 1 + 2; + copylen += 1 + 2; + + new_data = kmalloc(sizeof(*new_data) + len, GFP_ATOMIC); + if (new_data) { + new_data->length = len; + new_data->data[0] = WLAN_EID_VENDOR_SPECIFIC; + new_data->data[1] = len - 2; /* not counting EID, len */ + new_data->data[2] = (WLAN_OUI_WFA >> 16) & 0xff; + new_data->data[3] = (WLAN_OUI_WFA >> 8) & 0xff; + new_data->data[4] = (WLAN_OUI_WFA >> 0) & 0xff; + new_data->data[5] = WLAN_OUI_TYPE_WFA_P2P; + memcpy(&new_data->data[6], &noa_notif->noa_attribute, + copylen); + } + } else + new_data = NULL; + + rcu_assign_pointer(priv->noa_data, new_data); + + if (old_data) + kfree_rcu(old_data, rcu_head); + + return 0; +} + /** * iwl_setup_rx_handlers - Initialize Rx handler callbacks * @@ -1055,6 +1099,8 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv) handlers[BEACON_NOTIFICATION] = iwlagn_rx_beacon_notif; handlers[REPLY_ADD_STA] = iwl_add_sta_callback; + handlers[REPLY_WIPAN_NOA_NOTIFICATION] = iwlagn_rx_noa_notification; + /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 35a6b71..014b98a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -283,6 +283,19 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); #endif + if (unlikely(ieee80211_is_probe_resp(fc))) { + struct iwl_wipan_noa_data *noa_data = + rcu_dereference(priv->noa_data); + + if (noa_data && + pskb_expand_head(skb, 0, noa_data->length, + GFP_ATOMIC) == 0) { + memcpy(skb_put(skb, noa_data->length), + noa_data->data, noa_data->length); + hdr = (struct ieee80211_hdr *)skb->data; + } + } + hdr_len = ieee80211_hdrlen(fc); /* For management frames use broadcast id to do not break aggregation */ diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 9d463cf..3c0f4e6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -3069,6 +3069,7 @@ static void iwl_uninit_drv(struct iwl_priv *priv) kmem_cache_destroy(priv->tx_cmd_pool); kfree(priv->scan_cmd); kfree(priv->beacon_cmd); + kfree(rcu_dereference_raw(priv->noa_data)); #ifdef CONFIG_IWLWIFI_DEBUGFS kfree(priv->wowlan_sram); #endif diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 6c00a44..ef8620b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -824,6 +824,12 @@ struct iwl_testmode_trace { }; #endif +struct iwl_wipan_noa_data { + struct rcu_head rcu_head; + u32 length; + u8 data[]; +}; + struct iwl_priv { /*data shared among all the driver's layers */ @@ -883,6 +889,8 @@ struct iwl_priv { /* init calibration results */ struct iwl_calib_result calib_results[IWL_CALIB_MAX]; + struct iwl_wipan_noa_data __rcu *noa_data; + /* Scan related variables */ unsigned long scan_start; unsigned long scan_start_tsf; -- cgit v0.10.2 From b36b110c577a12157112faa1ec41b12924232af4 Mon Sep 17 00:00:00 2001 From: Todd Previte Date: Thu, 10 Nov 2011 06:55:02 -0800 Subject: iwlwifi: Suppress noisy syslog messages when RF_KILL switch engaged When a station is associated with an AP and the RF_KILL switch is engaged, numerous error messages were sent to the system log. The error messages were the result of the failure(s) of the various submodules to perform their tasks after the radios were disabled. To resolve this situation, the messages were modified to use a new macro, IWL_DEBUG_QUIET_RFKILL. This macro allows for the RF_KILL error messages to be sent to the log provided that IWL_DEBUG is true and IWL_DL_RADIO is '1'. For all other cases, the error messages resulting from an RFKILL event will not be sent to the system log. Messages logged because of an RFKILL will be tagged with the prefix '(RFKILL)' to clarify the cause of the error. Signed-off-by: Todd Previte Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 58a381c..4c52bee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -45,7 +45,8 @@ static int iwlagn_disable_bss(struct iwl_priv *priv, send->filter_flags = old_filter; if (ret) - IWL_ERR(priv, "Error clearing ASSOC_MSK on BSS (%d)\n", ret); + IWL_DEBUG_QUIET_RFKILL(priv, + "Error clearing ASSOC_MSK on BSS (%d)\n", ret); return ret; } @@ -124,7 +125,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv, sizeof(struct iwl_qosparam_cmd), &ctx->qos_data.def_qos_parm); if (ret) - IWL_ERR(priv, "Failed to update QoS\n"); + IWL_DEBUG_QUIET_RFKILL(priv, "Failed to update QoS\n"); } static int iwlagn_update_beacon(struct iwl_priv *priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index ed62836..9306768 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -840,7 +840,7 @@ int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, sta->addr); ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); if (ret) - IWL_ERR(priv, "Error removing station %pM\n", + IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", sta->addr); mutex_unlock(&priv->shrd->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 69a77e2..1dddf9b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -70,10 +70,25 @@ do { \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) +#define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ +do { \ + if (!iwl_is_rfkill(p->shrd)) \ + dev_printk(KERN_ERR, bus(p)->dev, "%c %s " fmt, \ + (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ + else if (iwl_get_debug_level(p->shrd) & IWL_DL_RADIO) \ + dev_printk(KERN_ERR, bus(p)->dev, "(RFKILL) %c %s " fmt, \ + (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ +} while (0) + #else #define IWL_DEBUG(m, level, fmt, args...) #define IWL_DEBUG_LIMIT(m, level, fmt, args...) #define iwl_print_hex_dump(m, level, p, len) +#define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ +do { \ + if (!iwl_is_rfkill(p->shrd)) \ + IWL_ERR(p, fmt, ##args); \ +} while (0) #endif /* CONFIG_IWLWIFI_DEBUG */ #ifdef CONFIG_IWLWIFI_DEBUGFS diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 4a0c953..461e1ae 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -982,7 +982,8 @@ static int iwl_send_cmd_async(struct iwl_trans *trans, struct iwl_host_cmd *cmd) ret = iwl_enqueue_hcmd(trans, cmd); if (ret < 0) { - IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", + IWL_DEBUG_QUIET_RFKILL(trans, + "Error sending %s: enqueue_hcmd failed: %d\n", get_cmd_string(cmd->id), ret); return ret; } @@ -1008,7 +1009,8 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) if (cmd_idx < 0) { ret = cmd_idx; clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); - IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", + IWL_DEBUG_QUIET_RFKILL(trans, + "Error sending %s: enqueue_hcmd failed: %d\n", get_cmd_string(cmd->id), ret); return ret; } @@ -1022,12 +1024,12 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) &trans_pcie->txq[trans->shrd->cmd_queue]; struct iwl_queue *q = &txq->q; - IWL_ERR(trans, + IWL_DEBUG_QUIET_RFKILL(trans, "Error sending %s: time out after %dms.\n", get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - IWL_ERR(trans, + IWL_DEBUG_QUIET_RFKILL(trans, "Current CMD queue read_ptr %d write_ptr %d\n", q->read_ptr, q->write_ptr); -- cgit v0.10.2 From 75a56eccb01fcc3c1ae8000130f3c9b3c8ec68d9 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:03 -0800 Subject: iwlwifi: two more SKUs for 6x05 series Add two more SKUs for 6x05 series of device. First SKU has low 5GHz channels actives, the other SKU has high 5GHz channels actives. Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 19cc6a8..9ecfbd7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -255,6 +255,8 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { {IWL_PCI_DEVICE(0x0082, 0xC020, iwl6005_2agn_sff_cfg)}, {IWL_PCI_DEVICE(0x0085, 0xC220, iwl6005_2agn_sff_cfg)}, {IWL_PCI_DEVICE(0x0082, 0x1341, iwl6005_2agn_d_cfg)}, + {IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_cfg)},/* low 5GHz active */ + {IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_cfg)},/* high 5GHz active */ /* 6x30 Series */ {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, -- cgit v0.10.2 From b2ccccdca46273c7b321ecf5041c362cd950da20 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:04 -0800 Subject: iwlagn: check for SMPS mode Check and report WARN only when its invalid Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 1a52ed2..6465983 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -827,6 +827,7 @@ static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) case IEEE80211_SMPS_STATIC: case IEEE80211_SMPS_DYNAMIC: return IWL_NUM_IDLE_CHAINS_SINGLE; + case IEEE80211_SMPS_AUTOMATIC: case IEEE80211_SMPS_OFF: return active_cnt; default: diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 4c52bee..8e45fba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -542,6 +542,9 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&priv->shrd->mutex); + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + goto out; + if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) { IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); goto out; -- cgit v0.10.2 From aed0fd4acd9b1a4fa042ea65f5de697996f6ac7f Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 10 Nov 2011 06:55:05 -0800 Subject: iwlagn: fix NULL ptr deref when reprogramming sta w/o LQ Reinette reports a crash in iwl_reprogram_ap_sta(). The debugging shows: b1 16 mov $0x16,%cl *f3 a5 rep movsl %ds <-- trapping instruction:(%rsi),%es:(%rdi) which is a memcpy of 22 (0x16) words (movsl). this points to "priv->stations[sta_id].lq" being NULL since that is the memcpy() of that size here. The only way I see for this to happen is if we try to do some RXON reprogramming while connecting to an AP, after tx_sync() but before full setup, but that seems like something that might very well happen. Fix this by checking if the LQ is present and only then reprogramming it. Reported-by: Reinette Chatre Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 9306768..1b112df 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -647,7 +647,7 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) int ret; struct iwl_addsta_cmd sta_cmd; struct iwl_link_quality_cmd lq; - bool active; + bool active, have_lq = false; spin_lock_irqsave(&priv->shrd->sta_lock, flags); if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { @@ -657,7 +657,10 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd)); sta_cmd.mode = 0; - memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq)); + if (priv->stations[sta_id].lq) { + memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq)); + have_lq = true; + } active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE; priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; @@ -679,7 +682,8 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) if (ret) IWL_ERR(priv, "failed to re-add STA %pM (%d)\n", priv->stations[sta_id].sta.sta.addr, ret); - iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); + if (have_lq) + iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); } int iwl_get_free_ucode_key_offset(struct iwl_priv *priv) -- cgit v0.10.2 From b6cb406a023184733bffc7762a75a2e204fff6b9 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:06 -0800 Subject: iwlwifi: remove un-supported SKUs BG only SKUs are no longer supported by 2000 and 1x5 series. Remove it Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 7943197..b319357 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -270,11 +270,6 @@ struct iwl_cfg iwl2000_2bgn_cfg = { .ht_params = &iwl2000_ht_params, }; -struct iwl_cfg iwl2000_2bg_cfg = { - .name = "2000 Series 2x2 BG", - IWL_DEVICE_2000, -}; - struct iwl_cfg iwl2000_2bgn_d_cfg = { .name = "2000D Series 2x2 BGN", IWL_DEVICE_2000, @@ -304,11 +299,6 @@ struct iwl_cfg iwl2030_2bgn_cfg = { .ht_params = &iwl2000_ht_params, }; -struct iwl_cfg iwl2030_2bg_cfg = { - .name = "2000 Series 2x2 BG/BT", - IWL_DEVICE_2030, -}; - #define IWL_DEVICE_105 \ .fw_name_pre = IWL105_FW_PRE, \ .ucode_api_max = IWL105_UCODE_API_MAX, \ @@ -326,11 +316,6 @@ struct iwl_cfg iwl2030_2bg_cfg = { .rx_with_siso_diversity = true, \ .iq_invert = true \ -struct iwl_cfg iwl105_bg_cfg = { - .name = "105 Series 1x1 BG", - IWL_DEVICE_105, -}; - struct iwl_cfg iwl105_bgn_cfg = { .name = "105 Series 1x1 BGN", IWL_DEVICE_105, @@ -361,11 +346,6 @@ struct iwl_cfg iwl105_bgn_d_cfg = { .rx_with_siso_diversity = true, \ .iq_invert = true \ -struct iwl_cfg iwl135_bg_cfg = { - .name = "135 Series 1x1 BG/BT", - IWL_DEVICE_135, -}; - struct iwl_cfg iwl135_bgn_cfg = { .name = "135 Series 1x1 BGN/BT", IWL_DEVICE_135, diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index c840c78..ee3363f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -439,16 +439,6 @@ struct iwl_cfg iwl6035_2agn_cfg = { .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6035_2abg_cfg = { - .name = "6035 Series 2x2 ABG/BT", - IWL_DEVICE_6030, -}; - -struct iwl_cfg iwl6035_2bg_cfg = { - .name = "6035 Series 2x2 BG/BT", - IWL_DEVICE_6030, -}; - struct iwl_cfg iwl1030_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN", IWL_DEVICE_6030, diff --git a/drivers/net/wireless/iwlwifi/iwl-cfg.h b/drivers/net/wireless/iwlwifi/iwl-cfg.h index 2a2dc45..e1d7825 100644 --- a/drivers/net/wireless/iwlwifi/iwl-cfg.h +++ b/drivers/net/wireless/iwlwifi/iwl-cfg.h @@ -101,17 +101,11 @@ extern struct iwl_cfg iwl100_bg_cfg; extern struct iwl_cfg iwl130_bgn_cfg; extern struct iwl_cfg iwl130_bg_cfg; extern struct iwl_cfg iwl2000_2bgn_cfg; -extern struct iwl_cfg iwl2000_2bg_cfg; extern struct iwl_cfg iwl2000_2bgn_d_cfg; extern struct iwl_cfg iwl2030_2bgn_cfg; -extern struct iwl_cfg iwl2030_2bg_cfg; extern struct iwl_cfg iwl6035_2agn_cfg; -extern struct iwl_cfg iwl6035_2abg_cfg; -extern struct iwl_cfg iwl6035_2bg_cfg; -extern struct iwl_cfg iwl105_bg_cfg; extern struct iwl_cfg iwl105_bgn_cfg; extern struct iwl_cfg iwl105_bgn_d_cfg; -extern struct iwl_cfg iwl135_bg_cfg; extern struct iwl_cfg iwl135_bgn_cfg; #endif /* __iwl_pci_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 9ecfbd7..86d6a23 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -326,46 +326,28 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { {IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)}, {IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)}, {IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0890, 0x4026, iwl2000_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0891, 0x4226, iwl2000_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0890, 0x4426, iwl2000_2bg_cfg)}, {IWL_PCI_DEVICE(0x0890, 0x4822, iwl2000_2bgn_d_cfg)}, /* 2x30 Series */ {IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)}, {IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)}, {IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0887, 0x4066, iwl2030_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0888, 0x4266, iwl2030_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0887, 0x4466, iwl2030_2bg_cfg)}, /* 6x35 Series */ {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4064, iwl6035_2abg_cfg)}, - {IWL_PCI_DEVICE(0x088F, 0x4264, iwl6035_2abg_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4464, iwl6035_2abg_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4066, iwl6035_2bg_cfg)}, - {IWL_PCI_DEVICE(0x088F, 0x4266, iwl6035_2bg_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4466, iwl6035_2bg_cfg)}, /* 105 Series */ {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, {IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)}, {IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0894, 0x0026, iwl105_bg_cfg)}, - {IWL_PCI_DEVICE(0x0895, 0x0226, iwl105_bg_cfg)}, - {IWL_PCI_DEVICE(0x0894, 0x0426, iwl105_bg_cfg)}, {IWL_PCI_DEVICE(0x0894, 0x0822, iwl105_bgn_d_cfg)}, /* 135 Series */ {IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)}, {IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)}, {IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0892, 0x0066, iwl135_bg_cfg)}, - {IWL_PCI_DEVICE(0x0893, 0x0266, iwl135_bg_cfg)}, - {IWL_PCI_DEVICE(0x0892, 0x0466, iwl135_bg_cfg)}, {0} }; -- cgit v0.10.2 From 5703ddb01328c8ee3fa315273ea3b29f6524fb38 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Thu, 10 Nov 2011 06:55:07 -0800 Subject: iwlagn: move ucode_write_complete from priv to trans structure ucode_write_complete is used for ucode loading. Move it as part of restructuring work out of the priv structure. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 8ba0dd5..502659a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c @@ -75,48 +75,49 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { /* * ucode */ -static int iwlagn_load_section(struct iwl_priv *priv, const char *name, +static int iwlagn_load_section(struct iwl_trans *trans, const char *name, struct fw_desc *image, u32 dst_addr) { + struct iwl_bus *bus = bus(trans); dma_addr_t phy_addr = image->p_addr; u32 byte_cnt = image->len; int ret; - priv->ucode_write_complete = 0; + trans->ucode_write_complete = 0; - iwl_write_direct32(bus(priv), + iwl_write_direct32(bus, FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); - iwl_write_direct32(bus(priv), + iwl_write_direct32(bus, FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); - iwl_write_direct32(bus(priv), + iwl_write_direct32(bus, FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); - iwl_write_direct32(bus(priv), + iwl_write_direct32(bus, FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), (iwl_get_dma_hi_addr(phy_addr) << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); - iwl_write_direct32(bus(priv), + iwl_write_direct32(bus, FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); - iwl_write_direct32(bus(priv), + iwl_write_direct32(bus, FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); - IWL_DEBUG_FW(priv, "%s uCode section being loaded...\n", name); - ret = wait_event_timeout(priv->shrd->wait_command_queue, - priv->ucode_write_complete, 5 * HZ); + IWL_DEBUG_FW(bus, "%s uCode section being loaded...\n", name); + ret = wait_event_timeout(trans->shrd->wait_command_queue, + trans->ucode_write_complete, 5 * HZ); if (!ret) { - IWL_ERR(priv, "Could not load the %s uCode section\n", + IWL_ERR(trans, "Could not load the %s uCode section\n", name); return -ETIMEDOUT; } @@ -129,12 +130,12 @@ static int iwlagn_load_given_ucode(struct iwl_priv *priv, { int ret = 0; - ret = iwlagn_load_section(priv, "INST", &image->code, + ret = iwlagn_load_section(trans(priv), "INST", &image->code, IWLAGN_RTC_INST_LOWER_BOUND); if (ret) return ret; - return iwlagn_load_section(priv, "DATA", &image->data, + return iwlagn_load_section(trans(priv), "DATA", &image->data, IWLAGN_RTC_DATA_LOWER_BOUND); } diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index ef8620b..4279e01 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -920,7 +920,6 @@ struct iwl_priv { struct fw_img ucode_wowlan; enum iwlagn_ucode_type ucode_type; - u8 ucode_write_complete; /* the image write is complete */ char firmware_name[25]; struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 374c68c..ee126f8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1108,7 +1108,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) isr_stats->tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ - priv(trans)->ucode_write_complete = 1; + trans->ucode_write_complete = 1; wake_up(&trans->shrd->wait_command_queue); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index c592312..34b817f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -212,12 +212,15 @@ struct iwl_trans_ops { * @ops - pointer to iwl_trans_ops * @shrd - pointer to iwl_shared which holds shared data from the upper layer * @hcmd_lock: protects HCMD + * @ucode_write_complete: indicates that the ucode has been copied. */ struct iwl_trans { const struct iwl_trans_ops *ops; struct iwl_shared *shrd; spinlock_t hcmd_lock; + u8 ucode_write_complete; /* the image write is complete */ + /* pointer to trans specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ char trans_specific[0] __attribute__((__aligned__(sizeof(void *)))); -- cgit v0.10.2 From 8929c24bf2ef4fb983ff86478116092080f8773f Mon Sep 17 00:00:00 2001 From: Don Fry Date: Thu, 10 Nov 2011 06:55:08 -0800 Subject: iwlagn: remove knowledge of ucode image location from upper layers The upper layers of the driver do not need to know where the ucode is stored. It already passes in an enum of which ucode to load. Let the lower layer routines select the ucode to load. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 502659a..1ad4af4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c @@ -125,6 +125,22 @@ static int iwlagn_load_section(struct iwl_trans *trans, const char *name, return 0; } +static inline struct fw_img *iwl_get_ucode_image(struct iwl_priv *priv, + enum iwlagn_ucode_type ucode_type) +{ + switch (ucode_type) { + case IWL_UCODE_INIT: + return &priv->ucode_init; + case IWL_UCODE_WOWLAN: + return &priv->ucode_wowlan; + case IWL_UCODE_REGULAR: + return &priv->ucode_rt; + case IWL_UCODE_NONE: + break; + } + return NULL; +} + static int iwlagn_load_given_ucode(struct iwl_priv *priv, struct fw_img *image) { @@ -520,13 +536,18 @@ static void iwlagn_alive_fn(struct iwl_priv *priv, #define UCODE_CALIB_TIMEOUT (2*HZ) int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, - struct fw_img *image, enum iwlagn_ucode_type ucode_type) { struct iwl_notification_wait alive_wait; struct iwlagn_alive_data alive_data; int ret; enum iwlagn_ucode_type old_type; + struct fw_img *image = iwl_get_ucode_image(priv, ucode_type); + + if (!image) { + IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); + return -EINVAL; + } ret = iwl_trans_start_device(trans(priv)); if (ret) @@ -609,8 +630,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) NULL, NULL); /* Will also start the device */ - ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, - IWL_UCODE_INIT); + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); if (ret) goto error; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 3c0f4e6..b6fa361 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1452,9 +1452,7 @@ static int __iwl_up(struct iwl_priv *priv) goto error; } - ret = iwlagn_load_ucode_wait_alive(priv, - &priv->ucode_rt, - IWL_UCODE_REGULAR); + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); if (ret) { IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); goto error; @@ -2102,8 +2100,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, priv->shrd->wowlan = true; - ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_wowlan, - IWL_UCODE_WOWLAN); + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); if (ret) goto error; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 5b936ec..adefab5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -95,7 +95,6 @@ int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); void iwlagn_send_prio_tbl(struct iwl_priv *priv); int iwlagn_run_init_ucode(struct iwl_priv *priv); int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, - struct fw_img *image, enum iwlagn_ucode_type ucode_type); /* lib */ diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 5e50d88..e3882d0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -396,8 +396,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) break; case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: - status = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, - IWL_UCODE_INIT); + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); if (status) IWL_DEBUG_INFO(priv, "Error loading init ucode: %d\n", status); @@ -409,9 +408,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) break; case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: - status = iwlagn_load_ucode_wait_alive(priv, - &priv->ucode_rt, - IWL_UCODE_REGULAR); + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); if (status) { IWL_DEBUG_INFO(priv, "Error loading runtime ucode: %d\n", status); -- cgit v0.10.2 From baa0005663d6b4aa48ab5c632d74b459fcfeb086 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Thu, 10 Nov 2011 06:55:09 -0800 Subject: iwlagn: push knowledge of ucode image lower down Move the knowledge of the ucode image to lower level routines. Also do not pass the iwl_priv structure lower than it needs to be. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 1ad4af4..9144ef5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c @@ -142,9 +142,16 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_priv *priv, } static int iwlagn_load_given_ucode(struct iwl_priv *priv, - struct fw_img *image) + enum iwlagn_ucode_type ucode_type) { int ret = 0; + struct fw_img *image = iwl_get_ucode_image(priv, ucode_type); + + + if (!image) { + IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); + return -EINVAL; + } ret = iwlagn_load_section(trans(priv), "INST", &image->code, IWLAGN_RTC_INST_LOWER_BOUND); @@ -435,7 +442,7 @@ static int iwlagn_alive_notify(struct iwl_priv *priv) * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ -static int iwl_verify_inst_sparse(struct iwl_priv *priv, +static int iwl_verify_inst_sparse(struct iwl_bus *bus, struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; @@ -443,15 +450,15 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv, u32 val; u32 i; - IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IWL_DL_IO is set */ - iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, i + IWLAGN_RTC_INST_LOWER_BOUND); - val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) return -EIO; } @@ -459,7 +466,7 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv, return 0; } -static void iwl_print_mismatch_inst(struct iwl_priv *priv, +static void iwl_print_mismatch_inst(struct iwl_bus *bus, struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; @@ -468,18 +475,18 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, u32 offs; int errors = 0; - IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); - iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, IWLAGN_RTC_INST_LOWER_BOUND); for (offs = 0; offs < len && errors < 20; offs += sizeof(u32), image++) { /* read data comes through single port, auto-incr addr */ - val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "uCode INST section at " + IWL_ERR(bus, "uCode INST section at " "offset 0x%x, is 0x%x, s/b 0x%x\n", offs, val, le32_to_cpu(*image)); errors++; @@ -491,16 +498,24 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, * iwl_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int iwl_verify_ucode(struct iwl_priv *priv, struct fw_img *img) +static int iwl_verify_ucode(struct iwl_priv *priv, + enum iwlagn_ucode_type ucode_type) { - if (!iwl_verify_inst_sparse(priv, &img->code)) { + struct fw_img *img = iwl_get_ucode_image(priv, ucode_type); + + if (!img) { + IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); + return -EINVAL; + } + + if (!iwl_verify_inst_sparse(bus(priv), &img->code)) { IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); return 0; } IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); - iwl_print_mismatch_inst(priv, &img->code); + iwl_print_mismatch_inst(bus(priv), &img->code); return -EIO; } @@ -542,12 +557,6 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, struct iwlagn_alive_data alive_data; int ret; enum iwlagn_ucode_type old_type; - struct fw_img *image = iwl_get_ucode_image(priv, ucode_type); - - if (!image) { - IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); - return -EINVAL; - } ret = iwl_trans_start_device(trans(priv)); if (ret) @@ -559,7 +568,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, old_type = priv->ucode_type; priv->ucode_type = ucode_type; - ret = iwlagn_load_given_ucode(priv, image); + ret = iwlagn_load_given_ucode(priv, ucode_type); if (ret) { priv->ucode_type = old_type; iwlagn_remove_notification(priv, &alive_wait); @@ -590,7 +599,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, * skip it for WoWLAN. */ if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(priv, image); + ret = iwl_verify_ucode(priv, ucode_type); if (ret) { priv->ucode_type = old_type; return ret; -- cgit v0.10.2 From de7f5f92dbda0652dcb850fd02762e628556f645 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Thu, 10 Nov 2011 06:55:10 -0800 Subject: iwlagn: move ucode files out of the iwl_priv structure Relocate the ucode files and update relevant code. More code refactoring. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 9144ef5..9ec315b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "iwl-dev.h" #include "iwl-core.h" @@ -72,6 +73,52 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} }; +/****************************************************************************** + * + * uCode download functions + * + ******************************************************************************/ + +static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) +{ + if (desc->v_addr) + dma_free_coherent(bus->dev, desc->len, + desc->v_addr, desc->p_addr); + desc->v_addr = NULL; + desc->len = 0; +} + +static void iwl_free_fw_img(struct iwl_bus *bus, struct fw_img *img) +{ + iwl_free_fw_desc(bus, &img->code); + iwl_free_fw_desc(bus, &img->data); +} + +void iwl_dealloc_ucode(struct iwl_trans *trans) +{ + iwl_free_fw_img(bus(trans), &trans->ucode_rt); + iwl_free_fw_img(bus(trans), &trans->ucode_init); + iwl_free_fw_img(bus(trans), &trans->ucode_wowlan); +} + +int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, + const void *data, size_t len) +{ + if (!len) { + desc->v_addr = NULL; + return -EINVAL; + } + + desc->v_addr = dma_alloc_coherent(bus->dev, len, + &desc->p_addr, GFP_KERNEL); + if (!desc->v_addr) + return -ENOMEM; + + desc->len = len; + memcpy(desc->v_addr, data, len); + return 0; +} + /* * ucode */ @@ -125,40 +172,41 @@ static int iwlagn_load_section(struct iwl_trans *trans, const char *name, return 0; } -static inline struct fw_img *iwl_get_ucode_image(struct iwl_priv *priv, - enum iwlagn_ucode_type ucode_type) +static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) { switch (ucode_type) { case IWL_UCODE_INIT: - return &priv->ucode_init; + return &trans->ucode_init; case IWL_UCODE_WOWLAN: - return &priv->ucode_wowlan; + return &trans->ucode_wowlan; case IWL_UCODE_REGULAR: - return &priv->ucode_rt; + return &trans->ucode_rt; case IWL_UCODE_NONE: break; } return NULL; } -static int iwlagn_load_given_ucode(struct iwl_priv *priv, - enum iwlagn_ucode_type ucode_type) +static int iwlagn_load_given_ucode(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) { int ret = 0; - struct fw_img *image = iwl_get_ucode_image(priv, ucode_type); + struct fw_img *image = iwl_get_ucode_image(trans, ucode_type); if (!image) { - IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); + IWL_ERR(trans, "Invalid ucode requested (%d)\n", + ucode_type); return -EINVAL; } - ret = iwlagn_load_section(trans(priv), "INST", &image->code, + ret = iwlagn_load_section(trans, "INST", &image->code, IWLAGN_RTC_INST_LOWER_BOUND); if (ret) return ret; - return iwlagn_load_section(trans(priv), "DATA", &image->data, + return iwlagn_load_section(trans, "DATA", &image->data, IWLAGN_RTC_DATA_LOWER_BOUND); } @@ -498,24 +546,24 @@ static void iwl_print_mismatch_inst(struct iwl_bus *bus, * iwl_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int iwl_verify_ucode(struct iwl_priv *priv, - enum iwlagn_ucode_type ucode_type) +static int iwl_verify_ucode(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) { - struct fw_img *img = iwl_get_ucode_image(priv, ucode_type); + struct fw_img *img = iwl_get_ucode_image(trans, ucode_type); if (!img) { - IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); + IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); return -EINVAL; } - if (!iwl_verify_inst_sparse(bus(priv), &img->code)) { - IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); + if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { + IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); return 0; } - IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); + IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); - iwl_print_mismatch_inst(bus(priv), &img->code); + iwl_print_mismatch_inst(bus(trans), &img->code); return -EIO; } @@ -551,12 +599,12 @@ static void iwlagn_alive_fn(struct iwl_priv *priv, #define UCODE_CALIB_TIMEOUT (2*HZ) int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, - enum iwlagn_ucode_type ucode_type) + enum iwl_ucode_type ucode_type) { struct iwl_notification_wait alive_wait; struct iwlagn_alive_data alive_data; int ret; - enum iwlagn_ucode_type old_type; + enum iwl_ucode_type old_type; ret = iwl_trans_start_device(trans(priv)); if (ret) @@ -568,7 +616,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, old_type = priv->ucode_type; priv->ucode_type = ucode_type; - ret = iwlagn_load_given_ucode(priv, ucode_type); + ret = iwlagn_load_given_ucode(trans(priv), ucode_type); if (ret) { priv->ucode_type = old_type; iwlagn_remove_notification(priv, &alive_wait); @@ -599,7 +647,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, * skip it for WoWLAN. */ if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(priv, ucode_type); + ret = iwl_verify_ucode(trans(priv), ucode_type); if (ret) { priv->ucode_type = old_type; return ret; @@ -628,7 +676,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) lockdep_assert_held(&priv->shrd->mutex); /* No init ucode required? Curious, but maybe ok */ - if (!priv->ucode_init.code.len) + if (!trans(priv)->ucode_init.code.len) return 0; if (priv->ucode_type != IWL_UCODE_NONE) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index b6fa361..7514b17 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -452,52 +451,6 @@ static void iwl_bg_tx_flush(struct work_struct *work) iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); } -/****************************************************************************** - * - * uCode download functions - * - ******************************************************************************/ - -static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc) -{ - if (desc->v_addr) - dma_free_coherent(bus(priv)->dev, desc->len, - desc->v_addr, desc->p_addr); - desc->v_addr = NULL; - desc->len = 0; -} - -static void iwl_free_fw_img(struct iwl_priv *priv, struct fw_img *img) -{ - iwl_free_fw_desc(priv, &img->code); - iwl_free_fw_desc(priv, &img->data); -} - -static void iwl_dealloc_ucode(struct iwl_priv *priv) -{ - iwl_free_fw_img(priv, &priv->ucode_rt); - iwl_free_fw_img(priv, &priv->ucode_init); - iwl_free_fw_img(priv, &priv->ucode_wowlan); -} - -static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc, - const void *data, size_t len) -{ - if (!len) { - desc->v_addr = NULL; - return -EINVAL; - } - - desc->v_addr = dma_alloc_coherent(bus(priv)->dev, len, - &desc->p_addr, GFP_KERNEL); - if (!desc->v_addr) - return -ENOMEM; - - desc->len = len; - memcpy(desc->v_addr, data, len); - return 0; -} - static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) { int i; @@ -1040,30 +993,32 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) /* Runtime instructions and 2 copies of data: * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ - if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.code, + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.code, pieces.inst, pieces.inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.data, + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.data, pieces.data, pieces.data_size)) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(priv, &priv->ucode_init.code, + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.code, pieces.init, pieces.init_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(priv, &priv->ucode_init.data, + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.data, pieces.init_data, pieces.init_data_size)) goto err_pci_alloc; } /* WoWLAN instructions and data */ if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.code, + if (iwl_alloc_fw_desc(bus(priv), + &trans(priv)->ucode_wowlan.code, pieces.wowlan_inst, pieces.wowlan_inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.data, + if (iwl_alloc_fw_desc(bus(priv), + &trans(priv)->ucode_wowlan.data, pieces.wowlan_data, pieces.wowlan_data_size)) goto err_pci_alloc; @@ -1156,7 +1111,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) err_pci_alloc: IWL_ERR(priv, "failed to allocate pci memory\n"); - iwl_dealloc_ucode(priv); + iwl_dealloc_ucode(trans(priv)); out_unbind: complete(&priv->firmware_loading_complete); device_release_driver(bus(priv)->dev); @@ -1697,7 +1652,8 @@ static int iwlagn_mac_setup_register(struct iwl_priv *priv, WIPHY_FLAG_DISABLE_BEACON_HINTS | WIPHY_FLAG_IBSS_RSN; - if (priv->ucode_wowlan.code.len && device_can_wakeup(bus(priv)->dev)) { + if (trans(priv)->ucode_wowlan.code.len && + device_can_wakeup(bus(priv)->dev)) { hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT | WIPHY_WOWLAN_EAP_IDENTITY_REQ | @@ -2241,15 +2197,16 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) #ifdef CONFIG_IWLWIFI_DEBUGFS if (ret == 0) { + struct iwl_trans *trans = trans(priv); if (!priv->wowlan_sram) priv->wowlan_sram = - kzalloc(priv->ucode_wowlan.data.len, + kzalloc(trans->ucode_wowlan.data.len, GFP_KERNEL); if (priv->wowlan_sram) _iwl_read_targ_mem_words( bus(priv), 0x800000, priv->wowlan_sram, - priv->ucode_wowlan.data.len / 4); + trans->ucode_wowlan.data.len / 4); } #endif } @@ -3400,7 +3357,7 @@ void __devexit iwl_remove(struct iwl_priv * priv) /*This will stop the queues, move the device to low power state */ iwl_trans_stop_device(trans(priv)); - iwl_dealloc_ucode(priv); + iwl_dealloc_ucode(trans(priv)); iwl_eeprom_free(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index adefab5..7cc5cd8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -95,7 +95,7 @@ int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); void iwlagn_send_prio_tbl(struct iwl_priv *priv); int iwlagn_run_init_ucode(struct iwl_priv *priv); int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, - enum iwlagn_ucode_type ucode_type); + enum iwl_ucode_type ucode_type); /* lib */ int iwlagn_send_tx_power(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index a1670e3..42871ba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -236,9 +236,9 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { priv->dbgfs_sram_offset = 0x800000; if (priv->ucode_type == IWL_UCODE_INIT) - priv->dbgfs_sram_len = priv->ucode_init.data.len; + priv->dbgfs_sram_len = trans(priv)->ucode_init.data.len; else - priv->dbgfs_sram_len = priv->ucode_rt.data.len; + priv->dbgfs_sram_len = trans(priv)->ucode_rt.data.len; } len = priv->dbgfs_sram_len; @@ -341,7 +341,7 @@ static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, priv->wowlan_sram, - priv->ucode_wowlan.data.len); + trans(priv)->ucode_wowlan.data.len); } static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 4279e01..2c68b9b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -230,17 +230,6 @@ struct iwl_vif_priv { u8 ibss_bssid_sta_id; }; -/* one for each uCode image (inst/data, boot/init/runtime) */ -struct fw_desc { - void *v_addr; /* access by driver */ - dma_addr_t p_addr; /* access by card's busmaster DMA */ - u32 len; /* bytes */ -}; - -struct fw_img { - struct fw_desc code, data; -}; - /* v1/v2 uCode file layout */ struct iwl_ucode_header { __le32 ver; /* major/minor/API/serial */ @@ -805,13 +794,6 @@ enum iwl_scan_type { IWL_SCAN_ROC, }; -enum iwlagn_ucode_type { - IWL_UCODE_NONE, - IWL_UCODE_REGULAR, - IWL_UCODE_INIT, - IWL_UCODE_WOWLAN, -}; - #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL struct iwl_testmode_trace { u32 buff_size; @@ -915,11 +897,7 @@ struct iwl_priv { u32 ucode_ver; /* version of ucode, copy of iwl_ucode.ver */ - struct fw_img ucode_rt; - struct fw_img ucode_init; - struct fw_img ucode_wowlan; - - enum iwlagn_ucode_type ucode_type; + enum iwl_ucode_type ucode_type; char firmware_name[25]; struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 34b817f..1ecdd1c2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -207,12 +207,34 @@ struct iwl_trans_ops { #endif }; +/* one for each uCode image (inst/data, boot/init/runtime) */ +struct fw_desc { + dma_addr_t p_addr; /* hardware address */ + void *v_addr; /* software address */ + u32 len; /* size in bytes */ +}; + +struct fw_img { + struct fw_desc code; /* firmware code image */ + struct fw_desc data; /* firmware data image */ +}; + +enum iwl_ucode_type { + IWL_UCODE_NONE, + IWL_UCODE_REGULAR, + IWL_UCODE_INIT, + IWL_UCODE_WOWLAN, +}; + /** * struct iwl_trans - transport common data * @ops - pointer to iwl_trans_ops * @shrd - pointer to iwl_shared which holds shared data from the upper layer * @hcmd_lock: protects HCMD * @ucode_write_complete: indicates that the ucode has been copied. + * @ucode_rt: run time ucode image + * @ucode_init: init ucode image + * @ucode_wowlan: wake on wireless ucode image (optional) */ struct iwl_trans { const struct iwl_trans_ops *ops; @@ -220,6 +242,9 @@ struct iwl_trans { spinlock_t hcmd_lock; u8 ucode_write_complete; /* the image write is complete */ + struct fw_img ucode_rt; + struct fw_img ucode_init; + struct fw_img ucode_wowlan; /* pointer to trans specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ @@ -351,4 +376,8 @@ static inline int iwl_trans_resume(struct iwl_trans *trans) ******************************************************/ extern const struct iwl_trans_ops trans_ops_pcie; +int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, + const void *data, size_t len); +void iwl_dealloc_ucode(struct iwl_trans *trans); + #endif /* __iwl_trans_h__ */ -- cgit v0.10.2 From 7335613ae27ae148fde720caccbfbbd9afa7465d Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:11 -0800 Subject: iwlwifi: move all mac80211 related functions to one place There are many mac80211 callback functions in the driver, as current implementation, those functions are scatter everywhere which is very difficult to find and maintain, move all the mac80211 callback functions into single file. There should be no functional changes Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index c73e5ed..a7ab280 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -1,6 +1,6 @@ # WIFI obj-$(CONFIG_IWLWIFI) += iwlwifi.o -iwlwifi-objs := iwl-agn.o iwl-agn-rs.o +iwlwifi-objs := iwl-agn.o iwl-agn-rs.o iwl-mac80211.o iwlwifi-objs += iwl-agn-ucode.o iwl-agn-tx.o iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 7514b17..e235e84 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -508,16 +508,7 @@ static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); } - -struct iwlagn_ucode_capabilities { - u32 max_probe_length; - u32 standard_phy_calibration_size; - u32 flags; -}; - static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); -static int iwlagn_mac_setup_register(struct iwl_priv *priv, - struct iwlagn_ucode_capabilities *capa); #define UCODE_EXPERIMENTAL_INDEX 100 #define UCODE_EXPERIMENTAL_TAG "exp" @@ -1307,7 +1298,7 @@ int iwl_alive_start(struct iwl_priv *priv) static void iwl_cancel_deferred_work(struct iwl_priv *priv); -static void __iwl_down(struct iwl_priv *priv) +void __iwl_down(struct iwl_priv *priv) { int exit_pending; @@ -1370,7 +1361,7 @@ static void __iwl_down(struct iwl_priv *priv) priv->beacon_skb = NULL; } -static void iwl_down(struct iwl_priv *priv) +void iwl_down(struct iwl_priv *priv) { mutex_lock(&priv->shrd->mutex); __iwl_down(priv); @@ -1379,55 +1370,6 @@ static void iwl_down(struct iwl_priv *priv) iwl_cancel_deferred_work(priv); } -#define MAX_HW_RESTARTS 5 - -static int __iwl_up(struct iwl_priv *priv) -{ - struct iwl_rxon_context *ctx; - int ret; - - lockdep_assert_held(&priv->shrd->mutex); - - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { - IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); - return -EIO; - } - - for_each_context(priv, ctx) { - ret = iwlagn_alloc_bcast_station(priv, ctx); - if (ret) { - iwl_dealloc_bcast_stations(priv); - return ret; - } - } - - ret = iwlagn_run_init_ucode(priv); - if (ret) { - IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); - goto error; - } - - ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); - if (ret) { - IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); - goto error; - } - - ret = iwl_alive_start(priv); - if (ret) - goto error; - return 0; - - error: - set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); - __iwl_down(priv); - clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); - - IWL_ERR(priv, "Unable to initialize device.\n"); - return ret; -} - - /***************************************************************************** * * Workqueue callbacks @@ -1455,7 +1397,7 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work) mutex_unlock(&priv->shrd->mutex); } -static void iwlagn_prepare_restart(struct iwl_priv *priv) +void iwlagn_prepare_restart(struct iwl_priv *priv) { struct iwl_rxon_context *ctx; bool bt_full_concurrent; @@ -1512,1598 +1454,202 @@ static void iwl_bg_restart(struct work_struct *data) } } -/***************************************************************************** - * - * mac80211 entry point functions - * - *****************************************************************************/ - -static const struct ieee80211_iface_limit iwlagn_sta_ap_limits[] = { - { - .max = 1, - .types = BIT(NL80211_IFTYPE_STATION), - }, - { - .max = 1, - .types = BIT(NL80211_IFTYPE_AP), - }, -}; - -static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = { - { - .max = 2, - .types = BIT(NL80211_IFTYPE_STATION), - }, -}; - -static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = { - { - .max = 1, - .types = BIT(NL80211_IFTYPE_STATION), - }, - { - .max = 1, - .types = BIT(NL80211_IFTYPE_P2P_GO) | - BIT(NL80211_IFTYPE_AP), - }, -}; - -static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = { - { - .max = 2, - .types = BIT(NL80211_IFTYPE_STATION), - }, - { - .max = 1, - .types = BIT(NL80211_IFTYPE_P2P_CLIENT), - }, -}; -static const struct ieee80211_iface_combination -iwlagn_iface_combinations_dualmode[] = { - { .num_different_channels = 1, - .max_interfaces = 2, - .beacon_int_infra_match = true, - .limits = iwlagn_sta_ap_limits, - .n_limits = ARRAY_SIZE(iwlagn_sta_ap_limits), - }, - { .num_different_channels = 1, - .max_interfaces = 2, - .limits = iwlagn_2sta_limits, - .n_limits = ARRAY_SIZE(iwlagn_2sta_limits), - }, -}; -static const struct ieee80211_iface_combination -iwlagn_iface_combinations_p2p[] = { - { .num_different_channels = 1, - .max_interfaces = 2, - .beacon_int_infra_match = true, - .limits = iwlagn_p2p_sta_go_limits, - .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits), - }, - { .num_different_channels = 1, - .max_interfaces = 2, - .limits = iwlagn_p2p_2sta_limits, - .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits), - }, -}; -/* - * Not a mac80211 entry point function, but it fits in with all the - * other mac80211 functions grouped here. - */ -static int iwlagn_mac_setup_register(struct iwl_priv *priv, - struct iwlagn_ucode_capabilities *capa) +void iwlagn_disable_roc(struct iwl_priv *priv) { - int ret; - struct ieee80211_hw *hw = priv->hw; - struct iwl_rxon_context *ctx; - - hw->rate_control_algorithm = "iwl-agn-rs"; - - /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_AMPDU_AGGREGATION | - IEEE80211_HW_NEED_DTIM_PERIOD | - IEEE80211_HW_SPECTRUM_MGMT | - IEEE80211_HW_REPORTS_TX_ACK_STATUS; - - /* - * Including the following line will crash some AP's. This - * workaround removes the stimulus which causes the crash until - * the AP software can be fixed. - hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; - */ - - hw->flags |= IEEE80211_HW_SUPPORTS_PS | - IEEE80211_HW_SUPPORTS_DYNAMIC_PS; - - if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) - hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | - IEEE80211_HW_SUPPORTS_STATIC_SMPS; - - if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) - hw->flags |= IEEE80211_HW_MFP_CAPABLE; - - hw->sta_data_size = sizeof(struct iwl_station_priv); - hw->vif_data_size = sizeof(struct iwl_vif_priv); - - for_each_context(priv, ctx) { - hw->wiphy->interface_modes |= ctx->interface_modes; - hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; - } - - BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); - - if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) { - hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p; - hw->wiphy->n_iface_combinations = - ARRAY_SIZE(iwlagn_iface_combinations_p2p); - } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { - hw->wiphy->iface_combinations = iwlagn_iface_combinations_dualmode; - hw->wiphy->n_iface_combinations = - ARRAY_SIZE(iwlagn_iface_combinations_dualmode); - } - - hw->wiphy->max_remain_on_channel_duration = 1000; - - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS | - WIPHY_FLAG_IBSS_RSN; - - if (trans(priv)->ucode_wowlan.code.len && - device_can_wakeup(bus(priv)->dev)) { - hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | - WIPHY_WOWLAN_DISCONNECT | - WIPHY_WOWLAN_EAP_IDENTITY_REQ | - WIPHY_WOWLAN_RFKILL_RELEASE; - if (!iwlagn_mod_params.sw_crypto) - hw->wiphy->wowlan.flags |= - WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | - WIPHY_WOWLAN_GTK_REKEY_FAILURE; - - hw->wiphy->wowlan.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS; - hw->wiphy->wowlan.pattern_min_len = - IWLAGN_WOWLAN_MIN_PATTERN_LEN; - hw->wiphy->wowlan.pattern_max_len = - IWLAGN_WOWLAN_MAX_PATTERN_LEN; - } - - if (iwlagn_mod_params.power_save) - hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; - else - hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; - hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; - /* we create the 802.11 header and a zero-length SSID element */ - hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; + lockdep_assert_held(&priv->shrd->mutex); - /* Default value; 4 EDCA QOS priorities */ - hw->queues = 4; + if (!priv->hw_roc_setup) + return; - hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; + ctx->staging.dev_type = RXON_DEV_TYPE_P2P; + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &priv->bands[IEEE80211_BAND_2GHZ]; - if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &priv->bands[IEEE80211_BAND_5GHZ]; + priv->hw_roc_channel = NULL; - iwl_leds_init(priv); + memset(ctx->staging.node_addr, 0, ETH_ALEN); - ret = ieee80211_register_hw(priv->hw); - if (ret) { - IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); - return ret; - } - priv->mac80211_registered = 1; + iwlagn_commit_rxon(priv, ctx); - return 0; + ctx->is_active = false; + priv->hw_roc_setup = false; } - -static int iwlagn_mac_start(struct ieee80211_hw *hw) +static void iwlagn_disable_roc_work(struct work_struct *work) { - struct iwl_priv *priv = hw->priv; - int ret; - - IWL_DEBUG_MAC80211(priv, "enter\n"); + struct iwl_priv *priv = container_of(work, struct iwl_priv, + hw_roc_disable_work.work); - /* we should be verifying the device is ready to be opened */ mutex_lock(&priv->shrd->mutex); - ret = __iwl_up(priv); + iwlagn_disable_roc(priv); mutex_unlock(&priv->shrd->mutex); - if (ret) - return ret; - - IWL_DEBUG_INFO(priv, "Start UP work done.\n"); - - /* Now we should be done, and the READY bit should be set. */ - if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status))) - ret = -EIO; - - iwlagn_led_enable(priv); - - priv->is_open = 1; - IWL_DEBUG_MAC80211(priv, "leave\n"); - return 0; } -static void iwlagn_mac_stop(struct ieee80211_hw *hw) +/***************************************************************************** + * + * driver setup and teardown + * + *****************************************************************************/ + +static void iwl_setup_deferred_work(struct iwl_priv *priv) { - struct iwl_priv *priv = hw->priv; + priv->shrd->workqueue = create_singlethread_workqueue(DRV_NAME); - IWL_DEBUG_MAC80211(priv, "enter\n"); + init_waitqueue_head(&priv->shrd->wait_command_queue); - if (!priv->is_open) - return; + INIT_WORK(&priv->restart, iwl_bg_restart); + INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update); + INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); + INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush); + INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency); + INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config); + INIT_DELAYED_WORK(&priv->hw_roc_disable_work, + iwlagn_disable_roc_work); - priv->is_open = 0; + iwl_setup_scan_deferred_work(priv); - iwl_down(priv); + if (priv->cfg->lib->bt_setup_deferred_work) + priv->cfg->lib->bt_setup_deferred_work(priv); - flush_workqueue(priv->shrd->workqueue); + init_timer(&priv->statistics_periodic); + priv->statistics_periodic.data = (unsigned long)priv; + priv->statistics_periodic.function = iwl_bg_statistics_periodic; - /* User space software may expect getting rfkill changes - * even if interface is down */ - iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF); - iwl_enable_rfkill_int(priv); + init_timer(&priv->ucode_trace); + priv->ucode_trace.data = (unsigned long)priv; + priv->ucode_trace.function = iwl_bg_ucode_trace; - IWL_DEBUG_MAC80211(priv, "leave\n"); + init_timer(&priv->watchdog); + priv->watchdog.data = (unsigned long)priv; + priv->watchdog.function = iwl_bg_watchdog; } -#ifdef CONFIG_PM_SLEEP -static int iwlagn_send_patterns(struct iwl_priv *priv, - struct cfg80211_wowlan *wowlan) +static void iwl_cancel_deferred_work(struct iwl_priv *priv) { - struct iwlagn_wowlan_patterns_cmd *pattern_cmd; - struct iwl_host_cmd cmd = { - .id = REPLY_WOWLAN_PATTERNS, - .dataflags[0] = IWL_HCMD_DFL_NOCOPY, - .flags = CMD_SYNC, - }; - int i, err; + if (priv->cfg->lib->cancel_deferred_work) + priv->cfg->lib->cancel_deferred_work(priv); - if (!wowlan->n_patterns) - return 0; + cancel_work_sync(&priv->run_time_calib_work); + cancel_work_sync(&priv->beacon_update); - cmd.len[0] = sizeof(*pattern_cmd) + - wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); + iwl_cancel_scan_deferred_work(priv); - pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); - if (!pattern_cmd) - return -ENOMEM; + cancel_work_sync(&priv->bt_full_concurrency); + cancel_work_sync(&priv->bt_runtime_config); + cancel_delayed_work_sync(&priv->hw_roc_disable_work); - pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); + del_timer_sync(&priv->statistics_periodic); + del_timer_sync(&priv->ucode_trace); +} - for (i = 0; i < wowlan->n_patterns; i++) { - int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); +static void iwl_init_hw_rates(struct iwl_priv *priv, + struct ieee80211_rate *rates) +{ + int i; - memcpy(&pattern_cmd->patterns[i].mask, - wowlan->patterns[i].mask, mask_len); - memcpy(&pattern_cmd->patterns[i].pattern, - wowlan->patterns[i].pattern, - wowlan->patterns[i].pattern_len); - pattern_cmd->patterns[i].mask_size = mask_len; - pattern_cmd->patterns[i].pattern_size = - wowlan->patterns[i].pattern_len; + for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) { + rates[i].bitrate = iwl_rates[i].ieee * 5; + rates[i].hw_value = i; /* Rate scaling will work on indexes */ + rates[i].hw_value_short = i; + rates[i].flags = 0; + if ((i >= IWL_FIRST_CCK_RATE) && (i <= IWL_LAST_CCK_RATE)) { + /* + * If CCK != 1M then set short preamble rate flag. + */ + rates[i].flags |= + (iwl_rates[i].plcp == IWL_RATE_1M_PLCP) ? + 0 : IEEE80211_RATE_SHORT_PREAMBLE; + } } - - cmd.data[0] = pattern_cmd; - err = iwl_trans_send_cmd(trans(priv), &cmd); - kfree(pattern_cmd); - return err; } -#endif -static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_gtk_rekey_data *data) +static int iwl_init_drv(struct iwl_priv *priv) { - struct iwl_priv *priv = hw->priv; - - if (iwlagn_mod_params.sw_crypto) - return; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + int ret; - if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif) - goto out; + spin_lock_init(&priv->shrd->sta_lock); - memcpy(priv->kek, data->kek, NL80211_KEK_LEN); - memcpy(priv->kck, data->kck, NL80211_KCK_LEN); - priv->replay_ctr = cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr)); - priv->have_rekey_data = true; + mutex_init(&priv->shrd->mutex); - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); -} + priv->ieee_channels = NULL; + priv->ieee_rates = NULL; + priv->band = IEEE80211_BAND_2GHZ; -struct wowlan_key_data { - struct iwl_rxon_context *ctx; - struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; - struct iwlagn_wowlan_tkip_params_cmd *tkip; - const u8 *bssid; - bool error, use_rsc_tsc, use_tkip; -}; + priv->iw_mode = NL80211_IFTYPE_STATION; + priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; + priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; + priv->agg_tids_count = 0; -#ifdef CONFIG_PM_SLEEP -static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) -{ - int i; + /* initialize force reset */ + priv->force_reset[IWL_RF_RESET].reset_duration = + IWL_DELAY_NEXT_FORCE_RF_RESET; + priv->force_reset[IWL_FW_RESET].reset_duration = + IWL_DELAY_NEXT_FORCE_FW_RELOAD; - for (i = 0; i < IWLAGN_P1K_SIZE; i++) - out[i] = cpu_to_le16(p1k[i]); -} + priv->rx_statistics_jiffies = jiffies; -static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key, - void *_data) -{ - struct iwl_priv *priv = hw->priv; - struct wowlan_key_data *data = _data; - struct iwl_rxon_context *ctx = data->ctx; - struct aes_sc *aes_sc, *aes_tx_sc = NULL; - struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; - struct iwlagn_p1k_cache *rx_p1ks; - u8 *rx_mic_key; - struct ieee80211_key_seq seq; - u32 cur_rx_iv32 = 0; - u16 p1k[IWLAGN_P1K_SIZE]; - int ret, i; + /* Choose which receivers/antennas to use */ + iwlagn_set_rxon_chain(priv, &priv->contexts[IWL_RXON_CTX_BSS]); - mutex_lock(&priv->shrd->mutex); + iwl_init_scan_params(priv); - if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) && - !sta && !ctx->key_mapping_keys) - ret = iwl_set_default_wep_key(priv, ctx, key); - else - ret = iwl_set_dynamic_key(priv, ctx, key, sta); + /* init bt coex */ + if (priv->cfg->bt_params && + priv->cfg->bt_params->advanced_bt_coexist) { + priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT; + priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT; + priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK; + priv->bt_on_thresh = BT_ON_THRESHOLD_DEF; + priv->bt_duration = BT_DURATION_LIMIT_DEF; + priv->dynamic_frag_thresh = BT_FRAG_THRESHOLD_DEF; + } + ret = iwl_init_channel_map(priv); if (ret) { - IWL_ERR(priv, "Error setting key during suspend!\n"); - data->error = true; + IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); + goto err; } - switch (key->cipher) { - case WLAN_CIPHER_SUITE_TKIP: - if (sta) { - tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; - tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; - - rx_p1ks = data->tkip->rx_uni; + ret = iwl_init_geos(priv); + if (ret) { + IWL_ERR(priv, "initializing geos failed: %d\n", ret); + goto err_free_channel_map; + } + iwl_init_hw_rates(priv, priv->ieee_rates); - ieee80211_get_key_tx_seq(key, &seq); - tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); - tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); + return 0; - ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); - iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); +err_free_channel_map: + iwl_free_channel_map(priv); +err: + return ret; +} - memcpy(data->tkip->mic_keys.tx, - &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], - IWLAGN_MIC_KEY_SIZE); +static void iwl_uninit_drv(struct iwl_priv *priv) +{ + iwl_calib_free_results(priv); + iwl_free_geos(priv); + iwl_free_channel_map(priv); + if (priv->tx_cmd_pool) + kmem_cache_destroy(priv->tx_cmd_pool); + kfree(priv->scan_cmd); + kfree(priv->beacon_cmd); + kfree(rcu_dereference_raw(priv->noa_data)); +#ifdef CONFIG_IWLWIFI_DEBUGFS + kfree(priv->wowlan_sram); +#endif +} - rx_mic_key = data->tkip->mic_keys.rx_unicast; - } else { - tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; - rx_p1ks = data->tkip->rx_multi; - rx_mic_key = data->tkip->mic_keys.rx_mcast; - } - /* - * For non-QoS this relies on the fact that both the uCode and - * mac80211 use TID 0 (as they need to to avoid replay attacks) - * for checking the IV in the frames. - */ - for (i = 0; i < IWLAGN_NUM_RSC; i++) { - ieee80211_get_key_rx_seq(key, i, &seq); - tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); - tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); - /* wrapping isn't allowed, AP must rekey */ - if (seq.tkip.iv32 > cur_rx_iv32) - cur_rx_iv32 = seq.tkip.iv32; - } - ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); - iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); - ieee80211_get_tkip_rx_p1k(key, data->bssid, - cur_rx_iv32 + 1, p1k); - iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); - - memcpy(rx_mic_key, - &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], - IWLAGN_MIC_KEY_SIZE); - - data->use_tkip = true; - data->use_rsc_tsc = true; - break; - case WLAN_CIPHER_SUITE_CCMP: - if (sta) { - u8 *pn = seq.ccmp.pn; - - aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; - aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; - - ieee80211_get_key_tx_seq(key, &seq); - aes_tx_sc->pn = cpu_to_le64( - (u64)pn[5] | - ((u64)pn[4] << 8) | - ((u64)pn[3] << 16) | - ((u64)pn[2] << 24) | - ((u64)pn[1] << 32) | - ((u64)pn[0] << 40)); - } else - aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; - - /* - * For non-QoS this relies on the fact that both the uCode and - * mac80211 use TID 0 for checking the IV in the frames. - */ - for (i = 0; i < IWLAGN_NUM_RSC; i++) { - u8 *pn = seq.ccmp.pn; - - ieee80211_get_key_rx_seq(key, i, &seq); - aes_sc->pn = cpu_to_le64( - (u64)pn[5] | - ((u64)pn[4] << 8) | - ((u64)pn[3] << 16) | - ((u64)pn[2] << 24) | - ((u64)pn[1] << 32) | - ((u64)pn[0] << 40)); - } - data->use_rsc_tsc = true; - break; - } - - mutex_unlock(&priv->shrd->mutex); -} - -static int iwlagn_mac_suspend(struct ieee80211_hw *hw, - struct cfg80211_wowlan *wowlan) -{ - struct iwl_priv *priv = hw->priv; - struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; - struct iwl_rxon_cmd rxon; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; - struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; - struct wowlan_key_data key_data = { - .ctx = ctx, - .bssid = ctx->active.bssid_addr, - .use_rsc_tsc = false, - .tkip = &tkip_cmd, - .use_tkip = false, - }; - struct iwlagn_d3_config_cmd d3_cfg_cmd = {}; - int ret, i; - u16 seq; - - if (WARN_ON(!wowlan)) - return -EINVAL; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - - /* Don't attempt WoWLAN when not associated, tear down instead. */ - if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION || - !iwl_is_associated_ctx(ctx)) { - ret = 1; - goto out; - } - - key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); - if (!key_data.rsc_tsc) { - ret = -ENOMEM; - goto out; - } - - memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); - - /* - * We know the last used seqno, and the uCode expects to know that - * one, it will increment before TX. - */ - seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; - wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); - - /* - * For QoS counters, we store the one to use next, so subtract 0x10 - * since the uCode will add 0x10 before using the value. - */ - for (i = 0; i < 8; i++) { - seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; - seq -= 0x10; - wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); - } - - if (wowlan->disconnect) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | - IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); - if (wowlan->magic_pkt) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); - if (wowlan->gtk_rekey_failure) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); - if (wowlan->eap_identity_req) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); - if (wowlan->four_way_handshake) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); - if (wowlan->n_patterns) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); - - if (wowlan->rfkill_release) - d3_cfg_cmd.wakeup_flags |= - cpu_to_le32(IWLAGN_D3_WAKEUP_RFKILL); - - iwl_scan_cancel_timeout(priv, 200); - - memcpy(&rxon, &ctx->active, sizeof(rxon)); - - iwl_trans_stop_device(trans(priv)); - - priv->shrd->wowlan = true; - - ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); - if (ret) - goto error; - - /* now configure WoWLAN ucode */ - ret = iwl_alive_start(priv); - if (ret) - goto error; - - memcpy(&ctx->staging, &rxon, sizeof(rxon)); - ret = iwlagn_commit_rxon(priv, ctx); - if (ret) - goto error; - - ret = iwl_power_update_mode(priv, true); - if (ret) - goto error; - - if (!iwlagn_mod_params.sw_crypto) { - /* mark all keys clear */ - priv->ucode_key_table = 0; - ctx->key_mapping_keys = 0; - - /* - * This needs to be unlocked due to lock ordering - * constraints. Since we're in the suspend path - * that isn't really a problem though. - */ - mutex_unlock(&priv->shrd->mutex); - ieee80211_iter_keys(priv->hw, ctx->vif, - iwlagn_wowlan_program_keys, - &key_data); - mutex_lock(&priv->shrd->mutex); - if (key_data.error) { - ret = -EIO; - goto error; - } - - if (key_data.use_rsc_tsc) { - struct iwl_host_cmd rsc_tsc_cmd = { - .id = REPLY_WOWLAN_TSC_RSC_PARAMS, - .flags = CMD_SYNC, - .data[0] = key_data.rsc_tsc, - .dataflags[0] = IWL_HCMD_DFL_NOCOPY, - .len[0] = sizeof(*key_data.rsc_tsc), - }; - - ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); - if (ret) - goto error; - } - - if (key_data.use_tkip) { - ret = iwl_trans_send_cmd_pdu(trans(priv), - REPLY_WOWLAN_TKIP_PARAMS, - CMD_SYNC, sizeof(tkip_cmd), - &tkip_cmd); - if (ret) - goto error; - } - - if (priv->have_rekey_data) { - memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); - memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); - kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); - memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); - kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); - kek_kck_cmd.replay_ctr = priv->replay_ctr; - - ret = iwl_trans_send_cmd_pdu(trans(priv), - REPLY_WOWLAN_KEK_KCK_MATERIAL, - CMD_SYNC, sizeof(kek_kck_cmd), - &kek_kck_cmd); - if (ret) - goto error; - } - } - - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, - sizeof(d3_cfg_cmd), &d3_cfg_cmd); - if (ret) - goto error; - - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, - CMD_SYNC, sizeof(wakeup_filter_cmd), - &wakeup_filter_cmd); - if (ret) - goto error; - - ret = iwlagn_send_patterns(priv, wowlan); - if (ret) - goto error; - - device_set_wakeup_enable(bus(priv)->dev, true); - - /* Now let the ucode operate on its own */ - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); - - goto out; - - error: - priv->shrd->wowlan = false; - iwlagn_prepare_restart(priv); - ieee80211_restart_hw(priv->hw); - out: - mutex_unlock(&priv->shrd->mutex); - kfree(key_data.rsc_tsc); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return ret; -} - -static int iwlagn_mac_resume(struct ieee80211_hw *hw) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - struct ieee80211_vif *vif; - unsigned long flags; - u32 base, status = 0xffffffff; - int ret = -EIO; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); - - base = priv->device_pointers.error_event_table; - if (iwlagn_hw_valid_rtc_data_addr(base)) { - spin_lock_irqsave(&bus(priv)->reg_lock, flags); - ret = iwl_grab_nic_access_silent(bus(priv)); - if (ret == 0) { - iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base); - status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); - iwl_release_nic_access(bus(priv)); - } - spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); - -#ifdef CONFIG_IWLWIFI_DEBUGFS - if (ret == 0) { - struct iwl_trans *trans = trans(priv); - if (!priv->wowlan_sram) - priv->wowlan_sram = - kzalloc(trans->ucode_wowlan.data.len, - GFP_KERNEL); - - if (priv->wowlan_sram) - _iwl_read_targ_mem_words( - bus(priv), 0x800000, priv->wowlan_sram, - trans->ucode_wowlan.data.len / 4); - } -#endif - } - - /* we'll clear ctx->vif during iwlagn_prepare_restart() */ - vif = ctx->vif; - - priv->shrd->wowlan = false; - - device_set_wakeup_enable(bus(priv)->dev, false); - - iwlagn_prepare_restart(priv); - - memset((void *)&ctx->active, 0, sizeof(ctx->active)); - iwl_connection_init_rx_config(priv, ctx); - iwlagn_set_rxon_chain(priv, ctx); - - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - ieee80211_resume_disconnect(vif); - - return 1; -} -#endif - -static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -{ - struct iwl_priv *priv = hw->priv; - - IWL_DEBUG_MACDUMP(priv, "enter\n"); - - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - - if (iwlagn_tx_skb(priv, skb)) - dev_kfree_skb_any(skb); - - IWL_DEBUG_MACDUMP(priv, "leave\n"); -} - -static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key) -{ - struct iwl_priv *priv = hw->priv; - - iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key); -} - -static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *ctx = vif_priv->ctx; - int ret; - bool is_default_wep_key = false; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - - if (iwlagn_mod_params.sw_crypto) { - IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); - return -EOPNOTSUPP; - } - - /* - * We could program these keys into the hardware as well, but we - * don't expect much multicast traffic in IBSS and having keys - * for more stations is probably more useful. - * - * Mark key TX-only and return 0. - */ - if (vif->type == NL80211_IFTYPE_ADHOC && - !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { - key->hw_key_idx = WEP_INVALID_OFFSET; - return 0; - } - - /* If they key was TX-only, accept deletion */ - if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET) - return 0; - - mutex_lock(&priv->shrd->mutex); - iwl_scan_cancel_timeout(priv, 100); - - BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT); - - /* - * If we are getting WEP group key and we didn't receive any key mapping - * so far, we are in legacy wep mode (group key only), otherwise we are - * in 1X mode. - * In legacy wep mode, we use another host command to the uCode. - */ - if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { - if (cmd == SET_KEY) - is_default_wep_key = !ctx->key_mapping_keys; - else - is_default_wep_key = - key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT; - } - - - switch (cmd) { - case SET_KEY: - if (is_default_wep_key) { - ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); - break; - } - ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta); - if (ret) { - /* - * can't add key for RX, but we don't need it - * in the device for TX so still return 0 - */ - ret = 0; - key->hw_key_idx = WEP_INVALID_OFFSET; - } - - IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); - break; - case DISABLE_KEY: - if (is_default_wep_key) - ret = iwl_remove_default_wep_key(priv, ctx, key); - else - ret = iwl_remove_dynamic_key(priv, ctx, key, sta); - - IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); - break; - default: - ret = -EINVAL; - } - - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return ret; -} - -static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size) -{ - struct iwl_priv *priv = hw->priv; - int ret = -EINVAL; - struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); - - IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", - sta->addr, tid); - - if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)) - return -EACCES; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - - switch (action) { - case IEEE80211_AMPDU_RX_START: - IWL_DEBUG_HT(priv, "start Rx\n"); - ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); - break; - case IEEE80211_AMPDU_RX_STOP: - IWL_DEBUG_HT(priv, "stop Rx\n"); - ret = iwl_sta_rx_agg_stop(priv, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) - ret = 0; - break; - case IEEE80211_AMPDU_TX_START: - IWL_DEBUG_HT(priv, "start Tx\n"); - ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); - break; - case IEEE80211_AMPDU_TX_STOP: - IWL_DEBUG_HT(priv, "stop Tx\n"); - ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); - if ((ret == 0) && (priv->agg_tids_count > 0)) { - priv->agg_tids_count--; - IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", - priv->agg_tids_count); - } - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) - ret = 0; - if (!priv->agg_tids_count && priv->cfg->ht_params && - priv->cfg->ht_params->use_rts_for_aggregation) { - /* - * switch off RTS/CTS if it was previously enabled - */ - sta_priv->lq_sta.lq.general_params.flags &= - ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; - iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), - &sta_priv->lq_sta.lq, CMD_ASYNC, false); - } - break; - case IEEE80211_AMPDU_TX_OPERATIONAL: - buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); - - iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, iwl_sta_id(sta), - tid, buf_size); - - /* - * If the limit is 0, then it wasn't initialised yet, - * use the default. We can do that since we take the - * minimum below, and we don't want to go above our - * default due to hardware restrictions. - */ - if (sta_priv->max_agg_bufsize == 0) - sta_priv->max_agg_bufsize = - LINK_QUAL_AGG_FRAME_LIMIT_DEF; - - /* - * Even though in theory the peer could have different - * aggregation reorder buffer sizes for different sessions, - * our ucode doesn't allow for that and has a global limit - * for each station. Therefore, use the minimum of all the - * aggregation sessions and our default value. - */ - sta_priv->max_agg_bufsize = - min(sta_priv->max_agg_bufsize, buf_size); - - if (priv->cfg->ht_params && - priv->cfg->ht_params->use_rts_for_aggregation) { - /* - * switch to RTS/CTS if it is the prefer protection - * method for HT traffic - */ - - sta_priv->lq_sta.lq.general_params.flags |= - LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; - } - priv->agg_tids_count++; - IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", - priv->agg_tids_count); - - sta_priv->lq_sta.lq.agg_params.agg_frame_cnt_limit = - sta_priv->max_agg_bufsize; - - iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), - &sta_priv->lq_sta.lq, CMD_ASYNC, false); - - IWL_INFO(priv, "Tx aggregation enabled on ra = %pM tid = %d\n", - sta->addr, tid); - ret = 0; - break; - } - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - return ret; -} - -static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - bool is_ap = vif->type == NL80211_IFTYPE_STATION; - int ret = 0; - u8 sta_id; - - IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n", - sta->addr); - mutex_lock(&priv->shrd->mutex); - IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", - sta->addr); - sta_priv->sta_id = IWL_INVALID_STATION; - - atomic_set(&sta_priv->pending_frames, 0); - if (vif->type == NL80211_IFTYPE_AP) - sta_priv->client = true; - - ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr, - is_ap, sta, &sta_id); - if (ret) { - IWL_ERR(priv, "Unable to add station %pM (%d)\n", - sta->addr, ret); - /* Should we return success if return code is EEXIST ? */ - goto out; - } - - sta_priv->sta_id = sta_id; - - /* Initialize rate scaling */ - IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", - sta->addr); - iwl_rs_rate_init(priv, sta, sta_id); - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return ret; -} - -static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch) -{ - struct iwl_priv *priv = hw->priv; - const struct iwl_channel_info *ch_info; - struct ieee80211_conf *conf = &hw->conf; - struct ieee80211_channel *channel = ch_switch->channel; - struct iwl_ht_config *ht_conf = &priv->current_ht_config; - /* - * MULTI-FIXME - * When we add support for multiple interfaces, we need to - * revisit this. The channel switch command in the device - * only affects the BSS context, but what does that really - * mean? And what if we get a CSA on the second interface? - * This needs a lot of work. - */ - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - u16 ch; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - - mutex_lock(&priv->shrd->mutex); - - if (iwl_is_rfkill(priv->shrd)) - goto out; - - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || - test_bit(STATUS_SCANNING, &priv->shrd->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) - goto out; - - if (!iwl_is_associated_ctx(ctx)) - goto out; - - if (!priv->cfg->lib->set_channel_switch) - goto out; - - ch = channel->hw_value; - if (le16_to_cpu(ctx->active.channel) == ch) - goto out; - - ch_info = iwl_get_channel_info(priv, channel->band, ch); - if (!is_channel_valid(ch_info)) { - IWL_DEBUG_MAC80211(priv, "invalid channel\n"); - goto out; - } - - spin_lock_irq(&priv->shrd->lock); - - priv->current_ht_config.smps = conf->smps_mode; - - /* Configure HT40 channels */ - ctx->ht.enabled = conf_is_ht(conf); - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else - ctx->ht.is_40mhz = false; - - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; - - iwl_set_rxon_channel(priv, channel, ctx); - iwl_set_rxon_ht(priv, ht_conf); - iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); - - spin_unlock_irq(&priv->shrd->lock); - - iwl_set_rate(priv); - /* - * at this point, staging_rxon has the - * configuration for channel switch - */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); - priv->switch_channel = cpu_to_le16(ch); - if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); - priv->switch_channel = 0; - ieee80211_chswitch_done(ctx->vif, false); - } - -out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); -} - -static void iwlagn_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) -{ - struct iwl_priv *priv = hw->priv; - __le32 filter_or = 0, filter_nand = 0; - struct iwl_rxon_context *ctx; - -#define CHK(test, flag) do { \ - if (*total_flags & (test)) \ - filter_or |= (flag); \ - else \ - filter_nand |= (flag); \ - } while (0) - - IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); - - CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); - /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ - CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); - CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); - -#undef CHK - - mutex_lock(&priv->shrd->mutex); - - for_each_context(priv, ctx) { - ctx->staging.filter_flags &= ~filter_nand; - ctx->staging.filter_flags |= filter_or; - - /* - * Not committing directly because hardware can perform a scan, - * but we'll eventually commit the filter flags change anyway. - */ - } - - mutex_unlock(&priv->shrd->mutex); - - /* - * Receiving all multicast frames is always enabled by the - * default flags setup in iwl_connection_init_rx_config() - * since we currently do not support programming multicast - * filters into the device. - */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; -} - -static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) -{ - struct iwl_priv *priv = hw->priv; - - mutex_lock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "enter\n"); - - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { - IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); - goto done; - } - if (iwl_is_rfkill(priv->shrd)) { - IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); - goto done; - } - - /* - * mac80211 will not push any more frames for transmit - * until the flush is completed - */ - if (drop) { - IWL_DEBUG_MAC80211(priv, "send flush command\n"); - if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { - IWL_ERR(priv, "flush request fail\n"); - goto done; - } - } - IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); - iwl_trans_wait_tx_queue_empty(trans(priv)); -done: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); -} - -void iwlagn_disable_roc(struct iwl_priv *priv) -{ - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; - - lockdep_assert_held(&priv->shrd->mutex); - - if (!priv->hw_roc_setup) - return; - - ctx->staging.dev_type = RXON_DEV_TYPE_P2P; - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - - priv->hw_roc_channel = NULL; - - memset(ctx->staging.node_addr, 0, ETH_ALEN); - - iwlagn_commit_rxon(priv, ctx); - - ctx->is_active = false; - priv->hw_roc_setup = false; -} - -static void iwlagn_disable_roc_work(struct work_struct *work) -{ - struct iwl_priv *priv = container_of(work, struct iwl_priv, - hw_roc_disable_work.work); - - mutex_lock(&priv->shrd->mutex); - iwlagn_disable_roc(priv); - mutex_unlock(&priv->shrd->mutex); -} - -static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, - struct ieee80211_channel *channel, - enum nl80211_channel_type channel_type, - int duration) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; - int err = 0; - - if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) - return -EOPNOTSUPP; - - if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT))) - return -EOPNOTSUPP; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - - if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { - err = -EBUSY; - goto out; - } - - priv->hw_roc_channel = channel; - priv->hw_roc_chantype = channel_type; - priv->hw_roc_duration = duration; - priv->hw_roc_start_notified = false; - cancel_delayed_work(&priv->hw_roc_disable_work); - - if (!ctx->is_active) { - ctx->is_active = true; - ctx->staging.dev_type = RXON_DEV_TYPE_P2P; - memcpy(ctx->staging.node_addr, - priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, - ETH_ALEN); - memcpy(ctx->staging.bssid_addr, - priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, - ETH_ALEN); - err = iwlagn_commit_rxon(priv, ctx); - if (err) - goto out; - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK | - RXON_FILTER_PROMISC_MSK | - RXON_FILTER_CTL2HOST_MSK; - - err = iwlagn_commit_rxon(priv, ctx); - if (err) { - iwlagn_disable_roc(priv); - goto out; - } - priv->hw_roc_setup = true; - } - - err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band); - if (err) - iwlagn_disable_roc(priv); - - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return err; -} - -static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) -{ - struct iwl_priv *priv = hw->priv; - - if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) - return -EOPNOTSUPP; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); - iwlagn_disable_roc(priv); - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return 0; -} - -static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const u8 *bssid, - enum ieee80211_tx_sync_type type) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *ctx = vif_priv->ctx; - int ret; - u8 sta_id; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - - if (iwl_is_associated_ctx(ctx)) { - ret = 0; - goto out; - } - - if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { - ret = -EBUSY; - goto out; - } - - ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id); - if (ret) - goto out; - - if (WARN_ON(sta_id != ctx->ap_sta_id)) { - ret = -EIO; - goto out_remove_sta; - } - - memcpy(ctx->bssid, bssid, ETH_ALEN); - ctx->preauth_bssid = true; - - ret = iwlagn_commit_rxon(priv, ctx); - - if (ret == 0) - goto out; - - out_remove_sta: - iwl_remove_station(priv, sta_id, bssid); - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return ret; -} - -static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const u8 *bssid, - enum ieee80211_tx_sync_type type) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *ctx = vif_priv->ctx; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - - if (iwl_is_associated_ctx(ctx)) - goto out; - - iwl_remove_station(priv, ctx->ap_sta_id, bssid); - ctx->preauth_bssid = false; - /* no need to commit */ - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); -} - -/***************************************************************************** - * - * driver setup and teardown - * - *****************************************************************************/ - -static void iwl_setup_deferred_work(struct iwl_priv *priv) -{ - priv->shrd->workqueue = create_singlethread_workqueue(DRV_NAME); - - init_waitqueue_head(&priv->shrd->wait_command_queue); - - INIT_WORK(&priv->restart, iwl_bg_restart); - INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update); - INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); - INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush); - INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency); - INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config); - INIT_DELAYED_WORK(&priv->hw_roc_disable_work, - iwlagn_disable_roc_work); - - iwl_setup_scan_deferred_work(priv); - - if (priv->cfg->lib->bt_setup_deferred_work) - priv->cfg->lib->bt_setup_deferred_work(priv); - - init_timer(&priv->statistics_periodic); - priv->statistics_periodic.data = (unsigned long)priv; - priv->statistics_periodic.function = iwl_bg_statistics_periodic; - - init_timer(&priv->ucode_trace); - priv->ucode_trace.data = (unsigned long)priv; - priv->ucode_trace.function = iwl_bg_ucode_trace; - - init_timer(&priv->watchdog); - priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = iwl_bg_watchdog; -} - -static void iwl_cancel_deferred_work(struct iwl_priv *priv) -{ - if (priv->cfg->lib->cancel_deferred_work) - priv->cfg->lib->cancel_deferred_work(priv); - - cancel_work_sync(&priv->run_time_calib_work); - cancel_work_sync(&priv->beacon_update); - - iwl_cancel_scan_deferred_work(priv); - - cancel_work_sync(&priv->bt_full_concurrency); - cancel_work_sync(&priv->bt_runtime_config); - cancel_delayed_work_sync(&priv->hw_roc_disable_work); - - del_timer_sync(&priv->statistics_periodic); - del_timer_sync(&priv->ucode_trace); -} - -static void iwl_init_hw_rates(struct iwl_priv *priv, - struct ieee80211_rate *rates) -{ - int i; - - for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = iwl_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on indexes */ - rates[i].hw_value_short = i; - rates[i].flags = 0; - if ((i >= IWL_FIRST_CCK_RATE) && (i <= IWL_LAST_CCK_RATE)) { - /* - * If CCK != 1M then set short preamble rate flag. - */ - rates[i].flags |= - (iwl_rates[i].plcp == IWL_RATE_1M_PLCP) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; - } - } -} - -static int iwl_init_drv(struct iwl_priv *priv) -{ - int ret; - - spin_lock_init(&priv->shrd->sta_lock); - - mutex_init(&priv->shrd->mutex); - - priv->ieee_channels = NULL; - priv->ieee_rates = NULL; - priv->band = IEEE80211_BAND_2GHZ; - - priv->iw_mode = NL80211_IFTYPE_STATION; - priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; - priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; - priv->agg_tids_count = 0; - - /* initialize force reset */ - priv->force_reset[IWL_RF_RESET].reset_duration = - IWL_DELAY_NEXT_FORCE_RF_RESET; - priv->force_reset[IWL_FW_RESET].reset_duration = - IWL_DELAY_NEXT_FORCE_FW_RELOAD; - - priv->rx_statistics_jiffies = jiffies; - - /* Choose which receivers/antennas to use */ - iwlagn_set_rxon_chain(priv, &priv->contexts[IWL_RXON_CTX_BSS]); - - iwl_init_scan_params(priv); - - /* init bt coex */ - if (priv->cfg->bt_params && - priv->cfg->bt_params->advanced_bt_coexist) { - priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT; - priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT; - priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK; - priv->bt_on_thresh = BT_ON_THRESHOLD_DEF; - priv->bt_duration = BT_DURATION_LIMIT_DEF; - priv->dynamic_frag_thresh = BT_FRAG_THRESHOLD_DEF; - } - - ret = iwl_init_channel_map(priv); - if (ret) { - IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); - goto err; - } - - ret = iwl_init_geos(priv); - if (ret) { - IWL_ERR(priv, "initializing geos failed: %d\n", ret); - goto err_free_channel_map; - } - iwl_init_hw_rates(priv, priv->ieee_rates); - - return 0; - -err_free_channel_map: - iwl_free_channel_map(priv); -err: - return ret; -} - -static void iwl_uninit_drv(struct iwl_priv *priv) -{ - iwl_calib_free_results(priv); - iwl_free_geos(priv); - iwl_free_channel_map(priv); - if (priv->tx_cmd_pool) - kmem_cache_destroy(priv->tx_cmd_pool); - kfree(priv->scan_cmd); - kfree(priv->beacon_cmd); - kfree(rcu_dereference_raw(priv->noa_data)); -#ifdef CONFIG_IWLWIFI_DEBUGFS - kfree(priv->wowlan_sram); -#endif -} - -static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, - enum ieee80211_rssi_event rssi_event) -{ - struct iwl_priv *priv = hw->priv; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); - - if (priv->cfg->bt_params && - priv->cfg->bt_params->advanced_bt_coexist) { - if (rssi_event == RSSI_EVENT_LOW) - priv->bt_enable_pspoll = true; - else if (rssi_event == RSSI_EVENT_HIGH) - priv->bt_enable_pspoll = false; - - iwlagn_send_advance_bt_config(priv); - } else { - IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled," - "ignoring RSSI callback\n"); - } - - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); -} - -static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, bool set) -{ - struct iwl_priv *priv = hw->priv; - - queue_work(priv->shrd->workqueue, &priv->beacon_update); - - return 0; -} - -struct ieee80211_ops iwlagn_hw_ops = { - .tx = iwlagn_mac_tx, - .start = iwlagn_mac_start, - .stop = iwlagn_mac_stop, -#ifdef CONFIG_PM_SLEEP - .suspend = iwlagn_mac_suspend, - .resume = iwlagn_mac_resume, -#endif - .add_interface = iwlagn_mac_add_interface, - .remove_interface = iwlagn_mac_remove_interface, - .change_interface = iwlagn_mac_change_interface, - .config = iwlagn_mac_config, - .configure_filter = iwlagn_configure_filter, - .set_key = iwlagn_mac_set_key, - .update_tkip_key = iwlagn_mac_update_tkip_key, - .set_rekey_data = iwlagn_mac_set_rekey_data, - .conf_tx = iwlagn_mac_conf_tx, - .bss_info_changed = iwlagn_bss_info_changed, - .ampdu_action = iwlagn_mac_ampdu_action, - .hw_scan = iwlagn_mac_hw_scan, - .sta_notify = iwlagn_mac_sta_notify, - .sta_add = iwlagn_mac_sta_add, - .sta_remove = iwlagn_mac_sta_remove, - .channel_switch = iwlagn_mac_channel_switch, - .flush = iwlagn_mac_flush, - .tx_last_beacon = iwlagn_mac_tx_last_beacon, - .remain_on_channel = iwlagn_mac_remain_on_channel, - .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, - .rssi_callback = iwlagn_mac_rssi_callback, - CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd) - CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump) - .tx_sync = iwlagn_mac_tx_sync, - .finish_tx_sync = iwlagn_mac_finish_tx_sync, - .set_tim = iwlagn_mac_set_tim, -}; - -static u32 iwl_hw_detect(struct iwl_priv *priv) -{ - return iwl_read32(bus(priv), CSR_HW_REV); -} +static u32 iwl_hw_detect(struct iwl_priv *priv) +{ + return iwl_read32(bus(priv), CSR_HW_REV); +} /* Size of one Rx buffer in host DRAM */ #define IWL_RX_BUF_SIZE_4K (4 * 1024) @@ -3132,24 +1678,7 @@ static int iwl_set_hw_params(struct iwl_priv *priv) return priv->cfg->lib->set_hw_params(priv); } -/* This function both allocates and initializes hw and priv. */ -static struct ieee80211_hw *iwl_alloc_all(void) -{ - struct iwl_priv *priv; - /* mac80211 allocates memory for this device instance, including - * space for this driver's private structure */ - struct ieee80211_hw *hw; - - hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); - if (!hw) - goto out; - - priv = hw->priv; - priv->hw = hw; -out: - return hw; -} int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, struct iwl_cfg *cfg) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 7cc5cd8..72af933 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -65,6 +65,12 @@ #include "iwl-dev.h" +struct iwlagn_ucode_capabilities { + u32 max_probe_length; + u32 standard_phy_calibration_size; + u32 flags; +}; + extern struct ieee80211_ops iwlagn_hw_ops; int iwl_reset_ict(struct iwl_trans *trans); @@ -77,6 +83,15 @@ static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) hdr->data_valid = 1; } +void __iwl_down(struct iwl_priv *priv); +void iwl_down(struct iwl_priv *priv); +void iwlagn_prepare_restart(struct iwl_priv *priv); + +/* MAC80211 */ +struct ieee80211_hw *iwl_alloc_all(void); +int iwlagn_mac_setup_register(struct iwl_priv *priv, + struct iwlagn_ucode_capabilities *capa); + /* RXON */ int iwlagn_set_pan_params(struct iwl_priv *priv); int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx); diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c new file mode 100644 index 0000000..43d795d --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -0,0 +1,1521 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * Portions of this file are derived from the ipw3945 project, as well + * as portions of the ieee80211 subsystem header files. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "iwl-eeprom.h" +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-agn-calib.h" +#include "iwl-agn.h" +#include "iwl-shared.h" +#include "iwl-bus.h" +#include "iwl-trans.h" + +/***************************************************************************** + * + * mac80211 entry point functions + * + *****************************************************************************/ + +static const struct ieee80211_iface_limit iwlagn_sta_ap_limits[] = { + { + .max = 1, + .types = BIT(NL80211_IFTYPE_STATION), + }, + { + .max = 1, + .types = BIT(NL80211_IFTYPE_AP), + }, +}; + +static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = { + { + .max = 2, + .types = BIT(NL80211_IFTYPE_STATION), + }, +}; + +static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = { + { + .max = 1, + .types = BIT(NL80211_IFTYPE_STATION), + }, + { + .max = 1, + .types = BIT(NL80211_IFTYPE_P2P_GO) | + BIT(NL80211_IFTYPE_AP), + }, +}; + +static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = { + { + .max = 2, + .types = BIT(NL80211_IFTYPE_STATION), + }, + { + .max = 1, + .types = BIT(NL80211_IFTYPE_P2P_CLIENT), + }, +}; + +static const struct ieee80211_iface_combination +iwlagn_iface_combinations_dualmode[] = { + { .num_different_channels = 1, + .max_interfaces = 2, + .beacon_int_infra_match = true, + .limits = iwlagn_sta_ap_limits, + .n_limits = ARRAY_SIZE(iwlagn_sta_ap_limits), + }, + { .num_different_channels = 1, + .max_interfaces = 2, + .limits = iwlagn_2sta_limits, + .n_limits = ARRAY_SIZE(iwlagn_2sta_limits), + }, +}; + +static const struct ieee80211_iface_combination +iwlagn_iface_combinations_p2p[] = { + { .num_different_channels = 1, + .max_interfaces = 2, + .beacon_int_infra_match = true, + .limits = iwlagn_p2p_sta_go_limits, + .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits), + }, + { .num_different_channels = 1, + .max_interfaces = 2, + .limits = iwlagn_p2p_2sta_limits, + .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits), + }, +}; + +/* + * Not a mac80211 entry point function, but it fits in with all the + * other mac80211 functions grouped here. + */ +int iwlagn_mac_setup_register(struct iwl_priv *priv, + struct iwlagn_ucode_capabilities *capa) +{ + int ret; + struct ieee80211_hw *hw = priv->hw; + struct iwl_rxon_context *ctx; + + hw->rate_control_algorithm = "iwl-agn-rs"; + + /* Tell mac80211 our characteristics */ + hw->flags = IEEE80211_HW_SIGNAL_DBM | + IEEE80211_HW_AMPDU_AGGREGATION | + IEEE80211_HW_NEED_DTIM_PERIOD | + IEEE80211_HW_SPECTRUM_MGMT | + IEEE80211_HW_REPORTS_TX_ACK_STATUS; + + /* + * Including the following line will crash some AP's. This + * workaround removes the stimulus which causes the crash until + * the AP software can be fixed. + hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; + */ + + hw->flags |= IEEE80211_HW_SUPPORTS_PS | + IEEE80211_HW_SUPPORTS_DYNAMIC_PS; + + if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) + hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | + IEEE80211_HW_SUPPORTS_STATIC_SMPS; + + if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) + hw->flags |= IEEE80211_HW_MFP_CAPABLE; + + hw->sta_data_size = sizeof(struct iwl_station_priv); + hw->vif_data_size = sizeof(struct iwl_vif_priv); + + for_each_context(priv, ctx) { + hw->wiphy->interface_modes |= ctx->interface_modes; + hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; + } + + BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); + + if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) { + hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p; + hw->wiphy->n_iface_combinations = + ARRAY_SIZE(iwlagn_iface_combinations_p2p); + } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { + hw->wiphy->iface_combinations = + iwlagn_iface_combinations_dualmode; + hw->wiphy->n_iface_combinations = + ARRAY_SIZE(iwlagn_iface_combinations_dualmode); + } + + hw->wiphy->max_remain_on_channel_duration = 1000; + + hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | + WIPHY_FLAG_DISABLE_BEACON_HINTS | + WIPHY_FLAG_IBSS_RSN; + + if (trans(priv)->ucode_wowlan.code.len && + device_can_wakeup(bus(priv)->dev)) { + hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | + WIPHY_WOWLAN_DISCONNECT | + WIPHY_WOWLAN_EAP_IDENTITY_REQ | + WIPHY_WOWLAN_RFKILL_RELEASE; + if (!iwlagn_mod_params.sw_crypto) + hw->wiphy->wowlan.flags |= + WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | + WIPHY_WOWLAN_GTK_REKEY_FAILURE; + + hw->wiphy->wowlan.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS; + hw->wiphy->wowlan.pattern_min_len = + IWLAGN_WOWLAN_MIN_PATTERN_LEN; + hw->wiphy->wowlan.pattern_max_len = + IWLAGN_WOWLAN_MAX_PATTERN_LEN; + } + + if (iwlagn_mod_params.power_save) + hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; + else + hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + + hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; + /* we create the 802.11 header and a zero-length SSID element */ + hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; + + /* Default value; 4 EDCA QOS priorities */ + hw->queues = 4; + + hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; + + if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &priv->bands[IEEE80211_BAND_2GHZ]; + if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) + priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &priv->bands[IEEE80211_BAND_5GHZ]; + + iwl_leds_init(priv); + + ret = ieee80211_register_hw(priv->hw); + if (ret) { + IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); + return ret; + } + priv->mac80211_registered = 1; + + return 0; +} + +static int __iwl_up(struct iwl_priv *priv) +{ + struct iwl_rxon_context *ctx; + int ret; + + lockdep_assert_held(&priv->shrd->mutex); + + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { + IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + return -EIO; + } + + for_each_context(priv, ctx) { + ret = iwlagn_alloc_bcast_station(priv, ctx); + if (ret) { + iwl_dealloc_bcast_stations(priv); + return ret; + } + } + + ret = iwlagn_run_init_ucode(priv); + if (ret) { + IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); + goto error; + } + + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); + if (ret) { + IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); + goto error; + } + + ret = iwl_alive_start(priv); + if (ret) + goto error; + return 0; + + error: + set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); + __iwl_down(priv); + clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); + + IWL_ERR(priv, "Unable to initialize device.\n"); + return ret; +} + +static int iwlagn_mac_start(struct ieee80211_hw *hw) +{ + struct iwl_priv *priv = hw->priv; + int ret; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + /* we should be verifying the device is ready to be opened */ + mutex_lock(&priv->shrd->mutex); + ret = __iwl_up(priv); + mutex_unlock(&priv->shrd->mutex); + if (ret) + return ret; + + IWL_DEBUG_INFO(priv, "Start UP work done.\n"); + + /* Now we should be done, and the READY bit should be set. */ + if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status))) + ret = -EIO; + + iwlagn_led_enable(priv); + + priv->is_open = 1; + IWL_DEBUG_MAC80211(priv, "leave\n"); + return 0; +} + +static void iwlagn_mac_stop(struct ieee80211_hw *hw) +{ + struct iwl_priv *priv = hw->priv; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + if (!priv->is_open) + return; + + priv->is_open = 0; + + iwl_down(priv); + + flush_workqueue(priv->shrd->workqueue); + + /* User space software may expect getting rfkill changes + * even if interface is down */ + iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF); + iwl_enable_rfkill_int(priv); + + IWL_DEBUG_MAC80211(priv, "leave\n"); +} + +static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct cfg80211_gtk_rekey_data *data) +{ + struct iwl_priv *priv = hw->priv; + + if (iwlagn_mod_params.sw_crypto) + return; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif) + goto out; + + memcpy(priv->kek, data->kek, NL80211_KEK_LEN); + memcpy(priv->kck, data->kck, NL80211_KCK_LEN); + priv->replay_ctr = + cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr)); + priv->have_rekey_data = true; + + out: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); +} + +#ifdef CONFIG_PM_SLEEP +struct wowlan_key_data { + struct iwl_rxon_context *ctx; + struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; + struct iwlagn_wowlan_tkip_params_cmd *tkip; + const u8 *bssid; + bool error, use_rsc_tsc, use_tkip; +}; + +static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) +{ + int i; + + for (i = 0; i < IWLAGN_P1K_SIZE; i++) + out[i] = cpu_to_le16(p1k[i]); +} + +static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key, + void *_data) +{ + struct iwl_priv *priv = hw->priv; + struct wowlan_key_data *data = _data; + struct iwl_rxon_context *ctx = data->ctx; + struct aes_sc *aes_sc, *aes_tx_sc = NULL; + struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; + struct iwlagn_p1k_cache *rx_p1ks; + u8 *rx_mic_key; + struct ieee80211_key_seq seq; + u32 cur_rx_iv32 = 0; + u16 p1k[IWLAGN_P1K_SIZE]; + int ret, i; + + mutex_lock(&priv->shrd->mutex); + + if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) && + !sta && !ctx->key_mapping_keys) + ret = iwl_set_default_wep_key(priv, ctx, key); + else + ret = iwl_set_dynamic_key(priv, ctx, key, sta); + + if (ret) { + IWL_ERR(priv, "Error setting key during suspend!\n"); + data->error = true; + } + + switch (key->cipher) { + case WLAN_CIPHER_SUITE_TKIP: + if (sta) { + tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; + tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; + + rx_p1ks = data->tkip->rx_uni; + + ieee80211_get_key_tx_seq(key, &seq); + tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); + tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); + + ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); + iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); + + memcpy(data->tkip->mic_keys.tx, + &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], + IWLAGN_MIC_KEY_SIZE); + + rx_mic_key = data->tkip->mic_keys.rx_unicast; + } else { + tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; + rx_p1ks = data->tkip->rx_multi; + rx_mic_key = data->tkip->mic_keys.rx_mcast; + } + + /* + * For non-QoS this relies on the fact that both the uCode and + * mac80211 use TID 0 (as they need to to avoid replay attacks) + * for checking the IV in the frames. + */ + for (i = 0; i < IWLAGN_NUM_RSC; i++) { + ieee80211_get_key_rx_seq(key, i, &seq); + tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); + tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); + /* wrapping isn't allowed, AP must rekey */ + if (seq.tkip.iv32 > cur_rx_iv32) + cur_rx_iv32 = seq.tkip.iv32; + } + + ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); + iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); + ieee80211_get_tkip_rx_p1k(key, data->bssid, + cur_rx_iv32 + 1, p1k); + iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); + + memcpy(rx_mic_key, + &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], + IWLAGN_MIC_KEY_SIZE); + + data->use_tkip = true; + data->use_rsc_tsc = true; + break; + case WLAN_CIPHER_SUITE_CCMP: + if (sta) { + u8 *pn = seq.ccmp.pn; + + aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; + aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; + + ieee80211_get_key_tx_seq(key, &seq); + aes_tx_sc->pn = cpu_to_le64( + (u64)pn[5] | + ((u64)pn[4] << 8) | + ((u64)pn[3] << 16) | + ((u64)pn[2] << 24) | + ((u64)pn[1] << 32) | + ((u64)pn[0] << 40)); + } else + aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; + + /* + * For non-QoS this relies on the fact that both the uCode and + * mac80211 use TID 0 for checking the IV in the frames. + */ + for (i = 0; i < IWLAGN_NUM_RSC; i++) { + u8 *pn = seq.ccmp.pn; + + ieee80211_get_key_rx_seq(key, i, &seq); + aes_sc->pn = cpu_to_le64( + (u64)pn[5] | + ((u64)pn[4] << 8) | + ((u64)pn[3] << 16) | + ((u64)pn[2] << 24) | + ((u64)pn[1] << 32) | + ((u64)pn[0] << 40)); + } + data->use_rsc_tsc = true; + break; + } + + mutex_unlock(&priv->shrd->mutex); +} + +static int iwlagn_send_patterns(struct iwl_priv *priv, + struct cfg80211_wowlan *wowlan) +{ + struct iwlagn_wowlan_patterns_cmd *pattern_cmd; + struct iwl_host_cmd cmd = { + .id = REPLY_WOWLAN_PATTERNS, + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, + .flags = CMD_SYNC, + }; + int i, err; + + if (!wowlan->n_patterns) + return 0; + + cmd.len[0] = sizeof(*pattern_cmd) + + wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); + + pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); + if (!pattern_cmd) + return -ENOMEM; + + pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); + + for (i = 0; i < wowlan->n_patterns; i++) { + int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); + + memcpy(&pattern_cmd->patterns[i].mask, + wowlan->patterns[i].mask, mask_len); + memcpy(&pattern_cmd->patterns[i].pattern, + wowlan->patterns[i].pattern, + wowlan->patterns[i].pattern_len); + pattern_cmd->patterns[i].mask_size = mask_len; + pattern_cmd->patterns[i].pattern_size = + wowlan->patterns[i].pattern_len; + } + + cmd.data[0] = pattern_cmd; + err = iwl_trans_send_cmd(trans(priv), &cmd); + kfree(pattern_cmd); + return err; +} + +static int iwlagn_mac_suspend(struct ieee80211_hw *hw, + struct cfg80211_wowlan *wowlan) +{ + struct iwl_priv *priv = hw->priv; + struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; + struct iwl_rxon_cmd rxon; + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; + struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; + struct wowlan_key_data key_data = { + .ctx = ctx, + .bssid = ctx->active.bssid_addr, + .use_rsc_tsc = false, + .tkip = &tkip_cmd, + .use_tkip = false, + }; + struct iwlagn_d3_config_cmd d3_cfg_cmd = {}; + int ret, i; + u16 seq; + + if (WARN_ON(!wowlan)) + return -EINVAL; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + /* Don't attempt WoWLAN when not associated, tear down instead. */ + if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION || + !iwl_is_associated_ctx(ctx)) { + ret = 1; + goto out; + } + + key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); + if (!key_data.rsc_tsc) { + ret = -ENOMEM; + goto out; + } + + memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); + + /* + * We know the last used seqno, and the uCode expects to know that + * one, it will increment before TX. + */ + seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; + wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); + + /* + * For QoS counters, we store the one to use next, so subtract 0x10 + * since the uCode will add 0x10 before using the value. + */ + for (i = 0; i < 8; i++) { + seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; + seq -= 0x10; + wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); + } + + if (wowlan->disconnect) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | + IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); + if (wowlan->magic_pkt) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); + if (wowlan->gtk_rekey_failure) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); + if (wowlan->eap_identity_req) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); + if (wowlan->four_way_handshake) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); + if (wowlan->n_patterns) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); + + if (wowlan->rfkill_release) + d3_cfg_cmd.wakeup_flags |= + cpu_to_le32(IWLAGN_D3_WAKEUP_RFKILL); + + iwl_scan_cancel_timeout(priv, 200); + + memcpy(&rxon, &ctx->active, sizeof(rxon)); + + iwl_trans_stop_device(trans(priv)); + + priv->shrd->wowlan = true; + + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); + if (ret) + goto error; + + /* now configure WoWLAN ucode */ + ret = iwl_alive_start(priv); + if (ret) + goto error; + + memcpy(&ctx->staging, &rxon, sizeof(rxon)); + ret = iwlagn_commit_rxon(priv, ctx); + if (ret) + goto error; + + ret = iwl_power_update_mode(priv, true); + if (ret) + goto error; + + if (!iwlagn_mod_params.sw_crypto) { + /* mark all keys clear */ + priv->ucode_key_table = 0; + ctx->key_mapping_keys = 0; + + /* + * This needs to be unlocked due to lock ordering + * constraints. Since we're in the suspend path + * that isn't really a problem though. + */ + mutex_unlock(&priv->shrd->mutex); + ieee80211_iter_keys(priv->hw, ctx->vif, + iwlagn_wowlan_program_keys, + &key_data); + mutex_lock(&priv->shrd->mutex); + if (key_data.error) { + ret = -EIO; + goto error; + } + + if (key_data.use_rsc_tsc) { + struct iwl_host_cmd rsc_tsc_cmd = { + .id = REPLY_WOWLAN_TSC_RSC_PARAMS, + .flags = CMD_SYNC, + .data[0] = key_data.rsc_tsc, + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, + .len[0] = sizeof(*key_data.rsc_tsc), + }; + + ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); + if (ret) + goto error; + } + + if (key_data.use_tkip) { + ret = iwl_trans_send_cmd_pdu(trans(priv), + REPLY_WOWLAN_TKIP_PARAMS, + CMD_SYNC, sizeof(tkip_cmd), + &tkip_cmd); + if (ret) + goto error; + } + + if (priv->have_rekey_data) { + memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); + memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); + kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); + memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); + kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); + kek_kck_cmd.replay_ctr = priv->replay_ctr; + + ret = iwl_trans_send_cmd_pdu(trans(priv), + REPLY_WOWLAN_KEK_KCK_MATERIAL, + CMD_SYNC, sizeof(kek_kck_cmd), + &kek_kck_cmd); + if (ret) + goto error; + } + } + + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, + sizeof(d3_cfg_cmd), &d3_cfg_cmd); + if (ret) + goto error; + + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, + CMD_SYNC, sizeof(wakeup_filter_cmd), + &wakeup_filter_cmd); + if (ret) + goto error; + + ret = iwlagn_send_patterns(priv, wowlan); + if (ret) + goto error; + + device_set_wakeup_enable(bus(priv)->dev, true); + + /* Now let the ucode operate on its own */ + iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); + + goto out; + + error: + priv->shrd->wowlan = false; + iwlagn_prepare_restart(priv); + ieee80211_restart_hw(priv->hw); + out: + mutex_unlock(&priv->shrd->mutex); + kfree(key_data.rsc_tsc); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return ret; +} + +static int iwlagn_mac_resume(struct ieee80211_hw *hw) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct ieee80211_vif *vif; + unsigned long flags; + u32 base, status = 0xffffffff; + int ret = -EIO; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); + + base = priv->device_pointers.error_event_table; + if (iwlagn_hw_valid_rtc_data_addr(base)) { + spin_lock_irqsave(&bus(priv)->reg_lock, flags); + ret = iwl_grab_nic_access_silent(bus(priv)); + if (ret == 0) { + iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base); + status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); + iwl_release_nic_access(bus(priv)); + } + spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); + +#ifdef CONFIG_IWLWIFI_DEBUGFS + if (ret == 0) { + struct iwl_trans *trans = trans(priv); + if (!priv->wowlan_sram) + priv->wowlan_sram = + kzalloc(trans->ucode_wowlan.data.len, + GFP_KERNEL); + + if (priv->wowlan_sram) + _iwl_read_targ_mem_words( + bus(priv), 0x800000, priv->wowlan_sram, + trans->ucode_wowlan.data.len / 4); + } +#endif + } + + /* we'll clear ctx->vif during iwlagn_prepare_restart() */ + vif = ctx->vif; + + priv->shrd->wowlan = false; + + device_set_wakeup_enable(bus(priv)->dev, false); + + iwlagn_prepare_restart(priv); + + memset((void *)&ctx->active, 0, sizeof(ctx->active)); + iwl_connection_init_rx_config(priv, ctx); + iwlagn_set_rxon_chain(priv, ctx); + + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + ieee80211_resume_disconnect(vif); + + return 1; +} + +#endif + +static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct iwl_priv *priv = hw->priv; + + IWL_DEBUG_MACDUMP(priv, "enter\n"); + + IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + + if (iwlagn_tx_skb(priv, skb)) + dev_kfree_skb_any(skb); + + IWL_DEBUG_MACDUMP(priv, "leave\n"); +} + +static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, + u32 iv32, u16 *phase1key) +{ + struct iwl_priv *priv = hw->priv; + + iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key); +} + +static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct iwl_rxon_context *ctx = vif_priv->ctx; + int ret; + bool is_default_wep_key = false; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + if (iwlagn_mod_params.sw_crypto) { + IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + return -EOPNOTSUPP; + } + + /* + * We could program these keys into the hardware as well, but we + * don't expect much multicast traffic in IBSS and having keys + * for more stations is probably more useful. + * + * Mark key TX-only and return 0. + */ + if (vif->type == NL80211_IFTYPE_ADHOC && + !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { + key->hw_key_idx = WEP_INVALID_OFFSET; + return 0; + } + + /* If they key was TX-only, accept deletion */ + if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET) + return 0; + + mutex_lock(&priv->shrd->mutex); + iwl_scan_cancel_timeout(priv, 100); + + BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT); + + /* + * If we are getting WEP group key and we didn't receive any key mapping + * so far, we are in legacy wep mode (group key only), otherwise we are + * in 1X mode. + * In legacy wep mode, we use another host command to the uCode. + */ + if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { + if (cmd == SET_KEY) + is_default_wep_key = !ctx->key_mapping_keys; + else + is_default_wep_key = + key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT; + } + + + switch (cmd) { + case SET_KEY: + if (is_default_wep_key) { + ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); + break; + } + ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta); + if (ret) { + /* + * can't add key for RX, but we don't need it + * in the device for TX so still return 0 + */ + ret = 0; + key->hw_key_idx = WEP_INVALID_OFFSET; + } + + IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + break; + case DISABLE_KEY: + if (is_default_wep_key) + ret = iwl_remove_default_wep_key(priv, ctx, key); + else + ret = iwl_remove_dynamic_key(priv, ctx, key, sta); + + IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return ret; +} + +static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size) +{ + struct iwl_priv *priv = hw->priv; + int ret = -EINVAL; + struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); + + IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", + sta->addr, tid); + + if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)) + return -EACCES; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + switch (action) { + case IEEE80211_AMPDU_RX_START: + IWL_DEBUG_HT(priv, "start Rx\n"); + ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); + break; + case IEEE80211_AMPDU_RX_STOP: + IWL_DEBUG_HT(priv, "stop Rx\n"); + ret = iwl_sta_rx_agg_stop(priv, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + ret = 0; + break; + case IEEE80211_AMPDU_TX_START: + IWL_DEBUG_HT(priv, "start Tx\n"); + ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); + break; + case IEEE80211_AMPDU_TX_STOP: + IWL_DEBUG_HT(priv, "stop Tx\n"); + ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); + if ((ret == 0) && (priv->agg_tids_count > 0)) { + priv->agg_tids_count--; + IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", + priv->agg_tids_count); + } + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + ret = 0; + if (!priv->agg_tids_count && priv->cfg->ht_params && + priv->cfg->ht_params->use_rts_for_aggregation) { + /* + * switch off RTS/CTS if it was previously enabled + */ + sta_priv->lq_sta.lq.general_params.flags &= + ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; + iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), + &sta_priv->lq_sta.lq, CMD_ASYNC, false); + } + break; + case IEEE80211_AMPDU_TX_OPERATIONAL: + buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); + + iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, iwl_sta_id(sta), + tid, buf_size); + + /* + * If the limit is 0, then it wasn't initialised yet, + * use the default. We can do that since we take the + * minimum below, and we don't want to go above our + * default due to hardware restrictions. + */ + if (sta_priv->max_agg_bufsize == 0) + sta_priv->max_agg_bufsize = + LINK_QUAL_AGG_FRAME_LIMIT_DEF; + + /* + * Even though in theory the peer could have different + * aggregation reorder buffer sizes for different sessions, + * our ucode doesn't allow for that and has a global limit + * for each station. Therefore, use the minimum of all the + * aggregation sessions and our default value. + */ + sta_priv->max_agg_bufsize = + min(sta_priv->max_agg_bufsize, buf_size); + + if (priv->cfg->ht_params && + priv->cfg->ht_params->use_rts_for_aggregation) { + /* + * switch to RTS/CTS if it is the prefer protection + * method for HT traffic + */ + + sta_priv->lq_sta.lq.general_params.flags |= + LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; + } + priv->agg_tids_count++; + IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", + priv->agg_tids_count); + + sta_priv->lq_sta.lq.agg_params.agg_frame_cnt_limit = + sta_priv->max_agg_bufsize; + + iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), + &sta_priv->lq_sta.lq, CMD_ASYNC, false); + + IWL_INFO(priv, "Tx aggregation enabled on ra = %pM tid = %d\n", + sta->addr, tid); + ret = 0; + break; + } + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + return ret; +} + +static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + bool is_ap = vif->type == NL80211_IFTYPE_STATION; + int ret = 0; + u8 sta_id; + + IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n", + sta->addr); + mutex_lock(&priv->shrd->mutex); + IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + sta->addr); + sta_priv->sta_id = IWL_INVALID_STATION; + + atomic_set(&sta_priv->pending_frames, 0); + if (vif->type == NL80211_IFTYPE_AP) + sta_priv->client = true; + + ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr, + is_ap, sta, &sta_id); + if (ret) { + IWL_ERR(priv, "Unable to add station %pM (%d)\n", + sta->addr, ret); + /* Should we return success if return code is EEXIST ? */ + goto out; + } + + sta_priv->sta_id = sta_id; + + /* Initialize rate scaling */ + IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + sta->addr); + iwl_rs_rate_init(priv, sta, sta_id); + out: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return ret; +} + +static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, + struct ieee80211_channel_switch *ch_switch) +{ + struct iwl_priv *priv = hw->priv; + const struct iwl_channel_info *ch_info; + struct ieee80211_conf *conf = &hw->conf; + struct ieee80211_channel *channel = ch_switch->channel; + struct iwl_ht_config *ht_conf = &priv->current_ht_config; + /* + * MULTI-FIXME + * When we add support for multiple interfaces, we need to + * revisit this. The channel switch command in the device + * only affects the BSS context, but what does that really + * mean? And what if we get a CSA on the second interface? + * This needs a lot of work. + */ + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + u16 ch; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + mutex_lock(&priv->shrd->mutex); + + if (iwl_is_rfkill(priv->shrd)) + goto out; + + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || + test_bit(STATUS_SCANNING, &priv->shrd->status) || + test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) + goto out; + + if (!iwl_is_associated_ctx(ctx)) + goto out; + + if (!priv->cfg->lib->set_channel_switch) + goto out; + + ch = channel->hw_value; + if (le16_to_cpu(ctx->active.channel) == ch) + goto out; + + ch_info = iwl_get_channel_info(priv, channel->band, ch); + if (!is_channel_valid(ch_info)) { + IWL_DEBUG_MAC80211(priv, "invalid channel\n"); + goto out; + } + + spin_lock_irq(&priv->shrd->lock); + + priv->current_ht_config.smps = conf->smps_mode; + + /* Configure HT40 channels */ + ctx->ht.enabled = conf_is_ht(conf); + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; + + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; + + iwl_set_rxon_channel(priv, channel, ctx); + iwl_set_rxon_ht(priv, ht_conf); + iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); + + spin_unlock_irq(&priv->shrd->lock); + + iwl_set_rate(priv); + /* + * at this point, staging_rxon has the + * configuration for channel switch + */ + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); + priv->switch_channel = cpu_to_le16(ch); + if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) { + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); + priv->switch_channel = 0; + ieee80211_chswitch_done(ctx->vif, false); + } + +out: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); +} + +static void iwlagn_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 multicast) +{ + struct iwl_priv *priv = hw->priv; + __le32 filter_or = 0, filter_nand = 0; + struct iwl_rxon_context *ctx; + +#define CHK(test, flag) do { \ + if (*total_flags & (test)) \ + filter_or |= (flag); \ + else \ + filter_nand |= (flag); \ + } while (0) + + IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + changed_flags, *total_flags); + + CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); + /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ + CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); + CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); + +#undef CHK + + mutex_lock(&priv->shrd->mutex); + + for_each_context(priv, ctx) { + ctx->staging.filter_flags &= ~filter_nand; + ctx->staging.filter_flags |= filter_or; + + /* + * Not committing directly because hardware can perform a scan, + * but we'll eventually commit the filter flags change anyway. + */ + } + + mutex_unlock(&priv->shrd->mutex); + + /* + * Receiving all multicast frames is always enabled by the + * default flags setup in iwl_connection_init_rx_config() + * since we currently do not support programming multicast + * filters into the device. + */ + *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; +} + +static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) +{ + struct iwl_priv *priv = hw->priv; + + mutex_lock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "enter\n"); + + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { + IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); + goto done; + } + if (iwl_is_rfkill(priv->shrd)) { + IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); + goto done; + } + + /* + * mac80211 will not push any more frames for transmit + * until the flush is completed + */ + if (drop) { + IWL_DEBUG_MAC80211(priv, "send flush command\n"); + if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { + IWL_ERR(priv, "flush request fail\n"); + goto done; + } + } + IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); + iwl_trans_wait_tx_queue_empty(trans(priv)); +done: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); +} + +static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, + struct ieee80211_channel *channel, + enum nl80211_channel_type channel_type, + int duration) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; + int err = 0; + + if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) + return -EOPNOTSUPP; + + if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT))) + return -EOPNOTSUPP; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { + err = -EBUSY; + goto out; + } + + priv->hw_roc_channel = channel; + priv->hw_roc_chantype = channel_type; + priv->hw_roc_duration = duration; + priv->hw_roc_start_notified = false; + cancel_delayed_work(&priv->hw_roc_disable_work); + + if (!ctx->is_active) { + ctx->is_active = true; + ctx->staging.dev_type = RXON_DEV_TYPE_P2P; + memcpy(ctx->staging.node_addr, + priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, + ETH_ALEN); + memcpy(ctx->staging.bssid_addr, + priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, + ETH_ALEN); + err = iwlagn_commit_rxon(priv, ctx); + if (err) + goto out; + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK | + RXON_FILTER_PROMISC_MSK | + RXON_FILTER_CTL2HOST_MSK; + + err = iwlagn_commit_rxon(priv, ctx); + if (err) { + iwlagn_disable_roc(priv); + goto out; + } + priv->hw_roc_setup = true; + } + + err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band); + if (err) + iwlagn_disable_roc(priv); + + out: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return err; +} + +static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) +{ + struct iwl_priv *priv = hw->priv; + + if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) + return -EOPNOTSUPP; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); + iwlagn_disable_roc(priv); + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return 0; +} + +static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + const u8 *bssid, + enum ieee80211_tx_sync_type type) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct iwl_rxon_context *ctx = vif_priv->ctx; + int ret; + u8 sta_id; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + if (iwl_is_associated_ctx(ctx)) { + ret = 0; + goto out; + } + + if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, + &priv->shrd->status)) { + ret = -EBUSY; + goto out; + } + + ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id); + if (ret) + goto out; + + if (WARN_ON(sta_id != ctx->ap_sta_id)) { + ret = -EIO; + goto out_remove_sta; + } + + memcpy(ctx->bssid, bssid, ETH_ALEN); + ctx->preauth_bssid = true; + + ret = iwlagn_commit_rxon(priv, ctx); + + if (ret == 0) + goto out; + + out_remove_sta: + iwl_remove_station(priv, sta_id, bssid); + out: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return ret; +} + +static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + const u8 *bssid, + enum ieee80211_tx_sync_type type) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct iwl_rxon_context *ctx = vif_priv->ctx; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + if (iwl_is_associated_ctx(ctx)) + goto out; + + iwl_remove_station(priv, ctx->ap_sta_id, bssid); + ctx->preauth_bssid = false; + /* no need to commit */ + out: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); +} + +static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, + enum ieee80211_rssi_event rssi_event) +{ + struct iwl_priv *priv = hw->priv; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&priv->shrd->mutex); + + if (priv->cfg->bt_params && + priv->cfg->bt_params->advanced_bt_coexist) { + if (rssi_event == RSSI_EVENT_LOW) + priv->bt_enable_pspoll = true; + else if (rssi_event == RSSI_EVENT_HIGH) + priv->bt_enable_pspoll = false; + + iwlagn_send_advance_bt_config(priv); + } else { + IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled," + "ignoring RSSI callback\n"); + } + + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); +} + +static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, bool set) +{ + struct iwl_priv *priv = hw->priv; + + queue_work(priv->shrd->workqueue, &priv->beacon_update); + + return 0; +} + +struct ieee80211_ops iwlagn_hw_ops = { + .tx = iwlagn_mac_tx, + .start = iwlagn_mac_start, + .stop = iwlagn_mac_stop, +#ifdef CONFIG_PM_SLEEP + .suspend = iwlagn_mac_suspend, + .resume = iwlagn_mac_resume, +#endif + .add_interface = iwlagn_mac_add_interface, + .remove_interface = iwlagn_mac_remove_interface, + .change_interface = iwlagn_mac_change_interface, + .config = iwlagn_mac_config, + .configure_filter = iwlagn_configure_filter, + .set_key = iwlagn_mac_set_key, + .update_tkip_key = iwlagn_mac_update_tkip_key, + .set_rekey_data = iwlagn_mac_set_rekey_data, + .conf_tx = iwlagn_mac_conf_tx, + .bss_info_changed = iwlagn_bss_info_changed, + .ampdu_action = iwlagn_mac_ampdu_action, + .hw_scan = iwlagn_mac_hw_scan, + .sta_notify = iwlagn_mac_sta_notify, + .sta_add = iwlagn_mac_sta_add, + .sta_remove = iwlagn_mac_sta_remove, + .channel_switch = iwlagn_mac_channel_switch, + .flush = iwlagn_mac_flush, + .tx_last_beacon = iwlagn_mac_tx_last_beacon, + .remain_on_channel = iwlagn_mac_remain_on_channel, + .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, + .rssi_callback = iwlagn_mac_rssi_callback, + CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd) + CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump) + .tx_sync = iwlagn_mac_tx_sync, + .finish_tx_sync = iwlagn_mac_finish_tx_sync, + .set_tim = iwlagn_mac_set_tim, +}; + +/* This function both allocates and initializes hw and priv. */ +struct ieee80211_hw *iwl_alloc_all(void) +{ + struct iwl_priv *priv; + /* mac80211 allocates memory for this device instance, including + * space for this driver's private structure */ + struct ieee80211_hw *hw; + + hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); + if (!hw) + goto out; + + priv = hw->priv; + priv->hw = hw; + +out: + return hw; +} -- cgit v0.10.2 From df912e5119759dad2d2f4b989a5fe83fbdfdeec0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 10 Nov 2011 06:55:12 -0800 Subject: iwlagn: use per-vif AC parameters Eliad added the ability to configure AC parameters per virtual interface; make use of this in iwlwifi and set the parameters in the right context. Since storage and uploading to the device is already per context, this is sufficient. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 001fdf1..989f9f3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1125,10 +1125,14 @@ int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, const struct ieee80211_tx_queue_params *params) { struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx; + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct iwl_rxon_context *ctx = vif_priv->ctx; unsigned long flags; int q; + if (WARN_ON(!ctx)) + return -EINVAL; + IWL_DEBUG_MAC80211(priv, "enter\n"); if (!iwl_is_ready_rf(priv->shrd)) { @@ -1145,21 +1149,15 @@ int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, spin_lock_irqsave(&priv->shrd->lock, flags); - /* - * MULTI-FIXME - * This may need to be done per interface in nl80211/cfg80211/mac80211. - */ - for_each_context(priv, ctx) { - ctx->qos_data.def_qos_parm.ac[q].cw_min = - cpu_to_le16(params->cw_min); - ctx->qos_data.def_qos_parm.ac[q].cw_max = - cpu_to_le16(params->cw_max); - ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; - ctx->qos_data.def_qos_parm.ac[q].edca_txop = - cpu_to_le16((params->txop * 32)); - - ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; - } + ctx->qos_data.def_qos_parm.ac[q].cw_min = + cpu_to_le16(params->cw_min); + ctx->qos_data.def_qos_parm.ac[q].cw_max = + cpu_to_le16(params->cw_max); + ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; + ctx->qos_data.def_qos_parm.ac[q].edca_txop = + cpu_to_le16((params->txop * 32)); + + ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; spin_unlock_irqrestore(&priv->shrd->lock, flags); -- cgit v0.10.2 From a69cd040d03711215c32f89683a025d28594d2b5 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 10 Nov 2011 06:55:13 -0800 Subject: iwlagn: explicitly program P2P QoS parameters In P2P device mode, the device needs to have valid QoS parameters. We currently have those because we program parameters from any virtual interface into all contexts, but not only do we want to get rid of this -- it is also unpredictable since on the BSS context we might have any parameters, and there it might even be programmed for HT. Explicitly program default QoS parameters into the PAN context for P2P (the defaults are 11g but with QoS disabled) to make device behaviour predictable. This also helps when in a follow-up patch we will use TX QoS parameters from mac80211 only for the context they were meant for -- without this first that would completely break P2P device discovery. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 43d795d..c06bfe4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -1305,7 +1305,35 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, cancel_delayed_work(&priv->hw_roc_disable_work); if (!ctx->is_active) { + static const struct iwl_qos_info default_qos_data = { + .def_qos_parm = { + .ac[0] = { + .cw_min = cpu_to_le16(3), + .cw_max = cpu_to_le16(7), + .aifsn = 2, + .edca_txop = cpu_to_le16(1504), + }, + .ac[1] = { + .cw_min = cpu_to_le16(7), + .cw_max = cpu_to_le16(15), + .aifsn = 2, + .edca_txop = cpu_to_le16(3008), + }, + .ac[2] = { + .cw_min = cpu_to_le16(15), + .cw_max = cpu_to_le16(1023), + .aifsn = 3, + }, + .ac[3] = { + .cw_min = cpu_to_le16(15), + .cw_max = cpu_to_le16(1023), + .aifsn = 7, + }, + }, + }; + ctx->is_active = true; + ctx->qos_data = default_qos_data; ctx->staging.dev_type = RXON_DEV_TYPE_P2P; memcpy(ctx->staging.node_addr, priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, -- cgit v0.10.2 From 0b7a4c788fd08ffd147b266b7d0992f6f13ccdae Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:14 -0800 Subject: iwlwifi: move more mac80211 callback function Move more mac80211 related functions to _mac80211 file Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 989f9f3..f7b0048 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1120,227 +1120,8 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear) &statistics_cmd); } -int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *ctx = vif_priv->ctx; - unsigned long flags; - int q; - - if (WARN_ON(!ctx)) - return -EINVAL; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - - if (!iwl_is_ready_rf(priv->shrd)) { - IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); - return -EIO; - } - - if (queue >= AC_NUM) { - IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); - return 0; - } - - q = AC_NUM - 1 - queue; - - spin_lock_irqsave(&priv->shrd->lock, flags); - - ctx->qos_data.def_qos_parm.ac[q].cw_min = - cpu_to_le16(params->cw_min); - ctx->qos_data.def_qos_parm.ac[q].cw_max = - cpu_to_le16(params->cw_max); - ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; - ctx->qos_data.def_qos_parm.ac[q].edca_txop = - cpu_to_le16((params->txop * 32)); - - ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; - - spin_unlock_irqrestore(&priv->shrd->lock, flags); - - IWL_DEBUG_MAC80211(priv, "leave\n"); - return 0; -} - -int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) -{ - struct iwl_priv *priv = hw->priv; - - return priv->ibss_manager == IWL_IBSS_MANAGER; -} - -static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) -{ - iwl_connection_init_rx_config(priv, ctx); - - iwlagn_set_rxon_chain(priv, ctx); - - return iwlagn_commit_rxon(priv, ctx); -} - -static int iwl_setup_interface(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) -{ - struct ieee80211_vif *vif = ctx->vif; - int err; - lockdep_assert_held(&priv->shrd->mutex); - - /* - * This variable will be correct only when there's just - * a single context, but all code using it is for hardware - * that supports only one context. - */ - priv->iw_mode = vif->type; - - ctx->is_active = true; - - err = iwl_set_mode(priv, ctx); - if (err) { - if (!ctx->always_active) - ctx->is_active = false; - return err; - } - - if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist && - vif->type == NL80211_IFTYPE_ADHOC) { - /* - * pretend to have high BT traffic as long as we - * are operating in IBSS mode, as this will cause - * the rate scaling etc. to behave as intended. - */ - priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; - } - - return 0; -} - -int iwlagn_mac_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *tmp, *ctx = NULL; - int err; - enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif); - IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", - viftype, vif->addr); - - cancel_delayed_work_sync(&priv->hw_roc_disable_work); - - mutex_lock(&priv->shrd->mutex); - - iwlagn_disable_roc(priv); - - if (!iwl_is_ready_rf(priv->shrd)) { - IWL_WARN(priv, "Try to add interface when device not ready\n"); - err = -EINVAL; - goto out; - } - - for_each_context(priv, tmp) { - u32 possible_modes = - tmp->interface_modes | tmp->exclusive_interface_modes; - - if (tmp->vif) { - /* check if this busy context is exclusive */ - if (tmp->exclusive_interface_modes & - BIT(tmp->vif->type)) { - err = -EINVAL; - goto out; - } - continue; - } - - if (!(possible_modes & BIT(viftype))) - continue; - - /* have maybe usable context w/o interface */ - ctx = tmp; - break; - } - - if (!ctx) { - err = -EOPNOTSUPP; - goto out; - } - - vif_priv->ctx = ctx; - ctx->vif = vif; - - err = iwl_setup_interface(priv, ctx); - if (!err) - goto out; - - ctx->vif = NULL; - priv->iw_mode = NL80211_IFTYPE_STATION; - out: - mutex_unlock(&priv->shrd->mutex); - - IWL_DEBUG_MAC80211(priv, "leave\n"); - return err; -} - -static void iwl_teardown_interface(struct iwl_priv *priv, - struct ieee80211_vif *vif, - bool mode_change) -{ - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); - - lockdep_assert_held(&priv->shrd->mutex); - - if (priv->scan_vif == vif) { - iwl_scan_cancel_timeout(priv, 200); - iwl_force_scan_end(priv); - } - - if (!mode_change) { - iwl_set_mode(priv, ctx); - if (!ctx->always_active) - ctx->is_active = false; - } - - /* - * When removing the IBSS interface, overwrite the - * BT traffic load with the stored one from the last - * notification, if any. If this is a device that - * doesn't implement this, this has no effect since - * both values are the same and zero. - */ - if (vif->type == NL80211_IFTYPE_ADHOC) - priv->bt_traffic_load = priv->last_bt_traffic_load; -} - -void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); - - IWL_DEBUG_MAC80211(priv, "enter\n"); - - mutex_lock(&priv->shrd->mutex); - - if (WARN_ON(ctx->vif != vif)) { - struct iwl_rxon_context *tmp; - IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif); - for_each_context(priv, tmp) - IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n", - tmp->ctxid, tmp, tmp->vif); - } - ctx->vif = NULL; - - iwl_teardown_interface(priv, vif, false); - - mutex_unlock(&priv->shrd->mutex); - - IWL_DEBUG_MAC80211(priv, "leave\n"); - -} #ifdef CONFIG_IWLWIFI_DEBUGFS @@ -1647,91 +1428,6 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external) return 0; } -int iwlagn_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); - struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - struct iwl_rxon_context *tmp; - enum nl80211_iftype newviftype = newtype; - u32 interface_modes; - int err; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - - newtype = ieee80211_iftype_p2p(newtype, newp2p); - - mutex_lock(&priv->shrd->mutex); - - if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { - /* - * Huh? But wait ... this can maybe happen when - * we're in the middle of a firmware restart! - */ - err = -EBUSY; - goto out; - } - - interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; - - if (!(interface_modes & BIT(newtype))) { - err = -EBUSY; - goto out; - } - - /* - * Refuse a change that should be done by moving from the PAN - * context to the BSS context instead, if the BSS context is - * available and can support the new interface type. - */ - if (ctx->ctxid == IWL_RXON_CTX_PAN && !bss_ctx->vif && - (bss_ctx->interface_modes & BIT(newtype) || - bss_ctx->exclusive_interface_modes & BIT(newtype))) { - BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); - err = -EBUSY; - goto out; - } - - if (ctx->exclusive_interface_modes & BIT(newtype)) { - for_each_context(priv, tmp) { - if (ctx == tmp) - continue; - - if (!tmp->vif) - continue; - - /* - * The current mode switch would be exclusive, but - * another context is active ... refuse the switch. - */ - err = -EBUSY; - goto out; - } - } - - /* success */ - iwl_teardown_interface(priv, vif, true); - vif->type = newviftype; - vif->p2p = newp2p; - err = iwl_setup_interface(priv, ctx); - WARN_ON(err); - /* - * We've switched internally, but submitting to the - * device may have failed for some reason. Mask this - * error, because otherwise mac80211 will not switch - * (and set the interface type back) and we'll be - * out of sync with it. - */ - err = 0; - - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return err; -} int iwl_cmd_echo_test(struct iwl_priv *priv) { diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 137da33..ee3692a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -237,10 +237,6 @@ struct iwl_cfg { * L i b * ***************************/ -int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params); -int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw); void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx, int hw_decrypt); int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx); @@ -260,13 +256,6 @@ bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv, void iwl_connection_init_rx_config(struct iwl_priv *priv, struct iwl_rxon_context *ctx); void iwl_set_rate(struct iwl_priv *priv); -int iwlagn_mac_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -int iwlagn_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p); int iwl_cmd_echo_test(struct iwl_priv *priv); #ifdef CONFIG_IWLWIFI_DEBUGFS int iwl_alloc_traffic_mem(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index c06bfe4..1b2dbb0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -1493,6 +1493,314 @@ static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, return 0; } +static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *params) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct iwl_rxon_context *ctx = vif_priv->ctx; + unsigned long flags; + int q; + + if (WARN_ON(!ctx)) + return -EINVAL; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + if (!iwl_is_ready_rf(priv->shrd)) { + IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + return -EIO; + } + + if (queue >= AC_NUM) { + IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); + return 0; + } + + q = AC_NUM - 1 - queue; + + spin_lock_irqsave(&priv->shrd->lock, flags); + + ctx->qos_data.def_qos_parm.ac[q].cw_min = + cpu_to_le16(params->cw_min); + ctx->qos_data.def_qos_parm.ac[q].cw_max = + cpu_to_le16(params->cw_max); + ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; + ctx->qos_data.def_qos_parm.ac[q].edca_txop = + cpu_to_le16((params->txop * 32)); + + ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; + + spin_unlock_irqrestore(&priv->shrd->lock, flags); + + IWL_DEBUG_MAC80211(priv, "leave\n"); + return 0; +} + +static int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) +{ + struct iwl_priv *priv = hw->priv; + + return priv->ibss_manager == IWL_IBSS_MANAGER; +} + +static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +{ + iwl_connection_init_rx_config(priv, ctx); + + iwlagn_set_rxon_chain(priv, ctx); + + return iwlagn_commit_rxon(priv, ctx); +} + +static int iwl_setup_interface(struct iwl_priv *priv, + struct iwl_rxon_context *ctx) +{ + struct ieee80211_vif *vif = ctx->vif; + int err; + + lockdep_assert_held(&priv->shrd->mutex); + + /* + * This variable will be correct only when there's just + * a single context, but all code using it is for hardware + * that supports only one context. + */ + priv->iw_mode = vif->type; + + ctx->is_active = true; + + err = iwl_set_mode(priv, ctx); + if (err) { + if (!ctx->always_active) + ctx->is_active = false; + return err; + } + + if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist && + vif->type == NL80211_IFTYPE_ADHOC) { + /* + * pretend to have high BT traffic as long as we + * are operating in IBSS mode, as this will cause + * the rate scaling etc. to behave as intended. + */ + priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; + } + + return 0; +} + +static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct iwl_rxon_context *tmp, *ctx = NULL; + int err; + enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif); + + IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", + viftype, vif->addr); + + cancel_delayed_work_sync(&priv->hw_roc_disable_work); + + mutex_lock(&priv->shrd->mutex); + + iwlagn_disable_roc(priv); + + if (!iwl_is_ready_rf(priv->shrd)) { + IWL_WARN(priv, "Try to add interface when device not ready\n"); + err = -EINVAL; + goto out; + } + + for_each_context(priv, tmp) { + u32 possible_modes = + tmp->interface_modes | tmp->exclusive_interface_modes; + + if (tmp->vif) { + /* check if this busy context is exclusive */ + if (tmp->exclusive_interface_modes & + BIT(tmp->vif->type)) { + err = -EINVAL; + goto out; + } + continue; + } + + if (!(possible_modes & BIT(viftype))) + continue; + + /* have maybe usable context w/o interface */ + ctx = tmp; + break; + } + + if (!ctx) { + err = -EOPNOTSUPP; + goto out; + } + + vif_priv->ctx = ctx; + ctx->vif = vif; + + err = iwl_setup_interface(priv, ctx); + if (!err) + goto out; + + ctx->vif = NULL; + priv->iw_mode = NL80211_IFTYPE_STATION; + out: + mutex_unlock(&priv->shrd->mutex); + + IWL_DEBUG_MAC80211(priv, "leave\n"); + return err; +} + +static void iwl_teardown_interface(struct iwl_priv *priv, + struct ieee80211_vif *vif, + bool mode_change) +{ + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); + + lockdep_assert_held(&priv->shrd->mutex); + + if (priv->scan_vif == vif) { + iwl_scan_cancel_timeout(priv, 200); + iwl_force_scan_end(priv); + } + + if (!mode_change) { + iwl_set_mode(priv, ctx); + if (!ctx->always_active) + ctx->is_active = false; + } + + /* + * When removing the IBSS interface, overwrite the + * BT traffic load with the stored one from the last + * notification, if any. If this is a device that + * doesn't implement this, this has no effect since + * both values are the same and zero. + */ + if (vif->type == NL80211_IFTYPE_ADHOC) + priv->bt_traffic_load = priv->last_bt_traffic_load; +} + +static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + mutex_lock(&priv->shrd->mutex); + + if (WARN_ON(ctx->vif != vif)) { + struct iwl_rxon_context *tmp; + IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif); + for_each_context(priv, tmp) + IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n", + tmp->ctxid, tmp, tmp->vif); + } + ctx->vif = NULL; + + iwl_teardown_interface(priv, vif, false); + + mutex_unlock(&priv->shrd->mutex); + + IWL_DEBUG_MAC80211(priv, "leave\n"); + +} + +static int iwlagn_mac_change_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum nl80211_iftype newtype, bool newp2p) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); + struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct iwl_rxon_context *tmp; + enum nl80211_iftype newviftype = newtype; + u32 interface_modes; + int err; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + newtype = ieee80211_iftype_p2p(newtype, newp2p); + + mutex_lock(&priv->shrd->mutex); + + if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { + /* + * Huh? But wait ... this can maybe happen when + * we're in the middle of a firmware restart! + */ + err = -EBUSY; + goto out; + } + + interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; + + if (!(interface_modes & BIT(newtype))) { + err = -EBUSY; + goto out; + } + + /* + * Refuse a change that should be done by moving from the PAN + * context to the BSS context instead, if the BSS context is + * available and can support the new interface type. + */ + if (ctx->ctxid == IWL_RXON_CTX_PAN && !bss_ctx->vif && + (bss_ctx->interface_modes & BIT(newtype) || + bss_ctx->exclusive_interface_modes & BIT(newtype))) { + BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); + err = -EBUSY; + goto out; + } + + if (ctx->exclusive_interface_modes & BIT(newtype)) { + for_each_context(priv, tmp) { + if (ctx == tmp) + continue; + + if (!tmp->vif) + continue; + + /* + * The current mode switch would be exclusive, but + * another context is active ... refuse the switch. + */ + err = -EBUSY; + goto out; + } + } + + /* success */ + iwl_teardown_interface(priv, vif, true); + vif->type = newviftype; + vif->p2p = newp2p; + err = iwl_setup_interface(priv, ctx); + WARN_ON(err); + /* + * We've switched internally, but submitting to the + * device may have failed for some reason. Mask this + * error, because otherwise mac80211 will not switch + * (and set the interface type back) and we'll be + * out of sync with it. + */ + err = 0; + + out: + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return err; +} + struct ieee80211_ops iwlagn_hw_ops = { .tx = iwlagn_mac_tx, .start = iwlagn_mac_start, -- cgit v0.10.2 From ba4c531984d480dff554e2ccb442958052482773 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:15 -0800 Subject: iwlwifi: move hw_scan into _mac80211 file iwlagn_mac_hw_scan should belong to _mac80211 callback. Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index ee3692a..fa47f75 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -312,9 +312,6 @@ void iwl_init_scan_params(struct iwl_priv *priv); int iwl_scan_cancel(struct iwl_priv *priv); void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); void iwl_force_scan_end(struct iwl_priv *priv); -int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req); void iwl_internal_short_hw_scan(struct iwl_priv *priv); int iwl_force_reset(struct iwl_priv *priv, int mode, bool external); u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 1b2dbb0..6df08bb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -1801,6 +1801,52 @@ static int iwlagn_mac_change_interface(struct ieee80211_hw *hw, return err; } +static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct cfg80211_scan_request *req) +{ + struct iwl_priv *priv = hw->priv; + int ret; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + if (req->n_channels == 0) + return -EINVAL; + + mutex_lock(&priv->shrd->mutex); + + /* + * If an internal scan is in progress, just set + * up the scan_request as per above. + */ + if (priv->scan_type != IWL_SCAN_NORMAL) { + IWL_DEBUG_SCAN(priv, + "SCAN request during internal scan - defer\n"); + priv->scan_request = req; + priv->scan_vif = vif; + ret = 0; + } else { + priv->scan_request = req; + priv->scan_vif = vif; + /* + * mac80211 will only ask for one band at a time + * so using channels[0] here is ok + */ + ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL, + req->channels[0]->band); + if (ret) { + priv->scan_request = NULL; + priv->scan_vif = NULL; + } + } + + IWL_DEBUG_MAC80211(priv, "leave\n"); + + mutex_unlock(&priv->shrd->mutex); + + return ret; +} + struct ieee80211_ops iwlagn_hw_ops = { .tx = iwlagn_mac_tx, .start = iwlagn_mac_start, diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index a26fbd3..625beec 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -939,51 +939,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, return 0; } -int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req) -{ - struct iwl_priv *priv = hw->priv; - int ret; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - - if (req->n_channels == 0) - return -EINVAL; - - mutex_lock(&priv->shrd->mutex); - - /* - * If an internal scan is in progress, just set - * up the scan_request as per above. - */ - if (priv->scan_type != IWL_SCAN_NORMAL) { - IWL_DEBUG_SCAN(priv, - "SCAN request during internal scan - defer\n"); - priv->scan_request = req; - priv->scan_vif = vif; - ret = 0; - } else { - priv->scan_request = req; - priv->scan_vif = vif; - /* - * mac80211 will only ask for one band at a time - * so using channels[0] here is ok - */ - ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL, - req->channels[0]->band); - if (ret) { - priv->scan_request = NULL; - priv->scan_vif = NULL; - } - } - - IWL_DEBUG_MAC80211(priv, "leave\n"); - - mutex_unlock(&priv->shrd->mutex); - - return ret; -} /* * internal short scan, this function should only been called while associated. -- cgit v0.10.2 From 76b2933111afe5a04e342040436a90c31c7661d4 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:16 -0800 Subject: iwlwifi: move station functions to mac80211 The station related mac80211 callback functions should belong to _mac80211 Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 1b112df..901fd94 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -829,28 +829,6 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, return ret; } -int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - int ret; - - IWL_DEBUG_MAC80211(priv, "enter: received request to remove " - "station %pM\n", sta->addr); - mutex_lock(&priv->shrd->mutex); - IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", - sta->addr); - ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); - if (ret) - IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", - sta->addr); - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return ret; -} void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u8 sta_id, struct iwl_link_quality_cmd *link_cmd) @@ -1468,20 +1446,7 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) -{ - unsigned long flags; - - spin_lock_irqsave(&priv->shrd->sta_lock, flags); - priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK; - priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; - priv->stations[sta_id].sta.sta.modify_mask = 0; - priv->stations[sta_id].sta.sleep_tx_count = 0; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); -} void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) { @@ -1498,36 +1463,3 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); } - -void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum sta_notify_cmd cmd, - struct ieee80211_sta *sta) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - int sta_id; - - IWL_DEBUG_MAC80211(priv, "enter\n"); - - switch (cmd) { - case STA_NOTIFY_SLEEP: - WARN_ON(!sta_priv->client); - sta_priv->asleep = true; - if (atomic_read(&sta_priv->pending_frames) > 0) - ieee80211_sta_block_awake(hw, sta, true); - break; - case STA_NOTIFY_AWAKE: - WARN_ON(!sta_priv->client); - if (!sta_priv->asleep) - break; - sta_priv->asleep = false; - sta_id = iwl_sta_id(sta); - if (sta_id != IWL_INVALID_STATION) - iwl_sta_modify_ps_wake(priv, sta_id); - break; - default: - break; - } - IWL_DEBUG_MAC80211(priv, "leave\n"); -} diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 72af933..d325132 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -210,9 +210,6 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, struct ieee80211_sta *sta, u8 *sta_id_r); int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, const u8 *addr); -int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta); - u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta); @@ -330,10 +327,6 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt); int iwl_update_bcast_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx); int iwl_update_bcast_stations(struct iwl_priv *priv); -void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum sta_notify_cmd cmd, - struct ieee80211_sta *sta); /* rate */ static inline u32 iwl_ant_idx_to_flags(u8 ant_idx) diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 6df08bb..b46702c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -1847,6 +1847,77 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, return ret; } +static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; + int ret; + + IWL_DEBUG_MAC80211(priv, "enter: received request to remove " + "station %pM\n", sta->addr); + mutex_lock(&priv->shrd->mutex); + IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", + sta->addr); + ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); + if (ret) + IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", + sta->addr); + mutex_unlock(&priv->shrd->mutex); + IWL_DEBUG_MAC80211(priv, "leave\n"); + + return ret; +} + +static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) +{ + unsigned long flags; + + spin_lock_irqsave(&priv->shrd->sta_lock, flags); + priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK; + priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; + priv->stations[sta_id].sta.sta.modify_mask = 0; + priv->stations[sta_id].sta.sleep_tx_count = 0; + priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); + spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + +} + +static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum sta_notify_cmd cmd, + struct ieee80211_sta *sta) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; + int sta_id; + + IWL_DEBUG_MAC80211(priv, "enter\n"); + + switch (cmd) { + case STA_NOTIFY_SLEEP: + WARN_ON(!sta_priv->client); + sta_priv->asleep = true; + if (atomic_read(&sta_priv->pending_frames) > 0) + ieee80211_sta_block_awake(hw, sta, true); + break; + case STA_NOTIFY_AWAKE: + WARN_ON(!sta_priv->client); + if (!sta_priv->asleep) + break; + sta_priv->asleep = false; + sta_id = iwl_sta_id(sta); + if (sta_id != IWL_INVALID_STATION) + iwl_sta_modify_ps_wake(priv, sta_id); + break; + default: + break; + } + IWL_DEBUG_MAC80211(priv, "leave\n"); +} + struct ieee80211_ops iwlagn_hw_ops = { .tx = iwlagn_mac_tx, .start = iwlagn_mac_start, -- cgit v0.10.2 From 023ca58f1d025d9c210f8003ca47d6b96cdac167 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:17 -0800 Subject: iwlwifi: Move the core suspend function to iwl-agn-lib The core suspend function is part of agn, iwl_mac80211 should only handle mac80211 I/F operations. Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 6465983..0bc9622 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -984,3 +984,360 @@ void iwlagn_remove_notification(struct iwl_priv *priv, list_del(&wait_entry->list); spin_unlock_bh(&priv->notif_wait_lock); } + +#ifdef CONFIG_PM_SLEEP +static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) +{ + int i; + + for (i = 0; i < IWLAGN_P1K_SIZE; i++) + out[i] = cpu_to_le16(p1k[i]); +} + +struct wowlan_key_data { + struct iwl_rxon_context *ctx; + struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; + struct iwlagn_wowlan_tkip_params_cmd *tkip; + const u8 *bssid; + bool error, use_rsc_tsc, use_tkip; +}; + + +static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key, + void *_data) +{ + struct iwl_priv *priv = hw->priv; + struct wowlan_key_data *data = _data; + struct iwl_rxon_context *ctx = data->ctx; + struct aes_sc *aes_sc, *aes_tx_sc = NULL; + struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; + struct iwlagn_p1k_cache *rx_p1ks; + u8 *rx_mic_key; + struct ieee80211_key_seq seq; + u32 cur_rx_iv32 = 0; + u16 p1k[IWLAGN_P1K_SIZE]; + int ret, i; + + mutex_lock(&priv->shrd->mutex); + + if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) && + !sta && !ctx->key_mapping_keys) + ret = iwl_set_default_wep_key(priv, ctx, key); + else + ret = iwl_set_dynamic_key(priv, ctx, key, sta); + + if (ret) { + IWL_ERR(priv, "Error setting key during suspend!\n"); + data->error = true; + } + + switch (key->cipher) { + case WLAN_CIPHER_SUITE_TKIP: + if (sta) { + tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; + tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; + + rx_p1ks = data->tkip->rx_uni; + + ieee80211_get_key_tx_seq(key, &seq); + tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); + tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); + + ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); + iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); + + memcpy(data->tkip->mic_keys.tx, + &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], + IWLAGN_MIC_KEY_SIZE); + + rx_mic_key = data->tkip->mic_keys.rx_unicast; + } else { + tkip_sc = + data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; + rx_p1ks = data->tkip->rx_multi; + rx_mic_key = data->tkip->mic_keys.rx_mcast; + } + + /* + * For non-QoS this relies on the fact that both the uCode and + * mac80211 use TID 0 (as they need to to avoid replay attacks) + * for checking the IV in the frames. + */ + for (i = 0; i < IWLAGN_NUM_RSC; i++) { + ieee80211_get_key_rx_seq(key, i, &seq); + tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); + tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); + /* wrapping isn't allowed, AP must rekey */ + if (seq.tkip.iv32 > cur_rx_iv32) + cur_rx_iv32 = seq.tkip.iv32; + } + + ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); + iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); + ieee80211_get_tkip_rx_p1k(key, data->bssid, + cur_rx_iv32 + 1, p1k); + iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); + + memcpy(rx_mic_key, + &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], + IWLAGN_MIC_KEY_SIZE); + + data->use_tkip = true; + data->use_rsc_tsc = true; + break; + case WLAN_CIPHER_SUITE_CCMP: + if (sta) { + u8 *pn = seq.ccmp.pn; + + aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; + aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; + + ieee80211_get_key_tx_seq(key, &seq); + aes_tx_sc->pn = cpu_to_le64( + (u64)pn[5] | + ((u64)pn[4] << 8) | + ((u64)pn[3] << 16) | + ((u64)pn[2] << 24) | + ((u64)pn[1] << 32) | + ((u64)pn[0] << 40)); + } else + aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; + + /* + * For non-QoS this relies on the fact that both the uCode and + * mac80211 use TID 0 for checking the IV in the frames. + */ + for (i = 0; i < IWLAGN_NUM_RSC; i++) { + u8 *pn = seq.ccmp.pn; + + ieee80211_get_key_rx_seq(key, i, &seq); + aes_sc->pn = cpu_to_le64( + (u64)pn[5] | + ((u64)pn[4] << 8) | + ((u64)pn[3] << 16) | + ((u64)pn[2] << 24) | + ((u64)pn[1] << 32) | + ((u64)pn[0] << 40)); + } + data->use_rsc_tsc = true; + break; + } + + mutex_unlock(&priv->shrd->mutex); +} + +int iwlagn_send_patterns(struct iwl_priv *priv, + struct cfg80211_wowlan *wowlan) +{ + struct iwlagn_wowlan_patterns_cmd *pattern_cmd; + struct iwl_host_cmd cmd = { + .id = REPLY_WOWLAN_PATTERNS, + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, + .flags = CMD_SYNC, + }; + int i, err; + + if (!wowlan->n_patterns) + return 0; + + cmd.len[0] = sizeof(*pattern_cmd) + + wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); + + pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); + if (!pattern_cmd) + return -ENOMEM; + + pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); + + for (i = 0; i < wowlan->n_patterns; i++) { + int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); + + memcpy(&pattern_cmd->patterns[i].mask, + wowlan->patterns[i].mask, mask_len); + memcpy(&pattern_cmd->patterns[i].pattern, + wowlan->patterns[i].pattern, + wowlan->patterns[i].pattern_len); + pattern_cmd->patterns[i].mask_size = mask_len; + pattern_cmd->patterns[i].pattern_size = + wowlan->patterns[i].pattern_len; + } + + cmd.data[0] = pattern_cmd; + err = iwl_trans_send_cmd(trans(priv), &cmd); + kfree(pattern_cmd); + return err; +} + +int iwlagn_suspend(struct iwl_priv *priv, + struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) +{ + struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; + struct iwl_rxon_cmd rxon; + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; + struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; + struct iwlagn_d3_config_cmd d3_cfg_cmd = {}; + struct wowlan_key_data key_data = { + .ctx = ctx, + .bssid = ctx->active.bssid_addr, + .use_rsc_tsc = false, + .tkip = &tkip_cmd, + .use_tkip = false, + }; + int ret, i; + u16 seq; + + key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); + if (!key_data.rsc_tsc) + return -ENOMEM; + + memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); + + /* + * We know the last used seqno, and the uCode expects to know that + * one, it will increment before TX. + */ + seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; + wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); + + /* + * For QoS counters, we store the one to use next, so subtract 0x10 + * since the uCode will add 0x10 before using the value. + */ + for (i = 0; i < 8; i++) { + seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; + seq -= 0x10; + wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); + } + + if (wowlan->disconnect) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | + IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); + if (wowlan->magic_pkt) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); + if (wowlan->gtk_rekey_failure) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); + if (wowlan->eap_identity_req) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); + if (wowlan->four_way_handshake) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); + if (wowlan->n_patterns) + wakeup_filter_cmd.enabled |= + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); + + if (wowlan->rfkill_release) + d3_cfg_cmd.wakeup_flags |= + cpu_to_le32(IWLAGN_D3_WAKEUP_RFKILL); + + iwl_scan_cancel_timeout(priv, 200); + + memcpy(&rxon, &ctx->active, sizeof(rxon)); + + iwl_trans_stop_device(trans(priv)); + + priv->shrd->wowlan = true; + + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); + if (ret) + goto out; + + /* now configure WoWLAN ucode */ + ret = iwl_alive_start(priv); + if (ret) + goto out; + + memcpy(&ctx->staging, &rxon, sizeof(rxon)); + ret = iwlagn_commit_rxon(priv, ctx); + if (ret) + goto out; + + ret = iwl_power_update_mode(priv, true); + if (ret) + goto out; + + if (!iwlagn_mod_params.sw_crypto) { + /* mark all keys clear */ + priv->ucode_key_table = 0; + ctx->key_mapping_keys = 0; + + /* + * This needs to be unlocked due to lock ordering + * constraints. Since we're in the suspend path + * that isn't really a problem though. + */ + mutex_unlock(&priv->shrd->mutex); + ieee80211_iter_keys(priv->hw, ctx->vif, + iwlagn_wowlan_program_keys, + &key_data); + mutex_lock(&priv->shrd->mutex); + if (key_data.error) { + ret = -EIO; + goto out; + } + + if (key_data.use_rsc_tsc) { + struct iwl_host_cmd rsc_tsc_cmd = { + .id = REPLY_WOWLAN_TSC_RSC_PARAMS, + .flags = CMD_SYNC, + .data[0] = key_data.rsc_tsc, + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, + .len[0] = sizeof(key_data.rsc_tsc), + }; + + ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); + if (ret) + goto out; + } + + if (key_data.use_tkip) { + ret = iwl_trans_send_cmd_pdu(trans(priv), + REPLY_WOWLAN_TKIP_PARAMS, + CMD_SYNC, sizeof(tkip_cmd), + &tkip_cmd); + if (ret) + goto out; + } + + if (priv->have_rekey_data) { + memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); + memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); + kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); + memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); + kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); + kek_kck_cmd.replay_ctr = priv->replay_ctr; + + ret = iwl_trans_send_cmd_pdu(trans(priv), + REPLY_WOWLAN_KEK_KCK_MATERIAL, + CMD_SYNC, sizeof(kek_kck_cmd), + &kek_kck_cmd); + if (ret) + goto out; + } + } + + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, + sizeof(d3_cfg_cmd), &d3_cfg_cmd); + if (ret) + goto out; + + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, + CMD_SYNC, sizeof(wakeup_filter_cmd), + &wakeup_filter_cmd); + if (ret) + goto out; + + ret = iwlagn_send_patterns(priv, wowlan); + out: + kfree(key_data.rsc_tsc); + return ret; +} +#endif diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index d325132..5d8d2f4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -119,6 +119,12 @@ u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); int iwlagn_send_beacon_cmd(struct iwl_priv *priv); +#ifdef CONFIG_PM_SLEEP +int iwlagn_send_patterns(struct iwl_priv *priv, + struct cfg80211_wowlan *wowlan); +int iwlagn_suspend(struct iwl_priv *priv, + struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); +#endif /* rx */ int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index b46702c..073e827 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -368,209 +368,13 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, } #ifdef CONFIG_PM_SLEEP -struct wowlan_key_data { - struct iwl_rxon_context *ctx; - struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; - struct iwlagn_wowlan_tkip_params_cmd *tkip; - const u8 *bssid; - bool error, use_rsc_tsc, use_tkip; -}; - -static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) -{ - int i; - - for (i = 0; i < IWLAGN_P1K_SIZE; i++) - out[i] = cpu_to_le16(p1k[i]); -} - -static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key, - void *_data) -{ - struct iwl_priv *priv = hw->priv; - struct wowlan_key_data *data = _data; - struct iwl_rxon_context *ctx = data->ctx; - struct aes_sc *aes_sc, *aes_tx_sc = NULL; - struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; - struct iwlagn_p1k_cache *rx_p1ks; - u8 *rx_mic_key; - struct ieee80211_key_seq seq; - u32 cur_rx_iv32 = 0; - u16 p1k[IWLAGN_P1K_SIZE]; - int ret, i; - - mutex_lock(&priv->shrd->mutex); - - if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) && - !sta && !ctx->key_mapping_keys) - ret = iwl_set_default_wep_key(priv, ctx, key); - else - ret = iwl_set_dynamic_key(priv, ctx, key, sta); - - if (ret) { - IWL_ERR(priv, "Error setting key during suspend!\n"); - data->error = true; - } - - switch (key->cipher) { - case WLAN_CIPHER_SUITE_TKIP: - if (sta) { - tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; - tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; - - rx_p1ks = data->tkip->rx_uni; - - ieee80211_get_key_tx_seq(key, &seq); - tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); - tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); - - ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); - iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); - - memcpy(data->tkip->mic_keys.tx, - &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], - IWLAGN_MIC_KEY_SIZE); - - rx_mic_key = data->tkip->mic_keys.rx_unicast; - } else { - tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; - rx_p1ks = data->tkip->rx_multi; - rx_mic_key = data->tkip->mic_keys.rx_mcast; - } - - /* - * For non-QoS this relies on the fact that both the uCode and - * mac80211 use TID 0 (as they need to to avoid replay attacks) - * for checking the IV in the frames. - */ - for (i = 0; i < IWLAGN_NUM_RSC; i++) { - ieee80211_get_key_rx_seq(key, i, &seq); - tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); - tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); - /* wrapping isn't allowed, AP must rekey */ - if (seq.tkip.iv32 > cur_rx_iv32) - cur_rx_iv32 = seq.tkip.iv32; - } - - ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); - iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); - ieee80211_get_tkip_rx_p1k(key, data->bssid, - cur_rx_iv32 + 1, p1k); - iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); - - memcpy(rx_mic_key, - &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], - IWLAGN_MIC_KEY_SIZE); - - data->use_tkip = true; - data->use_rsc_tsc = true; - break; - case WLAN_CIPHER_SUITE_CCMP: - if (sta) { - u8 *pn = seq.ccmp.pn; - - aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; - aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; - - ieee80211_get_key_tx_seq(key, &seq); - aes_tx_sc->pn = cpu_to_le64( - (u64)pn[5] | - ((u64)pn[4] << 8) | - ((u64)pn[3] << 16) | - ((u64)pn[2] << 24) | - ((u64)pn[1] << 32) | - ((u64)pn[0] << 40)); - } else - aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; - - /* - * For non-QoS this relies on the fact that both the uCode and - * mac80211 use TID 0 for checking the IV in the frames. - */ - for (i = 0; i < IWLAGN_NUM_RSC; i++) { - u8 *pn = seq.ccmp.pn; - - ieee80211_get_key_rx_seq(key, i, &seq); - aes_sc->pn = cpu_to_le64( - (u64)pn[5] | - ((u64)pn[4] << 8) | - ((u64)pn[3] << 16) | - ((u64)pn[2] << 24) | - ((u64)pn[1] << 32) | - ((u64)pn[0] << 40)); - } - data->use_rsc_tsc = true; - break; - } - - mutex_unlock(&priv->shrd->mutex); -} - -static int iwlagn_send_patterns(struct iwl_priv *priv, - struct cfg80211_wowlan *wowlan) -{ - struct iwlagn_wowlan_patterns_cmd *pattern_cmd; - struct iwl_host_cmd cmd = { - .id = REPLY_WOWLAN_PATTERNS, - .dataflags[0] = IWL_HCMD_DFL_NOCOPY, - .flags = CMD_SYNC, - }; - int i, err; - - if (!wowlan->n_patterns) - return 0; - - cmd.len[0] = sizeof(*pattern_cmd) + - wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); - - pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); - if (!pattern_cmd) - return -ENOMEM; - - pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); - - for (i = 0; i < wowlan->n_patterns; i++) { - int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); - - memcpy(&pattern_cmd->patterns[i].mask, - wowlan->patterns[i].mask, mask_len); - memcpy(&pattern_cmd->patterns[i].pattern, - wowlan->patterns[i].pattern, - wowlan->patterns[i].pattern_len); - pattern_cmd->patterns[i].mask_size = mask_len; - pattern_cmd->patterns[i].pattern_size = - wowlan->patterns[i].pattern_len; - } - - cmd.data[0] = pattern_cmd; - err = iwl_trans_send_cmd(trans(priv), &cmd); - kfree(pattern_cmd); - return err; -} static int iwlagn_mac_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) { struct iwl_priv *priv = hw->priv; - struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; - struct iwl_rxon_cmd rxon; struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; - struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; - struct wowlan_key_data key_data = { - .ctx = ctx, - .bssid = ctx->active.bssid_addr, - .use_rsc_tsc = false, - .tkip = &tkip_cmd, - .use_tkip = false, - }; - struct iwlagn_d3_config_cmd d3_cfg_cmd = {}; - int ret, i; - u16 seq; + int ret; if (WARN_ON(!wowlan)) return -EINVAL; @@ -585,153 +389,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, goto out; } - key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); - if (!key_data.rsc_tsc) { - ret = -ENOMEM; - goto out; - } - - memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); - - /* - * We know the last used seqno, and the uCode expects to know that - * one, it will increment before TX. - */ - seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; - wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); - - /* - * For QoS counters, we store the one to use next, so subtract 0x10 - * since the uCode will add 0x10 before using the value. - */ - for (i = 0; i < 8; i++) { - seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; - seq -= 0x10; - wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); - } - - if (wowlan->disconnect) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | - IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); - if (wowlan->magic_pkt) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); - if (wowlan->gtk_rekey_failure) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); - if (wowlan->eap_identity_req) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); - if (wowlan->four_way_handshake) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); - if (wowlan->n_patterns) - wakeup_filter_cmd.enabled |= - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); - - if (wowlan->rfkill_release) - d3_cfg_cmd.wakeup_flags |= - cpu_to_le32(IWLAGN_D3_WAKEUP_RFKILL); - - iwl_scan_cancel_timeout(priv, 200); - - memcpy(&rxon, &ctx->active, sizeof(rxon)); - - iwl_trans_stop_device(trans(priv)); - - priv->shrd->wowlan = true; - - ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); - if (ret) - goto error; - - /* now configure WoWLAN ucode */ - ret = iwl_alive_start(priv); - if (ret) - goto error; - - memcpy(&ctx->staging, &rxon, sizeof(rxon)); - ret = iwlagn_commit_rxon(priv, ctx); - if (ret) - goto error; - - ret = iwl_power_update_mode(priv, true); - if (ret) - goto error; - - if (!iwlagn_mod_params.sw_crypto) { - /* mark all keys clear */ - priv->ucode_key_table = 0; - ctx->key_mapping_keys = 0; - - /* - * This needs to be unlocked due to lock ordering - * constraints. Since we're in the suspend path - * that isn't really a problem though. - */ - mutex_unlock(&priv->shrd->mutex); - ieee80211_iter_keys(priv->hw, ctx->vif, - iwlagn_wowlan_program_keys, - &key_data); - mutex_lock(&priv->shrd->mutex); - if (key_data.error) { - ret = -EIO; - goto error; - } - - if (key_data.use_rsc_tsc) { - struct iwl_host_cmd rsc_tsc_cmd = { - .id = REPLY_WOWLAN_TSC_RSC_PARAMS, - .flags = CMD_SYNC, - .data[0] = key_data.rsc_tsc, - .dataflags[0] = IWL_HCMD_DFL_NOCOPY, - .len[0] = sizeof(*key_data.rsc_tsc), - }; - - ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); - if (ret) - goto error; - } - - if (key_data.use_tkip) { - ret = iwl_trans_send_cmd_pdu(trans(priv), - REPLY_WOWLAN_TKIP_PARAMS, - CMD_SYNC, sizeof(tkip_cmd), - &tkip_cmd); - if (ret) - goto error; - } - - if (priv->have_rekey_data) { - memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); - memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); - kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); - memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); - kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); - kek_kck_cmd.replay_ctr = priv->replay_ctr; - - ret = iwl_trans_send_cmd_pdu(trans(priv), - REPLY_WOWLAN_KEK_KCK_MATERIAL, - CMD_SYNC, sizeof(kek_kck_cmd), - &kek_kck_cmd); - if (ret) - goto error; - } - } - - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, - sizeof(d3_cfg_cmd), &d3_cfg_cmd); - if (ret) - goto error; - - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, - CMD_SYNC, sizeof(wakeup_filter_cmd), - &wakeup_filter_cmd); - if (ret) - goto error; - - ret = iwlagn_send_patterns(priv, wowlan); + ret = iwlagn_suspend(priv, hw, wowlan); if (ret) goto error; @@ -749,7 +407,6 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, ieee80211_restart_hw(priv->hw); out: mutex_unlock(&priv->shrd->mutex); - kfree(key_data.rsc_tsc); IWL_DEBUG_MAC80211(priv, "leave\n"); return ret; -- cgit v0.10.2 From 89db3b972c997d910b648497345fb0410ad04aec Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:18 -0800 Subject: iwlwifi: set "echo" host command length "echo" host command has no data, set the length to 0 Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index f7b0048..f9e9170 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1434,6 +1434,7 @@ int iwl_cmd_echo_test(struct iwl_priv *priv) int ret; struct iwl_host_cmd cmd = { .id = REPLY_ECHO, + .len = { 0 }, .flags = CMD_SYNC, }; -- cgit v0.10.2 From 94b3c45c7be7a392764e5945d4ebb095a42e5ef0 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 10 Nov 2011 06:55:19 -0800 Subject: iwlwifi: check status before send command Check the status before sending host command, if any of the condition match, cancel the host command before queue Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 461e1ae..09a31dc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -1001,6 +1001,20 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", get_cmd_string(cmd->id)); + if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status)) + return -EBUSY; + + + if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { + IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", + get_cmd_string(cmd->id)); + return -ECANCELED; + } + if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) { + IWL_ERR(trans, "Command %s failed: FW Error\n", + get_cmd_string(cmd->id)); + return -EIO; + } set_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", get_cmd_string(cmd->id)); @@ -1041,18 +1055,6 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) } } - if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { - IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", - get_cmd_string(cmd->id)); - ret = -ECANCELED; - goto fail; - } - if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) { - IWL_ERR(trans, "Command %s failed: FW Error\n", - get_cmd_string(cmd->id)); - ret = -EIO; - goto fail; - } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { IWL_ERR(trans, "Error: Response NULL in '%s'\n", get_cmd_string(cmd->id)); -- cgit v0.10.2 From 9cac4943aa15763a2b1f13d276ae03b4cd5aa9a1 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 10 Nov 2011 06:55:20 -0800 Subject: iwlwifi: fix unused label in iwl_send_cmd_sync Warning introduced by c847474b7dfdda304d0d8ffcc5a9db546b1cb3e9 iwlwifi: check status before send command Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 09a31dc..a6d898b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -1075,7 +1075,7 @@ cancel: trans_pcie->txq[trans->shrd->cmd_queue].meta[cmd_idx].flags &= ~CMD_WANT_SKB; } -fail: + if (cmd->reply_page) { iwl_free_pages(trans->shrd, cmd->reply_page); cmd->reply_page = 0; -- cgit v0.10.2 From 3ddf6befb98d5dd61466a0e0e585037f6dca352f Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 10 Nov 2011 06:55:21 -0800 Subject: iwlagn: convert remain-on-channel duration to TU The device expects TU but we get ms, so convert. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 073e827..05b1f0d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -957,7 +957,8 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, priv->hw_roc_channel = channel; priv->hw_roc_chantype = channel_type; - priv->hw_roc_duration = duration; + /* convert from ms to TU */ + priv->hw_roc_duration = DIV_ROUND_UP(1000 * duration, 1024); priv->hw_roc_start_notified = false; cancel_delayed_work(&priv->hw_roc_disable_work); -- cgit v0.10.2 From eb32043f430d74d4381b29273d174b376593d072 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 10 Nov 2011 06:55:22 -0800 Subject: iwlagn: don't always split remain-on-channel Due to the P2P context always having the associated bit set when we got to this code, we were splitting up the remain-on-channel durations unconditionally. This isn't needed -- if the P2P context is in P2P device type mode it doesn't impose restrictions on timing to skip it in that case. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 625beec..359d218 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -416,6 +416,8 @@ static u16 iwl_limit_dwell(struct iwl_priv *priv, u16 dwell_time) if (!iwl_is_associated_ctx(ctx)) continue; + if (ctx->staging.dev_type == RXON_DEV_TYPE_P2P) + continue; value = ctx->beacon_int; if (!value) value = IWL_PASSIVE_DWELL_BASE; -- cgit v0.10.2 From 0dcf50ca4ebdef5468aa2475de2b87feec5a1e8f Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 10 Nov 2011 06:55:23 -0800 Subject: iwlwifi: remove the use of the QOS debug flag This bit was used only once. Use IWL_DL_INFO instead. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 8e45fba..b73077f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -117,7 +117,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv, if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", + IWL_DEBUG_INFO(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 1dddf9b..a11e7aa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -166,7 +166,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DL_11H (1 << 28) #define IWL_DL_STATS (1 << 29) #define IWL_DL_TX_REPLY (1 << 30) -#define IWL_DL_QOS (1 << 31) +#define IWL_DL_UNUSED (1 << 31) #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) @@ -203,7 +203,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) #define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_QOS(p, f, a...) IWL_DEBUG(p, IWL_DL_QOS, f, ## a) +#define IWL_DEBUG_UNUSED(p, f, a...) IWL_DEBUG(p, IWL_DL_UNUSED, f, ## a) #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) #define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a) -- cgit v0.10.2 From 81a3de1ce2929fef2b112c048c50bc52b686f94d Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 10 Nov 2011 06:55:24 -0800 Subject: iwlwifi: add debug information on queue stop / wake Users complain that the traffic gets stalled sometimes. This will allow easier debugging. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index f0d6d94..fdb4c37 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -800,7 +800,8 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv, ctx->active.bssid_addr)) continue; ctx->last_tx_rejected = false; - iwl_trans_wake_any_queue(trans(priv), ctx->ctxid); + iwl_trans_wake_any_queue(trans(priv), ctx->ctxid, + "channel got active"); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index b73077f..8de97f5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -844,7 +844,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, if (ctx->last_tx_rejected) { ctx->last_tx_rejected = false; iwl_trans_wake_any_queue(trans(priv), - ctx->ctxid); + ctx->ctxid, + "Disassoc: flush queue"); } ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 014b98a..e6a02e0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -813,7 +813,8 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, iwl_is_associated_ctx(ctx) && ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION) { ctx->last_tx_rejected = true; - iwl_trans_stop_queue(trans(priv), txq_id); + iwl_trans_stop_queue(trans(priv), txq_id, + "Tx on passive channel"); IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index a11e7aa..40ef97b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -166,7 +166,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DL_11H (1 << 28) #define IWL_DL_STATS (1 << 29) #define IWL_DL_TX_REPLY (1 << 30) -#define IWL_DL_UNUSED (1 << 31) +#define IWL_DL_TX_QUEUES (1 << 31) #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) @@ -203,7 +203,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) #define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_UNUSED(p, f, a...) IWL_DEBUG(p, IWL_DL_UNUSED, f, ## a) +#define IWL_DEBUG_TX_QUEUES(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_QUEUES, f, ## a) #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) #define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 2b6756e..afaaa2a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -355,7 +355,7 @@ static inline void iwl_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) } static inline void iwl_wake_queue(struct iwl_trans *trans, - struct iwl_tx_queue *txq) + struct iwl_tx_queue *txq, const char *msg) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -363,13 +363,22 @@ static inline void iwl_wake_queue(struct iwl_trans *trans, struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) - if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) + if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) { + if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) { iwl_wake_sw_queue(priv(trans), ac); + IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d ac %d. %s", + hwq, ac, msg); + } else { + IWL_DEBUG_TX_QUEUES(trans, "Don't wake hwq %d ac %d" + " stop count %d. %s", + hwq, ac, atomic_read(&trans_pcie-> + queue_stop_count[ac]), msg); + } + } } static inline void iwl_stop_queue(struct iwl_trans *trans, - struct iwl_tx_queue *txq) + struct iwl_tx_queue *txq, const char *msg) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -377,9 +386,23 @@ static inline void iwl_stop_queue(struct iwl_trans *trans, struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) - if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) + if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) { + if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) { iwl_stop_sw_queue(priv(trans), ac); + IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d ac %d" + " stop count %d. %s", + hwq, ac, atomic_read(&trans_pcie-> + queue_stop_count[ac]), msg); + } else { + IWL_DEBUG_TX_QUEUES(trans, "Don't stop hwq %d ac %d" + " stop count %d. %s", + hwq, ac, atomic_read(&trans_pcie-> + queue_stop_count[ac]), msg); + } + } else { + IWL_DEBUG_TX_QUEUES(trans, "stop hwq %d, but it is stopped/ %s", + hwq, msg); + } } #ifdef ieee80211_stop_queue diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index a6d898b..6dba151 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -430,7 +430,7 @@ void iwl_trans_tx_queue_set_status(struct iwl_trans *trans, txq->sched_retry = scd_retry; - IWL_DEBUG_INFO(trans, "%s %s Queue %d on FIFO %d\n", + IWL_DEBUG_TX_QUEUES(trans, "%s %s Queue %d on FIFO %d\n", active ? "Activate" : "Deactivate", scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id); } @@ -561,12 +561,13 @@ int iwl_trans_pcie_tx_agg_alloc(struct iwl_trans *trans, tid_data = &trans->shrd->tid_data[sta_id][tid]; if (tid_data->tfds_in_queue == 0) { - IWL_DEBUG_HT(trans, "HW queue is empty\n"); + IWL_DEBUG_TX_QUEUES(trans, "HW queue is empty\n"); tid_data->agg.state = IWL_AGG_ON; iwl_start_tx_ba_trans_ready(priv(trans), ctx, sta_id, tid); } else { - IWL_DEBUG_HT(trans, "HW queue is NOT empty: %d packets in HW" - "queue\n", tid_data->tfds_in_queue); + IWL_DEBUG_TX_QUEUES(trans, + "HW queue is NOT empty: %d packets in HW" + " queue\n", tid_data->tfds_in_queue); tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; } spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); @@ -643,14 +644,15 @@ int iwl_trans_pcie_tx_agg_disable(struct iwl_trans *trans, /* The queue is not empty */ if (write_ptr != read_ptr) { - IWL_DEBUG_HT(trans, "Stopping a non empty AGG HW QUEUE\n"); + IWL_DEBUG_TX_QUEUES(trans, + "Stopping a non empty AGG HW QUEUE\n"); trans->shrd->tid_data[sta_id][tid].agg.state = IWL_EMPTYING_HW_QUEUE_DELBA; spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); return 0; } - IWL_DEBUG_HT(trans, "HW queue is empty\n"); + IWL_DEBUG_TX_QUEUES(trans, "HW queue is empty\n"); turn_off: trans->shrd->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index da34110..a1a5833 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1231,7 +1231,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, txq->need_update = 1; iwl_txq_update_write_ptr(trans, txq); } else { - iwl_stop_queue(trans, txq); + iwl_stop_queue(trans, txq, "Queue is full"); } } return 0; @@ -1283,20 +1283,21 @@ static int iwlagn_txq_check_empty(struct iwl_trans *trans, /* aggregated HW queue */ if ((txq_id == tid_data->agg.txq_id) && (q->read_ptr == q->write_ptr)) { - IWL_DEBUG_HT(trans, + IWL_DEBUG_TX_QUEUES(trans, "HW queue empty: continue DELBA flow\n"); iwl_trans_pcie_txq_agg_disable(trans, txq_id); tid_data->agg.state = IWL_AGG_OFF; iwl_stop_tx_ba_trans_ready(priv(trans), NUM_IWL_RXON_CTX, sta_id, tid); - iwl_wake_queue(trans, &trans_pcie->txq[txq_id]); + iwl_wake_queue(trans, &trans_pcie->txq[txq_id], + "DELBA flow complete"); } break; case IWL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - IWL_DEBUG_HT(trans, + IWL_DEBUG_TX_QUEUES(trans, "HW queue empty: continue ADDBA flow\n"); tid_data->agg.state = IWL_AGG_ON; iwl_start_tx_ba_trans_ready(priv(trans), @@ -1354,7 +1355,7 @@ static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, ssn , tfd_num, txq_id, txq->swq_id); freed = iwl_tx_queue_reclaim(trans, txq_id, tfd_num, skbs); if (iwl_queue_space(&txq->q) > txq->q.low_mark && cond) - iwl_wake_queue(trans, txq); + iwl_wake_queue(trans, txq, "Packets reclaimed"); } iwl_free_tfds_in_queue(trans, sta_id, tid, freed); @@ -1418,7 +1419,8 @@ static int iwl_trans_pcie_resume(struct iwl_trans *trans) #endif /* CONFIG_PM_SLEEP */ static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, - enum iwl_rxon_context_id ctx) + enum iwl_rxon_context_id ctx, + const char *msg) { u8 ac, txq_id; struct iwl_trans_pcie *trans_pcie = @@ -1426,11 +1428,11 @@ static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, for (ac = 0; ac < AC_NUM; ac++) { txq_id = trans_pcie->ac_to_queue[ctx][ac]; - IWL_DEBUG_INFO(trans, "Queue Status: Q[%d] %s\n", + IWL_DEBUG_TX_QUEUES(trans, "Queue Status: Q[%d] %s\n", ac, (atomic_read(&trans_pcie->queue_stop_count[ac]) > 0) ? "stopped" : "awake"); - iwl_wake_queue(trans, &trans_pcie->txq[txq_id]); + iwl_wake_queue(trans, &trans_pcie->txq[txq_id], msg); } } @@ -1453,11 +1455,12 @@ static struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd) return iwl_trans; } -static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id) +static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id, + const char *msg) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - iwl_stop_queue(trans, &trans_pcie->txq[txq_id]); + iwl_stop_queue(trans, &trans_pcie->txq[txq_id], msg); } #define IWL_FLUSH_WAIT_MS 2000 diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 1ecdd1c2..7839362 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -171,7 +171,8 @@ struct iwl_trans_ops { void (*tx_start)(struct iwl_trans *trans); void (*wake_any_queue)(struct iwl_trans *trans, - enum iwl_rxon_context_id ctx); + enum iwl_rxon_context_id ctx, + const char *msg); int (*send_cmd)(struct iwl_trans *trans, struct iwl_host_cmd *cmd); @@ -196,7 +197,7 @@ struct iwl_trans_ops { void (*free)(struct iwl_trans *trans); - void (*stop_queue)(struct iwl_trans *trans, int q); + void (*stop_queue)(struct iwl_trans *trans, int q, const char *msg); int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); int (*check_stuck_queue)(struct iwl_trans *trans, int q); @@ -277,9 +278,10 @@ static inline void iwl_trans_tx_start(struct iwl_trans *trans) } static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, - enum iwl_rxon_context_id ctx) + enum iwl_rxon_context_id ctx, + const char *msg) { - trans->ops->wake_any_queue(trans, ctx); + trans->ops->wake_any_queue(trans, ctx, msg); } @@ -339,9 +341,10 @@ static inline void iwl_trans_free(struct iwl_trans *trans) trans->ops->free(trans); } -static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q) +static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q, + const char *msg) { - trans->ops->stop_queue(trans, q); + trans->ops->stop_queue(trans, q, msg); } static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) -- cgit v0.10.2 From 383b0874abc8c23f15a15773812fb09f23078311 Mon Sep 17 00:00:00 2001 From: "Venkataraman, Meenakshi" Date: Thu, 10 Nov 2011 06:55:25 -0800 Subject: iwlwifi: fix rate-scaling algorithm for BT combo devices iwlwifi tries to avoid using antenna B in BT combo devices when BT is active. A bug in the rate-scaling algorithm was causing the combo device to never attempt MIMO rates. Fix the algorithm to opportunistically try MIMO rates when BT traffic is low. Signed-off-by: Meenakshi Venkataraman Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 66118ce..359c47a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -1458,10 +1458,8 @@ static int rs_move_legacy_other(struct iwl_priv *priv, break; case IWL_BT_COEX_TRAFFIC_LOAD_LOW: /* avoid antenna B unless MIMO */ - valid_tx_ant = - first_antenna(hw_params(priv).valid_tx_ant); if (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2) - tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; + tbl->action = IWL_LEGACY_SWITCH_SISO; break; case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: @@ -1636,10 +1634,8 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, break; case IWL_BT_COEX_TRAFFIC_LOAD_LOW: /* avoid antenna B unless MIMO */ - valid_tx_ant = - first_antenna(hw_params(priv).valid_tx_ant); if (tbl->action == IWL_SISO_SWITCH_ANTENNA2) - tbl->action = IWL_SISO_SWITCH_ANTENNA1; + tbl->action = IWL_SISO_SWITCH_MIMO2_AB; break; case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: -- cgit v0.10.2 From 1431b2166a83ba0cc46007269298caa53c86a6d0 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Thu, 10 Nov 2011 06:55:26 -0800 Subject: iwlagn: Remove dependence of iwl_priv from eeprom routines. Make the eeprom routines less dependent on the iwl_priv structure. Don't use the priv when bus structure is sufficient. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index a4e43bd..2fcde58 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -149,23 +149,23 @@ static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */ * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ -static int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv) +static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) { u16 count; int ret; for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ - iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(bus, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = iwl_poll_bit(bus(priv), CSR_HW_IF_CONFIG_REG, + ret = iwl_poll_bit(bus, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); if (ret >= 0) { - IWL_DEBUG_EEPROM(priv, + IWL_DEBUG_EEPROM(bus, "Acquired semaphore after %d tries.\n", count+1); return ret; @@ -175,9 +175,9 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv) return ret; } -static void iwl_eeprom_release_semaphore(struct iwl_priv *priv) +static void iwl_eeprom_release_semaphore(struct iwl_bus *bus) { - iwl_clear_bit(bus(priv), CSR_HW_IF_CONFIG_REG, + iwl_clear_bit(bus, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } @@ -302,19 +302,19 @@ void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) * ******************************************************************************/ -static void iwl_set_otp_access(struct iwl_priv *priv, enum iwl_access_mode mode) +static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode) { - iwl_read32(bus(priv), CSR_OTP_GP_REG); + iwl_read32(bus, CSR_OTP_GP_REG); if (mode == IWL_OTP_ACCESS_ABSOLUTE) - iwl_clear_bit(bus(priv), CSR_OTP_GP_REG, + iwl_clear_bit(bus, CSR_OTP_GP_REG, CSR_OTP_GP_REG_OTP_ACCESS_MODE); else - iwl_set_bit(bus(priv), CSR_OTP_GP_REG, + iwl_set_bit(bus, CSR_OTP_GP_REG, CSR_OTP_GP_REG_OTP_ACCESS_MODE); } -static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) +static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) { u32 otpgp; int nvm_type; @@ -322,7 +322,7 @@ static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) /* OTP only valid for CP/PP and after */ switch (hw_rev & CSR_HW_REV_TYPE_MSK) { case CSR_HW_REV_TYPE_NONE: - IWL_ERR(priv, "Unknown hardware type\n"); + IWL_ERR(bus, "Unknown hardware type\n"); return -ENOENT; case CSR_HW_REV_TYPE_5300: case CSR_HW_REV_TYPE_5350: @@ -331,7 +331,7 @@ static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) nvm_type = NVM_DEVICE_TYPE_EEPROM; break; default: - otpgp = iwl_read32(bus(priv), CSR_OTP_GP_REG); + otpgp = iwl_read32(bus, CSR_OTP_GP_REG); if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT) nvm_type = NVM_DEVICE_TYPE_OTP; else @@ -341,73 +341,73 @@ static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) return nvm_type; } -static int iwl_init_otp_access(struct iwl_priv *priv) +static int iwl_init_otp_access(struct iwl_bus *bus) { int ret; /* Enable 40MHz radio clock */ - iwl_write32(bus(priv), CSR_GP_CNTRL, - iwl_read32(bus(priv), CSR_GP_CNTRL) | + iwl_write32(bus, CSR_GP_CNTRL, + iwl_read32(bus, CSR_GP_CNTRL) | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); /* wait for clock to be ready */ - ret = iwl_poll_bit(bus(priv), CSR_GP_CNTRL, + ret = iwl_poll_bit(bus, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) - IWL_ERR(priv, "Time out access OTP\n"); + IWL_ERR(bus, "Time out access OTP\n"); else { - iwl_set_bits_prph(bus(priv), APMG_PS_CTRL_REG, + iwl_set_bits_prph(bus, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - iwl_clear_bits_prph(bus(priv), APMG_PS_CTRL_REG, + iwl_clear_bits_prph(bus, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); /* * CSR auto clock gate disable bit - * this is only applicable for HW with OTP shadow RAM */ - if (priv->cfg->base_params->shadow_ram_support) - iwl_set_bit(bus(priv), CSR_DBG_LINK_PWR_MGMT_REG, + if (priv(bus)->cfg->base_params->shadow_ram_support) + iwl_set_bit(bus, CSR_DBG_LINK_PWR_MGMT_REG, CSR_RESET_LINK_PWR_MGMT_DISABLED); } return ret; } -static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, __le16 *eeprom_data) +static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) { int ret = 0; u32 r; u32 otpgp; - iwl_write32(bus(priv), CSR_EEPROM_REG, + iwl_write32(bus, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = iwl_poll_bit(bus(priv), CSR_EEPROM_REG, + ret = iwl_poll_bit(bus, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IWL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IWL_ERR(priv, "Time out reading OTP[%d]\n", addr); + IWL_ERR(bus, "Time out reading OTP[%d]\n", addr); return ret; } - r = iwl_read32(bus(priv), CSR_EEPROM_REG); + r = iwl_read32(bus, CSR_EEPROM_REG); /* check for ECC errors: */ - otpgp = iwl_read32(bus(priv), CSR_OTP_GP_REG); + otpgp = iwl_read32(bus, CSR_OTP_GP_REG); if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { /* stop in this case */ /* set the uncorrectable OTP ECC bit for acknowledgement */ - iwl_set_bit(bus(priv), CSR_OTP_GP_REG, + iwl_set_bit(bus, CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); - IWL_ERR(priv, "Uncorrectable OTP ECC error, abort OTP read\n"); + IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n"); return -EINVAL; } if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { /* continue in this case */ /* set the correctable OTP ECC bit for acknowledgement */ - iwl_set_bit(bus(priv), CSR_OTP_GP_REG, + iwl_set_bit(bus, CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); - IWL_ERR(priv, "Correctable OTP ECC error, continue read\n"); + IWL_ERR(bus, "Correctable OTP ECC error, continue read\n"); } *eeprom_data = cpu_to_le16(r >> 16); return 0; @@ -416,20 +416,20 @@ static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, __le16 *eeprom_dat /* * iwl_is_otp_empty: check for empty OTP */ -static bool iwl_is_otp_empty(struct iwl_priv *priv) +static bool iwl_is_otp_empty(struct iwl_bus *bus) { u16 next_link_addr = 0; __le16 link_value; bool is_empty = false; /* locate the beginning of OTP link list */ - if (!iwl_read_otp_word(priv, next_link_addr, &link_value)) { + if (!iwl_read_otp_word(bus, next_link_addr, &link_value)) { if (!link_value) { - IWL_ERR(priv, "OTP is empty\n"); + IWL_ERR(bus, "OTP is empty\n"); is_empty = true; } } else { - IWL_ERR(priv, "Unable to read first block of OTP list.\n"); + IWL_ERR(bus, "Unable to read first block of OTP list.\n"); is_empty = true; } @@ -446,7 +446,7 @@ static bool iwl_is_otp_empty(struct iwl_priv *priv) * we should read and used to configure the device. * only perform this operation if shadow RAM is disabled */ -static int iwl_find_otp_image(struct iwl_priv *priv, +static int iwl_find_otp_image(struct iwl_bus *bus, u16 *validblockaddr) { u16 next_link_addr = 0, valid_addr; @@ -454,10 +454,10 @@ static int iwl_find_otp_image(struct iwl_priv *priv, int usedblocks = 0; /* set addressing mode to absolute to traverse the link list */ - iwl_set_otp_access(priv, IWL_OTP_ACCESS_ABSOLUTE); + iwl_set_otp_access(bus, IWL_OTP_ACCESS_ABSOLUTE); /* checking for empty OTP or error */ - if (iwl_is_otp_empty(priv)) + if (iwl_is_otp_empty(bus)) return -EINVAL; /* @@ -471,9 +471,9 @@ static int iwl_find_otp_image(struct iwl_priv *priv, */ valid_addr = next_link_addr; next_link_addr = le16_to_cpu(link_value) * sizeof(u16); - IWL_DEBUG_EEPROM(priv, "OTP blocks %d addr 0x%x\n", + IWL_DEBUG_EEPROM(bus, "OTP blocks %d addr 0x%x\n", usedblocks, next_link_addr); - if (iwl_read_otp_word(priv, next_link_addr, &link_value)) + if (iwl_read_otp_word(bus, next_link_addr, &link_value)) return -EINVAL; if (!link_value) { /* @@ -488,10 +488,10 @@ static int iwl_find_otp_image(struct iwl_priv *priv, } /* more in the link list, continue */ usedblocks++; - } while (usedblocks <= priv->cfg->base_params->max_ll_items); + } while (usedblocks <= priv(bus)->cfg->base_params->max_ll_items); /* OTP has no valid blocks */ - IWL_DEBUG_EEPROM(priv, "OTP has no valid blocks\n"); + IWL_DEBUG_EEPROM(bus, "OTP has no valid blocks\n"); return -EINVAL; } @@ -504,28 +504,28 @@ static int iwl_find_otp_image(struct iwl_priv *priv, * iwl_get_max_txpower_avg - get the highest tx power from all chains. * find the highest tx power from all chains for the channel */ -static s8 iwl_get_max_txpower_avg(struct iwl_priv *priv, +static s8 iwl_get_max_txpower_avg(struct iwl_cfg *cfg, struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, int element, s8 *max_txpower_in_half_dbm) { s8 max_txpower_avg = 0; /* (dBm) */ /* Take the highest tx power from any valid chains */ - if ((priv->cfg->valid_tx_ant & ANT_A) && + if ((cfg->valid_tx_ant & ANT_A) && (enhanced_txpower[element].chain_a_max > max_txpower_avg)) max_txpower_avg = enhanced_txpower[element].chain_a_max; - if ((priv->cfg->valid_tx_ant & ANT_B) && + if ((cfg->valid_tx_ant & ANT_B) && (enhanced_txpower[element].chain_b_max > max_txpower_avg)) max_txpower_avg = enhanced_txpower[element].chain_b_max; - if ((priv->cfg->valid_tx_ant & ANT_C) && + if ((cfg->valid_tx_ant & ANT_C) && (enhanced_txpower[element].chain_c_max > max_txpower_avg)) max_txpower_avg = enhanced_txpower[element].chain_c_max; - if (((priv->cfg->valid_tx_ant == ANT_AB) | - (priv->cfg->valid_tx_ant == ANT_BC) | - (priv->cfg->valid_tx_ant == ANT_AC)) && + if (((cfg->valid_tx_ant == ANT_AB) | + (cfg->valid_tx_ant == ANT_BC) | + (cfg->valid_tx_ant == ANT_AC)) && (enhanced_txpower[element].mimo2_max > max_txpower_avg)) max_txpower_avg = enhanced_txpower[element].mimo2_max; - if ((priv->cfg->valid_tx_ant == ANT_ABC) && + if ((cfg->valid_tx_ant == ANT_ABC) && (enhanced_txpower[element].mimo3_max > max_txpower_avg)) max_txpower_avg = enhanced_txpower[element].mimo3_max; @@ -627,7 +627,7 @@ void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) ((txp->delta_20_in_40 & 0xf0) >> 4), (txp->delta_20_in_40 & 0x0f)); - max_txp_avg = iwl_get_max_txpower_avg(priv, txp_array, idx, + max_txp_avg = iwl_get_max_txpower_avg(priv->cfg, txp_array, idx, &max_txp_avg_halfdbm); /* @@ -660,7 +660,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) u16 validblockaddr = 0; u16 cache_addr = 0; - priv->nvm_device_type = iwl_get_nvm_type(priv, hw_rev); + priv->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev); if (priv->nvm_device_type == -ENOENT) return -ENOENT; /* allocate eeprom */ @@ -683,7 +683,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) } /* Make sure driver (instead of uCode) is allowed to read EEPROM */ - ret = iwl_eeprom_acquire_semaphore(priv); + ret = iwl_eeprom_acquire_semaphore(bus(priv)); if (ret < 0) { IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; @@ -692,7 +692,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) { - ret = iwl_init_otp_access(priv); + ret = iwl_init_otp_access(bus(priv)); if (ret) { IWL_ERR(priv, "Failed to initialize OTP access.\n"); ret = -ENOENT; @@ -707,7 +707,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); /* traversing the linked list if no shadow ram supported */ if (!priv->cfg->base_params->shadow_ram_support) { - if (iwl_find_otp_image(priv, &validblockaddr)) { + if (iwl_find_otp_image(bus(priv), &validblockaddr)) { ret = -ENOENT; goto done; } @@ -716,7 +716,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) addr += sizeof(u16)) { __le16 eeprom_data; - ret = iwl_read_otp_word(priv, addr, &eeprom_data); + ret = iwl_read_otp_word(bus(priv), addr, &eeprom_data); if (ret) goto done; e[cache_addr / 2] = eeprom_data; @@ -750,7 +750,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) ret = 0; done: - iwl_eeprom_release_semaphore(priv); + iwl_eeprom_release_semaphore(bus(priv)); err: if (ret) -- cgit v0.10.2 From 97b52cfd1ae0c2f7284ee36e80ea0c22000f90bf Mon Sep 17 00:00:00 2001 From: Don Fry Date: Thu, 10 Nov 2011 06:55:27 -0800 Subject: iwlagn: move nvm_device_type from iwl_priv to iwl_trans The nvm_device_type is eeprom related and does not need to be part of the iwl_priv structure. Move it and eliminate access to the iwl_priv structure. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 42871ba..68b04f5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -430,7 +430,7 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file, eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " "version: 0x%x\n", - (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) + (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) ? "OTP" : "EEPROM", eeprom_ver); for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 2c68b9b..556e4a2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -944,7 +944,6 @@ struct iwl_priv { /* eeprom -- this is in the card's little endian byte order */ u8 *eeprom; - int nvm_device_type; struct iwl_eeprom_calib_info *calib_info; enum nl80211_iftype iw_mode; diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index 2fcde58..dcada08 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -182,32 +182,32 @@ static void iwl_eeprom_release_semaphore(struct iwl_bus *bus) } -static int iwl_eeprom_verify_signature(struct iwl_priv *priv) +static int iwl_eeprom_verify_signature(struct iwl_trans *trans) { - u32 gp = iwl_read32(bus(priv), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = iwl_read32(bus(trans), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; - IWL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); + IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp); switch (gp) { case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP: - if (priv->nvm_device_type != NVM_DEVICE_TYPE_OTP) { - IWL_ERR(priv, "EEPROM with bad signature: 0x%08x\n", + if (trans->nvm_device_type != NVM_DEVICE_TYPE_OTP) { + IWL_ERR(trans, "EEPROM with bad signature: 0x%08x\n", gp); ret = -ENOENT; } break; case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: - if (priv->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) { - IWL_ERR(priv, "OTP with bad signature: 0x%08x\n", gp); + if (trans->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) { + IWL_ERR(trans, "OTP with bad signature: 0x%08x\n", gp); ret = -ENOENT; } break; case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP: default: - IWL_ERR(priv, "bad EEPROM/OTP signature, type=%s, " + IWL_ERR(trans, "bad EEPROM/OTP signature, type=%s, " "EEPROM_GP=0x%08x\n", - (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) + (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) ? "OTP" : "EEPROM", gp); ret = -ENOENT; break; @@ -660,8 +660,8 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) u16 validblockaddr = 0; u16 cache_addr = 0; - priv->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev); - if (priv->nvm_device_type == -ENOENT) + trans(priv)->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev); + if (trans(priv)->nvm_device_type == -ENOENT) return -ENOENT; /* allocate eeprom */ sz = priv->cfg->base_params->eeprom_size; @@ -675,7 +675,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) iwl_apm_init(priv); - ret = iwl_eeprom_verify_signature(priv); + ret = iwl_eeprom_verify_signature(trans(priv)); if (ret < 0) { IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; @@ -690,7 +690,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) goto err; } - if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) { + if (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) { ret = iwl_init_otp_access(bus(priv)); if (ret) { @@ -744,7 +744,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) } IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", - (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) + (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) ? "OTP" : "EEPROM", iwl_eeprom_query16(priv, EEPROM_VERSION)); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 7839362..50227eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -247,6 +247,9 @@ struct iwl_trans { struct fw_img ucode_init; struct fw_img ucode_wowlan; + /* eeprom related variables */ + int nvm_device_type; + /* pointer to trans specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ char trans_specific[0] __attribute__((__aligned__(sizeof(void *)))); -- cgit v0.10.2 From e9b7086b80c4d9e354f4edc9e280ae85a60df408 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Fri, 11 Nov 2011 10:15:11 -0800 Subject: ARM: OMAP: Fix reprogramming of dpll1 rate Commit a66cb3454f220f49f900646ebdc76cb943319eb7 (ARM: OMAP: Map SRAM later on with ioremap_exec()) moved the SRAM init to happen later to remove a dependency to early SoC detection for map_io. This broke booting on some boards not using Kconfig option for OMAP_CLOCKS_SET_BY_BOOTLOADER as the dpll1 reprogramming would cause the following error: kernel BUG at arch/arm/plat-omap/sram.c:226! Internal error: Oops - undefined instruction: 0 [#1] PREEMPT Modules linked in: CPU: 0 Not tainted (3.2.0-rc1-e3 #9) PC is at omap_sram_reprogram_clock+0x28/0x30 LR is at omap1_select_table_rate+0x88/0xb4 pc : [] lr : [] psr: 600000d3 sp : c035bf10 ip : c035bf20 fp : c035bf1c r10: c035bfd4 r9 : 54029252 r8 : c03f8120 r7 : c0362b50 r6 : 00b71b00 r5 : c03873cc r4 : c0362b40 r3 : 00000000 r2 : c0362b40 r1 : 0000010a r0 : 00002cb0 Flags: nZCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel Control: 0000317f Table: 10004000 DAC: 00000017 Process swapper (pid: 0, stack limit = 0xc035a270) Stack: (0xc035bf10 to 0xc035c000) bf00: c035bf3c c035bf20 c0019f54 c001b0ac bf20: 00001000 00002cb3 00000004 c035ed4c c035bf74 c035bf40 c033ea24 c0019edc bf40: c02f526c 00000002 00000015 bc058c9b 93111a16 c035335c 02000000 c035ed4c bf60: c035ed4c c03f8120 c035bf84 c035bf78 c00194c4 c033e8ec c035bfc4 c035bf88 bf80: c033bc24 c00194a0 c035bf90 c035bf98 00000000 00000000 00000000 00000000 bfa0: 00000001 00000000 c0354678 c035ece4 10004000 103532f4 c035bff4 c035bfc8 bfc0: c0338574 c033b598 00000000 00000000 00000000 c035467c 0000317d c035c03c bfe0: c0354678 c035ece4 00000000 c035bff8 10008040 c0338508 00000000 00000000 Backtrace: [] (omap_sram_reprogram_clock+0x0/0x30) from [] (omap1_select_table_rate+0x88/0xb4) [] (omap1_select_table_rate+0x0/0xb4) from [] (omap1_clk_init+0x148/0x334) r7:c035ed4c r6:00000004 r5:00002cb3 r4:00001000 [] (omap1_clk_init+0x0/0x334) from [] (omap1_init_early+0x34/0x48) r8:c03f8120 r7:c035ed4c r6:c035ed4c r5:02000000 r4:c035335c [] (omap1_init_early+0x0/0x48) from [] (setup_arch+0x69c/0x79c) [] (setup_arch+0x0/0x79c) from [] (start_kernel+0x7c/0x2f4) [] (start_kernel+0x0/0x2f4) from [<10008040>] (0x10008040) r7:c035ece4 r6:c0354678 r5:c035c03c r4:0000317d Code: 0a000002 e1a0e00f e12fff13 e89da800 (e7f001f2) Fix this by adding omap1_clk_late_init() that only reprograms dpll1 if the bootloader rate is less than 60MHz. This also allows removing of the OMAP_CLOCKS_SET_BY_BOOTLOADER option. Reported-by: Aaro Koskinen Tested-by: Aaro Koskinen Signed-off-by: Tony Lindgren diff --git a/arch/arm/configs/omap1_defconfig b/arch/arm/configs/omap1_defconfig index 7b63462..a7e7775 100644 --- a/arch/arm/configs/omap1_defconfig +++ b/arch/arm/configs/omap1_defconfig @@ -48,7 +48,6 @@ CONFIG_MACH_SX1=y CONFIG_MACH_NOKIA770=y CONFIG_MACH_AMS_DELTA=y CONFIG_MACH_OMAP_GENERIC=y -CONFIG_OMAP_CLOCKS_SET_BY_BOOTLOADER=y CONFIG_OMAP_ARM_216MHZ=y CONFIG_OMAP_ARM_195MHZ=y CONFIG_OMAP_ARM_192MHZ=y diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig index e0a0281..73f287d 100644 --- a/arch/arm/mach-omap1/Kconfig +++ b/arch/arm/mach-omap1/Kconfig @@ -171,14 +171,6 @@ config MACH_OMAP_GENERIC comment "OMAP CPU Speed" depends on ARCH_OMAP1 -config OMAP_CLOCKS_SET_BY_BOOTLOADER - bool "OMAP clocks set by bootloader" - depends on ARCH_OMAP1 - help - Enable this option to prevent the kernel from overriding the clock - frequencies programmed by bootloader for MPU, DSP, MMUs, TC, - internal LCD controller and MPU peripherals. - config OMAP_ARM_216MHZ bool "OMAP ARM 216 MHz CPU (1710 only)" depends on ARCH_OMAP1 && ARCH_OMAP16XX diff --git a/arch/arm/mach-omap1/clock.h b/arch/arm/mach-omap1/clock.h index eaf09ef..16b1423 100644 --- a/arch/arm/mach-omap1/clock.h +++ b/arch/arm/mach-omap1/clock.h @@ -17,7 +17,8 @@ #include -extern int __init omap1_clk_init(void); +int omap1_clk_init(void); +void omap1_clk_late_init(void); extern int omap1_clk_enable(struct clk *clk); extern void omap1_clk_disable(struct clk *clk); extern long omap1_clk_round_rate(struct clk *clk, unsigned long rate); diff --git a/arch/arm/mach-omap1/clock_data.c b/arch/arm/mach-omap1/clock_data.c index 92400b9..1297bb5 100644 --- a/arch/arm/mach-omap1/clock_data.c +++ b/arch/arm/mach-omap1/clock_data.c @@ -767,6 +767,15 @@ static struct clk_functions omap1_clk_functions = { .clk_disable_unused = omap1_clk_disable_unused, }; +static void __init omap1_show_rates(void) +{ + pr_notice("Clocking rate (xtal/DPLL1/MPU): " + "%ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n", + ck_ref.rate / 1000000, (ck_ref.rate / 100000) % 10, + ck_dpll1.rate / 1000000, (ck_dpll1.rate / 100000) % 10, + arm_ck.rate / 1000000, (arm_ck.rate / 100000) % 10); +} + int __init omap1_clk_init(void) { struct omap_clk *c; @@ -835,9 +844,12 @@ int __init omap1_clk_init(void) /* We want to be in syncronous scalable mode */ omap_writew(0x1000, ARM_SYSST); -#ifdef CONFIG_OMAP_CLOCKS_SET_BY_BOOTLOADER - /* Use values set by bootloader. Determine PLL rate and recalculate - * dependent clocks as if kernel had changed PLL or divisors. + + /* + * Initially use the values set by bootloader. Determine PLL rate and + * recalculate dependent clocks as if kernel had changed PLL or + * divisors. See also omap1_clk_late_init() that can reprogram dpll1 + * after the SRAM is initialized. */ { unsigned pll_ctl_val = omap_readw(DPLL_CTL); @@ -862,25 +874,10 @@ int __init omap1_clk_init(void) } } } -#else - /* Find the highest supported frequency and enable it */ - if (omap1_select_table_rate(&virtual_ck_mpu, ~0)) { - printk(KERN_ERR "System frequencies not set. Check your config.\n"); - /* Guess sane values (60MHz) */ - omap_writew(0x2290, DPLL_CTL); - omap_writew(cpu_is_omap7xx() ? 0x3005 : 0x1005, ARM_CKCTL); - ck_dpll1.rate = 60000000; - } -#endif propagate_rate(&ck_dpll1); /* Cache rates for clocks connected to ck_ref (not dpll1) */ propagate_rate(&ck_ref); - printk(KERN_INFO "Clocking rate (xtal/DPLL1/MPU): " - "%ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n", - ck_ref.rate / 1000000, (ck_ref.rate / 100000) % 10, - ck_dpll1.rate / 1000000, (ck_dpll1.rate / 100000) % 10, - arm_ck.rate / 1000000, (arm_ck.rate / 100000) % 10); - + omap1_show_rates(); if (machine_is_omap_perseus2() || machine_is_omap_fsample()) { /* Select slicer output as OMAP input clock */ omap_writew(omap_readw(OMAP7XX_PCC_UPLD_CTRL) & ~0x1, @@ -925,3 +922,21 @@ int __init omap1_clk_init(void) return 0; } + +#define OMAP1_DPLL1_SANE_VALUE 60000000 + +void __init omap1_clk_late_init(void) +{ + if (ck_dpll1.rate >= OMAP1_DPLL1_SANE_VALUE) + return; + + /* Find the highest supported frequency and enable it */ + if (omap1_select_table_rate(&virtual_ck_mpu, ~0)) { + pr_err("System frequencies not set, using default. Check your config.\n"); + omap_writew(0x2290, DPLL_CTL); + omap_writew(cpu_is_omap7xx() ? 0x3005 : 0x1005, ARM_CKCTL); + ck_dpll1.rate = OMAP1_DPLL1_SANE_VALUE; + } + propagate_rate(&ck_dpll1); + omap1_show_rates(); +} diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c index 48ef988..475cb2f 100644 --- a/arch/arm/mach-omap1/devices.c +++ b/arch/arm/mach-omap1/devices.c @@ -30,6 +30,8 @@ #include #include +#include "clock.h" + /*-------------------------------------------------------------------------*/ #if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE) @@ -293,6 +295,7 @@ static int __init omap1_init_devices(void) return -ENODEV; omap_sram_init(); + omap1_clk_late_init(); /* please keep these calls, and their implementations above, * in alphabetical order so they're easier to sort through. -- cgit v0.10.2 From 9752915e3ead9ce794744dde3a1c7f6f49a1e936 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:16 +0100 Subject: brcm80211: smac: fix endianess issue for OTP memory access This fixes issue when using OTP memory. It was introduced by following commit: commit 028f78d43d80dcb8b1142ea38606067151dd3d51 Author: Arend van Spriel Date: Fri Oct 21 16:16:35 2011 +0200 brcm80211: smac: change buffer endianess convert function interface Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 0539a6a..3a9b81d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -835,6 +835,8 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords) */ return -ENODATA; + /* fixup the endianness so crc8 will pass */ + cpu_to_le16_buf(buf, sz); if (crc8(brcms_srom_crc8_table, (u8 *) buf, sz * 2, CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) err = -EIO; -- cgit v0.10.2 From bfd8284b6523203e5218864d74b82571df80534f Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:17 +0100 Subject: brcm80211: smac: remove code under unused macro definitions There were a couple of code segments left that were placed under a macro definition that was not applicable or not used in the brcmsmac driver. These pieces of code have been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c index 89ad1b7..55e9f45 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c @@ -1153,121 +1153,6 @@ brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm, u16 chanspec, &txpwr); } -#ifdef POWER_DBG -static void wlc_phy_txpower_limits_dump(struct txpwr_limits *txpwr) -{ - int i; - char buf[80]; - char fraction[4][4] = { " ", ".25", ".5 ", ".75" }; - - sprintf(buf, "CCK "); - for (i = 0; i < BRCMS_NUM_RATES_CCK; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->cck[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->cck[i] % BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz OFDM SISO "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm[i] % BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz OFDM CDD "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz OFDM SISO "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_40_siso[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz OFDM CDD "); - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->ofdm_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_40_cdd[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS0-7 SISO "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_siso[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_siso[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS0-7 CDD "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_cdd[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS0-7 STBC "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_stbc[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_stbc[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "20 MHz MCS8-15 SDM "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_20_mimo[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_mimo[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS0-7 SISO "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_siso[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS0-7 CDD "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_cdd[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS0-7 STBC "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_stbc[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_stbc[i] % - BRCMS_TXPWR_DB_FACTOR]); - printk(KERN_DEBUG "%s\n", buf); - - sprintf(buf, "40 MHz MCS8-15 SDM "); - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) - sprintf(buf[strlen(buf)], " %2d%s", - txpwr->mcs_40_mimo[i] / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_mimo[i] % - BRCMS_TXPWR_DB_FACTOR]); - } - printk(KERN_DEBUG "%s\n", buf); - - printk(KERN_DEBUG "MCS32 %2d%s\n", - txpwr->mcs32 / BRCMS_TXPWR_DB_FACTOR, - fraction[txpwr->mcs32 % BRCMS_TXPWR_DB_FACTOR]); -} -#endif /* POWER_DBG */ - void brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, struct txpwr_limits *txpwr) @@ -1478,9 +1363,6 @@ brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, txpwr->mcs_40_stbc[i] = txpwr->mcs_40_cdd[i]; } -#ifdef POWER_DBG - wlc_phy_txpower_limits_dump(txpwr); -#endif return; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index 2faea50..e17edf7 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -190,15 +190,7 @@ u16 read_radio_reg(struct brcms_phy *pi, u16 addr) data = R_REG(&pi->regs->radioregdata); } else { W_REG_FLUSH(&pi->regs->phy4waddr, addr); - -#ifdef __ARM_ARCH_4T__ - __asm__(" .align 4 "); - __asm__(" nop "); - data = R_REG(&pi->regs->phy4wdatalo); -#else data = R_REG(&pi->regs->phy4wdatalo); -#endif - } pi->phy_wreg = 0; -- cgit v0.10.2 From b7eec4233c348447e3f2d653f6c64128f2457c94 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:18 +0100 Subject: brcm80211: smac: replace own access category definitions with mac80211 enum The brcmsmac had own definitions for the access categories. The mac80211 header provides these as well as they are used in the conf_tx callback. As the definitions did not match the driver configured the tx parameters to the wrong queue. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index f193fab..0e8873e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -109,11 +109,6 @@ #define BPHY_PLCP_TIME 192 #define RIFS_11N_TIME 2 -#define AC_BE 0 -#define AC_BK 1 -#define AC_VI 2 -#define AC_VO 3 - /* length of the BCN template area */ #define BCN_TMPL_LEN 512 @@ -305,10 +300,22 @@ uint brcm_msg_level = #endif /* BCMDBG */ /* TX FIFO number to WME/802.1E Access Category */ -static const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; +static const u8 wme_fifo2ac[] = { + IEEE80211_AC_BK, + IEEE80211_AC_BE, + IEEE80211_AC_VI, + IEEE80211_AC_VO, + IEEE80211_AC_BE, + IEEE80211_AC_BE +}; -/* WME/802.1E Access Category to TX FIFO number */ -static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; +/* ieee80211 Access Category to TX FIFO number */ +static const u8 wme_ac2fifo[] = { + TX_AC_VO_FIFO, + TX_AC_VI_FIFO, + TX_AC_BE_FIFO, + TX_AC_BK_FIFO +}; /* 802.1D Priority to precedence queue mapping */ const u8 wlc_prio2prec_map[] = { @@ -893,7 +900,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) lfbl, /* Long Frame Rate Fallback Limit */ fbl; - if (queue < AC_COUNT) { + if (queue < IEEE80211_NUM_ACS) { sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], EDCF_SFB); lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], @@ -4125,7 +4132,7 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, EDCF_TXOP2USEC(acp_shm.txop); acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); - if (aci == AC_VI && acp_shm.txop == 0 + if (aci == IEEE80211_AC_VI && acp_shm.txop == 0 && acp_shm.aifs < EDCF_AIFSN_MAX) acp_shm.aifs++; @@ -4175,7 +4182,7 @@ static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) }; /* ucode needs these parameters during its initialization */ const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; - for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) { + for (i_ac = 0; i_ac < IEEE80211_NUM_ACS; i_ac++, edcf_acp++) { /* find out which ac this set of params applies to */ aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; @@ -5172,7 +5179,7 @@ static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) if (!wlc->clk) return; - for (ac = 0; ac < AC_COUNT; ac++) + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), wlc->wme_retries[ac]); } @@ -5647,7 +5654,7 @@ int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); - for (ac = 0; ac < AC_COUNT; ac++) { + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SHORT, wlc->SRL); wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], @@ -8358,7 +8365,7 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) /* Uninitialized; read from HW */ int ac; - for (ac = 0; ac < AC_COUNT; ac++) + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) wlc->wme_retries[ac] = brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index 9a7535d..251c350 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -44,8 +44,6 @@ /* transmit buffer max headroom for protocol headers */ #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN) -#define AC_COUNT 4 - /* Macros for doing definition and get/set of bitfields * Usage example, e.g. a three-bit field (bits 4-6): * #define _M BITFIELD_MASK(3) @@ -436,7 +434,7 @@ struct brcms_txq_info { * bcn_li_dtim: beacon listen interval in # dtims. * WDarmed: watchdog timer is armed. * WDlast: last time wlc_watchdog() was called. - * edcf_txop[AC_COUNT]: current txop for each ac. + * edcf_txop[IEEE80211_NUM_ACS]: current txop for each ac. * wme_retries: per-AC retry limits. * tx_prec_map: Precedence map based on HW FIFO space. * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME. @@ -535,9 +533,9 @@ struct brcms_c_info { u32 WDlast; /* WME */ - u16 edcf_txop[AC_COUNT]; + u16 edcf_txop[IEEE80211_NUM_ACS]; - u16 wme_retries[AC_COUNT]; + u16 wme_retries[IEEE80211_NUM_ACS]; u16 tx_prec_map; u16 fifo2prec_map[NFIFO]; -- cgit v0.10.2 From a0f24c8a9328b58c2881e6a1c139110700a1a584 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:19 +0100 Subject: brcm80211: smac: remove duplicate definition of D11_PHY_HDR_LEN The macro definition D11_PHY_HDR_LEN was defined in d11.h and pub.h. It has been removed from pub.h. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Roland Vossen Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 022523a..8f3da0e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -248,7 +248,6 @@ enum brcms_srom_id { }; #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ -#define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ /* phy types */ #define PHY_TYPE_A 0 /* Phy type A */ -- cgit v0.10.2 From e9ca530a7b183691d9799fd40772c2cd398b494a Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Thu, 10 Nov 2011 20:30:20 +0100 Subject: brcm80211: smac: don't modify sta parameters when adding sta Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 8e35c62..6d3c7b6 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -619,13 +619,6 @@ brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, wl->pub->global_ampdu->scb = scb; wl->pub->global_ampdu->max_pdu = 16; - sta->ht_cap.ht_supported = true; - sta->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; - sta->ht_cap.ampdu_density = AMPDU_DEF_MPDU_DENSITY; - sta->ht_cap.cap = IEEE80211_HT_CAP_GRN_FLD | - IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT; - /* * minstrel_ht initiates addBA on our behalf by calling * ieee80211_start_tx_ba_session() -- cgit v0.10.2 From 6ca687d9461b25ce2339ba1809ec13ef459d4661 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 10 Nov 2011 20:30:21 +0100 Subject: brcm80211: fmac: add iscoreup function for bcm4330 chip New type of backplane interconnect support is needed for bcm4330 Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 43b4496..5b81336 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3120,9 +3120,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) (u8 *)&zeros, 4); } } else { - idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_INTERNAL_MEM); - if (!brcmf_sdio_chip_iscoreup(bus->sdiodev, - ci->c_inf[idx].base)) { + if (!ci->iscoreup(bus->sdiodev, ci, BCMA_CORE_INTERNAL_MEM)) { brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); bcmerror = -EBADE; goto fail; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 99d00dd..263ad0c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -45,6 +45,10 @@ ((((sbidh) & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT) | \ ((sbidh) & SSB_IDHIGH_RCLO)) +/* SOC Interconnect types (aka chip types) */ +#define SOCI_SB 0 +#define SOCI_AI 1 + #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) /* SDIO Pad drive strength to select value mappings */ struct sdiod_drive_str { @@ -106,19 +110,44 @@ brcmf_sdio_chip_corerev(struct brcmf_sdio_dev *sdiodev, return SBCOREREV(regdata); } -bool -brcmf_sdio_chip_iscoreup(struct brcmf_sdio_dev *sdiodev, - u32 corebase) +static bool +brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) { u32 regdata; + u8 idx; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); regdata &= (SSB_TMSLOW_RESET | SSB_TMSLOW_REJECT | SSB_IMSTATE_REJECT | SSB_TMSLOW_CLOCK); return (SSB_TMSLOW_CLOCK == regdata); } +static bool +brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) +{ + u32 regdata; + u8 idx; + bool ret; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); + + regdata = brcmf_sdcard_reg_read(sdiodev, + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); + ret = (regdata & (BCMA_IOCTL_FGC | BCMA_IOCTL_CLK)) == BCMA_IOCTL_CLK; + + regdata = brcmf_sdcard_reg_read(sdiodev, + ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, + 4); + ret = ret && ((regdata & BCMA_RESET_CTL_RESET) == 0); + + return ret; +} + void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) { @@ -258,6 +287,7 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, CORE_CC_REG(ci->c_inf[0].base, chipid), 4); ci->chip = regdata & CID_ID_MASK; ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; + ci->socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT; brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); @@ -277,6 +307,18 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, return -ENODEV; } + switch (ci->socitype) { + case SOCI_SB: + ci->iscoreup = brcmf_sdio_sb_iscoreup; + break; + case SOCI_AI: + ci->iscoreup = brcmf_sdio_ai_iscoreup; + break; + default: + brcmf_dbg(ERROR, "socitype %u not supported\n", ci->socitype); + return -ENODEV; + } + return 0; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 0ee37ae..557c80d 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -65,12 +65,16 @@ struct chip_core_info { struct chip_info { u32 chip; u32 chiprev; + u32 socitype; /* core info */ /* always put chipcommon core at 0, bus core at 1 */ struct chip_core_info c_inf[BRCMF_MAX_CORENUM]; u32 pmurev; u32 pmucaps; u32 ramsize; + + bool (*iscoreup)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, + u16 coreid); }; struct sbconfig { @@ -115,8 +119,6 @@ struct sbconfig { extern void brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase); -extern bool brcmf_sdio_chip_iscoreup(struct brcmf_sdio_dev *sdiodev, - u32 corebase); extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase); extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, -- cgit v0.10.2 From 523894f2672b9832da9f9fcce3043f1720ca42f4 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 10 Nov 2011 20:30:22 +0100 Subject: brcm80211: fmac: add corerev function for bcm4330 chip This patch is part of the series adding new backplane support Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 263ad0c..85b665e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -49,6 +49,10 @@ #define SOCI_SB 0 #define SOCI_AI 1 +/* EROM CompIdentB */ +#define CIB_REV_MASK 0xff000000 +#define CIB_REV_SHIFT 24 + #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) /* SDIO Pad drive strength to select value mappings */ struct sdiod_drive_str { @@ -100,16 +104,30 @@ brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid) } static u32 -brcmf_sdio_chip_corerev(struct brcmf_sdio_dev *sdiodev, - u32 corebase) +brcmf_sdio_sb_corerev(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) { u32 regdata; + u8 idx; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidhigh), 4); + CORE_SB(ci->c_inf[idx].base, sbidhigh), 4); return SBCOREREV(regdata); } +static u32 +brcmf_sdio_ai_corerev(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) +{ + u8 idx; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); + + return (ci->c_inf[idx].cib & CIB_REV_MASK) >> CIB_REV_SHIFT; +} + static bool brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u16 coreid) @@ -310,9 +328,11 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, switch (ci->socitype) { case SOCI_SB: ci->iscoreup = brcmf_sdio_sb_iscoreup; + ci->corerev = brcmf_sdio_sb_corerev; break; case SOCI_AI: ci->iscoreup = brcmf_sdio_ai_iscoreup; + ci->corerev = brcmf_sdio_ai_corerev; break; default: brcmf_dbg(ERROR, "socitype %u not supported\n", ci->socitype); @@ -378,8 +398,7 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, u8 idx; /* get chipcommon rev */ - ci->c_inf[0].rev = - brcmf_sdio_chip_corerev(sdiodev, ci->c_inf[0].base); + ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id); /* get chipcommon capabilites */ ci->c_inf[0].caps = @@ -393,7 +412,7 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, ci->pmurev = ci->pmucaps & PCAP_REV_MASK; } - ci->c_inf[1].rev = brcmf_sdio_chip_corerev(sdiodev, ci->c_inf[1].base); + ci->c_inf[1].rev = ci->corerev(sdiodev, ci, ci->c_inf[1].id); regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(ci->c_inf[1].base, sbidhigh), 4); ci->c_inf[1].id = (regdata & SSB_IDHIGH_CC) >> SSB_IDHIGH_CC_SHIFT; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 557c80d..ea91e60 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -60,6 +60,7 @@ struct chip_core_info { u32 base; u32 wrapbase; u32 caps; + u32 cib; }; struct chip_info { @@ -75,6 +76,8 @@ struct chip_info { bool (*iscoreup)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u16 coreid); + u32 (*corerev)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, + u16 coreid); }; struct sbconfig { -- cgit v0.10.2 From 086a2e0a63eef367dab9b4499ba0cfe3a309ec94 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 10 Nov 2011 20:30:23 +0100 Subject: brcm80211: fmac: add coredisable function for bcm4330 chip This patch is part of the series of adding new backplane support Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 5b81336..0d0e283 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3098,7 +3098,6 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) { uint retries; int bcmerror = 0; - u8 idx; struct chip_info *ci = bus->ci; /* To enter download state, disable ARM and reset SOCRAM. @@ -3107,11 +3106,10 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) if (enter) { bus->alp_only = true; - idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3); - brcmf_sdio_chip_coredisable(bus->sdiodev, ci->c_inf[idx].base); + ci->coredisable(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); - idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_INTERNAL_MEM); - brcmf_sdio_chip_resetcore(bus->sdiodev, ci->c_inf[idx].base); + brcmf_sdio_chip_resetcore(bus->sdiodev, ci, + BCMA_CORE_INTERNAL_MEM); /* Clear the top bit of memory */ if (bus->ramsize) { @@ -3135,8 +3133,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) w_sdreg32(bus, 0xFFFFFFFF, offsetof(struct sdpcmd_regs, intstatus), &retries); - idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3); - brcmf_sdio_chip_resetcore(bus->sdiodev, ci->c_inf[idx].base); + brcmf_sdio_chip_resetcore(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); /* Allow HT Clock now that the ARM is running. */ bus->alp_only = false; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 85b665e..d2cf8c6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -166,124 +166,165 @@ brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev, return ret; } -void -brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, u32 corebase) +static void +brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) { u32 regdata; + u8 idx; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); if (regdata & SSB_TMSLOW_RESET) return; regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); if ((regdata & SSB_TMSLOW_CLOCK) != 0) { /* * set target reject and spin until busy is clear * (preserve core-specific bits) */ regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), - 4, regdata | SSB_TMSLOW_REJECT); + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), + 4, regdata | SSB_TMSLOW_REJECT); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); udelay(1); SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4) & + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4) & SSB_TMSHIGH_BUSY), 100000); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4); if (regdata & SSB_TMSHIGH_BUSY) brcmf_dbg(ERROR, "core state still busy\n"); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); + CORE_SB(ci->c_inf[idx].base, sbidlow), 4); if (regdata & SSB_IDLOW_INITIATOR) { regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) | + CORE_SB(ci->c_inf[idx].base, sbimstate), 4) | SSB_IMSTATE_REJECT; brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, + CORE_SB(ci->c_inf[idx].base, sbimstate), 4, regdata); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); + CORE_SB(ci->c_inf[idx].base, sbimstate), 4); udelay(1); SPINWAIT((brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & + CORE_SB(ci->c_inf[idx].base, sbimstate), 4) & SSB_IMSTATE_BUSY), 100000); } /* set reset and reject while enabling the clocks */ brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, (SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatelow), 4); + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); udelay(10); /* clear the initiator reject bit */ regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbidlow), 4); + CORE_SB(ci->c_inf[idx].base, sbidlow), 4); if (regdata & SSB_IDLOW_INITIATOR) { regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4) & + CORE_SB(ci->c_inf[idx].base, sbimstate), 4) & ~SSB_IMSTATE_REJECT; brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbimstate), 4, + CORE_SB(ci->c_inf[idx].base, sbimstate), 4, regdata); } } /* leave reset and reject asserted */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); udelay(1); } +static void +brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) +{ + u8 idx; + u32 regdata; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); + + /* if core is already in reset, just return */ + regdata = brcmf_sdcard_reg_read(sdiodev, + ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, + 4); + if ((regdata & BCMA_RESET_CTL_RESET) != 0) + return; + + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, + 4, 0); + regdata = brcmf_sdcard_reg_read(sdiodev, + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); + udelay(10); + + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, + 4, BCMA_RESET_CTL_RESET); + udelay(1); +} + void -brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) +brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) { u32 regdata; + u8 idx; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); /* * Must do the disable sequence first to work for * arbitrary current core state. */ - brcmf_sdio_chip_coredisable(sdiodev, corebase); + ci->coredisable(sdiodev, ci, coreid); /* * Now do the initialization sequence. * set reset while enabling the clock and * forcing them on throughout the core */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, - SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET); + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET); udelay(1); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4); + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4); if (regdata & SSB_TMSHIGH_SERR) brcmf_sdcard_reg_write(sdiodev, - CORE_SB(corebase, sbtmstatehigh), 4, 0); + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4, 0); regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(corebase, sbimstate), 4); + CORE_SB(ci->c_inf[idx].base, sbimstate), 4); if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO)) - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbimstate), 4, regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO)); /* clear reset and allow it to propagate throughout the core */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK); udelay(1); /* leave clock enabled */ - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), + brcmf_sdcard_reg_write(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, SSB_TMSLOW_CLOCK); udelay(1); } @@ -329,10 +370,12 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, case SOCI_SB: ci->iscoreup = brcmf_sdio_sb_iscoreup; ci->corerev = brcmf_sdio_sb_corerev; + ci->coredisable = brcmf_sdio_sb_coredisable; break; case SOCI_AI: ci->iscoreup = brcmf_sdio_ai_iscoreup; ci->corerev = brcmf_sdio_ai_corerev; + ci->coredisable = brcmf_sdio_ai_coredisable; break; default: brcmf_dbg(ERROR, "socitype %u not supported\n", ci->socitype); @@ -395,7 +438,6 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci) { u32 regdata; - u8 idx; /* get chipcommon rev */ ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id); @@ -425,8 +467,7 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, * Make sure any on-chip ARM is off (in case strapping is wrong), * or downloaded code was already running. */ - idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3); - brcmf_sdio_chip_coredisable(sdiodev, ci->c_inf[idx].base); + ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3); } int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index ea91e60..22232a8 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -78,6 +78,8 @@ struct chip_info { u16 coreid); u32 (*corerev)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u16 coreid); + void (*coredisable)(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid); }; struct sbconfig { @@ -121,9 +123,7 @@ struct sbconfig { }; extern void brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, - u32 corebase); -extern void brcmf_sdio_chip_coredisable(struct brcmf_sdio_dev *sdiodev, - u32 corebase); + struct chip_info *ci, u16 coreid); extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, struct chip_info **ci_ptr, u32 regs); extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); -- cgit v0.10.2 From d77e70ff5ace175f19447a1965691a794c27de24 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 10 Nov 2011 20:30:24 +0100 Subject: brcm80211: fmac: add resetcore function for bcm4330 chip This patch is part of the series of adding new backplane support Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 0d0e283..a5d1c35 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3108,8 +3108,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) ci->coredisable(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); - brcmf_sdio_chip_resetcore(bus->sdiodev, ci, - BCMA_CORE_INTERNAL_MEM); + ci->resetcore(bus->sdiodev, ci, BCMA_CORE_INTERNAL_MEM); /* Clear the top bit of memory */ if (bus->ramsize) { @@ -3133,7 +3132,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) w_sdreg32(bus, 0xFFFFFFFF, offsetof(struct sdpcmd_regs, intstatus), &retries); - brcmf_sdio_chip_resetcore(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); + ci->resetcore(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); /* Allow HT Clock now that the ARM is running. */ bus->alp_only = false; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index d2cf8c6..cef9abb 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -278,9 +278,9 @@ brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev, udelay(1); } -void -brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, - struct chip_info *ci, u16 coreid) +static void +brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) { u32 regdata; u8 idx; @@ -291,7 +291,7 @@ brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, * Must do the disable sequence first to work for * arbitrary current core state. */ - ci->coredisable(sdiodev, ci, coreid); + brcmf_sdio_sb_coredisable(sdiodev, ci, coreid); /* * Now do the initialization sequence. @@ -301,8 +301,11 @@ brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, brcmf_sdcard_reg_write(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); udelay(1); + /* clear any serror */ regdata = brcmf_sdcard_reg_read(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4); if (regdata & SSB_TMSHIGH_SERR) @@ -320,12 +323,44 @@ brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, brcmf_sdcard_reg_write(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); udelay(1); /* leave clock enabled */ brcmf_sdcard_reg_write(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, SSB_TMSLOW_CLOCK); + regdata = brcmf_sdcard_reg_read(sdiodev, + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); + udelay(1); +} + +static void +brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid) +{ + u8 idx; + u32 regdata; + + idx = brcmf_sdio_chip_getinfidx(ci, coreid); + + /* must disable first to work for arbitrary current core state */ + brcmf_sdio_ai_coredisable(sdiodev, ci, coreid); + + /* now do initialization sequence */ + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, + 4, BCMA_IOCTL_FGC | BCMA_IOCTL_CLK); + regdata = brcmf_sdcard_reg_read(sdiodev, + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, + 4, 0); + udelay(1); + + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, + 4, BCMA_IOCTL_CLK); + regdata = brcmf_sdcard_reg_read(sdiodev, + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); udelay(1); } @@ -371,11 +406,13 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, ci->iscoreup = brcmf_sdio_sb_iscoreup; ci->corerev = brcmf_sdio_sb_corerev; ci->coredisable = brcmf_sdio_sb_coredisable; + ci->resetcore = brcmf_sdio_sb_resetcore; break; case SOCI_AI: ci->iscoreup = brcmf_sdio_ai_iscoreup; ci->corerev = brcmf_sdio_ai_corerev; ci->coredisable = brcmf_sdio_ai_coredisable; + ci->resetcore = brcmf_sdio_ai_resetcore; break; default: brcmf_dbg(ERROR, "socitype %u not supported\n", ci->socitype); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h index 22232a8..ce974d7 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h @@ -80,6 +80,8 @@ struct chip_info { u16 coreid); void (*coredisable)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, u16 coreid); + void (*resetcore)(struct brcmf_sdio_dev *sdiodev, + struct chip_info *ci, u16 coreid); }; struct sbconfig { @@ -122,8 +124,6 @@ struct sbconfig { u32 sbidhigh; /* identification */ }; -extern void brcmf_sdio_chip_resetcore(struct brcmf_sdio_dev *sdiodev, - struct chip_info *ci, u16 coreid); extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, struct chip_info **ci_ptr, u32 regs); extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); -- cgit v0.10.2 From 122d36fd5ac99305d294012044198894648bf0f8 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 10 Nov 2011 20:30:25 +0100 Subject: brcm80211: fmac: remove id retrieve code sdio_chip.c is dedicated to sdio bus chip. No need to retrieve id for bus core Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index cef9abb..f6b1822 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -474,8 +474,6 @@ static void brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci) { - u32 regdata; - /* get chipcommon rev */ ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id); @@ -492,9 +490,6 @@ brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, } ci->c_inf[1].rev = ci->corerev(sdiodev, ci, ci->c_inf[1].id); - regdata = brcmf_sdcard_reg_read(sdiodev, - CORE_SB(ci->c_inf[1].base, sbidhigh), 4); - ci->c_inf[1].id = (regdata & SSB_IDHIGH_CC) >> SSB_IDHIGH_CC_SHIFT; brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", ci->c_inf[0].rev, ci->pmurev, -- cgit v0.10.2 From ad4d71f69ebe2acab75d0a8a66ab9f7609151cce Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:26 +0100 Subject: brcm80211: smac: remove usage of brcmu_pkttotlen The function brcmu_pkttotlen calculates the total length of a sk_buff chain following the next pointer. In brcmsmac this is not needed as in each place where it was used the provided sk_buff had a NULL pointer as next field value. Reviewed-by: Alwin Beukers Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c index 7f27dbd..43f7a72 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c @@ -649,7 +649,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, len = roundup(len, 4); ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN); - dma_len += (u16) brcmu_pkttotlen(p); + dma_len += (u16) p->len; BCMMSG(wlc->wiphy, "wl%d: ampdu_len %d" " seg_cnt %d null delim %d\n", @@ -741,9 +741,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, if (p) { if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && ((u8) (p->priority) == tid)) { - - plen = brcmu_pkttotlen(p) + - AMPDU_MAX_MPDU_OVERHEAD; + plen = p->len + AMPDU_MAX_MPDU_OVERHEAD; plen = max(scb_ampdu->min_len, plen); if ((plen + ampdu_len) > max_ampdu_bytes) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 0e8873e..6a679c9 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -949,7 +949,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) tx_info->flags |= IEEE80211_TX_STAT_ACK; } - totlen = brcmu_pkttotlen(p); + totlen = p->len; free_pdu = true; brcms_c_txfifo_complete(wlc, queue, 1); @@ -6716,7 +6716,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, qos = ieee80211_is_data_qos(h->frame_control); /* compute length of frame in bytes for use in PLCP computations */ - len = brcmu_pkttotlen(p); + len = p->len; phylen = len + FCS_LEN; /* Get tx_info */ -- cgit v0.10.2 From ad3b8b39189689dbff84c8a8edf024511b087f87 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:27 +0100 Subject: brcm80211: util: use sk_buff_head in precedence queue functions Instead of dealing with sk_buff prev pointers the queue functions now make use of the sk_buff_head functions provided by the kernel. Reported-by: Johannes Berg Reviewed-by: Alwin Beukers Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index 12b795f..57e656f 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -86,21 +86,13 @@ EXPORT_SYMBOL(brcmu_pkttotlen); struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, struct sk_buff *p) { - struct pktq_prec *q; + struct sk_buff_head *q; if (pktq_full(pq) || pktq_pfull(pq, prec)) return NULL; - q = &pq->q[prec]; - - if (q->head) - q->tail->prev = p; - else - q->head = p; - - q->tail = p; - q->len++; - + q = &pq->q[prec].skblist; + skb_queue_tail(q, p); pq->len++; if (pq->hi_prec < prec) @@ -113,20 +105,13 @@ EXPORT_SYMBOL(brcmu_pktq_penq); struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec, struct sk_buff *p) { - struct pktq_prec *q; + struct sk_buff_head *q; if (pktq_full(pq) || pktq_pfull(pq, prec)) return NULL; - q = &pq->q[prec]; - - if (q->head == NULL) - q->tail = p; - - p->prev = q->head; - q->head = p; - q->len++; - + q = &pq->q[prec].skblist; + skb_queue_head(q, p); pq->len++; if (pq->hi_prec < prec) @@ -138,53 +123,30 @@ EXPORT_SYMBOL(brcmu_pktq_penq_head); struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec) { - struct pktq_prec *q; + struct sk_buff_head *q; struct sk_buff *p; - q = &pq->q[prec]; - - p = q->head; + q = &pq->q[prec].skblist; + p = skb_dequeue(q); if (p == NULL) return NULL; - q->head = p->prev; - if (q->head == NULL) - q->tail = NULL; - - q->len--; - pq->len--; - - p->prev = NULL; - return p; } EXPORT_SYMBOL(brcmu_pktq_pdeq); struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec) { - struct pktq_prec *q; - struct sk_buff *p, *prev; - - q = &pq->q[prec]; + struct sk_buff_head *q; + struct sk_buff *p; - p = q->head; + q = &pq->q[prec].skblist; + p = skb_dequeue_tail(q); if (p == NULL) return NULL; - for (prev = NULL; p != q->tail; p = p->prev) - prev = p; - - if (prev) - prev->prev = NULL; - else - q->head = NULL; - - q->tail = prev; - q->len--; - pq->len--; - return p; } EXPORT_SYMBOL(brcmu_pktq_pdeq_tail); @@ -193,31 +155,17 @@ void brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, bool (*fn)(struct sk_buff *, void *), void *arg) { - struct pktq_prec *q; - struct sk_buff *p, *prev = NULL; + struct sk_buff_head *q; + struct sk_buff *p, *next; - q = &pq->q[prec]; - p = q->head; - while (p) { + q = &pq->q[prec].skblist; + skb_queue_walk_safe(q, p, next) { if (fn == NULL || (*fn) (p, arg)) { - bool head = (p == q->head); - if (head) - q->head = p->prev; - else - prev->prev = p->prev; - p->prev = NULL; + skb_unlink(p, q); brcmu_pkt_buf_free_skb(p); - q->len--; pq->len--; - p = (head ? q->head : prev->prev); - } else { - prev = p; - p = p->prev; } } - - if (q->head == NULL) - q->tail = NULL; } EXPORT_SYMBOL(brcmu_pktq_pflush); @@ -242,8 +190,10 @@ void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len) pq->max = (u16) max_len; - for (prec = 0; prec < num_prec; prec++) + for (prec = 0; prec < num_prec; prec++) { pq->q[prec].max = pq->max; + skb_queue_head_init(&pq->q[prec].skblist); + } } EXPORT_SYMBOL(brcmu_pktq_init); @@ -255,13 +205,13 @@ struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out) return NULL; for (prec = 0; prec < pq->hi_prec; prec++) - if (pq->q[prec].head) + if (!skb_queue_empty(&pq->q[prec].skblist)) break; if (prec_out) *prec_out = prec; - return pq->q[prec].tail; + return skb_peek_tail(&pq->q[prec].skblist); } EXPORT_SYMBOL(brcmu_pktq_peek_tail); @@ -274,7 +224,7 @@ int brcmu_pktq_mlen(struct pktq *pq, uint prec_bmp) for (prec = 0; prec <= pq->hi_prec; prec++) if (prec_bmp & (1 << prec)) - len += pq->q[prec].len; + len += pq->q[prec].skblist.qlen; return len; } @@ -284,39 +234,32 @@ EXPORT_SYMBOL(brcmu_pktq_mlen); struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) { - struct pktq_prec *q; + struct sk_buff_head *q; struct sk_buff *p; int prec; if (pq->len == 0) return NULL; - while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL) + while ((prec = pq->hi_prec) > 0 && + skb_queue_empty(&pq->q[prec].skblist)) pq->hi_prec--; - while ((prec_bmp & (1 << prec)) == 0 || pq->q[prec].head == NULL) + while ((prec_bmp & (1 << prec)) == 0 || + skb_queue_empty(&pq->q[prec].skblist)) if (prec-- == 0) return NULL; - q = &pq->q[prec]; - - p = q->head; + q = &pq->q[prec].skblist; + p = skb_dequeue(q); if (p == NULL) return NULL; - q->head = p->prev; - if (q->head == NULL) - q->tail = NULL; - - q->len--; + pq->len--; if (prec_out) *prec_out = prec; - pq->len--; - - p->prev = NULL; - return p; } EXPORT_SYMBOL(brcmu_pktq_mdeq); diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index ccf6015..cae4e51 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h @@ -65,9 +65,7 @@ #define ETHER_ADDR_STR_LEN 18 struct pktq_prec { - struct sk_buff *head; /* first packet to dequeue */ - struct sk_buff *tail; /* last packet to dequeue */ - u16 len; /* number of queued packets */ + struct sk_buff_head skblist; u16 max; /* maximum number of queued packets */ }; @@ -88,32 +86,32 @@ struct pktq { static inline int pktq_plen(struct pktq *pq, int prec) { - return pq->q[prec].len; + return pq->q[prec].skblist.qlen; } static inline int pktq_pavail(struct pktq *pq, int prec) { - return pq->q[prec].max - pq->q[prec].len; + return pq->q[prec].max - pq->q[prec].skblist.qlen; } static inline bool pktq_pfull(struct pktq *pq, int prec) { - return pq->q[prec].len >= pq->q[prec].max; + return pq->q[prec].skblist.qlen >= pq->q[prec].max; } static inline bool pktq_pempty(struct pktq *pq, int prec) { - return pq->q[prec].len == 0; + return skb_queue_empty(&pq->q[prec].skblist); } static inline struct sk_buff *pktq_ppeek(struct pktq *pq, int prec) { - return pq->q[prec].head; + return skb_peek(&pq->q[prec].skblist); } static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec) { - return pq->q[prec].tail; + return skb_peek_tail(&pq->q[prec].skblist); } extern struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, -- cgit v0.10.2 From 02a588a2e3b9e0156f306a542bb6cd29ba42e1b9 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Thu, 10 Nov 2011 20:30:28 +0100 Subject: brcm80211: smac: combine promiscuous mode functionality Combined mac configuration for promiscious mode and monitor mode, and removed unused monitor mode flag in pub structure. Reviewed-by: Arend van Spriel Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 6a679c9..36e3e06 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -3583,42 +3583,30 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, brcms_c_set_phy_chanspec(wlc, chanspec); } -static void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc) -{ - if (wlc->bcnmisc_monitor) - brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); - else - brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, 0); -} - -void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) -{ - wlc->bcnmisc_monitor = promisc; - brcms_c_mac_bcn_promisc(wlc); -} - -/* set or clear maccontrol bits MCTL_PROMISC and MCTL_KEEPCONTROL */ +/* + * Set or clear maccontrol bits MCTL_PROMISC, MCTL_BCNS_PROMISC and + * MCTL_KEEPCONTROL + */ static void brcms_c_mac_promisc(struct brcms_c_info *wlc) { u32 promisc_bits = 0; - /* - * promiscuous mode just sets MCTL_PROMISC - * Note: APs get all BSS traffic without the need to set - * the MCTL_PROMISC bit since all BSS data traffic is - * directed at the AP - */ - if (wlc->pub->promisc) - promisc_bits |= MCTL_PROMISC; + if (wlc->bcnmisc_monitor) + promisc_bits |= MCTL_BCNS_PROMISC; - /* monitor mode needs both MCTL_PROMISC and MCTL_KEEPCONTROL - * Note: monitor mode also needs MCTL_BCNS_PROMISC, but that is - * handled in brcms_c_mac_bcn_promisc() - */ if (wlc->monitor) - promisc_bits |= MCTL_PROMISC | MCTL_KEEPCONTROL; + promisc_bits |= + MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL; - brcms_b_mctrl(wlc->hw, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits); + brcms_b_mctrl(wlc->hw, + MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL, + promisc_bits); +} + +void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) +{ + wlc->bcnmisc_monitor = promisc; + brcms_c_mac_promisc(wlc); } /* @@ -3650,7 +3638,6 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) } /* update the various promisc bits */ - brcms_c_mac_bcn_promisc(wlc); brcms_c_mac_promisc(wlc); } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 8f3da0e..21ccf3a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -381,7 +381,6 @@ struct brcms_pub { uint _nbands; /* # bands supported */ uint now; /* # elapsed seconds */ - bool promisc; /* promiscuous destination address */ bool delayed_down; /* down delayed */ bool associated; /* true:part of [I]BSS, false: not */ /* (union of stas_associated, aps_associated) */ -- cgit v0.10.2 From 9a95e60e0610bb8ec39c74d2c8546514a76428df Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:29 +0100 Subject: brcm80211: util: move brcmu_pkttotlen() function to brcmfmac The functions brcmu_pkttotlen() is only used in brcmfmac driver so it has been moved there. It also does not use the sk_buff next pointer anymore but walks a skb queue to determine the total length. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index a5d1c35..c406b46 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -1107,6 +1107,18 @@ static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_bus *bus, uint len) return ret; } +/* return total length of buffer chain */ +static uint brcmf_sdbrcm_glom_len(struct brcmf_bus *bus) +{ + struct sk_buff *p; + uint total; + + total = 0; + skb_queue_walk(&bus->glom, p) + total += p->len; + return total; +} + static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) { u16 dlen, totlen; @@ -1218,7 +1230,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) } pfirst = skb_peek(&bus->glom); - dlen = (u16) brcmu_pkttotlen(pfirst); + dlen = (u16) brcmf_sdbrcm_glom_len(bus); /* Do an SDIO read for the superframe. Configurable iovar to * read directly into the chained packet, or allocate a large diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index 57e656f..3a92f72 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -66,19 +66,6 @@ void brcmu_pkt_buf_free_skb(struct sk_buff *skb) } EXPORT_SYMBOL(brcmu_pkt_buf_free_skb); - -/* return total length of buffer chain */ -uint brcmu_pkttotlen(struct sk_buff *p) -{ - uint total; - - total = 0; - for (; p; p = p->next) - total += p->len; - return total; -} -EXPORT_SYMBOL(brcmu_pkttotlen); - /* * osl multiple-precedence packet queue * hi_prec is always >= the number of the highest non-empty precedence diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index cae4e51..ad249a0 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h @@ -170,9 +170,6 @@ extern void brcmu_pktq_flush(struct pktq *pq, bool dir, bool (*fn)(struct sk_buff *, void *), void *arg); /* externs */ -/* packet */ -extern uint brcmu_pkttotlen(struct sk_buff *p); - /* ip address */ struct ipv4_addr; -- cgit v0.10.2 From 53ee4bc46784ad53d0a9be52e8d687dd4e89a055 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:30 +0100 Subject: brcm80211: util: remove pointer traversal from brcmu_pkt_buf_free_skb The function brcmu_pkt_buf_free_skb() was following the next pointer to free all linked packets. However, it is only called with unlinked packets so this can be removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index 3a92f72..b7537f7 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -41,28 +41,17 @@ EXPORT_SYMBOL(brcmu_pkt_buf_get_skb); /* Free the driver packet. Free the tag if present */ void brcmu_pkt_buf_free_skb(struct sk_buff *skb) { - struct sk_buff *nskb; - int nest = 0; - - /* perversion: we use skb->next to chain multi-skb packets */ - while (skb) { - nskb = skb->next; - skb->next = NULL; - - if (skb->destructor) - /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if - * destructor exists - */ - dev_kfree_skb_any(skb); - else - /* can free immediately (even in_irq()) if destructor - * does not exist - */ - dev_kfree_skb(skb); - - nest++; - skb = nskb; - } + WARN_ON(skb->next); + if (skb->destructor) + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if + * destructor exists + */ + dev_kfree_skb_any(skb); + else + /* can free immediately (even in_irq()) if destructor + * does not exist + */ + dev_kfree_skb(skb); } EXPORT_SYMBOL(brcmu_pkt_buf_free_skb); -- cgit v0.10.2 From 046808daf9f6b8c5275861330d4f8c2e6cfe3c31 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 10 Nov 2011 20:30:31 +0100 Subject: brcm80211: fmac: add function to free the glom skb queue In several places in dhd_sdio.c a skb packet queue was being emptied and the packets freed. This warrants to have a function in place to do this. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index c406b46..d8a521a 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -1119,6 +1119,16 @@ static uint brcmf_sdbrcm_glom_len(struct brcmf_bus *bus) return total; } +static void brcmf_sdbrcm_free_glom(struct brcmf_bus *bus) +{ + struct sk_buff *cur, *next; + + skb_queue_walk_safe(&bus->glom, cur, next) { + skb_unlink(cur, &bus->glom); + brcmu_pkt_buf_free_skb(cur); + } +} + static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) { u16 dlen, totlen; @@ -1203,11 +1213,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) } pfirst = pnext = NULL; } else { - if (!skb_queue_empty(&bus->glom)) - skb_queue_walk_safe(&bus->glom, pfirst, pnext) { - skb_unlink(pfirst, &bus->glom); - brcmu_pkt_buf_free_skb(pfirst); - } + brcmf_sdbrcm_free_glom(bus); num = 0; } @@ -1274,10 +1280,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) bus->glomerr = 0; brcmf_sdbrcm_rxfail(bus, true, false); bus->rxglomfail++; - skb_queue_walk_safe(&bus->glom, pfirst, pnext) { - skb_unlink(pfirst, &bus->glom); - brcmu_pkt_buf_free_skb(pfirst); - } + brcmf_sdbrcm_free_glom(bus); } return 0; } @@ -1399,10 +1402,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) bus->glomerr = 0; brcmf_sdbrcm_rxfail(bus, true, false); bus->rxglomfail++; - skb_queue_walk_safe(&bus->glom, pfirst, pnext) { - skb_unlink(pfirst, &bus->glom); - brcmu_pkt_buf_free_skb(pfirst); - } + brcmf_sdbrcm_free_glom(bus); } bus->nextlen = 0; return 0; @@ -3369,8 +3369,6 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) u8 saveclk; uint retries; int err; - struct sk_buff *cur; - struct sk_buff *next; brcmf_dbg(TRACE, "Enter\n"); @@ -3430,11 +3428,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) /* Clear any held glomming stuff */ if (bus->glomd) brcmu_pkt_buf_free_skb(bus->glomd); - if (!skb_queue_empty(&bus->glom)) - skb_queue_walk_safe(&bus->glom, cur, next) { - skb_unlink(cur, &bus->glom); - brcmu_pkt_buf_free_skb(cur); - } + brcmf_sdbrcm_free_glom(bus); /* Clear rx control and wake any waiters */ bus->rxlen = 0; -- cgit v0.10.2 From 99b72cde632b67603f4c7f18e8ff23a57b484478 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 10 Nov 2011 20:30:33 +0100 Subject: brcm80211: fmac: remove PCMCIA core related code all the devices supported or will be supported by brcmfmac do not have a PCMCIA bus core. So remove the corresponding code. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index d8a521a..22913af 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -687,14 +687,6 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) return -EBADE; } - if (pendok && ((bus->ci->c_inf[1].id == PCMCIA_CORE_ID) - && (bus->ci->c_inf[1].rev == 9))) { - u32 dummy, retries; - r_sdreg32(bus, &dummy, - offsetof(struct sdpcmd_regs, clockctlstatus), - &retries); - } - /* Check current status */ clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); @@ -911,13 +903,6 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); - /* Force pad isolation off if possible - (in case power never toggled) */ - if ((bus->ci->c_inf[1].id == PCMCIA_CORE_ID) - && (bus->ci->c_inf[1].rev >= 10)) - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, - SBSDIO_DEVICE_CTL, 0, NULL); - /* Make sure the controller has the bus up */ brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); -- cgit v0.10.2 From e78946e198b9cf2656dceb5ea2c21759f469a125 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 10 Nov 2011 20:30:34 +0100 Subject: brcm80211: fmac: release bss struct returned from cfg80211_inform_bss Referenced struct returned by cfg80211_inform_bss must be released with cfg80211_put_bss to avoid memory leak. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 73be2c8..cc19a73 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -2049,10 +2049,10 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, notify_timestamp, notify_capability, notify_interval, notify_ie, notify_ielen, notify_signal, GFP_KERNEL); - if (!bss) { - WL_ERR("cfg80211_inform_bss_frame error\n"); - return -EINVAL; - } + if (!bss) + return -ENOMEM; + + cfg80211_put_bss(bss); return err; } @@ -2096,6 +2096,7 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, struct ieee80211_channel *notify_channel; struct brcmf_bss_info_le *bi = NULL; struct ieee80211_supported_band *band; + struct cfg80211_bss *bss; u8 *buf = NULL; s32 err = 0; u16 channel; @@ -2149,10 +2150,17 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, WL_CONN("signal: %d\n", notify_signal); WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); - cfg80211_inform_bss(wiphy, notify_channel, bssid, + bss = cfg80211_inform_bss(wiphy, notify_channel, bssid, notify_timestamp, notify_capability, notify_interval, notify_ie, notify_ielen, notify_signal, GFP_KERNEL); + if (!bss) { + err = -ENOMEM; + goto CleanUp; + } + + cfg80211_put_bss(bss); + CleanUp: kfree(buf); -- cgit v0.10.2 From 6d377cdbe3d35d67468fcfe7473fc3f0f74fa647 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Fri, 11 Nov 2011 13:29:29 -0500 Subject: brcmsmac: fix warning in _initvars_srom_pci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC [M] drivers/net/wireless/brcm80211/brcmsmac/srom.o drivers/net/wireless/brcm80211/brcmsmac/srom.c: In function ‘_initvars_srom_pci’: drivers/net/wireless/brcm80211/brcmsmac/srom.c:641:6: warning: ‘val’ may be used uninitialized in this function Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 3a9b81d..b6987ea 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -638,7 +638,7 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) struct brcms_srom_list_head *entry; enum brcms_srom_id id; u16 w; - u32 val; + u32 val = 0; const struct brcms_sromvar *srv; uint width; uint flags; -- cgit v0.10.2 From 731f8e1c41a4d0ffb589e2395f931f8a1aa6c6a4 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Fri, 11 Nov 2011 13:49:45 -0500 Subject: libertas: release bss references and avoid warning from cfg80211_inform_bss MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC [M] drivers/net/wireless/libertas/cfg.o drivers/net/wireless/libertas/cfg.c: In function ‘lbs_ret_scan’: drivers/net/wireless/libertas/cfg.c:636:24: warning: ignoring return value of ‘cfg80211_inform_bss’, declared with attribute warn_unused_result drivers/net/wireless/libertas/cfg.c: In function ‘lbs_join_post’: drivers/net/wireless/libertas/cfg.c:1766:21: warning: ignoring return value of ‘cfg80211_inform_bss’, declared with attribute warn_unused_result Signed-off-by: John W. Linville diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index 4fcd653..89f34ad 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c @@ -485,6 +485,7 @@ static int lbs_cfg_set_channel(struct wiphy *wiphy, static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, struct cmd_header *resp) { + struct cfg80211_bss *bss; struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; int bsssize; const u8 *pos; @@ -632,12 +633,14 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, LBS_SCAN_RSSI_TO_MBM(rssi)/100); if (channel && - !(channel->flags & IEEE80211_CHAN_DISABLED)) - cfg80211_inform_bss(wiphy, channel, + !(channel->flags & IEEE80211_CHAN_DISABLED)) { + bss = cfg80211_inform_bss(wiphy, channel, bssid, le64_to_cpu(*(__le64 *)tsfdesc), capa, intvl, ie, ielen, LBS_SCAN_RSSI_TO_MBM(rssi), GFP_KERNEL); + cfg80211_put_bss(bss); + } } else lbs_deb_scan("scan response: missing BSS channel IE\n"); @@ -1720,6 +1723,7 @@ static void lbs_join_post(struct lbs_private *priv, 2 + 2 + /* atim */ 2 + 8]; /* extended rates */ u8 *fake = fake_ie; + struct cfg80211_bss *bss; lbs_deb_enter(LBS_DEB_CFG80211); @@ -1763,14 +1767,15 @@ static void lbs_join_post(struct lbs_private *priv, *fake++ = 0x6c; lbs_deb_hex(LBS_DEB_CFG80211, "IE", fake_ie, fake - fake_ie); - cfg80211_inform_bss(priv->wdev->wiphy, - params->channel, - bssid, - 0, - capability, - params->beacon_interval, - fake_ie, fake - fake_ie, - 0, GFP_KERNEL); + bss = cfg80211_inform_bss(priv->wdev->wiphy, + params->channel, + bssid, + 0, + capability, + params->beacon_interval, + fake_ie, fake - fake_ie, + 0, GFP_KERNEL); + cfg80211_put_bss(bss); memcpy(priv->wdev->ssid, params->ssid, params->ssid_len); priv->wdev->ssid_len = params->ssid_len; -- cgit v0.10.2 From b4487c2d0edaf1332d7a9f11b5661044955ef5e2 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 11 Nov 2011 20:22:30 +0100 Subject: mac80211: fix warning in ieee80211_probe_client The warning is spurious -- if !sta we always exit without using the unassigned qos variable, and if we do find the sta we assign it. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index c2416fb..1063a7e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2570,12 +2570,13 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, rcu_read_lock(); sta = sta_info_get(sdata, peer); - if (sta) + if (sta) { qos = test_sta_flag(sta, WLAN_STA_WME); - rcu_read_unlock(); - - if (!sta) + rcu_read_unlock(); + } else { + rcu_read_unlock(); return -ENOLINK; + } if (qos) { fc = cpu_to_le16(IEEE80211_FTYPE_DATA | -- cgit v0.10.2 From 30128031d71741ef7d0e32c345e3bf02aa8a0704 Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 10 Nov 2011 19:17:57 +0000 Subject: be2net: init (vf)_if_handle/vf_pmac_id to handle failure scenarios Initialize if_handle, vf_if_handle and vf_pmac_id with "-1" so that in failure cases when be_clear() is called, we can skip over if_destroy/pmac_del cmds if they have not been created. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 644e8fe..4163980 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -289,14 +289,12 @@ struct be_drv_stats { struct be_vf_cfg { unsigned char vf_mac_addr[ETH_ALEN]; - u32 vf_if_handle; - u32 vf_pmac_id; + int vf_if_handle; + int vf_pmac_id; u16 vf_vlan_tag; u32 vf_tx_rate; }; -#define BE_INVALID_PMAC_ID 0xffffffff - struct be_adapter { struct pci_dev *pdev; struct net_device *netdev; @@ -347,7 +345,7 @@ struct be_adapter { /* Ethtool knobs and info */ char fw_ver[FW_VER_LEN]; - u32 if_handle; /* Used to configure filtering */ + int if_handle; /* Used to configure filtering */ u32 pmac_id; /* MAC addr handle used by BE card */ u32 beacon_state; /* for set_phys_id */ diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 2c7b366..c5912c4 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -695,12 +695,15 @@ err: } /* Uses synchronous MCCQ */ -int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id, u32 dom) +int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id, u32 dom) { struct be_mcc_wrb *wrb; struct be_cmd_req_pmac_del *req; int status; + if (pmac_id == -1) + return 0; + spin_lock_bh(&adapter->mcc_lock); wrb = wrb_from_mccq(adapter); @@ -1136,7 +1139,7 @@ err: } /* Uses MCCQ */ -int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) +int be_cmd_if_destroy(struct be_adapter *adapter, int interface_id, u32 domain) { struct be_mcc_wrb *wrb; struct be_cmd_req_if_destroy *req; @@ -1145,7 +1148,7 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain) if (adapter->eeh_err) return -EIO; - if (!interface_id) + if (interface_id == -1) return 0; spin_lock_bh(&adapter->mcc_lock); diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index a35cd03..0818039 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h @@ -1417,11 +1417,11 @@ extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, u32 if_id, u32 *pmac_id, u32 domain); extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, - u32 pmac_id, u32 domain); + int pmac_id, u32 domain); extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id, u32 domain); -extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle, +extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle, u32 domain); extern int be_cmd_eq_create(struct be_adapter *adapter, struct be_queue_info *eq, int eq_delay); diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index bf266a0..83d971d 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -848,15 +848,11 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) return -EINVAL; - if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) - status = be_cmd_pmac_del(adapter, - adapter->vf_cfg[vf].vf_if_handle, - adapter->vf_cfg[vf].vf_pmac_id, vf + 1); + status = be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle, + adapter->vf_cfg[vf].vf_pmac_id, vf + 1); - status = be_cmd_pmac_add(adapter, mac, - adapter->vf_cfg[vf].vf_if_handle, + status = be_cmd_pmac_add(adapter, mac, adapter->vf_cfg[vf].vf_if_handle, &adapter->vf_cfg[vf].vf_pmac_id, vf + 1); - if (status) dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", mac, vf); @@ -2488,17 +2484,13 @@ static void be_vf_clear(struct be_adapter *adapter) { u32 vf; - for (vf = 0; vf < num_vfs; vf++) { - if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) - be_cmd_pmac_del(adapter, - adapter->vf_cfg[vf].vf_if_handle, - adapter->vf_cfg[vf].vf_pmac_id, vf + 1); - } + for (vf = 0; vf < num_vfs; vf++) + be_cmd_pmac_del(adapter, adapter->vf_cfg[vf].vf_if_handle, + adapter->vf_cfg[vf].vf_pmac_id, vf + 1); for (vf = 0; vf < num_vfs; vf++) - if (adapter->vf_cfg[vf].vf_if_handle) - be_cmd_if_destroy(adapter, - adapter->vf_cfg[vf].vf_if_handle, vf + 1); + be_cmd_if_destroy(adapter, adapter->vf_cfg[vf].vf_if_handle, + vf + 1); } static int be_clear(struct be_adapter *adapter) @@ -2511,22 +2503,30 @@ static int be_clear(struct be_adapter *adapter) be_mcc_queues_destroy(adapter); be_rx_queues_destroy(adapter); be_tx_queues_destroy(adapter); - adapter->eq_next_idx = 0; - - adapter->be3_native = false; - adapter->promiscuous = false; /* tell fw we're done with firing cmds */ be_cmd_fw_clean(adapter); return 0; } +static void be_vf_setup_init(struct be_adapter *adapter) +{ + int vf; + + for (vf = 0; vf < num_vfs; vf++) { + adapter->vf_cfg[vf].vf_if_handle = -1; + adapter->vf_cfg[vf].vf_pmac_id = -1; + } +} + static int be_vf_setup(struct be_adapter *adapter) { u32 cap_flags, en_flags, vf; u16 lnk_speed; int status; + be_vf_setup_init(adapter); + cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST; for (vf = 0; vf < num_vfs; vf++) { status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, @@ -2534,7 +2534,6 @@ static int be_vf_setup(struct be_adapter *adapter) NULL, vf+1); if (status) goto err; - adapter->vf_cfg[vf].vf_pmac_id = BE_INVALID_PMAC_ID; } if (!lancer_chip(adapter)) { @@ -2555,6 +2554,16 @@ err: return status; } +static void be_setup_init(struct be_adapter *adapter) +{ + adapter->vlan_prio_bmap = 0xff; + adapter->link_speed = -1; + adapter->if_handle = -1; + adapter->be3_native = false; + adapter->promiscuous = false; + adapter->eq_next_idx = 0; +} + static int be_setup(struct be_adapter *adapter) { struct net_device *netdev = adapter->netdev; @@ -2563,9 +2572,7 @@ static int be_setup(struct be_adapter *adapter) int status; u8 mac[ETH_ALEN]; - /* Allow all priorities by default. A GRP5 evt may modify this */ - adapter->vlan_prio_bmap = 0xff; - adapter->link_speed = -1; + be_setup_init(adapter); be_cmd_req_native_mode(adapter); -- cgit v0.10.2 From 72f02485626b3e71955e54d227ede1b54021d571 Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 10 Nov 2011 19:17:58 +0000 Subject: be2net: stop checking the UE registers after an EEH error Signed-off-by: Sathya Perla Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 83d971d..99da07f 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -1978,6 +1978,9 @@ void be_detect_dump_ue(struct be_adapter *adapter) u32 sliport_status = 0, sliport_err1 = 0, sliport_err2 = 0; u32 i; + if (adapter->eeh_err || adapter->ue_detected) + return; + if (lancer_chip(adapter)) { sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); if (sliport_status & SLIPORT_STATUS_ERR_MASK) { @@ -2039,8 +2042,7 @@ static void be_worker(struct work_struct *work) struct be_rx_obj *rxo; int i; - if (!adapter->ue_detected) - be_detect_dump_ue(adapter); + be_detect_dump_ue(adapter); /* when interrupts are not yet enabled, just reap any pending * mcc completions */ -- cgit v0.10.2 From 434b3648e9a58600cea5f3a1a0a7a89048e4df61 Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 10 Nov 2011 19:17:59 +0000 Subject: be2net: don't log more than one error on detecting EEH/UE errors Currently we're spamming error messages each time a FW cmd call is made while in EEH/UE error state. One log msg on error detection is enough. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index c5912c4..94cd77c 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -31,11 +31,8 @@ static void be_mcc_notify(struct be_adapter *adapter) struct be_queue_info *mccq = &adapter->mcc_obj.q; u32 val = 0; - if (adapter->eeh_err) { - dev_info(&adapter->pdev->dev, - "Error in Card Detected! Cannot issue commands\n"); + if (adapter->eeh_err) return; - } val |= mccq->id & DB_MCCQ_RING_ID_MASK; val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT; @@ -298,19 +295,13 @@ static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) int msecs = 0; u32 ready; - if (adapter->eeh_err) { - dev_err(&adapter->pdev->dev, - "Error detected in card.Cannot issue commands\n"); + if (adapter->eeh_err) return -EIO; - } do { ready = ioread32(db); - if (ready == 0xffffffff) { - dev_err(&adapter->pdev->dev, - "pci slot disconnected\n"); + if (ready == 0xffffffff) return -1; - } ready &= MPU_MAILBOX_DB_RDY_MASK; if (ready) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 99da07f..0e97b6d 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -2007,7 +2007,8 @@ void be_detect_dump_ue(struct be_adapter *adapter) sliport_status & SLIPORT_STATUS_ERR_MASK) { adapter->ue_detected = true; adapter->eeh_err = true; - dev_err(&adapter->pdev->dev, "UE Detected!!\n"); + dev_err(&adapter->pdev->dev, + "Unrecoverable error in the card\n"); } if (ue_lo) { -- cgit v0.10.2 From 6589ade019dcab245d3bb847370f855b56cdf6ad Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 10 Nov 2011 19:18:00 +0000 Subject: be2net: stop issuing FW cmds if any cmd times out A FW cmd timeout (with a sufficiently large timeout value in the order of tens of seconds) indicates an unresponsive FW. In this state issuing further cmds and waiting for a completion will only stall the process. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 4163980..34f162d 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -350,6 +350,8 @@ struct be_adapter { u32 beacon_state; /* for set_phys_id */ bool eeh_err; + bool ue_detected; + bool fw_timeout; u32 port_num; bool promiscuous; bool wol; @@ -357,7 +359,6 @@ struct be_adapter { u32 function_caps; u32 rx_fc; /* Rx flow control */ u32 tx_fc; /* Tx flow control */ - bool ue_detected; bool stats_cmd_sent; int link_speed; u8 port_type; @@ -522,6 +523,11 @@ static inline bool be_multi_rxq(const struct be_adapter *adapter) return adapter->num_rx_qs > 1; } +static inline bool be_error(struct be_adapter *adapter) +{ + return adapter->eeh_err || adapter->ue_detected || adapter->fw_timeout; +} + extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped); extern void be_link_status_update(struct be_adapter *adapter, u32 link_status); diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 94cd77c..ad3eef0 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -31,7 +31,7 @@ static void be_mcc_notify(struct be_adapter *adapter) struct be_queue_info *mccq = &adapter->mcc_obj.q; u32 val = 0; - if (adapter->eeh_err) + if (be_error(adapter)) return; val |= mccq->id & DB_MCCQ_RING_ID_MASK; @@ -263,10 +263,10 @@ static int be_mcc_wait_compl(struct be_adapter *adapter) int i, num, status = 0; struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; - if (adapter->eeh_err) - return -EIO; - for (i = 0; i < mcc_timeout; i++) { + if (be_error(adapter)) + return -EIO; + num = be_process_mcc(adapter, &status); if (num) be_cq_notify(adapter, mcc_obj->cq.id, @@ -277,7 +277,8 @@ static int be_mcc_wait_compl(struct be_adapter *adapter) udelay(100); } if (i == mcc_timeout) { - dev_err(&adapter->pdev->dev, "mccq poll timed out\n"); + dev_err(&adapter->pdev->dev, "FW not responding\n"); + adapter->fw_timeout = true; return -1; } return status; @@ -295,10 +296,10 @@ static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) int msecs = 0; u32 ready; - if (adapter->eeh_err) - return -EIO; - do { + if (be_error(adapter)) + return -EIO; + ready = ioread32(db); if (ready == 0xffffffff) return -1; @@ -308,7 +309,8 @@ static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) break; if (msecs > 4000) { - dev_err(&adapter->pdev->dev, "mbox poll timed out\n"); + dev_err(&adapter->pdev->dev, "FW not responding\n"); + adapter->fw_timeout = true; be_detect_dump_ue(adapter); return -1; } @@ -546,9 +548,6 @@ int be_cmd_fw_clean(struct be_adapter *adapter) u8 *wrb; int status; - if (adapter->eeh_err) - return -EIO; - if (mutex_lock_interruptible(&adapter->mbox_lock)) return -1; @@ -1012,9 +1011,6 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, u8 subsys = 0, opcode = 0; int status; - if (adapter->eeh_err) - return -EIO; - if (mutex_lock_interruptible(&adapter->mbox_lock)) return -1; @@ -1136,9 +1132,6 @@ int be_cmd_if_destroy(struct be_adapter *adapter, int interface_id, u32 domain) struct be_cmd_req_if_destroy *req; int status; - if (adapter->eeh_err) - return -EIO; - if (interface_id == -1) return 0; diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 0e97b6d..ce20d64 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -3569,6 +3569,8 @@ static pci_ers_result_t be_eeh_reset(struct pci_dev *pdev) dev_info(&adapter->pdev->dev, "EEH reset\n"); adapter->eeh_err = false; + adapter->ue_detected = false; + adapter->fw_timeout = false; status = pci_enable_device(pdev); if (status) -- cgit v0.10.2 From 5e07021e434a64c454b0e9fb9f5aa763f131b22b Mon Sep 17 00:00:00 2001 From: Dai Shuibing Date: Thu, 3 Nov 2011 11:39:37 +0200 Subject: ath6kl: Add support for configuring SMS4 keys Indicate support for WPI-SMS4 cipher and allow SMS4 keys to be configured. Signed-off-by: Dai Shuibing Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 4d1394a..d2b23da 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -203,6 +203,10 @@ static int ath6kl_set_cipher(struct ath6kl_vif *vif, u32 cipher, bool ucast) *ar_cipher = AES_CRYPT; *ar_cipher_len = 0; break; + case WLAN_CIPHER_SUITE_SMS4: + *ar_cipher = WAPI_CRYPT; + *ar_cipher_len = 0; + break; default: ath6kl_err("cipher 0x%x not supported\n", cipher); return -ENOTSUPP; @@ -935,13 +939,19 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, key_usage = GROUP_USAGE; if (params) { + int seq_len = params->seq_len; + if (params->cipher == WLAN_CIPHER_SUITE_SMS4 && + seq_len > ATH6KL_KEY_SEQ_LEN) { + /* Only first half of the WPI PN is configured */ + seq_len = ATH6KL_KEY_SEQ_LEN; + } if (params->key_len > WLAN_MAX_KEY_LEN || - params->seq_len > sizeof(key->seq)) + seq_len > sizeof(key->seq)) return -EINVAL; key->key_len = params->key_len; memcpy(key->key, params->key, key->key_len); - key->seq_len = params->seq_len; + key->seq_len = seq_len; memcpy(key->seq, params->seq, key->seq_len); key->cipher = params->cipher; } @@ -959,6 +969,9 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, case WLAN_CIPHER_SUITE_CCMP: key_type = AES_CRYPT; break; + case WLAN_CIPHER_SUITE_SMS4: + key_type = WAPI_CRYPT; + break; default: return -ENOTSUPP; @@ -1451,6 +1464,7 @@ static const u32 cipher_suites[] = { WLAN_CIPHER_SUITE_TKIP, WLAN_CIPHER_SUITE_CCMP, CCKM_KRK_CIPHER_SUITE, + WLAN_CIPHER_SUITE_SMS4, }; static bool is_rate_legacy(s32 rate) diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index 41e465f..bfd6597 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -71,6 +71,7 @@ enum crypto_type { WEP_CRYPT = 0x02, TKIP_CRYPT = 0x04, AES_CRYPT = 0x08, + WAPI_CRYPT = 0x10, }; struct htc_endpoint_credit_dist; -- cgit v0.10.2 From b8214df1d963cad2aae1479b86452e205312004e Mon Sep 17 00:00:00 2001 From: Dai Shuibing Date: Thu, 3 Nov 2011 11:39:38 +0200 Subject: ath6kl: Allow SMS4 to be configured in AP mode Signed-off-by: Dai Shuibing Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d2b23da..f612639 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2093,6 +2093,9 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, case WLAN_CIPHER_SUITE_CCMP: p.prwise_crypto_type |= AES_CRYPT; break; + case WLAN_CIPHER_SUITE_SMS4: + p.prwise_crypto_type |= WAPI_CRYPT; + break; } } if (p.prwise_crypto_type == 0) { @@ -2112,6 +2115,9 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, case WLAN_CIPHER_SUITE_CCMP: p.grp_crypto_type = AES_CRYPT; break; + case WLAN_CIPHER_SUITE_SMS4: + p.grp_crypto_type = WAPI_CRYPT; + break; default: p.grp_crypto_type = NONE_CRYPT; break; -- cgit v0.10.2 From 30677ae015ade68a315e66385f64448c532ce39a Mon Sep 17 00:00:00 2001 From: Dai Shuibing Date: Thu, 3 Nov 2011 11:39:39 +0200 Subject: ath6kl: Indicate WAPI IE from (Re)Association Request frame This is needed to know whether the STA requests WAPI to be used and if so, with what AKM and cipher. Signed-off-by: Dai Shuibing Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 5e5f4ca..1195f94 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -534,6 +534,18 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, wpa_ie = pos; /* WPS IE */ break; /* overrides WPA/RSN IE */ } + } else if (pos[0] == 0x44 && wpa_ie == NULL) { + /* + * Note: WAPI Parameter Set IE re-uses Element ID that + * was officially allocated for BSS AC Access Delay. As + * such, we need to be a bit more careful on when + * parsing the frame. However, BSS AC Access Delay + * element is not supposed to be included in + * (Re)Association Request frames, so this should not + * cause problems. + */ + wpa_ie = pos; /* WAPI IE */ + break; } pos += 2 + pos[1]; } -- cgit v0.10.2 From f3803eb2f57450ad3f67f8f6dd728f94ad8c717d Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Mon, 7 Nov 2011 12:50:17 +0530 Subject: ath6kl: Fix accessing wrong skb->data in ath6kl_tx_complete() When buffer alignmnet is applied, the data pointer of skb taken from cookie will no longer point to the first byte of the actual data. But the skb->data pointer is used in ath6kl_tx_complete() to get the index of the virtual interface which will not give the correct interface index and sometimes may give the following WARN_ON() message. Use packet->buf instead of skb->data to fix this. WARNING: at drivers/net/wireless/ath/ath6kl/wmi.c:88 ath6kl_get_vif_by_index+0x5b/0x60 [ath6kl]() Hardware name: 2842K3U Modules linked in: ath6kl mmc_block cfg80211 binfmt_misc ppdev nfs nfsd lockd nfs_acl auth_rpcgss sunrpc exportfs snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_intel +snd_hda_codec snd_hwdep snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy thinkpad_acpi snd_seq_oss snd_seq_midi snd_rawmidi joydev fbcon tileblit font bitblit softcursor +snd_seq_midi_event snd_seq snd_timer snd_seq_device i915 uvcvideo drm_kms_helper drm psmouse serio_raw snd i2c_algo_bit sdhci_pci videodev intel_agp soundcore intel_gtt jmb38x_ms +memstick sdhci snd_page_alloc nvram lp parport agpgart video ahci r8169 mii libahci [last unloaded: ath6kl] Pid: 15482, comm: kworker/u:1 Tainted: G W 3.1.0-rc10-wl+ #2 Call Trace: [] warn_slowpath_common+0x72/0xa0 [] ? ath6kl_get_vif_by_index+0x5b/0x60 [ath6kl] [] ? ath6kl_get_vif_by_index+0x5b/0x60 [ath6kl] [] warn_slowpath_null+0x22/0x30 [] ath6kl_get_vif_by_index+0x5b/0x60 [ath6kl] [] ath6kl_tx_complete+0x128/0x4d0 [ath6kl] [] ? mmc_request_done+0x80/0x80 [] htc_tx_complete+0x5e/0x70 [ath6kl] [] ? _raw_spin_unlock_bh+0x16/0x20 [] ? ath6kl_sdio_scatter_req_add+0x48/0x60 [ath6kl] [] htc_async_tx_scat_complete+0xb2/0x120 [ath6kl] [] ath6kl_sdio_scat_rw+0x87/0x370 [ath6kl] [] ? __switch_to+0xd2/0x190 [] ? finish_task_switch+0x45/0xd0 [] ? __schedule+0x3ae/0x8b0 [] ath6kl_sdio_write_async_work+0x4a/0xf0 [ath6kl] [] process_one_work+0x116/0x3c0 [] ? ath6kl_sdio_read_write_sync+0xb0/0xb0 [ath6kl] [] worker_thread+0x140/0x3b0 [] ? manage_workers+0x1f0/0x1f0 [] kthread+0x74/0x80 [] ? kthread_worker_fn+0x160/0x160 [] kernel_thread_helper+0x6/0x10 Reported-by: Aarthi Thiruvengadam Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index d9cff2b..62beadb 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -571,8 +571,6 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) if (!skb || !skb->data) goto fatal; - packet->buf = skb->data; - __skb_queue_tail(&skb_queue, skb); if (!status && (packet->act_len != skb->len)) @@ -593,10 +591,10 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) if (eid == ar->ctrl_ep) { if_idx = wmi_cmd_hdr_get_if_idx( - (struct wmi_cmd_hdr *) skb->data); + (struct wmi_cmd_hdr *) packet->buf); } else { if_idx = wmi_data_hdr_get_if_idx( - (struct wmi_data_hdr *) skb->data); + (struct wmi_data_hdr *) packet->buf); } vif = ath6kl_get_vif_by_index(ar, if_idx); -- cgit v0.10.2 From 901db39c845f676a46349a833fbe89a9ad0699ee Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 8 Nov 2011 20:01:25 +0530 Subject: ath6kl: Fix packet drop when ath6kl_cookie runs out "ath6kl: Maintain virtual interface in a list" mistakenly stops the netq only when the mode is ibss. This causes packet drops in sta mode when the available cookies (buffer abstraction in ath6kl and also used for tx throttling) runs out for the highest priority traffic. This patch just fixes this regression though the original code may still need fixes which can be addressed in separate patches. Reported-by: Kalle Valo Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 62beadb..0b45d45 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -453,11 +453,11 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, set_bit(WMI_CTRL_EP_FULL, &ar->flag); spin_unlock_bh(&ar->lock); ath6kl_err("wmi ctrl ep is full\n"); - goto stop_adhoc_netq; + return action; } if (packet->info.tx.tag == ATH6KL_CONTROL_PKT_TAG) - goto stop_adhoc_netq; + return action; /* * The last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for @@ -465,20 +465,18 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, */ if (ar->ac_stream_pri_map[ar->ep2ac_map[endpoint]] < ar->hiac_stream_active_pri && - ar->cookie_count <= MAX_HI_COOKIE_NUM) { + ar->cookie_count <= MAX_HI_COOKIE_NUM) /* * Give preference to the highest priority stream by * dropping the packets which overflowed. */ action = HTC_SEND_FULL_DROP; - goto stop_adhoc_netq; - } -stop_adhoc_netq: /* FIXME: Locking */ spin_lock_bh(&ar->list_lock); list_for_each_entry(vif, &ar->vif_list, list) { - if (vif->nw_type == ADHOC_NETWORK) { + if (vif->nw_type == ADHOC_NETWORK || + action != HTC_SEND_FULL_DROP) { spin_unlock_bh(&ar->list_lock); spin_lock_bh(&vif->if_lock); -- cgit v0.10.2 From 4eab6f4f43032015131db97f089734633c1b3c1f Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Wed, 9 Nov 2011 17:02:23 +0530 Subject: ath6kl: Fix cfg80211 warning while starting IBSS mode When the connect event is received from the target in IBSS mode, cfg80211_ibss_joined() is called without informing BSS info to cfg80211 layer which internally hits the below WARN_ON message. WARNING: at net/wireless/ibss.c:33 __cfg80211_ibss_joined+0x153/0x180 [cfg80211]() [..] [ 4916.845878] Call Trace: [ 4916.845889] [] warn_slowpath_common+0x72/0xa0 [ 4916.845905] [] ? __cfg80211_ibss_joined+0x153/0x180 [cfg80211] [ 4916.845918] [] ? __cfg80211_ibss_joined+0x153/0x180 [cfg80211] [ 4916.845923] [] warn_slowpath_null+0x22/0x30 [ 4916.845934] [] __cfg80211_ibss_joined+0x153/0x180 [cfg80211] [ 4916.845941] [] ? default_spin_lock_flags+0x8/0x10 [ 4916.845952] [] cfg80211_process_rdev_events+0x19d/0x220 [cfg80211] [ 4916.845962] [] cfg80211_event_work+0x2b/0x50 [cfg80211] [ 4916.845968] [] process_one_work+0x116/0x3c0 [ 4916.845977] [] ? cfg80211_get_dev_from_info+0x40/0x40 [cfg80211] [ 4916.845982] [] worker_thread+0x140/0x3b0 [ 4916.845986] [] ? manage_workers+0x1f0/0x1f0 [ 4916.845991] [] kthread+0x74/0x80 [ 4916.845995] [] ? kthread_worker_fn+0x160/0x160 [ 4916.846001] [] kernel_thread_helper+0x6/0x10 [ 4916.846005] ---[ end trace 769254924e409367 ]--- This patch make sures that BSS info is delivered via cfg80211_inform_bss() to cfg80211 in advance before intimating IBSS status to cfg80211. In addition to this, one debug message is also added to know ad-hoc mode status (creator/joiner). kvalo: change subject Signed-off-by: Raja Mani Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index f612639..41260c8 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -565,17 +565,28 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return 0; } -static int ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, const u8 *bssid, +static int ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, + enum network_type nw_type, + const u8 *bssid, struct ieee80211_channel *chan, const u8 *beacon_ie, size_t beacon_ie_len) { struct ath6kl *ar = vif->ar; struct cfg80211_bss *bss; + u16 cap_mask, cap_val; u8 *ie; + if (nw_type & ADHOC_NETWORK) { + cap_mask = WLAN_CAPABILITY_IBSS; + cap_val = WLAN_CAPABILITY_IBSS; + } else { + cap_mask = WLAN_CAPABILITY_ESS; + cap_val = WLAN_CAPABILITY_ESS; + } + bss = cfg80211_get_bss(ar->wiphy, chan, bssid, - vif->ssid, vif->ssid_len, WLAN_CAPABILITY_ESS, - WLAN_CAPABILITY_ESS); + vif->ssid, vif->ssid_len, + cap_mask, cap_val); if (bss == NULL) { /* * Since cfg80211 may not yet know about the BSS, @@ -593,13 +604,12 @@ static int ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, const u8 *bssid, memcpy(ie + 2, vif->ssid, vif->ssid_len); memcpy(ie + 2 + vif->ssid_len, beacon_ie, beacon_ie_len); bss = cfg80211_inform_bss(ar->wiphy, chan, - bssid, 0, WLAN_CAPABILITY_ESS, 100, + bssid, 0, cap_val, 100, ie, 2 + vif->ssid_len + beacon_ie_len, 0, GFP_KERNEL); if (bss) - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "added dummy bss for " - "%pM prior to indicating connect/roamed " - "event\n", bssid); + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "added bss %pM to " + "cfg80211\n", bssid); kfree(ie); } else ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "cfg80211 already has a bss " @@ -662,16 +672,16 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, chan = ieee80211_get_channel(ar->wiphy, (int) channel); - - if (nw_type & ADHOC_NETWORK) { - cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL); + if (ath6kl_add_bss_if_needed(vif, nw_type, bssid, chan, assoc_info, + beacon_ie_len) < 0) { + ath6kl_err("could not add cfg80211 bss entry\n"); return; } - if (ath6kl_add_bss_if_needed(vif, bssid, chan, assoc_info, - beacon_ie_len) < 0) { - ath6kl_err("could not add cfg80211 bss entry for " - "connect/roamed notification\n"); + if (nw_type & ADHOC_NETWORK) { + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "ad-hoc %s selected\n", + nw_type & ADHOC_CREATOR ? "creator" : "joiner"); + cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL); return; } -- cgit v0.10.2 From bd24a50fe66ef1f64a84a3d02e0f464bb394bb9b Mon Sep 17 00:00:00 2001 From: Aarthi Thiruvengadam Date: Wed, 9 Nov 2011 10:05:56 -0800 Subject: ath6kl: Fix target minimum length requirement for WMI_SEND_PROBE_RESPONSE_CMDID The firmware expects the minimum length of WMI_SEND_PROBE_RESPONSE_CMDID to be 13. However, when the device is a P2P GO and it needs to send a probe response to a non-P2P client, there are no P2P IEs to be added, and therefore the length of the WMI command is 12. This command gets rejected by the firmware. To fix this, add an extra byte to satisfy the minimum length requirement. Signed-off-by: Aarthi Thiruvengadam Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 922344d..f1d53d0 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -3024,8 +3024,12 @@ int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, { struct sk_buff *skb; struct wmi_p2p_probe_response_cmd *p; + size_t cmd_len = sizeof(*p) + data_len; - skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); + if (data_len == 0) + cmd_len++; /* work around target minimum length requirement */ + + skb = ath6kl_wmi_get_new_buf(cmd_len); if (!skb) return -ENOMEM; -- cgit v0.10.2 From 66b693c3b84876d33afd35b9d717d8b9d07384c8 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:17:33 +0200 Subject: ath6kl: move bmi calls to hif driver In preparation for USB support which has it's own method for bmi. Based on code by Kevin Fang. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index a962fe4..12f5b57 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -19,165 +19,6 @@ #include "target.h" #include "debug.h" -static int ath6kl_get_bmi_cmd_credits(struct ath6kl *ar) -{ - u32 addr; - unsigned long timeout; - int ret; - - ar->bmi.cmd_credits = 0; - - /* Read the counter register to get the command credits */ - addr = COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 4; - - timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT); - while (time_before(jiffies, timeout) && !ar->bmi.cmd_credits) { - - /* - * Hit the credit counter with a 4-byte access, the first byte - * read will hit the counter and cause a decrement, while the - * remaining 3 bytes has no effect. The rationale behind this - * is to make all HIF accesses 4-byte aligned. - */ - ret = hif_read_write_sync(ar, addr, - (u8 *)&ar->bmi.cmd_credits, 4, - HIF_RD_SYNC_BYTE_INC); - if (ret) { - ath6kl_err("Unable to decrement the command credit count register: %d\n", - ret); - return ret; - } - - /* The counter is only 8 bits. - * Ignore anything in the upper 3 bytes - */ - ar->bmi.cmd_credits &= 0xFF; - } - - if (!ar->bmi.cmd_credits) { - ath6kl_err("bmi communication timeout\n"); - return -ETIMEDOUT; - } - - return 0; -} - -static int ath6kl_bmi_get_rx_lkahd(struct ath6kl *ar) -{ - unsigned long timeout; - u32 rx_word = 0; - int ret = 0; - - timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT); - while (time_before(jiffies, timeout) && !rx_word) { - ret = hif_read_write_sync(ar, RX_LOOKAHEAD_VALID_ADDRESS, - (u8 *)&rx_word, sizeof(rx_word), - HIF_RD_SYNC_BYTE_INC); - if (ret) { - ath6kl_err("unable to read RX_LOOKAHEAD_VALID\n"); - return ret; - } - - /* all we really want is one bit */ - rx_word &= (1 << ENDPOINT1); - } - - if (!rx_word) { - ath6kl_err("bmi_recv_buf FIFO empty\n"); - return -EINVAL; - } - - return ret; -} - -static int ath6kl_bmi_send_buf(struct ath6kl *ar, u8 *buf, u32 len) -{ - int ret; - u32 addr; - - ret = ath6kl_get_bmi_cmd_credits(ar); - if (ret) - return ret; - - addr = ar->mbox_info.htc_addr; - - ret = hif_read_write_sync(ar, addr, buf, len, - HIF_WR_SYNC_BYTE_INC); - if (ret) - ath6kl_err("unable to send the bmi data to the device\n"); - - return ret; -} - -static int ath6kl_bmi_recv_buf(struct ath6kl *ar, u8 *buf, u32 len) -{ - int ret; - u32 addr; - - /* - * During normal bootup, small reads may be required. - * Rather than issue an HIF Read and then wait as the Target - * adds successive bytes to the FIFO, we wait here until - * we know that response data is available. - * - * This allows us to cleanly timeout on an unexpected - * Target failure rather than risk problems at the HIF level. - * In particular, this avoids SDIO timeouts and possibly garbage - * data on some host controllers. And on an interconnect - * such as Compact Flash (as well as some SDIO masters) which - * does not provide any indication on data timeout, it avoids - * a potential hang or garbage response. - * - * Synchronization is more difficult for reads larger than the - * size of the MBOX FIFO (128B), because the Target is unable - * to push the 129th byte of data until AFTER the Host posts an - * HIF Read and removes some FIFO data. So for large reads the - * Host proceeds to post an HIF Read BEFORE all the data is - * actually available to read. Fortunately, large BMI reads do - * not occur in practice -- they're supported for debug/development. - * - * So Host/Target BMI synchronization is divided into these cases: - * CASE 1: length < 4 - * Should not happen - * - * CASE 2: 4 <= length <= 128 - * Wait for first 4 bytes to be in FIFO - * If CONSERVATIVE_BMI_READ is enabled, also wait for - * a BMI command credit, which indicates that the ENTIRE - * response is available in the the FIFO - * - * CASE 3: length > 128 - * Wait for the first 4 bytes to be in FIFO - * - * For most uses, a small timeout should be sufficient and we will - * usually see a response quickly; but there may be some unusual - * (debug) cases of BMI_EXECUTE where we want an larger timeout. - * For now, we use an unbounded busy loop while waiting for - * BMI_EXECUTE. - * - * If BMI_EXECUTE ever needs to support longer-latency execution, - * especially in production, this code needs to be enhanced to sleep - * and yield. Also note that BMI_COMMUNICATION_TIMEOUT is currently - * a function of Host processor speed. - */ - if (len >= 4) { /* NB: Currently, always true */ - ret = ath6kl_bmi_get_rx_lkahd(ar); - if (ret) - return ret; - } - - addr = ar->mbox_info.htc_addr; - ret = hif_read_write_sync(ar, addr, buf, len, - HIF_RD_SYNC_BYTE_INC); - if (ret) { - ath6kl_err("Unable to read the bmi data from the device: %d\n", - ret); - return ret; - } - - return 0; -} - int ath6kl_bmi_done(struct ath6kl *ar) { int ret; @@ -190,7 +31,7 @@ int ath6kl_bmi_done(struct ath6kl *ar) ar->bmi.done_sent = true; - ret = ath6kl_bmi_send_buf(ar, (u8 *)&cid, sizeof(cid)); + ret = ath6kl_hif_bmi_write(ar, (u8 *)&cid, sizeof(cid)); if (ret) { ath6kl_err("Unable to send bmi done: %d\n", ret); return ret; @@ -210,13 +51,13 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar, return -EACCES; } - ret = ath6kl_bmi_send_buf(ar, (u8 *)&cid, sizeof(cid)); + ret = ath6kl_hif_bmi_write(ar, (u8 *)&cid, sizeof(cid)); if (ret) { ath6kl_err("Unable to send get target info: %d\n", ret); return ret; } - ret = ath6kl_bmi_recv_buf(ar, (u8 *)&targ_info->version, + ret = ath6kl_hif_bmi_read(ar, (u8 *)&targ_info->version, sizeof(targ_info->version)); if (ret) { ath6kl_err("Unable to recv target info: %d\n", ret); @@ -225,7 +66,7 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar, if (le32_to_cpu(targ_info->version) == TARGET_VERSION_SENTINAL) { /* Determine how many bytes are in the Target's targ_info */ - ret = ath6kl_bmi_recv_buf(ar, + ret = ath6kl_hif_bmi_read(ar, (u8 *)&targ_info->byte_count, sizeof(targ_info->byte_count)); if (ret) { @@ -244,7 +85,7 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar, } /* Read the remainder of the targ_info */ - ret = ath6kl_bmi_recv_buf(ar, + ret = ath6kl_hif_bmi_read(ar, ((u8 *)targ_info) + sizeof(targ_info->byte_count), sizeof(*targ_info) - @@ -300,13 +141,13 @@ int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) memcpy(&(ar->bmi.cmd_buf[offset]), &rx_len, sizeof(rx_len)); offset += sizeof(len); - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to write to the device: %d\n", ret); return ret; } - ret = ath6kl_bmi_recv_buf(ar, ar->bmi.cmd_buf, rx_len); + ret = ath6kl_hif_bmi_read(ar, ar->bmi.cmd_buf, rx_len); if (ret) { ath6kl_err("Unable to read from the device: %d\n", ret); @@ -371,7 +212,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) memcpy(&(ar->bmi.cmd_buf[offset]), src, tx_len); offset += tx_len; - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to write to the device: %d\n", ret); @@ -413,13 +254,13 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param) memcpy(&(ar->bmi.cmd_buf[offset]), param, sizeof(*param)); offset += sizeof(*param); - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to write to the device: %d\n", ret); return ret; } - ret = ath6kl_bmi_recv_buf(ar, ar->bmi.cmd_buf, sizeof(*param)); + ret = ath6kl_hif_bmi_read(ar, ar->bmi.cmd_buf, sizeof(*param)); if (ret) { ath6kl_err("Unable to read from the device: %d\n", ret); return ret; @@ -457,7 +298,7 @@ int ath6kl_bmi_set_app_start(struct ath6kl *ar, u32 addr) memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); offset += sizeof(addr); - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to write to the device: %d\n", ret); return ret; @@ -493,13 +334,13 @@ int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param) memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); offset += sizeof(addr); - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to write to the device: %d\n", ret); return ret; } - ret = ath6kl_bmi_recv_buf(ar, ar->bmi.cmd_buf, sizeof(*param)); + ret = ath6kl_hif_bmi_read(ar, ar->bmi.cmd_buf, sizeof(*param)); if (ret) { ath6kl_err("Unable to read from the device: %d\n", ret); return ret; @@ -540,7 +381,7 @@ int ath6kl_bmi_reg_write(struct ath6kl *ar, u32 addr, u32 param) memcpy(&(ar->bmi.cmd_buf[offset]), ¶m, sizeof(param)); offset += sizeof(param); - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to write to the device: %d\n", ret); return ret; @@ -587,7 +428,7 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len) tx_len); offset += tx_len; - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to write to the device: %d\n", ret); @@ -629,7 +470,7 @@ int ath6kl_bmi_lz_stream_start(struct ath6kl *ar, u32 addr) memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); offset += sizeof(addr); - ret = ath6kl_bmi_send_buf(ar, ar->bmi.cmd_buf, offset); + ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); if (ret) { ath6kl_err("Unable to start LZ stream to the device: %d\n", ret); diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index eed2287..0c4c602 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -91,6 +91,16 @@ static inline int ath6kl_hif_suspend(struct ath6kl *ar, return ar->hif_ops->suspend(ar, wow); } +static inline int ath6kl_hif_bmi_read(struct ath6kl *ar, u8 *buf, u32 len) +{ + return ar->hif_ops->bmi_read(ar, buf, len); +} + +static inline int ath6kl_hif_bmi_write(struct ath6kl *ar, u8 *buf, u32 len) +{ + return ar->hif_ops->bmi_write(ar, buf, len); +} + static inline int ath6kl_hif_resume(struct ath6kl *ar) { ath6kl_dbg(ATH6KL_DBG_HIF, "hif resume\n"); diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index f2dc3bc..42004e9 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -244,6 +244,8 @@ struct ath6kl_hif_ops { void (*cleanup_scatter)(struct ath6kl *ar); int (*suspend)(struct ath6kl *ar, struct cfg80211_wowlan *wow); int (*resume)(struct ath6kl *ar); + int (*bmi_read)(struct ath6kl *ar, u8 *buf, u32 len); + int (*bmi_write)(struct ath6kl *ar, u8 *buf, u32 len); int (*power_on)(struct ath6kl *ar); int (*power_off)(struct ath6kl *ar); void (*stop)(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index beb5f9b..080be036 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -845,6 +845,166 @@ static int ath6kl_sdio_resume(struct ath6kl *ar) return 0; } +static int ath6kl_sdio_bmi_credits(struct ath6kl *ar) +{ + u32 addr; + unsigned long timeout; + int ret; + + ar->bmi.cmd_credits = 0; + + /* Read the counter register to get the command credits */ + addr = COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 4; + + timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT); + while (time_before(jiffies, timeout) && !ar->bmi.cmd_credits) { + + /* + * Hit the credit counter with a 4-byte access, the first byte + * read will hit the counter and cause a decrement, while the + * remaining 3 bytes has no effect. The rationale behind this + * is to make all HIF accesses 4-byte aligned. + */ + ret = ath6kl_sdio_read_write_sync(ar, addr, + (u8 *)&ar->bmi.cmd_credits, 4, + HIF_RD_SYNC_BYTE_INC); + if (ret) { + ath6kl_err("Unable to decrement the command credit " + "count register: %d\n", ret); + return ret; + } + + /* The counter is only 8 bits. + * Ignore anything in the upper 3 bytes + */ + ar->bmi.cmd_credits &= 0xFF; + } + + if (!ar->bmi.cmd_credits) { + ath6kl_err("bmi communication timeout\n"); + return -ETIMEDOUT; + } + + return 0; +} + +static int ath6kl_bmi_get_rx_lkahd(struct ath6kl *ar) +{ + unsigned long timeout; + u32 rx_word = 0; + int ret = 0; + + timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT); + while ((time_before(jiffies, timeout)) && !rx_word) { + ret = ath6kl_sdio_read_write_sync(ar, + RX_LOOKAHEAD_VALID_ADDRESS, + (u8 *)&rx_word, sizeof(rx_word), + HIF_RD_SYNC_BYTE_INC); + if (ret) { + ath6kl_err("unable to read RX_LOOKAHEAD_VALID\n"); + return ret; + } + + /* all we really want is one bit */ + rx_word &= (1 << ENDPOINT1); + } + + if (!rx_word) { + ath6kl_err("bmi_recv_buf FIFO empty\n"); + return -EINVAL; + } + + return ret; +} + +static int ath6kl_sdio_bmi_write(struct ath6kl *ar, u8 *buf, u32 len) +{ + int ret; + u32 addr; + + ret = ath6kl_sdio_bmi_credits(ar); + if (ret) + return ret; + + addr = ar->mbox_info.htc_addr; + + ret = ath6kl_sdio_read_write_sync(ar, addr, buf, len, + HIF_WR_SYNC_BYTE_INC); + if (ret) + ath6kl_err("unable to send the bmi data to the device\n"); + + return ret; +} + +static int ath6kl_sdio_bmi_read(struct ath6kl *ar, u8 *buf, u32 len) +{ + int ret; + u32 addr; + + /* + * During normal bootup, small reads may be required. + * Rather than issue an HIF Read and then wait as the Target + * adds successive bytes to the FIFO, we wait here until + * we know that response data is available. + * + * This allows us to cleanly timeout on an unexpected + * Target failure rather than risk problems at the HIF level. + * In particular, this avoids SDIO timeouts and possibly garbage + * data on some host controllers. And on an interconnect + * such as Compact Flash (as well as some SDIO masters) which + * does not provide any indication on data timeout, it avoids + * a potential hang or garbage response. + * + * Synchronization is more difficult for reads larger than the + * size of the MBOX FIFO (128B), because the Target is unable + * to push the 129th byte of data until AFTER the Host posts an + * HIF Read and removes some FIFO data. So for large reads the + * Host proceeds to post an HIF Read BEFORE all the data is + * actually available to read. Fortunately, large BMI reads do + * not occur in practice -- they're supported for debug/development. + * + * So Host/Target BMI synchronization is divided into these cases: + * CASE 1: length < 4 + * Should not happen + * + * CASE 2: 4 <= length <= 128 + * Wait for first 4 bytes to be in FIFO + * If CONSERVATIVE_BMI_READ is enabled, also wait for + * a BMI command credit, which indicates that the ENTIRE + * response is available in the the FIFO + * + * CASE 3: length > 128 + * Wait for the first 4 bytes to be in FIFO + * + * For most uses, a small timeout should be sufficient and we will + * usually see a response quickly; but there may be some unusual + * (debug) cases of BMI_EXECUTE where we want an larger timeout. + * For now, we use an unbounded busy loop while waiting for + * BMI_EXECUTE. + * + * If BMI_EXECUTE ever needs to support longer-latency execution, + * especially in production, this code needs to be enhanced to sleep + * and yield. Also note that BMI_COMMUNICATION_TIMEOUT is currently + * a function of Host processor speed. + */ + if (len >= 4) { /* NB: Currently, always true */ + ret = ath6kl_bmi_get_rx_lkahd(ar); + if (ret) + return ret; + } + + addr = ar->mbox_info.htc_addr; + ret = ath6kl_sdio_read_write_sync(ar, addr, buf, len, + HIF_RD_SYNC_BYTE_INC); + if (ret) { + ath6kl_err("Unable to read the bmi data from the device: %d\n", + ret); + return ret; + } + + return 0; +} + static void ath6kl_sdio_stop(struct ath6kl *ar) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); @@ -889,6 +1049,8 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .cleanup_scatter = ath6kl_sdio_cleanup_scatter, .suspend = ath6kl_sdio_suspend, .resume = ath6kl_sdio_resume, + .bmi_read = ath6kl_sdio_bmi_read, + .bmi_write = ath6kl_sdio_bmi_write, .power_on = ath6kl_sdio_power_on, .power_off = ath6kl_sdio_power_off, .stop = ath6kl_sdio_stop, -- cgit v0.10.2 From 1f4c894d3a35e88331c01e681d033a2000c3667b Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:17:42 +0200 Subject: ath6kl: change bmi sizes being configurable by HIF SDIO and USB have different maximum sizes for BMI commands so make that configurable. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index 12f5b57..bce3575 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -117,8 +117,8 @@ int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) return -EACCES; } - size = BMI_DATASZ_MAX + sizeof(cid) + sizeof(addr) + sizeof(len); - if (size > MAX_BMI_CMDBUF_SZ) { + size = ar->bmi.max_data_size + sizeof(cid) + sizeof(addr) + sizeof(len); + if (size > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } @@ -131,8 +131,8 @@ int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) len_remain = len; while (len_remain) { - rx_len = (len_remain < BMI_DATASZ_MAX) ? - len_remain : BMI_DATASZ_MAX; + rx_len = (len_remain < ar->bmi.max_data_size) ? + len_remain : ar->bmi.max_data_size; offset = 0; memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); @@ -167,7 +167,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) u32 offset; u32 len_remain, tx_len; const u32 header = sizeof(cid) + sizeof(addr) + sizeof(len); - u8 aligned_buf[BMI_DATASZ_MAX]; + u8 aligned_buf[400]; u8 *src; if (ar->bmi.done_sent) { @@ -175,12 +175,15 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) return -EACCES; } - if ((BMI_DATASZ_MAX + header) > MAX_BMI_CMDBUF_SZ) { + if ((ar->bmi.max_data_size + header) > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } - memset(ar->bmi.cmd_buf, 0, BMI_DATASZ_MAX + header); + if (WARN_ON(ar->bmi.max_data_size > sizeof(aligned_buf))) + return -E2BIG; + + memset(ar->bmi.cmd_buf, 0, ar->bmi.max_data_size + header); ath6kl_dbg(ATH6KL_DBG_BMI, "bmi write memory: addr: 0x%x, len: %d\n", addr, len); @@ -189,7 +192,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) while (len_remain) { src = &buf[len - len_remain]; - if (len_remain < (BMI_DATASZ_MAX - header)) { + if (len_remain < (ar->bmi.max_data_size - header)) { if (len_remain & 3) { /* align it with 4 bytes */ len_remain = len_remain + @@ -199,7 +202,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) } tx_len = len_remain; } else { - tx_len = (BMI_DATASZ_MAX - header); + tx_len = (ar->bmi.max_data_size - header); } offset = 0; @@ -237,7 +240,7 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param) } size = sizeof(cid) + sizeof(addr) + sizeof(param); - if (size > MAX_BMI_CMDBUF_SZ) { + if (size > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } @@ -284,7 +287,7 @@ int ath6kl_bmi_set_app_start(struct ath6kl *ar, u32 addr) } size = sizeof(cid) + sizeof(addr); - if (size > MAX_BMI_CMDBUF_SZ) { + if (size > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } @@ -320,7 +323,7 @@ int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param) } size = sizeof(cid) + sizeof(addr); - if (size > MAX_BMI_CMDBUF_SZ) { + if (size > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } @@ -363,7 +366,7 @@ int ath6kl_bmi_reg_write(struct ath6kl *ar, u32 addr, u32 param) } size = sizeof(cid) + sizeof(addr) + sizeof(param); - if (size > MAX_BMI_CMDBUF_SZ) { + if (size > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } @@ -404,8 +407,8 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len) return -EACCES; } - size = BMI_DATASZ_MAX + header; - if (size > MAX_BMI_CMDBUF_SZ) { + size = ar->bmi.max_data_size + header; + if (size > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } @@ -416,8 +419,8 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len) len_remain = len; while (len_remain) { - tx_len = (len_remain < (BMI_DATASZ_MAX - header)) ? - len_remain : (BMI_DATASZ_MAX - header); + tx_len = (len_remain < (ar->bmi.max_data_size - header)) ? + len_remain : (ar->bmi.max_data_size - header); offset = 0; memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); @@ -454,7 +457,7 @@ int ath6kl_bmi_lz_stream_start(struct ath6kl *ar, u32 addr) } size = sizeof(cid) + sizeof(addr); - if (size > MAX_BMI_CMDBUF_SZ) { + if (size > ar->bmi.max_cmd_size) { WARN_ON(1); return -EINVAL; } @@ -518,8 +521,13 @@ void ath6kl_bmi_reset(struct ath6kl *ar) int ath6kl_bmi_init(struct ath6kl *ar) { - ar->bmi.cmd_buf = kzalloc(MAX_BMI_CMDBUF_SZ, GFP_ATOMIC); + if (WARN_ON(ar->bmi.max_data_size == 0)) + return -EINVAL; + + /* cmd + addr + len + data_size */ + ar->bmi.max_cmd_size = ar->bmi.max_data_size + (sizeof(u32) * 3); + ar->bmi.cmd_buf = kzalloc(ar->bmi.max_cmd_size, GFP_ATOMIC); if (!ar->bmi.cmd_buf) return -ENOMEM; diff --git a/drivers/net/wireless/ath/ath6kl/bmi.h b/drivers/net/wireless/ath/ath6kl/bmi.h index 009e8f6..f1ca681 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.h +++ b/drivers/net/wireless/ath/ath6kl/bmi.h @@ -44,12 +44,6 @@ * BMI handles all required Target-side cache flushing. */ -#define MAX_BMI_CMDBUF_SZ (BMI_DATASZ_MAX + \ - (sizeof(u32) * 3 /* cmd + addr + len */)) - -/* Maximum data size used for BMI transfers */ -#define BMI_DATASZ_MAX 256 - /* BMI Commands */ #define BMI_NO_COMMAND 0 diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index e7e095e..c08c02e 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -272,6 +272,8 @@ struct ath6kl_bmi { u32 cmd_credits; bool done_sent; u8 *cmd_buf; + u32 max_data_size; + u32 max_cmd_size; }; struct target_stats { diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 080be036..46a9bd6 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1139,6 +1139,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ar_sdio->ar = ar; ar->hif_priv = ar_sdio; ar->hif_ops = &ath6kl_sdio_ops; + ar->bmi.max_data_size = 256; ath6kl_sdio_set_mbox_info(ar); -- cgit v0.10.2 From c71114959dc952a509822f22251d01004b3b94cc Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:17:51 +0200 Subject: ath6kl: move diag commands to hif driver This is preparation for USB support which will have different diag commands. Based on code by Kevin Fang. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index 0c4c602..2fe1dad 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -91,6 +91,26 @@ static inline int ath6kl_hif_suspend(struct ath6kl *ar, return ar->hif_ops->suspend(ar, wow); } +/* + * Read from the ATH6KL through its diagnostic window. No cooperation from + * the Target is required for this. + */ +static inline int ath6kl_hif_diag_read32(struct ath6kl *ar, u32 address, + u32 *value) +{ + return ar->hif_ops->diag_read32(ar, address, value); +} + +/* + * Write to the ATH6KL through its diagnostic window. No cooperation from + * the Target is required for this. + */ +static inline int ath6kl_hif_diag_write32(struct ath6kl *ar, u32 address, + __le32 value) +{ + return ar->hif_ops->diag_write32(ar, address, value); +} + static inline int ath6kl_hif_bmi_read(struct ath6kl *ar, u8 *buf, u32 len) { return ar->hif_ops->bmi_read(ar, buf, len); diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 42004e9..15b5d98 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -244,6 +244,8 @@ struct ath6kl_hif_ops { void (*cleanup_scatter)(struct ath6kl *ar); int (*suspend)(struct ath6kl *ar, struct cfg80211_wowlan *wow); int (*resume)(struct ath6kl *ar); + int (*diag_read32)(struct ath6kl *ar, u32 address, u32 *value); + int (*diag_write32)(struct ath6kl *ar, u32 address, __le32 value); int (*bmi_read)(struct ath6kl *ar, u8 *buf, u32 len); int (*bmi_write)(struct ath6kl *ar, u8 *buf, u32 len); int (*power_on)(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 1195f94..ea84894 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -175,64 +175,6 @@ void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie) ar->cookie_count++; } -/* set the window address register (using 4-byte register access ). */ -static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr) -{ - int status; - s32 i; - __le32 addr_val; - - /* - * Write bytes 1,2,3 of the register to set the upper address bytes, - * the LSB is written last to initiate the access cycle - */ - - for (i = 1; i <= 3; i++) { - /* - * Fill the buffer with the address byte value we want to - * hit 4 times. No need to worry about endianness as the - * same byte is copied to all four bytes of addr_val at - * any time. - */ - memset((u8 *)&addr_val, ((u8 *)&addr)[i], 4); - - /* - * Hit each byte of the register address with a 4-byte - * write operation to the same address, this is a harmless - * operation. - */ - status = hif_read_write_sync(ar, reg_addr + i, (u8 *)&addr_val, - 4, HIF_WR_SYNC_BYTE_FIX); - if (status) - break; - } - - if (status) { - ath6kl_err("failed to write initial bytes of 0x%x to window reg: 0x%X\n", - addr, reg_addr); - return status; - } - - /* - * Write the address register again, this time write the whole - * 4-byte value. The effect here is that the LSB write causes the - * cycle to start, the extra 3 byte write to bytes 1,2,3 has no - * effect since we are writing the same values again - */ - addr_val = cpu_to_le32(addr); - status = hif_read_write_sync(ar, reg_addr, - (u8 *)&(addr_val), - 4, HIF_WR_SYNC_BYTE_INC); - - if (status) { - ath6kl_err("failed to write 0x%x to window reg: 0x%X\n", - addr, reg_addr); - return status; - } - - return 0; -} - /* * Read from the hardware through its diagnostic window. No cooperation * from the firmware is required for this. @@ -241,14 +183,7 @@ int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value) { int ret; - /* set window register to start read cycle */ - ret = ath6kl_set_addrwin_reg(ar, WINDOW_READ_ADDR_ADDRESS, address); - if (ret) - return ret; - - /* read the data */ - ret = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *) value, - sizeof(*value), HIF_RD_SYNC_BYTE_INC); + ret = ath6kl_hif_diag_read32(ar, address, value); if (ret) { ath6kl_warn("failed to read32 through diagnose window: %d\n", ret); @@ -266,18 +201,15 @@ int ath6kl_diag_write32(struct ath6kl *ar, u32 address, __le32 value) { int ret; - /* set write data */ - ret = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *) &value, - sizeof(value), HIF_WR_SYNC_BYTE_INC); + ret = ath6kl_hif_diag_write32(ar, address, value); + if (ret) { ath6kl_err("failed to write 0x%x during diagnose window to 0x%d\n", address, value); return ret; } - /* set window register, which starts the write cycle */ - return ath6kl_set_addrwin_reg(ar, WINDOW_WRITE_ADDR_ADDRESS, - address); + return 0; } int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 46a9bd6..b633c80 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -845,6 +845,104 @@ static int ath6kl_sdio_resume(struct ath6kl *ar) return 0; } +/* set the window address register (using 4-byte register access ). */ +static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr) +{ + int status; + u8 addr_val[4]; + s32 i; + + /* + * Write bytes 1,2,3 of the register to set the upper address bytes, + * the LSB is written last to initiate the access cycle + */ + + for (i = 1; i <= 3; i++) { + /* + * Fill the buffer with the address byte value we want to + * hit 4 times. + */ + memset(addr_val, ((u8 *)&addr)[i], 4); + + /* + * Hit each byte of the register address with a 4-byte + * write operation to the same address, this is a harmless + * operation. + */ + status = ath6kl_sdio_read_write_sync(ar, reg_addr + i, addr_val, + 4, HIF_WR_SYNC_BYTE_FIX); + if (status) + break; + } + + if (status) { + ath6kl_err("%s: failed to write initial bytes of 0x%x " + "to window reg: 0x%X\n", __func__, + addr, reg_addr); + return status; + } + + /* + * Write the address register again, this time write the whole + * 4-byte value. The effect here is that the LSB write causes the + * cycle to start, the extra 3 byte write to bytes 1,2,3 has no + * effect since we are writing the same values again + */ + status = ath6kl_sdio_read_write_sync(ar, reg_addr, (u8 *)(&addr), + 4, HIF_WR_SYNC_BYTE_INC); + + if (status) { + ath6kl_err("%s: failed to write 0x%x to window reg: 0x%X\n", + __func__, addr, reg_addr); + return status; + } + + return 0; +} + +static int ath6kl_sdio_diag_read32(struct ath6kl *ar, u32 address, u32 *data) +{ + int status; + + /* set window register to start read cycle */ + status = ath6kl_set_addrwin_reg(ar, WINDOW_READ_ADDR_ADDRESS, + address); + + if (status) + return status; + + /* read the data */ + status = ath6kl_sdio_read_write_sync(ar, WINDOW_DATA_ADDRESS, + (u8 *)data, sizeof(u32), HIF_RD_SYNC_BYTE_INC); + if (status) { + ath6kl_err("%s: failed to read from window data addr\n", + __func__); + return status; + } + + return status; +} + +static int ath6kl_sdio_diag_write32(struct ath6kl *ar, u32 address, + __le32 data) +{ + int status; + u32 val = (__force u32) data; + + /* set write data */ + status = ath6kl_sdio_read_write_sync(ar, WINDOW_DATA_ADDRESS, + (u8 *) &val, sizeof(u32), HIF_WR_SYNC_BYTE_INC); + if (status) { + ath6kl_err("%s: failed to write 0x%x to window data addr\n", + __func__, data); + return status; + } + + /* set window register, which starts the write cycle */ + return ath6kl_set_addrwin_reg(ar, WINDOW_WRITE_ADDR_ADDRESS, + address); +} + static int ath6kl_sdio_bmi_credits(struct ath6kl *ar) { u32 addr; @@ -1049,6 +1147,8 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .cleanup_scatter = ath6kl_sdio_cleanup_scatter, .suspend = ath6kl_sdio_suspend, .resume = ath6kl_sdio_resume, + .diag_read32 = ath6kl_sdio_diag_read32, + .diag_write32 = ath6kl_sdio_diag_write32, .bmi_read = ath6kl_sdio_bmi_read, .bmi_write = ath6kl_sdio_bmi_write, .power_on = ath6kl_sdio_power_on, -- cgit v0.10.2 From d5720e59410578d00c1767d66b2b8dfeda91a08b Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:17:59 +0200 Subject: ath6kl: update ar6004 definitions Add also hw 1.1. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index c08c02e..415fa00e 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -114,11 +114,19 @@ struct ath6kl_fw_ie { /* AR6004 1.0 definitions */ #define AR6004_REV1_VERSION 0x30000623 -#define AR6004_REV1_FIRMWARE_FILE "ath6k/AR6004/hw6.1/fw.ram.bin" -#define AR6004_REV1_FIRMWARE_2_FILE "ath6k/AR6004/hw6.1/fw-2.bin" -#define AR6004_REV1_BOARD_DATA_FILE "ath6k/AR6004/hw6.1/bdata.bin" -#define AR6004_REV1_DEFAULT_BOARD_DATA_FILE "ath6k/AR6004/hw6.1/bdata.DB132.bin" -#define AR6004_REV1_EPPING_FIRMWARE_FILE "ath6k/AR6004/hw6.1/endpointping.bin" +#define AR6004_REV1_FIRMWARE_2_FILE "ath6k/AR6004/hw1.0/fw-2.bin" +#define AR6004_REV1_FIRMWARE_FILE "ath6k/AR6004/hw1.0/fw.ram.bin" +#define AR6004_REV1_BOARD_DATA_FILE "ath6k/AR6004/hw1.0/bdata.bin" +#define AR6004_REV1_DEFAULT_BOARD_DATA_FILE \ + "ath6k/AR6004/hw1.0/bdata.DB132.bin" + +/* AR6004 1.1 definitions */ +#define AR6004_REV2_VERSION 0x30000001 +#define AR6004_REV2_FIRMWARE_2_FILE "ath6k/AR6004/hw1.1/fw-2.bin" +#define AR6004_REV2_FIRMWARE_FILE "ath6k/AR6004/hw1.1/fw.ram.bin" +#define AR6004_REV2_BOARD_DATA_FILE "ath6k/AR6004/hw1.1/bdata.bin" +#define AR6004_REV2_DEFAULT_BOARD_DATA_FILE \ + "ath6k/AR6004/hw1.1/bdata.DB132.bin" /* Per STA data, used in AP mode */ #define STA_PS_AWAKE BIT(0) diff --git a/drivers/net/wireless/ath/ath6kl/target.h b/drivers/net/wireless/ath/ath6kl/target.h index 687e2b3..35478d4 100644 --- a/drivers/net/wireless/ath/ath6kl/target.h +++ b/drivers/net/wireless/ath/ath6kl/target.h @@ -20,7 +20,7 @@ #define AR6003_BOARD_DATA_SZ 1024 #define AR6003_BOARD_EXT_DATA_SZ 768 -#define AR6004_BOARD_DATA_SZ 7168 +#define AR6004_BOARD_DATA_SZ 6144 #define AR6004_BOARD_EXT_DATA_SZ 0 #define RESET_CONTROL_ADDRESS 0x00000000 @@ -344,9 +344,12 @@ struct host_interest { #define AR6003_REV3_DATASET_PATCH_ADDRESS 0x57FF74 #define AR6003_REV3_RAM_RESERVE_SIZE 512 -#define AR6004_REV1_BOARD_DATA_ADDRESS 0x435400 +#define AR6004_REV1_BOARD_DATA_ADDRESS 0x433900 #define AR6004_REV1_BOARD_EXT_DATA_ADDRESS 0x437000 -#define AR6004_REV1_RAM_RESERVE_SIZE 11264 +#define AR6004_REV1_RAM_RESERVE_SIZE 19456 + +#define AR6004_REV2_BOARD_DATA_ADDRESS 0x43d400 +#define AR6004_REV2_RAM_RESERVE_SIZE 11264 #define ATH6KL_FWLOG_PAYLOAD_SIZE 1500 -- cgit v0.10.2 From 50e2740b7bba90560321fba67840778c1fdb178b Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:18:06 +0200 Subject: ath6kl: firmware boot fixes for ar6004 These have changed a bit since last time ar6004 code was commited. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 57529ac..e96ce07 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -821,6 +821,9 @@ static int ath6kl_fetch_fw_api2(struct ath6kl *ar) case AR6004_REV1_VERSION: filename = AR6004_REV1_FIRMWARE_2_FILE; break; + case AR6004_REV2_VERSION: + filename = AR6004_REV2_FIRMWARE_2_FILE; + break; default: return -EOPNOTSUPP; } @@ -995,7 +998,11 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) * writing board data. */ if (ar->target_type == TARGET_TYPE_AR6004) { - board_address = AR6004_REV1_BOARD_DATA_ADDRESS; + if (ar->version.target_ver == AR6004_REV1_VERSION) + board_address = AR6004_REV1_BOARD_DATA_ADDRESS; + else + board_address = AR6004_REV2_BOARD_DATA_ADDRESS; + ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_board_data)), @@ -1013,7 +1020,8 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) HI_ITEM(hi_board_ext_data)), (u8 *) &board_ext_address, 4); - if (board_ext_address == 0) { + if (ar->target_type == TARGET_TYPE_AR6003 && + board_ext_address == 0) { ath6kl_err("Failed to get board file target address.\n"); return -EINVAL; } @@ -1033,8 +1041,8 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) break; } - if (ar->fw_board_len == (board_data_size + - board_ext_data_size)) { + if (board_ext_address && + ar->fw_board_len == (board_data_size + board_ext_data_size)) { /* write extended board data */ ath6kl_dbg(ATH6KL_DBG_BOOT, @@ -1092,8 +1100,8 @@ static int ath6kl_upload_otp(struct ath6kl *ar) bool from_hw = false; int ret; - if (WARN_ON(ar->fw_otp == NULL)) - return -ENOENT; + if (ar->fw_otp == NULL) + return 0; address = ar->hw.app_load_addr; @@ -1142,7 +1150,7 @@ static int ath6kl_upload_firmware(struct ath6kl *ar) int ret; if (WARN_ON(ar->fw == NULL)) - return -ENOENT; + return 0; address = ar->hw.app_load_addr; @@ -1172,8 +1180,8 @@ static int ath6kl_upload_patch(struct ath6kl *ar) u32 address, param; int ret; - if (WARN_ON(ar->fw_patch == NULL)) - return -ENOENT; + if (ar->fw_patch == NULL) + return 0; address = ar->hw.dataset_patch_addr; @@ -1346,10 +1354,16 @@ static int ath6kl_init_hw_params(struct ath6kl *ar) break; case AR6004_REV1_VERSION: ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS; - ar->hw.app_load_addr = AR6003_REV3_APP_LOAD_ADDRESS; + ar->hw.app_load_addr = 0x1234; ar->hw.board_ext_data_addr = AR6004_REV1_BOARD_EXT_DATA_ADDRESS; ar->hw.reserved_ram_size = AR6004_REV1_RAM_RESERVE_SIZE; break; + case AR6004_REV2_VERSION: + ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS; + ar->hw.app_load_addr = 0x1234; + ar->hw.board_ext_data_addr = AR6004_REV1_BOARD_EXT_DATA_ADDRESS; + ar->hw.reserved_ram_size = AR6004_REV2_RAM_RESERVE_SIZE; + break; default: ath6kl_err("Unsupported hardware version: 0x%x\n", ar->version.target_ver); -- cgit v0.10.2 From d93e2c2f2109a3b804fa799079a6dd4d315af857 Mon Sep 17 00:00:00 2001 From: Naveen Gangadharan Date: Fri, 11 Nov 2011 12:18:14 +0200 Subject: ath6kl: AR6004 SDIO support Add support for AR6004 SDIO. Tested scan, association (open mode) and ping. kvalo: change commit log a bit, drop board address changes Signed-off-by: Naveen Gangadharan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 15b5d98..699a036 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -35,6 +35,7 @@ #define MAX_SCATTER_REQ_TRANSFER_SIZE (32 * 1024) #define MANUFACTURER_ID_AR6003_BASE 0x300 +#define MANUFACTURER_ID_AR6004_BASE 0x400 /* SDIO manufacturer ID and Codes */ #define MANUFACTURER_ID_ATH6KL_BASE_MASK 0xFF00 #define MANUFACTURER_CODE 0x271 /* Atheros */ diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index b633c80..d61e39a 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1289,6 +1289,8 @@ static void ath6kl_sdio_remove(struct sdio_func *func) static const struct sdio_device_id ath6kl_sdio_devices[] = { {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x0))}, {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x1))}, + {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x0))}, + {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x1))}, {}, }; -- cgit v0.10.2 From 77eab1e929c371f98c6a17a8c5f566529d3b0be2 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:18:22 +0200 Subject: ath6kl: add hif_type In some rare cases core code needs to know what hif type is used. Add a field to struct ath6kl to denote that. Hopefully this is just a temporary solution. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 415fa00e..03e378d 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -391,6 +391,11 @@ struct ath6kl_req_key { u8 key_len; }; +enum ath6kl_hif_type { + ATH6KL_HIF_TYPE_SDIO, + ATH6KL_HIF_TYPE_USB, +}; + #define MAX_NUM_VIF 1 /* vif flags info */ @@ -484,6 +489,7 @@ struct ath6kl { int tx_pending[ENDPOINT_MAX]; int total_tx_data_pend; struct htc_target *htc_target; + enum ath6kl_hif_type hif_type; void *hif_priv; struct list_head vif_list; /* Lock to avoid race in vif_list entries among add/del/traverse */ diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index d61e39a..7ad57cd 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1237,6 +1237,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, } ar_sdio->ar = ar; + ar->hif_type = ATH6KL_HIF_TYPE_SDIO; ar->hif_priv = ar_sdio; ar->hif_ops = &ath6kl_sdio_ops; ar->bmi.max_data_size = 256; -- cgit v0.10.2 From 59d954dda4b9b3f3e61d4b87a2b26952b8c4c09d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:18:29 +0200 Subject: ath6kl: add USB support Add USB support for ar6004. Currently only firmware can be booted, no commands can be sent to firmware yet as HTC layer doesn't work with USB yet. Based on patches by Kevin Fang. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index bce3575..aef00d5 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -57,8 +57,14 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar, return ret; } - ret = ath6kl_hif_bmi_read(ar, (u8 *)&targ_info->version, - sizeof(targ_info->version)); + if (ar->hif_type == ATH6KL_HIF_TYPE_USB) { + ret = ath6kl_hif_bmi_read(ar, (u8 *)targ_info, + sizeof(*targ_info)); + } else { + ret = ath6kl_hif_bmi_read(ar, (u8 *)&targ_info->version, + sizeof(targ_info->version)); + } + if (ret) { ath6kl_err("Unable to recv target info: %d\n", ret); return ret; diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index c24d120..9b779aa 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -41,6 +41,7 @@ enum ATH6K_DEBUG_MASK { ATH6KL_DBG_BOOT = BIT(18), /* driver init and fw boot */ ATH6KL_DBG_WMI_DUMP = BIT(19), ATH6KL_DBG_SUSPEND = BIT(20), + ATH6KL_DBG_USB = BIT(21), ATH6KL_DBG_ANY = 0xffffffff /* enable all logs */ }; diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c new file mode 100644 index 0000000..b85ca3f --- /dev/null +++ b/drivers/net/wireless/ath/ath6kl/usb.c @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2007-2011 Atheros Communications Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include "debug.h" +#include "core.h" + +/* usb device object */ +struct ath6kl_usb { + struct usb_device *udev; + struct usb_interface *interface; + u8 *diag_cmd_buffer; + u8 *diag_resp_buffer; + struct ath6kl *ar; +}; + +/* diagnostic command defnitions */ +#define ATH6KL_USB_CONTROL_REQ_SEND_BMI_CMD 1 +#define ATH6KL_USB_CONTROL_REQ_RECV_BMI_RESP 2 +#define ATH6KL_USB_CONTROL_REQ_DIAG_CMD 3 +#define ATH6KL_USB_CONTROL_REQ_DIAG_RESP 4 + +#define ATH6KL_USB_CTRL_DIAG_CC_READ 0 +#define ATH6KL_USB_CTRL_DIAG_CC_WRITE 1 + +struct ath6kl_usb_ctrl_diag_cmd_write { + __le32 cmd; + __le32 address; + __le32 value; + __le32 _pad[1]; +} __packed; + +struct ath6kl_usb_ctrl_diag_cmd_read { + __le32 cmd; + __le32 address; +} __packed; + +struct ath6kl_usb_ctrl_diag_resp_read { + __le32 value; +} __packed; + +#define ATH6KL_USB_MAX_DIAG_CMD (sizeof(struct ath6kl_usb_ctrl_diag_cmd_write)) +#define ATH6KL_USB_MAX_DIAG_RESP (sizeof(struct ath6kl_usb_ctrl_diag_resp_read)) + +static void ath6kl_usb_destroy(struct ath6kl_usb *ar_usb) +{ + usb_set_intfdata(ar_usb->interface, NULL); + + kfree(ar_usb->diag_cmd_buffer); + kfree(ar_usb->diag_resp_buffer); + + kfree(ar_usb); +} + +static struct ath6kl_usb *ath6kl_usb_create(struct usb_interface *interface) +{ + struct ath6kl_usb *ar_usb = NULL; + struct usb_device *dev = interface_to_usbdev(interface); + int status = 0; + + ar_usb = kzalloc(sizeof(struct ath6kl_usb), GFP_KERNEL); + if (ar_usb == NULL) + goto fail_ath6kl_usb_create; + + memset(ar_usb, 0, sizeof(struct ath6kl_usb)); + usb_set_intfdata(interface, ar_usb); + ar_usb->udev = dev; + ar_usb->interface = interface; + + ar_usb->diag_cmd_buffer = kzalloc(ATH6KL_USB_MAX_DIAG_CMD, GFP_KERNEL); + if (ar_usb->diag_cmd_buffer == NULL) { + status = -ENOMEM; + goto fail_ath6kl_usb_create; + } + + ar_usb->diag_resp_buffer = kzalloc(ATH6KL_USB_MAX_DIAG_RESP, + GFP_KERNEL); + if (ar_usb->diag_resp_buffer == NULL) { + status = -ENOMEM; + goto fail_ath6kl_usb_create; + } + +fail_ath6kl_usb_create: + if (status != 0) { + ath6kl_usb_destroy(ar_usb); + ar_usb = NULL; + } + return ar_usb; +} + +static void ath6kl_usb_device_detached(struct usb_interface *interface) +{ + struct ath6kl_usb *ar_usb; + + ar_usb = usb_get_intfdata(interface); + if (ar_usb == NULL) + return; + + ath6kl_stop_txrx(ar_usb->ar); + + ath6kl_core_cleanup(ar_usb->ar); + + ath6kl_usb_destroy(ar_usb); +} + +static int ath6kl_usb_submit_ctrl_out(struct ath6kl_usb *ar_usb, + u8 req, u16 value, u16 index, void *data, + u32 size) +{ + u8 *buf = NULL; + int ret; + + if (size > 0) { + buf = kmalloc(size, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + + memcpy(buf, data, size); + } + + /* note: if successful returns number of bytes transfered */ + ret = usb_control_msg(ar_usb->udev, + usb_sndctrlpipe(ar_usb->udev, 0), + req, + USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, buf, + size, 1000); + + if (ret < 0) { + ath6kl_dbg(ATH6KL_DBG_USB, "%s failed,result = %d\n", + __func__, ret); + } + + kfree(buf); + + return 0; +} + +static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb, + u8 req, u16 value, u16 index, void *data, + u32 size) +{ + u8 *buf = NULL; + int ret; + + if (size > 0) { + buf = kmalloc(size, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + } + + /* note: if successful returns number of bytes transfered */ + ret = usb_control_msg(ar_usb->udev, + usb_rcvctrlpipe(ar_usb->udev, 0), + req, + USB_DIR_IN | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, buf, + size, 2 * HZ); + + if (ret < 0) { + ath6kl_dbg(ATH6KL_DBG_USB, "%s failed,result = %d\n", + __func__, ret); + } + + memcpy((u8 *) data, buf, size); + + kfree(buf); + + return 0; +} + +static int ath6kl_usb_ctrl_msg_exchange(struct ath6kl_usb *ar_usb, + u8 req_val, u8 *req_buf, u32 req_len, + u8 resp_val, u8 *resp_buf, u32 *resp_len) +{ + int ret; + + /* send command */ + ret = ath6kl_usb_submit_ctrl_out(ar_usb, req_val, 0, 0, + req_buf, req_len); + + if (ret != 0) + return ret; + + if (resp_buf == NULL) { + /* no expected response */ + return ret; + } + + /* get response */ + ret = ath6kl_usb_submit_ctrl_in(ar_usb, resp_val, 0, 0, + resp_buf, *resp_len); + + return ret; +} + +static int ath6kl_usb_diag_read32(struct ath6kl *ar, u32 address, u32 *data) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + struct ath6kl_usb_ctrl_diag_resp_read *resp; + struct ath6kl_usb_ctrl_diag_cmd_read *cmd; + u32 resp_len; + int ret; + + cmd = (struct ath6kl_usb_ctrl_diag_cmd_read *) ar_usb->diag_cmd_buffer; + + memset(cmd, 0, sizeof(*cmd)); + cmd->cmd = ATH6KL_USB_CTRL_DIAG_CC_READ; + cmd->address = cpu_to_le32(address); + resp_len = sizeof(*resp); + + ret = ath6kl_usb_ctrl_msg_exchange(ar_usb, + ATH6KL_USB_CONTROL_REQ_DIAG_CMD, + (u8 *) cmd, + sizeof(struct ath6kl_usb_ctrl_diag_cmd_write), + ATH6KL_USB_CONTROL_REQ_DIAG_RESP, + ar_usb->diag_resp_buffer, &resp_len); + + if (ret) + return ret; + + resp = (struct ath6kl_usb_ctrl_diag_resp_read *) + ar_usb->diag_resp_buffer; + + *data = le32_to_cpu(resp->value); + + return ret; +} + +static int ath6kl_usb_diag_write32(struct ath6kl *ar, u32 address, __le32 data) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + struct ath6kl_usb_ctrl_diag_cmd_write *cmd; + + cmd = (struct ath6kl_usb_ctrl_diag_cmd_write *) ar_usb->diag_cmd_buffer; + + memset(cmd, 0, sizeof(struct ath6kl_usb_ctrl_diag_cmd_write)); + cmd->cmd = cpu_to_le32(ATH6KL_USB_CTRL_DIAG_CC_WRITE); + cmd->address = cpu_to_le32(address); + cmd->value = data; + + return ath6kl_usb_ctrl_msg_exchange(ar_usb, + ATH6KL_USB_CONTROL_REQ_DIAG_CMD, + (u8 *) cmd, + sizeof(*cmd), + 0, NULL, NULL); + +} + +static int ath6kl_usb_bmi_read(struct ath6kl *ar, u8 *buf, u32 len) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + int ret; + + /* get response */ + ret = ath6kl_usb_submit_ctrl_in(ar_usb, + ATH6KL_USB_CONTROL_REQ_RECV_BMI_RESP, + 0, 0, buf, len); + if (ret != 0) { + ath6kl_err("Unable to read the bmi data from the device: %d\n", + ret); + return ret; + } + + return 0; +} + +static int ath6kl_usb_bmi_write(struct ath6kl *ar, u8 *buf, u32 len) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + int ret; + + /* send command */ + ret = ath6kl_usb_submit_ctrl_out(ar_usb, + ATH6KL_USB_CONTROL_REQ_SEND_BMI_CMD, + 0, 0, buf, len); + if (ret != 0) { + ath6kl_err("unable to send the bmi data to the device: %d\n", + ret); + return ret; + } + + return 0; +} + +static int ath6kl_usb_power_on(struct ath6kl *ar) +{ + return 0; +} + +static int ath6kl_usb_power_off(struct ath6kl *ar) +{ + return 0; +} + +static const struct ath6kl_hif_ops ath6kl_usb_ops = { + .diag_read32 = ath6kl_usb_diag_read32, + .diag_write32 = ath6kl_usb_diag_write32, + .bmi_read = ath6kl_usb_bmi_read, + .bmi_write = ath6kl_usb_bmi_write, + .power_on = ath6kl_usb_power_on, + .power_off = ath6kl_usb_power_off, +}; + +/* ath6kl usb driver registered functions */ +static int ath6kl_usb_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_device *dev = interface_to_usbdev(interface); + struct ath6kl *ar; + struct ath6kl_usb *ar_usb = NULL; + int vendor_id, product_id; + int ret = 0; + + usb_get_dev(dev); + + vendor_id = le16_to_cpu(dev->descriptor.idVendor); + product_id = le16_to_cpu(dev->descriptor.idProduct); + + ath6kl_dbg(ATH6KL_DBG_USB, "vendor_id = %04x\n", vendor_id); + ath6kl_dbg(ATH6KL_DBG_USB, "product_id = %04x\n", product_id); + + if (interface->cur_altsetting) + ath6kl_dbg(ATH6KL_DBG_USB, "USB Interface %d\n", + interface->cur_altsetting->desc.bInterfaceNumber); + + + if (dev->speed == USB_SPEED_HIGH) + ath6kl_dbg(ATH6KL_DBG_USB, "USB 2.0 Host\n"); + else + ath6kl_dbg(ATH6KL_DBG_USB, "USB 1.1 Host\n"); + + ar_usb = ath6kl_usb_create(interface); + + if (ar_usb == NULL) { + ret = -ENOMEM; + goto err_usb_put; + } + + ar = ath6kl_core_alloc(&ar_usb->udev->dev); + if (ar == NULL) { + ath6kl_err("Failed to alloc ath6kl core\n"); + ret = -ENOMEM; + goto err_usb_destroy; + } + + ar->hif_priv = ar_usb; + ar->hif_type = ATH6KL_HIF_TYPE_USB; + ar->hif_ops = &ath6kl_usb_ops; + ar->mbox_info.block_size = 16; + ar->bmi.max_data_size = 252; + + ar_usb->ar = ar; + + ret = ath6kl_core_init(ar); + if (ret) { + ath6kl_err("Failed to init ath6kl core: %d\n", ret); + goto err_core_free; + } + + return ret; + +err_core_free: + ath6kl_core_free(ar); +err_usb_destroy: + ath6kl_usb_destroy(ar_usb); +err_usb_put: + usb_put_dev(dev); + + return ret; +} + +static void ath6kl_usb_remove(struct usb_interface *interface) +{ + usb_put_dev(interface_to_usbdev(interface)); + ath6kl_usb_device_detached(interface); +} + +/* table of devices that work with this driver */ +static struct usb_device_id ath6kl_usb_ids[] = { + {USB_DEVICE(0x0cf3, 0x9374)}, + { /* Terminating entry */ }, +}; + +MODULE_DEVICE_TABLE(usb, ath6kl_usb_ids); + +static struct usb_driver ath6kl_usb_driver = { + .name = "ath6kl_usb", + .probe = ath6kl_usb_probe, + .disconnect = ath6kl_usb_remove, + .id_table = ath6kl_usb_ids, +}; + +static int ath6kl_usb_init(void) +{ + usb_register(&ath6kl_usb_driver); + return 0; +} + +static void ath6kl_usb_exit(void) +{ + usb_deregister(&ath6kl_usb_driver); +} + +module_init(ath6kl_usb_init); +module_exit(ath6kl_usb_exit); + +MODULE_AUTHOR("Atheros Communications, Inc."); +MODULE_DESCRIPTION("Driver support for Atheros AR600x USB devices"); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_FIRMWARE(AR6004_REV1_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6004_REV1_BOARD_DATA_FILE); +MODULE_FIRMWARE(AR6004_REV1_DEFAULT_BOARD_DATA_FILE); +MODULE_FIRMWARE(AR6004_REV2_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6004_REV2_BOARD_DATA_FILE); +MODULE_FIRMWARE(AR6004_REV2_DEFAULT_BOARD_DATA_FILE); -- cgit v0.10.2 From d70385a26ad9a122a5450d066550470107b6bc38 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:18:37 +0200 Subject: ath6kl: disable HTC for USB devices As HTC layer doesn't support USB devices return an error if that happens. USB support will be added to HTC in the future, this is just a temporary solution. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index e57da35..0772ef6 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -689,6 +689,11 @@ int ath6kl_hif_setup(struct ath6kl_device *dev) ath6kl_dbg(ATH6KL_DBG_HIF, "hif block size %d mbox addr 0x%x\n", dev->htc_cnxt->block_sz, dev->ar->mbox_info.htc_addr); + /* usb doesn't support enabling interrupts */ + /* FIXME: remove check once USB support is implemented */ + if (dev->ar->hif_type == ATH6KL_HIF_TYPE_USB) + return 0; + status = ath6kl_hif_disable_intrs(dev); fail_setup: diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index f3b63ca25..b017022 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2543,6 +2543,12 @@ int ath6kl_htc_wait_target(struct htc_target *target) struct htc_service_connect_resp resp; int status; + /* FIXME: remove once USB support is implemented */ + if (target->dev->ar->hif_type == ATH6KL_HIF_TYPE_USB) { + ath6kl_err("HTC doesn't support USB yet. Patience!\n"); + return -EOPNOTSUPP; + } + /* we should be getting 1 control message that the target is ready */ packet = htc_wait_for_ctrl_msg(target); @@ -2772,7 +2778,9 @@ void ath6kl_htc_cleanup(struct htc_target *target) { struct htc_packet *packet, *tmp_packet; - ath6kl_hif_cleanup_scatter(target->dev->ar); + /* FIXME: remove check once USB support is implemented */ + if (target->dev->ar->hif_type != ATH6KL_HIF_TYPE_USB) + ath6kl_hif_cleanup_scatter(target->dev->ar); list_for_each_entry_safe(packet, tmp_packet, &target->free_ctrl_txbuf, list) { -- cgit v0.10.2 From fde57764ef8751b9aca11b6f6221ac5555bda699 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 11 Nov 2011 12:18:45 +0200 Subject: ath6kl: enable USB support Now two modules are built, ath6kl_sdio.ko and ath6kl_usb.ko. But the USB module isn't fully functional yet as HTC layer is missing support and that's why it's marked as experimental for now. Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/Kconfig b/drivers/net/wireless/ath/ath6kl/Kconfig index 3d5f8be..d755a5e 100644 --- a/drivers/net/wireless/ath/ath6kl/Kconfig +++ b/drivers/net/wireless/ath/ath6kl/Kconfig @@ -1,12 +1,29 @@ config ATH6KL - tristate "Atheros ath6kl support" + tristate "Atheros mobile chipsets support" + +config ATH6KL_SDIO + tristate "Atheros ath6kl SDIO support" + depends on ATH6KL depends on MMC depends on CFG80211 ---help--- This module adds support for wireless adapters based on - Atheros AR6003 chipset running over SDIO. If you choose to - build it as a module, it will be called ath6kl. Pls note - that AR6002 and AR6001 are not supported by this driver. + Atheros AR6003 and AR6004 chipsets running over SDIO. If you + choose to build it as a module, it will be called ath6kl_sdio. + Please note that AR6002 and AR6001 are not supported by this + driver. + +config ATH6KL_USB + tristate "Atheros ath6kl USB support" + depends on ATH6KL + depends on USB + depends on CFG80211 + depends on EXPERIMENTAL + ---help--- + This module adds support for wireless adapters based on + Atheros AR6004 chipset running over USB. This is still under + implementation and it isn't functional. If you choose to + build it as a module, it will be called ath6kl_usb. config ATH6KL_DEBUG bool "Atheros ath6kl debugging" diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile index 7070693..e14cef9 100644 --- a/drivers/net/wireless/ath/ath6kl/Makefile +++ b/drivers/net/wireless/ath/ath6kl/Makefile @@ -21,17 +21,30 @@ # Author(s): ="Atheros" #------------------------------------------------------------------------------ -obj-$(CONFIG_ATH6KL) := ath6kl.o -ath6kl-y += debug.o -ath6kl-y += hif.o -ath6kl-y += htc.o -ath6kl-y += bmi.o -ath6kl-y += cfg80211.o -ath6kl-y += init.o -ath6kl-y += main.o -ath6kl-y += txrx.o -ath6kl-y += wmi.o -ath6kl-y += sdio.o -ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o +obj-$(CONFIG_ATH6KL_SDIO) := ath6kl_sdio.o +ath6kl_sdio-y += debug.o +ath6kl_sdio-y += hif.o +ath6kl_sdio-y += htc.o +ath6kl_sdio-y += bmi.o +ath6kl_sdio-y += cfg80211.o +ath6kl_sdio-y += init.o +ath6kl_sdio-y += main.o +ath6kl_sdio-y += txrx.o +ath6kl_sdio-y += wmi.o +ath6kl_sdio-y += sdio.o +ath6kl_sdio-$(CONFIG_NL80211_TESTMODE) += testmode.o + +obj-$(CONFIG_ATH6KL_USB) += ath6kl_usb.o +ath6kl_usb-y += debug.o +ath6kl_usb-y += hif.o +ath6kl_usb-y += htc.o +ath6kl_usb-y += bmi.o +ath6kl_usb-y += cfg80211.o +ath6kl_usb-y += init.o +ath6kl_usb-y += main.o +ath6kl_usb-y += txrx.o +ath6kl_usb-y += wmi.o +ath6kl_usb-y += usb.o +ath6kl_usb-$(CONFIG_NL80211_TESTMODE) += testmode.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 7ad57cd..fff2f90 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1298,7 +1298,7 @@ static const struct sdio_device_id ath6kl_sdio_devices[] = { MODULE_DEVICE_TABLE(sdio, ath6kl_sdio_devices); static struct sdio_driver ath6kl_sdio_driver = { - .name = "ath6kl", + .name = "ath6kl_sdio", .id_table = ath6kl_sdio_devices, .probe = ath6kl_sdio_probe, .remove = ath6kl_sdio_remove, -- cgit v0.10.2 From 7cefa44f140bc88def4f68f38c76d37d5fd61630 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 11 Nov 2011 20:33:00 +0530 Subject: ath6kl: Fix bug in setting default key index for tx in AP mode vif->def_txkey_index is set to key_index in ath6kl_cfg80211_add_key(). If the interface is configured with multiple static wep keys, vif->def_txkey_index would be holding the index of the last key configured, not the default tx key index. Remove this unnecessary default key index setting in ath6kl_cfg80211_add_key() to configure the right key index in WEP thereby make it work when multiple wep keys are configured. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 41260c8..0ef8442 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -997,8 +997,6 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, __func__, key_index, key->key_len, key_type, key_usage, key->seq_len); - vif->def_txkey_index = key_index; - if (vif->nw_type == AP_NETWORK && !pairwise && (key_type == TKIP_CRYPT || key_type == AES_CRYPT) && params) { ar->ap_mode_bkey.valid = true; @@ -1033,8 +1031,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, return 0; } - return ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, - vif->def_txkey_index, + return ath6kl_wmi_addkey_cmd(ar->wmi, vif->fw_vif_idx, key_index, key_type, key_usage, key->key_len, key->seq, key->seq_len, key->key, KEY_OP_INIT_VAL, -- cgit v0.10.2 From be5abaafad8090a5051355b1d224bfbae0951fc2 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 11 Nov 2011 20:33:01 +0530 Subject: ath6kl: Fix bug in setting dot11_auth_mode in AP mode OPEN_AUTH is passed as dot11_auth_mode by default, this would affect the AP mode when configured with shared authentication type. Assign appropriate auth type to fix this from driver. A patch in wpa_supplicant (wpa_supplicant: Set configured auth_algs) is also needed to fix this. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 0ef8442..7cf983b 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2006,7 +2006,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, int ies_len; struct wmi_connect_cmd p; int res; - int i; + int i, ret; ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: add=%d\n", __func__, add); @@ -2064,7 +2064,9 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, if (info->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) return -EOPNOTSUPP; /* TODO */ - vif->dot11_auth_mode = OPEN_AUTH; + ret = ath6kl_set_auth_type(vif, info->auth_type); + if (ret) + return ret; memset(&p, 0, sizeof(p)); -- cgit v0.10.2 From b4da228c6458c054c8ee5d909aa835b8a52a50e3 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 13 Nov 2011 01:22:40 +0100 Subject: powerpc/4xx: Fix typo 'PCC4xx_MSI' Signed-off-by: Paul Bolle Acked-by: Josh Boyer Signed-off-by: Jiri Kosina diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig index 595e28a..2c1a3e6 100644 --- a/arch/powerpc/platforms/44x/Kconfig +++ b/arch/powerpc/platforms/44x/Kconfig @@ -75,7 +75,7 @@ config KATMAI select PCI select PPC4xx_PCI_EXPRESS select PCI_MSI - select PCC4xx_MSI + select PPC4xx_MSI help This option enables support for the AMCC PPC440SPe evaluation board. -- cgit v0.10.2 From 06b19a5526e6133b5f0d902f18e24f3a4220ba7c Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 13 Nov 2011 13:00:56 +0100 Subject: s390: drop "select HAVE_GET_USER_PAGES_FAST" There is no Kconfig symbol named HAVE_GET_USER_PAGES_FAST. The select statement for that symbol is a nop. Drop it. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index ed5cb5a..ce8eaaa 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -87,7 +87,6 @@ config S390 select HAVE_KERNEL_LZMA select HAVE_KERNEL_LZO select HAVE_KERNEL_XZ - select HAVE_GET_USER_PAGES_FAST select HAVE_ARCH_MUTEX_CPU_RELAX select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 select HAVE_RCU_TABLE_FREE if SMP -- cgit v0.10.2 From 4da669a2e3e5bc70b30a0465f3641528681b5f77 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sat, 12 Nov 2011 21:27:55 +0100 Subject: crypto: drop selects of bogus Kconfig symbol Commits 2cdc6899a8 ("crypto: ghash - Add GHASH digest algorithm for GCM") and 0e1227d356 ("crypto: ghash - Add PCLMULQDQ accelerated implementation") added "select CRYPTO_SHASH" to two entries. That Kconfig symbol doesn't exist. These two selects are nops. Drop them. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/crypto/Kconfig b/crypto/Kconfig index ae27b753..82d4d45 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -321,7 +321,6 @@ config CRYPTO_CRC32C_INTEL config CRYPTO_GHASH tristate "GHASH digest algorithm" - select CRYPTO_SHASH select CRYPTO_GF128MUL help GHASH is message digest algorithm for GCM (Galois/Counter Mode). @@ -459,7 +458,6 @@ config CRYPTO_WP512 config CRYPTO_GHASH_CLMUL_NI_INTEL tristate "GHASH digest algorithm (CLMUL-NI accelerated)" depends on X86 && 64BIT - select CRYPTO_SHASH select CRYPTO_CRYPTD help GHASH is message digest algorithm for GCM (Galois/Counter Mode). -- cgit v0.10.2 From afcaed05bcdd0d5c311ce1c210f7046989581bbf Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Wed, 9 Nov 2011 01:20:52 +0100 Subject: mtd: drop select of MTD_PARTITIONS MTD_PARTITIONS got killed in commit 6a8a98b22b. This means that since v3.0 this Kconfig symbol doesn't exist anymore. Apparently selecting a non-existant symbol is a nop. Drop that select. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index cce7b70..dd02792 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig @@ -420,7 +420,6 @@ config MTD_NAND_NANDSIM config MTD_NAND_GPMI_NAND bool "GPMI NAND Flash Controller driver" depends on MTD_NAND && (SOC_IMX23 || SOC_IMX28) - select MTD_PARTITIONS select MTD_CMDLINE_PARTS help Enables NAND Flash support for IMX23 or IMX28. -- cgit v0.10.2 From 085c9461edc964d1956aece94c45ce6295f6221f Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 13 Nov 2011 19:26:53 +0100 Subject: powerpc/mpc5121: drop "select MPC5121_ADS_CPLD" There is no Kconfig symbol named MPC5121_ADS_CPLD. The select statement for that symbol is a nop. Drop it. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/powerpc/platforms/512x/Kconfig b/arch/powerpc/platforms/512x/Kconfig index b3ebce1..c169998 100644 --- a/arch/powerpc/platforms/512x/Kconfig +++ b/arch/powerpc/platforms/512x/Kconfig @@ -12,7 +12,6 @@ config MPC5121_ADS bool "Freescale MPC5121E ADS" depends on PPC_MPC512x select DEFAULT_UIMAGE - select MPC5121_ADS_CPLD help This option enables support for the MPC5121E ADS board. -- cgit v0.10.2 From 3f9416cacc705e7d44611048168fc9180233299c Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sat, 12 Nov 2011 22:47:36 +0100 Subject: drop "select GCD" from three Kconfig files There is no Kconfig symbol named GCD. The three select statements for that symbol are nops. Drop these. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index c72bf8d..4c1686a 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -65,7 +65,6 @@ config AR7 select SYS_SUPPORTS_LITTLE_ENDIAN select SYS_SUPPORTS_ZBOOT_UART16550 select ARCH_REQUIRE_GPIOLIB - select GCD select VLYNQ help Support for the Texas Instruments AR7 System-on-a-Chip diff --git a/net/netfilter/ipvs/Kconfig b/net/netfilter/ipvs/Kconfig index 70bd1d0..ca80de5 100644 --- a/net/netfilter/ipvs/Kconfig +++ b/net/netfilter/ipvs/Kconfig @@ -122,7 +122,6 @@ config IP_VS_RR config IP_VS_WRR tristate "weighted round-robin scheduling" - select GCD ---help--- The weighted robin-robin scheduling algorithm directs network connections to different real servers based on server weights diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 475455c..c15682a 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -5,7 +5,6 @@ config SND_TIMER config SND_PCM tristate select SND_TIMER - select GCD config SND_HWDEP tristate -- cgit v0.10.2 From 63f722e62948b1da8c460087d40f2a61d3b726c3 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 13 Nov 2011 21:23:35 +0100 Subject: MIPS: Sibyte: drop select of SIBYTE_CFE SIBYTE_CFE got killed in commit 05f94eebd5 ("MIPS: Sibyte: Remove standalone kernel support"). This means that since v2.6.31 there is no Kconfig symbol SIBYTE_CFE. The select statement for that symbol is a nop. Drop it. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/arch/mips/sibyte/Kconfig b/arch/mips/sibyte/Kconfig index 3e639bd..3cd937e 100644 --- a/arch/mips/sibyte/Kconfig +++ b/arch/mips/sibyte/Kconfig @@ -71,7 +71,6 @@ config SIBYTE_SB1xxx_SOC bool select DMA_COHERENT select IRQ_CPU - select SIBYTE_CFE select SWAP_IO_SPACE select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_64BIT_KERNEL -- cgit v0.10.2 From 92094aa0946a0e64ef5dd810ccc829fb6aae93c6 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Sun, 13 Nov 2011 21:41:00 +0100 Subject: MAINTAINERS: update ipwireless entry Drop the git tree from MAINTAINERS for ipwireless_cs, as there is no active development on this driver happening. Also change the driver from Maintained to Odd Fixes for the same reason. Cc: David Sterba Signed-off-by: Jiri Kosina diff --git a/MAINTAINERS b/MAINTAINERS index 071a996..14b8688 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3582,8 +3582,7 @@ F: net/netfilter/ipvs/ IPWIRELESS DRIVER M: Jiri Kosina M: David Sterba -S: Maintained -T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/ipwireless_cs.git +S: Odd Fixes F: drivers/tty/ipwireless/ IPX NETWORK LAYER -- cgit v0.10.2 From 62ac0dc9ec0b90b83103ebb659e0696c344e4be4 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:21 +0000 Subject: bnx2x: allow FCoE and DCB for 578xx Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index 51bd748..5cba9d7 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -923,7 +923,7 @@ static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp, void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled) { - if (!CHIP_IS_E1x(bp) && !CHIP_IS_E3(bp)) { + if (!CHIP_IS_E1x(bp)) { bp->dcb_state = dcb_on; bp->dcbx_enabled = dcbx_enabled; } else { diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 6486ab8..6f3a784 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -10817,8 +10817,8 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, bp->qm_cid_count = bnx2x_set_qm_cid_count(bp); #ifdef BCM_CNIC - /* disable FCOE L2 queue for E1x and E3*/ - if (CHIP_IS_E1x(bp) || CHIP_IS_E3(bp)) + /* disable FCOE L2 queue for E1x */ + if (CHIP_IS_E1x(bp)) bp->flags |= NO_FCOE_FLAG; #endif -- cgit v0.10.2 From f233cafe1a9df8de75f446bc6f5dc715cc564325 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:22 +0000 Subject: bnx2x: use rx_queue index for skb_record_rx_queue() Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index aec7212..e17a739 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -507,6 +507,7 @@ struct bnx2x_fastpath { __le16 fp_hc_idx; u8 index; /* number in fp array */ + u8 rx_queue; /* index for skb_record */ u8 cl_id; /* eth client id */ u8 cl_qzone_id; u8 fw_sb_id; /* status block number in FW */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 580b44e..1ace946 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -755,7 +755,7 @@ reuse_rx: } } - skb_record_rx_queue(skb, fp->index); + skb_record_rx_queue(skb, fp->rx_queue); if (le16_to_cpu(cqe_fp->pars_flags.flags) & PARSING_FLAGS_VLAN) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 283d663..4a16757 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1318,6 +1318,7 @@ static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp) struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp); unsigned long q_type = 0; + bnx2x_fcoe(bp, rx_queue) = BNX2X_NUM_ETH_QUEUES(bp); bnx2x_fcoe(bp, cl_id) = bnx2x_cnic_eth_cl_id(bp, BNX2X_FCOE_ETH_CL_ID_IDX); /** Current BNX2X_FCOE_ETH_CID deffinition implies not more than diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 6f3a784..1d185f2 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -5247,7 +5247,7 @@ static void bnx2x_init_eth_fp(struct bnx2x *bp, int fp_idx) u8 cos; unsigned long q_type = 0; u32 cids[BNX2X_MULTI_TX_COS] = { 0 }; - + fp->rx_queue = fp_idx; fp->cid = fp_idx; fp->cl_id = bnx2x_fp_cl_id(fp); fp->fw_sb_id = bnx2x_fp_fw_sb_id(fp); -- cgit v0.10.2 From ad756594a8d88ffc048d14b8d5c02971e08856ce Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:23 +0000 Subject: bnx2x: remove unused variable Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 1ace946..f946a6e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1094,13 +1094,11 @@ static void bnx2x_free_tx_skbs(struct bnx2x *bp) for_each_cos_in_tx_queue(fp, cos) { struct bnx2x_fp_txdata *txdata = &fp->txdata[cos]; - u16 bd_cons = txdata->tx_bd_cons; u16 sw_prod = txdata->tx_pkt_prod; u16 sw_cons = txdata->tx_pkt_cons; while (sw_cons != sw_prod) { - bd_cons = bnx2x_free_tx_pkt(bp, txdata, - TX_BD(sw_cons)); + bnx2x_free_tx_pkt(bp, txdata, TX_BD(sw_cons)); sw_cons++; } } -- cgit v0.10.2 From b306f5edf6615d3abeba16914872c24c9be29051 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:24 +0000 Subject: bnx2x: separate FCoE and iSCSI license initialization. FCoE license info must be initialized at probe(), but iSCSI at open(). Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index f946a6e..3f80c11 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1934,6 +1934,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) mod_timer(&bp->timer, jiffies + bp->current_interval); #ifdef BCM_CNIC + /* re-read iscsi info */ + bnx2x_get_iscsi_info(bp); bnx2x_setup_cnic_irq_info(bp); if (bp->state == BNX2X_STATE_OPEN) bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 4a16757..c1d7833 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1489,4 +1489,14 @@ static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg) return max_cfg; } +#ifdef BCM_CNIC +/** + * bnx2x_get_iscsi_info - update iSCSI params according to licensing info. + * + * @bp: driver handle + * + */ +void bnx2x_get_iscsi_info(struct bnx2x *bp); +#endif + #endif /* BNX2X_CMN_H */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 1d185f2..26dc539 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -9268,21 +9268,38 @@ static void __devinit bnx2x_get_port_hwinfo(struct bnx2x *bp) } #ifdef BCM_CNIC -static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) +void bnx2x_get_iscsi_info(struct bnx2x *bp) { int port = BP_PORT(bp); - int func = BP_ABS_FUNC(bp); u32 max_iscsi_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, drv_lic_key[port].max_iscsi_conn); - u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, - drv_lic_key[port].max_fcoe_conn); - /* Get the number of maximum allowed iSCSI and FCoE connections */ + /* Get the number of maximum allowed iSCSI connections */ bp->cnic_eth_dev.max_iscsi_conn = (max_iscsi_conn & BNX2X_MAX_ISCSI_INIT_CONN_MASK) >> BNX2X_MAX_ISCSI_INIT_CONN_SHIFT; + BNX2X_DEV_INFO("max_iscsi_conn 0x%x\n", + bp->cnic_eth_dev.max_iscsi_conn); + + /* + * If maximum allowed number of connections is zero - + * disable the feature. + */ + if (!bp->cnic_eth_dev.max_iscsi_conn) + bp->flags |= NO_ISCSI_FLAG; +} + +static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp) +{ + int port = BP_PORT(bp); + int func = BP_ABS_FUNC(bp); + + u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp, + drv_lic_key[port].max_fcoe_conn); + + /* Get the number of maximum allowed FCoE connections */ bp->cnic_eth_dev.max_fcoe_conn = (max_fcoe_conn & BNX2X_MAX_FCOE_INIT_CONN_MASK) >> BNX2X_MAX_FCOE_INIT_CONN_SHIFT; @@ -9334,20 +9351,26 @@ static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) } } - BNX2X_DEV_INFO("max_iscsi_conn 0x%x max_fcoe_conn 0x%x\n", - bp->cnic_eth_dev.max_iscsi_conn, - bp->cnic_eth_dev.max_fcoe_conn); + BNX2X_DEV_INFO("max_fcoe_conn 0x%x\n", bp->cnic_eth_dev.max_fcoe_conn); /* * If maximum allowed number of connections is zero - * disable the feature. */ - if (!bp->cnic_eth_dev.max_iscsi_conn) - bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; - if (!bp->cnic_eth_dev.max_fcoe_conn) bp->flags |= NO_FCOE_FLAG; } + +static void __devinit bnx2x_get_cnic_info(struct bnx2x *bp) +{ + /* + * iSCSI may be dynamically disabled but reading + * info here we will decrease memory usage by driver + * if the feature is disabled for good + */ + bnx2x_get_iscsi_info(bp); + bnx2x_get_fcoe_info(bp); +} #endif static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) -- cgit v0.10.2 From 00253a8cf3119af6cb07c9de2c08a50d39fc7201 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:25 +0000 Subject: bnx2x: propagate DCBX negotiation We need propagate the DCBX results from PMF to other functions on the same port, in order to properly update netdev structure and allow following new ETS and PFC configurations. Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 3f80c11..e9a91a3 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1927,7 +1927,9 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) break; } - if (!bp->port.pmf) + if (bp->port.pmf) + bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 0); + else bnx2x__link_status_update(bp); /* start the timer */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index c1d7833..59f1291 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1499,4 +1499,58 @@ static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg) void bnx2x_get_iscsi_info(struct bnx2x *bp); #endif +/* returns func by VN for current port */ +static inline int func_by_vn(struct bnx2x *bp, int vn) +{ + return 2 * vn + BP_PORT(bp); +} + +/** + * bnx2x_link_sync_notify - send notification to other functions. + * + * @bp: driver handle + * + */ +static inline void bnx2x_link_sync_notify(struct bnx2x *bp) +{ + int func; + int vn; + + /* Set the attention towards other drivers on the same port */ + for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { + if (vn == BP_VN(bp)) + continue; + + func = func_by_vn(bp, vn); + REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_0 + + (LINK_SYNC_ATTENTION_BIT_FUNC_0 + func)*4, 1); + } +} + +/** + * bnx2x_update_drv_flags - update flags in shmem + * + * @bp: driver handle + * @flags: flags to update + * @set: set or clear + * + */ +static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set) +{ + if (SHMEM2_HAS(bp, drv_flags)) { + u32 drv_flags; + bnx2x_acquire_hw_lock(bp, HW_LOCK_DRV_FLAGS); + drv_flags = SHMEM2_RD(bp, drv_flags); + + if (set) + SET_FLAGS(drv_flags, flags); + else + RESET_FLAGS(drv_flags, flags); + + SHMEM2_WR(bp, drv_flags, drv_flags); + DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags); + bnx2x_release_hw_lock(bp, HW_LOCK_DRV_FLAGS); + } +} + #endif /* BNX2X_CMN_H */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index 5cba9d7..a0598fd 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -685,24 +685,6 @@ int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall) } #endif -static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set) -{ - if (SHMEM2_HAS(bp, drv_flags)) { - u32 drv_flags; - bnx2x_acquire_hw_lock(bp, HW_LOCK_DRV_FLAGS); - drv_flags = SHMEM2_RD(bp, drv_flags); - - if (set) - SET_FLAGS(drv_flags, flags); - else - RESET_FLAGS(drv_flags, flags); - - SHMEM2_WR(bp, drv_flags, drv_flags); - DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags); - bnx2x_release_hw_lock(bp, HW_LOCK_DRV_FLAGS); - } -} - static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x *bp) { u8 prio, cos; @@ -755,18 +737,26 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) /* mark DCBX result for PMF migration */ bnx2x_update_drv_flags(bp, DRV_FLAGS_DCB_CONFIGURED, 1); #ifdef BCM_DCBNL - /** + /* * Add new app tlvs to dcbnl */ bnx2x_dcbnl_update_applist(bp, false); #endif - bnx2x_dcbx_stop_hw_tx(bp); - - /* reconfigure the netdevice with the results of the new + /* + * reconfigure the netdevice with the results of the new * dcbx negotiation. */ bnx2x_dcbx_update_tc_mapping(bp); + /* + * allow other funtions to update their netdevices + * accordingly + */ + if (IS_MF(bp)) + bnx2x_link_sync_notify(bp); + + bnx2x_dcbx_stop_hw_tx(bp); + return; } case BNX2X_DCBX_STATE_TX_PAUSED: @@ -775,6 +765,7 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) bnx2x_dcbx_update_ets_params(bp); bnx2x_dcbx_resume_hw_tx(bp); + return; case BNX2X_DCBX_STATE_TX_RELEASED: DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n"); @@ -1863,7 +1854,7 @@ static void bnx2x_dcbx_fw_struct(struct bnx2x *bp, void bnx2x_dcbx_pmf_update(struct bnx2x *bp) { /* if we need to syncronize DCBX result from prev PMF - * read it from shmem and update bp accordingly + * read it from shmem and update bp and netdev accordingly */ if (SHMEM2_HAS(bp, drv_flags) && GET_FLAGS(SHMEM2_RD(bp, drv_flags), DRV_FLAGS_DCB_CONFIGURED)) { @@ -1875,6 +1866,22 @@ void bnx2x_dcbx_pmf_update(struct bnx2x *bp) bp->dcbx_error); bnx2x_get_dcbx_drv_param(bp, &bp->dcbx_local_feat, bp->dcbx_error); +#ifdef BCM_DCBNL + /* + * Add new app tlvs to dcbnl + */ + bnx2x_dcbnl_update_applist(bp, false); + /* + * Send a notification for the new negotiated parameters + */ + dcbnl_cee_notify(bp->dev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0); +#endif + /* + * reconfigure the netdevice with the results of the new + * dcbx negotiation. + */ + bnx2x_dcbx_update_tc_mapping(bp); + } } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 26dc539..967c41b 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -2318,12 +2318,6 @@ static void bnx2x_calc_vn_weight_sum(struct bnx2x *bp) CMNG_FLAGS_PER_PORT_FAIRNESS_VN; } -/* returns func by VN for current port */ -static inline int func_by_vn(struct bnx2x *bp, int vn) -{ - return 2 * vn + BP_PORT(bp); -} - static void bnx2x_init_vn_minmax(struct bnx2x *bp, int vn) { struct rate_shaping_vars_per_vn m_rs_vn; @@ -2475,22 +2469,6 @@ static void bnx2x_cmng_fns_init(struct bnx2x *bp, u8 read_cfg, u8 cmng_type) "rate shaping and fairness are disabled\n"); } -static inline void bnx2x_link_sync_notify(struct bnx2x *bp) -{ - int func; - int vn; - - /* Set the attention towards other drivers on the same port */ - for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) { - if (vn == BP_VN(bp)) - continue; - - func = func_by_vn(bp, vn); - REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_0 + - (LINK_SYNC_ATTENTION_BIT_FUNC_0 + func)*4, 1); - } -} - /* This function is called upon link interrupt */ static void bnx2x_link_attn(struct bnx2x *bp) { @@ -2549,6 +2527,9 @@ void bnx2x__link_status_update(struct bnx2x *bp) if (bp->state != BNX2X_STATE_OPEN) return; + /* read updated dcb configuration */ + bnx2x_dcbx_pmf_update(bp); + bnx2x_link_status_update(&bp->link_params, &bp->link_vars); if (bp->link_vars.link_up) -- cgit v0.10.2 From f9c058b633000e64fba05fc14ba94dd09a20e674 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:26 +0000 Subject: bnx2x: DCBX: use #define instead of magic Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index a0598fd..5051cf3 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -874,7 +874,7 @@ static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp, /*For IEEE admin_recommendation_bw_precentage *For IEEE admin_recommendation_ets_pg */ af->pfc.pri_en_bitmap = (u8)dp->admin_pfc_bitmap; - for (i = 0; i < 4; i++) { + for (i = 0; i < DCBX_CONFIG_MAX_APP_PROTOCOL; i++) { if (dp->admin_priority_app_table[i].valid) { struct bnx2x_admin_priority_app_table *table = dp->admin_priority_app_table; @@ -2249,7 +2249,7 @@ static int bnx2x_set_admin_app_up(struct bnx2x *bp, u8 idtype, u16 idval, u8 up) int i, ff; /* iterate over the app entries looking for idtype and idval */ - for (i = 0, ff = -1; i < 4; i++) { + for (i = 0, ff = -1; i < DCBX_CONFIG_MAX_APP_PROTOCOL; i++) { struct bnx2x_admin_priority_app_table *app_ent = &bp->dcbx_config_params.admin_priority_app_table[i]; if (bnx2x_admin_app_is_equal(app_ent, idtype, idval)) @@ -2258,7 +2258,7 @@ static int bnx2x_set_admin_app_up(struct bnx2x *bp, u8 idtype, u16 idval, u8 up) if (ff < 0 && !app_ent->valid) ff = i; } - if (i < 4) + if (i < DCBX_CONFIG_MAX_APP_PROTOCOL) /* if found overwrite up */ bp->dcbx_config_params. admin_priority_app_table[i].priority = up; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h index 2c6a3bc..2ab9254 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h @@ -90,6 +90,7 @@ struct bnx2x_admin_priority_app_table { u32 app_id; }; +#define DCBX_CONFIG_MAX_APP_PROTOCOL 4 struct bnx2x_config_dcbx_params { u32 overwrite_settings; u32 admin_dcbx_version; @@ -109,7 +110,8 @@ struct bnx2x_config_dcbx_params { u32 admin_recommendation_bw_precentage[8]; u32 admin_recommendation_ets_pg[8]; u32 admin_pfc_bitmap; - struct bnx2x_admin_priority_app_table admin_priority_app_table[4]; + struct bnx2x_admin_priority_app_table + admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL]; u32 admin_default_priority; }; -- cgit v0.10.2 From b363782761eea7076619fe44063b915dae0b4cc7 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:27 +0000 Subject: bnx2x: simplify definition of RX_SGE_MASK_LEN and use it. Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index e17a739..b78c384 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -411,8 +411,7 @@ union db_prod { /* Number of u64 elements in SGE mask array */ -#define RX_SGE_MASK_LEN ((NUM_RX_SGE_PAGES * RX_SGE_CNT) / \ - BIT_VEC64_ELEM_SZ) +#define RX_SGE_MASK_LEN (NUM_RX_SGE / BIT_VEC64_ELEM_SZ) #define RX_SGE_MASK_LEN_MASK (RX_SGE_MASK_LEN - 1) #define NEXT_SGE_MASK_ELEM(el) (((el) + 1) & RX_SGE_MASK_LEN_MASK) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 59f1291..260226d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -874,8 +874,7 @@ static inline void bnx2x_clear_sge_mask_next_elems(struct bnx2x_fastpath *fp) static inline void bnx2x_init_sge_ring_bit_mask(struct bnx2x_fastpath *fp) { /* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */ - memset(fp->sge_mask, 0xff, - (NUM_RX_SGE >> BIT_VEC64_ELEM_SHIFT)*sizeof(u64)); + memset(fp->sge_mask, 0xff, sizeof(fp->sge_mask)); /* Clear the two last indices in the page to 1: these are the indices that correspond to the "next" element, -- cgit v0.10.2 From 46fa1309fe5b05249447df903ec256c3509eb985 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:28 +0000 Subject: bnx2x: remove unused #define Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index b78c384..23e91f4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -1984,13 +1984,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, #define HW_PRTY_ASSERT_SET_4 (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | \ AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR) -#define RSS_FLAGS(bp) \ - (TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY | \ - TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY | \ - TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY | \ - TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | \ - (bp->multi_mode << \ - TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT)) #define MULTI_MASK 0x7f -- cgit v0.10.2 From 8304859adc213df9f69a86e06164683f76cd5d49 Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Sun, 13 Nov 2011 04:34:29 +0000 Subject: bnx2x: add fan failure event handling Shut down the device in case of fan failure to prevent HW damage. Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 23e91f4..78613ef 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -1141,6 +1141,7 @@ struct bnx2x_fw_stats_data { enum { BNX2X_SP_RTNL_SETUP_TC, BNX2X_SP_RTNL_TX_TIMEOUT, + BNX2X_SP_RTNL_FAN_FAILURE, }; @@ -2048,6 +2049,8 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, #define BNX2X_VPD_LEN 128 #define VENDOR_ID_LEN 4 +int bnx2x_close(struct net_device *dev); + /* Congestion management fairness mode */ #define CMNG_FNS_NONE 0 #define CMNG_FNS_MINMAX 1 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 967c41b..33ff60d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -3299,6 +3299,17 @@ static inline void bnx2x_fan_failure(struct bnx2x *bp) netdev_err(bp->dev, "Fan Failure on Network Controller has caused" " the driver to shutdown the card to prevent permanent" " damage. Please contact OEM Support for assistance\n"); + + /* + * Scheudle device reset (unload) + * This is due to some boards consuming sufficient power when driver is + * up to overheat if fan fails. + */ + smp_mb__before_clear_bit(); + set_bit(BNX2X_SP_RTNL_FAN_FAILURE, &bp->sp_rtnl_state); + smp_mb__after_clear_bit(); + schedule_delayed_work(&bp->sp_rtnl_task, 0); + } static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) @@ -8503,6 +8514,17 @@ sp_rtnl_not_reset: if (test_and_clear_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state)) bnx2x_setup_tc(bp->dev, bp->dcbx_port_params.ets.num_of_cos); + /* + * in case of fan failure we need to reset id if the "stop on error" + * debug flag is set, since we trying to prevent permanent overheating + * damage + */ + if (test_and_clear_bit(BNX2X_SP_RTNL_FAN_FAILURE, &bp->sp_rtnl_state)) { + DP(BNX2X_MSG_SP, "fan failure detected. Unloading driver"); + netif_device_detach(bp->dev); + bnx2x_close(bp->dev); + } + sp_rtnl_exit: rtnl_unlock(); } @@ -9969,7 +9991,7 @@ static int bnx2x_open(struct net_device *dev) } /* called with rtnl_lock */ -static int bnx2x_close(struct net_device *dev) +int bnx2x_close(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); -- cgit v0.10.2 From 4a025f49d3f2f2f39b474af360c81a5587b41657 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:30 +0000 Subject: bnx2x: prevent race in statistics flow The race may cause access of registers while MAC hw block is in reset state. As a result syslog will show error messages. We can prevent this by using state from local variable. Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c index 02ac6a7..3034f0e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c @@ -1349,12 +1349,14 @@ void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) enum bnx2x_stats_state state; if (unlikely(bp->panic)) return; - bnx2x_stats_stm[bp->stats_state][event].action(bp); + spin_lock_bh(&bp->stats_lock); state = bp->stats_state; bp->stats_state = bnx2x_stats_stm[state][event].next_state; spin_unlock_bh(&bp->stats_lock); + bnx2x_stats_stm[state][event].action(bp); + if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", state, event, bp->stats_state); -- cgit v0.10.2 From 72754080d14feef1ca0b3ae383ddfdc5d9a71b1a Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Sun, 13 Nov 2011 04:34:31 +0000 Subject: bnx2x: Remove on-stack napi struct variable Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index e9a91a3..13dad92 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -79,19 +79,21 @@ static inline void bnx2x_bz_fp(struct bnx2x *bp, int index) * @to: destination FP index * * Makes sure the contents of the bp->fp[to].napi is kept - * intact. + * intact. This is done by first copying the napi struct from + * the target to the source, and then mem copying the entire + * source onto the target */ static inline void bnx2x_move_fp(struct bnx2x *bp, int from, int to) { struct bnx2x_fastpath *from_fp = &bp->fp[from]; struct bnx2x_fastpath *to_fp = &bp->fp[to]; - struct napi_struct orig_napi = to_fp->napi; + + /* Copy the NAPI object as it has been already initialized */ + from_fp->napi = to_fp->napi; + /* Move bnx2x_fastpath contents */ memcpy(to_fp, from_fp, sizeof(*to_fp)); to_fp->index = to; - - /* Restore the NAPI object as it has been already initialized */ - to_fp->napi = orig_napi; } int load_count[2][3] = { {0} }; /* per-path: 0-common, 1-port0, 2-port1 */ -- cgit v0.10.2 From 5d70b88cd41ef0f2ac0caaab4fd492dd686feee6 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 13 Nov 2011 04:34:32 +0000 Subject: bnx2x: update driver version to 1.70.35-0 Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 78613ef..4b90b51 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -23,8 +23,8 @@ * (you will need to reboot afterwards) */ /* #define BNX2X_STOP_ON_ERROR */ -#define DRV_MODULE_VERSION "1.70.30-0" -#define DRV_MODULE_RELDATE "2011/10/25" +#define DRV_MODULE_VERSION "1.70.35-0" +#define DRV_MODULE_RELDATE "2011/11/10" #define BNX2X_BC_VER 0x040200 #if defined(CONFIG_DCB) -- cgit v0.10.2 From 3d249d4ca7d0ed6629a135ea1ea21c72286c0d80 Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Fri, 11 Nov 2011 22:16:48 +0000 Subject: net: introduce ethernet teaming device This patch introduces new network device called team. It supposes to be very fast, simple, userspace-driven alternative to existing bonding driver. Userspace library called libteam with couple of demo apps is available here: https://github.com/jpirko/libteam Note it's still in its dipers atm. team<->libteam use generic netlink for communication. That and rtnl suppose to be the only way to configure team device, no sysfs etc. Python binding of libteam was recently introduced. Daemon providing arpmon/miimon active-backup functionality will be introduced shortly. All what's necessary is already implemented in kernel team driver. v7->v8: - check ndo_ndo_vlan_rx_[add/kill]_vid functions before calling them. - use dev_kfree_skb_any() instead of dev_kfree_skb() v6->v7: - transmit and receive functions are not checked in hot paths. That also resolves memory leak on transmit when no port is present v5->v6: - changed couple of _rcu calls to non _rcu ones in non-readers v4->v5: - team_change_mtu() uses team->lock while travesing though port list - mac address changes are moved completely to jurisdiction of userspace daemon. This way the daemon can do FOM1, FOM2 and possibly other weird things with mac addresses. Only round-robin mode sets up all ports to bond's address then enslaved. - Extended Kconfig text v3->v4: - remove redundant synchronize_rcu from __team_change_mode() - revert "set and clear of mode_ops happens per pointer, not per byte" - extend comment of function __team_change_mode() v2->v3: - team_change_mtu() uses rcu version of list traversal to unwind - set and clear of mode_ops happens per pointer, not per byte - port hashlist changed to be embedded into team structure - error branch in team_port_enter() does cleanup now - fixed rtln->rtnl v1->v2: - modes are made as modules. Makes team more modular and extendable. - several commenters' nitpicks found on v1 were fixed - several other bugs were fixed. - note I ignored Eric's comment about roundrobin port selector as Eric's way may be easily implemented as another mode (mode "random") in future. Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller diff --git a/Documentation/networking/team.txt b/Documentation/networking/team.txt new file mode 100644 index 0000000..5a01368 --- /dev/null +++ b/Documentation/networking/team.txt @@ -0,0 +1,2 @@ +Team devices are driven from userspace via libteam library which is here: + https://github.com/jpirko/libteam diff --git a/MAINTAINERS b/MAINTAINERS index 4808256..8d94169 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6484,6 +6484,13 @@ W: http://tcp-lp-mod.sourceforge.net/ S: Maintained F: net/ipv4/tcp_lp.c +TEAM DRIVER +M: Jiri Pirko +L: netdev@vger.kernel.org +S: Supported +F: drivers/net/team/ +F: include/linux/if_team.h + TEGRA SUPPORT M: Colin Cross M: Olof Johansson diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 583f66c..b3020be 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -125,6 +125,8 @@ config IFB 'ifb1' etc. Look at the iproute2 documentation directory for usage etc +source "drivers/net/team/Kconfig" + config MACVLAN tristate "MAC-VLAN support (EXPERIMENTAL)" depends on EXPERIMENTAL diff --git a/drivers/net/Makefile b/drivers/net/Makefile index fa877cd..4e4ebfe 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_NET) += Space.o loopback.o obj-$(CONFIG_NETCONSOLE) += netconsole.o obj-$(CONFIG_PHYLIB) += phy/ obj-$(CONFIG_RIONET) += rionet.o +obj-$(CONFIG_NET_TEAM) += team/ obj-$(CONFIG_TUN) += tun.o obj-$(CONFIG_VETH) += veth.o obj-$(CONFIG_VIRTIO_NET) += virtio_net.o diff --git a/drivers/net/team/Kconfig b/drivers/net/team/Kconfig new file mode 100644 index 0000000..248a144 --- /dev/null +++ b/drivers/net/team/Kconfig @@ -0,0 +1,43 @@ +menuconfig NET_TEAM + tristate "Ethernet team driver support (EXPERIMENTAL)" + depends on EXPERIMENTAL + ---help--- + This allows one to create virtual interfaces that teams together + multiple ethernet devices. + + Team devices can be added using the "ip" command from the + iproute2 package: + + "ip link add link [ address MAC ] [ NAME ] type team" + + To compile this driver as a module, choose M here: the module + will be called team. + +if NET_TEAM + +config NET_TEAM_MODE_ROUNDROBIN + tristate "Round-robin mode support" + depends on NET_TEAM + ---help--- + Basic mode where port used for transmitting packets is selected in + round-robin fashion using packet counter. + + All added ports are setup to have bond's mac address. + + To compile this team mode as a module, choose M here: the module + will be called team_mode_roundrobin. + +config NET_TEAM_MODE_ACTIVEBACKUP + tristate "Active-backup mode support" + depends on NET_TEAM + ---help--- + Only one port is active at a time and the rest of ports are used + for backup. + + Mac addresses of ports are not modified. Userspace is responsible + to do so. + + To compile this team mode as a module, choose M here: the module + will be called team_mode_activebackup. + +endif # NET_TEAM diff --git a/drivers/net/team/Makefile b/drivers/net/team/Makefile new file mode 100644 index 0000000..85f2028 --- /dev/null +++ b/drivers/net/team/Makefile @@ -0,0 +1,7 @@ +# +# Makefile for the network team driver +# + +obj-$(CONFIG_NET_TEAM) += team.o +obj-$(CONFIG_NET_TEAM_MODE_ROUNDROBIN) += team_mode_roundrobin.o +obj-$(CONFIG_NET_TEAM_MODE_ACTIVEBACKUP) += team_mode_activebackup.o diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c new file mode 100644 index 0000000..60672bb --- /dev/null +++ b/drivers/net/team/team.c @@ -0,0 +1,1583 @@ +/* + * net/drivers/team/team.c - Network team device driver + * Copyright (c) 2011 Jiri Pirko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRV_NAME "team" + + +/********** + * Helpers + **********/ + +#define team_port_exists(dev) (dev->priv_flags & IFF_TEAM_PORT) + +static struct team_port *team_port_get_rcu(const struct net_device *dev) +{ + struct team_port *port = rcu_dereference(dev->rx_handler_data); + + return team_port_exists(dev) ? port : NULL; +} + +static struct team_port *team_port_get_rtnl(const struct net_device *dev) +{ + struct team_port *port = rtnl_dereference(dev->rx_handler_data); + + return team_port_exists(dev) ? port : NULL; +} + +/* + * Since the ability to change mac address for open port device is tested in + * team_port_add, this function can be called without control of return value + */ +static int __set_port_mac(struct net_device *port_dev, + const unsigned char *dev_addr) +{ + struct sockaddr addr; + + memcpy(addr.sa_data, dev_addr, ETH_ALEN); + addr.sa_family = ARPHRD_ETHER; + return dev_set_mac_address(port_dev, &addr); +} + +int team_port_set_orig_mac(struct team_port *port) +{ + return __set_port_mac(port->dev, port->orig.dev_addr); +} + +int team_port_set_team_mac(struct team_port *port) +{ + return __set_port_mac(port->dev, port->team->dev->dev_addr); +} +EXPORT_SYMBOL(team_port_set_team_mac); + + +/******************* + * Options handling + *******************/ + +void team_options_register(struct team *team, struct team_option *option, + size_t option_count) +{ + int i; + + for (i = 0; i < option_count; i++, option++) + list_add_tail(&option->list, &team->option_list); +} +EXPORT_SYMBOL(team_options_register); + +static void __team_options_change_check(struct team *team, + struct team_option *changed_option); + +static void __team_options_unregister(struct team *team, + struct team_option *option, + size_t option_count) +{ + int i; + + for (i = 0; i < option_count; i++, option++) + list_del(&option->list); +} + +void team_options_unregister(struct team *team, struct team_option *option, + size_t option_count) +{ + __team_options_unregister(team, option, option_count); + __team_options_change_check(team, NULL); +} +EXPORT_SYMBOL(team_options_unregister); + +static int team_option_get(struct team *team, struct team_option *option, + void *arg) +{ + return option->getter(team, arg); +} + +static int team_option_set(struct team *team, struct team_option *option, + void *arg) +{ + int err; + + err = option->setter(team, arg); + if (err) + return err; + + __team_options_change_check(team, option); + return err; +} + +/**************** + * Mode handling + ****************/ + +static LIST_HEAD(mode_list); +static DEFINE_SPINLOCK(mode_list_lock); + +static struct team_mode *__find_mode(const char *kind) +{ + struct team_mode *mode; + + list_for_each_entry(mode, &mode_list, list) { + if (strcmp(mode->kind, kind) == 0) + return mode; + } + return NULL; +} + +static bool is_good_mode_name(const char *name) +{ + while (*name != '\0') { + if (!isalpha(*name) && !isdigit(*name) && *name != '_') + return false; + name++; + } + return true; +} + +int team_mode_register(struct team_mode *mode) +{ + int err = 0; + + if (!is_good_mode_name(mode->kind) || + mode->priv_size > TEAM_MODE_PRIV_SIZE) + return -EINVAL; + spin_lock(&mode_list_lock); + if (__find_mode(mode->kind)) { + err = -EEXIST; + goto unlock; + } + list_add_tail(&mode->list, &mode_list); +unlock: + spin_unlock(&mode_list_lock); + return err; +} +EXPORT_SYMBOL(team_mode_register); + +int team_mode_unregister(struct team_mode *mode) +{ + spin_lock(&mode_list_lock); + list_del_init(&mode->list); + spin_unlock(&mode_list_lock); + return 0; +} +EXPORT_SYMBOL(team_mode_unregister); + +static struct team_mode *team_mode_get(const char *kind) +{ + struct team_mode *mode; + + spin_lock(&mode_list_lock); + mode = __find_mode(kind); + if (!mode) { + spin_unlock(&mode_list_lock); + request_module("team-mode-%s", kind); + spin_lock(&mode_list_lock); + mode = __find_mode(kind); + } + if (mode) + if (!try_module_get(mode->owner)) + mode = NULL; + + spin_unlock(&mode_list_lock); + return mode; +} + +static void team_mode_put(const struct team_mode *mode) +{ + module_put(mode->owner); +} + +static bool team_dummy_transmit(struct team *team, struct sk_buff *skb) +{ + dev_kfree_skb_any(skb); + return false; +} + +rx_handler_result_t team_dummy_receive(struct team *team, + struct team_port *port, + struct sk_buff *skb) +{ + return RX_HANDLER_ANOTHER; +} + +static void team_adjust_ops(struct team *team) +{ + /* + * To avoid checks in rx/tx skb paths, ensure here that non-null and + * correct ops are always set. + */ + + if (list_empty(&team->port_list) || + !team->mode || !team->mode->ops->transmit) + team->ops.transmit = team_dummy_transmit; + else + team->ops.transmit = team->mode->ops->transmit; + + if (list_empty(&team->port_list) || + !team->mode || !team->mode->ops->receive) + team->ops.receive = team_dummy_receive; + else + team->ops.receive = team->mode->ops->receive; +} + +/* + * We can benefit from the fact that it's ensured no port is present + * at the time of mode change. Therefore no packets are in fly so there's no + * need to set mode operations in any special way. + */ +static int __team_change_mode(struct team *team, + const struct team_mode *new_mode) +{ + /* Check if mode was previously set and do cleanup if so */ + if (team->mode) { + void (*exit_op)(struct team *team) = team->ops.exit; + + /* Clear ops area so no callback is called any longer */ + memset(&team->ops, 0, sizeof(struct team_mode_ops)); + team_adjust_ops(team); + + if (exit_op) + exit_op(team); + team_mode_put(team->mode); + team->mode = NULL; + /* zero private data area */ + memset(&team->mode_priv, 0, + sizeof(struct team) - offsetof(struct team, mode_priv)); + } + + if (!new_mode) + return 0; + + if (new_mode->ops->init) { + int err; + + err = new_mode->ops->init(team); + if (err) + return err; + } + + team->mode = new_mode; + memcpy(&team->ops, new_mode->ops, sizeof(struct team_mode_ops)); + team_adjust_ops(team); + + return 0; +} + +static int team_change_mode(struct team *team, const char *kind) +{ + struct team_mode *new_mode; + struct net_device *dev = team->dev; + int err; + + if (!list_empty(&team->port_list)) { + netdev_err(dev, "No ports can be present during mode change\n"); + return -EBUSY; + } + + if (team->mode && strcmp(team->mode->kind, kind) == 0) { + netdev_err(dev, "Unable to change to the same mode the team is in\n"); + return -EINVAL; + } + + new_mode = team_mode_get(kind); + if (!new_mode) { + netdev_err(dev, "Mode \"%s\" not found\n", kind); + return -EINVAL; + } + + err = __team_change_mode(team, new_mode); + if (err) { + netdev_err(dev, "Failed to change to mode \"%s\"\n", kind); + team_mode_put(new_mode); + return err; + } + + netdev_info(dev, "Mode changed to \"%s\"\n", kind); + return 0; +} + + +/************************ + * Rx path frame handler + ************************/ + +/* note: already called with rcu_read_lock */ +static rx_handler_result_t team_handle_frame(struct sk_buff **pskb) +{ + struct sk_buff *skb = *pskb; + struct team_port *port; + struct team *team; + rx_handler_result_t res; + + skb = skb_share_check(skb, GFP_ATOMIC); + if (!skb) + return RX_HANDLER_CONSUMED; + + *pskb = skb; + + port = team_port_get_rcu(skb->dev); + team = port->team; + + res = team->ops.receive(team, port, skb); + if (res == RX_HANDLER_ANOTHER) { + struct team_pcpu_stats *pcpu_stats; + + pcpu_stats = this_cpu_ptr(team->pcpu_stats); + u64_stats_update_begin(&pcpu_stats->syncp); + pcpu_stats->rx_packets++; + pcpu_stats->rx_bytes += skb->len; + if (skb->pkt_type == PACKET_MULTICAST) + pcpu_stats->rx_multicast++; + u64_stats_update_end(&pcpu_stats->syncp); + + skb->dev = team->dev; + } else { + this_cpu_inc(team->pcpu_stats->rx_dropped); + } + + return res; +} + + +/**************** + * Port handling + ****************/ + +static bool team_port_find(const struct team *team, + const struct team_port *port) +{ + struct team_port *cur; + + list_for_each_entry(cur, &team->port_list, list) + if (cur == port) + return true; + return false; +} + +/* + * Add/delete port to the team port list. Write guarded by rtnl_lock. + * Takes care of correct port->index setup (might be racy). + */ +static void team_port_list_add_port(struct team *team, + struct team_port *port) +{ + port->index = team->port_count++; + hlist_add_head_rcu(&port->hlist, + team_port_index_hash(team, port->index)); + list_add_tail_rcu(&port->list, &team->port_list); +} + +static void __reconstruct_port_hlist(struct team *team, int rm_index) +{ + int i; + struct team_port *port; + + for (i = rm_index + 1; i < team->port_count; i++) { + port = team_get_port_by_index(team, i); + hlist_del_rcu(&port->hlist); + port->index--; + hlist_add_head_rcu(&port->hlist, + team_port_index_hash(team, port->index)); + } +} + +static void team_port_list_del_port(struct team *team, + struct team_port *port) +{ + int rm_index = port->index; + + hlist_del_rcu(&port->hlist); + list_del_rcu(&port->list); + __reconstruct_port_hlist(team, rm_index); + team->port_count--; +} + +#define TEAM_VLAN_FEATURES (NETIF_F_ALL_CSUM | NETIF_F_SG | \ + NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \ + NETIF_F_HIGHDMA | NETIF_F_LRO) + +static void __team_compute_features(struct team *team) +{ + struct team_port *port; + u32 vlan_features = TEAM_VLAN_FEATURES; + unsigned short max_hard_header_len = ETH_HLEN; + + list_for_each_entry(port, &team->port_list, list) { + vlan_features = netdev_increment_features(vlan_features, + port->dev->vlan_features, + TEAM_VLAN_FEATURES); + + if (port->dev->hard_header_len > max_hard_header_len) + max_hard_header_len = port->dev->hard_header_len; + } + + team->dev->vlan_features = vlan_features; + team->dev->hard_header_len = max_hard_header_len; + + netdev_change_features(team->dev); +} + +static void team_compute_features(struct team *team) +{ + spin_lock(&team->lock); + __team_compute_features(team); + spin_unlock(&team->lock); +} + +static int team_port_enter(struct team *team, struct team_port *port) +{ + int err = 0; + + dev_hold(team->dev); + port->dev->priv_flags |= IFF_TEAM_PORT; + if (team->ops.port_enter) { + err = team->ops.port_enter(team, port); + if (err) { + netdev_err(team->dev, "Device %s failed to enter team mode\n", + port->dev->name); + goto err_port_enter; + } + } + + return 0; + +err_port_enter: + port->dev->priv_flags &= ~IFF_TEAM_PORT; + dev_put(team->dev); + + return err; +} + +static void team_port_leave(struct team *team, struct team_port *port) +{ + if (team->ops.port_leave) + team->ops.port_leave(team, port); + port->dev->priv_flags &= ~IFF_TEAM_PORT; + dev_put(team->dev); +} + +static void __team_port_change_check(struct team_port *port, bool linkup); + +static int team_port_add(struct team *team, struct net_device *port_dev) +{ + struct net_device *dev = team->dev; + struct team_port *port; + char *portname = port_dev->name; + int err; + + if (port_dev->flags & IFF_LOOPBACK || + port_dev->type != ARPHRD_ETHER) { + netdev_err(dev, "Device %s is of an unsupported type\n", + portname); + return -EINVAL; + } + + if (team_port_exists(port_dev)) { + netdev_err(dev, "Device %s is already a port " + "of a team device\n", portname); + return -EBUSY; + } + + if (port_dev->flags & IFF_UP) { + netdev_err(dev, "Device %s is up. Set it down before adding it as a team port\n", + portname); + return -EBUSY; + } + + port = kzalloc(sizeof(struct team_port), GFP_KERNEL); + if (!port) + return -ENOMEM; + + port->dev = port_dev; + port->team = team; + + port->orig.mtu = port_dev->mtu; + err = dev_set_mtu(port_dev, dev->mtu); + if (err) { + netdev_dbg(dev, "Error %d calling dev_set_mtu\n", err); + goto err_set_mtu; + } + + memcpy(port->orig.dev_addr, port_dev->dev_addr, ETH_ALEN); + + err = team_port_enter(team, port); + if (err) { + netdev_err(dev, "Device %s failed to enter team mode\n", + portname); + goto err_port_enter; + } + + err = dev_open(port_dev); + if (err) { + netdev_dbg(dev, "Device %s opening failed\n", + portname); + goto err_dev_open; + } + + err = netdev_set_master(port_dev, dev); + if (err) { + netdev_err(dev, "Device %s failed to set master\n", portname); + goto err_set_master; + } + + err = netdev_rx_handler_register(port_dev, team_handle_frame, + port); + if (err) { + netdev_err(dev, "Device %s failed to register rx_handler\n", + portname); + goto err_handler_register; + } + + team_port_list_add_port(team, port); + team_adjust_ops(team); + __team_compute_features(team); + __team_port_change_check(port, !!netif_carrier_ok(port_dev)); + + netdev_info(dev, "Port device %s added\n", portname); + + return 0; + +err_handler_register: + netdev_set_master(port_dev, NULL); + +err_set_master: + dev_close(port_dev); + +err_dev_open: + team_port_leave(team, port); + team_port_set_orig_mac(port); + +err_port_enter: + dev_set_mtu(port_dev, port->orig.mtu); + +err_set_mtu: + kfree(port); + + return err; +} + +static int team_port_del(struct team *team, struct net_device *port_dev) +{ + struct net_device *dev = team->dev; + struct team_port *port; + char *portname = port_dev->name; + + port = team_port_get_rtnl(port_dev); + if (!port || !team_port_find(team, port)) { + netdev_err(dev, "Device %s does not act as a port of this team\n", + portname); + return -ENOENT; + } + + __team_port_change_check(port, false); + team_port_list_del_port(team, port); + team_adjust_ops(team); + netdev_rx_handler_unregister(port_dev); + netdev_set_master(port_dev, NULL); + dev_close(port_dev); + team_port_leave(team, port); + team_port_set_orig_mac(port); + dev_set_mtu(port_dev, port->orig.mtu); + synchronize_rcu(); + kfree(port); + netdev_info(dev, "Port device %s removed\n", portname); + __team_compute_features(team); + + return 0; +} + + +/***************** + * Net device ops + *****************/ + +static const char team_no_mode_kind[] = "*NOMODE*"; + +static int team_mode_option_get(struct team *team, void *arg) +{ + const char **str = arg; + + *str = team->mode ? team->mode->kind : team_no_mode_kind; + return 0; +} + +static int team_mode_option_set(struct team *team, void *arg) +{ + const char **str = arg; + + return team_change_mode(team, *str); +} + +static struct team_option team_options[] = { + { + .name = "mode", + .type = TEAM_OPTION_TYPE_STRING, + .getter = team_mode_option_get, + .setter = team_mode_option_set, + }, +}; + +static int team_init(struct net_device *dev) +{ + struct team *team = netdev_priv(dev); + int i; + + team->dev = dev; + spin_lock_init(&team->lock); + + team->pcpu_stats = alloc_percpu(struct team_pcpu_stats); + if (!team->pcpu_stats) + return -ENOMEM; + + for (i = 0; i < TEAM_PORT_HASHENTRIES; i++) + INIT_HLIST_HEAD(&team->port_hlist[i]); + INIT_LIST_HEAD(&team->port_list); + + team_adjust_ops(team); + + INIT_LIST_HEAD(&team->option_list); + team_options_register(team, team_options, ARRAY_SIZE(team_options)); + netif_carrier_off(dev); + + return 0; +} + +static void team_uninit(struct net_device *dev) +{ + struct team *team = netdev_priv(dev); + struct team_port *port; + struct team_port *tmp; + + spin_lock(&team->lock); + list_for_each_entry_safe(port, tmp, &team->port_list, list) + team_port_del(team, port->dev); + + __team_change_mode(team, NULL); /* cleanup */ + __team_options_unregister(team, team_options, ARRAY_SIZE(team_options)); + spin_unlock(&team->lock); +} + +static void team_destructor(struct net_device *dev) +{ + struct team *team = netdev_priv(dev); + + free_percpu(team->pcpu_stats); + free_netdev(dev); +} + +static int team_open(struct net_device *dev) +{ + netif_carrier_on(dev); + return 0; +} + +static int team_close(struct net_device *dev) +{ + netif_carrier_off(dev); + return 0; +} + +/* + * note: already called with rcu_read_lock + */ +static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct team *team = netdev_priv(dev); + bool tx_success = false; + unsigned int len = skb->len; + + tx_success = team->ops.transmit(team, skb); + if (tx_success) { + struct team_pcpu_stats *pcpu_stats; + + pcpu_stats = this_cpu_ptr(team->pcpu_stats); + u64_stats_update_begin(&pcpu_stats->syncp); + pcpu_stats->tx_packets++; + pcpu_stats->tx_bytes += len; + u64_stats_update_end(&pcpu_stats->syncp); + } else { + this_cpu_inc(team->pcpu_stats->tx_dropped); + } + + return NETDEV_TX_OK; +} + +static void team_change_rx_flags(struct net_device *dev, int change) +{ + struct team *team = netdev_priv(dev); + struct team_port *port; + int inc; + + rcu_read_lock(); + list_for_each_entry_rcu(port, &team->port_list, list) { + if (change & IFF_PROMISC) { + inc = dev->flags & IFF_PROMISC ? 1 : -1; + dev_set_promiscuity(port->dev, inc); + } + if (change & IFF_ALLMULTI) { + inc = dev->flags & IFF_ALLMULTI ? 1 : -1; + dev_set_allmulti(port->dev, inc); + } + } + rcu_read_unlock(); +} + +static void team_set_rx_mode(struct net_device *dev) +{ + struct team *team = netdev_priv(dev); + struct team_port *port; + + rcu_read_lock(); + list_for_each_entry_rcu(port, &team->port_list, list) { + dev_uc_sync(port->dev, dev); + dev_mc_sync(port->dev, dev); + } + rcu_read_unlock(); +} + +static int team_set_mac_address(struct net_device *dev, void *p) +{ + struct team *team = netdev_priv(dev); + struct team_port *port; + struct sockaddr *addr = p; + + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + rcu_read_lock(); + list_for_each_entry_rcu(port, &team->port_list, list) + if (team->ops.port_change_mac) + team->ops.port_change_mac(team, port); + rcu_read_unlock(); + return 0; +} + +static int team_change_mtu(struct net_device *dev, int new_mtu) +{ + struct team *team = netdev_priv(dev); + struct team_port *port; + int err; + + /* + * Alhough this is reader, it's guarded by team lock. It's not possible + * to traverse list in reverse under rcu_read_lock + */ + spin_lock(&team->lock); + list_for_each_entry(port, &team->port_list, list) { + err = dev_set_mtu(port->dev, new_mtu); + if (err) { + netdev_err(dev, "Device %s failed to change mtu", + port->dev->name); + goto unwind; + } + } + spin_unlock(&team->lock); + + dev->mtu = new_mtu; + + return 0; + +unwind: + list_for_each_entry_continue_reverse(port, &team->port_list, list) + dev_set_mtu(port->dev, dev->mtu); + spin_unlock(&team->lock); + + return err; +} + +static struct rtnl_link_stats64 * +team_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) +{ + struct team *team = netdev_priv(dev); + struct team_pcpu_stats *p; + u64 rx_packets, rx_bytes, rx_multicast, tx_packets, tx_bytes; + u32 rx_dropped = 0, tx_dropped = 0; + unsigned int start; + int i; + + for_each_possible_cpu(i) { + p = per_cpu_ptr(team->pcpu_stats, i); + do { + start = u64_stats_fetch_begin_bh(&p->syncp); + rx_packets = p->rx_packets; + rx_bytes = p->rx_bytes; + rx_multicast = p->rx_multicast; + tx_packets = p->tx_packets; + tx_bytes = p->tx_bytes; + } while (u64_stats_fetch_retry_bh(&p->syncp, start)); + + stats->rx_packets += rx_packets; + stats->rx_bytes += rx_bytes; + stats->multicast += rx_multicast; + stats->tx_packets += tx_packets; + stats->tx_bytes += tx_bytes; + /* + * rx_dropped & tx_dropped are u32, updated + * without syncp protection. + */ + rx_dropped += p->rx_dropped; + tx_dropped += p->tx_dropped; + } + stats->rx_dropped = rx_dropped; + stats->tx_dropped = tx_dropped; + return stats; +} + +static void team_vlan_rx_add_vid(struct net_device *dev, uint16_t vid) +{ + struct team *team = netdev_priv(dev); + struct team_port *port; + + rcu_read_lock(); + list_for_each_entry_rcu(port, &team->port_list, list) { + const struct net_device_ops *ops = port->dev->netdev_ops; + + if (ops->ndo_vlan_rx_add_vid) + ops->ndo_vlan_rx_add_vid(port->dev, vid); + } + rcu_read_unlock(); +} + +static void team_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid) +{ + struct team *team = netdev_priv(dev); + struct team_port *port; + + rcu_read_lock(); + list_for_each_entry_rcu(port, &team->port_list, list) { + const struct net_device_ops *ops = port->dev->netdev_ops; + + if (ops->ndo_vlan_rx_kill_vid) + ops->ndo_vlan_rx_kill_vid(port->dev, vid); + } + rcu_read_unlock(); +} + +static int team_add_slave(struct net_device *dev, struct net_device *port_dev) +{ + struct team *team = netdev_priv(dev); + int err; + + spin_lock(&team->lock); + err = team_port_add(team, port_dev); + spin_unlock(&team->lock); + return err; +} + +static int team_del_slave(struct net_device *dev, struct net_device *port_dev) +{ + struct team *team = netdev_priv(dev); + int err; + + spin_lock(&team->lock); + err = team_port_del(team, port_dev); + spin_unlock(&team->lock); + return err; +} + +static const struct net_device_ops team_netdev_ops = { + .ndo_init = team_init, + .ndo_uninit = team_uninit, + .ndo_open = team_open, + .ndo_stop = team_close, + .ndo_start_xmit = team_xmit, + .ndo_change_rx_flags = team_change_rx_flags, + .ndo_set_rx_mode = team_set_rx_mode, + .ndo_set_mac_address = team_set_mac_address, + .ndo_change_mtu = team_change_mtu, + .ndo_get_stats64 = team_get_stats64, + .ndo_vlan_rx_add_vid = team_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = team_vlan_rx_kill_vid, + .ndo_add_slave = team_add_slave, + .ndo_del_slave = team_del_slave, +}; + + +/*********************** + * rt netlink interface + ***********************/ + +static void team_setup(struct net_device *dev) +{ + ether_setup(dev); + + dev->netdev_ops = &team_netdev_ops; + dev->destructor = team_destructor; + dev->tx_queue_len = 0; + dev->flags |= IFF_MULTICAST; + dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); + + /* + * Indicate we support unicast address filtering. That way core won't + * bring us to promisc mode in case a unicast addr is added. + * Let this up to underlay drivers. + */ + dev->priv_flags |= IFF_UNICAST_FLT; + + dev->features |= NETIF_F_LLTX; + dev->features |= NETIF_F_GRO; + dev->hw_features = NETIF_F_HW_VLAN_TX | + NETIF_F_HW_VLAN_RX | + NETIF_F_HW_VLAN_FILTER; + + dev->features |= dev->hw_features; +} + +static int team_newlink(struct net *src_net, struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[]) +{ + int err; + + if (tb[IFLA_ADDRESS] == NULL) + random_ether_addr(dev->dev_addr); + + err = register_netdevice(dev); + if (err) + return err; + + return 0; +} + +static int team_validate(struct nlattr *tb[], struct nlattr *data[]) +{ + if (tb[IFLA_ADDRESS]) { + if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) + return -EINVAL; + if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) + return -EADDRNOTAVAIL; + } + return 0; +} + +static struct rtnl_link_ops team_link_ops __read_mostly = { + .kind = DRV_NAME, + .priv_size = sizeof(struct team), + .setup = team_setup, + .newlink = team_newlink, + .validate = team_validate, +}; + + +/*********************************** + * Generic netlink custom interface + ***********************************/ + +static struct genl_family team_nl_family = { + .id = GENL_ID_GENERATE, + .name = TEAM_GENL_NAME, + .version = TEAM_GENL_VERSION, + .maxattr = TEAM_ATTR_MAX, + .netnsok = true, +}; + +static const struct nla_policy team_nl_policy[TEAM_ATTR_MAX + 1] = { + [TEAM_ATTR_UNSPEC] = { .type = NLA_UNSPEC, }, + [TEAM_ATTR_TEAM_IFINDEX] = { .type = NLA_U32 }, + [TEAM_ATTR_LIST_OPTION] = { .type = NLA_NESTED }, + [TEAM_ATTR_LIST_PORT] = { .type = NLA_NESTED }, +}; + +static const struct nla_policy +team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = { + [TEAM_ATTR_OPTION_UNSPEC] = { .type = NLA_UNSPEC, }, + [TEAM_ATTR_OPTION_NAME] = { + .type = NLA_STRING, + .len = TEAM_STRING_MAX_LEN, + }, + [TEAM_ATTR_OPTION_CHANGED] = { .type = NLA_FLAG }, + [TEAM_ATTR_OPTION_TYPE] = { .type = NLA_U8 }, + [TEAM_ATTR_OPTION_DATA] = { + .type = NLA_BINARY, + .len = TEAM_STRING_MAX_LEN, + }, +}; + +static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info) +{ + struct sk_buff *msg; + void *hdr; + int err; + + msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, + &team_nl_family, 0, TEAM_CMD_NOOP); + if (IS_ERR(hdr)) { + err = PTR_ERR(hdr); + goto err_msg_put; + } + + genlmsg_end(msg, hdr); + + return genlmsg_unicast(genl_info_net(info), msg, info->snd_pid); + +err_msg_put: + nlmsg_free(msg); + + return err; +} + +/* + * Netlink cmd functions should be locked by following two functions. + * To ensure team_uninit would not be called in between, hold rcu_read_lock + * all the time. + */ +static struct team *team_nl_team_get(struct genl_info *info) +{ + struct net *net = genl_info_net(info); + int ifindex; + struct net_device *dev; + struct team *team; + + if (!info->attrs[TEAM_ATTR_TEAM_IFINDEX]) + return NULL; + + ifindex = nla_get_u32(info->attrs[TEAM_ATTR_TEAM_IFINDEX]); + rcu_read_lock(); + dev = dev_get_by_index_rcu(net, ifindex); + if (!dev || dev->netdev_ops != &team_netdev_ops) { + rcu_read_unlock(); + return NULL; + } + + team = netdev_priv(dev); + spin_lock(&team->lock); + return team; +} + +static void team_nl_team_put(struct team *team) +{ + spin_unlock(&team->lock); + rcu_read_unlock(); +} + +static int team_nl_send_generic(struct genl_info *info, struct team *team, + int (*fill_func)(struct sk_buff *skb, + struct genl_info *info, + int flags, struct team *team)) +{ + struct sk_buff *skb; + int err; + + skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + err = fill_func(skb, info, NLM_F_ACK, team); + if (err < 0) + goto err_fill; + + err = genlmsg_unicast(genl_info_net(info), skb, info->snd_pid); + return err; + +err_fill: + nlmsg_free(skb); + return err; +} + +static int team_nl_fill_options_get_changed(struct sk_buff *skb, + u32 pid, u32 seq, int flags, + struct team *team, + struct team_option *changed_option) +{ + struct nlattr *option_list; + void *hdr; + struct team_option *option; + + hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags, + TEAM_CMD_OPTIONS_GET); + if (IS_ERR(hdr)) + return PTR_ERR(hdr); + + NLA_PUT_U32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex); + option_list = nla_nest_start(skb, TEAM_ATTR_LIST_OPTION); + if (!option_list) + return -EMSGSIZE; + + list_for_each_entry(option, &team->option_list, list) { + struct nlattr *option_item; + long arg; + + option_item = nla_nest_start(skb, TEAM_ATTR_ITEM_OPTION); + if (!option_item) + goto nla_put_failure; + NLA_PUT_STRING(skb, TEAM_ATTR_OPTION_NAME, option->name); + if (option == changed_option) + NLA_PUT_FLAG(skb, TEAM_ATTR_OPTION_CHANGED); + switch (option->type) { + case TEAM_OPTION_TYPE_U32: + NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_U32); + team_option_get(team, option, &arg); + NLA_PUT_U32(skb, TEAM_ATTR_OPTION_DATA, arg); + break; + case TEAM_OPTION_TYPE_STRING: + NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_STRING); + team_option_get(team, option, &arg); + NLA_PUT_STRING(skb, TEAM_ATTR_OPTION_DATA, + (char *) arg); + break; + default: + BUG(); + } + nla_nest_end(skb, option_item); + } + + nla_nest_end(skb, option_list); + return genlmsg_end(skb, hdr); + +nla_put_failure: + genlmsg_cancel(skb, hdr); + return -EMSGSIZE; +} + +static int team_nl_fill_options_get(struct sk_buff *skb, + struct genl_info *info, int flags, + struct team *team) +{ + return team_nl_fill_options_get_changed(skb, info->snd_pid, + info->snd_seq, NLM_F_ACK, + team, NULL); +} + +static int team_nl_cmd_options_get(struct sk_buff *skb, struct genl_info *info) +{ + struct team *team; + int err; + + team = team_nl_team_get(info); + if (!team) + return -EINVAL; + + err = team_nl_send_generic(info, team, team_nl_fill_options_get); + + team_nl_team_put(team); + + return err; +} + +static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info) +{ + struct team *team; + int err = 0; + int i; + struct nlattr *nl_option; + + team = team_nl_team_get(info); + if (!team) + return -EINVAL; + + err = -EINVAL; + if (!info->attrs[TEAM_ATTR_LIST_OPTION]) { + err = -EINVAL; + goto team_put; + } + + nla_for_each_nested(nl_option, info->attrs[TEAM_ATTR_LIST_OPTION], i) { + struct nlattr *mode_attrs[TEAM_ATTR_OPTION_MAX + 1]; + enum team_option_type opt_type; + struct team_option *option; + char *opt_name; + bool opt_found = false; + + if (nla_type(nl_option) != TEAM_ATTR_ITEM_OPTION) { + err = -EINVAL; + goto team_put; + } + err = nla_parse_nested(mode_attrs, TEAM_ATTR_OPTION_MAX, + nl_option, team_nl_option_policy); + if (err) + goto team_put; + if (!mode_attrs[TEAM_ATTR_OPTION_NAME] || + !mode_attrs[TEAM_ATTR_OPTION_TYPE] || + !mode_attrs[TEAM_ATTR_OPTION_DATA]) { + err = -EINVAL; + goto team_put; + } + switch (nla_get_u8(mode_attrs[TEAM_ATTR_OPTION_TYPE])) { + case NLA_U32: + opt_type = TEAM_OPTION_TYPE_U32; + break; + case NLA_STRING: + opt_type = TEAM_OPTION_TYPE_STRING; + break; + default: + goto team_put; + } + + opt_name = nla_data(mode_attrs[TEAM_ATTR_OPTION_NAME]); + list_for_each_entry(option, &team->option_list, list) { + long arg; + struct nlattr *opt_data_attr; + + if (option->type != opt_type || + strcmp(option->name, opt_name)) + continue; + opt_found = true; + opt_data_attr = mode_attrs[TEAM_ATTR_OPTION_DATA]; + switch (opt_type) { + case TEAM_OPTION_TYPE_U32: + arg = nla_get_u32(opt_data_attr); + break; + case TEAM_OPTION_TYPE_STRING: + arg = (long) nla_data(opt_data_attr); + break; + default: + BUG(); + } + err = team_option_set(team, option, &arg); + if (err) + goto team_put; + } + if (!opt_found) { + err = -ENOENT; + goto team_put; + } + } + +team_put: + team_nl_team_put(team); + + return err; +} + +static int team_nl_fill_port_list_get_changed(struct sk_buff *skb, + u32 pid, u32 seq, int flags, + struct team *team, + struct team_port *changed_port) +{ + struct nlattr *port_list; + void *hdr; + struct team_port *port; + + hdr = genlmsg_put(skb, pid, seq, &team_nl_family, flags, + TEAM_CMD_PORT_LIST_GET); + if (IS_ERR(hdr)) + return PTR_ERR(hdr); + + NLA_PUT_U32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex); + port_list = nla_nest_start(skb, TEAM_ATTR_LIST_PORT); + if (!port_list) + return -EMSGSIZE; + + list_for_each_entry(port, &team->port_list, list) { + struct nlattr *port_item; + + port_item = nla_nest_start(skb, TEAM_ATTR_ITEM_PORT); + if (!port_item) + goto nla_put_failure; + NLA_PUT_U32(skb, TEAM_ATTR_PORT_IFINDEX, port->dev->ifindex); + if (port == changed_port) + NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_CHANGED); + if (port->linkup) + NLA_PUT_FLAG(skb, TEAM_ATTR_PORT_LINKUP); + NLA_PUT_U32(skb, TEAM_ATTR_PORT_SPEED, port->speed); + NLA_PUT_U8(skb, TEAM_ATTR_PORT_DUPLEX, port->duplex); + nla_nest_end(skb, port_item); + } + + nla_nest_end(skb, port_list); + return genlmsg_end(skb, hdr); + +nla_put_failure: + genlmsg_cancel(skb, hdr); + return -EMSGSIZE; +} + +static int team_nl_fill_port_list_get(struct sk_buff *skb, + struct genl_info *info, int flags, + struct team *team) +{ + return team_nl_fill_port_list_get_changed(skb, info->snd_pid, + info->snd_seq, NLM_F_ACK, + team, NULL); +} + +static int team_nl_cmd_port_list_get(struct sk_buff *skb, + struct genl_info *info) +{ + struct team *team; + int err; + + team = team_nl_team_get(info); + if (!team) + return -EINVAL; + + err = team_nl_send_generic(info, team, team_nl_fill_port_list_get); + + team_nl_team_put(team); + + return err; +} + +static struct genl_ops team_nl_ops[] = { + { + .cmd = TEAM_CMD_NOOP, + .doit = team_nl_cmd_noop, + .policy = team_nl_policy, + }, + { + .cmd = TEAM_CMD_OPTIONS_SET, + .doit = team_nl_cmd_options_set, + .policy = team_nl_policy, + .flags = GENL_ADMIN_PERM, + }, + { + .cmd = TEAM_CMD_OPTIONS_GET, + .doit = team_nl_cmd_options_get, + .policy = team_nl_policy, + .flags = GENL_ADMIN_PERM, + }, + { + .cmd = TEAM_CMD_PORT_LIST_GET, + .doit = team_nl_cmd_port_list_get, + .policy = team_nl_policy, + .flags = GENL_ADMIN_PERM, + }, +}; + +static struct genl_multicast_group team_change_event_mcgrp = { + .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, +}; + +static int team_nl_send_event_options_get(struct team *team, + struct team_option *changed_option) +{ + struct sk_buff *skb; + int err; + struct net *net = dev_net(team->dev); + + skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + err = team_nl_fill_options_get_changed(skb, 0, 0, 0, team, + changed_option); + if (err < 0) + goto err_fill; + + err = genlmsg_multicast_netns(net, skb, 0, team_change_event_mcgrp.id, + GFP_KERNEL); + return err; + +err_fill: + nlmsg_free(skb); + return err; +} + +static int team_nl_send_event_port_list_get(struct team_port *port) +{ + struct sk_buff *skb; + int err; + struct net *net = dev_net(port->team->dev); + + skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + err = team_nl_fill_port_list_get_changed(skb, 0, 0, 0, + port->team, port); + if (err < 0) + goto err_fill; + + err = genlmsg_multicast_netns(net, skb, 0, team_change_event_mcgrp.id, + GFP_KERNEL); + return err; + +err_fill: + nlmsg_free(skb); + return err; +} + +static int team_nl_init(void) +{ + int err; + + err = genl_register_family_with_ops(&team_nl_family, team_nl_ops, + ARRAY_SIZE(team_nl_ops)); + if (err) + return err; + + err = genl_register_mc_group(&team_nl_family, &team_change_event_mcgrp); + if (err) + goto err_change_event_grp_reg; + + return 0; + +err_change_event_grp_reg: + genl_unregister_family(&team_nl_family); + + return err; +} + +static void team_nl_fini(void) +{ + genl_unregister_family(&team_nl_family); +} + + +/****************** + * Change checkers + ******************/ + +static void __team_options_change_check(struct team *team, + struct team_option *changed_option) +{ + int err; + + err = team_nl_send_event_options_get(team, changed_option); + if (err) + netdev_warn(team->dev, "Failed to send options change via netlink\n"); +} + +/* rtnl lock is held */ +static void __team_port_change_check(struct team_port *port, bool linkup) +{ + int err; + + if (port->linkup == linkup) + return; + + port->linkup = linkup; + if (linkup) { + struct ethtool_cmd ecmd; + + err = __ethtool_get_settings(port->dev, &ecmd); + if (!err) { + port->speed = ethtool_cmd_speed(&ecmd); + port->duplex = ecmd.duplex; + goto send_event; + } + } + port->speed = 0; + port->duplex = 0; + +send_event: + err = team_nl_send_event_port_list_get(port); + if (err) + netdev_warn(port->team->dev, "Failed to send port change of device %s via netlink\n", + port->dev->name); + +} + +static void team_port_change_check(struct team_port *port, bool linkup) +{ + struct team *team = port->team; + + spin_lock(&team->lock); + __team_port_change_check(port, linkup); + spin_unlock(&team->lock); +} + +/************************************ + * Net device notifier event handler + ************************************/ + +static int team_device_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = (struct net_device *) ptr; + struct team_port *port; + + port = team_port_get_rtnl(dev); + if (!port) + return NOTIFY_DONE; + + switch (event) { + case NETDEV_UP: + if (netif_carrier_ok(dev)) + team_port_change_check(port, true); + case NETDEV_DOWN: + team_port_change_check(port, false); + case NETDEV_CHANGE: + if (netif_running(port->dev)) + team_port_change_check(port, + !!netif_carrier_ok(port->dev)); + break; + case NETDEV_UNREGISTER: + team_del_slave(port->team->dev, dev); + break; + case NETDEV_FEAT_CHANGE: + team_compute_features(port->team); + break; + case NETDEV_CHANGEMTU: + /* Forbid to change mtu of underlaying device */ + return NOTIFY_BAD; + case NETDEV_PRE_TYPE_CHANGE: + /* Forbid to change type of underlaying device */ + return NOTIFY_BAD; + } + return NOTIFY_DONE; +} + +static struct notifier_block team_notifier_block __read_mostly = { + .notifier_call = team_device_event, +}; + + +/*********************** + * Module init and exit + ***********************/ + +static int __init team_module_init(void) +{ + int err; + + register_netdevice_notifier(&team_notifier_block); + + err = rtnl_link_register(&team_link_ops); + if (err) + goto err_rtnl_reg; + + err = team_nl_init(); + if (err) + goto err_nl_init; + + return 0; + +err_nl_init: + rtnl_link_unregister(&team_link_ops); + +err_rtnl_reg: + unregister_netdevice_notifier(&team_notifier_block); + + return err; +} + +static void __exit team_module_exit(void) +{ + team_nl_fini(); + rtnl_link_unregister(&team_link_ops); + unregister_netdevice_notifier(&team_notifier_block); +} + +module_init(team_module_init); +module_exit(team_module_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Jiri Pirko "); +MODULE_DESCRIPTION("Ethernet team device driver"); +MODULE_ALIAS_RTNL_LINK(DRV_NAME); diff --git a/drivers/net/team/team_mode_activebackup.c b/drivers/net/team/team_mode_activebackup.c new file mode 100644 index 0000000..6fe920c --- /dev/null +++ b/drivers/net/team/team_mode_activebackup.c @@ -0,0 +1,137 @@ +/* + * net/drivers/team/team_mode_activebackup.c - Active-backup mode for team + * Copyright (c) 2011 Jiri Pirko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct ab_priv { + struct team_port __rcu *active_port; +}; + +static struct ab_priv *ab_priv(struct team *team) +{ + return (struct ab_priv *) &team->mode_priv; +} + +static rx_handler_result_t ab_receive(struct team *team, struct team_port *port, + struct sk_buff *skb) { + struct team_port *active_port; + + active_port = rcu_dereference(ab_priv(team)->active_port); + if (active_port != port) + return RX_HANDLER_EXACT; + return RX_HANDLER_ANOTHER; +} + +static bool ab_transmit(struct team *team, struct sk_buff *skb) +{ + struct team_port *active_port; + + active_port = rcu_dereference(ab_priv(team)->active_port); + if (unlikely(!active_port)) + goto drop; + skb->dev = active_port->dev; + if (dev_queue_xmit(skb)) + return false; + return true; + +drop: + dev_kfree_skb_any(skb); + return false; +} + +static void ab_port_leave(struct team *team, struct team_port *port) +{ + if (ab_priv(team)->active_port == port) + rcu_assign_pointer(ab_priv(team)->active_port, NULL); +} + +static int ab_active_port_get(struct team *team, void *arg) +{ + u32 *ifindex = arg; + + *ifindex = 0; + if (ab_priv(team)->active_port) + *ifindex = ab_priv(team)->active_port->dev->ifindex; + return 0; +} + +static int ab_active_port_set(struct team *team, void *arg) +{ + u32 *ifindex = arg; + struct team_port *port; + + list_for_each_entry_rcu(port, &team->port_list, list) { + if (port->dev->ifindex == *ifindex) { + rcu_assign_pointer(ab_priv(team)->active_port, port); + return 0; + } + } + return -ENOENT; +} + +static struct team_option ab_options[] = { + { + .name = "activeport", + .type = TEAM_OPTION_TYPE_U32, + .getter = ab_active_port_get, + .setter = ab_active_port_set, + }, +}; + +int ab_init(struct team *team) +{ + team_options_register(team, ab_options, ARRAY_SIZE(ab_options)); + return 0; +} + +void ab_exit(struct team *team) +{ + team_options_unregister(team, ab_options, ARRAY_SIZE(ab_options)); +} + +static const struct team_mode_ops ab_mode_ops = { + .init = ab_init, + .exit = ab_exit, + .receive = ab_receive, + .transmit = ab_transmit, + .port_leave = ab_port_leave, +}; + +static struct team_mode ab_mode = { + .kind = "activebackup", + .owner = THIS_MODULE, + .priv_size = sizeof(struct ab_priv), + .ops = &ab_mode_ops, +}; + +static int __init ab_init_module(void) +{ + return team_mode_register(&ab_mode); +} + +static void __exit ab_cleanup_module(void) +{ + team_mode_unregister(&ab_mode); +} + +module_init(ab_init_module); +module_exit(ab_cleanup_module); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Jiri Pirko "); +MODULE_DESCRIPTION("Active-backup mode for team"); +MODULE_ALIAS("team-mode-activebackup"); diff --git a/drivers/net/team/team_mode_roundrobin.c b/drivers/net/team/team_mode_roundrobin.c new file mode 100644 index 0000000..a0e8f80 --- /dev/null +++ b/drivers/net/team/team_mode_roundrobin.c @@ -0,0 +1,107 @@ +/* + * net/drivers/team/team_mode_roundrobin.c - Round-robin mode for team + * Copyright (c) 2011 Jiri Pirko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct rr_priv { + unsigned int sent_packets; +}; + +static struct rr_priv *rr_priv(struct team *team) +{ + return (struct rr_priv *) &team->mode_priv; +} + +static struct team_port *__get_first_port_up(struct team *team, + struct team_port *port) +{ + struct team_port *cur; + + if (port->linkup) + return port; + cur = port; + list_for_each_entry_continue_rcu(cur, &team->port_list, list) + if (cur->linkup) + return cur; + list_for_each_entry_rcu(cur, &team->port_list, list) { + if (cur == port) + break; + if (cur->linkup) + return cur; + } + return NULL; +} + +static bool rr_transmit(struct team *team, struct sk_buff *skb) +{ + struct team_port *port; + int port_index; + + port_index = rr_priv(team)->sent_packets++ % team->port_count; + port = team_get_port_by_index_rcu(team, port_index); + port = __get_first_port_up(team, port); + if (unlikely(!port)) + goto drop; + skb->dev = port->dev; + if (dev_queue_xmit(skb)) + return false; + return true; + +drop: + dev_kfree_skb_any(skb); + return false; +} + +static int rr_port_enter(struct team *team, struct team_port *port) +{ + return team_port_set_team_mac(port); +} + +static void rr_port_change_mac(struct team *team, struct team_port *port) +{ + team_port_set_team_mac(port); +} + +static const struct team_mode_ops rr_mode_ops = { + .transmit = rr_transmit, + .port_enter = rr_port_enter, + .port_change_mac = rr_port_change_mac, +}; + +static struct team_mode rr_mode = { + .kind = "roundrobin", + .owner = THIS_MODULE, + .priv_size = sizeof(struct rr_priv), + .ops = &rr_mode_ops, +}; + +static int __init rr_init_module(void) +{ + return team_mode_register(&rr_mode); +} + +static void __exit rr_cleanup_module(void) +{ + team_mode_unregister(&rr_mode); +} + +module_init(rr_init_module); +module_exit(rr_cleanup_module); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Jiri Pirko "); +MODULE_DESCRIPTION("Round-robin mode for team"); +MODULE_ALIAS("team-mode-roundrobin"); diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 619b565..0b091b3 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -185,6 +185,7 @@ header-y += if_pppol2tp.h header-y += if_pppox.h header-y += if_slip.h header-y += if_strip.h +header-y += if_team.h header-y += if_tr.h header-y += if_tun.h header-y += if_tunnel.h diff --git a/include/linux/if.h b/include/linux/if.h index db20bd4..06b6ef6 100644 --- a/include/linux/if.h +++ b/include/linux/if.h @@ -79,6 +79,7 @@ #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing * skbs on transmit */ #define IFF_UNICAST_FLT 0x20000 /* Supports unicast filtering */ +#define IFF_TEAM_PORT 0x40000 /* device used as team port */ #define IF_GET_IFACE 0x0001 /* for querying only */ #define IF_GET_PROTO 0x0002 diff --git a/include/linux/if_team.h b/include/linux/if_team.h new file mode 100644 index 0000000..14f6388 --- /dev/null +++ b/include/linux/if_team.h @@ -0,0 +1,242 @@ +/* + * include/linux/if_team.h - Network team device driver header + * Copyright (c) 2011 Jiri Pirko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef _LINUX_IF_TEAM_H_ +#define _LINUX_IF_TEAM_H_ + +#ifdef __KERNEL__ + +struct team_pcpu_stats { + u64 rx_packets; + u64 rx_bytes; + u64 rx_multicast; + u64 tx_packets; + u64 tx_bytes; + struct u64_stats_sync syncp; + u32 rx_dropped; + u32 tx_dropped; +}; + +struct team; + +struct team_port { + struct net_device *dev; + struct hlist_node hlist; /* node in hash list */ + struct list_head list; /* node in ordinary list */ + struct team *team; + int index; + + /* + * A place for storing original values of the device before it + * become a port. + */ + struct { + unsigned char dev_addr[MAX_ADDR_LEN]; + unsigned int mtu; + } orig; + + bool linkup; + u32 speed; + u8 duplex; + + struct rcu_head rcu; +}; + +struct team_mode_ops { + int (*init)(struct team *team); + void (*exit)(struct team *team); + rx_handler_result_t (*receive)(struct team *team, + struct team_port *port, + struct sk_buff *skb); + bool (*transmit)(struct team *team, struct sk_buff *skb); + int (*port_enter)(struct team *team, struct team_port *port); + void (*port_leave)(struct team *team, struct team_port *port); + void (*port_change_mac)(struct team *team, struct team_port *port); +}; + +enum team_option_type { + TEAM_OPTION_TYPE_U32, + TEAM_OPTION_TYPE_STRING, +}; + +struct team_option { + struct list_head list; + const char *name; + enum team_option_type type; + int (*getter)(struct team *team, void *arg); + int (*setter)(struct team *team, void *arg); +}; + +struct team_mode { + struct list_head list; + const char *kind; + struct module *owner; + size_t priv_size; + const struct team_mode_ops *ops; +}; + +#define TEAM_PORT_HASHBITS 4 +#define TEAM_PORT_HASHENTRIES (1 << TEAM_PORT_HASHBITS) + +#define TEAM_MODE_PRIV_LONGS 4 +#define TEAM_MODE_PRIV_SIZE (sizeof(long) * TEAM_MODE_PRIV_LONGS) + +struct team { + struct net_device *dev; /* associated netdevice */ + struct team_pcpu_stats __percpu *pcpu_stats; + + spinlock_t lock; /* used for overall locking, e.g. port lists write */ + + /* + * port lists with port count + */ + int port_count; + struct hlist_head port_hlist[TEAM_PORT_HASHENTRIES]; + struct list_head port_list; + + struct list_head option_list; + + const struct team_mode *mode; + struct team_mode_ops ops; + long mode_priv[TEAM_MODE_PRIV_LONGS]; +}; + +static inline struct hlist_head *team_port_index_hash(struct team *team, + int port_index) +{ + return &team->port_hlist[port_index & (TEAM_PORT_HASHENTRIES - 1)]; +} + +static inline struct team_port *team_get_port_by_index(struct team *team, + int port_index) +{ + struct hlist_node *p; + struct team_port *port; + struct hlist_head *head = team_port_index_hash(team, port_index); + + hlist_for_each_entry(port, p, head, hlist) + if (port->index == port_index) + return port; + return NULL; +} +static inline struct team_port *team_get_port_by_index_rcu(struct team *team, + int port_index) +{ + struct hlist_node *p; + struct team_port *port; + struct hlist_head *head = team_port_index_hash(team, port_index); + + hlist_for_each_entry_rcu(port, p, head, hlist) + if (port->index == port_index) + return port; + return NULL; +} + +extern int team_port_set_team_mac(struct team_port *port); +extern void team_options_register(struct team *team, + struct team_option *option, + size_t option_count); +extern void team_options_unregister(struct team *team, + struct team_option *option, + size_t option_count); +extern int team_mode_register(struct team_mode *mode); +extern int team_mode_unregister(struct team_mode *mode); + +#endif /* __KERNEL__ */ + +#define TEAM_STRING_MAX_LEN 32 + +/********************************** + * NETLINK_GENERIC netlink family. + **********************************/ + +enum { + TEAM_CMD_NOOP, + TEAM_CMD_OPTIONS_SET, + TEAM_CMD_OPTIONS_GET, + TEAM_CMD_PORT_LIST_GET, + + __TEAM_CMD_MAX, + TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1), +}; + +enum { + TEAM_ATTR_UNSPEC, + TEAM_ATTR_TEAM_IFINDEX, /* u32 */ + TEAM_ATTR_LIST_OPTION, /* nest */ + TEAM_ATTR_LIST_PORT, /* nest */ + + __TEAM_ATTR_MAX, + TEAM_ATTR_MAX = __TEAM_ATTR_MAX - 1, +}; + +/* Nested layout of get/set msg: + * + * [TEAM_ATTR_LIST_OPTION] + * [TEAM_ATTR_ITEM_OPTION] + * [TEAM_ATTR_OPTION_*], ... + * [TEAM_ATTR_ITEM_OPTION] + * [TEAM_ATTR_OPTION_*], ... + * ... + * [TEAM_ATTR_LIST_PORT] + * [TEAM_ATTR_ITEM_PORT] + * [TEAM_ATTR_PORT_*], ... + * [TEAM_ATTR_ITEM_PORT] + * [TEAM_ATTR_PORT_*], ... + * ... + */ + +enum { + TEAM_ATTR_ITEM_OPTION_UNSPEC, + TEAM_ATTR_ITEM_OPTION, /* nest */ + + __TEAM_ATTR_ITEM_OPTION_MAX, + TEAM_ATTR_ITEM_OPTION_MAX = __TEAM_ATTR_ITEM_OPTION_MAX - 1, +}; + +enum { + TEAM_ATTR_OPTION_UNSPEC, + TEAM_ATTR_OPTION_NAME, /* string */ + TEAM_ATTR_OPTION_CHANGED, /* flag */ + TEAM_ATTR_OPTION_TYPE, /* u8 */ + TEAM_ATTR_OPTION_DATA, /* dynamic */ + + __TEAM_ATTR_OPTION_MAX, + TEAM_ATTR_OPTION_MAX = __TEAM_ATTR_OPTION_MAX - 1, +}; + +enum { + TEAM_ATTR_ITEM_PORT_UNSPEC, + TEAM_ATTR_ITEM_PORT, /* nest */ + + __TEAM_ATTR_ITEM_PORT_MAX, + TEAM_ATTR_ITEM_PORT_MAX = __TEAM_ATTR_ITEM_PORT_MAX - 1, +}; + +enum { + TEAM_ATTR_PORT_UNSPEC, + TEAM_ATTR_PORT_IFINDEX, /* u32 */ + TEAM_ATTR_PORT_CHANGED, /* flag */ + TEAM_ATTR_PORT_LINKUP, /* flag */ + TEAM_ATTR_PORT_SPEED, /* u32 */ + TEAM_ATTR_PORT_DUPLEX, /* u8 */ + + __TEAM_ATTR_PORT_MAX, + TEAM_ATTR_PORT_MAX = __TEAM_ATTR_PORT_MAX - 1, +}; + +/* + * NETLINK_GENERIC related info + */ +#define TEAM_GENL_NAME "team" +#define TEAM_GENL_VERSION 0x1 +#define TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME "change_event" + +#endif /* _LINUX_IF_TEAM_H_ */ -- cgit v0.10.2 From 2a24444f8f2bea694003e3eac5c2f8d9a386bdc5 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Sun, 13 Nov 2011 01:24:04 +0000 Subject: ipv6: reduce percpu needs for icmpv6msg mibs Reading /proc/net/snmp6 on a machine with a lot of cpus is very expensive (can be ~88000 us). This is because ICMPV6MSG MIB uses 4096 bytes per cpu, and folding values for all possible cpus can read 16 Mbytes of memory (32MBytes on non x86 arches) ICMP messages are not considered as fast path on a typical server, and eventually few cpus handle them anyway. We can afford an atomic operation instead of using percpu data. This saves 4096 bytes per cpu and per network namespace. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller diff --git a/include/net/ipv6.h b/include/net/ipv6.h index a366a8a..3f0258d 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -132,6 +132,15 @@ extern struct ctl_path net_ipv6_ctl_path[]; SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ }) +/* per device and per net counters are atomic_long_t */ +#define _DEVINC_ATOMIC_ATOMIC(net, statname, idev, field) \ +({ \ + struct inet6_dev *_idev = (idev); \ + if (likely(_idev != NULL)) \ + SNMP_INC_STATS_ATOMIC_LONG((_idev)->stats.statname##dev, (field)); \ + SNMP_INC_STATS_ATOMIC_LONG((net)->mib.statname##_statistics, (field));\ +}) + #define _DEVADD(net, statname, modifier, idev, field, val) \ ({ \ struct inet6_dev *_idev = (idev); \ @@ -168,11 +177,11 @@ extern struct ctl_path net_ipv6_ctl_path[]; _DEVINCATOMIC(net, icmpv6, _BH, idev, field) #define ICMP6MSGOUT_INC_STATS(net, idev, field) \ - _DEVINCATOMIC(net, icmpv6msg, , idev, field +256) + _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field +256) #define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ - _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field +256) + _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field +256) #define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ - _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field) + _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field) struct ip6_ra_chain { struct ip6_ra_chain *next; diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h index f360135..30f6728 100644 --- a/include/net/netns/mib.h +++ b/include/net/netns/mib.h @@ -18,7 +18,7 @@ struct netns_mib { DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); - DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); + DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib, icmpv6msg_statistics); #endif #ifdef CONFIG_XFRM_STATISTICS DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); diff --git a/include/net/snmp.h b/include/net/snmp.h index 0feafa6..2f65e16 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -84,7 +84,7 @@ struct icmpv6_mib_device { #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX /* per network ns counters */ struct icmpv6msg_mib { - unsigned long mibs[ICMP6MSG_MIB_MAX]; + atomic_long_t mibs[ICMP6MSG_MIB_MAX]; }; /* per device counters, (shared on all cpus) */ struct icmpv6msg_mib_device { diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 1040424..282dc7a 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -985,9 +985,9 @@ static int __net_init ipv6_init_mibs(struct net *net) sizeof(struct icmpv6_mib), __alignof__(struct icmpv6_mib)) < 0) goto err_icmp_mib; - if (snmp_mib_init((void __percpu **)net->mib.icmpv6msg_statistics, - sizeof(struct icmpv6msg_mib), - __alignof__(struct icmpv6msg_mib)) < 0) + net->mib.icmpv6msg_statistics = kzalloc(sizeof(struct icmpv6msg_mib), + GFP_KERNEL); + if (!net->mib.icmpv6msg_statistics) goto err_icmpmsg_mib; return 0; @@ -1008,7 +1008,7 @@ static void ipv6_cleanup_mibs(struct net *net) snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6); snmp_mib_free((void __percpu **)net->mib.ipv6_statistics); snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics); - snmp_mib_free((void __percpu **)net->mib.icmpv6msg_statistics); + kfree(net->mib.icmpv6msg_statistics); } static int __net_init inet6_net_init(struct net *net) diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 1008ce9..fdeb6d0 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c @@ -142,11 +142,7 @@ static const struct snmp_mib snmp6_udplite6_list[] = { SNMP_MIB_SENTINEL }; -/* can be called either with percpu mib (pcpumib != NULL), - * or shared one (smib != NULL) - */ -static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void __percpu **pcpumib, - atomic_long_t *smib) +static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, atomic_long_t *smib) { char name[32]; int i; @@ -163,14 +159,14 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void __percpu **pcpum snprintf(name, sizeof(name), "Icmp6%s%s", i & 0x100 ? "Out" : "In", p); seq_printf(seq, "%-32s\t%lu\n", name, - pcpumib ? snmp_fold_field(pcpumib, i) : atomic_long_read(smib + i)); + atomic_long_read(smib + i)); } /* print by number (nonzero only) - ICMPMsgStat format */ for (i = 0; i < ICMP6MSG_MIB_MAX; i++) { unsigned long val; - val = pcpumib ? snmp_fold_field(pcpumib, i) : atomic_long_read(smib + i); + val = atomic_long_read(smib + i); if (!val) continue; snprintf(name, sizeof(name), "Icmp6%sType%u", @@ -215,8 +211,7 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp)); snmp6_seq_show_item(seq, (void __percpu **)net->mib.icmpv6_statistics, NULL, snmp6_icmp6_list); - snmp6_seq_show_icmpv6msg(seq, - (void __percpu **)net->mib.icmpv6msg_statistics, NULL); + snmp6_seq_show_icmpv6msg(seq, net->mib.icmpv6msg_statistics->mibs); snmp6_seq_show_item(seq, (void __percpu **)net->mib.udp_stats_in6, NULL, snmp6_udp6_list); snmp6_seq_show_item(seq, (void __percpu **)net->mib.udplite_stats_in6, @@ -246,7 +241,7 @@ static int snmp6_dev_seq_show(struct seq_file *seq, void *v) snmp6_ipstats_list); snmp6_seq_show_item(seq, NULL, idev->stats.icmpv6dev->mibs, snmp6_icmp6_list); - snmp6_seq_show_icmpv6msg(seq, NULL, idev->stats.icmpv6msgdev->mibs); + snmp6_seq_show_icmpv6msg(seq, idev->stats.icmpv6msgdev->mibs); return 0; } -- cgit v0.10.2 From 719269afbc69ab96339aad6c2d3b32f7d8311146 Mon Sep 17 00:00:00 2001 From: "alex.bluesman.smirnov@gmail.com" Date: Thu, 10 Nov 2011 07:38:38 +0000 Subject: 6LoWPAN: add fragmentation support This patch adds support for frame fragmentation. Signed-off-by: Alexander Smirnov Signed-off-by: David S. Miller diff --git a/include/net/ieee802154.h b/include/net/ieee802154.h index d52685d..ee59f8b 100644 --- a/include/net/ieee802154.h +++ b/include/net/ieee802154.h @@ -21,11 +21,14 @@ * Maxim Gorbachyov * Maxim Osipov * Dmitry Eremin-Solenikov + * Alexander Smirnov */ #ifndef NET_IEEE802154_H #define NET_IEEE802154_H +#define IEEE802154_MTU 127 + #define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */ #define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */ #define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */ @@ -56,6 +59,9 @@ (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT) +/* MAC footer size */ +#define IEEE802154_MFR_SIZE 2 /* 2 octets */ + /* MAC's Command Frames Identifiers */ #define IEEE802154_CMD_ASSOCIATION_REQ 0x01 #define IEEE802154_CMD_ASSOCIATION_RESP 0x02 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 19d6aef..7d4cb58 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -113,6 +113,20 @@ struct lowpan_dev_record { struct list_head list; }; +struct lowpan_fragment { + struct sk_buff *skb; /* skb to be assembled */ + spinlock_t lock; /* concurency lock */ + u16 length; /* length to be assemled */ + u32 bytes_rcv; /* bytes received */ + u16 tag; /* current fragment tag */ + struct timer_list timer; /* assembling timer */ + struct list_head list; /* fragments list */ +}; + +static unsigned short fragment_tag; +static LIST_HEAD(lowpan_fragments); +spinlock_t flist_lock; + static inline struct lowpan_dev_info *lowpan_dev_info(const struct net_device *dev) { @@ -244,6 +258,17 @@ static u8 lowpan_fetch_skb_u8(struct sk_buff *skb) return ret; } +static u16 lowpan_fetch_skb_u16(struct sk_buff *skb) +{ + u16 ret; + + BUG_ON(!pskb_may_pull(skb, 2)); + + ret = skb->data[0] | (skb->data[1] << 8); + skb_pull(skb, 2); + return ret; +} + static int lowpan_header_create(struct sk_buff *skb, struct net_device *dev, unsigned short type, const void *_daddr, @@ -467,6 +492,7 @@ static int lowpan_header_create(struct sk_buff *skb, memcpy(&(sa.hwaddr), saddr, 8); mac_cb(skb)->flags = IEEE802154_FC_TYPE_DATA; + return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev, type, (void *)&da, (void *)&sa, skb->len); } @@ -511,6 +537,21 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr) return stat; } +static void lowpan_fragment_timer_expired(unsigned long entry_addr) +{ + struct lowpan_fragment *entry = (struct lowpan_fragment *)entry_addr; + + pr_debug("%s: timer expired for frame with tag %d\n", __func__, + entry->tag); + + spin_lock(&flist_lock); + list_del(&entry->list); + spin_unlock(&flist_lock); + + dev_kfree_skb(entry->skb); + kfree(entry); +} + static int lowpan_process_data(struct sk_buff *skb) { @@ -525,6 +566,107 @@ lowpan_process_data(struct sk_buff *skb) if (skb->len < 2) goto drop; iphc0 = lowpan_fetch_skb_u8(skb); + + /* fragments assembling */ + switch (iphc0 & LOWPAN_DISPATCH_MASK) { + case LOWPAN_DISPATCH_FRAG1: + case LOWPAN_DISPATCH_FRAGN: + { + struct lowpan_fragment *frame; + u8 len, offset; + u16 tag; + bool found = false; + + len = lowpan_fetch_skb_u8(skb); /* frame length */ + tag = lowpan_fetch_skb_u16(skb); + + /* + * check if frame assembling with the same tag is + * already in progress + */ + spin_lock(&flist_lock); + + list_for_each_entry(frame, &lowpan_fragments, list) + if (frame->tag == tag) { + found = true; + break; + } + + /* alloc new frame structure */ + if (!found) { + frame = kzalloc(sizeof(struct lowpan_fragment), + GFP_ATOMIC); + if (!frame) + goto unlock_and_drop; + + INIT_LIST_HEAD(&frame->list); + + frame->length = (iphc0 & 7) | (len << 3); + frame->tag = tag; + + /* allocate buffer for frame assembling */ + frame->skb = alloc_skb(frame->length + + sizeof(struct ipv6hdr), GFP_ATOMIC); + + if (!frame->skb) { + kfree(frame); + goto unlock_and_drop; + } + + frame->skb->priority = skb->priority; + frame->skb->dev = skb->dev; + + /* reserve headroom for uncompressed ipv6 header */ + skb_reserve(frame->skb, sizeof(struct ipv6hdr)); + skb_put(frame->skb, frame->length); + + init_timer(&frame->timer); + /* time out is the same as for ipv6 - 60 sec */ + frame->timer.expires = jiffies + LOWPAN_FRAG_TIMEOUT; + frame->timer.data = (unsigned long)frame; + frame->timer.function = lowpan_fragment_timer_expired; + + add_timer(&frame->timer); + + list_add_tail(&frame->list, &lowpan_fragments); + } + + if ((iphc0 & LOWPAN_DISPATCH_MASK) == LOWPAN_DISPATCH_FRAG1) + goto unlock_and_drop; + + offset = lowpan_fetch_skb_u8(skb); /* fetch offset */ + + /* if payload fits buffer, copy it */ + if (likely((offset * 8 + skb->len) <= frame->length)) + skb_copy_to_linear_data_offset(frame->skb, offset * 8, + skb->data, skb->len); + else + goto unlock_and_drop; + + frame->bytes_rcv += skb->len; + + /* frame assembling complete */ + if ((frame->bytes_rcv == frame->length) && + frame->timer.expires > jiffies) { + /* if timer haven't expired - first of all delete it */ + del_timer(&frame->timer); + list_del(&frame->list); + spin_unlock(&flist_lock); + + dev_kfree_skb(skb); + skb = frame->skb; + kfree(frame); + iphc0 = lowpan_fetch_skb_u8(skb); + break; + } + spin_unlock(&flist_lock); + + return kfree_skb(skb), 0; + } + default: + break; + } + iphc1 = lowpan_fetch_skb_u8(skb); _saddr = mac_cb(skb)->sa.hwaddr; @@ -674,6 +816,9 @@ lowpan_process_data(struct sk_buff *skb) lowpan_raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, sizeof(hdr)); return lowpan_skb_deliver(skb, &hdr); + +unlock_and_drop: + spin_unlock(&flist_lock); drop: kfree_skb(skb); return -EINVAL; @@ -692,18 +837,118 @@ static int lowpan_set_address(struct net_device *dev, void *p) return 0; } +static int lowpan_get_mac_header_length(struct sk_buff *skb) +{ + /* + * Currently long addressing mode is supported only, so the overall + * header size is 21: + * FC SeqNum DPAN DA SA Sec + * 2 + 1 + 2 + 8 + 8 + 0 = 21 + */ + return 21; +} + +static int +lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, + int mlen, int plen, int offset) +{ + struct sk_buff *frag; + int hlen, ret; + + /* if payload length is zero, therefore it's a first fragment */ + hlen = (plen == 0 ? LOWPAN_FRAG1_HEAD_SIZE : LOWPAN_FRAGN_HEAD_SIZE); + + lowpan_raw_dump_inline(__func__, "6lowpan fragment header", head, hlen); + + frag = dev_alloc_skb(hlen + mlen + plen + IEEE802154_MFR_SIZE); + if (!frag) + return -ENOMEM; + + frag->priority = skb->priority; + frag->dev = skb->dev; + + /* copy header, MFR and payload */ + memcpy(skb_put(frag, mlen), skb->data, mlen); + memcpy(skb_put(frag, hlen), head, hlen); + + if (plen) + skb_copy_from_linear_data_offset(skb, offset + mlen, + skb_put(frag, plen), plen); + + lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data, + frag->len); + + ret = dev_queue_xmit(frag); + + if (ret < 0) + dev_kfree_skb(frag); + + return ret; +} + +static int +lowpan_skb_fragmentation(struct sk_buff *skb) +{ + int err, header_length, payload_length, tag, offset = 0; + u8 head[5]; + + header_length = lowpan_get_mac_header_length(skb); + payload_length = skb->len - header_length; + tag = fragment_tag++; + + /* first fragment header */ + head[0] = LOWPAN_DISPATCH_FRAG1 | (payload_length & 0x7); + head[1] = (payload_length >> 3) & 0xff; + head[2] = tag & 0xff; + head[3] = tag >> 8; + + err = lowpan_fragment_xmit(skb, head, header_length, 0, 0); + + /* next fragment header */ + head[0] &= ~LOWPAN_DISPATCH_FRAG1; + head[0] |= LOWPAN_DISPATCH_FRAGN; + + while ((payload_length - offset > 0) && (err >= 0)) { + int len = LOWPAN_FRAG_SIZE; + + head[4] = offset / 8; + + if (payload_length - offset < len) + len = payload_length - offset; + + err = lowpan_fragment_xmit(skb, head, header_length, + len, offset); + offset += len; + } + + return err; +} + static netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev) { - int err = 0; + int err = -1; pr_debug("(%s): package xmit\n", __func__); skb->dev = lowpan_dev_info(dev)->real_dev; if (skb->dev == NULL) { pr_debug("(%s) ERROR: no real wpan device found\n", __func__); - dev_kfree_skb(skb); - } else + goto error; + } + + if (skb->len <= IEEE802154_MTU) { err = dev_queue_xmit(skb); + goto out; + } + + pr_debug("(%s): frame is too big, fragmentation is needed\n", + __func__); + err = lowpan_skb_fragmentation(skb); +error: + dev_kfree_skb(skb); +out: + if (err < 0) + pr_debug("(%s): ERROR: xmit failed\n", __func__); return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK); } @@ -765,8 +1010,15 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, goto drop; /* check that it's our buffer */ - if ((skb->data[0] & 0xe0) == 0x60) + switch (skb->data[0] & 0xe0) { + case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */ + case LOWPAN_DISPATCH_FRAG1: /* first fragment header */ + case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */ lowpan_process_data(skb); + break; + default: + break; + } return NET_RX_SUCCESS; diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h index 5d8cf80..5d2e5a0 100644 --- a/net/ieee802154/6lowpan.h +++ b/net/ieee802154/6lowpan.h @@ -159,6 +159,24 @@ #define LOWPAN_DISPATCH_FRAG1 0xc0 /* 11000xxx */ #define LOWPAN_DISPATCH_FRAGN 0xe0 /* 11100xxx */ +#define LOWPAN_DISPATCH_MASK 0xf8 /* 11111000 */ + +#define LOWPAN_FRAG_TIMEOUT (HZ * 60) /* time-out 60 sec */ + +#define LOWPAN_FRAG1_HEAD_SIZE 0x4 +#define LOWPAN_FRAGN_HEAD_SIZE 0x5 + +/* + * According IEEE802.15.4 standard: + * - MTU is 127 octets + * - maximum MHR size is 37 octets + * - MFR size is 2 octets + * + * so minimal payload size that we may guarantee is: + * MTU - MHR - MFR = 88 octets + */ +#define LOWPAN_FRAG_SIZE 88 + /* * Values of fields within the IPHC encoding first byte * (C stands for compressed and I for inline) -- cgit v0.10.2 From e86586ba8c570591372bc6cd0435a9bc1364c6d5 Mon Sep 17 00:00:00 2001 From: "alex.bluesman.smirnov@gmail.com" Date: Thu, 10 Nov 2011 07:39:15 +0000 Subject: 6LoWPAN: disable debugging by default This patch disables debug output enabled by default. Signed-off-by: Alexander Smirnov Acked-by: Dmitry Eremin-Solenikov Signed-off-by: David S. Miller diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 7d4cb58..af5553e 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -50,8 +50,6 @@ * SUCH DAMAGE. */ -#define DEBUG - #include #include #include -- cgit v0.10.2 From 4d039f684314b707fdae3c7262faf4a80c548194 Mon Sep 17 00:00:00 2001 From: "alex.bluesman.smirnov@gmail.com" Date: Thu, 10 Nov 2011 07:39:37 +0000 Subject: 6LoWPAN: set proper netdev flags This patch fixes settings for device initialization which makes possible to use NDISC and TCP. Signed-off-by: Alexander Smirnov Acked-by: Dmitry Eremin-Solenikov Signed-off-by: David S. Miller diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index af5553e..39ec6e0 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -973,13 +973,12 @@ static void lowpan_setup(struct net_device *dev) dev->addr_len = IEEE802154_ADDR_LEN; memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN); dev->type = ARPHRD_IEEE802154; - dev->features = NETIF_F_NO_CSUM; /* Frame Control + Sequence Number + Address fields + Security Header */ dev->hard_header_len = 2 + 1 + 20 + 14; dev->needed_tailroom = 2; /* FCS */ dev->mtu = 1281; dev->tx_queue_len = 0; - dev->flags = IFF_NOARP | IFF_BROADCAST; + dev->flags = IFF_BROADCAST | IFF_MULTICAST; dev->watchdog_timeo = 0; dev->netdev_ops = &lowpan_netdev_ops; -- cgit v0.10.2 From 3bd5b958c2a2dd1a9b4c8d21e75fb47b062fc941 Mon Sep 17 00:00:00 2001 From: "alex.bluesman.smirnov@gmail.com" Date: Thu, 10 Nov 2011 07:40:14 +0000 Subject: 6LoWPAN: UDP header compression This patch adds support for UDP header compression. Derived from Contiki OS. Signed-off-by: Alexander Smirnov Signed-off-by: David S. Miller diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 39ec6e0..9bf82d7 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -246,6 +246,50 @@ lowpan_uncompress_addr(struct sk_buff *skb, struct in6_addr *ipaddr, return 0; } +static void +lowpan_compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb) +{ + struct udphdr *uh = udp_hdr(skb); + + pr_debug("(%s): UDP header compression\n", __func__); + + if (((uh->source & LOWPAN_NHC_UDP_4BIT_MASK) == + LOWPAN_NHC_UDP_4BIT_PORT) && + ((uh->dest & LOWPAN_NHC_UDP_4BIT_MASK) == + LOWPAN_NHC_UDP_4BIT_PORT)) { + pr_debug("(%s): both ports compression to 4 bits\n", __func__); + **hc06_ptr = LOWPAN_NHC_UDP_CS_P_11; + **(hc06_ptr + 1) = /* subtraction is faster */ + (u8)((uh->dest - LOWPAN_NHC_UDP_4BIT_PORT) + + ((uh->source & LOWPAN_NHC_UDP_4BIT_PORT) << 4)); + *hc06_ptr += 2; + } else if ((uh->dest & LOWPAN_NHC_UDP_8BIT_MASK) == + LOWPAN_NHC_UDP_8BIT_PORT) { + pr_debug("(%s): remove 8 bits of dest\n", __func__); + **hc06_ptr = LOWPAN_NHC_UDP_CS_P_01; + memcpy(*hc06_ptr + 1, &uh->source, 2); + **(hc06_ptr + 3) = (u8)(uh->dest - LOWPAN_NHC_UDP_8BIT_PORT); + *hc06_ptr += 4; + } else if ((uh->source & LOWPAN_NHC_UDP_8BIT_MASK) == + LOWPAN_NHC_UDP_8BIT_PORT) { + pr_debug("(%s): remove 8 bits of source\n", __func__); + **hc06_ptr = LOWPAN_NHC_UDP_CS_P_10; + memcpy(*hc06_ptr + 1, &uh->dest, 2); + **(hc06_ptr + 3) = (u8)(uh->source - LOWPAN_NHC_UDP_8BIT_PORT); + *hc06_ptr += 4; + } else { + pr_debug("(%s): can't compress header\n", __func__); + **hc06_ptr = LOWPAN_NHC_UDP_CS_P_00; + memcpy(*hc06_ptr + 1, &uh->source, 2); + memcpy(*hc06_ptr + 3, &uh->dest, 2); + *hc06_ptr += 5; + } + + /* checksum is always inline */ + memcpy(*hc06_ptr, &uh->check, 2); + *hc06_ptr += 2; +} + static u8 lowpan_fetch_skb_u8(struct sk_buff *skb) { u8 ret; @@ -365,8 +409,6 @@ static int lowpan_header_create(struct sk_buff *skb, if (hdr->nexthdr == UIP_PROTO_UDP) iphc0 |= LOWPAN_IPHC_NH_C; -/* TODO: next header compression */ - if ((iphc0 & LOWPAN_IPHC_NH_C) == 0) { *hc06_ptr = hdr->nexthdr; hc06_ptr += 1; @@ -454,8 +496,9 @@ static int lowpan_header_create(struct sk_buff *skb, } } - /* TODO: UDP header compression */ - /* TODO: Next Header compression */ + /* UDP header compression */ + if (hdr->nexthdr == UIP_PROTO_UDP) + lowpan_compress_udp_header(&hc06_ptr, skb); head[0] = iphc0; head[1] = iphc1; diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h index 5d2e5a0..aeff3f3 100644 --- a/net/ieee802154/6lowpan.h +++ b/net/ieee802154/6lowpan.h @@ -219,6 +219,11 @@ #define LOWPAN_NHC_UDP_CHECKSUMC 0x04 #define LOWPAN_NHC_UDP_CHECKSUMI 0x00 +#define LOWPAN_NHC_UDP_4BIT_PORT 0xF0B0 +#define LOWPAN_NHC_UDP_4BIT_MASK 0xFFF0 +#define LOWPAN_NHC_UDP_8BIT_PORT 0xF000 +#define LOWPAN_NHC_UDP_8BIT_MASK 0xFF00 + /* values for port compression, _with checksum_ ie bit 5 set to 0 */ #define LOWPAN_NHC_UDP_CS_P_00 0xF0 /* all inline */ #define LOWPAN_NHC_UDP_CS_P_01 0xF1 /* source 16bit inline, -- cgit v0.10.2 From f8b1b5d231c6db03f87e9db195530156fde47c4b Mon Sep 17 00:00:00 2001 From: "alex.bluesman.smirnov@gmail.com" Date: Thu, 10 Nov 2011 07:40:53 +0000 Subject: 6LoWPAN: UDP header decompression This patch provides possibility to decompress UDP headers. Derived from Contiki OS. Signed-off-by: Alexander Smirnov Signed-off-by: David S. Miller diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 9bf82d7..602f318 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -311,6 +311,62 @@ static u16 lowpan_fetch_skb_u16(struct sk_buff *skb) return ret; } +static int +lowpan_uncompress_udp_header(struct sk_buff *skb) +{ + struct udphdr *uh = udp_hdr(skb); + u8 tmp; + + tmp = lowpan_fetch_skb_u8(skb); + + if ((tmp & LOWPAN_NHC_UDP_MASK) == LOWPAN_NHC_UDP_ID) { + pr_debug("(%s): UDP header uncompression\n", __func__); + switch (tmp & LOWPAN_NHC_UDP_CS_P_11) { + case LOWPAN_NHC_UDP_CS_P_00: + memcpy(&uh->source, &skb->data[0], 2); + memcpy(&uh->dest, &skb->data[2], 2); + skb_pull(skb, 4); + break; + case LOWPAN_NHC_UDP_CS_P_01: + memcpy(&uh->source, &skb->data[0], 2); + uh->dest = + skb->data[2] + LOWPAN_NHC_UDP_8BIT_PORT; + skb_pull(skb, 3); + break; + case LOWPAN_NHC_UDP_CS_P_10: + uh->source = skb->data[0] + LOWPAN_NHC_UDP_8BIT_PORT; + memcpy(&uh->dest, &skb->data[1], 2); + skb_pull(skb, 3); + break; + case LOWPAN_NHC_UDP_CS_P_11: + uh->source = + LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] >> 4); + uh->dest = + LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] & 0x0f); + skb_pull(skb, 1); + break; + default: + pr_debug("(%s) ERROR: unknown UDP format\n", __func__); + goto err; + break; + } + + pr_debug("(%s): uncompressed UDP ports: src = %d, dst = %d\n", + __func__, uh->source, uh->dest); + + /* copy checksum */ + memcpy(&uh->check, &skb->data[0], 2); + skb_pull(skb, 2); + } else { + pr_debug("(%s): ERROR: unsupported NH format\n", __func__); + goto err; + } + + return 0; +err: + return -EINVAL; +} + static int lowpan_header_create(struct sk_buff *skb, struct net_device *dev, unsigned short type, const void *_daddr, @@ -842,7 +898,10 @@ lowpan_process_data(struct sk_buff *skb) goto drop; } - /* TODO: UDP header parse */ + /* UDP data uncompression */ + if (iphc0 & LOWPAN_IPHC_NH_C) + if (lowpan_uncompress_udp_header(skb)) + goto drop; /* Not fragmented package */ hdr.payload_len = htons(skb->len); -- cgit v0.10.2 From 63ce40e4fd7d68373127a51dd1facef07c93cf4a Mon Sep 17 00:00:00 2001 From: "alex.bluesman.smirnov@gmail.com" Date: Thu, 10 Nov 2011 07:41:11 +0000 Subject: 6LoWPAN: update documentation This patch adds chapter to documentation which describes how to use 6lowpan technology. Signed-off-by: Alexander Smirnov Signed-off-by: David S. Miller diff --git a/Documentation/networking/ieee802154.txt b/Documentation/networking/ieee802154.txt index f41ea24..1dc1c24 100644 --- a/Documentation/networking/ieee802154.txt +++ b/Documentation/networking/ieee802154.txt @@ -78,3 +78,30 @@ in software. This is currently WIP. See header include/net/mac802154.h and several drivers in drivers/ieee802154/. +6LoWPAN Linux implementation +============================ + +The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80 +octets of actual MAC payload once security is turned on, on a wireless link +with a link throughput of 250 kbps or less. The 6LoWPAN adaptation format +[RFC4944] was specified to carry IPv6 datagrams over such constrained links, +taking into account limited bandwidth, memory, or energy resources that are +expected in applications such as wireless Sensor Networks. [RFC4944] defines +a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header +to support the IPv6 minimum MTU requirement [RFC2460], and stateless header +compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the +relatively large IPv6 and UDP headers down to (in the best case) several bytes. + +In Semptember 2011 the standard update was published - [RFC6282]. +It deprecates HC1 and HC2 compression and defines IPHC encoding format which is +used in this Linux implementation. + +All the code related to 6lowpan you may find in files: net/ieee802154/6lowpan.* + +To setup 6lowpan interface you need (busybox release > 1.17.0): +1. Add IEEE802.15.4 interface and initialize PANid; +2. Add 6lowpan interface by command like: + # ip link add link wpan0 name lowpan0 type lowpan +3. Set MAC (if needs): + # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be +4. Bring up 'lowpan0' interface -- cgit v0.10.2 From e19df76a1113dc57cda696cd78d06f2834f6d6bb Mon Sep 17 00:00:00 2001 From: Sanjay Hortikar Date: Fri, 11 Nov 2011 16:11:21 +0000 Subject: net-forcedeth: Add internal loopback support for forcedeth NICs. Support enabling/disabling/querying internal loopback mode for forcedeth NICs using ethtool. Signed-off-by: Sanjay Hortikar Signed-off-by: Mahesh Bandewar Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index d24c45b..e8a5ae3 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -3003,6 +3003,73 @@ static void nv_update_pause(struct net_device *dev, u32 pause_flags) } } +static void nv_force_linkspeed(struct net_device *dev, int speed, int duplex) +{ + struct fe_priv *np = netdev_priv(dev); + u8 __iomem *base = get_hwbase(dev); + u32 phyreg, txreg; + int mii_status; + + np->linkspeed = NVREG_LINKSPEED_FORCE|speed; + np->duplex = duplex; + + /* see if gigabit phy */ + mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ); + if (mii_status & PHY_GIGABIT) { + np->gigabit = PHY_GIGABIT; + phyreg = readl(base + NvRegSlotTime); + phyreg &= ~(0x3FF00); + if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_10) + phyreg |= NVREG_SLOTTIME_10_100_FULL; + else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_100) + phyreg |= NVREG_SLOTTIME_10_100_FULL; + else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_1000) + phyreg |= NVREG_SLOTTIME_1000_FULL; + writel(phyreg, base + NvRegSlotTime); + } + + phyreg = readl(base + NvRegPhyInterface); + phyreg &= ~(PHY_HALF|PHY_100|PHY_1000); + if (np->duplex == 0) + phyreg |= PHY_HALF; + if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_100) + phyreg |= PHY_100; + else if ((np->linkspeed & NVREG_LINKSPEED_MASK) == + NVREG_LINKSPEED_1000) + phyreg |= PHY_1000; + writel(phyreg, base + NvRegPhyInterface); + + if (phyreg & PHY_RGMII) { + if ((np->linkspeed & NVREG_LINKSPEED_MASK) == + NVREG_LINKSPEED_1000) + txreg = NVREG_TX_DEFERRAL_RGMII_1000; + else + txreg = NVREG_TX_DEFERRAL_RGMII_10_100; + } else { + txreg = NVREG_TX_DEFERRAL_DEFAULT; + } + writel(txreg, base + NvRegTxDeferral); + + if (np->desc_ver == DESC_VER_1) { + txreg = NVREG_TX_WM_DESC1_DEFAULT; + } else { + if ((np->linkspeed & NVREG_LINKSPEED_MASK) == + NVREG_LINKSPEED_1000) + txreg = NVREG_TX_WM_DESC2_3_1000; + else + txreg = NVREG_TX_WM_DESC2_3_DEFAULT; + } + writel(txreg, base + NvRegTxWatermark); + + writel(NVREG_MISC1_FORCE | (np->duplex ? 0 : NVREG_MISC1_HD), + base + NvRegMisc1); + pci_push(base); + writel(np->linkspeed, base + NvRegLinkSpeed); + pci_push(base); + + return; +} + /** * nv_update_linkspeed: Setup the MAC according to the link partner * @dev: Network device to be configured @@ -3024,11 +3091,25 @@ static int nv_update_linkspeed(struct net_device *dev) int newls = np->linkspeed; int newdup = np->duplex; int mii_status; + u32 bmcr; int retval = 0; u32 control_1000, status_1000, phyreg, pause_flags, txreg; u32 txrxFlags = 0; u32 phy_exp; + /* If device loopback is enabled, set carrier on and enable max link + * speed. + */ + bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); + if (bmcr & BMCR_LOOPBACK) { + if (netif_running(dev)) { + nv_force_linkspeed(dev, NVREG_LINKSPEED_1000, 1); + if (!netif_carrier_ok(dev)) + netif_carrier_on(dev); + } + return 1; + } + /* BMSR_LSTATUS is latched, read it twice: * we want the current value. */ @@ -4455,6 +4536,61 @@ static int nv_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam* return 0; } +static int nv_set_loopback(struct net_device *dev, u32 features) +{ + struct fe_priv *np = netdev_priv(dev); + unsigned long flags; + u32 miicontrol; + int err, retval = 0; + + spin_lock_irqsave(&np->lock, flags); + miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); + if (features & NETIF_F_LOOPBACK) { + if (miicontrol & BMCR_LOOPBACK) { + spin_unlock_irqrestore(&np->lock, flags); + netdev_info(dev, "Loopback already enabled\n"); + return 0; + } + nv_disable_irq(dev); + /* Turn on loopback mode */ + miicontrol |= BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED1000; + err = mii_rw(dev, np->phyaddr, MII_BMCR, miicontrol); + if (err) { + retval = PHY_ERROR; + spin_unlock_irqrestore(&np->lock, flags); + phy_init(dev); + } else { + if (netif_running(dev)) { + /* Force 1000 Mbps full-duplex */ + nv_force_linkspeed(dev, NVREG_LINKSPEED_1000, + 1); + /* Force link up */ + netif_carrier_on(dev); + } + spin_unlock_irqrestore(&np->lock, flags); + netdev_info(dev, + "Internal PHY loopback mode enabled.\n"); + } + } else { + if (!(miicontrol & BMCR_LOOPBACK)) { + spin_unlock_irqrestore(&np->lock, flags); + netdev_info(dev, "Loopback already disabled\n"); + return 0; + } + nv_disable_irq(dev); + /* Turn off loopback */ + spin_unlock_irqrestore(&np->lock, flags); + netdev_info(dev, "Internal PHY loopback mode disabled.\n"); + phy_init(dev); + } + msleep(500); + spin_lock_irqsave(&np->lock, flags); + nv_enable_irq(dev); + spin_unlock_irqrestore(&np->lock, flags); + + return retval; +} + static u32 nv_fix_features(struct net_device *dev, u32 features) { /* vlan is dependent on rx checksum offload */ @@ -4490,6 +4626,13 @@ static int nv_set_features(struct net_device *dev, u32 features) struct fe_priv *np = netdev_priv(dev); u8 __iomem *base = get_hwbase(dev); u32 changed = dev->features ^ features; + int retval; + + if ((changed & NETIF_F_LOOPBACK) && netif_running(dev)) { + retval = nv_set_loopback(dev, features); + if (retval != 0) + return retval; + } if (changed & NETIF_F_RXCSUM) { spin_lock_irq(&np->lock); @@ -5124,6 +5267,12 @@ static int nv_open(struct net_device *dev) spin_unlock_irq(&np->lock); + /* If the loopback feature was set while the device was down, make sure + * that it's set correctly now. + */ + if (dev->features & NETIF_F_LOOPBACK) + nv_set_loopback(dev, dev->features); + return 0; out_drain: nv_drain_rxtx(dev); @@ -5328,6 +5477,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i dev->features |= dev->hw_features; + /* Add loopback capability to the device. */ + dev->hw_features |= NETIF_F_LOOPBACK; + np->pause_flags = NV_PAUSEFRAME_RX_CAPABLE | NV_PAUSEFRAME_RX_REQ | NV_PAUSEFRAME_AUTONEG; if ((id->driver_data & DEV_HAS_PAUSEFRAME_TX_V1) || (id->driver_data & DEV_HAS_PAUSEFRAME_TX_V2) || @@ -5603,12 +5755,14 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i dev_info(&pci_dev->dev, "ifname %s, PHY OUI 0x%x @ %d, addr %pM\n", dev->name, np->phy_oui, np->phyaddr, dev->dev_addr); - dev_info(&pci_dev->dev, "%s%s%s%s%s%s%s%s%s%sdesc-v%u\n", + dev_info(&pci_dev->dev, "%s%s%s%s%s%s%s%s%s%s%sdesc-v%u\n", dev->features & NETIF_F_HIGHDMA ? "highdma " : "", dev->features & (NETIF_F_IP_CSUM | NETIF_F_SG) ? "csum " : "", dev->features & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX) ? "vlan " : "", + dev->features & (NETIF_F_LOOPBACK) ? + "loopback " : "", id->driver_data & DEV_HAS_POWER_CNTRL ? "pwrctl " : "", id->driver_data & DEV_HAS_MGMT_UNIT ? "mgmt " : "", id->driver_data & DEV_NEED_TIMERIRQ ? "timirq " : "", -- cgit v0.10.2 From 952c5ca14eab113072716ae075c6fd184f011a89 Mon Sep 17 00:00:00 2001 From: Andy Fleming Date: Fri, 11 Nov 2011 05:10:39 +0000 Subject: fsl_pq_mdio: Clean up tbi address configuration The code for setting the address of the internal TBI PHY was convoluted enough without a maze of ifdefs. Clean it up a bit so we allow the logic to fail down to -ENODEV at the end of the if/else ladder, rather than using ifdefs to repeat the same failure code over and over. Also, remove the support for the auto-configuration. I'm not aware of anyone using it, and it ends up using the bus mutex before it's been initialized. Signed-off-by: Andy Fleming Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c index 52f4e8a..4d9f84b 100644 --- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c +++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c @@ -183,28 +183,10 @@ void fsl_pq_mdio_bus_name(char *name, struct device_node *np) } EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name); -/* Scan the bus in reverse, looking for an empty spot */ -static int fsl_pq_mdio_find_free(struct mii_bus *new_bus) -{ - int i; - - for (i = PHY_MAX_ADDR; i > 0; i--) { - u32 phy_id; - - if (get_phy_id(new_bus, i, &phy_id)) - return -1; - - if (phy_id == 0xffffffff) - break; - } - - return i; -} - -#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) { +#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) struct gfar __iomem *enet_regs; /* @@ -220,15 +202,15 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct devi } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || of_device_is_compatible(np, "fsl,etsec2-tbi")) { return of_iomap(np, 1); - } else - return NULL; -} + } #endif + return NULL; +} -#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) { +#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) struct device_node *np = NULL; int err = 0; @@ -261,9 +243,10 @@ static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) return err; else return -EINVAL; -} +#else + return -ENODEV; #endif - +} static int fsl_pq_mdio_probe(struct platform_device *ofdev) { @@ -339,19 +322,13 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) of_device_is_compatible(np, "fsl,etsec2-mdio") || of_device_is_compatible(np, "fsl,etsec2-tbi") || of_device_is_compatible(np, "gianfar")) { -#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) tbipa = get_gfar_tbipa(regs, np); if (!tbipa) { err = -EINVAL; goto err_free_irqs; } -#else - err = -ENODEV; - goto err_free_irqs; -#endif } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || of_device_is_compatible(np, "ucc_geth_phy")) { -#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) u32 id; static u32 mii_mng_master; @@ -364,10 +341,6 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) mii_mng_master = id; ucc_set_qe_mux_mii_mng(id - 1); } -#else - err = -ENODEV; - goto err_free_irqs; -#endif } else { err = -ENODEV; goto err_free_irqs; @@ -386,16 +359,6 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) } if (tbiaddr == -1) { - out_be32(tbipa, 0); - - tbiaddr = fsl_pq_mdio_find_free(new_bus); - } - - /* - * We define TBIPA at 0 to be illegal, opting to fail for boards that - * have PHYs at 1-31, rather than change tbipa and rescan. - */ - if (tbiaddr == 0) { err = -EBUSY; goto err_free_irqs; -- cgit v0.10.2 From 22f4cb4bd06db14912f69039917422fe0c5b11fb Mon Sep 17 00:00:00 2001 From: Haojian Zhuang Date: Wed, 9 Nov 2011 10:47:21 +0800 Subject: ARM: mmp: fix build error on gpio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parameters of GPIO_REG() should be assigned as volatile. arch/arm/plat-pxa/include/plat/gpio.h: In function ‘gpio_get_value’: arch/arm/plat-pxa/include/plat/gpio.h:12:21: error: invalid operands to binary & (have ‘void *’ and ‘int’) arch/arm/plat-pxa/include/plat/gpio.h: In function ‘gpio_set_value’: arch/arm/plat-pxa/include/plat/gpio.h:21:4: error: lvalue required as left operand of assignment arch/arm/plat-pxa/include/plat/gpio.h:23:4: error: lvalue required as left operand of assignment Signed-off-by: Haojian Zhuang Signed-off-by: Eric Miao diff --git a/arch/arm/mach-mmp/include/mach/gpio-pxa.h b/arch/arm/mach-mmp/include/mach/gpio-pxa.h index d14eeaf..99b4ce1 100644 --- a/arch/arm/mach-mmp/include/mach/gpio-pxa.h +++ b/arch/arm/mach-mmp/include/mach/gpio-pxa.h @@ -7,7 +7,7 @@ #define GPIO_REGS_VIRT (APB_VIRT_BASE + 0x19000) #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) -#define GPIO_REG(x) (GPIO_REGS_VIRT + (x)) +#define GPIO_REG(x) (*(volatile u32 *)(GPIO_REGS_VIRT + (x))) #define NR_BUILTIN_GPIO IRQ_GPIO_NUM -- cgit v0.10.2 From 23020ab35364f2c91133b099c2b1f7458e29aa96 Mon Sep 17 00:00:00 2001 From: Rick Jones Date: Wed, 9 Nov 2011 09:58:07 +0000 Subject: Sweep additional floors of strcpy in .get_drvinfo routines Perform another round of floor sweeping, converting the .get_drvinfo routines of additional drivers from strcpy to strlcpy along with some conversion of sprintf to snprintf. Signed-off-by: Rick Jones Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c index a9745f4..a388118 100644 --- a/drivers/net/ethernet/amd/amd8111e.c +++ b/drivers/net/ethernet/amd/amd8111e.c @@ -1412,10 +1412,11 @@ static void amd8111e_get_drvinfo(struct net_device* dev, struct ethtool_drvinfo { struct amd8111e_priv *lp = netdev_priv(dev); struct pci_dev *pci_dev = lp->pci_dev; - strcpy (info->driver, MODULE_NAME); - strcpy (info->version, MODULE_VERS); - sprintf(info->fw_version,"%u",chip_version); - strcpy (info->bus_info, pci_name(pci_dev)); + strlcpy(info->driver, MODULE_NAME, sizeof(info->driver)); + strlcpy(info->version, MODULE_VERS, sizeof(info->version)); + snprintf(info->fw_version, sizeof(info->fw_version), + "%u", chip_version); + strlcpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); } static int amd8111e_get_regs_len(struct net_device *dev) diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c index f92bc6e..20e6dab 100644 --- a/drivers/net/ethernet/amd/pcnet32.c +++ b/drivers/net/ethernet/amd/pcnet32.c @@ -711,12 +711,14 @@ static void pcnet32_get_drvinfo(struct net_device *dev, { struct pcnet32_private *lp = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); if (lp->pci_dev) - strcpy(info->bus_info, pci_name(lp->pci_dev)); + strlcpy(info->bus_info, pci_name(lp->pci_dev), + sizeof(info->bus_info)); else - sprintf(info->bus_info, "VLB 0x%lx", dev->base_addr); + snprintf(info->bus_info, sizeof(info->bus_info), + "VLB 0x%lx", dev->base_addr); } static u32 pcnet32_get_link(struct net_device *dev) diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c index ca26d97..26d0fd2 100644 --- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c +++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c @@ -434,10 +434,11 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct adapter *adapter = dev->ml_priv; - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->fw_version, "N/A"); - strcpy(info->bus_info, pci_name(adapter->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); + strlcpy(info->bus_info, pci_name(adapter->pdev), + sizeof(info->bus_info)); } static int get_sset_count(struct net_device *dev, int sset) diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c index 4d15c8f..053560d 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c @@ -1576,11 +1576,12 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) t3_get_tp_version(adapter, &tp_vers); spin_unlock(&adapter->stats_lock); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(adapter->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(adapter->pdev), + sizeof(info->bus_info)); if (!fw_vers) - strcpy(info->fw_version, "N/A"); + strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); else { snprintf(info->fw_version, sizeof(info->fw_version), "%s %u.%u.%u TP %u.%u.%u", diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 4c8f42a..48ffe11 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -1002,12 +1002,13 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct adapter *adapter = netdev2adap(dev); - strcpy(info->driver, KBUILD_MODNAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(adapter->pdev)); + strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(adapter->pdev), + sizeof(info->bus_info)); if (!adapter->params.fw_vers) - strcpy(info->fw_version, "N/A"); + strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); else snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u.%u.%u, TP %u.%u.%u.%u", diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index da9072b..ee81d8e 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -1203,9 +1203,10 @@ static void cxgb4vf_get_drvinfo(struct net_device *dev, { struct adapter *adapter = netdev2adap(dev); - strcpy(drvinfo->driver, KBUILD_MODNAME); - strcpy(drvinfo->version, DRV_VERSION); - strcpy(drvinfo->bus_info, pci_name(to_pci_dev(dev->dev.parent))); + strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); + strlcpy(drvinfo->bus_info, pci_name(to_pci_dev(dev->dev.parent)), + sizeof(drvinfo->bus_info)); snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%u.%u.%u.%u, TP %u.%u.%u.%u", FW_HDR_FW_VER_MAJOR_GET(adapter->params.dev.fwrev), diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 5a2fdf7..4600327 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -2376,10 +2376,11 @@ static void e100_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info) { struct nic *nic = netdev_priv(netdev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->fw_version, "N/A"); - strcpy(info->bus_info, pci_name(nic->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); + strlcpy(info->bus_info, pci_name(nic->pdev), + sizeof(info->bus_info)); } #define E100_PHY_REGS 0x1C diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 7becff1..7d88c7c 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c @@ -2292,9 +2292,9 @@ jme_get_drvinfo(struct net_device *netdev, { struct jme_adapter *jme = netdev_priv(netdev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(jme->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(jme->pdev), sizeof(info->bus_info)); } static int diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index 7ece990..3b67fe6 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c @@ -6093,9 +6093,10 @@ static void netdev_get_drvinfo(struct net_device *dev, struct dev_priv *priv = netdev_priv(dev); struct dev_info *hw_priv = priv->adapter; - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(hw_priv->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(hw_priv->pdev), + sizeof(info->bus_info)); } /** diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c index 8c80271..0063194 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c @@ -161,10 +161,11 @@ static void pch_gbe_get_drvinfo(struct net_device *netdev, { struct pch_gbe_adapter *adapter = netdev_priv(netdev); - strcpy(drvinfo->driver, KBUILD_MODNAME); - strcpy(drvinfo->version, pch_driver_version); - strcpy(drvinfo->fw_version, "N/A"); - strcpy(drvinfo->bus_info, pci_name(adapter->pdev)); + strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, pch_driver_version, sizeof(drvinfo->version)); + strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->regdump_len = pch_gbe_get_regs_len(netdev); } diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c index 1b4658c..220e982 100644 --- a/drivers/net/ethernet/sis/sis190.c +++ b/drivers/net/ethernet/sis/sis190.c @@ -1760,9 +1760,10 @@ static void sis190_get_drvinfo(struct net_device *dev, { struct sis190_private *tp = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(tp->pci_dev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(tp->pci_dev), + sizeof(info->bus_info)); } static int sis190_get_regs_len(struct net_device *dev) diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index a184abc..c8efc70 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c @@ -1991,9 +1991,10 @@ static void sis900_get_drvinfo(struct net_device *net_dev, { struct sis900_private *sis_priv = netdev_priv(net_dev); - strcpy (info->driver, SIS900_MODULE_NAME); - strcpy (info->version, SIS900_DRV_VERSION); - strcpy (info->bus_info, pci_name(sis_priv->pci_dev)); + strlcpy(info->driver, SIS900_MODULE_NAME, sizeof(info->driver)); + strlcpy(info->version, SIS900_DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(sis_priv->pci_dev), + sizeof(info->bus_info)); } static u32 sis900_get_msglevel(struct net_device *net_dev) diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index 73c7081..3ebeb9d 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -6823,12 +6823,13 @@ static void niu_get_drvinfo(struct net_device *dev, struct niu *np = netdev_priv(dev); struct niu_vpd *vpd = &np->vpd; - strcpy(info->driver, DRV_MODULE_NAME); - strcpy(info->version, DRV_MODULE_VERSION); - sprintf(info->fw_version, "%d.%d", + strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); + snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d", vpd->fcode_major, vpd->fcode_minor); if (np->parent->plat_type != PLAT_TYPE_NIU) - strcpy(info->bus_info, pci_name(np->pdev)); + strlcpy(info->bus_info, pci_name(np->pdev), + sizeof(info->bus_info)); } static int niu_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c index ceab215..31441a8 100644 --- a/drivers/net/ethernet/sun/sungem.c +++ b/drivers/net/ethernet/sun/sungem.c @@ -2517,9 +2517,9 @@ static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info { struct gem *gp = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(gp->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(gp->pdev), sizeof(info->bus_info)); } static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index cf14ab9..eebd52f 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2457,11 +2457,11 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info { struct happy_meal *hp = netdev_priv(dev); - strcpy(info->driver, "sunhme"); - strcpy(info->version, "2.02"); + strlcpy(info->driver, "sunhme", sizeof(info->driver)); + strlcpy(info->version, "2.02", sizeof(info->version)); if (hp->happy_flags & HFLAG_PCI) { struct pci_dev *pdev = hp->happy_dev; - strcpy(info->bus_info, pci_name(pdev)); + strlcpy(info->bus_info, pci_name(pdev), sizeof(info->bus_info)); } #ifdef CONFIG_SBUS else { @@ -2469,7 +2469,8 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info struct platform_device *op = hp->happy_dev; regs = of_get_property(op->dev.of_node, "regs", NULL); if (regs) - sprintf(info->bus_info, "SBUS:%d", + snprintf(info->bus_info, sizeof(info->bus_info), + "SBUS:%d", regs->which_io); } #endif diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index f34dd99..5587ecd 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c @@ -2009,9 +2009,9 @@ static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i { struct rhine_private *rp = netdev_priv(dev); - strcpy(info->driver, DRV_NAME); - strcpy(info->version, DRV_VERSION); - strcpy(info->bus_info, pci_name(rp->pdev)); + strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(rp->pdev), sizeof(info->bus_info)); } static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c index 4535d7c..59bb5fd 100644 --- a/drivers/net/ethernet/via/via-velocity.c +++ b/drivers/net/ethernet/via/via-velocity.c @@ -3270,9 +3270,9 @@ static int velocity_set_settings(struct net_device *dev, static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct velocity_info *vptr = netdev_priv(dev); - strcpy(info->driver, VELOCITY_NAME); - strcpy(info->version, VELOCITY_VERSION); - strcpy(info->bus_info, pci_name(vptr->pdev)); + strlcpy(info->driver, VELOCITY_NAME, sizeof(info->driver)); + strlcpy(info->version, VELOCITY_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(vptr->pdev), sizeof(info->bus_info)); } static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) -- cgit v0.10.2 From 292d1398983f3514a0eab13b7606df7f4730b498 Mon Sep 17 00:00:00 2001 From: stephen hemminger Date: Wed, 9 Nov 2011 18:30:08 +0000 Subject: bridge: add NTF_USE support More changes to the recent code to support control of forwarding database via netlink. * Support NTF_USE like neighbour table * Validate state bits from application * Only send notifications (and change bits) if new entry is different. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index c8e7861..973813e 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -556,7 +556,7 @@ skip: return skb->len; } -/* Create new static fdb entry */ +/* Update (create or replace) forwarding database entry */ static int fdb_add_entry(struct net_bridge_port *source, const __u8 *addr, __u16 state, __u16 flags) { @@ -575,16 +575,21 @@ static int fdb_add_entry(struct net_bridge_port *source, const __u8 *addr, } else { if (flags & NLM_F_EXCL) return -EEXIST; + } + + if (fdb_to_nud(fdb) != state) { + if (state & NUD_PERMANENT) + fdb->is_local = fdb->is_static = 1; + else if (state & NUD_NOARP) { + fdb->is_local = 0; + fdb->is_static = 1; + } else + fdb->is_local = fdb->is_static = 0; - if (flags & NLM_F_REPLACE) - fdb->updated = fdb->used = jiffies; - fdb->is_local = fdb->is_static = 0; + fdb->updated = fdb->used = jiffies; + fdb_notify(fdb, RTM_NEWNEIGH); } - if (state & NUD_PERMANENT) - fdb->is_local = fdb->is_static = 1; - else if (state & NUD_NOARP) - fdb->is_static = 1; return 0; } @@ -627,6 +632,11 @@ int br_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) return -EINVAL; } + if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE))) { + pr_info("bridge: RTM_NEWNEIGH with invalid state %#x\n", ndm->ndm_state); + return -EINVAL; + } + p = br_port_get_rtnl(dev); if (p == NULL) { pr_info("bridge: RTM_NEWNEIGH %s not a bridge port\n", @@ -634,9 +644,15 @@ int br_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) return -EINVAL; } - spin_lock_bh(&p->br->hash_lock); - err = fdb_add_entry(p, addr, ndm->ndm_state, nlh->nlmsg_flags); - spin_unlock_bh(&p->br->hash_lock); + if (ndm->ndm_flags & NTF_USE) { + rcu_read_lock(); + br_fdb_update(p->br, p, addr); + rcu_read_unlock(); + } else { + spin_lock_bh(&p->br->hash_lock); + err = fdb_add_entry(p, addr, ndm->ndm_state, nlh->nlmsg_flags); + spin_unlock_bh(&p->br->hash_lock); + } return err; } -- cgit v0.10.2 From 8b5c171bb3dc0686b2647a84e990199c5faa9ef8 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 9 Nov 2011 12:07:14 +0000 Subject: neigh: new unresolved queue limits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le mercredi 09 novembre 2011 à 16:21 -0500, David Miller a écrit : > From: David Miller > Date: Wed, 09 Nov 2011 16:16:44 -0500 (EST) > > > From: Eric Dumazet > > Date: Wed, 09 Nov 2011 12:14:09 +0100 > > > >> unres_qlen is the number of frames we are able to queue per unresolved > >> neighbour. Its default value (3) was never changed and is responsible > >> for strange drops, especially if IP fragments are used, or multiple > >> sessions start in parallel. Even a single tcp flow can hit this limit. > > ... > > > > Ok, I've applied this, let's see what happens :-) > > Early answer, build fails. > > Please test build this patch with DECNET enabled and resubmit. The > decnet neigh layer still refers to the removed ->queue_len member. > > Thanks. Ouch, this was fixed on one machine yesterday, but not the other one I used this morning, sorry. [PATCH V5 net-next] neigh: new unresolved queue limits unres_qlen is the number of frames we are able to queue per unresolved neighbour. Its default value (3) was never changed and is responsible for strange drops, especially if IP fragments are used, or multiple sessions start in parallel. Even a single tcp flow can hit this limit. $ arp -d 192.168.20.108 ; ping -c 2 -s 8000 192.168.20.108 PING 192.168.20.108 (192.168.20.108) 8000(8028) bytes of data. 8008 bytes from 192.168.20.108: icmp_seq=2 ttl=64 time=0.322 ms Signed-off-by: David S. Miller diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index f049a1c..b886706 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -31,6 +31,16 @@ neigh/default/gc_thresh3 - INTEGER when using large numbers of interfaces and when communicating with large numbers of directly-connected peers. +neigh/default/unres_qlen_bytes - INTEGER + The maximum number of bytes which may be used by packets + queued for each unresolved address by other network layers. + (added in linux 3.3) + +neigh/default/unres_qlen - INTEGER + The maximum number of packets which may be queued for each + unresolved address by other network layers. + (deprecated in linux 3.3) : use unres_qlen_bytes instead. + mtu_expires - INTEGER Time, in seconds, that cached PMTU information is kept. diff --git a/include/linux/neighbour.h b/include/linux/neighbour.h index a7003b7..b188f68 100644 --- a/include/linux/neighbour.h +++ b/include/linux/neighbour.h @@ -116,6 +116,7 @@ enum { NDTPA_PROXY_DELAY, /* u64, msecs */ NDTPA_PROXY_QLEN, /* u32 */ NDTPA_LOCKTIME, /* u64, msecs */ + NDTPA_QUEUE_LENBYTES, /* u32 */ __NDTPA_MAX }; #define NDTPA_MAX (__NDTPA_MAX - 1) diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 2720884..7ae5acf 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -59,7 +59,7 @@ struct neigh_parms { int reachable_time; int delay_probe_time; - int queue_len; + int queue_len_bytes; int ucast_probes; int app_probes; int mcast_probes; @@ -99,6 +99,7 @@ struct neighbour { rwlock_t lock; atomic_t refcnt; struct sk_buff_head arp_queue; + unsigned int arp_queue_len_bytes; struct timer_list timer; unsigned long used; atomic_t probes; diff --git a/net/atm/clip.c b/net/atm/clip.c index 8523940..32c41b8 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c @@ -329,7 +329,7 @@ static struct neigh_table clip_tbl = { .gc_staletime = 60 * HZ, .reachable_time = 30 * HZ, .delay_probe_time = 5 * HZ, - .queue_len = 3, + .queue_len_bytes = 64 * 1024, .ucast_probes = 3, .mcast_probes = 3, .anycast_delay = 1 * HZ, diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 039d51e..2684794 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -238,6 +238,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev) it to safe state. */ skb_queue_purge(&n->arp_queue); + n->arp_queue_len_bytes = 0; n->output = neigh_blackhole; if (n->nud_state & NUD_VALID) n->nud_state = NUD_NOARP; @@ -702,6 +703,7 @@ void neigh_destroy(struct neighbour *neigh) printk(KERN_WARNING "Impossible event.\n"); skb_queue_purge(&neigh->arp_queue); + neigh->arp_queue_len_bytes = 0; dev_put(neigh->dev); neigh_parms_put(neigh->parms); @@ -842,6 +844,7 @@ static void neigh_invalidate(struct neighbour *neigh) write_lock(&neigh->lock); } skb_queue_purge(&neigh->arp_queue); + neigh->arp_queue_len_bytes = 0; } static void neigh_probe(struct neighbour *neigh) @@ -980,15 +983,20 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) if (neigh->nud_state == NUD_INCOMPLETE) { if (skb) { - if (skb_queue_len(&neigh->arp_queue) >= - neigh->parms->queue_len) { + while (neigh->arp_queue_len_bytes + skb->truesize > + neigh->parms->queue_len_bytes) { struct sk_buff *buff; + buff = __skb_dequeue(&neigh->arp_queue); + if (!buff) + break; + neigh->arp_queue_len_bytes -= buff->truesize; kfree_skb(buff); NEIGH_CACHE_STAT_INC(neigh->tbl, unres_discards); } skb_dst_force(skb); __skb_queue_tail(&neigh->arp_queue, skb); + neigh->arp_queue_len_bytes += skb->truesize; } rc = 1; } @@ -1175,6 +1183,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, write_lock_bh(&neigh->lock); } skb_queue_purge(&neigh->arp_queue); + neigh->arp_queue_len_bytes = 0; } out: if (update_isrouter) { @@ -1747,7 +1756,11 @@ static int neightbl_fill_parms(struct sk_buff *skb, struct neigh_parms *parms) NLA_PUT_U32(skb, NDTPA_IFINDEX, parms->dev->ifindex); NLA_PUT_U32(skb, NDTPA_REFCNT, atomic_read(&parms->refcnt)); - NLA_PUT_U32(skb, NDTPA_QUEUE_LEN, parms->queue_len); + NLA_PUT_U32(skb, NDTPA_QUEUE_LENBYTES, parms->queue_len_bytes); + /* approximative value for deprecated QUEUE_LEN (in packets) */ + NLA_PUT_U32(skb, NDTPA_QUEUE_LEN, + DIV_ROUND_UP(parms->queue_len_bytes, + SKB_TRUESIZE(ETH_FRAME_LEN))); NLA_PUT_U32(skb, NDTPA_PROXY_QLEN, parms->proxy_qlen); NLA_PUT_U32(skb, NDTPA_APP_PROBES, parms->app_probes); NLA_PUT_U32(skb, NDTPA_UCAST_PROBES, parms->ucast_probes); @@ -1974,7 +1987,11 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) switch (i) { case NDTPA_QUEUE_LEN: - p->queue_len = nla_get_u32(tbp[i]); + p->queue_len_bytes = nla_get_u32(tbp[i]) * + SKB_TRUESIZE(ETH_FRAME_LEN); + break; + case NDTPA_QUEUE_LENBYTES: + p->queue_len_bytes = nla_get_u32(tbp[i]); break; case NDTPA_PROXY_QLEN: p->proxy_qlen = nla_get_u32(tbp[i]); @@ -2635,117 +2652,158 @@ EXPORT_SYMBOL(neigh_app_ns); #ifdef CONFIG_SYSCTL -#define NEIGH_VARS_MAX 19 +static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer, + size_t *lenp, loff_t *ppos) +{ + int size, ret; + ctl_table tmp = *ctl; + + tmp.data = &size; + size = DIV_ROUND_UP(*(int *)ctl->data, SKB_TRUESIZE(ETH_FRAME_LEN)); + ret = proc_dointvec(&tmp, write, buffer, lenp, ppos); + if (write && !ret) + *(int *)ctl->data = size * SKB_TRUESIZE(ETH_FRAME_LEN); + return ret; +} + +enum { + NEIGH_VAR_MCAST_PROBE, + NEIGH_VAR_UCAST_PROBE, + NEIGH_VAR_APP_PROBE, + NEIGH_VAR_RETRANS_TIME, + NEIGH_VAR_BASE_REACHABLE_TIME, + NEIGH_VAR_DELAY_PROBE_TIME, + NEIGH_VAR_GC_STALETIME, + NEIGH_VAR_QUEUE_LEN, + NEIGH_VAR_QUEUE_LEN_BYTES, + NEIGH_VAR_PROXY_QLEN, + NEIGH_VAR_ANYCAST_DELAY, + NEIGH_VAR_PROXY_DELAY, + NEIGH_VAR_LOCKTIME, + NEIGH_VAR_RETRANS_TIME_MS, + NEIGH_VAR_BASE_REACHABLE_TIME_MS, + NEIGH_VAR_GC_INTERVAL, + NEIGH_VAR_GC_THRESH1, + NEIGH_VAR_GC_THRESH2, + NEIGH_VAR_GC_THRESH3, + NEIGH_VAR_MAX +}; static struct neigh_sysctl_table { struct ctl_table_header *sysctl_header; - struct ctl_table neigh_vars[NEIGH_VARS_MAX]; + struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1]; char *dev_name; } neigh_sysctl_template __read_mostly = { .neigh_vars = { - { + [NEIGH_VAR_MCAST_PROBE] = { .procname = "mcast_solicit", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, - { + [NEIGH_VAR_UCAST_PROBE] = { .procname = "ucast_solicit", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, - { + [NEIGH_VAR_APP_PROBE] = { .procname = "app_solicit", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, - { + [NEIGH_VAR_RETRANS_TIME] = { .procname = "retrans_time", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_userhz_jiffies, }, - { + [NEIGH_VAR_BASE_REACHABLE_TIME] = { .procname = "base_reachable_time", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, - { + [NEIGH_VAR_DELAY_PROBE_TIME] = { .procname = "delay_first_probe_time", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, - { + [NEIGH_VAR_GC_STALETIME] = { .procname = "gc_stale_time", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, - { + [NEIGH_VAR_QUEUE_LEN] = { .procname = "unres_qlen", .maxlen = sizeof(int), .mode = 0644, + .proc_handler = proc_unres_qlen, + }, + [NEIGH_VAR_QUEUE_LEN_BYTES] = { + .procname = "unres_qlen_bytes", + .maxlen = sizeof(int), + .mode = 0644, .proc_handler = proc_dointvec, }, - { + [NEIGH_VAR_PROXY_QLEN] = { .procname = "proxy_qlen", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, - { + [NEIGH_VAR_ANYCAST_DELAY] = { .procname = "anycast_delay", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_userhz_jiffies, }, - { + [NEIGH_VAR_PROXY_DELAY] = { .procname = "proxy_delay", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_userhz_jiffies, }, - { + [NEIGH_VAR_LOCKTIME] = { .procname = "locktime", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_userhz_jiffies, }, - { + [NEIGH_VAR_RETRANS_TIME_MS] = { .procname = "retrans_time_ms", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_ms_jiffies, }, - { + [NEIGH_VAR_BASE_REACHABLE_TIME_MS] = { .procname = "base_reachable_time_ms", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_ms_jiffies, }, - { + [NEIGH_VAR_GC_INTERVAL] = { .procname = "gc_interval", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, - { + [NEIGH_VAR_GC_THRESH1] = { .procname = "gc_thresh1", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, - { + [NEIGH_VAR_GC_THRESH2] = { .procname = "gc_thresh2", .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, - { + [NEIGH_VAR_GC_THRESH3] = { .procname = "gc_thresh3", .maxlen = sizeof(int), .mode = 0644, @@ -2778,47 +2836,49 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, if (!t) goto err; - t->neigh_vars[0].data = &p->mcast_probes; - t->neigh_vars[1].data = &p->ucast_probes; - t->neigh_vars[2].data = &p->app_probes; - t->neigh_vars[3].data = &p->retrans_time; - t->neigh_vars[4].data = &p->base_reachable_time; - t->neigh_vars[5].data = &p->delay_probe_time; - t->neigh_vars[6].data = &p->gc_staletime; - t->neigh_vars[7].data = &p->queue_len; - t->neigh_vars[8].data = &p->proxy_qlen; - t->neigh_vars[9].data = &p->anycast_delay; - t->neigh_vars[10].data = &p->proxy_delay; - t->neigh_vars[11].data = &p->locktime; - t->neigh_vars[12].data = &p->retrans_time; - t->neigh_vars[13].data = &p->base_reachable_time; + t->neigh_vars[NEIGH_VAR_MCAST_PROBE].data = &p->mcast_probes; + t->neigh_vars[NEIGH_VAR_UCAST_PROBE].data = &p->ucast_probes; + t->neigh_vars[NEIGH_VAR_APP_PROBE].data = &p->app_probes; + t->neigh_vars[NEIGH_VAR_RETRANS_TIME].data = &p->retrans_time; + t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].data = &p->base_reachable_time; + t->neigh_vars[NEIGH_VAR_DELAY_PROBE_TIME].data = &p->delay_probe_time; + t->neigh_vars[NEIGH_VAR_GC_STALETIME].data = &p->gc_staletime; + t->neigh_vars[NEIGH_VAR_QUEUE_LEN].data = &p->queue_len_bytes; + t->neigh_vars[NEIGH_VAR_QUEUE_LEN_BYTES].data = &p->queue_len_bytes; + t->neigh_vars[NEIGH_VAR_PROXY_QLEN].data = &p->proxy_qlen; + t->neigh_vars[NEIGH_VAR_ANYCAST_DELAY].data = &p->anycast_delay; + t->neigh_vars[NEIGH_VAR_PROXY_DELAY].data = &p->proxy_delay; + t->neigh_vars[NEIGH_VAR_LOCKTIME].data = &p->locktime; + t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].data = &p->retrans_time; + t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].data = &p->base_reachable_time; if (dev) { dev_name_source = dev->name; /* Terminate the table early */ - memset(&t->neigh_vars[14], 0, sizeof(t->neigh_vars[14])); + memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0, + sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL])); } else { dev_name_source = neigh_path[NEIGH_CTL_PATH_DEV].procname; - t->neigh_vars[14].data = (int *)(p + 1); - t->neigh_vars[15].data = (int *)(p + 1) + 1; - t->neigh_vars[16].data = (int *)(p + 1) + 2; - t->neigh_vars[17].data = (int *)(p + 1) + 3; + t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = (int *)(p + 1); + t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = (int *)(p + 1) + 1; + t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = (int *)(p + 1) + 2; + t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (int *)(p + 1) + 3; } if (handler) { /* RetransTime */ - t->neigh_vars[3].proc_handler = handler; - t->neigh_vars[3].extra1 = dev; + t->neigh_vars[NEIGH_VAR_RETRANS_TIME].proc_handler = handler; + t->neigh_vars[NEIGH_VAR_RETRANS_TIME].extra1 = dev; /* ReachableTime */ - t->neigh_vars[4].proc_handler = handler; - t->neigh_vars[4].extra1 = dev; + t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].proc_handler = handler; + t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].extra1 = dev; /* RetransTime (in milliseconds)*/ - t->neigh_vars[12].proc_handler = handler; - t->neigh_vars[12].extra1 = dev; + t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].proc_handler = handler; + t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].extra1 = dev; /* ReachableTime (in milliseconds) */ - t->neigh_vars[13].proc_handler = handler; - t->neigh_vars[13].extra1 = dev; + t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler = handler; + t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].extra1 = dev; } t->dev_name = kstrdup(dev_name_source, GFP_KERNEL); diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index 7f0eb08..3532ac6 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c @@ -107,7 +107,7 @@ struct neigh_table dn_neigh_table = { .gc_staletime = 60 * HZ, .reachable_time = 30 * HZ, .delay_probe_time = 5 * HZ, - .queue_len = 3, + .queue_len_bytes = 64*1024, .ucast_probes = 0, .app_probes = 0, .mcast_probes = 0, diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 96a164a..d732827 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -177,7 +177,7 @@ struct neigh_table arp_tbl = { .gc_staletime = 60 * HZ, .reachable_time = 30 * HZ, .delay_probe_time = 5 * HZ, - .queue_len = 3, + .queue_len_bytes = 64*1024, .ucast_probes = 3, .mcast_probes = 3, .anycast_delay = 1 * HZ, diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 44e5b7f..4a20982 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -141,7 +141,7 @@ struct neigh_table nd_tbl = { .gc_staletime = 60 * HZ, .reachable_time = ND_REACHABLE_TIME, .delay_probe_time = 5 * HZ, - .queue_len = 3, + .queue_len_bytes = 64*1024, .ucast_probes = 3, .mcast_probes = 3, .anycast_delay = 1 * HZ, -- cgit v0.10.2 From 452448f9283e1939408b397e87974a418825b0a8 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Wed, 9 Nov 2011 10:50:49 +0000 Subject: net/can/mscan: add listen only mode This patch adds listen only mode to the mscan controller. Signed-off-by: Marc Kleine-Budde Acked-by: Wolfgang Grandegger Signed-off-by: David S. Miller diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c index ec4a311..74f3b18 100644 --- a/drivers/net/can/mscan/mscan.c +++ b/drivers/net/can/mscan/mscan.c @@ -581,7 +581,10 @@ static int mscan_open(struct net_device *dev) priv->open_time = jiffies; - clrbits8(®s->canctl1, MSCAN_LISTEN); + if (ctrlmode.flags & CAN_CTRLMODE_LISTENONLY) + setbits8(®s->canctl1, MSCAN_LISTEN); + else + clrbits8(®s->canctl1, MSCAN_LISTEN); ret = mscan_start(dev); if (ret) @@ -690,7 +693,8 @@ struct net_device *alloc_mscandev(void) priv->can.bittiming_const = &mscan_bittiming_const; priv->can.do_set_bittiming = mscan_do_set_bittiming; priv->can.do_set_mode = mscan_do_set_mode; - priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; + priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | + CAN_CTRLMODE_LISTENONLY; for (i = 0; i < TX_QUEUE_SIZE; i++) { priv->tx_queue[i].id = i; -- cgit v0.10.2 From c3e072f8a6c5625028531c40ec65f7e301531be2 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Mon, 14 Nov 2011 08:21:30 +0200 Subject: net: fsl_pq_mdio: fix non tbi phy access Since 952c5ca1 (fsl_pq_mdio: Clean up tbi address configuration) .probe returns -EBUSY when the "tbi-phy" node is missing. Fix this. Cc: Andy Fleming Signed-off-by: Baruch Siach Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c index 4d9f84b..8dee1ae 100644 --- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c +++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c @@ -356,16 +356,16 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) if (prop) tbiaddr = *prop; - } - if (tbiaddr == -1) { - err = -EBUSY; + if (tbiaddr == -1) { + err = -EBUSY; - goto err_free_irqs; + goto err_free_irqs; + } else { + out_be32(tbipa, tbiaddr); + } } - out_be32(tbipa, tbiaddr); - err = of_mdiobus_register(new_bus, np); if (err) { printk (KERN_ERR "%s: Cannot register as MDIO bus\n", -- cgit v0.10.2 From 71ae920d36964f2bcadbe6dac208940837941357 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 14 Nov 2011 00:01:12 +0100 Subject: usb: gadget: drop "select USB_GADGET_S3C_HSOTG_PIO" There is no Kconfig symbol named USB_GADGET_S3C_HSOTG_PIO. The select statement for that symbol is a nop. Drop it. Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index b21cd37..870a707 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -264,7 +264,6 @@ config USB_PXA27X config USB_S3C_HSOTG tristate "S3C HS/OtG USB Device controller" depends on S3C_DEV_USB_HSOTG - select USB_GADGET_S3C_HSOTG_PIO select USB_GADGET_DUALSPEED help The Samsung S3C64XX USB2.0 high-speed gadget controller -- cgit v0.10.2 From 7433f2b78cb35cacf1799faa3b068255a6ef5f1f Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 13 Nov 2011 22:52:40 +0100 Subject: spi: drop "select SPI_MASTER_OF" There is no Kconfig symbol named SPI_MASTER_OF. The select statement for that symbol is a nop. Drop it. While we're touching that Kconfig entry also drop a superfluous dependency on SPI (this entry is wrapped in "if SPI" / "endif"). Signed-off-by: Paul Bolle Signed-off-by: Jiri Kosina diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index a1fd73d..950ccb7 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -174,8 +174,7 @@ config SPI_LM70_LLP config SPI_MPC52xx tristate "Freescale MPC52xx SPI (non-PSC) controller support" - depends on PPC_MPC52xx && SPI - select SPI_MASTER_OF + depends on PPC_MPC52xx help This drivers supports the MPC52xx SPI controller in master SPI mode. -- cgit v0.10.2 From cf5f0acf3935c91379e709a71ecf68805d366659 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Oct 2011 16:52:28 +0200 Subject: sched: Add a comment to effective_load() since it's a pain Every time I have to stare at this function I need to completely reverse engineer its workings, about time I write a comment explaining the thing. Collected bits and pieces from previous changelogs, mostly: 4be9daaa1b33701f011f4117f22dc1e45a3e6e34 83378269a5fad98f562ebc0f09c349575e6cbfe1 Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1318518057.27731.2.camel@twins Signed-off-by: Ingo Molnar diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 5c9e679..aba20f4 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -772,19 +772,32 @@ static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update) list_del_leaf_cfs_rq(cfs_rq); } +static inline long calc_tg_weight(struct task_group *tg, struct cfs_rq *cfs_rq) +{ + long tg_weight; + + /* + * Use this CPU's actual weight instead of the last load_contribution + * to gain a more accurate current total weight. See + * update_cfs_rq_load_contribution(). + */ + tg_weight = atomic_read(&tg->load_weight); + tg_weight -= cfs_rq->load_contribution; + tg_weight += cfs_rq->load.weight; + + return tg_weight; +} + static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg) { - long load_weight, load, shares; + long tg_weight, load, shares; + tg_weight = calc_tg_weight(tg, cfs_rq); load = cfs_rq->load.weight; - load_weight = atomic_read(&tg->load_weight); - load_weight += load; - load_weight -= cfs_rq->load_contribution; - shares = (tg->shares * load); - if (load_weight) - shares /= load_weight; + if (tg_weight) + shares /= tg_weight; if (shares < MIN_SHARES) shares = MIN_SHARES; @@ -2036,36 +2049,100 @@ static void task_waking_fair(struct task_struct *p) * Adding load to a group doesn't make a group heavier, but can cause movement * of group shares between cpus. Assuming the shares were perfectly aligned one * can calculate the shift in shares. + * + * Calculate the effective load difference if @wl is added (subtracted) to @tg + * on this @cpu and results in a total addition (subtraction) of @wg to the + * total group weight. + * + * Given a runqueue weight distribution (rw_i) we can compute a shares + * distribution (s_i) using: + * + * s_i = rw_i / \Sum rw_j (1) + * + * Suppose we have 4 CPUs and our @tg is a direct child of the root group and + * has 7 equal weight tasks, distributed as below (rw_i), with the resulting + * shares distribution (s_i): + * + * rw_i = { 2, 4, 1, 0 } + * s_i = { 2/7, 4/7, 1/7, 0 } + * + * As per wake_affine() we're interested in the load of two CPUs (the CPU the + * task used to run on and the CPU the waker is running on), we need to + * compute the effect of waking a task on either CPU and, in case of a sync + * wakeup, compute the effect of the current task going to sleep. + * + * So for a change of @wl to the local @cpu with an overall group weight change + * of @wl we can compute the new shares distribution (s'_i) using: + * + * s'_i = (rw_i + @wl) / (@wg + \Sum rw_j) (2) + * + * Suppose we're interested in CPUs 0 and 1, and want to compute the load + * differences in waking a task to CPU 0. The additional task changes the + * weight and shares distributions like: + * + * rw'_i = { 3, 4, 1, 0 } + * s'_i = { 3/8, 4/8, 1/8, 0 } + * + * We can then compute the difference in effective weight by using: + * + * dw_i = S * (s'_i - s_i) (3) + * + * Where 'S' is the group weight as seen by its parent. + * + * Therefore the effective change in loads on CPU 0 would be 5/56 (3/8 - 2/7) + * times the weight of the group. The effect on CPU 1 would be -4/56 (4/8 - + * 4/7) times the weight of the group. */ static long effective_load(struct task_group *tg, int cpu, long wl, long wg) { struct sched_entity *se = tg->se[cpu]; - if (!tg->parent) + if (!tg->parent) /* the trivial, non-cgroup case */ return wl; for_each_sched_entity(se) { - long lw, w; + long w, W; tg = se->my_q->tg; - w = se->my_q->load.weight; - /* use this cpu's instantaneous contribution */ - lw = atomic_read(&tg->load_weight); - lw -= se->my_q->load_contribution; - lw += w + wg; + /* + * W = @wg + \Sum rw_j + */ + W = wg + calc_tg_weight(tg, se->my_q); - wl += w; + /* + * w = rw_i + @wl + */ + w = se->my_q->load.weight + wl; - if (lw > 0 && wl < lw) - wl = (wl * tg->shares) / lw; + /* + * wl = S * s'_i; see (2) + */ + if (W > 0 && w < W) + wl = (w * tg->shares) / W; else wl = tg->shares; - /* zero point is MIN_SHARES */ + /* + * Per the above, wl is the new se->load.weight value; since + * those are clipped to [MIN_SHARES, ...) do so now. See + * calc_cfs_shares(). + */ if (wl < MIN_SHARES) wl = MIN_SHARES; + + /* + * wl = dw_i = S * (s'_i - s_i); see (3) + */ wl -= se->load.weight; + + /* + * Recursively apply this logic to all parent groups to compute + * the final effective load change on the root group. Since + * only the @tg group gets extra weight, all parent groups can + * only redistribute existing shares. @wl is the shift in shares + * resulting from this level per the above. + */ wg = 0; } -- cgit v0.10.2 From 461819ac8ee950ce027c72a066156a3df9e60c7e Mon Sep 17 00:00:00 2001 From: Hui Kang Date: Tue, 11 Oct 2011 23:00:59 -0400 Subject: sched_fair: Fix a typo in the comment describing update_sd_lb_stats Signed-off-by: Hui Kang Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1318388459-4427-1-git-send-email-hkang.sunysb@gmail.com Signed-off-by: Ingo Molnar diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index aba20f4..7e51b5b 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -3588,7 +3588,7 @@ static bool update_sd_pick_busiest(struct sched_domain *sd, } /** - * update_sd_lb_stats - Update sched_group's statistics for load balancing. + * update_sd_lb_stats - Update sched_domain's statistics for load balancing. * @sd: sched_domain whose statistics are to be updated. * @this_cpu: Cpu for which load balance is currently performed. * @idle: Idle status of this_cpu -- cgit v0.10.2 From c6dc7f055d333ef35f397b8d7c3abcd1918bf8cb Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Thu, 6 Oct 2011 15:22:46 -0400 Subject: sched: Document wait_for_completion_*() return values The return-value convention for these functions varies depending on whether they're interruptible or can timeout. It can be a little confusing--document it. Signed-off-by: J. Bruce Fields Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/20111006192246.GB28026@fieldses.org Signed-off-by: Ingo Molnar diff --git a/kernel/sched.c b/kernel/sched.c index 0e9344a..3d2c436 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -4810,6 +4810,9 @@ EXPORT_SYMBOL(wait_for_completion); * This waits for either a completion of a specific task to be signaled or for a * specified timeout to expire. The timeout is in jiffies. It is not * interruptible. + * + * The return value is 0 if timed out, and positive (at least 1, or number of + * jiffies left till timeout) if completed. */ unsigned long __sched wait_for_completion_timeout(struct completion *x, unsigned long timeout) @@ -4824,6 +4827,8 @@ EXPORT_SYMBOL(wait_for_completion_timeout); * * This waits for completion of a specific task to be signaled. It is * interruptible. + * + * The return value is -ERESTARTSYS if interrupted, 0 if completed. */ int __sched wait_for_completion_interruptible(struct completion *x) { @@ -4841,6 +4846,9 @@ EXPORT_SYMBOL(wait_for_completion_interruptible); * * This waits for either a completion of a specific task to be signaled or for a * specified timeout to expire. It is interruptible. The timeout is in jiffies. + * + * The return value is -ERESTARTSYS if interrupted, 0 if timed out, + * positive (at least 1, or number of jiffies left till timeout) if completed. */ long __sched wait_for_completion_interruptible_timeout(struct completion *x, @@ -4856,6 +4864,8 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout); * * This waits to be signaled for completion of a specific task. It can be * interrupted by a kill signal. + * + * The return value is -ERESTARTSYS if interrupted, 0 if completed. */ int __sched wait_for_completion_killable(struct completion *x) { @@ -4874,6 +4884,9 @@ EXPORT_SYMBOL(wait_for_completion_killable); * This waits for either a completion of a specific task to be * signaled or for a specified timeout to expire. It can be * interrupted by a kill signal. The timeout is in jiffies. + * + * The return value is -ERESTARTSYS if interrupted, 0 if timed out, + * positive (at least 1, or number of jiffies left till timeout) if completed. */ long __sched wait_for_completion_killable_timeout(struct completion *x, -- cgit v0.10.2 From 4a6184ce7a48c478dee0d8a9ed74c1fa35161858 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 6 Oct 2011 22:39:14 +0200 Subject: sched, rt: Provide means of disabling cross-cpu bandwidth sharing Normally the RT bandwidth scheme will share bandwidth across the entire root_domain. However sometimes its convenient to disable this sharing for debug purposes. Provide a simple feature switch to this end. Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar diff --git a/kernel/sched_features.h b/kernel/sched_features.h index efa0a7b..8480224 100644 --- a/kernel/sched_features.h +++ b/kernel/sched_features.h @@ -67,3 +67,4 @@ SCHED_FEAT(NONTASK_POWER, 1) SCHED_FEAT(TTWU_QUEUE, 1) SCHED_FEAT(FORCE_SD_OVERLAP, 0) +SCHED_FEAT(RT_RUNTIME_SHARE, 1) diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index 056cbd2..583a136 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c @@ -560,6 +560,9 @@ static int balance_runtime(struct rt_rq *rt_rq) { int more = 0; + if (!sched_feat(RT_RUNTIME_SHARE)) + return more; + if (rt_rq->rt_time > rt_rq->rt_runtime) { raw_spin_unlock(&rt_rq->rt_runtime_lock); more = do_balance_runtime(rt_rq); -- cgit v0.10.2 From f1c6f1a7eed963ed233ba4c8b6fa8addb86c6ddc Mon Sep 17 00:00:00 2001 From: Carsten Emde Date: Wed, 26 Oct 2011 23:14:16 +0200 Subject: sched: Set the command name of the idle tasks in SMP kernels In UP systems, the idle task is initialized using the init_task structure from which the command name is taken (currently "swapper"). In SMP systems, one idle task per CPU is forked by the worker thread from which the task structure is copied. The command name is, therefore, "kworker/0:0" or "kworker/0:1", if not updated. Since such update was lacking, all idle tasks in SMP systems were incorrectly named. This longtime bug was not discovered immediately, because there is no /proc/0 entry - the bug only becomes apparent when tracing is enabled. This patch sets the command name of the idle tasks in SMP systems to the name that is used in the INIT_TASK structure suffixed by a slash and the number of the CPU. Signed-off-by: Carsten Emde Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/20111026211708.768925506@osadl.org Signed-off-by: Ingo Molnar diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 08ffab0..b6e5b8b 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -126,6 +126,8 @@ extern struct cred init_cred; # define INIT_PERF_EVENTS(tsk) #endif +#define INIT_TASK_COMM "swapper" + /* * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB) @@ -162,7 +164,7 @@ extern struct cred init_cred; .group_leader = &tsk, \ RCU_INIT_POINTER(.real_cred, &init_cred), \ RCU_INIT_POINTER(.cred, &init_cred), \ - .comm = "swapper", \ + .comm = INIT_TASK_COMM, \ .thread = INIT_THREAD, \ .fs = &init_fs, \ .files = &init_files, \ diff --git a/kernel/sched.c b/kernel/sched.c index 3d2c436..d6b149c 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -71,6 +71,7 @@ #include #include #include +#include #include #include @@ -6112,6 +6113,9 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) */ idle->sched_class = &idle_sched_class; ftrace_graph_init_idle_task(idle, cpu); +#if defined(CONFIG_SMP) + sprintf(idle->comm, "%s/%d", INIT_TASK_COMM, cpu); +#endif } /* -- cgit v0.10.2 From 57d1c0c03c6b48b2b96870d831b9ce6b917f53ac Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Fri, 7 Oct 2011 13:36:40 +0200 Subject: perf/x86: Fix PEBS instruction unwind Masami spotted that we always try to decode the instruction stream as 64bit instructions when running a 64bit kernel, this doesn't work for ia32-compat proglets. Use TIF_IA32 to detect if we need to use the 32bit instruction decoder. Reported-by: Masami Hiramatsu Cc: stable@kernel.org Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c index c0d238f..73da6b6 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c @@ -493,6 +493,7 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs) unsigned long from = cpuc->lbr_entries[0].from; unsigned long old_to, to = cpuc->lbr_entries[0].to; unsigned long ip = regs->ip; + int is_64bit = 0; /* * We don't need to fixup if the PEBS assist is fault like @@ -544,7 +545,10 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs) } else kaddr = (void *)to; - kernel_insn_init(&insn, kaddr); +#ifdef CONFIG_X86_64 + is_64bit = kernel_ip(to) || !test_thread_flag(TIF_IA32); +#endif + insn_init(&insn, kaddr, is_64bit); insn_get_length(&insn); to += insn.length; } while (to < ip); -- cgit v0.10.2 From 1d5f003f5a964711853514b04ddc872eec0fdc7b Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Sun, 23 Oct 2011 19:10:33 +0200 Subject: perf: Do not set task_ctx pointer in cpuctx if there are no events in the context Do not set task_ctx pointer during sched_in if there are no events associated with the context. Otherwise if during task execution total number of events in the system will become zero perf_event_context_sched_out() will not be called and cpuctx->task_ctx will be left with a stale value. Signed-off-by: Gleb Natapov Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/20111023171033.GI17571@redhat.com Signed-off-by: Ingo Molnar diff --git a/kernel/events/core.c b/kernel/events/core.c index 0e8457d..b0c1186 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2173,7 +2173,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx, perf_event_sched_in(cpuctx, ctx, task); - cpuctx->task_ctx = ctx; + if (ctx->nr_events) + cpuctx->task_ctx = ctx; perf_pmu_enable(ctx->pmu); perf_ctx_unlock(cpuctx, ctx); -- cgit v0.10.2 From aa2bc1ade59003a379ffc485d6da2d92ea3370a6 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Wed, 9 Nov 2011 17:56:37 +0100 Subject: perf: Don't use -ENOSPC for out of PMU resources People (Linus) objected to using -ENOSPC to signal not having enough resources on the PMU to satisfy the request. Use -EINVAL. Requested-by: Linus Torvalds Cc: Stephane Eranian Cc: Will Deacon Cc: Deng-Cheng Zhu Cc: David Daney Cc: Ralf Baechle Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-xv8geaz2zpbjhlx0svmpp28n@git.kernel.org [ merged to newer kernel, fixed up MIPS impact ] Signed-off-by: Ingo Molnar diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index 24e2347..ff17b17 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c @@ -347,15 +347,15 @@ validate_group(struct perf_event *event) memset(&fake_pmu, 0, sizeof(fake_pmu)); if (!validate_event(&fake_pmu, leader)) - return -ENOSPC; + return -EINVAL; list_for_each_entry(sibling, &leader->sibling_list, group_entry) { if (!validate_event(&fake_pmu, sibling)) - return -ENOSPC; + return -EINVAL; } if (!validate_event(&fake_pmu, event)) - return -ENOSPC; + return -EINVAL; return 0; } diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c index 4f2971b..315fc0b 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c @@ -623,7 +623,7 @@ static int mipspmu_event_init(struct perf_event *event) if (!atomic_inc_not_zero(&active_events)) { if (atomic_read(&active_events) > MIPS_MAX_HWEVENTS) { atomic_dec(&active_events); - return -ENOSPC; + return -EINVAL; } mutex_lock(&pmu_reserve_mutex); @@ -732,15 +732,15 @@ static int validate_group(struct perf_event *event) memset(&fake_cpuc, 0, sizeof(fake_cpuc)); if (!validate_event(&fake_cpuc, leader)) - return -ENOSPC; + return -EINVAL; list_for_each_entry(sibling, &leader->sibling_list, group_entry) { if (!validate_event(&fake_cpuc, sibling)) - return -ENOSPC; + return -EINVAL; } if (!validate_event(&fake_cpuc, event)) - return -ENOSPC; + return -EINVAL; return 0; } diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 6408910..ff0e8d4 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -588,7 +588,7 @@ done: x86_pmu.put_event_constraints(cpuc, cpuc->event_list[i]); } } - return num ? -ENOSPC : 0; + return num ? -EINVAL : 0; } /* @@ -607,7 +607,7 @@ static int collect_events(struct cpu_hw_events *cpuc, struct perf_event *leader, if (is_x86_event(leader)) { if (n >= max_count) - return -ENOSPC; + return -EINVAL; cpuc->event_list[n] = leader; n++; } @@ -620,7 +620,7 @@ static int collect_events(struct cpu_hw_events *cpuc, struct perf_event *leader, continue; if (n >= max_count) - return -ENOSPC; + return -EINVAL; cpuc->event_list[n] = event; n++; @@ -1316,7 +1316,7 @@ static int validate_event(struct perf_event *event) c = x86_pmu.get_event_constraints(fake_cpuc, event); if (!c || !c->weight) - ret = -ENOSPC; + ret = -EINVAL; if (x86_pmu.put_event_constraints) x86_pmu.put_event_constraints(fake_cpuc, event); @@ -1341,7 +1341,7 @@ static int validate_group(struct perf_event *event) { struct perf_event *leader = event->group_leader; struct cpu_hw_events *fake_cpuc; - int ret = -ENOSPC, n; + int ret = -EINVAL, n; fake_cpuc = allocate_fake_cpuc(); if (IS_ERR(fake_cpuc)) diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c index 492bf13..ef484d9 100644 --- a/arch/x86/kernel/cpu/perf_event_p4.c +++ b/arch/x86/kernel/cpu/perf_event_p4.c @@ -1268,7 +1268,7 @@ reserve: } done: - return num ? -ENOSPC : 0; + return num ? -EINVAL : 0; } static __initconst const struct x86_pmu p4_pmu = { -- cgit v0.10.2 From ed13ec58bfe0d5dc95f748e6118432cb0fa283cb Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Mon, 14 Nov 2011 10:03:25 +0100 Subject: perf/x86: Enable raw event access to Intel offcore events Now that the core offcore support is fixed up (thanks Stephane) and we have sane generic events utilizing them, re-enable the raw access to the feature as well. Note that it doesn't matter if you use event 0x1b7 or 0x1bb to specify an offcore event, either one works and neither guarantees you'll end up on a particular offcore MSR. Based on original patch from: Vince Weaver . Signed-off-by: Peter Zijlstra Cc: Vince Weaver . Cc: Stephane Eranian Link: http://lkml.kernel.org/r/alpine.DEB.2.00.1108031200390.703@cl320.eecs.utk.edu Signed-off-by: Ingo Molnar diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index ff0e8d4..2bda212 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -312,12 +312,8 @@ int x86_setup_perfctr(struct perf_event *event) return -EOPNOTSUPP; } - /* - * Do not allow config1 (extended registers) to propagate, - * there's no sane user-space generalization yet: - */ if (attr->type == PERF_TYPE_RAW) - return 0; + return x86_pmu_extra_regs(event->attr.config, event); if (attr->type == PERF_TYPE_HW_CACHE) return set_ext_hw_attr(hwc, event); -- cgit v0.10.2 From 9251f904f95175b4a1d8cbc0449e748f9edd7629 Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Sun, 16 Oct 2011 17:15:04 +0200 Subject: perf: Carve out callchain functionality Split the callchain code from the perf events core into a new kernel/events/callchain.c file. This simplifies a bit the big core.c Signed-off-by: Borislav Petkov Cc: Arnaldo Carvalho de Melo Cc: Stephane Eranian [keep ctx recursion handling inline and use internal headers] Signed-off-by: Frederic Weisbecker Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1318778104-17152-1-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar diff --git a/kernel/events/Makefile b/kernel/events/Makefile index 89e5e8a..22d901f 100644 --- a/kernel/events/Makefile +++ b/kernel/events/Makefile @@ -2,5 +2,5 @@ ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_core.o = -pg endif -obj-y := core.o ring_buffer.o +obj-y := core.o ring_buffer.o callchain.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c new file mode 100644 index 0000000..057e24b --- /dev/null +++ b/kernel/events/callchain.c @@ -0,0 +1,191 @@ +/* + * Performance events callchain code, extracted from core.c: + * + * Copyright (C) 2008 Thomas Gleixner + * Copyright (C) 2008-2011 Red Hat, Inc., Ingo Molnar + * Copyright (C) 2008-2011 Red Hat, Inc., Peter Zijlstra + * Copyright © 2009 Paul Mackerras, IBM Corp. + * + * For licensing details see kernel-base/COPYING + */ + +#include +#include +#include "internal.h" + +struct callchain_cpus_entries { + struct rcu_head rcu_head; + struct perf_callchain_entry *cpu_entries[0]; +}; + +static DEFINE_PER_CPU(int, callchain_recursion[PERF_NR_CONTEXTS]); +static atomic_t nr_callchain_events; +static DEFINE_MUTEX(callchain_mutex); +static struct callchain_cpus_entries *callchain_cpus_entries; + + +__weak void perf_callchain_kernel(struct perf_callchain_entry *entry, + struct pt_regs *regs) +{ +} + +__weak void perf_callchain_user(struct perf_callchain_entry *entry, + struct pt_regs *regs) +{ +} + +static void release_callchain_buffers_rcu(struct rcu_head *head) +{ + struct callchain_cpus_entries *entries; + int cpu; + + entries = container_of(head, struct callchain_cpus_entries, rcu_head); + + for_each_possible_cpu(cpu) + kfree(entries->cpu_entries[cpu]); + + kfree(entries); +} + +static void release_callchain_buffers(void) +{ + struct callchain_cpus_entries *entries; + + entries = callchain_cpus_entries; + rcu_assign_pointer(callchain_cpus_entries, NULL); + call_rcu(&entries->rcu_head, release_callchain_buffers_rcu); +} + +static int alloc_callchain_buffers(void) +{ + int cpu; + int size; + struct callchain_cpus_entries *entries; + + /* + * We can't use the percpu allocation API for data that can be + * accessed from NMI. Use a temporary manual per cpu allocation + * until that gets sorted out. + */ + size = offsetof(struct callchain_cpus_entries, cpu_entries[nr_cpu_ids]); + + entries = kzalloc(size, GFP_KERNEL); + if (!entries) + return -ENOMEM; + + size = sizeof(struct perf_callchain_entry) * PERF_NR_CONTEXTS; + + for_each_possible_cpu(cpu) { + entries->cpu_entries[cpu] = kmalloc_node(size, GFP_KERNEL, + cpu_to_node(cpu)); + if (!entries->cpu_entries[cpu]) + goto fail; + } + + rcu_assign_pointer(callchain_cpus_entries, entries); + + return 0; + +fail: + for_each_possible_cpu(cpu) + kfree(entries->cpu_entries[cpu]); + kfree(entries); + + return -ENOMEM; +} + +int get_callchain_buffers(void) +{ + int err = 0; + int count; + + mutex_lock(&callchain_mutex); + + count = atomic_inc_return(&nr_callchain_events); + if (WARN_ON_ONCE(count < 1)) { + err = -EINVAL; + goto exit; + } + + if (count > 1) { + /* If the allocation failed, give up */ + if (!callchain_cpus_entries) + err = -ENOMEM; + goto exit; + } + + err = alloc_callchain_buffers(); + if (err) + release_callchain_buffers(); +exit: + mutex_unlock(&callchain_mutex); + + return err; +} + +void put_callchain_buffers(void) +{ + if (atomic_dec_and_mutex_lock(&nr_callchain_events, &callchain_mutex)) { + release_callchain_buffers(); + mutex_unlock(&callchain_mutex); + } +} + +static struct perf_callchain_entry *get_callchain_entry(int *rctx) +{ + int cpu; + struct callchain_cpus_entries *entries; + + *rctx = get_recursion_context(__get_cpu_var(callchain_recursion)); + if (*rctx == -1) + return NULL; + + entries = rcu_dereference(callchain_cpus_entries); + if (!entries) + return NULL; + + cpu = smp_processor_id(); + + return &entries->cpu_entries[cpu][*rctx]; +} + +static void +put_callchain_entry(int rctx) +{ + put_recursion_context(__get_cpu_var(callchain_recursion), rctx); +} + +struct perf_callchain_entry *perf_callchain(struct pt_regs *regs) +{ + int rctx; + struct perf_callchain_entry *entry; + + + entry = get_callchain_entry(&rctx); + if (rctx == -1) + return NULL; + + if (!entry) + goto exit_put; + + entry->nr = 0; + + if (!user_mode(regs)) { + perf_callchain_store(entry, PERF_CONTEXT_KERNEL); + perf_callchain_kernel(entry, regs); + if (current->mm) + regs = task_pt_regs(current); + else + regs = NULL; + } + + if (regs) { + perf_callchain_store(entry, PERF_CONTEXT_USER); + perf_callchain_user(entry, regs); + } + +exit_put: + put_callchain_entry(rctx); + + return entry; +} diff --git a/kernel/events/core.c b/kernel/events/core.c index 0e8457d..eadac69 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2570,215 +2570,6 @@ static u64 perf_event_read(struct perf_event *event) } /* - * Callchain support - */ - -struct callchain_cpus_entries { - struct rcu_head rcu_head; - struct perf_callchain_entry *cpu_entries[0]; -}; - -static DEFINE_PER_CPU(int, callchain_recursion[PERF_NR_CONTEXTS]); -static atomic_t nr_callchain_events; -static DEFINE_MUTEX(callchain_mutex); -struct callchain_cpus_entries *callchain_cpus_entries; - - -__weak void perf_callchain_kernel(struct perf_callchain_entry *entry, - struct pt_regs *regs) -{ -} - -__weak void perf_callchain_user(struct perf_callchain_entry *entry, - struct pt_regs *regs) -{ -} - -static void release_callchain_buffers_rcu(struct rcu_head *head) -{ - struct callchain_cpus_entries *entries; - int cpu; - - entries = container_of(head, struct callchain_cpus_entries, rcu_head); - - for_each_possible_cpu(cpu) - kfree(entries->cpu_entries[cpu]); - - kfree(entries); -} - -static void release_callchain_buffers(void) -{ - struct callchain_cpus_entries *entries; - - entries = callchain_cpus_entries; - rcu_assign_pointer(callchain_cpus_entries, NULL); - call_rcu(&entries->rcu_head, release_callchain_buffers_rcu); -} - -static int alloc_callchain_buffers(void) -{ - int cpu; - int size; - struct callchain_cpus_entries *entries; - - /* - * We can't use the percpu allocation API for data that can be - * accessed from NMI. Use a temporary manual per cpu allocation - * until that gets sorted out. - */ - size = offsetof(struct callchain_cpus_entries, cpu_entries[nr_cpu_ids]); - - entries = kzalloc(size, GFP_KERNEL); - if (!entries) - return -ENOMEM; - - size = sizeof(struct perf_callchain_entry) * PERF_NR_CONTEXTS; - - for_each_possible_cpu(cpu) { - entries->cpu_entries[cpu] = kmalloc_node(size, GFP_KERNEL, - cpu_to_node(cpu)); - if (!entries->cpu_entries[cpu]) - goto fail; - } - - rcu_assign_pointer(callchain_cpus_entries, entries); - - return 0; - -fail: - for_each_possible_cpu(cpu) - kfree(entries->cpu_entries[cpu]); - kfree(entries); - - return -ENOMEM; -} - -static int get_callchain_buffers(void) -{ - int err = 0; - int count; - - mutex_lock(&callchain_mutex); - - count = atomic_inc_return(&nr_callchain_events); - if (WARN_ON_ONCE(count < 1)) { - err = -EINVAL; - goto exit; - } - - if (count > 1) { - /* If the allocation failed, give up */ - if (!callchain_cpus_entries) - err = -ENOMEM; - goto exit; - } - - err = alloc_callchain_buffers(); - if (err) - release_callchain_buffers(); -exit: - mutex_unlock(&callchain_mutex); - - return err; -} - -static void put_callchain_buffers(void) -{ - if (atomic_dec_and_mutex_lock(&nr_callchain_events, &callchain_mutex)) { - release_callchain_buffers(); - mutex_unlock(&callchain_mutex); - } -} - -static int get_recursion_context(int *recursion) -{ - int rctx; - - if (in_nmi()) - rctx = 3; - else if (in_irq()) - rctx = 2; - else if (in_softirq()) - rctx = 1; - else - rctx = 0; - - if (recursion[rctx]) - return -1; - - recursion[rctx]++; - barrier(); - - return rctx; -} - -static inline void put_recursion_context(int *recursion, int rctx) -{ - barrier(); - recursion[rctx]--; -} - -static struct perf_callchain_entry *get_callchain_entry(int *rctx) -{ - int cpu; - struct callchain_cpus_entries *entries; - - *rctx = get_recursion_context(__get_cpu_var(callchain_recursion)); - if (*rctx == -1) - return NULL; - - entries = rcu_dereference(callchain_cpus_entries); - if (!entries) - return NULL; - - cpu = smp_processor_id(); - - return &entries->cpu_entries[cpu][*rctx]; -} - -static void -put_callchain_entry(int rctx) -{ - put_recursion_context(__get_cpu_var(callchain_recursion), rctx); -} - -static struct perf_callchain_entry *perf_callchain(struct pt_regs *regs) -{ - int rctx; - struct perf_callchain_entry *entry; - - - entry = get_callchain_entry(&rctx); - if (rctx == -1) - return NULL; - - if (!entry) - goto exit_put; - - entry->nr = 0; - - if (!user_mode(regs)) { - perf_callchain_store(entry, PERF_CONTEXT_KERNEL); - perf_callchain_kernel(entry, regs); - if (current->mm) - regs = task_pt_regs(current); - else - regs = NULL; - } - - if (regs) { - perf_callchain_store(entry, PERF_CONTEXT_USER); - perf_callchain_user(entry, regs); - } - -exit_put: - put_callchain_entry(rctx); - - return entry; -} - -/* * Initialize the perf_event context in a task_struct: */ static void __perf_event_init_context(struct perf_event_context *ctx) diff --git a/kernel/events/internal.h b/kernel/events/internal.h index 09097dd..be4a43f 100644 --- a/kernel/events/internal.h +++ b/kernel/events/internal.h @@ -1,6 +1,10 @@ #ifndef _KERNEL_EVENTS_INTERNAL_H #define _KERNEL_EVENTS_INTERNAL_H +#include + +/* Buffer handling */ + #define RING_BUFFER_WRITABLE 0x01 struct ring_buffer { @@ -64,7 +68,7 @@ static inline int page_order(struct ring_buffer *rb) } #endif -static unsigned long perf_data_size(struct ring_buffer *rb) +static inline unsigned long perf_data_size(struct ring_buffer *rb) { return rb->nr_pages << (PAGE_SHIFT + page_order(rb)); } @@ -93,4 +97,37 @@ __output_copy(struct perf_output_handle *handle, } while (len); } +/* Callchain handling */ +extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs); +extern int get_callchain_buffers(void); +extern void put_callchain_buffers(void); + +static inline int get_recursion_context(int *recursion) +{ + int rctx; + + if (in_nmi()) + rctx = 3; + else if (in_irq()) + rctx = 2; + else if (in_softirq()) + rctx = 1; + else + rctx = 0; + + if (recursion[rctx]) + return -1; + + recursion[rctx]++; + barrier(); + + return rctx; +} + +static inline void put_recursion_context(int *recursion, int rctx) +{ + barrier(); + recursion[rctx]--; +} + #endif /* _KERNEL_EVENTS_INTERNAL_H */ -- cgit v0.10.2 From 5d81e5cfb37a174e8ddc0413e2e70cdf05807ace Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Mon, 7 Nov 2011 15:54:12 +0300 Subject: events: Don't divide events if it has field period This patch solves the following problem: Now some samples may be lost due to throttling. The number of samples is restricted by sysctl_perf_event_sample_rate/HZ. A trace event is divided on some samples according to event's period. I don't sure, that we should generate more than one sample on each trace event. I think the better way to use SAMPLE_PERIOD. E.g.: I want to trace when a process sleeps. I created a process, which sleeps for 1ms and for 4ms. perf got 100 events in both cases. swapper 0 [000] 1141.371830: sched_stat_sleep: comm=foo pid=1801 delay=1386750 [ns] swapper 0 [000] 1141.369444: sched_stat_sleep: comm=foo pid=1801 delay=4499585 [ns] In the first case a kernel want to send 4499585 events and in the second case it wants to send 1386750 events. perf-reports shows that process sleeps in both places equal time. It's bug. With this patch kernel generates one event on each "sleep" and the time slice is saved in the field "period". Perf knows how handle it. Signed-off-by: Andrew Vagin Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1320670457-2633428-3-git-send-email-avagin@openvz.org Signed-off-by: Ingo Molnar diff --git a/kernel/events/core.c b/kernel/events/core.c index eadac69..8d9dea5 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4528,7 +4528,6 @@ static void perf_swevent_overflow(struct perf_event *event, u64 overflow, struct hw_perf_event *hwc = &event->hw; int throttle = 0; - data->period = event->hw.last_period; if (!overflow) overflow = perf_swevent_set_period(event); @@ -4562,6 +4561,12 @@ static void perf_swevent_event(struct perf_event *event, u64 nr, if (!is_sampling_event(event)) return; + if ((event->attr.sample_type & PERF_SAMPLE_PERIOD) && !event->attr.freq) { + data->period = nr; + return perf_swevent_overflow(event, 1, data, regs); + } else + data->period = event->hw.last_period; + if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq) return perf_swevent_overflow(event, 1, data, regs); -- cgit v0.10.2 From 94d24fc47219219b5aa23b45956cc37ee5aa5b01 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 7 Jun 2011 11:17:30 +0200 Subject: printk, lockdep: Disable lock debugging on zap_locks() zap_locks() is used by printk() in a last ditch effort to get data out, clearly we cannot trust lock state after this so make it disable lock debugging. Also don't treat printk recursion through lockdep as a normal recursion bug but try hard to get the lockdep splat out. Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-kqxwmo4xz37e1s8w0xopvr0q@git.kernel.org Signed-off-by: Ingo Molnar diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b6a56e3..d36619e 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -343,6 +343,8 @@ extern void lockdep_trace_alloc(gfp_t mask); #define lockdep_assert_held(l) WARN_ON(debug_locks && !lockdep_is_held(l)) +#define lockdep_recursing(tsk) ((tsk)->lockdep_recursion) + #else /* !LOCKDEP */ static inline void lockdep_off(void) @@ -392,6 +394,8 @@ struct lock_class_key { }; #define lockdep_assert_held(l) do { } while (0) +#define lockdep_recursing(tsk) (0) + #endif /* !LOCKDEP */ #ifdef CONFIG_LOCK_STAT diff --git a/kernel/printk.c b/kernel/printk.c index 1455a0d..6d08794 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -688,6 +688,7 @@ static void zap_locks(void) oops_timestamp = jiffies; + debug_locks_off(); /* If a crash is occurring, make sure we can't deadlock */ raw_spin_lock_init(&logbuf_lock); /* And make sure that we print immediately */ @@ -856,7 +857,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) * recursion and return - but flag the recursion so that * it can be printed at the next appropriate moment: */ - if (!oops_in_progress) { + if (!oops_in_progress && !lockdep_recursing(current)) { recursion_bug = 1; goto out_restore_irqs; } -- cgit v0.10.2 From 47ff5c95db598184122aa634fa3452c0eecea877 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 7 Jun 2011 11:17:30 +0200 Subject: printk, lockdep: Remove superfluous preempt_disable() The raw_lock_irq_{save,restore}() already implies a non-preemptibility. Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar diff --git a/kernel/printk.c b/kernel/printk.c index 6d08794..ba5ee04 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -841,7 +841,6 @@ asmlinkage int vprintk(const char *fmt, va_list args) boot_delay_msec(); printk_delay(); - preempt_disable(); /* This stops the holder of console_sem just where we want him */ raw_local_irq_save(flags); this_cpu = smp_processor_id(); @@ -965,7 +964,6 @@ asmlinkage int vprintk(const char *fmt, va_list args) out_restore_irqs: raw_local_irq_restore(flags); - preempt_enable(); return printed_len; } EXPORT_SYMBOL(printk); -- cgit v0.10.2 From 1a9a8aefa8f0530c97f4606ab7a2fc01fe31e9c1 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 7 Jun 2011 11:17:30 +0200 Subject: printk, lockdep: Switch to tracked irq ops Switch to local_irq_ ops so that the irq state is properly tracked (raw_local_irq_* isn't tracked by lockdep, causing confusion). Possible now that commit dd4e5d3ac4a ("lockdep: Fix trace_[soft,hard]irqs_[on,off]() recursion") cured the reason we needed the raw_ ops. Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar diff --git a/kernel/printk.c b/kernel/printk.c index ba5ee04..dfd8f73 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -842,7 +842,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) printk_delay(); /* This stops the holder of console_sem just where we want him */ - raw_local_irq_save(flags); + local_irq_save(flags); this_cpu = smp_processor_id(); /* @@ -962,7 +962,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) lockdep_on(); out_restore_irqs: - raw_local_irq_restore(flags); + local_irq_restore(flags); return printed_len; } -- cgit v0.10.2 From 87cdee71166fa107c5dc8e43060eeefa533c6a3b Mon Sep 17 00:00:00 2001 From: Yong Zhang Date: Wed, 9 Nov 2011 16:07:14 +0800 Subject: lockdep: Always try to set ->class_cache in register_lock_class() lockdep_init_map() Commit ["62016250 lockdep: Add improved subclass caching"] tries to improve performance (expecially to reduce the cost of rq->lock) when using lockdep, but it fails due to lockdep_init_map() in which ->class_cache is cleared. The typical caller is lock_set_subclass(), after that class will not be cached anymore. This patch tries to achive the goal of commit 62016250 by always setting ->class_cache in register_lock_class(). === Score comparison of benchmarks === for i in `seq 1 10`; do ./perf bench -f simple sched messaging; done before: min: 0.604, max: 0.660, avg: 0.622 after: min: 0.414, max: 0.473, avg: 0.427 for i in `seq 1 10`; do ./perf bench -f simple sched messaging -g 40; done before: min: 2.347, max: 2.421, avg: 2.391 after: min: 1.652, max: 1.699, avg: 1.671 Signed-off-by: Yong Zhang Cc: Hitoshi Mitake Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/20111109080714.GC8124@zhy Signed-off-by: Ingo Molnar diff --git a/kernel/lockdep.c b/kernel/lockdep.c index e69434b..103bed8 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c @@ -722,7 +722,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force) class = look_up_lock_class(lock, subclass); if (likely(class)) - return class; + goto out_set_class_cache; /* * Debug-check: all keys must be persistent! @@ -807,6 +807,7 @@ out_unlock_set: graph_unlock(); raw_local_irq_restore(flags); +out_set_class_cache: if (!subclass || force) lock->class_cache[0] = class; else if (subclass < NR_LOCKDEP_CACHING_CLASSES) -- cgit v0.10.2 From b2b5ce9d1ccf1c45f8ac68e5d901112ab76ba199 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 14 Nov 2011 06:03:34 +0000 Subject: net: introduce build_skb() One of the thing we discussed during netdev 2011 conference was the idea to change some network drivers to allocate/populate their skb at RX completion time, right before feeding the skb to network stack. In old days, we allocated skbs when populating the RX ring. This means bringing into cpu cache sk_buff and skb_shared_info cache lines (since we clear/initialize them), then 'queue' skb->data to NIC. By the time NIC fills a frame in skb->data buffer and host can process it, cpu probably threw away the cache lines from its caches, because lot of things happened between the allocation and final use. So the deal would be to allocate only the data buffer for the NIC to populate its RX ring buffer. And use build_skb() at RX completion to attach a data buffer (now filled with an ethernet frame) to a new skb, initialize the skb_shared_info portion, and give the hot skb to network stack. build_skb() is the function to allocate an skb, caller providing the data buffer that should be attached to it. Drivers are expected to call skb_reserve() right after build_skb() to adjust skb->data to the Ethernet frame (usually skipping NET_SKB_PAD and NET_IP_ALIGN, but some drivers might add a hardware provided alignment) Data provided to build_skb() MUST have been allocated by a prior kmalloc() call, with enough room to add SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) bytes at the end of the data without corrupting incoming frame. data = kmalloc(NET_SKB_PAD + NET_IP_ALIGN + 1536 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), GFP_ATOMIC); ... skb = build_skb(data); if (!skb) { recycle_data(data); } else { skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN); ... } Signed-off-by: Eric Dumazet CC: Eilon Greenstein CC: Ben Hutchings CC: Tom Herbert CC: Jamal Hadi Salim CC: Stephen Hemminger CC: Thomas Graf CC: Herbert Xu CC: Jeff Kirsher Signed-off-by: David S. Miller diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index fe86488..abad8a0 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -540,6 +540,7 @@ extern void consume_skb(struct sk_buff *skb); extern void __kfree_skb(struct sk_buff *skb); extern struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int fclone, int node); +extern struct sk_buff *build_skb(void *data); static inline struct sk_buff *alloc_skb(unsigned int size, gfp_t priority) { diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 18a3ceb..8d2c5b3 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -245,6 +245,55 @@ nodata: EXPORT_SYMBOL(__alloc_skb); /** + * build_skb - build a network buffer + * @data: data buffer provided by caller + * + * Allocate a new &sk_buff. Caller provides space holding head and + * skb_shared_info. @data must have been allocated by kmalloc() + * The return is the new skb buffer. + * On a failure the return is %NULL, and @data is not freed. + * Notes : + * Before IO, driver allocates only data buffer where NIC put incoming frame + * Driver should add room at head (NET_SKB_PAD) and + * MUST add room at tail (SKB_DATA_ALIGN(skb_shared_info)) + * After IO, driver calls build_skb(), to allocate sk_buff and populate it + * before giving packet to stack. + * RX rings only contains data buffers, not full skbs. + */ +struct sk_buff *build_skb(void *data) +{ + struct skb_shared_info *shinfo; + struct sk_buff *skb; + unsigned int size; + + skb = kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC); + if (!skb) + return NULL; + + size = ksize(data) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + + memset(skb, 0, offsetof(struct sk_buff, tail)); + skb->truesize = SKB_TRUESIZE(size); + atomic_set(&skb->users, 1); + skb->head = data; + skb->data = data; + skb_reset_tail_pointer(skb); + skb->end = skb->tail + size; +#ifdef NET_SKBUFF_DATA_USES_OFFSET + skb->mac_header = ~0U; +#endif + + /* make sure we initialize shinfo sequentially */ + shinfo = skb_shinfo(skb); + memset(shinfo, 0, offsetof(struct skb_shared_info, dataref)); + atomic_set(&shinfo->dataref, 1); + kmemcheck_annotate_variable(shinfo->destructor_arg); + + return skb; +} +EXPORT_SYMBOL(build_skb); + +/** * __netdev_alloc_skb - allocate an skbuff for rx on a specific device * @dev: network device to receive on * @length: length to allocate -- cgit v0.10.2 From e52fcb2462ac484e6dd6e68869536609f0216938 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 14 Nov 2011 06:05:34 +0000 Subject: bnx2x: uses build_skb() in receive path bnx2x uses following formula to compute its rx_buf_sz : dev->mtu + 2*L1_CACHE_BYTES + 14 + 8 + 8 + 2 Then core network adds NET_SKB_PAD and SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) Final allocated size for skb head on x86_64 (L1_CACHE_BYTES = 64, MTU=1500) : 2112 bytes : SLUB/SLAB round this to 4096 bytes. Since skb truesize is then bigger than SK_MEM_QUANTUM, we have lot of false sharing because of mem_reclaim in UDP stack. One possible way to half truesize is to reduce the need by 64 bytes (2112 -> 2048 bytes) Instead of allocating a full cache line at the end of packet for alignment, we can use the fact that skb_shared_info sits at the end of skb->head, and we can use this room, if we convert bnx2x to new build_skb() infrastructure. skb_shared_info will be initialized after hardware finished its transfert, so we can eventually overwrite the final padding. Using build_skb() also reduces cache line misses in the driver, since we use cache hot skb instead of cold ones. Number of in-flight sk_buff structures is lower, they are recycled while still hot. Performance results : (820.000 pps on a rx UDP monothread benchmark, instead of 720.000 pps) Signed-off-by: Eric Dumazet CC: Eilon Greenstein CC: Ben Hutchings CC: Tom Herbert CC: Jamal Hadi Salim CC: Stephen Hemminger CC: Thomas Graf CC: Herbert Xu CC: Jeff Kirsher Acked-by: Eilon Greenstein Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 4b90b51..0f7b7a4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -293,8 +293,13 @@ enum { #define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp)) /* fast path */ +/* + * This driver uses new build_skb() API : + * RX ring buffer contains pointer to kmalloc() data only, + * skb are built only after Hardware filled the frame. + */ struct sw_rx_bd { - struct sk_buff *skb; + u8 *data; DEFINE_DMA_UNMAP_ADDR(mapping); }; @@ -424,8 +429,8 @@ union host_hc_status_block { struct bnx2x_agg_info { /* - * First aggregation buffer is an skb, the following - are pages. - * We will preallocate the skbs for each aggregation when + * First aggregation buffer is a data buffer, the following - are pages. + * We will preallocate the data buffer for each aggregation when * we open the interface and will replace the BD at the consumer * with this one when we receive the TPA_START CQE in order to * keep the Rx BD ring consistent. @@ -439,6 +444,7 @@ struct bnx2x_agg_info { u16 parsing_flags; u16 vlan_tag; u16 len_on_bd; + u32 rxhash; }; #define Q_STATS_OFFSET32(stat_name) \ @@ -1187,10 +1193,20 @@ struct bnx2x { #define ETH_MAX_JUMBO_PACKET_SIZE 9600 /* Max supported alignment is 256 (8 shift) */ -#define BNX2X_RX_ALIGN_SHIFT ((L1_CACHE_SHIFT < 8) ? \ - L1_CACHE_SHIFT : 8) - /* FW use 2 Cache lines Alignment for start packet and size */ -#define BNX2X_FW_RX_ALIGN (2 << BNX2X_RX_ALIGN_SHIFT) +#define BNX2X_RX_ALIGN_SHIFT min(8, L1_CACHE_SHIFT) + + /* FW uses 2 Cache lines Alignment for start packet and size + * + * We assume skb_build() uses sizeof(struct skb_shared_info) bytes + * at the end of skb->data, to avoid wasting a full cache line. + * This reduces memory use (skb->truesize). + */ +#define BNX2X_FW_RX_ALIGN_START (1UL << BNX2X_RX_ALIGN_SHIFT) + +#define BNX2X_FW_RX_ALIGN_END \ + max(1UL << BNX2X_RX_ALIGN_SHIFT, \ + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) + #define BNX2X_PXP_DRAM_ALIGN (BNX2X_RX_ALIGN_SHIFT - 5) struct host_sp_status_block *def_status_blk; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 13dad92..0d60b9e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -294,8 +294,21 @@ static void bnx2x_update_sge_prod(struct bnx2x_fastpath *fp, fp->last_max_sge, fp->rx_sge_prod); } +/* Set Toeplitz hash value in the skb using the value from the + * CQE (calculated by HW). + */ +static u32 bnx2x_get_rxhash(const struct bnx2x *bp, + const struct eth_fast_path_rx_cqe *cqe) +{ + /* Set Toeplitz hash from CQE */ + if ((bp->dev->features & NETIF_F_RXHASH) && + (cqe->status_flags & ETH_FAST_PATH_RX_CQE_RSS_HASH_FLG)) + return le32_to_cpu(cqe->rss_hash_result); + return 0; +} + static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, - struct sk_buff *skb, u16 cons, u16 prod, + u16 cons, u16 prod, struct eth_fast_path_rx_cqe *cqe) { struct bnx2x *bp = fp->bp; @@ -310,9 +323,9 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, if (tpa_info->tpa_state != BNX2X_TPA_STOP) BNX2X_ERR("start of bin not in stop [%d]\n", queue); - /* Try to map an empty skb from the aggregation info */ + /* Try to map an empty data buffer from the aggregation info */ mapping = dma_map_single(&bp->pdev->dev, - first_buf->skb->data, + first_buf->data + NET_SKB_PAD, fp->rx_buf_size, DMA_FROM_DEVICE); /* * ...if it fails - move the skb from the consumer to the producer @@ -322,15 +335,15 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { /* Move the BD from the consumer to the producer */ - bnx2x_reuse_rx_skb(fp, cons, prod); + bnx2x_reuse_rx_data(fp, cons, prod); tpa_info->tpa_state = BNX2X_TPA_ERROR; return; } - /* move empty skb from pool to prod */ - prod_rx_buf->skb = first_buf->skb; + /* move empty data from pool to prod */ + prod_rx_buf->data = first_buf->data; dma_unmap_addr_set(prod_rx_buf, mapping, mapping); - /* point prod_bd to new skb */ + /* point prod_bd to new data */ prod_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); prod_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); @@ -344,6 +357,7 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, tpa_info->tpa_state = BNX2X_TPA_START; tpa_info->len_on_bd = le16_to_cpu(cqe->len_on_bd); tpa_info->placement_offset = cqe->placement_offset; + tpa_info->rxhash = bnx2x_get_rxhash(bp, cqe); #ifdef BNX2X_STOP_ON_ERROR fp->tpa_queue_used |= (1 << queue); @@ -471,11 +485,12 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, { struct bnx2x_agg_info *tpa_info = &fp->tpa_info[queue]; struct sw_rx_bd *rx_buf = &tpa_info->first_buf; - u8 pad = tpa_info->placement_offset; + u32 pad = tpa_info->placement_offset; u16 len = tpa_info->len_on_bd; - struct sk_buff *skb = rx_buf->skb; + struct sk_buff *skb = NULL; + u8 *data = rx_buf->data; /* alloc new skb */ - struct sk_buff *new_skb; + u8 *new_data; u8 old_tpa_state = tpa_info->tpa_state; tpa_info->tpa_state = BNX2X_TPA_STOP; @@ -486,18 +501,18 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, if (old_tpa_state == BNX2X_TPA_ERROR) goto drop; - /* Try to allocate the new skb */ - new_skb = netdev_alloc_skb(bp->dev, fp->rx_buf_size); + /* Try to allocate the new data */ + new_data = kmalloc(fp->rx_buf_size + NET_SKB_PAD, GFP_ATOMIC); /* Unmap skb in the pool anyway, as we are going to change pool entry status to BNX2X_TPA_STOP even if new skb allocation fails. */ dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); + if (likely(new_data)) + skb = build_skb(data); - if (likely(new_skb)) { - prefetch(skb); - prefetch(((char *)(skb)) + L1_CACHE_BYTES); + if (likely(skb)) { #ifdef BNX2X_STOP_ON_ERROR if (pad + len > fp->rx_buf_size) { @@ -509,8 +524,9 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, } #endif - skb_reserve(skb, pad); + skb_reserve(skb, pad + NET_SKB_PAD); skb_put(skb, len); + skb->rxhash = tpa_info->rxhash; skb->protocol = eth_type_trans(skb, bp->dev); skb->ip_summed = CHECKSUM_UNNECESSARY; @@ -526,8 +542,8 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, } - /* put new skb in bin */ - rx_buf->skb = new_skb; + /* put new data in bin */ + rx_buf->data = new_data; return; } @@ -539,19 +555,6 @@ drop: fp->eth_q_stats.rx_skb_alloc_failed++; } -/* Set Toeplitz hash value in the skb using the value from the - * CQE (calculated by HW). - */ -static inline void bnx2x_set_skb_rxhash(struct bnx2x *bp, union eth_rx_cqe *cqe, - struct sk_buff *skb) -{ - /* Set Toeplitz hash from CQE */ - if ((bp->dev->features & NETIF_F_RXHASH) && - (cqe->fast_path_cqe.status_flags & - ETH_FAST_PATH_RX_CQE_RSS_HASH_FLG)) - skb->rxhash = - le32_to_cpu(cqe->fast_path_cqe.rss_hash_result); -} int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) { @@ -594,6 +597,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) u8 cqe_fp_flags; enum eth_rx_cqe_type cqe_fp_type; u16 len, pad; + u8 *data; #ifdef BNX2X_STOP_ON_ERROR if (unlikely(bp->panic)) @@ -604,13 +608,6 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) bd_prod = RX_BD(bd_prod); bd_cons = RX_BD(bd_cons); - /* Prefetch the page containing the BD descriptor - at producer's index. It will be needed when new skb is - allocated */ - prefetch((void *)(PAGE_ALIGN((unsigned long) - (&fp->rx_desc_ring[bd_prod])) - - PAGE_SIZE + 1)); - cqe = &fp->rx_comp_ring[comp_ring_cons]; cqe_fp = &cqe->fast_path_cqe; cqe_fp_flags = cqe_fp->type_error_flags; @@ -626,125 +623,110 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) if (unlikely(CQE_TYPE_SLOW(cqe_fp_type))) { bnx2x_sp_event(fp, cqe); goto next_cqe; + } + rx_buf = &fp->rx_buf_ring[bd_cons]; + data = rx_buf->data; - /* this is an rx packet */ - } else { - rx_buf = &fp->rx_buf_ring[bd_cons]; - skb = rx_buf->skb; - prefetch(skb); - - if (!CQE_TYPE_FAST(cqe_fp_type)) { + if (!CQE_TYPE_FAST(cqe_fp_type)) { #ifdef BNX2X_STOP_ON_ERROR - /* sanity check */ - if (fp->disable_tpa && - (CQE_TYPE_START(cqe_fp_type) || - CQE_TYPE_STOP(cqe_fp_type))) - BNX2X_ERR("START/STOP packet while " - "disable_tpa type %x\n", - CQE_TYPE(cqe_fp_type)); + /* sanity check */ + if (fp->disable_tpa && + (CQE_TYPE_START(cqe_fp_type) || + CQE_TYPE_STOP(cqe_fp_type))) + BNX2X_ERR("START/STOP packet while " + "disable_tpa type %x\n", + CQE_TYPE(cqe_fp_type)); #endif - if (CQE_TYPE_START(cqe_fp_type)) { - u16 queue = cqe_fp->queue_index; - DP(NETIF_MSG_RX_STATUS, - "calling tpa_start on queue %d\n", - queue); - - bnx2x_tpa_start(fp, queue, skb, - bd_cons, bd_prod, - cqe_fp); - - /* Set Toeplitz hash for LRO skb */ - bnx2x_set_skb_rxhash(bp, cqe, skb); - - goto next_rx; - - } else { - u16 queue = - cqe->end_agg_cqe.queue_index; - DP(NETIF_MSG_RX_STATUS, - "calling tpa_stop on queue %d\n", - queue); + if (CQE_TYPE_START(cqe_fp_type)) { + u16 queue = cqe_fp->queue_index; + DP(NETIF_MSG_RX_STATUS, + "calling tpa_start on queue %d\n", + queue); - bnx2x_tpa_stop(bp, fp, queue, - &cqe->end_agg_cqe, - comp_ring_cons); + bnx2x_tpa_start(fp, queue, + bd_cons, bd_prod, + cqe_fp); + goto next_rx; + } else { + u16 queue = + cqe->end_agg_cqe.queue_index; + DP(NETIF_MSG_RX_STATUS, + "calling tpa_stop on queue %d\n", + queue); + + bnx2x_tpa_stop(bp, fp, queue, + &cqe->end_agg_cqe, + comp_ring_cons); #ifdef BNX2X_STOP_ON_ERROR - if (bp->panic) - return 0; + if (bp->panic) + return 0; #endif - bnx2x_update_sge_prod(fp, cqe_fp); - goto next_cqe; - } + bnx2x_update_sge_prod(fp, cqe_fp); + goto next_cqe; } - /* non TPA */ - len = le16_to_cpu(cqe_fp->pkt_len); - pad = cqe_fp->placement_offset; - dma_sync_single_for_cpu(&bp->pdev->dev, + } + /* non TPA */ + len = le16_to_cpu(cqe_fp->pkt_len); + pad = cqe_fp->placement_offset; + dma_sync_single_for_cpu(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), - pad + RX_COPY_THRESH, - DMA_FROM_DEVICE); - prefetch(((char *)(skb)) + L1_CACHE_BYTES); + pad + RX_COPY_THRESH, + DMA_FROM_DEVICE); + pad += NET_SKB_PAD; + prefetch(data + pad); /* speedup eth_type_trans() */ + /* is this an error packet? */ + if (unlikely(cqe_fp_flags & ETH_RX_ERROR_FALGS)) { + DP(NETIF_MSG_RX_ERR, + "ERROR flags %x rx packet %u\n", + cqe_fp_flags, sw_comp_cons); + fp->eth_q_stats.rx_err_discard_pkt++; + goto reuse_rx; + } - /* is this an error packet? */ - if (unlikely(cqe_fp_flags & ETH_RX_ERROR_FALGS)) { + /* Since we don't have a jumbo ring + * copy small packets if mtu > 1500 + */ + if ((bp->dev->mtu > ETH_MAX_PACKET_SIZE) && + (len <= RX_COPY_THRESH)) { + skb = netdev_alloc_skb_ip_align(bp->dev, len); + if (skb == NULL) { DP(NETIF_MSG_RX_ERR, - "ERROR flags %x rx packet %u\n", - cqe_fp_flags, sw_comp_cons); - fp->eth_q_stats.rx_err_discard_pkt++; + "ERROR packet dropped because of alloc failure\n"); + fp->eth_q_stats.rx_skb_alloc_failed++; goto reuse_rx; } - - /* Since we don't have a jumbo ring - * copy small packets if mtu > 1500 - */ - if ((bp->dev->mtu > ETH_MAX_PACKET_SIZE) && - (len <= RX_COPY_THRESH)) { - struct sk_buff *new_skb; - - new_skb = netdev_alloc_skb(bp->dev, len + pad); - if (new_skb == NULL) { - DP(NETIF_MSG_RX_ERR, - "ERROR packet dropped " - "because of alloc failure\n"); - fp->eth_q_stats.rx_skb_alloc_failed++; - goto reuse_rx; - } - - /* aligned copy */ - skb_copy_from_linear_data_offset(skb, pad, - new_skb->data + pad, len); - skb_reserve(new_skb, pad); - skb_put(new_skb, len); - - bnx2x_reuse_rx_skb(fp, bd_cons, bd_prod); - - skb = new_skb; - - } else - if (likely(bnx2x_alloc_rx_skb(bp, fp, bd_prod) == 0)) { + memcpy(skb->data, data + pad, len); + bnx2x_reuse_rx_data(fp, bd_cons, bd_prod); + } else { + if (likely(bnx2x_alloc_rx_data(bp, fp, bd_prod) == 0)) { dma_unmap_single(&bp->pdev->dev, - dma_unmap_addr(rx_buf, mapping), + dma_unmap_addr(rx_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); + skb = build_skb(data); + if (unlikely(!skb)) { + kfree(data); + fp->eth_q_stats.rx_skb_alloc_failed++; + goto next_rx; + } skb_reserve(skb, pad); - skb_put(skb, len); - } else { DP(NETIF_MSG_RX_ERR, "ERROR packet dropped because " "of alloc failure\n"); fp->eth_q_stats.rx_skb_alloc_failed++; reuse_rx: - bnx2x_reuse_rx_skb(fp, bd_cons, bd_prod); + bnx2x_reuse_rx_data(fp, bd_cons, bd_prod); goto next_rx; } + skb_put(skb, len); skb->protocol = eth_type_trans(skb, bp->dev); /* Set Toeplitz hash for a none-LRO skb */ - bnx2x_set_skb_rxhash(bp, cqe, skb); + skb->rxhash = bnx2x_get_rxhash(bp, cqe_fp); skb_checksum_none_assert(skb); @@ -767,7 +749,7 @@ reuse_rx: next_rx: - rx_buf->skb = NULL; + rx_buf->data = NULL; bd_cons = NEXT_RX_IDX(bd_cons); bd_prod = NEXT_RX_IDX(bd_prod); @@ -1013,9 +995,9 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) struct sw_rx_bd *first_buf = &tpa_info->first_buf; - first_buf->skb = netdev_alloc_skb(bp->dev, - fp->rx_buf_size); - if (!first_buf->skb) { + first_buf->data = kmalloc(fp->rx_buf_size + NET_SKB_PAD, + GFP_ATOMIC); + if (!first_buf->data) { BNX2X_ERR("Failed to allocate TPA " "skb pool for queue[%d] - " "disabling TPA on this " @@ -1118,16 +1100,16 @@ static void bnx2x_free_rx_bds(struct bnx2x_fastpath *fp) for (i = 0; i < NUM_RX_BD; i++) { struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[i]; - struct sk_buff *skb = rx_buf->skb; + u8 *data = rx_buf->data; - if (skb == NULL) + if (data == NULL) continue; dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); - rx_buf->skb = NULL; - dev_kfree_skb(skb); + rx_buf->data = NULL; + kfree(data); } } @@ -1509,6 +1491,7 @@ static inline void bnx2x_set_rx_buf_size(struct bnx2x *bp) for_each_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; + u32 mtu; /* Always use a mini-jumbo MTU for the FCoE L2 ring */ if (IS_FCOE_IDX(i)) @@ -1518,13 +1501,15 @@ static inline void bnx2x_set_rx_buf_size(struct bnx2x *bp) * IP_HEADER_ALIGNMENT_PADDING to prevent a buffer * overrun attack. */ - fp->rx_buf_size = - BNX2X_FCOE_MINI_JUMBO_MTU + ETH_OVREHEAD + - BNX2X_FW_RX_ALIGN + IP_HEADER_ALIGNMENT_PADDING; + mtu = BNX2X_FCOE_MINI_JUMBO_MTU; else - fp->rx_buf_size = - bp->dev->mtu + ETH_OVREHEAD + - BNX2X_FW_RX_ALIGN + IP_HEADER_ALIGNMENT_PADDING; + mtu = bp->dev->mtu; + fp->rx_buf_size = BNX2X_FW_RX_ALIGN_START + + IP_HEADER_ALIGNMENT_PADDING + + ETH_OVREHEAD + + mtu + + BNX2X_FW_RX_ALIGN_END; + /* Note : rx_buf_size doesnt take into account NET_SKB_PAD */ } } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 260226d..41eb17e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -910,26 +910,27 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp, return 0; } -static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp, - struct bnx2x_fastpath *fp, u16 index) +static inline int bnx2x_alloc_rx_data(struct bnx2x *bp, + struct bnx2x_fastpath *fp, u16 index) { - struct sk_buff *skb; + u8 *data; struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[index]; struct eth_rx_bd *rx_bd = &fp->rx_desc_ring[index]; dma_addr_t mapping; - skb = netdev_alloc_skb(bp->dev, fp->rx_buf_size); - if (unlikely(skb == NULL)) + data = kmalloc(fp->rx_buf_size + NET_SKB_PAD, GFP_ATOMIC); + if (unlikely(data == NULL)) return -ENOMEM; - mapping = dma_map_single(&bp->pdev->dev, skb->data, fp->rx_buf_size, + mapping = dma_map_single(&bp->pdev->dev, data + NET_SKB_PAD, + fp->rx_buf_size, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { - dev_kfree_skb_any(skb); + kfree(data); return -ENOMEM; } - rx_buf->skb = skb; + rx_buf->data = data; dma_unmap_addr_set(rx_buf, mapping, mapping); rx_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); @@ -938,12 +939,12 @@ static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp, return 0; } -/* note that we are not allocating a new skb, +/* note that we are not allocating a new buffer, * we are just moving one from cons to prod * we are not creating a new mapping, * so there is no need to check for dma_mapping_error(). */ -static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp, +static inline void bnx2x_reuse_rx_data(struct bnx2x_fastpath *fp, u16 cons, u16 prod) { struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons]; @@ -953,7 +954,7 @@ static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp, dma_unmap_addr_set(prod_rx_buf, mapping, dma_unmap_addr(cons_rx_buf, mapping)); - prod_rx_buf->skb = cons_rx_buf->skb; + prod_rx_buf->data = cons_rx_buf->data; *prod_bd = *cons_bd; } @@ -1029,9 +1030,9 @@ static inline void bnx2x_free_tpa_pool(struct bnx2x *bp, for (i = 0; i < last; i++) { struct bnx2x_agg_info *tpa_info = &fp->tpa_info[i]; struct sw_rx_bd *first_buf = &tpa_info->first_buf; - struct sk_buff *skb = first_buf->skb; + u8 *data = first_buf->data; - if (skb == NULL) { + if (data == NULL) { DP(NETIF_MSG_IFDOWN, "tpa bin %d empty on free\n", i); continue; } @@ -1039,8 +1040,8 @@ static inline void bnx2x_free_tpa_pool(struct bnx2x *bp, dma_unmap_single(&bp->pdev->dev, dma_unmap_addr(first_buf, mapping), fp->rx_buf_size, DMA_FROM_DEVICE); - dev_kfree_skb(skb); - first_buf->skb = NULL; + kfree(data); + first_buf->data = NULL; } } @@ -1148,7 +1149,7 @@ static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp, * fp->eth_q_stats.rx_skb_alloc_failed = 0 */ for (i = 0; i < rx_ring_size; i++) { - if (bnx2x_alloc_rx_skb(bp, fp, ring_prod) < 0) { + if (bnx2x_alloc_rx_data(bp, fp, ring_prod) < 0) { fp->eth_q_stats.rx_skb_alloc_failed++; continue; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index f6402fa..ec31871 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -1740,6 +1740,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) struct sw_rx_bd *rx_buf; u16 len; int rc = -ENODEV; + u8 *data; /* check the loopback mode */ switch (loopback_mode) { @@ -1865,10 +1866,9 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) dma_sync_single_for_cpu(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), fp_rx->rx_buf_size, DMA_FROM_DEVICE); - skb = rx_buf->skb; - skb_reserve(skb, cqe->fast_path_cqe.placement_offset); + data = rx_buf->data + NET_SKB_PAD + cqe->fast_path_cqe.placement_offset; for (i = ETH_HLEN; i < pkt_size; i++) - if (*(skb->data + i) != (unsigned char) (i & 0xff)) + if (*(data + i) != (unsigned char) (i & 0xff)) goto test_loopback_rx_exit; rc = 0; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 33ff60d..80fb9b5 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -2789,8 +2789,8 @@ static void bnx2x_pf_rx_q_prep(struct bnx2x *bp, /* This should be a maximum number of data bytes that may be * placed on the BD (not including paddings). */ - rxq_init->buf_sz = fp->rx_buf_size - BNX2X_FW_RX_ALIGN - - IP_HEADER_ALIGNMENT_PADDING; + rxq_init->buf_sz = fp->rx_buf_size - BNX2X_FW_RX_ALIGN_START - + BNX2X_FW_RX_ALIGN_END - IP_HEADER_ALIGNMENT_PADDING; rxq_init->cl_qzone_id = fp->cl_qzone_id; rxq_init->tpa_agg_sz = tpa_agg_size; -- cgit v0.10.2 From 612a94d6f24eb2427eabf554392080302da664dd Mon Sep 17 00:00:00 2001 From: Rick Jones Date: Mon, 14 Nov 2011 08:13:25 +0000 Subject: Sweep the last of the active .get_drvinfo floors under ethernet/ This round of floor sweeping converts strncpy calls in various .get_drvinfo routines to the preferred strlcpy. It also does a modicum of other cleaning in those routines. Signed-off-by: Rick Jones Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index c3786fd..1fe5df0 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -217,11 +217,11 @@ static void enic_get_drvinfo(struct net_device *netdev, enic_dev_fw_info(enic, &fw_info); - strncpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); - strncpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); - strncpy(drvinfo->fw_version, fw_info->fw_version, + strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version)); + strlcpy(drvinfo->fw_version, fw_info->fw_version, sizeof(drvinfo->fw_version)); - strncpy(drvinfo->bus_info, pci_name(enic->pdev), + strlcpy(drvinfo->bus_info, pci_name(enic->pdev), sizeof(drvinfo->bus_info)); } diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c index 2b223ac..63faec6 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c @@ -515,14 +515,15 @@ static void e1000_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct e1000_adapter *adapter = netdev_priv(netdev); - char firmware_version[32]; - strncpy(drvinfo->driver, e1000_driver_name, 32); - strncpy(drvinfo->version, e1000_driver_version, 32); + strlcpy(drvinfo->driver, e1000_driver_name, + sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, e1000_driver_version, + sizeof(drvinfo->version)); - sprintf(firmware_version, "N/A"); - strncpy(drvinfo->fw_version, firmware_version, 32); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); + strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->regdump_len = e1000_get_regs_len(netdev); drvinfo->eedump_len = e1000_get_eeprom_len(netdev); } diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index 69c9d21..6d8f0ed 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -579,26 +579,24 @@ static void e1000_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct e1000_adapter *adapter = netdev_priv(netdev); - char firmware_version[32]; - strncpy(drvinfo->driver, e1000e_driver_name, - sizeof(drvinfo->driver) - 1); + strlcpy(drvinfo->driver, e1000e_driver_name, + sizeof(drvinfo->driver)); strncpy(drvinfo->version, e1000e_driver_version, - sizeof(drvinfo->version) - 1); + sizeof(drvinfo->version)); /* * EEPROM image version # is reported as firmware version # for * PCI-E controllers */ - snprintf(firmware_version, sizeof(firmware_version), "%d.%d-%d", + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%d.%d-%d", (adapter->eeprom_vers & 0xF000) >> 12, (adapter->eeprom_vers & 0x0FF0) >> 4, (adapter->eeprom_vers & 0x000F)); - strncpy(drvinfo->fw_version, firmware_version, - sizeof(drvinfo->fw_version) - 1); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), - sizeof(drvinfo->bus_info) - 1); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->regdump_len = e1000_get_regs_len(netdev); drvinfo->eedump_len = e1000_get_eeprom_len(netdev); } diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index 43873eb..e9335ef 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -673,25 +673,22 @@ static void igb_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct igb_adapter *adapter = netdev_priv(netdev); - char firmware_version[32]; u16 eeprom_data; - strncpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver) - 1); - strncpy(drvinfo->version, igb_driver_version, - sizeof(drvinfo->version) - 1); + strlcpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, igb_driver_version, sizeof(drvinfo->version)); /* EEPROM image version # is reported as firmware version # for * 82575 controllers */ adapter->hw.nvm.ops.read(&adapter->hw, 5, 1, &eeprom_data); - sprintf(firmware_version, "%d.%d-%d", + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%d.%d-%d", (eeprom_data & 0xF000) >> 12, (eeprom_data & 0x0FF0) >> 4, eeprom_data & 0x000F); - strncpy(drvinfo->fw_version, firmware_version, - sizeof(drvinfo->fw_version) - 1); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), - sizeof(drvinfo->bus_info) - 1); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = IGB_STATS_LEN; drvinfo->testinfo_len = IGB_TEST_LEN; drvinfo->regdump_len = igb_get_regs_len(netdev); diff --git a/drivers/net/ethernet/intel/igbvf/ethtool.c b/drivers/net/ethernet/intel/igbvf/ethtool.c index 2c25858..e60f1c6 100644 --- a/drivers/net/ethernet/intel/igbvf/ethtool.c +++ b/drivers/net/ethernet/intel/igbvf/ethtool.c @@ -191,12 +191,14 @@ static void igbvf_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct igbvf_adapter *adapter = netdev_priv(netdev); - char firmware_version[32] = "N/A"; - strncpy(drvinfo->driver, igbvf_driver_name, 32); - strncpy(drvinfo->version, igbvf_driver_version, 32); - strncpy(drvinfo->fw_version, firmware_version, 32); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); + strlcpy(drvinfo->driver, igbvf_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, igbvf_driver_version, + sizeof(drvinfo->version)); + strlcpy(drvinfo->fw_version, "N/A", + sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->regdump_len = igbvf_get_regs_len(netdev); drvinfo->eedump_len = igbvf_get_eeprom_len(netdev); } diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c index 9dfce7d..96fcb0e 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c @@ -473,10 +473,13 @@ ixgb_get_drvinfo(struct net_device *netdev, { struct ixgb_adapter *adapter = netdev_priv(netdev); - strncpy(drvinfo->driver, ixgb_driver_name, 32); - strncpy(drvinfo->version, ixgb_driver_version, 32); - strncpy(drvinfo->fw_version, "N/A", 32); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); + strlcpy(drvinfo->driver, ixgb_driver_name, + sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, ixgb_driver_version, + sizeof(drvinfo->version)); + strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = IXGB_STATS_LEN; drvinfo->regdump_len = ixgb_get_regs_len(netdev); drvinfo->eedump_len = ixgb_get_eeprom_len(netdev); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 70d58c3..91f871b 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -888,23 +888,19 @@ static void ixgbe_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct ixgbe_adapter *adapter = netdev_priv(netdev); - char firmware_version[32]; u32 nvm_track_id; - strncpy(drvinfo->driver, ixgbe_driver_name, - sizeof(drvinfo->driver) - 1); - strncpy(drvinfo->version, ixgbe_driver_version, - sizeof(drvinfo->version) - 1); + strlcpy(drvinfo->driver, ixgbe_driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, ixgbe_driver_version, + sizeof(drvinfo->version)); nvm_track_id = (adapter->eeprom_verh << 16) | adapter->eeprom_verl; - snprintf(firmware_version, sizeof(firmware_version), "0x%08x", + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "0x%08x", nvm_track_id); - strncpy(drvinfo->fw_version, firmware_version, - sizeof(drvinfo->fw_version) - 1); - strncpy(drvinfo->bus_info, pci_name(adapter->pdev), - sizeof(drvinfo->bus_info) - 1); + strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = IXGBE_STATS_LEN; drvinfo->testinfo_len = IXGBE_TEST_LEN; drvinfo->regdump_len = ixgbe_get_regs_len(netdev); diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 74e2a2a..ee637a2 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -45,13 +45,16 @@ mlx4_en_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_dev *mdev = priv->mdev; - strncpy(drvinfo->driver, DRV_NAME, 32); - strncpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", 32); - sprintf(drvinfo->fw_version, "%d.%d.%d", + strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", + sizeof(drvinfo->version)); + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%d.%d.%d", (u16) (mdev->dev->caps.fw_ver >> 32), (u16) ((mdev->dev->caps.fw_ver >> 16) & 0xffff), (u16) (mdev->dev->caps.fw_ver & 0xffff)); - strncpy(drvinfo->bus_info, pci_name(mdev->dev->pdev), 32); + strlcpy(drvinfo->bus_info, pci_name(mdev->dev->pdev), + sizeof(drvinfo->bus_info)); drvinfo->n_stats = 0; drvinfo->regdump_len = 0; drvinfo->eedump_len = 0; diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index fd40988..f10665f 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c @@ -4532,10 +4532,9 @@ static void cas_set_multicast(struct net_device *dev) static void cas_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct cas *cp = netdev_priv(dev); - strncpy(info->driver, DRV_MODULE_NAME, ETHTOOL_BUSINFO_LEN); - strncpy(info->version, DRV_MODULE_VERSION, ETHTOOL_BUSINFO_LEN); - info->fw_version[0] = '\0'; - strncpy(info->bus_info, pci_name(cp->pdev), ETHTOOL_BUSINFO_LEN); + strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); + strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); + strlcpy(info->bus_info, pci_name(cp->pdev), sizeof(info->bus_info)); info->regdump_len = cp->casreg_len < CAS_MAX_REGS ? cp->casreg_len : CAS_MAX_REGS; info->n_stats = CAS_NUM_STAT_KEYS; -- cgit v0.10.2 From abbd00b82a2771b0460ba2cffdb1343aa827ccde Mon Sep 17 00:00:00 2001 From: Wolfgang Grandegger Date: Mon, 14 Nov 2011 14:30:05 -0500 Subject: net/can/mscan: Fix buggy listen only mode setting This patch fixes an issue introduced recently with commit 452448f9283e1939408b397e87974a418825b0a8. CC: Marc Kleine-Budde Signed-off-by: Wolfgang Grandegger Signed-off-by: David S. Miller diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c index 74f3b18..1c82dd8 100644 --- a/drivers/net/can/mscan/mscan.c +++ b/drivers/net/can/mscan/mscan.c @@ -581,7 +581,7 @@ static int mscan_open(struct net_device *dev) priv->open_time = jiffies; - if (ctrlmode.flags & CAN_CTRLMODE_LISTENONLY) + if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) setbits8(®s->canctl1, MSCAN_LISTEN); else clrbits8(®s->canctl1, MSCAN_LISTEN); -- cgit v0.10.2 From d71314b4ac88637f9ac2770a9f635babdf6f2ff9 Mon Sep 17 00:00:00 2001 From: Matti Vaittinen Date: Mon, 14 Nov 2011 00:14:49 +0000 Subject: IPv6 routing, NLM_F_* flag support: warn if new route is created without NLM_F_CREATE The support for NLM_F_* flags at IPv6 routing requests. Warn if NLM_F_CREATE flag is not defined for RTM_NEWROUTE request, creating new table. Later NLM_F_CREATE may be required for new route creation. Patch created against linux-3.2-rc1 Signed-off-by: Matti Vaittinen Signed-off-by: David S. Miller diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 8473016..05c89be 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1230,9 +1230,18 @@ int ip6_route_add(struct fib6_config *cfg) if (cfg->fc_metric == 0) cfg->fc_metric = IP6_RT_PRIO_USER; - table = fib6_new_table(net, cfg->fc_table); + err = -ENOBUFS; + if (NULL != cfg->fc_nlinfo.nlh && + !(cfg->fc_nlinfo.nlh->nlmsg_flags&NLM_F_CREATE)) { + table = fib6_get_table(net, cfg->fc_table); + if (table == NULL) { + printk(KERN_WARNING "IPv6: NLM_F_CREATE should be specified when creating new route\n"); + table = fib6_new_table(net, cfg->fc_table); + } + } else { + table = fib6_new_table(net, cfg->fc_table); + } if (table == NULL) { - err = -ENOBUFS; goto out; } -- cgit v0.10.2 From 4a287eba2de395713d8b2b2aeaa69fa086832d34 Mon Sep 17 00:00:00 2001 From: Matti Vaittinen Date: Mon, 14 Nov 2011 00:15:14 +0000 Subject: IPv6 routing, NLM_F_* flag support: REPLACE and EXCL flags support, warn about missing CREATE flag The support for NLM_F_* flags at IPv6 routing requests. If NLM_F_CREATE flag is not defined for RTM_NEWROUTE request, warning is printed, but no error is returned. Instead new route is added. Later NLM_F_CREATE may be required for new route creation. Exception is when NLM_F_REPLACE flag is given without NLM_F_CREATE, and no matching route is found. In this case it should be safe to assume that the request issuer is familiar with NLM_F_* flags, and does really not want route to be created. Specifying NLM_F_REPLACE flag will now make the kernel to search for matching route, and replace it with new one. If no route is found and NLM_F_CREATE is specified as well, then new route is created. Also, specifying NLM_F_EXCL will yield returning of error if matching route is found. Patch created against linux-3.2-rc1 Signed-off-by: Matti Vaittinen Signed-off-by: David S. Miller diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 93718f3..9239d55 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -425,7 +425,8 @@ out: static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr, int addrlen, int plen, - int offset) + int offset, int allow_create, + int replace_required) { struct fib6_node *fn, *in, *ln; struct fib6_node *pn = NULL; @@ -447,8 +448,12 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr, * Prefix match */ if (plen < fn->fn_bit || - !ipv6_prefix_equal(&key->addr, addr, fn->fn_bit)) + !ipv6_prefix_equal(&key->addr, addr, fn->fn_bit)) { + if (!allow_create) + printk(KERN_WARNING + "IPv6: NLM_F_CREATE should be set when creating new route\n"); goto insert_above; + } /* * Exact match ? @@ -477,10 +482,26 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr, fn = dir ? fn->right: fn->left; } while (fn); + if (replace_required && !allow_create) { + /* We should not create new node because + * NLM_F_REPLACE was specified without NLM_F_CREATE + * I assume it is safe to require NLM_F_CREATE when + * REPLACE flag is used! Later we may want to remove the + * check for replace_required, because according + * to netlink specification, NLM_F_CREATE + * MUST be specified if new route is created. + * That would keep IPv6 consistent with IPv4 + */ + printk(KERN_WARNING + "IPv6: NLM_F_CREATE should be set when creating new route - ignoring request\n"); + return ERR_PTR(-ENOENT); + } /* * We walked to the bottom of tree. * Create new leaf node without children. */ + if (!allow_create) + printk(KERN_WARNING "IPv6: NLM_F_CREATE should be set when creating new route\n"); ln = node_alloc(); @@ -614,6 +635,12 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, { struct rt6_info *iter = NULL; struct rt6_info **ins; + int replace = (NULL != info && + NULL != info->nlh && + (info->nlh->nlmsg_flags&NLM_F_REPLACE)); + int add = ((NULL == info || NULL == info->nlh) || + (info->nlh->nlmsg_flags&NLM_F_CREATE)); + int found = 0; ins = &fn->leaf; @@ -626,6 +653,13 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, /* * Same priority level */ + if (NULL != info->nlh && + (info->nlh->nlmsg_flags&NLM_F_EXCL)) + return -EEXIST; + if (replace) { + found++; + break; + } if (iter->rt6i_dev == rt->rt6i_dev && iter->rt6i_idev == rt->rt6i_idev && @@ -655,17 +689,40 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, /* * insert node */ + if (!replace) { + if (!add) + printk(KERN_WARNING "IPv6: NLM_F_CREATE should be set when creating new route\n"); + +add: + rt->dst.rt6_next = iter; + *ins = rt; + rt->rt6i_node = fn; + atomic_inc(&rt->rt6i_ref); + inet6_rt_notify(RTM_NEWROUTE, rt, info); + info->nl_net->ipv6.rt6_stats->fib_rt_entries++; + + if ((fn->fn_flags & RTN_RTINFO) == 0) { + info->nl_net->ipv6.rt6_stats->fib_route_nodes++; + fn->fn_flags |= RTN_RTINFO; + } - rt->dst.rt6_next = iter; - *ins = rt; - rt->rt6i_node = fn; - atomic_inc(&rt->rt6i_ref); - inet6_rt_notify(RTM_NEWROUTE, rt, info); - info->nl_net->ipv6.rt6_stats->fib_rt_entries++; - - if ((fn->fn_flags & RTN_RTINFO) == 0) { - info->nl_net->ipv6.rt6_stats->fib_route_nodes++; - fn->fn_flags |= RTN_RTINFO; + } else { + if (!found) { + if (add) + goto add; + printk(KERN_WARNING "IPv6: NLM_F_REPLACE set, but no existing node found!\n"); + return -ENOENT; + } + *ins = rt; + rt->rt6i_node = fn; + rt->dst.rt6_next = iter->dst.rt6_next; + atomic_inc(&rt->rt6i_ref); + inet6_rt_notify(RTM_NEWROUTE, rt, info); + rt6_release(iter); + if ((fn->fn_flags & RTN_RTINFO) == 0) { + info->nl_net->ipv6.rt6_stats->fib_route_nodes++; + fn->fn_flags |= RTN_RTINFO; + } } return 0; @@ -696,9 +753,25 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) { struct fib6_node *fn, *pn = NULL; int err = -ENOMEM; + int allow_create = 1; + int replace_required = 0; + if (NULL != info && NULL != info->nlh) { + if (!(info->nlh->nlmsg_flags&NLM_F_CREATE)) + allow_create = 0; + if ((info->nlh->nlmsg_flags&NLM_F_REPLACE)) + replace_required = 1; + } + if (!allow_create && !replace_required) + printk(KERN_WARNING "IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE\n"); fn = fib6_add_1(root, &rt->rt6i_dst.addr, sizeof(struct in6_addr), - rt->rt6i_dst.plen, offsetof(struct rt6_info, rt6i_dst)); + rt->rt6i_dst.plen, offsetof(struct rt6_info, rt6i_dst), + allow_create, replace_required); + + if (IS_ERR(fn)) { + err = PTR_ERR(fn); + fn = NULL; + } if (fn == NULL) goto out; @@ -736,7 +809,8 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) sn = fib6_add_1(sfn, &rt->rt6i_src.addr, sizeof(struct in6_addr), rt->rt6i_src.plen, - offsetof(struct rt6_info, rt6i_src)); + offsetof(struct rt6_info, rt6i_src), + allow_create, replace_required); if (sn == NULL) { /* If it is failed, discard just allocated @@ -753,8 +827,13 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) } else { sn = fib6_add_1(fn->subtree, &rt->rt6i_src.addr, sizeof(struct in6_addr), rt->rt6i_src.plen, - offsetof(struct rt6_info, rt6i_src)); + offsetof(struct rt6_info, rt6i_src), + allow_create, replace_required); + if (IS_ERR(sn)) { + err = PTR_ERR(sn); + sn = NULL; + } if (sn == NULL) goto st_failure; } -- cgit v0.10.2 From 5219e4c93c281377700206ae2b3ba4d91653d2ba Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Mon, 14 Nov 2011 14:36:40 -0500 Subject: bnx2x: add endline at end of message Reported-by: Joe Perches Signed-off-by: Dmitry Kravkov Signed-off-by: David S. Miller diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 80fb9b5..9090afc 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -8520,7 +8520,7 @@ sp_rtnl_not_reset: * damage */ if (test_and_clear_bit(BNX2X_SP_RTNL_FAN_FAILURE, &bp->sp_rtnl_state)) { - DP(BNX2X_MSG_SP, "fan failure detected. Unloading driver"); + DP(BNX2X_MSG_SP, "fan failure detected. Unloading driver\n"); netif_device_detach(bp->dev); bnx2x_close(bp->dev); } -- cgit v0.10.2 From ad79eefc42d56cb851a2b28a86e481cf1161005e Mon Sep 17 00:00:00 2001 From: "RongQing.Li" Date: Mon, 14 Nov 2011 14:37:24 -0500 Subject: ipv4: fix a memory leak in ic_bootp_send_if when dev_hard_header() failed, the newly allocated skb should be freed. Signed-off-by: RongQing.Li Signed-off-by: David S. Miller diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 0da2afc..7f17ba8 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -822,8 +822,13 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d skb->dev = dev; skb->protocol = htons(ETH_P_IP); if (dev_hard_header(skb, dev, ntohs(skb->protocol), - dev->broadcast, dev->dev_addr, skb->len) < 0 || - dev_queue_xmit(skb) < 0) + dev->broadcast, dev->dev_addr, skb->len) < 0) { + kfree_skb(skb); + printk("E"); + return; + } + + if (dev_queue_xmit(skb) < 0) printk("E"); } -- cgit v0.10.2 From abbb18fb4ad7472ee2e1351f0ca12bce64cac143 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Nov 2011 10:40:15 +0100 Subject: regmap: return ERR_PTR instead of NULL in regmap_init The regmap_init documentation states that it will either return a pointer to a valid regmap structure or a ERR_PTR in case of an error. Currently it returns a NULL pointer in case no bus or no config was given. Since NULL is not a ERR_PTR a caller might assume that it is a pointer to a valid regmap structure, so return a ERR_PTR(-EINVAL) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index b08df85..b84ebf9e 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -139,7 +139,7 @@ struct regmap *regmap_init(struct device *dev, int ret = -EINVAL; if (!bus || !config) - return NULL; + goto err; map = kzalloc(sizeof(*map), GFP_KERNEL); if (map == NULL) { -- cgit v0.10.2 From 021cd616decb4e8a4b31f1f8c466a847e8c04e67 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Nov 2011 10:40:16 +0100 Subject: regmap: Fix memory leak in regcache_hw_init error path Make sure reg_defaults_raw gets freed in case of an error. Signed-off-by: Lars-Peter Clausen Acked-by: Dimitris Papastamos Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 6ab9f03..7944626 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -61,8 +61,10 @@ static int regcache_hw_init(struct regmap *map) map->reg_defaults = kmalloc(count * sizeof(struct reg_default), GFP_KERNEL); - if (!map->reg_defaults) - return -ENOMEM; + if (!map->reg_defaults) { + ret = -ENOMEM; + goto err_free; + } /* fill the reg_defaults */ map->num_reg_defaults = count; @@ -77,6 +79,12 @@ static int regcache_hw_init(struct regmap *map) } return 0; + +err_free: + if (map->cache_free) + kfree(map->reg_defaults_raw); + + return ret; } int regcache_init(struct regmap *map) -- cgit v0.10.2 From bd061c78cabc28bb64ed79f784d24918b6bdb791 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Nov 2011 10:40:17 +0100 Subject: regmap: Fix memory leak in regcache_init error path Make sure all allocated memory gets freed again in case initializing the cache failed. Signed-off-by: Lars-Peter Clausen Acked-by: Dimitris Papastamos Signed-off-by: Mark Brown diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 7944626..27fae58 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -144,9 +144,18 @@ int regcache_init(struct regmap *map) if (map->cache_ops->init) { dev_dbg(map->dev, "Initializing %s cache\n", map->cache_ops->name); - return map->cache_ops->init(map); + ret = map->cache_ops->init(map); + if (ret) + goto err_free; } return 0; + +err_free: + kfree(map->reg_defaults); + if (map->cache_free) + kfree(map->reg_defaults_raw); + + return ret; } void regcache_exit(struct regmap *map) -- cgit v0.10.2 From fee005e5dd82a43546c1b1beb187e82415360940 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 15 Aug 2011 15:00:42 +0200 Subject: iwlegacy: remove tracing This is not useful. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index aef65cd..2a1ae10 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -43,23 +43,6 @@ config IWLWIFI_LEGACY_DEBUGFS is a low-impact option that allows getting insight into the driver's state at runtime. -config IWLWIFI_LEGACY_DEVICE_TRACING - bool "iwlwifilegacy legacy device access tracing" - depends on IWLWIFI_LEGACY - depends on EVENT_TRACING - help - Say Y here to trace all commands, including TX frames and IO - accesses, sent to the device. If you say yes, iwlwifilegacy will - register with the ftrace framework for event tracing and dump - all this information to the ringbuffer, you may need to - increase the ringbuffer size. See the ftrace documentation - for more information. - - When tracing is not enabled, this option still has some - (though rather small) overhead. - - If unsure, say Y so we can help you better when problems - occur. endmenu config IWL4965 diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index d56aeb3..4f67e45 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -3,12 +3,9 @@ iwl-legacy-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-legacy-objs += iwl-scan.o iwl-led.o iwl-legacy-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-debugfs.o -iwl-legacy-$(CONFIG_IWLWIFI_LEGACY_DEVICE_TRACING) += iwl-devtrace.o iwl-legacy-objs += $(iwl-legacy-m) -CFLAGS_iwl-devtrace.o := -I$(src) - # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := iwl-4965.o iwl4965-base.o iwl-4965-rs.o iwl-4965-led.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 7f12e36..e421fdf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -513,12 +513,6 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) pci_dma_sync_single_for_device(priv->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); - trace_iwlwifi_legacy_dev_tx(priv, - &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr], - sizeof(struct iwl_tfd), - &out_cmd->hdr, firstlen, - skb->data + hdr_len, secondlen); - /* Tell device the write index *just past* this latest filled TFD */ q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); iwl_legacy_txq_update_write_ptr(priv, txq); diff --git a/drivers/net/wireless/iwlegacy/iwl-devtrace.c b/drivers/net/wireless/iwlegacy/iwl-devtrace.c deleted file mode 100644 index acec991..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-devtrace.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include - -/* sparse doesn't like tracepoint macros */ -#ifndef __CHECKER__ -#include "iwl-dev.h" - -#define CREATE_TRACE_POINTS -#include "iwl-devtrace.h" - -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_iowrite8); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ioread32); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_iowrite32); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_rx); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_tx); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_error); -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-devtrace.h b/drivers/net/wireless/iwlegacy/iwl-devtrace.h deleted file mode 100644 index a443725..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-devtrace.h +++ /dev/null @@ -1,210 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#if !defined(__IWLWIFI_LEGACY_DEVICE_TRACE) || defined(TRACE_HEADER_MULTI_READ) -#define __IWLWIFI_LEGACY_DEVICE_TRACE - -#include - -#if !defined(CONFIG_IWLWIFI_LEGACY_DEVICE_TRACING) || defined(__CHECKER__) -#undef TRACE_EVENT -#define TRACE_EVENT(name, proto, ...) \ -static inline void trace_ ## name(proto) {} -#endif - - -#define PRIV_ENTRY __field(struct iwl_priv *, priv) -#define PRIV_ASSIGN (__entry->priv = priv) - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM iwlwifi_legacy_io - -TRACE_EVENT(iwlwifi_legacy_dev_ioread32, - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), - TP_ARGS(priv, offs, val), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, offs) - __field(u32, val) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->offs = offs; - __entry->val = val; - ), - TP_printk("[%p] read io[%#x] = %#x", __entry->priv, - __entry->offs, __entry->val) -); - -TRACE_EVENT(iwlwifi_legacy_dev_iowrite8, - TP_PROTO(struct iwl_priv *priv, u32 offs, u8 val), - TP_ARGS(priv, offs, val), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, offs) - __field(u8, val) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->offs = offs; - __entry->val = val; - ), - TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, - __entry->offs, __entry->val) -); - -TRACE_EVENT(iwlwifi_legacy_dev_iowrite32, - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), - TP_ARGS(priv, offs, val), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, offs) - __field(u32, val) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->offs = offs; - __entry->val = val; - ), - TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, - __entry->offs, __entry->val) -); - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM iwlwifi_legacy_ucode - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM iwlwifi - -TRACE_EVENT(iwlwifi_legacy_dev_hcmd, - TP_PROTO(struct iwl_priv *priv, void *hcmd, size_t len, u32 flags), - TP_ARGS(priv, hcmd, len, flags), - TP_STRUCT__entry( - PRIV_ENTRY - __dynamic_array(u8, hcmd, len) - __field(u32, flags) - ), - TP_fast_assign( - PRIV_ASSIGN; - memcpy(__get_dynamic_array(hcmd), hcmd, len); - __entry->flags = flags; - ), - TP_printk("[%p] hcmd %#.2x (%ssync)", - __entry->priv, ((u8 *)__get_dynamic_array(hcmd))[0], - __entry->flags & CMD_ASYNC ? "a" : "") -); - -TRACE_EVENT(iwlwifi_legacy_dev_rx, - TP_PROTO(struct iwl_priv *priv, void *rxbuf, size_t len), - TP_ARGS(priv, rxbuf, len), - TP_STRUCT__entry( - PRIV_ENTRY - __dynamic_array(u8, rxbuf, len) - ), - TP_fast_assign( - PRIV_ASSIGN; - memcpy(__get_dynamic_array(rxbuf), rxbuf, len); - ), - TP_printk("[%p] RX cmd %#.2x", - __entry->priv, ((u8 *)__get_dynamic_array(rxbuf))[4]) -); - -TRACE_EVENT(iwlwifi_legacy_dev_tx, - TP_PROTO(struct iwl_priv *priv, void *tfd, size_t tfdlen, - void *buf0, size_t buf0_len, - void *buf1, size_t buf1_len), - TP_ARGS(priv, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len), - TP_STRUCT__entry( - PRIV_ENTRY - - __field(size_t, framelen) - __dynamic_array(u8, tfd, tfdlen) - - /* - * Do not insert between or below these items, - * we want to keep the frame together (except - * for the possible padding). - */ - __dynamic_array(u8, buf0, buf0_len) - __dynamic_array(u8, buf1, buf1_len) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->framelen = buf0_len + buf1_len; - memcpy(__get_dynamic_array(tfd), tfd, tfdlen); - memcpy(__get_dynamic_array(buf0), buf0, buf0_len); - memcpy(__get_dynamic_array(buf1), buf1, buf1_len); - ), - TP_printk("[%p] TX %.2x (%zu bytes)", - __entry->priv, - ((u8 *)__get_dynamic_array(buf0))[0], - __entry->framelen) -); - -TRACE_EVENT(iwlwifi_legacy_dev_ucode_error, - TP_PROTO(struct iwl_priv *priv, u32 desc, u32 time, - u32 data1, u32 data2, u32 line, u32 blink1, - u32 blink2, u32 ilink1, u32 ilink2), - TP_ARGS(priv, desc, time, data1, data2, line, - blink1, blink2, ilink1, ilink2), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, desc) - __field(u32, time) - __field(u32, data1) - __field(u32, data2) - __field(u32, line) - __field(u32, blink1) - __field(u32, blink2) - __field(u32, ilink1) - __field(u32, ilink2) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->desc = desc; - __entry->time = time; - __entry->data1 = data1; - __entry->data2 = data2; - __entry->line = line; - __entry->blink1 = blink1; - __entry->blink2 = blink2; - __entry->ilink1 = ilink1; - __entry->ilink2 = ilink2; - ), - TP_printk("[%p] #%02d %010u data 0x%08X 0x%08X line %u, " - "blink 0x%05X 0x%05X ilink 0x%05X 0x%05X", - __entry->priv, __entry->desc, __entry->time, __entry->data1, - __entry->data2, __entry->line, __entry->blink1, - __entry->blink2, __entry->ilink1, __entry->ilink2) -); - -#endif /* __IWLWIFI_DEVICE_TRACE */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE iwl-devtrace -#include diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 5cc5d34..868ef01 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -33,7 +33,6 @@ #include "iwl-dev.h" #include "iwl-debug.h" -#include "iwl-devtrace.h" /* * IO, register, and NIC memory access functions @@ -65,7 +64,6 @@ static inline void _iwl_legacy_write8(struct iwl_priv *priv, u32 ofs, u8 val) { - trace_iwlwifi_legacy_dev_iowrite8(priv, ofs, val); iowrite8(val, priv->hw_base + ofs); } @@ -86,7 +84,6 @@ __iwl_legacy_write8(const char *f, u32 l, struct iwl_priv *priv, static inline void _iwl_legacy_write32(struct iwl_priv *priv, u32 ofs, u32 val) { - trace_iwlwifi_legacy_dev_iowrite32(priv, ofs, val); iowrite32(val, priv->hw_base + ofs); } @@ -107,7 +104,6 @@ __iwl_legacy_write32(const char *f, u32 l, struct iwl_priv *priv, static inline u32 _iwl_legacy_read32(struct iwl_priv *priv, u32 ofs) { u32 val = ioread32(priv->hw_base + ofs); - trace_iwlwifi_legacy_dev_ioread32(priv, ofs, val); return val; } diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index ef9e268..e1a559b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -539,9 +539,6 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) dma_unmap_addr_set(out_meta, mapping, phys_addr); dma_unmap_len_set(out_meta, len, fix_size); - trace_iwlwifi_legacy_dev_hcmd(priv, &out_cmd->hdr, - fix_size, cmd->flags); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, phys_addr, fix_size, 1, U32_PAD(cmd->len)); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index b282d86..7507819 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1246,7 +1246,6 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ - trace_iwlwifi_legacy_dev_rx(priv, pkt, len); /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -1403,8 +1402,6 @@ void iwl3945_dump_nic_error_log(struct iwl_priv *priv) "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", iwl3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); - trace_iwlwifi_legacy_dev_ucode_error(priv, desc, time, data1, 0, - 0, blink1, blink2, ilink1, ilink2); } } diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d2fba9e..fd2f7a4 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -679,7 +679,6 @@ void iwl4965_rx_handle(struct iwl_priv *priv) len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ - trace_iwlwifi_legacy_dev_rx(priv, pkt, len); /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -1569,10 +1568,6 @@ void iwl4965_dump_nic_error_log(struct iwl_priv *priv) time = iwl_legacy_read_targ_mem(priv, base + 11 * sizeof(u32)); hcmd = iwl_legacy_read_targ_mem(priv, base + 22 * sizeof(u32)); - trace_iwlwifi_legacy_dev_ucode_error(priv, desc, - time, data1, data2, line, - blink1, blink2, ilink1, ilink2); - IWL_ERR(priv, "Desc Time " "data1 data2 line\n"); IWL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", -- cgit v0.10.2 From e2ebc8337d116acdc25469ec8547ae665f50a4c1 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 24 Oct 2011 15:41:30 +0200 Subject: iwlegacy: rename iwl to il iwl_legacy prefix result in long function names, what cause that we have frequent line split and not readable code. Also iwl_foo symbols are duplicated in iwlwifi driver, what is annoying when editing kernel tree with cscope. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index cfabb38..954aed4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -29,7 +29,7 @@ #include "iwl-3945-debugfs.h" -static int iwl3945_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) +static int il3945_statistics_flag(struct il_priv *priv, char *buf, int bufsz) { int p = 0; @@ -50,11 +50,11 @@ static int iwl3945_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) return p; } -ssize_t iwl3945_ucode_rx_stats_read(struct file *file, +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 + @@ -66,12 +66,12 @@ ssize_t iwl3945_ucode_rx_stats_read(struct file *file, struct iwl39_statistics_rx_non_phy *general, *accum_general; struct iwl39_statistics_rx_non_phy *delta_general, *max_general; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -93,7 +93,7 @@ ssize_t iwl3945_ucode_rx_stats_read(struct file *file, max_cck = &priv->_3945.max_delta.rx.cck; max_general = &priv->_3945.max_delta.rx.general; - pos += iwl3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Rx - OFDM:"); @@ -325,23 +325,23 @@ ssize_t iwl3945_ucode_rx_stats_read(struct file *file, return ret; } -ssize_t iwl3945_ucode_tx_stats_read(struct file *file, +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250; ssize_t ret; struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -354,7 +354,7 @@ ssize_t iwl3945_ucode_tx_stats_read(struct file *file, accum_tx = &priv->_3945.accum_statistics.tx; delta_tx = &priv->_3945.delta_statistics.tx; max_tx = &priv->_3945.max_delta.tx; - pos += iwl3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Tx:"); @@ -421,11 +421,11 @@ ssize_t iwl3945_ucode_tx_stats_read(struct file *file, return ret; } -ssize_t iwl3945_ucode_general_stats_read(struct file *file, +ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300; @@ -435,12 +435,12 @@ ssize_t iwl3945_ucode_general_stats_read(struct file *file, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -461,7 +461,7 @@ ssize_t iwl3945_ucode_general_stats_read(struct file *file, accum_div = &priv->_3945.accum_statistics.general.div; delta_div = &priv->_3945.delta_statistics.general.div; max_div = &priv->_3945.max_delta.general.div; - pos += iwl3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_General:"); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h index 8fef4b3..54334ac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h @@ -31,27 +31,27 @@ #include "iwl-debug.h" #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -ssize_t iwl3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl3945_ucode_general_stats_read(struct file *file, +ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); #else -static ssize_t iwl3945_ucode_rx_stats_read(struct file *file, +static ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } -static ssize_t iwl3945_ucode_tx_stats_read(struct file *file, +static ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } -static ssize_t iwl3945_ucode_general_stats_read(struct file *file, +static ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h index 836c991..b98cabb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ -#ifndef __iwl_3945_fh_h__ -#define __iwl_3945_fh_h__ +#ifndef __il_3945_fh_h__ +#define __il_3945_fh_h__ /************************************/ /* iwl3945 Flow Handler Definitions */ @@ -172,16 +172,16 @@ #define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) -struct iwl3945_tfd_tb { +struct il3945_tfd_tb { __le32 addr; __le32 len; } __packed; -struct iwl3945_tfd { +struct il3945_tfd { __le32 control_flags; - struct iwl3945_tfd_tb tbs[4]; + struct il3945_tfd_tb tbs[4]; u8 __pad[28]; } __packed; -#endif /* __iwl_3945_fh_h__ */ +#endif /* __il_3945_fh_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index 5c3a68d..ad05093 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -66,8 +66,8 @@ * Please use iwl-3945.h for driver implementation definitions. */ -#ifndef __iwl_3945_hw__ -#define __iwl_3945_hw__ +#ifndef __il_3945_hw__ +#define __il_3945_hw__ #include "iwl-eeprom.h" @@ -90,7 +90,7 @@ * Data copied from EEPROM. * DO NOT ALTER THIS STRUCTURE!!! */ -struct iwl3945_eeprom_txpower_sample { +struct il3945_eeprom_txpower_sample { u8 gain_index; /* index into power (gain) setup table ... */ s8 power; /* ... for this pwr level for this chnl group */ u16 v_det; /* PA output voltage */ @@ -104,8 +104,8 @@ struct iwl3945_eeprom_txpower_sample { * Data copied from EEPROM. * DO NOT ALTER THIS STRUCTURE!!! */ -struct iwl3945_eeprom_txpower_group { - struct iwl3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ +struct il3945_eeprom_txpower_group { + struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ s32 a, b, c, d, e; /* coefficients for voltage->power * formula (signed) */ s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on @@ -123,7 +123,7 @@ struct iwl3945_eeprom_txpower_group { * difference between current temperature and factory calib temperature. * Data copied from EEPROM. */ -struct iwl3945_eeprom_temperature_corr { +struct il3945_eeprom_temperature_corr { u32 Ta; u32 Tb; u32 Tc; @@ -134,7 +134,7 @@ struct iwl3945_eeprom_temperature_corr { /* * EEPROM map */ -struct iwl3945_eeprom { +struct il3945_eeprom { u8 reserved0[16]; u16 device_id; /* abs.ofs: 16 */ u8 reserved1[2]; @@ -171,7 +171,7 @@ struct iwl3945_eeprom { * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ u16 band_1_count; /* abs.ofs: 196 */ - struct iwl_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ + struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ /* * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, @@ -179,38 +179,38 @@ struct iwl3945_eeprom { * (4915-5080MHz) (none of these is ever supported) */ u16 band_2_count; /* abs.ofs: 226 */ - struct iwl_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ + struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ /* * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 * (5170-5320MHz) */ u16 band_3_count; /* abs.ofs: 254 */ - struct iwl_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ + struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ /* * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 * (5500-5700MHz) */ u16 band_4_count; /* abs.ofs: 280 */ - struct iwl_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ + struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ /* * 5.7 GHz channels 145, 149, 153, 157, 161, 165 * (5725-5825MHz) */ u16 band_5_count; /* abs.ofs: 304 */ - struct iwl_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ + struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ u8 reserved9[194]; /* * 3945 Txpower calibration data. */ -#define IWL_NUM_TX_CALIB_GROUPS 5 - struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS]; +#define IL_NUM_TX_CALIB_GROUPS 5 + struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; /* abs.ofs: 512 */ - struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ + struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ u8 reserved16[172]; /* fill out to full 1024 byte block */ } __packed; @@ -225,7 +225,7 @@ struct iwl3945_eeprom { #define IWL39_NUM_QUEUES 5 #define IWL39_CMD_QUEUE_NUM 4 -#define IWL_DEFAULT_TX_RETRY 15 +#define IL_DEFAULT_TX_RETRY 15 /*********************************************/ @@ -262,29 +262,29 @@ struct iwl3945_eeprom { /* Size of uCode instruction memory in bootstrap state machine */ #define IWL39_MAX_BSM_SIZE IWL39_RTC_INST_SIZE -static inline int iwl3945_hw_valid_rtc_data_addr(u32 addr) +static inline int il3945_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IWL39_RTC_DATA_LOWER_BOUND) && (addr < IWL39_RTC_DATA_UPPER_BOUND); } -/* Base physical address of iwl3945_shared is provided to FH_TSSR_CBB_BASE - * and &iwl3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ -struct iwl3945_shared { +/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE + * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ +struct il3945_shared { __le32 tx_base_ptr[8]; } __packed; -static inline u8 iwl3945_hw_get_rate(__le16 rate_n_flags) +static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags) & 0xFF; } -static inline u16 iwl3945_hw_get_rate_n_flags(__le16 rate_n_flags) +static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags); } -static inline __le16 iwl3945_hw_set_rate_n_flags(u8 rate, u16 flags) +static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) { return cpu_to_le16((u16)rate|flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.c b/drivers/net/wireless/iwlegacy/iwl-3945-led.c index 7a7f0f3..69703b0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-led.c @@ -44,20 +44,20 @@ /* Send led command */ -static int iwl3945_send_led_cmd(struct iwl_priv *priv, - struct iwl_led_cmd *led_cmd) +static int il3945_send_led_cmd(struct il_priv *priv, + struct il_led_cmd *led_cmd) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_LEDS_CMD, - .len = sizeof(struct iwl_led_cmd), + .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, .callback = NULL, }; - return iwl_legacy_send_cmd(priv, &cmd); + return il_send_cmd(priv, &cmd); } -const struct iwl_led_ops iwl3945_led_ops = { - .cmd = iwl3945_send_led_cmd, +const struct il_led_ops il3945_led_ops = { + .cmd = il3945_send_led_cmd, }; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.h b/drivers/net/wireless/iwlegacy/iwl-3945-led.h index 9671627..369c72d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-led.h @@ -24,9 +24,9 @@ * *****************************************************************************/ -#ifndef __iwl_3945_led_h__ -#define __iwl_3945_led_h__ +#ifndef __il_3945_led_h__ +#define __il_3945_led_h__ -extern const struct iwl_led_ops iwl3945_led_ops; +extern const struct il_led_ops il3945_led_ops; -#endif /* __iwl_3945_led_h__ */ +#endif /* __il_3945_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 8faeaf2..d97f24b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -42,80 +42,80 @@ #define RS_NAME "iwl-3945-rs" -static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g[IL_RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 }; -static s32 iwl3945_expected_tpt_g_prot[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g_prot[IL_RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 }; -static s32 iwl3945_expected_tpt_a[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_a[IL_RATE_COUNT_3945] = { 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 }; -static s32 iwl3945_expected_tpt_b[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_b[IL_RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 }; -struct iwl3945_tpt_entry { +struct il3945_tpt_entry { s8 min_rssi; u8 index; }; -static struct iwl3945_tpt_entry iwl3945_tpt_table_a[] = { - {-60, IWL_RATE_54M_INDEX}, - {-64, IWL_RATE_48M_INDEX}, - {-72, IWL_RATE_36M_INDEX}, - {-80, IWL_RATE_24M_INDEX}, - {-84, IWL_RATE_18M_INDEX}, - {-85, IWL_RATE_12M_INDEX}, - {-87, IWL_RATE_9M_INDEX}, - {-89, IWL_RATE_6M_INDEX} +static struct il3945_tpt_entry il3945_tpt_table_a[] = { + {-60, IL_RATE_54M_INDEX}, + {-64, IL_RATE_48M_INDEX}, + {-72, IL_RATE_36M_INDEX}, + {-80, IL_RATE_24M_INDEX}, + {-84, IL_RATE_18M_INDEX}, + {-85, IL_RATE_12M_INDEX}, + {-87, IL_RATE_9M_INDEX}, + {-89, IL_RATE_6M_INDEX} }; -static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { - {-60, IWL_RATE_54M_INDEX}, - {-64, IWL_RATE_48M_INDEX}, - {-68, IWL_RATE_36M_INDEX}, - {-80, IWL_RATE_24M_INDEX}, - {-84, IWL_RATE_18M_INDEX}, - {-85, IWL_RATE_12M_INDEX}, - {-86, IWL_RATE_11M_INDEX}, - {-88, IWL_RATE_5M_INDEX}, - {-90, IWL_RATE_2M_INDEX}, - {-92, IWL_RATE_1M_INDEX} +static struct il3945_tpt_entry il3945_tpt_table_g[] = { + {-60, IL_RATE_54M_INDEX}, + {-64, IL_RATE_48M_INDEX}, + {-68, IL_RATE_36M_INDEX}, + {-80, IL_RATE_24M_INDEX}, + {-84, IL_RATE_18M_INDEX}, + {-85, IL_RATE_12M_INDEX}, + {-86, IL_RATE_11M_INDEX}, + {-88, IL_RATE_5M_INDEX}, + {-90, IL_RATE_2M_INDEX}, + {-92, IL_RATE_1M_INDEX} }; -#define IWL_RATE_MAX_WINDOW 62 -#define IWL_RATE_FLUSH (3*HZ) -#define IWL_RATE_WIN_FLUSH (HZ/2) +#define IL_RATE_MAX_WINDOW 62 +#define IL_RATE_FLUSH (3*HZ) +#define IL_RATE_WIN_FLUSH (HZ/2) #define IWL39_RATE_HIGH_TH 11520 -#define IWL_SUCCESS_UP_TH 8960 -#define IWL_SUCCESS_DOWN_TH 10880 -#define IWL_RATE_MIN_FAILURE_TH 6 -#define IWL_RATE_MIN_SUCCESS_TH 8 -#define IWL_RATE_DECREASE_TH 1920 -#define IWL_RATE_RETRY_TH 15 - -static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) +#define IL_SUCCESS_UP_TH 8960 +#define IL_SUCCESS_DOWN_TH 10880 +#define IL_RATE_MIN_FAILURE_TH 6 +#define IL_RATE_MIN_SUCCESS_TH 8 +#define IL_RATE_DECREASE_TH 1920 +#define IL_RATE_RETRY_TH 15 + +static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) { u32 index = 0; u32 table_size = 0; - struct iwl3945_tpt_entry *tpt_table = NULL; + struct il3945_tpt_entry *tpt_table = NULL; - if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) - rssi = IWL_MIN_RSSI_VAL; + if ((rssi < IL_MIN_RSSI_VAL) || (rssi > IL_MAX_RSSI_VAL)) + rssi = IL_MIN_RSSI_VAL; switch (band) { case IEEE80211_BAND_2GHZ: - tpt_table = iwl3945_tpt_table_g; - table_size = ARRAY_SIZE(iwl3945_tpt_table_g); + tpt_table = il3945_tpt_table_g; + table_size = ARRAY_SIZE(il3945_tpt_table_g); break; case IEEE80211_BAND_5GHZ: - tpt_table = iwl3945_tpt_table_a; - table_size = ARRAY_SIZE(iwl3945_tpt_table_a); + tpt_table = il3945_tpt_table_a; + table_size = ARRAY_SIZE(il3945_tpt_table_a); break; default: @@ -131,46 +131,46 @@ static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) return tpt_table[index].index; } -static void iwl3945_clear_window(struct iwl3945_rate_scale_data *window) +static void il3945_clear_window(struct il3945_rate_scale_data *window) { window->data = 0; window->success_counter = 0; window->success_ratio = -1; window->counter = 0; - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; window->stamp = 0; } /** - * iwl3945_rate_scale_flush_windows - flush out the rate scale windows + * il3945_rate_scale_flush_windows - flush out the rate scale windows * * Returns the number of windows that have gathered data but were * not flushed. If there were any that were not flushed, then * reschedule the rate flushing routine. */ -static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta) +static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) { int unflushed = 0; int i; unsigned long flags; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *priv __maybe_unused = rs_sta->priv; /* * For each rate, if we have collected data on that rate - * and it has been more than IWL_RATE_WIN_FLUSH + * and it has been more than IL_RATE_WIN_FLUSH * since we flushed, clear out the gathered statistics */ - for (i = 0; i < IWL_RATE_COUNT_3945; i++) { + for (i = 0; i < IL_RATE_COUNT_3945; i++) { if (!rs_sta->win[i].counter) continue; spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + - IWL_RATE_WIN_FLUSH)) { - IWL_DEBUG_RATE(priv, "flushing %d samples of rate " + IL_RATE_WIN_FLUSH)) { + IL_DEBUG_RATE(priv, "flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); - iwl3945_clear_window(&rs_sta->win[i]); + il3945_clear_window(&rs_sta->win[i]); } else unflushed++; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -179,21 +179,21 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta) return unflushed; } -#define IWL_RATE_FLUSH_MAX 5000 /* msec */ -#define IWL_RATE_FLUSH_MIN 50 /* msec */ -#define IWL_AVERAGE_PACKETS 1500 +#define IL_RATE_FLUSH_MAX 5000 /* msec */ +#define IL_RATE_FLUSH_MIN 50 /* msec */ +#define IL_AVERAGE_PACKETS 1500 -static void iwl3945_bg_rate_scale_flush(unsigned long data) +static void il3945_bg_rate_scale_flush(unsigned long data) { - struct iwl3945_rs_sta *rs_sta = (void *)data; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + struct il3945_rs_sta *rs_sta = (void *)data; + struct il_priv *priv __maybe_unused = rs_sta->priv; int unflushed = 0; unsigned long flags; u32 packet_count, duration, pps; - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); - unflushed = iwl3945_rate_scale_flush_windows(rs_sta); + unflushed = il3945_rate_scale_flush_windows(rs_sta); spin_lock_irqsave(&rs_sta->lock, flags); @@ -206,7 +206,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - IWL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n", + IL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ @@ -216,17 +216,17 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) pps = 0; if (pps) { - duration = (IWL_AVERAGE_PACKETS * 1000) / pps; - if (duration < IWL_RATE_FLUSH_MIN) - duration = IWL_RATE_FLUSH_MIN; - else if (duration > IWL_RATE_FLUSH_MAX) - duration = IWL_RATE_FLUSH_MAX; + duration = (IL_AVERAGE_PACKETS * 1000) / pps; + if (duration < IL_RATE_FLUSH_MIN) + duration = IL_RATE_FLUSH_MIN; + else if (duration > IL_RATE_FLUSH_MAX) + duration = IL_RATE_FLUSH_MAX; } else - duration = IWL_RATE_FLUSH_MAX; + duration = IL_RATE_FLUSH_MAX; rs_sta->flush_time = msecs_to_jiffies(duration); - IWL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n", + IL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n", duration, packet_count); mod_timer(&rs_sta->rate_scale_flush, jiffies + @@ -234,7 +234,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) rs_sta->last_partial_flush = jiffies; } else { - rs_sta->flush_time = IWL_RATE_FLUSH; + rs_sta->flush_time = IL_RATE_FLUSH; rs_sta->flush_pending = 0; } /* If there weren't any unflushed entries, we don't schedule the timer @@ -244,26 +244,26 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) spin_unlock_irqrestore(&rs_sta->lock, flags); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "leave\n"); } /** - * iwl3945_collect_tx_data - Update the success/failure sliding window + * il3945_collect_tx_data - Update the success/failure sliding window * * We keep a sliding window of the last 64 packets transmitted * at this rate. window->data contains the bitmask of successful * packets. */ -static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, - struct iwl3945_rate_scale_data *window, +static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, + struct il3945_rate_scale_data *window, int success, int retries, int index) { unsigned long flags; s32 fail_count; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *priv __maybe_unused = rs_sta->priv; if (!retries) { - IWL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n"); + IL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n"); return; } @@ -278,13 +278,13 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, * we keep these bitmaps!). * */ while (retries > 0) { - if (window->counter >= IWL_RATE_MAX_WINDOW) { + if (window->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IWL_RATE_MAX_WINDOW - 1; + window->counter = IL_RATE_MAX_WINDOW - 1; - if (window->data & (1ULL << (IWL_RATE_MAX_WINDOW - 1))) { - window->data &= ~(1ULL << (IWL_RATE_MAX_WINDOW - 1)); + if (window->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { + window->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); window->success_counter--; } } @@ -310,17 +310,17 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, window->success_ratio = 128 * (100 * window->success_counter) / window->counter; else - window->success_ratio = IWL_INVALID_VALUE; + window->success_ratio = IL_INVALID_VALUE; fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IWL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH)) + if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || + (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) window->average_tpt = ((window->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; /* Tag this window as having been updated */ window->stamp = jiffies; @@ -332,40 +332,40 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, /* * Called after adding a new station to initialize rate scaling */ -void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_id) +void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id) { struct ieee80211_hw *hw = priv->hw; struct ieee80211_conf *conf = &priv->hw->conf; - struct iwl3945_sta_priv *psta; - struct iwl3945_rs_sta *rs_sta; + struct il3945_sta_priv *psta; + struct il3945_rs_sta *rs_sta; struct ieee80211_supported_band *sband; int i; - IWL_DEBUG_INFO(priv, "enter\n"); - if (sta_id == priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id) + IL_DEBUG_INFO(priv, "enter\n"); + if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) goto out; - psta = (struct iwl3945_sta_priv *) sta->drv_priv; + psta = (struct il3945_sta_priv *) sta->drv_priv; rs_sta = &psta->rs_sta; sband = hw->wiphy->bands[conf->channel->band]; rs_sta->priv = priv; - rs_sta->start_rate = IWL_RATE_INVALID; + rs_sta->start_rate = IL_RATE_INVALID; /* default to just 802.11b */ - rs_sta->expected_tpt = iwl3945_expected_tpt_b; + rs_sta->expected_tpt = il3945_expected_tpt_b; rs_sta->last_partial_flush = jiffies; rs_sta->last_flush = jiffies; - rs_sta->flush_time = IWL_RATE_FLUSH; + rs_sta->flush_time = IL_RATE_FLUSH; rs_sta->last_tx_packets = 0; rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; - rs_sta->rate_scale_flush.function = iwl3945_bg_rate_scale_flush; + rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; - for (i = 0; i < IWL_RATE_COUNT_3945; i++) - iwl3945_clear_window(&rs_sta->win[i]); + for (i = 0; i < IL_RATE_COUNT_3945; i++) + il3945_clear_window(&rs_sta->win[i]); /* TODO: what is a good starting rate for STA? About middle? Maybe not * the lowest or the highest rate.. Could consider using RSSI from @@ -380,56 +380,56 @@ void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 s } priv->_3945.sta_supp_rates = sta->supp_rates[sband->band]; - /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ + /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ if (sband->band == IEEE80211_BAND_5GHZ) { - rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; + rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; priv->_3945.sta_supp_rates = priv->_3945.sta_supp_rates << - IWL_FIRST_OFDM_RATE; + IL_FIRST_OFDM_RATE; } out: - priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - IWL_DEBUG_INFO(priv, "leave\n"); + IL_DEBUG_INFO(priv, "leave\n"); } -static void *iwl3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } /* rate scale requires free function to be implemented */ -static void iwl3945_rs_free(void *priv) +static void il3945_rs_free(void *priv) { return; } -static void *iwl3945_rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp) +static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) { - struct iwl3945_rs_sta *rs_sta; - struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; - struct iwl_priv *priv __maybe_unused = iwl_priv; + struct il3945_rs_sta *rs_sta; + struct il3945_sta_priv *psta = (void *) sta->drv_priv; + struct il_priv *priv __maybe_unused = il_priv; - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); rs_sta = &psta->rs_sta; spin_lock_init(&rs_sta->lock); init_timer(&rs_sta->rate_scale_flush); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "leave\n"); return rs_sta; } -static void iwl3945_rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, +static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, void *priv_sta) { - struct iwl3945_rs_sta *rs_sta = priv_sta; + struct il3945_rs_sta *rs_sta = priv_sta; /* - * Be careful not to use any members of iwl3945_rs_sta (like trying - * to use iwl_priv to print out debugging) since it may not be fully + * Be careful not to use any members of il3945_rs_sta (like trying + * to use il_priv to print out debugging) since it may not be fully * initialized at this point. */ del_timer_sync(&rs_sta->rate_scale_flush); @@ -437,43 +437,43 @@ static void iwl3945_rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, /** - * iwl3945_rs_tx_status - Update rate control values based on Tx results + * il3945_rs_tx_status - Update rate control values based on Tx results * - * NOTE: Uses iwl_priv->retry_rate for the # of retries attempted by + * NOTE: Uses il_priv->retry_rate for the # of retries attempted by * the hardware for each rate. */ -static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, +static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta, struct sk_buff *skb) { s8 retries = 0, current_count; int scale_rate_index, first_index, last_index; unsigned long flags; - struct iwl_priv *priv = (struct iwl_priv *)priv_rate; - struct iwl3945_rs_sta *rs_sta = priv_sta; + struct il_priv *priv = (struct il_priv *)priv_rate; + struct il3945_rs_sta *rs_sta = priv_sta; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); retries = info->status.rates[0].count; /* Sanity Check for retries */ - if (retries > IWL_RATE_RETRY_TH) - retries = IWL_RATE_RETRY_TH; + if (retries > IL_RATE_RETRY_TH) + retries = IL_RATE_RETRY_TH; first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if ((first_index < 0) || (first_index >= IWL_RATE_COUNT_3945)) { - IWL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index); + if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { + IL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index); return; } if (!priv_sta) { - IWL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n"); + IL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n"); return; } /* Treat uninitialized rate scaling data same as non-existing. */ if (!rs_sta->priv) { - IWL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); + IL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); return; } @@ -499,16 +499,16 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban last_index = scale_rate_index; } else { current_count = priv->retry_rate; - last_index = iwl3945_rs_next_rate(priv, + last_index = il3945_rs_next_rate(priv, scale_rate_index); } /* Update this rate accounting for as many retries * as was used for it (per current_count) */ - iwl3945_collect_tx_data(rs_sta, + il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_index], 0, current_count, scale_rate_index); - IWL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n", + IL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n", scale_rate_index, current_count); retries -= current_count; @@ -518,11 +518,11 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban /* Update the last index window with success/failure based on ACK */ - IWL_DEBUG_RATE(priv, "Update rate %d with %s.\n", + IL_DEBUG_RATE(priv, "Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); - iwl3945_collect_tx_data(rs_sta, + il3945_collect_tx_data(rs_sta, &rs_sta->win[last_index], info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); @@ -543,15 +543,15 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban spin_unlock_irqrestore(&rs_sta->lock, flags); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "leave\n"); } -static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, +static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u8 index, u16 rate_mask, enum ieee80211_band band) { - u8 high = IWL_RATE_INVALID; - u8 low = IWL_RATE_INVALID; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + u8 high = IL_RATE_INVALID; + u8 low = IL_RATE_INVALID; + struct il_priv *priv __maybe_unused = rs_sta->priv; /* 802.11A walks to the next literal adjacent rate in * the rate table */ @@ -570,7 +570,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IWL_RATE_COUNT_3945; + for (mask = (1 << i); i < IL_RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { high = i; @@ -582,36 +582,36 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, } low = index; - while (low != IWL_RATE_INVALID) { + while (low != IL_RATE_INVALID) { if (rs_sta->tgg) - low = iwl3945_rates[low].prev_rs_tgg; + low = il3945_rates[low].prev_rs_tgg; else - low = iwl3945_rates[low].prev_rs; - if (low == IWL_RATE_INVALID) + low = il3945_rates[low].prev_rs; + if (low == IL_RATE_INVALID) break; if (rate_mask & (1 << low)) break; - IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); } high = index; - while (high != IWL_RATE_INVALID) { + while (high != IL_RATE_INVALID) { if (rs_sta->tgg) - high = iwl3945_rates[high].next_rs_tgg; + high = il3945_rates[high].next_rs_tgg; else - high = iwl3945_rates[high].next_rs; - if (high == IWL_RATE_INVALID) + high = il3945_rates[high].next_rs; + if (high == IL_RATE_INVALID) break; if (rate_mask & (1 << high)) break; - IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; } /** - * iwl3945_rs_get_rate - find the rate for the requested packet + * il3945_rs_get_rate - find the rate for the requested packet * * Returns the ieee80211_rate structure allocated by the driver. * @@ -626,33 +626,33 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, * rate table and must reference the driver allocated rate table * */ -static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, +static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, struct ieee80211_tx_rate_control *txrc) { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; - u8 low = IWL_RATE_INVALID; - u8 high = IWL_RATE_INVALID; + u8 low = IL_RATE_INVALID; + u8 high = IL_RATE_INVALID; u16 high_low; int index; - struct iwl3945_rs_sta *rs_sta = priv_sta; - struct iwl3945_rate_scale_data *window = NULL; - int current_tpt = IWL_INVALID_VALUE; - int low_tpt = IWL_INVALID_VALUE; - int high_tpt = IWL_INVALID_VALUE; + struct il3945_rs_sta *rs_sta = priv_sta; + struct il3945_rate_scale_data *window = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; u32 fail_count; s8 scale_action = 0; unsigned long flags; u16 rate_mask; s8 max_rate_idx = -1; - struct iwl_priv *priv __maybe_unused = (struct iwl_priv *)priv_r; + struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (rs_sta && !rs_sta->priv) { - IWL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); + IL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); priv_sta = NULL; } @@ -664,25 +664,25 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, /* get user max rate if set */ max_rate_idx = txrc->max_rate_idx; if ((sband->band == IEEE80211_BAND_5GHZ) && (max_rate_idx != -1)) - max_rate_idx += IWL_FIRST_OFDM_RATE; - if ((max_rate_idx < 0) || (max_rate_idx >= IWL_RATE_COUNT)) + max_rate_idx += IL_FIRST_OFDM_RATE; + if ((max_rate_idx < 0) || (max_rate_idx >= IL_RATE_COUNT)) max_rate_idx = -1; - index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT_3945 - 1); + index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1); if (sband->band == IEEE80211_BAND_5GHZ) - rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; + rate_mask = rate_mask << IL_FIRST_OFDM_RATE; spin_lock_irqsave(&rs_sta->lock, flags); /* for recent assoc, choose best rate regarding * to rssi value */ - if (rs_sta->start_rate != IWL_RATE_INVALID) { + if (rs_sta->start_rate != IL_RATE_INVALID) { if (rs_sta->start_rate < index && (rate_mask & (1 << rs_sta->start_rate))) index = rs_sta->start_rate; - rs_sta->start_rate = IWL_RATE_INVALID; + rs_sta->start_rate = IL_RATE_INVALID; } /* force user max rate if set by user */ @@ -695,11 +695,11 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, fail_count = window->counter - window->success_counter; - if (((fail_count < IWL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { + if (((fail_count < IL_RATE_MIN_FAILURE_TH) && + (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { spin_unlock_irqrestore(&rs_sta->lock, flags); - IWL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: " + IL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, @@ -708,27 +708,27 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, rs_sta->expected_tpt ? "not " : ""); /* Can't calculate this yet; not enough history */ - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; goto out; } current_tpt = window->average_tpt; - high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, + high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask, sband->band); low = high_low & 0xff; high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ if ((max_rate_idx != -1) && (max_rate_idx < high)) - high = IWL_RATE_INVALID; + high = IL_RATE_INVALID; /* Collect Measured throughputs of adjacent rates */ - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) low_tpt = rs_sta->win[low].average_tpt; - if (high != IWL_RATE_INVALID) + if (high != IL_RATE_INVALID) high_tpt = rs_sta->win[high].average_tpt; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -736,51 +736,51 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { - IWL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); + if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { + IL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ - } else if ((low_tpt == IWL_INVALID_VALUE) && - (high_tpt == IWL_INVALID_VALUE)) { + } else if ((low_tpt == IL_INVALID_VALUE) && + (high_tpt == IL_INVALID_VALUE)) { - if (high != IWL_RATE_INVALID && window->success_ratio >= IWL_RATE_INCREASE_TH) + if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; - else if (low != IWL_RATE_INVALID) + else if (low != IL_RATE_INVALID) scale_action = 0; /* Both adjacent throughputs are measured, but neither one has * better throughput; we're using the best rate, don't change * it! */ - } else if ((low_tpt != IWL_INVALID_VALUE) && - (high_tpt != IWL_INVALID_VALUE) && + } else if ((low_tpt != IL_INVALID_VALUE) && + (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) { - IWL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < " + IL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; /* At least one of the rates has better throughput */ } else { - if (high_tpt != IWL_INVALID_VALUE) { + if (high_tpt != IL_INVALID_VALUE) { /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - window->success_ratio >= IWL_RATE_INCREASE_TH) + window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "decrease rate because of high tpt\n"); scale_action = 0; } - } else if (low_tpt != IWL_INVALID_VALUE) { + } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "decrease rate because of low tpt\n"); scale_action = -1; - } else if (window->success_ratio >= IWL_RATE_INCREASE_TH) { + } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { /* Lower rate has better * throughput,decrease rate */ scale_action = 1; @@ -790,8 +790,8 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IWL_RATE_INVALID) && - ((window->success_ratio > IWL_RATE_HIGH_TH) || + if ((scale_action == -1) && (low != IL_RATE_INVALID) && + ((window->success_ratio > IL_RATE_HIGH_TH) || (current_tpt > (100 * rs_sta->expected_tpt[low])))) scale_action = 0; @@ -799,13 +799,13 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, case -1: /* Decrese rate */ - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) index = low; break; case 1: /* Increase rate */ - if (high != IWL_RATE_INVALID) + if (high != IL_RATE_INVALID) index = high; break; @@ -816,32 +816,32 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, break; } - IWL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n", + IL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n", index, scale_action, low, high); out: if (sband->band == IEEE80211_BAND_5GHZ) { - if (WARN_ON_ONCE(index < IWL_FIRST_OFDM_RATE)) - index = IWL_FIRST_OFDM_RATE; + if (WARN_ON_ONCE(index < IL_FIRST_OFDM_RATE)) + index = IL_FIRST_OFDM_RATE; rs_sta->last_txrate_idx = index; - info->control.rates[0].idx = index - IWL_FIRST_OFDM_RATE; + info->control.rates[0].idx = index - IL_FIRST_OFDM_RATE; } else { rs_sta->last_txrate_idx = index; info->control.rates[0].idx = rs_sta->last_txrate_idx; } - IWL_DEBUG_RATE(priv, "leave: %d\n", index); + IL_DEBUG_RATE(priv, "leave: %d\n", index); } #ifdef CONFIG_MAC80211_DEBUGFS -static int iwl3945_open_file_generic(struct inode *inode, struct file *file) +static int il3945_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, +static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -849,7 +849,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, int desc = 0; int j; ssize_t ret; - struct iwl3945_rs_sta *lq_sta = file->private_data; + struct il3945_rs_sta *lq_sta = file->private_data; buff = kmalloc(1024, GFP_KERNEL); if (!buff) @@ -860,7 +860,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, lq_sta->tx_packets, lq_sta->last_txrate_idx, lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); - for (j = 0; j < IWL_RATE_COUNT_3945; j++) { + for (j = 0; j < IL_RATE_COUNT_3945; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->win[j].counter, @@ -873,15 +873,15 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = iwl3945_sta_dbgfs_stats_table_read, - .open = iwl3945_open_file_generic, + .read = il3945_sta_dbgfs_stats_table_read, + .open = il3945_open_file_generic, .llseek = default_llseek, }; -static void iwl3945_add_debugfs(void *priv, void *priv_sta, +static void il3945_add_debugfs(void *priv, void *priv_sta, struct dentry *dir) { - struct iwl3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = priv_sta; lq_sta->rs_sta_dbgfs_stats_table_file = debugfs_create_file("rate_stats_table", 0600, dir, @@ -889,9 +889,9 @@ static void iwl3945_add_debugfs(void *priv, void *priv_sta, } -static void iwl3945_remove_debugfs(void *priv, void *priv_sta) +static void il3945_remove_debugfs(void *priv, void *priv_sta) { - struct iwl3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = priv_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); } #endif @@ -901,7 +901,7 @@ static void iwl3945_remove_debugfs(void *priv, void *priv_sta) * the station is added. Since mac80211 calls this function before a * station is added we ignore it. */ -static void iwl3945_rs_rate_init_stub(void *priv_r, +static void il3945_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta) { @@ -910,36 +910,36 @@ static void iwl3945_rs_rate_init_stub(void *priv_r, static struct rate_control_ops rs_ops = { .module = NULL, .name = RS_NAME, - .tx_status = iwl3945_rs_tx_status, - .get_rate = iwl3945_rs_get_rate, - .rate_init = iwl3945_rs_rate_init_stub, - .alloc = iwl3945_rs_alloc, - .free = iwl3945_rs_free, - .alloc_sta = iwl3945_rs_alloc_sta, - .free_sta = iwl3945_rs_free_sta, + .tx_status = il3945_rs_tx_status, + .get_rate = il3945_rs_get_rate, + .rate_init = il3945_rs_rate_init_stub, + .alloc = il3945_rs_alloc, + .free = il3945_rs_free, + .alloc_sta = il3945_rs_alloc_sta, + .free_sta = il3945_rs_free_sta, #ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = iwl3945_add_debugfs, - .remove_sta_debugfs = iwl3945_remove_debugfs, + .add_sta_debugfs = il3945_add_debugfs, + .remove_sta_debugfs = il3945_remove_debugfs, #endif }; -void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) +void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; s32 rssi = 0; unsigned long flags; - struct iwl3945_rs_sta *rs_sta; + struct il3945_rs_sta *rs_sta; struct ieee80211_sta *sta; - struct iwl3945_sta_priv *psta; + struct il3945_sta_priv *psta; - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); rcu_read_lock(); - sta = ieee80211_find_sta(priv->contexts[IWL_RXON_CTX_BSS].vif, + sta = ieee80211_find_sta(priv->contexts[IL_RXON_CTX_BSS].vif, priv->stations[sta_id].sta.sta.addr); if (!sta) { - IWL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); + IL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } @@ -953,16 +953,16 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) switch (priv->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (priv->contexts[IWL_RXON_CTX_BSS].active.flags & + if (priv->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; - rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; + rs_sta->expected_tpt = il3945_expected_tpt_g_prot; } else - rs_sta->expected_tpt = iwl3945_expected_tpt_g; + rs_sta->expected_tpt = il3945_expected_tpt_g; break; case IEEE80211_BAND_5GHZ: - rs_sta->expected_tpt = iwl3945_expected_tpt_a; + rs_sta->expected_tpt = il3945_expected_tpt_a; break; case IEEE80211_NUM_BANDS: BUG(); @@ -973,24 +973,24 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rssi = priv->_3945.last_rx_rssi; if (rssi == 0) - rssi = IWL_MIN_RSSI_VAL; + rssi = IL_MIN_RSSI_VAL; - IWL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi); + IL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi); - rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band); + rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, priv->band); - IWL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: " + IL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, - iwl3945_rates[rs_sta->start_rate].plcp); + il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); } -int iwl3945_rate_control_register(void) +int il3945_rate_control_register(void) { return ieee80211_rate_control_register(&rs_ops); } -void iwl3945_rate_control_unregister(void) +void il3945_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_ops); } diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index f7c0a74..6d1740b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -51,70 +51,70 @@ #include "iwl-3945-led.h" #include "iwl-3945-debugfs.h" -#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ - IWL_RATE_##r##M_IEEE, \ - IWL_RATE_##ip##M_INDEX, \ - IWL_RATE_##in##M_INDEX, \ - IWL_RATE_##rp##M_INDEX, \ - IWL_RATE_##rn##M_INDEX, \ - IWL_RATE_##pp##M_INDEX, \ - IWL_RATE_##np##M_INDEX, \ - IWL_RATE_##r##M_INDEX_TABLE, \ - IWL_RATE_##ip##M_INDEX_TABLE } +#define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ + [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ + IL_RATE_##r##M_IEEE, \ + IL_RATE_##ip##M_INDEX, \ + IL_RATE_##in##M_INDEX, \ + IL_RATE_##rp##M_INDEX, \ + IL_RATE_##rn##M_INDEX, \ + IL_RATE_##pp##M_INDEX, \ + IL_RATE_##np##M_INDEX, \ + IL_RATE_##r##M_INDEX_TABLE, \ + IL_RATE_##ip##M_INDEX_TABLE } /* * Parameter order: * rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IWL_RATE_INVALID + * maps to IL_RATE_INVALID * */ -const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT_3945] = { - IWL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IWL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IWL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IWL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ - IWL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IWL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ - IWL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IWL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IWL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IWL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IWL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IWL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ +const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945] = { + IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ }; -static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index) +static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) { - u8 rate = iwl3945_rates[rate_index].prev_ieee; + u8 rate = il3945_rates[rate_index].prev_ieee; - if (rate == IWL_RATE_INVALID) + if (rate == IL_RATE_INVALID) rate = rate_index; return rate; } -/* 1 = enable the iwl3945_disable_events() function */ -#define IWL_EVT_DISABLE (0) -#define IWL_EVT_DISABLE_SIZE (1532/32) +/* 1 = enable the il3945_disable_events() function */ +#define IL_EVT_DISABLE (0) +#define IL_EVT_DISABLE_SIZE (1532/32) /** - * iwl3945_disable_events - Disable selected events in uCode event log + * il3945_disable_events - Disable selected events in uCode event log * * Disable an event by writing "1"s into "disable" * bitmap in SRAM. Bit position corresponds to Event # (id/type). * Default values of 0 enable uCode events to be logged. * Use for only special debugging. This function is just a placeholder as-is, * you'll need to provide the special bits! ... - * ... and set IWL_EVT_DISABLE to 1. */ -void iwl3945_disable_events(struct iwl_priv *priv) + * ... and set IL_EVT_DISABLE to 1. */ +void il3945_disable_events(struct il_priv *priv) { int i; u32 base; /* SRAM address of event log header */ u32 disable_ptr; /* SRAM address of event-disable bitmap array */ u32 array_size; /* # of u32 entries in array */ - static const u32 evt_disable[IWL_EVT_DISABLE_SIZE] = { + static const u32 evt_disable[IL_EVT_DISABLE_SIZE] = { 0x00000000, /* 31 - 0 Event id numbers */ 0x00000000, /* 63 - 32 */ 0x00000000, /* 95 - 64 */ @@ -165,37 +165,37 @@ void iwl3945_disable_events(struct iwl_priv *priv) }; base = le32_to_cpu(priv->card_alive.log_event_table_ptr); - if (!iwl3945_hw_valid_rtc_data_addr(base)) { - IWL_ERR(priv, "Invalid event log pointer 0x%08X\n", base); + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR(priv, "Invalid event log pointer 0x%08X\n", base); return; } - disable_ptr = iwl_legacy_read_targ_mem(priv, base + (4 * sizeof(u32))); - array_size = iwl_legacy_read_targ_mem(priv, base + (5 * sizeof(u32))); + disable_ptr = il_read_targ_mem(priv, base + (4 * sizeof(u32))); + array_size = il_read_targ_mem(priv, base + (5 * sizeof(u32))); - if (IWL_EVT_DISABLE && (array_size == IWL_EVT_DISABLE_SIZE)) { - IWL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n", + if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { + IL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n", disable_ptr); - for (i = 0; i < IWL_EVT_DISABLE_SIZE; i++) - iwl_legacy_write_targ_mem(priv, + for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) + il_write_targ_mem(priv, disable_ptr + (i * sizeof(u32)), evt_disable[i]); } else { - IWL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n"); - IWL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n"); - IWL_DEBUG_INFO(priv, " in SRAM at 0x%x, size %d u32s\n", + IL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n"); + IL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n"); + IL_DEBUG_INFO(priv, " in SRAM at 0x%x, size %d u32s\n", disable_ptr, array_size); } } -static int iwl3945_hwrate_to_plcp_idx(u8 plcp) +static int il3945_hwrate_to_plcp_idx(u8 plcp) { int idx; - for (idx = 0; idx < IWL_RATE_COUNT_3945; idx++) - if (iwl3945_rates[idx].plcp == plcp) + for (idx = 0; idx < IL_RATE_COUNT_3945; idx++) + if (il3945_rates[idx].plcp == plcp) return idx; return -1; } @@ -203,7 +203,7 @@ static int iwl3945_hwrate_to_plcp_idx(u8 plcp) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG #define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x -static const char *iwl3945_get_tx_fail_reason(u32 status) +static const char *il3945_get_tx_fail_reason(u32 status) { switch (status & TX_STATUS_MSK) { case TX_3945_STATUS_SUCCESS: @@ -229,7 +229,7 @@ static const char *iwl3945_get_tx_fail_reason(u32 status) return "UNKNOWN"; } #else -static inline const char *iwl3945_get_tx_fail_reason(u32 status) +static inline const char *il3945_get_tx_fail_reason(u32 status) { return ""; } @@ -240,22 +240,22 @@ static inline const char *iwl3945_get_tx_fail_reason(u32 status) * for A and B mode we need to overright prev * value */ -int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate) +int il3945_rs_next_rate(struct il_priv *priv, int rate) { - int next_rate = iwl3945_get_prev_ieee_rate(rate); + int next_rate = il3945_get_prev_ieee_rate(rate); switch (priv->band) { case IEEE80211_BAND_5GHZ: - if (rate == IWL_RATE_12M_INDEX) - next_rate = IWL_RATE_9M_INDEX; - else if (rate == IWL_RATE_6M_INDEX) - next_rate = IWL_RATE_6M_INDEX; + if (rate == IL_RATE_12M_INDEX) + next_rate = IL_RATE_9M_INDEX; + else if (rate == IL_RATE_6M_INDEX) + next_rate = IL_RATE_6M_INDEX; break; case IEEE80211_BAND_2GHZ: - if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) && - iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { - if (rate == IWL_RATE_11M_INDEX) - next_rate = IWL_RATE_5M_INDEX; + if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (rate == IL_RATE_11M_INDEX) + next_rate = IL_RATE_5M_INDEX; } break; @@ -268,24 +268,24 @@ int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate) /** - * iwl3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd + * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd * * When FW advances 'R' index, all entries between old and new 'R' index * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv, +static void il3945_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; - struct iwl_tx_info *tx_info; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; BUG_ON(txq_id == IWL39_CMD_QUEUE_NUM); - for (index = iwl_legacy_queue_inc_wrap(index, q->n_bd); + for (index = il_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); @@ -293,31 +293,31 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv, priv->cfg->ops->lib->txq_free_tfd(priv, txq); } - if (iwl_legacy_queue_space(q) > q->low_mark && (txq_id >= 0) && + if (il_queue_space(q) > q->low_mark && (txq_id >= 0) && (txq_id != IWL39_CMD_QUEUE_NUM) && priv->mac80211_registered) - iwl_legacy_wake_queue(priv, txq); + il_wake_queue(priv, txq); } /** - * iwl3945_rx_reply_tx - Handle Tx response + * il3945_rx_reply_tx - Handle Tx response */ -static void iwl3945_rx_reply_tx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_tx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct iwl_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &priv->txq[txq_id]; struct ieee80211_tx_info *info; - struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; u32 status = le32_to_cpu(tx_resp->status); int rate_idx; int fail; - if ((index >= txq->q.n_bd) || (iwl_legacy_queue_used(&txq->q, index) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -329,9 +329,9 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv, ieee80211_tx_info_clear_status(info); /* Fill the MRR chain with some info about on-chip retransmissions */ - rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate); + rate_idx = il3945_hwrate_to_plcp_idx(tx_resp->rate); if (info->band == IEEE80211_BAND_5GHZ) - rate_idx -= IWL_FIRST_OFDM_RATE; + rate_idx -= IL_FIRST_OFDM_RATE; fail = tx_resp->failure_frame; @@ -342,15 +342,15 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv, info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - IWL_DEBUG_TX(priv, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", - txq_id, iwl3945_get_tx_fail_reason(status), status, + IL_DEBUG_TX(priv, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - IWL_DEBUG_TX_REPLY(priv, "Tx queue reclaim %d\n", index); - iwl3945_tx_queue_reclaim(priv, txq_id, index); + IL_DEBUG_TX_REPLY(priv, "Tx queue reclaim %d\n", index); + il3945_tx_queue_reclaim(priv, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) - IWL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); + IL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); } @@ -363,7 +363,7 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv, * *****************************************************************************/ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -static void iwl3945_accumulative_statistics(struct iwl_priv *priv, +static void il3945_accumulative_statistics(struct il_priv *priv, __le32 *stats) { int i; @@ -376,7 +376,7 @@ static void iwl3945_accumulative_statistics(struct iwl_priv *priv, delta = (u32 *)&priv->_3945.delta_statistics; max_delta = (u32 *)&priv->_3945.max_delta; - for (i = sizeof(__le32); i < sizeof(struct iwl3945_notif_statistics); + for (i = sizeof(__le32); i < sizeof(struct il3945_notif_statistics); i += sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { @@ -396,39 +396,39 @@ static void iwl3945_accumulative_statistics(struct iwl_priv *priv, } #endif -void iwl3945_hw_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il3945_hw_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); - IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct iwl3945_notif_statistics), + IL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); + il3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); #endif memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); } -void iwl3945_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il3945_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS memset(&priv->_3945.accum_statistics, 0, - sizeof(struct iwl3945_notif_statistics)); + sizeof(struct il3945_notif_statistics)); memset(&priv->_3945.delta_statistics, 0, - sizeof(struct iwl3945_notif_statistics)); + sizeof(struct il3945_notif_statistics)); memset(&priv->_3945.max_delta, 0, - sizeof(struct iwl3945_notif_statistics)); + sizeof(struct il3945_notif_statistics)); #endif - IWL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(priv, "Statistics have been cleared\n"); } - iwl3945_hw_rx_statistics(priv, rxb); + il3945_hw_rx_statistics(priv, rxb); } @@ -439,7 +439,7 @@ void iwl3945_reply_statistics(struct iwl_priv *priv, ******************************************************************************/ /* This is necessary only for a number of statistics, see the caller. */ -static int iwl3945_is_network_packet(struct iwl_priv *priv, +static int il3945_is_network_packet(struct il_priv *priv, struct ieee80211_hdr *header) { /* Filter incoming packets to determine if they are targeted toward @@ -456,14 +456,14 @@ static int iwl3945_is_network_packet(struct iwl_priv *priv, } } -static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, +static void il3945_pass_packet_to_mac80211(struct il_priv *priv, + struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); - struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); - struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); u16 len = le16_to_cpu(rx_hdr->len); struct sk_buff *skb; __le16 fc = hdr->frame_control; @@ -471,32 +471,32 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv, /* We received data from the HW, so stop the watchdog */ if (unlikely(len + IWL39_RX_FRAME_SIZE > PAGE_SIZE << priv->hw_params.rx_page_order)) { - IWL_DEBUG_DROP(priv, "Corruption detected!\n"); + IL_DEBUG_DROP(priv, "Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ if (unlikely(!priv->is_open)) { - IWL_DEBUG_DROP_LIMIT(priv, + IL_DEBUG_DROP_LIMIT(priv, "Dropping packet while interface is not open.\n"); return; } skb = dev_alloc_skb(128); if (!skb) { - IWL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(priv, "dev_alloc_skb failed\n"); return; } - if (!iwl3945_mod_params.sw_crypto) - iwl_legacy_set_decrypted_flag(priv, + if (!il3945_mod_params.sw_crypto) + il_set_decrypted_flag(priv, (struct ieee80211_hdr *)rxb_addr(rxb), le32_to_cpu(rx_end->status), stats); skb_add_rx_frag(skb, 0, rxb->page, (void *)rx_hdr->payload - (void *)pkt, len); - iwl_legacy_update_stats(priv, false, fc, len); + il_update_stats(priv, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); ieee80211_rx(priv->hw, skb); @@ -504,17 +504,17 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv, rxb->page = NULL; } -#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) +#define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void iwl3945_rx_reply_rx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_rx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl3945_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt); - struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); - struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); u8 network_packet; @@ -527,9 +527,9 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), rx_status.band); - rx_status.rate_idx = iwl3945_hwrate_to_plcp_idx(rx_hdr->rate); + rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); if (rx_status.band == IEEE80211_BAND_5GHZ) - rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; + rx_status.rate_idx -= IL_FIRST_OFDM_RATE; rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; @@ -539,14 +539,14 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, rx_status.flag |= RX_FLAG_SHORTPRE; if ((unlikely(rx_stats->phy_count > 20))) { - IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", rx_stats->phy_count); return; } if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -555,21 +555,21 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; - IWL_DEBUG_STATS(priv, "Rssi %d sig_avg %d noise_diff %d\n", + IL_DEBUG_STATS(priv, "Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, rx_stats_noise_diff); - header = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); + header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - network_packet = iwl3945_is_network_packet(priv, header); + network_packet = il3945_is_network_packet(priv, header); - IWL_DEBUG_STATS_LIMIT(priv, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + IL_DEBUG_STATS_LIMIT(priv, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, rx_status.rate_idx); - iwl_legacy_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), + il_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), header); if (network_packet) { @@ -579,19 +579,19 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, priv->_3945.last_rx_rssi = rx_status.signal; } - iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status); + il3945_pass_packet_to_mac80211(priv, rxb, &rx_status); } -int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) { int count; - struct iwl_queue *q; - struct iwl3945_tfd *tfd, *tfd_tmp; + struct il_queue *q; + struct il3945_tfd *tfd, *tfd_tmp; q = &txq->q; - tfd_tmp = (struct iwl3945_tfd *)txq->tfds; + tfd_tmp = (struct il3945_tfd *)txq->tfds; tfd = &tfd_tmp[q->write_ptr]; if (reset) @@ -600,7 +600,7 @@ int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { - IWL_ERR(priv, "Error can not send more than %d chunks\n", + IL_ERR(priv, "Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; } @@ -617,15 +617,15 @@ int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, } /** - * iwl3945_hw_txq_free_tfd - Free one TFD, those at index [txq->q.read_ptr] + * il3945_hw_txq_free_tfd - Free one TFD, those at index [txq->q.read_ptr] * * Does NOT advance any indexes */ -void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) +void il3945_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) { - struct iwl3945_tfd *tfd_tmp = (struct iwl3945_tfd *)txq->tfds; + struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; int index = txq->q.read_ptr; - struct iwl3945_tfd *tfd = &tfd_tmp[index]; + struct il3945_tfd *tfd = &tfd_tmp[index]; struct pci_dev *dev = priv->pci_dev; int i; int counter; @@ -633,7 +633,7 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* sanity check */ counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if (counter > NUM_TFD_CHUNKS) { - IWL_ERR(priv, "Too many chunks: %i\n", counter); + IL_ERR(priv, "Too many chunks: %i\n", counter); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -666,37 +666,37 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) } /** - * iwl3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: + * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: * */ -void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, +void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, + struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value; - u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT_3945); + u16 rate_index = min(hw_value & 0xffff, IL_RATE_COUNT_3945); u16 rate_mask; int rate; u8 rts_retry_limit; u8 data_retry_limit; __le32 tx_flags; __le16 fc = hdr->frame_control; - struct iwl3945_tx_cmd *tx_cmd = (struct iwl3945_tx_cmd *)cmd->cmd.payload; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - rate = iwl3945_rates[rate_index].plcp; + rate = il3945_rates[rate_index].plcp; tx_flags = tx_cmd->tx_flags; /* We need to figure out how to get the sta->supp_rates while * in this running context */ - rate_mask = IWL_RATES_MASK_3945; + rate_mask = IL_RATES_MASK_3945; /* Set retry limit on DATA packets and Probe Responses*/ if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else - data_retry_limit = IWL_DEFAULT_TX_RETRY; + data_retry_limit = IL_DEFAULT_TX_RETRY; tx_cmd->data_retry_limit = data_retry_limit; if (tx_id >= IWL39_CMD_QUEUE_NUM) @@ -713,24 +713,24 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, /* OFDM */ tx_cmd->supp_rates[0] = - ((rate_mask & IWL_OFDM_RATES_MASK) >> IWL_FIRST_OFDM_RATE) & 0xFF; + ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); - IWL_DEBUG_RATE(priv, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + IL_DEBUG_RATE(priv, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); } -static u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate) +static u8 il3945_sync_sta(struct il_priv *priv, int sta_id, u16 tx_rate) { unsigned long flags_spin; - struct iwl_station_entry *station; + struct il_station_entry *station; - if (sta_id == IWL_INVALID_STATION) - return IWL_INVALID_STATION; + if (sta_id == IL_INVALID_STATION) + return IL_INVALID_STATION; spin_lock_irqsave(&priv->sta_lock, flags_spin); station = &priv->stations[sta_id]; @@ -738,46 +738,46 @@ static u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate) station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; station->sta.rate_n_flags = cpu_to_le16(tx_rate); station->sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_legacy_send_add_sta(priv, &station->sta, CMD_ASYNC); + il_send_add_sta(priv, &station->sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - IWL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n", + IL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } -static void iwl3945_set_pwr_vmain(struct iwl_priv *priv) +static void il3945_set_pwr_vmain(struct il_priv *priv) { /* * (for documentation purposes) * to set power to V_AUX, do if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) { - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); - iwl_poll_bit(priv, CSR_GPIO_IN, + il_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VAUX_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); } */ - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - iwl_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + il_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } -static int iwl3945_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +static int il3945_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) { - iwl_legacy_write_direct32(priv, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - iwl_legacy_write_direct32(priv, FH39_RCSR_RPTR_ADDR(0), + il_write_direct32(priv, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_write_direct32(priv, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); - iwl_legacy_write_direct32(priv, FH39_RCSR_WPTR(0), 0); - iwl_legacy_write_direct32(priv, FH39_RCSR_CONFIG(0), + il_write_direct32(priv, FH39_RCSR_WPTR(0), 0); + il_write_direct32(priv, FH39_RCSR_CONFIG(0), FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | @@ -788,32 +788,32 @@ static int iwl3945_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ - iwl_legacy_read_direct32(priv, FH39_RSSR_CTRL); + il_read_direct32(priv, FH39_RSSR_CTRL); return 0; } -static int iwl3945_tx_reset(struct iwl_priv *priv) +static int il3945_tx_reset(struct il_priv *priv) { /* bypass mode */ - iwl_legacy_write_prph(priv, ALM_SCD_MODE_REG, 0x2); + il_write_prph(priv, ALM_SCD_MODE_REG, 0x2); /* RA 0 is active */ - iwl_legacy_write_prph(priv, ALM_SCD_ARASTAT_REG, 0x01); + il_write_prph(priv, ALM_SCD_ARASTAT_REG, 0x01); /* all 6 fifo are active */ - iwl_legacy_write_prph(priv, ALM_SCD_TXFACT_REG, 0x3f); + il_write_prph(priv, ALM_SCD_TXFACT_REG, 0x3f); - iwl_legacy_write_prph(priv, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - iwl_legacy_write_prph(priv, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - iwl_legacy_write_prph(priv, ALM_SCD_TXF4MF_REG, 0x000004); - iwl_legacy_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005); + il_write_prph(priv, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_write_prph(priv, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_write_prph(priv, ALM_SCD_TXF4MF_REG, 0x000004); + il_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005); - iwl_legacy_write_direct32(priv, FH39_TSSR_CBB_BASE, + il_write_direct32(priv, FH39_TSSR_CBB_BASE, priv->_3945.shared_phys); - iwl_legacy_write_direct32(priv, FH39_TSSR_MSG_CONFIG, + il_write_direct32(priv, FH39_TSSR_MSG_CONFIG, FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | @@ -827,24 +827,24 @@ static int iwl3945_tx_reset(struct iwl_priv *priv) } /** - * iwl3945_txq_ctx_reset - Reset TX queue context + * il3945_txq_ctx_reset - Reset TX queue context * * Destroys all DMA structures and initialize them again */ -static int iwl3945_txq_ctx_reset(struct iwl_priv *priv) +static int il3945_txq_ctx_reset(struct il_priv *priv) { int rc; int txq_id, slots_num; - iwl3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(priv); /* allocate tx queue structure */ - rc = iwl_legacy_alloc_txq_mem(priv); + rc = il_alloc_txq_mem(priv); if (rc) return rc; /* Tx CMD queue */ - rc = iwl3945_tx_reset(priv); + rc = il3945_tx_reset(priv); if (rc) goto error; @@ -852,10 +852,10 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { slots_num = (txq_id == IWL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = iwl_legacy_tx_queue_init(priv, &priv->txq[txq_id], + rc = il_tx_queue_init(priv, &priv->txq[txq_id], slots_num, txq_id); if (rc) { - IWL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(priv, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -863,133 +863,133 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv) return rc; error: - iwl3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(priv); return rc; } /* * Start up 3945's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via iwl_legacy_apm_stop()) + * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -static int iwl3945_apm_init(struct iwl_priv *priv) +static int il3945_apm_init(struct il_priv *priv) { - int ret = iwl_legacy_apm_init(priv); + int ret = il_apm_init(priv); /* Clear APMG (NIC's internal power management) interrupts */ - iwl_legacy_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0); - iwl_legacy_write_prph(priv, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + il_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0); + il_write_prph(priv, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ - iwl_legacy_set_bits_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - iwl_legacy_clear_bits_prph(priv, APMG_PS_CTRL_REG, + il_clear_bits_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); return ret; } -static void iwl3945_nic_config(struct iwl_priv *priv) +static void il3945_nic_config(struct il_priv *priv) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; unsigned long flags; u8 rev_id = priv->pci_dev->revision; spin_lock_irqsave(&priv->lock, flags); /* Determine HW type */ - IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); + IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - IWL_DEBUG_INFO(priv, "RTP type\n"); + IL_DEBUG_INFO(priv, "RTP type\n"); else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - IWL_DEBUG_INFO(priv, "3945 RADIO-MB type\n"); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(priv, "3945 RADIO-MB type\n"); + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { - IWL_DEBUG_INFO(priv, "3945 RADIO-MM type\n"); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(priv, "3945 RADIO-MM type\n"); + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - IWL_DEBUG_INFO(priv, "SKU OP mode is mrc\n"); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(priv, "SKU OP mode is mrc\n"); + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else - IWL_DEBUG_INFO(priv, "SKU OP mode is basic\n"); + IL_DEBUG_INFO(priv, "SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - IWL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", eeprom->board_revision); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - IWL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", eeprom->board_revision); - iwl_legacy_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } if (eeprom->almgor_m_version <= 1) { - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - IWL_DEBUG_INFO(priv, "Card M type A version is 0x%X\n", + IL_DEBUG_INFO(priv, "Card M type A version is 0x%X\n", eeprom->almgor_m_version); } else { - IWL_DEBUG_INFO(priv, "Card M type B version is 0x%X\n", + IL_DEBUG_INFO(priv, "Card M type B version is 0x%X\n", eeprom->almgor_m_version); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); } spin_unlock_irqrestore(&priv->lock, flags); if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - IWL_DEBUG_RF_KILL(priv, "SW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(priv, "SW RF KILL supported in EEPROM.\n"); if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - IWL_DEBUG_RF_KILL(priv, "HW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(priv, "HW RF KILL supported in EEPROM.\n"); } -int iwl3945_hw_nic_init(struct iwl_priv *priv) +int il3945_hw_nic_init(struct il_priv *priv) { int rc; unsigned long flags; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; spin_lock_irqsave(&priv->lock, flags); priv->cfg->ops->lib->apm_ops.init(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl3945_set_pwr_vmain(priv); + il3945_set_pwr_vmain(priv); priv->cfg->ops->lib->apm_ops.config(priv); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - rc = iwl_legacy_rx_queue_alloc(priv); + rc = il_rx_queue_alloc(priv); if (rc) { - IWL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(priv, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - iwl3945_rx_queue_reset(priv, rxq); + il3945_rx_queue_reset(priv, rxq); - iwl3945_rx_replenish(priv); + il3945_rx_replenish(priv); - iwl3945_rx_init(priv, rxq); + il3945_rx_init(priv, rxq); /* Look at using this instead: rxq->need_update = 1; - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); */ - iwl_legacy_write_direct32(priv, FH39_RCSR_WPTR(0), rxq->write & ~7); + il_write_direct32(priv, FH39_RCSR_WPTR(0), rxq->write & ~7); - rc = iwl3945_txq_ctx_reset(priv); + rc = il3945_txq_ctx_reset(priv); if (rc) return rc; @@ -999,11 +999,11 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv) } /** - * iwl3945_hw_txq_ctx_free - Free TXQ Context + * il3945_hw_txq_ctx_free - Free TXQ Context * * Destroy all TX DMA queues and structures */ -void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv) +void il3945_hw_txq_ctx_free(struct il_priv *priv) { int txq_id; @@ -1012,73 +1012,73 @@ void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) if (txq_id == IWL39_CMD_QUEUE_NUM) - iwl_legacy_cmd_queue_free(priv); + il_cmd_queue_free(priv); else - iwl_legacy_tx_queue_free(priv, txq_id); + il_tx_queue_free(priv, txq_id); /* free tx queue structure */ - iwl_legacy_txq_mem(priv); + il_txq_mem(priv); } -void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv) +void il3945_hw_txq_ctx_stop(struct il_priv *priv) { int txq_id; /* stop SCD */ - iwl_legacy_write_prph(priv, ALM_SCD_MODE_REG, 0); - iwl_legacy_write_prph(priv, ALM_SCD_TXFACT_REG, 0); + il_write_prph(priv, ALM_SCD_MODE_REG, 0); + il_write_prph(priv, ALM_SCD_TXFACT_REG, 0); /* reset TFD queues */ for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - iwl_legacy_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), 0x0); - iwl_poll_direct_bit(priv, FH39_TSSR_TX_STATUS, + il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_direct_bit(priv, FH39_TSSR_TX_STATUS, FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), 1000); } - iwl3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(priv); } /** - * iwl3945_hw_reg_adjust_power_by_temp + * il3945_hw_reg_adjust_power_by_temp * return index delta into power gain settings table */ -static int iwl3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) +static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) { return (new_reading - old_reading) * (-11) / 100; } /** - * iwl3945_hw_reg_temp_out_of_range - Keep temperature in sane range + * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range */ -static inline int iwl3945_hw_reg_temp_out_of_range(int temperature) +static inline int il3945_hw_reg_temp_out_of_range(int temperature) { return ((temperature < -260) || (temperature > 25)) ? 1 : 0; } -int iwl3945_hw_get_temperature(struct iwl_priv *priv) +int il3945_hw_get_temperature(struct il_priv *priv) { - return iwl_read32(priv, CSR_UCODE_DRV_GP2); + return il_read32(priv, CSR_UCODE_DRV_GP2); } /** - * iwl3945_hw_reg_txpower_get_temperature + * il3945_hw_reg_txpower_get_temperature * get the current temperature by reading from NIC */ -static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv) +static int il3945_hw_reg_txpower_get_temperature(struct il_priv *priv) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; int temperature; - temperature = iwl3945_hw_get_temperature(priv); + temperature = il3945_hw_get_temperature(priv); /* driver's okay range is -260 to +25. * human readable okay range is 0 to +285 */ - IWL_DEBUG_INFO(priv, "Temperature: %d\n", temperature + IWL_TEMP_CONVERT); + IL_DEBUG_INFO(priv, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); /* handle insane temp reading */ - if (iwl3945_hw_reg_temp_out_of_range(temperature)) { - IWL_ERR(priv, "Error bad temperature value %d\n", temperature); + if (il3945_hw_reg_temp_out_of_range(temperature)) { + IL_ERR(priv, "Error bad temperature value %d\n", temperature); /* if really really hot(?), * substitute the 3rd band/group's temp measured at factory */ @@ -1094,37 +1094,37 @@ static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv) /* Adjust Txpower only if temperature variance is greater than threshold. * * Both are lower than older versions' 9 degrees */ -#define IWL_TEMPERATURE_LIMIT_TIMER 6 +#define IL_TEMPERATURE_LIMIT_TIMER 6 /** - * iwl3945_is_temp_calib_needed - determines if new calibration is needed + * il3945_is_temp_calib_needed - determines if new calibration is needed * * records new temperature in tx_mgr->temperature. * replaces tx_mgr->last_temperature *only* if calib needed * (assumes caller will actually do the calibration!). */ -static int iwl3945_is_temp_calib_needed(struct iwl_priv *priv) +static int il3945_is_temp_calib_needed(struct il_priv *priv) { int temp_diff; - priv->temperature = iwl3945_hw_reg_txpower_get_temperature(priv); + priv->temperature = il3945_hw_reg_txpower_get_temperature(priv); temp_diff = priv->temperature - priv->last_temperature; /* get absolute value */ if (temp_diff < 0) { - IWL_DEBUG_POWER(priv, "Getting cooler, delta %d,\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting cooler, delta %d,\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IWL_DEBUG_POWER(priv, "Same temp,\n"); + IL_DEBUG_POWER(priv, "Same temp,\n"); else - IWL_DEBUG_POWER(priv, "Getting warmer, delta %d,\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting warmer, delta %d,\n", temp_diff); /* if we don't need calibration, *don't* update last_temperature */ - if (temp_diff < IWL_TEMPERATURE_LIMIT_TIMER) { - IWL_DEBUG_POWER(priv, "Timed thermal calib not needed\n"); + if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { + IL_DEBUG_POWER(priv, "Timed thermal calib not needed\n"); return 0; } - IWL_DEBUG_POWER(priv, "Timed thermal calib needed\n"); + IL_DEBUG_POWER(priv, "Timed thermal calib needed\n"); /* assume that caller will actually do calib ... * update the "last temperature" value */ @@ -1132,13 +1132,13 @@ static int iwl3945_is_temp_calib_needed(struct iwl_priv *priv) return 1; } -#define IWL_MAX_GAIN_ENTRIES 78 -#define IWL_CCK_FROM_OFDM_POWER_DIFF -5 -#define IWL_CCK_FROM_OFDM_INDEX_DIFF (10) +#define IL_MAX_GAIN_ENTRIES 78 +#define IL_CCK_FROM_OFDM_POWER_DIFF -5 +#define IL_CCK_FROM_OFDM_INDEX_DIFF (10) /* radio and DSP power table, each step is 1/2 dB. * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ -static struct iwl3945_tx_power power_gain_table[2][IWL_MAX_GAIN_ENTRIES] = { +static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { { {251, 127}, /* 2.4 GHz, highest power */ {251, 127}, @@ -1299,12 +1299,12 @@ static struct iwl3945_tx_power power_gain_table[2][IWL_MAX_GAIN_ENTRIES] = { {3, 120} } /* 5.x GHz, lowest power */ }; -static inline u8 iwl3945_hw_reg_fix_power_index(int index) +static inline u8 il3945_hw_reg_fix_power_index(int index) { if (index < 0) return 0; - if (index >= IWL_MAX_GAIN_ENTRIES) - return IWL_MAX_GAIN_ENTRIES - 1; + if (index >= IL_MAX_GAIN_ENTRIES) + return IL_MAX_GAIN_ENTRIES - 1; return (u8) index; } @@ -1312,17 +1312,17 @@ static inline u8 iwl3945_hw_reg_fix_power_index(int index) #define REG_RECALIB_PERIOD (60) /** - * iwl3945_hw_reg_set_scan_power - Set Tx power for scan probe requests + * il3945_hw_reg_set_scan_power - Set Tx power for scan probe requests * * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_index, +static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_index, s32 rate_index, const s8 *clip_pwrs, - struct iwl_channel_info *ch_info, + struct il_channel_info *ch_info, int band_index) { - struct iwl3945_scan_power_info *scan_power_info; + struct il3945_scan_power_info *scan_power_info; s8 power; u8 power_index; @@ -1331,7 +1331,7 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[IWL_RATE_6M_INDEX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[IL_RATE_6M_INDEX_TABLE]); power = min(power, priv->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1343,7 +1343,7 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in * *index*. */ power_index = ch_info->power_info[rate_index].power_table_index - (power - ch_info->power_info - [IWL_RATE_6M_INDEX_TABLE].requested_power) * 2; + [IL_RATE_6M_INDEX_TABLE].requested_power) * 2; /* store reference index that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1355,7 +1355,7 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in * of the table. */ /* don't exceed table bounds for "real" setting */ - power_index = iwl3945_hw_reg_fix_power_index(power_index); + power_index = il3945_hw_reg_fix_power_index(power_index); scan_power_info->power_table_index = power_index; scan_power_info->tpc.tx_gain = @@ -1365,17 +1365,17 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in } /** - * iwl3945_send_tx_power - fill in Tx Power command with gain settings + * il3945_send_tx_power - fill in Tx Power command with gain settings * * Configures power settings for all rates for the current channel, * using values from channel info struct, and send to NIC */ -static int iwl3945_send_tx_power(struct iwl_priv *priv) +static int il3945_send_tx_power(struct il_priv *priv) { int rate_idx, i; - const struct iwl_channel_info *ch_info = NULL; - struct iwl3945_txpowertable_cmd txpower = { - .channel = priv->contexts[IWL_RXON_CTX_BSS].active.channel, + const struct il_channel_info *ch_info = NULL; + struct il3945_txpowertable_cmd txpower = { + .channel = priv->contexts[IL_RXON_CTX_BSS].active.channel, }; u16 chan; @@ -1383,32 +1383,32 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) "TX Power requested while scanning!\n")) return -EAGAIN; - chan = le16_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.channel); + chan = le16_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.channel); txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; - ch_info = iwl_legacy_get_channel_info(priv, priv->band, chan); + ch_info = il_get_channel_info(priv, priv->band, chan); if (!ch_info) { - IWL_ERR(priv, + IL_ERR(priv, "Failed to get channel info for channel %d [%d]\n", chan, priv->band); return -EINVAL; } - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_POWER(priv, "Not calling TX_PWR_TABLE_CMD on " + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_POWER(priv, "Not calling TX_PWR_TABLE_CMD on " "non-Tx channel.\n"); return 0; } /* fill cmd with power settings for all rates for current channel */ /* Fill OFDM rate */ - for (rate_idx = IWL_FIRST_OFDM_RATE, i = 0; + for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; rate_idx <= IWL39_LAST_OFDM_RATE; rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = iwl3945_rates[rate_idx].plcp; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IWL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1416,12 +1416,12 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) txpower.power[i].rate); } /* Fill CCK rates */ - for (rate_idx = IWL_FIRST_CCK_RATE; - rate_idx <= IWL_LAST_CCK_RATE; rate_idx++, i++) { + for (rate_idx = IL_FIRST_CCK_RATE; + rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = iwl3945_rates[rate_idx].plcp; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IWL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1429,14 +1429,14 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) txpower.power[i].rate); } - return iwl_legacy_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, - sizeof(struct iwl3945_txpowertable_cmd), + return il_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, + sizeof(struct il3945_txpowertable_cmd), &txpower); } /** - * iwl3945_hw_reg_set_new_power - Configures power tables at new levels + * il3945_hw_reg_set_new_power - Configures power tables at new levels * @ch_info: Channel to update. Uses power_info.requested_power. * * Replace requested_power and base_power_index ch_info fields for @@ -1451,10 +1451,10 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) * properly fill out the scan powers, and actual h/w gain settings, * and send changes to NIC */ -static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, - struct iwl_channel_info *ch_info) +static int il3945_hw_reg_set_new_power(struct il_priv *priv, + struct il_channel_info *ch_info) { - struct iwl3945_channel_power_info *power_info; + struct il3945_channel_power_info *power_info; int power_changed = 0; int i; const s8 *clip_pwrs; @@ -1467,7 +1467,7 @@ static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = IWL_RATE_6M_INDEX_TABLE; i <= IWL_RATE_54M_INDEX_TABLE; + for (i = IL_RATE_6M_INDEX_TABLE; i <= IL_RATE_54M_INDEX_TABLE; i++, ++power_info) { int delta_idx; @@ -1491,15 +1491,15 @@ static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[IWL_RATE_12M_INDEX_TABLE]. - requested_power + IWL_CCK_FROM_OFDM_POWER_DIFF; + ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; - /* do all CCK rates' iwl3945_channel_power_info structures */ - for (i = IWL_RATE_1M_INDEX_TABLE; i <= IWL_RATE_11M_INDEX_TABLE; i++) { + /* do all CCK rates' il3945_channel_power_info structures */ + for (i = IL_RATE_1M_INDEX_TABLE; i <= IL_RATE_11M_INDEX_TABLE; i++) { power_info->requested_power = power; power_info->base_power_index = - ch_info->power_info[IWL_RATE_12M_INDEX_TABLE]. - base_power_index + IWL_CCK_FROM_OFDM_INDEX_DIFF; + ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + base_power_index + IL_CCK_FROM_OFDM_INDEX_DIFF; ++power_info; } } @@ -1508,13 +1508,13 @@ static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, } /** - * iwl3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel + * il3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel * * NOTE: Returned power limit may be less (but not more) than requested, * based strictly on regulatory (eeprom and spectrum mgt) limitations * (no consideration for h/w clipping limitations). */ -static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info) +static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) { s8 max_power; @@ -1533,7 +1533,7 @@ static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info) } /** - * iwl3945_hw_reg_comp_txpower_temp - Compensate for temperature + * il3945_hw_reg_comp_txpower_temp - Compensate for temperature * * Compensate txpower settings of *all* channels for temperature. * This only accounts for the difference between current temperature @@ -1542,10 +1542,10 @@ static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info) * * If RxOn is "associated", this sends the new Txpower to NIC! */ -static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) +static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) { - struct iwl_channel_info *ch_info = NULL; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il_channel_info *ch_info = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; int delta_index; const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; @@ -1563,7 +1563,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) /* set up new Tx power info for each and every channel, 2.4 and 5.x */ for (i = 0; i < priv->channel_count; i++) { ch_info = &priv->channel_info[i]; - a_band = iwl_legacy_is_channel_a_band(ch_info); + a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ ref_temp = (s16)eeprom->groups[ch_info->group_index]. @@ -1571,11 +1571,11 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) /* get power index adjustment based on current and factory * temps */ - delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature, + delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_index = 0; rate_index < IWL_RATE_COUNT_3945; + for (rate_index = 0; rate_index < IL_RATE_COUNT_3945; rate_index++) { int power_idx = ch_info->power_info[rate_index].base_power_index; @@ -1584,7 +1584,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) power_idx += delta_index; /* stay within table range */ - power_idx = iwl3945_hw_reg_fix_power_index(power_idx); + power_idx = il3945_hw_reg_fix_power_index(power_idx); ch_info->power_info[rate_index]. power_table_index = (u8) power_idx; ch_info->power_info[rate_index].tpc = @@ -1596,10 +1596,10 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ for (scan_tbl_index = 0; - scan_tbl_index < IWL_NUM_SCAN_RATES; scan_tbl_index++) { + scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IWL_RATE_1M_INDEX_TABLE : IWL_RATE_6M_INDEX_TABLE; - iwl3945_hw_reg_set_scan_power(priv, scan_tbl_index, + IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + il3945_hw_reg_set_scan_power(priv, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } @@ -1609,68 +1609,68 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) return priv->cfg->ops->lib->send_tx_power(priv); } -int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power) +int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power) { - struct iwl_channel_info *ch_info; + struct il_channel_info *ch_info; s8 max_power; u8 a_band; u8 i; if (priv->tx_power_user_lmt == power) { - IWL_DEBUG_POWER(priv, "Requested Tx power same as current " + IL_DEBUG_POWER(priv, "Requested Tx power same as current " "limit: %ddBm.\n", power); return 0; } - IWL_DEBUG_POWER(priv, "Setting upper limit clamp to %ddBm.\n", power); + IL_DEBUG_POWER(priv, "Setting upper limit clamp to %ddBm.\n", power); priv->tx_power_user_lmt = power; /* set up new Tx powers for each and every channel, 2.4 and 5.x */ for (i = 0; i < priv->channel_count; i++) { ch_info = &priv->channel_info[i]; - a_band = iwl_legacy_is_channel_a_band(ch_info); + a_band = il_is_channel_a_band(ch_info); /* find minimum power of all user and regulatory constraints * (does not consider h/w clipping limitations) */ - max_power = iwl3945_hw_reg_get_ch_txpower_limit(ch_info); + max_power = il3945_hw_reg_get_ch_txpower_limit(ch_info); max_power = min(power, max_power); if (max_power != ch_info->curr_txpow) { ch_info->curr_txpow = max_power; /* this considers the h/w clipping limitations */ - iwl3945_hw_reg_set_new_power(priv, ch_info); + il3945_hw_reg_set_new_power(priv, ch_info); } } /* update txpower settings for all channels, * send to NIC if associated. */ - iwl3945_is_temp_calib_needed(priv); - iwl3945_hw_reg_comp_txpower_temp(priv); + il3945_is_temp_calib_needed(priv); + il3945_hw_reg_comp_txpower_temp(priv); return 0; } -static int iwl3945_send_rxon_assoc(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il3945_send_rxon_assoc(struct il_priv *priv, + struct il_rxon_context *ctx) { int rc = 0; - struct iwl_rx_packet *pkt; - struct iwl3945_rxon_assoc_cmd rxon_assoc; - struct iwl_host_cmd cmd = { + struct il_rx_packet *pkt; + struct il3945_rxon_assoc_cmd rxon_assoc; + struct il_host_cmd cmd = { .id = REPLY_RXON_ASSOC, .len = sizeof(rxon_assoc), .flags = CMD_WANT_SKB, .data = &rxon_assoc, }; - const struct iwl_legacy_rxon_cmd *rxon1 = &ctx->staging; - const struct iwl_legacy_rxon_cmd *rxon2 = &ctx->active; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; if ((rxon1->flags == rxon2->flags) && (rxon1->filter_flags == rxon2->filter_flags) && (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1680,41 +1680,41 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv, rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; rxon_assoc.reserved = 0; - rc = iwl_legacy_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(priv, &cmd); if (rc) return rc; - pkt = (struct iwl_rx_packet *)cmd.reply_page; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n"); + pkt = (struct il_rx_packet *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return rc; } /** - * iwl3945_commit_rxon - commit staging_rxon to hardware + * il3945_commit_rxon - commit staging_rxon to hardware * * The RXON command in staging_rxon is committed to the hardware and * the active_rxon structure is updated with the new data. This * function correctly transitions out of the RXON_ASSOC_MSK state if * a HW tune is required based on the RXON structure changes. */ -int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ - struct iwl3945_rxon_cmd *active_rxon = (void *)&ctx->active; - struct iwl3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; + struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; + struct il3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; int rc = 0; bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EINVAL; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -1; /* always get timestamp with Rx frame */ @@ -1723,23 +1723,23 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) /* select antenna */ staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); - staging_rxon->flags |= iwl3945_get_antenna_flags(priv); + staging_rxon->flags |= il3945_get_antenna_flags(priv); - rc = iwl_legacy_check_rxon_cmd(priv, ctx); + rc = il_check_rxon_cmd(priv, ctx); if (rc) { - IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } /* If we don't need to send a full RXON, we can use - * iwl3945_rxon_assoc_cmd which is used to reconfigure filter + * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!iwl_legacy_full_rxon_required(priv, - &priv->contexts[IWL_RXON_CTX_BSS])) { - rc = iwl_legacy_send_rxon_assoc(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + if (!il_full_rxon_required(priv, + &priv->contexts[IL_RXON_CTX_BSS])) { + rc = il_send_rxon_assoc(priv, + &priv->contexts[IL_RXON_CTX_BSS]); if (rc) { - IWL_ERR(priv, "Error setting RXON_ASSOC " + IL_ERR(priv, "Error setting RXON_ASSOC " "configuration (%d).\n", rc); return rc; } @@ -1749,7 +1749,7 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(priv, priv->tx_power_next, false); return 0; } @@ -1757,8 +1757,8 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS) && new_assoc) { - IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + if (il_is_associated(priv, IL_RXON_CTX_BSS) && new_assoc) { + IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; /* @@ -1767,25 +1767,25 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_RXON, - sizeof(struct iwl3945_rxon_cmd), - &priv->contexts[IWL_RXON_CTX_BSS].active); + rc = il_send_cmd_pdu(priv, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), + &priv->contexts[IL_RXON_CTX_BSS].active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IWL_ERR(priv, "Error clearing ASSOC_MSK on current " + IL_ERR(priv, "Error clearing ASSOC_MSK on current " "configuration (%d).\n", rc); return rc; } - iwl_legacy_clear_ucode_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); - iwl_legacy_restore_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + il_clear_ucode_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); } - IWL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(priv, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1800,38 +1800,38 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) staging_rxon->reserved4 = 0; staging_rxon->reserved5 = 0; - iwl_legacy_set_rxon_hwcrypto(priv, ctx, !iwl3945_mod_params.sw_crypto); + il_set_rxon_hwcrypto(priv, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_RXON, - sizeof(struct iwl3945_rxon_cmd), + rc = il_send_cmd_pdu(priv, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { - IWL_ERR(priv, "Error setting new configuration (%d).\n", rc); + IL_ERR(priv, "Error setting new configuration (%d).\n", rc); return rc; } memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); if (!new_assoc) { - iwl_legacy_clear_ucode_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); - iwl_legacy_restore_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + il_clear_ucode_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); } /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - rc = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true); + rc = il_set_tx_power(priv, priv->tx_power_next, true); if (rc) { - IWL_ERR(priv, "Error setting Tx power (%d).\n", rc); + IL_ERR(priv, "Error setting Tx power (%d).\n", rc); return rc; } /* Init the hardware's rate fallback order based on the band */ - rc = iwl3945_init_hw_rate_table(priv); + rc = il3945_init_hw_rate_table(priv); if (rc) { - IWL_ERR(priv, "Error setting HW rate table: %02X\n", rc); + IL_ERR(priv, "Error setting HW rate table: %02X\n", rc); return -EIO; } @@ -1839,7 +1839,7 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) } /** - * iwl3945_reg_txpower_periodic - called when time to check our temperature. + * il3945_reg_txpower_periodic - called when time to check our temperature. * * -- reset periodic timer * -- see if temp has changed enough to warrant re-calibration ... if so: @@ -1848,38 +1848,38 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * -- send new set of gain settings to NIC * NOTE: This should continue working, even when we're not associated, * so we can keep our internal table of scan powers current. */ -void iwl3945_reg_txpower_periodic(struct iwl_priv *priv) +void il3945_reg_txpower_periodic(struct il_priv *priv) { /* This will kick in the "brute force" - * iwl3945_hw_reg_comp_txpower_temp() below */ - if (!iwl3945_is_temp_calib_needed(priv)) + * il3945_hw_reg_comp_txpower_temp() below */ + if (!il3945_is_temp_calib_needed(priv)) goto reschedule; /* Set up a new set of temp-adjusted TxPowers, send to NIC. * This is based *only* on current temperature, * ignoring any previous power measurements */ - iwl3945_hw_reg_comp_txpower_temp(priv); + il3945_hw_reg_comp_txpower_temp(priv); reschedule: queue_delayed_work(priv->workqueue, &priv->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); } -static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work) +static void il3945_bg_reg_txpower_periodic(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, + struct il_priv *priv = container_of(work, struct il_priv, _3945.thermal_periodic.work); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; mutex_lock(&priv->mutex); - iwl3945_reg_txpower_periodic(priv); + il3945_reg_txpower_periodic(priv); mutex_unlock(&priv->mutex); } /** - * iwl3945_hw_reg_get_ch_grp_index - find the channel-group index (0-4) + * il3945_hw_reg_get_ch_grp_index - find the channel-group index (0-4) * for the channel. * * This function is used when initializing channel-info structs. @@ -1889,17 +1889,17 @@ static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv, - const struct iwl_channel_info *ch_info) +static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, + const struct il_channel_info *ch_info) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; - struct iwl3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; u8 group; u16 group_index = 0; /* based on factory calib frequencies */ u8 grp_channel; /* Find the group index for the channel ... don't use index 1(?) */ - if (iwl_legacy_is_channel_a_band(ch_info)) { + if (il_is_channel_a_band(ch_info)) { for (group = 1; group < 5; group++) { grp_channel = ch_grp[group].group_channel; if (ch_info->channel <= grp_channel) { @@ -1913,27 +1913,27 @@ static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv, } else group_index = 0; /* 2.4 GHz, group 0 */ - IWL_DEBUG_POWER(priv, "Chnl %d mapped to grp %d\n", ch_info->channel, + IL_DEBUG_POWER(priv, "Chnl %d mapped to grp %d\n", ch_info->channel, group_index); return group_index; } /** - * iwl3945_hw_reg_get_matched_power_index - Interpolate to get nominal index + * il3945_hw_reg_get_matched_power_index - Interpolate to get nominal index * * Interpolate to get nominal (i.e. at factory calibration temperature) index * into radio/DSP gain settings table for requested power. */ -static int iwl3945_hw_reg_get_matched_power_index(struct iwl_priv *priv, +static int il3945_hw_reg_get_matched_power_index(struct il_priv *priv, s8 requested_power, s32 setting_index, s32 *new_index) { - const struct iwl3945_eeprom_txpower_group *chnl_grp = NULL; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + const struct il3945_eeprom_txpower_group *chnl_grp = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; s32 index0, index1; s32 power = 2 * requested_power; s32 i; - const struct iwl3945_eeprom_txpower_sample *samples; + const struct il3945_eeprom_txpower_sample *samples; s32 gains0, gains1; s32 res; s32 denominator; @@ -1973,23 +1973,23 @@ static int iwl3945_hw_reg_get_matched_power_index(struct iwl_priv *priv, return 0; } -static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) +static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) { u32 i; s32 rate_index; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; - const struct iwl3945_eeprom_txpower_group *group; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + const struct il3945_eeprom_txpower_group *group; - IWL_DEBUG_POWER(priv, "Initializing factory calib info from EEPROM\n"); + IL_DEBUG_POWER(priv, "Initializing factory calib info from EEPROM\n"); - for (i = 0; i < IWL_NUM_TX_CALIB_GROUPS; i++) { + for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { s8 *clip_pwrs; /* table of power levels for each rate */ s8 satur_pwr; /* saturation power for each chnl group */ group = &eeprom->groups[i]; /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { - IWL_WARN(priv, "Error: saturation power is %d, " + IL_WARN(priv, "Error: saturation power is %d, " "less than minimum expected 40\n", group->saturation_power); return; @@ -2011,21 +2011,21 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) /* fill in channel group's nominal powers for each rate */ for (rate_index = 0; - rate_index < IWL_RATE_COUNT_3945; rate_index++, clip_pwrs++) { + rate_index < IL_RATE_COUNT_3945; rate_index++, clip_pwrs++) { switch (rate_index) { - case IWL_RATE_36M_INDEX_TABLE: + case IL_RATE_36M_INDEX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case IWL_RATE_48M_INDEX_TABLE: + case IL_RATE_48M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case IWL_RATE_54M_INDEX_TABLE: + case IL_RATE_54M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2040,7 +2040,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) } /** - * iwl3945_txpower_set_from_eeprom - Set channel power info based on EEPROM + * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM * * Second pass (during init) to set up priv->channel_info * @@ -2054,11 +2054,11 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) * * This does *not* write values to NIC, just sets up our internal table. */ -int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) +int il3945_txpower_set_from_eeprom(struct il_priv *priv) { - struct iwl_channel_info *ch_info = NULL; - struct iwl3945_channel_power_info *pwr_info; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il_channel_info *ch_info = NULL; + struct il3945_channel_power_info *pwr_info; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; int delta_index; u8 rate_index; u8 scan_tbl_index; @@ -2071,37 +2071,37 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) /* save temperature reference, * so we can determine next time to calibrate */ - temperature = iwl3945_hw_reg_txpower_get_temperature(priv); + temperature = il3945_hw_reg_txpower_get_temperature(priv); priv->last_temperature = temperature; - iwl3945_hw_reg_init_channel_groups(priv); + il3945_hw_reg_init_channel_groups(priv); /* initialize Tx power info for each and every channel, 2.4 and 5.x */ for (i = 0, ch_info = priv->channel_info; i < priv->channel_count; i++, ch_info++) { - a_band = iwl_legacy_is_channel_a_band(ch_info); - if (!iwl_legacy_is_channel_valid(ch_info)) + a_band = il_is_channel_a_band(ch_info); + if (!il_is_channel_valid(ch_info)) continue; /* find this channel's channel group (*not* "band") index */ ch_info->group_index = - iwl3945_hw_reg_get_ch_grp_index(priv, ch_info); + il3945_hw_reg_get_ch_grp_index(priv, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; /* calculate power index *adjustment* value according to * diff between current temperature and factory temperature */ - delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature, + delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, eeprom->groups[ch_info->group_index]. temperature); - IWL_DEBUG_POWER(priv, "Delta index for channel %d: %d [%d]\n", + IL_DEBUG_POWER(priv, "Delta index for channel %d: %d [%d]\n", ch_info->channel, delta_index, temperature + - IWL_TEMP_CONVERT); + IL_TEMP_CONVERT); /* set tx power value for all OFDM rates */ - for (rate_index = 0; rate_index < IWL_OFDM_RATES; + for (rate_index = 0; rate_index < IL_OFDM_RATES; rate_index++) { s32 uninitialized_var(power_idx); int rc; @@ -2115,11 +2115,11 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) /* get base (i.e. at factory-measured temperature) * power table index for this rate's power */ - rc = iwl3945_hw_reg_get_matched_power_index(priv, pwr, + rc = il3945_hw_reg_get_matched_power_index(priv, pwr, ch_info->group_index, &power_idx); if (rc) { - IWL_ERR(priv, "Invalid power index\n"); + IL_ERR(priv, "Invalid power index\n"); return rc; } pwr_info->base_power_index = (u8) power_idx; @@ -2128,9 +2128,9 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) power_idx += delta_index; /* stay within range of gain table */ - power_idx = iwl3945_hw_reg_fix_power_index(power_idx); + power_idx = il3945_hw_reg_fix_power_index(power_idx); - /* fill 1 OFDM rate's iwl3945_channel_power_info struct */ + /* fill 1 OFDM rate's il3945_channel_power_info struct */ pwr_info->requested_power = pwr; pwr_info->power_table_index = (u8) power_idx; pwr_info->tpc.tx_gain = @@ -2140,25 +2140,25 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[IWL_RATE_12M_INDEX_TABLE]; + pwr_info = &ch_info->power_info[IL_RATE_12M_INDEX_TABLE]; power = pwr_info->requested_power + - IWL_CCK_FROM_OFDM_POWER_DIFF; + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_index = pwr_info->power_table_index + - IWL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_INDEX_DIFF; base_pwr_index = pwr_info->base_power_index + - IWL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_INDEX_DIFF; /* stay within table range */ - pwr_index = iwl3945_hw_reg_fix_power_index(pwr_index); + pwr_index = il3945_hw_reg_fix_power_index(pwr_index); gain = power_gain_table[a_band][pwr_index].tx_gain; dsp_atten = power_gain_table[a_band][pwr_index].dsp_atten; - /* fill each CCK rate's iwl3945_channel_power_info structure + /* fill each CCK rate's il3945_channel_power_info structure * NOTE: All CCK-rate Txpwrs are the same for a given chnl! * NOTE: CCK rates start at end of OFDM rates! */ for (rate_index = 0; - rate_index < IWL_CCK_RATES; rate_index++) { - pwr_info = &ch_info->power_info[rate_index+IWL_OFDM_RATES]; + rate_index < IL_CCK_RATES; rate_index++) { + pwr_info = &ch_info->power_info[rate_index+IL_OFDM_RATES]; pwr_info->requested_power = power; pwr_info->power_table_index = pwr_index; pwr_info->base_power_index = base_pwr_index; @@ -2168,10 +2168,10 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ for (scan_tbl_index = 0; - scan_tbl_index < IWL_NUM_SCAN_RATES; scan_tbl_index++) { + scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IWL_RATE_1M_INDEX_TABLE : IWL_RATE_6M_INDEX_TABLE; - iwl3945_hw_reg_set_scan_power(priv, scan_tbl_index, + IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + il3945_hw_reg_set_scan_power(priv, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } } @@ -2179,31 +2179,31 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) return 0; } -int iwl3945_hw_rxq_stop(struct iwl_priv *priv) +int il3945_hw_rxq_stop(struct il_priv *priv) { int rc; - iwl_legacy_write_direct32(priv, FH39_RCSR_CONFIG(0), 0); - rc = iwl_poll_direct_bit(priv, FH39_RSSR_STATUS, + il_write_direct32(priv, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_direct_bit(priv, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) - IWL_ERR(priv, "Can't stop Rx DMA.\n"); + IL_ERR(priv, "Can't stop Rx DMA.\n"); return 0; } -int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) +int il3945_hw_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq) { int txq_id = txq->q.id; - struct iwl3945_shared *shared_data = priv->_3945.shared_virt; + struct il3945_shared *shared_data = priv->_3945.shared_virt; shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - iwl_legacy_write_direct32(priv, FH39_CBCC_CTRL(txq_id), 0); - iwl_legacy_write_direct32(priv, FH39_CBCC_BASE(txq_id), 0); + il_write_direct32(priv, FH39_CBCC_CTRL(txq_id), 0); + il_write_direct32(priv, FH39_CBCC_BASE(txq_id), 0); - iwl_legacy_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), + il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | @@ -2211,7 +2211,7 @@ int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ - iwl_read32(priv, FH39_TSSR_CBB_BASE); + il_read32(priv, FH39_TSSR_CBB_BASE); return 0; } @@ -2219,26 +2219,26 @@ int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* * HCMD utils */ -static u16 iwl3945_get_hcmd_size(u8 cmd_id, u16 len) +static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case REPLY_RXON: - return sizeof(struct iwl3945_rxon_cmd); + return sizeof(struct il3945_rxon_cmd); case POWER_TABLE_CMD: - return sizeof(struct iwl3945_powertable_cmd); + return sizeof(struct il3945_powertable_cmd); default: return len; } } -static u16 iwl3945_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, +static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 *data) { - struct iwl3945_addsta_cmd *addsta = (struct iwl3945_addsta_cmd *)data; + struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; addsta->mode = cmd->mode; memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct iwl4965_keyinfo)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); addsta->station_flags = cmd->station_flags; addsta->station_flags_msk = cmd->station_flags_msk; addsta->tid_disable_tx = cpu_to_le16(0); @@ -2247,23 +2247,23 @@ static u16 iwl3945_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - return (u16)sizeof(struct iwl3945_addsta_cmd); + return (u16)sizeof(struct il3945_addsta_cmd); } -static int iwl3945_add_bssid_station(struct iwl_priv *priv, +static int il3945_add_bssid_station(struct il_priv *priv, const u8 *addr, u8 *sta_id_r) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; int ret; u8 sta_id; unsigned long flags; if (sta_id_r) - *sta_id_r = IWL_INVALID_STATION; + *sta_id_r = IL_INVALID_STATION; - ret = iwl_legacy_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(priv, "Unable to add station %pM\n", addr); return ret; } @@ -2271,93 +2271,93 @@ static int iwl3945_add_bssid_station(struct iwl_priv *priv, *sta_id_r = sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IWL_STA_LOCAL; + priv->stations[sta_id].used |= IL_STA_LOCAL; spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } -static int iwl3945_manage_ibss_station(struct iwl_priv *priv, +static int il3945_manage_ibss_station(struct il_priv *priv, struct ieee80211_vif *vif, bool add) { - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; int ret; if (add) { - ret = iwl3945_add_bssid_station(priv, vif->bss_conf.bssid, + ret = il3945_add_bssid_station(priv, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); if (ret) return ret; - iwl3945_sync_sta(priv, vif_priv->ibss_bssid_sta_id, + il3945_sync_sta(priv, vif_priv->ibss_bssid_sta_id, (priv->band == IEEE80211_BAND_5GHZ) ? - IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP); - iwl3945_rate_scale_init(priv->hw, vif_priv->ibss_bssid_sta_id); + IL_RATE_6M_PLCP : IL_RATE_1M_PLCP); + il3945_rate_scale_init(priv->hw, vif_priv->ibss_bssid_sta_id); return 0; } - return iwl_legacy_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } /** - * iwl3945_init_hw_rate_table - Initialize the hardware rate fallback table + * il3945_init_hw_rate_table - Initialize the hardware rate fallback table */ -int iwl3945_init_hw_rate_table(struct iwl_priv *priv) +int il3945_init_hw_rate_table(struct il_priv *priv) { int rc, i, index, prev_index; - struct iwl3945_rate_scaling_cmd rate_cmd = { + struct il3945_rate_scaling_cmd rate_cmd = { .reserved = {0, 0, 0}, }; - struct iwl3945_rate_scaling_info *table = rate_cmd.table; + struct il3945_rate_scaling_info *table = rate_cmd.table; - for (i = 0; i < ARRAY_SIZE(iwl3945_rates); i++) { - index = iwl3945_rates[i].table_rs_index; + for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { + index = il3945_rates[i].table_rs_index; table[index].rate_n_flags = - iwl3945_hw_set_rate_n_flags(iwl3945_rates[i].plcp, 0); + il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); table[index].try_cnt = priv->retry_rate; - prev_index = iwl3945_get_prev_ieee_rate(i); + prev_index = il3945_get_prev_ieee_rate(i); table[index].next_rate_index = - iwl3945_rates[prev_index].table_rs_index; + il3945_rates[prev_index].table_rs_index; } switch (priv->band) { case IEEE80211_BAND_5GHZ: - IWL_DEBUG_RATE(priv, "Select A mode rate scale\n"); + IL_DEBUG_RATE(priv, "Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = IWL_RATE_1M_INDEX_TABLE; - i <= IWL_RATE_11M_INDEX_TABLE; i++) + for (i = IL_RATE_1M_INDEX_TABLE; + i <= IL_RATE_11M_INDEX_TABLE; i++) table[i].next_rate_index = - iwl3945_rates[IWL_FIRST_OFDM_RATE].table_rs_index; + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; /* Don't fall back to CCK rates */ - table[IWL_RATE_12M_INDEX_TABLE].next_rate_index = - IWL_RATE_9M_INDEX_TABLE; + table[IL_RATE_12M_INDEX_TABLE].next_rate_index = + IL_RATE_9M_INDEX_TABLE; /* Don't drop out of OFDM rates */ - table[IWL_RATE_6M_INDEX_TABLE].next_rate_index = - iwl3945_rates[IWL_FIRST_OFDM_RATE].table_rs_index; + table[IL_RATE_6M_INDEX_TABLE].next_rate_index = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; break; case IEEE80211_BAND_2GHZ: - IWL_DEBUG_RATE(priv, "Select B/G mode rate scale\n"); + IL_DEBUG_RATE(priv, "Select B/G mode rate scale\n"); /* If an OFDM rate is used, have it fall back to the * 1M CCK rates */ - if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) && - iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { + if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(priv, IL_RXON_CTX_BSS)) { - index = IWL_FIRST_CCK_RATE; - for (i = IWL_RATE_6M_INDEX_TABLE; - i <= IWL_RATE_54M_INDEX_TABLE; i++) + index = IL_FIRST_CCK_RATE; + for (i = IL_RATE_6M_INDEX_TABLE; + i <= IL_RATE_54M_INDEX_TABLE; i++) table[i].next_rate_index = - iwl3945_rates[index].table_rs_index; + il3945_rates[index].table_rs_index; - index = IWL_RATE_11M_INDEX_TABLE; + index = IL_RATE_11M_INDEX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = IWL_RATE_5M_INDEX_TABLE; + table[index].next_rate_index = IL_RATE_5M_INDEX_TABLE; } break; @@ -2368,41 +2368,41 @@ int iwl3945_init_hw_rate_table(struct iwl_priv *priv) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + rc = il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return iwl_legacy_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + return il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } /* Called when initializing driver */ -int iwl3945_hw_set_hw_params(struct iwl_priv *priv) +int il3945_hw_set_hw_params(struct il_priv *priv) { memset((void *)&priv->hw_params, 0, - sizeof(struct iwl_hw_params)); + sizeof(struct il_hw_params)); priv->_3945.shared_virt = dma_alloc_coherent(&priv->pci_dev->dev, - sizeof(struct iwl3945_shared), + sizeof(struct il3945_shared), &priv->_3945.shared_phys, GFP_KERNEL); if (!priv->_3945.shared_virt) { - IWL_ERR(priv, "failed to allocate pci memory\n"); + IL_ERR(priv, "failed to allocate pci memory\n"); return -ENOMEM; } /* Assign number of Usable TX queues */ priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; - priv->hw_params.tfd_size = sizeof(struct iwl3945_tfd); - priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_3K); + priv->hw_params.tfd_size = sizeof(struct il3945_tfd); + priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; priv->hw_params.max_stations = IWL3945_STATION_COUNT; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; + priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; priv->sta_key_max_num = STA_KEY_MAX_NUM; @@ -2413,20 +2413,20 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv) return 0; } -unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl3945_frame *frame, u8 rate) +unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, + struct il3945_frame *frame, u8 rate) { - struct iwl3945_tx_beacon_cmd *tx_beacon_cmd; + struct il3945_tx_beacon_cmd *tx_beacon_cmd; unsigned int frame_size; - tx_beacon_cmd = (struct iwl3945_tx_beacon_cmd *)&frame->u; + tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); tx_beacon_cmd->tx.sta_id = - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id; + priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - frame_size = iwl3945_fill_beacon_frame(priv, + frame_size = il3945_fill_beacon_frame(priv, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); @@ -2437,51 +2437,51 @@ unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv, tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK); - /* supp_rates[0] == OFDM start at IWL_FIRST_OFDM_RATE*/ + /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ tx_beacon_cmd->tx.supp_rates[0] = - (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; tx_beacon_cmd->tx.supp_rates[1] = - (IWL_CCK_BASIC_RATES_MASK & 0xF); + (IL_CCK_BASIC_RATES_MASK & 0xF); - return sizeof(struct iwl3945_tx_beacon_cmd) + frame_size; + return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void iwl3945_hw_rx_handler_setup(struct iwl_priv *priv) +void il3945_hw_rx_handler_setup(struct il_priv *priv) { - priv->rx_handlers[REPLY_TX] = iwl3945_rx_reply_tx; - priv->rx_handlers[REPLY_3945_RX] = iwl3945_rx_reply_rx; + priv->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; + priv->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; } -void iwl3945_hw_setup_deferred_work(struct iwl_priv *priv) +void il3945_hw_setup_deferred_work(struct il_priv *priv) { INIT_DELAYED_WORK(&priv->_3945.thermal_periodic, - iwl3945_bg_reg_txpower_periodic); + il3945_bg_reg_txpower_periodic); } -void iwl3945_hw_cancel_deferred_work(struct iwl_priv *priv) +void il3945_hw_cancel_deferred_work(struct il_priv *priv) { cancel_delayed_work(&priv->_3945.thermal_periodic); } /* check contents of special bootstrap uCode SRAM */ -static int iwl3945_verify_bsm(struct iwl_priv *priv) +static int il3945_verify_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; u32 reg; u32 val; - IWL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(priv, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = iwl_legacy_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = iwl_legacy_read_prph(priv, reg); + val = il_read_prph(priv, reg); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(priv, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -2490,7 +2490,7 @@ static int iwl3945_verify_bsm(struct iwl_priv *priv) } } - IWL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); return 0; } @@ -2510,20 +2510,20 @@ static int iwl3945_verify_bsm(struct iwl_priv *priv) * simply claims ownership, which should be safe when this function is called * (i.e. before loading uCode!). */ -static int iwl3945_eeprom_acquire_semaphore(struct iwl_priv *priv) +static int il3945_eeprom_acquire_semaphore(struct il_priv *priv) { - _iwl_legacy_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); + _il_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); return 0; } -static void iwl3945_eeprom_release_semaphore(struct iwl_priv *priv) +static void il3945_eeprom_release_semaphore(struct il_priv *priv) { return; } /** - * iwl3945_load_bsm - Load bootstrap instructions + * il3945_load_bsm - Load bootstrap instructions * * BSM operation: * @@ -2554,7 +2554,7 @@ static void iwl3945_eeprom_release_semaphore(struct iwl_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int iwl3945_load_bsm(struct iwl_priv *priv) +static int il3945_load_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; @@ -2567,7 +2567,7 @@ static int iwl3945_load_bsm(struct iwl_priv *priv) u32 done; u32 reg_offset; - IWL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(priv, "Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL39_MAX_BSM_SIZE) @@ -2575,7 +2575,7 @@ static int iwl3945_load_bsm(struct iwl_priv *priv) /* Tell bootstrap uCode where to find the "Initialize" uCode * in host DRAM ... host DRAM physical address bits 31:0 for 3945. - * NOTE: iwl3945_initialize_alive_start() will replace these values, + * NOTE: il3945_initialize_alive_start() will replace these values, * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ pinst = priv->ucode_init.p_addr; @@ -2583,69 +2583,69 @@ static int iwl3945_load_bsm(struct iwl_priv *priv) inst_len = priv->ucode_init.len; data_len = priv->ucode_init_data.len; - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _iwl_legacy_write_prph(priv, reg_offset, + _il_write_prph(priv, reg_offset, le32_to_cpu(*image)); - rc = iwl3945_verify_bsm(priv); + rc = il3945_verify_bsm(priv); if (rc) return rc; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - iwl_legacy_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - iwl_legacy_write_prph(priv, BSM_WR_MEM_DST_REG, + il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(priv, BSM_WR_MEM_DST_REG, IWL39_RTC_INST_LOWER_BOUND); - iwl_legacy_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - iwl_legacy_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = iwl_legacy_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(priv, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IWL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); else { - IWL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(priv, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - iwl_legacy_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; } -static struct iwl_hcmd_ops iwl3945_hcmd = { - .rxon_assoc = iwl3945_send_rxon_assoc, - .commit_rxon = iwl3945_commit_rxon, +static struct il_hcmd_ops il3945_hcmd = { + .rxon_assoc = il3945_send_rxon_assoc, + .commit_rxon = il3945_commit_rxon, }; -static struct iwl_lib_ops iwl3945_lib = { - .txq_attach_buf_to_tfd = iwl3945_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = iwl3945_hw_txq_free_tfd, - .txq_init = iwl3945_hw_tx_queue_init, - .load_ucode = iwl3945_load_bsm, - .dump_nic_error_log = iwl3945_dump_nic_error_log, +static struct il_lib_ops il3945_lib = { + .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il3945_hw_txq_free_tfd, + .txq_init = il3945_hw_tx_queue_init, + .load_ucode = il3945_load_bsm, + .dump_nic_error_log = il3945_dump_nic_error_log, .apm_ops = { - .init = iwl3945_apm_init, - .config = iwl3945_nic_config, + .init = il3945_apm_init, + .config = il3945_nic_config, }, .eeprom_ops = { .regulatory_bands = { @@ -2657,85 +2657,85 @@ static struct iwl_lib_ops iwl3945_lib = { EEPROM_REGULATORY_BAND_NO_HT40, EEPROM_REGULATORY_BAND_NO_HT40, }, - .acquire_semaphore = iwl3945_eeprom_acquire_semaphore, - .release_semaphore = iwl3945_eeprom_release_semaphore, + .acquire_semaphore = il3945_eeprom_acquire_semaphore, + .release_semaphore = il3945_eeprom_release_semaphore, }, - .send_tx_power = iwl3945_send_tx_power, - .is_valid_rtc_data_addr = iwl3945_hw_valid_rtc_data_addr, + .send_tx_power = il3945_send_tx_power, + .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, .debugfs_ops = { - .rx_stats_read = iwl3945_ucode_rx_stats_read, - .tx_stats_read = iwl3945_ucode_tx_stats_read, - .general_stats_read = iwl3945_ucode_general_stats_read, + .rx_stats_read = il3945_ucode_rx_stats_read, + .tx_stats_read = il3945_ucode_tx_stats_read, + .general_stats_read = il3945_ucode_general_stats_read, }, }; -static const struct iwl_legacy_ops iwl3945_legacy_ops = { - .post_associate = iwl3945_post_associate, - .config_ap = iwl3945_config_ap, - .manage_ibss_station = iwl3945_manage_ibss_station, +static const struct il_legacy_ops il3945_legacy_ops = { + .post_associate = il3945_post_associate, + .config_ap = il3945_config_ap, + .manage_ibss_station = il3945_manage_ibss_station, }; -static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = { - .get_hcmd_size = iwl3945_get_hcmd_size, - .build_addsta_hcmd = iwl3945_build_addsta_hcmd, - .request_scan = iwl3945_request_scan, - .post_scan = iwl3945_post_scan, +static struct il_hcmd_utils_ops il3945_hcmd_utils = { + .get_hcmd_size = il3945_get_hcmd_size, + .build_addsta_hcmd = il3945_build_addsta_hcmd, + .request_scan = il3945_request_scan, + .post_scan = il3945_post_scan, }; -static const struct iwl_ops iwl3945_ops = { - .lib = &iwl3945_lib, - .hcmd = &iwl3945_hcmd, - .utils = &iwl3945_hcmd_utils, - .led = &iwl3945_led_ops, - .legacy = &iwl3945_legacy_ops, - .ieee80211_ops = &iwl3945_hw_ops, +static const struct il_ops il3945_ops = { + .lib = &il3945_lib, + .hcmd = &il3945_hcmd, + .utils = &il3945_hcmd_utils, + .led = &il3945_led_ops, + .legacy = &il3945_legacy_ops, + .ieee80211_ops = &il3945_hw_ops, }; -static struct iwl_base_params iwl3945_base_params = { +static struct il_base_params il3945_base_params = { .eeprom_size = IWL3945_EEPROM_IMG_SIZE, .num_of_queues = IWL39_NUM_QUEUES, .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, .set_l0s = false, .use_bsm = true, .led_compensation = 64, - .wd_timeout = IWL_DEF_WD_TIMEOUT, + .wd_timeout = IL_DEF_WD_TIMEOUT, }; -static struct iwl_cfg iwl3945_bg_cfg = { +static struct il_cfg il3945_bg_cfg = { .name = "3945BG", .fw_name_pre = IWL3945_FW_PRE, .ucode_api_max = IWL3945_UCODE_API_MAX, .ucode_api_min = IWL3945_UCODE_API_MIN, - .sku = IWL_SKU_G, + .sku = IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &iwl3945_ops, - .mod_params = &iwl3945_mod_params, - .base_params = &iwl3945_base_params, - .led_mode = IWL_LED_BLINK, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, }; -static struct iwl_cfg iwl3945_abg_cfg = { +static struct il_cfg il3945_abg_cfg = { .name = "3945ABG", .fw_name_pre = IWL3945_FW_PRE, .ucode_api_max = IWL3945_UCODE_API_MAX, .ucode_api_min = IWL3945_UCODE_API_MIN, - .sku = IWL_SKU_A|IWL_SKU_G, + .sku = IL_SKU_A|IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &iwl3945_ops, - .mod_params = &iwl3945_mod_params, - .base_params = &iwl3945_base_params, - .led_mode = IWL_LED_BLINK, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, }; -DEFINE_PCI_DEVICE_TABLE(iwl3945_hw_card_ids) = { - {IWL_PCI_DEVICE(0x4222, 0x1005, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4222, 0x1034, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4222, 0x1044, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4227, 0x1014, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4222, PCI_ANY_ID, iwl3945_abg_cfg)}, - {IWL_PCI_DEVICE(0x4227, PCI_ANY_ID, iwl3945_abg_cfg)}, +DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { + {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, + {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, {0} }; -MODULE_DEVICE_TABLE(pci, iwl3945_hw_card_ids); +MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index b118b59..167eedc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -29,15 +29,15 @@ * Please use iwl-3945-hw.h for hardware-related definitions. */ -#ifndef __iwl_3945_h__ -#define __iwl_3945_h__ +#ifndef __il_3945_h__ +#define __il_3945_h__ #include /* for struct pci_device_id */ #include #include /* Hardware specific file defines the PCI IDs table for that hardware module */ -extern const struct pci_device_id iwl3945_hw_card_ids[]; +extern const struct pci_device_id il3945_hw_card_ids[]; #include "iwl-csr.h" #include "iwl-prph.h" @@ -69,12 +69,12 @@ extern const struct pci_device_id iwl3945_hw_card_ids[]; * noise info (e.g. averaging might be done in app); measured dBm values are * always negative ... using a negative value as the default keeps all * averages within an s8's (used in some apps) range of negative values. */ -#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127) +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) /* Module parameters accessible from iwl-*.c */ -extern struct iwl_mod_params iwl3945_mod_params; +extern struct il_mod_params il3945_mod_params; -struct iwl3945_rate_scale_data { +struct il3945_rate_scale_data { u64 data; s32 success_counter; s32 success_ratio; @@ -83,9 +83,9 @@ struct iwl3945_rate_scale_data { unsigned long stamp; }; -struct iwl3945_rs_sta { +struct il3945_rs_sta { spinlock_t lock; - struct iwl_priv *priv; + struct il_priv *priv; s32 *expected_tpt; unsigned long last_partial_flush; unsigned long last_flush; @@ -96,7 +96,7 @@ struct iwl3945_rs_sta { u8 flush_pending; u8 start_rate; struct timer_list rate_scale_flush; - struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945]; + struct il3945_rate_scale_data win[IL_RATE_COUNT_3945]; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *rs_sta_dbgfs_stats_table_file; #endif @@ -110,15 +110,15 @@ struct iwl3945_rs_sta { * The common struct MUST be first because it is shared between * 3945 and 4965! */ -struct iwl3945_sta_priv { - struct iwl_station_priv_common common; - struct iwl3945_rs_sta rs_sta; +struct il3945_sta_priv { + struct il_station_priv_common common; + struct il3945_rs_sta rs_sta; }; -enum iwl3945_antenna { - IWL_ANTENNA_DIVERSITY, - IWL_ANTENNA_MAIN, - IWL_ANTENNA_AUX +enum il3945_antenna { + IL_ANTENNA_DIVERSITY, + IL_ANTENNA_MAIN, + IL_ANTENNA_AUX }; /* @@ -138,23 +138,23 @@ enum iwl3945_antenna { #define DEFAULT_SHORT_RETRY_LIMIT 7U #define DEFAULT_LONG_RETRY_LIMIT 4U -#define IWL_TX_FIFO_AC0 0 -#define IWL_TX_FIFO_AC1 1 -#define IWL_TX_FIFO_AC2 2 -#define IWL_TX_FIFO_AC3 3 -#define IWL_TX_FIFO_HCCA_1 5 -#define IWL_TX_FIFO_HCCA_2 6 -#define IWL_TX_FIFO_NONE 7 +#define IL_TX_FIFO_AC0 0 +#define IL_TX_FIFO_AC1 1 +#define IL_TX_FIFO_AC2 2 +#define IL_TX_FIFO_AC3 3 +#define IL_TX_FIFO_HCCA_1 5 +#define IL_TX_FIFO_HCCA_2 6 +#define IL_TX_FIFO_NONE 7 #define IEEE80211_DATA_LEN 2304 #define IEEE80211_4ADDR_LEN 30 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) -struct iwl3945_frame { +struct il3945_frame { union { struct ieee80211_hdr frame; - struct iwl3945_tx_beacon_cmd beacon; + struct il3945_tx_beacon_cmd beacon; u8 raw[IEEE80211_FRAME_LEN]; u8 cmd[360]; } u; @@ -169,19 +169,19 @@ struct iwl3945_frame { #define SUP_RATE_11B_MAX_NUM_CHANNELS 4 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12 -#define IWL_SUPPORTED_RATES_IE_LEN 8 +#define IL_SUPPORTED_RATES_IE_LEN 8 #define SCAN_INTERVAL 100 #define MAX_TID_COUNT 9 -#define IWL_INVALID_RATE 0xFF -#define IWL_INVALID_VALUE -1 +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 #define STA_PS_STATUS_WAKE 0 #define STA_PS_STATUS_SLEEP 1 -struct iwl3945_ibss_seq { +struct il3945_ibss_seq { u8 mac[ETH_ALEN]; u16 seq_num; u16 frag_num; @@ -189,14 +189,14 @@ struct iwl3945_ibss_seq { struct list_head list; }; -#define IWL_RX_HDR(x) ((struct iwl3945_rx_frame_hdr *)(\ +#define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\ x->u.rx_frame.stats.payload + \ x->u.rx_frame.stats.phy_count)) -#define IWL_RX_END(x) ((struct iwl3945_rx_frame_end *)(\ - IWL_RX_HDR(x)->payload + \ - le16_to_cpu(IWL_RX_HDR(x)->len))) -#define IWL_RX_STATS(x) (&x->u.rx_frame.stats) -#define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload) +#define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\ + IL_RX_HDR(x)->payload + \ + le16_to_cpu(IL_RX_HDR(x)->len))) +#define IL_RX_STATS(x) (&x->u.rx_frame.stats) +#define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) /****************************************************************************** @@ -205,14 +205,14 @@ struct iwl3945_ibss_seq { * for use by iwl-*.c * *****************************************************************************/ -extern int iwl3945_calc_db_from_ratio(int sig_ratio); -extern void iwl3945_rx_replenish(void *data); -extern void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -extern unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv, +extern int il3945_calc_db_from_ratio(int sig_ratio); +extern void il3945_rx_replenish(void *data); +extern void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); +extern unsigned int il3945_fill_beacon_frame(struct il_priv *priv, struct ieee80211_hdr *hdr, int left); -extern int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log, +extern int il3945_dump_nic_event_log(struct il_priv *priv, bool full_log, char **buf, bool display); -extern void iwl3945_dump_nic_error_log(struct iwl_priv *priv); +extern void il3945_dump_nic_error_log(struct il_priv *priv); /****************************************************************************** * @@ -223,86 +223,86 @@ extern void iwl3945_dump_nic_error_log(struct iwl_priv *priv); * which is why they are in the hardware specific files (vs. iwl-base.c) * * Naming convention -- - * iwl3945_ <-- Its part of iwlwifi (should be changed to iwl3945_) - * iwl3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) + * il3945_ <-- Its part of iwlwifi (should be changed to il3945_) + * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * iwl3945_bg_ <-- Called from work queue context - * iwl3945_mac_ <-- mac80211 callback + * il3945_bg_ <-- Called from work queue context + * il3945_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void iwl3945_hw_rx_handler_setup(struct iwl_priv *priv); -extern void iwl3945_hw_setup_deferred_work(struct iwl_priv *priv); -extern void iwl3945_hw_cancel_deferred_work(struct iwl_priv *priv); -extern int iwl3945_hw_rxq_stop(struct iwl_priv *priv); -extern int iwl3945_hw_set_hw_params(struct iwl_priv *priv); -extern int iwl3945_hw_nic_init(struct iwl_priv *priv); -extern int iwl3945_hw_nic_stop_master(struct iwl_priv *priv); -extern void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv); -extern void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv); -extern int iwl3945_hw_nic_reset(struct iwl_priv *priv); -extern int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +extern void il3945_hw_rx_handler_setup(struct il_priv *priv); +extern void il3945_hw_setup_deferred_work(struct il_priv *priv); +extern void il3945_hw_cancel_deferred_work(struct il_priv *priv); +extern int il3945_hw_rxq_stop(struct il_priv *priv); +extern int il3945_hw_set_hw_params(struct il_priv *priv); +extern int il3945_hw_nic_init(struct il_priv *priv); +extern int il3945_hw_nic_stop_master(struct il_priv *priv); +extern void il3945_hw_txq_ctx_free(struct il_priv *priv); +extern void il3945_hw_txq_ctx_stop(struct il_priv *priv); +extern int il3945_hw_nic_reset(struct il_priv *priv); +extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -extern void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -extern int iwl3945_hw_get_temperature(struct iwl_priv *priv); -extern int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -extern unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl3945_frame *frame, u8 rate); -void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, +extern void il3945_hw_txq_free_tfd(struct il_priv *priv, + struct il_tx_queue *txq); +extern int il3945_hw_get_temperature(struct il_priv *priv); +extern int il3945_hw_tx_queue_init(struct il_priv *priv, + struct il_tx_queue *txq); +extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, + struct il3945_frame *frame, u8 rate); +void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, + struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id); -extern int iwl3945_hw_reg_send_txpower(struct iwl_priv *priv); -extern int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power); -extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl3945_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -extern void iwl3945_disable_events(struct iwl_priv *priv); -extern int iwl4965_get_temperature(const struct iwl_priv *priv); -extern void iwl3945_post_associate(struct iwl_priv *priv); -extern void iwl3945_config_ap(struct iwl_priv *priv); - -extern int iwl3945_commit_rxon(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +extern int il3945_hw_reg_send_txpower(struct il_priv *priv); +extern int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power); +extern void il3945_hw_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il3945_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +extern void il3945_disable_events(struct il_priv *priv); +extern int il4965_get_temperature(const struct il_priv *priv); +extern void il3945_post_associate(struct il_priv *priv); +extern void il3945_config_ap(struct il_priv *priv); + +extern int il3945_commit_rxon(struct il_priv *priv, + struct il_rxon_context *ctx); /** - * iwl3945_hw_find_station - Find station id for a given BSSID + * il3945_hw_find_station - Find station id for a given BSSID * @bssid: MAC address of station ID to find * * NOTE: This should not be hardware specific but the code has * not yet been merged into a single common layer for managing the * station tables. */ -extern u8 iwl3945_hw_find_station(struct iwl_priv *priv, const u8 *bssid); +extern u8 il3945_hw_find_station(struct il_priv *priv, const u8 *bssid); -extern struct ieee80211_ops iwl3945_hw_ops; +extern struct ieee80211_ops il3945_hw_ops; /* * Forward declare iwl-3945.c functions for iwl3945-base.c */ -extern __le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv); -extern int iwl3945_init_hw_rate_table(struct iwl_priv *priv); -extern void iwl3945_reg_txpower_periodic(struct iwl_priv *priv); -extern int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv); +extern __le32 il3945_get_antenna_flags(const struct il_priv *priv); +extern int il3945_init_hw_rate_table(struct il_priv *priv); +extern void il3945_reg_txpower_periodic(struct il_priv *priv); +extern int il3945_txpower_set_from_eeprom(struct il_priv *priv); -extern const struct iwl_channel_info *iwl3945_get_channel_info( - const struct iwl_priv *priv, enum ieee80211_band band, u16 channel); +extern const struct il_channel_info *il3945_get_channel_info( + const struct il_priv *priv, enum ieee80211_band band, u16 channel); -extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate); +extern int il3945_rs_next_rate(struct il_priv *priv, int rate); /* scanning */ -int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); -void iwl3945_post_scan(struct iwl_priv *priv); +int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); +void il3945_post_scan(struct il_priv *priv); /* rates */ -extern const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT_3945]; +extern const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945]; -/* Requires full declaration of iwl_priv before including */ +/* Requires full declaration of il_priv before including */ #include "iwl-io.h" #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 162d877..115eeb3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -80,11 +80,11 @@ struct statistics_general_data { u32 beacon_energy_c; }; -void iwl4965_calib_free_results(struct iwl_priv *priv) +void il4965_calib_free_results(struct il_priv *priv) { int i; - for (i = 0; i < IWL_CALIB_MAX; i++) { + for (i = 0; i < IL_CALIB_MAX; i++) { kfree(priv->calib_results[i].buf); priv->calib_results[i].buf = NULL; priv->calib_results[i].buf_len = 0; @@ -103,7 +103,7 @@ void iwl4965_calib_free_results(struct iwl_priv *priv) * enough to receive all of our own network traffic, but not so * high that our DSP gets too busy trying to lock onto non-network * activity/noise. */ -static int iwl4965_sens_energy_cck(struct iwl_priv *priv, +static int il4965_sens_energy_cck(struct il_priv *priv, u32 norm_fa, u32 rx_enable_time, struct statistics_general_data *rx_info) @@ -129,8 +129,8 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, u32 false_alarms = norm_fa * 200 * 1024; u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; - struct iwl_sensitivity_data *data = NULL; - const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; data = &(priv->sensitivity_data); @@ -160,7 +160,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - IWL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", + IL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, silence_rssi_b, silence_rssi_c, silence_ref); @@ -184,7 +184,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); max_nrg_cck += 6; - IWL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + IL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", rx_info->beacon_energy_a, rx_info->beacon_energy_b, rx_info->beacon_energy_c, max_nrg_cck - 6); @@ -194,16 +194,16 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, data->num_in_cck_no_fa++; else data->num_in_cck_no_fa = 0; - IWL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n", + IL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n", data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if ((false_alarms > max_false_alarms) && (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { - IWL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n", + IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n", false_alarms, max_false_alarms); - IWL_DEBUG_CALIB(priv, "... reducing sensitivity\n"); - data->nrg_curr_state = IWL_FA_TOO_MANY; + IL_DEBUG_CALIB(priv, "... reducing sensitivity\n"); + data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ data->nrg_silence_ref = silence_ref; @@ -212,14 +212,14 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; /* Else if we got fewer than desired, increase sensitivity */ } else if (false_alarms < min_false_alarms) { - data->nrg_curr_state = IWL_FA_TOO_FEW; + data->nrg_curr_state = IL_FA_TOO_FEW; /* Compare silence level with silence level for most recent * healthy number or too many false alarms */ data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - (s32)silence_ref; - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "norm FA %u < min FA %u, silence diff %d\n", false_alarms, min_false_alarms, data->nrg_auto_corr_silence_diff); @@ -230,23 +230,23 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, * from a previous beacon with too many, or healthy # FAs * OR 2) We've seen a lot of beacons (100) with too few * false alarms */ - if ((data->nrg_prev_state != IWL_FA_TOO_MANY) && + if ((data->nrg_prev_state != IL_FA_TOO_MANY) && ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { - IWL_DEBUG_CALIB(priv, "... increasing sensitivity\n"); + IL_DEBUG_CALIB(priv, "... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); } else { - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "... but not changing sensitivity\n"); } /* Else we got a healthy number of false alarms, keep status quo */ } else { - IWL_DEBUG_CALIB(priv, " FA in safe zone\n"); - data->nrg_curr_state = IWL_FA_GOOD_RANGE; + IL_DEBUG_CALIB(priv, " FA in safe zone\n"); + data->nrg_curr_state = IL_FA_GOOD_RANGE; /* Store for use in "fewer than desired" with later beacon */ data->nrg_silence_ref = silence_ref; @@ -254,8 +254,8 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, /* If previous beacon had too many false alarms, * give it some extra margin by reducing sensitivity again * (but don't go below measured energy of desired Rx) */ - if (IWL_FA_TOO_MANY == data->nrg_prev_state) { - IWL_DEBUG_CALIB(priv, "... increasing margin\n"); + if (IL_FA_TOO_MANY == data->nrg_prev_state) { + IL_DEBUG_CALIB(priv, "... increasing margin\n"); if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) data->nrg_th_cck -= NRG_MARGIN; else @@ -269,7 +269,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, * Lower value is higher energy, so we use max()! */ data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - IWL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); + IL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); data->nrg_prev_state = data->nrg_curr_state; @@ -306,7 +306,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, } -static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, +static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, u32 norm_fa, u32 rx_enable_time) { @@ -314,15 +314,15 @@ static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, u32 false_alarms = norm_fa * 200 * 1024; u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; - struct iwl_sensitivity_data *data = NULL; - const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; data = &(priv->sensitivity_data); /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - IWL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n", + IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n", false_alarms, max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; @@ -345,7 +345,7 @@ static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - IWL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n", + IL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n", false_alarms, min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; @@ -364,14 +364,14 @@ static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, data->auto_corr_ofdm_mrc_x1 = max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); } else { - IWL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n", + IL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n", min_false_alarms, false_alarms, max_false_alarms); } return 0; } -static void iwl4965_prepare_legacy_sensitivity_tbl(struct iwl_priv *priv, - struct iwl_sensitivity_data *data, +static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv, + struct il_sensitivity_data *data, __le16 *tbl) { tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX] = @@ -400,24 +400,24 @@ static void iwl4965_prepare_legacy_sensitivity_tbl(struct iwl_priv *priv, tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = cpu_to_le16(data->nrg_th_cca); - IWL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + IL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, data->nrg_th_ofdm); - IWL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", + IL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, data->auto_corr_cck_mrc, data->nrg_th_cck); } /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ -static int iwl4965_sensitivity_write(struct iwl_priv *priv) +static int il4965_sensitivity_write(struct il_priv *priv) { - struct iwl_sensitivity_cmd cmd; - struct iwl_sensitivity_data *data = NULL; - struct iwl_host_cmd cmd_out = { + struct il_sensitivity_cmd cmd; + struct il_sensitivity_data *data = NULL; + struct il_host_cmd cmd_out = { .id = SENSITIVITY_CMD, - .len = sizeof(struct iwl_sensitivity_cmd), + .len = sizeof(struct il_sensitivity_cmd), .flags = CMD_ASYNC, .data = &cmd, }; @@ -426,7 +426,7 @@ static int iwl4965_sensitivity_write(struct iwl_priv *priv) memset(&cmd, 0, sizeof(cmd)); - iwl4965_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]); + il4965_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; @@ -434,7 +434,7 @@ static int iwl4965_sensitivity_write(struct iwl_priv *priv) /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]), sizeof(u16)*HD_TABLE_SIZE)) { - IWL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n"); + IL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n"); return 0; } @@ -442,20 +442,20 @@ static int iwl4965_sensitivity_write(struct iwl_priv *priv) memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), sizeof(u16)*HD_TABLE_SIZE); - return iwl_legacy_send_cmd(priv, &cmd_out); + return il_send_cmd(priv, &cmd_out); } -void iwl4965_init_sensitivity(struct iwl_priv *priv) +void il4965_init_sensitivity(struct il_priv *priv) { int ret = 0; int i; - struct iwl_sensitivity_data *data = NULL; - const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; if (priv->disable_sens_cal) return; - IWL_DEBUG_CALIB(priv, "Start iwl4965_init_sensitivity\n"); + IL_DEBUG_CALIB(priv, "Start il4965_init_sensitivity\n"); /* Clear driver's sensitivity algo data */ data = &(priv->sensitivity_data); @@ -463,11 +463,11 @@ void iwl4965_init_sensitivity(struct iwl_priv *priv) if (ranges == NULL) return; - memset(data, 0, sizeof(struct iwl_sensitivity_data)); + memset(data, 0, sizeof(struct il_sensitivity_data)); data->num_in_cck_no_fa = 0; - data->nrg_curr_state = IWL_FA_TOO_MANY; - data->nrg_prev_state = IWL_FA_TOO_MANY; + data->nrg_curr_state = IL_FA_TOO_MANY; + data->nrg_prev_state = IL_FA_TOO_MANY; data->nrg_silence_ref = 0; data->nrg_silence_idx = 0; data->nrg_energy_idx = 0; @@ -495,11 +495,11 @@ void iwl4965_init_sensitivity(struct iwl_priv *priv) data->last_bad_plcp_cnt_cck = 0; data->last_fa_cnt_cck = 0; - ret |= iwl4965_sensitivity_write(priv); - IWL_DEBUG_CALIB(priv, "<sensitivity_data); - if (!iwl_legacy_is_any_associated(priv)) { - IWL_DEBUG_CALIB(priv, "<< - not associated\n"); + if (!il_is_any_associated(priv)) { + IL_DEBUG_CALIB(priv, "<< - not associated\n"); return; } spin_lock_irqsave(&priv->lock, flags); - rx_info = &(((struct iwl_notif_statistics *)resp)->rx.general); - ofdm = &(((struct iwl_notif_statistics *)resp)->rx.ofdm); - cck = &(((struct iwl_notif_statistics *)resp)->rx.cck); + rx_info = &(((struct il_notif_statistics *)resp)->rx.general); + ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm); + cck = &(((struct il_notif_statistics *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IWL_DEBUG_CALIB(priv, "<< invalid data.\n"); + IL_DEBUG_CALIB(priv, "<< invalid data.\n"); spin_unlock_irqrestore(&priv->lock, flags); return; } @@ -558,10 +558,10 @@ void iwl4965_sensitivity_calibration(struct iwl_priv *priv, void *resp) spin_unlock_irqrestore(&priv->lock, flags); - IWL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); + IL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); if (!rx_enable_time) { - IWL_DEBUG_CALIB(priv, "<< RX Enable Time == 0!\n"); + IL_DEBUG_CALIB(priv, "<< RX Enable Time == 0!\n"); return; } @@ -600,17 +600,17 @@ void iwl4965_sensitivity_calibration(struct iwl_priv *priv, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); - iwl4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); - iwl4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); + il4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); + il4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); - iwl4965_sensitivity_write(priv); + il4965_sensitivity_write(priv); } -static inline u8 iwl4965_find_first_chain(u8 mask) +static inline u8 il4965_find_first_chain(u8 mask) { if (mask & ANT_A) return CHAIN_A; @@ -624,8 +624,8 @@ static inline u8 iwl4965_find_first_chain(u8 mask) * disconnected. */ static void -iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, - struct iwl_chain_noise_data *data) +il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, + struct il_chain_noise_data *data) { u32 active_chains = 0; u32 max_average_sig; @@ -657,9 +657,9 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - IWL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], average_sig[2]); - IWL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n", + IL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n", max_average_sig, max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ @@ -673,7 +673,7 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, data->disconn_array[i] = 1; else active_chains |= (1 << i); - IWL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d " + IL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d " "disconn_array[i] = %d\n", i, rssi_delta, data->disconn_array[i]); } @@ -710,10 +710,10 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, * connect the first valid tx chain */ first_chain = - iwl4965_find_first_chain(priv->cfg->valid_tx_ant); + il4965_find_first_chain(priv->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "All Tx chains are disconnected W/A - declare %d as connected\n", first_chain); break; @@ -722,25 +722,25 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, if (active_chains != priv->hw_params.valid_rx_ant && active_chains != priv->chain_noise_data.active_chains) - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "Detected that not all antennas are connected! " "Connected: %#x, valid: %#x.\n", active_chains, priv->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - IWL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n", + IL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n", active_chains); } -static void iwl4965_gain_computation(struct iwl_priv *priv, +static void il4965_gain_computation(struct il_priv *priv, u32 *average_noise, u16 min_average_noise_antenna_i, u32 min_average_noise, u8 default_chain) { int i, ret; - struct iwl_chain_noise_data *data = &priv->chain_noise_data; + struct il_chain_noise_data *data = &priv->chain_noise_data; data->delta_gain_code[min_average_noise_antenna_i] = 0; @@ -762,32 +762,32 @@ static void iwl4965_gain_computation(struct iwl_priv *priv, data->delta_gain_code[i] = 0; } } - IWL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], data->delta_gain_code[1], data->delta_gain_code[2]); /* Differential gain gets sent to uCode only once */ if (!data->radio_write) { - struct iwl_calib_diff_gain_cmd cmd; + struct il_calib_diff_gain_cmd cmd; data->radio_write = 1; memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = iwl_legacy_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + ret = il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd); if (ret) - IWL_DEBUG_CALIB(priv, "fail sending cmd " + IL_DEBUG_CALIB(priv, "fail sending cmd " "REPLY_PHY_CALIBRATION_CMD\n"); /* TODO we might want recalculate * rx_chain in rxon cmd */ /* Mark so we run this algo only once! */ - data->state = IWL_CHAIN_NOISE_CALIBRATED; + data->state = IL_CHAIN_NOISE_CALIBRATED; } } @@ -799,9 +799,9 @@ static void iwl4965_gain_computation(struct iwl_priv *priv, * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. */ -void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) +void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) { - struct iwl_chain_noise_data *data = NULL; + struct il_chain_noise_data *data = NULL; u32 chain_noise_a; u32 chain_noise_b; @@ -821,7 +821,7 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) unsigned long flags; struct statistics_rx_non_phy *rx_info; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (priv->disable_chain_noise_cal) return; @@ -832,19 +832,19 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) * Accumulate just the first "chain_noise_num_beacons" after * the first association, then we're done forever. */ - if (data->state != IWL_CHAIN_NOISE_ACCUMULATE) { - if (data->state == IWL_CHAIN_NOISE_ALIVE) - IWL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); + if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { + if (data->state == IL_CHAIN_NOISE_ALIVE) + IL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); return; } spin_lock_irqsave(&priv->lock, flags); - rx_info = &(((struct iwl_notif_statistics *)stat_resp)-> + rx_info = &(((struct il_notif_statistics *)stat_resp)-> rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IWL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); + IL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); spin_unlock_irqrestore(&priv->lock, flags); return; } @@ -852,16 +852,16 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); rxon_chnum = le16_to_cpu(ctx->staging.channel); - stat_band24 = !!(((struct iwl_notif_statistics *) + stat_band24 = !!(((struct il_notif_statistics *) stat_resp)->flag & STATISTICS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct iwl_notif_statistics *) + stat_chnum = le32_to_cpu(((struct il_notif_statistics *) stat_resp)->flag) >> 16; /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { - IWL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", + IL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); spin_unlock_irqrestore(&priv->lock, flags); return; @@ -894,11 +894,11 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - IWL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n", + IL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, data->beacon_count); - IWL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, chain_sig_c); - IWL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: @@ -909,7 +909,7 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) return; /* Analyze signal for disconnected antenna */ - iwl4965_find_disconn_antenna(priv, average_sig, data); + il4965_find_disconn_antenna(priv, average_sig, data); /* Analyze noise for rx balance */ average_noise[0] = data->chain_noise_a / @@ -929,16 +929,16 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) } } - IWL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n", average_noise[0], average_noise[1], average_noise[2]); - IWL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", + IL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", min_average_noise, min_average_noise_antenna_i); - iwl4965_gain_computation(priv, average_noise, + il4965_gain_computation(priv, average_noise, min_average_noise_antenna_i, min_average_noise, - iwl4965_find_first_chain(priv->cfg->valid_rx_ant)); + il4965_find_first_chain(priv->cfg->valid_rx_ant)); /* Some power changes may have been made during the calibration. * Update and commit the RXON @@ -946,22 +946,22 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) if (priv->cfg->ops->lib->update_chain_flags) priv->cfg->ops->lib->update_chain_flags(priv); - data->state = IWL_CHAIN_NOISE_DONE; - iwl_legacy_power_update_mode(priv, false); + data->state = IL_CHAIN_NOISE_DONE; + il_power_update_mode(priv, false); } -void iwl4965_reset_run_time_calib(struct iwl_priv *priv) +void il4965_reset_run_time_calib(struct il_priv *priv) { int i; memset(&(priv->sensitivity_data), 0, - sizeof(struct iwl_sensitivity_data)); + sizeof(struct il_sensitivity_data)); memset(&(priv->chain_noise_data), 0, - sizeof(struct iwl_chain_noise_data)); + sizeof(struct il_chain_noise_data)); for (i = 0; i < NUM_RX_CHAINS; i++) priv->chain_noise_data.delta_gain_code[i] = CHAIN_NOISE_DELTA_GAIN_INIT_VAL; /* Ask for statistics now, the uCode will send notification * periodically after association */ - iwl_legacy_send_statistics_request(priv, CMD_ASYNC, true); + il_send_statistics_request(priv, CMD_ASYNC, true); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h index f46c80e..a23081f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h @@ -59,17 +59,17 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_4965_calib_h__ -#define __iwl_4965_calib_h__ +#ifndef __il_4965_calib_h__ +#define __il_4965_calib_h__ #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-commands.h" -void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp); -void iwl4965_sensitivity_calibration(struct iwl_priv *priv, void *resp); -void iwl4965_init_sensitivity(struct iwl_priv *priv); -void iwl4965_reset_run_time_calib(struct iwl_priv *priv); -void iwl4965_calib_free_results(struct iwl_priv *priv); +void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp); +void il4965_sensitivity_calibration(struct il_priv *priv, void *resp); +void il4965_init_sensitivity(struct il_priv *priv); +void il4965_reset_run_time_calib(struct il_priv *priv); +void il4965_calib_free_results(struct il_priv *priv); -#endif /* __iwl_4965_calib_h__ */ +#endif /* __il_4965_calib_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index 1c93665..3c2876f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -33,7 +33,7 @@ static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = "%-32s current cumulative delta max\n"; -static int iwl4965_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) +static int il4965_statistics_flag(struct il_priv *priv, char *buf, int bufsz) { int p = 0; u32 flag; @@ -54,10 +54,10 @@ static int iwl4965_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) return p; } -ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_rx_phy) * 40 + @@ -70,12 +70,12 @@ ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, struct statistics_rx_non_phy *delta_general, *max_general; struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -101,7 +101,7 @@ ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, max_general = &priv->_4965.max_delta.rx.general; max_ht = &priv->_4965.max_delta.rx.ofdm_ht; - pos += iwl4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Rx - OFDM:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -485,23 +485,23 @@ ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, return ret; } -ssize_t iwl4965_ucode_tx_stats_read(struct file *file, +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct statistics_tx) * 48) + 250; ssize_t ret; struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -514,7 +514,7 @@ ssize_t iwl4965_ucode_tx_stats_read(struct file *file, delta_tx = &priv->_4965.delta_statistics.tx; max_tx = &priv->_4965.max_delta.tx; - pos += iwl4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -661,10 +661,10 @@ ssize_t iwl4965_ucode_tx_stats_read(struct file *file, } ssize_t -iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_general) * 10 + 300; @@ -674,12 +674,12 @@ iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct statistics_div *div, *accum_div, *delta_div, *max_div; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -700,7 +700,7 @@ iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, delta_div = &priv->_4965.delta_statistics.general.common.div; max_div = &priv->_4965.max_delta.general.common.div; - pos += iwl4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_General:"); pos += scnprintf(buf + pos, bufsz - pos, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h index 6c8e353..ca1cf58 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h @@ -31,27 +31,27 @@ #include "iwl-debug.h" #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl4965_ucode_general_stats_read(struct file *file, +ssize_t il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); #else static ssize_t -iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } static ssize_t -iwl4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } static ssize_t -iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index cb9baab..e657b44 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -87,23 +87,23 @@ * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ -int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv) +int il4965_eeprom_acquire_semaphore(struct il_priv *priv) { u16 count; int ret; for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); if (ret >= 0) { - IWL_DEBUG_IO(priv, + IL_DEBUG_IO(priv, "Acquired semaphore after %d tries.\n", count+1); return ret; @@ -113,32 +113,32 @@ int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv) return ret; } -void iwl4965_eeprom_release_semaphore(struct iwl_priv *priv) +void il4965_eeprom_release_semaphore(struct il_priv *priv) { - iwl_legacy_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } -int iwl4965_eeprom_check_version(struct iwl_priv *priv) +int il4965_eeprom_check_version(struct il_priv *priv) { u16 eeprom_ver; u16 calib_ver; - eeprom_ver = iwl_legacy_eeprom_query16(priv, EEPROM_VERSION); - calib_ver = iwl_legacy_eeprom_query16(priv, + eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); + calib_ver = il_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET); if (eeprom_ver < priv->cfg->eeprom_ver || calib_ver < priv->cfg->eeprom_calib_ver) goto err; - IWL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", + IL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: - IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " + IL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " "CALIB=0x%x < 0x%x\n", eeprom_ver, priv->cfg->eeprom_ver, calib_ver, priv->cfg->eeprom_calib_ver); @@ -146,9 +146,9 @@ err: } -void iwl4965_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) +void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac) { - const u8 *addr = iwl_legacy_eeprom_query_addr(priv, + const u8 *addr = il_eeprom_query_addr(priv, EEPROM_MAC_ADDRESS); memcpy(mac, addr, ETH_ALEN); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index fc6fa28..b6b7fe2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -66,8 +66,8 @@ * Use iwl-dev.h for driver implementation definitions. */ -#ifndef __iwl_4965_hw_h__ -#define __iwl_4965_hw_h__ +#ifndef __il_4965_hw_h__ +#define __il_4965_hw_h__ #include "iwl-fh.h" @@ -100,7 +100,7 @@ /* Size of uCode instruction memory in bootstrap state machine */ #define IWL49_MAX_BSM_SIZE BSM_SRAM_SIZE -static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) +static inline int il4965_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IWL49_RTC_DATA_LOWER_BOUND) && (addr < IWL49_RTC_DATA_UPPER_BOUND); @@ -118,7 +118,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * real-time temperature indicator. * * uCode provides all 4 values to the driver via the "initialize alive" - * notification (see struct iwl4965_init_alive_resp). After the runtime uCode + * notification (see struct il4965_init_alive_resp). After the runtime uCode * image loads, uCode updates the R4 value via statistics notifications * (see STATISTICS_NOTIFICATION), which occur after each received beacon * when associated, or can be requested via REPLY_STATISTICS_CMD. @@ -143,12 +143,12 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) #define TEMPERATURE_CALIB_A_VAL 259 /* Limit range of calculated temperature to be between these Kelvin values */ -#define IWL_TX_POWER_TEMPERATURE_MIN (263) -#define IWL_TX_POWER_TEMPERATURE_MAX (410) +#define IL_TX_POWER_TEMPERATURE_MIN (263) +#define IL_TX_POWER_TEMPERATURE_MAX (410) -#define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ - (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \ - ((t) > IWL_TX_POWER_TEMPERATURE_MAX)) +#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ + (((t) < IL_TX_POWER_TEMPERATURE_MIN) || \ + ((t) > IL_TX_POWER_TEMPERATURE_MAX)) /********************* END TEMPERATURE ***************************************/ @@ -168,7 +168,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz * (legacy) channels. * - * See struct iwl4965_eeprom_channel for format, and struct iwl4965_eeprom + * See struct il4965_eeprom_channel for format, and struct il4965_eeprom * for locations in EEPROM. * * 2) Factory txpower calibration information is provided separately for @@ -177,11 +177,11 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. * - * See struct iwl4965_eeprom_calib_info (and the tree of structures - * contained within it) for format, and struct iwl4965_eeprom for + * See struct il4965_eeprom_calib_info (and the tree of structures + * contained within it) for format, and struct il4965_eeprom for * locations in EEPROM. * - * "Initialization alive" notification (see struct iwl4965_init_alive_resp) + * "Initialization alive" notification (see struct il4965_init_alive_resp) * consists of: * * 1) Temperature calculation parameters. @@ -238,7 +238,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * 3) Determine (EEPROM) calibration sub band for the target channel, by * comparing against first and last channels in each sub band - * (see struct iwl4965_eeprom_calib_subband_info). + * (see struct il4965_eeprom_calib_subband_info). * * * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, @@ -254,7 +254,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * span of the sampled channels. * * Driver may choose the pair (for 2 Tx chains) of measurements (see - * struct iwl4965_eeprom_calib_ch_info) for which the actual measured + * struct il4965_eeprom_calib_ch_info) for which the actual measured * txpower comes closest to the desired txpower. Usually, though, * the middle set of measurements is closest to the regulatory limits, * and is therefore a good choice for all txpower calculations (this @@ -370,7 +370,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * * 11) Read gain table entries for DSP and radio gain, place into appropriate - * location(s) in command (struct iwl4965_txpowertable_cmd). + * location(s) in command (struct il4965_txpowertable_cmd). */ /** @@ -382,7 +382,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * The value "6" represents number of steps in gain table to reduce power 3 dB. * Each step is 1/2 dB. */ -#define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) +#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) /** * CCK gain compensation. @@ -394,13 +394,13 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, * bits [3:2], 1 = B, 2 = C. */ -#define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9) -#define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5) +#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9) +#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5) /* * 4965 power supply voltage compensation for txpower */ -#define TX_POWER_IWL_VOLTAGE_CODES_PER_03V (7) +#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7) /** * Gain tables. @@ -668,10 +668,10 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * Units are in half-dBm (i.e. "34" means 17 dBm). */ -#define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34) -#define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34) -#define IWL_TX_POWER_REGULATORY_MIN (0) -#define IWL_TX_POWER_REGULATORY_MAX (34) +#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34) +#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34) +#define IL_TX_POWER_REGULATORY_MIN (0) +#define IL_TX_POWER_REGULATORY_MAX (34) /** * Sanity checks and default values for EEPROM saturation levels. @@ -689,10 +689,10 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * Units are in half-dBm (i.e. "38" means 19 dBm). */ -#define IWL_TX_POWER_DEFAULT_SATURATION_24 (38) -#define IWL_TX_POWER_DEFAULT_SATURATION_52 (38) -#define IWL_TX_POWER_SATURATION_MIN (20) -#define IWL_TX_POWER_SATURATION_MAX (50) +#define IL_TX_POWER_DEFAULT_SATURATION_24 (38) +#define IL_TX_POWER_DEFAULT_SATURATION_52 (38) +#define IL_TX_POWER_SATURATION_MIN (20) +#define IL_TX_POWER_SATURATION_MAX (50) /** * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) @@ -709,24 +709,24 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * Different frequency ranges require different compensation, as shown below. */ /* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR1_FCH 34 -#define CALIB_IWL_TX_ATTEN_GR1_LCH 43 +#define CALIB_IL_TX_ATTEN_GR1_FCH 34 +#define CALIB_IL_TX_ATTEN_GR1_LCH 43 /* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR2_FCH 44 -#define CALIB_IWL_TX_ATTEN_GR2_LCH 70 +#define CALIB_IL_TX_ATTEN_GR2_FCH 44 +#define CALIB_IL_TX_ATTEN_GR2_LCH 70 /* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR3_FCH 71 -#define CALIB_IWL_TX_ATTEN_GR3_LCH 124 +#define CALIB_IL_TX_ATTEN_GR3_FCH 71 +#define CALIB_IL_TX_ATTEN_GR3_LCH 124 /* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR4_FCH 125 -#define CALIB_IWL_TX_ATTEN_GR4_LCH 200 +#define CALIB_IL_TX_ATTEN_GR4_FCH 125 +#define CALIB_IL_TX_ATTEN_GR4_LCH 200 /* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR5_FCH 1 -#define CALIB_IWL_TX_ATTEN_GR5_LCH 20 +#define CALIB_IL_TX_ATTEN_GR5_FCH 1 +#define CALIB_IL_TX_ATTEN_GR5_LCH 20 enum { CALIB_CH_GROUP_1 = 0, @@ -767,7 +767,7 @@ enum { /** - * struct iwl4965_schedq_bc_tbl + * struct il4965_schedq_bc_tbl * * Byte Count table * @@ -784,7 +784,7 @@ enum { * padding puts each byte count table on a 1024-byte boundary; * 4965 assumes tables are separated by 1024 bytes. */ -struct iwl4965_scd_bc_tbl { +struct il4965_scd_bc_tbl { __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; } __packed; @@ -808,4 +808,4 @@ struct iwl4965_scd_bc_tbl { #define IWL4965_FIRST_AMPDU_QUEUE 10 -#endif /* !__iwl_4965_hw_h__ */ +#endif /* !__il_4965_hw_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c index 6862fdc..d2c8eac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.c @@ -44,30 +44,30 @@ /* Send led command */ static int -iwl4965_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd) +il4965_send_led_cmd(struct il_priv *priv, struct il_led_cmd *led_cmd) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_LEDS_CMD, - .len = sizeof(struct iwl_led_cmd), + .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, .callback = NULL, }; u32 reg; - reg = iwl_read32(priv, CSR_LED_REG); + reg = il_read32(priv, CSR_LED_REG); if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + il_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); - return iwl_legacy_send_cmd(priv, &cmd); + return il_send_cmd(priv, &cmd); } /* Set led register off */ -void iwl4965_led_enable(struct iwl_priv *priv) +void il4965_led_enable(struct il_priv *priv) { - iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); + il_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } -const struct iwl_led_ops iwl4965_led_ops = { - .cmd = iwl4965_send_led_cmd, +const struct il_led_ops il4965_led_ops = { + .cmd = il4965_send_led_cmd, }; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.h b/drivers/net/wireless/iwlegacy/iwl-4965-led.h index 5ed3615..ab03dff 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.h @@ -24,10 +24,10 @@ * *****************************************************************************/ -#ifndef __iwl_4965_led_h__ -#define __iwl_4965_led_h__ +#ifndef __il_4965_led_h__ +#define __il_4965_led_h__ -extern const struct iwl_led_ops iwl4965_led_ops; -void iwl4965_led_enable(struct iwl_priv *priv); +extern const struct il_led_ops il4965_led_ops; +void il4965_led_enable(struct il_priv *priv); -#endif /* __iwl_4965_led_h__ */ +#endif /* __il_4965_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 2be6d9e..25f1d47 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -40,11 +40,11 @@ #include "iwl-4965.h" #include "iwl-sta.h" -void iwl4965_check_abort_status(struct iwl_priv *priv, +void il4965_check_abort_status(struct il_priv *priv, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IWL_ERR(priv, "Tx flush command to flush out all frames\n"); + IL_ERR(priv, "Tx flush command to flush out all frames\n"); if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) queue_work(priv->workqueue, &priv->tx_flush); } @@ -53,13 +53,13 @@ void iwl4965_check_abort_status(struct iwl_priv *priv, /* * EEPROM */ -struct iwl_mod_params iwl4965_mod_params = { +struct il_mod_params il4965_mod_params = { .amsdu_size_8K = 1, .restart_fw = 1, /* the rest are 0 by default */ }; -void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -74,7 +74,7 @@ void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -91,7 +91,7 @@ void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) { u32 rb_size; const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ @@ -103,17 +103,17 @@ int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - iwl_legacy_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write index */ - iwl_legacy_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - iwl_legacy_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - iwl_legacy_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -122,7 +122,7 @@ int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - iwl_legacy_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, + il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | @@ -131,32 +131,32 @@ int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ - iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); + il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); return 0; } -static void iwl4965_set_pwr_vmain(struct iwl_priv *priv) +static void il4965_set_pwr_vmain(struct il_priv *priv) { /* * (for documentation purposes) * to set power to V_AUX, do: if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); */ - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); } -int iwl4965_hw_nic_init(struct iwl_priv *priv) +int il4965_hw_nic_init(struct il_priv *priv) { unsigned long flags; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; int ret; /* nic_init */ @@ -164,42 +164,42 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) priv->cfg->ops->lib->apm_ops.init(priv); /* Set interrupt coalescing calibration timer to default (512 usecs) */ - iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); + il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); spin_unlock_irqrestore(&priv->lock, flags); - iwl4965_set_pwr_vmain(priv); + il4965_set_pwr_vmain(priv); priv->cfg->ops->lib->apm_ops.config(priv); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - ret = iwl_legacy_rx_queue_alloc(priv); + ret = il_rx_queue_alloc(priv); if (ret) { - IWL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(priv, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - iwl4965_rx_queue_reset(priv, rxq); + il4965_rx_queue_reset(priv, rxq); - iwl4965_rx_replenish(priv); + il4965_rx_replenish(priv); - iwl4965_rx_init(priv, rxq); + il4965_rx_init(priv, rxq); spin_lock_irqsave(&priv->lock, flags); rxq->need_update = 1; - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); spin_unlock_irqrestore(&priv->lock, flags); /* Allocate or reset and init all Tx and Command queues */ if (!priv->txq) { - ret = iwl4965_txq_ctx_alloc(priv); + ret = il4965_txq_ctx_alloc(priv); if (ret) return ret; } else - iwl4965_txq_ctx_reset(priv); + il4965_txq_ctx_reset(priv); set_bit(STATUS_INIT, &priv->status); @@ -207,16 +207,16 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) } /** - * iwl4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl_priv *priv, +static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *priv, dma_addr_t dma_addr) { return cpu_to_le32((u32)(dma_addr >> 8)); } /** - * iwl4965_rx_queue_restock - refill RX queue from pre-allocated pool + * il4965_rx_queue_restock - refill RX queue from pre-allocated pool * * If there are slots in the RX queue that need to be restocked, * and we have free pre-allocated buffers, fill the ranks as much @@ -226,26 +226,26 @@ static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -void iwl4965_rx_queue_restock(struct iwl_priv *priv) +void il4965_rx_queue_restock(struct il_priv *priv) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; unsigned long flags; spin_lock_irqsave(&rxq->lock, flags); - while ((iwl_legacy_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { /* The overwritten rxb must be a used one */ rxb = rxq->queue[rxq->write]; BUG_ON(rxb && rxb->page); /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = iwl4965_dma_addr2rbd_ptr(priv, + rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(priv, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; @@ -264,23 +264,23 @@ void iwl4965_rx_queue_restock(struct iwl_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); } } /** - * iwl4965_rx_replenish - Move all used packet from rx_used to rx_free + * il4965_rx_replenish - Move all used packet from rx_used to rx_free * * When moving to rx_free an SKB is allocated for the slot. * - * Also restock the Rx queue via iwl_rx_queue_restock. + * Also restock the Rx queue via il_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) +static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -303,13 +303,13 @@ static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IWL_DEBUG_INFO(priv, "alloc_pages failed, " + IL_DEBUG_INFO(priv, "alloc_pages failed, " "order: %d\n", priv->hw_params.rx_page_order); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IWL_CRIT(priv, + IL_CRIT(priv, "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? @@ -329,7 +329,7 @@ static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -355,22 +355,22 @@ static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) } } -void iwl4965_rx_replenish(struct iwl_priv *priv) +void il4965_rx_replenish(struct il_priv *priv) { unsigned long flags; - iwl4965_rx_allocate(priv, GFP_KERNEL); + il4965_rx_allocate(priv, GFP_KERNEL); spin_lock_irqsave(&priv->lock, flags); - iwl4965_rx_queue_restock(priv); + il4965_rx_queue_restock(priv); spin_unlock_irqrestore(&priv->lock, flags); } -void iwl4965_rx_replenish_now(struct iwl_priv *priv) +void il4965_rx_replenish_now(struct il_priv *priv) { - iwl4965_rx_allocate(priv, GFP_ATOMIC); + il4965_rx_allocate(priv, GFP_ATOMIC); - iwl4965_rx_queue_restock(priv); + il4965_rx_queue_restock(priv); } /* Assumes that the skb field of the buffers in 'pool' is kept accurate. @@ -378,7 +378,7 @@ void iwl4965_rx_replenish_now(struct iwl_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { @@ -386,31 +386,31 @@ void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } } dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status), + dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; } -int iwl4965_rxq_stop(struct iwl_priv *priv) +int il4965_rxq_stop(struct il_priv *priv) { /* stop Rx DMA */ - iwl_legacy_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, + il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; } -int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) { int idx = 0; int band_offset = 0; @@ -422,8 +422,8 @@ int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) /* Legacy rate format, search for match in table */ } else { if (band == IEEE80211_BAND_5GHZ) - band_offset = IWL_FIRST_OFDM_RATE; - for (idx = band_offset; idx < IWL_RATE_COUNT_LEGACY; idx++) + band_offset = IL_FIRST_OFDM_RATE; + for (idx = band_offset; idx < IL_RATE_COUNT_LEGACY; idx++) if (iwlegacy_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx - band_offset; } @@ -431,13 +431,13 @@ int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) return -1; } -static int iwl4965_calc_rssi(struct iwl_priv *priv, - struct iwl_rx_phy_res *rx_resp) +static int il4965_calc_rssi(struct il_priv *priv, + struct il_rx_phy_res *rx_resp) { /* data from PHY/DSP regarding signal strength, etc., * contents are always there, not configurable by host. */ - struct iwl4965_rx_non_cfg_phy *ncphy = - (struct iwl4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; + struct il4965_rx_non_cfg_phy *ncphy = + (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; u32 agc = (le16_to_cpu(ncphy->agc_info) & IWL49_AGC_DB_MASK) >> IWL49_AGC_DB_POS; @@ -456,7 +456,7 @@ static int iwl4965_calc_rssi(struct iwl_priv *priv, if (valid_antennae & (1 << i)) max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", + IL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], max_rssi, agc); @@ -466,7 +466,7 @@ static int iwl4965_calc_rssi(struct iwl_priv *priv, } -static u32 iwl4965_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in) +static u32 il4965_translate_rx_status(struct il_priv *priv, u32 decrypt_in) { u32 decrypt_out = 0; @@ -519,17 +519,17 @@ static u32 iwl4965_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in) break; } - IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n", + IL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; } -static void iwl4965_pass_packet_to_mac80211(struct iwl_priv *priv, +static void il4965_pass_packet_to_mac80211(struct il_priv *priv, struct ieee80211_hdr *hdr, u16 len, u32 ampdu_status, - struct iwl_rx_mem_buffer *rxb, + struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { struct sk_buff *skb; @@ -537,25 +537,25 @@ static void iwl4965_pass_packet_to_mac80211(struct iwl_priv *priv, /* We only process data packets if the interface is open */ if (unlikely(!priv->is_open)) { - IWL_DEBUG_DROP_LIMIT(priv, + IL_DEBUG_DROP_LIMIT(priv, "Dropping packet while interface is not open.\n"); return; } /* In case of HW accelerated crypto and bad decryption, drop */ if (!priv->cfg->mod_params->sw_crypto && - iwl_legacy_set_decrypted_flag(priv, hdr, ampdu_status, stats)) + il_set_decrypted_flag(priv, hdr, ampdu_status, stats)) return; skb = dev_alloc_skb(128); if (!skb) { - IWL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(priv, "dev_alloc_skb failed\n"); return; } skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); - iwl_legacy_update_stats(priv, false, fc, len); + il_update_stats(priv, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); ieee80211_rx(priv->hw, skb); @@ -565,15 +565,15 @@ static void iwl4965_pass_packet_to_mac80211(struct iwl_priv *priv, /* Called for REPLY_RX (legacy ABG frames), or * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ -void iwl4965_rx_reply_rx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_reply_rx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_rx_phy_res *phy_res; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_phy_res *phy_res; __le32 rx_pkt_status; - struct iwl_rx_mpdu_res_start *amsdu; + struct il_rx_mpdu_res_start *amsdu; u32 len; u32 ampdu_status; u32 rate_n_flags; @@ -588,7 +588,7 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, * received. */ if (pkt->hdr.cmd == REPLY_RX) { - phy_res = (struct iwl_rx_phy_res *)pkt->u.raw; + phy_res = (struct il_rx_phy_res *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + phy_res->cfg_phy_cnt); @@ -598,27 +598,27 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, ampdu_status = le32_to_cpu(rx_pkt_status); } else { if (!priv->_4965.last_phy_res_valid) { - IWL_ERR(priv, "MPDU frame without cached PHY data\n"); + IL_ERR(priv, "MPDU frame without cached PHY data\n"); return; } phy_res = &priv->_4965.last_phy_res; - amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw; + amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); len = le16_to_cpu(amsdu->byte_count); rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = iwl4965_translate_rx_status(priv, + ampdu_status = il4965_translate_rx_status(priv, le32_to_cpu(rx_pkt_status)); } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", + IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -634,7 +634,7 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), rx_status.band); rx_status.rate_idx = - iwl4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); + il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); rx_status.flag = 0; /* TSF isn't reliable. In order to allow smooth user experience, @@ -644,10 +644,10 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); /* Find max signal strength (dBm) among 3 antenna/receiver chains */ - rx_status.signal = iwl4965_calc_rssi(priv, phy_res); + rx_status.signal = il4965_calc_rssi(priv, phy_res); - iwl_legacy_dbg_log_rx_data_frame(priv, len, header); - IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", + il_dbg_log_rx_data_frame(priv, len, header); + IL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* @@ -679,41 +679,41 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, if (rate_n_flags & RATE_MCS_SGI_MSK) rx_status.flag |= RX_FLAG_SHORT_GI; - iwl4965_pass_packet_to_mac80211(priv, header, len, ampdu_status, + il4965_pass_packet_to_mac80211(priv, header, len, ampdu_status, rxb, &rx_status); } /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). - * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ -void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) + * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ +void il4965_rx_reply_rx_phy(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); priv->_4965.last_phy_res_valid = true; memcpy(&priv->_4965.last_phy_res, pkt->u.raw, - sizeof(struct iwl_rx_phy_res)); + sizeof(struct il_rx_phy_res)); } -static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, +static int il4965_get_channels_for_scan(struct il_priv *priv, struct ieee80211_vif *vif, enum ieee80211_band band, u8 is_active, u8 n_probes, - struct iwl_scan_channel *scan_ch) + struct il_scan_channel *scan_ch) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; u16 passive_dwell = 0; u16 active_dwell = 0; int added, i; u16 channel; - sband = iwl_get_hw_mode(priv, band); + sband = il_get_hw_mode(priv, band); if (!sband) return 0; - active_dwell = iwl_legacy_get_active_dwell_time(priv, band, n_probes); - passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(priv, band, n_probes); + passive_dwell = il_get_passive_dwell_time(priv, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; @@ -727,22 +727,22 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, channel = chan->hw_value; scan_ch->channel = cpu_to_le16(channel); - ch_info = iwl_legacy_get_channel_info(priv, band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_SCAN(priv, + ch_info = il_get_channel_info(priv, band, channel); + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n", channel); continue; } - if (!is_active || iwl_legacy_is_channel_passive(ch_info) || + if (!is_active || il_is_channel_passive(ch_info) || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; else scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; if (n_probes) - scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes); + scan_ch->type |= IL_SCAN_PROBE_MASK(n_probes); scan_ch->active_dwell = cpu_to_le16(active_dwell); scan_ch->passive_dwell = cpu_to_le16(passive_dwell); @@ -759,7 +759,7 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - IWL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n", + IL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n", channel, le32_to_cpu(scan_ch->type), (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", @@ -770,19 +770,19 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, added++; } - IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); return added; } -int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) +int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, - .len = sizeof(struct iwl_scan_cmd), + .len = sizeof(struct il_scan_cmd), .flags = CMD_SIZE_HUGE, }; - struct iwl_scan_cmd *scan; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_scan_cmd *scan; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; u32 rate_flags = 0; u16 cmd_len; u16 rx_chain = 0; @@ -799,30 +799,30 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) lockdep_assert_held(&priv->mutex); if (vif) - ctx = iwl_legacy_rxon_ctx_from_vif(vif); + ctx = il_rxon_ctx_from_vif(vif); if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) + - IWL_MAX_SCAN_SIZE, GFP_KERNEL); + priv->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!priv->scan_cmd) { - IWL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(priv, "fail to allocate memory for scan\n"); return -ENOMEM; } } scan = priv->scan_cmd; - memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE); + memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); - scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; - scan->quiet_time = IWL_ACTIVE_QUIET_TIME; + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (iwl_legacy_is_any_associated(priv)) { + if (il_is_any_associated(priv)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(priv, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; @@ -834,13 +834,13 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan_suspend_time = (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (priv->scan_request->n_ssids) { int i, p = 0; - IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); + IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); for (i = 0; i < priv->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!priv->scan_request->ssids[i].ssid_len) @@ -856,7 +856,7 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) } is_active = true; } else - IWL_DEBUG_SCAN(priv, "Start passive scan.\n"); + IL_DEBUG_SCAN(priv, "Start passive scan.\n"); scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; scan->tx_cmd.sta_id = ctx->bcast_sta_id; @@ -866,21 +866,21 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; chan_mod = le32_to_cpu( - priv->contexts[IWL_RXON_CTX_BSS].active.flags & + priv->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { - rate = IWL_RATE_6M_PLCP; + rate = IL_RATE_6M_PLCP; } else { - rate = IWL_RATE_1M_PLCP; + rate = IL_RATE_1M_PLCP; rate_flags = RATE_MCS_CCK_MSK; } break; case IEEE80211_BAND_5GHZ: - rate = IWL_RATE_6M_PLCP; + rate = IL_RATE_6M_PLCP; break; default: - IWL_WARN(priv, "Invalid scan band\n"); + IL_WARN(priv, "Invalid scan band\n"); return -EIO; } @@ -898,22 +898,22 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) * need to receive during our dwell time on a channel before * sending out probes -- setting this to a huge value will * mean we never reach it, but at the same time work around - * the aforementioned issue. Thus use IWL_GOOD_CRC_TH_NEVER - * here instead of IWL_GOOD_CRC_TH_DISABLED. + * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER + * here instead of IL_GOOD_CRC_TH_DISABLED. */ - scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT : - IWL_GOOD_CRC_TH_NEVER; + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_NEVER; band = priv->scan_band; if (priv->cfg->scan_rx_antennas[band]) rx_ant = priv->cfg->scan_rx_antennas[band]; - priv->scan_tx_ant[band] = iwl4965_toggle_tx_ant(priv, + priv->scan_tx_ant[band] = il4965_toggle_tx_ant(priv, priv->scan_tx_ant[band], scan_tx_antennas); - rate_flags |= iwl4965_ant_idx_to_flags(priv->scan_tx_ant[band]); - scan->tx_cmd.rate_n_flags = iwl4965_hw_set_rate_n_flags(rate, rate_flags); + rate_flags |= il4965_ant_idx_to_flags(priv->scan_tx_ant[band]); + scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ if (test_bit(STATUS_POWER_PMI, &priv->status)) { @@ -923,10 +923,10 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) if (!active_chains) active_chains = rx_ant; - IWL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n", + IL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n", priv->chain_noise_data.active_chains); - rx_ant = iwl4965_first_antenna(active_chains); + rx_ant = il4965_first_antenna(active_chains); } /* MIMO is not used here, but value is required */ @@ -936,53 +936,53 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; scan->rx_chain = cpu_to_le16(rx_chain); - cmd_len = iwl_legacy_fill_probe_req(priv, + cmd_len = il_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, vif->addr, priv->scan_request->ie, priv->scan_request->ie_len, - IWL_MAX_SCAN_SIZE - sizeof(*scan)); + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(cmd_len); scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | RXON_FILTER_BCON_AWARE_MSK); - scan->channel_count = iwl4965_get_channels_for_scan(priv, vif, band, + scan->channel_count = il4965_get_channels_for_scan(priv, vif, band, is_active, n_probes, (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { - IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); return -EIO; } cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct iwl_scan_channel); + scan->channel_count * sizeof(struct il_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); set_bit(STATUS_SCAN_HW, &priv->status); - ret = iwl_legacy_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(priv, &cmd); if (ret) clear_bit(STATUS_SCAN_HW, &priv->status); return ret; } -int iwl4965_manage_ibss_station(struct iwl_priv *priv, +int il4965_manage_ibss_station(struct il_priv *priv, struct ieee80211_vif *vif, bool add) { - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; if (add) - return iwl4965_add_bssid_station(priv, vif_priv->ctx, + return il4965_add_bssid_station(priv, vif_priv->ctx, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); - return iwl_legacy_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } -void iwl4965_free_tfds_in_queue(struct iwl_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *priv, int sta_id, int tid, int freed) { lockdep_assert_held(&priv->sta_lock); @@ -990,25 +990,25 @@ void iwl4965_free_tfds_in_queue(struct iwl_priv *priv, if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed) priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { - IWL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n", + IL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n", priv->stations[sta_id].tid[tid].tfds_in_queue, freed); priv->stations[sta_id].tid[tid].tfds_in_queue = 0; } } -#define IWL_TX_QUEUE_MSK 0xfffff +#define IL_TX_QUEUE_MSK 0xfffff -static bool iwl4965_is_single_rx_stream(struct iwl_priv *priv) +static bool il4965_is_single_rx_stream(struct il_priv *priv) { return priv->current_ht_config.smps == IEEE80211_SMPS_STATIC || priv->current_ht_config.single_chain_sufficient; } -#define IWL_NUM_RX_CHAINS_MULTIPLE 3 -#define IWL_NUM_RX_CHAINS_SINGLE 2 -#define IWL_NUM_IDLE_CHAINS_DUAL 2 -#define IWL_NUM_IDLE_CHAINS_SINGLE 1 +#define IL_NUM_RX_CHAINS_MULTIPLE 3 +#define IL_NUM_RX_CHAINS_SINGLE 2 +#define IL_NUM_IDLE_CHAINS_DUAL 2 +#define IL_NUM_IDLE_CHAINS_SINGLE 1 /* * Determine how many receiver/antenna chains to use. @@ -1020,13 +1020,13 @@ static bool iwl4965_is_single_rx_stream(struct iwl_priv *priv) * MIMO (dual stream) requires at least 2, but works better with 3. * This does not determine *which* chains to use, just how many. */ -static int iwl4965_get_active_rx_chain_count(struct iwl_priv *priv) +static int il4965_get_active_rx_chain_count(struct il_priv *priv) { /* # of Rx chains to use when expecting MIMO. */ - if (iwl4965_is_single_rx_stream(priv)) - return IWL_NUM_RX_CHAINS_SINGLE; + if (il4965_is_single_rx_stream(priv)) + return IL_NUM_RX_CHAINS_SINGLE; else - return IWL_NUM_RX_CHAINS_MULTIPLE; + return IL_NUM_RX_CHAINS_MULTIPLE; } /* @@ -1034,13 +1034,13 @@ static int iwl4965_get_active_rx_chain_count(struct iwl_priv *priv) * multiplexing power save, use the active count for rx chain count. */ static int -iwl4965_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) +il4965_get_idle_rx_chain_count(struct il_priv *priv, int active_cnt) { /* # Rx chains when idling, depending on SMPS mode */ switch (priv->current_ht_config.smps) { case IEEE80211_SMPS_STATIC: case IEEE80211_SMPS_DYNAMIC: - return IWL_NUM_IDLE_CHAINS_SINGLE; + return IL_NUM_IDLE_CHAINS_SINGLE; case IEEE80211_SMPS_OFF: return active_cnt; default: @@ -1051,7 +1051,7 @@ iwl4965_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) } /* up to 4 chains */ -static u8 iwl4965_count_chain_bitmap(u32 chain_bitmap) +static u8 il4965_count_chain_bitmap(u32 chain_bitmap) { u8 res; res = (chain_bitmap & BIT(0)) >> 0; @@ -1062,14 +1062,14 @@ static u8 iwl4965_count_chain_bitmap(u32 chain_bitmap) } /** - * iwl4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image + * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image * * Selects how many and which Rx receivers/antennas/chains to use. * This should not be used for scan command ... it puts data in wrong place. */ -void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) { - bool is_single = iwl4965_is_single_rx_stream(priv); + bool is_single = il4965_is_single_rx_stream(priv); bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; u32 active_chains; @@ -1077,7 +1077,7 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) /* Tell uCode which antennas are actually connected. * Before first association, we assume all antennas are connected. - * Just after first association, iwl4965_chain_noise_calibration() + * Just after first association, il4965_chain_noise_calibration() * checks which antennas actually *are* connected. */ if (priv->chain_noise_data.active_chains) active_chains = priv->chain_noise_data.active_chains; @@ -1087,14 +1087,14 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; /* How many receivers should we use? */ - active_rx_cnt = iwl4965_get_active_rx_chain_count(priv); - idle_rx_cnt = iwl4965_get_idle_rx_chain_count(priv, active_rx_cnt); + active_rx_cnt = il4965_get_active_rx_chain_count(priv); + idle_rx_cnt = il4965_get_idle_rx_chain_count(priv, active_rx_cnt); /* correct rx chain count according hw settings * and chain noise calibration */ - valid_rx_cnt = iwl4965_count_chain_bitmap(active_chains); + valid_rx_cnt = il4965_count_chain_bitmap(active_chains); if (valid_rx_cnt < active_rx_cnt) active_rx_cnt = valid_rx_cnt; @@ -1106,12 +1106,12 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) ctx->staging.rx_chain = cpu_to_le16(rx_chain); - if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam) + if (!is_single && (active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE) && is_cam) ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - IWL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", + IL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, active_rx_cnt, idle_rx_cnt); @@ -1119,7 +1119,7 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) active_rx_cnt < idle_rx_cnt); } -u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid) +u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant, u8 valid) { int i; u8 ind = ant; @@ -1132,24 +1132,24 @@ u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid) return ant; } -static const char *iwl4965_get_fh_string(int cmd) +static const char *il4965_get_fh_string(int cmd) { switch (cmd) { - IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); - IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); - IWL_CMD(FH_RSCSR_CHNL0_WPTR); - IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); - IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); - IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG); - IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IWL_CMD(FH_TSSR_TX_STATUS_REG); - IWL_CMD(FH_TSSR_TX_ERROR_REG); + IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH_RSCSR_CHNL0_WPTR); + IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH_TSSR_TX_STATUS_REG); + IL_CMD(FH_TSSR_TX_ERROR_REG); default: return "UNKNOWN"; } } -int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display) +int il4965_dump_fh(struct il_priv *priv, char **buf, bool display) { int i; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1178,17 +1178,17 @@ int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display) for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", - iwl4965_get_fh_string(fh_tbl[i]), - iwl_legacy_read_direct32(priv, fh_tbl[i])); + il4965_get_fh_string(fh_tbl[i]), + il_read_direct32(priv, fh_tbl[i])); } return pos; } #endif - IWL_ERR(priv, "FH register values:\n"); + IL_ERR(priv, "FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IWL_ERR(priv, " %34s: 0X%08x\n", - iwl4965_get_fh_string(fh_tbl[i]), - iwl_legacy_read_direct32(priv, fh_tbl[i])); + IL_ERR(priv, " %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), + il_read_direct32(priv, fh_tbl[i])); } return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 57ebe21..a7298f5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -43,26 +43,26 @@ #define IWL4965_RS_NAME "iwl-4965-rs" #define NUM_TRY_BEFORE_ANT_TOGGLE 1 -#define IWL_NUMBER_TRY 1 -#define IWL_HT_NUMBER_TRY 3 +#define IL_NUMBER_TRY 1 +#define IL_HT_NUMBER_TRY 3 -#define IWL_RATE_MAX_WINDOW 62 /* # tx in history window */ -#define IWL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ -#define IWL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ +#define IL_RATE_MAX_WINDOW 62 /* # tx in history window */ +#define IL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ +#define IL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ /* max allowed rate miss before sync LQ cmd */ -#define IWL_MISSED_RATE_MAX 15 +#define IL_MISSED_RATE_MAX 15 /* max time to accum history 2 seconds */ -#define IWL_RATE_SCALE_FLUSH_INTVL (3*HZ) +#define IL_RATE_SCALE_FLUSH_INTVL (3*HZ) static u8 rs_ht_to_legacy[] = { - IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, - IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, - IWL_RATE_6M_INDEX, - IWL_RATE_6M_INDEX, IWL_RATE_9M_INDEX, - IWL_RATE_12M_INDEX, IWL_RATE_18M_INDEX, - IWL_RATE_24M_INDEX, IWL_RATE_36M_INDEX, - IWL_RATE_48M_INDEX, IWL_RATE_54M_INDEX + IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, + IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, + IL_RATE_6M_INDEX, + IL_RATE_6M_INDEX, IL_RATE_9M_INDEX, + IL_RATE_12M_INDEX, IL_RATE_18M_INDEX, + IL_RATE_24M_INDEX, IL_RATE_36M_INDEX, + IL_RATE_48M_INDEX, IL_RATE_54M_INDEX }; static const u8 ant_toggle_lookup[] = { @@ -76,43 +76,43 @@ static const u8 ant_toggle_lookup[] = { /*ANT_ABC -> */ ANT_ABC, }; -#define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ - IWL_RATE_SISO_##s##M_PLCP, \ - IWL_RATE_MIMO2_##s##M_PLCP,\ - IWL_RATE_##r##M_IEEE, \ - IWL_RATE_##ip##M_INDEX, \ - IWL_RATE_##in##M_INDEX, \ - IWL_RATE_##rp##M_INDEX, \ - IWL_RATE_##rn##M_INDEX, \ - IWL_RATE_##pp##M_INDEX, \ - IWL_RATE_##np##M_INDEX } +#define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ + [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ + IL_RATE_SISO_##s##M_PLCP, \ + IL_RATE_MIMO2_##s##M_PLCP,\ + IL_RATE_##r##M_IEEE, \ + IL_RATE_##ip##M_INDEX, \ + IL_RATE_##in##M_INDEX, \ + IL_RATE_##rp##M_INDEX, \ + IL_RATE_##rn##M_INDEX, \ + IL_RATE_##pp##M_INDEX, \ + IL_RATE_##np##M_INDEX } /* * Parameter order: * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IWL_RATE_INVALID + * maps to IL_RATE_INVALID * */ -const struct iwl_rate_info iwlegacy_rates[IWL_RATE_COUNT] = { - IWL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IWL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IWL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IWL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IWL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IWL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ - IWL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IWL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IWL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IWL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IWL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IWL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ - IWL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ +const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT] = { + IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ }; -static int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) +static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) { int idx = 0; @@ -120,14 +120,14 @@ static int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) if (rate_n_flags & RATE_MCS_HT_MSK) { idx = (rate_n_flags & 0xff); - if (idx >= IWL_RATE_MIMO2_6M_PLCP) - idx = idx - IWL_RATE_MIMO2_6M_PLCP; + if (idx >= IL_RATE_MIMO2_6M_PLCP) + idx = idx - IL_RATE_MIMO2_6M_PLCP; - idx += IWL_FIRST_OFDM_RATE; + idx += IL_FIRST_OFDM_RATE; /* skip 9M not supported in ht*/ - if (idx >= IWL_RATE_9M_INDEX) + if (idx >= IL_RATE_9M_INDEX) idx += 1; - if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE)) + if ((idx >= IL_FIRST_OFDM_RATE) && (idx <= IL_LAST_OFDM_RATE)) return idx; /* legacy rate format, search for match in table */ @@ -140,20 +140,20 @@ static int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) return -1; } -static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *priv, struct sk_buff *skb, struct ieee80211_sta *sta, - struct iwl_lq_sta *lq_sta); -static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, u32 rate_n_flags); -static void iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, + struct il_lq_sta *lq_sta); +static void il4965_rs_fill_link_cmd(struct il_priv *priv, + struct il_lq_sta *lq_sta, u32 rate_n_flags); +static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search); #ifdef CONFIG_MAC80211_DEBUGFS -static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index); #else -static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index) {} #endif @@ -169,32 +169,32 @@ static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, * (2.4 GHz) band. */ -static s32 expected_tpt_legacy[IWL_RATE_COUNT] = { +static s32 expected_tpt_legacy[IL_RATE_COUNT] = { 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 }; -static s32 expected_tpt_siso20MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_siso20MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ }; -static s32 expected_tpt_siso40MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_siso40MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ }; -static s32 expected_tpt_mimo2_20MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_20MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ }; -static s32 expected_tpt_mimo2_40MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_40MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ @@ -202,7 +202,7 @@ static s32 expected_tpt_mimo2_40MHz[4][IWL_RATE_COUNT] = { }; /* mbps, mcs */ -static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = { +static const struct il_rate_mcs_info il_rate_mcs[IL_RATE_COUNT] = { { "1", "BPSK DSSS"}, { "2", "QPSK DSSS"}, {"5.5", "BPSK CCK"}, @@ -220,23 +220,23 @@ static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = { #define MCS_INDEX_PER_STREAM (8) -static inline u8 iwl4965_rs_extract_rate(u32 rate_n_flags) +static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) { return (u8)(rate_n_flags & 0xFF); } static void -iwl4965_rs_rate_scale_clear_window(struct iwl_rate_scale_data *window) +il4965_rs_rate_scale_clear_window(struct il_rate_scale_data *window) { window->data = 0; window->success_counter = 0; - window->success_ratio = IWL_INVALID_VALUE; + window->success_ratio = IL_INVALID_VALUE; window->counter = 0; - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; window->stamp = 0; } -static inline u8 iwl4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) +static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) { return (ant_type & valid_antenna) == ant_type; } @@ -246,7 +246,7 @@ static inline u8 iwl4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) * TID_MAX_TIME_DIFF, will be deleted. */ static void -iwl4965_rs_tl_rm_old_stats(struct iwl_traffic_load *tl, u32 curr_time) +il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) { /* The oldest age we want to keep */ u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; @@ -267,13 +267,13 @@ iwl4965_rs_tl_rm_old_stats(struct iwl_traffic_load *tl, u32 curr_time) * increment traffic load value for tid and also remove * any old values if passed the certain time period */ -static u8 iwl4965_rs_tl_add_packet(struct iwl_lq_sta *lq_data, +static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, struct ieee80211_hdr *hdr) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; s32 index; - struct iwl_traffic_load *tl = NULL; + struct il_traffic_load *tl = NULL; u8 tid; if (ieee80211_is_data_qos(hdr->frame_control)) { @@ -305,7 +305,7 @@ static u8 iwl4965_rs_tl_add_packet(struct iwl_lq_sta *lq_data, /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ if (index >= TID_QUEUE_MAX_SIZE) - iwl4965_rs_tl_rm_old_stats(tl, curr_time); + il4965_rs_tl_rm_old_stats(tl, curr_time); index = (tl->head + index) % TID_QUEUE_MAX_SIZE; tl->packet_count[index] = tl->packet_count[index] + 1; @@ -320,12 +320,12 @@ static u8 iwl4965_rs_tl_add_packet(struct iwl_lq_sta *lq_data, /* get the traffic load value for tid */ -static u32 iwl4965_rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid) +static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; s32 index; - struct iwl_traffic_load *tl = NULL; + struct il_traffic_load *tl = NULL; if (tid >= TID_MAX_LOAD_COUNT) return 0; @@ -343,22 +343,22 @@ static u32 iwl4965_rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid) /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ if (index >= TID_QUEUE_MAX_SIZE) - iwl4965_rs_tl_rm_old_stats(tl, curr_time); + il4965_rs_tl_rm_old_stats(tl, curr_time); return tl->total; } -static int iwl4965_rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, - struct iwl_lq_sta *lq_data, u8 tid, +static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, + struct il_lq_sta *lq_data, u8 tid, struct ieee80211_sta *sta) { int ret = -EAGAIN; u32 load; - load = iwl4965_rs_tl_get_load(lq_data, tid); + load = il4965_rs_tl_get_load(lq_data, tid); - if (load > IWL_AGG_LOAD_THRESHOLD) { - IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", + if (load > IL_AGG_LOAD_THRESHOLD) { + IL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { @@ -367,29 +367,29 @@ static int iwl4965_rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, * this might be cause by reloading firmware * stop the tx ba session here */ - IWL_ERR(priv, "Fail start Tx agg on tid: %d\n", + IL_ERR(priv, "Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { - IWL_ERR(priv, "Aggregation not enabled for tid %d " + IL_ERR(priv, "Aggregation not enabled for tid %d " "because load = %u\n", tid, load); } return ret; } -static void iwl4965_rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, - struct iwl_lq_sta *lq_data, +static void il4965_rs_tl_turn_on_agg(struct il_priv *priv, u8 tid, + struct il_lq_sta *lq_data, struct ieee80211_sta *sta) { if (tid < TID_MAX_LOAD_COUNT) - iwl4965_rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); + il4965_rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); else - IWL_ERR(priv, "tid exceeds max load count: %d/%d\n", + IL_ERR(priv, "tid exceeds max load count: %d/%d\n", tid, TID_MAX_LOAD_COUNT); } -static inline int iwl4965_get_iwl4965_num_of_ant_from_rate(u32 rate_n_flags) +static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) { return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + @@ -397,11 +397,11 @@ static inline int iwl4965_get_iwl4965_num_of_ant_from_rate(u32 rate_n_flags) } /* - * Static function to get the expected throughput from an iwl_scale_tbl_info + * Static function to get the expected throughput from an il_scale_tbl_info * that wraps a NULL pointer check */ static s32 -iwl4965_get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index) +il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) { if (tbl->expected_tpt) return tbl->expected_tpt[rs_index]; @@ -409,27 +409,27 @@ iwl4965_get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index) } /** - * iwl4965_rs_collect_tx_data - Update the success/failure sliding window + * il4965_rs_collect_tx_data - Update the success/failure sliding window * * We keep a sliding window of the last 62 packets transmitted * at this rate. window->data contains the bitmask of successful * packets. */ -static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, +static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_index, int attempts, int successes) { - struct iwl_rate_scale_data *window = NULL; - static const u64 mask = (((u64)1) << (IWL_RATE_MAX_WINDOW - 1)); + struct il_rate_scale_data *window = NULL; + static const u64 mask = (((u64)1) << (IL_RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; - if (scale_index < 0 || scale_index >= IWL_RATE_COUNT) + if (scale_index < 0 || scale_index >= IL_RATE_COUNT) return -EINVAL; /* Select window for current tx bit rate */ window = &(tbl->win[scale_index]); /* Get expected throughput */ - tpt = iwl4965_get_expected_tpt(tbl, scale_index); + tpt = il4965_get_expected_tpt(tbl, scale_index); /* * Keep track of only the latest 62 tx frame attempts in this rate's @@ -440,10 +440,10 @@ static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, * we keep these bitmaps!). */ while (attempts > 0) { - if (window->counter >= IWL_RATE_MAX_WINDOW) { + if (window->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IWL_RATE_MAX_WINDOW - 1; + window->counter = IL_RATE_MAX_WINDOW - 1; if (window->data & mask) { window->data &= ~mask; @@ -472,16 +472,16 @@ static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, window->success_ratio = 128 * (100 * window->success_counter) / window->counter; else - window->success_ratio = IWL_INVALID_VALUE; + window->success_ratio = IL_INVALID_VALUE; fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IWL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH)) + if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || + (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) window->average_tpt = (window->success_ratio * tpt + 64) / 128; else - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; /* Tag this window as having been updated */ window->stamp = jiffies; @@ -492,21 +492,21 @@ static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, /* * Fill uCode API rate_n_flags field, based on "search" or "active" table. */ -static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, - struct iwl_scale_tbl_info *tbl, +static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, + struct il_scale_tbl_info *tbl, int index, u8 use_green) { u32 rate_n_flags = 0; if (is_legacy(tbl->lq_type)) { rate_n_flags = iwlegacy_rates[index].plcp; - if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE) + if (index >= IL_FIRST_CCK_RATE && index <= IL_LAST_CCK_RATE) rate_n_flags |= RATE_MCS_CCK_MSK; } else if (is_Ht(tbl->lq_type)) { - if (index > IWL_LAST_OFDM_RATE) { - IWL_ERR(priv, "Invalid HT rate index %d\n", index); - index = IWL_LAST_OFDM_RATE; + if (index > IL_LAST_OFDM_RATE) { + IL_ERR(priv, "Invalid HT rate index %d\n", index); + index = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; @@ -515,7 +515,7 @@ static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, else rate_n_flags |= iwlegacy_rates[index].plcp_mimo2; } else { - IWL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); + IL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); } rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & @@ -535,7 +535,7 @@ static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, rate_n_flags |= RATE_MCS_GF_MSK; if (is_siso(tbl->lq_type) && tbl->is_SGI) { rate_n_flags &= ~RATE_MCS_SGI_MSK; - IWL_ERR(priv, "GF was set with SGI:SISO\n"); + IL_ERR(priv, "GF was set with SGI:SISO\n"); } } } @@ -546,19 +546,19 @@ static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, * Interpret uCode API's rate_n_flags format, * fill "search" or "active" tx mode table. */ -static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, +static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, enum ieee80211_band band, - struct iwl_scale_tbl_info *tbl, + struct il_scale_tbl_info *tbl, int *rate_idx) { u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); - u8 iwl4965_num_of_ant = iwl4965_get_iwl4965_num_of_ant_from_rate(rate_n_flags); + u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); u8 mcs; - memset(tbl, 0, sizeof(struct iwl_scale_tbl_info)); - *rate_idx = iwl4965_hwrate_to_plcp_idx(rate_n_flags); + memset(tbl, 0, sizeof(struct il_scale_tbl_info)); + *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - if (*rate_idx == IWL_RATE_INVALID) { + if (*rate_idx == IL_RATE_INVALID) { *rate_idx = -1; return -EINVAL; } @@ -567,11 +567,11 @@ static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, tbl->is_dup = 0; tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); tbl->lq_type = LQ_NONE; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; /* legacy rate format */ if (!(rate_n_flags & RATE_MCS_HT_MSK)) { - if (iwl4965_num_of_ant == 1) { + if (il4965_num_of_ant == 1) { if (band == IEEE80211_BAND_5GHZ) tbl->lq_type = LQ_A; else @@ -589,15 +589,15 @@ static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, if (rate_n_flags & RATE_MCS_DUP_MSK) tbl->is_dup = 1; - mcs = iwl4965_rs_extract_rate(rate_n_flags); + mcs = il4965_rs_extract_rate(rate_n_flags); /* SISO */ - if (mcs <= IWL_RATE_SISO_60M_PLCP) { - if (iwl4965_num_of_ant == 1) + if (mcs <= IL_RATE_SISO_60M_PLCP) { + if (il4965_num_of_ant == 1) tbl->lq_type = LQ_SISO; /*else NONE*/ /* MIMO2 */ } else { - if (iwl4965_num_of_ant == 2) + if (il4965_num_of_ant == 2) tbl->lq_type = LQ_MIMO2; } } @@ -606,21 +606,21 @@ static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* switch to another antenna/antennas and return 1 */ /* if no other valid antenna found, return 0 */ -static int iwl4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, - struct iwl_scale_tbl_info *tbl) +static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, + struct il_scale_tbl_info *tbl) { u8 new_ant_type; if (!tbl->ant_type || tbl->ant_type > ANT_ABC) return 0; - if (!iwl4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) + if (!il4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) return 0; new_ant_type = ant_toggle_lookup[tbl->ant_type]; while ((new_ant_type != tbl->ant_type) && - !iwl4965_rs_is_valid_ant(valid_ant, new_ant_type)) + !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) new_ant_type = ant_toggle_lookup[new_ant_type]; if (new_ant_type == tbl->ant_type) @@ -636,25 +636,25 @@ static int iwl4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, * Green-field mode is valid if the station supports it and * there are no non-GF stations present in the BSS. */ -static bool iwl4965_rs_use_green(struct ieee80211_sta *sta) +static bool il4965_rs_use_green(struct ieee80211_sta *sta) { - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && !(ctx->ht.non_gf_sta_present); } /** - * iwl4965_rs_get_supported_rates - get the available rates + * il4965_rs_get_supported_rates - get the available rates * * if management frame or broadcast frame only return * basic available rates. * */ -static u16 iwl4965_rs_get_supported_rates(struct iwl_lq_sta *lq_sta, +static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, struct ieee80211_hdr *hdr, - enum iwl_table_type rate_type) + enum il_table_type rate_type) { if (is_legacy(rate_type)) { return lq_sta->active_legacy_rate; @@ -667,11 +667,11 @@ static u16 iwl4965_rs_get_supported_rates(struct iwl_lq_sta *lq_sta, } static u16 -iwl4965_rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, +il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, int rate_type) { - u8 high = IWL_RATE_INVALID; - u8 low = IWL_RATE_INVALID; + u8 high = IL_RATE_INVALID; + u8 low = IL_RATE_INVALID; /* 802.11A or ht walks to the next literal adjacent rate in * the rate table */ @@ -690,7 +690,7 @@ iwl4965_rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IWL_RATE_COUNT; i++, mask <<= 1) { + for (mask = (1 << i); i < IL_RATE_COUNT; i++, mask <<= 1) { if (rate_mask & mask) { high = i; break; @@ -701,30 +701,30 @@ iwl4965_rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, } low = index; - while (low != IWL_RATE_INVALID) { + while (low != IL_RATE_INVALID) { low = iwlegacy_rates[low].prev_rs; - if (low == IWL_RATE_INVALID) + if (low == IL_RATE_INVALID) break; if (rate_mask & (1 << low)) break; - IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); } high = index; - while (high != IWL_RATE_INVALID) { + while (high != IL_RATE_INVALID) { high = iwlegacy_rates[high].next_rs; - if (high == IWL_RATE_INVALID) + if (high == IL_RATE_INVALID) break; if (rate_mask & (1 << high)) break; - IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; } -static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl, +static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, u8 scale_index, u8 ht_possible) { s32 low; @@ -732,7 +732,7 @@ static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, u16 high_low; u8 switch_to_legacy = 0; u8 is_green = lq_sta->is_green; - struct iwl_priv *priv = lq_sta->drv; + struct il_priv *priv = lq_sta->drv; /* check if we need to switch from HT to legacy rates. * assumption is that mandatory rates (1Mbps or 6Mbps) @@ -745,23 +745,23 @@ static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, else tbl->lq_type = LQ_G; - if (iwl4965_num_of_ant(tbl->ant_type) > 1) + if (il4965_num_of_ant(tbl->ant_type) > 1) tbl->ant_type = - iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(priv->hw_params.valid_tx_ant); tbl->is_ht40 = 0; tbl->is_SGI = 0; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; } - rate_mask = iwl4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); + rate_mask = il4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); /* Mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { /* supp_rates has no CCK bits in A mode */ if (lq_sta->band == IEEE80211_BAND_5GHZ) rate_mask = (u16)(rate_mask & - (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else rate_mask = (u16)(rate_mask & lq_sta->supp_rates); } @@ -772,23 +772,23 @@ static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, goto out; } - high_low = iwl4965_rs_get_adjacent_rate(lq_sta->drv, + high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, scale_index, rate_mask, tbl->lq_type); low = high_low & 0xff; - if (low == IWL_RATE_INVALID) + if (low == IL_RATE_INVALID) low = scale_index; out: - return iwl4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); + return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); } /* * Simple function to compare two rate scale table types */ -static bool iwl4965_table_type_matches(struct iwl_scale_tbl_info *a, - struct iwl_scale_tbl_info *b) +static bool il4965_table_type_matches(struct il_scale_tbl_info *a, + struct il_scale_tbl_info *b) { return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && (a->is_SGI == b->is_SGI); @@ -798,34 +798,34 @@ static bool iwl4965_table_type_matches(struct iwl_scale_tbl_info *a, * mac80211 sends us Tx status */ static void -iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, +il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta, struct sk_buff *skb) { int legacy_success; int retries; int rs_index, mac_index, i; - struct iwl_lq_sta *lq_sta = priv_sta; - struct iwl_link_quality_cmd *table; + struct il_lq_sta *lq_sta = priv_sta; + struct il_link_quality_cmd *table; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct iwl_priv *priv = (struct iwl_priv *)priv_r; + struct il_priv *priv = (struct il_priv *)priv_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); enum mac80211_rate_control_flags mac_flags; u32 tx_rate; - struct iwl_scale_tbl_info tbl_type; - struct iwl_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_scale_tbl_info tbl_type; + struct il_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; - IWL_DEBUG_RATE_LIMIT(priv, + IL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { - IWL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n"); + IL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n"); return; } else if (!lq_sta->drv) { - IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); + IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); return; } @@ -848,23 +848,23 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, */ table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - iwl4965_rs_get_tbl_info_from_mcs(tx_rate, + il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); if (priv->band == IEEE80211_BAND_5GHZ) - rs_index -= IWL_FIRST_OFDM_RATE; + rs_index -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; mac_index = info->status.rates[0].idx; /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (IWL_RATE_9M_INDEX - IWL_FIRST_OFDM_RATE)) + if (mac_index >= (IL_RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) mac_index++; /* * mac80211 HT index is always zero-indexed; we need to move * HT OFDM rates after CCK rates in 2.4 GHz band */ if (priv->band == IEEE80211_BAND_2GHZ) - mac_index += IWL_FIRST_OFDM_RATE; + mac_index += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ if ((mac_index < 0) || @@ -880,18 +880,18 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, (!!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || (rs_index != mac_index)) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); /* * Since rates mis-match, the last LQ command may have failed. - * After IWL_MISSED_RATE_MAX mis-matches, resync the uCode with + * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with * ... driver. */ lq_sta->missed_rate_counter++; - if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { + if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { lq_sta->missed_rate_counter = 0; - iwl_legacy_send_lq_cmd(priv, ctx, &lq_sta->lq, + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); } /* Regardless, ignore this status info for outdated rate */ @@ -901,30 +901,30 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter = 0; /* Figure out if rate scale algorithm is in active or search table */ - if (iwl4965_table_type_matches(&tbl_type, + if (il4965_table_type_matches(&tbl_type, &(lq_sta->lq_info[lq_sta->active_tbl]))) { curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - } else if (iwl4965_table_type_matches(&tbl_type, + } else if (il4965_table_type_matches(&tbl_type, &lq_sta->lq_info[1 - lq_sta->active_tbl])) { curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - IWL_DEBUG_RATE(priv, "active- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(priv, "active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - IWL_DEBUG_RATE(priv, "search- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(priv, "search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - IWL_DEBUG_RATE(priv, "actual- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(priv, "actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection * and continue to perform rate scale to find the rate table */ - iwl4965_rs_stay_in_table(lq_sta, true); + il4965_rs_stay_in_table(lq_sta, true); goto done; } @@ -937,9 +937,9 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, */ if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - iwl4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, + il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); - iwl4965_rs_collect_tx_data(curr_tbl, rs_index, + il4965_rs_collect_tx_data(curr_tbl, rs_index, info->status.ampdu_len, info->status.ampdu_ack_len); @@ -962,20 +962,20 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, /* Collect data for each rate used during failed TX attempts */ for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); - iwl4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, + il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); /* * Only collect stats if retried rate is in the same RS * table as active/search. */ - if (iwl4965_table_type_matches(&tbl_type, curr_tbl)) + if (il4965_table_type_matches(&tbl_type, curr_tbl)) tmp_tbl = curr_tbl; - else if (iwl4965_table_type_matches(&tbl_type, + else if (il4965_table_type_matches(&tbl_type, other_tbl)) tmp_tbl = other_tbl; else continue; - iwl4965_rs_collect_tx_data(tmp_tbl, rs_index, 1, + il4965_rs_collect_tx_data(tmp_tbl, rs_index, 1, i < retries ? 0 : legacy_success); } @@ -990,7 +990,7 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, done: /* See if there's a better rate or modulation mode to try. */ if (sta && sta->supp_rates[sband->band]) - iwl4965_rs_rate_scale_perform(priv, skb, sta, lq_sta); + il4965_rs_rate_scale_perform(priv, skb, sta, lq_sta); } /* @@ -1001,19 +1001,19 @@ done: * These control how long we stay using same modulation mode before * searching for a new mode. */ -static void iwl4965_rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy, - struct iwl_lq_sta *lq_sta) +static void il4965_rs_set_stay_in_table(struct il_priv *priv, u8 is_legacy, + struct il_lq_sta *lq_sta) { - IWL_DEBUG_RATE(priv, "we are staying in the same table\n"); + IL_DEBUG_RATE(priv, "we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { - lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT; - lq_sta->max_failure_limit = IWL_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IWL_LEGACY_SUCCESS_LIMIT; + lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; + lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; } else { - lq_sta->table_count_limit = IWL_NONE_LEGACY_TABLE_COUNT; - lq_sta->max_failure_limit = IWL_NONE_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IWL_NONE_LEGACY_SUCCESS_LIMIT; + lq_sta->table_count_limit = IL_NONE_LEGACY_TABLE_COUNT; + lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; } lq_sta->table_count = 0; lq_sta->total_failed = 0; @@ -1025,11 +1025,11 @@ static void iwl4965_rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy, /* * Find correct throughput table for given mode of modulation */ -static void iwl4965_rs_set_expected_tpt_table(struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl) +static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl) { /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[IWL_RATE_COUNT]; + s32 (*ht_tbl_pointer)[IL_RATE_COUNT]; /* Check for invalid LQ type */ if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { @@ -1077,13 +1077,13 @@ static void iwl4965_rs_set_expected_tpt_table(struct iwl_lq_sta *lq_sta, * to decrease to match "active" throughput. When moving from MIMO to SISO, * bit rate will typically need to increase, but not if performance was bad. */ -static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl, /* "search" */ +static s32 il4965_rs_get_best_rate(struct il_priv *priv, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, /* "search" */ u16 rate_mask, s8 index) { /* "active" values */ - struct iwl_scale_tbl_info *active_tbl = + struct il_scale_tbl_info *active_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); s32 active_sr = active_tbl->win[index].success_ratio; s32 active_tpt = active_tbl->expected_tpt[index]; @@ -1095,10 +1095,10 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, u16 high_low; s8 rate = index; - new_rate = high = low = start_hi = IWL_RATE_INVALID; + new_rate = high = low = start_hi = IL_RATE_INVALID; for (; ;) { - high_low = iwl4965_rs_get_adjacent_rate(priv, rate, rate_mask, + high_low = il4965_rs_get_adjacent_rate(priv, rate, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -1120,16 +1120,16 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, * "active" throughput (under perfect conditions). */ if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && - ((active_sr > IWL_RATE_DECREASE_TH) && - (active_sr <= IWL_RATE_HIGH_TH) && + ((active_sr > IL_RATE_DECREASE_TH) && + (active_sr <= IL_RATE_HIGH_TH) && (tpt_tbl[rate] <= active_tpt))) || - ((active_sr >= IWL_RATE_SCALE_SWITCH) && + ((active_sr >= IL_RATE_SCALE_SWITCH) && (tpt_tbl[rate] > active_tpt))) { /* (2nd or later pass) * If we've already tried to raise the rate, and are * now trying to lower it, use the higher rate. */ - if (start_hi != IWL_RATE_INVALID) { + if (start_hi != IL_RATE_INVALID) { new_rate = start_hi; break; } @@ -1137,7 +1137,7 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, new_rate = rate; /* Loop again with lower rate */ - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) rate = low; /* Lower rate not available, use the original */ @@ -1149,11 +1149,11 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, /* (2nd or later pass) * If we've already tried to lower the rate, and are * now trying to raise it, use the lower rate. */ - if (new_rate != IWL_RATE_INVALID) + if (new_rate != IL_RATE_INVALID) break; /* Loop again with higher rate */ - else if (high != IWL_RATE_INVALID) { + else if (high != IL_RATE_INVALID) { start_hi = high; rate = high; @@ -1171,17 +1171,17 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, /* * Set up search table for MIMO2 */ -static int iwl4965_rs_switch_to_mimo2(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_switch_to_mimo2(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct iwl_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int index) { u16 rate_mask; s32 rate; s8 is_green = lq_sta->is_green; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; @@ -1194,35 +1194,35 @@ static int iwl4965_rs_switch_to_mimo2(struct iwl_priv *priv, if (priv->hw_params.tx_chains_num < 2) return -1; - IWL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n"); + IL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n"); tbl->lq_type = LQ_MIMO2; tbl->is_dup = lq_sta->is_dup; tbl->action = 0; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_mimo2_rate; - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; - iwl4965_rs_set_expected_tpt_table(lq_sta, tbl); + il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = iwl4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); - IWL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", + IL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); - if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IWL_DEBUG_RATE(priv, + if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + IL_DEBUG_RATE(priv, "Can't switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = iwl4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate, is_green); - IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1230,30 +1230,30 @@ static int iwl4965_rs_switch_to_mimo2(struct iwl_priv *priv, /* * Set up search table for SISO */ -static int iwl4965_rs_switch_to_siso(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_switch_to_siso(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct iwl_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int index) { u16 rate_mask; u8 is_green = lq_sta->is_green; s32 rate; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - IWL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n"); + IL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n"); tbl->is_dup = lq_sta->is_dup; tbl->lq_type = LQ_SISO; tbl->action = 0; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_siso_rate; - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; @@ -1261,19 +1261,19 @@ static int iwl4965_rs_switch_to_siso(struct iwl_priv *priv, if (is_green) tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ - iwl4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = iwl4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); - IWL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask); - if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask); + if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + IL_DEBUG_RATE(priv, "can not switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = iwl4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate, is_green); - IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1281,62 +1281,62 @@ static int iwl4965_rs_switch_to_siso(struct iwl_priv *priv, /* * Try to switch to new modulation mode from legacy */ -static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_move_legacy_other(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) { - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct iwl_scale_tbl_info *search_tbl = + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct iwl_rate_scale_data *window = &(tbl->win[index]); - u32 sz = (sizeof(struct iwl_scale_tbl_info) - - (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); + struct il_rate_scale_data *window = &(tbl->win[index]); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; u8 valid_tx_ant = priv->hw_params.valid_tx_ant; u8 tx_chains_num = priv->hw_params.tx_chains_num; int ret = 0; u8 update_search_tbl_counter = 0; - tbl->action = IWL_LEGACY_SWITCH_SISO; + tbl->action = IL_LEGACY_SWITCH_SISO; start_action = tbl->action; for (; ;) { lq_sta->action_counter++; switch (tbl->action) { - case IWL_LEGACY_SWITCH_ANTENNA1: - case IWL_LEGACY_SWITCH_ANTENNA2: - IWL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); + case IL_LEGACY_SWITCH_ANTENNA1: + case IL_LEGACY_SWITCH_ANTENNA2: + IL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); - if ((tbl->action == IWL_LEGACY_SWITCH_ANTENNA1 && + if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && tx_chains_num <= 1) || - (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2 && + (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && tx_chains_num <= 2)) break; /* Don't change antenna if success has been great */ - if (window->success_ratio >= IWL_RS_GOOD_RATIO) + if (window->success_ratio >= IL_RS_GOOD_RATIO) break; /* Set up search table to try other antenna */ memcpy(search_tbl, tbl, sz); - if (iwl4965_rs_toggle_antenna(valid_tx_ant, + if (il4965_rs_toggle_antenna(valid_tx_ant, &search_tbl->current_rate, search_tbl)) { update_search_tbl_counter = 1; - iwl4965_rs_set_expected_tpt_table(lq_sta, + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); goto out; } break; - case IWL_LEGACY_SWITCH_SISO: - IWL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n"); + case IL_LEGACY_SWITCH_SISO: + IL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n"); /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - ret = iwl4965_rs_switch_to_siso(priv, lq_sta, conf, sta, + ret = il4965_rs_switch_to_siso(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) { lq_sta->action_counter = 0; @@ -1344,27 +1344,27 @@ static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, } break; - case IWL_LEGACY_SWITCH_MIMO2_AB: - case IWL_LEGACY_SWITCH_MIMO2_AC: - case IWL_LEGACY_SWITCH_MIMO2_BC: - IWL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n"); + case IL_LEGACY_SWITCH_MIMO2_AB: + case IL_LEGACY_SWITCH_MIMO2_AC: + case IL_LEGACY_SWITCH_MIMO2_BC: + IL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n"); /* Set up search table to try MIMO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AB) + if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AB) search_tbl->ant_type = ANT_AB; - else if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AC) + else if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AC) search_tbl->ant_type = ANT_AC; else search_tbl->ant_type = ANT_BC; - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, + if (!il4965_rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) break; - ret = iwl4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) { @@ -1374,8 +1374,8 @@ static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, break; } tbl->action++; - if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; if (tbl->action == start_action) break; @@ -1387,8 +1387,8 @@ static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, out: lq_sta->search_better_tbl = 1; tbl->action++; - if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; if (update_search_tbl_counter) search_tbl->action = tbl->action; return 0; @@ -1398,19 +1398,19 @@ out: /* * Try to switch to new modulation mode from SISO */ -static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_move_siso_to_other(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) { u8 is_green = lq_sta->is_green; - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct iwl_scale_tbl_info *search_tbl = + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct iwl_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *window = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct iwl_scale_tbl_info) - - (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; u8 valid_tx_ant = priv->hw_params.valid_tx_ant; u8 tx_chains_num = priv->hw_params.tx_chains_num; @@ -1422,50 +1422,50 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, for (;;) { lq_sta->action_counter++; switch (tbl->action) { - case IWL_SISO_SWITCH_ANTENNA1: - case IWL_SISO_SWITCH_ANTENNA2: - IWL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); - if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 && + case IL_SISO_SWITCH_ANTENNA1: + case IL_SISO_SWITCH_ANTENNA2: + IL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); + if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && tx_chains_num <= 1) || - (tbl->action == IWL_SISO_SWITCH_ANTENNA2 && + (tbl->action == IL_SISO_SWITCH_ANTENNA2 && tx_chains_num <= 2)) break; - if (window->success_ratio >= IWL_RS_GOOD_RATIO) + if (window->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); - if (iwl4965_rs_toggle_antenna(valid_tx_ant, + if (il4965_rs_toggle_antenna(valid_tx_ant, &search_tbl->current_rate, search_tbl)) { update_search_tbl_counter = 1; goto out; } break; - case IWL_SISO_SWITCH_MIMO2_AB: - case IWL_SISO_SWITCH_MIMO2_AC: - case IWL_SISO_SWITCH_MIMO2_BC: - IWL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n"); + case IL_SISO_SWITCH_MIMO2_AB: + case IL_SISO_SWITCH_MIMO2_AC: + case IL_SISO_SWITCH_MIMO2_BC: + IL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n"); memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - if (tbl->action == IWL_SISO_SWITCH_MIMO2_AB) + if (tbl->action == IL_SISO_SWITCH_MIMO2_AB) search_tbl->ant_type = ANT_AB; - else if (tbl->action == IWL_SISO_SWITCH_MIMO2_AC) + else if (tbl->action == IL_SISO_SWITCH_MIMO2_AC) search_tbl->ant_type = ANT_AC; else search_tbl->ant_type = ANT_BC; - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, + if (!il4965_rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) break; - ret = iwl4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) goto out; break; - case IWL_SISO_SWITCH_GI: + case IL_SISO_SWITCH_GI: if (!tbl->is_ht40 && !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; @@ -1473,32 +1473,32 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IWL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n"); + IL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n"); memcpy(search_tbl, tbl, sz); if (is_green) { if (!tbl->is_SGI) break; else - IWL_ERR(priv, + IL_ERR(priv, "SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; - iwl4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); if (tbl->is_SGI) { s32 tpt = lq_sta->last_tpt / 100; if (tpt >= search_tbl->expected_tpt[index]) break; } search_tbl->current_rate = - iwl4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(priv, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; } tbl->action++; - if (tbl->action > IWL_SISO_SWITCH_GI) - tbl->action = IWL_SISO_SWITCH_ANTENNA1; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; if (tbl->action == start_action) break; @@ -1509,8 +1509,8 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, out: lq_sta->search_better_tbl = 1; tbl->action++; - if (tbl->action > IWL_SISO_SWITCH_GI) - tbl->action = IWL_SISO_SWITCH_ANTENNA1; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; if (update_search_tbl_counter) search_tbl->action = tbl->action; @@ -1520,19 +1520,19 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, /* * Try to switch to new modulation mode from MIMO2 */ -static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) { s8 is_green = lq_sta->is_green; - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct iwl_scale_tbl_info *search_tbl = + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct iwl_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *window = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct iwl_scale_tbl_info) - - (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; u8 valid_tx_ant = priv->hw_params.valid_tx_ant; u8 tx_chains_num = priv->hw_params.tx_chains_num; @@ -1543,43 +1543,43 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, for (;;) { lq_sta->action_counter++; switch (tbl->action) { - case IWL_MIMO2_SWITCH_ANTENNA1: - case IWL_MIMO2_SWITCH_ANTENNA2: - IWL_DEBUG_RATE(priv, "LQ: MIMO2 toggle Antennas\n"); + case IL_MIMO2_SWITCH_ANTENNA1: + case IL_MIMO2_SWITCH_ANTENNA2: + IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle Antennas\n"); if (tx_chains_num <= 2) break; - if (window->success_ratio >= IWL_RS_GOOD_RATIO) + if (window->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); - if (iwl4965_rs_toggle_antenna(valid_tx_ant, + if (il4965_rs_toggle_antenna(valid_tx_ant, &search_tbl->current_rate, search_tbl)) { update_search_tbl_counter = 1; goto out; } break; - case IWL_MIMO2_SWITCH_SISO_A: - case IWL_MIMO2_SWITCH_SISO_B: - case IWL_MIMO2_SWITCH_SISO_C: - IWL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n"); + case IL_MIMO2_SWITCH_SISO_A: + case IL_MIMO2_SWITCH_SISO_B: + case IL_MIMO2_SWITCH_SISO_C: + IL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n"); /* Set up new search table for SISO */ memcpy(search_tbl, tbl, sz); - if (tbl->action == IWL_MIMO2_SWITCH_SISO_A) + if (tbl->action == IL_MIMO2_SWITCH_SISO_A) search_tbl->ant_type = ANT_A; - else if (tbl->action == IWL_MIMO2_SWITCH_SISO_B) + else if (tbl->action == IL_MIMO2_SWITCH_SISO_B) search_tbl->ant_type = ANT_B; else search_tbl->ant_type = ANT_C; - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, + if (!il4965_rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) break; - ret = iwl4965_rs_switch_to_siso(priv, lq_sta, + ret = il4965_rs_switch_to_siso(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) @@ -1587,7 +1587,7 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, break; - case IWL_MIMO2_SWITCH_GI: + case IL_MIMO2_SWITCH_GI: if (!tbl->is_ht40 && !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; @@ -1595,12 +1595,12 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IWL_DEBUG_RATE(priv, "LQ: MIMO2 toggle SGI/NGI\n"); + IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle SGI/NGI\n"); /* Set up new search table for MIMO2 */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = !tbl->is_SGI; - iwl4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); /* * If active table already uses the fastest possible * modulation (dual stream with short guard interval), @@ -1613,15 +1613,15 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, break; } search_tbl->current_rate = - iwl4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(priv, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; } tbl->action++; - if (tbl->action > IWL_MIMO2_SWITCH_GI) - tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; if (tbl->action == start_action) break; @@ -1631,8 +1631,8 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, out: lq_sta->search_better_tbl = 1; tbl->action++; - if (tbl->action > IWL_MIMO2_SWITCH_GI) - tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; if (update_search_tbl_counter) search_tbl->action = tbl->action; @@ -1648,13 +1648,13 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, * 3) elapsed time in this mode (not used, for now) */ static void -iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) +il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) { - struct iwl_scale_tbl_info *tbl; + struct il_scale_tbl_info *tbl; int i; int active_tbl; int flush_interval_passed = 0; - struct iwl_priv *priv; + struct il_priv *priv; priv = lq_sta->drv; active_tbl = lq_sta->active_tbl; @@ -1669,7 +1669,7 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) flush_interval_passed = time_after(jiffies, (unsigned long)(lq_sta->flush_timer + - IWL_RATE_SCALE_FLUSH_INTVL)); + IL_RATE_SCALE_FLUSH_INTVL)); /* * Check if we should allow search for new modulation mode. @@ -1684,7 +1684,7 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) (lq_sta->total_success > lq_sta->max_success_limit) || ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) && (flush_interval_passed))) { - IWL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:", + IL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, flush_interval_passed); @@ -1707,10 +1707,10 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) lq_sta->table_count_limit) { lq_sta->table_count = 0; - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "LQ: stay in table clear win\n"); - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &(tbl->win[i])); } } @@ -1719,8 +1719,8 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) * bitmaps and stats in active table (this will become the new * "search" table). */ if (!lq_sta->stay_in_tbl) { - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &(tbl->win[i])); } } @@ -1730,18 +1730,18 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) * setup rate table in uCode * return rate_n_flags as used in the table */ -static u32 iwl4965_rs_update_rate_tbl(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, - struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl, +static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, + struct il_rxon_context *ctx, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, int index, u8 is_green) { u32 rate; /* Update uCode's rate table. */ - rate = iwl4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); - iwl4965_rs_fill_link_cmd(priv, lq_sta, rate); - iwl_legacy_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); + rate = il4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); + il4965_rs_fill_link_cmd(priv, lq_sta, rate); + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); return rate; } @@ -1749,28 +1749,28 @@ static u32 iwl4965_rs_update_rate_tbl(struct iwl_priv *priv, /* * Do rate scaling and search for new modulation mode. */ -static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *priv, struct sk_buff *skb, struct ieee80211_sta *sta, - struct iwl_lq_sta *lq_sta) + struct il_lq_sta *lq_sta) { struct ieee80211_hw *hw = priv->hw; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - int low = IWL_RATE_INVALID; - int high = IWL_RATE_INVALID; + int low = IL_RATE_INVALID; + int high = IL_RATE_INVALID; int index; int i; - struct iwl_rate_scale_data *window = NULL; - int current_tpt = IWL_INVALID_VALUE; - int low_tpt = IWL_INVALID_VALUE; - int high_tpt = IWL_INVALID_VALUE; + struct il_rate_scale_data *window = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; u32 fail_count; s8 scale_action = 0; u16 rate_mask; u8 update_lq = 0; - struct iwl_scale_tbl_info *tbl, *tbl1; + struct il_scale_tbl_info *tbl, *tbl1; u16 rate_scale_index_msk = 0; u32 rate; u8 is_green = 0; @@ -1779,11 +1779,11 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, u16 high_low; s32 sr; u8 tid = MAX_TID_COUNT; - struct iwl_tid_data *tid_data; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_tid_data *tid_data; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; - IWL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ @@ -1796,10 +1796,10 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; - tid = iwl4965_rs_tl_add_packet(lq_sta, hdr); + tid = il4965_rs_tl_add_packet(lq_sta, hdr); if ((tid != MAX_TID_COUNT) && (lq_sta->tx_agg_tid_en & (1 << tid))) { tid_data = &priv->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IWL_AGG_OFF) + if (tid_data->agg.state == IL_AGG_OFF) lq_sta->is_agg = 0; else lq_sta->is_agg = 1; @@ -1820,26 +1820,26 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, if (is_legacy(tbl->lq_type)) lq_sta->is_green = 0; else - lq_sta->is_green = iwl4965_rs_use_green(sta); + lq_sta->is_green = il4965_rs_use_green(sta); is_green = lq_sta->is_green; /* current tx rate */ index = lq_sta->last_txrate_idx; - IWL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index, + IL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index, tbl->lq_type); /* rates available for this association, and for modulation mode */ - rate_mask = iwl4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); + rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - IWL_DEBUG_RATE(priv, "mask 0x%04X\n", rate_mask); + IL_DEBUG_RATE(priv, "mask 0x%04X\n", rate_mask); /* mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { if (lq_sta->band == IEEE80211_BAND_5GHZ) /* supp_rates has no CCK bits in A mode */ rate_scale_index_msk = (u16) (rate_mask & - (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else rate_scale_index_msk = (u16) (rate_mask & lq_sta->supp_rates); @@ -1851,15 +1851,15 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, rate_scale_index_msk = rate_mask; if (!((1 << index) & rate_scale_index_msk)) { - IWL_ERR(priv, "Current Rate is not valid\n"); + IL_ERR(priv, "Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ tbl->lq_type = LQ_NONE; lq_sta->search_better_tbl = 0; tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ - index = iwl4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = iwl4965_rs_update_rate_tbl(priv, ctx, lq_sta, + index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, tbl, index, is_green); } return; @@ -1867,7 +1867,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* Get expected throughput table and history window for current rate */ if (!tbl->expected_tpt) { - IWL_ERR(priv, "tbl->expected_tpt is NULL\n"); + IL_ERR(priv, "tbl->expected_tpt is NULL\n"); return; } @@ -1890,18 +1890,18 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * in current association (use new rate found above). */ fail_count = window->counter - window->success_counter; - if ((fail_count < IWL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) { - IWL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d " + if ((fail_count < IL_RATE_MIN_FAILURE_TH) && + (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { + IL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); /* Can't calculate this yet; not enough history */ - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; /* Should we stay with this modulation mode, * or search for a new one? */ - iwl4965_rs_stay_in_table(lq_sta, false); + il4965_rs_stay_in_table(lq_sta, false); goto out; } @@ -1909,7 +1909,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * actual average throughput */ if (window->average_tpt != ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { - IWL_ERR(priv, + IL_ERR(priv, "expected_tpt should have been calculated by now\n"); window->average_tpt = ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128); @@ -1922,7 +1922,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * continuing to use the setup that we've been trying. */ if (window->average_tpt > lq_sta->last_tpt) { - IWL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE " + IL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1938,7 +1938,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* Else poor success; go back to mode in "active" table */ } else { - IWL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE " + IL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1952,7 +1952,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, tbl = &(lq_sta->lq_info[active_tbl]); /* Revert to "active" rate and throughput info */ - index = iwl4965_hwrate_to_plcp_idx(tbl->current_rate); + index = il4965_hwrate_to_plcp_idx(tbl->current_rate); current_tpt = lq_sta->last_tpt; /* Need to set up a new rate table in uCode */ @@ -1968,7 +1968,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = iwl4965_rs_get_adjacent_rate(priv, index, + high_low = il4965_rs_get_adjacent_rate(priv, index, rate_scale_index_msk, tbl->lq_type); low = high_low & 0xff; @@ -1977,39 +1977,39 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* If user set max rate, dont allow higher than user constrain */ if ((lq_sta->max_rate_idx != -1) && (lq_sta->max_rate_idx < high)) - high = IWL_RATE_INVALID; + high = IL_RATE_INVALID; sr = window->success_ratio; /* Collect measured throughputs for current and adjacent rates */ current_tpt = window->average_tpt; - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) low_tpt = tbl->win[low].average_tpt; - if (high != IWL_RATE_INVALID) + if (high != IL_RATE_INVALID) high_tpt = tbl->win[high].average_tpt; scale_action = 0; /* Too many failures, decrease rate */ - if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) { - IWL_DEBUG_RATE(priv, + if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { + IL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates; try increase. */ - } else if ((low_tpt == IWL_INVALID_VALUE) && - (high_tpt == IWL_INVALID_VALUE)) { + } else if ((low_tpt == IL_INVALID_VALUE) && + (high_tpt == IL_INVALID_VALUE)) { - if (high != IWL_RATE_INVALID && sr >= IWL_RATE_INCREASE_TH) + if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH) scale_action = 1; - else if (low != IWL_RATE_INVALID) + else if (low != IL_RATE_INVALID) scale_action = 0; } /* Both adjacent throughputs are measured, but neither one has better * throughput; we're using the best rate, don't change it! */ - else if ((low_tpt != IWL_INVALID_VALUE) && - (high_tpt != IWL_INVALID_VALUE) && + else if ((low_tpt != IL_INVALID_VALUE) && + (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) scale_action = 0; @@ -2018,23 +2018,23 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * and may have better performance. */ else { /* Higher adjacent rate's throughput is measured */ - if (high_tpt != IWL_INVALID_VALUE) { + if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ if (high_tpt > current_tpt && - sr >= IWL_RATE_INCREASE_TH) { + sr >= IL_RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; } /* Lower adjacent rate's throughput is measured */ - } else if (low_tpt != IWL_INVALID_VALUE) { + } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "decrease rate because of low tpt\n"); scale_action = -1; - } else if (sr >= IWL_RATE_INCREASE_TH) { + } else if (sr >= IL_RATE_INCREASE_TH) { scale_action = 1; } } @@ -2042,15 +2042,15 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IWL_RATE_INVALID) && - ((sr > IWL_RATE_HIGH_TH) || + if ((scale_action == -1) && (low != IL_RATE_INVALID) && + ((sr > IL_RATE_HIGH_TH) || (current_tpt > (100 * tbl->expected_tpt[low])))) scale_action = 0; switch (scale_action) { case -1: /* Decrease starting rate, update uCode's rate table */ - if (low != IWL_RATE_INVALID) { + if (low != IL_RATE_INVALID) { update_lq = 1; index = low; } @@ -2058,7 +2058,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, break; case 1: /* Increase starting rate, update uCode's rate table */ - if (high != IWL_RATE_INVALID) { + if (high != IL_RATE_INVALID) { update_lq = 1; index = high; } @@ -2070,19 +2070,19 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, break; } - IWL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d " + IL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d " "high %d type %d\n", index, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) - rate = iwl4965_rs_update_rate_tbl(priv, ctx, lq_sta, + rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, tbl, index, is_green); /* Should we stay with this modulation mode, * or search for a new one? */ - iwl4965_rs_stay_in_table(lq_sta, false); + il4965_rs_stay_in_table(lq_sta, false); /* * Search for new modulation mode if we're: @@ -2098,32 +2098,32 @@ lq_update: /* Select a new "search" modulation mode to try. * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) - iwl4965_rs_move_legacy_other(priv, lq_sta, + il4965_rs_move_legacy_other(priv, lq_sta, conf, sta, index); else if (is_siso(tbl->lq_type)) - iwl4965_rs_move_siso_to_other(priv, lq_sta, + il4965_rs_move_siso_to_other(priv, lq_sta, conf, sta, index); else /* (is_mimo2(tbl->lq_type)) */ - iwl4965_rs_move_mimo2_to_other(priv, lq_sta, + il4965_rs_move_mimo2_to_other(priv, lq_sta, conf, sta, index); /* If new "search" mode was selected, set up in uCode table */ if (lq_sta->search_better_tbl) { /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &(tbl->win[i])); /* Use new "search" start rate */ - index = iwl4965_hwrate_to_plcp_idx(tbl->current_rate); + index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n", tbl->current_rate, index); - iwl4965_rs_fill_link_cmd(priv, lq_sta, + il4965_rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); - iwl_legacy_send_lq_cmd(priv, ctx, + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); } else done_search = 1; @@ -2138,8 +2138,8 @@ lq_update: tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && lq_sta->action_counter > tbl1->max_search) { - IWL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); - iwl4965_rs_set_stay_in_table(priv, 1, lq_sta); + IL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); + il4965_rs_set_stay_in_table(priv, 1, lq_sta); } /* If we're in an HT mode, and all 3 mode switch actions @@ -2147,32 +2147,32 @@ lq_update: * mode for a while before next round of mode comparisons. */ if (lq_sta->enable_counter && (lq_sta->action_counter >= tbl1->max_search)) { - if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && + if ((lq_sta->last_tpt > IL_AGG_TPT_THREHOLD) && (lq_sta->tx_agg_tid_en & (1 << tid)) && (tid != MAX_TID_COUNT)) { tid_data = &priv->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IWL_AGG_OFF) { - IWL_DEBUG_RATE(priv, + if (tid_data->agg.state == IL_AGG_OFF) { + IL_DEBUG_RATE(priv, "try to aggregate tid %d\n", tid); - iwl4965_rs_tl_turn_on_agg(priv, tid, + il4965_rs_tl_turn_on_agg(priv, tid, lq_sta, sta); } } - iwl4965_rs_set_stay_in_table(priv, 0, lq_sta); + il4965_rs_set_stay_in_table(priv, 0, lq_sta); } } out: - tbl->current_rate = iwl4965_rate_n_flags_from_tbl(priv, tbl, + tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); i = index; lq_sta->last_txrate_idx = i; } /** - * iwl4965_rs_initialize_lq - Initialize a station's hardware rate table + * il4965_rs_initialize_lq - Initialize a station's hardware rate table * * The uCode's station table contains a table of fallback rates * for automatic fallback during transmission. @@ -2185,20 +2185,20 @@ out: * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ -static void iwl4965_rs_initialize_lq(struct iwl_priv *priv, +static void il4965_rs_initialize_lq(struct il_priv *priv, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct iwl_lq_sta *lq_sta) + struct il_lq_sta *lq_sta) { - struct iwl_scale_tbl_info *tbl; + struct il_scale_tbl_info *tbl; int rate_idx; int i; u32 rate; - u8 use_green = iwl4965_rs_use_green(sta); + u8 use_green = il4965_rs_use_green(sta); u8 active_tbl = 0; u8 valid_tx_ant; - struct iwl_station_priv *sta_priv; - struct iwl_rxon_context *ctx; + struct il_station_priv *sta_priv; + struct il_rxon_context *ctx; if (!sta || !lq_sta) return; @@ -2217,56 +2217,56 @@ static void iwl4965_rs_initialize_lq(struct iwl_priv *priv, tbl = &(lq_sta->lq_info[active_tbl]); - if ((i < 0) || (i >= IWL_RATE_COUNT)) + if ((i < 0) || (i >= IL_RATE_COUNT)) i = 0; rate = iwlegacy_rates[i].plcp; - tbl->ant_type = iwl4965_first_antenna(valid_tx_ant); + tbl->ant_type = il4965_first_antenna(valid_tx_ant); rate |= tbl->ant_type << RATE_MCS_ANT_POS; - if (i >= IWL_FIRST_CCK_RATE && i <= IWL_LAST_CCK_RATE) + if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) rate |= RATE_MCS_CCK_MSK; - iwl4965_rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) - iwl4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); + il4965_rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); + if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) + il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); - rate = iwl4965_rate_n_flags_from_tbl(priv, tbl, rate_idx, use_green); + rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate_idx, use_green); tbl->current_rate = rate; - iwl4965_rs_set_expected_tpt_table(lq_sta, tbl); - iwl4965_rs_fill_link_cmd(NULL, lq_sta, rate); + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + il4965_rs_fill_link_cmd(NULL, lq_sta, rate); priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; - iwl_legacy_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_SYNC, true); + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_SYNC, true); } static void -iwl4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, +il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, struct ieee80211_tx_rate_control *txrc) { struct sk_buff *skb = txrc->skb; struct ieee80211_supported_band *sband = txrc->sband; - struct iwl_priv *priv __maybe_unused = (struct iwl_priv *)priv_r; + struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct iwl_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = priv_sta; int rate_idx; - IWL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { lq_sta->max_rate_idx = txrc->max_rate_idx; if ((sband->band == IEEE80211_BAND_5GHZ) && (lq_sta->max_rate_idx != -1)) - lq_sta->max_rate_idx += IWL_FIRST_OFDM_RATE; + lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; if ((lq_sta->max_rate_idx < 0) || - (lq_sta->max_rate_idx >= IWL_RATE_COUNT)) + (lq_sta->max_rate_idx >= IL_RATE_COUNT)) lq_sta->max_rate_idx = -1; } /* Treat uninitialized rate scaling data same as non-existing. */ if (lq_sta && !lq_sta->drv) { - IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); + IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); priv_sta = NULL; } @@ -2280,11 +2280,11 @@ iwl4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, rate_idx = lq_sta->last_txrate_idx; if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { - rate_idx -= IWL_FIRST_OFDM_RATE; + rate_idx -= IL_FIRST_OFDM_RATE; /* 6M and 9M shared same MCS index */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; - if (iwl4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - IWL_RATE_MIMO2_6M_PLCP) + if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= + IL_RATE_MIMO2_6M_PLCP) rate_idx = rate_idx + MCS_INDEX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) @@ -2301,29 +2301,29 @@ iwl4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ - if ((rate_idx < 0) || (rate_idx >= IWL_RATE_COUNT_LEGACY) || + if ((rate_idx < 0) || (rate_idx >= IL_RATE_COUNT_LEGACY) || ((sband->band == IEEE80211_BAND_5GHZ) && - (rate_idx < IWL_FIRST_OFDM_RATE))) + (rate_idx < IL_FIRST_OFDM_RATE))) rate_idx = rate_lowest_index(sband, sta); /* On valid 5 GHz rate, adjust index */ else if (sband->band == IEEE80211_BAND_5GHZ) - rate_idx -= IWL_FIRST_OFDM_RATE; + rate_idx -= IL_FIRST_OFDM_RATE; info->control.rates[0].flags = 0; } info->control.rates[0].idx = rate_idx; } -static void *iwl4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, +static void *il4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, gfp_t gfp) { - struct iwl_lq_sta *lq_sta; - struct iwl_station_priv *sta_priv = - (struct iwl_station_priv *) sta->drv_priv; - struct iwl_priv *priv; + struct il_lq_sta *lq_sta; + struct il_station_priv *sta_priv = + (struct il_station_priv *) sta->drv_priv; + struct il_priv *priv; - priv = (struct iwl_priv *)priv_rate; - IWL_DEBUG_RATE(priv, "create station rate scale window\n"); + priv = (struct il_priv *)priv_rate; + IL_DEBUG_RATE(priv, "create station rate scale window\n"); lq_sta = &sta_priv->lq_sta; @@ -2334,7 +2334,7 @@ static void *iwl4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, * Called after adding a new station to initialize rate scaling */ void -iwl4965_rs_rate_init(struct iwl_priv *priv, +il4965_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id) { @@ -2342,11 +2342,11 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, struct ieee80211_hw *hw = priv->hw; struct ieee80211_conf *conf = &priv->hw->conf; struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - struct iwl_station_priv *sta_priv; - struct iwl_lq_sta *lq_sta; + struct il_station_priv *sta_priv; + struct il_lq_sta *lq_sta; struct ieee80211_supported_band *sband; - sta_priv = (struct iwl_station_priv *) sta->drv_priv; + sta_priv = (struct il_station_priv *) sta->drv_priv; lq_sta = &sta_priv->lq_sta; sband = hw->wiphy->bands[conf->channel->band]; @@ -2354,18 +2354,18 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, lq_sta->lq.sta_id = sta_id; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); - IWL_DEBUG_RATE(priv, "LQ:" + IL_DEBUG_RATE(priv, "LQ:" "*** rate scale station global init for station %d ***\n", sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -2375,8 +2375,8 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, lq_sta->is_dup = 0; lq_sta->max_rate_idx = -1; - lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; - lq_sta->is_green = iwl4965_rs_use_green(sta); + lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; + lq_sta->is_green = il4965_rs_use_green(sta); lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); lq_sta->band = priv->band; /* @@ -2386,69 +2386,69 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; lq_sta->active_siso_rate &= ~((u16)0x2); - lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE; + lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; /* Same here */ lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; lq_sta->active_mimo2_rate &= ~((u16)0x2); - lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE; + lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; /* These values will be overridden later */ lq_sta->lq.general_params.single_stream_ant_msk = - iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(priv->hw_params.valid_tx_ant); lq_sta->lq.general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant & - ~iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + ~il4965_first_antenna(priv->hw_params.valid_tx_ant); if (!lq_sta->lq.general_params.dual_stream_ant_msk) { lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; - } else if (iwl4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { lq_sta->lq.general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant; } /* as default allow aggregation for all tids */ - lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; + lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; lq_sta->drv = priv; /* Set last_txrate_idx to lowest rate */ lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); if (sband->band == IEEE80211_BAND_5GHZ) - lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; + lq_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; lq_sta->is_agg = 0; #ifdef CONFIG_MAC80211_DEBUGFS lq_sta->dbg_fixed_rate = 0; #endif - iwl4965_rs_initialize_lq(priv, conf, sta, lq_sta); + il4965_rs_initialize_lq(priv, conf, sta, lq_sta); } -static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, u32 new_rate) +static void il4965_rs_fill_link_cmd(struct il_priv *priv, + struct il_lq_sta *lq_sta, u32 new_rate) { - struct iwl_scale_tbl_info tbl_type; + struct il_scale_tbl_info tbl_type; int index = 0; int rate_idx; int repeat_rate = 0; u8 ant_toggle_cnt = 0; u8 use_ht_possible = 1; u8 valid_tx_ant = 0; - struct iwl_link_quality_cmd *lq_cmd = &lq_sta->lq; + struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; /* Override starting rate (index 0) if needed for debug purposes */ - iwl4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); /* Interpret new_rate (rate_n_flags) */ - iwl4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, &rate_idx); /* How many times should we repeat the initial rate? */ if (is_legacy(tbl_type.lq_type)) { ant_toggle_cnt = 1; - repeat_rate = IWL_NUMBER_TRY; + repeat_rate = IL_NUMBER_TRY; } else { - repeat_rate = IWL_HT_NUMBER_TRY; + repeat_rate = IL_HT_NUMBER_TRY; } lq_cmd->general_params.mimo_delimiter = @@ -2457,10 +2457,10 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, /* Fill 1st table entry (index 0) */ lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); - if (iwl4965_num_of_ant(tbl_type.ant_type) == 1) { + if (il4965_num_of_ant(tbl_type.ant_type) == 1) { lq_cmd->general_params.single_stream_ant_msk = tbl_type.ant_type; - } else if (iwl4965_num_of_ant(tbl_type.ant_type) == 2) { + } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { lq_cmd->general_params.dual_stream_ant_msk = tbl_type.ant_type; } /* otherwise we don't modify the existing value */ @@ -2473,20 +2473,20 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, /* Fill rest of rate table */ while (index < LINK_QUAL_MAX_RETRY_NUM) { /* Repeat initial/next rate. - * For legacy IWL_NUMBER_TRY == 1, this loop will not execute. - * For HT IWL_HT_NUMBER_TRY == 3, this executes twice. */ + * For legacy IL_NUMBER_TRY == 1, this loop will not execute. + * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ while (repeat_rate > 0 && (index < LINK_QUAL_MAX_RETRY_NUM)) { if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; else if (priv && - iwl4965_rs_toggle_antenna(valid_tx_ant, + il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; } /* Override next rate if needed for debug purposes */ - iwl4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); /* Fill next table entry */ lq_cmd->rs_table[index].rate_n_flags = @@ -2495,18 +2495,18 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, index++; } - iwl4965_rs_get_tbl_info_from_mcs(new_rate, + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, &rate_idx); /* Indicate to uCode which entries might be MIMO. * If initial rate was MIMO, this will finally end up - * as (IWL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ + * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ if (is_mimo(tbl_type.lq_type)) lq_cmd->general_params.mimo_delimiter = index; /* Get next rate */ - new_rate = iwl4965_rs_get_lower_rate(lq_sta, + new_rate = il4965_rs_get_lower_rate(lq_sta, &tbl_type, rate_idx, use_ht_possible); @@ -2515,21 +2515,21 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; else if (priv && - iwl4965_rs_toggle_antenna(valid_tx_ant, + il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; - repeat_rate = IWL_NUMBER_TRY; + repeat_rate = IL_NUMBER_TRY; } else { - repeat_rate = IWL_HT_NUMBER_TRY; + repeat_rate = IL_HT_NUMBER_TRY; } /* Don't allow HT rates after next pass. - * iwl4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ + * il4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ use_ht_possible = 0; /* Override next rate if needed for debug purposes */ - iwl4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); /* Fill next table entry */ lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); @@ -2546,36 +2546,36 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, } static void -*iwl4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } /* rate scale requires free function to be implemented */ -static void iwl4965_rs_free(void *priv_rate) +static void il4965_rs_free(void *priv_rate) { return; } -static void iwl4965_rs_free_sta(void *priv_r, struct ieee80211_sta *sta, +static void il4965_rs_free_sta(void *priv_r, struct ieee80211_sta *sta, void *priv_sta) { - struct iwl_priv *priv __maybe_unused = priv_r; + struct il_priv *priv __maybe_unused = priv_r; - IWL_DEBUG_RATE(priv, "enter\n"); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "leave\n"); } #ifdef CONFIG_MAC80211_DEBUGFS -static int iwl4965_open_file_generic(struct inode *inode, struct file *file) +static int il4965_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index) { - struct iwl_priv *priv; + struct il_priv *priv; u8 valid_tx_ant; u8 ant_sel_tx; @@ -2587,30 +2587,30 @@ static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, >> RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; - IWL_DEBUG_RATE(priv, "Fixed rate ON\n"); + IL_DEBUG_RATE(priv, "Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IWL_ERR(priv, + IL_ERR(priv, "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); - IWL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); } } else { - IWL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); } } -static ssize_t iwl4965_rs_sta_dbgfs_scale_table_write(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_lq_sta *lq_sta = file->private_data; - struct iwl_priv *priv; + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *priv; char buf[64]; size_t buf_size; u32 parsed_rate; - struct iwl_station_priv *sta_priv = - container_of(lq_sta, struct iwl_station_priv, lq_sta); - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = + container_of(lq_sta, struct il_station_priv, lq_sta); + struct il_rxon_context *ctx = sta_priv->common.ctx; priv = lq_sta->drv; memset(buf, 0, sizeof(buf)); @@ -2627,19 +2627,19 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", + IL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { - iwl4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); - iwl_legacy_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, + il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); + il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, false); } return count; } -static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char *buff; @@ -2648,9 +2648,9 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, int index = 0; ssize_t ret; - struct iwl_lq_sta *lq_sta = file->private_data; - struct iwl_priv *priv; - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *priv; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); priv = lq_sta->drv; buff = kmalloc(1024, GFP_KERNEL); @@ -2702,19 +2702,19 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, lq_sta->lq.general_params.start_rate_index[3]); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - index = iwl4965_hwrate_to_plcp_idx( + index = il4965_hwrate_to_plcp_idx( le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); if (is_legacy(tbl->lq_type)) { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - iwl_rate_mcs[index].mbps); + il_rate_mcs[index].mbps); } else { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps (%s)\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - iwl_rate_mcs[index].mbps, iwl_rate_mcs[index].mcs); + il_rate_mcs[index].mbps, il_rate_mcs[index].mcs); } } @@ -2724,12 +2724,12 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_scale_table_ops = { - .write = iwl4965_rs_sta_dbgfs_scale_table_write, - .read = iwl4965_rs_sta_dbgfs_scale_table_read, - .open = iwl4965_open_file_generic, + .write = il4965_rs_sta_dbgfs_scale_table_write, + .read = il4965_rs_sta_dbgfs_scale_table_read, + .open = il4965_open_file_generic, .llseek = default_llseek, }; -static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char *buff; @@ -2737,7 +2737,7 @@ static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, int i, j; ssize_t ret; - struct iwl_lq_sta *lq_sta = file->private_data; + struct il_lq_sta *lq_sta = file->private_data; buff = kmalloc(1024, GFP_KERNEL); if (!buff) @@ -2754,7 +2754,7 @@ static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, lq_sta->lq_info[i].is_dup, lq_sta->is_green, lq_sta->lq_info[i].current_rate); - for (j = 0; j < IWL_RATE_COUNT; j++) { + for (j = 0; j < IL_RATE_COUNT; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->lq_info[i].win[j].counter, @@ -2768,21 +2768,21 @@ static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = iwl4965_rs_sta_dbgfs_stats_table_read, - .open = iwl4965_open_file_generic, + .read = il4965_rs_sta_dbgfs_stats_table_read, + .open = il4965_open_file_generic, .llseek = default_llseek, }; -static ssize_t iwl4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char buff[120]; int desc = 0; ssize_t ret; - struct iwl_lq_sta *lq_sta = file->private_data; - struct iwl_priv *priv; - struct iwl_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *priv; + struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; priv = lq_sta->drv; @@ -2800,15 +2800,15 @@ static ssize_t iwl4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { - .read = iwl4965_rs_sta_dbgfs_rate_scale_data_read, - .open = iwl4965_open_file_generic, + .read = il4965_rs_sta_dbgfs_rate_scale_data_read, + .open = il4965_open_file_generic, .llseek = default_llseek, }; -static void iwl4965_rs_add_debugfs(void *priv, void *priv_sta, +static void il4965_rs_add_debugfs(void *priv, void *priv_sta, struct dentry *dir) { - struct iwl_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = priv_sta; lq_sta->rs_sta_dbgfs_scale_table_file = debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, lq_sta, &rs_sta_dbgfs_scale_table_ops); @@ -2824,9 +2824,9 @@ static void iwl4965_rs_add_debugfs(void *priv, void *priv_sta, } -static void iwl4965_rs_remove_debugfs(void *priv, void *priv_sta) +static void il4965_rs_remove_debugfs(void *priv, void *priv_sta) { - struct iwl_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = priv_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); @@ -2840,32 +2840,32 @@ static void iwl4965_rs_remove_debugfs(void *priv, void *priv_sta) * station is added we ignore it. */ static void -iwl4965_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, +il4965_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta) { } static struct rate_control_ops rs_4965_ops = { .module = NULL, .name = IWL4965_RS_NAME, - .tx_status = iwl4965_rs_tx_status, - .get_rate = iwl4965_rs_get_rate, - .rate_init = iwl4965_rs_rate_init_stub, - .alloc = iwl4965_rs_alloc, - .free = iwl4965_rs_free, - .alloc_sta = iwl4965_rs_alloc_sta, - .free_sta = iwl4965_rs_free_sta, + .tx_status = il4965_rs_tx_status, + .get_rate = il4965_rs_get_rate, + .rate_init = il4965_rs_rate_init_stub, + .alloc = il4965_rs_alloc, + .free = il4965_rs_free, + .alloc_sta = il4965_rs_alloc_sta, + .free_sta = il4965_rs_free_sta, #ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = iwl4965_rs_add_debugfs, - .remove_sta_debugfs = iwl4965_rs_remove_debugfs, + .add_sta_debugfs = il4965_rs_add_debugfs, + .remove_sta_debugfs = il4965_rs_remove_debugfs, #endif }; -int iwl4965_rate_control_register(void) +int il4965_rate_control_register(void) { return ieee80211_rate_control_register(&rs_4965_ops); } -void iwl4965_rate_control_unregister(void) +void il4965_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_4965_ops); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 2b144bb..47cbe56 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -41,31 +41,31 @@ #include "iwl-4965-hw.h" #include "iwl-4965.h" -void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_missed_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_missed_beacon_notif *missed_beacon; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_missed_beacon_notif *missed_beacon; missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > priv->missed_beacon_threshold) { - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "missed bcn cnsq %d totl %d rcd %d expctd %d\n", le32_to_cpu(missed_beacon->consecutive_missed_beacons), le32_to_cpu(missed_beacon->total_missed_becons), le32_to_cpu(missed_beacon->num_recvd_beacons), le32_to_cpu(missed_beacon->num_expected_beacons)); if (!test_bit(STATUS_SCANNING, &priv->status)) - iwl4965_init_sensitivity(priv); + il4965_init_sensitivity(priv); } } /* Calculate noise level, based on measurements during network silence just * before arriving beacon. This measurement can be done only if we know * exactly when to expect beacons, therefore only when we're associated. */ -static void iwl4965_rx_calc_noise(struct iwl_priv *priv) +static void il4965_rx_calc_noise(struct il_priv *priv) { struct statistics_rx_non_phy *rx_info; int num_active_rx = 0; @@ -98,9 +98,9 @@ static void iwl4965_rx_calc_noise(struct iwl_priv *priv) if (num_active_rx) last_rx_noise = (total_silence / num_active_rx) - 107; else - last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; + last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", + IL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, bcn_silence_b, bcn_silence_c, last_rx_noise); } @@ -111,7 +111,7 @@ static void iwl4965_rx_calc_noise(struct iwl_priv *priv) * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void iwl4965_accumulative_statistics(struct iwl_priv *priv, +static void il4965_accumulative_statistics(struct il_priv *priv, __le32 *stats) { int i, size; @@ -123,7 +123,7 @@ static void iwl4965_accumulative_statistics(struct iwl_priv *priv, prev_stats = (__le32 *)&priv->_4965.statistics; accum_stats = (u32 *)&priv->_4965.accum_statistics; - size = sizeof(struct iwl_notif_statistics); + size = sizeof(struct il_notif_statistics); general = &priv->_4965.statistics.general.common; accum_general = &priv->_4965.accum_statistics.general.common; tx = &priv->_4965.statistics.tx; @@ -151,15 +151,15 @@ static void iwl4965_accumulative_statistics(struct iwl_priv *priv, #define REG_RECALIB_PERIOD (60) -void iwl4965_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { int change; - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); - IWL_DEBUG_RX(priv, + IL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct iwl_notif_statistics), + (int)sizeof(struct il_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); @@ -170,7 +170,7 @@ void iwl4965_rx_statistics(struct iwl_priv *priv, (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - iwl4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); + il4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); #endif /* TODO: reading some of statistics is unneeded */ @@ -188,28 +188,28 @@ void iwl4965_rx_statistics(struct iwl_priv *priv, if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { - iwl4965_rx_calc_noise(priv); + il4965_rx_calc_noise(priv); queue_work(priv->workqueue, &priv->run_time_calib_work); } if (priv->cfg->ops->lib->temp_ops.temperature && change) priv->cfg->ops->lib->temp_ops.temperature(priv); } -void iwl4965_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS memset(&priv->_4965.accum_statistics, 0, - sizeof(struct iwl_notif_statistics)); + sizeof(struct il_notif_statistics)); memset(&priv->_4965.delta_statistics, 0, - sizeof(struct iwl_notif_statistics)); + sizeof(struct il_notif_statistics)); memset(&priv->_4965.max_delta, 0, - sizeof(struct iwl_notif_statistics)); + sizeof(struct il_notif_statistics)); #endif - IWL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(priv, "Statistics have been cleared\n"); } - iwl4965_rx_statistics(priv, rxb); + il4965_rx_statistics(priv, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index a262c23..3ac9aef 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -34,45 +34,45 @@ #include "iwl-sta.h" #include "iwl-4965.h" -static struct iwl_link_quality_cmd * -iwl4965_sta_alloc_lq(struct iwl_priv *priv, u8 sta_id) +static struct il_link_quality_cmd * +il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) { int i, r; - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; u32 rate_flags = 0; __le32 rate_n_flags; - link_cmd = kzalloc(sizeof(struct iwl_link_quality_cmd), GFP_KERNEL); + link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); if (!link_cmd) { - IWL_ERR(priv, "Unable to allocate memory for LQ cmd.\n"); + IL_ERR(priv, "Unable to allocate memory for LQ cmd.\n"); return NULL; } /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ if (priv->band == IEEE80211_BAND_5GHZ) - r = IWL_RATE_6M_INDEX; + r = IL_RATE_6M_INDEX; else - r = IWL_RATE_1M_INDEX; + r = IL_RATE_1M_INDEX; - if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) + if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; - rate_flags |= iwl4965_first_antenna(priv->hw_params.valid_tx_ant) << + rate_flags |= il4965_first_antenna(priv->hw_params.valid_tx_ant) << RATE_MCS_ANT_POS; - rate_n_flags = iwl4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, + rate_n_flags = il4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, rate_flags); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; link_cmd->general_params.single_stream_ant_msk = - iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(priv->hw_params.valid_tx_ant); link_cmd->general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant & - ~iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + ~il4965_first_antenna(priv->hw_params.valid_tx_ant); if (!link_cmd->general_params.dual_stream_ant_msk) { link_cmd->general_params.dual_stream_ant_msk = ANT_AB; - } else if (iwl4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { link_cmd->general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant; } @@ -87,25 +87,25 @@ iwl4965_sta_alloc_lq(struct iwl_priv *priv, u8 sta_id) } /* - * iwl4965_add_bssid_station - Add the special IBSS BSSID station + * il4965_add_bssid_station - Add the special IBSS BSSID station * * Function sleeps. */ int -iwl4965_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, +il4965_add_bssid_station(struct il_priv *priv, struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r) { int ret; u8 sta_id; - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; unsigned long flags; if (sta_id_r) - *sta_id_r = IWL_INVALID_STATION; + *sta_id_r = IL_INVALID_STATION; - ret = iwl_legacy_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(priv, "Unable to add station %pM\n", addr); return ret; } @@ -113,21 +113,21 @@ iwl4965_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, *sta_id_r = sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IWL_STA_LOCAL; + priv->stations[sta_id].used |= IL_STA_LOCAL; spin_unlock_irqrestore(&priv->sta_lock, flags); /* Set up default rate scaling table in device's station table */ - link_cmd = iwl4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(priv, sta_id); if (!link_cmd) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to initialize rate scaling for station %pM.\n", addr); return -ENOMEM; } - ret = iwl_legacy_send_lq_cmd(priv, ctx, link_cmd, CMD_SYNC, true); + ret = il_send_lq_cmd(priv, ctx, link_cmd, CMD_SYNC, true); if (ret) - IWL_ERR(priv, "Link quality command failed (%d)\n", ret); + IL_ERR(priv, "Link quality command failed (%d)\n", ret); spin_lock_irqsave(&priv->sta_lock, flags); priv->stations[sta_id].lq = link_cmd; @@ -136,16 +136,16 @@ iwl4965_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, return 0; } -static int iwl4965_static_wepkey_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_static_wepkey_cmd(struct il_priv *priv, + struct il_rxon_context *ctx, bool send_if_empty) { int i, not_empty = 0; - u8 buff[sizeof(struct iwl_wep_cmd) + - sizeof(struct iwl_wep_key) * WEP_KEYS_MAX]; - struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff; - size_t cmd_size = sizeof(struct iwl_wep_cmd); - struct iwl_host_cmd cmd = { + u8 buff[sizeof(struct il_wep_cmd) + + sizeof(struct il_wep_key) * WEP_KEYS_MAX]; + struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; + size_t cmd_size = sizeof(struct il_wep_cmd); + struct il_host_cmd cmd = { .id = ctx->wep_key_cmd, .data = wep_cmd, .flags = CMD_SYNC, @@ -154,7 +154,7 @@ static int iwl4965_static_wepkey_cmd(struct iwl_priv *priv, might_sleep(); memset(wep_cmd, 0, cmd_size + - (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX)); + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); for (i = 0; i < WEP_KEYS_MAX ; i++) { wep_cmd->key[i].key_index = i; @@ -173,51 +173,51 @@ static int iwl4965_static_wepkey_cmd(struct iwl_priv *priv, wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; wep_cmd->num_keys = WEP_KEYS_MAX; - cmd_size += sizeof(struct iwl_wep_key) * WEP_KEYS_MAX; + cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; cmd.len = cmd_size; if (not_empty || send_if_empty) - return iwl_legacy_send_cmd(priv, &cmd); + return il_send_cmd(priv, &cmd); else return 0; } -int iwl4965_restore_default_wep_keys(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il4965_restore_default_wep_keys(struct il_priv *priv, + struct il_rxon_context *ctx) { lockdep_assert_held(&priv->mutex); - return iwl4965_static_wepkey_cmd(priv, ctx, false); + return il4965_static_wepkey_cmd(priv, ctx, false); } -int iwl4965_remove_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; lockdep_assert_held(&priv->mutex); - IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", + IL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_WEP(priv, + if (il_is_rfkill(priv)) { + IL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } - ret = iwl4965_static_wepkey_cmd(priv, ctx, 1); - IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(priv, ctx, 1); + IL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; } -int iwl4965_set_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_set_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; @@ -226,7 +226,7 @@ int iwl4965_set_default_wep_key(struct iwl_priv *priv, if (keyconf->keylen != WEP_KEY_LEN_128 && keyconf->keylen != WEP_KEY_LEN_64) { - IWL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen); + IL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen); return -EINVAL; } @@ -238,21 +238,21 @@ int iwl4965_set_default_wep_key(struct iwl_priv *priv, memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, keyconf->keylen); - ret = iwl4965_static_wepkey_cmd(priv, ctx, false); - IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(priv, ctx, false); + IL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, keyconf->keyidx, ret); return ret; } -static int iwl4965_set_wep_dynamic_key_info(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -283,7 +283,7 @@ static int iwl4965_set_wep_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -295,20 +295,20 @@ static int iwl4965_set_wep_dynamic_key_info(struct iwl_priv *priv, priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -static int iwl4965_set_ccmp_dynamic_key_info(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -334,7 +334,7 @@ static int iwl4965_set_ccmp_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -346,14 +346,14 @@ static int iwl4965_set_ccmp_dynamic_key_info(struct iwl_priv *priv, priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -static int iwl4965_set_tkip_dynamic_key_info(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_set_tkip_dynamic_key_info(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { @@ -379,7 +379,7 @@ static int iwl4965_set_tkip_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -399,8 +399,8 @@ static int iwl4965_set_tkip_dynamic_key_info(struct iwl_priv *priv, return ret; } -void iwl4965_update_tkip_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il4965_update_tkip_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { @@ -408,14 +408,14 @@ void iwl4965_update_tkip_key(struct iwl_priv *priv, unsigned long flags; int i; - if (iwl_legacy_scan_cancel(priv)) { + if (il_scan_cancel(priv)) { /* cancel scan failed, just live w/ bad key and rely briefly on SW decryption */ return; } - sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id_or_broadcast(priv, ctx, sta); + if (sta_id == IL_INVALID_STATION) return; spin_lock_irqsave(&priv->sta_lock, flags); @@ -429,21 +429,21 @@ void iwl4965_update_tkip_key(struct iwl_priv *priv, priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_legacy_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); + il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags); } -int iwl4965_remove_dynamic_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_dynamic_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; u16 key_flags; u8 keyidx; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -453,7 +453,7 @@ int iwl4965_remove_dynamic_key(struct iwl_priv *priv, key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - IWL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n", + IL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { @@ -467,7 +467,7 @@ int iwl4965_remove_dynamic_key(struct iwl_priv *priv, } if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IWL_WARN(priv, "Removing wrong key %d 0x%x\n", + IL_WARN(priv, "Removing wrong key %d 0x%x\n", keyconf->keyidx, key_flags); spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; @@ -475,32 +475,32 @@ int iwl4965_remove_dynamic_key(struct iwl_priv *priv, if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset, &priv->ucode_key_table)) - IWL_ERR(priv, "index %d not used in uCode key table.\n", + IL_ERR(priv, "index %d not used in uCode key table.\n", priv->stations[sta_id].sta.key.key_offset); memset(&priv->stations[sta_id].keyinfo, 0, - sizeof(struct iwl_hw_key)); + sizeof(struct il_hw_key)); memset(&priv->stations[sta_id].sta.key, 0, - sizeof(struct iwl4965_keyinfo)); + sizeof(struct il4965_keyinfo)); priv->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; priv->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_WEP(priv, + if (il_is_rfkill(priv)) { + IL_DEBUG_WEP(priv, "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -int iwl4965_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, +int il4965_set_dynamic_key(struct il_priv *priv, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret; @@ -512,26 +512,26 @@ int iwl4965_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = iwl4965_set_ccmp_dynamic_key_info(priv, ctx, + ret = il4965_set_ccmp_dynamic_key_info(priv, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = iwl4965_set_tkip_dynamic_key_info(priv, ctx, + ret = il4965_set_tkip_dynamic_key_info(priv, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = iwl4965_set_wep_dynamic_key_info(priv, ctx, + ret = il4965_set_wep_dynamic_key_info(priv, ctx, keyconf, sta_id); break; default: - IWL_ERR(priv, + IL_ERR(priv, "Unknown alg: %s cipher = %x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IWL_DEBUG_WEP(priv, + IL_DEBUG_WEP(priv, "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -540,36 +540,36 @@ int iwl4965_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, } /** - * iwl4965_alloc_bcast_station - add broadcast station into driver's station table. + * il4965_alloc_bcast_station - add broadcast station into driver's station table. * * This adds the broadcast station into the driver's station table * and marks it driver active, so that it will be restored to the * device at the next best time. */ -int iwl4965_alloc_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il4965_alloc_bcast_station(struct il_priv *priv, + struct il_rxon_context *ctx) { - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; unsigned long flags; u8 sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = iwl_legacy_prep_station(priv, ctx, iwlegacy_bcast_addr, + sta_id = il_prep_station(priv, ctx, iwlegacy_bcast_addr, false, NULL); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Unable to prepare broadcast station\n"); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&priv->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IWL_STA_BCAST; + priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used |= IL_STA_BCAST; spin_unlock_irqrestore(&priv->sta_lock, flags); - link_cmd = iwl4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(priv, sta_id); if (!link_cmd) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -582,21 +582,21 @@ int iwl4965_alloc_bcast_station(struct iwl_priv *priv, } /** - * iwl4965_update_bcast_station - update broadcast station's LQ command + * il4965_update_bcast_station - update broadcast station's LQ command * * Only used by iwl4965. Placed here to have all bcast station management * code together. */ -static int iwl4965_update_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il4965_update_bcast_station(struct il_priv *priv, + struct il_rxon_context *ctx) { unsigned long flags; - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; u8 sta_id = ctx->bcast_sta_id; - link_cmd = iwl4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(priv, sta_id); if (!link_cmd) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -605,7 +605,7 @@ static int iwl4965_update_bcast_station(struct iwl_priv *priv, if (priv->stations[sta_id].lq) kfree(priv->stations[sta_id].lq); else - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Bcast station rate scaling has not been initialized yet.\n"); priv->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&priv->sta_lock, flags); @@ -613,13 +613,13 @@ static int iwl4965_update_bcast_station(struct iwl_priv *priv, return 0; } -int iwl4965_update_bcast_stations(struct iwl_priv *priv) +int il4965_update_bcast_stations(struct il_priv *priv) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; int ret = 0; for_each_context(priv, ctx) { - ret = iwl4965_update_bcast_station(priv, ctx); + ret = il4965_update_bcast_station(priv, ctx); if (ret) break; } @@ -628,12 +628,12 @@ int iwl4965_update_bcast_stations(struct iwl_priv *priv) } /** - * iwl4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table + * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table */ -int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) +int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, int sta_id, int tid) { unsigned long flags; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -643,23 +643,23 @@ int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, int tid, u16 ssn) { unsigned long flags; int sta_id; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); - sta_id = iwl_legacy_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) return -ENXIO; spin_lock_irqsave(&priv->sta_lock, flags); @@ -669,24 +669,24 @@ int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, int tid) { unsigned long flags; int sta_id; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); - sta_id = iwl_legacy_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } @@ -696,14 +696,14 @@ int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } void -iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) +il4965_sta_modify_sleep_tx_count(struct il_priv *priv, int sta_id, int cnt) { unsigned long flags; @@ -714,7 +714,7 @@ iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) STA_MODIFY_SLEEP_TX_COUNT_MSK; priv->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_legacy_send_add_sta(priv, + il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index e421fdf..3fdb9d9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -77,7 +77,7 @@ static const u8 tid_to_ac[] = { IEEE80211_AC_VO }; -static inline int iwl4965_get_ac_from_tid(u16 tid) +static inline int il4965_get_ac_from_tid(u16 tid) { if (likely(tid < ARRAY_SIZE(tid_to_ac))) return tid_to_ac[tid]; @@ -87,7 +87,7 @@ static inline int iwl4965_get_ac_from_tid(u16 tid) } static inline int -iwl4965_get_fifo_from_tid(struct iwl_rxon_context *ctx, u16 tid) +il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) { if (likely(tid < ARRAY_SIZE(tid_to_ac))) return ctx->ac_to_fifo[tid_to_ac[tid]]; @@ -99,9 +99,9 @@ iwl4965_get_fifo_from_tid(struct iwl_rxon_context *ctx, u16 tid) /* * handle build REPLY_TX command notification. */ -static void iwl4965_tx_cmd_build_basic(struct iwl_priv *priv, +static void il4965_tx_cmd_build_basic(struct il_priv *priv, struct sk_buff *skb, - struct iwl_tx_cmd *tx_cmd, + struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, u8 std_id) @@ -137,7 +137,7 @@ static void iwl4965_tx_cmd_build_basic(struct iwl_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - iwl_legacy_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(priv, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -156,8 +156,8 @@ static void iwl4965_tx_cmd_build_basic(struct iwl_priv *priv, #define RTS_DFAULT_RETRY_LIMIT 60 -static void iwl4965_tx_cmd_build_rate(struct iwl_priv *priv, - struct iwl_tx_cmd *tx_cmd, +static void il4965_tx_cmd_build_rate(struct il_priv *priv, + struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, __le16 fc) { @@ -196,34 +196,34 @@ static void iwl4965_tx_cmd_build_rate(struct iwl_priv *priv, */ rate_idx = info->control.rates[0].idx; if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || - (rate_idx < 0) || (rate_idx > IWL_RATE_COUNT_LEGACY)) + (rate_idx < 0) || (rate_idx > IL_RATE_COUNT_LEGACY)) rate_idx = rate_lowest_index(&priv->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ if (info->band == IEEE80211_BAND_5GHZ) - rate_idx += IWL_FIRST_OFDM_RATE; + rate_idx += IL_FIRST_OFDM_RATE; /* Get PLCP rate for tx_cmd->rate_n_flags */ rate_plcp = iwlegacy_rates[rate_idx].plcp; /* Zero out flags for this packet */ rate_flags = 0; /* Set CCK flag as needed */ - if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE)) + if ((rate_idx >= IL_FIRST_CCK_RATE) && (rate_idx <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ - priv->mgmt_tx_ant = iwl4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, + priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, priv->hw_params.valid_tx_ant); - rate_flags |= iwl4965_ant_idx_to_flags(priv->mgmt_tx_ant); + rate_flags |= il4965_ant_idx_to_flags(priv->mgmt_tx_ant); /* Set the rate in the TX cmd */ - tx_cmd->rate_n_flags = iwl4965_hw_set_rate_n_flags(rate_plcp, rate_flags); + tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); } -static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, +static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, struct ieee80211_tx_info *info, - struct iwl_tx_cmd *tx_cmd, + struct il_tx_cmd *tx_cmd, struct sk_buff *skb_frag, int sta_id) { @@ -235,13 +235,13 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); if (info->flags & IEEE80211_TX_CTL_AMPDU) tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); + IL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); break; case WLAN_CIPHER_SUITE_WEP104: @@ -253,12 +253,12 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " "with key %d\n", keyconf->keyidx); break; default: - IWL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher); + IL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher); break; } } @@ -266,18 +266,18 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, /* * start REPLY_TX command process */ -int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) +int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_sta *sta = info->control.sta; - struct iwl_station_priv *sta_priv = NULL; - struct iwl_tx_queue *txq; - struct iwl_queue *q; - struct iwl_device_cmd *out_cmd; - struct iwl_cmd_meta *out_meta; - struct iwl_tx_cmd *tx_cmd; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_station_priv *sta_priv = NULL; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + struct il_tx_cmd *tx_cmd; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; int txq_id; dma_addr_t phys_addr; dma_addr_t txcmd_phys; @@ -294,11 +294,11 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) bool is_agg = false; if (info->control.vif) - ctx = iwl_legacy_rxon_ctx_from_vif(info->control.vif); + ctx = il_rxon_ctx_from_vif(info->control.vif); spin_lock_irqsave(&priv->lock, flags); - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + if (il_is_rfkill(priv)) { + IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); goto drop_unlock; } @@ -306,11 +306,11 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IWL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(priv, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); #endif hdr_len = ieee80211_hdrlen(fc); @@ -320,16 +320,16 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) sta_id = ctx->bcast_sta_id; else { /* Find index into station table for destination station */ - sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta); + sta_id = il_sta_id_or_broadcast(priv, ctx, info->control.sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + if (sta_id == IL_INVALID_STATION) { + IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } - IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); + IL_DEBUG_TX(priv, "station Id %d\n", sta_id); if (sta) sta_priv = (void *)sta->drv_priv; @@ -345,7 +345,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * For now set the counter to just 1 since we do not * support uAPSD yet. */ - iwl4965_sta_modify_sleep_tx_count(priv, sta_id, 1); + il4965_sta_modify_sleep_tx_count(priv, sta_id, 1); } /* @@ -381,7 +381,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) seq_number += 0x10; /* aggregation is on for this */ if (info->flags & IEEE80211_TX_CTL_AMPDU && - priv->stations[sta_id].tid[tid].agg.state == IWL_AGG_ON) { + priv->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; is_agg = true; } @@ -390,7 +390,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) txq = &priv->txq[txq_id]; q = &txq->q; - if (unlikely(iwl_legacy_queue_space(q) < q->high_mark)) { + if (unlikely(il_queue_space(q) < q->high_mark)) { spin_unlock(&priv->sta_lock); goto drop_unlock; } @@ -404,7 +404,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) spin_unlock(&priv->sta_lock); /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; txq->txb[q->write_ptr].ctx = ctx; @@ -413,7 +413,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) out_meta = &txq->meta[q->write_ptr]; tx_cmd = &out_cmd->cmd.tx; memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); - memset(tx_cmd, 0, sizeof(struct iwl_tx_cmd)); + memset(tx_cmd, 0, sizeof(struct il_tx_cmd)); /* * Set up the Tx-command (not MAC!) header. @@ -434,15 +434,15 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) tx_cmd->len = cpu_to_le16(len); if (info->control.hw_key) - iwl4965_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); + il4965_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - iwl4965_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); - iwl_legacy_dbg_log_tx_data_frame(priv, len, hdr); + il4965_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); + il_dbg_log_tx_data_frame(priv, len, hdr); - iwl4965_tx_cmd_build_rate(priv, tx_cmd, info, fc); + il4965_tx_cmd_build_rate(priv, tx_cmd, info, fc); - iwl_legacy_update_stats(priv, true, fc, len); + il_update_stats(priv, true, fc, len); /* * Use the first empty entry in this queue's command buffer array * to contain the Tx command and MAC header concatenated together @@ -452,8 +452,8 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct iwl_tx_cmd) + - sizeof(struct iwl_cmd_header) + hdr_len; + len = sizeof(struct il_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; firstlen = (len + 3) & ~3; /* Tell NIC about any 2-byte padding after MAC header */ @@ -490,20 +490,20 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) 0, 0); } - scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + - offsetof(struct iwl_tx_cmd, scratch); + scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + + offsetof(struct il_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ pci_dma_sync_single_for_cpu(priv->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); - tx_cmd->dram_msb_ptr = iwl_legacy_get_dma_hi_addr(scratch_phys); + tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - IWL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IWL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); /* Set up entry for this TFD in Tx byte-count array */ if (info->flags & IEEE80211_TX_CTL_AMPDU) @@ -514,8 +514,8 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) firstlen, PCI_DMA_BIDIRECTIONAL); /* Tell device the write index *just past* this latest filled TFD */ - q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); - iwl_legacy_txq_update_write_ptr(priv, txq); + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); /* @@ -535,15 +535,15 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) if (sta_priv && sta_priv->client && !is_agg) atomic_inc(&sta_priv->pending_frames); - if ((iwl_legacy_queue_space(q) < q->high_mark) && + if ((il_queue_space(q) < q->high_mark) && priv->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&priv->lock, flags); txq->need_update = 1; - iwl_legacy_txq_update_write_ptr(priv, txq); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); } else { - iwl_legacy_stop_queue(priv, txq); + il_stop_queue(priv, txq); } } @@ -554,8 +554,8 @@ drop_unlock: return -1; } -static inline int iwl4965_alloc_dma_ptr(struct iwl_priv *priv, - struct iwl_dma_ptr *ptr, size_t size) +static inline int il4965_alloc_dma_ptr(struct il_priv *priv, + struct il_dma_ptr *ptr, size_t size) { ptr->addr = dma_alloc_coherent(&priv->pci_dev->dev, size, &ptr->dma, GFP_KERNEL); @@ -565,8 +565,8 @@ static inline int iwl4965_alloc_dma_ptr(struct iwl_priv *priv, return 0; } -static inline void iwl4965_free_dma_ptr(struct iwl_priv *priv, - struct iwl_dma_ptr *ptr) +static inline void il4965_free_dma_ptr(struct il_priv *priv, + struct il_dma_ptr *ptr) { if (unlikely(!ptr->addr)) return; @@ -576,11 +576,11 @@ static inline void iwl4965_free_dma_ptr(struct iwl_priv *priv, } /** - * iwl4965_hw_txq_ctx_free - Free TXQ Context + * il4965_hw_txq_ctx_free - Free TXQ Context * * Destroy all TX DMA queues and structures */ -void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv) +void il4965_hw_txq_ctx_free(struct il_priv *priv) { int txq_id; @@ -588,59 +588,59 @@ void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv) if (priv->txq) { for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) if (txq_id == priv->cmd_queue) - iwl_legacy_cmd_queue_free(priv); + il_cmd_queue_free(priv); else - iwl_legacy_tx_queue_free(priv, txq_id); + il_tx_queue_free(priv, txq_id); } - iwl4965_free_dma_ptr(priv, &priv->kw); + il4965_free_dma_ptr(priv, &priv->kw); - iwl4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); /* free tx queue structure */ - iwl_legacy_txq_mem(priv); + il_txq_mem(priv); } /** - * iwl4965_txq_ctx_alloc - allocate TX queue context + * il4965_txq_ctx_alloc - allocate TX queue context * Allocate all Tx DMA structures and initialize them * * @param priv * @return error code */ -int iwl4965_txq_ctx_alloc(struct iwl_priv *priv) +int il4965_txq_ctx_alloc(struct il_priv *priv) { int ret; int txq_id, slots_num; unsigned long flags; /* Free all tx/cmd queues and keep-warm buffer */ - iwl4965_hw_txq_ctx_free(priv); + il4965_hw_txq_ctx_free(priv); - ret = iwl4965_alloc_dma_ptr(priv, &priv->scd_bc_tbls, + ret = il4965_alloc_dma_ptr(priv, &priv->scd_bc_tbls, priv->hw_params.scd_bc_tbls_size); if (ret) { - IWL_ERR(priv, "Scheduler BC Table allocation failed\n"); + IL_ERR(priv, "Scheduler BC Table allocation failed\n"); goto error_bc_tbls; } /* Alloc keep-warm buffer */ - ret = iwl4965_alloc_dma_ptr(priv, &priv->kw, IWL_KW_SIZE); + ret = il4965_alloc_dma_ptr(priv, &priv->kw, IL_KW_SIZE); if (ret) { - IWL_ERR(priv, "Keep Warm allocation failed\n"); + IL_ERR(priv, "Keep Warm allocation failed\n"); goto error_kw; } /* allocate tx queue structure */ - ret = iwl_legacy_alloc_txq_mem(priv); + ret = il_alloc_txq_mem(priv); if (ret) goto error; spin_lock_irqsave(&priv->lock, flags); /* Turn off all Tx DMA fifos */ - iwl4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(priv, 0); /* Tell NIC where to find the "keep warm" buffer */ - iwl_legacy_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); spin_unlock_irqrestore(&priv->lock, flags); @@ -648,11 +648,11 @@ int iwl4965_txq_ctx_alloc(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { slots_num = (txq_id == priv->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = iwl_legacy_tx_queue_init(priv, + ret = il_tx_queue_init(priv, &priv->txq[txq_id], slots_num, txq_id); if (ret) { - IWL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(priv, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -660,15 +660,15 @@ int iwl4965_txq_ctx_alloc(struct iwl_priv *priv) return ret; error: - iwl4965_hw_txq_ctx_free(priv); - iwl4965_free_dma_ptr(priv, &priv->kw); + il4965_hw_txq_ctx_free(priv); + il4965_free_dma_ptr(priv, &priv->kw); error_kw: - iwl4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); error_bc_tbls: return ret; } -void iwl4965_txq_ctx_reset(struct iwl_priv *priv) +void il4965_txq_ctx_reset(struct il_priv *priv) { int txq_id, slots_num; unsigned long flags; @@ -676,10 +676,10 @@ void iwl4965_txq_ctx_reset(struct iwl_priv *priv) spin_lock_irqsave(&priv->lock, flags); /* Turn off all Tx DMA fifos */ - iwl4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(priv, 0); /* Tell NIC where to find the "keep warm" buffer */ - iwl_legacy_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); spin_unlock_irqrestore(&priv->lock, flags); @@ -687,15 +687,15 @@ void iwl4965_txq_ctx_reset(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { slots_num = txq_id == priv->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - iwl_legacy_tx_queue_reset(priv, &priv->txq[txq_id], + il_tx_queue_reset(priv, &priv->txq[txq_id], slots_num, txq_id); } } /** - * iwl4965_txq_ctx_stop - Stop all Tx DMA channels + * il4965_txq_ctx_stop - Stop all Tx DMA channels */ -void iwl4965_txq_ctx_stop(struct iwl_priv *priv) +void il4965_txq_ctx_stop(struct il_priv *priv) { int ch, txq_id; unsigned long flags; @@ -703,18 +703,18 @@ void iwl4965_txq_ctx_stop(struct iwl_priv *priv) /* Turn off all Tx DMA fifos */ spin_lock_irqsave(&priv->lock, flags); - iwl4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(priv, 0); /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < priv->hw_params.dma_chnl_num; ch++) { - iwl_legacy_write_direct32(priv, + il_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, + if (il_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) - IWL_ERR(priv, "Failing on timeout while stopping" + IL_ERR(priv, "Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, - iwl_legacy_read_direct32(priv, + il_read_direct32(priv, FH_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&priv->lock, flags); @@ -725,9 +725,9 @@ void iwl4965_txq_ctx_stop(struct iwl_priv *priv) /* Unmap DMA from host system and free skb's */ for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) if (txq_id == priv->cmd_queue) - iwl_legacy_cmd_queue_unmap(priv); + il_cmd_queue_unmap(priv); else - iwl_legacy_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(priv, txq_id); } /* @@ -736,7 +736,7 @@ void iwl4965_txq_ctx_stop(struct iwl_priv *priv) * Should never return anything < 7, because they should already * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) */ -static int iwl4965_txq_ctx_activate_free(struct iwl_priv *priv) +static int il4965_txq_ctx_activate_free(struct il_priv *priv) { int txq_id; @@ -747,53 +747,53 @@ static int iwl4965_txq_ctx_activate_free(struct iwl_priv *priv) } /** - * iwl4965_tx_queue_stop_scheduler - Stop queue, but keep configuration + * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration */ -static void iwl4965_tx_queue_stop_scheduler(struct iwl_priv *priv, +static void il4965_tx_queue_stop_scheduler(struct il_priv *priv, u16 txq_id) { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - iwl_legacy_write_prph(priv, + il_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** - * iwl4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue + * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue */ -static int iwl4965_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid, +static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, u16 txq_id) { u32 tbl_dw_addr; u32 tbl_dw; u16 scd_q2ratid; - scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; + scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; tbl_dw_addr = priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); - tbl_dw = iwl_legacy_read_targ_mem(priv, tbl_dw_addr); + tbl_dw = il_read_targ_mem(priv, tbl_dw_addr); if (txq_id & 0x1) tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); else tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); - iwl_legacy_write_targ_mem(priv, tbl_dw_addr, tbl_dw); + il_write_targ_mem(priv, tbl_dw_addr, tbl_dw); return 0; } /** - * iwl4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue + * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue * * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ -static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, +static int il4965_txq_agg_enable(struct il_priv *priv, int txq_id, int tx_fifo, int sta_id, int tid, u16 ssn_idx) { unsigned long flags; @@ -803,7 +803,7 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IWL_WARN(priv, + IL_WARN(priv, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -814,42 +814,42 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, ra_tid = BUILD_RAxTID(sta_id, tid); /* Modify device's station table to Tx this TID */ - ret = iwl4965_sta_tx_modify_enable_tid(priv, sta_id, tid); + ret = il4965_sta_tx_modify_enable_tid(priv, sta_id, tid); if (ret) return ret; spin_lock_irqsave(&priv->lock, flags); /* Stop this Tx queue before configuring it */ - iwl4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(priv, txq_id); /* Map receiver-address / traffic-ID to this queue */ - iwl4965_tx_queue_set_q2ratid(priv, ra_tid, txq_id); + il4965_tx_queue_set_q2ratid(priv, ra_tid, txq_id); /* Set this queue as a chain-building queue */ - iwl_legacy_set_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_set_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); /* Place first TFD at index corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - iwl4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il4965_set_wr_ptrs(priv, txq_id, ssn_idx); /* Set up Tx window size and frame limit for this queue */ - iwl_legacy_write_targ_mem(priv, + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - iwl_legacy_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), (SCD_FRAME_LIMIT << IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - iwl_legacy_set_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_set_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ - iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); + il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); spin_unlock_irqrestore(&priv->lock, flags); @@ -857,7 +857,7 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, } -int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn) { int sta_id; @@ -865,31 +865,31 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, int txq_id; int ret; unsigned long flags; - struct iwl_tid_data *tid_data; + struct il_tid_data *tid_data; - tx_fifo = iwl4965_get_fifo_from_tid(iwl_legacy_rxon_ctx_from_vif(vif), tid); + tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); if (unlikely(tx_fifo < 0)) return tx_fifo; - IWL_WARN(priv, "%s on ra = %pM tid = %d\n", + IL_WARN(priv, "%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); - sta_id = iwl_legacy_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Start AGG on invalid station\n"); + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Start AGG on invalid station\n"); return -ENXIO; } if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; - if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) { - IWL_ERR(priv, "Start AGG when state is not IWL_AGG_OFF !\n"); + if (priv->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { + IL_ERR(priv, "Start AGG when state is not IL_AGG_OFF !\n"); return -ENXIO; } - txq_id = iwl4965_txq_ctx_activate_free(priv); + txq_id = il4965_txq_ctx_activate_free(priv); if (txq_id == -1) { - IWL_ERR(priv, "No free aggregation queue available\n"); + IL_ERR(priv, "No free aggregation queue available\n"); return -ENXIO; } @@ -897,11 +897,11 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, tid_data = &priv->stations[sta_id].tid[tid]; *ssn = SEQ_TO_SN(tid_data->seq_number); tid_data->agg.txq_id = txq_id; - iwl_legacy_set_swq_id(&priv->txq[txq_id], - iwl4965_get_ac_from_tid(tid), txq_id); + il_set_swq_id(&priv->txq[txq_id], + il4965_get_ac_from_tid(tid), txq_id); spin_unlock_irqrestore(&priv->sta_lock, flags); - ret = iwl4965_txq_agg_enable(priv, txq_id, tx_fifo, + ret = il4965_txq_agg_enable(priv, txq_id, tx_fifo, sta_id, tid, *ssn); if (ret) return ret; @@ -909,14 +909,14 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, spin_lock_irqsave(&priv->sta_lock, flags); tid_data = &priv->stations[sta_id].tid[tid]; if (tid_data->tfds_in_queue == 0) { - IWL_DEBUG_HT(priv, "HW queue is empty\n"); - tid_data->agg.state = IWL_AGG_ON; + IL_DEBUG_HT(priv, "HW queue is empty\n"); + tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - IWL_DEBUG_HT(priv, + IL_DEBUG_HT(priv, "HW queue is NOT empty: %d packets in HW queue\n", tid_data->tfds_in_queue); - tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; + tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; } spin_unlock_irqrestore(&priv->sta_lock, flags); return ret; @@ -926,13 +926,13 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE * priv->lock must be held by the caller */ -static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, +static int il4965_txq_agg_disable(struct il_priv *priv, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IWL_WARN(priv, + IL_WARN(priv, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -940,40 +940,40 @@ static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, return -EINVAL; } - iwl4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(priv, txq_id); - iwl_legacy_clear_bits_prph(priv, + il_clear_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); /* supposes that ssn_idx is valid (!= 0xFFF) */ - iwl4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il4965_set_wr_ptrs(priv, txq_id, ssn_idx); - iwl_legacy_clear_bits_prph(priv, + il_clear_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - iwl_txq_ctx_deactivate(priv, txq_id); - iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); + il_txq_ctx_deactivate(priv, txq_id); + il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); return 0; } -int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid) { int tx_fifo_id, txq_id, sta_id, ssn; - struct iwl_tid_data *tid_data; + struct il_tid_data *tid_data; int write_ptr, read_ptr; unsigned long flags; - tx_fifo_id = iwl4965_get_fifo_from_tid(iwl_legacy_rxon_ctx_from_vif(vif), tid); + tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); if (unlikely(tx_fifo_id < 0)) return tx_fifo_id; - sta_id = iwl_legacy_sta_id(sta); + sta_id = il_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } @@ -984,19 +984,19 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, txq_id = tid_data->agg.txq_id; switch (priv->stations[sta_id].tid[tid].agg.state) { - case IWL_EMPTYING_HW_QUEUE_ADDBA: + case IL_EMPTYING_HW_QUEUE_ADDBA: /* * This can happen if the peer stops aggregation * again before we've had a chance to drain the * queue we selected previously, i.e. before the * session was really started completely. */ - IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); + IL_DEBUG_HT(priv, "AGG stop before setup done\n"); goto turn_off; - case IWL_AGG_ON: + case IL_AGG_ON: break; default: - IWL_WARN(priv, "Stopping AGG while state not ON or starting\n"); + IL_WARN(priv, "Stopping AGG while state not ON or starting\n"); } write_ptr = priv->txq[txq_id].q.write_ptr; @@ -1004,16 +1004,16 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, /* The queue is not empty */ if (write_ptr != read_ptr) { - IWL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n"); + IL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n"); priv->stations[sta_id].tid[tid].agg.state = - IWL_EMPTYING_HW_QUEUE_DELBA; + IL_EMPTYING_HW_QUEUE_DELBA; spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } - IWL_DEBUG_HT(priv, "HW queue is empty\n"); + IL_DEBUG_HT(priv, "HW queue is empty\n"); turn_off: - priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; + priv->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; /* do not restore/save irqs */ spin_unlock(&priv->sta_lock); @@ -1026,7 +1026,7 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, * to deactivate the uCode queue, just return "success" to allow * mac80211 to clean up it own data. */ - iwl4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id); + il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id); spin_unlock_irqrestore(&priv->lock, flags); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); @@ -1034,39 +1034,39 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, return 0; } -int iwl4965_txq_check_empty(struct iwl_priv *priv, +int il4965_txq_check_empty(struct il_priv *priv, int sta_id, u8 tid, int txq_id) { - struct iwl_queue *q = &priv->txq[txq_id].q; + struct il_queue *q = &priv->txq[txq_id].q; u8 *addr = priv->stations[sta_id].sta.sta.addr; - struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; - struct iwl_rxon_context *ctx; + struct il_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; + struct il_rxon_context *ctx; ctx = &priv->contexts[priv->stations[sta_id].ctxid]; lockdep_assert_held(&priv->sta_lock); switch (priv->stations[sta_id].tid[tid].agg.state) { - case IWL_EMPTYING_HW_QUEUE_DELBA: + case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ if ((txq_id == tid_data->agg.txq_id) && (q->read_ptr == q->write_ptr)) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); - int tx_fifo = iwl4965_get_fifo_from_tid(ctx, tid); - IWL_DEBUG_HT(priv, + int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); + IL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n"); - iwl4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo); - tid_data->agg.state = IWL_AGG_OFF; + il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo); + tid_data->agg.state = IL_AGG_OFF; ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } break; - case IWL_EMPTYING_HW_QUEUE_ADDBA: + case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - IWL_DEBUG_HT(priv, + IL_DEBUG_HT(priv, "HW queue empty: continue ADDBA flow\n"); - tid_data->agg.state = IWL_AGG_ON; + tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } break; @@ -1075,12 +1075,12 @@ int iwl4965_txq_check_empty(struct iwl_priv *priv, return 0; } -static void iwl4965_non_agg_tx_status(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static void il4965_non_agg_tx_status(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr1) { struct ieee80211_sta *sta; - struct iwl_station_priv *sta_priv; + struct il_station_priv *sta_priv; rcu_read_lock(); sta = ieee80211_find_sta(ctx->vif, addr1); @@ -1095,35 +1095,35 @@ static void iwl4965_non_agg_tx_status(struct iwl_priv *priv, } static void -iwl4965_tx_status(struct iwl_priv *priv, struct iwl_tx_info *tx_info, +il4965_tx_status(struct il_priv *priv, struct il_tx_info *tx_info, bool is_agg) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; if (!is_agg) - iwl4965_non_agg_tx_status(priv, tx_info->ctx, hdr->addr1); + il4965_non_agg_tx_status(priv, tx_info->ctx, hdr->addr1); ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); } -int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) +int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; - struct iwl_tx_info *tx_info; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; int nfreed = 0; struct ieee80211_hdr *hdr; - if ((index >= q->n_bd) || (iwl_legacy_queue_used(q, index) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); return 0; } - for (index = iwl_legacy_queue_inc_wrap(index, q->n_bd); + for (index = il_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -1134,7 +1134,7 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) if (ieee80211_is_data_qos(hdr->frame_control)) nfreed++; - iwl4965_tx_status(priv, tx_info, + il4965_tx_status(priv, tx_info, txq_id >= IWL4965_FIRST_AMPDU_QUEUE); tx_info->skb = NULL; @@ -1144,14 +1144,14 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) } /** - * iwl4965_tx_status_reply_compressed_ba - Update tx status from block-ack + * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack * * Go through block-ack's bitmap of ACK'd frames, update driver's record of * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. */ -static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_ht_agg *agg, - struct iwl_compressed_ba_resp *ba_resp) +static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, + struct il_ht_agg *agg, + struct il_compressed_ba_resp *ba_resp) { int i, sh, ack; @@ -1163,13 +1163,13 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) - IWL_ERR(priv, "Received BA when not expected\n"); + IL_ERR(priv, "Received BA when not expected\n"); return -EINVAL; } /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - IWL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, + IL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx window bits */ @@ -1178,7 +1178,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, sh += 0x100; if (agg->frame_count > (64 - sh)) { - IWL_DEBUG_TX_REPLY(priv, "more frames than bitmap size"); + IL_DEBUG_TX_REPLY(priv, "more frames than bitmap size"); return -1; } @@ -1195,7 +1195,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - IWL_DEBUG_TX_REPLY(priv, "%s ON i=%d idx=%d raw=%d\n", + IL_DEBUG_TX_REPLY(priv, "%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff, agg->start_idx + i); @@ -1203,7 +1203,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, ++i; } - IWL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", + IL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", (unsigned long long)bitmap); info = IEEE80211_SKB_CB(priv->txq[scd_flow].txb[agg->start_idx].skb); @@ -1212,7 +1212,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, info->flags |= IEEE80211_TX_STAT_AMPDU; info->status.ampdu_ack_len = successes; info->status.ampdu_len = agg->frame_count; - iwl4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); + il4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); return 0; } @@ -1220,7 +1220,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, /** * translate ucode response to mac80211 tx status control values */ -void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, +void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, struct ieee80211_tx_info *info) { struct ieee80211_tx_rate *r = &info->control.rates[0]; @@ -1237,22 +1237,22 @@ void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, r->flags |= IEEE80211_TX_RC_DUP_DATA; if (rate_n_flags & RATE_MCS_SGI_MSK) r->flags |= IEEE80211_TX_RC_SHORT_GI; - r->idx = iwl4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); + r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); } /** - * iwl4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA + * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA * * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_reply_compressed_ba(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; - struct iwl_tx_queue *txq = NULL; - struct iwl_ht_agg *agg; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; + struct il_tx_queue *txq = NULL; + struct il_ht_agg *agg; int index; int sta_id; int tid; @@ -1266,7 +1266,7 @@ void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= priv->hw_params.max_txq_num) { - IWL_ERR(priv, + IL_ERR(priv, "BUG_ON scd_flow is bigger than number of queues\n"); return; } @@ -1282,23 +1282,23 @@ void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - IWL_DEBUG_TX_REPLY(priv, + IL_DEBUG_TX_REPLY(priv, "BA scd_flow %d does not match txq_id %d\n", scd_flow, agg->txq_id); return; } /* Find index just before block-ack window */ - index = iwl_legacy_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); + index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); spin_lock_irqsave(&priv->sta_lock, flags); - IWL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, " + IL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); - IWL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," + IL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, @@ -1306,34 +1306,34 @@ void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, (unsigned long long)le64_to_cpu(ba_resp->bitmap), ba_resp->scd_flow, ba_resp->scd_ssn); - IWL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx\n", + IL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, (unsigned long long)agg->bitmap); /* Update driver's record of ACK vs. not for each frame in window */ - iwl4965_tx_status_reply_compressed_ba(priv, agg, ba_resp); + il4965_tx_status_reply_compressed_ba(priv, agg, ba_resp); /* Release all TFDs before the SSN, i.e. all TFDs in front of * block-ack window (we assume that they've been successfully * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ - int freed = iwl4965_tx_queue_reclaim(priv, scd_flow, index); - iwl4965_free_tfds_in_queue(priv, sta_id, tid, freed); + int freed = il4965_tx_queue_reclaim(priv, scd_flow, index); + il4965_free_tfds_in_queue(priv, sta_id, tid, freed); - if ((iwl_legacy_queue_space(&txq->q) > txq->q.low_mark) && + if ((il_queue_space(&txq->q) > txq->q.low_mark) && priv->mac80211_registered && - (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) - iwl_legacy_wake_queue(priv, txq); + (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + il_wake_queue(priv, txq); - iwl4965_txq_check_empty(priv, sta_id, tid, scd_flow); + il4965_txq_check_empty(priv, sta_id, tid, scd_flow); } spin_unlock_irqrestore(&priv->sta_lock, flags); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -const char *iwl4965_get_tx_fail_reason(u32 status) +const char *il4965_get_tx_fail_reason(u32 status) { #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x #define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 001d148..3c9df1b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -40,30 +40,30 @@ #include "iwl-4965.h" #include "iwl-4965-calib.h" -#define IWL_AC_UNSET -1 +#define IL_AC_UNSET -1 /** - * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host, + * il_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ static int -iwl4965_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len) +il4965_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) { u32 val; int ret = 0; u32 errcnt = 0; u32 i; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + * if IL_DL_IO is set */ + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; errcnt++; @@ -76,10 +76,10 @@ iwl4965_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len) } /** - * iwl4965_verify_inst_full - verify runtime uCode image in card vs. host, + * il4965_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int iwl4965_verify_inst_full(struct iwl_priv *priv, __le32 *image, +static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) { u32 val; @@ -87,19 +87,19 @@ static int iwl4965_verify_inst_full(struct iwl_priv *priv, __le32 *image, int ret = 0; u32 errcnt; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + * if IL_DL_IO is set */ + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(priv, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); ret = -EIO; @@ -110,17 +110,17 @@ static int iwl4965_verify_inst_full(struct iwl_priv *priv, __le32 *image, } if (!errcnt) - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "ucode image in INSTRUCTION memory is good\n"); return ret; } /** - * iwl4965_verify_ucode - determine which instruction image is in SRAM, + * il4965_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -int iwl4965_verify_ucode(struct iwl_priv *priv) +int il4965_verify_ucode(struct il_priv *priv) { __le32 *image; u32 len; @@ -129,38 +129,38 @@ int iwl4965_verify_ucode(struct iwl_priv *priv) /* Try bootstrap */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - ret = iwl4965_verify_inst_sparse(priv, image, len); + ret = il4965_verify_inst_sparse(priv, image, len); if (!ret) { - IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ image = (__le32 *)priv->ucode_init.v_addr; len = priv->ucode_init.len; - ret = iwl4965_verify_inst_sparse(priv, image, len); + ret = il4965_verify_inst_sparse(priv, image, len); if (!ret) { - IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ image = (__le32 *)priv->ucode_code.v_addr; len = priv->ucode_code.len; - ret = iwl4965_verify_inst_sparse(priv, image, len); + ret = il4965_verify_inst_sparse(priv, image, len); if (!ret) { - IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); return 0; } - IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - ret = iwl4965_verify_inst_full(priv, image, len); + ret = il4965_verify_inst_full(priv, image, len); return ret; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 86f4fce..0f2bc5f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -48,8 +48,8 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" -static int iwl4965_send_tx_power(struct iwl_priv *priv); -static int iwl4965_hw_get_temperature(struct iwl_priv *priv); +static int il4965_send_tx_power(struct il_priv *priv); +static int il4965_hw_get_temperature(struct il_priv *priv); /* Highest firmware API version supported */ #define IWL4965_UCODE_API_MAX 2 @@ -62,23 +62,23 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv); #define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ -static int iwl4965_verify_bsm(struct iwl_priv *priv) +static int il4965_verify_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; u32 reg; u32 val; - IWL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(priv, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = iwl_legacy_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = iwl_legacy_read_prph(priv, reg); + val = il_read_prph(priv, reg); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(priv, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -87,13 +87,13 @@ static int iwl4965_verify_bsm(struct iwl_priv *priv) } } - IWL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); return 0; } /** - * iwl4965_load_bsm - Load bootstrap instructions + * il4965_load_bsm - Load bootstrap instructions * * BSM operation: * @@ -124,7 +124,7 @@ static int iwl4965_verify_bsm(struct iwl_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int iwl4965_load_bsm(struct iwl_priv *priv) +static int il4965_load_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; @@ -137,7 +137,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) u32 reg_offset; int ret; - IWL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(priv, "Begin load bsm\n"); priv->ucode_type = UCODE_RT; @@ -147,7 +147,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) /* Tell bootstrap uCode where to find the "Initialize" uCode * in host DRAM ... host DRAM physical address bits 35:4 for 4965. - * NOTE: iwl_init_alive_start() will replace these values, + * NOTE: il_init_alive_start() will replace these values, * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ @@ -156,48 +156,48 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) inst_len = priv->ucode_init.len; data_len = priv->ucode_init_data.len; - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _iwl_legacy_write_prph(priv, reg_offset, le32_to_cpu(*image)); + _il_write_prph(priv, reg_offset, le32_to_cpu(*image)); - ret = iwl4965_verify_bsm(priv); + ret = il4965_verify_bsm(priv); if (ret) return ret; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - iwl_legacy_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - iwl_legacy_write_prph(priv, + il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(priv, BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); - iwl_legacy_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - iwl_legacy_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = iwl_legacy_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(priv, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IWL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); else { - IWL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(priv, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - iwl_legacy_write_prph(priv, + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); @@ -205,7 +205,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) } /** - * iwl4965_set_ucode_ptrs - Set uCode address location + * il4965_set_ucode_ptrs - Set uCode address location * * Tell initialization uCode where to find runtime uCode. * @@ -213,7 +213,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv) +static int il4965_set_ucode_ptrs(struct il_priv *priv) { dma_addr_t pinst; dma_addr_t pdata; @@ -224,22 +224,22 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv) pdata = priv->ucode_data_backup.p_addr >> 4; /* Tell bootstrap uCode where to find image to load */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, priv->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, priv->ucode_code.len | BSM_DRAM_INST_LOAD); - IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); return ret; } /** - * iwl4965_init_alive_start - Called after REPLY_ALIVE notification received + * il4965_init_alive_start - Called after REPLY_ALIVE notification received * * Called after REPLY_ALIVE notification received from "initialize" uCode. * @@ -249,29 +249,29 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void iwl4965_init_alive_start(struct iwl_priv *priv) +static void il4965_init_alive_start(struct il_priv *priv) { /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (iwl4965_verify_ucode(priv)) { + if (il4965_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Calculate temperature */ - priv->temperature = iwl4965_hw_get_temperature(priv); + priv->temperature = il4965_hw_get_temperature(priv); /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (iwl4965_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + if (il4965_set_ucode_ptrs(priv)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -288,29 +288,29 @@ static bool iw4965_is_ht40_channel(__le32 rxon_flags) (chan_mod == CHANNEL_MODE_MIXED)); } -static void iwl4965_nic_config(struct iwl_priv *priv) +static void il4965_nic_config(struct il_priv *priv) { unsigned long flags; u16 radio_cfg; spin_lock_irqsave(&priv->lock, flags); - radio_cfg = iwl_legacy_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + radio_cfg = il_eeprom_query16(priv, EEPROM_RADIO_CONFIG); /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | EEPROM_RF_CFG_STEP_MSK(radio_cfg) | EEPROM_RF_CFG_DASH_MSK(radio_cfg)); /* set CSR_HW_CONFIG_REG for uCode use */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - priv->calib_info = (struct iwl_eeprom_calib_info *) - iwl_legacy_eeprom_query_addr(priv, + priv->calib_info = (struct il_eeprom_calib_info *) + il_eeprom_query_addr(priv, EEPROM_4965_CALIB_TXPOWER_OFFSET); spin_unlock_irqrestore(&priv->lock, flags); @@ -319,13 +319,13 @@ static void iwl4965_nic_config(struct iwl_priv *priv) /* Reset differential Rx gains in NIC to prepare for chain noise calibration. * Called after every association, but this runs only once! * ... once chain noise is calibrated the first time, it's good forever. */ -static void iwl4965_chain_noise_reset(struct iwl_priv *priv) +static void il4965_chain_noise_reset(struct il_priv *priv) { - struct iwl_chain_noise_data *data = &(priv->chain_noise_data); + struct il_chain_noise_data *data = &(priv->chain_noise_data); - if ((data->state == IWL_CHAIN_NOISE_ALIVE) && - iwl_legacy_is_any_associated(priv)) { - struct iwl_calib_diff_gain_cmd cmd; + if ((data->state == IL_CHAIN_NOISE_ALIVE) && + il_is_any_associated(priv)) { + struct il_calib_diff_gain_cmd cmd; /* clear data for chain noise calibration algorithm */ data->chain_noise_a = 0; @@ -337,20 +337,20 @@ static void iwl4965_chain_noise_reset(struct iwl_priv *priv) data->beacon_count = 0; memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (iwl_legacy_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + if (il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd)) - IWL_ERR(priv, + IL_ERR(priv, "Could not send REPLY_PHY_CALIBRATION_CMD\n"); - data->state = IWL_CHAIN_NOISE_ACCUMULATE; - IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); + data->state = IL_CHAIN_NOISE_ACCUMULATE; + IL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); } } -static struct iwl_sensitivity_ranges iwl4965_sensitivity = { +static struct il_sensitivity_ranges il4965_sensitivity = { .min_nrg_cck = 97, .max_nrg_cck = 0, /* not used, set to 0 */ @@ -377,7 +377,7 @@ static struct iwl_sensitivity_ranges iwl4965_sensitivity = { .nrg_th_cca = 62, }; -static void iwl4965_set_ct_threshold(struct iwl_priv *priv) +static void il4965_set_ct_threshold(struct il_priv *priv) { /* want Kelvin */ priv->hw_params.ct_kill_threshold = @@ -385,13 +385,13 @@ static void iwl4965_set_ct_threshold(struct iwl_priv *priv) } /** - * iwl4965_hw_set_hw_params + * il4965_hw_set_hw_params * * Called when initializing driver */ -static int iwl4965_hw_set_hw_params(struct iwl_priv *priv) +static int il4965_hw_set_hw_params(struct il_priv *priv) { - if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES && + if (priv->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && priv->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) priv->cfg->base_params->num_of_queues = priv->cfg->mod_params->num_of_queues; @@ -400,10 +400,10 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; priv->hw_params.scd_bc_tbls_size = priv->cfg->base_params->num_of_queues * - sizeof(struct iwl4965_scd_bc_tbl); - priv->hw_params.tfd_size = sizeof(struct iwl_tfd); + sizeof(struct il4965_scd_bc_tbl); + priv->hw_params.tfd_size = sizeof(struct il_tfd); priv->hw_params.max_stations = IWL4965_STATION_COUNT; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; + priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; priv->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; priv->hw_params.max_bsm_size = BSM_SRAM_SIZE; @@ -411,20 +411,20 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; - priv->hw_params.tx_chains_num = iwl4965_num_of_ant(priv->cfg->valid_tx_ant); - priv->hw_params.rx_chains_num = iwl4965_num_of_ant(priv->cfg->valid_rx_ant); + priv->hw_params.tx_chains_num = il4965_num_of_ant(priv->cfg->valid_tx_ant); + priv->hw_params.rx_chains_num = il4965_num_of_ant(priv->cfg->valid_rx_ant); priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant; priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant; - iwl4965_set_ct_threshold(priv); + il4965_set_ct_threshold(priv); - priv->hw_params.sens = &iwl4965_sensitivity; + priv->hw_params.sens = &il4965_sensitivity; priv->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; return 0; } -static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) +static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) { s32 sign = 1; @@ -443,7 +443,7 @@ static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) } /** - * iwl4965_get_voltage_compensation - Power supply voltage comp for txpower + * il4965_get_voltage_compensation - Power supply voltage comp for txpower * * Determines power supply voltage compensation for txpower calculations. * Returns number of 1/2-dB steps to subtract from gain table index, @@ -453,17 +453,17 @@ static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) * Voltage indication is higher for lower voltage. * Lower voltage requires more gain (lower gain table index). */ -static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage, +static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage) { s32 comp = 0; - if ((TX_POWER_IWL_ILLEGAL_VOLTAGE == eeprom_voltage) || - (TX_POWER_IWL_ILLEGAL_VOLTAGE == current_voltage)) + if ((TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage) || + (TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage)) return 0; - iwl4965_math_div_round(current_voltage - eeprom_voltage, - TX_POWER_IWL_VOLTAGE_CODES_PER_03V, &comp); + il4965_math_div_round(current_voltage - eeprom_voltage, + TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); if (current_voltage > eeprom_voltage) comp *= 2; @@ -473,32 +473,32 @@ static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage, return comp; } -static s32 iwl4965_get_tx_atten_grp(u16 channel) +static s32 il4965_get_tx_atten_grp(u16 channel) { - if (channel >= CALIB_IWL_TX_ATTEN_GR5_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR5_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && + channel <= CALIB_IL_TX_ATTEN_GR5_LCH) return CALIB_CH_GROUP_5; - if (channel >= CALIB_IWL_TX_ATTEN_GR1_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR1_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR1_FCH && + channel <= CALIB_IL_TX_ATTEN_GR1_LCH) return CALIB_CH_GROUP_1; - if (channel >= CALIB_IWL_TX_ATTEN_GR2_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR2_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR2_FCH && + channel <= CALIB_IL_TX_ATTEN_GR2_LCH) return CALIB_CH_GROUP_2; - if (channel >= CALIB_IWL_TX_ATTEN_GR3_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR3_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR3_FCH && + channel <= CALIB_IL_TX_ATTEN_GR3_LCH) return CALIB_CH_GROUP_3; - if (channel >= CALIB_IWL_TX_ATTEN_GR4_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR4_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR4_FCH && + channel <= CALIB_IL_TX_ATTEN_GR4_LCH) return CALIB_CH_GROUP_4; return -EINVAL; } -static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel) +static u32 il4965_get_sub_band(const struct il_priv *priv, u32 channel) { s32 b = -1; @@ -514,41 +514,41 @@ static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel) return b; } -static s32 iwl4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) +static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) { s32 val; if (x2 == x1) return y1; else { - iwl4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); + il4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); return val + y2; } } /** - * iwl4965_interpolate_chan - Interpolate factory measurements for one channel + * il4965_interpolate_chan - Interpolate factory measurements for one channel * * Interpolates factory measurements from the two sample channels within a * sub-band, to apply to channel of interest. Interpolation is proportional to * differences in channel frequencies, which is proportional to differences * in channel number. */ -static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, - struct iwl_eeprom_calib_ch_info *chan_info) +static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, + struct il_eeprom_calib_ch_info *chan_info) { s32 s = -1; u32 c; u32 m; - const struct iwl_eeprom_calib_measure *m1; - const struct iwl_eeprom_calib_measure *m2; - struct iwl_eeprom_calib_measure *omeas; + const struct il_eeprom_calib_measure *m1; + const struct il_eeprom_calib_measure *m2; + struct il_eeprom_calib_measure *omeas; u32 ch_i1; u32 ch_i2; - s = iwl4965_get_sub_band(priv, channel); + s = il4965_get_sub_band(priv, channel); if (s >= EEPROM_TX_POWER_BANDS) { - IWL_ERR(priv, "Tx Power can not find channel %d\n", channel); + IL_ERR(priv, "Tx Power can not find channel %d\n", channel); return -1; } @@ -556,7 +556,7 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, ch_i2 = priv->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - IWL_DEBUG_TXPOWER(priv, "channel %d subband %d factory cal ch %d & %d\n", + IL_DEBUG_TXPOWER(priv, "channel %d subband %d factory cal ch %d & %d\n", channel, s, ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { @@ -568,34 +568,34 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, omeas = &(chan_info->measurements[c][m]); omeas->actual_pow = - (u8) iwl4965_interpolate_value(channel, ch_i1, + (u8) il4965_interpolate_value(channel, ch_i1, m1->actual_pow, ch_i2, m2->actual_pow); omeas->gain_idx = - (u8) iwl4965_interpolate_value(channel, ch_i1, + (u8) il4965_interpolate_value(channel, ch_i1, m1->gain_idx, ch_i2, m2->gain_idx); omeas->temperature = - (u8) iwl4965_interpolate_value(channel, ch_i1, + (u8) il4965_interpolate_value(channel, ch_i1, m1->temperature, ch_i2, m2->temperature); omeas->pa_det = - (s8) iwl4965_interpolate_value(channel, ch_i1, + (s8) il4965_interpolate_value(channel, ch_i1, m1->pa_det, ch_i2, m2->pa_det); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, m1->actual_pow, m2->actual_pow, omeas->actual_pow); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, m1->gain_idx, m2->gain_idx, omeas->gain_idx); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, m1->pa_det, m2->pa_det, omeas->pa_det); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, m1->temperature, m2->temperature, omeas->temperature); @@ -617,7 +617,7 @@ static s32 back_off_table[] = { /* Thermal compensation values for txpower for various frequency ranges ... * ratios from 3:1 to 4.5:1 of degrees (Celsius) per half-dB gain adjust */ -static struct iwl4965_txpower_comp_entry { +static struct il4965_txpower_comp_entry { s32 degrees_per_05db_a; s32 degrees_per_05db_a_denom; } tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { @@ -867,9 +867,9 @@ static const struct gain_entry gain_table[2][108] = { } }; -static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, +static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, u8 is_ht40, u8 ctrl_chan_high, - struct iwl4965_tx_power_db *tx_power_tbl) + struct il4965_tx_power_db *tx_power_tbl) { u8 saturation_power; s32 target_power; @@ -881,9 +881,9 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, s32 txatten_grp = CALIB_CH_GROUP_MAX; int i; int c; - const struct iwl_channel_info *ch_info = NULL; - struct iwl_eeprom_calib_ch_info ch_eeprom_info; - const struct iwl_eeprom_calib_measure *measurement; + const struct il_channel_info *ch_info = NULL; + struct il_eeprom_calib_ch_info ch_eeprom_info; + const struct il_eeprom_calib_measure *measurement; s16 voltage; s32 init_voltage; s32 voltage_compensation; @@ -900,24 +900,24 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, user_target_power = 2 * priv->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - IWL_DEBUG_TXPOWER(priv, "chan %d band %d is_ht40 %d\n", channel, band, + IL_DEBUG_TXPOWER(priv, "chan %d band %d is_ht40 %d\n", channel, band, is_ht40); - ch_info = iwl_legacy_get_channel_info(priv, priv->band, channel); + ch_info = il_get_channel_info(priv, priv->band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) + if (!il_is_channel_valid(ch_info)) return -EINVAL; /* get txatten group, used to select 1) thermal txpower adjustment * and 2) mimo txpower balance between Tx chains. */ - txatten_grp = iwl4965_get_tx_atten_grp(channel); + txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IWL_ERR(priv, "Can't find txatten group for channel %d.\n", + IL_ERR(priv, "Can't find txatten group for channel %d.\n", channel); return txatten_grp; } - IWL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n", + IL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n", channel, txatten_grp); if (is_ht40) { @@ -934,12 +934,12 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, else saturation_power = priv->calib_info->saturation_power52; - if (saturation_power < IWL_TX_POWER_SATURATION_MIN || - saturation_power > IWL_TX_POWER_SATURATION_MAX) { + if (saturation_power < IL_TX_POWER_SATURATION_MIN || + saturation_power > IL_TX_POWER_SATURATION_MAX) { if (band) - saturation_power = IWL_TX_POWER_DEFAULT_SATURATION_24; + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24; else - saturation_power = IWL_TX_POWER_DEFAULT_SATURATION_52; + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52; } /* regulatory txpower limits ... reg_limit values are in half-dBm, @@ -949,31 +949,31 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, else reg_limit = ch_info->max_power_avg * 2; - if ((reg_limit < IWL_TX_POWER_REGULATORY_MIN) || - (reg_limit > IWL_TX_POWER_REGULATORY_MAX)) { + if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) || + (reg_limit > IL_TX_POWER_REGULATORY_MAX)) { if (band) - reg_limit = IWL_TX_POWER_DEFAULT_REGULATORY_24; + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24; else - reg_limit = IWL_TX_POWER_DEFAULT_REGULATORY_52; + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52; } /* Interpolate txpower calibration values for this channel, * based on factory calibration tests on spaced channels. */ - iwl4965_interpolate_chan(priv, channel, &ch_eeprom_info); + il4965_interpolate_chan(priv, channel, &ch_eeprom_info); /* calculate tx gain adjustment based on power supply voltage */ voltage = le16_to_cpu(priv->calib_info->voltage); init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage); voltage_compensation = - iwl4965_get_voltage_compensation(voltage, init_voltage); + il4965_get_voltage_compensation(voltage, init_voltage); - IWL_DEBUG_TXPOWER(priv, "curr volt %d eeprom volt %d volt comp %d\n", + IL_DEBUG_TXPOWER(priv, "curr volt %d eeprom volt %d volt comp %d\n", init_voltage, voltage, voltage_compensation); /* get current temperature (Celsius) */ - current_temp = max(priv->temperature, IWL_TX_POWER_TEMPERATURE_MIN); - current_temp = min(priv->temperature, IWL_TX_POWER_TEMPERATURE_MAX); + current_temp = max(priv->temperature, IL_TX_POWER_TEMPERATURE_MIN); + current_temp = min(priv->temperature, IL_TX_POWER_TEMPERATURE_MAX); current_temp = KELVIN_TO_CELSIUS(current_temp); /* select thermal txpower adjustment params, based on channel group @@ -990,7 +990,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, /* txgain adjustment (in half-dB steps) based on difference * between factory and current temperature */ factory_temp = measurement->temperature; - iwl4965_math_div_round((current_temp - factory_temp) * + il4965_math_div_round((current_temp - factory_temp) * degrees_per_05db_denom, degrees_per_05db_num, &temperature_comp[c]); @@ -998,13 +998,13 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, factory_gain_index[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; - IWL_DEBUG_TXPOWER(priv, "chain = %d\n", c); - IWL_DEBUG_TXPOWER(priv, "fctry tmp %d, " + IL_DEBUG_TXPOWER(priv, "chain = %d\n", c); + IL_DEBUG_TXPOWER(priv, "fctry tmp %d, " "curr tmp %d, comp %d steps\n", factory_temp, current_temp, temperature_comp[c]); - IWL_DEBUG_TXPOWER(priv, "fctry idx %d, fctry pwr %d\n", + IL_DEBUG_TXPOWER(priv, "fctry idx %d, fctry pwr %d\n", factory_gain_index[c], factory_actual_pwr[c]); } @@ -1012,14 +1012,14 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, /* for each of 33 bit-rates (including 1 for CCK) */ for (i = 0; i < POWER_TABLE_NUM_ENTRIES; i++) { u8 is_mimo_rate; - union iwl4965_tx_power_dual_stream tx_power; + union il4965_tx_power_dual_stream tx_power; /* for mimo, reduce each chain's txpower by half * (3dB, 6 steps), so total output power is regulatory * compliant. */ if (i & 0x8) { current_regulatory = reg_limit - - IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION; + IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; is_mimo_rate = 1; } else { current_regulatory = reg_limit; @@ -1037,7 +1037,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - IWL_DEBUG_TXPOWER(priv, "rate %d sat %d reg %d usr %d tgt %d\n", + IL_DEBUG_TXPOWER(priv, "rate %d sat %d reg %d usr %d tgt %d\n", i, saturation_power - back_off_table[i], current_regulatory, user_target_power, target_power); @@ -1061,7 +1061,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, voltage_compensation + atten_value); -/* IWL_DEBUG_TXPOWER(priv, "calculated txpower index %d\n", +/* IL_DEBUG_TXPOWER(priv, "calculated txpower index %d\n", power_index); */ if (power_index < get_min_power_index(i, band)) @@ -1074,16 +1074,16 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, /* CCK, rate 32, reduce txpower for CCK */ if (i == POWER_TABLE_CCK_ENTRY) power_index += - IWL_TX_POWER_CCK_COMPENSATION_C_STEP; + IL_TX_POWER_CCK_COMPENSATION_C_STEP; /* stay within the table! */ if (power_index > 107) { - IWL_WARN(priv, "txpower index %d > 107\n", + IL_WARN(priv, "txpower index %d > 107\n", power_index); power_index = 107; } if (power_index < 0) { - IWL_WARN(priv, "txpower index %d < 0\n", + IL_WARN(priv, "txpower index %d < 0\n", power_index); power_index = 0; } @@ -1094,7 +1094,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, tx_power.s.dsp_predis_atten[c] = gain_table[band][power_index].dsp; - IWL_DEBUG_TXPOWER(priv, "chain %d mimo %d index %d " + IL_DEBUG_TXPOWER(priv, "chain %d mimo %d index %d " "gain 0x%02x dsp %d\n", c, atten_value, power_index, tx_power.s.radio_tx_gain[c], @@ -1109,19 +1109,19 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, } /** - * iwl4965_send_tx_power - Configure the TXPOWER level user limit + * il4965_send_tx_power - Configure the TXPOWER level user limit * * Uses the active RXON for channel, band, and characteristics (ht40, high) * The power limit is taken from priv->tx_power_user_lmt. */ -static int iwl4965_send_tx_power(struct iwl_priv *priv) +static int il4965_send_tx_power(struct il_priv *priv) { - struct iwl4965_txpowertable_cmd cmd = { 0 }; + struct il4965_txpowertable_cmd cmd = { 0 }; int ret; u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status), "TX Power requested while scanning!\n")) @@ -1137,26 +1137,26 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv) cmd.band = band; cmd.channel = ctx->active.channel; - ret = iwl4965_fill_txpower_tbl(priv, band, + ret = il4965_fill_txpower_tbl(priv, band, le16_to_cpu(ctx->active.channel), is_ht40, ctrl_chan_high, &cmd.tx_power); if (ret) goto out; - ret = iwl_legacy_send_cmd_pdu(priv, + ret = il_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd); out: return ret; } -static int iwl4965_send_rxon_assoc(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il4965_send_rxon_assoc(struct il_priv *priv, + struct il_rxon_context *ctx) { int ret = 0; - struct iwl4965_rxon_assoc_cmd rxon_assoc; - const struct iwl_legacy_rxon_cmd *rxon1 = &ctx->staging; - const struct iwl_legacy_rxon_cmd *rxon2 = &ctx->active; + struct il4965_rxon_assoc_cmd rxon_assoc; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; if ((rxon1->flags == rxon2->flags) && (rxon1->filter_flags == rxon2->filter_flags) && @@ -1167,7 +1167,7 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv, rxon2->ofdm_ht_dual_stream_basic_rates) && (rxon1->rx_chain == rxon2->rx_chain) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1182,21 +1182,21 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = iwl_legacy_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, + ret = il_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, sizeof(rxon_assoc), &rxon_assoc, NULL); return ret; } -static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ - struct iwl_legacy_rxon_cmd *active_rxon = (void *)&ctx->active; + struct il_rxon_cmd *active_rxon = (void *)&ctx->active; int ret; bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EBUSY; if (!ctx->is_active) @@ -1205,9 +1205,9 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c /* always get timestamp with Rx frame */ ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; - ret = iwl_legacy_check_rxon_cmd(priv, ctx); + ret = il_check_rxon_cmd(priv, ctx); if (ret) { - IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1217,28 +1217,28 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c */ if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status) && (priv->switch_channel != ctx->staging.channel)) { - IWL_DEBUG_11H(priv, "abort channel switch on %d\n", + IL_DEBUG_11H(priv, "abort channel switch on %d\n", le16_to_cpu(priv->switch_channel)); - iwl_legacy_chswitch_done(priv, false); + il_chswitch_done(priv, false); } /* If we don't need to send a full RXON, we can use - * iwl_rxon_assoc_cmd which is used to reconfigure filter + * il_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!iwl_legacy_full_rxon_required(priv, ctx)) { - ret = iwl_legacy_send_rxon_assoc(priv, ctx); + if (!il_full_rxon_required(priv, ctx)) { + ret = il_send_rxon_assoc(priv, ctx); if (ret) { - IWL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); + IL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - iwl_legacy_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(priv, ctx); /* * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(priv, priv->tx_power_next, false); return 0; } @@ -1246,31 +1246,31 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (iwl_legacy_is_associated_ctx(ctx) && new_assoc) { - IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + if (il_is_associated_ctx(ctx) && new_assoc) { + IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = iwl_legacy_send_cmd_pdu(priv, ctx->rxon_cmd, - sizeof(struct iwl_legacy_rxon_cmd), + ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), active_rxon); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (ret) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); + IL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); return ret; } - iwl_legacy_clear_ucode_stations(priv, ctx); - iwl_legacy_restore_stations(priv, ctx); - ret = iwl4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(priv, ctx); + il_restore_stations(priv, ctx); + ret = il4965_restore_default_wep_keys(priv, ctx); if (ret) { - IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); return ret; } } - IWL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(priv, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1278,7 +1278,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c le16_to_cpu(ctx->staging.channel), ctx->staging.bssid_addr); - iwl_legacy_set_rxon_hwcrypto(priv, ctx, + il_set_rxon_hwcrypto(priv, ctx, !priv->cfg->mod_params->sw_crypto); /* Apply the new configuration @@ -1286,19 +1286,19 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c * stations is needed after it (the RXON command) completes */ if (!new_assoc) { - ret = iwl_legacy_send_cmd_pdu(priv, ctx->rxon_cmd, - sizeof(struct iwl_legacy_rxon_cmd), &ctx->staging); + ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(priv, "Error setting new RXON (%d)\n", ret); return ret; } - IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); + IL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - iwl_legacy_clear_ucode_stations(priv, ctx); - iwl_legacy_restore_stations(priv, ctx); - ret = iwl4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(priv, ctx); + il_restore_stations(priv, ctx); + ret = il4965_restore_default_wep_keys(priv, ctx); if (ret) { - IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); return ret; } } @@ -1307,39 +1307,39 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c /* Apply the new configuration * RXON assoc doesn't clear the station table in uCode, */ - ret = iwl_legacy_send_cmd_pdu(priv, ctx->rxon_cmd, - sizeof(struct iwl_legacy_rxon_cmd), &ctx->staging); + ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(priv, "Error setting new RXON (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); } - iwl_legacy_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(priv, ctx); - iwl4965_init_sensitivity(priv); + il4965_init_sensitivity(priv); /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - ret = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true); + ret = il_set_tx_power(priv, priv->tx_power_next, true); if (ret) { - IWL_ERR(priv, "Error sending TX power (%d)\n", ret); + IL_ERR(priv, "Error sending TX power (%d)\n", ret); return ret; } return 0; } -static int iwl4965_hw_channel_switch(struct iwl_priv *priv, +static int il4965_hw_channel_switch(struct il_priv *priv, struct ieee80211_channel_switch *ch_switch) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; int rc; u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct iwl4965_channel_switch_cmd cmd; - const struct iwl_channel_info *ch_info; + struct il4965_channel_switch_cmd cmd; + const struct il_channel_info *ch_info; u32 switch_time_in_usec, ucode_switch_time; u16 ch; u32 tsf_low; @@ -1379,47 +1379,47 @@ static int iwl4965_hw_channel_switch(struct iwl_priv *priv, else { switch_time_in_usec = vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = iwl_legacy_usecs_to_beacons(priv, + ucode_switch_time = il_usecs_to_beacons(priv, switch_time_in_usec, beacon_interval); - cmd.switch_time = iwl_legacy_add_beacon_time(priv, + cmd.switch_time = il_add_beacon_time(priv, priv->ucode_beacon_time, ucode_switch_time, beacon_interval); } - IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n", + IL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n", cmd.switch_time); - ch_info = iwl_legacy_get_channel_info(priv, priv->band, ch); + ch_info = il_get_channel_info(priv, priv->band, ch); if (ch_info) - cmd.expect_beacon = iwl_legacy_is_channel_radar(ch_info); + cmd.expect_beacon = il_is_channel_radar(ch_info); else { - IWL_ERR(priv, "invalid channel switch from %u to %u\n", + IL_ERR(priv, "invalid channel switch from %u to %u\n", ctx->active.channel, ch); return -EFAULT; } - rc = iwl4965_fill_txpower_tbl(priv, band, ch, is_ht40, + rc = il4965_fill_txpower_tbl(priv, band, ch, is_ht40, ctrl_chan_high, &cmd.tx_power); if (rc) { - IWL_DEBUG_11H(priv, "error:%d fill txpower_tbl\n", rc); + IL_DEBUG_11H(priv, "error:%d fill txpower_tbl\n", rc); return rc; } - return iwl_legacy_send_cmd_pdu(priv, + return il_send_cmd_pdu(priv, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** - * iwl4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array + * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array */ -static void iwl4965_txq_update_byte_cnt_tbl(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +static void il4965_txq_update_byte_cnt_tbl(struct il_priv *priv, + struct il_tx_queue *txq, u16 byte_cnt) { - struct iwl4965_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr; + struct il4965_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr; int txq_id = txq->q.id; int write_ptr = txq->q.write_ptr; - int len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; + int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; __le16 bc_ent; WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX); @@ -1435,12 +1435,12 @@ static void iwl4965_txq_update_byte_cnt_tbl(struct iwl_priv *priv, } /** - * iwl4965_hw_get_temperature - return the calibrated temperature (in Kelvin) + * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) * @statistics: Provides the temperature reading from the uCode * * A return of <0 indicates bogus data in the statistics */ -static int iwl4965_hw_get_temperature(struct iwl_priv *priv) +static int il4965_hw_get_temperature(struct il_priv *priv) { s32 temperature; s32 vt; @@ -1450,13 +1450,13 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) if (test_bit(STATUS_TEMPERATURE, &priv->status) && (priv->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - IWL_DEBUG_TEMP(priv, "Running HT40 temperature calibration\n"); + IL_DEBUG_TEMP(priv, "Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[1]); R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[1]); R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[1]); R4 = le32_to_cpu(priv->card_alive_init.therm_r4[1]); } else { - IWL_DEBUG_TEMP(priv, "Running temperature calibration\n"); + IL_DEBUG_TEMP(priv, "Running temperature calibration\n"); R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[0]); R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[0]); R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[0]); @@ -1476,10 +1476,10 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) vt = sign_extend32(le32_to_cpu(priv->_4965.statistics. general.common.temperature), 23); - IWL_DEBUG_TEMP(priv, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + IL_DEBUG_TEMP(priv, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { - IWL_ERR(priv, "Calibration conflict R1 == R3\n"); + IL_ERR(priv, "Calibration conflict R1 == R3\n"); return -1; } @@ -1489,17 +1489,17 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) temperature /= (R3 - R1); temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - IWL_DEBUG_TEMP(priv, "Calibrated temperature: %dK, %dC\n", + IL_DEBUG_TEMP(priv, "Calibrated temperature: %dK, %dC\n", temperature, KELVIN_TO_CELSIUS(temperature)); return temperature; } /* Adjust Txpower only if temperature variance is greater than threshold. */ -#define IWL_TEMPERATURE_THRESHOLD 3 +#define IL_TEMPERATURE_THRESHOLD 3 /** - * iwl4965_is_temp_calib_needed - determines if new calibration is needed + * il4965_is_temp_calib_needed - determines if new calibration is needed * * If the temperature changed has changed sufficiently, then a recalibration * is needed. @@ -1507,12 +1507,12 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) * Assumes caller will replace priv->last_temperature once calibration * executed. */ -static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv) +static int il4965_is_temp_calib_needed(struct il_priv *priv) { int temp_diff; if (!test_bit(STATUS_STATISTICS, &priv->status)) { - IWL_DEBUG_TEMP(priv, "Temperature not updated -- no statistics.\n"); + IL_DEBUG_TEMP(priv, "Temperature not updated -- no statistics.\n"); return 0; } @@ -1520,39 +1520,39 @@ static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv) /* get absolute value */ if (temp_diff < 0) { - IWL_DEBUG_POWER(priv, "Getting cooler, delta %d\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting cooler, delta %d\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IWL_DEBUG_POWER(priv, "Temperature unchanged\n"); + IL_DEBUG_POWER(priv, "Temperature unchanged\n"); else - IWL_DEBUG_POWER(priv, "Getting warmer, delta %d\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting warmer, delta %d\n", temp_diff); - if (temp_diff < IWL_TEMPERATURE_THRESHOLD) { - IWL_DEBUG_POWER(priv, " => thermal txpower calib not needed\n"); + if (temp_diff < IL_TEMPERATURE_THRESHOLD) { + IL_DEBUG_POWER(priv, " => thermal txpower calib not needed\n"); return 0; } - IWL_DEBUG_POWER(priv, " => thermal txpower calib needed\n"); + IL_DEBUG_POWER(priv, " => thermal txpower calib needed\n"); return 1; } -static void iwl4965_temperature_calib(struct iwl_priv *priv) +static void il4965_temperature_calib(struct il_priv *priv) { s32 temp; - temp = iwl4965_hw_get_temperature(priv); - if (IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) + temp = il4965_hw_get_temperature(priv); + if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) return; if (priv->temperature != temp) { if (priv->temperature) - IWL_DEBUG_TEMP(priv, "Temperature changed " + IL_DEBUG_TEMP(priv, "Temperature changed " "from %dC to %dC\n", KELVIN_TO_CELSIUS(priv->temperature), KELVIN_TO_CELSIUS(temp)); else - IWL_DEBUG_TEMP(priv, "Temperature " + IL_DEBUG_TEMP(priv, "Temperature " "initialized to %dC\n", KELVIN_TO_CELSIUS(temp)); } @@ -1562,27 +1562,27 @@ static void iwl4965_temperature_calib(struct iwl_priv *priv) if (!priv->disable_tx_power_cal && unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && - iwl4965_is_temp_calib_needed(priv)) + il4965_is_temp_calib_needed(priv)) queue_work(priv->workqueue, &priv->txpower_work); } -static u16 iwl4965_get_hcmd_size(u8 cmd_id, u16 len) +static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case REPLY_RXON: - return (u16) sizeof(struct iwl4965_rxon_cmd); + return (u16) sizeof(struct il4965_rxon_cmd); default: return len; } } -static u16 iwl4965_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, +static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 *data) { - struct iwl4965_addsta_cmd *addsta = (struct iwl4965_addsta_cmd *)data; + struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; addsta->mode = cmd->mode; memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct iwl4965_keyinfo)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); addsta->station_flags = cmd->station_flags; addsta->station_flags_msk = cmd->station_flags_msk; addsta->tid_disable_tx = cmd->tid_disable_tx; @@ -1593,20 +1593,20 @@ static u16 iwl4965_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, addsta->reserved1 = cpu_to_le16(0); addsta->reserved2 = cpu_to_le16(0); - return (u16)sizeof(struct iwl4965_addsta_cmd); + return (u16)sizeof(struct il4965_addsta_cmd); } -static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) +static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) { return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; } /** - * iwl4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue + * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ -static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, - struct iwl_ht_agg *agg, - struct iwl4965_tx_resp *tx_resp, +static int il4965_tx_status_reply_tx(struct il_priv *priv, + struct il_ht_agg *agg, + struct il4965_tx_resp *tx_resp, int txq_id, u16 start_idx) { u16 status; @@ -1617,7 +1617,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, int i, sh, idx; u16 seq; if (agg->wait_for_ba) - IWL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n"); + IL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n"); agg->frame_count = tx_resp->frame_count; agg->start_idx = start_idx; @@ -1630,18 +1630,18 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, status = le16_to_cpu(frame_status[0].status); idx = start_idx; - IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n", + IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n", agg->frame_count, agg->start_idx, idx); info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb); info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags &= ~IEEE80211_TX_CTL_AMPDU; - info->flags |= iwl4965_tx_status_to_mac80211(status); - iwl4965_hwrate_to_tx_control(priv, rate_n_flags, info); + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(priv, rate_n_flags, info); - IWL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n", + IL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n", status & 0xff, tx_resp->failure_frame); - IWL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags); + IL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; } else { @@ -1661,12 +1661,12 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, AGG_TX_STATE_ABORT_MSK)) continue; - IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n", + IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n", agg->frame_count, txq_id, idx); - hdr = iwl_legacy_tx_queue_get_hdr(priv, txq_id, idx); + hdr = il_tx_queue_get_hdr(priv, txq_id, idx); if (!hdr) { - IWL_ERR(priv, + IL_ERR(priv, "BUG_ON idx doesn't point to valid skb" " idx=%d, txq_id=%d\n", idx, txq_id); return -1; @@ -1674,14 +1674,14 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IWL_ERR(priv, + IL_ERR(priv, "BUG_ON idx doesn't match seq control" " idx=%d, seq_idx=%d, seq=%d\n", idx, SEQ_TO_SN(sc), hdr->seq_ctrl); return -1; } - IWL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n", + IL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n", i, idx, SEQ_TO_SN(sc)); sh = idx - start; @@ -1699,13 +1699,13 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, sh = 0; } bitmap |= 1ULL << sh; - IWL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n", start, (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; - IWL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n", agg->frame_count, agg->start_idx, (unsigned long long)agg->bitmap); @@ -1715,18 +1715,18 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, return 0; } -static u8 iwl4965_find_station(struct iwl_priv *priv, const u8 *addr) +static u8 il4965_find_station(struct il_priv *priv, const u8 *addr) { int i; int start = 0; - int ret = IWL_INVALID_STATION; + int ret = IL_INVALID_STATION; unsigned long flags; if ((priv->iw_mode == NL80211_IFTYPE_ADHOC)) - start = IWL_STA_ID; + start = IL_STA_ID; if (is_broadcast_ether_addr(addr)) - return priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id; + return priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; spin_lock_irqsave(&priv->sta_lock, flags); for (i = start; i < priv->hw_params.max_stations; i++) @@ -1737,7 +1737,7 @@ static u8 iwl4965_find_station(struct iwl_priv *priv, const u8 *addr) goto out; } - IWL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n", + IL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n", addr, priv->num_stations); out: @@ -1746,42 +1746,42 @@ static u8 iwl4965_find_station(struct iwl_priv *priv, const u8 *addr) * arrive before we completed processing the adding of * station */ - if (ret != IWL_INVALID_STATION && - (!(priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) || - ((priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) && - (priv->stations[ret].used & IWL_STA_UCODE_INPROGRESS)))) { - IWL_ERR(priv, "Requested station info for sta %d before ready.\n", + if (ret != IL_INVALID_STATION && + (!(priv->stations[ret].used & IL_STA_UCODE_ACTIVE) || + ((priv->stations[ret].used & IL_STA_UCODE_ACTIVE) && + (priv->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { + IL_ERR(priv, "Requested station info for sta %d before ready.\n", ret); - ret = IWL_INVALID_STATION; + ret = IL_INVALID_STATION; } spin_unlock_irqrestore(&priv->sta_lock, flags); return ret; } -static int iwl4965_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) +static int il4965_get_ra_sta_id(struct il_priv *priv, struct ieee80211_hdr *hdr) { if (priv->iw_mode == NL80211_IFTYPE_STATION) { - return IWL_AP_ID; + return IL_AP_ID; } else { u8 *da = ieee80211_get_DA(hdr); - return iwl4965_find_station(priv, da); + return il4965_find_station(priv, da); } } /** - * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response + * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response */ -static void iwl4965_rx_reply_tx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_reply_tx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct iwl_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &priv->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; - struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; u32 status = le32_to_cpu(tx_resp->u.status); int uninitialized_var(tid); int sta_id; @@ -1789,8 +1789,8 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, u8 *qc = NULL; unsigned long flags; - if ((index >= txq->q.n_bd) || (iwl_legacy_queue_used(&txq->q, index) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -1801,88 +1801,88 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); memset(&info->status, 0, sizeof(info->status)); - hdr = iwl_legacy_tx_queue_get_hdr(priv, txq_id, index); + hdr = il_tx_queue_get_hdr(priv, txq_id, index); if (ieee80211_is_data_qos(hdr->frame_control)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; } - sta_id = iwl4965_get_ra_sta_id(priv, hdr); - if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) { - IWL_ERR(priv, "Station not known\n"); + sta_id = il4965_get_ra_sta_id(priv, hdr); + if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { + IL_ERR(priv, "Station not known\n"); return; } spin_lock_irqsave(&priv->sta_lock, flags); if (txq->sched_retry) { - const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); - struct iwl_ht_agg *agg = NULL; + const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); + struct il_ht_agg *agg = NULL; WARN_ON(!qc); agg = &priv->stations[sta_id].tid[tid].agg; - iwl4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); + il4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); /* check if BAR is needed */ - if ((tx_resp->frame_count == 1) && !iwl4965_is_tx_success(status)) + if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; if (txq->q.read_ptr != (scd_ssn & 0xff)) { - index = iwl_legacy_queue_dec_wrap(scd_ssn & 0xff, + index = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); - IWL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn " + IL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn " "%d index %d\n", scd_ssn , index); - freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); + freed = il4965_tx_queue_reclaim(priv, txq_id, index); if (qc) - iwl4965_free_tfds_in_queue(priv, sta_id, + il4965_free_tfds_in_queue(priv, sta_id, tid, freed); if (priv->mac80211_registered && - (iwl_legacy_queue_space(&txq->q) > txq->q.low_mark) - && (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) - iwl_legacy_wake_queue(priv, txq); + (il_queue_space(&txq->q) > txq->q.low_mark) + && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + il_wake_queue(priv, txq); } } else { info->status.rates[0].count = tx_resp->failure_frame + 1; - info->flags |= iwl4965_tx_status_to_mac80211(status); - iwl4965_hwrate_to_tx_control(priv, + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), info); - IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " + IL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " "rate_n_flags 0x%x retries %d\n", txq_id, - iwl4965_get_tx_fail_reason(status), status, + il4965_get_tx_fail_reason(status), status, le32_to_cpu(tx_resp->rate_n_flags), tx_resp->failure_frame); - freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); - if (qc && likely(sta_id != IWL_INVALID_STATION)) - iwl4965_free_tfds_in_queue(priv, sta_id, tid, freed); - else if (sta_id == IWL_INVALID_STATION) - IWL_DEBUG_TX_REPLY(priv, "Station not known\n"); + freed = il4965_tx_queue_reclaim(priv, txq_id, index); + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_free_tfds_in_queue(priv, sta_id, tid, freed); + else if (sta_id == IL_INVALID_STATION) + IL_DEBUG_TX_REPLY(priv, "Station not known\n"); if (priv->mac80211_registered && - (iwl_legacy_queue_space(&txq->q) > txq->q.low_mark)) - iwl_legacy_wake_queue(priv, txq); + (il_queue_space(&txq->q) > txq->q.low_mark)) + il_wake_queue(priv, txq); } - if (qc && likely(sta_id != IWL_INVALID_STATION)) - iwl4965_txq_check_empty(priv, sta_id, tid, txq_id); + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_txq_check_empty(priv, sta_id, tid, txq_id); - iwl4965_check_abort_status(priv, tx_resp->frame_count, status); + il4965_check_abort_status(priv, tx_resp->frame_count, status); spin_unlock_irqrestore(&priv->sta_lock, flags); } -static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl4965_beacon_notif *beacon = (void *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; u8 rate __maybe_unused = - iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d " + IL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d " "tsf:0x%.8x%.8x rate:%d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1894,36 +1894,36 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, } /* Set up 4965-specific Rx frame reply handlers */ -static void iwl4965_rx_handler_setup(struct iwl_priv *priv) +static void il4965_rx_handler_setup(struct il_priv *priv) { /* Legacy Rx frames */ - priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx; + priv->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; /* Tx response */ - priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; - priv->rx_handlers[BEACON_NOTIFICATION] = iwl4965_rx_beacon_notif; + priv->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; + priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; } -static struct iwl_hcmd_ops iwl4965_hcmd = { - .rxon_assoc = iwl4965_send_rxon_assoc, - .commit_rxon = iwl4965_commit_rxon, - .set_rxon_chain = iwl4965_set_rxon_chain, +static struct il_hcmd_ops il4965_hcmd = { + .rxon_assoc = il4965_send_rxon_assoc, + .commit_rxon = il4965_commit_rxon, + .set_rxon_chain = il4965_set_rxon_chain, }; -static void iwl4965_post_scan(struct iwl_priv *priv) +static void il4965_post_scan(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } -static void iwl4965_post_associate(struct iwl_priv *priv) +static void il4965_post_associate(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; struct ieee80211_conf *conf = NULL; int ret = 0; @@ -1934,28 +1934,28 @@ static void iwl4965_post_associate(struct iwl_priv *priv) if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); - conf = iwl_legacy_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(priv->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); - ret = iwl_legacy_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(priv, ctx); if (ret) - IWL_WARN(priv, "RXON timing - " + IL_WARN(priv, "RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - iwl_legacy_set_rxon_ht(priv, &priv->current_ht_config); + il_set_rxon_ht(priv, &priv->current_ht_config); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", vif->bss_conf.aid, vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) @@ -1970,19 +1970,19 @@ static void iwl4965_post_associate(struct iwl_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); - IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", vif->bss_conf.aid, ctx->active.bssid_addr); switch (vif->type) { case NL80211_IFTYPE_STATION: break; case NL80211_IFTYPE_ADHOC: - iwl4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(priv); break; default: - IWL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(priv, "%s Should not be called in %d mode\n", __func__, vif->type); break; } @@ -1990,17 +1990,17 @@ static void iwl4965_post_associate(struct iwl_priv *priv) /* the chain noise calibration will enabled PM upon completion * If chain noise has already been run, then we need to enable * power management here */ - if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE) - iwl_legacy_power_update_mode(priv, false); + if (priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE) + il_power_update_mode(priv, false); /* Enable Rx differential gain and sensitivity calibrations */ - iwl4965_chain_noise_reset(priv); + il4965_chain_noise_reset(priv); priv->start_calib = 1; } -static void iwl4965_config_ap(struct iwl_priv *priv) +static void il4965_config_ap(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int ret = 0; @@ -2010,22 +2010,22 @@ static void iwl4965_config_ap(struct iwl_priv *priv) return; /* The following should be done only at AP bring up */ - if (!iwl_legacy_is_associated_ctx(ctx)) { + if (!il_is_associated_ctx(ctx)) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); /* RXON Timing */ - ret = iwl_legacy_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(priv, ctx); if (ret) - IWL_WARN(priv, "RXON timing failed - " + IL_WARN(priv, "RXON timing failed - " "Attempting to continue.\n"); /* AP has all antennas */ priv->chain_noise_data.active_chains = priv->hw_params.valid_rx_ant; - iwl_legacy_set_rxon_ht(priv, &priv->current_ht_config); + il_set_rxon_ht(priv, &priv->current_ht_config); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); @@ -2047,37 +2047,37 @@ static void iwl4965_config_ap(struct iwl_priv *priv) ~RXON_FLG_SHORT_SLOT_MSK; } /* need to send beacon cmd before committing assoc RXON! */ - iwl4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(priv); /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } - iwl4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(priv); } -static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { - .get_hcmd_size = iwl4965_get_hcmd_size, - .build_addsta_hcmd = iwl4965_build_addsta_hcmd, - .request_scan = iwl4965_request_scan, - .post_scan = iwl4965_post_scan, +static struct il_hcmd_utils_ops il4965_hcmd_utils = { + .get_hcmd_size = il4965_get_hcmd_size, + .build_addsta_hcmd = il4965_build_addsta_hcmd, + .request_scan = il4965_request_scan, + .post_scan = il4965_post_scan, }; -static struct iwl_lib_ops iwl4965_lib = { - .set_hw_params = iwl4965_hw_set_hw_params, - .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl, - .txq_attach_buf_to_tfd = iwl4965_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = iwl4965_hw_txq_free_tfd, - .txq_init = iwl4965_hw_tx_queue_init, - .rx_handler_setup = iwl4965_rx_handler_setup, - .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, - .init_alive_start = iwl4965_init_alive_start, - .load_ucode = iwl4965_load_bsm, - .dump_nic_error_log = iwl4965_dump_nic_error_log, - .dump_fh = iwl4965_dump_fh, - .set_channel_switch = iwl4965_hw_channel_switch, +static struct il_lib_ops il4965_lib = { + .set_hw_params = il4965_hw_set_hw_params, + .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl, + .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il4965_hw_txq_free_tfd, + .txq_init = il4965_hw_tx_queue_init, + .rx_handler_setup = il4965_rx_handler_setup, + .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, + .init_alive_start = il4965_init_alive_start, + .load_ucode = il4965_load_bsm, + .dump_nic_error_log = il4965_dump_nic_error_log, + .dump_fh = il4965_dump_fh, + .set_channel_switch = il4965_hw_channel_switch, .apm_ops = { - .init = iwl_legacy_apm_init, - .config = iwl4965_nic_config, + .init = il_apm_init, + .config = il4965_nic_config, }, .eeprom_ops = { .regulatory_bands = { @@ -2089,60 +2089,60 @@ static struct iwl_lib_ops iwl4965_lib = { EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS }, - .acquire_semaphore = iwl4965_eeprom_acquire_semaphore, - .release_semaphore = iwl4965_eeprom_release_semaphore, + .acquire_semaphore = il4965_eeprom_acquire_semaphore, + .release_semaphore = il4965_eeprom_release_semaphore, }, - .send_tx_power = iwl4965_send_tx_power, - .update_chain_flags = iwl4965_update_chain_flags, + .send_tx_power = il4965_send_tx_power, + .update_chain_flags = il4965_update_chain_flags, .temp_ops = { - .temperature = iwl4965_temperature_calib, + .temperature = il4965_temperature_calib, }, .debugfs_ops = { - .rx_stats_read = iwl4965_ucode_rx_stats_read, - .tx_stats_read = iwl4965_ucode_tx_stats_read, - .general_stats_read = iwl4965_ucode_general_stats_read, + .rx_stats_read = il4965_ucode_rx_stats_read, + .tx_stats_read = il4965_ucode_tx_stats_read, + .general_stats_read = il4965_ucode_general_stats_read, }, }; -static const struct iwl_legacy_ops iwl4965_legacy_ops = { - .post_associate = iwl4965_post_associate, - .config_ap = iwl4965_config_ap, - .manage_ibss_station = iwl4965_manage_ibss_station, - .update_bcast_stations = iwl4965_update_bcast_stations, +static const struct il_legacy_ops il4965_legacy_ops = { + .post_associate = il4965_post_associate, + .config_ap = il4965_config_ap, + .manage_ibss_station = il4965_manage_ibss_station, + .update_bcast_stations = il4965_update_bcast_stations, }; -struct ieee80211_ops iwl4965_hw_ops = { - .tx = iwl4965_mac_tx, - .start = iwl4965_mac_start, - .stop = iwl4965_mac_stop, - .add_interface = iwl_legacy_mac_add_interface, - .remove_interface = iwl_legacy_mac_remove_interface, - .change_interface = iwl_legacy_mac_change_interface, - .config = iwl_legacy_mac_config, - .configure_filter = iwl4965_configure_filter, - .set_key = iwl4965_mac_set_key, - .update_tkip_key = iwl4965_mac_update_tkip_key, - .conf_tx = iwl_legacy_mac_conf_tx, - .reset_tsf = iwl_legacy_mac_reset_tsf, - .bss_info_changed = iwl_legacy_mac_bss_info_changed, - .ampdu_action = iwl4965_mac_ampdu_action, - .hw_scan = iwl_legacy_mac_hw_scan, - .sta_add = iwl4965_mac_sta_add, - .sta_remove = iwl_legacy_mac_sta_remove, - .channel_switch = iwl4965_mac_channel_switch, - .tx_last_beacon = iwl_legacy_mac_tx_last_beacon, +struct ieee80211_ops il4965_hw_ops = { + .tx = il4965_mac_tx, + .start = il4965_mac_start, + .stop = il4965_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il4965_configure_filter, + .set_key = il4965_mac_set_key, + .update_tkip_key = il4965_mac_update_tkip_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .ampdu_action = il4965_mac_ampdu_action, + .hw_scan = il_mac_hw_scan, + .sta_add = il4965_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .channel_switch = il4965_mac_channel_switch, + .tx_last_beacon = il_mac_tx_last_beacon, }; -static const struct iwl_ops iwl4965_ops = { - .lib = &iwl4965_lib, - .hcmd = &iwl4965_hcmd, - .utils = &iwl4965_hcmd_utils, - .led = &iwl4965_led_ops, - .legacy = &iwl4965_legacy_ops, - .ieee80211_ops = &iwl4965_hw_ops, +static const struct il_ops il4965_ops = { + .lib = &il4965_lib, + .hcmd = &il4965_hcmd, + .utils = &il4965_hcmd_utils, + .led = &il4965_led_ops, + .legacy = &il4965_legacy_ops, + .ieee80211_ops = &il4965_hw_ops, }; -static struct iwl_base_params iwl4965_base_params = { +static struct il_base_params il4965_base_params = { .eeprom_size = IWL4965_EEPROM_IMG_SIZE, .num_of_queues = IWL49_NUM_QUEUES, .num_of_ampdu_queues = IWL49_NUM_AMPDU_QUEUES, @@ -2151,27 +2151,27 @@ static struct iwl_base_params iwl4965_base_params = { .use_bsm = true, .led_compensation = 61, .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS, - .wd_timeout = IWL_DEF_WD_TIMEOUT, + .wd_timeout = IL_DEF_WD_TIMEOUT, .temperature_kelvin = true, .ucode_tracing = true, .sensitivity_calib_by_driver = true, .chain_noise_calib_by_driver = true, }; -struct iwl_cfg iwl4965_cfg = { +struct il_cfg il4965_cfg = { .name = "Intel(R) Wireless WiFi Link 4965AGN", .fw_name_pre = IWL4965_FW_PRE, .ucode_api_max = IWL4965_UCODE_API_MAX, .ucode_api_min = IWL4965_UCODE_API_MIN, - .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, + .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, .valid_tx_ant = ANT_AB, .valid_rx_ant = ANT_ABC, .eeprom_ver = EEPROM_4965_EEPROM_VERSION, .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, - .ops = &iwl4965_ops, - .mod_params = &iwl4965_mod_params, - .base_params = &iwl4965_base_params, - .led_mode = IWL_LED_BLINK, + .ops = &il4965_ops, + .mod_params = &il4965_mod_params, + .base_params = &il4965_base_params, + .led_mode = IL_LED_BLINK, /* * Force use of chains B and C for scan RX on 5 GHz band * because the device has off-channel reception on chain A. diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 01f8163..7b32216 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -60,92 +60,92 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_4965_h__ -#define __iwl_4965_h__ +#ifndef __il_4965_h__ +#define __il_4965_h__ #include "iwl-dev.h" /* configuration for the _4965 devices */ -extern struct iwl_cfg iwl4965_cfg; +extern struct il_cfg il4965_cfg; -extern struct iwl_mod_params iwl4965_mod_params; +extern struct il_mod_params il4965_mod_params; -extern struct ieee80211_ops iwl4965_hw_ops; +extern struct ieee80211_ops il4965_hw_ops; /* tx queue */ -void iwl4965_free_tfds_in_queue(struct iwl_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *priv, int sta_id, int tid, int freed); /* RXON */ -void iwl4965_set_rxon_chain(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +void il4965_set_rxon_chain(struct il_priv *priv, + struct il_rxon_context *ctx); /* uCode */ -int iwl4965_verify_ucode(struct iwl_priv *priv); +int il4965_verify_ucode(struct il_priv *priv); /* lib */ -void iwl4965_check_abort_status(struct iwl_priv *priv, +void il4965_check_abort_status(struct il_priv *priv, u8 frame_count, u32 status); -void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -int iwl4965_hw_nic_init(struct iwl_priv *priv); -int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display); +void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); +int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq); +int il4965_hw_nic_init(struct il_priv *priv); +int il4965_dump_fh(struct il_priv *priv, char **buf, bool display); /* rx */ -void iwl4965_rx_queue_restock(struct iwl_priv *priv); -void iwl4965_rx_replenish(struct iwl_priv *priv); -void iwl4965_rx_replenish_now(struct iwl_priv *priv); -void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -int iwl4965_rxq_stop(struct iwl_priv *priv); -int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void iwl4965_rx_reply_rx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl4965_rx_handle(struct iwl_priv *priv); +void il4965_rx_queue_restock(struct il_priv *priv); +void il4965_rx_replenish(struct il_priv *priv); +void il4965_rx_replenish_now(struct il_priv *priv); +void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq); +int il4965_rxq_stop(struct il_priv *priv); +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); +void il4965_rx_reply_rx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il4965_rx_reply_rx_phy(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il4965_rx_handle(struct il_priv *priv); /* tx */ -void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq); -int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, +int il4965_hw_tx_queue_init(struct il_priv *priv, + struct il_tx_queue *txq); +void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, struct ieee80211_tx_info *info); -int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); -int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb); +int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn); -int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); -int iwl4965_txq_check_empty(struct iwl_priv *priv, +int il4965_txq_check_empty(struct il_priv *priv, int sta_id, u8 tid, int txq_id); -void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); -void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv); -int iwl4965_txq_ctx_alloc(struct iwl_priv *priv); -void iwl4965_txq_ctx_reset(struct iwl_priv *priv); -void iwl4965_txq_ctx_stop(struct iwl_priv *priv); -void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask); +void il4965_rx_reply_compressed_ba(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index); +void il4965_hw_txq_ctx_free(struct il_priv *priv); +int il4965_txq_ctx_alloc(struct il_priv *priv); +void il4965_txq_ctx_reset(struct il_priv *priv); +void il4965_txq_ctx_stop(struct il_priv *priv); +void il4965_txq_set_sched(struct il_priv *priv, u32 mask); /* * Acquire priv->lock before calling this function ! */ -void iwl4965_set_wr_ptrs(struct iwl_priv *priv, int txq_id, u32 index); +void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index); /** - * iwl4965_tx_queue_set_status - (optionally) start Tx/Cmd queue + * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed * @scd_retry: (1) Indicates queue will be used in aggregation mode * * NOTE: Acquire priv->lock before calling this function ! */ -void iwl4965_tx_queue_set_status(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il4965_tx_queue_set_status(struct il_priv *priv, + struct il_tx_queue *txq, int tx_fifo_id, int scd_retry); -static inline u32 iwl4965_tx_status_to_mac80211(u32 status) +static inline u32 il4965_tx_status_to_mac80211(u32 status) { status &= TX_STATUS_MSK; @@ -160,123 +160,123 @@ static inline u32 iwl4965_tx_status_to_mac80211(u32 status) } } -static inline bool iwl4965_is_tx_success(u32 status) +static inline bool il4965_is_tx_success(u32 status) { status &= TX_STATUS_MSK; return (status == TX_STATUS_SUCCESS) || (status == TX_STATUS_DIRECT_DONE); } -u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid); +u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant_idx, u8 valid); /* rx */ -void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -bool iwl4965_good_plcp_health(struct iwl_priv *priv, - struct iwl_rx_packet *pkt); -void iwl4965_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl4965_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); +void il4965_rx_missed_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +bool il4965_good_plcp_health(struct il_priv *priv, + struct il_rx_packet *pkt); +void il4965_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il4965_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); /* scan */ -int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); +int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); /* station mgmt */ -int iwl4965_manage_ibss_station(struct iwl_priv *priv, +int il4965_manage_ibss_station(struct il_priv *priv, struct ieee80211_vif *vif, bool add); /* hcmd */ -int iwl4965_send_beacon_cmd(struct iwl_priv *priv); +int il4965_send_beacon_cmd(struct il_priv *priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -const char *iwl4965_get_tx_fail_reason(u32 status); +const char *il4965_get_tx_fail_reason(u32 status); #else static inline const char * -iwl4965_get_tx_fail_reason(u32 status) { return ""; } +il4965_get_tx_fail_reason(u32 status) { return ""; } #endif /* station management */ -int iwl4965_alloc_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl4965_add_bssid_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_alloc_bcast_station(struct il_priv *priv, + struct il_rxon_context *ctx); +int il4965_add_bssid_station(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r); -int iwl4965_remove_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int iwl4965_set_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_set_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int iwl4965_restore_default_wep_keys(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl4965_set_dynamic_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_restore_default_wep_keys(struct il_priv *priv, + struct il_rxon_context *ctx); +int il4965_set_dynamic_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -int iwl4965_remove_dynamic_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_dynamic_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -void iwl4965_update_tkip_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il4965_update_tkip_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv, +int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, int sta_id, int tid); -int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, int tid, u16 ssn); -int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, int tid); -void iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv, +void il4965_sta_modify_sleep_tx_count(struct il_priv *priv, int sta_id, int cnt); -int iwl4965_update_bcast_stations(struct iwl_priv *priv); +int il4965_update_bcast_stations(struct il_priv *priv); /* rate */ -static inline u32 iwl4965_ant_idx_to_flags(u8 ant_idx) +static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) { return BIT(ant_idx) << RATE_MCS_ANT_POS; } -static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags) +static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) { return le32_to_cpu(rate_n_flags) & 0xFF; } -static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u32 flags) +static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) { return cpu_to_le32(flags|(u32)rate); } /* eeprom */ -void iwl4965_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); -int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv); -void iwl4965_eeprom_release_semaphore(struct iwl_priv *priv); -int iwl4965_eeprom_check_version(struct iwl_priv *priv); +void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac); +int il4965_eeprom_acquire_semaphore(struct il_priv *priv); +void il4965_eeprom_release_semaphore(struct il_priv *priv); +int il4965_eeprom_check_version(struct il_priv *priv); /* mac80211 handlers (for 4965) */ -void iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); -int iwl4965_mac_start(struct ieee80211_hw *hw); -void iwl4965_mac_stop(struct ieee80211_hw *hw); -void iwl4965_configure_filter(struct ieee80211_hw *hw, +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); +int il4965_mac_start(struct ieee80211_hw *hw); +void il4965_mac_stop(struct ieee80211_hw *hw); +void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, unsigned int *total_flags, u64 multicast); -int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key); -void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size); -int iwl4965_mac_sta_add(struct ieee80211_hw *hw, +int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, +void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch); -#endif /* __iwl_4965_h__ */ +#endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 8990405..347d402 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -66,22 +66,22 @@ * Please use iwl-dev.h for driver implementation definitions. */ -#ifndef __iwl_legacy_commands_h__ -#define __iwl_legacy_commands_h__ +#ifndef __il_commands_h__ +#define __il_commands_h__ -struct iwl_priv; +struct il_priv; /* uCode version contains 4 values: Major/Minor/API/Serial */ -#define IWL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) -#define IWL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) -#define IWL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) -#define IWL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) +#define IL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) +#define IL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) +#define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) +#define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) /* Tx rates */ -#define IWL_CCK_RATES 4 -#define IWL_OFDM_RATES 8 -#define IWL_MAX_RATES (IWL_CCK_RATES + IWL_OFDM_RATES) +#define IL_CCK_RATES 4 +#define IL_OFDM_RATES 8 +#define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) enum { REPLY_ALIVE = 0x1, @@ -163,8 +163,8 @@ enum { * *****************************************************************************/ -/* iwl_cmd_header flags value */ -#define IWL_CMD_FAILED_MSK 0x40 +/* il_cmd_header flags value */ +#define IL_CMD_FAILED_MSK 0x40 #define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) #define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) @@ -174,12 +174,12 @@ enum { #define SEQ_RX_FRAME cpu_to_le16(0x8000) /** - * struct iwl_cmd_header + * struct il_cmd_header * * This header format appears in the beginning of each command sent from the * driver, and each response/notification received from uCode. */ -struct iwl_cmd_header { +struct il_cmd_header { u8 cmd; /* Command ID: REPLY_RXON, etc. */ u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ /* @@ -212,7 +212,7 @@ struct iwl_cmd_header { /** - * struct iwl3945_tx_power + * struct il3945_tx_power * * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH * @@ -223,21 +223,21 @@ struct iwl_cmd_header { * 2) Radio gain. This sets the analog gain of the radio Tx path. * It is a coarser setting, and behaves in a logarithmic (dB) fashion. * - * Driver obtains values from struct iwl3945_tx_power power_gain_table[][]. + * Driver obtains values from struct il3945_tx_power power_gain_table[][]. */ -struct iwl3945_tx_power { +struct il3945_tx_power { u8 tx_gain; /* gain for analog radio */ u8 dsp_atten; /* gain for DSP */ } __packed; /** - * struct iwl3945_power_per_rate + * struct il3945_power_per_rate * * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH */ -struct iwl3945_power_per_rate { +struct il3945_power_per_rate { u8 rate; /* plcp */ - struct iwl3945_tx_power tpc; + struct il3945_tx_power tpc; u8 reserved; } __packed; @@ -330,11 +330,11 @@ struct iwl3945_power_per_rate { #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32 #define POWER_TABLE_CCK_ENTRY 32 -#define IWL_PWR_NUM_HT_OFDM_ENTRIES 24 -#define IWL_PWR_CCK_ENTRIES 2 +#define IL_PWR_NUM_HT_OFDM_ENTRIES 24 +#define IL_PWR_CCK_ENTRIES 2 /** - * union iwl4965_tx_power_dual_stream + * union il4965_tx_power_dual_stream * * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH * Use __le32 version (struct tx_power_dual_stream) when building command. @@ -349,7 +349,7 @@ struct iwl3945_power_per_rate { * * See more details in doc for TXPOWER in iwl-4965-hw.h. */ -union iwl4965_tx_power_dual_stream { +union il4965_tx_power_dual_stream { struct { u8 radio_tx_gain[2]; u8 dsp_predis_atten[2]; @@ -362,18 +362,18 @@ union iwl4965_tx_power_dual_stream { * * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH * - * Same format as iwl_tx_power_dual_stream, but __le32 + * Same format as il_tx_power_dual_stream, but __le32 */ struct tx_power_dual_stream { __le32 dw; } __packed; /** - * struct iwl4965_tx_power_db + * struct il4965_tx_power_db * * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH */ -struct iwl4965_tx_power_db { +struct il4965_tx_power_db { struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES]; } __packed; @@ -410,7 +410,7 @@ struct iwl4965_tx_power_db { * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, * for each of 5 frequency ranges. */ -struct iwl_init_alive_resp { +struct il_init_alive_resp { u8 ucode_minor; u8 ucode_major; __le16 reserved1; @@ -511,7 +511,7 @@ struct iwl_init_alive_resp { * The Linux driver can print both logs to the system log when a uCode error * occurs. */ -struct iwl_alive_resp { +struct il_alive_resp { u8 ucode_minor; u8 ucode_major; __le16 reserved1; @@ -528,7 +528,7 @@ struct iwl_alive_resp { /* * REPLY_ERROR = 0x2 (response only, not a command) */ -struct iwl_error_resp { +struct il_error_resp { __le32 error_type; u8 cmd_id; u8 reserved1; @@ -657,7 +657,7 @@ enum { * regardless of whether RXON_FILTER_ASSOC_MSK is set. */ -struct iwl3945_rxon_cmd { +struct il3945_rxon_cmd { u8 node_addr[6]; __le16 reserved1; u8 bssid_addr[6]; @@ -676,7 +676,7 @@ struct iwl3945_rxon_cmd { __le16 reserved5; } __packed; -struct iwl4965_rxon_cmd { +struct il4965_rxon_cmd { u8 node_addr[6]; __le16 reserved1; u8 bssid_addr[6]; @@ -699,7 +699,7 @@ struct iwl4965_rxon_cmd { /* Create a common rxon cmd which will be typecast into the 3945 or 4965 * specific rxon cmd, depending on where it is called from. */ -struct iwl_legacy_rxon_cmd { +struct il_rxon_cmd { u8 node_addr[6]; __le16 reserved1; u8 bssid_addr[6]; @@ -725,7 +725,7 @@ struct iwl_legacy_rxon_cmd { /* * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response) */ -struct iwl3945_rxon_assoc_cmd { +struct il3945_rxon_assoc_cmd { __le32 flags; __le32 filter_flags; u8 ofdm_basic_rates; @@ -733,7 +733,7 @@ struct iwl3945_rxon_assoc_cmd { __le16 reserved; } __packed; -struct iwl4965_rxon_assoc_cmd { +struct il4965_rxon_assoc_cmd { __le32 flags; __le32 filter_flags; u8 ofdm_basic_rates; @@ -744,14 +744,14 @@ struct iwl4965_rxon_assoc_cmd { __le16 reserved; } __packed; -#define IWL_CONN_MAX_LISTEN_INTERVAL 10 -#define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ +#define IL_CONN_MAX_LISTEN_INTERVAL 10 +#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ #define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) */ -struct iwl_rxon_time_cmd { +struct il_rxon_time_cmd { __le64 timestamp; __le16 beacon_interval; __le16 atim_window; @@ -764,30 +764,30 @@ struct iwl_rxon_time_cmd { /* * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response) */ -struct iwl3945_channel_switch_cmd { +struct il3945_channel_switch_cmd { u8 band; u8 expect_beacon; __le16 channel; __le32 rxon_flags; __le32 rxon_filter_flags; __le32 switch_time; - struct iwl3945_power_per_rate power[IWL_MAX_RATES]; + struct il3945_power_per_rate power[IL_MAX_RATES]; } __packed; -struct iwl4965_channel_switch_cmd { +struct il4965_channel_switch_cmd { u8 band; u8 expect_beacon; __le16 channel; __le32 rxon_flags; __le32 rxon_filter_flags; __le32 switch_time; - struct iwl4965_tx_power_db tx_power; + struct il4965_tx_power_db tx_power; } __packed; /* * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command) */ -struct iwl_csa_notification { +struct il_csa_notification { __le16 band; __le16 channel; __le32 status; /* 0 - OK, 1 - fail */ @@ -800,8 +800,8 @@ struct iwl_csa_notification { *****************************************************************************/ /** - * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM - * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd + * struct il_ac_qos -- QOS timing params for REPLY_QOS_PARAM + * One for each of 4 EDCA access categories in struct il_qosparam_cmd * * @cw_min: Contention window, start value in numbers of slots. * Should be a power-of-2, minus 1. Device's default is 0x0f. @@ -815,7 +815,7 @@ struct iwl_csa_notification { * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW * value, to cap the CW value. */ -struct iwl_ac_qos { +struct il_ac_qos { __le16 cw_min; __le16 cw_max; u8 aifsn; @@ -837,9 +837,9 @@ struct iwl_ac_qos { * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs * 0: Background, 1: Best Effort, 2: Video, 3: Voice. */ -struct iwl_qosparam_cmd { +struct il_qosparam_cmd { __le32 qos_flags; - struct iwl_ac_qos ac[AC_NUM]; + struct il_ac_qos ac[AC_NUM]; } __packed; /****************************************************************************** @@ -852,15 +852,15 @@ struct iwl_qosparam_cmd { */ /* Special, dedicated locations within device's station table */ -#define IWL_AP_ID 0 -#define IWL_STA_ID 2 +#define IL_AP_ID 0 +#define IL_STA_ID 2 #define IWL3945_BROADCAST_ID 24 #define IWL3945_STATION_COUNT 25 #define IWL4965_BROADCAST_ID 31 #define IWL4965_STATION_COUNT 32 -#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/ -#define IWL_INVALID_STATION 255 +#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ +#define IL_INVALID_STATION 255 #define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) #define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) @@ -905,7 +905,7 @@ struct iwl_qosparam_cmd { * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ #define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) -struct iwl4965_keyinfo { +struct il4965_keyinfo { __le16 key_flags; u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */ u8 reserved1; @@ -923,7 +923,7 @@ struct iwl4965_keyinfo { * * Driver selects unused table index when adding new station, * or the index to a pre-existing station entry when modifying that station. - * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP). + * Some indexes have special purposes (IL_AP_ID, index 0, is for AP). * * modify_mask flags select which parameters to modify vs. leave alone. */ @@ -954,19 +954,19 @@ struct sta_id_modify { * their own txpower/rate setup data). * * When getting started on a new channel, driver must set up the - * IWL_BROADCAST_ID entry (last entry in the table). For a client + * IL_BROADCAST_ID entry (last entry in the table). For a client * station in a BSS, once an AP is selected, driver sets up the AP STA - * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP + * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP * are all that are needed for a BSS client station. If the device is * used as AP, or in an IBSS network, driver must set up station table - * entries for all STAs in network, starting with index IWL_STA_ID. + * entries for all STAs in network, starting with index IL_STA_ID. */ -struct iwl3945_addsta_cmd { +struct il3945_addsta_cmd { u8 mode; /* 1: modify existing, 0: add new station */ u8 reserved[3]; struct sta_id_modify sta; - struct iwl4965_keyinfo key; + struct il4965_keyinfo key; __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ @@ -990,11 +990,11 @@ struct iwl3945_addsta_cmd { __le16 add_immediate_ba_ssn; } __packed; -struct iwl4965_addsta_cmd { +struct il4965_addsta_cmd { u8 mode; /* 1: modify existing, 0: add new station */ u8 reserved[3]; struct sta_id_modify sta; - struct iwl4965_keyinfo key; + struct il4965_keyinfo key; __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ @@ -1028,11 +1028,11 @@ struct iwl4965_addsta_cmd { } __packed; /* Wrapper struct for 3945 and 4965 addsta_cmd structures */ -struct iwl_legacy_addsta_cmd { +struct il_addsta_cmd { u8 mode; /* 1: modify existing, 0: add new station */ u8 reserved[3]; struct sta_id_modify sta; - struct iwl4965_keyinfo key; + struct il4965_keyinfo key; __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ @@ -1073,7 +1073,7 @@ struct iwl_legacy_addsta_cmd { /* * REPLY_ADD_STA = 0x18 (response) */ -struct iwl_add_sta_resp { +struct il_add_sta_resp { u8 status; /* ADD_STA_* */ } __packed; @@ -1081,34 +1081,34 @@ struct iwl_add_sta_resp { /* * REPLY_REM_STA = 0x19 (response) */ -struct iwl_rem_sta_resp { +struct il_rem_sta_resp { u8 status; } __packed; /* * REPLY_REM_STA = 0x19 (command) */ -struct iwl_rem_sta_cmd { +struct il_rem_sta_cmd { u8 num_sta; /* number of removed stations */ u8 reserved[3]; u8 addr[ETH_ALEN]; /* MAC addr of the first station */ u8 reserved2[2]; } __packed; -#define IWL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) -#define IWL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) -#define IWL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) -#define IWL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) -#define IWL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) +#define IL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) +#define IL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) +#define IL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) +#define IL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) +#define IL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) -#define IWL_DROP_SINGLE 0 -#define IWL_DROP_SELECTED 1 -#define IWL_DROP_ALL 2 +#define IL_DROP_SINGLE 0 +#define IL_DROP_SELECTED 1 +#define IL_DROP_ALL 2 /* * REPLY_WEP_KEY = 0x20 */ -struct iwl_wep_key { +struct il_wep_key { u8 key_index; u8 key_offset; u8 reserved1[2]; @@ -1117,12 +1117,12 @@ struct iwl_wep_key { u8 key[16]; } __packed; -struct iwl_wep_cmd { +struct il_wep_cmd { u8 num_keys; u8 global_key_type; u8 flags; u8 reserved; - struct iwl_wep_key key[0]; + struct il_wep_key key[0]; } __packed; #define WEP_KEY_WEP_TYPE 1 @@ -1169,7 +1169,7 @@ struct iwl_wep_cmd { #define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) -struct iwl3945_rx_frame_stats { +struct il3945_rx_frame_stats { u8 phy_count; u8 id; u8 rssi; @@ -1179,7 +1179,7 @@ struct iwl3945_rx_frame_stats { u8 payload[0]; } __packed; -struct iwl3945_rx_frame_hdr { +struct il3945_rx_frame_hdr { __le16 channel; __le16 phy_flags; u8 reserved1; @@ -1188,7 +1188,7 @@ struct iwl3945_rx_frame_hdr { u8 payload[0]; } __packed; -struct iwl3945_rx_frame_end { +struct il3945_rx_frame_end { __le32 status; __le64 timestamp; __le32 beacon_timestamp; @@ -1202,13 +1202,13 @@ struct iwl3945_rx_frame_end { * The actual offsets of the hdr and end are dynamic based on * stats.phy_count */ -struct iwl3945_rx_frame { - struct iwl3945_rx_frame_stats stats; - struct iwl3945_rx_frame_hdr hdr; - struct iwl3945_rx_frame_end end; +struct il3945_rx_frame { + struct il3945_rx_frame_stats stats; + struct il3945_rx_frame_hdr hdr; + struct il3945_rx_frame_end end; } __packed; -#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct iwl3945_rx_frame)) +#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) /* Fixed (non-configurable) rx data from phy */ @@ -1217,7 +1217,7 @@ struct iwl3945_rx_frame { #define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) #define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ #define IWL49_AGC_DB_POS (7) -struct iwl4965_rx_non_cfg_phy { +struct il4965_rx_non_cfg_phy { __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */ @@ -1229,7 +1229,7 @@ struct iwl4965_rx_non_cfg_phy { * REPLY_RX = 0xc3 (response only, not a command) * Used only for legacy (non 11n) frames. */ -struct iwl_rx_phy_res { +struct il_rx_phy_res { u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ u8 stat_id; /* configurable DSP phy data set ID */ @@ -1244,7 +1244,7 @@ struct iwl_rx_phy_res { __le16 frame_time; /* frame's time on the air */ } __packed; -struct iwl_rx_mpdu_res_start { +struct il_rx_mpdu_res_start { __le16 byte_count; __le16 reserved; } __packed; @@ -1372,7 +1372,7 @@ struct iwl_rx_mpdu_res_start { * REPLY_TX = 0x1c (command) */ -struct iwl3945_tx_cmd { +struct il3945_tx_cmd { /* * MPDU byte count: * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, @@ -1436,7 +1436,7 @@ struct iwl3945_tx_cmd { /* * REPLY_TX = 0x1c (response) */ -struct iwl3945_tx_resp { +struct il3945_tx_resp { u8 failure_rts; u8 failure_frame; u8 bt_kill_count; @@ -1451,13 +1451,13 @@ struct iwl3945_tx_resp { * Used for managing Tx retries when expecting block-acks. * Driver should set these fields to 0. */ -struct iwl_dram_scratch { +struct il_dram_scratch { u8 try_cnt; /* Tx attempts */ u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */ __le16 reserved; } __packed; -struct iwl_tx_cmd { +struct il_tx_cmd { /* * MPDU byte count: * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, @@ -1481,7 +1481,7 @@ struct iwl_tx_cmd { /* uCode may modify this field of the Tx command (in host DRAM!). * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */ - struct iwl_dram_scratch scratch; + struct il_dram_scratch scratch; /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */ __le32 rate_n_flags; /* RATE_MCS_* */ @@ -1697,7 +1697,7 @@ struct agg_tx_status { __le16 sequence; } __packed; -struct iwl4965_tx_resp { +struct il4965_tx_resp { u8 frame_count; /* 1 no aggregation, >1 aggregation */ u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ u8 failure_rts; /* # failures due to unsuccessful RTS */ @@ -1739,7 +1739,7 @@ struct iwl4965_tx_resp { * * Reports Block-Acknowledge from recipient station */ -struct iwl_compressed_ba_resp { +struct il_compressed_ba_resp { __le32 sta_addr_lo32; __le16 sta_addr_hi16; __le16 reserved; @@ -1759,23 +1759,23 @@ struct iwl_compressed_ba_resp { * See details under "TXPOWER" in iwl-4965-hw.h. */ -struct iwl3945_txpowertable_cmd { +struct il3945_txpowertable_cmd { u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ u8 reserved; __le16 channel; - struct iwl3945_power_per_rate power[IWL_MAX_RATES]; + struct il3945_power_per_rate power[IL_MAX_RATES]; } __packed; -struct iwl4965_txpowertable_cmd { +struct il4965_txpowertable_cmd { u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ u8 reserved; __le16 channel; - struct iwl4965_tx_power_db tx_power; + struct il4965_tx_power_db tx_power; } __packed; /** - * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response + * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response * * REPLY_RATE_SCALE = 0x47 (command, has simple generic response) * @@ -1789,16 +1789,16 @@ struct iwl4965_txpowertable_cmd { * when passed through ofdm_basic_rates on the REPLY_RXON * command would be bit 0 (1 << 0) */ -struct iwl3945_rate_scaling_info { +struct il3945_rate_scaling_info { __le16 rate_n_flags; u8 try_cnt; u8 next_rate_index; } __packed; -struct iwl3945_rate_scaling_cmd { +struct il3945_rate_scaling_cmd { u8 table_id; u8 reserved[3]; - struct iwl3945_rate_scaling_info table[IWL_MAX_RATES]; + struct il3945_rate_scaling_info table[IL_MAX_RATES]; } __packed; @@ -1818,11 +1818,11 @@ struct iwl3945_rate_scaling_cmd { /** - * struct iwl_link_qual_general_params + * struct il_link_qual_general_params * * Used in REPLY_TX_LINK_QUALITY_CMD */ -struct iwl_link_qual_general_params { +struct il_link_qual_general_params { u8 flags; /* No entries at or above this (driver chosen) index contain MIMO */ @@ -1861,11 +1861,11 @@ struct iwl_link_qual_general_params { #define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) /** - * struct iwl_link_qual_agg_params + * struct il_link_qual_agg_params * * Used in REPLY_TX_LINK_QUALITY_CMD */ -struct iwl_link_qual_agg_params { +struct il_link_qual_agg_params { /* *Maximum number of uSec in aggregation. @@ -1966,7 +1966,7 @@ struct iwl_link_qual_agg_params { * * When using block-ack (aggregation), all frames are transmitted at the same * rate, since there is no per-attempt acknowledgment from the destination - * station. The Tx response struct iwl_tx_resp indicates the Tx rate in + * station. The Tx response struct il_tx_resp indicates the Tx rate in * rate_n_flags field. After receiving a block-ack, the driver can update * history for the entire block all at once. * @@ -2079,14 +2079,14 @@ struct iwl_link_qual_agg_params { * legacy), and then repeat the search process. * */ -struct iwl_link_quality_cmd { +struct il_link_quality_cmd { /* Index of destination/recipient station in uCode's station table */ u8 sta_id; u8 reserved1; __le16 control; /* not used */ - struct iwl_link_qual_general_params general_params; - struct iwl_link_qual_agg_params agg_params; + struct il_link_qual_general_params general_params; + struct il_link_qual_agg_params agg_params; /* * Rate info; when using rate-scaling, Tx command's initial_rate_index @@ -2094,7 +2094,7 @@ struct iwl_link_quality_cmd { * 4965 devices works its way through table when retrying Tx. */ struct { - __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */ + __le32 rate_n_flags; /* RATE_MCS_*, IL_RATE_* */ } rs_table[LINK_QUAL_MAX_RETRY_NUM]; __le32 reserved2; } __packed; @@ -2123,7 +2123,7 @@ struct iwl_link_quality_cmd { * same platform. Bluetooth device alerts wireless device when it will Tx; * wireless device can delay or kill its own Tx to accommodate. */ -struct iwl_bt_cmd { +struct il_bt_cmd { u8 flags; u8 lead_time; u8 max_kill; @@ -2150,18 +2150,18 @@ struct iwl_bt_cmd { RXON_FILTER_ASSOC_MSK | \ RXON_FILTER_BCON_AWARE_MSK) -struct iwl_measure_channel { +struct il_measure_channel { __le32 duration; /* measurement duration in extended beacon * format */ u8 channel; /* channel to measure */ - u8 type; /* see enum iwl_measure_type */ + u8 type; /* see enum il_measure_type */ __le16 reserved; } __packed; /* * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command) */ -struct iwl_spectrum_cmd { +struct il_spectrum_cmd { __le16 len; /* number of bytes starting from token */ u8 token; /* token id */ u8 id; /* measurement id -- 0 or 1 */ @@ -2174,13 +2174,13 @@ struct iwl_spectrum_cmd { __le32 filter_flags; /* rxon filter flags */ __le16 channel_count; /* minimum 1, maximum 10 */ __le16 reserved3; - struct iwl_measure_channel channels[10]; + struct il_measure_channel channels[10]; } __packed; /* * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response) */ -struct iwl_spectrum_resp { +struct il_spectrum_resp { u8 token; u8 id; /* id of the prior command replaced, or 0xff */ __le16 status; /* 0 - command will be handled @@ -2188,49 +2188,49 @@ struct iwl_spectrum_resp { * measurement) */ } __packed; -enum iwl_measurement_state { - IWL_MEASUREMENT_START = 0, - IWL_MEASUREMENT_STOP = 1, +enum il_measurement_state { + IL_MEASUREMENT_START = 0, + IL_MEASUREMENT_STOP = 1, }; -enum iwl_measurement_status { - IWL_MEASUREMENT_OK = 0, - IWL_MEASUREMENT_CONCURRENT = 1, - IWL_MEASUREMENT_CSA_CONFLICT = 2, - IWL_MEASUREMENT_TGH_CONFLICT = 3, +enum il_measurement_status { + IL_MEASUREMENT_OK = 0, + IL_MEASUREMENT_CONCURRENT = 1, + IL_MEASUREMENT_CSA_CONFLICT = 2, + IL_MEASUREMENT_TGH_CONFLICT = 3, /* 4-5 reserved */ - IWL_MEASUREMENT_STOPPED = 6, - IWL_MEASUREMENT_TIMEOUT = 7, - IWL_MEASUREMENT_PERIODIC_FAILED = 8, + IL_MEASUREMENT_STOPPED = 6, + IL_MEASUREMENT_TIMEOUT = 7, + IL_MEASUREMENT_PERIODIC_FAILED = 8, }; #define NUM_ELEMENTS_IN_HISTOGRAM 8 -struct iwl_measurement_histogram { +struct il_measurement_histogram { __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */ __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */ } __packed; /* clear channel availability counters */ -struct iwl_measurement_cca_counters { +struct il_measurement_cca_counters { __le32 ofdm; __le32 cck; } __packed; -enum iwl_measure_type { - IWL_MEASURE_BASIC = (1 << 0), - IWL_MEASURE_CHANNEL_LOAD = (1 << 1), - IWL_MEASURE_HISTOGRAM_RPI = (1 << 2), - IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3), - IWL_MEASURE_FRAME = (1 << 4), +enum il_measure_type { + IL_MEASURE_BASIC = (1 << 0), + IL_MEASURE_CHANNEL_LOAD = (1 << 1), + IL_MEASURE_HISTOGRAM_RPI = (1 << 2), + IL_MEASURE_HISTOGRAM_NOISE = (1 << 3), + IL_MEASURE_FRAME = (1 << 4), /* bits 5:6 are reserved */ - IWL_MEASURE_IDLE = (1 << 7), + IL_MEASURE_IDLE = (1 << 7), }; /* * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command) */ -struct iwl_spectrum_notification { +struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ u8 token; u8 channel_index; /* index in measurement channel list */ @@ -2238,7 +2238,7 @@ struct iwl_spectrum_notification { __le32 start_time; /* lower 32-bits of TSF */ u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ u8 channel; - u8 type; /* see enum iwl_measurement_type */ + u8 type; /* see enum il_measurement_type */ u8 reserved1; /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only * valid if applicable for measurement type requested. */ @@ -2248,9 +2248,9 @@ struct iwl_spectrum_notification { u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 - * unidentified */ u8 reserved2[3]; - struct iwl_measurement_histogram histogram; + struct il_measurement_histogram histogram; __le32 stop_time; /* lower 32-bits of TSF */ - __le32 status; /* see iwl_measurement_status */ + __le32 status; /* see il_measurement_status */ } __packed; /****************************************************************************** @@ -2260,7 +2260,7 @@ struct iwl_spectrum_notification { *****************************************************************************/ /** - * struct iwl_powertable_cmd - Power Table Command + * struct il_powertable_cmd - Power Table Command * @flags: See below: * * POWER_TABLE_CMD = 0x77 (command, has simple generic response) @@ -2294,26 +2294,26 @@ struct iwl_spectrum_notification { * ucode assume sleep over DTIM is allowed and we don't need to wake up * for every DTIM. */ -#define IWL_POWER_VEC_SIZE 5 +#define IL_POWER_VEC_SIZE 5 -#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) -#define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) +#define IL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) +#define IL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) -struct iwl3945_powertable_cmd { +struct il3945_powertable_cmd { __le16 flags; u8 reserved[2]; __le32 rx_data_timeout; __le32 tx_data_timeout; - __le32 sleep_interval[IWL_POWER_VEC_SIZE]; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; } __packed; -struct iwl_powertable_cmd { +struct il_powertable_cmd { __le16 flags; u8 keep_alive_seconds; /* 3945 reserved */ u8 debug_flags; /* 3945 reserved */ __le32 rx_data_timeout; __le32 tx_data_timeout; - __le32 sleep_interval[IWL_POWER_VEC_SIZE]; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; __le32 keep_alive_beacons; } __packed; @@ -2321,7 +2321,7 @@ struct iwl_powertable_cmd { * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command) * all devices identical. */ -struct iwl_sleep_notification { +struct il_sleep_notification { u8 pm_sleep_mode; u8 pm_wakeup_src; __le16 reserved; @@ -2332,23 +2332,23 @@ struct iwl_sleep_notification { /* Sleep states. all devices identical. */ enum { - IWL_PM_NO_SLEEP = 0, - IWL_PM_SLP_MAC = 1, - IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, - IWL_PM_SLP_FULL_MAC_CARD_STATE = 3, - IWL_PM_SLP_PHY = 4, - IWL_PM_SLP_REPENT = 5, - IWL_PM_WAKEUP_BY_TIMER = 6, - IWL_PM_WAKEUP_BY_DRIVER = 7, - IWL_PM_WAKEUP_BY_RFKILL = 8, + IL_PM_NO_SLEEP = 0, + IL_PM_SLP_MAC = 1, + IL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, + IL_PM_SLP_FULL_MAC_CARD_STATE = 3, + IL_PM_SLP_PHY = 4, + IL_PM_SLP_REPENT = 5, + IL_PM_WAKEUP_BY_TIMER = 6, + IL_PM_WAKEUP_BY_DRIVER = 7, + IL_PM_WAKEUP_BY_RFKILL = 8, /* 3 reserved */ - IWL_PM_NUM_OF_MODES = 12, + IL_PM_NUM_OF_MODES = 12, }; /* * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command) */ -struct iwl_card_state_notif { +struct il_card_state_notif { __le32 flags; } __packed; @@ -2357,7 +2357,7 @@ struct iwl_card_state_notif { #define CT_CARD_DISABLED 0x04 #define RXON_CARD_DISABLED 0x10 -struct iwl_ct_kill_config { +struct il_ct_kill_config { __le32 reserved; __le32 critical_temperature_M; __le32 critical_temperature_R; @@ -2373,7 +2373,7 @@ struct iwl_ct_kill_config { #define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) /** - * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table + * struct il_scan_channel - entry in REPLY_SCAN_CMD channel table * * One for each channel in the scan list. * Each channel can independently select: @@ -2383,7 +2383,7 @@ struct iwl_ct_kill_config { * quiet_plcp_th, good_CRC_th) * * To avoid uCode errors, make sure the following are true (see comments - * under struct iwl_scan_cmd about max_out_time and quiet_time): + * under struct il_scan_cmd about max_out_time and quiet_time): * 1) If using passive_dwell (i.e. passive_dwell != 0): * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0) * 2) quiet_time <= active_dwell @@ -2391,7 +2391,7 @@ struct iwl_ct_kill_config { * passive_dwell < max_out_time * active_dwell < max_out_time */ -struct iwl3945_scan_channel { +struct il3945_scan_channel { /* * type is defined as: * 0:0 1 = active, 0 = passive @@ -2400,8 +2400,8 @@ struct iwl3945_scan_channel { * 5:7 reserved */ u8 type; - u8 channel; /* band is selected by iwl3945_scan_cmd "flags" field */ - struct iwl3945_tx_power tpc; + u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ + struct il3945_tx_power tpc; __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ } __packed; @@ -2409,7 +2409,7 @@ struct iwl3945_scan_channel { /* set number of direct probes u8 type */ #define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) -struct iwl_scan_channel { +struct il_scan_channel { /* * type is defined as: * 0:0 1 = active, 0 = passive @@ -2418,7 +2418,7 @@ struct iwl_scan_channel { * 21:31 reserved */ __le32 type; - __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */ + __le16 channel; /* band is selected by il_scan_cmd "flags" field */ u8 tx_gain; /* gain for analog radio */ u8 dsp_atten; /* gain for DSP */ __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ @@ -2426,17 +2426,17 @@ struct iwl_scan_channel { } __packed; /* set number of direct probes __le32 type */ -#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) +#define IL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) /** - * struct iwl_ssid_ie - directed scan network information element + * struct il_ssid_ie - directed scan network information element * * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in - * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel; + * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; * each channel may select different ssids from among the 20 (4) entries. * SSID IEs get transmitted in reverse order of entry. */ -struct iwl_ssid_ie { +struct il_ssid_ie { u8 id; u8 len; u8 ssid[32]; @@ -2445,11 +2445,11 @@ struct iwl_ssid_ie { #define PROBE_OPTION_MAX_3945 4 #define PROBE_OPTION_MAX 20 #define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) -#define IWL_GOOD_CRC_TH_DISABLED 0 -#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) -#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) -#define IWL_MAX_SCAN_SIZE 1024 -#define IWL_MAX_CMD_SIZE 4096 +#define IL_GOOD_CRC_TH_DISABLED 0 +#define IL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) +#define IL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) +#define IL_MAX_SCAN_SIZE 1024 +#define IL_MAX_CMD_SIZE 4096 /* * REPLY_SCAN_CMD = 0x80 (command) @@ -2501,10 +2501,10 @@ struct iwl_ssid_ie { * Driver must use separate scan commands for 2.4 vs. 5 GHz bands. * * To avoid uCode errors, see timing restrictions described under - * struct iwl_scan_channel. + * struct il_scan_channel. */ -struct iwl3945_scan_cmd { +struct il3945_scan_cmd { __le16 len; u8 reserved0; u8 channel_count; /* # channels in channel list */ @@ -2525,10 +2525,10 @@ struct iwl3945_scan_cmd { /* For active scans (set to all-0s for passive scans). * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct iwl3945_tx_cmd tx_cmd; + struct il3945_tx_cmd tx_cmd; /* For directed active scans (set to all-0s otherwise) */ - struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; /* * Probe request frame, followed by channel list. @@ -2538,7 +2538,7 @@ struct iwl3945_scan_cmd { * Number of channels in list is specified by channel_count. * Each channel in list is of type: * - * struct iwl3945_scan_channel channels[0]; + * struct il3945_scan_channel channels[0]; * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait @@ -2548,7 +2548,7 @@ struct iwl3945_scan_cmd { u8 data[0]; } __packed; -struct iwl_scan_cmd { +struct il_scan_cmd { __le16 len; u8 reserved0; u8 channel_count; /* # channels in channel list */ @@ -2569,10 +2569,10 @@ struct iwl_scan_cmd { /* For active scans (set to all-0s for passive scans). * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct iwl_tx_cmd tx_cmd; + struct il_tx_cmd tx_cmd; /* For directed active scans (set to all-0s otherwise) */ - struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX]; + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX]; /* * Probe request frame, followed by channel list. @@ -2582,7 +2582,7 @@ struct iwl_scan_cmd { * Number of channels in list is specified by channel_count. * Each channel in list is of type: * - * struct iwl_scan_channel channels[0]; + * struct il_scan_channel channels[0]; * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait @@ -2600,14 +2600,14 @@ struct iwl_scan_cmd { /* * REPLY_SCAN_CMD = 0x80 (response) */ -struct iwl_scanreq_notification { +struct il_scanreq_notification { __le32 status; /* 1: okay, 2: cannot fulfill request */ } __packed; /* * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command) */ -struct iwl_scanstart_notification { +struct il_scanstart_notification { __le32 tsf_low; __le32 tsf_high; __le32 beacon_timer; @@ -2620,17 +2620,17 @@ struct iwl_scanstart_notification { #define SCAN_OWNER_STATUS 0x1 #define MEASURE_OWNER_STATUS 0x2 -#define IWL_PROBE_STATUS_OK 0 -#define IWL_PROBE_STATUS_TX_FAILED BIT(0) +#define IL_PROBE_STATUS_OK 0 +#define IL_PROBE_STATUS_TX_FAILED BIT(0) /* error statuses combined with TX_FAILED */ -#define IWL_PROBE_STATUS_FAIL_TTL BIT(1) -#define IWL_PROBE_STATUS_FAIL_BT BIT(2) +#define IL_PROBE_STATUS_FAIL_TTL BIT(1) +#define IL_PROBE_STATUS_FAIL_BT BIT(2) #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */ /* * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) */ -struct iwl_scanresults_notification { +struct il_scanresults_notification { u8 channel; u8 band; u8 probe_status; @@ -2643,7 +2643,7 @@ struct iwl_scanresults_notification { /* * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command) */ -struct iwl_scancomplete_notification { +struct il_scancomplete_notification { u8 scanned_channels; u8 status; u8 last_channel; @@ -2658,24 +2658,24 @@ struct iwl_scancomplete_notification { * *****************************************************************************/ -enum iwl_ibss_manager { - IWL_NOT_IBSS_MANAGER = 0, - IWL_IBSS_MANAGER = 1, +enum il_ibss_manager { + IL_NOT_IBSS_MANAGER = 0, + IL_IBSS_MANAGER = 1, }; /* * BEACON_NOTIFICATION = 0x90 (notification only, not a command) */ -struct iwl3945_beacon_notif { - struct iwl3945_tx_resp beacon_notify_hdr; +struct il3945_beacon_notif { + struct il3945_tx_resp beacon_notify_hdr; __le32 low_tsf; __le32 high_tsf; __le32 ibss_mgr_status; } __packed; -struct iwl4965_beacon_notif { - struct iwl4965_tx_resp beacon_notify_hdr; +struct il4965_beacon_notif { + struct il4965_tx_resp beacon_notify_hdr; __le32 low_tsf; __le32 high_tsf; __le32 ibss_mgr_status; @@ -2685,16 +2685,16 @@ struct iwl4965_beacon_notif { * REPLY_TX_BEACON = 0x91 (command, has simple generic response) */ -struct iwl3945_tx_beacon_cmd { - struct iwl3945_tx_cmd tx; +struct il3945_tx_beacon_cmd { + struct il3945_tx_cmd tx; __le16 tim_idx; u8 tim_size; u8 reserved1; struct ieee80211_hdr frame[0]; /* beacon frame */ } __packed; -struct iwl_tx_beacon_cmd { - struct iwl_tx_cmd tx; +struct il_tx_beacon_cmd { + struct il_tx_cmd tx; __le16 tim_idx; u8 tim_size; u8 reserved1; @@ -2707,7 +2707,7 @@ struct iwl_tx_beacon_cmd { * *****************************************************************************/ -#define IWL_TEMP_CONVERT 260 +#define IL_TEMP_CONVERT 260 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4 @@ -2977,10 +2977,10 @@ struct statistics_general { * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself. */ -#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ -#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ -struct iwl_statistics_cmd { - __le32 configuration_flags; /* IWL_STATS_CONF_* */ +#define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ +#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ +struct il_statistics_cmd { + __le32 configuration_flags; /* IL_STATS_CONF_* */ } __packed; /* @@ -3001,14 +3001,14 @@ struct iwl_statistics_cmd { #define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) #define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) -struct iwl3945_notif_statistics { +struct il3945_notif_statistics { __le32 flag; struct iwl39_statistics_rx rx; struct iwl39_statistics_tx tx; struct iwl39_statistics_general general; } __packed; -struct iwl_notif_statistics { +struct il_notif_statistics { __le32 flag; struct statistics_rx rx; struct statistics_tx tx; @@ -3035,11 +3035,11 @@ struct iwl_notif_statistics { * */ -#define IWL_MISSED_BEACON_THRESHOLD_MIN (1) -#define IWL_MISSED_BEACON_THRESHOLD_DEF (5) -#define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF +#define IL_MISSED_BEACON_THRESHOLD_MIN (1) +#define IL_MISSED_BEACON_THRESHOLD_DEF (5) +#define IL_MISSED_BEACON_THRESHOLD_MAX IL_MISSED_BEACON_THRESHOLD_DEF -struct iwl_missed_beacon_notif { +struct il_missed_beacon_notif { __le32 consecutive_missed_beacons; __le32 total_missed_becons; __le32 num_expected_beacons; @@ -3111,7 +3111,7 @@ struct iwl_missed_beacon_notif { * * Total number of false alarms = false_alarms + plcp_errs * - * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd + * For OFDM, adjust the following table entries in struct il_sensitivity_cmd * (notice that the start points for OFDM are at or close to settings for * maximum sensitivity): * @@ -3152,7 +3152,7 @@ struct iwl_missed_beacon_notif { * Reset this to 0 at the first beacon period that falls within the * "good" range (5 to 50 false alarms per 204.8 milliseconds rx). * - * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd + * Then, adjust the following CCK table entries in struct il_sensitivity_cmd * (notice that the start points for CCK are at maximum sensitivity): * * START / MIN / MAX @@ -3217,7 +3217,7 @@ struct iwl_missed_beacon_notif { */ /* - * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd) + * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ #define HD_TABLE_SIZE (11) /* number of entries */ #define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */ @@ -3232,18 +3232,18 @@ struct iwl_missed_beacon_notif { #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9) #define HD_OFDM_ENERGY_TH_IN_INDEX (10) -/* Control field in struct iwl_sensitivity_cmd */ +/* Control field in struct il_sensitivity_cmd */ #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0) #define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1) /** - * struct iwl_sensitivity_cmd + * struct il_sensitivity_cmd * @control: (1) updates working table, (0) updates default table * @table: energy threshold values, use HD_* as index into table * * Always use "1" in "control" to update uCode's working table and DSP. */ -struct iwl_sensitivity_cmd { +struct il_sensitivity_cmd { __le16 control; /* always use "1" */ __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */ } __packed; @@ -3294,7 +3294,7 @@ struct iwl_sensitivity_cmd { * (accum_noise[i] - accum_noise[reference]) / 30 * * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB. - * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the + * For use in diff_gain_[abc] fields of struct il_calibration_cmd, the * driver should limit the difference results to a range of 0-3 (0-4.5 dB), * and set bit 2 to indicate "reduce gain". The value for the reference * (weakest) chain should be "0". @@ -3306,24 +3306,24 @@ struct iwl_sensitivity_cmd { /* Phy calibration command for series */ /* The default calibrate table size if not specified by firmware */ -#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 +#define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 enum { - IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, - IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, + IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, + IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, }; -#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253) +#define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) -struct iwl_calib_hdr { +struct il_calib_hdr { u8 op_code; u8 first_group; u8 groups_num; u8 data_valid; } __packed; -/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ -struct iwl_calib_diff_gain_cmd { - struct iwl_calib_hdr hdr; +/* IL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ +struct il_calib_diff_gain_cmd { + struct il_calib_hdr hdr; s8 diff_gain_a; /* see above */ s8 diff_gain_b; s8 diff_gain_c; @@ -3343,7 +3343,7 @@ struct iwl_calib_diff_gain_cmd { * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), * this command turns it on or off, or sets up a periodic blinking cycle. */ -struct iwl_led_cmd { +struct il_led_cmd { __le32 interval; /* "interval" in uSec */ u8 id; /* 1: Activity, 2: Link, 3: Tech */ u8 off; /* # intervals off while blinking; @@ -3360,7 +3360,7 @@ struct iwl_led_cmd { * *****************************************************************************/ -struct iwl_rx_packet { +struct il_rx_packet { /* * The first 4 bytes of the RX frame header contain both the RX frame * size and some flags. @@ -3372,27 +3372,27 @@ struct iwl_rx_packet { * 13-00: RX frame size */ __le32 len_n_flags; - struct iwl_cmd_header hdr; + struct il_cmd_header hdr; union { - struct iwl3945_rx_frame rx_frame; - struct iwl3945_tx_resp tx_resp; - struct iwl3945_beacon_notif beacon_status; - - struct iwl_alive_resp alive_frame; - struct iwl_spectrum_notification spectrum_notif; - struct iwl_csa_notification csa_notif; - struct iwl_error_resp err_resp; - struct iwl_card_state_notif card_state_notif; - struct iwl_add_sta_resp add_sta; - struct iwl_rem_sta_resp rem_sta; - struct iwl_sleep_notification sleep_notif; - struct iwl_spectrum_resp spectrum; - struct iwl_notif_statistics stats; - struct iwl_compressed_ba_resp compressed_ba; - struct iwl_missed_beacon_notif missed_beacon; + struct il3945_rx_frame rx_frame; + struct il3945_tx_resp tx_resp; + struct il3945_beacon_notif beacon_status; + + struct il_alive_resp alive_frame; + struct il_spectrum_notification spectrum_notif; + struct il_csa_notification csa_notif; + struct il_error_resp err_resp; + struct il_card_state_notif card_state_notif; + struct il_add_sta_resp add_sta; + struct il_rem_sta_resp rem_sta; + struct il_sleep_notification sleep_notif; + struct il_spectrum_resp spectrum; + struct il_notif_statistics stats; + struct il_compressed_ba_resp compressed_ba; + struct il_missed_beacon_notif missed_beacon; __le32 status; u8 raw[0]; } u; } __packed; -#endif /* __iwl_legacy_commands_h__ */ +#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 2bd5659..7eae279 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -76,14 +76,14 @@ EXPORT_SYMBOL(iwlegacy_bcast_addr); /* This function both allocates and initializes hw and priv. */ -struct ieee80211_hw *iwl_legacy_alloc_all(struct iwl_cfg *cfg) +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) { - struct iwl_priv *priv; + struct il_priv *priv; /* mac80211 allocates memory for this device instance, including * space for this driver's private structure */ struct ieee80211_hw *hw; - hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), + hw = ieee80211_alloc_hw(sizeof(struct il_priv), cfg->ops->ieee80211_ops); if (hw == NULL) { pr_err("%s: Can not allocate network device\n", @@ -97,11 +97,11 @@ struct ieee80211_hw *iwl_legacy_alloc_all(struct iwl_cfg *cfg) out: return hw; } -EXPORT_SYMBOL(iwl_legacy_alloc_all); +EXPORT_SYMBOL(il_alloc_all); #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void iwl_legacy_init_ht_hw_capab(const struct iwl_priv *priv, +static void il_init_ht_hw_capab(const struct il_priv *priv, struct ieee80211_sta_ht_cap *ht_info, enum ieee80211_band band) { @@ -150,11 +150,11 @@ static void iwl_legacy_init_ht_hw_capab(const struct iwl_priv *priv, } /** - * iwl_legacy_init_geos - Initialize mac80211's geo/channel info based from eeprom + * il_init_geos - Initialize mac80211's geo/channel info based from eeprom */ -int iwl_legacy_init_geos(struct iwl_priv *priv) +int il_init_geos(struct il_priv *priv) { - struct iwl_channel_info *ch; + struct il_channel_info *ch; struct ieee80211_supported_band *sband; struct ieee80211_channel *channels; struct ieee80211_channel *geo_ch; @@ -164,7 +164,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); + IL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); set_bit(STATUS_GEO_CONFIGURED, &priv->status); return 0; } @@ -174,7 +174,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) if (!channels) return -ENOMEM; - rates = kzalloc((sizeof(struct ieee80211_rate) * IWL_RATE_COUNT_LEGACY), + rates = kzalloc((sizeof(struct ieee80211_rate) * IL_RATE_COUNT_LEGACY), GFP_KERNEL); if (!rates) { kfree(channels); @@ -185,21 +185,21 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) sband = &priv->bands[IEEE80211_BAND_5GHZ]; sband->channels = &channels[ARRAY_SIZE(iwlegacy_eeprom_band_1)]; /* just OFDM */ - sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; - sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE; + sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; + sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; - if (priv->cfg->sku & IWL_SKU_N) - iwl_legacy_init_ht_hw_capab(priv, &sband->ht_cap, + if (priv->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_5GHZ); sband = &priv->bands[IEEE80211_BAND_2GHZ]; sband->channels = channels; /* OFDM & CCK */ sband->bitrates = rates; - sband->n_bitrates = IWL_RATE_COUNT_LEGACY; + sband->n_bitrates = IL_RATE_COUNT_LEGACY; - if (priv->cfg->sku & IWL_SKU_N) - iwl_legacy_init_ht_hw_capab(priv, &sband->ht_cap, + if (priv->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_2GHZ); priv->ieee_channels = channels; @@ -208,7 +208,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) for (i = 0; i < priv->channel_count; i++) { ch = &priv->channel_info[i]; - if (!iwl_legacy_is_channel_valid(ch)) + if (!il_is_channel_valid(ch)) continue; sband = &priv->bands[ch->band]; @@ -221,7 +221,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) geo_ch->max_antenna_gain = 0xff; geo_ch->hw_value = ch->channel; - if (iwl_legacy_is_channel_valid(ch)) { + if (il_is_channel_valid(ch)) { if (!(ch->flags & EEPROM_CHANNEL_IBSS)) geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; @@ -239,9 +239,9 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - IWL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + IL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, geo_ch->center_freq, - iwl_legacy_is_channel_a_band(ch) ? "5.2" : "2.4", + il_is_channel_a_band(ch) ? "5.2" : "2.4", geo_ch->flags & IEEE80211_CHAN_DISABLED ? "restricted" : "valid", geo_ch->flags); @@ -252,15 +252,15 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) priv->tx_power_next = max_tx_power; if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - priv->cfg->sku & IWL_SKU_A) { - IWL_INFO(priv, "Incorrectly detected BG card as ABG. " + priv->cfg->sku & IL_SKU_A) { + IL_INFO(priv, "Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", priv->pci_dev->device, priv->pci_dev->subsystem_device); - priv->cfg->sku &= ~IWL_SKU_A; + priv->cfg->sku &= ~IL_SKU_A; } - IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", + IL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", priv->bands[IEEE80211_BAND_2GHZ].n_channels, priv->bands[IEEE80211_BAND_5GHZ].n_channels); @@ -268,27 +268,27 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) return 0; } -EXPORT_SYMBOL(iwl_legacy_init_geos); +EXPORT_SYMBOL(il_init_geos); /* - * iwl_legacy_free_geos - undo allocations in iwl_legacy_init_geos + * il_free_geos - undo allocations in il_init_geos */ -void iwl_legacy_free_geos(struct iwl_priv *priv) +void il_free_geos(struct il_priv *priv) { kfree(priv->ieee_channels); kfree(priv->ieee_rates); clear_bit(STATUS_GEO_CONFIGURED, &priv->status); } -EXPORT_SYMBOL(iwl_legacy_free_geos); +EXPORT_SYMBOL(il_free_geos); -static bool iwl_legacy_is_channel_extension(struct iwl_priv *priv, +static bool il_is_channel_extension(struct il_priv *priv, enum ieee80211_band band, u16 channel, u8 extension_chan_offset) { - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; - ch_info = iwl_legacy_get_channel_info(priv, band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) + ch_info = il_get_channel_info(priv, band, channel); + if (!il_is_channel_valid(ch_info)) return false; if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) @@ -301,8 +301,8 @@ static bool iwl_legacy_is_channel_extension(struct iwl_priv *priv, return false; } -bool iwl_legacy_is_ht40_tx_allowed(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +bool il_is_ht40_tx_allowed(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap) { if (!ctx->ht.enabled || !ctx->ht.is_40mhz) @@ -320,13 +320,13 @@ bool iwl_legacy_is_ht40_tx_allowed(struct iwl_priv *priv, return false; #endif - return iwl_legacy_is_channel_extension(priv, priv->band, + return il_is_channel_extension(priv, priv->band, le16_to_cpu(ctx->staging.channel), ctx->ht.extension_chan_offset); } -EXPORT_SYMBOL(iwl_legacy_is_ht40_tx_allowed); +EXPORT_SYMBOL(il_is_ht40_tx_allowed); -static u16 iwl_legacy_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) +static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) { u16 new_val; u16 beacon_factor; @@ -360,7 +360,7 @@ static u16 iwl_legacy_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) } int -iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) { u64 tsf; s32 interval_tm, rem; @@ -368,11 +368,11 @@ iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) u16 beacon_int; struct ieee80211_vif *vif = ctx->vif; - conf = iwl_legacy_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(priv->hw); lockdep_assert_held(&priv->mutex); - memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); + memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); ctx->timing.timestamp = cpu_to_le64(priv->timestamp); ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); @@ -385,7 +385,7 @@ iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) */ ctx->timing.atim_window = 0; - beacon_int = iwl_legacy_adjust_beacon_interval(beacon_int, + beacon_int = il_adjust_beacon_interval(beacon_int, priv->hw_params.max_beacon_itrvl * TIME_UNIT); ctx->timing.beacon_interval = cpu_to_le16(beacon_int); @@ -396,23 +396,23 @@ iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - IWL_DEBUG_ASSOC(priv, + IL_DEBUG_ASSOC(priv, "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), le16_to_cpu(ctx->timing.atim_window)); - return iwl_legacy_send_cmd_pdu(priv, ctx->rxon_timing_cmd, + return il_send_cmd_pdu(priv, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); } -EXPORT_SYMBOL(iwl_legacy_send_rxon_timing); +EXPORT_SYMBOL(il_send_rxon_timing); void -iwl_legacy_set_rxon_hwcrypto(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +il_set_rxon_hwcrypto(struct il_priv *priv, + struct il_rxon_context *ctx, int hw_decrypt) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; if (hw_decrypt) rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; @@ -420,112 +420,112 @@ iwl_legacy_set_rxon_hwcrypto(struct iwl_priv *priv, rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; } -EXPORT_SYMBOL(iwl_legacy_set_rxon_hwcrypto); +EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ int -iwl_legacy_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_check_rxon_cmd(struct il_priv *priv, struct il_rxon_context *ctx) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; bool error = false; if (rxon->flags & RXON_FLG_BAND_24G_MSK) { if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IWL_WARN(priv, "check 2.4G: wrong narrow\n"); + IL_WARN(priv, "check 2.4G: wrong narrow\n"); error = true; } if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IWL_WARN(priv, "check 2.4G: wrong radar\n"); + IL_WARN(priv, "check 2.4G: wrong radar\n"); error = true; } } else { if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IWL_WARN(priv, "check 5.2G: not short slot!\n"); + IL_WARN(priv, "check 5.2G: not short slot!\n"); error = true; } if (rxon->flags & RXON_FLG_CCK_MSK) { - IWL_WARN(priv, "check 5.2G: CCK!\n"); + IL_WARN(priv, "check 5.2G: CCK!\n"); error = true; } } if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IWL_WARN(priv, "mac/bssid mcast!\n"); + IL_WARN(priv, "mac/bssid mcast!\n"); error = true; } /* make sure basic rates 6Mbps and 1Mbps are supported */ - if ((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0 && - (rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0) { - IWL_WARN(priv, "neither 1 nor 6 are basic\n"); + if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && + (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { + IL_WARN(priv, "neither 1 nor 6 are basic\n"); error = true; } if (le16_to_cpu(rxon->assoc_id) > 2007) { - IWL_WARN(priv, "aid > 2007\n"); + IL_WARN(priv, "aid > 2007\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IWL_WARN(priv, "CCK and short slot\n"); + IL_WARN(priv, "CCK and short slot\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IWL_WARN(priv, "CCK and auto detect"); + IL_WARN(priv, "CCK and auto detect"); error = true; } if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK) { - IWL_WARN(priv, "TGg but no auto-detect\n"); + IL_WARN(priv, "TGg but no auto-detect\n"); error = true; } if (error) - IWL_WARN(priv, "Tuning to channel %d\n", + IL_WARN(priv, "Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { - IWL_ERR(priv, "Invalid RXON\n"); + IL_ERR(priv, "Invalid RXON\n"); return -EINVAL; } return 0; } -EXPORT_SYMBOL(iwl_legacy_check_rxon_cmd); +EXPORT_SYMBOL(il_check_rxon_cmd); /** - * iwl_legacy_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed + * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed * @priv: staging_rxon is compared to active_rxon * * If the RXON structure is changing enough to require a new tune, * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. */ -int iwl_legacy_full_rxon_required(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il_full_rxon_required(struct il_priv *priv, + struct il_rxon_context *ctx) { - const struct iwl_legacy_rxon_cmd *staging = &ctx->staging; - const struct iwl_legacy_rxon_cmd *active = &ctx->active; + const struct il_rxon_cmd *staging = &ctx->staging; + const struct il_rxon_cmd *active = &ctx->active; #define CHK(cond) \ if ((cond)) { \ - IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ + IL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ return 1; \ } #define CHK_NEQ(c1, c2) \ if ((c1) != (c2)) { \ - IWL_DEBUG_INFO(priv, "need full RXON - " \ + IL_DEBUG_INFO(priv, "need full RXON - " \ #c1 " != " #c2 " - %d != %d\n", \ (c1), (c2)); \ return 1; \ } /* These items are only settable from the full RXON command */ - CHK(!iwl_legacy_is_associated_ctx(ctx)); + CHK(!il_is_associated_ctx(ctx)); CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); CHK(compare_ether_addr(staging->node_addr, active->node_addr)); CHK(compare_ether_addr(staging->wlap_bssid_addr, @@ -556,27 +556,27 @@ int iwl_legacy_full_rxon_required(struct iwl_priv *priv, return 0; } -EXPORT_SYMBOL(iwl_legacy_full_rxon_required); +EXPORT_SYMBOL(il_full_rxon_required); -u8 iwl_legacy_get_lowest_plcp(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +u8 il_get_lowest_plcp(struct il_priv *priv, + struct il_rxon_context *ctx) { /* * Assign the lowest rate -- should really get this from * the beacon skb from mac80211. */ if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) - return IWL_RATE_1M_PLCP; + return IL_RATE_1M_PLCP; else - return IWL_RATE_6M_PLCP; + return IL_RATE_6M_PLCP; } -EXPORT_SYMBOL(iwl_legacy_get_lowest_plcp); +EXPORT_SYMBOL(il_get_lowest_plcp); -static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, - struct iwl_ht_config *ht_conf, - struct iwl_rxon_context *ctx) +static void _il_set_rxon_ht(struct il_priv *priv, + struct il_ht_config *ht_conf, + struct il_rxon_context *ctx) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; if (!ctx->ht.enabled) { rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | @@ -594,7 +594,7 @@ static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, /* clear the HT channel mode before set the mode */ rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, NULL)) { + if (il_is_ht40_tx_allowed(priv, ctx, NULL)) { /* pure ht40 */ if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { @@ -626,7 +626,7 @@ static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IWL_ERR(priv, + IL_ERR(priv, "invalid extension channel offset\n"); break; } @@ -638,30 +638,30 @@ static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); - IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " + IL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), ctx->ht.protection, ctx->ht.extension_chan_offset); } -void iwl_legacy_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf) +void il_set_rxon_ht(struct il_priv *priv, struct il_ht_config *ht_conf) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; for_each_context(priv, ctx) - _iwl_legacy_set_rxon_ht(priv, ht_conf, ctx); + _il_set_rxon_ht(priv, ht_conf, ctx); } -EXPORT_SYMBOL(iwl_legacy_set_rxon_ht); +EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ -u8 iwl_legacy_get_single_channel_number(struct iwl_priv *priv, +u8 il_get_single_channel_number(struct il_priv *priv, enum ieee80211_band band) { - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; int i; u8 channel = 0; u8 min, max; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; if (band == IEEE80211_BAND_5GHZ) { min = 14; @@ -685,25 +685,25 @@ u8 iwl_legacy_get_single_channel_number(struct iwl_priv *priv, continue; channel = priv->channel_info[i].channel; - ch_info = iwl_legacy_get_channel_info(priv, band, channel); - if (iwl_legacy_is_channel_valid(ch_info)) + ch_info = il_get_channel_info(priv, band, channel); + if (il_is_channel_valid(ch_info)) break; } return channel; } -EXPORT_SYMBOL(iwl_legacy_get_single_channel_number); +EXPORT_SYMBOL(il_get_single_channel_number); /** - * iwl_legacy_set_rxon_channel - Set the band and channel values in staging RXON + * il_set_rxon_channel - Set the band and channel values in staging RXON * @ch: requested channel as a pointer to struct ieee80211_channel * NOTE: Does not commit to the hardware; it sets appropriate bit fields * in the staging RXON flag structure based on the ch->band */ int -iwl_legacy_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, - struct iwl_rxon_context *ctx) +il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, + struct il_rxon_context *ctx) { enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; @@ -720,14 +720,14 @@ iwl_legacy_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, priv->band = band; - IWL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); + IL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); return 0; } -EXPORT_SYMBOL(iwl_legacy_set_rxon_channel); +EXPORT_SYMBOL(il_set_rxon_channel); -void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il_set_flags_for_band(struct il_priv *priv, + struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif) { @@ -737,7 +737,7 @@ void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, | RXON_FLG_CCK_MSK); ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; } else { - /* Copied from iwl_post_associate() */ + /* Copied from il_post_associate() */ if (vif && vif->bss_conf.use_short_slot) ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else @@ -748,15 +748,15 @@ void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, ctx->staging.flags &= ~RXON_FLG_CCK_MSK; } } -EXPORT_SYMBOL(iwl_legacy_set_flags_for_band); +EXPORT_SYMBOL(il_set_flags_for_band); /* * initialize rxon structure with default values from eeprom */ -void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +void il_connection_init_rx_config(struct il_priv *priv, + struct il_rxon_context *ctx) { - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; memset(&ctx->staging, 0, sizeof(ctx->staging)); @@ -778,7 +778,7 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, break; default: - IWL_ERR(priv, "Unsupported interface type %d\n", + IL_ERR(priv, "Unsupported interface type %d\n", ctx->vif->type); break; } @@ -792,7 +792,7 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; #endif - ch_info = iwl_legacy_get_channel_info(priv, priv->band, + ch_info = il_get_channel_info(priv, priv->band, le16_to_cpu(ctx->active.channel)); if (!ch_info) @@ -801,12 +801,12 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, ctx->staging.channel = cpu_to_le16(ch_info->channel); priv->band = ch_info->band; - iwl_legacy_set_flags_for_band(priv, ctx, priv->band, ctx->vif); + il_set_flags_for_band(priv, ctx, priv->band, ctx->vif); ctx->staging.ofdm_basic_rates = - (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; ctx->staging.cck_basic_rates = - (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; + (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; /* clear both MIX and PURE40 mode flag */ ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | @@ -817,18 +817,18 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; } -EXPORT_SYMBOL(iwl_legacy_connection_init_rx_config); +EXPORT_SYMBOL(il_connection_init_rx_config); -void iwl_legacy_set_rate(struct iwl_priv *priv) +void il_set_rate(struct il_priv *priv) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; int i; - hw = iwl_get_hw_mode(priv, priv->band); + hw = il_get_hw_mode(priv, priv->band); if (!hw) { - IWL_ERR(priv, "Failed to set rate: unable to get hw mode\n"); + IL_ERR(priv, "Failed to set rate: unable to get hw mode\n"); return; } @@ -836,25 +836,25 @@ void iwl_legacy_set_rate(struct iwl_priv *priv) for (i = 0; i < hw->n_bitrates; i++) { rate = &(hw->bitrates[i]); - if (rate->hw_value < IWL_RATE_COUNT_LEGACY) + if (rate->hw_value < IL_RATE_COUNT_LEGACY) priv->active_rate |= (1 << rate->hw_value); } - IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); + IL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); for_each_context(priv, ctx) { ctx->staging.cck_basic_rates = - (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; + (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; ctx->staging.ofdm_basic_rates = - (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; } } -EXPORT_SYMBOL(iwl_legacy_set_rate); +EXPORT_SYMBOL(il_set_rate); -void iwl_legacy_chswitch_done(struct iwl_priv *priv, bool is_success) +void il_chswitch_done(struct il_priv *priv, bool is_success) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; @@ -862,15 +862,15 @@ void iwl_legacy_chswitch_done(struct iwl_priv *priv, bool is_success) if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) ieee80211_chswitch_done(ctx->vif, is_success); } -EXPORT_SYMBOL(iwl_legacy_chswitch_done); +EXPORT_SYMBOL(il_chswitch_done); -void iwl_legacy_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) +void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_csa_notification *csa = &(pkt->u.csa_notif); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_csa_notification *csa = &(pkt->u.csa_notif); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - struct iwl_legacy_rxon_cmd *rxon = (void *)&ctx->active; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_cmd *rxon = (void *)&ctx->active; if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) return; @@ -878,63 +878,63 @@ void iwl_legacy_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - IWL_DEBUG_11H(priv, "CSA notif: channel %d\n", + IL_DEBUG_11H(priv, "CSA notif: channel %d\n", le16_to_cpu(csa->channel)); - iwl_legacy_chswitch_done(priv, true); + il_chswitch_done(priv, true); } else { - IWL_ERR(priv, "CSA notif (fail) : channel %d\n", + IL_ERR(priv, "CSA notif (fail) : channel %d\n", le16_to_cpu(csa->channel)); - iwl_legacy_chswitch_done(priv, false); + il_chswitch_done(priv, false); } } -EXPORT_SYMBOL(iwl_legacy_rx_csa); +EXPORT_SYMBOL(il_rx_csa); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +void il_print_rx_config_cmd(struct il_priv *priv, + struct il_rxon_context *ctx) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; - IWL_DEBUG_RADIO(priv, "RX CONFIG:\n"); - iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - IWL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", + IL_DEBUG_RADIO(priv, "RX CONFIG:\n"); + il_print_hex_dump(priv, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); + IL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); - IWL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - IWL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n", + IL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + IL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); - IWL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); - IWL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); + IL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); - IWL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); - IWL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); - IWL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - IWL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", + IL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); + IL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + IL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } -EXPORT_SYMBOL(iwl_legacy_print_rx_config_cmd); +EXPORT_SYMBOL(il_print_rx_config_cmd); #endif /** - * iwl_legacy_irq_handle_error - called for HW or SW error interrupt from card + * il_irq_handle_error - called for HW or SW error interrupt from card */ -void iwl_legacy_irq_handle_error(struct iwl_priv *priv) +void il_irq_handle_error(struct il_priv *priv) { - /* Set the FW error flag -- cleared on iwl_down */ + /* Set the FW error flag -- cleared on il_down */ set_bit(STATUS_FW_ERROR, &priv->status); /* Cancel currently queued command. */ clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_ERR(priv, "Loaded firmware version: %s\n", + IL_ERR(priv, "Loaded firmware version: %s\n", priv->hw->wiphy->fw_version); priv->cfg->ops->lib->dump_nic_error_log(priv); if (priv->cfg->ops->lib->dump_fh) priv->cfg->ops->lib->dump_fh(priv, NULL, false); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) - iwl_legacy_print_rx_config_cmd(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + if (il_get_debug_level(priv) & IL_DL_FW_ERRORS) + il_print_rx_config_cmd(priv, + &priv->contexts[IL_RXON_CTX_BSS]); #endif wake_up(&priv->wait_command_queue); @@ -944,41 +944,41 @@ void iwl_legacy_irq_handle_error(struct iwl_priv *priv) clear_bit(STATUS_READY, &priv->status); if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IWL_DEBUG(priv, IWL_DL_FW_ERRORS, + IL_DEBUG(priv, IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); if (priv->cfg->mod_params->restart_fw) queue_work(priv->workqueue, &priv->restart); } } -EXPORT_SYMBOL(iwl_legacy_irq_handle_error); +EXPORT_SYMBOL(il_irq_handle_error); -static int iwl_legacy_apm_stop_master(struct iwl_priv *priv) +static int il_apm_stop_master(struct il_priv *priv) { int ret = 0; /* stop device's busmaster DMA activity */ - iwl_legacy_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = iwl_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + ret = il_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) - IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); + IL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); - IWL_DEBUG_INFO(priv, "stop master\n"); + IL_DEBUG_INFO(priv, "stop master\n"); return ret; } -void iwl_legacy_apm_stop(struct iwl_priv *priv) +void il_apm_stop(struct il_priv *priv) { - IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); + IL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); /* Stop device's DMA activity */ - iwl_legacy_apm_stop_master(priv); + il_apm_stop_master(priv); /* Reset the entire device */ - iwl_legacy_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); udelay(10); @@ -986,23 +986,23 @@ void iwl_legacy_apm_stop(struct iwl_priv *priv) * Clear "initialization complete" bit to move adapter from * D0A* (powered-up Active) --> D0U* (Uninitialized) state. */ - iwl_legacy_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } -EXPORT_SYMBOL(iwl_legacy_apm_stop); +EXPORT_SYMBOL(il_apm_stop); /* * Start up NIC's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via iwl_legacy_apm_stop()) + * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -int iwl_legacy_apm_init(struct iwl_priv *priv) +int il_apm_init(struct il_priv *priv) { int ret = 0; u16 lctl; - IWL_DEBUG_INFO(priv, "Init card's basic functions\n"); + IL_DEBUG_INFO(priv, "Init card's basic functions\n"); /* * Use "set_bit" below rather than "write", to preserve any hardware @@ -1010,18 +1010,18 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) */ /* Disable L0S exit timer (platform NMI Work/Around) */ - iwl_legacy_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(priv, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); /* * Disable L0s without affecting L1; * don't wait for ICH L0s (ICH bug W/A) */ - iwl_legacy_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(priv, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); /* Set FH wait threshold to maximum (HW error during stress W/A) */ - iwl_legacy_set_bit(priv, CSR_DBG_HPET_MEM_REG, + il_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); /* @@ -1029,7 +1029,7 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) * wake device's PCI Express link L1a -> L0s * NOTE: This is no-op for 3945 (non-existent bit) */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); /* @@ -1041,42 +1041,42 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) * power savings, even without L1. */ if (priv->cfg->base_params->set_l0s) { - lctl = iwl_legacy_pcie_link_ctl(priv); + lctl = il_pcie_link_ctl(priv); if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) { /* L1-ASPM enabled; disable(!) L0S */ - iwl_legacy_set_bit(priv, CSR_GIO_REG, + il_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IWL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); + IL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ - iwl_legacy_clear_bit(priv, CSR_GIO_REG, + il_clear_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IWL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); + IL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); } } /* Configure analog phase-lock-loop before activating to D0A */ if (priv->cfg->base_params->pll_cfg_val) - iwl_legacy_set_bit(priv, CSR_ANA_PLL_CFG, + il_set_bit(priv, CSR_ANA_PLL_CFG, priv->cfg->base_params->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from * D0U* --> D0A* (powered-up active) state. */ - iwl_legacy_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); /* * Wait for clock stabilization; once stabilized, access to - * device-internal resources is supported, e.g. iwl_legacy_write_prph() + * device-internal resources is supported, e.g. il_write_prph() * and accesses to uCode SRAM. */ - ret = iwl_poll_bit(priv, CSR_GP_CNTRL, + ret = il_poll_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { - IWL_DEBUG_INFO(priv, "Failed to init the card\n"); + IL_DEBUG_INFO(priv, "Failed to init the card\n"); goto out; } @@ -1089,29 +1089,29 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) * set by default in "CLK_CTRL_REG" after reset. */ if (priv->cfg->base_params->use_bsm) - iwl_legacy_write_prph(priv, APMG_CLK_EN_REG, + il_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - iwl_legacy_write_prph(priv, APMG_CLK_EN_REG, + il_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); /* Disable L1-Active */ - iwl_legacy_set_bits_prph(priv, APMG_PCIDEV_STT_REG, + il_set_bits_prph(priv, APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_L1_ACT_DIS); out: return ret; } -EXPORT_SYMBOL(iwl_legacy_apm_init); +EXPORT_SYMBOL(il_apm_init); -int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) +int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force) { int ret; s8 prev_tx_power; bool defer; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; lockdep_assert_held(&priv->mutex); @@ -1123,20 +1123,20 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IWL_WARN(priv, + IL_WARN(priv, "Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } if (tx_power > priv->tx_power_device_lmt) { - IWL_WARN(priv, + IL_WARN(priv, "Requested user TXPOWER %d above upper limit %d.\n", tx_power, priv->tx_power_device_lmt); return -EINVAL; } - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return -EIO; /* scan complete and commit_rxon use tx_power_next value, @@ -1147,7 +1147,7 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) defer = test_bit(STATUS_SCANNING, &priv->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { - IWL_DEBUG_INFO(priv, "Deferring tx power set\n"); + IL_DEBUG_INFO(priv, "Deferring tx power set\n"); return 0; } @@ -1163,11 +1163,11 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) } return ret; } -EXPORT_SYMBOL(iwl_legacy_set_tx_power); +EXPORT_SYMBOL(il_set_tx_power); -void iwl_legacy_send_bt_config(struct iwl_priv *priv) +void il_send_bt_config(struct il_priv *priv) { - struct iwl_bt_cmd bt_cmd = { + struct il_bt_cmd bt_cmd = { .lead_time = BT_LEAD_TIME_DEF, .max_kill = BT_MAX_KILL_DEF, .kill_ack_mask = 0, @@ -1179,95 +1179,95 @@ void iwl_legacy_send_bt_config(struct iwl_priv *priv) else bt_cmd.flags = BT_COEX_ENABLE; - IWL_DEBUG_INFO(priv, "BT coex %s\n", + IL_DEBUG_INFO(priv, "BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (iwl_legacy_send_cmd_pdu(priv, REPLY_BT_CONFIG, - sizeof(struct iwl_bt_cmd), &bt_cmd)) - IWL_ERR(priv, "failed to send BT Coex Config\n"); + if (il_send_cmd_pdu(priv, REPLY_BT_CONFIG, + sizeof(struct il_bt_cmd), &bt_cmd)) + IL_ERR(priv, "failed to send BT Coex Config\n"); } -EXPORT_SYMBOL(iwl_legacy_send_bt_config); +EXPORT_SYMBOL(il_send_bt_config); -int iwl_legacy_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear) +int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear) { - struct iwl_statistics_cmd statistics_cmd = { + struct il_statistics_cmd statistics_cmd = { .configuration_flags = - clear ? IWL_STATS_CONF_CLEAR_STATS : 0, + clear ? IL_STATS_CONF_CLEAR_STATS : 0, }; if (flags & CMD_ASYNC) - return iwl_legacy_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, - sizeof(struct iwl_statistics_cmd), + return il_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, + sizeof(struct il_statistics_cmd), &statistics_cmd, NULL); else - return iwl_legacy_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, - sizeof(struct iwl_statistics_cmd), + return il_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, + sizeof(struct il_statistics_cmd), &statistics_cmd); } -EXPORT_SYMBOL(iwl_legacy_send_statistics_request); +EXPORT_SYMBOL(il_send_statistics_request); -void iwl_legacy_rx_pm_sleep_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_pm_sleep_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); - IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); + IL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } -EXPORT_SYMBOL(iwl_legacy_rx_pm_sleep_notif); +EXPORT_SYMBOL(il_rx_pm_sleep_notif); -void iwl_legacy_rx_pm_debug_statistics_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_pm_debug_statistics_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " + IL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " "notification for %s:\n", len, - iwl_legacy_get_cmd_string(pkt->hdr.cmd)); - iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len); + il_get_cmd_string(pkt->hdr.cmd)); + il_print_hex_dump(priv, IL_DL_RADIO, pkt->u.raw, len); } -EXPORT_SYMBOL(iwl_legacy_rx_pm_debug_statistics_notif); +EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); -void iwl_legacy_rx_reply_error(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_reply_error(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); - IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " + IL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", le32_to_cpu(pkt->u.err_resp.error_type), - iwl_legacy_get_cmd_string(pkt->u.err_resp.cmd_id), + il_get_cmd_string(pkt->u.err_resp.cmd_id), pkt->u.err_resp.cmd_id, le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), le32_to_cpu(pkt->u.err_resp.error_info)); } -EXPORT_SYMBOL(iwl_legacy_rx_reply_error); +EXPORT_SYMBOL(il_rx_reply_error); -void iwl_legacy_clear_isr_stats(struct iwl_priv *priv) +void il_clear_isr_stats(struct il_priv *priv) { memset(&priv->isr_stats, 0, sizeof(priv->isr_stats)); } -int iwl_legacy_mac_conf_tx(struct ieee80211_hw *hw, +int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx; + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx; unsigned long flags; int q; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(priv)) { + IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); return -EIO; } if (queue >= AC_NUM) { - IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); + IL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); return 0; } @@ -1289,32 +1289,32 @@ int iwl_legacy_mac_conf_tx(struct ieee80211_hw *hw, spin_unlock_irqrestore(&priv->lock, flags); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return 0; } -EXPORT_SYMBOL(iwl_legacy_mac_conf_tx); +EXPORT_SYMBOL(il_mac_conf_tx); -int iwl_legacy_mac_tx_last_beacon(struct ieee80211_hw *hw) +int il_mac_tx_last_beacon(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - return priv->ibss_manager == IWL_IBSS_MANAGER; + return priv->ibss_manager == IL_IBSS_MANAGER; } -EXPORT_SYMBOL_GPL(iwl_legacy_mac_tx_last_beacon); +EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int -iwl_legacy_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_set_mode(struct il_priv *priv, struct il_rxon_context *ctx) { - iwl_legacy_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(priv, ctx); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); - return iwl_legacy_commit_rxon(priv, ctx); + return il_commit_rxon(priv, ctx); } -static int iwl_legacy_setup_interface(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il_setup_interface(struct il_priv *priv, + struct il_rxon_context *ctx) { struct ieee80211_vif *vif = ctx->vif; int err; @@ -1330,7 +1330,7 @@ static int iwl_legacy_setup_interface(struct iwl_priv *priv, ctx->is_active = true; - err = iwl_legacy_set_mode(priv, ctx); + err = il_set_mode(priv, ctx); if (err) { if (!ctx->always_active) ctx->is_active = false; @@ -1341,20 +1341,20 @@ static int iwl_legacy_setup_interface(struct iwl_priv *priv, } int -iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *tmp, *ctx = NULL; + struct il_priv *priv = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_rxon_context *tmp, *ctx = NULL; int err; - IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", + IL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", vif->type, vif->addr); mutex_lock(&priv->mutex); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_WARN(priv, "Try to add interface when device not ready\n"); + if (!il_is_ready_rf(priv)) { + IL_WARN(priv, "Try to add interface when device not ready\n"); err = -EINVAL; goto out; } @@ -1389,7 +1389,7 @@ iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) vif_priv->ctx = ctx; ctx->vif = vif; - err = iwl_legacy_setup_interface(priv, ctx); + err = il_setup_interface(priv, ctx); if (!err) goto out; @@ -1398,95 +1398,95 @@ iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) out: mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return err; } -EXPORT_SYMBOL(iwl_legacy_mac_add_interface); +EXPORT_SYMBOL(il_mac_add_interface); -static void iwl_legacy_teardown_interface(struct iwl_priv *priv, +static void il_teardown_interface(struct il_priv *priv, struct ieee80211_vif *vif, bool mode_change) { - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); lockdep_assert_held(&priv->mutex); if (priv->scan_vif == vif) { - iwl_legacy_scan_cancel_timeout(priv, 200); - iwl_legacy_force_scan_end(priv); + il_scan_cancel_timeout(priv, 200); + il_force_scan_end(priv); } if (!mode_change) { - iwl_legacy_set_mode(priv, ctx); + il_set_mode(priv, ctx); if (!ctx->always_active) ctx->is_active = false; } } -void iwl_legacy_mac_remove_interface(struct ieee80211_hw *hw, +void il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->mutex); WARN_ON(ctx->vif != vif); ctx->vif = NULL; - iwl_legacy_teardown_interface(priv, vif, false); + il_teardown_interface(priv, vif, false); memset(priv->bssid, 0, ETH_ALEN); mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -EXPORT_SYMBOL(iwl_legacy_mac_remove_interface); +EXPORT_SYMBOL(il_mac_remove_interface); -int iwl_legacy_alloc_txq_mem(struct iwl_priv *priv) +int il_alloc_txq_mem(struct il_priv *priv) { if (!priv->txq) priv->txq = kzalloc( - sizeof(struct iwl_tx_queue) * + sizeof(struct il_tx_queue) * priv->cfg->base_params->num_of_queues, GFP_KERNEL); if (!priv->txq) { - IWL_ERR(priv, "Not enough memory for txq\n"); + IL_ERR(priv, "Not enough memory for txq\n"); return -ENOMEM; } return 0; } -EXPORT_SYMBOL(iwl_legacy_alloc_txq_mem); +EXPORT_SYMBOL(il_alloc_txq_mem); -void iwl_legacy_txq_mem(struct iwl_priv *priv) +void il_txq_mem(struct il_priv *priv) { kfree(priv->txq); priv->txq = NULL; } -EXPORT_SYMBOL(iwl_legacy_txq_mem); +EXPORT_SYMBOL(il_txq_mem); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -#define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES) +#define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) -void iwl_legacy_reset_traffic_log(struct iwl_priv *priv) +void il_reset_traffic_log(struct il_priv *priv) { priv->tx_traffic_idx = 0; priv->rx_traffic_idx = 0; if (priv->tx_traffic) - memset(priv->tx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE); + memset(priv->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); if (priv->rx_traffic) - memset(priv->rx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE); + memset(priv->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); } -int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) +int il_alloc_traffic_mem(struct il_priv *priv) { - u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE; + u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; - if (iwlegacy_debug_level & IWL_DL_TX) { + if (iwlegacy_debug_level & IL_DL_TX) { if (!priv->tx_traffic) { priv->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1494,7 +1494,7 @@ int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) return -ENOMEM; } } - if (iwlegacy_debug_level & IWL_DL_RX) { + if (iwlegacy_debug_level & IL_DL_RX) { if (!priv->rx_traffic) { priv->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1502,12 +1502,12 @@ int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) return -ENOMEM; } } - iwl_legacy_reset_traffic_log(priv); + il_reset_traffic_log(priv); return 0; } -EXPORT_SYMBOL(iwl_legacy_alloc_traffic_mem); +EXPORT_SYMBOL(il_alloc_traffic_mem); -void iwl_legacy_free_traffic_mem(struct iwl_priv *priv) +void il_free_traffic_mem(struct il_priv *priv) { kfree(priv->tx_traffic); priv->tx_traffic = NULL; @@ -1515,15 +1515,15 @@ void iwl_legacy_free_traffic_mem(struct iwl_priv *priv) kfree(priv->rx_traffic); priv->rx_traffic = NULL; } -EXPORT_SYMBOL(iwl_legacy_free_traffic_mem); +EXPORT_SYMBOL(il_free_traffic_mem); -void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, +void il_dbg_log_tx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IWL_DL_TX))) + if (likely(!(iwlegacy_debug_level & IL_DL_TX))) return; if (!priv->tx_traffic) @@ -1531,24 +1531,24 @@ void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IWL_TRAFFIC_ENTRY_SIZE) - ? IWL_TRAFFIC_ENTRY_SIZE : length; + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((priv->tx_traffic + - (priv->tx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)), + (priv->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); priv->tx_traffic_idx = - (priv->tx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES; + (priv->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } -EXPORT_SYMBOL(iwl_legacy_dbg_log_tx_data_frame); +EXPORT_SYMBOL(il_dbg_log_tx_data_frame); -void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IWL_DL_RX))) + if (likely(!(iwlegacy_debug_level & IL_DL_RX))) return; if (!priv->rx_traffic) @@ -1556,56 +1556,56 @@ void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IWL_TRAFFIC_ENTRY_SIZE) - ? IWL_TRAFFIC_ENTRY_SIZE : length; + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((priv->rx_traffic + - (priv->rx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)), + (priv->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); priv->rx_traffic_idx = - (priv->rx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES; + (priv->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } -EXPORT_SYMBOL(iwl_legacy_dbg_log_rx_data_frame); +EXPORT_SYMBOL(il_dbg_log_rx_data_frame); -const char *iwl_legacy_get_mgmt_string(int cmd) +const char *il_get_mgmt_string(int cmd) { switch (cmd) { - IWL_CMD(MANAGEMENT_ASSOC_REQ); - IWL_CMD(MANAGEMENT_ASSOC_RESP); - IWL_CMD(MANAGEMENT_REASSOC_REQ); - IWL_CMD(MANAGEMENT_REASSOC_RESP); - IWL_CMD(MANAGEMENT_PROBE_REQ); - IWL_CMD(MANAGEMENT_PROBE_RESP); - IWL_CMD(MANAGEMENT_BEACON); - IWL_CMD(MANAGEMENT_ATIM); - IWL_CMD(MANAGEMENT_DISASSOC); - IWL_CMD(MANAGEMENT_AUTH); - IWL_CMD(MANAGEMENT_DEAUTH); - IWL_CMD(MANAGEMENT_ACTION); + IL_CMD(MANAGEMENT_ASSOC_REQ); + IL_CMD(MANAGEMENT_ASSOC_RESP); + IL_CMD(MANAGEMENT_REASSOC_REQ); + IL_CMD(MANAGEMENT_REASSOC_RESP); + IL_CMD(MANAGEMENT_PROBE_REQ); + IL_CMD(MANAGEMENT_PROBE_RESP); + IL_CMD(MANAGEMENT_BEACON); + IL_CMD(MANAGEMENT_ATIM); + IL_CMD(MANAGEMENT_DISASSOC); + IL_CMD(MANAGEMENT_AUTH); + IL_CMD(MANAGEMENT_DEAUTH); + IL_CMD(MANAGEMENT_ACTION); default: return "UNKNOWN"; } } -const char *iwl_legacy_get_ctrl_string(int cmd) +const char *il_get_ctrl_string(int cmd) { switch (cmd) { - IWL_CMD(CONTROL_BACK_REQ); - IWL_CMD(CONTROL_BACK); - IWL_CMD(CONTROL_PSPOLL); - IWL_CMD(CONTROL_RTS); - IWL_CMD(CONTROL_CTS); - IWL_CMD(CONTROL_ACK); - IWL_CMD(CONTROL_CFEND); - IWL_CMD(CONTROL_CFENDACK); + IL_CMD(CONTROL_BACK_REQ); + IL_CMD(CONTROL_BACK); + IL_CMD(CONTROL_PSPOLL); + IL_CMD(CONTROL_RTS); + IL_CMD(CONTROL_CTS); + IL_CMD(CONTROL_ACK); + IL_CMD(CONTROL_CFEND); + IL_CMD(CONTROL_CFENDACK); default: return "UNKNOWN"; } } -void iwl_legacy_clear_traffic_stats(struct iwl_priv *priv) +void il_clear_traffic_stats(struct il_priv *priv) { memset(&priv->tx_stats, 0, sizeof(struct traffic_stats)); memset(&priv->rx_stats, 0, sizeof(struct traffic_stats)); @@ -1613,17 +1613,17 @@ void iwl_legacy_clear_traffic_stats(struct iwl_priv *priv) /* * if CONFIG_IWLWIFI_LEGACY_DEBUGFS defined, - * iwl_legacy_update_stats function will + * il_update_stats function will * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass * Use debugFs to display the rx/rx_statistics * if CONFIG_IWLWIFI_LEGACY_DEBUGFS not being defined, then no MGMT and CTRL * information will be recorded, but DATA pkt still will be recorded - * for the reason of iwl_led.c need to control the led blinking based on + * for the reason of il_led.c need to control the led blinking based on * number of tx and rx data. * */ void -iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) +il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) { struct traffic_stats *stats; @@ -1704,12 +1704,12 @@ iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) stats->data_bytes += len; } } -EXPORT_SYMBOL(iwl_legacy_update_stats); +EXPORT_SYMBOL(il_update_stats); #endif -int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) +int il_force_reset(struct il_priv *priv, bool external) { - struct iwl_force_reset *force_reset; + struct il_force_reset *force_reset; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EINVAL; @@ -1720,7 +1720,7 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + force_reset->reset_duration, jiffies)) { - IWL_DEBUG_INFO(priv, "force reset rejected\n"); + IL_DEBUG_INFO(priv, "force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; } @@ -1738,14 +1738,14 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) */ if (!external && !priv->cfg->mod_params->restart_fw) { - IWL_DEBUG_INFO(priv, "Cancel firmware reload based on " + IL_DEBUG_INFO(priv, "Cancel firmware reload based on " "module parameter setting\n"); return 0; } - IWL_ERR(priv, "On demand firmware reload\n"); + IL_ERR(priv, "On demand firmware reload\n"); - /* Set the FW error flag -- cleared on iwl_down */ + /* Set the FW error flag -- cleared on il_down */ set_bit(STATUS_FW_ERROR, &priv->status); wake_up(&priv->wait_command_queue); /* @@ -1759,13 +1759,13 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) } int -iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, +il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); - struct iwl_rxon_context *tmp; + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + struct il_rxon_context *tmp; u32 interface_modes; int err; @@ -1773,7 +1773,7 @@ iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); - if (!ctx->vif || !iwl_legacy_is_ready_rf(priv)) { + if (!ctx->vif || !il_is_ready_rf(priv)) { /* * Huh? But wait ... this can maybe happen when * we're in the middle of a firmware restart! @@ -1807,10 +1807,10 @@ iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, } /* success */ - iwl_legacy_teardown_interface(priv, vif, true); + il_teardown_interface(priv, vif, true); vif->type = newtype; vif->p2p = newp2p; - err = iwl_legacy_setup_interface(priv, ctx); + err = il_setup_interface(priv, ctx); WARN_ON(err); /* * We've switched internally, but submitting to the @@ -1825,16 +1825,16 @@ iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, mutex_unlock(&priv->mutex); return err; } -EXPORT_SYMBOL(iwl_legacy_mac_change_interface); +EXPORT_SYMBOL(il_mac_change_interface); /* * On every watchdog tick we check (latest) time stamp. If it does not * change during timeout period and queue is not empty we reset firmware. */ -static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt) +static int il_check_stuck_queue(struct il_priv *priv, int cnt) { - struct iwl_tx_queue *txq = &priv->txq[cnt]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[cnt]; + struct il_queue *q = &txq->q; unsigned long timeout; int ret; @@ -1847,9 +1847,9 @@ static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt) msecs_to_jiffies(priv->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IWL_ERR(priv, "Queue %d stuck for %u ms.\n", + IL_ERR(priv, "Queue %d stuck for %u ms.\n", q->id, priv->cfg->base_params->wd_timeout); - ret = iwl_legacy_force_reset(priv, false); + ret = il_force_reset(priv, false); return (ret == -EAGAIN) ? 0 : 1; } @@ -1860,15 +1860,15 @@ static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt) * Making watchdog tick be a quarter of timeout assure we will * discover the queue hung between timeout and 1.25*timeout */ -#define IWL_WD_TICK(timeout) ((timeout) / 4) +#define IL_WD_TICK(timeout) ((timeout) / 4) /* * Watchdog timer callback, we check each tx queue for stuck, if if hung * we reset the firmware. If everything is fine just rearm the timer. */ -void iwl_legacy_bg_watchdog(unsigned long data) +void il_bg_watchdog(unsigned long data) { - struct iwl_priv *priv = (struct iwl_priv *)data; + struct il_priv *priv = (struct il_priv *)data; int cnt; unsigned long timeout; @@ -1880,36 +1880,36 @@ void iwl_legacy_bg_watchdog(unsigned long data) return; /* monitor and check for stuck cmd queue */ - if (iwl_legacy_check_stuck_queue(priv, priv->cmd_queue)) + if (il_check_stuck_queue(priv, priv->cmd_queue)) return; /* monitor and check for other stuck queues */ - if (iwl_legacy_is_any_associated(priv)) { + if (il_is_any_associated(priv)) { for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { /* skip as we already checked the command queue */ if (cnt == priv->cmd_queue) continue; - if (iwl_legacy_check_stuck_queue(priv, cnt)) + if (il_check_stuck_queue(priv, cnt)) return; } } mod_timer(&priv->watchdog, jiffies + - msecs_to_jiffies(IWL_WD_TICK(timeout))); + msecs_to_jiffies(IL_WD_TICK(timeout))); } -EXPORT_SYMBOL(iwl_legacy_bg_watchdog); +EXPORT_SYMBOL(il_bg_watchdog); -void iwl_legacy_setup_watchdog(struct iwl_priv *priv) +void il_setup_watchdog(struct il_priv *priv) { unsigned int timeout = priv->cfg->base_params->wd_timeout; if (timeout) mod_timer(&priv->watchdog, - jiffies + msecs_to_jiffies(IWL_WD_TICK(timeout))); + jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); else del_timer(&priv->watchdog); } -EXPORT_SYMBOL(iwl_legacy_setup_watchdog); +EXPORT_SYMBOL(il_setup_watchdog); /* * extended beacon time format @@ -1918,7 +1918,7 @@ EXPORT_SYMBOL(iwl_legacy_setup_watchdog); * the internal part is the time in usec within one beacon interval */ u32 -iwl_legacy_usecs_to_beacons(struct iwl_priv *priv, +il_usecs_to_beacons(struct il_priv *priv, u32 usec, u32 beacon_interval) { u32 quot; @@ -1929,30 +1929,30 @@ iwl_legacy_usecs_to_beacons(struct iwl_priv *priv, return 0; quot = (usec / interval) & - (iwl_legacy_beacon_time_mask_high(priv, + (il_beacon_time_mask_high(priv, priv->hw_params.beacon_time_tsf_bits) >> priv->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & iwl_legacy_beacon_time_mask_low(priv, + rem = (usec % interval) & il_beacon_time_mask_low(priv, priv->hw_params.beacon_time_tsf_bits); return (quot << priv->hw_params.beacon_time_tsf_bits) + rem; } -EXPORT_SYMBOL(iwl_legacy_usecs_to_beacons); +EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ -__le32 iwl_legacy_add_beacon_time(struct iwl_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *priv, u32 base, u32 addon, u32 beacon_interval) { - u32 base_low = base & iwl_legacy_beacon_time_mask_low(priv, + u32 base_low = base & il_beacon_time_mask_low(priv, priv->hw_params.beacon_time_tsf_bits); - u32 addon_low = addon & iwl_legacy_beacon_time_mask_low(priv, + u32 addon_low = addon & il_beacon_time_mask_low(priv, priv->hw_params.beacon_time_tsf_bits); u32 interval = beacon_interval * TIME_UNIT; - u32 res = (base & iwl_legacy_beacon_time_mask_high(priv, + u32 res = (base & il_beacon_time_mask_high(priv, priv->hw_params.beacon_time_tsf_bits)) + - (addon & iwl_legacy_beacon_time_mask_high(priv, + (addon & il_beacon_time_mask_high(priv, priv->hw_params.beacon_time_tsf_bits)); if (base_low > addon_low) @@ -1965,32 +1965,32 @@ __le32 iwl_legacy_add_beacon_time(struct iwl_priv *priv, u32 base, return cpu_to_le32(res); } -EXPORT_SYMBOL(iwl_legacy_add_beacon_time); +EXPORT_SYMBOL(il_add_beacon_time); #ifdef CONFIG_PM -int iwl_legacy_pci_suspend(struct device *device) +int il_pci_suspend(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); /* * This function is called when system goes into suspend state - * mac80211 will call iwl_mac_stop() from the mac80211 suspend function - * first but since iwl_mac_stop() has no knowledge of who the caller is, + * mac80211 will call il_mac_stop() from the mac80211 suspend function + * first but since il_mac_stop() has no knowledge of who the caller is, * it will not call apm_ops.stop() to stop the DMA operation. * Calling apm_ops.stop here to make sure we stop the DMA. */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); return 0; } -EXPORT_SYMBOL(iwl_legacy_pci_suspend); +EXPORT_SYMBOL(il_pci_suspend); -int iwl_legacy_pci_resume(struct device *device) +int il_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); bool hw_rfkill = false; /* @@ -1999,9 +1999,9 @@ int iwl_legacy_pci_resume(struct device *device) */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); - if (!(iwl_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; @@ -2014,22 +2014,22 @@ int iwl_legacy_pci_resume(struct device *device) return 0; } -EXPORT_SYMBOL(iwl_legacy_pci_resume); +EXPORT_SYMBOL(il_pci_resume); -const struct dev_pm_ops iwl_legacy_pm_ops = { - .suspend = iwl_legacy_pci_suspend, - .resume = iwl_legacy_pci_resume, - .freeze = iwl_legacy_pci_suspend, - .thaw = iwl_legacy_pci_resume, - .poweroff = iwl_legacy_pci_suspend, - .restore = iwl_legacy_pci_resume, +const struct dev_pm_ops il_pm_ops = { + .suspend = il_pci_suspend, + .resume = il_pci_resume, + .freeze = il_pci_suspend, + .thaw = il_pci_resume, + .poweroff = il_pci_suspend, + .restore = il_pci_resume, }; -EXPORT_SYMBOL(iwl_legacy_pm_ops); +EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ static void -iwl_legacy_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) { if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; @@ -2046,43 +2046,43 @@ iwl_legacy_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx) if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", + IL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); - iwl_legacy_send_cmd_pdu_async(priv, ctx->qos_cmd, - sizeof(struct iwl_qosparam_cmd), + il_send_cmd_pdu_async(priv, ctx->qos_cmd, + sizeof(struct il_qosparam_cmd), &ctx->qos_data.def_qos_parm, NULL); } /** - * iwl_legacy_mac_config - mac80211 config callback + * il_mac_config - mac80211 config callback */ -int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) +int il_mac_config(struct ieee80211_hw *hw, u32 changed) { - struct iwl_priv *priv = hw->priv; - const struct iwl_channel_info *ch_info; + struct il_priv *priv = hw->priv; + const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = conf->channel; - struct iwl_ht_config *ht_conf = &priv->current_ht_config; - struct iwl_rxon_context *ctx; + struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_rxon_context *ctx; unsigned long flags = 0; int ret = 0; u16 ch; int scan_active = 0; - bool ht_changed[NUM_IWL_RXON_CTX] = {}; + bool ht_changed[NUM_IL_RXON_CTX] = {}; if (WARN_ON(!priv->cfg->ops->legacy)) return -EOPNOTSUPP; mutex_lock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n", + IL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n", channel->hw_value, changed); if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) { scan_active = 1; - IWL_DEBUG_MAC80211(priv, "scan active\n"); + IL_DEBUG_MAC80211(priv, "scan active\n"); } if (changed & (IEEE80211_CONF_CHANGE_SMPS | @@ -2110,16 +2110,16 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) goto set_ch_out; ch = channel->hw_value; - ch_info = iwl_legacy_get_channel_info(priv, channel->band, ch); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); + ch_info = il_get_channel_info(priv, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); ret = -EINVAL; goto set_ch_out; } if (priv->iw_mode == NL80211_IFTYPE_ADHOC && - !iwl_legacy_is_channel_ibss(ch_info)) { - IWL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n"); + !il_is_channel_ibss(ch_info)) { + IL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n"); ret = -EINVAL; goto set_ch_out; } @@ -2151,7 +2151,7 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) /* * Default to no protection. Protection mode will - * later be set from BSS config in iwl_ht_conf + * later be set from BSS config in il_ht_conf */ ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; @@ -2162,10 +2162,10 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - iwl_legacy_set_rxon_channel(priv, channel, ctx); - iwl_legacy_set_rxon_ht(priv, ht_conf); + il_set_rxon_channel(priv, channel, ctx); + il_set_rxon_ht(priv, ht_conf); - iwl_legacy_set_flags_for_band(priv, ctx, channel->band, + il_set_flags_for_band(priv, ctx, channel->band, ctx->vif); } @@ -2179,25 +2179,25 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) /* The list of supported rates and rate mask can be different * for each band; since the band may have changed, reset * the rate mask to what mac80211 lists */ - iwl_legacy_set_rate(priv); + il_set_rate(priv); } if (changed & (IEEE80211_CONF_CHANGE_PS | IEEE80211_CONF_CHANGE_IDLE)) { - ret = iwl_legacy_power_update_mode(priv, false); + ret = il_power_update_mode(priv, false); if (ret) - IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); + IL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", + IL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", priv->tx_power_user_lmt, conf->power_level); - iwl_legacy_set_tx_power(priv, conf->power_level, false); + il_set_tx_power(priv, conf->power_level, false); } - if (!iwl_legacy_is_ready(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); + if (!il_is_ready(priv)) { + IL_DEBUG_MAC80211(priv, "leave - not ready\n"); goto out; } @@ -2206,37 +2206,37 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) for_each_context(priv, ctx) { if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); else - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Not re-sending same RXON configuration.\n"); if (ht_changed[ctx->ctxid]) - iwl_legacy_update_qos(priv, ctx); + il_update_qos(priv, ctx); } out: - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); mutex_unlock(&priv->mutex); return ret; } -EXPORT_SYMBOL(iwl_legacy_mac_config); +EXPORT_SYMBOL(il_mac_config); -void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, +void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; unsigned long flags; - /* IBSS can only be the IWL_RXON_CTX_BSS context */ - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + /* IBSS can only be the IL_RXON_CTX_BSS context */ + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (WARN_ON(!priv->cfg->ops->legacy)) return; mutex_lock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); spin_lock_irqsave(&priv->lock, flags); - memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_config)); + memset(&priv->current_ht_config, 0, sizeof(struct il_ht_config)); spin_unlock_irqrestore(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags); @@ -2251,9 +2251,9 @@ void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, spin_unlock_irqrestore(&priv->lock, flags); - iwl_legacy_scan_cancel_timeout(priv, 100); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); + il_scan_cancel_timeout(priv, 100); + if (!il_is_ready_rf(priv)) { + IL_DEBUG_MAC80211(priv, "leave - not ready\n"); mutex_unlock(&priv->mutex); return; } @@ -2262,25 +2262,25 @@ void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, * clear RXON_FILTER_ASSOC_MSK bit */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); - iwl_legacy_set_rate(priv); + il_set_rate(priv); mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -EXPORT_SYMBOL(iwl_legacy_mac_reset_tsf); +EXPORT_SYMBOL(il_mac_reset_tsf); -static void iwl_legacy_ht_conf(struct iwl_priv *priv, +static void il_ht_conf(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &priv->current_ht_config; struct ieee80211_sta *sta; struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IWL_DEBUG_ASSOC(priv, "enter:\n"); + IL_DEBUG_ASSOC(priv, "enter:\n"); if (!ctx->ht.enabled) return; @@ -2329,13 +2329,13 @@ static void iwl_legacy_ht_conf(struct iwl_priv *priv, break; } - IWL_DEBUG_ASSOC(priv, "leave\n"); + IL_DEBUG_ASSOC(priv, "leave\n"); } -static inline void iwl_legacy_set_no_assoc(struct iwl_priv *priv, +static inline void il_set_no_assoc(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); /* * inform the ucode that there is no longer an @@ -2344,13 +2344,13 @@ static inline void iwl_legacy_set_no_assoc(struct iwl_priv *priv, */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = 0; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } -static void iwl_legacy_beacon_update(struct ieee80211_hw *hw, +static void il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; unsigned long flags; __le64 timestamp; struct sk_buff *skb = ieee80211_beacon_get(hw, vif); @@ -2358,12 +2358,12 @@ static void iwl_legacy_beacon_update(struct ieee80211_hw *hw, if (!skb) return; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); lockdep_assert_held(&priv->mutex); if (!priv->beacon_ctx) { - IWL_ERR(priv, "update beacon but no beacon context!\n"); + IL_ERR(priv, "update beacon but no beacon context!\n"); dev_kfree_skb(skb); return; } @@ -2378,34 +2378,34 @@ static void iwl_legacy_beacon_update(struct ieee80211_hw *hw, timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; priv->timestamp = le64_to_cpu(timestamp); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); spin_unlock_irqrestore(&priv->lock, flags); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(priv)) { + IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); return; } priv->cfg->ops->legacy->post_associate(priv); } -void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, +void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); int ret; if (WARN_ON(!priv->cfg->ops->legacy)) return; - IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); + IL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); mutex_lock(&priv->mutex); - if (!iwl_legacy_is_alive(priv)) { + if (!il_is_alive(priv)) { mutex_unlock(&priv->mutex); return; } @@ -2415,7 +2415,7 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, spin_lock_irqsave(&priv->lock, flags); ctx->qos_data.qos_active = bss_conf->qos; - iwl_legacy_update_qos(priv, ctx); + il_update_qos(priv, ctx); spin_unlock_irqrestore(&priv->lock, flags); } @@ -2432,17 +2432,17 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_BSSID) { - IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); + IL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); /* * If there is currently a HW scan going on in the * background then we need to cancel it else the RXON * below/in post_associate will fail. */ - if (iwl_legacy_scan_cancel_timeout(priv, 100)) { - IWL_WARN(priv, + if (il_scan_cancel_timeout(priv, 100)) { + IL_WARN(priv, "Aborted scan still in progress after 100ms\n"); - IWL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n"); mutex_unlock(&priv->mutex); return; @@ -2468,10 +2468,10 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, * it will invoke post_associate. */ if (vif->type == NL80211_IFTYPE_ADHOC && changes & BSS_CHANGED_BEACON) - iwl_legacy_beacon_update(hw, vif); + il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", + IL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2480,7 +2480,7 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - IWL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) @@ -2496,7 +2496,7 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, if (changes & BSS_CHANGED_BASIC_RATES) { /* XXX use this information * - * To do that, remove code from iwl_legacy_set_rate() and put something + * To do that, remove code from il_set_rate() and put something * like this here: * if (A-band) @@ -2511,32 +2511,32 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_HT) { - iwl_legacy_ht_conf(priv, vif); + il_ht_conf(priv, vif); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); } if (changes & BSS_CHANGED_ASSOC) { - IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); + IL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); if (bss_conf->assoc) { priv->timestamp = bss_conf->timestamp; - if (!iwl_legacy_is_rfkill(priv)) + if (!il_is_rfkill(priv)) priv->cfg->ops->legacy->post_associate(priv); } else - iwl_legacy_set_no_assoc(priv, vif); + il_set_no_assoc(priv, vif); } - if (changes && iwl_legacy_is_associated_ctx(ctx) && bss_conf->aid) { - IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", + if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { + IL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", changes); - ret = iwl_legacy_send_rxon_assoc(priv, ctx); + ret = il_send_rxon_assoc(priv, ctx); if (!ret) { /* Sync active_rxon with latest change. */ memcpy((void *)&ctx->active, &ctx->staging, - sizeof(struct iwl_legacy_rxon_cmd)); + sizeof(struct il_rxon_cmd)); } } @@ -2547,27 +2547,27 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); priv->cfg->ops->legacy->config_ap(priv); } else - iwl_legacy_set_no_assoc(priv, vif); + il_set_no_assoc(priv, vif); } if (changes & BSS_CHANGED_IBSS) { ret = priv->cfg->ops->legacy->manage_ibss_station(priv, vif, bss_conf->ibss_joined); if (ret) - IWL_ERR(priv, "failed to %s IBSS station %pM\n", + IL_ERR(priv, "failed to %s IBSS station %pM\n", bss_conf->ibss_joined ? "add" : "remove", bss_conf->bssid); } mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -EXPORT_SYMBOL(iwl_legacy_mac_bss_info_changed); +EXPORT_SYMBOL(il_mac_bss_info_changed); -irqreturn_t iwl_legacy_isr(int irq, void *data) +irqreturn_t il_isr(int irq, void *data) { - struct iwl_priv *priv = data; + struct il_priv *priv = data; u32 inta, inta_mask; u32 inta_fh; unsigned long flags; @@ -2580,18 +2580,18 @@ irqreturn_t iwl_legacy_isr(int irq, void *data) * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */ - iwl_write32(priv, CSR_INT_MASK, 0x00000000); + inta_mask = il_read32(priv, CSR_INT_MASK); /* just for debug */ + il_write32(priv, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ - inta = iwl_read32(priv, CSR_INT); - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); + inta = il_read32(priv, CSR_INT); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); /* Ignore interrupt if there's nothing in NIC to service. * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - IWL_DEBUG_ISR(priv, + IL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -2599,16 +2599,16 @@ irqreturn_t iwl_legacy_isr(int irq, void *data) if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { /* Hardware disappeared. It might have already raised * an interrupt */ - IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); + IL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); goto unplugged; } - IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + IL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); inta &= ~CSR_INT_BIT_SCD; - /* iwl_irq_tasklet() will service interrupts and re-enable them */ + /* il_irq_tasklet() will service interrupts and re-enable them */ if (likely(inta || inta_fh)) tasklet_schedule(&priv->irq_tasklet); @@ -2620,17 +2620,17 @@ none: /* re-enable interrupts here since we don't have anything to service. */ /* only Re-enable if disabled by irq */ if (test_bit(STATUS_INT_ENABLED, &priv->status)) - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); return IRQ_NONE; } -EXPORT_SYMBOL(iwl_legacy_isr); +EXPORT_SYMBOL(il_isr); /* - * iwl_legacy_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this + * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this * function. */ -void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv, +void il_tx_cmd_protection(struct il_priv *priv, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags) { @@ -2658,4 +2658,4 @@ void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv, *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; } } -EXPORT_SYMBOL(iwl_legacy_tx_cmd_protection); +EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index d1271fe..92f37c9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -60,54 +60,54 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_legacy_core_h__ -#define __iwl_legacy_core_h__ +#ifndef __il_core_h__ +#define __il_core_h__ /************************ * forward declarations * ************************/ -struct iwl_host_cmd; -struct iwl_cmd; +struct il_host_cmd; +struct il_cmd; #define IWLWIFI_VERSION "in-tree:" #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" #define DRV_AUTHOR "" -#define IWL_PCI_DEVICE(dev, subdev, cfg) \ +#define IL_PCI_DEVICE(dev, subdev, cfg) \ .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ .driver_data = (kernel_ulong_t)&(cfg) #define TIME_UNIT 1024 -#define IWL_SKU_G 0x1 -#define IWL_SKU_A 0x2 -#define IWL_SKU_N 0x8 +#define IL_SKU_G 0x1 +#define IL_SKU_A 0x2 +#define IL_SKU_N 0x8 -#define IWL_CMD(x) case x: return #x +#define IL_CMD(x) case x: return #x -struct iwl_hcmd_ops { - int (*rxon_assoc)(struct iwl_priv *priv, struct iwl_rxon_context *ctx); - int (*commit_rxon)(struct iwl_priv *priv, struct iwl_rxon_context *ctx); - void (*set_rxon_chain)(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +struct il_hcmd_ops { + int (*rxon_assoc)(struct il_priv *priv, struct il_rxon_context *ctx); + int (*commit_rxon)(struct il_priv *priv, struct il_rxon_context *ctx); + void (*set_rxon_chain)(struct il_priv *priv, + struct il_rxon_context *ctx); }; -struct iwl_hcmd_utils_ops { +struct il_hcmd_utils_ops { u16 (*get_hcmd_size)(u8 cmd_id, u16 len); - u16 (*build_addsta_hcmd)(const struct iwl_legacy_addsta_cmd *cmd, + u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, u8 *data); - int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif); - void (*post_scan)(struct iwl_priv *priv); + int (*request_scan)(struct il_priv *priv, struct ieee80211_vif *vif); + void (*post_scan)(struct il_priv *priv); }; -struct iwl_apm_ops { - int (*init)(struct iwl_priv *priv); - void (*config)(struct iwl_priv *priv); +struct il_apm_ops { + int (*init)(struct il_priv *priv); + void (*config)(struct il_priv *priv); }; -struct iwl_debugfs_ops { +struct il_debugfs_ops { ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, @@ -116,79 +116,79 @@ struct iwl_debugfs_ops { size_t count, loff_t *ppos); }; -struct iwl_temp_ops { - void (*temperature)(struct iwl_priv *priv); +struct il_temp_ops { + void (*temperature)(struct il_priv *priv); }; -struct iwl_lib_ops { +struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params)(struct iwl_priv *priv); + int (*set_hw_params)(struct il_priv *priv); /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv, - struct iwl_tx_queue *txq, + void (*txq_update_byte_cnt_tbl)(struct il_priv *priv, + struct il_tx_queue *txq, u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct iwl_priv *priv, - struct iwl_tx_queue *txq, + int (*txq_attach_buf_to_tfd)(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct iwl_priv *priv, - struct iwl_tx_queue *txq); - int (*txq_init)(struct iwl_priv *priv, - struct iwl_tx_queue *txq); + void (*txq_free_tfd)(struct il_priv *priv, + struct il_tx_queue *txq); + int (*txq_init)(struct il_priv *priv, + struct il_tx_queue *txq); /* setup Rx handler */ - void (*rx_handler_setup)(struct iwl_priv *priv); + void (*rx_handler_setup)(struct il_priv *priv); /* alive notification after init uCode load */ - void (*init_alive_start)(struct iwl_priv *priv); + void (*init_alive_start)(struct il_priv *priv); /* check validity of rtc data address */ int (*is_valid_rtc_data_addr)(u32 addr); /* 1st ucode load */ - int (*load_ucode)(struct iwl_priv *priv); + int (*load_ucode)(struct il_priv *priv); - void (*dump_nic_error_log)(struct iwl_priv *priv); - int (*dump_fh)(struct iwl_priv *priv, char **buf, bool display); - int (*set_channel_switch)(struct iwl_priv *priv, + void (*dump_nic_error_log)(struct il_priv *priv); + int (*dump_fh)(struct il_priv *priv, char **buf, bool display); + int (*set_channel_switch)(struct il_priv *priv, struct ieee80211_channel_switch *ch_switch); /* power management */ - struct iwl_apm_ops apm_ops; + struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct iwl_priv *priv); - void (*update_chain_flags)(struct iwl_priv *priv); + int (*send_tx_power) (struct il_priv *priv); + void (*update_chain_flags)(struct il_priv *priv); /* eeprom operations (as defined in iwl-eeprom.h) */ - struct iwl_eeprom_ops eeprom_ops; + struct il_eeprom_ops eeprom_ops; /* temperature */ - struct iwl_temp_ops temp_ops; + struct il_temp_ops temp_ops; - struct iwl_debugfs_ops debugfs_ops; + struct il_debugfs_ops debugfs_ops; }; -struct iwl_led_ops { - int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd); +struct il_led_ops { + int (*cmd)(struct il_priv *priv, struct il_led_cmd *led_cmd); }; -struct iwl_legacy_ops { - void (*post_associate)(struct iwl_priv *priv); - void (*config_ap)(struct iwl_priv *priv); +struct il_legacy_ops { + void (*post_associate)(struct il_priv *priv); + void (*config_ap)(struct il_priv *priv); /* station management */ - int (*update_bcast_stations)(struct iwl_priv *priv); - int (*manage_ibss_station)(struct iwl_priv *priv, + int (*update_bcast_stations)(struct il_priv *priv); + int (*manage_ibss_station)(struct il_priv *priv, struct ieee80211_vif *vif, bool add); }; -struct iwl_ops { - const struct iwl_lib_ops *lib; - const struct iwl_hcmd_ops *hcmd; - const struct iwl_hcmd_utils_ops *utils; - const struct iwl_led_ops *led; - const struct iwl_nic_ops *nic; - const struct iwl_legacy_ops *legacy; +struct il_ops { + const struct il_lib_ops *lib; + const struct il_hcmd_ops *hcmd; + const struct il_hcmd_utils_ops *utils; + const struct il_led_ops *led; + const struct il_nic_ops *nic; + const struct il_legacy_ops *legacy; const struct ieee80211_ops *ieee80211_ops; }; -struct iwl_mod_params { +struct il_mod_params { int sw_crypto; /* def: 0 = using hardware encryption */ int disable_hw_scan; /* def: 0 = use h/w scan */ int num_of_queues; /* def: HW dependent */ @@ -211,11 +211,11 @@ struct iwl_mod_params { * @chain_noise_calib_by_driver: driver has the capability to perform * chain noise calibration operation */ -struct iwl_base_params { +struct il_base_params { int eeprom_size; int num_of_queues; /* def: HW dependent */ int num_of_ampdu_queues;/* def: HW dependent */ - /* for iwl_legacy_apm_init() */ + /* for il_apm_init() */ u32 pll_cfg_val; bool set_l0s; bool use_bsm; @@ -230,7 +230,7 @@ struct iwl_base_params { }; /** - * struct iwl_cfg + * struct il_cfg * @fw_name_pre: Firmware filename prefix. The api version and extension * (.ucode) will be added to filename before loading from disk. The * filename is constructed as fw_name_pre.ucode. @@ -243,11 +243,11 @@ struct iwl_base_params { * driver specifies which APIs it supports (with @ucode_api_max being the * highest and @ucode_api_min the lowest). Firmware will only be loaded if * it has a supported API version. The firmware's API version will be - * stored in @iwl_priv, enabling the driver to make runtime changes based + * stored in @il_priv, enabling the driver to make runtime changes based * on firmware version used. * * For example, - * if (IWL_UCODE_API(priv->ucode_ver) >= 2) { + * if (IL_UCODE_API(priv->ucode_ver) >= 2) { * Driver interacts with Firmware API version >= 2. * } else { * Driver interacts with Firmware API version 1. @@ -255,12 +255,12 @@ struct iwl_base_params { * * The ideal usage of this infrastructure is to treat a new ucode API * release as a new hardware revision. That is, through utilizing the - * iwl_hcmd_utils_ops etc. we accommodate different command structures + * il_hcmd_utils_ops etc. we accommodate different command structures * and flows between hardware versions as well as their API * versions. * */ -struct iwl_cfg { +struct il_cfg { /* params specific to an individual device within a device family */ const char *name; const char *fw_name_pre; @@ -271,97 +271,97 @@ struct iwl_cfg { unsigned int sku; u16 eeprom_ver; u16 eeprom_calib_ver; - const struct iwl_ops *ops; + const struct il_ops *ops; /* module based parameters which can be set from modprobe cmd */ - const struct iwl_mod_params *mod_params; + const struct il_mod_params *mod_params; /* params not likely to change within a device family */ - struct iwl_base_params *base_params; + struct il_base_params *base_params; /* params likely to change within a device family */ u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; - enum iwl_led_mode led_mode; + enum il_led_mode led_mode; }; /*************************** * L i b * ***************************/ -struct ieee80211_hw *iwl_legacy_alloc_all(struct iwl_cfg *cfg); -int iwl_legacy_mac_conf_tx(struct ieee80211_hw *hw, +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); +int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params); -int iwl_legacy_mac_tx_last_beacon(struct ieee80211_hw *hw); -void iwl_legacy_set_rxon_hwcrypto(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il_mac_tx_last_beacon(struct ieee80211_hw *hw); +void il_set_rxon_hwcrypto(struct il_priv *priv, + struct il_rxon_context *ctx, int hw_decrypt); -int iwl_legacy_check_rxon_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl_legacy_full_rxon_required(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl_legacy_set_rxon_channel(struct iwl_priv *priv, +int il_check_rxon_cmd(struct il_priv *priv, + struct il_rxon_context *ctx); +int il_full_rxon_required(struct il_priv *priv, + struct il_rxon_context *ctx); +int il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, - struct iwl_rxon_context *ctx); -void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, + struct il_rxon_context *ctx); +void il_set_flags_for_band(struct il_priv *priv, + struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif); -u8 iwl_legacy_get_single_channel_number(struct iwl_priv *priv, +u8 il_get_single_channel_number(struct il_priv *priv, enum ieee80211_band band); -void iwl_legacy_set_rxon_ht(struct iwl_priv *priv, - struct iwl_ht_config *ht_conf); -bool iwl_legacy_is_ht40_tx_allowed(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il_set_rxon_ht(struct il_priv *priv, + struct il_ht_config *ht_conf); +bool il_is_ht40_tx_allowed(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap); -void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -void iwl_legacy_set_rate(struct iwl_priv *priv); -int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, +void il_connection_init_rx_config(struct il_priv *priv, + struct il_rxon_context *ctx); +void il_set_rate(struct il_priv *priv); +int il_set_decrypted_flag(struct il_priv *priv, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats); -void iwl_legacy_irq_handle_error(struct iwl_priv *priv); -int iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, +void il_irq_handle_error(struct il_priv *priv); +int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); -void iwl_legacy_mac_remove_interface(struct ieee80211_hw *hw, +void il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); -int iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, +int il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p); -int iwl_legacy_alloc_txq_mem(struct iwl_priv *priv); -void iwl_legacy_txq_mem(struct iwl_priv *priv); +int il_alloc_txq_mem(struct il_priv *priv); +void il_txq_mem(struct il_priv *priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv); -void iwl_legacy_free_traffic_mem(struct iwl_priv *priv); -void iwl_legacy_reset_traffic_log(struct iwl_priv *priv); -void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, +int il_alloc_traffic_mem(struct il_priv *priv); +void il_free_traffic_mem(struct il_priv *priv); +void il_reset_traffic_log(struct il_priv *priv); +void il_dbg_log_tx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header); -void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header); -const char *iwl_legacy_get_mgmt_string(int cmd); -const char *iwl_legacy_get_ctrl_string(int cmd); -void iwl_legacy_clear_traffic_stats(struct iwl_priv *priv); -void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, +const char *il_get_mgmt_string(int cmd); +const char *il_get_ctrl_string(int cmd); +void il_clear_traffic_stats(struct il_priv *priv); +void il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len); #else -static inline int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) +static inline int il_alloc_traffic_mem(struct il_priv *priv) { return 0; } -static inline void iwl_legacy_free_traffic_mem(struct iwl_priv *priv) +static inline void il_free_traffic_mem(struct il_priv *priv) { } -static inline void iwl_legacy_reset_traffic_log(struct iwl_priv *priv) +static inline void il_reset_traffic_log(struct il_priv *priv) { } -static inline void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, +static inline void il_dbg_log_tx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { } -static inline void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, +static inline void il_dbg_log_rx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { } -static inline void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, +static inline void il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) { } @@ -369,83 +369,83 @@ static inline void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, /***************************************************** * RX handlers. * **************************************************/ -void iwl_legacy_rx_pm_sleep_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl_legacy_rx_pm_debug_statistics_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl_legacy_rx_reply_error(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); +void il_rx_pm_sleep_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il_rx_pm_debug_statistics_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il_rx_reply_error(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); /***************************************************** * RX ******************************************************/ -void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv); -void iwl_legacy_cmd_queue_free(struct iwl_priv *priv); -int iwl_legacy_rx_queue_alloc(struct iwl_priv *priv); -void iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, - struct iwl_rx_queue *q); -int iwl_legacy_rx_queue_space(const struct iwl_rx_queue *q); -void iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); +void il_cmd_queue_unmap(struct il_priv *priv); +void il_cmd_queue_free(struct il_priv *priv); +int il_rx_queue_alloc(struct il_priv *priv); +void il_rx_queue_update_write_ptr(struct il_priv *priv, + struct il_rx_queue *q); +int il_rx_queue_space(const struct il_rx_queue *q); +void il_tx_cmd_complete(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); /* Handlers */ -void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl_legacy_recover_from_statistics(struct iwl_priv *priv, - struct iwl_rx_packet *pkt); -void iwl_legacy_chswitch_done(struct iwl_priv *priv, bool is_success); -void iwl_legacy_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); +void il_rx_spectrum_measure_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il_recover_from_statistics(struct il_priv *priv, + struct il_rx_packet *pkt); +void il_chswitch_done(struct il_priv *priv, bool is_success); +void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb); /* TX helpers */ /***************************************************** * TX ******************************************************/ -void iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, +void il_txq_update_write_ptr(struct il_priv *priv, + struct il_tx_queue *txq); +int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, int slots_num, u32 txq_id); -void iwl_legacy_tx_queue_reset(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il_tx_queue_reset(struct il_priv *priv, + struct il_tx_queue *txq, int slots_num, u32 txq_id); -void iwl_legacy_tx_queue_unmap(struct iwl_priv *priv, int txq_id); -void iwl_legacy_tx_queue_free(struct iwl_priv *priv, int txq_id); -void iwl_legacy_setup_watchdog(struct iwl_priv *priv); +void il_tx_queue_unmap(struct il_priv *priv, int txq_id); +void il_tx_queue_free(struct il_priv *priv, int txq_id); +void il_setup_watchdog(struct il_priv *priv); /***************************************************** * TX power ****************************************************/ -int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force); +int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force); /******************************************************************************* * Rate ******************************************************************************/ -u8 iwl_legacy_get_lowest_plcp(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +u8 il_get_lowest_plcp(struct il_priv *priv, + struct il_rxon_context *ctx); /******************************************************************************* * Scanning ******************************************************************************/ -void iwl_legacy_init_scan_params(struct iwl_priv *priv); -int iwl_legacy_scan_cancel(struct iwl_priv *priv); -int iwl_legacy_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); -void iwl_legacy_force_scan_end(struct iwl_priv *priv); -int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, +void il_init_scan_params(struct il_priv *priv); +int il_scan_cancel(struct il_priv *priv); +int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms); +void il_force_scan_end(struct il_priv *priv); +int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req); -void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv); -int iwl_legacy_force_reset(struct iwl_priv *priv, bool external); -u16 iwl_legacy_fill_probe_req(struct iwl_priv *priv, +void il_internal_short_hw_scan(struct il_priv *priv); +int il_force_reset(struct il_priv *priv, bool external); +u16 il_fill_probe_req(struct il_priv *priv, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ie, int ie_len, int left); -void iwl_legacy_setup_rx_scan_handlers(struct iwl_priv *priv); -u16 iwl_legacy_get_active_dwell_time(struct iwl_priv *priv, +void il_setup_rx_scan_handlers(struct il_priv *priv); +u16 il_get_active_dwell_time(struct il_priv *priv, enum ieee80211_band band, u8 n_probes); -u16 iwl_legacy_get_passive_dwell_time(struct iwl_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *priv, enum ieee80211_band band, struct ieee80211_vif *vif); -void iwl_legacy_setup_scan_deferred_work(struct iwl_priv *priv); -void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv); +void il_setup_scan_deferred_work(struct il_priv *priv); +void il_cancel_scan_deferred_work(struct il_priv *priv); /* For faster active scanning, scan will move to the next channel if fewer than * PLCP_QUIET_THRESH packets are heard on this channel within @@ -453,35 +453,35 @@ void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv); * time if it's a quiet channel (nothing responded to our probe, and there's * no other traffic). * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ -#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ -#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ +#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ +#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ -#define IWL_SCAN_CHECK_WATCHDOG (HZ * 7) +#define IL_SCAN_CHECK_WATCHDOG (HZ * 7) /***************************************************** * S e n d i n g H o s t C o m m a n d s * *****************************************************/ -const char *iwl_legacy_get_cmd_string(u8 cmd); -int __must_check iwl_legacy_send_cmd_sync(struct iwl_priv *priv, - struct iwl_host_cmd *cmd); -int iwl_legacy_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); -int __must_check iwl_legacy_send_cmd_pdu(struct iwl_priv *priv, u8 id, +const char *il_get_cmd_string(u8 cmd); +int __must_check il_send_cmd_sync(struct il_priv *priv, + struct il_host_cmd *cmd); +int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd); +int __must_check il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data); -int iwl_legacy_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len, +int il_send_cmd_pdu_async(struct il_priv *priv, u8 id, u16 len, const void *data, - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt)); + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt)); -int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); +int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd); /***************************************************** * PCI * *****************************************************/ -static inline u16 iwl_legacy_pcie_link_ctl(struct iwl_priv *priv) +static inline u16 il_pcie_link_ctl(struct il_priv *priv) { int pos; u16 pci_lnk_ctl; @@ -490,46 +490,46 @@ static inline u16 iwl_legacy_pcie_link_ctl(struct iwl_priv *priv) return pci_lnk_ctl; } -void iwl_legacy_bg_watchdog(unsigned long data); -u32 iwl_legacy_usecs_to_beacons(struct iwl_priv *priv, +void il_bg_watchdog(unsigned long data); +u32 il_usecs_to_beacons(struct il_priv *priv, u32 usec, u32 beacon_interval); -__le32 iwl_legacy_add_beacon_time(struct iwl_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *priv, u32 base, u32 addon, u32 beacon_interval); #ifdef CONFIG_PM -int iwl_legacy_pci_suspend(struct device *device); -int iwl_legacy_pci_resume(struct device *device); -extern const struct dev_pm_ops iwl_legacy_pm_ops; +int il_pci_suspend(struct device *device); +int il_pci_resume(struct device *device); +extern const struct dev_pm_ops il_pm_ops; -#define IWL_LEGACY_PM_OPS (&iwl_legacy_pm_ops) +#define IL_LEGACY_PM_OPS (&il_pm_ops) #else /* !CONFIG_PM */ -#define IWL_LEGACY_PM_OPS NULL +#define IL_LEGACY_PM_OPS NULL #endif /* !CONFIG_PM */ /***************************************************** * Error Handling Debugging ******************************************************/ -void iwl4965_dump_nic_error_log(struct iwl_priv *priv); +void il4965_dump_nic_error_log(struct il_priv *priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +void il_print_rx_config_cmd(struct il_priv *priv, + struct il_rxon_context *ctx); #else -static inline void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static inline void il_print_rx_config_cmd(struct il_priv *priv, + struct il_rxon_context *ctx) { } #endif -void iwl_legacy_clear_isr_stats(struct iwl_priv *priv); +void il_clear_isr_stats(struct il_priv *priv); /***************************************************** * GEOS ******************************************************/ -int iwl_legacy_init_geos(struct iwl_priv *priv); -void iwl_legacy_free_geos(struct iwl_priv *priv); +int il_init_geos(struct il_priv *priv); +void il_free_geos(struct il_priv *priv); /*************** DRIVER STATUS FUNCTIONS *****/ @@ -552,7 +552,7 @@ void iwl_legacy_free_geos(struct iwl_priv *priv); #define STATUS_FW_ERROR 17 #define STATUS_CHANNEL_SWITCH_PENDING 18 -static inline int iwl_legacy_is_ready(struct iwl_priv *priv) +static inline int il_is_ready(struct il_priv *priv) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ @@ -561,76 +561,76 @@ static inline int iwl_legacy_is_ready(struct iwl_priv *priv) !test_bit(STATUS_EXIT_PENDING, &priv->status); } -static inline int iwl_legacy_is_alive(struct iwl_priv *priv) +static inline int il_is_alive(struct il_priv *priv) { return test_bit(STATUS_ALIVE, &priv->status); } -static inline int iwl_legacy_is_init(struct iwl_priv *priv) +static inline int il_is_init(struct il_priv *priv) { return test_bit(STATUS_INIT, &priv->status); } -static inline int iwl_legacy_is_rfkill_hw(struct iwl_priv *priv) +static inline int il_is_rfkill_hw(struct il_priv *priv) { return test_bit(STATUS_RF_KILL_HW, &priv->status); } -static inline int iwl_legacy_is_rfkill(struct iwl_priv *priv) +static inline int il_is_rfkill(struct il_priv *priv) { - return iwl_legacy_is_rfkill_hw(priv); + return il_is_rfkill_hw(priv); } -static inline int iwl_legacy_is_ctkill(struct iwl_priv *priv) +static inline int il_is_ctkill(struct il_priv *priv) { return test_bit(STATUS_CT_KILL, &priv->status); } -static inline int iwl_legacy_is_ready_rf(struct iwl_priv *priv) +static inline int il_is_ready_rf(struct il_priv *priv) { - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) return 0; - return iwl_legacy_is_ready(priv); + return il_is_ready(priv); } -extern void iwl_legacy_send_bt_config(struct iwl_priv *priv); -extern int iwl_legacy_send_statistics_request(struct iwl_priv *priv, +extern void il_send_bt_config(struct il_priv *priv); +extern int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear); -void iwl_legacy_apm_stop(struct iwl_priv *priv); -int iwl_legacy_apm_init(struct iwl_priv *priv); +void il_apm_stop(struct il_priv *priv); +int il_apm_init(struct il_priv *priv); -int iwl_legacy_send_rxon_timing(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -static inline int iwl_legacy_send_rxon_assoc(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il_send_rxon_timing(struct il_priv *priv, + struct il_rxon_context *ctx); +static inline int il_send_rxon_assoc(struct il_priv *priv, + struct il_rxon_context *ctx) { return priv->cfg->ops->hcmd->rxon_assoc(priv, ctx); } -static inline int iwl_legacy_commit_rxon(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static inline int il_commit_rxon(struct il_priv *priv, + struct il_rxon_context *ctx) { return priv->cfg->ops->hcmd->commit_rxon(priv, ctx); } -static inline const struct ieee80211_supported_band *iwl_get_hw_mode( - struct iwl_priv *priv, enum ieee80211_band band) +static inline const struct ieee80211_supported_band *il_get_hw_mode( + struct il_priv *priv, enum ieee80211_band band) { return priv->hw->wiphy->bands[band]; } /* mac80211 handlers */ -int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed); -void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, +int il_mac_config(struct ieee80211_hw *hw, u32 changed); +void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif); -void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, +void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); -void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv, +void il_tx_cmd_protection(struct il_priv *priv, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags); -irqreturn_t iwl_legacy_isr(int irq, void *data); +irqreturn_t il_isr(int irq, void *data); -#endif /* __iwl_legacy_core_h__ */ +#endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index 668a961..24b71ae 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ -#ifndef __iwl_legacy_csr_h__ -#define __iwl_legacy_csr_h__ +#ifndef __il_csr_h__ +#define __il_csr_h__ /* * CSR (control and status registers) * @@ -70,9 +70,9 @@ * low power states due to driver-invoked device resets * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. * - * Use iwl_write32() and iwl_read32() family to access these registers; + * Use il_write32() and il_read32() family to access these registers; * these provide simple PCI bus access, without waking up the MAC. - * Do not use iwl_legacy_write_direct32() family for these registers; + * Do not use il_write_direct32() family for these registers; * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. * The MAC (uCode processor, etc.) does not need to be powered up for accessing * the CSR registers. @@ -91,7 +91,7 @@ #define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ #define CSR_GP_CNTRL (CSR_BASE+0x024) -/* 2nd byte of CSR_INT_COALESCING, not accessible via iwl_write32()! */ +/* 2nd byte of CSR_INT_COALESCING, not accessible via il_write32()! */ #define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) /* @@ -368,13 +368,13 @@ * to indirectly access device's internal memory or registers that * may be powered-down. * - * Use iwl_legacy_write_direct32()/iwl_legacy_read_direct32() family + * Use il_write_direct32()/il_read_direct32() family * for these registers; * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ * to make sure the MAC (uCode processor, etc.) is powered up for accessing * internal resources. * - * Do not use iwl_write32()/iwl_read32() family to access these registers; + * Do not use il_write32()/il_read32() family to access these registers; * these provide only simple PCI bus access, without waking up the MAC. */ #define HBUS_BASE (0x400) @@ -419,4 +419,4 @@ */ #define HBUS_TARG_WRPTR (HBUS_BASE+0x060) -#endif /* !__iwl_legacy_csr_h__ */ +#endif /* !__il_csr_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index ae13112..1bbad76 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -26,65 +26,65 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_debug_h__ -#define __iwl_legacy_debug_h__ +#ifndef __il_debug_h__ +#define __il_debug_h__ -struct iwl_priv; +struct il_priv; extern u32 iwlegacy_debug_level; -#define IWL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) -#define IWL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) -#define IWL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) -#define IWL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) +#define IL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) +#define IL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) +#define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) +#define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) -#define iwl_print_hex_error(priv, p, len) \ +#define il_print_hex_error(priv, p, len) \ do { \ print_hex_dump(KERN_ERR, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -#define IWL_DEBUG(__priv, level, fmt, args...) \ +#define IL_DEBUG(__priv, level, fmt, args...) \ do { \ - if (iwl_legacy_get_debug_level(__priv) & (level)) \ + if (il_get_debug_level(__priv) & (level)) \ dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ __func__ , ## args); \ } while (0) -#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...) \ +#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) \ do { \ - if ((iwl_legacy_get_debug_level(__priv) & (level)) && net_ratelimit()) \ + if ((il_get_debug_level(__priv) & (level)) && net_ratelimit()) \ dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ __func__ , ## args); \ } while (0) -#define iwl_print_hex_dump(priv, level, p, len) \ +#define il_print_hex_dump(priv, level, p, len) \ do { \ - if (iwl_legacy_get_debug_level(priv) & level) \ + if (il_get_debug_level(priv) & level) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) #else -#define IWL_DEBUG(__priv, level, fmt, args...) -#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...) -static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level, +#define IL_DEBUG(__priv, level, fmt, args...) +#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) +static inline void il_print_hex_dump(struct il_priv *priv, int level, const void *p, u32 len) {} #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name); -void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv); +int il_dbgfs_register(struct il_priv *priv, const char *name); +void il_dbgfs_unregister(struct il_priv *priv); #else static inline int -iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) +il_dbgfs_register(struct il_priv *priv, const char *name) { return 0; } -static inline void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) +static inline void il_dbgfs_unregister(struct il_priv *priv) { } #endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ @@ -95,12 +95,12 @@ static inline void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) * If you are defining a new debug classification, simply add it to the #define * list here in the form of * - * #define IWL_DL_xxxx VALUE + * #define IL_DL_xxxx VALUE * * where xxxx should be the name of the classification (for example, WEP). * - * You then need to either add a IWL_xxxx_DEBUG() macro definition for your - * classification, or use IWL_DEBUG(IWL_DL_xxxx, ...) whenever you want + * You then need to either add a IL_xxxx_DEBUG() macro definition for your + * classification, or use IL_DEBUG(IL_DL_xxxx, ...) whenever you want * to send output to that classification. * * The active debug levels can be accessed via files @@ -113,86 +113,86 @@ static inline void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) */ /* 0x0000000F - 0x00000001 */ -#define IWL_DL_INFO (1 << 0) -#define IWL_DL_MAC80211 (1 << 1) -#define IWL_DL_HCMD (1 << 2) -#define IWL_DL_STATE (1 << 3) +#define IL_DL_INFO (1 << 0) +#define IL_DL_MAC80211 (1 << 1) +#define IL_DL_HCMD (1 << 2) +#define IL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ -#define IWL_DL_MACDUMP (1 << 4) -#define IWL_DL_HCMD_DUMP (1 << 5) -#define IWL_DL_EEPROM (1 << 6) -#define IWL_DL_RADIO (1 << 7) +#define IL_DL_MACDUMP (1 << 4) +#define IL_DL_HCMD_DUMP (1 << 5) +#define IL_DL_EEPROM (1 << 6) +#define IL_DL_RADIO (1 << 7) /* 0x00000F00 - 0x00000100 */ -#define IWL_DL_POWER (1 << 8) -#define IWL_DL_TEMP (1 << 9) -#define IWL_DL_NOTIF (1 << 10) -#define IWL_DL_SCAN (1 << 11) +#define IL_DL_POWER (1 << 8) +#define IL_DL_TEMP (1 << 9) +#define IL_DL_NOTIF (1 << 10) +#define IL_DL_SCAN (1 << 11) /* 0x0000F000 - 0x00001000 */ -#define IWL_DL_ASSOC (1 << 12) -#define IWL_DL_DROP (1 << 13) -#define IWL_DL_TXPOWER (1 << 14) -#define IWL_DL_AP (1 << 15) +#define IL_DL_ASSOC (1 << 12) +#define IL_DL_DROP (1 << 13) +#define IL_DL_TXPOWER (1 << 14) +#define IL_DL_AP (1 << 15) /* 0x000F0000 - 0x00010000 */ -#define IWL_DL_FW (1 << 16) -#define IWL_DL_RF_KILL (1 << 17) -#define IWL_DL_FW_ERRORS (1 << 18) -#define IWL_DL_LED (1 << 19) +#define IL_DL_FW (1 << 16) +#define IL_DL_RF_KILL (1 << 17) +#define IL_DL_FW_ERRORS (1 << 18) +#define IL_DL_LED (1 << 19) /* 0x00F00000 - 0x00100000 */ -#define IWL_DL_RATE (1 << 20) -#define IWL_DL_CALIB (1 << 21) -#define IWL_DL_WEP (1 << 22) -#define IWL_DL_TX (1 << 23) +#define IL_DL_RATE (1 << 20) +#define IL_DL_CALIB (1 << 21) +#define IL_DL_WEP (1 << 22) +#define IL_DL_TX (1 << 23) /* 0x0F000000 - 0x01000000 */ -#define IWL_DL_RX (1 << 24) -#define IWL_DL_ISR (1 << 25) -#define IWL_DL_HT (1 << 26) -#define IWL_DL_IO (1 << 27) +#define IL_DL_RX (1 << 24) +#define IL_DL_ISR (1 << 25) +#define IL_DL_HT (1 << 26) +#define IL_DL_IO (1 << 27) /* 0xF0000000 - 0x10000000 */ -#define IWL_DL_11H (1 << 28) -#define IWL_DL_STATS (1 << 29) -#define IWL_DL_TX_REPLY (1 << 30) -#define IWL_DL_QOS (1 << 31) +#define IL_DL_11H (1 << 28) +#define IL_DL_STATS (1 << 29) +#define IL_DL_TX_REPLY (1 << 30) +#define IL_DL_QOS (1 << 31) -#define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) -#define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) -#define IWL_DEBUG_MACDUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_MACDUMP, f, ## a) -#define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a) -#define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a) -#define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a) -#define IWL_DEBUG_TX(p, f, a...) IWL_DEBUG(p, IWL_DL_TX, f, ## a) -#define IWL_DEBUG_ISR(p, f, a...) IWL_DEBUG(p, IWL_DL_ISR, f, ## a) -#define IWL_DEBUG_LED(p, f, a...) IWL_DEBUG(p, IWL_DL_LED, f, ## a) -#define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a) -#define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a) -#define IWL_DEBUG_HC_DUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD_DUMP, f, ## a) -#define IWL_DEBUG_EEPROM(p, f, a...) IWL_DEBUG(p, IWL_DL_EEPROM, f, ## a) -#define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a) -#define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a) -#define IWL_DEBUG_RF_KILL(p, f, a...) IWL_DEBUG(p, IWL_DL_RF_KILL, f, ## a) -#define IWL_DEBUG_DROP(p, f, a...) IWL_DEBUG(p, IWL_DL_DROP, f, ## a) -#define IWL_DEBUG_DROP_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_DROP, f, ## a) -#define IWL_DEBUG_AP(p, f, a...) IWL_DEBUG(p, IWL_DL_AP, f, ## a) -#define IWL_DEBUG_TXPOWER(p, f, a...) IWL_DEBUG(p, IWL_DL_TXPOWER, f, ## a) -#define IWL_DEBUG_IO(p, f, a...) IWL_DEBUG(p, IWL_DL_IO, f, ## a) -#define IWL_DEBUG_RATE(p, f, a...) IWL_DEBUG(p, IWL_DL_RATE, f, ## a) -#define IWL_DEBUG_RATE_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_RATE, f, ## a) -#define IWL_DEBUG_NOTIF(p, f, a...) IWL_DEBUG(p, IWL_DL_NOTIF, f, ## a) -#define IWL_DEBUG_ASSOC(p, f, a...) \ - IWL_DEBUG(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) -#define IWL_DEBUG_ASSOC_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) -#define IWL_DEBUG_HT(p, f, a...) IWL_DEBUG(p, IWL_DL_HT, f, ## a) -#define IWL_DEBUG_STATS(p, f, a...) IWL_DEBUG(p, IWL_DL_STATS, f, ## a) -#define IWL_DEBUG_STATS_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_STATS, f, ## a) -#define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_QOS(p, f, a...) IWL_DEBUG(p, IWL_DL_QOS, f, ## a) -#define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) -#define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) -#define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a) +#define IL_DEBUG_INFO(p, f, a...) IL_DEBUG(p, IL_DL_INFO, f, ## a) +#define IL_DEBUG_MAC80211(p, f, a...) IL_DEBUG(p, IL_DL_MAC80211, f, ## a) +#define IL_DEBUG_MACDUMP(p, f, a...) IL_DEBUG(p, IL_DL_MACDUMP, f, ## a) +#define IL_DEBUG_TEMP(p, f, a...) IL_DEBUG(p, IL_DL_TEMP, f, ## a) +#define IL_DEBUG_SCAN(p, f, a...) IL_DEBUG(p, IL_DL_SCAN, f, ## a) +#define IL_DEBUG_RX(p, f, a...) IL_DEBUG(p, IL_DL_RX, f, ## a) +#define IL_DEBUG_TX(p, f, a...) IL_DEBUG(p, IL_DL_TX, f, ## a) +#define IL_DEBUG_ISR(p, f, a...) IL_DEBUG(p, IL_DL_ISR, f, ## a) +#define IL_DEBUG_LED(p, f, a...) IL_DEBUG(p, IL_DL_LED, f, ## a) +#define IL_DEBUG_WEP(p, f, a...) IL_DEBUG(p, IL_DL_WEP, f, ## a) +#define IL_DEBUG_HC(p, f, a...) IL_DEBUG(p, IL_DL_HCMD, f, ## a) +#define IL_DEBUG_HC_DUMP(p, f, a...) IL_DEBUG(p, IL_DL_HCMD_DUMP, f, ## a) +#define IL_DEBUG_EEPROM(p, f, a...) IL_DEBUG(p, IL_DL_EEPROM, f, ## a) +#define IL_DEBUG_CALIB(p, f, a...) IL_DEBUG(p, IL_DL_CALIB, f, ## a) +#define IL_DEBUG_FW(p, f, a...) IL_DEBUG(p, IL_DL_FW, f, ## a) +#define IL_DEBUG_RF_KILL(p, f, a...) IL_DEBUG(p, IL_DL_RF_KILL, f, ## a) +#define IL_DEBUG_DROP(p, f, a...) IL_DEBUG(p, IL_DL_DROP, f, ## a) +#define IL_DEBUG_DROP_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_DROP, f, ## a) +#define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) +#define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) +#define IL_DEBUG_IO(p, f, a...) IL_DEBUG(p, IL_DL_IO, f, ## a) +#define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) +#define IL_DEBUG_RATE_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_RATE, f, ## a) +#define IL_DEBUG_NOTIF(p, f, a...) IL_DEBUG(p, IL_DL_NOTIF, f, ## a) +#define IL_DEBUG_ASSOC(p, f, a...) \ + IL_DEBUG(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) +#define IL_DEBUG_ASSOC_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) +#define IL_DEBUG_HT(p, f, a...) IL_DEBUG(p, IL_DL_HT, f, ## a) +#define IL_DEBUG_STATS(p, f, a...) IL_DEBUG(p, IL_DL_STATS, f, ## a) +#define IL_DEBUG_STATS_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_STATS, f, ## a) +#define IL_DEBUG_TX_REPLY(p, f, a...) IL_DEBUG(p, IL_DL_TX_REPLY, f, ## a) +#define IL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_TX_REPLY, f, ## a) +#define IL_DEBUG_QOS(p, f, a...) IL_DEBUG(p, IL_DL_QOS, f, ## a) +#define IL_DEBUG_RADIO(p, f, a...) IL_DEBUG(p, IL_DL_RADIO, f, ## a) +#define IL_DEBUG_POWER(p, f, a...) IL_DEBUG(p, IL_DL_POWER, f, ## a) +#define IL_DEBUG_11H(p, f, a...) IL_DEBUG(p, IL_DL_11H, f, ## a) #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 996996a..057dec5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -37,7 +37,7 @@ /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ if (!debugfs_create_file(#name, mode, parent, priv, \ - &iwl_legacy_dbgfs_##name##_ops)) \ + &il_dbgfs_##name##_ops)) \ goto err; \ } while (0) @@ -59,18 +59,18 @@ /* file operation */ #define DEBUGFS_READ_FUNC(name) \ -static ssize_t iwl_legacy_dbgfs_##name##_read(struct file *file, \ +static ssize_t il_dbgfs_##name##_read(struct file *file, \ char __user *user_buf, \ size_t count, loff_t *ppos); #define DEBUGFS_WRITE_FUNC(name) \ -static ssize_t iwl_legacy_dbgfs_##name##_write(struct file *file, \ +static ssize_t il_dbgfs_##name##_write(struct file *file, \ const char __user *user_buf, \ size_t count, loff_t *ppos); static int -iwl_legacy_dbgfs_open_file_generic(struct inode *inode, struct file *file) +il_dbgfs_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; @@ -78,35 +78,35 @@ iwl_legacy_dbgfs_open_file_generic(struct inode *inode, struct file *file) #define DEBUGFS_READ_FILE_OPS(name) \ DEBUGFS_READ_FUNC(name); \ -static const struct file_operations iwl_legacy_dbgfs_##name##_ops = { \ - .read = iwl_legacy_dbgfs_##name##_read, \ - .open = iwl_legacy_dbgfs_open_file_generic, \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ .llseek = generic_file_llseek, \ }; #define DEBUGFS_WRITE_FILE_OPS(name) \ DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations iwl_legacy_dbgfs_##name##_ops = { \ - .write = iwl_legacy_dbgfs_##name##_write, \ - .open = iwl_legacy_dbgfs_open_file_generic, \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .open = il_dbgfs_open_file_generic, \ .llseek = generic_file_llseek, \ }; #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ DEBUGFS_READ_FUNC(name); \ DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations iwl_legacy_dbgfs_##name##_ops = { \ - .write = iwl_legacy_dbgfs_##name##_write, \ - .read = iwl_legacy_dbgfs_##name##_read, \ - .open = iwl_legacy_dbgfs_open_file_generic, \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ .llseek = generic_file_llseek, \ }; -static ssize_t iwl_legacy_dbgfs_tx_statistics_read(struct file *file, +static ssize_t il_dbgfs_tx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char *buf; int pos = 0; @@ -121,14 +121,14 @@ static ssize_t iwl_legacy_dbgfs_tx_statistics_read(struct file *file, for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_mgmt_string(cnt), + il_get_mgmt_string(cnt), priv->tx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_ctrl_string(cnt), + il_get_ctrl_string(cnt), priv->tx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); @@ -142,11 +142,11 @@ static ssize_t iwl_legacy_dbgfs_tx_statistics_read(struct file *file, } static ssize_t -iwl_legacy_dbgfs_clear_traffic_statistics_write(struct file *file, +il_dbgfs_clear_traffic_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; u32 clear_flag; char buf[8]; int buf_size; @@ -157,16 +157,16 @@ iwl_legacy_dbgfs_clear_traffic_statistics_write(struct file *file, return -EFAULT; if (sscanf(buf, "%x", &clear_flag) != 1) return -EFAULT; - iwl_legacy_clear_traffic_stats(priv); + il_clear_traffic_stats(priv); return count; } -static ssize_t iwl_legacy_dbgfs_rx_statistics_read(struct file *file, +static ssize_t il_dbgfs_rx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char *buf; int pos = 0; int cnt; @@ -181,14 +181,14 @@ static ssize_t iwl_legacy_dbgfs_rx_statistics_read(struct file *file, for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_mgmt_string(cnt), + il_get_mgmt_string(cnt), priv->rx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_ctrl_string(cnt), + il_get_ctrl_string(cnt), priv->rx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); @@ -205,7 +205,7 @@ static ssize_t iwl_legacy_dbgfs_rx_statistics_read(struct file *file, #define BYTE1_MASK 0x000000ff; #define BYTE2_MASK 0x0000ffff; #define BYTE3_MASK 0x00ffffff; -static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, +static ssize_t il_dbgfs_sram_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -214,7 +214,7 @@ static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, ssize_t ret; int i; int pos = 0; - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; size_t bufsz; /* default is to dump the entire data segment */ @@ -234,7 +234,7 @@ static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", priv->dbgfs_sram_offset); for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { - val = iwl_legacy_read_targ_mem(priv, priv->dbgfs_sram_offset + \ + val = il_read_targ_mem(priv, priv->dbgfs_sram_offset + \ priv->dbgfs_sram_len - i); if (i < 4) { switch (i) { @@ -260,11 +260,11 @@ static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_sram_write(struct file *file, +static ssize_t il_dbgfs_sram_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[64]; int buf_size; u32 offset, len; @@ -286,11 +286,11 @@ static ssize_t iwl_legacy_dbgfs_sram_write(struct file *file, } static ssize_t -iwl_legacy_dbgfs_stations_read(struct file *file, char __user *user_buf, +il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_station_entry *station; + struct il_priv *priv = file->private_data; + struct il_station_entry *station; int max_sta = priv->hw_params.max_stations; char *buf; int i, j, pos = 0; @@ -343,13 +343,13 @@ iwl_legacy_dbgfs_stations_read(struct file *file, char __user *user_buf, return ret; } -static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file, +static ssize_t il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { ssize_t ret; - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0, ofs = 0, buf_size = 0; const u8 *ptr; char *buf; @@ -358,23 +358,23 @@ static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file, buf_size = 4 * eeprom_len + 256; if (eeprom_len % 16) { - IWL_ERR(priv, "NVM size is not multiple of 16.\n"); + IL_ERR(priv, "NVM size is not multiple of 16.\n"); return -ENODATA; } ptr = priv->eeprom; if (!ptr) { - IWL_ERR(priv, "Invalid EEPROM memory\n"); + IL_ERR(priv, "Invalid EEPROM memory\n"); return -ENOMEM; } /* 4 characters for byte 0xYY */ buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } - eeprom_ver = iwl_legacy_eeprom_query16(priv, EEPROM_VERSION); + eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n", eeprom_ver); for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { @@ -392,10 +392,10 @@ static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file, } static ssize_t -iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, +il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; struct ieee80211_channel *channels = NULL; const struct ieee80211_supported_band *supp_band = NULL; int pos = 0, i, bufsz = PAGE_SIZE; @@ -407,11 +407,11 @@ iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } - supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); + supp_band = il_get_hw_mode(priv, IEEE80211_BAND_2GHZ); if (supp_band) { channels = supp_band->channels; @@ -434,7 +434,7 @@ iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, IEEE80211_CHAN_PASSIVE_SCAN ? "passive only" : "active/passive"); } - supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); + supp_band = il_get_hw_mode(priv, IEEE80211_BAND_5GHZ); if (supp_band) { channels = supp_band->channels; @@ -462,11 +462,11 @@ iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, return ret; } -static ssize_t iwl_legacy_dbgfs_status_read(struct file *file, +static ssize_t il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[512]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -506,11 +506,11 @@ static ssize_t iwl_legacy_dbgfs_status_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, +static ssize_t il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -519,7 +519,7 @@ static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -558,7 +558,7 @@ static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, if (priv->isr_stats.rx_handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", - iwl_legacy_get_cmd_string(cnt), + il_get_cmd_string(cnt), priv->isr_stats.rx_handlers[cnt]); } @@ -573,11 +573,11 @@ static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_interrupt_write(struct file *file, +static ssize_t il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; u32 reset_flag; @@ -589,19 +589,19 @@ static ssize_t iwl_legacy_dbgfs_interrupt_write(struct file *file, if (sscanf(buf, "%x", &reset_flag) != 1) return -EFAULT; if (reset_flag == 0) - iwl_legacy_clear_isr_stats(priv); + il_clear_isr_stats(priv); return count; } static ssize_t -iwl_legacy_dbgfs_qos_read(struct file *file, char __user *user_buf, +il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_rxon_context *ctx; + struct il_priv *priv = file->private_data; + struct il_rxon_context *ctx; int pos = 0, i; - char buf[256 * NUM_IWL_RXON_CTX]; + char buf[256 * NUM_IL_RXON_CTX]; const size_t bufsz = sizeof(buf); for_each_context(priv, ctx) { @@ -622,11 +622,11 @@ iwl_legacy_dbgfs_qos_read(struct file *file, char __user *user_buf, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_disable_ht40_write(struct file *file, +static ssize_t il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int ht40; @@ -637,10 +637,10 @@ static ssize_t iwl_legacy_dbgfs_disable_ht40_write(struct file *file, return -EFAULT; if (sscanf(buf, "%d", &ht40) != 1) return -EFAULT; - if (!iwl_legacy_is_any_associated(priv)) + if (!il_is_any_associated(priv)) priv->disable_ht40 = ht40 ? true : false; else { - IWL_ERR(priv, "Sta associated with AP - " + IL_ERR(priv, "Sta associated with AP - " "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } @@ -648,11 +648,11 @@ static ssize_t iwl_legacy_dbgfs_disable_ht40_write(struct file *file, return count; } -static ssize_t iwl_legacy_dbgfs_disable_ht40_read(struct file *file, +static ssize_t il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[100]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -672,29 +672,29 @@ DEBUGFS_READ_WRITE_FILE_OPS(interrupt); DEBUGFS_READ_FILE_OPS(qos); DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); -static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, +static ssize_t il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0, ofs = 0; int cnt = 0, entry; - struct iwl_tx_queue *txq; - struct iwl_queue *q; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_rx_queue *rxq = &priv->rxq; char *buf; - int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + + int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + (priv->cfg->base_params->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; if (!priv->txq) { - IWL_ERR(priv, "txq not ready\n"); + IL_ERR(priv, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate buffer\n"); + IL_ERR(priv, "Can not allocate buffer\n"); return -ENOMEM; } pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); @@ -705,12 +705,12 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, q->read_ptr, q->write_ptr); } - if (priv->tx_traffic && (iwlegacy_debug_level & IWL_DL_TX)) { + if (priv->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { ptr = priv->tx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", priv->tx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { pos += scnprintf(buf + pos, bufsz - pos, "0x%.4x ", ofs); @@ -728,12 +728,12 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, "read: %u, write: %u\n", rxq->read, rxq->write); - if (priv->rx_traffic && (iwlegacy_debug_level & IWL_DL_RX)) { + if (priv->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { ptr = priv->rx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", priv->rx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { pos += scnprintf(buf + pos, bufsz - pos, "0x%.4x ", ofs); @@ -751,11 +751,11 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_traffic_log_write(struct file *file, +static ssize_t il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int traffic_log; @@ -767,18 +767,18 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_write(struct file *file, if (sscanf(buf, "%d", &traffic_log) != 1) return -EFAULT; if (traffic_log == 0) - iwl_legacy_reset_traffic_log(priv); + il_reset_traffic_log(priv); return count; } -static ssize_t iwl_legacy_dbgfs_tx_queue_read(struct file *file, +static ssize_t il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_tx_queue *txq; - struct iwl_queue *q; + struct il_priv *priv = file->private_data; + struct il_tx_queue *txq; + struct il_queue *q; char *buf; int pos = 0; int cnt; @@ -787,7 +787,7 @@ static ssize_t iwl_legacy_dbgfs_tx_queue_read(struct file *file, priv->cfg->base_params->num_of_queues; if (!priv->txq) { - IWL_ERR(priv, "txq not ready\n"); + IL_ERR(priv, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); @@ -816,12 +816,12 @@ static ssize_t iwl_legacy_dbgfs_tx_queue_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_rx_queue_read(struct file *file, +static ssize_t il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_priv *priv = file->private_data; + struct il_rx_queue *rxq = &priv->rxq; char buf[256]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -842,49 +842,49 @@ static ssize_t iwl_legacy_dbgfs_rx_queue_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_ucode_rx_stats_read(struct file *file, +static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, count, ppos); } -static ssize_t iwl_legacy_dbgfs_ucode_tx_stats_read(struct file *file, +static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, count, ppos); } -static ssize_t iwl_legacy_dbgfs_ucode_general_stats_read(struct file *file, +static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, count, ppos); } -static ssize_t iwl_legacy_dbgfs_sensitivity_read(struct file *file, +static ssize_t il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; int cnt = 0; char *buf; - int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; + int bufsz = sizeof(struct il_sensitivity_data) * 4 + 100; ssize_t ret; - struct iwl_sensitivity_data *data; + struct il_sensitivity_data *data; data = &priv->sensitivity_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -950,22 +950,22 @@ static ssize_t iwl_legacy_dbgfs_sensitivity_read(struct file *file, } -static ssize_t iwl_legacy_dbgfs_chain_noise_read(struct file *file, +static ssize_t il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; int cnt = 0; char *buf; - int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; + int bufsz = sizeof(struct il_chain_noise_data) * 4 + 100; ssize_t ret; - struct iwl_chain_noise_data *data; + struct il_chain_noise_data *data; data = &priv->chain_noise_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -1008,17 +1008,17 @@ static ssize_t iwl_legacy_dbgfs_chain_noise_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_power_save_status_read(struct file *file, +static ssize_t il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[60]; int pos = 0; const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) & + pwrsave_status = il_read32(priv, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); @@ -1031,11 +1031,11 @@ static ssize_t iwl_legacy_dbgfs_power_save_status_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_clear_ucode_statistics_write(struct file *file, +static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int clear; @@ -1049,43 +1049,43 @@ static ssize_t iwl_legacy_dbgfs_clear_ucode_statistics_write(struct file *file, /* make request to uCode to retrieve statistics information */ mutex_lock(&priv->mutex); - iwl_legacy_send_statistics_request(priv, CMD_SYNC, true); + il_send_statistics_request(priv, CMD_SYNC, true); mutex_unlock(&priv->mutex); return count; } -static ssize_t iwl_legacy_dbgfs_rxon_flags_read(struct file *file, +static ssize_t il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); + le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t iwl_legacy_dbgfs_rxon_filter_flags_read(struct file *file, +static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); + le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t iwl_legacy_dbgfs_fh_reg_read(struct file *file, +static ssize_t il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char *buf; int pos = 0; ssize_t ret = -EFAULT; @@ -1102,11 +1102,11 @@ static ssize_t iwl_legacy_dbgfs_fh_reg_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_missed_beacon_read(struct file *file, +static ssize_t il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char buf[12]; const size_t bufsz = sizeof(buf); @@ -1117,11 +1117,11 @@ static ssize_t iwl_legacy_dbgfs_missed_beacon_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_missed_beacon_write(struct file *file, +static ssize_t il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int missed; @@ -1133,25 +1133,25 @@ static ssize_t iwl_legacy_dbgfs_missed_beacon_write(struct file *file, if (sscanf(buf, "%d", &missed) != 1) return -EINVAL; - if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || - missed > IWL_MISSED_BEACON_THRESHOLD_MAX) + if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || + missed > IL_MISSED_BEACON_THRESHOLD_MAX) priv->missed_beacon_threshold = - IWL_MISSED_BEACON_THRESHOLD_DEF; + IL_MISSED_BEACON_THRESHOLD_DEF; else priv->missed_beacon_threshold = missed; return count; } -static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file, +static ssize_t il_dbgfs_force_reset_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char buf[300]; const size_t bufsz = sizeof(buf); - struct iwl_force_reset *force_reset; + struct il_force_reset *force_reset; force_reset = &priv->force_reset; @@ -1171,23 +1171,23 @@ static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_force_reset_write(struct file *file, +static ssize_t il_dbgfs_force_reset_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { int ret; - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; - ret = iwl_legacy_force_reset(priv, true); + ret = il_force_reset(priv, true); return ret ? ret : count; } -static ssize_t iwl_legacy_dbgfs_wd_timeout_write(struct file *file, +static ssize_t il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int timeout; @@ -1198,11 +1198,11 @@ static ssize_t iwl_legacy_dbgfs_wd_timeout_write(struct file *file, return -EFAULT; if (sscanf(buf, "%d", &timeout) != 1) return -EINVAL; - if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT) - timeout = IWL_DEF_WD_TIMEOUT; + if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) + timeout = IL_DEF_WD_TIMEOUT; priv->cfg->base_params->wd_timeout = timeout; - iwl_legacy_setup_watchdog(priv); + il_setup_watchdog(priv); return count; } @@ -1230,7 +1230,7 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout); * Create the debugfs files and directories * */ -int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) +int il_dbgfs_register(struct il_priv *priv, const char *name) { struct dentry *phyd = priv->hw->wiphy->debugfsdir; struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; @@ -1292,17 +1292,17 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) return 0; err: - IWL_ERR(priv, "Can't create the debugfs directory\n"); - iwl_legacy_dbgfs_unregister(priv); + IL_ERR(priv, "Can't create the debugfs directory\n"); + il_dbgfs_unregister(priv); return -ENOMEM; } -EXPORT_SYMBOL(iwl_legacy_dbgfs_register); +EXPORT_SYMBOL(il_dbgfs_register); /** * Remove the debugfs files and directories * */ -void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) +void il_dbgfs_unregister(struct il_priv *priv) { if (!priv->debugfs_dir) return; @@ -1310,4 +1310,4 @@ void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) debugfs_remove_recursive(priv->debugfs_dir); priv->debugfs_dir = NULL; } -EXPORT_SYMBOL(iwl_legacy_dbgfs_unregister); +EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 9c786ed..20c44f3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -29,8 +29,8 @@ * Please use iwl-4965-hw.h for hardware-related definitions. */ -#ifndef __iwl_legacy_dev_h__ -#define __iwl_legacy_dev_h__ +#ifndef __il_dev_h__ +#define __il_dev_h__ #include #include /* for struct pci_device_id */ @@ -50,7 +50,7 @@ #include "iwl-power.h" #include "iwl-legacy-rs.h" -struct iwl_tx_queue; +struct il_tx_queue; /* CT-KILL constants */ #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ @@ -66,7 +66,7 @@ struct iwl_tx_queue; * noise info (e.g. averaging might be done in app); measured dBm values are * always negative ... using a negative value as the default keeps all * averages within an s8's (used in some apps) range of negative values. */ -#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127) +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) /* * RTS threshold here is total size [2347] minus 4 FCS bytes @@ -85,7 +85,7 @@ struct iwl_tx_queue; #define DEFAULT_SHORT_RETRY_LIMIT 7U #define DEFAULT_LONG_RETRY_LIMIT 4U -struct iwl_rx_mem_buffer { +struct il_rx_mem_buffer { dma_addr_t page_dma; struct page *page; struct list_head list; @@ -94,11 +94,11 @@ struct iwl_rx_mem_buffer { #define rxb_addr(r) page_address(r->page) /* defined below */ -struct iwl_device_cmd; +struct il_device_cmd; -struct iwl_cmd_meta { +struct il_cmd_meta { /* only for SYNC commands, iff the reply skb is wanted */ - struct iwl_host_cmd *source; + struct il_host_cmd *source; /* * only for ASYNC commands * (which is somewhat stupid -- look at iwl-sta.c for instance @@ -106,9 +106,9 @@ struct iwl_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt); + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ @@ -123,7 +123,7 @@ struct iwl_cmd_meta { * * Contains common data for Rx and Tx queues */ -struct iwl_queue { +struct il_queue { int n_bd; /* number of BDs in this queue */ int write_ptr; /* 1-st empty entry (index) host_w*/ int read_ptr; /* last used entry (index) host_r*/ @@ -138,13 +138,13 @@ struct iwl_queue { }; /* One for each TFD */ -struct iwl_tx_info { +struct il_tx_info { struct sk_buff *skb; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; }; /** - * struct iwl_tx_queue - Tx Queue for DMA + * struct il_tx_queue - Tx Queue for DMA * @q: generic Rx/Tx queue descriptor * @bd: base of circular buffer of TFDs * @cmd: array of command/TX buffer pointers @@ -161,12 +161,12 @@ struct iwl_tx_info { #define TFD_TX_CMD_SLOTS 256 #define TFD_CMD_SLOTS 32 -struct iwl_tx_queue { - struct iwl_queue q; +struct il_tx_queue { + struct il_queue q; void *tfds; - struct iwl_device_cmd **cmd; - struct iwl_cmd_meta *meta; - struct iwl_tx_info *txb; + struct il_device_cmd **cmd; + struct il_cmd_meta *meta; + struct il_tx_info *txb; unsigned long time_stamp; u8 need_update; u8 sched_retry; @@ -174,23 +174,23 @@ struct iwl_tx_queue { u8 swq_id; }; -#define IWL_NUM_SCAN_RATES (2) +#define IL_NUM_SCAN_RATES (2) -struct iwl4965_channel_tgd_info { +struct il4965_channel_tgd_info { u8 type; s8 max_power; }; -struct iwl4965_channel_tgh_info { +struct il4965_channel_tgh_info { s64 last_radar_time; }; #define IWL4965_MAX_RATE (33) -struct iwl3945_clip_group { +struct il3945_clip_group { /* maximum power level to prevent clipping for each rate, derived by * us from this band's saturation power in EEPROM */ - const s8 clip_powers[IWL_MAX_RATES]; + const s8 clip_powers[IL_MAX_RATES]; }; /* current Tx power values to use, one for each rate for each channel. @@ -200,8 +200,8 @@ struct iwl3945_clip_group { * -- spectrum management * -- user preference (e.g. iwconfig) * when requested power is set, base power index must also be set. */ -struct iwl3945_channel_power_info { - struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */ +struct il3945_channel_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ s8 power_table_index; /* actual (compenst'd) index into gain table */ s8 base_power_index; /* gain index for power at factory temp. */ s8 requested_power; /* power (dBm) requested for this chnl/rate */ @@ -209,8 +209,8 @@ struct iwl3945_channel_power_info { /* current scan Tx power values to use, one for each scan rate for each * channel. */ -struct iwl3945_scan_power_info { - struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */ +struct il3945_scan_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ s8 power_table_index; /* actual (compenst'd) index into gain table */ s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ }; @@ -220,11 +220,11 @@ struct iwl3945_scan_power_info { * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant * with one another! */ -struct iwl_channel_info { - struct iwl4965_channel_tgd_info tgd; - struct iwl4965_channel_tgh_info tgh; - struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */ - struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for +struct il_channel_info { + struct il4965_channel_tgd_info tgd; + struct il4965_channel_tgh_info tgh; + struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */ + struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for * HT40 channel */ u8 channel; /* channel number */ @@ -246,34 +246,34 @@ struct iwl_channel_info { /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for * remembering/modifying gain settings (indexes). */ - struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE]; + struct il3945_channel_power_info power_info[IWL4965_MAX_RATE]; /* Radio/DSP gain settings for each scan rate, for directed scans. */ - struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES]; + struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; }; -#define IWL_TX_FIFO_BK 0 /* shared */ -#define IWL_TX_FIFO_BE 1 -#define IWL_TX_FIFO_VI 2 /* shared */ -#define IWL_TX_FIFO_VO 3 -#define IWL_TX_FIFO_UNUSED -1 +#define IL_TX_FIFO_BK 0 /* shared */ +#define IL_TX_FIFO_BE 1 +#define IL_TX_FIFO_VI 2 /* shared */ +#define IL_TX_FIFO_VO 3 +#define IL_TX_FIFO_UNUSED -1 /* Minimum number of queues. MAX_NUM is defined in hw specific files. * Set the minimum to accommodate the 4 standard TX queues, 1 command * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */ -#define IWL_MIN_NUM_QUEUES 10 +#define IL_MIN_NUM_QUEUES 10 -#define IWL_DEFAULT_CMD_QUEUE_NUM 4 +#define IL_DEFAULT_CMD_QUEUE_NUM 4 #define IEEE80211_DATA_LEN 2304 #define IEEE80211_4ADDR_LEN 30 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) -struct iwl_frame { +struct il_frame { union { struct ieee80211_hdr frame; - struct iwl_tx_beacon_cmd beacon; + struct il_tx_beacon_cmd beacon; u8 raw[IEEE80211_FRAME_LEN]; u8 cmd[360]; } u; @@ -297,33 +297,33 @@ enum { #define DEF_CMD_PAYLOAD_SIZE 320 /** - * struct iwl_device_cmd + * struct il_device_cmd * * For allocation of the command and tx queues, this establishes the overall * size of the largest command we send to uCode, except for a scan command * (which is relatively huge; space is allocated separately). */ -struct iwl_device_cmd { - struct iwl_cmd_header hdr; /* uCode API */ +struct il_device_cmd { + struct il_cmd_header hdr; /* uCode API */ union { u32 flags; u8 val8; u16 val16; u32 val32; - struct iwl_tx_cmd tx; + struct il_tx_cmd tx; u8 payload[DEF_CMD_PAYLOAD_SIZE]; } __packed cmd; } __packed; -#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd)) +#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) -struct iwl_host_cmd { +struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt); + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt); u32 flags; u16 len; u8 id; @@ -334,7 +334,7 @@ struct iwl_host_cmd { #define SUP_RATE_11G_MAX_NUM_CHANNELS 12 /** - * struct iwl_rx_queue - Rx queue + * struct il_rx_queue - Rx queue * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) * @read: Shared index to newest available Rx buffer @@ -346,13 +346,13 @@ struct iwl_host_cmd { * @rb_stts: driver's pointer to receive buffer status * @rb_stts_dma: bus address of receive buffer status * - * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers + * NOTE: rx_free and rx_used are used as a FIFO for il_rx_mem_buffers */ -struct iwl_rx_queue { +struct il_rx_queue { __le32 *bd; dma_addr_t bd_dma; - struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; - struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE]; + struct il_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; + struct il_rx_mem_buffer *queue[RX_QUEUE_SIZE]; u32 read; u32 write; u32 free_count; @@ -360,20 +360,20 @@ struct iwl_rx_queue { struct list_head rx_free; struct list_head rx_used; int need_update; - struct iwl_rb_status *rb_stts; + struct il_rb_status *rb_stts; dma_addr_t rb_stts_dma; spinlock_t lock; }; -#define IWL_SUPPORTED_RATES_IE_LEN 8 +#define IL_SUPPORTED_RATES_IE_LEN 8 #define MAX_TID_COUNT 9 -#define IWL_INVALID_RATE 0xFF -#define IWL_INVALID_VALUE -1 +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 /** - * struct iwl_ht_agg -- aggregation status while waiting for block-ack + * struct il_ht_agg -- aggregation status while waiting for block-ack * @txq_id: Tx queue used for Tx attempt * @frame_count: # frames attempted by Tx command * @wait_for_ba: Expect block-ack before next Tx reply @@ -386,35 +386,35 @@ struct iwl_rx_queue { * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info * until block ack arrives. */ -struct iwl_ht_agg { +struct il_ht_agg { u16 txq_id; u16 frame_count; u16 wait_for_ba; u16 start_idx; u64 bitmap; u32 rate_n_flags; -#define IWL_AGG_OFF 0 -#define IWL_AGG_ON 1 -#define IWL_EMPTYING_HW_QUEUE_ADDBA 2 -#define IWL_EMPTYING_HW_QUEUE_DELBA 3 +#define IL_AGG_OFF 0 +#define IL_AGG_ON 1 +#define IL_EMPTYING_HW_QUEUE_ADDBA 2 +#define IL_EMPTYING_HW_QUEUE_DELBA 3 u8 state; }; -struct iwl_tid_data { +struct il_tid_data { u16 seq_number; /* 4965 only */ u16 tfds_in_queue; - struct iwl_ht_agg agg; + struct il_ht_agg agg; }; -struct iwl_hw_key { +struct il_hw_key { u32 cipher; int keylen; u8 keyidx; u8 key[32]; }; -union iwl_ht_rate_supp { +union il_ht_rate_supp { u16 rates; struct { u8 siso_rate; @@ -445,38 +445,38 @@ union iwl_ht_rate_supp { #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC #define CFG_HT_MPDU_DENSITY_MIN (0x1) -struct iwl_ht_config { +struct il_ht_config { bool single_chain_sufficient; enum ieee80211_smps_mode smps; /* current smps mode */ }; /* QoS structures */ -struct iwl_qos_info { +struct il_qos_info { int qos_active; - struct iwl_qosparam_cmd def_qos_parm; + struct il_qosparam_cmd def_qos_parm; }; /* * Structure should be accessed with sta_lock held. When station addition - * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only - * the commands (iwl_legacy_addsta_cmd and iwl_link_quality_cmd) without + * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only + * the commands (il_addsta_cmd and il_link_quality_cmd) without * sta_lock held. */ -struct iwl_station_entry { - struct iwl_legacy_addsta_cmd sta; - struct iwl_tid_data tid[MAX_TID_COUNT]; +struct il_station_entry { + struct il_addsta_cmd sta; + struct il_tid_data tid[MAX_TID_COUNT]; u8 used, ctxid; - struct iwl_hw_key keyinfo; - struct iwl_link_quality_cmd *lq; + struct il_hw_key keyinfo; + struct il_link_quality_cmd *lq; }; -struct iwl_station_priv_common { - struct iwl_rxon_context *ctx; +struct il_station_priv_common { + struct il_rxon_context *ctx; u8 sta_id; }; /* - * iwl_station_priv: Driver's private station information + * il_station_priv: Driver's private station information * * When mac80211 creates a station it reserves some space (hw->sta_data_size) * in the structure for use by driver. This structure is places in that @@ -485,22 +485,22 @@ struct iwl_station_priv_common { * The common struct MUST be first because it is shared between * 3945 and 4965! */ -struct iwl_station_priv { - struct iwl_station_priv_common common; - struct iwl_lq_sta lq_sta; +struct il_station_priv { + struct il_station_priv_common common; + struct il_lq_sta lq_sta; atomic_t pending_frames; bool client; bool asleep; }; /** - * struct iwl_vif_priv - driver's private per-interface information + * struct il_vif_priv - driver's private per-interface information * * When mac80211 allocates a virtual interface, it can allocate * space for us to put data into. */ -struct iwl_vif_priv { - struct iwl_rxon_context *ctx; +struct il_vif_priv { + struct il_rxon_context *ctx; u8 ibss_bssid_sta_id; }; @@ -512,7 +512,7 @@ struct fw_desc { }; /* uCode file layout */ -struct iwl_ucode_header { +struct il_ucode_header { __le32 ver; /* major/minor/API/serial */ struct { __le32 inst_size; /* bytes of runtime code */ @@ -524,7 +524,7 @@ struct iwl_ucode_header { } v1; }; -struct iwl4965_ibss_seq { +struct il4965_ibss_seq { u8 mac[ETH_ALEN]; u16 seq_num; u16 frag_num; @@ -532,7 +532,7 @@ struct iwl4965_ibss_seq { struct list_head list; }; -struct iwl_sensitivity_ranges { +struct il_sensitivity_ranges { u16 min_nrg_cck; u16 max_nrg_cck; @@ -565,7 +565,7 @@ struct iwl_sensitivity_ranges { /** - * struct iwl_hw_params + * struct il_hw_params * @max_txq_num: Max # Tx queues supported * @dma_chnl_num: Number of Tx DMA/FIFO channels * @scd_bc_tbls_size: size of scheduler byte count tables @@ -583,9 +583,9 @@ struct iwl_sensitivity_ranges { * @max_xxx_size: for ucode uses * @ct_kill_threshold: temperature threshold * @beacon_time_tsf_bits: number of valid tsf bits for beacon time - * @struct iwl_sensitivity_ranges: range of sensitivity values + * @struct il_sensitivity_ranges: range of sensitivity values */ -struct iwl_hw_params { +struct il_hw_params { u8 max_txq_num; u8 dma_chnl_num; u16 scd_bc_tbls_size; @@ -606,7 +606,7 @@ struct iwl_hw_params { u32 max_bsm_size; u32 ct_kill_threshold; /* value in hw-dependent units */ u16 beacon_time_tsf_bits; - const struct iwl_sensitivity_ranges *sens; + const struct il_sensitivity_ranges *sens; }; @@ -619,16 +619,16 @@ struct iwl_hw_params { * which is why they are in the core module files. * * Naming convention -- - * iwl_ <-- Is part of iwlwifi + * il_ <-- Is part of iwlwifi * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * iwl4965_bg_ <-- Called from work queue context - * iwl4965_mac_ <-- mac80211 callback + * il4965_bg_ <-- Called from work queue context + * il4965_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void iwl4965_update_chain_flags(struct iwl_priv *priv); +extern void il4965_update_chain_flags(struct il_priv *priv); extern const u8 iwlegacy_bcast_addr[ETH_ALEN]; -extern int iwl_legacy_queue_space(const struct iwl_queue *q); -static inline int iwl_legacy_queue_used(const struct iwl_queue *q, int i) +extern int il_queue_space(const struct il_queue *q); +static inline int il_queue_used(const struct il_queue *q, int i) { return q->write_ptr >= q->read_ptr ? (i >= q->read_ptr && i < q->write_ptr) : @@ -636,7 +636,7 @@ static inline int iwl_legacy_queue_used(const struct iwl_queue *q, int i) } -static inline u8 iwl_legacy_get_cmd_index(struct iwl_queue *q, u32 index, +static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, int is_huge) { /* @@ -652,26 +652,26 @@ static inline u8 iwl_legacy_get_cmd_index(struct iwl_queue *q, u32 index, } -struct iwl_dma_ptr { +struct il_dma_ptr { dma_addr_t dma; void *addr; size_t size; }; -#define IWL_OPERATION_MODE_AUTO 0 -#define IWL_OPERATION_MODE_HT_ONLY 1 -#define IWL_OPERATION_MODE_MIXED 2 -#define IWL_OPERATION_MODE_20MHZ 3 +#define IL_OPERATION_MODE_AUTO 0 +#define IL_OPERATION_MODE_HT_ONLY 1 +#define IL_OPERATION_MODE_MIXED 2 +#define IL_OPERATION_MODE_20MHZ 3 -#define IWL_TX_CRC_SIZE 4 -#define IWL_TX_DELIMITER_SIZE 4 +#define IL_TX_CRC_SIZE 4 +#define IL_TX_DELIMITER_SIZE 4 -#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000 +#define TX_POWER_IL_ILLEGAL_VOLTAGE -10000 /* Sensitivity and chain noise calibration */ #define INITIALIZATION_VALUE 0xFFFF #define IWL4965_CAL_NUM_BEACONS 20 -#define IWL_CAL_NUM_BEACONS 16 +#define IL_CAL_NUM_BEACONS 16 #define MAXIMUM_ALLOWED_PATHLOSS 15 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 @@ -704,35 +704,35 @@ struct iwl_dma_ptr { #define NRG_NUM_PREV_STAT_L 20 #define NUM_RX_CHAINS 3 -enum iwl4965_false_alarm_state { - IWL_FA_TOO_MANY = 0, - IWL_FA_TOO_FEW = 1, - IWL_FA_GOOD_RANGE = 2, +enum il4965_false_alarm_state { + IL_FA_TOO_MANY = 0, + IL_FA_TOO_FEW = 1, + IL_FA_GOOD_RANGE = 2, }; -enum iwl4965_chain_noise_state { - IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ - IWL_CHAIN_NOISE_ACCUMULATE, - IWL_CHAIN_NOISE_CALIBRATED, - IWL_CHAIN_NOISE_DONE, +enum il4965_chain_noise_state { + IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ + IL_CHAIN_NOISE_ACCUMULATE, + IL_CHAIN_NOISE_CALIBRATED, + IL_CHAIN_NOISE_DONE, }; -enum iwl4965_calib_enabled_state { - IWL_CALIB_DISABLED = 0, /* must be 0 */ - IWL_CALIB_ENABLED = 1, +enum il4965_calib_enabled_state { + IL_CALIB_DISABLED = 0, /* must be 0 */ + IL_CALIB_ENABLED = 1, }; /* - * enum iwl_calib + * enum il_calib * defines the order in which results of initial calibrations * should be sent to the runtime uCode */ -enum iwl_calib { - IWL_CALIB_MAX, +enum il_calib { + IL_CALIB_MAX, }; /* Opaque calibration results */ -struct iwl_calib_result { +struct il_calib_result { void *buf; size_t buf_len; }; @@ -744,7 +744,7 @@ enum ucode_type { }; /* Sensitivity calib data */ -struct iwl_sensitivity_data { +struct il_sensitivity_data { u32 auto_corr_ofdm; u32 auto_corr_ofdm_mrc; u32 auto_corr_ofdm_x1; @@ -775,7 +775,7 @@ struct iwl_sensitivity_data { }; /* Chain noise (differential Rx gain) calib data */ -struct iwl_chain_noise_data { +struct il_chain_noise_data { u32 active_chains; u32 chain_noise_a; u32 chain_noise_b; @@ -793,8 +793,8 @@ struct iwl_chain_noise_data { #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ -#define IWL_TRAFFIC_ENTRIES (256) -#define IWL_TRAFFIC_ENTRY_SIZE (64) +#define IL_TRAFFIC_ENTRIES (256) +#define IL_TRAFFIC_ENTRY_SIZE (64) enum { MEASUREMENT_READY = (1 << 0), @@ -818,7 +818,7 @@ struct isr_statistics { }; /* management statistics */ -enum iwl_mgmt_stats { +enum il_mgmt_stats { MANAGEMENT_ASSOC_REQ = 0, MANAGEMENT_ASSOC_RESP, MANAGEMENT_REASSOC_REQ, @@ -834,7 +834,7 @@ enum iwl_mgmt_stats { MANAGEMENT_MAX, }; /* control statistics */ -enum iwl_ctrl_stats { +enum il_ctrl_stats { CONTROL_BACK_REQ = 0, CONTROL_BACK, CONTROL_PSPOLL, @@ -863,21 +863,21 @@ struct traffic_stats { * default interrupt coalescing timer is 64 x 32 = 2048 usecs * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs */ -#define IWL_HOST_INT_TIMEOUT_MAX (0xFF) -#define IWL_HOST_INT_TIMEOUT_DEF (0x40) -#define IWL_HOST_INT_TIMEOUT_MIN (0x0) -#define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) -#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) -#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) +#define IL_HOST_INT_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_TIMEOUT_DEF (0x40) +#define IL_HOST_INT_TIMEOUT_MIN (0x0) +#define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) +#define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) -#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) +#define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) /* TX queue watchdog timeouts in mSecs */ -#define IWL_DEF_WD_TIMEOUT (2000) -#define IWL_LONG_WD_TIMEOUT (10000) -#define IWL_MAX_WD_TIMEOUT (120000) +#define IL_DEF_WD_TIMEOUT (2000) +#define IL_LONG_WD_TIMEOUT (10000) +#define IL_MAX_WD_TIMEOUT (120000) -struct iwl_force_reset { +struct il_force_reset { int reset_request_count; int reset_success_count; int reset_reject_count; @@ -899,13 +899,13 @@ struct iwl_force_reset { */ #define IWL4965_EXT_BEACON_TIME_POS 22 -enum iwl_rxon_context_id { - IWL_RXON_CTX_BSS, +enum il_rxon_context_id { + IL_RXON_CTX_BSS, - NUM_IWL_RXON_CTX + NUM_IL_RXON_CTX }; -struct iwl_rxon_context { +struct il_rxon_context { struct ieee80211_vif *vif; const u8 *ac_to_fifo; @@ -921,7 +921,7 @@ struct iwl_rxon_context { bool ht_need_multiple_chains; - enum iwl_rxon_context_id ctxid; + enum il_rxon_context_id ctxid; u32 interface_modes, exclusive_interface_modes; u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; @@ -932,12 +932,12 @@ struct iwl_rxon_context { * routines that actually update the physical * hardware. */ - const struct iwl_legacy_rxon_cmd active; - struct iwl_legacy_rxon_cmd staging; + const struct il_rxon_cmd active; + struct il_rxon_cmd staging; - struct iwl_rxon_time_cmd timing; + struct il_rxon_time_cmd timing; - struct iwl_qos_info qos_data; + struct il_qos_info qos_data; u8 bcast_sta_id, ap_sta_id; @@ -945,7 +945,7 @@ struct iwl_rxon_context { u8 qos_cmd; u8 wep_key_cmd; - struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; + struct il_wep_key wep_keys[WEP_KEYS_MAX]; u8 key_mapping_keys; __le32 station_flags; @@ -958,13 +958,13 @@ struct iwl_rxon_context { } ht; }; -struct iwl_priv { +struct il_priv { /* ieee device used by generic ieee processing code */ struct ieee80211_hw *hw; struct ieee80211_channel *ieee_channels; struct ieee80211_rate *ieee_rates; - struct iwl_cfg *cfg; + struct il_cfg *cfg; /* temporary frame storage list */ struct list_head free_frames; @@ -973,13 +973,13 @@ struct iwl_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); + void (*rx_handlers[REPLY_MAX])(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; /* spectrum measurement report caching */ - struct iwl_spectrum_notification measure_report; + struct il_spectrum_notification measure_report; u8 measurement_status; /* ucode beacon time */ @@ -990,11 +990,11 @@ struct iwl_priv { u32 ibss_manager; /* force reset */ - struct iwl_force_reset force_reset; + struct il_force_reset force_reset; - /* we allocate array of iwl_channel_info for NIC's valid channels. + /* we allocate array of il_channel_info for NIC's valid channels. * Access via channel # using indirect index array */ - struct iwl_channel_info *channel_info; /* channel info array */ + struct il_channel_info *channel_info; /* channel info array */ u8 channel_count; /* # of channels */ /* thermal calibration */ @@ -1002,7 +1002,7 @@ struct iwl_priv { s32 last_temperature; /* init calibration results */ - struct iwl_calib_result calib_results[IWL_CALIB_MAX]; + struct il_calib_result calib_results[IL_CALIB_MAX]; /* Scan related variables */ unsigned long scan_start; @@ -1044,7 +1044,7 @@ struct iwl_priv { /* uCode images, save to reload in case of failure */ int fw_index; /* firmware we're trying to load */ u32 ucode_ver; /* version of ucode, copy of - iwl_ucode.ver */ + il_ucode.ver */ struct fw_desc ucode_code; /* runtime inst */ struct fw_desc ucode_data; /* runtime data original */ struct fw_desc ucode_data_backup; /* runtime data save/restore */ @@ -1055,23 +1055,23 @@ struct iwl_priv { u8 ucode_write_complete; /* the image write is complete */ char firmware_name[25]; - struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; + struct il_rxon_context contexts[NUM_IL_RXON_CTX]; __le16 switch_channel; /* 1st responses from initialize and runtime uCode images. * _4965's initialize alive response contains some calibration data. */ - struct iwl_init_alive_resp card_alive_init; - struct iwl_alive_resp card_alive; + struct il_init_alive_resp card_alive_init; + struct il_alive_resp card_alive; u16 active_rate; u8 start_calib; - struct iwl_sensitivity_data sensitivity_data; - struct iwl_chain_noise_data chain_noise_data; + struct il_sensitivity_data sensitivity_data; + struct il_chain_noise_data chain_noise_data; __le16 sensitivity_tbl[HD_TABLE_SIZE]; - struct iwl_ht_config current_ht_config; + struct il_ht_config current_ht_config; /* Rate scaling data */ u8 retry_rate; @@ -1081,11 +1081,11 @@ struct iwl_priv { int activity_timer_active; /* Rx and Tx DMA processing queues */ - struct iwl_rx_queue rxq; - struct iwl_tx_queue *txq; + struct il_rx_queue rxq; + struct il_tx_queue *txq; unsigned long txq_ctx_active_msk; - struct iwl_dma_ptr kw; /* keep warm address */ - struct iwl_dma_ptr scd_bc_tbls; + struct il_dma_ptr kw; /* keep warm address */ + struct il_dma_ptr scd_bc_tbls; u32 scd_base_addr; /* scheduler sram base address */ @@ -1098,7 +1098,7 @@ struct iwl_priv { /* counts interrupts */ struct isr_statistics isr_stats; - struct iwl_power_mgr power_data; + struct il_power_mgr power_data; /* context information */ u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ @@ -1108,12 +1108,12 @@ struct iwl_priv { /* Note: if lock and sta_lock are needed, lock must be acquired first */ spinlock_t sta_lock; int num_stations; - struct iwl_station_entry stations[IWL_STATION_COUNT]; + struct il_station_entry stations[IL_STATION_COUNT]; unsigned long ucode_key_table; /* queue refcounts */ -#define IWL_MAX_HW_QUEUES 32 - unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)]; +#define IL_MAX_HW_QUEUES 32 + unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)]; /* for each AC */ atomic_t queue_stop_count[4]; @@ -1124,7 +1124,7 @@ struct iwl_priv { /* eeprom -- this is in the card's little endian byte order */ u8 *eeprom; - struct iwl_eeprom_calib_info *calib_info; + struct il_eeprom_calib_info *calib_info; enum nl80211_iftype iw_mode; @@ -1140,11 +1140,11 @@ struct iwl_priv { struct delayed_work thermal_periodic; struct delayed_work rfkill_poll; - struct iwl3945_notif_statistics statistics; + struct il3945_notif_statistics statistics; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - struct iwl3945_notif_statistics accum_statistics; - struct iwl3945_notif_statistics delta_statistics; - struct iwl3945_notif_statistics max_delta; + struct il3945_notif_statistics accum_statistics; + struct il3945_notif_statistics delta_statistics; + struct il3945_notif_statistics max_delta; #endif u32 sta_supp_rates; @@ -1159,13 +1159,13 @@ struct iwl_priv { * EEPROM has a derived clip setting for * each rate. */ - const struct iwl3945_clip_group clip_groups[5]; + const struct il3945_clip_group clip_groups[5]; } _3945; #endif #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) struct { - struct iwl_rx_phy_res last_phy_res; + struct il_rx_phy_res last_phy_res; bool last_phy_res_valid; struct completion firmware_loading_complete; @@ -1178,18 +1178,18 @@ struct iwl_priv { u8 phy_calib_chain_noise_reset_cmd; u8 phy_calib_chain_noise_gain_cmd; - struct iwl_notif_statistics statistics; + struct il_notif_statistics statistics; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - struct iwl_notif_statistics accum_statistics; - struct iwl_notif_statistics delta_statistics; - struct iwl_notif_statistics max_delta; + struct il_notif_statistics accum_statistics; + struct il_notif_statistics delta_statistics; + struct il_notif_statistics max_delta; #endif } _4965; #endif }; - struct iwl_hw_params hw_params; + struct il_hw_params hw_params; u32 inta_mask; @@ -1200,7 +1200,7 @@ struct iwl_priv { struct work_struct rx_replenish; struct work_struct abort_scan; - struct iwl_rxon_context *beacon_ctx; + struct il_rxon_context *beacon_ctx; struct sk_buff *beacon_skb; struct work_struct tx_flush; @@ -1245,27 +1245,27 @@ struct iwl_priv { struct led_classdev led; unsigned long blink_on, blink_off; bool led_registered; -}; /*iwl_priv */ +}; /*il_priv */ -static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id) +static inline void il_txq_ctx_activate(struct il_priv *priv, int txq_id) { set_bit(txq_id, &priv->txq_ctx_active_msk); } -static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id) +static inline void il_txq_ctx_deactivate(struct il_priv *priv, int txq_id) { clear_bit(txq_id, &priv->txq_ctx_active_msk); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG /* - * iwl_legacy_get_debug_level: Return active debug level for device + * il_get_debug_level: Return active debug level for device * * Using sysfs it is possible to set per device debug level. This debug * level will be used if set, otherwise the global debug level which can be * set via module parameter is used. */ -static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *priv) { if (priv->debug_level) return priv->debug_level; @@ -1273,7 +1273,7 @@ static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) return iwlegacy_debug_level; } #else -static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *priv) { return iwlegacy_debug_level; } @@ -1281,7 +1281,7 @@ static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) static inline struct ieee80211_hdr * -iwl_legacy_tx_queue_get_hdr(struct iwl_priv *priv, +il_tx_queue_get_hdr(struct il_priv *priv, int txq_id, int idx) { if (priv->txq[txq_id].txb[idx].skb) @@ -1290,75 +1290,75 @@ iwl_legacy_tx_queue_get_hdr(struct iwl_priv *priv, return NULL; } -static inline struct iwl_rxon_context * -iwl_legacy_rxon_ctx_from_vif(struct ieee80211_vif *vif) +static inline struct il_rxon_context * +il_rxon_ctx_from_vif(struct ieee80211_vif *vif) { - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; return vif_priv->ctx; } #define for_each_context(priv, ctx) \ - for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \ - ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \ + for (ctx = &priv->contexts[IL_RXON_CTX_BSS]; \ + ctx < &priv->contexts[NUM_IL_RXON_CTX]; ctx++) \ if (priv->valid_contexts & BIT(ctx->ctxid)) -static inline int iwl_legacy_is_associated(struct iwl_priv *priv, - enum iwl_rxon_context_id ctxid) +static inline int il_is_associated(struct il_priv *priv, + enum il_rxon_context_id ctxid) { return (priv->contexts[ctxid].active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int iwl_legacy_is_any_associated(struct iwl_priv *priv) +static inline int il_is_any_associated(struct il_priv *priv) { - return iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS); + return il_is_associated(priv, IL_RXON_CTX_BSS); } -static inline int iwl_legacy_is_associated_ctx(struct iwl_rxon_context *ctx) +static inline int il_is_associated_ctx(struct il_rxon_context *ctx) { return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int iwl_legacy_is_channel_valid(const struct iwl_channel_info *ch_info) +static inline int il_is_channel_valid(const struct il_channel_info *ch_info) { if (ch_info == NULL) return 0; return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; } -static inline int iwl_legacy_is_channel_radar(const struct iwl_channel_info *ch_info) +static inline int il_is_channel_radar(const struct il_channel_info *ch_info) { return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; } -static inline u8 iwl_legacy_is_channel_a_band(const struct iwl_channel_info *ch_info) +static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) { return ch_info->band == IEEE80211_BAND_5GHZ; } static inline int -iwl_legacy_is_channel_passive(const struct iwl_channel_info *ch) +il_is_channel_passive(const struct il_channel_info *ch) { return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; } static inline int -iwl_legacy_is_channel_ibss(const struct iwl_channel_info *ch) +il_is_channel_ibss(const struct il_channel_info *ch) { return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; } static inline void -__iwl_legacy_free_pages(struct iwl_priv *priv, struct page *page) +__il_free_pages(struct il_priv *priv, struct page *page) { __free_pages(page, priv->hw_params.rx_page_order); priv->alloc_rxb_page--; } -static inline void iwl_legacy_free_pages(struct iwl_priv *priv, unsigned long page) +static inline void il_free_pages(struct il_priv *priv, unsigned long page) { free_pages(page, priv->hw_params.rx_page_order); priv->alloc_rxb_page--; } -#endif /* __iwl_legacy_dev_h__ */ +#endif /* __il_dev_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5bf3f49..1075f1d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -81,7 +81,7 @@ * EEPROM contents to the specific channel number supported for each * band. * - * For example, iwl_priv->eeprom.band_3_channels[4] from the band_3 + * For example, il_priv->eeprom.band_3_channels[4] from the band_3 * definition below maps to physical channel 42 in the 5.2GHz spectrum. * The specific geography and calibration information for that channel * is contained in the eeprom map itself. @@ -142,18 +142,18 @@ static const u8 iwlegacy_eeprom_band_7[] = { /* 5.2 ht40 channel */ * ******************************************************************************/ -static int iwl_legacy_eeprom_verify_signature(struct iwl_priv *priv) +static int il_eeprom_verify_signature(struct il_priv *priv) { - u32 gp = iwl_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = il_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; - IWL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); + IL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); switch (gp) { case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IWL_ERR(priv, "bad EEPROM signature," + IL_ERR(priv, "bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; @@ -162,39 +162,39 @@ static int iwl_legacy_eeprom_verify_signature(struct iwl_priv *priv) } const u8 -*iwl_legacy_eeprom_query_addr(const struct iwl_priv *priv, size_t offset) +*il_eeprom_query_addr(const struct il_priv *priv, size_t offset) { BUG_ON(offset >= priv->cfg->base_params->eeprom_size); return &priv->eeprom[offset]; } -EXPORT_SYMBOL(iwl_legacy_eeprom_query_addr); +EXPORT_SYMBOL(il_eeprom_query_addr); -u16 iwl_legacy_eeprom_query16(const struct iwl_priv *priv, size_t offset) +u16 il_eeprom_query16(const struct il_priv *priv, size_t offset) { if (!priv->eeprom) return 0; return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8); } -EXPORT_SYMBOL(iwl_legacy_eeprom_query16); +EXPORT_SYMBOL(il_eeprom_query16); /** - * iwl_legacy_eeprom_init - read EEPROM contents + * il_eeprom_init - read EEPROM contents * * Load the EEPROM contents from adapter into priv->eeprom * * NOTE: This routine uses the non-debug IO access functions. */ -int iwl_legacy_eeprom_init(struct iwl_priv *priv) +int il_eeprom_init(struct il_priv *priv) { __le16 *e; - u32 gp = iwl_read32(priv, CSR_EEPROM_GP); + u32 gp = il_read32(priv, CSR_EEPROM_GP); int sz; int ret; u16 addr; /* allocate eeprom */ sz = priv->cfg->base_params->eeprom_size; - IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); + IL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); priv->eeprom = kzalloc(sz, GFP_KERNEL); if (!priv->eeprom) { ret = -ENOMEM; @@ -204,9 +204,9 @@ int iwl_legacy_eeprom_init(struct iwl_priv *priv) priv->cfg->ops->lib->apm_ops.init(priv); - ret = iwl_legacy_eeprom_verify_signature(priv); + ret = il_eeprom_verify_signature(priv); if (ret < 0) { - IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); + IL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; goto err; } @@ -214,7 +214,7 @@ int iwl_legacy_eeprom_init(struct iwl_priv *priv) /* Make sure driver (instead of uCode) is allowed to read EEPROM */ ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv); if (ret < 0) { - IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); + IL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; goto err; } @@ -223,25 +223,25 @@ int iwl_legacy_eeprom_init(struct iwl_priv *priv) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - _iwl_legacy_write32(priv, CSR_EEPROM_REG, + _il_write32(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = iwl_poll_bit(priv, CSR_EEPROM_REG, + ret = il_poll_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, - IWL_EEPROM_ACCESS_TIMEOUT); + IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IWL_ERR(priv, "Time out reading EEPROM[%d]\n", + IL_ERR(priv, "Time out reading EEPROM[%d]\n", addr); goto done; } - r = _iwl_legacy_read_direct32(priv, CSR_EEPROM_REG); + r = _il_read_direct32(priv, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } - IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", + IL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", "EEPROM", - iwl_legacy_eeprom_query16(priv, EEPROM_VERSION)); + il_eeprom_query16(priv, EEPROM_VERSION)); ret = 0; done: @@ -249,24 +249,24 @@ done: err: if (ret) - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); /* Reset chip to save power until we load uCode during "up". */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); alloc_err: return ret; } -EXPORT_SYMBOL(iwl_legacy_eeprom_init); +EXPORT_SYMBOL(il_eeprom_init); -void iwl_legacy_eeprom_free(struct iwl_priv *priv) +void il_eeprom_free(struct il_priv *priv) { kfree(priv->eeprom); priv->eeprom = NULL; } -EXPORT_SYMBOL(iwl_legacy_eeprom_free); +EXPORT_SYMBOL(il_eeprom_free); -static void iwl_legacy_init_band_reference(const struct iwl_priv *priv, +static void il_init_band_reference(const struct il_priv *priv, int eep_band, int *eeprom_ch_count, - const struct iwl_eeprom_channel **eeprom_ch_info, + const struct il_eeprom_channel **eeprom_ch_info, const u8 **eeprom_ch_index) { u32 offset = priv->cfg->ops->lib-> @@ -274,44 +274,44 @@ static void iwl_legacy_init_band_reference(const struct iwl_priv *priv, switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_1); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_2); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_3); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_4); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_5); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_6); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_7); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_7; break; default: @@ -322,27 +322,27 @@ static void iwl_legacy_init_band_reference(const struct iwl_priv *priv, #define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ ? # x " " : "") /** - * iwl_legacy_mod_ht40_chan_info - Copy ht40 channel info into driver's priv. + * il_mod_ht40_chan_info - Copy ht40 channel info into driver's priv. * * Does not set up a command, or touch hardware. */ -static int iwl_legacy_mod_ht40_chan_info(struct iwl_priv *priv, +static int il_mod_ht40_chan_info(struct il_priv *priv, enum ieee80211_band band, u16 channel, - const struct iwl_eeprom_channel *eeprom_ch, + const struct il_eeprom_channel *eeprom_ch, u8 clear_ht40_extension_channel) { - struct iwl_channel_info *ch_info; + struct il_channel_info *ch_info; - ch_info = (struct iwl_channel_info *) - iwl_legacy_get_channel_info(priv, band, channel); + ch_info = (struct il_channel_info *) + il_get_channel_info(priv, band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) + if (!il_is_channel_valid(ch_info)) return -1; - IWL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + IL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, - iwl_legacy_is_channel_a_band(ch_info) ? + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", CHECK_AND_PRINT(IBSS), CHECK_AND_PRINT(ACTIVE), @@ -369,22 +369,22 @@ static int iwl_legacy_mod_ht40_chan_info(struct iwl_priv *priv, ? # x " " : "") /** - * iwl_legacy_init_channel_map - Set up driver's info for all possible channels + * il_init_channel_map - Set up driver's info for all possible channels */ -int iwl_legacy_init_channel_map(struct iwl_priv *priv) +int il_init_channel_map(struct il_priv *priv) { int eeprom_ch_count = 0; const u8 *eeprom_ch_index = NULL; - const struct iwl_eeprom_channel *eeprom_ch_info = NULL; + const struct il_eeprom_channel *eeprom_ch_info = NULL; int band, ch; - struct iwl_channel_info *ch_info; + struct il_channel_info *ch_info; if (priv->channel_count) { - IWL_DEBUG_EEPROM(priv, "Channel map already initialized.\n"); + IL_DEBUG_EEPROM(priv, "Channel map already initialized.\n"); return 0; } - IWL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n"); + IL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n"); priv->channel_count = ARRAY_SIZE(iwlegacy_eeprom_band_1) + @@ -393,13 +393,13 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) ARRAY_SIZE(iwlegacy_eeprom_band_4) + ARRAY_SIZE(iwlegacy_eeprom_band_5); - IWL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n", + IL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n", priv->channel_count); - priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) * + priv->channel_info = kzalloc(sizeof(struct il_channel_info) * priv->channel_count, GFP_KERNEL); if (!priv->channel_info) { - IWL_ERR(priv, "Could not allocate channel_info\n"); + IL_ERR(priv, "Could not allocate channel_info\n"); priv->channel_count = 0; return -ENOMEM; } @@ -411,7 +411,7 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) * what just in the EEPROM) */ for (band = 1; band <= 5; band++) { - iwl_legacy_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(priv, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* Loop through each band adding each of the channels */ @@ -432,13 +432,13 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) ch_info->ht40_extension_channel = IEEE80211_CHAN_NO_HT40; - if (!(iwl_legacy_is_channel_valid(ch_info))) { - IWL_DEBUG_EEPROM(priv, + if (!(il_is_channel_valid(ch_info))) { + IL_DEBUG_EEPROM(priv, "Ch. %d Flags %x [%sGHz] - " "No traffic\n", ch_info->channel, ch_info->flags, - iwl_legacy_is_channel_a_band(ch_info) ? + il_is_channel_a_band(ch_info) ? "5.2" : "2.4"); ch_info++; continue; @@ -450,11 +450,11 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - IWL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] " + IL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, - iwl_legacy_is_channel_a_band(ch_info) ? + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", CHECK_AND_PRINT_I(VALID), CHECK_AND_PRINT_I(IBSS), @@ -485,7 +485,7 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) for (band = 6; band <= 7; band++) { enum ieee80211_band ieeeband; - iwl_legacy_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(priv, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ @@ -495,13 +495,13 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ - iwl_legacy_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(priv, ieeeband, eeprom_ch_index[ch], &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ - iwl_legacy_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(priv, ieeeband, eeprom_ch_index[ch] + 4, &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40MINUS); @@ -510,25 +510,25 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) return 0; } -EXPORT_SYMBOL(iwl_legacy_init_channel_map); +EXPORT_SYMBOL(il_init_channel_map); /* - * iwl_legacy_free_channel_map - undo allocations in iwl_legacy_init_channel_map + * il_free_channel_map - undo allocations in il_init_channel_map */ -void iwl_legacy_free_channel_map(struct iwl_priv *priv) +void il_free_channel_map(struct il_priv *priv) { kfree(priv->channel_info); priv->channel_count = 0; } -EXPORT_SYMBOL(iwl_legacy_free_channel_map); +EXPORT_SYMBOL(il_free_channel_map); /** - * iwl_legacy_get_channel_info - Find driver's private channel info + * il_get_channel_info - Find driver's private channel info * * Based on band and channel number. */ const struct -iwl_channel_info *iwl_legacy_get_channel_info(const struct iwl_priv *priv, +il_channel_info *il_get_channel_info(const struct il_priv *priv, enum ieee80211_band band, u16 channel) { int i; @@ -550,4 +550,4 @@ iwl_channel_info *iwl_legacy_get_channel_info(const struct iwl_priv *priv, return NULL; } -EXPORT_SYMBOL(iwl_legacy_get_channel_info); +EXPORT_SYMBOL(il_get_channel_info); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index c59c810..9ad6871 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -60,12 +60,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_legacy_eeprom_h__ -#define __iwl_legacy_eeprom_h__ +#ifndef __il_eeprom_h__ +#define __il_eeprom_h__ #include -struct iwl_priv; +struct il_priv; /* * EEPROM access time values: @@ -75,14 +75,14 @@ struct iwl_priv; * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. */ -#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ +#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ -#define IWL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ -#define IWL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ +#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ +#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ /* - * Regulatory channel usage flags in EEPROM struct iwl4965_eeprom_channel.flags. + * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. * * IBSS and/or AP operation is allowed *only* on those channels with * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because @@ -97,7 +97,7 @@ struct iwl_priv; * * NOTE: Using a channel inappropriately will result in a uCode error! */ -#define IWL_NUM_TX_CALIB_GROUPS 5 +#define IL_NUM_TX_CALIB_GROUPS 5 enum { EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ @@ -116,7 +116,7 @@ enum { /* *regulatory* channel data format in eeprom, one for each channel. * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */ -struct iwl_eeprom_channel { +struct il_eeprom_channel { u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ } __packed; @@ -160,7 +160,7 @@ extern const u8 iwlegacy_eeprom_band_1[14]; * * 4) RF power amplifier detector level measurement (not used). */ -struct iwl_eeprom_calib_measure { +struct il_eeprom_calib_measure { u8 temperature; /* Device temperature (Celsius) */ u8 gain_idx; /* Index into gain table */ u8 actual_pow; /* Measured RF output power, half-dBm */ @@ -176,9 +176,9 @@ struct iwl_eeprom_calib_measure { * 2) Measurements for each of 3 power levels for each of 2 radio transmitters * (a.k.a. "tx chains") (6 measurements altogether) */ -struct iwl_eeprom_calib_ch_info { +struct il_eeprom_calib_ch_info { u8 ch_num; - struct iwl_eeprom_calib_measure + struct il_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS] [EEPROM_TX_POWER_MEASUREMENTS]; } __packed; @@ -193,11 +193,11 @@ struct iwl_eeprom_calib_ch_info { * * 2) Sample measurement sets for 2 channels close to the range endpoints. */ -struct iwl_eeprom_calib_subband_info { +struct il_eeprom_calib_subband_info { u8 ch_from; /* channel number of lowest channel in subband */ u8 ch_to; /* channel number of highest channel in subband */ - struct iwl_eeprom_calib_ch_info ch1; - struct iwl_eeprom_calib_ch_info ch2; + struct il_eeprom_calib_ch_info ch1; + struct il_eeprom_calib_ch_info ch2; } __packed; @@ -218,14 +218,14 @@ struct iwl_eeprom_calib_subband_info { * characteristics of the analog radio circuitry vary with frequency. * * Not all sets need to be filled with data; - * struct iwl_eeprom_calib_subband_info contains range of channels + * struct il_eeprom_calib_subband_info contains range of channels * (0 if unused) for each set of data. */ -struct iwl_eeprom_calib_info { +struct il_eeprom_calib_info { u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ u8 saturation_power52; /* half-dBm */ __le16 voltage; /* signed */ - struct iwl_eeprom_calib_subband_info + struct il_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS]; } __packed; @@ -323,22 +323,22 @@ struct iwl_eeprom_calib_info { #define EEPROM_REGULATORY_BAND_NO_HT40 (0) -struct iwl_eeprom_ops { +struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct iwl_priv *priv); - void (*release_semaphore) (struct iwl_priv *priv); + int (*acquire_semaphore) (struct il_priv *priv); + void (*release_semaphore) (struct il_priv *priv); }; -int iwl_legacy_eeprom_init(struct iwl_priv *priv); -void iwl_legacy_eeprom_free(struct iwl_priv *priv); -const u8 *iwl_legacy_eeprom_query_addr(const struct iwl_priv *priv, +int il_eeprom_init(struct il_priv *priv); +void il_eeprom_free(struct il_priv *priv); +const u8 *il_eeprom_query_addr(const struct il_priv *priv, size_t offset); -u16 iwl_legacy_eeprom_query16(const struct iwl_priv *priv, size_t offset); -int iwl_legacy_init_channel_map(struct iwl_priv *priv); -void iwl_legacy_free_channel_map(struct iwl_priv *priv); -const struct iwl_channel_info *iwl_legacy_get_channel_info( - const struct iwl_priv *priv, +u16 il_eeprom_query16(const struct il_priv *priv, size_t offset); +int il_init_channel_map(struct il_priv *priv); +void il_free_channel_map(struct il_priv *priv); +const struct il_channel_info *il_get_channel_info( + const struct il_priv *priv, enum ieee80211_band band, u16 channel); -#endif /* __iwl_legacy_eeprom_h__ */ +#endif /* __il_eeprom_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index 6e60918..0ae36df 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ -#ifndef __iwl_legacy_fh_h__ -#define __iwl_legacy_fh_h__ +#ifndef __il_fh_h__ +#define __il_fh_h__ /****************************/ /* Flow Handler Definitions */ @@ -99,7 +99,7 @@ * * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) - * (see struct iwl_tfd_frame). These 16 pointer registers are offset by 0x04 + * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04 * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte * aligned (address bits 0-7 must be 0). * @@ -146,7 +146,7 @@ * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. * * Bit fields in lower dword of Rx status buffer (upper dword not used - * by driver; see struct iwl4965_shared, val0): + * by driver; see struct il4965_shared, val0): * 31-12: Not used by driver * 11- 0: Index of last filled Rx buffer descriptor * (4965 writes, driver reads this value) @@ -424,12 +424,12 @@ #define RX_LOW_WATERMARK 8 /* Size of one Rx buffer in host DRAM */ -#define IWL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ -#define IWL_RX_BUF_SIZE_4K (4 * 1024) -#define IWL_RX_BUF_SIZE_8K (8 * 1024) +#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ +#define IL_RX_BUF_SIZE_4K (4 * 1024) +#define IL_RX_BUF_SIZE_8K (8 * 1024) /** - * struct iwl_rb_status - reseve buffer status + * struct il_rb_status - reseve buffer status * host memory mapped FH registers * @closed_rb_num [0:11] - Indicates the index of the RB which was closed * @closed_fr_num [0:11] - Indicates the index of the RX Frame which was closed @@ -438,7 +438,7 @@ * @finished_fr_num [0:11] - Indicates the index of the RX Frame * which was transferred */ -struct iwl_rb_status { +struct il_rb_status { __le16 closed_rb_num; __le16 closed_fr_num; __le16 finished_rb_num; @@ -450,15 +450,15 @@ struct iwl_rb_status { #define TFD_QUEUE_SIZE_MAX (256) #define TFD_QUEUE_SIZE_BC_DUP (64) #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) -#define IWL_TX_DMA_MASK DMA_BIT_MASK(36) -#define IWL_NUM_OF_TBS 20 +#define IL_TX_DMA_MASK DMA_BIT_MASK(36) +#define IL_NUM_OF_TBS 20 -static inline u8 iwl_legacy_get_dma_hi_addr(dma_addr_t addr) +static inline u8 il_get_dma_hi_addr(dma_addr_t addr) { return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; } /** - * struct iwl_tfd_tb transmit buffer descriptor within transmit frame descriptor + * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor * * This structure contains dma address and length of transmission address * @@ -467,13 +467,13 @@ static inline u8 iwl_legacy_get_dma_hi_addr(dma_addr_t addr) * @hi_n_len 0-3 [35:32] portion of dma * 4-15 length of the tx buffer */ -struct iwl_tfd_tb { +struct il_tfd_tb { __le32 lo; __le16 hi_n_len; } __packed; /** - * struct iwl_tfd + * struct il_tfd * * Transmit Frame Descriptor (TFD) * @@ -500,14 +500,14 @@ struct iwl_tfd_tb { * * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. */ -struct iwl_tfd { +struct il_tfd { u8 __reserved1[3]; u8 num_tbs; - struct iwl_tfd_tb tbs[IWL_NUM_OF_TBS]; + struct il_tfd_tb tbs[IL_NUM_OF_TBS]; __le32 __pad; } __packed; /* Keep Warm Size */ -#define IWL_KW_SIZE 0x1000 /* 4k */ +#define IL_KW_SIZE 0x1000 /* 4k */ -#endif /* !__iwl_legacy_fh_h__ */ +#endif /* !__il_fh_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index ce1fc9f..515befc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -37,66 +37,66 @@ #include "iwl-core.h" -const char *iwl_legacy_get_cmd_string(u8 cmd) +const char *il_get_cmd_string(u8 cmd) { switch (cmd) { - IWL_CMD(REPLY_ALIVE); - IWL_CMD(REPLY_ERROR); - IWL_CMD(REPLY_RXON); - IWL_CMD(REPLY_RXON_ASSOC); - IWL_CMD(REPLY_QOS_PARAM); - IWL_CMD(REPLY_RXON_TIMING); - IWL_CMD(REPLY_ADD_STA); - IWL_CMD(REPLY_REMOVE_STA); - IWL_CMD(REPLY_WEPKEY); - IWL_CMD(REPLY_3945_RX); - IWL_CMD(REPLY_TX); - IWL_CMD(REPLY_RATE_SCALE); - IWL_CMD(REPLY_LEDS_CMD); - IWL_CMD(REPLY_TX_LINK_QUALITY_CMD); - IWL_CMD(REPLY_CHANNEL_SWITCH); - IWL_CMD(CHANNEL_SWITCH_NOTIFICATION); - IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); - IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION); - IWL_CMD(POWER_TABLE_CMD); - IWL_CMD(PM_SLEEP_NOTIFICATION); - IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); - IWL_CMD(REPLY_SCAN_CMD); - IWL_CMD(REPLY_SCAN_ABORT_CMD); - IWL_CMD(SCAN_START_NOTIFICATION); - IWL_CMD(SCAN_RESULTS_NOTIFICATION); - IWL_CMD(SCAN_COMPLETE_NOTIFICATION); - IWL_CMD(BEACON_NOTIFICATION); - IWL_CMD(REPLY_TX_BEACON); - IWL_CMD(REPLY_TX_PWR_TABLE_CMD); - IWL_CMD(REPLY_BT_CONFIG); - IWL_CMD(REPLY_STATISTICS_CMD); - IWL_CMD(STATISTICS_NOTIFICATION); - IWL_CMD(CARD_STATE_NOTIFICATION); - IWL_CMD(MISSED_BEACONS_NOTIFICATION); - IWL_CMD(REPLY_CT_KILL_CONFIG_CMD); - IWL_CMD(SENSITIVITY_CMD); - IWL_CMD(REPLY_PHY_CALIBRATION_CMD); - IWL_CMD(REPLY_RX_PHY_CMD); - IWL_CMD(REPLY_RX_MPDU_CMD); - IWL_CMD(REPLY_RX); - IWL_CMD(REPLY_COMPRESSED_BA); + IL_CMD(REPLY_ALIVE); + IL_CMD(REPLY_ERROR); + IL_CMD(REPLY_RXON); + IL_CMD(REPLY_RXON_ASSOC); + IL_CMD(REPLY_QOS_PARAM); + IL_CMD(REPLY_RXON_TIMING); + IL_CMD(REPLY_ADD_STA); + IL_CMD(REPLY_REMOVE_STA); + IL_CMD(REPLY_WEPKEY); + IL_CMD(REPLY_3945_RX); + IL_CMD(REPLY_TX); + IL_CMD(REPLY_RATE_SCALE); + IL_CMD(REPLY_LEDS_CMD); + IL_CMD(REPLY_TX_LINK_QUALITY_CMD); + IL_CMD(REPLY_CHANNEL_SWITCH); + IL_CMD(CHANNEL_SWITCH_NOTIFICATION); + IL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); + IL_CMD(SPECTRUM_MEASURE_NOTIFICATION); + IL_CMD(POWER_TABLE_CMD); + IL_CMD(PM_SLEEP_NOTIFICATION); + IL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); + IL_CMD(REPLY_SCAN_CMD); + IL_CMD(REPLY_SCAN_ABORT_CMD); + IL_CMD(SCAN_START_NOTIFICATION); + IL_CMD(SCAN_RESULTS_NOTIFICATION); + IL_CMD(SCAN_COMPLETE_NOTIFICATION); + IL_CMD(BEACON_NOTIFICATION); + IL_CMD(REPLY_TX_BEACON); + IL_CMD(REPLY_TX_PWR_TABLE_CMD); + IL_CMD(REPLY_BT_CONFIG); + IL_CMD(REPLY_STATISTICS_CMD); + IL_CMD(STATISTICS_NOTIFICATION); + IL_CMD(CARD_STATE_NOTIFICATION); + IL_CMD(MISSED_BEACONS_NOTIFICATION); + IL_CMD(REPLY_CT_KILL_CONFIG_CMD); + IL_CMD(SENSITIVITY_CMD); + IL_CMD(REPLY_PHY_CALIBRATION_CMD); + IL_CMD(REPLY_RX_PHY_CMD); + IL_CMD(REPLY_RX_MPDU_CMD); + IL_CMD(REPLY_RX); + IL_CMD(REPLY_COMPRESSED_BA); default: return "UNKNOWN"; } } -EXPORT_SYMBOL(iwl_legacy_get_cmd_string); +EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) -static void iwl_legacy_generic_cmd_callback(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt) +static void il_generic_cmd_callback(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt) { - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from %s (0x%08X)\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } @@ -104,18 +104,18 @@ static void iwl_legacy_generic_cmd_callback(struct iwl_priv *priv, switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IWL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + IL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - IWL_DEBUG_HC(priv, "back from %s (0x%08X)\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + IL_DEBUG_HC(priv, "back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); } #endif } static int -iwl_legacy_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +il_send_cmd_async(struct il_priv *priv, struct il_host_cmd *cmd) { int ret; @@ -126,21 +126,21 @@ iwl_legacy_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd) /* Assign a generic callback if one is not provided */ if (!cmd->callback) - cmd->callback = iwl_legacy_generic_cmd_callback; + cmd->callback = il_generic_cmd_callback; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EBUSY; - ret = iwl_legacy_enqueue_hcmd(priv, cmd); + ret = il_enqueue_hcmd(priv, cmd); if (ret < 0) { - IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", - iwl_legacy_get_cmd_string(cmd->id), ret); + IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); return ret; } return 0; } -int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +int il_send_cmd_sync(struct il_priv *priv, struct il_host_cmd *cmd) { int cmd_idx; int ret; @@ -152,18 +152,18 @@ int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); - IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", + il_get_cmd_string(cmd->id)); set_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); - cmd_idx = iwl_legacy_enqueue_hcmd(priv, cmd); + cmd_idx = il_enqueue_hcmd(priv, cmd); if (cmd_idx < 0) { ret = cmd_idx; - IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", - iwl_legacy_get_cmd_string(cmd->id), ret); + IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); goto out; } @@ -172,35 +172,35 @@ int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) HOST_COMPLETE_TIMEOUT); if (!ret) { if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) { - IWL_ERR(priv, + IL_ERR(priv, "Error sending %s: time out after %dms.\n", - iwl_legacy_get_cmd_string(cmd->id), + il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", - iwl_legacy_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; goto cancel; } } if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { - IWL_ERR(priv, "Command %s aborted: RF KILL Switch\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_ERR(priv, "Command %s aborted: RF KILL Switch\n", + il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } if (test_bit(STATUS_FW_ERROR, &priv->status)) { - IWL_ERR(priv, "Command %s failed: FW Error\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_ERR(priv, "Command %s failed: FW Error\n", + il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IWL_ERR(priv, "Error: Response NULL in '%s'\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_ERR(priv, "Error: Response NULL in '%s'\n", + il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; } @@ -221,43 +221,43 @@ cancel: } fail: if (cmd->reply_page) { - iwl_legacy_free_pages(priv, cmd->reply_page); + il_free_pages(priv, cmd->reply_page); cmd->reply_page = 0; } out: return ret; } -EXPORT_SYMBOL(iwl_legacy_send_cmd_sync); +EXPORT_SYMBOL(il_send_cmd_sync); -int iwl_legacy_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd) { if (cmd->flags & CMD_ASYNC) - return iwl_legacy_send_cmd_async(priv, cmd); + return il_send_cmd_async(priv, cmd); - return iwl_legacy_send_cmd_sync(priv, cmd); + return il_send_cmd_sync(priv, cmd); } -EXPORT_SYMBOL(iwl_legacy_send_cmd); +EXPORT_SYMBOL(il_send_cmd); int -iwl_legacy_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len, const void *data) +il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = id, .len = len, .data = data, }; - return iwl_legacy_send_cmd_sync(priv, &cmd); + return il_send_cmd_sync(priv, &cmd); } -EXPORT_SYMBOL(iwl_legacy_send_cmd_pdu); +EXPORT_SYMBOL(il_send_cmd_pdu); -int iwl_legacy_send_cmd_pdu_async(struct iwl_priv *priv, +int il_send_cmd_pdu_async(struct il_priv *priv, u8 id, u16 len, const void *data, - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt)) + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt)) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = id, .len = len, .data = data, @@ -266,6 +266,6 @@ int iwl_legacy_send_cmd_pdu_async(struct iwl_priv *priv, cmd.flags |= CMD_ASYNC; cmd.callback = callback; - return iwl_legacy_send_cmd_async(priv, &cmd); + return il_send_cmd_async(priv, &cmd); } -EXPORT_SYMBOL(iwl_legacy_send_cmd_pdu_async); +EXPORT_SYMBOL(il_send_cmd_pdu_async); diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index 5cf23ea..e4e63b5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -27,45 +27,45 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_helpers_h__ -#define __iwl_legacy_helpers_h__ +#ifndef __il_helpers_h__ +#define __il_helpers_h__ #include #include #include "iwl-io.h" -#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) +#define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -static inline struct ieee80211_conf *iwl_legacy_ieee80211_get_hw_conf( +static inline struct ieee80211_conf *il_ieee80211_get_hw_conf( struct ieee80211_hw *hw) { return &hw->conf; } /** - * iwl_legacy_queue_inc_wrap - increment queue index, wrap back to beginning + * il_queue_inc_wrap - increment queue index, wrap back to beginning * @index -- current index * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int iwl_legacy_queue_inc_wrap(int index, int n_bd) +static inline int il_queue_inc_wrap(int index, int n_bd) { return ++index & (n_bd - 1); } /** - * iwl_legacy_queue_dec_wrap - decrement queue index, wrap back to end + * il_queue_dec_wrap - decrement queue index, wrap back to end * @index -- current index * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int iwl_legacy_queue_dec_wrap(int index, int n_bd) +static inline int il_queue_dec_wrap(int index, int n_bd) { return --index & (n_bd - 1); } /* TODO: Move fw_desc functions to iwl-pci.ko */ -static inline void iwl_legacy_free_fw_desc(struct pci_dev *pci_dev, +static inline void il_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (desc->v_addr) @@ -75,7 +75,7 @@ static inline void iwl_legacy_free_fw_desc(struct pci_dev *pci_dev, desc->len = 0; } -static inline int iwl_legacy_alloc_fw_desc(struct pci_dev *pci_dev, +static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (!desc->len) { @@ -100,7 +100,7 @@ static inline int iwl_legacy_alloc_fw_desc(struct pci_dev *pci_dev, * +---------------------- unused */ static inline void -iwl_legacy_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) +il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) { BUG_ON(ac > 3); /* only have 2 bits */ BUG_ON(hwq > 31); /* only use 5 bits */ @@ -108,8 +108,8 @@ iwl_legacy_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) txq->swq_id = (hwq << 2) | ac; } -static inline void iwl_legacy_wake_queue(struct iwl_priv *priv, - struct iwl_tx_queue *txq) +static inline void il_wake_queue(struct il_priv *priv, + struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -120,8 +120,8 @@ static inline void iwl_legacy_wake_queue(struct iwl_priv *priv, ieee80211_wake_queue(priv->hw, ac); } -static inline void iwl_legacy_stop_queue(struct iwl_priv *priv, - struct iwl_tx_queue *txq) +static inline void il_stop_queue(struct il_priv *priv, + struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -144,53 +144,53 @@ static inline void iwl_legacy_stop_queue(struct iwl_priv *priv, #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue -static inline void iwl_legacy_disable_interrupts(struct iwl_priv *priv) +static inline void il_disable_interrupts(struct il_priv *priv) { clear_bit(STATUS_INT_ENABLED, &priv->status); /* disable interrupts from uCode/NIC to host */ - iwl_write32(priv, CSR_INT_MASK, 0x00000000); + il_write32(priv, CSR_INT_MASK, 0x00000000); /* acknowledge/clear/reset any interrupts still pending * from uCode or flow handler (Rx/Tx DMA) */ - iwl_write32(priv, CSR_INT, 0xffffffff); - iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); - IWL_DEBUG_ISR(priv, "Disabled interrupts\n"); + il_write32(priv, CSR_INT, 0xffffffff); + il_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); + IL_DEBUG_ISR(priv, "Disabled interrupts\n"); } -static inline void iwl_legacy_enable_rfkill_int(struct iwl_priv *priv) +static inline void il_enable_rfkill_int(struct il_priv *priv) { - IWL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); - iwl_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + IL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); + il_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } -static inline void iwl_legacy_enable_interrupts(struct iwl_priv *priv) +static inline void il_enable_interrupts(struct il_priv *priv) { - IWL_DEBUG_ISR(priv, "Enabling interrupts\n"); + IL_DEBUG_ISR(priv, "Enabling interrupts\n"); set_bit(STATUS_INT_ENABLED, &priv->status); - iwl_write32(priv, CSR_INT_MASK, priv->inta_mask); + il_write32(priv, CSR_INT_MASK, priv->inta_mask); } /** - * iwl_legacy_beacon_time_mask_low - mask of lower 32 bit of beacon time - * @priv -- pointer to iwl_priv data structure + * il_beacon_time_mask_low - mask of lower 32 bit of beacon time + * @priv -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 iwl_legacy_beacon_time_mask_low(struct iwl_priv *priv, +static inline u32 il_beacon_time_mask_low(struct il_priv *priv, u16 tsf_bits) { return (1 << tsf_bits) - 1; } /** - * iwl_legacy_beacon_time_mask_high - mask of higher 32 bit of beacon time - * @priv -- pointer to iwl_priv data structure + * il_beacon_time_mask_high - mask of higher 32 bit of beacon time + * @priv -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 iwl_legacy_beacon_time_mask_high(struct iwl_priv *priv, +static inline u32 il_beacon_time_mask_high(struct il_priv *priv, u16 tsf_bits) { return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; } -#endif /* __iwl_legacy_helpers_h__ */ +#endif /* __il_helpers_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 868ef01..ebeb6e2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -26,8 +26,8 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_io_h__ -#define __iwl_legacy_io_h__ +#ifndef __il_io_h__ +#define __il_io_h__ #include @@ -52,8 +52,8 @@ * * If you wish to call the function without any debug or state checking, * you should use the single _ prefix version (as is used by dependent IO - * routines, for example _iwl_legacy_read_direct32 calls the non-check version of - * _iwl_legacy_read32.) + * routines, for example _il_read_direct32 calls the non-check version of + * _il_read32.) * * These declarations are *extremely* useful in quickly isolating code deltas * which result in misconfiguration of the hardware I/O. In combination with @@ -62,46 +62,46 @@ * */ -static inline void _iwl_legacy_write8(struct iwl_priv *priv, u32 ofs, u8 val) +static inline void _il_write8(struct il_priv *priv, u32 ofs, u8 val) { iowrite8(val, priv->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__iwl_legacy_write8(const char *f, u32 l, struct iwl_priv *priv, +__il_write8(const char *f, u32 l, struct il_priv *priv, u32 ofs, u8 val) { - IWL_DEBUG_IO(priv, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); - _iwl_legacy_write8(priv, ofs, val); + IL_DEBUG_IO(priv, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); + _il_write8(priv, ofs, val); } -#define iwl_write8(priv, ofs, val) \ - __iwl_legacy_write8(__FILE__, __LINE__, priv, ofs, val) +#define il_write8(priv, ofs, val) \ + __il_write8(__FILE__, __LINE__, priv, ofs, val) #else -#define iwl_write8(priv, ofs, val) _iwl_legacy_write8(priv, ofs, val) +#define il_write8(priv, ofs, val) _il_write8(priv, ofs, val) #endif -static inline void _iwl_legacy_write32(struct iwl_priv *priv, u32 ofs, u32 val) +static inline void _il_write32(struct il_priv *priv, u32 ofs, u32 val) { iowrite32(val, priv->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__iwl_legacy_write32(const char *f, u32 l, struct iwl_priv *priv, +__il_write32(const char *f, u32 l, struct il_priv *priv, u32 ofs, u32 val) { - IWL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); - _iwl_legacy_write32(priv, ofs, val); + IL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); + _il_write32(priv, ofs, val); } -#define iwl_write32(priv, ofs, val) \ - __iwl_legacy_write32(__FILE__, __LINE__, priv, ofs, val) +#define il_write32(priv, ofs, val) \ + __il_write32(__FILE__, __LINE__, priv, ofs, val) #else -#define iwl_write32(priv, ofs, val) _iwl_legacy_write32(priv, ofs, val) +#define il_write32(priv, ofs, val) _il_write32(priv, ofs, val) #endif -static inline u32 _iwl_legacy_read32(struct iwl_priv *priv, u32 ofs) +static inline u32 _il_read32(struct il_priv *priv, u32 ofs) { u32 val = ioread32(priv->hw_base + ofs); return val; @@ -109,122 +109,122 @@ static inline u32 _iwl_legacy_read32(struct iwl_priv *priv, u32 ofs) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline u32 -__iwl_legacy_read32(char *f, u32 l, struct iwl_priv *priv, u32 ofs) +__il_read32(char *f, u32 l, struct il_priv *priv, u32 ofs) { - IWL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); - return _iwl_legacy_read32(priv, ofs); + IL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); + return _il_read32(priv, ofs); } -#define iwl_read32(priv, ofs) __iwl_legacy_read32(__FILE__, __LINE__, priv, ofs) +#define il_read32(priv, ofs) __il_read32(__FILE__, __LINE__, priv, ofs) #else -#define iwl_read32(p, o) _iwl_legacy_read32(p, o) +#define il_read32(p, o) _il_read32(p, o) #endif -#define IWL_POLL_INTERVAL 10 /* microseconds */ +#define IL_POLL_INTERVAL 10 /* microseconds */ static inline int -_iwl_legacy_poll_bit(struct iwl_priv *priv, u32 addr, +_il_poll_bit(struct il_priv *priv, u32 addr, u32 bits, u32 mask, int timeout) { int t = 0; do { - if ((_iwl_legacy_read32(priv, addr) & mask) == (bits & mask)) + if ((_il_read32(priv, addr) & mask) == (bits & mask)) return t; - udelay(IWL_POLL_INTERVAL); - t += IWL_POLL_INTERVAL; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; } while (t < timeout); return -ETIMEDOUT; } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __iwl_legacy_poll_bit(const char *f, u32 l, - struct iwl_priv *priv, u32 addr, +static inline int __il_poll_bit(const char *f, u32 l, + struct il_priv *priv, u32 addr, u32 bits, u32 mask, int timeout) { - int ret = _iwl_legacy_poll_bit(priv, addr, bits, mask, timeout); - IWL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", + int ret = _il_poll_bit(priv, addr, bits, mask, timeout); + IL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", addr, bits, mask, unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l); return ret; } -#define iwl_poll_bit(priv, addr, bits, mask, timeout) \ - __iwl_legacy_poll_bit(__FILE__, __LINE__, priv, addr, \ +#define il_poll_bit(priv, addr, bits, mask, timeout) \ + __il_poll_bit(__FILE__, __LINE__, priv, addr, \ bits, mask, timeout) #else -#define iwl_poll_bit(p, a, b, m, t) _iwl_legacy_poll_bit(p, a, b, m, t) +#define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) #endif -static inline void _iwl_legacy_set_bit(struct iwl_priv *priv, u32 reg, u32 mask) +static inline void _il_set_bit(struct il_priv *priv, u32 reg, u32 mask) { - _iwl_legacy_write32(priv, reg, _iwl_legacy_read32(priv, reg) | mask); + _il_write32(priv, reg, _il_read32(priv, reg) | mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __iwl_legacy_set_bit(const char *f, u32 l, - struct iwl_priv *priv, u32 reg, u32 mask) +static inline void __il_set_bit(const char *f, u32 l, + struct il_priv *priv, u32 reg, u32 mask) { - u32 val = _iwl_legacy_read32(priv, reg) | mask; - IWL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, + u32 val = _il_read32(priv, reg) | mask; + IL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _iwl_legacy_write32(priv, reg, val); + _il_write32(priv, reg, val); } -static inline void iwl_legacy_set_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - __iwl_legacy_set_bit(__FILE__, __LINE__, p, r, m); + __il_set_bit(__FILE__, __LINE__, p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #else -static inline void iwl_legacy_set_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - _iwl_legacy_set_bit(p, r, m); + _il_set_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #endif static inline void -_iwl_legacy_clear_bit(struct iwl_priv *priv, u32 reg, u32 mask) +_il_clear_bit(struct il_priv *priv, u32 reg, u32 mask) { - _iwl_legacy_write32(priv, reg, _iwl_legacy_read32(priv, reg) & ~mask); + _il_write32(priv, reg, _il_read32(priv, reg) & ~mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__iwl_legacy_clear_bit(const char *f, u32 l, - struct iwl_priv *priv, u32 reg, u32 mask) +__il_clear_bit(const char *f, u32 l, + struct il_priv *priv, u32 reg, u32 mask) { - u32 val = _iwl_legacy_read32(priv, reg) & ~mask; - IWL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _iwl_legacy_write32(priv, reg, val); + u32 val = _il_read32(priv, reg) & ~mask; + IL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); + _il_write32(priv, reg, val); } -static inline void iwl_legacy_clear_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - __iwl_legacy_clear_bit(__FILE__, __LINE__, p, r, m); + __il_clear_bit(__FILE__, __LINE__, p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #else -static inline void iwl_legacy_clear_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - _iwl_legacy_clear_bit(p, r, m); + _il_clear_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #endif -static inline int _iwl_legacy_grab_nic_access(struct iwl_priv *priv) +static inline int _il_grab_nic_access(struct il_priv *priv) { int ret; u32 val; /* this bit wakes up the NIC */ - _iwl_legacy_set_bit(priv, CSR_GP_CNTRL, + _il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* @@ -244,15 +244,15 @@ static inline int _iwl_legacy_grab_nic_access(struct iwl_priv *priv) * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). * */ - ret = _iwl_legacy_poll_bit(priv, CSR_GP_CNTRL, + ret = _il_poll_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { - val = _iwl_legacy_read32(priv, CSR_GP_CNTRL); - IWL_ERR(priv, + val = _il_read32(priv, CSR_GP_CNTRL); + IL_ERR(priv, "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _iwl_legacy_write32(priv, CSR_RESET, + _il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } @@ -261,280 +261,280 @@ static inline int _iwl_legacy_grab_nic_access(struct iwl_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __iwl_legacy_grab_nic_access(const char *f, u32 l, - struct iwl_priv *priv) +static inline int __il_grab_nic_access(const char *f, u32 l, + struct il_priv *priv) { - IWL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l); - return _iwl_legacy_grab_nic_access(priv); + IL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l); + return _il_grab_nic_access(priv); } -#define iwl_grab_nic_access(priv) \ - __iwl_legacy_grab_nic_access(__FILE__, __LINE__, priv) +#define il_grab_nic_access(priv) \ + __il_grab_nic_access(__FILE__, __LINE__, priv) #else -#define iwl_grab_nic_access(priv) \ - _iwl_legacy_grab_nic_access(priv) +#define il_grab_nic_access(priv) \ + _il_grab_nic_access(priv) #endif -static inline void _iwl_legacy_release_nic_access(struct iwl_priv *priv) +static inline void _il_release_nic_access(struct il_priv *priv) { - _iwl_legacy_clear_bit(priv, CSR_GP_CNTRL, + _il_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __iwl_legacy_release_nic_access(const char *f, u32 l, - struct iwl_priv *priv) +static inline void __il_release_nic_access(const char *f, u32 l, + struct il_priv *priv) { - IWL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l); - _iwl_legacy_release_nic_access(priv); + IL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l); + _il_release_nic_access(priv); } -#define iwl_release_nic_access(priv) \ - __iwl_legacy_release_nic_access(__FILE__, __LINE__, priv) +#define il_release_nic_access(priv) \ + __il_release_nic_access(__FILE__, __LINE__, priv) #else -#define iwl_release_nic_access(priv) \ - _iwl_legacy_release_nic_access(priv) +#define il_release_nic_access(priv) \ + _il_release_nic_access(priv) #endif -static inline u32 _iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg) +static inline u32 _il_read_direct32(struct il_priv *priv, u32 reg) { - return _iwl_legacy_read32(priv, reg); + return _il_read32(priv, reg); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline u32 __iwl_legacy_read_direct32(const char *f, u32 l, - struct iwl_priv *priv, u32 reg) +static inline u32 __il_read_direct32(const char *f, u32 l, + struct il_priv *priv, u32 reg) { - u32 value = _iwl_legacy_read_direct32(priv, reg); - IWL_DEBUG_IO(priv, + u32 value = _il_read_direct32(priv, reg); + IL_DEBUG_IO(priv, "read_direct32(0x%4X) = 0x%08x - %s %d\n", reg, value, f, l); return value; } -static inline u32 iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) { u32 value; unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - value = __iwl_legacy_read_direct32(__FILE__, __LINE__, priv, reg); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + value = __il_read_direct32(__FILE__, __LINE__, priv, reg); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return value; } #else -static inline u32 iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) { u32 value; unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - value = _iwl_legacy_read_direct32(priv, reg); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + value = _il_read_direct32(priv, reg); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return value; } #endif -static inline void _iwl_legacy_write_direct32(struct iwl_priv *priv, +static inline void _il_write_direct32(struct il_priv *priv, u32 reg, u32 value) { - _iwl_legacy_write32(priv, reg, value); + _il_write32(priv, reg, value); } static inline void -iwl_legacy_write_direct32(struct iwl_priv *priv, u32 reg, u32 value) +il_write_direct32(struct il_priv *priv, u32 reg, u32 value) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_direct32(priv, reg, value); - iwl_release_nic_access(priv); + if (!il_grab_nic_access(priv)) { + _il_write_direct32(priv, reg, value); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -static inline void iwl_legacy_write_reg_buf(struct iwl_priv *priv, +static inline void il_write_reg_buf(struct il_priv *priv, u32 reg, u32 len, u32 *values) { u32 count = sizeof(u32); if ((priv != NULL) && (values != NULL)) { for (; 0 < len; len -= count, reg += count, values++) - iwl_legacy_write_direct32(priv, reg, *values); + il_write_direct32(priv, reg, *values); } } -static inline int _iwl_legacy_poll_direct_bit(struct iwl_priv *priv, u32 addr, +static inline int _il_poll_direct_bit(struct il_priv *priv, u32 addr, u32 mask, int timeout) { int t = 0; do { - if ((iwl_legacy_read_direct32(priv, addr) & mask) == mask) + if ((il_read_direct32(priv, addr) & mask) == mask) return t; - udelay(IWL_POLL_INTERVAL); - t += IWL_POLL_INTERVAL; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; } while (t < timeout); return -ETIMEDOUT; } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __iwl_legacy_poll_direct_bit(const char *f, u32 l, - struct iwl_priv *priv, +static inline int __il_poll_direct_bit(const char *f, u32 l, + struct il_priv *priv, u32 addr, u32 mask, int timeout) { - int ret = _iwl_legacy_poll_direct_bit(priv, addr, mask, timeout); + int ret = _il_poll_direct_bit(priv, addr, mask, timeout); if (unlikely(ret == -ETIMEDOUT)) - IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - " + IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - " "timedout - %s %d\n", addr, mask, f, l); else - IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " + IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " "- %s %d\n", addr, mask, ret, f, l); return ret; } -#define iwl_poll_direct_bit(priv, addr, mask, timeout) \ -__iwl_legacy_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout) +#define il_poll_direct_bit(priv, addr, mask, timeout) \ +__il_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout) #else -#define iwl_poll_direct_bit _iwl_legacy_poll_direct_bit +#define il_poll_direct_bit _il_poll_direct_bit #endif -static inline u32 _iwl_legacy_read_prph(struct iwl_priv *priv, u32 reg) +static inline u32 _il_read_prph(struct il_priv *priv, u32 reg) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + _il_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); - return _iwl_legacy_read_direct32(priv, HBUS_TARG_PRPH_RDAT); + return _il_read_direct32(priv, HBUS_TARG_PRPH_RDAT); } -static inline u32 iwl_legacy_read_prph(struct iwl_priv *priv, u32 reg) +static inline u32 il_read_prph(struct il_priv *priv, u32 reg) { unsigned long reg_flags; u32 val; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - val = _iwl_legacy_read_prph(priv, reg); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + val = _il_read_prph(priv, reg); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return val; } -static inline void _iwl_legacy_write_prph(struct iwl_priv *priv, +static inline void _il_write_prph(struct il_priv *priv, u32 addr, u32 val) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_WADDR, + _il_write_direct32(priv, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); - _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val); + _il_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val); } static inline void -iwl_legacy_write_prph(struct iwl_priv *priv, u32 addr, u32 val) +il_write_prph(struct il_priv *priv, u32 addr, u32 val) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_prph(priv, addr, val); - iwl_release_nic_access(priv); + if (!il_grab_nic_access(priv)) { + _il_write_prph(priv, addr, val); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -#define _iwl_legacy_set_bits_prph(priv, reg, mask) \ -_iwl_legacy_write_prph(priv, reg, (_iwl_legacy_read_prph(priv, reg) | mask)) +#define _il_set_bits_prph(priv, reg, mask) \ +_il_write_prph(priv, reg, (_il_read_prph(priv, reg) | mask)) static inline void -iwl_legacy_set_bits_prph(struct iwl_priv *priv, u32 reg, u32 mask) +il_set_bits_prph(struct il_priv *priv, u32 reg, u32 mask) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - _iwl_legacy_set_bits_prph(priv, reg, mask); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + _il_set_bits_prph(priv, reg, mask); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -#define _iwl_legacy_set_bits_mask_prph(priv, reg, bits, mask) \ -_iwl_legacy_write_prph(priv, reg, \ - ((_iwl_legacy_read_prph(priv, reg) & mask) | bits)) +#define _il_set_bits_mask_prph(priv, reg, bits, mask) \ +_il_write_prph(priv, reg, \ + ((_il_read_prph(priv, reg) & mask) | bits)) -static inline void iwl_legacy_set_bits_mask_prph(struct iwl_priv *priv, u32 reg, +static inline void il_set_bits_mask_prph(struct il_priv *priv, u32 reg, u32 bits, u32 mask) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - _iwl_legacy_set_bits_mask_prph(priv, reg, bits, mask); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + _il_set_bits_mask_prph(priv, reg, bits, mask); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -static inline void iwl_legacy_clear_bits_prph(struct iwl_priv +static inline void il_clear_bits_prph(struct il_priv *priv, u32 reg, u32 mask) { unsigned long reg_flags; u32 val; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - val = _iwl_legacy_read_prph(priv, reg); - _iwl_legacy_write_prph(priv, reg, (val & ~mask)); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + val = _il_read_prph(priv, reg); + _il_write_prph(priv, reg, (val & ~mask)); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -static inline u32 iwl_legacy_read_targ_mem(struct iwl_priv *priv, u32 addr) +static inline u32 il_read_targ_mem(struct il_priv *priv, u32 addr) { unsigned long reg_flags; u32 value; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); + il_grab_nic_access(priv); - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr); + _il_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr); rmb(); - value = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + value = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); - iwl_release_nic_access(priv); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return value; } static inline void -iwl_legacy_write_targ_mem(struct iwl_priv *priv, u32 addr, u32 val) +il_write_targ_mem(struct il_priv *priv, u32 addr, u32 val) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + if (!il_grab_nic_access(priv)) { + _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); wmb(); - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WDAT, val); - iwl_release_nic_access(priv); + _il_write_direct32(priv, HBUS_TARG_MEM_WDAT, val); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } static inline void -iwl_legacy_write_targ_mem_buf(struct iwl_priv *priv, u32 addr, +il_write_targ_mem_buf(struct il_priv *priv, u32 addr, u32 len, u32 *values) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + if (!il_grab_nic_access(priv)) { + _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _iwl_legacy_write_direct32(priv, + _il_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values); - iwl_release_nic_access(priv); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index dc568a4..490b183 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -41,7 +41,7 @@ #include "iwl-core.h" #include "iwl-io.h" -/* default: IWL_LED_BLINK(0) using blinking index table */ +/* default: IL_LED_BLINK(0) using blinking index table */ static int led_mode; module_param(led_mode, int, S_IRUGO); MODULE_PARM_DESC(led_mode, "0=system default, " @@ -60,7 +60,7 @@ MODULE_PARM_DESC(led_mode, "0=system default, " * >0 to 1 167 167 * <=0 SOLID ON */ -static const struct ieee80211_tpt_blink iwl_blink[] = { +static const struct ieee80211_tpt_blink il_blink[] = { { .throughput = 0, .blink_time = 334 }, { .throughput = 1 * 1024 - 1, .blink_time = 260 }, { .throughput = 5 * 1024 - 1, .blink_time = 220 }, @@ -84,11 +84,11 @@ static const struct ieee80211_tpt_blink iwl_blink[] = { * compensation = (100 - averageDeviation) * 64 / 100 * NewBlinkTime = (compensation * BlinkTime) / 64 */ -static inline u8 iwl_legacy_blink_compensation(struct iwl_priv *priv, +static inline u8 il_blink_compensation(struct il_priv *priv, u8 time, u16 compensation) { if (!compensation) { - IWL_ERR(priv, "undefined blink compensation: " + IL_ERR(priv, "undefined blink compensation: " "use pre-defined blinking time\n"); return time; } @@ -97,13 +97,13 @@ static inline u8 iwl_legacy_blink_compensation(struct iwl_priv *priv, } /* Set led pattern command */ -static int iwl_legacy_led_cmd(struct iwl_priv *priv, +static int il_led_cmd(struct il_priv *priv, unsigned long on, unsigned long off) { - struct iwl_led_cmd led_cmd = { - .id = IWL_LED_LINK, - .interval = IWL_DEF_LED_INTRVL + struct il_led_cmd led_cmd = { + .id = IL_LED_LINK, + .interval = IL_DEF_LED_INTRVL }; int ret; @@ -115,14 +115,14 @@ static int iwl_legacy_led_cmd(struct iwl_priv *priv, if (off == 0) { /* led is SOLID_ON */ - on = IWL_LED_SOLID; + on = IL_LED_SOLID; } - IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", + IL_DEBUG_LED(priv, "Led blink time compensation=%u\n", priv->cfg->base_params->led_compensation); - led_cmd.on = iwl_legacy_blink_compensation(priv, on, + led_cmd.on = il_blink_compensation(priv, on, priv->cfg->base_params->led_compensation); - led_cmd.off = iwl_legacy_blink_compensation(priv, off, + led_cmd.off = il_blink_compensation(priv, off, priv->cfg->base_params->led_compensation); ret = priv->cfg->ops->led->cmd(priv, &led_cmd); @@ -133,52 +133,52 @@ static int iwl_legacy_led_cmd(struct iwl_priv *priv, return ret; } -static void iwl_legacy_led_brightness_set(struct led_classdev *led_cdev, +static void il_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness) { - struct iwl_priv *priv = container_of(led_cdev, struct iwl_priv, led); + struct il_priv *priv = container_of(led_cdev, struct il_priv, led); unsigned long on = 0; if (brightness > 0) - on = IWL_LED_SOLID; + on = IL_LED_SOLID; - iwl_legacy_led_cmd(priv, on, 0); + il_led_cmd(priv, on, 0); } -static int iwl_legacy_led_blink_set(struct led_classdev *led_cdev, +static int il_led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - struct iwl_priv *priv = container_of(led_cdev, struct iwl_priv, led); + struct il_priv *priv = container_of(led_cdev, struct il_priv, led); - return iwl_legacy_led_cmd(priv, *delay_on, *delay_off); + return il_led_cmd(priv, *delay_on, *delay_off); } -void iwl_legacy_leds_init(struct iwl_priv *priv) +void il_leds_init(struct il_priv *priv) { int mode = led_mode; int ret; - if (mode == IWL_LED_DEFAULT) + if (mode == IL_LED_DEFAULT) mode = priv->cfg->led_mode; priv->led.name = kasprintf(GFP_KERNEL, "%s-led", wiphy_name(priv->hw->wiphy)); - priv->led.brightness_set = iwl_legacy_led_brightness_set; - priv->led.blink_set = iwl_legacy_led_blink_set; + priv->led.brightness_set = il_led_brightness_set; + priv->led.blink_set = il_led_blink_set; priv->led.max_brightness = 1; switch (mode) { - case IWL_LED_DEFAULT: + case IL_LED_DEFAULT: WARN_ON(1); break; - case IWL_LED_BLINK: + case IL_LED_BLINK: priv->led.default_trigger = ieee80211_create_tpt_led_trigger(priv->hw, IEEE80211_TPT_LEDTRIG_FL_CONNECTED, - iwl_blink, ARRAY_SIZE(iwl_blink)); + il_blink, ARRAY_SIZE(il_blink)); break; - case IWL_LED_RF_STATE: + case IL_LED_RF_STATE: priv->led.default_trigger = ieee80211_get_radio_led_name(priv->hw); break; @@ -192,9 +192,9 @@ void iwl_legacy_leds_init(struct iwl_priv *priv) priv->led_registered = true; } -EXPORT_SYMBOL(iwl_legacy_leds_init); +EXPORT_SYMBOL(il_leds_init); -void iwl_legacy_leds_exit(struct iwl_priv *priv) +void il_leds_exit(struct il_priv *priv) { if (!priv->led_registered) return; @@ -202,4 +202,4 @@ void iwl_legacy_leds_exit(struct iwl_priv *priv) led_classdev_unregister(&priv->led); kfree(priv->led.name); } -EXPORT_SYMBOL(iwl_legacy_leds_exit); +EXPORT_SYMBOL(il_leds_exit); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.h b/drivers/net/wireless/iwlegacy/iwl-led.h index f0791f7..ea7a8ea 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-led.h @@ -24,33 +24,33 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_leds_h__ -#define __iwl_legacy_leds_h__ +#ifndef __il_leds_h__ +#define __il_leds_h__ -struct iwl_priv; +struct il_priv; -#define IWL_LED_SOLID 11 -#define IWL_DEF_LED_INTRVL cpu_to_le32(1000) +#define IL_LED_SOLID 11 +#define IL_DEF_LED_INTRVL cpu_to_le32(1000) -#define IWL_LED_ACTIVITY (0<<1) -#define IWL_LED_LINK (1<<1) +#define IL_LED_ACTIVITY (0<<1) +#define IL_LED_LINK (1<<1) /* * LED mode - * IWL_LED_DEFAULT: use device default - * IWL_LED_RF_STATE: turn LED on/off based on RF state + * IL_LED_DEFAULT: use device default + * IL_LED_RF_STATE: turn LED on/off based on RF state * LED ON = RF ON * LED OFF = RF OFF - * IWL_LED_BLINK: adjust led blink rate based on blink table + * IL_LED_BLINK: adjust led blink rate based on blink table */ -enum iwl_led_mode { - IWL_LED_DEFAULT, - IWL_LED_RF_STATE, - IWL_LED_BLINK, +enum il_led_mode { + IL_LED_DEFAULT, + IL_LED_RF_STATE, + IL_LED_BLINK, }; -void iwl_legacy_leds_init(struct iwl_priv *priv); -void iwl_legacy_leds_exit(struct iwl_priv *priv); +void il_leds_init(struct il_priv *priv); +void il_leds_exit(struct il_priv *priv); -#endif /* __iwl_legacy_leds_h__ */ +#endif /* __il_leds_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 38647e4..72ef91e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -24,14 +24,14 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_rs_h__ -#define __iwl_legacy_rs_h__ - -struct iwl_rate_info { - u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ +#ifndef __il_rs_h__ +#define __il_rs_h__ + +struct il_rate_info { + u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: IL_RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: IL_RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -40,9 +40,9 @@ struct iwl_rate_info { u8 next_rs_tgg; /* next rate used in TGG rs algo */ }; -struct iwl3945_rate_info { - u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ +struct il3945_rate_info { + u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ + u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -56,210 +56,210 @@ struct iwl3945_rate_info { /* * These serve as indexes into - * struct iwl_rate_info iwlegacy_rates[IWL_RATE_COUNT]; + * struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; */ enum { - IWL_RATE_1M_INDEX = 0, - IWL_RATE_2M_INDEX, - IWL_RATE_5M_INDEX, - IWL_RATE_11M_INDEX, - IWL_RATE_6M_INDEX, - IWL_RATE_9M_INDEX, - IWL_RATE_12M_INDEX, - IWL_RATE_18M_INDEX, - IWL_RATE_24M_INDEX, - IWL_RATE_36M_INDEX, - IWL_RATE_48M_INDEX, - IWL_RATE_54M_INDEX, - IWL_RATE_60M_INDEX, - IWL_RATE_COUNT, - IWL_RATE_COUNT_LEGACY = IWL_RATE_COUNT - 1, /* Excluding 60M */ - IWL_RATE_COUNT_3945 = IWL_RATE_COUNT - 1, - IWL_RATE_INVM_INDEX = IWL_RATE_COUNT, - IWL_RATE_INVALID = IWL_RATE_COUNT, + IL_RATE_1M_INDEX = 0, + IL_RATE_2M_INDEX, + IL_RATE_5M_INDEX, + IL_RATE_11M_INDEX, + IL_RATE_6M_INDEX, + IL_RATE_9M_INDEX, + IL_RATE_12M_INDEX, + IL_RATE_18M_INDEX, + IL_RATE_24M_INDEX, + IL_RATE_36M_INDEX, + IL_RATE_48M_INDEX, + IL_RATE_54M_INDEX, + IL_RATE_60M_INDEX, + IL_RATE_COUNT, + IL_RATE_COUNT_LEGACY = IL_RATE_COUNT - 1, /* Excluding 60M */ + IL_RATE_COUNT_3945 = IL_RATE_COUNT - 1, + IL_RATE_INVM_INDEX = IL_RATE_COUNT, + IL_RATE_INVALID = IL_RATE_COUNT, }; enum { - IWL_RATE_6M_INDEX_TABLE = 0, - IWL_RATE_9M_INDEX_TABLE, - IWL_RATE_12M_INDEX_TABLE, - IWL_RATE_18M_INDEX_TABLE, - IWL_RATE_24M_INDEX_TABLE, - IWL_RATE_36M_INDEX_TABLE, - IWL_RATE_48M_INDEX_TABLE, - IWL_RATE_54M_INDEX_TABLE, - IWL_RATE_1M_INDEX_TABLE, - IWL_RATE_2M_INDEX_TABLE, - IWL_RATE_5M_INDEX_TABLE, - IWL_RATE_11M_INDEX_TABLE, - IWL_RATE_INVM_INDEX_TABLE = IWL_RATE_INVM_INDEX - 1, + IL_RATE_6M_INDEX_TABLE = 0, + IL_RATE_9M_INDEX_TABLE, + IL_RATE_12M_INDEX_TABLE, + IL_RATE_18M_INDEX_TABLE, + IL_RATE_24M_INDEX_TABLE, + IL_RATE_36M_INDEX_TABLE, + IL_RATE_48M_INDEX_TABLE, + IL_RATE_54M_INDEX_TABLE, + IL_RATE_1M_INDEX_TABLE, + IL_RATE_2M_INDEX_TABLE, + IL_RATE_5M_INDEX_TABLE, + IL_RATE_11M_INDEX_TABLE, + IL_RATE_INVM_INDEX_TABLE = IL_RATE_INVM_INDEX - 1, }; enum { - IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX, - IWL39_LAST_OFDM_RATE = IWL_RATE_54M_INDEX, - IWL_LAST_OFDM_RATE = IWL_RATE_60M_INDEX, - IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX, - IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX, + IL_FIRST_OFDM_RATE = IL_RATE_6M_INDEX, + IWL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, + IL_LAST_OFDM_RATE = IL_RATE_60M_INDEX, + IL_FIRST_CCK_RATE = IL_RATE_1M_INDEX, + IL_LAST_CCK_RATE = IL_RATE_11M_INDEX, }; /* #define vs. enum to keep from defaulting to 'large integer' */ -#define IWL_RATE_6M_MASK (1 << IWL_RATE_6M_INDEX) -#define IWL_RATE_9M_MASK (1 << IWL_RATE_9M_INDEX) -#define IWL_RATE_12M_MASK (1 << IWL_RATE_12M_INDEX) -#define IWL_RATE_18M_MASK (1 << IWL_RATE_18M_INDEX) -#define IWL_RATE_24M_MASK (1 << IWL_RATE_24M_INDEX) -#define IWL_RATE_36M_MASK (1 << IWL_RATE_36M_INDEX) -#define IWL_RATE_48M_MASK (1 << IWL_RATE_48M_INDEX) -#define IWL_RATE_54M_MASK (1 << IWL_RATE_54M_INDEX) -#define IWL_RATE_60M_MASK (1 << IWL_RATE_60M_INDEX) -#define IWL_RATE_1M_MASK (1 << IWL_RATE_1M_INDEX) -#define IWL_RATE_2M_MASK (1 << IWL_RATE_2M_INDEX) -#define IWL_RATE_5M_MASK (1 << IWL_RATE_5M_INDEX) -#define IWL_RATE_11M_MASK (1 << IWL_RATE_11M_INDEX) +#define IL_RATE_6M_MASK (1 << IL_RATE_6M_INDEX) +#define IL_RATE_9M_MASK (1 << IL_RATE_9M_INDEX) +#define IL_RATE_12M_MASK (1 << IL_RATE_12M_INDEX) +#define IL_RATE_18M_MASK (1 << IL_RATE_18M_INDEX) +#define IL_RATE_24M_MASK (1 << IL_RATE_24M_INDEX) +#define IL_RATE_36M_MASK (1 << IL_RATE_36M_INDEX) +#define IL_RATE_48M_MASK (1 << IL_RATE_48M_INDEX) +#define IL_RATE_54M_MASK (1 << IL_RATE_54M_INDEX) +#define IL_RATE_60M_MASK (1 << IL_RATE_60M_INDEX) +#define IL_RATE_1M_MASK (1 << IL_RATE_1M_INDEX) +#define IL_RATE_2M_MASK (1 << IL_RATE_2M_INDEX) +#define IL_RATE_5M_MASK (1 << IL_RATE_5M_INDEX) +#define IL_RATE_11M_MASK (1 << IL_RATE_11M_INDEX) /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { - IWL_RATE_6M_PLCP = 13, - IWL_RATE_9M_PLCP = 15, - IWL_RATE_12M_PLCP = 5, - IWL_RATE_18M_PLCP = 7, - IWL_RATE_24M_PLCP = 9, - IWL_RATE_36M_PLCP = 11, - IWL_RATE_48M_PLCP = 1, - IWL_RATE_54M_PLCP = 3, - IWL_RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - IWL_RATE_1M_PLCP = 10, - IWL_RATE_2M_PLCP = 20, - IWL_RATE_5M_PLCP = 55, - IWL_RATE_11M_PLCP = 110, - /*FIXME:RS:add IWL_RATE_LEGACY_INVM_PLCP = 0,*/ + IL_RATE_6M_PLCP = 13, + IL_RATE_9M_PLCP = 15, + IL_RATE_12M_PLCP = 5, + IL_RATE_18M_PLCP = 7, + IL_RATE_24M_PLCP = 9, + IL_RATE_36M_PLCP = 11, + IL_RATE_48M_PLCP = 1, + IL_RATE_54M_PLCP = 3, + IL_RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ + IL_RATE_1M_PLCP = 10, + IL_RATE_2M_PLCP = 20, + IL_RATE_5M_PLCP = 55, + IL_RATE_11M_PLCP = 110, + /*FIXME:RS:add IL_RATE_LEGACY_INVM_PLCP = 0,*/ }; /* uCode API values for OFDM high-throughput (HT) bit rates */ enum { - IWL_RATE_SISO_6M_PLCP = 0, - IWL_RATE_SISO_12M_PLCP = 1, - IWL_RATE_SISO_18M_PLCP = 2, - IWL_RATE_SISO_24M_PLCP = 3, - IWL_RATE_SISO_36M_PLCP = 4, - IWL_RATE_SISO_48M_PLCP = 5, - IWL_RATE_SISO_54M_PLCP = 6, - IWL_RATE_SISO_60M_PLCP = 7, - IWL_RATE_MIMO2_6M_PLCP = 0x8, - IWL_RATE_MIMO2_12M_PLCP = 0x9, - IWL_RATE_MIMO2_18M_PLCP = 0xa, - IWL_RATE_MIMO2_24M_PLCP = 0xb, - IWL_RATE_MIMO2_36M_PLCP = 0xc, - IWL_RATE_MIMO2_48M_PLCP = 0xd, - IWL_RATE_MIMO2_54M_PLCP = 0xe, - IWL_RATE_MIMO2_60M_PLCP = 0xf, - IWL_RATE_SISO_INVM_PLCP, - IWL_RATE_MIMO2_INVM_PLCP = IWL_RATE_SISO_INVM_PLCP, + IL_RATE_SISO_6M_PLCP = 0, + IL_RATE_SISO_12M_PLCP = 1, + IL_RATE_SISO_18M_PLCP = 2, + IL_RATE_SISO_24M_PLCP = 3, + IL_RATE_SISO_36M_PLCP = 4, + IL_RATE_SISO_48M_PLCP = 5, + IL_RATE_SISO_54M_PLCP = 6, + IL_RATE_SISO_60M_PLCP = 7, + IL_RATE_MIMO2_6M_PLCP = 0x8, + IL_RATE_MIMO2_12M_PLCP = 0x9, + IL_RATE_MIMO2_18M_PLCP = 0xa, + IL_RATE_MIMO2_24M_PLCP = 0xb, + IL_RATE_MIMO2_36M_PLCP = 0xc, + IL_RATE_MIMO2_48M_PLCP = 0xd, + IL_RATE_MIMO2_54M_PLCP = 0xe, + IL_RATE_MIMO2_60M_PLCP = 0xf, + IL_RATE_SISO_INVM_PLCP, + IL_RATE_MIMO2_INVM_PLCP = IL_RATE_SISO_INVM_PLCP, }; /* MAC header values for bit rates */ enum { - IWL_RATE_6M_IEEE = 12, - IWL_RATE_9M_IEEE = 18, - IWL_RATE_12M_IEEE = 24, - IWL_RATE_18M_IEEE = 36, - IWL_RATE_24M_IEEE = 48, - IWL_RATE_36M_IEEE = 72, - IWL_RATE_48M_IEEE = 96, - IWL_RATE_54M_IEEE = 108, - IWL_RATE_60M_IEEE = 120, - IWL_RATE_1M_IEEE = 2, - IWL_RATE_2M_IEEE = 4, - IWL_RATE_5M_IEEE = 11, - IWL_RATE_11M_IEEE = 22, + IL_RATE_6M_IEEE = 12, + IL_RATE_9M_IEEE = 18, + IL_RATE_12M_IEEE = 24, + IL_RATE_18M_IEEE = 36, + IL_RATE_24M_IEEE = 48, + IL_RATE_36M_IEEE = 72, + IL_RATE_48M_IEEE = 96, + IL_RATE_54M_IEEE = 108, + IL_RATE_60M_IEEE = 120, + IL_RATE_1M_IEEE = 2, + IL_RATE_2M_IEEE = 4, + IL_RATE_5M_IEEE = 11, + IL_RATE_11M_IEEE = 22, }; -#define IWL_CCK_BASIC_RATES_MASK \ - (IWL_RATE_1M_MASK | \ - IWL_RATE_2M_MASK) +#define IL_CCK_BASIC_RATES_MASK \ + (IL_RATE_1M_MASK | \ + IL_RATE_2M_MASK) -#define IWL_CCK_RATES_MASK \ - (IWL_CCK_BASIC_RATES_MASK | \ - IWL_RATE_5M_MASK | \ - IWL_RATE_11M_MASK) +#define IL_CCK_RATES_MASK \ + (IL_CCK_BASIC_RATES_MASK | \ + IL_RATE_5M_MASK | \ + IL_RATE_11M_MASK) -#define IWL_OFDM_BASIC_RATES_MASK \ - (IWL_RATE_6M_MASK | \ - IWL_RATE_12M_MASK | \ - IWL_RATE_24M_MASK) +#define IL_OFDM_BASIC_RATES_MASK \ + (IL_RATE_6M_MASK | \ + IL_RATE_12M_MASK | \ + IL_RATE_24M_MASK) -#define IWL_OFDM_RATES_MASK \ - (IWL_OFDM_BASIC_RATES_MASK | \ - IWL_RATE_9M_MASK | \ - IWL_RATE_18M_MASK | \ - IWL_RATE_36M_MASK | \ - IWL_RATE_48M_MASK | \ - IWL_RATE_54M_MASK) +#define IL_OFDM_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + IL_RATE_9M_MASK | \ + IL_RATE_18M_MASK | \ + IL_RATE_36M_MASK | \ + IL_RATE_48M_MASK | \ + IL_RATE_54M_MASK) -#define IWL_BASIC_RATES_MASK \ - (IWL_OFDM_BASIC_RATES_MASK | \ - IWL_CCK_BASIC_RATES_MASK) +#define IL_BASIC_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + IL_CCK_BASIC_RATES_MASK) -#define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) -#define IWL_RATES_MASK_3945 ((1 << IWL_RATE_COUNT_3945) - 1) +#define IL_RATES_MASK ((1 << IL_RATE_COUNT) - 1) +#define IL_RATES_MASK_3945 ((1 << IL_RATE_COUNT_3945) - 1) -#define IWL_INVALID_VALUE -1 +#define IL_INVALID_VALUE -1 -#define IWL_MIN_RSSI_VAL -100 -#define IWL_MAX_RSSI_VAL 0 +#define IL_MIN_RSSI_VAL -100 +#define IL_MAX_RSSI_VAL 0 /* These values specify how many Tx frame attempts before * searching for a new modulation mode */ -#define IWL_LEGACY_FAILURE_LIMIT 160 -#define IWL_LEGACY_SUCCESS_LIMIT 480 -#define IWL_LEGACY_TABLE_COUNT 160 +#define IL_LEGACY_FAILURE_LIMIT 160 +#define IL_LEGACY_SUCCESS_LIMIT 480 +#define IL_LEGACY_TABLE_COUNT 160 -#define IWL_NONE_LEGACY_FAILURE_LIMIT 400 -#define IWL_NONE_LEGACY_SUCCESS_LIMIT 4500 -#define IWL_NONE_LEGACY_TABLE_COUNT 1500 +#define IL_NONE_LEGACY_FAILURE_LIMIT 400 +#define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 +#define IL_NONE_LEGACY_TABLE_COUNT 1500 /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ -#define IWL_RS_GOOD_RATIO 12800 /* 100% */ -#define IWL_RATE_SCALE_SWITCH 10880 /* 85% */ -#define IWL_RATE_HIGH_TH 10880 /* 85% */ -#define IWL_RATE_INCREASE_TH 6400 /* 50% */ -#define IWL_RATE_DECREASE_TH 1920 /* 15% */ +#define IL_RS_GOOD_RATIO 12800 /* 100% */ +#define IL_RATE_SCALE_SWITCH 10880 /* 85% */ +#define IL_RATE_HIGH_TH 10880 /* 85% */ +#define IL_RATE_INCREASE_TH 6400 /* 50% */ +#define IL_RATE_DECREASE_TH 1920 /* 15% */ /* possible actions when in legacy mode */ -#define IWL_LEGACY_SWITCH_ANTENNA1 0 -#define IWL_LEGACY_SWITCH_ANTENNA2 1 -#define IWL_LEGACY_SWITCH_SISO 2 -#define IWL_LEGACY_SWITCH_MIMO2_AB 3 -#define IWL_LEGACY_SWITCH_MIMO2_AC 4 -#define IWL_LEGACY_SWITCH_MIMO2_BC 5 +#define IL_LEGACY_SWITCH_ANTENNA1 0 +#define IL_LEGACY_SWITCH_ANTENNA2 1 +#define IL_LEGACY_SWITCH_SISO 2 +#define IL_LEGACY_SWITCH_MIMO2_AB 3 +#define IL_LEGACY_SWITCH_MIMO2_AC 4 +#define IL_LEGACY_SWITCH_MIMO2_BC 5 /* possible actions when in siso mode */ -#define IWL_SISO_SWITCH_ANTENNA1 0 -#define IWL_SISO_SWITCH_ANTENNA2 1 -#define IWL_SISO_SWITCH_MIMO2_AB 2 -#define IWL_SISO_SWITCH_MIMO2_AC 3 -#define IWL_SISO_SWITCH_MIMO2_BC 4 -#define IWL_SISO_SWITCH_GI 5 +#define IL_SISO_SWITCH_ANTENNA1 0 +#define IL_SISO_SWITCH_ANTENNA2 1 +#define IL_SISO_SWITCH_MIMO2_AB 2 +#define IL_SISO_SWITCH_MIMO2_AC 3 +#define IL_SISO_SWITCH_MIMO2_BC 4 +#define IL_SISO_SWITCH_GI 5 /* possible actions when in mimo mode */ -#define IWL_MIMO2_SWITCH_ANTENNA1 0 -#define IWL_MIMO2_SWITCH_ANTENNA2 1 -#define IWL_MIMO2_SWITCH_SISO_A 2 -#define IWL_MIMO2_SWITCH_SISO_B 3 -#define IWL_MIMO2_SWITCH_SISO_C 4 -#define IWL_MIMO2_SWITCH_GI 5 +#define IL_MIMO2_SWITCH_ANTENNA1 0 +#define IL_MIMO2_SWITCH_ANTENNA2 1 +#define IL_MIMO2_SWITCH_SISO_A 2 +#define IL_MIMO2_SWITCH_SISO_B 3 +#define IL_MIMO2_SWITCH_SISO_C 4 +#define IL_MIMO2_SWITCH_GI 5 -#define IWL_MAX_SEARCH IWL_MIMO2_SWITCH_GI +#define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI -#define IWL_ACTION_LIMIT 3 /* # possible actions */ +#define IL_ACTION_LIMIT 3 /* # possible actions */ #define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */ /* load per tid defines for A-MPDU activation */ -#define IWL_AGG_TPT_THREHOLD 0 -#define IWL_AGG_LOAD_THRESHOLD 10 -#define IWL_AGG_ALL_TID 0xff +#define IL_AGG_TPT_THREHOLD 0 +#define IL_AGG_LOAD_THRESHOLD 10 +#define IL_AGG_ALL_TID 0xff #define TID_QUEUE_CELL_SPACING 50 /*mS */ #define TID_QUEUE_MAX_SIZE 20 #define TID_ROUND_VALUE 5 /* mS */ @@ -268,9 +268,9 @@ enum { #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) -extern const struct iwl_rate_info iwlegacy_rates[IWL_RATE_COUNT]; +extern const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; -enum iwl_table_type { +enum il_table_type { LQ_NONE, LQ_G, /* legacy types */ LQ_A, @@ -296,17 +296,17 @@ enum iwl_table_type { #define ANT_BC (ANT_B | ANT_C) #define ANT_ABC (ANT_AB | ANT_C) -#define IWL_MAX_MCS_DISPLAY_SIZE 12 +#define IL_MAX_MCS_DISPLAY_SIZE 12 -struct iwl_rate_mcs_info { - char mbps[IWL_MAX_MCS_DISPLAY_SIZE]; - char mcs[IWL_MAX_MCS_DISPLAY_SIZE]; +struct il_rate_mcs_info { + char mbps[IL_MAX_MCS_DISPLAY_SIZE]; + char mcs[IL_MAX_MCS_DISPLAY_SIZE]; }; /** - * struct iwl_rate_scale_data -- tx success history for one rate + * struct il_rate_scale_data -- tx success history for one rate */ -struct iwl_rate_scale_data { +struct il_rate_scale_data { u64 data; /* bitmap of successful frames */ s32 success_counter; /* number of frames successful */ s32 success_ratio; /* per-cent * 128 */ @@ -316,25 +316,25 @@ struct iwl_rate_scale_data { }; /** - * struct iwl_scale_tbl_info -- tx params and success history for all rates + * struct il_scale_tbl_info -- tx params and success history for all rates * - * There are two of these in struct iwl_lq_sta, + * There are two of these in struct il_lq_sta, * one for "active", and one for "search". */ -struct iwl_scale_tbl_info { - enum iwl_table_type lq_type; +struct il_scale_tbl_info { + enum il_table_type lq_type; u8 ant_type; u8 is_SGI; /* 1 = short guard interval */ u8 is_ht40; /* 1 = 40 MHz channel width */ u8 is_dup; /* 1 = duplicated data streams */ - u8 action; /* change modulation; IWL_[LEGACY/SISO/MIMO]_SWITCH_* */ + u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ u8 max_search; /* maximun number of tables we can search */ s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ u32 current_rate; /* rate_n_flags, uCode API format */ - struct iwl_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */ + struct il_rate_scale_data win[IL_RATE_COUNT]; /* rate histories */ }; -struct iwl_traffic_load { +struct il_traffic_load { unsigned long time_stamp; /* age of the oldest statistics */ u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time * slice */ @@ -346,11 +346,11 @@ struct iwl_traffic_load { }; /** - * struct iwl_lq_sta -- driver's rate scaling private structure + * struct il_lq_sta -- driver's rate scaling private structure * * Pointer to this gets passed back and forth between driver and mac80211. */ -struct iwl_lq_sta { +struct il_lq_sta { u8 active_tbl; /* index of active table, range 0-1 */ u8 enable_counter; /* indicates HT mode */ u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ @@ -371,7 +371,7 @@ struct iwl_lq_sta { u8 is_dup; enum ieee80211_band band; - /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ + /* The following are bitmaps of rates; IL_RATE_6M_MASK, etc. */ u32 supp_rates; u16 active_legacy_rate; u16 active_siso_rate; @@ -379,9 +379,9 @@ struct iwl_lq_sta { s8 max_rate_idx; /* Max rate set by user */ u8 missed_rate_counter; - struct iwl_link_quality_cmd lq; - struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ - struct iwl_traffic_load load[TID_MAX_LOAD_COUNT]; + struct il_link_quality_cmd lq; + struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ + struct il_traffic_load load[TID_MAX_LOAD_COUNT]; u8 tx_agg_tid_en; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *rs_sta_dbgfs_scale_table_file; @@ -390,7 +390,7 @@ struct iwl_lq_sta { struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; u32 dbg_fixed_rate; #endif - struct iwl_priv *drv; + struct il_priv *drv; /* used to be in sta_info */ int last_txrate_idx; @@ -400,14 +400,14 @@ struct iwl_lq_sta { u8 is_agg; }; -static inline u8 iwl4965_num_of_ant(u8 mask) +static inline u8 il4965_num_of_ant(u8 mask) { return !!((mask) & ANT_A) + !!((mask) & ANT_B) + !!((mask) & ANT_C); } -static inline u8 iwl4965_first_antenna(u8 mask) +static inline u8 il4965_first_antenna(u8 mask) { if (mask & ANT_A) return ANT_A; @@ -418,39 +418,39 @@ static inline u8 iwl4965_first_antenna(u8 mask) /** - * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info + * il3945_rate_scale_init - Initialize the rate scale table based on assoc info * * The specific throughput table used is based on the type of network * the associated with, including A, B, G, and G w/ TGG protection */ -extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); +extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); /* Initialize station's rate scaling information after adding station */ -extern void iwl4965_rs_rate_init(struct iwl_priv *priv, +extern void il4965_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id); -extern void iwl3945_rs_rate_init(struct iwl_priv *priv, +extern void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id); /** - * iwl_rate_control_register - Register the rate control algorithm callbacks + * il_rate_control_register - Register the rate control algorithm callbacks * * Since the rate control algorithm is hardware specific, there is no need * or reason to place it as a stand alone module. The driver can call - * iwl_rate_control_register in order to register the rate control callbacks + * il_rate_control_register in order to register the rate control callbacks * with the mac80211 subsystem. This should be performed prior to calling * ieee80211_register_hw * */ -extern int iwl4965_rate_control_register(void); -extern int iwl3945_rate_control_register(void); +extern int il4965_rate_control_register(void); +extern int il3945_rate_control_register(void); /** - * iwl_rate_control_unregister - Unregister the rate control callbacks + * il_rate_control_unregister - Unregister the rate control callbacks * * This should be called after calling ieee80211_unregister_hw, but before * the driver is unloaded. */ -extern void iwl4965_rate_control_unregister(void); -extern void iwl3945_rate_control_unregister(void); +extern void il4965_rate_control_unregister(void); +extern void il3945_rate_control_unregister(void); -#endif /* __iwl_legacy_rs__ */ +#endif /* __il_rs__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 903ef0d..7ccff25 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -55,32 +55,32 @@ * (level 1) and for thermal throttle (levels 3 through 5) */ -struct iwl_power_vec_entry { - struct iwl_powertable_cmd cmd; +struct il_power_vec_entry { + struct il_powertable_cmd cmd; u8 no_dtim; /* number of skip dtim */ }; -static void iwl_legacy_power_sleep_cam_cmd(struct iwl_priv *priv, - struct iwl_powertable_cmd *cmd) +static void il_power_sleep_cam_cmd(struct il_priv *priv, + struct il_powertable_cmd *cmd) { memset(cmd, 0, sizeof(*cmd)); if (priv->power_data.pci_pm) - cmd->flags |= IWL_POWER_PCI_PM_MSK; + cmd->flags |= IL_POWER_PCI_PM_MSK; - IWL_DEBUG_POWER(priv, "Sleep command for CAM\n"); + IL_DEBUG_POWER(priv, "Sleep command for CAM\n"); } static int -iwl_legacy_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd) +il_set_power(struct il_priv *priv, struct il_powertable_cmd *cmd) { - IWL_DEBUG_POWER(priv, "Sending power/sleep command\n"); - IWL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); - IWL_DEBUG_POWER(priv, "Tx timeout = %u\n", + IL_DEBUG_POWER(priv, "Sending power/sleep command\n"); + IL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); + IL_DEBUG_POWER(priv, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); - IWL_DEBUG_POWER(priv, "Rx timeout = %u\n", + IL_DEBUG_POWER(priv, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); - IWL_DEBUG_POWER(priv, + IL_DEBUG_POWER(priv, "Sleep interval vector = { %d , %d , %d , %d , %d }\n", le32_to_cpu(cmd->sleep_interval[0]), le32_to_cpu(cmd->sleep_interval[1]), @@ -88,12 +88,12 @@ iwl_legacy_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return iwl_legacy_send_cmd_pdu(priv, POWER_TABLE_CMD, - sizeof(struct iwl_powertable_cmd), cmd); + return il_send_cmd_pdu(priv, POWER_TABLE_CMD, + sizeof(struct il_powertable_cmd), cmd); } int -iwl_legacy_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, bool force) { int ret; @@ -102,58 +102,58 @@ iwl_legacy_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, lockdep_assert_held(&priv->mutex); /* Don't update the RX chain when chain noise calibration is running */ - update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE || - priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE; + update_chains = priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE || + priv->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) return 0; - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return -EIO; /* scan complete use sleep_power_next, need to be updated */ memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); if (test_bit(STATUS_SCANNING, &priv->status) && !force) { - IWL_DEBUG_INFO(priv, "Defer power set mode while scanning\n"); + IL_DEBUG_INFO(priv, "Defer power set mode while scanning\n"); return 0; } - if (cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK) + if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) set_bit(STATUS_POWER_PMI, &priv->status); - ret = iwl_legacy_set_power(priv, cmd); + ret = il_set_power(priv, cmd); if (!ret) { - if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)) + if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) clear_bit(STATUS_POWER_PMI, &priv->status); if (priv->cfg->ops->lib->update_chain_flags && update_chains) priv->cfg->ops->lib->update_chain_flags(priv); else if (priv->cfg->ops->lib->update_chain_flags) - IWL_DEBUG_POWER(priv, + IL_DEBUG_POWER(priv, "Cannot update the power, chain noise " "calibration running: %d\n", priv->chain_noise_data.state); memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else - IWL_ERR(priv, "set power fail, ret = %d", ret); + IL_ERR(priv, "set power fail, ret = %d", ret); return ret; } -int iwl_legacy_power_update_mode(struct iwl_priv *priv, bool force) +int il_power_update_mode(struct il_priv *priv, bool force) { - struct iwl_powertable_cmd cmd; + struct il_powertable_cmd cmd; - iwl_legacy_power_sleep_cam_cmd(priv, &cmd); - return iwl_legacy_power_set_mode(priv, &cmd, force); + il_power_sleep_cam_cmd(priv, &cmd); + return il_power_set_mode(priv, &cmd, force); } -EXPORT_SYMBOL(iwl_legacy_power_update_mode); +EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ -void iwl_legacy_power_initialize(struct iwl_priv *priv) +void il_power_initialize(struct il_priv *priv) { - u16 lctl = iwl_legacy_pcie_link_ctl(priv); + u16 lctl = il_pcie_link_ctl(priv); priv->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); @@ -162,4 +162,4 @@ void iwl_legacy_power_initialize(struct iwl_priv *priv) memset(&priv->power_data.sleep_cmd, 0, sizeof(priv->power_data.sleep_cmd)); } -EXPORT_SYMBOL(iwl_legacy_power_initialize); +EXPORT_SYMBOL(il_power_initialize); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index d30b36a..dba4ca9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -25,31 +25,31 @@ * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#ifndef __iwl_legacy_power_setting_h__ -#define __iwl_legacy_power_setting_h__ +#ifndef __il_power_setting_h__ +#define __il_power_setting_h__ #include "iwl-commands.h" -enum iwl_power_level { - IWL_POWER_INDEX_1, - IWL_POWER_INDEX_2, - IWL_POWER_INDEX_3, - IWL_POWER_INDEX_4, - IWL_POWER_INDEX_5, - IWL_POWER_NUM +enum il_power_level { + IL_POWER_INDEX_1, + IL_POWER_INDEX_2, + IL_POWER_INDEX_3, + IL_POWER_INDEX_4, + IL_POWER_INDEX_5, + IL_POWER_NUM }; -struct iwl_power_mgr { - struct iwl_powertable_cmd sleep_cmd; - struct iwl_powertable_cmd sleep_cmd_next; +struct il_power_mgr { + struct il_powertable_cmd sleep_cmd; + struct il_powertable_cmd sleep_cmd_next; int debug_sleep_level_override; bool pci_pm; }; int -iwl_legacy_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, bool force); -int iwl_legacy_power_update_mode(struct iwl_priv *priv, bool force); -void iwl_legacy_power_initialize(struct iwl_priv *priv); +int il_power_update_mode(struct il_priv *priv, bool force); +void il_power_initialize(struct il_priv *priv); -#endif /* __iwl_legacy_power_setting_h__ */ +#endif /* __il_power_setting_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 30a4930..96788a1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_legacy_prph_h__ -#define __iwl_legacy_prph_h__ +#ifndef __il_prph_h__ +#define __il_prph_h__ /* * Registers in this file are internal, not PCI bus memory mapped. @@ -120,13 +120,13 @@ * * 1) Initialization -- performs hardware calibration and sets up some * internal data, then notifies host via "initialize alive" notification - * (struct iwl_init_alive_resp) that it has completed all of its work. + * (struct il_init_alive_resp) that it has completed all of its work. * After signal from host, it then loads and starts the runtime program. * The initialization program must be used when initially setting up the * NIC after loading the driver. * * 2) Runtime/Protocol -- performs all normal runtime operations. This - * notifies host via "alive" notification (struct iwl_alive_resp) that it + * notifies host via "alive" notification (struct il_alive_resp) that it * is ready to be used. * * When initializing the NIC, the host driver does the following procedure: @@ -287,7 +287,7 @@ * Tx completion may end up being out-of-order). * * The driver must maintain the queue's Byte Count table in host DRAM - * (struct iwl4965_sched_queue_byte_cnt_tbl) for this mode. + * (struct il4965_sched_queue_byte_cnt_tbl) for this mode. * This mode does not support fragmentation. * * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. @@ -514,10 +514,10 @@ #define IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ ((IWL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) -#define IWL_SCD_TXFIFO_POS_TID (0) -#define IWL_SCD_TXFIFO_POS_RA (4) -#define IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) +#define IL_SCD_TXFIFO_POS_TID (0) +#define IL_SCD_TXFIFO_POS_RA (4) +#define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) /*********************** END TX SCHEDULER *************************************/ -#endif /* __iwl_legacy_prph_h__ */ +#endif /* __il_prph_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 9b5d0ab..9a2714c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -73,7 +73,7 @@ * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. - * + In iwl_rx_replenish (scheduled) if 'processed' != 'read' then the + * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ INDEX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, @@ -86,28 +86,28 @@ * * Driver sequence: * - * iwl_legacy_rx_queue_alloc() Allocates rx_free - * iwl_rx_replenish() Replenishes rx_free list from rx_used, and calls - * iwl_rx_queue_restock - * iwl_rx_queue_restock() Moves available buffers from rx_free into Rx + * il_rx_queue_alloc() Allocates rx_free + * il_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il_rx_queue_restock + * il_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates * the WRITE index. If insufficient rx_free buffers - * are available, schedules iwl_rx_replenish + * are available, schedules il_rx_replenish * * -- enable interrupts -- - * ISR - iwl_rx() Detach iwl_rx_mem_buffers from pool up to the + * ISR - il_rx() Detach il_rx_mem_buffers from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. - * Calls iwl_rx_queue_restock to refill any empty + * Calls il_rx_queue_restock to refill any empty * slots. * ... * */ /** - * iwl_legacy_rx_queue_space - Return number of free slots available in queue. + * il_rx_queue_space - Return number of free slots available in queue. */ -int iwl_legacy_rx_queue_space(const struct iwl_rx_queue *q) +int il_rx_queue_space(const struct il_rx_queue *q) { int s = q->read - q->write; if (s <= 0) @@ -118,14 +118,14 @@ int iwl_legacy_rx_queue_space(const struct iwl_rx_queue *q) s = 0; return s; } -EXPORT_SYMBOL(iwl_legacy_rx_queue_space); +EXPORT_SYMBOL(il_rx_queue_space); /** - * iwl_legacy_rx_queue_update_write_ptr - Update the write pointer for the RX queue + * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue */ void -iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, - struct iwl_rx_queue *q) +il_rx_queue_update_write_ptr(struct il_priv *priv, + struct il_rx_queue *q) { unsigned long flags; u32 rx_wrt_ptr_reg = priv->hw_params.rx_wrt_ptr_reg; @@ -138,26 +138,26 @@ iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, /* If power-saving is in use, make sure device is awake */ if (test_bit(STATUS_POWER_PMI, &priv->status)) { - reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); + reg = il_read32(priv, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Rx queue requesting wakeup," " GP1 = 0x%x\n", reg); - iwl_legacy_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); goto exit_unlock; } q->write_actual = (q->write & ~0x7); - iwl_legacy_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - iwl_legacy_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual); } @@ -166,11 +166,11 @@ iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, exit_unlock: spin_unlock_irqrestore(&q->lock, flags); } -EXPORT_SYMBOL(iwl_legacy_rx_queue_update_write_ptr); +EXPORT_SYMBOL(il_rx_queue_update_write_ptr); -int iwl_legacy_rx_queue_alloc(struct iwl_priv *priv) +int il_rx_queue_alloc(struct il_priv *priv) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct device *dev = &priv->pci_dev->dev; int i; @@ -184,7 +184,7 @@ int iwl_legacy_rx_queue_alloc(struct iwl_priv *priv) if (!rxq->bd) goto err_bd; - rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct iwl_rb_status), + rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), &rxq->rb_stts_dma, GFP_KERNEL); if (!rxq->rb_stts) goto err_rb; @@ -207,17 +207,17 @@ err_rb: err_bd: return -ENOMEM; } -EXPORT_SYMBOL(iwl_legacy_rx_queue_alloc); +EXPORT_SYMBOL(il_rx_queue_alloc); -void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_spectrum_measure_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - IWL_DEBUG_11H(priv, + IL_DEBUG_11H(priv, "Spectrum Measure Notification: Start\n"); return; } @@ -225,12 +225,12 @@ void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, memcpy(&priv->measure_report, report, sizeof(*report)); priv->measurement_status |= MEASUREMENT_READY; } -EXPORT_SYMBOL(iwl_legacy_rx_spectrum_measure_notif); +EXPORT_SYMBOL(il_rx_spectrum_measure_notif); /* * returns non-zero if packet should be dropped */ -int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, +int il_set_decrypted_flag(struct il_priv *priv, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats) @@ -241,14 +241,14 @@ int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags & + if (priv->contexts[IL_RXON_CTX_BSS].active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; if (!(fc & IEEE80211_FCTL_PROTECTED)) return 0; - IWL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res); + IL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res); switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { case RX_RES_STATUS_SEC_TYPE_TKIP: /* The uCode has got a bad phase 1 Key, pushes the packet. @@ -262,13 +262,13 @@ int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, RX_RES_STATUS_BAD_ICV_MIC) { /* bad ICV, the packet is destroyed since the * decryption is inplace, drop it */ - IWL_DEBUG_RX(priv, "Packet destroyed\n"); + IL_DEBUG_RX(priv, "Packet destroyed\n"); return -1; } case RX_RES_STATUS_SEC_TYPE_CCMP: if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == RX_RES_STATUS_DECRYPT_OK) { - IWL_DEBUG_RX(priv, "hw decrypt successfully!!!\n"); + IL_DEBUG_RX(priv, "hw decrypt successfully!!!\n"); stats->flag |= RX_FLAG_DECRYPTED; } break; @@ -278,4 +278,4 @@ int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, } return 0; } -EXPORT_SYMBOL(iwl_legacy_set_decrypted_flag); +EXPORT_SYMBOL(il_set_decrypted_flag); diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index a6b5222..93e939c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -40,25 +40,25 @@ /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after * sending probe req. This should be set long enough to hear probe responses * from more than one AP. */ -#define IWL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ -#define IWL_ACTIVE_DWELL_TIME_52 (20) +#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ +#define IL_ACTIVE_DWELL_TIME_52 (20) -#define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3) -#define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2) +#define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) +#define IL_ACTIVE_DWELL_FACTOR_52GHZ (2) /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. * Must be set longer than active dwell time. * For the most reliable scan, set > AP beacon interval (typically 100msec). */ -#define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ -#define IWL_PASSIVE_DWELL_TIME_52 (10) -#define IWL_PASSIVE_DWELL_BASE (100) -#define IWL_CHANNEL_TUNE_TIME 5 +#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ +#define IL_PASSIVE_DWELL_TIME_52 (10) +#define IL_PASSIVE_DWELL_BASE (100) +#define IL_CHANNEL_TUNE_TIME 5 -static int iwl_legacy_send_scan_abort(struct iwl_priv *priv) +static int il_send_scan_abort(struct il_priv *priv) { int ret; - struct iwl_rx_packet *pkt; - struct iwl_host_cmd cmd = { + struct il_rx_packet *pkt; + struct il_host_cmd cmd = { .id = REPLY_SCAN_ABORT_CMD, .flags = CMD_WANT_SKB, }; @@ -73,11 +73,11 @@ static int iwl_legacy_send_scan_abort(struct iwl_priv *priv) test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EIO; - ret = iwl_legacy_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(priv, &cmd); if (ret) return ret; - pkt = (struct iwl_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->u.status != CAN_ABORT_STATUS) { /* The scan abort will return 1 for success or * 2 for "failure". A failure condition can be @@ -85,19 +85,19 @@ static int iwl_legacy_send_scan_abort(struct iwl_priv *priv) * can occur if we send the scan abort before we * the microcode has notified us that a scan is * completed. */ - IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status); + IL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status); ret = -EIO; } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return ret; } -static void iwl_legacy_complete_scan(struct iwl_priv *priv, bool aborted) +static void il_complete_scan(struct il_priv *priv, bool aborted) { /* check if scan was requested from mac80211 */ if (priv->scan_request) { - IWL_DEBUG_SCAN(priv, "Complete scan in mac80211\n"); + IL_DEBUG_SCAN(priv, "Complete scan in mac80211\n"); ieee80211_scan_completed(priv->hw, aborted); } @@ -105,71 +105,71 @@ static void iwl_legacy_complete_scan(struct iwl_priv *priv, bool aborted) priv->scan_request = NULL; } -void iwl_legacy_force_scan_end(struct iwl_priv *priv) +void il_force_scan_end(struct il_priv *priv) { lockdep_assert_held(&priv->mutex); if (!test_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); + IL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); return; } - IWL_DEBUG_SCAN(priv, "Forcing scan end\n"); + IL_DEBUG_SCAN(priv, "Forcing scan end\n"); clear_bit(STATUS_SCANNING, &priv->status); clear_bit(STATUS_SCAN_HW, &priv->status); clear_bit(STATUS_SCAN_ABORTING, &priv->status); - iwl_legacy_complete_scan(priv, true); + il_complete_scan(priv, true); } -static void iwl_legacy_do_scan_abort(struct iwl_priv *priv) +static void il_do_scan_abort(struct il_priv *priv) { int ret; lockdep_assert_held(&priv->mutex); if (!test_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); + IL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); return; } if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan abort in progress\n"); + IL_DEBUG_SCAN(priv, "Scan abort in progress\n"); return; } - ret = iwl_legacy_send_scan_abort(priv); + ret = il_send_scan_abort(priv); if (ret) { - IWL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret); - iwl_legacy_force_scan_end(priv); + IL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret); + il_force_scan_end(priv); } else - IWL_DEBUG_SCAN(priv, "Successfully send scan abort\n"); + IL_DEBUG_SCAN(priv, "Successfully send scan abort\n"); } /** - * iwl_scan_cancel - Cancel any currently executing HW scan + * il_scan_cancel - Cancel any currently executing HW scan */ -int iwl_legacy_scan_cancel(struct iwl_priv *priv) +int il_scan_cancel(struct il_priv *priv) { - IWL_DEBUG_SCAN(priv, "Queuing abort scan\n"); + IL_DEBUG_SCAN(priv, "Queuing abort scan\n"); queue_work(priv->workqueue, &priv->abort_scan); return 0; } -EXPORT_SYMBOL(iwl_legacy_scan_cancel); +EXPORT_SYMBOL(il_scan_cancel); /** - * iwl_legacy_scan_cancel_timeout - Cancel any currently executing HW scan + * il_scan_cancel_timeout - Cancel any currently executing HW scan * @ms: amount of time to wait (in milliseconds) for scan to abort * */ -int iwl_legacy_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) +int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms) { unsigned long timeout = jiffies + msecs_to_jiffies(ms); lockdep_assert_held(&priv->mutex); - IWL_DEBUG_SCAN(priv, "Scan cancel timeout\n"); + IL_DEBUG_SCAN(priv, "Scan cancel timeout\n"); - iwl_legacy_do_scan_abort(priv); + il_do_scan_abort(priv); while (time_before_eq(jiffies, timeout)) { if (!test_bit(STATUS_SCAN_HW, &priv->status)) @@ -179,30 +179,30 @@ int iwl_legacy_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) return test_bit(STATUS_SCAN_HW, &priv->status); } -EXPORT_SYMBOL(iwl_legacy_scan_cancel_timeout); +EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to REPLY_SCAN_CMD (0x80) */ -static void iwl_legacy_rx_reply_scan(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_reply_scan(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanreq_notification *notif = - (struct iwl_scanreq_notification *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scanreq_notification *notif = + (struct il_scanreq_notification *)pkt->u.raw; - IWL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status); + IL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status); #endif } /* Service SCAN_START_NOTIFICATION (0x82) */ -static void iwl_legacy_rx_scan_start_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_scan_start_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanstart_notification *notif = - (struct iwl_scanstart_notification *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scanstart_notification *notif = + (struct il_scanstart_notification *)pkt->u.raw; priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); - IWL_DEBUG_SCAN(priv, "Scan start: " + IL_DEBUG_SCAN(priv, "Scan start: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, @@ -213,15 +213,15 @@ static void iwl_legacy_rx_scan_start_notif(struct iwl_priv *priv, } /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ -static void iwl_legacy_rx_scan_results_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_scan_results_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanresults_notification *notif = - (struct iwl_scanresults_notification *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scanresults_notification *notif = + (struct il_scanresults_notification *)pkt->u.raw; - IWL_DEBUG_SCAN(priv, "Scan ch.res: " + IL_DEBUG_SCAN(priv, "Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " "elapsed=%lu usec\n", @@ -235,16 +235,16 @@ static void iwl_legacy_rx_scan_results_notif(struct iwl_priv *priv, } /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ -static void iwl_legacy_rx_scan_complete_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_scan_complete_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - IWL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", scan_notif->scanned_channels, scan_notif->tsf_low, @@ -253,49 +253,49 @@ static void iwl_legacy_rx_scan_complete_notif(struct iwl_priv *priv, /* The HW is no longer scanning */ clear_bit(STATUS_SCAN_HW, &priv->status); - IWL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n", + IL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n", (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", jiffies_to_msecs(jiffies - priv->scan_start)); queue_work(priv->workqueue, &priv->scan_completed); } -void iwl_legacy_setup_rx_scan_handlers(struct iwl_priv *priv) +void il_setup_rx_scan_handlers(struct il_priv *priv) { /* scan handlers */ - priv->rx_handlers[REPLY_SCAN_CMD] = iwl_legacy_rx_reply_scan; + priv->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; priv->rx_handlers[SCAN_START_NOTIFICATION] = - iwl_legacy_rx_scan_start_notif; + il_rx_scan_start_notif; priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = - iwl_legacy_rx_scan_results_notif; + il_rx_scan_results_notif; priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = - iwl_legacy_rx_scan_complete_notif; + il_rx_scan_complete_notif; } -EXPORT_SYMBOL(iwl_legacy_setup_rx_scan_handlers); +EXPORT_SYMBOL(il_setup_rx_scan_handlers); -inline u16 iwl_legacy_get_active_dwell_time(struct iwl_priv *priv, +inline u16 il_get_active_dwell_time(struct il_priv *priv, enum ieee80211_band band, u8 n_probes) { if (band == IEEE80211_BAND_5GHZ) - return IWL_ACTIVE_DWELL_TIME_52 + - IWL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); + return IL_ACTIVE_DWELL_TIME_52 + + IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); else - return IWL_ACTIVE_DWELL_TIME_24 + - IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); + return IL_ACTIVE_DWELL_TIME_24 + + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); } -EXPORT_SYMBOL(iwl_legacy_get_active_dwell_time); +EXPORT_SYMBOL(il_get_active_dwell_time); -u16 iwl_legacy_get_passive_dwell_time(struct iwl_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *priv, enum ieee80211_band band, struct ieee80211_vif *vif) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; u16 passive = (band == IEEE80211_BAND_2GHZ) ? - IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : - IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; - if (iwl_legacy_is_any_associated(priv)) { + if (il_is_any_associated(priv)) { /* * If we're associated, we clamp the maximum passive * dwell time to be 98% of the smallest beacon interval @@ -304,21 +304,21 @@ u16 iwl_legacy_get_passive_dwell_time(struct iwl_priv *priv, for_each_context(priv, ctx) { u16 value; - if (!iwl_legacy_is_associated_ctx(ctx)) + if (!il_is_associated_ctx(ctx)) continue; value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if ((value > IWL_PASSIVE_DWELL_BASE) || !value) - value = IWL_PASSIVE_DWELL_BASE; - value = (value * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; + if ((value > IL_PASSIVE_DWELL_BASE) || !value) + value = IL_PASSIVE_DWELL_BASE; + value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; passive = min(value, passive); } } return passive; } -EXPORT_SYMBOL(iwl_legacy_get_passive_dwell_time); +EXPORT_SYMBOL(il_get_passive_dwell_time); -void iwl_legacy_init_scan_params(struct iwl_priv *priv) +void il_init_scan_params(struct il_priv *priv) { u8 ant_idx = fls(priv->hw_params.valid_tx_ant) - 1; if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ]) @@ -326,9 +326,9 @@ void iwl_legacy_init_scan_params(struct iwl_priv *priv) if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ]) priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } -EXPORT_SYMBOL(iwl_legacy_init_scan_params); +EXPORT_SYMBOL(il_init_scan_params); -static int iwl_legacy_scan_initiate(struct iwl_priv *priv, +static int il_scan_initiate(struct il_priv *priv, struct ieee80211_vif *vif) { int ret; @@ -340,23 +340,23 @@ static int iwl_legacy_scan_initiate(struct iwl_priv *priv, cancel_delayed_work(&priv->scan_check); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_WARN(priv, "Request scan called when driver not ready.\n"); + if (!il_is_ready_rf(priv)) { + IL_WARN(priv, "Request scan called when driver not ready.\n"); return -EIO; } if (test_bit(STATUS_SCAN_HW, &priv->status)) { - IWL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(priv, "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan request while abort pending.\n"); + IL_DEBUG_SCAN(priv, "Scan request while abort pending.\n"); return -EBUSY; } - IWL_DEBUG_SCAN(priv, "Starting scan...\n"); + IL_DEBUG_SCAN(priv, "Starting scan...\n"); set_bit(STATUS_SCANNING, &priv->status); priv->scan_start = jiffies; @@ -368,19 +368,19 @@ static int iwl_legacy_scan_initiate(struct iwl_priv *priv, } queue_delayed_work(priv->workqueue, &priv->scan_check, - IWL_SCAN_CHECK_WATCHDOG); + IL_SCAN_CHECK_WATCHDOG); return 0; } -int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, +int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (req->n_channels == 0) return -EINVAL; @@ -388,7 +388,7 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); if (test_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); + IL_DEBUG_SCAN(priv, "Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; } @@ -398,38 +398,38 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, priv->scan_vif = vif; priv->scan_band = req->channels[0]->band; - ret = iwl_legacy_scan_initiate(priv, vif); + ret = il_scan_initiate(priv, vif); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); out_unlock: mutex_unlock(&priv->mutex); return ret; } -EXPORT_SYMBOL(iwl_legacy_mac_hw_scan); +EXPORT_SYMBOL(il_mac_hw_scan); -static void iwl_legacy_bg_scan_check(struct work_struct *data) +static void il_bg_scan_check(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, scan_check.work); + struct il_priv *priv = + container_of(data, struct il_priv, scan_check.work); - IWL_DEBUG_SCAN(priv, "Scan check work\n"); + IL_DEBUG_SCAN(priv, "Scan check work\n"); /* Since we are here firmware does not finish scan and * most likely is in bad shape, so we don't bother to * send abort command, just force scan complete to mac80211 */ mutex_lock(&priv->mutex); - iwl_legacy_force_scan_end(priv); + il_force_scan_end(priv); mutex_unlock(&priv->mutex); } /** - * iwl_legacy_fill_probe_req - fill in all required fields and IE for probe request + * il_fill_probe_req - fill in all required fields and IE for probe request */ u16 -iwl_legacy_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, +il_fill_probe_req(struct il_priv *priv, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ies, int ie_len, int left) { int len = 0; @@ -471,28 +471,28 @@ iwl_legacy_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, return (u16)len; } -EXPORT_SYMBOL(iwl_legacy_fill_probe_req); +EXPORT_SYMBOL(il_fill_probe_req); -static void iwl_legacy_bg_abort_scan(struct work_struct *work) +static void il_bg_abort_scan(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); + struct il_priv *priv = container_of(work, struct il_priv, abort_scan); - IWL_DEBUG_SCAN(priv, "Abort scan work\n"); + IL_DEBUG_SCAN(priv, "Abort scan work\n"); /* We keep scan_check work queued in case when firmware will not * report back scan completed notification */ mutex_lock(&priv->mutex); - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); mutex_unlock(&priv->mutex); } -static void iwl_legacy_bg_scan_completed(struct work_struct *work) +static void il_bg_scan_completed(struct work_struct *work) { - struct iwl_priv *priv = - container_of(work, struct iwl_priv, scan_completed); + struct il_priv *priv = + container_of(work, struct il_priv, scan_completed); bool aborted; - IWL_DEBUG_SCAN(priv, "Completed scan.\n"); + IL_DEBUG_SCAN(priv, "Completed scan.\n"); cancel_delayed_work(&priv->scan_check); @@ -500,26 +500,26 @@ static void iwl_legacy_bg_scan_completed(struct work_struct *work) aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status); if (aborted) - IWL_DEBUG_SCAN(priv, "Aborted scan completed.\n"); + IL_DEBUG_SCAN(priv, "Aborted scan completed.\n"); if (!test_and_clear_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan already completed.\n"); + IL_DEBUG_SCAN(priv, "Scan already completed.\n"); goto out_settings; } - iwl_legacy_complete_scan(priv, aborted); + il_complete_scan(priv, aborted); out_settings: /* Can we still talk to firmware ? */ - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) goto out; /* * We do not commit power settings while scan is pending, * do it now if the settings changed. */ - iwl_legacy_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); - iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); + il_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); + il_set_tx_power(priv, priv->tx_power_next, false); priv->cfg->ops->utils->post_scan(priv); @@ -527,23 +527,23 @@ out: mutex_unlock(&priv->mutex); } -void iwl_legacy_setup_scan_deferred_work(struct iwl_priv *priv) +void il_setup_scan_deferred_work(struct il_priv *priv) { - INIT_WORK(&priv->scan_completed, iwl_legacy_bg_scan_completed); - INIT_WORK(&priv->abort_scan, iwl_legacy_bg_abort_scan); - INIT_DELAYED_WORK(&priv->scan_check, iwl_legacy_bg_scan_check); + INIT_WORK(&priv->scan_completed, il_bg_scan_completed); + INIT_WORK(&priv->abort_scan, il_bg_abort_scan); + INIT_DELAYED_WORK(&priv->scan_check, il_bg_scan_check); } -EXPORT_SYMBOL(iwl_legacy_setup_scan_deferred_work); +EXPORT_SYMBOL(il_setup_scan_deferred_work); -void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv) +void il_cancel_scan_deferred_work(struct il_priv *priv) { cancel_work_sync(&priv->abort_scan); cancel_work_sync(&priv->scan_completed); if (cancel_delayed_work_sync(&priv->scan_check)) { mutex_lock(&priv->mutex); - iwl_legacy_force_scan_end(priv); + il_force_scan_end(priv); mutex_unlock(&priv->mutex); } } -EXPORT_SYMBOL(iwl_legacy_cancel_scan_deferred_work); +EXPORT_SYMBOL(il_cancel_scan_deferred_work); diff --git a/drivers/net/wireless/iwlegacy/iwl-spectrum.h b/drivers/net/wireless/iwlegacy/iwl-spectrum.h index 9f70a47..85fe48e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-spectrum.h +++ b/drivers/net/wireless/iwlegacy/iwl-spectrum.h @@ -26,8 +26,8 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_spectrum_h__ -#define __iwl_legacy_spectrum_h__ +#ifndef __il_spectrum_h__ +#define __il_spectrum_h__ enum { /* ieee80211_basic_report.map */ IEEE80211_BASIC_MAP_BSS = (1 << 0), IEEE80211_BASIC_MAP_OFDM = (1 << 1), diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 66f0fb2..3773f7d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -37,72 +37,72 @@ #include "iwl-sta.h" /* priv->sta_lock must be held */ -static void iwl_legacy_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) +static void il_sta_ucode_activate(struct il_priv *priv, u8 sta_id) { - if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) - IWL_ERR(priv, + if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) + IL_ERR(priv, "ACTIVATE a non DRIVER active station id %u addr %pM\n", sta_id, priv->stations[sta_id].sta.sta.addr); - if (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) { - IWL_DEBUG_ASSOC(priv, + if (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_ASSOC(priv, "STA id %u addr %pM already present" " in uCode (according to driver)\n", sta_id, priv->stations[sta_id].sta.sta.addr); } else { - priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE; - IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", + priv->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; + IL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", sta_id, priv->stations[sta_id].sta.sta.addr); } } -static int iwl_legacy_process_add_sta_resp(struct iwl_priv *priv, - struct iwl_legacy_addsta_cmd *addsta, - struct iwl_rx_packet *pkt, +static int il_process_add_sta_resp(struct il_priv *priv, + struct il_addsta_cmd *addsta, + struct il_rx_packet *pkt, bool sync) { u8 sta_id = addsta->sta.sta_id; unsigned long flags; int ret = -EIO; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n", + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } - IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n", + IL_DEBUG_INFO(priv, "Processing response for adding station %u\n", sta_id); spin_lock_irqsave(&priv->sta_lock, flags); switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); - iwl_legacy_sta_ucode_activate(priv, sta_id); + IL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); + il_sta_ucode_activate(priv, sta_id); ret = 0; break; case ADD_STA_NO_ROOM_IN_TABLE: - IWL_ERR(priv, "Adding station %d failed, no room in table.\n", + IL_ERR(priv, "Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IWL_ERR(priv, + IL_ERR(priv, "Adding station %d failed, no block ack resource.\n", sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: - IWL_ERR(priv, "Attempting to modify non-existing station %d\n", + IL_ERR(priv, "Attempting to modify non-existing station %d\n", sta_id); break; default: - IWL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n", + IL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } - IWL_DEBUG_INFO(priv, "%s station id %u addr %pM\n", + IL_DEBUG_INFO(priv, "%s station id %u addr %pM\n", priv->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", sta_id, priv->stations[sta_id].sta.sta.addr); @@ -115,7 +115,7 @@ static int iwl_legacy_process_add_sta_resp(struct iwl_priv *priv, * issue has not yet been resolved and this debugging is left to * observe the problem. */ - IWL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n", + IL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n", priv->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); @@ -124,59 +124,59 @@ static int iwl_legacy_process_add_sta_resp(struct iwl_priv *priv, return ret; } -static void iwl_legacy_add_sta_callback(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt) +static void il_add_sta_callback(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt) { - struct iwl_legacy_addsta_cmd *addsta = - (struct iwl_legacy_addsta_cmd *)cmd->cmd.payload; + struct il_addsta_cmd *addsta = + (struct il_addsta_cmd *)cmd->cmd.payload; - iwl_legacy_process_add_sta_resp(priv, addsta, pkt, false); + il_process_add_sta_resp(priv, addsta, pkt, false); } -int iwl_legacy_send_add_sta(struct iwl_priv *priv, - struct iwl_legacy_addsta_cmd *sta, u8 flags) +int il_send_add_sta(struct il_priv *priv, + struct il_addsta_cmd *sta, u8 flags) { - struct iwl_rx_packet *pkt = NULL; + struct il_rx_packet *pkt = NULL; int ret = 0; u8 data[sizeof(*sta)]; - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_ADD_STA, .flags = flags, .data = data, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", + IL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) - cmd.callback = iwl_legacy_add_sta_callback; + cmd.callback = il_add_sta_callback; else { cmd.flags |= CMD_WANT_SKB; might_sleep(); } cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); - ret = iwl_legacy_send_cmd(priv, &cmd); + ret = il_send_cmd(priv, &cmd); if (ret || (flags & CMD_ASYNC)) return ret; if (ret == 0) { - pkt = (struct iwl_rx_packet *)cmd.reply_page; - ret = iwl_legacy_process_add_sta_resp(priv, sta, pkt, true); + pkt = (struct il_rx_packet *)cmd.reply_page; + ret = il_process_add_sta_resp(priv, sta, pkt, true); } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return ret; } -EXPORT_SYMBOL(iwl_legacy_send_add_sta); +EXPORT_SYMBOL(il_send_add_sta); -static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, +static void il_set_ht_add_station(struct il_priv *priv, u8 index, struct ieee80211_sta *sta, - struct iwl_rxon_context *ctx) + struct il_rxon_context *ctx) { struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; __le32 sta_flags; @@ -186,7 +186,7 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, goto done; mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; - IWL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n", + IL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n", (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? @@ -206,7 +206,7 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, case WLAN_HT_CAP_SM_PS_DISABLED: break; default: - IWL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode); + IL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode); break; } @@ -216,7 +216,7 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, sta_flags |= cpu_to_le32( (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) sta_flags |= STA_FLG_HT40_EN_MSK; else sta_flags &= ~STA_FLG_HT40_EN_MSK; @@ -227,16 +227,16 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, } /** - * iwl_legacy_prep_station - Prepare station information for addition + * il_prep_station - Prepare station information for addition * * should be called with sta_lock held */ -u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, +u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta) { - struct iwl_station_entry *station; + struct il_station_entry *station; int i; - u8 sta_id = IWL_INVALID_STATION; + u8 sta_id = IL_INVALID_STATION; u16 rate; if (is_ap) @@ -244,7 +244,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, else if (is_broadcast_ether_addr(addr)) sta_id = ctx->bcast_sta_id; else - for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) { + for (i = IL_STA_ID; i < priv->hw_params.max_stations; i++) { if (!compare_ether_addr(priv->stations[i].sta.sta.addr, addr)) { sta_id = i; @@ -252,7 +252,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, } if (!priv->stations[i].used && - sta_id == IWL_INVALID_STATION) + sta_id == IL_INVALID_STATION) sta_id = i; } @@ -260,7 +260,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, * These two conditions have the same outcome, but keep them * separate */ - if (unlikely(sta_id == IWL_INVALID_STATION)) + if (unlikely(sta_id == IL_INVALID_STATION)) return sta_id; /* @@ -268,30 +268,30 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) { - IWL_DEBUG_INFO(priv, + if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(priv, "STA %d already in process of being added.\n", sta_id); return sta_id; } - if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) && + if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) { - IWL_DEBUG_ASSOC(priv, + IL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); return sta_id; } station = &priv->stations[sta_id]; - station->used = IWL_STA_DRIVER_ACTIVE; - IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", + station->used = IL_STA_DRIVER_ACTIVE; + IL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", sta_id, addr); priv->num_stations++; /* Set up the REPLY_ADD_STA command to send to device */ - memset(&station->sta, 0, sizeof(struct iwl_legacy_addsta_cmd)); + memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); memcpy(station->sta.sta.addr, addr, ETH_ALEN); station->sta.mode = 0; station->sta.sta.sta_id = sta_id; @@ -299,7 +299,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, station->ctxid = ctx->ctxid; if (sta) { - struct iwl_station_priv_common *sta_priv; + struct il_station_priv_common *sta_priv; sta_priv = (void *)sta->drv_priv; sta_priv->ctx = ctx; @@ -310,40 +310,40 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, * STA and broadcast STA) pass in a NULL sta, and mac80211 * doesn't allow HT IBSS. */ - iwl_legacy_set_ht_add_station(priv, sta_id, sta, ctx); + il_set_ht_add_station(priv, sta_id, sta, ctx); /* 3945 only */ rate = (priv->band == IEEE80211_BAND_5GHZ) ? - IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP; + IL_RATE_6M_PLCP : IL_RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); return sta_id; } -EXPORT_SYMBOL_GPL(iwl_legacy_prep_station); +EXPORT_SYMBOL_GPL(il_prep_station); #define STA_WAIT_TIMEOUT (HZ/2) /** - * iwl_legacy_add_station_common - + * il_add_station_common - */ int -iwl_legacy_add_station_common(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +il_add_station_common(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r) { unsigned long flags_spin; int ret = 0; u8 sta_id; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; *sta_id_r = 0; spin_lock_irqsave(&priv->sta_lock, flags_spin); - sta_id = iwl_legacy_prep_station(priv, ctx, addr, is_ap, sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Unable to prepare station %pM for addition\n", + sta_id = il_prep_station(priv, ctx, addr, is_ap, sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Unable to prepare station %pM for addition\n", addr); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EINVAL; @@ -354,75 +354,75 @@ iwl_legacy_add_station_common(struct iwl_priv *priv, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) { - IWL_DEBUG_INFO(priv, + if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(priv, "STA %d already in process of being added.\n", sta_id); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EEXIST; } - if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { - IWL_DEBUG_ASSOC(priv, + if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EEXIST; } - priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS; + priv->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); /* Add station to device's station table */ - ret = iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&priv->sta_lock, flags_spin); - IWL_ERR(priv, "Adding station %pM failed.\n", + IL_ERR(priv, "Adding station %pM failed.\n", priv->stations[sta_id].sta.sta.addr); - priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } *sta_id_r = sta_id; return ret; } -EXPORT_SYMBOL(iwl_legacy_add_station_common); +EXPORT_SYMBOL(il_add_station_common); /** - * iwl_legacy_sta_ucode_deactivate - deactivate ucode status for a station + * il_sta_ucode_deactivate - deactivate ucode status for a station * * priv->sta_lock must be held */ -static void iwl_legacy_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id) +static void il_sta_ucode_deactivate(struct il_priv *priv, u8 sta_id) { /* Ucode must be active and driver must be non active */ if ((priv->stations[sta_id].used & - (IWL_STA_UCODE_ACTIVE | IWL_STA_DRIVER_ACTIVE)) != - IWL_STA_UCODE_ACTIVE) - IWL_ERR(priv, "removed non active STA %u\n", sta_id); + (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != + IL_STA_UCODE_ACTIVE) + IL_ERR(priv, "removed non active STA %u\n", sta_id); - priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE; + priv->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; - memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry)); - IWL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id); + memset(&priv->stations[sta_id], 0, sizeof(struct il_station_entry)); + IL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id); } -static int iwl_legacy_send_remove_station(struct iwl_priv *priv, +static int il_send_remove_station(struct il_priv *priv, const u8 *addr, int sta_id, bool temporary) { - struct iwl_rx_packet *pkt; + struct il_rx_packet *pkt; int ret; unsigned long flags_spin; - struct iwl_rem_sta_cmd rm_sta_cmd; + struct il_rem_sta_cmd rm_sta_cmd; - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_REMOVE_STA, - .len = sizeof(struct iwl_rem_sta_cmd), + .len = sizeof(struct il_rem_sta_cmd), .flags = CMD_SYNC, .data = &rm_sta_cmd, }; @@ -433,14 +433,14 @@ static int iwl_legacy_send_remove_station(struct iwl_priv *priv, cmd.flags |= CMD_WANT_SKB; - ret = iwl_legacy_send_cmd(priv, &cmd); + ret = il_send_cmd(priv, &cmd); if (ret) return ret; - pkt = (struct iwl_rx_packet *)cmd.reply_page; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", + pkt = (struct il_rx_packet *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -450,33 +450,33 @@ static int iwl_legacy_send_remove_station(struct iwl_priv *priv, case REM_STA_SUCCESS_MSK: if (!temporary) { spin_lock_irqsave(&priv->sta_lock, flags_spin); - iwl_legacy_sta_ucode_deactivate(priv, sta_id); + il_sta_ucode_deactivate(priv, sta_id); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } - IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); + IL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); break; default: ret = -EIO; - IWL_ERR(priv, "REPLY_REMOVE_STA failed\n"); + IL_ERR(priv, "REPLY_REMOVE_STA failed\n"); break; } } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return ret; } /** - * iwl_legacy_remove_station - Remove driver's knowledge of station. + * il_remove_station - Remove driver's knowledge of station. */ -int iwl_legacy_remove_station(struct iwl_priv *priv, const u8 sta_id, +int il_remove_station(struct il_priv *priv, const u8 sta_id, const u8 *addr) { unsigned long flags; - if (!iwl_legacy_is_ready(priv)) { - IWL_DEBUG_INFO(priv, + if (!il_is_ready(priv)) { + IL_DEBUG_INFO(priv, "Unable to remove station %pM, device not ready.\n", addr); /* @@ -487,32 +487,32 @@ int iwl_legacy_remove_station(struct iwl_priv *priv, const u8 sta_id, return 0; } - IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", + IL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", sta_id, addr); - if (WARN_ON(sta_id == IWL_INVALID_STATION)) + if (WARN_ON(sta_id == IL_INVALID_STATION)) return -EINVAL; spin_lock_irqsave(&priv->sta_lock, flags); - if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { - IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", + if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { + IL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", addr); goto out_err; } - if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { - IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", + if (!(priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", addr); goto out_err; } - if (priv->stations[sta_id].used & IWL_STA_LOCAL) { + if (priv->stations[sta_id].used & IL_STA_LOCAL) { kfree(priv->stations[sta_id].lq); priv->stations[sta_id].lq = NULL; } - priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; priv->num_stations--; @@ -520,52 +520,52 @@ int iwl_legacy_remove_station(struct iwl_priv *priv, const u8 sta_id, spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_remove_station(priv, addr, sta_id, false); + return il_send_remove_station(priv, addr, sta_id, false); out_err: spin_unlock_irqrestore(&priv->sta_lock, flags); return -EINVAL; } -EXPORT_SYMBOL_GPL(iwl_legacy_remove_station); +EXPORT_SYMBOL_GPL(il_remove_station); /** - * iwl_legacy_clear_ucode_stations - clear ucode station table bits + * il_clear_ucode_stations - clear ucode station table bits * * This function clears all the bits in the driver indicating * which stations are active in the ucode. Call when something * other than explicit station management would cause this in * the ucode, e.g. unassociated RXON. */ -void iwl_legacy_clear_ucode_stations(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +void il_clear_ucode_stations(struct il_priv *priv, + struct il_rxon_context *ctx) { int i; unsigned long flags_spin; bool cleared = false; - IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n"); + IL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n"); spin_lock_irqsave(&priv->sta_lock, flags_spin); for (i = 0; i < priv->hw_params.max_stations; i++) { if (ctx && ctx->ctxid != priv->stations[i].ctxid) continue; - if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) { - IWL_DEBUG_INFO(priv, + if (priv->stations[i].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i); - priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE; + priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; } } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); if (!cleared) - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "No active stations found to be cleared\n"); } -EXPORT_SYMBOL(iwl_legacy_clear_ucode_stations); +EXPORT_SYMBOL(il_clear_ucode_stations); /** - * iwl_legacy_restore_stations() - Restore driver known stations to device + * il_restore_stations() - Restore driver known stations to device * * All stations considered active by driver, but not present in ucode, is * restored. @@ -573,57 +573,57 @@ EXPORT_SYMBOL(iwl_legacy_clear_ucode_stations); * Function sleeps. */ void -iwl_legacy_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) { - struct iwl_legacy_addsta_cmd sta_cmd; - struct iwl_link_quality_cmd lq; + struct il_addsta_cmd sta_cmd; + struct il_link_quality_cmd lq; unsigned long flags_spin; int i; bool found = false; int ret; bool send_lq; - if (!iwl_legacy_is_ready(priv)) { - IWL_DEBUG_INFO(priv, + if (!il_is_ready(priv)) { + IL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n"); return; } - IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); + IL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); spin_lock_irqsave(&priv->sta_lock, flags_spin); for (i = 0; i < priv->hw_params.max_stations; i++) { if (ctx->ctxid != priv->stations[i].ctxid) continue; - if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) && - !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) { - IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n", + if ((priv->stations[i].used & IL_STA_DRIVER_ACTIVE) && + !(priv->stations[i].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(priv, "Restoring sta %pM\n", priv->stations[i].sta.sta.addr); priv->stations[i].sta.mode = 0; - priv->stations[i].used |= IWL_STA_UCODE_INPROGRESS; + priv->stations[i].used |= IL_STA_UCODE_INPROGRESS; found = true; } } for (i = 0; i < priv->hw_params.max_stations; i++) { - if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) { + if ((priv->stations[i].used & IL_STA_UCODE_INPROGRESS)) { memcpy(&sta_cmd, &priv->stations[i].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); send_lq = false; if (priv->stations[i].lq) { memcpy(&lq, priv->stations[i].lq, - sizeof(struct iwl_link_quality_cmd)); + sizeof(struct il_link_quality_cmd)); send_lq = true; } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - ret = iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&priv->sta_lock, flags_spin); - IWL_ERR(priv, "Adding station %pM failed.\n", + IL_ERR(priv, "Adding station %pM failed.\n", priv->stations[i].sta.sta.addr); priv->stations[i].used &= - ~IWL_STA_DRIVER_ACTIVE; + ~IL_STA_DRIVER_ACTIVE; priv->stations[i].used &= - ~IWL_STA_UCODE_INPROGRESS; + ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } @@ -632,24 +632,24 @@ iwl_legacy_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * current LQ command */ if (send_lq) - iwl_legacy_send_lq_cmd(priv, ctx, &lq, + il_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; } } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); if (!found) - IWL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(priv, "Restoring all known stations" " .... no stations to be restored.\n"); else - IWL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(priv, "Restoring all known stations" " .... complete.\n"); } -EXPORT_SYMBOL(iwl_legacy_restore_stations); +EXPORT_SYMBOL(il_restore_stations); -int iwl_legacy_get_free_ucode_key_index(struct iwl_priv *priv) +int il_get_free_ucode_key_index(struct il_priv *priv) { int i; @@ -659,19 +659,19 @@ int iwl_legacy_get_free_ucode_key_index(struct iwl_priv *priv) return WEP_INVALID_OFFSET; } -EXPORT_SYMBOL(iwl_legacy_get_free_ucode_key_index); +EXPORT_SYMBOL(il_get_free_ucode_key_index); -void iwl_legacy_dealloc_bcast_stations(struct iwl_priv *priv) +void il_dealloc_bcast_stations(struct il_priv *priv) { unsigned long flags; int i; spin_lock_irqsave(&priv->sta_lock, flags); for (i = 0; i < priv->hw_params.max_stations; i++) { - if (!(priv->stations[i].used & IWL_STA_BCAST)) + if (!(priv->stations[i].used & IL_STA_BCAST)) continue; - priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE; + priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; priv->num_stations--; BUG_ON(priv->num_stations < 0); kfree(priv->stations[i].lq); @@ -679,31 +679,31 @@ void iwl_legacy_dealloc_bcast_stations(struct iwl_priv *priv) } spin_unlock_irqrestore(&priv->sta_lock, flags); } -EXPORT_SYMBOL_GPL(iwl_legacy_dealloc_bcast_stations); +EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static void iwl_legacy_dump_lq_cmd(struct iwl_priv *priv, - struct iwl_link_quality_cmd *lq) +static void il_dump_lq_cmd(struct il_priv *priv, + struct il_link_quality_cmd *lq) { int i; - IWL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id); - IWL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n", + IL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id); + IL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - IWL_DEBUG_RATE(priv, "lq index %d 0x%X\n", + IL_DEBUG_RATE(priv, "lq index %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else -static inline void iwl_legacy_dump_lq_cmd(struct iwl_priv *priv, - struct iwl_link_quality_cmd *lq) +static inline void il_dump_lq_cmd(struct il_priv *priv, + struct il_link_quality_cmd *lq) { } #endif /** - * iwl_legacy_is_lq_table_valid() - Test one aspect of LQ cmd for validity + * il_is_lq_table_valid() - Test one aspect of LQ cmd for validity * * It sometimes happens when a HT rate has been in use and we * loose connectivity with AP then mac80211 will first tell us that the @@ -713,21 +713,21 @@ static inline void iwl_legacy_dump_lq_cmd(struct iwl_priv *priv, * Test for this to prevent driver from sending LQ command between the time * RXON flags are updated and when LQ command is updated. */ -static bool iwl_legacy_is_lq_table_valid(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, - struct iwl_link_quality_cmd *lq) +static bool il_is_lq_table_valid(struct il_priv *priv, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq) { int i; if (ctx->ht.enabled) return true; - IWL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n", + IL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "index %d of LQ expects HT channel\n", i); return false; @@ -737,7 +737,7 @@ static bool iwl_legacy_is_lq_table_valid(struct iwl_priv *priv, } /** - * iwl_legacy_send_lq_cmd() - Send link quality command + * il_send_lq_cmd() - Send link quality command * @init: This command is sent as part of station initialization right * after station has been added. * @@ -746,35 +746,35 @@ static bool iwl_legacy_is_lq_table_valid(struct iwl_priv *priv, * this case to clear the state indicating that station creation is in * progress. */ -int iwl_legacy_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, - struct iwl_link_quality_cmd *lq, u8 flags, bool init) +int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init) { int ret = 0; unsigned long flags_spin; - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_TX_LINK_QUALITY_CMD, - .len = sizeof(struct iwl_link_quality_cmd), + .len = sizeof(struct il_link_quality_cmd), .flags = flags, .data = lq, }; - if (WARN_ON(lq->sta_id == IWL_INVALID_STATION)) + if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) return -EINVAL; spin_lock_irqsave(&priv->sta_lock, flags_spin); - if (!(priv->stations[lq->sta_id].used & IWL_STA_DRIVER_ACTIVE)) { + if (!(priv->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EINVAL; } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - iwl_legacy_dump_lq_cmd(priv, lq); + il_dump_lq_cmd(priv, lq); BUG_ON(init && (cmd.flags & CMD_ASYNC)); - if (iwl_legacy_is_lq_table_valid(priv, ctx, lq)) - ret = iwl_legacy_send_cmd(priv, &cmd); + if (il_is_lq_table_valid(priv, ctx, lq)) + ret = il_send_cmd(priv, &cmd); else ret = -EINVAL; @@ -782,35 +782,35 @@ int iwl_legacy_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, return ret; if (init) { - IWL_DEBUG_INFO(priv, "init LQ command complete," + IL_DEBUG_INFO(priv, "init LQ command complete," " clearing sta addition status for sta %d\n", lq->sta_id); spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } return ret; } -EXPORT_SYMBOL(iwl_legacy_send_lq_cmd); +EXPORT_SYMBOL(il_send_lq_cmd); -int iwl_legacy_mac_sta_remove(struct ieee80211_hw *hw, +int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; - struct iwl_station_priv_common *sta_common = (void *)sta->drv_priv; + struct il_priv *priv = hw->priv; + struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - IWL_DEBUG_INFO(priv, "received request to remove station %pM\n", + IL_DEBUG_INFO(priv, "received request to remove station %pM\n", sta->addr); mutex_lock(&priv->mutex); - IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", + IL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", sta->addr); - ret = iwl_legacy_remove_station(priv, sta_common->sta_id, sta->addr); + ret = il_remove_station(priv, sta_common->sta_id, sta->addr); if (ret) - IWL_ERR(priv, "Error removing station %pM\n", + IL_ERR(priv, "Error removing station %pM\n", sta->addr); mutex_unlock(&priv->mutex); return ret; } -EXPORT_SYMBOL(iwl_legacy_mac_sta_remove); +EXPORT_SYMBOL(il_mac_sta_remove); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index 67bd75f..555b060 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -26,65 +26,65 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * *****************************************************************************/ -#ifndef __iwl_legacy_sta_h__ -#define __iwl_legacy_sta_h__ +#ifndef __il_sta_h__ +#define __il_sta_h__ #include "iwl-dev.h" #define HW_KEY_DYNAMIC 0 #define HW_KEY_DEFAULT 1 -#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ -#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ -#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of +#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ +#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ +#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of being activated */ -#define IWL_STA_LOCAL BIT(3) /* station state not directed by mac80211; +#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; (this is for the IBSS BSSID stations) */ -#define IWL_STA_BCAST BIT(4) /* this station is the special bcast station */ - - -void iwl_legacy_restore_stations(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -void iwl_legacy_clear_ucode_stations(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -void iwl_legacy_dealloc_bcast_stations(struct iwl_priv *priv); -int iwl_legacy_get_free_ucode_key_index(struct iwl_priv *priv); -int iwl_legacy_send_add_sta(struct iwl_priv *priv, - struct iwl_legacy_addsta_cmd *sta, u8 flags); -int iwl_legacy_add_station_common(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ + + +void il_restore_stations(struct il_priv *priv, + struct il_rxon_context *ctx); +void il_clear_ucode_stations(struct il_priv *priv, + struct il_rxon_context *ctx); +void il_dealloc_bcast_stations(struct il_priv *priv); +int il_get_free_ucode_key_index(struct il_priv *priv); +int il_send_add_sta(struct il_priv *priv, + struct il_addsta_cmd *sta, u8 flags); +int il_add_station_common(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r); -int iwl_legacy_remove_station(struct iwl_priv *priv, +int il_remove_station(struct il_priv *priv, const u8 sta_id, const u8 *addr); -int iwl_legacy_mac_sta_remove(struct ieee80211_hw *hw, +int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -u8 iwl_legacy_prep_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +u8 il_prep_station(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta); -int iwl_legacy_send_lq_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, - struct iwl_link_quality_cmd *lq, +int il_send_lq_cmd(struct il_priv *priv, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init); /** - * iwl_legacy_clear_driver_stations - clear knowledge of all stations from driver + * il_clear_driver_stations - clear knowledge of all stations from driver * @priv: iwl priv struct * - * This is called during iwl_down() to make sure that in the case + * This is called during il_down() to make sure that in the case * we're coming there from a hardware restart mac80211 will be * able to reconfigure stations -- if we're getting there in the * normal down flow then the stations will already be cleared. */ -static inline void iwl_legacy_clear_driver_stations(struct iwl_priv *priv) +static inline void il_clear_driver_stations(struct il_priv *priv) { unsigned long flags; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; spin_lock_irqsave(&priv->sta_lock, flags); memset(priv->stations, 0, sizeof(priv->stations)); @@ -107,16 +107,16 @@ static inline void iwl_legacy_clear_driver_stations(struct iwl_priv *priv) spin_unlock_irqrestore(&priv->sta_lock, flags); } -static inline int iwl_legacy_sta_id(struct ieee80211_sta *sta) +static inline int il_sta_id(struct ieee80211_sta *sta) { if (WARN_ON(!sta)) - return IWL_INVALID_STATION; + return IL_INVALID_STATION; - return ((struct iwl_station_priv_common *)sta->drv_priv)->sta_id; + return ((struct il_station_priv_common *)sta->drv_priv)->sta_id; } /** - * iwl_legacy_sta_id_or_broadcast - return sta_id or broadcast sta + * il_sta_id_or_broadcast - return sta_id or broadcast sta * @priv: iwl priv * @context: the current context * @sta: mac80211 station @@ -126,8 +126,8 @@ static inline int iwl_legacy_sta_id(struct ieee80211_sta *sta) * that case, we need to use the broadcast station, so this * inline wraps that pattern. */ -static inline int iwl_legacy_sta_id_or_broadcast(struct iwl_priv *priv, - struct iwl_rxon_context *context, +static inline int il_sta_id_or_broadcast(struct il_priv *priv, + struct il_rxon_context *context, struct ieee80211_sta *sta) { int sta_id; @@ -135,14 +135,14 @@ static inline int iwl_legacy_sta_id_or_broadcast(struct iwl_priv *priv, if (!sta) return context->bcast_sta_id; - sta_id = iwl_legacy_sta_id(sta); + sta_id = il_sta_id(sta); /* * mac80211 should not be passing a partially * initialised station! */ - WARN_ON(sta_id == IWL_INVALID_STATION); + WARN_ON(sta_id == IL_INVALID_STATION); return sta_id; } -#endif /* __iwl_legacy_sta_h__ */ +#endif /* __il_sta_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index e1a559b..1c27c60 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -39,10 +39,10 @@ #include "iwl-helpers.h" /** - * iwl_legacy_txq_update_write_ptr - Send new write index to hardware + * il_txq_update_write_ptr - Send new write index to hardware */ void -iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) +il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) { u32 reg = 0; int txq_id = txq->q.id; @@ -55,18 +55,18 @@ iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ - reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); + reg = il_read32(priv, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Tx queue %d requesting wakeup," " GP1 = 0x%x\n", txq_id, reg); - iwl_legacy_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); return; } - iwl_legacy_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(priv, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* @@ -75,45 +75,45 @@ iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - iwl_write32(priv, HBUS_TARG_WRPTR, + il_write32(priv, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } -EXPORT_SYMBOL(iwl_legacy_txq_update_write_ptr); +EXPORT_SYMBOL(il_txq_update_write_ptr); /** - * iwl_legacy_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's + * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's */ -void iwl_legacy_tx_queue_unmap(struct iwl_priv *priv, int txq_id) +void il_tx_queue_unmap(struct il_priv *priv, int txq_id) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; if (q->n_bd == 0) return; while (q->write_ptr != q->read_ptr) { priv->cfg->ops->lib->txq_free_tfd(priv, txq); - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd); + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } -EXPORT_SYMBOL(iwl_legacy_tx_queue_unmap); +EXPORT_SYMBOL(il_tx_queue_unmap); /** - * iwl_legacy_tx_queue_free - Deallocate DMA queue. + * il_tx_queue_free - Deallocate DMA queue. * @txq: Transmit queue to deallocate. * * Empty queue by removing and destroying all BD's. * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void iwl_legacy_tx_queue_free(struct iwl_priv *priv, int txq_id) +void il_tx_queue_free(struct il_priv *priv, int txq_id) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &priv->txq[txq_id]; struct device *dev = &priv->pci_dev->dev; int i; - iwl_legacy_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(priv, txq_id); /* De-alloc array of command/tx buffers */ for (i = 0; i < TFD_TX_CMD_SLOTS; i++) @@ -137,22 +137,22 @@ void iwl_legacy_tx_queue_free(struct iwl_priv *priv, int txq_id) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } -EXPORT_SYMBOL(iwl_legacy_tx_queue_free); +EXPORT_SYMBOL(il_tx_queue_free); /** - * iwl_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue + * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue */ -void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv) +void il_cmd_queue_unmap(struct il_priv *priv) { - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_queue *q = &txq->q; int i; if (q->n_bd == 0) return; while (q->read_ptr != q->write_ptr) { - i = iwl_legacy_get_cmd_index(q, q->read_ptr, 0); + i = il_get_cmd_index(q, q->read_ptr, 0); if (txq->meta[i].flags & CMD_MAPPED) { pci_unmap_single(priv->pci_dev, @@ -162,7 +162,7 @@ void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv) txq->meta[i].flags = 0; } - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd); + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } i = q->n_window; @@ -174,23 +174,23 @@ void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv) txq->meta[i].flags = 0; } } -EXPORT_SYMBOL(iwl_legacy_cmd_queue_unmap); +EXPORT_SYMBOL(il_cmd_queue_unmap); /** - * iwl_legacy_cmd_queue_free - Deallocate DMA queue. + * il_cmd_queue_free - Deallocate DMA queue. * @txq: Transmit queue to deallocate. * * Empty queue by removing and destroying all BD's. * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void iwl_legacy_cmd_queue_free(struct iwl_priv *priv) +void il_cmd_queue_free(struct il_priv *priv) { - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; struct device *dev = &priv->pci_dev->dev; int i; - iwl_legacy_cmd_queue_unmap(priv); + il_cmd_queue_unmap(priv); /* De-alloc array of command/tx buffers */ for (i = 0; i <= TFD_CMD_SLOTS; i++) @@ -210,7 +210,7 @@ void iwl_legacy_cmd_queue_free(struct iwl_priv *priv) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } -EXPORT_SYMBOL(iwl_legacy_cmd_queue_free); +EXPORT_SYMBOL(il_cmd_queue_free); /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** * DMA services @@ -235,7 +235,7 @@ EXPORT_SYMBOL(iwl_legacy_cmd_queue_free); * See more detailed info in iwl-4965-hw.h. ***************************************************/ -int iwl_legacy_queue_space(const struct iwl_queue *q) +int il_queue_space(const struct il_queue *q) { int s = q->read_ptr - q->write_ptr; @@ -250,25 +250,25 @@ int iwl_legacy_queue_space(const struct iwl_queue *q) s = 0; return s; } -EXPORT_SYMBOL(iwl_legacy_queue_space); +EXPORT_SYMBOL(il_queue_space); /** - * iwl_legacy_queue_init - Initialize queue's high/low-water and read/write indexes + * il_queue_init - Initialize queue's high/low-water and read/write indexes */ -static int iwl_legacy_queue_init(struct iwl_priv *priv, struct iwl_queue *q, +static int il_queue_init(struct il_priv *priv, struct il_queue *q, int count, int slots_num, u32 id) { q->n_bd = count; q->n_window = slots_num; q->id = id; - /* count must be power-of-two size, otherwise iwl_legacy_queue_inc_wrap - * and iwl_legacy_queue_dec_wrap are broken. */ + /* count must be power-of-two size, otherwise il_queue_inc_wrap + * and il_queue_dec_wrap are broken. */ BUG_ON(!is_power_of_2(count)); /* slots_num must be power-of-two size, otherwise - * iwl_legacy_get_cmd_index is broken. */ + * il_get_cmd_index is broken. */ BUG_ON(!is_power_of_2(slots_num)); q->low_mark = q->n_window / 4; @@ -285,10 +285,10 @@ static int iwl_legacy_queue_init(struct iwl_priv *priv, struct iwl_queue *q, } /** - * iwl_legacy_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue + * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue */ -static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, - struct iwl_tx_queue *txq, u32 id) +static int il_tx_queue_alloc(struct il_priv *priv, + struct il_tx_queue *txq, u32 id) { struct device *dev = &priv->pci_dev->dev; size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; @@ -299,7 +299,7 @@ static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, txq->txb = kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, GFP_KERNEL); if (!txq->txb) { - IWL_ERR(priv, "kmalloc for auxiliary BD " + IL_ERR(priv, "kmalloc for auxiliary BD " "structures failed\n"); goto error; } @@ -312,7 +312,7 @@ static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { - IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); + IL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; } txq->q.id = id; @@ -327,9 +327,9 @@ static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, } /** - * iwl_legacy_tx_queue_init - Allocate and initialize one tx/cmd queue + * il_tx_queue_init - Allocate and initialize one tx/cmd queue */ -int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, +int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int i, len; @@ -347,19 +347,19 @@ int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, if (txq_id == priv->cmd_queue) actual_slots++; - txq->meta = kzalloc(sizeof(struct iwl_cmd_meta) * actual_slots, + txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); - txq->cmd = kzalloc(sizeof(struct iwl_device_cmd *) * actual_slots, + txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL); if (!txq->meta || !txq->cmd) goto out_free_arrays; - len = sizeof(struct iwl_device_cmd); + len = sizeof(struct il_device_cmd); for (i = 0; i < actual_slots; i++) { /* only happens for cmd queue */ if (i == slots_num) - len = IWL_MAX_CMD_SIZE; + len = IL_MAX_CMD_SIZE; txq->cmd[i] = kmalloc(len, GFP_KERNEL); if (!txq->cmd[i]) @@ -367,7 +367,7 @@ int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, } /* Alloc driver data array and TFD circular buffer */ - ret = iwl_legacy_tx_queue_alloc(priv, txq, txq_id); + ret = il_tx_queue_alloc(priv, txq, txq_id); if (ret) goto err; @@ -379,14 +379,14 @@ int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, * (if they need one at all). */ if (txq_id < 4) - iwl_legacy_set_swq_id(txq, txq_id, txq_id); + il_set_swq_id(txq, txq_id, txq_id); /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise - * iwl_legacy_queue_inc_wrap and iwl_legacy_queue_dec_wrap are broken. */ + * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); /* Initialize queue's high/low-water marks, and head/tail indexes */ - iwl_legacy_queue_init(priv, &txq->q, + il_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ @@ -402,9 +402,9 @@ out_free_arrays: return -ENOMEM; } -EXPORT_SYMBOL(iwl_legacy_tx_queue_init); +EXPORT_SYMBOL(il_tx_queue_init); -void iwl_legacy_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq, +void il_tx_queue_reset(struct il_priv *priv, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int actual_slots = slots_num; @@ -412,23 +412,23 @@ void iwl_legacy_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq, if (txq_id == priv->cmd_queue) actual_slots++; - memset(txq->meta, 0, sizeof(struct iwl_cmd_meta) * actual_slots); + memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); txq->need_update = 0; /* Initialize queue's high/low-water marks, and head/tail indexes */ - iwl_legacy_queue_init(priv, &txq->q, + il_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ priv->cfg->ops->lib->txq_init(priv, txq); } -EXPORT_SYMBOL(iwl_legacy_tx_queue_reset); +EXPORT_SYMBOL(il_tx_queue_reset); /*************** HOST COMMAND QUEUE FUNCTIONS *****/ /** - * iwl_legacy_enqueue_hcmd - enqueue a uCode command + * il_enqueue_hcmd - enqueue a uCode command * @priv: device private data point * @cmd: a point to the ucode command structure * @@ -436,12 +436,12 @@ EXPORT_SYMBOL(iwl_legacy_tx_queue_reset); * failed. On success, it turns the index (> 0) of command in the * command queue. */ -int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) { - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; - struct iwl_queue *q = &txq->q; - struct iwl_device_cmd *out_cmd; - struct iwl_cmd_meta *out_meta; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_queue *q = &txq->q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; dma_addr_t phys_addr; unsigned long flags; int len; @@ -458,25 +458,25 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) * of device_cmd and max_cmd_size. */ BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && !(cmd->flags & CMD_SIZE_HUGE)); - BUG_ON(fix_size > IWL_MAX_CMD_SIZE); + BUG_ON(fix_size > IL_MAX_CMD_SIZE); - if (iwl_legacy_is_rfkill(priv) || iwl_legacy_is_ctkill(priv)) { - IWL_WARN(priv, "Not sending command - %s KILL\n", - iwl_legacy_is_rfkill(priv) ? "RF" : "CT"); + if (il_is_rfkill(priv) || il_is_ctkill(priv)) { + IL_WARN(priv, "Not sending command - %s KILL\n", + il_is_rfkill(priv) ? "RF" : "CT"); return -EIO; } spin_lock_irqsave(&priv->hcmd_lock, flags); - if (iwl_legacy_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { + if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { spin_unlock_irqrestore(&priv->hcmd_lock, flags); - IWL_ERR(priv, "Restarting adapter due to command queue full\n"); + IL_ERR(priv, "Restarting adapter due to command queue full\n"); queue_work(priv->workqueue, &priv->restart); return -ENOSPC; } - idx = iwl_legacy_get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); + idx = il_get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); out_cmd = txq->cmd[idx]; out_meta = &txq->meta[idx]; @@ -503,26 +503,26 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) INDEX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; - len = sizeof(struct iwl_device_cmd); + len = sizeof(struct il_device_cmd); if (idx == TFD_CMD_SLOTS) - len = IWL_MAX_CMD_SIZE; + len = IL_MAX_CMD_SIZE; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IWL_DEBUG_HC_DUMP(priv, + IL_DEBUG_HC_DUMP(priv, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", - iwl_legacy_get_cmd_string(out_cmd->hdr.cmd), + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->write_ptr, idx, priv->cmd_queue); break; default: - IWL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, " + IL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", - iwl_legacy_get_cmd_string(out_cmd->hdr.cmd), + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->write_ptr, idx, priv->cmd_queue); @@ -544,39 +544,39 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) U32_PAD(cmd->len)); /* Increment and update queue's write index */ - q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); - iwl_legacy_txq_update_write_ptr(priv, txq); + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->hcmd_lock, flags); return idx; } /** - * iwl_legacy_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd + * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd * * When FW advances 'R' index, all entries between old and new 'R' index * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void iwl_legacy_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, +static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, int idx, int cmd_idx) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; int nfreed = 0; - if ((idx >= q->n_bd) || (iwl_legacy_queue_used(q, idx) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; } - for (idx = iwl_legacy_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IWL_ERR(priv, "HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR(priv, "HCMD skipped: index (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); queue_work(priv->workqueue, &priv->restart); } @@ -585,7 +585,7 @@ static void iwl_legacy_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, } /** - * iwl_legacy_tx_cmd_complete - Pull unused buffers off the queue and reclaim them + * il_tx_cmd_complete - Pull unused buffers off the queue and reclaim them * @rxb: Rx buffer to reclaim * * If an Rx buffer has an async callback associated with it the callback @@ -593,17 +593,17 @@ static void iwl_legacy_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, * if the callback returns 1 */ void -iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) +il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); int cmd_index; bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); - struct iwl_device_cmd *cmd; - struct iwl_cmd_meta *meta; - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_device_cmd *cmd; + struct il_cmd_meta *meta; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; unsigned long flags; /* If a Tx command is being handled and it isn't in the actual @@ -614,11 +614,11 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) txq_id, priv->cmd_queue, sequence, priv->txq[priv->cmd_queue].q.read_ptr, priv->txq[priv->cmd_queue].q.write_ptr)) { - iwl_print_hex_error(priv, pkt, 32); + il_print_hex_error(priv, pkt, 32); return; } - cmd_index = iwl_legacy_get_cmd_index(&txq->q, index, huge); + cmd_index = il_get_cmd_index(&txq->q, index, huge); cmd = txq->cmd[cmd_index]; meta = &txq->meta[cmd_index]; @@ -638,12 +638,12 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) spin_lock_irqsave(&priv->hcmd_lock, flags); - iwl_legacy_hcmd_queue_reclaim(priv, txq_id, index, cmd_index); + il_hcmd_queue_reclaim(priv, txq_id, index, cmd_index); if (!(meta->flags & CMD_ASYNC)) { clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd)); + IL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->hdr.cmd)); wake_up(&priv->wait_command_queue); } @@ -652,4 +652,4 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) spin_unlock_irqrestore(&priv->hcmd_lock, flags); } -EXPORT_SYMBOL(iwl_legacy_tx_cmd_complete); +EXPORT_SYMBOL(il_tx_cmd_complete); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 7507819..d24937a 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -89,7 +89,7 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); /* module parameters */ -struct iwl_mod_params iwl3945_mod_params = { +struct il_mod_params il3945_mod_params = { .sw_crypto = 1, .restart_fw = 1, .disable_hw_scan = 1, @@ -97,43 +97,43 @@ struct iwl_mod_params iwl3945_mod_params = { }; /** - * iwl3945_get_antenna_flags - Get antenna flags for RXON command + * il3945_get_antenna_flags - Get antenna flags for RXON command * @priv: eeprom and antenna fields are used to determine antenna flags * * priv->eeprom39 is used to determine if antenna AUX/MAIN are reversed - * iwl3945_mod_params.antenna specifies the antenna diversity mode: + * il3945_mod_params.antenna specifies the antenna diversity mode: * - * IWL_ANTENNA_DIVERSITY - NIC selects best antenna by itself - * IWL_ANTENNA_MAIN - Force MAIN antenna - * IWL_ANTENNA_AUX - Force AUX antenna + * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself + * IL_ANTENNA_MAIN - Force MAIN antenna + * IL_ANTENNA_AUX - Force AUX antenna */ -__le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv) +__le32 il3945_get_antenna_flags(const struct il_priv *priv) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; - switch (iwl3945_mod_params.antenna) { - case IWL_ANTENNA_DIVERSITY: + switch (il3945_mod_params.antenna) { + case IL_ANTENNA_DIVERSITY: return 0; - case IWL_ANTENNA_MAIN: + case IL_ANTENNA_MAIN: if (eeprom->antenna_switch_type) return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; - case IWL_ANTENNA_AUX: + case IL_ANTENNA_AUX: if (eeprom->antenna_switch_type) return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; } /* bad antenna selector value */ - IWL_ERR(priv, "Bad antenna selector value (0x%x)\n", - iwl3945_mod_params.antenna); + IL_ERR(priv, "Bad antenna selector value (0x%x)\n", + il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ } -static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, +static int il3945_set_ccmp_dynamic_key_info(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { @@ -144,7 +144,7 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - if (sta_id == priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; @@ -163,7 +163,7 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -174,9 +174,9 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - IWL_DEBUG_INFO(priv, "hwcrypto: modify ucode station key info\n"); + IL_DEBUG_INFO(priv, "hwcrypto: modify ucode station key info\n"); - ret = iwl_legacy_send_add_sta(priv, + ret = il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags); @@ -184,40 +184,40 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, return ret; } -static int iwl3945_set_tkip_dynamic_key_info(struct iwl_priv *priv, +static int il3945_set_tkip_dynamic_key_info(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int iwl3945_set_wep_dynamic_key_info(struct iwl_priv *priv, +static int il3945_set_wep_dynamic_key_info(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int iwl3945_clear_sta_key_info(struct iwl_priv *priv, u8 sta_id) +static int il3945_clear_sta_key_info(struct il_priv *priv, u8 sta_id) { unsigned long flags; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; spin_lock_irqsave(&priv->sta_lock, flags); - memset(&priv->stations[sta_id].keyinfo, 0, sizeof(struct iwl_hw_key)); + memset(&priv->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); memset(&priv->stations[sta_id].sta.key, 0, - sizeof(struct iwl4965_keyinfo)); + sizeof(struct il4965_keyinfo)); priv->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_legacy_addsta_cmd)); + memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - IWL_DEBUG_INFO(priv, "hwcrypto: clear ucode station key info\n"); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + IL_DEBUG_INFO(priv, "hwcrypto: clear ucode station key info\n"); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -static int iwl3945_set_dynamic_key(struct iwl_priv *priv, +static int il3945_set_dynamic_key(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret = 0; @@ -226,75 +226,75 @@ static int iwl3945_set_dynamic_key(struct iwl_priv *priv, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = iwl3945_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = iwl3945_set_tkip_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_tkip_dynamic_key_info(priv, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = iwl3945_set_wep_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_wep_dynamic_key_info(priv, keyconf, sta_id); break; default: - IWL_ERR(priv, "Unknown alg: %s alg=%x\n", __func__, + IL_ERR(priv, "Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IWL_DEBUG_WEP(priv, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + IL_DEBUG_WEP(priv, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } -static int iwl3945_remove_static_key(struct iwl_priv *priv) +static int il3945_remove_static_key(struct il_priv *priv) { int ret = -EOPNOTSUPP; return ret; } -static int iwl3945_set_static_key(struct iwl_priv *priv, +static int il3945_set_static_key(struct il_priv *priv, struct ieee80211_key_conf *key) { if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) return -EOPNOTSUPP; - IWL_ERR(priv, "Static key invalid: cipher %x\n", key->cipher); + IL_ERR(priv, "Static key invalid: cipher %x\n", key->cipher); return -EINVAL; } -static void iwl3945_clear_free_frames(struct iwl_priv *priv) +static void il3945_clear_free_frames(struct il_priv *priv) { struct list_head *element; - IWL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", + IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", priv->frames_count); while (!list_empty(&priv->free_frames)) { element = priv->free_frames.next; list_del(element); - kfree(list_entry(element, struct iwl3945_frame, list)); + kfree(list_entry(element, struct il3945_frame, list)); priv->frames_count--; } if (priv->frames_count) { - IWL_WARN(priv, "%d frames still in use. Did we lose one?\n", + IL_WARN(priv, "%d frames still in use. Did we lose one?\n", priv->frames_count); priv->frames_count = 0; } } -static struct iwl3945_frame *iwl3945_get_free_frame(struct iwl_priv *priv) +static struct il3945_frame *il3945_get_free_frame(struct il_priv *priv) { - struct iwl3945_frame *frame; + struct il3945_frame *frame; struct list_head *element; if (list_empty(&priv->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IWL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(priv, "Could not allocate frame!\n"); return NULL; } @@ -304,21 +304,21 @@ static struct iwl3945_frame *iwl3945_get_free_frame(struct iwl_priv *priv) element = priv->free_frames.next; list_del(element); - return list_entry(element, struct iwl3945_frame, list); + return list_entry(element, struct il3945_frame, list); } -static void iwl3945_free_frame(struct iwl_priv *priv, struct iwl3945_frame *frame) +static void il3945_free_frame(struct il_priv *priv, struct il3945_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &priv->free_frames); } -unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv, +unsigned int il3945_fill_beacon_frame(struct il_priv *priv, struct ieee80211_hdr *hdr, int left) { - if (!iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS) || !priv->beacon_skb) + if (!il_is_associated(priv, IL_RXON_CTX_BSS) || !priv->beacon_skb) return 0; if (priv->beacon_skb->len > left) @@ -329,51 +329,51 @@ unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv, return priv->beacon_skb->len; } -static int iwl3945_send_beacon_cmd(struct iwl_priv *priv) +static int il3945_send_beacon_cmd(struct il_priv *priv) { - struct iwl3945_frame *frame; + struct il3945_frame *frame; unsigned int frame_size; int rc; u8 rate; - frame = iwl3945_get_free_frame(priv); + frame = il3945_get_free_frame(priv); if (!frame) { - IWL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(priv, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - rate = iwl_legacy_get_lowest_plcp(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + rate = il_get_lowest_plcp(priv, + &priv->contexts[IL_RXON_CTX_BSS]); - frame_size = iwl3945_hw_get_beacon_cmd(priv, frame, rate); + frame_size = il3945_hw_get_beacon_cmd(priv, frame, rate); - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - iwl3945_free_frame(priv, frame); + il3945_free_frame(priv, frame); return rc; } -static void iwl3945_unset_hw_params(struct iwl_priv *priv) +static void il3945_unset_hw_params(struct il_priv *priv) { if (priv->_3945.shared_virt) dma_free_coherent(&priv->pci_dev->dev, - sizeof(struct iwl3945_shared), + sizeof(struct il3945_shared), priv->_3945.shared_virt, priv->_3945.shared_phys); } -static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, +static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, struct ieee80211_tx_info *info, - struct iwl_device_cmd *cmd, + struct il_device_cmd *cmd, struct sk_buff *skb_frag, int sta_id) { - struct iwl3945_tx_cmd *tx_cmd = (struct iwl3945_tx_cmd *)cmd->cmd.payload; - struct iwl_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + struct il_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; tx_cmd->sec_ctl = 0; @@ -381,7 +381,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, case WLAN_CIPHER_SUITE_CCMP: tx_cmd->sec_ctl = TX_CMD_SEC_CCM; memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: @@ -396,12 +396,12 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " "with key %d\n", info->control.hw_key->hw_key_idx); break; default: - IWL_ERR(priv, "Unknown encode cipher %x\n", keyinfo->cipher); + IL_ERR(priv, "Unknown encode cipher %x\n", keyinfo->cipher); break; } } @@ -409,12 +409,12 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, /* * handle build REPLY_TX command notification. */ -static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, +static void il3945_build_tx_cmd_basic(struct il_priv *priv, + struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, u8 std_id) { - struct iwl3945_tx_cmd *tx_cmd = (struct iwl3945_tx_cmd *)cmd->cmd.payload; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; __le32 tx_flags = tx_cmd->tx_flags; __le16 fc = hdr->frame_control; @@ -443,7 +443,7 @@ static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - iwl_legacy_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(priv, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -463,15 +463,15 @@ static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv, /* * start REPLY_TX command process */ -static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) +static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct iwl3945_tx_cmd *tx_cmd; - struct iwl_tx_queue *txq = NULL; - struct iwl_queue *q = NULL; - struct iwl_device_cmd *out_cmd; - struct iwl_cmd_meta *out_meta; + struct il3945_tx_cmd *tx_cmd; + struct il_tx_queue *txq = NULL; + struct il_queue *q = NULL; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; dma_addr_t phys_addr; dma_addr_t txcmd_phys; int txq_id = skb_get_queue_mapping(skb); @@ -485,13 +485,13 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) unsigned long flags; spin_lock_irqsave(&priv->lock, flags); - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + if (il_is_rfkill(priv)) { + IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); goto drop_unlock; } - if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == IWL_INVALID_RATE) { - IWL_ERR(priv, "ERROR: No TX rate available.\n"); + if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + IL_ERR(priv, "ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -502,11 +502,11 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IWL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(priv, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); #endif spin_unlock_irqrestore(&priv->lock, flags); @@ -514,16 +514,16 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) hdr_len = ieee80211_hdrlen(fc); /* Find index into station table for destination station */ - sta_id = iwl_legacy_sta_id_or_broadcast( - priv, &priv->contexts[IWL_RXON_CTX_BSS], + sta_id = il_sta_id_or_broadcast( + priv, &priv->contexts[IL_RXON_CTX_BSS], info->control.sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + if (sta_id == IL_INVALID_STATION) { + IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } - IWL_DEBUG_RATE(priv, "station Id %d\n", sta_id); + IL_DEBUG_RATE(priv, "station Id %d\n", sta_id); if (ieee80211_is_data_qos(fc)) { u8 *qc = ieee80211_get_qos_ctl(hdr); @@ -536,22 +536,22 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) txq = &priv->txq[txq_id]; q = &txq->q; - if ((iwl_legacy_queue_space(q) < q->high_mark)) + if ((il_queue_space(q) < q->high_mark)) goto drop; spin_lock_irqsave(&priv->lock, flags); - idx = iwl_legacy_get_cmd_index(q, q->write_ptr, 0); + idx = il_get_cmd_index(q, q->write_ptr, 0); /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + txq->txb[q->write_ptr].ctx = &priv->contexts[IL_RXON_CTX_BSS]; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; out_meta = &txq->meta[idx]; - tx_cmd = (struct iwl3945_tx_cmd *)out_cmd->cmd.payload; + tx_cmd = (struct il3945_tx_cmd *)out_cmd->cmd.payload; memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); memset(tx_cmd, 0, sizeof(*tx_cmd)); @@ -570,20 +570,20 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) if (info->control.hw_key) - iwl3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, sta_id); + il3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - iwl3945_build_tx_cmd_basic(priv, out_cmd, info, hdr, sta_id); + il3945_build_tx_cmd_basic(priv, out_cmd, info, hdr, sta_id); /* set is_hcca to 0; it probably will never be implemented */ - iwl3945_hw_build_tx_cmd_rate(priv, out_cmd, info, hdr, sta_id, 0); + il3945_hw_build_tx_cmd_rate(priv, out_cmd, info, hdr, sta_id, 0); /* Total # bytes to be transmitted */ len = (u16)skb->len; tx_cmd->len = cpu_to_le16(len); - iwl_legacy_dbg_log_tx_data_frame(priv, len, hdr); - iwl_legacy_update_stats(priv, true, fc, len); + il_dbg_log_tx_data_frame(priv, len, hdr); + il_update_stats(priv, true, fc, len); tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; @@ -594,11 +594,11 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) txq->need_update = 0; } - IWL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IWL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - iwl_print_hex_dump(priv, IWL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, + IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(priv, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, ieee80211_hdrlen(fc)); /* @@ -610,8 +610,8 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct iwl3945_tx_cmd) + - sizeof(struct iwl_cmd_header) + hdr_len; + len = sizeof(struct il3945_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; len = (len + 3) & ~3; /* Physical address of this Tx command's header (not MAC header!), @@ -642,20 +642,20 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) /* Tell device the write index *just past* this latest filled TFD */ - q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); - iwl_legacy_txq_update_write_ptr(priv, txq); + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); - if ((iwl_legacy_queue_space(q) < q->high_mark) + if ((il_queue_space(q) < q->high_mark) && priv->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&priv->lock, flags); txq->need_update = 1; - iwl_legacy_txq_update_write_ptr(priv, txq); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); } - iwl_legacy_stop_queue(priv, txq); + il_stop_queue(priv, txq); } return 0; @@ -666,13 +666,13 @@ drop: return -1; } -static int iwl3945_get_measurement(struct iwl_priv *priv, +static int il3945_get_measurement(struct il_priv *priv, struct ieee80211_measurement_params *params, u8 type) { - struct iwl_spectrum_cmd spectrum; - struct iwl_rx_packet *pkt; - struct iwl_host_cmd cmd = { + struct il_spectrum_cmd spectrum; + struct il_rx_packet *pkt; + struct il_host_cmd cmd = { .id = REPLY_SPECTRUM_MEASUREMENT_CMD, .data = (void *)&spectrum, .flags = CMD_WANT_SKB, @@ -681,10 +681,10 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, int rc; int spectrum_resp_status; int duration = le16_to_cpu(params->duration); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) - add_time = iwl_legacy_usecs_to_beacons(priv, + if (il_is_associated(priv, IL_RXON_CTX_BSS)) + add_time = il_usecs_to_beacons(priv, le64_to_cpu(params->start_time) - priv->_3945.last_tsf, le16_to_cpu(ctx->timing.beacon_interval)); @@ -697,9 +697,9 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, cmd.len = sizeof(spectrum); spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) + if (il_is_associated(priv, IL_RXON_CTX_BSS)) spectrum.start_time = - iwl_legacy_add_beacon_time(priv, + il_add_beacon_time(priv, priv->_3945.last_beacon_time, add_time, le16_to_cpu(ctx->timing.beacon_interval)); else @@ -712,13 +712,13 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, spectrum.flags |= RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; - rc = iwl_legacy_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(priv, &cmd); if (rc) return rc; - pkt = (struct iwl_rx_packet *)cmd.reply_page; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_RX_ON_ASSOC command\n"); + pkt = (struct il_rx_packet *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -726,7 +726,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, switch (spectrum_resp_status) { case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { - IWL_DEBUG_INFO(priv, "Replaced existing measurement: %d\n", + IL_DEBUG_INFO(priv, "Replaced existing measurement: %d\n", pkt->u.spectrum.id); priv->measurement_status &= ~MEASUREMENT_READY; } @@ -739,36 +739,36 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, break; } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return rc; } -static void iwl3945_rx_reply_alive(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_alive(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_alive_resp *palive; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; struct delayed_work *pwork; palive = &pkt->u.alive_frame; - IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); memcpy(&priv->card_alive_init, &pkt->u.alive_frame, - sizeof(struct iwl_alive_resp)); + sizeof(struct il_alive_resp)); pwork = &priv->init_alive_start; } else { - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); memcpy(&priv->card_alive, &pkt->u.alive_frame, - sizeof(struct iwl_alive_resp)); + sizeof(struct il_alive_resp)); pwork = &priv->alive_start; - iwl3945_disable_events(priv); + il3945_disable_events(priv); } /* We delay the ALIVE response by 5ms to @@ -777,28 +777,28 @@ static void iwl3945_rx_reply_alive(struct iwl_priv *priv, queue_delayed_work(priv->workqueue, pwork, msecs_to_jiffies(5)); else - IWL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(priv, "uCode did not respond OK.\n"); } -static void iwl3945_rx_reply_add_sta(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_add_sta(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); #endif - IWL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + IL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); } -static void iwl3945_rx_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl3945_beacon_notif *beacon = &(pkt->u.beacon_status); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - IWL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -813,18 +813,18 @@ static void iwl3945_rx_beacon_notif(struct iwl_priv *priv, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_card_state_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = priv->status; - IWL_WARN(priv, "Card state received: HW:%s SW:%s\n", + IL_WARN(priv, "Card state received: HW:%s SW:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(priv, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) @@ -833,7 +833,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, clear_bit(STATUS_RF_KILL_HW, &priv->status); - iwl_legacy_scan_cancel(priv); + il_scan_cancel(priv); if ((test_bit(STATUS_RF_KILL_HW, &status) != test_bit(STATUS_RF_KILL_HW, &priv->status))) @@ -844,7 +844,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, } /** - * iwl3945_setup_rx_handlers - Initialize Rx handler callbacks + * il3945_setup_rx_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -852,32 +852,32 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) +static void il3945_setup_rx_handlers(struct il_priv *priv) { - priv->rx_handlers[REPLY_ALIVE] = iwl3945_rx_reply_alive; - priv->rx_handlers[REPLY_ADD_STA] = iwl3945_rx_reply_add_sta; - priv->rx_handlers[REPLY_ERROR] = iwl_legacy_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_legacy_rx_csa; + priv->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; + priv->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; + priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - iwl_legacy_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl_legacy_rx_pm_sleep_notif; + il_rx_spectrum_measure_notif; + priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - iwl_legacy_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = iwl3945_rx_beacon_notif; + il_rx_pm_debug_statistics_notif; + priv->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics; + priv->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; + priv->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; - iwl_legacy_setup_rx_scan_handlers(priv); - priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl3945_rx_card_state_notif; + il_setup_rx_scan_handlers(priv); + priv->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ - iwl3945_hw_rx_handler_setup(priv); + il3945_hw_rx_handler_setup(priv); } /************************** RX-FUNCTIONS ****************************/ @@ -885,7 +885,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) * Rx theory of operation * * The host allocates 32 DMA target addresses and passes the host address - * to the firmware at register IWL_RFDS_TABLE_LOWER + N * RFD_SIZE where N is + * to the firmware at register IL_RFDS_TABLE_LOWER + N * RFD_SIZE where N is * 0 to 31 * * Rx Queue Indexes @@ -914,7 +914,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. - * + In iwl3945_rx_replenish (scheduled) if 'processed' != 'read' then the + * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ INDEX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, @@ -927,34 +927,34 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) * * Driver sequence: * - * iwl3945_rx_replenish() Replenishes rx_free list from rx_used, and calls - * iwl3945_rx_queue_restock - * iwl3945_rx_queue_restock() Moves available buffers from rx_free into Rx + * il3945_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il3945_rx_queue_restock + * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates * the WRITE index. If insufficient rx_free buffers - * are available, schedules iwl3945_rx_replenish + * are available, schedules il3945_rx_replenish * * -- enable interrupts -- - * ISR - iwl3945_rx() Detach iwl_rx_mem_buffers from pool up to the + * ISR - il3945_rx() Detach il_rx_mem_buffers from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. - * Calls iwl3945_rx_queue_restock to refill any empty + * Calls il3945_rx_queue_restock to refill any empty * slots. * ... * */ /** - * iwl3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl_priv *priv, +static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *priv, dma_addr_t dma_addr) { return cpu_to_le32((u32)dma_addr); } /** - * iwl3945_rx_queue_restock - refill RX queue from pre-allocated pool + * il3945_rx_queue_restock - refill RX queue from pre-allocated pool * * If there are slots in the RX queue that need to be restocked, * and we have free pre-allocated buffers, fill the ranks as much @@ -964,24 +964,24 @@ static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -static void iwl3945_rx_queue_restock(struct iwl_priv *priv) +static void il3945_rx_queue_restock(struct il_priv *priv) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; unsigned long flags; int write; spin_lock_irqsave(&rxq->lock, flags); write = rxq->write & ~0x7; - while ((iwl_legacy_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = iwl3945_dma_addr2rbd_ptr(priv, rxb->page_dma); + rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(priv, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -1000,23 +1000,23 @@ static void iwl3945_rx_queue_restock(struct iwl_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); } } /** - * iwl3945_rx_replenish - Move all used packet from rx_used to rx_free + * il3945_rx_replenish - Move all used packet from rx_used to rx_free * * When moving to rx_free an SKB is allocated for the slot. * - * Also restock the Rx queue via iwl3945_rx_queue_restock. + * Also restock the Rx queue via il3945_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) +static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -1040,10 +1040,10 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IWL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n"); + IL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IWL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will @@ -1059,7 +1059,7 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -1079,7 +1079,7 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) } } -void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -1094,7 +1094,7 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -1108,23 +1108,23 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -void iwl3945_rx_replenish(void *data) +void il3945_rx_replenish(void *data) { - struct iwl_priv *priv = data; + struct il_priv *priv = data; unsigned long flags; - iwl3945_rx_allocate(priv, GFP_KERNEL); + il3945_rx_allocate(priv, GFP_KERNEL); spin_lock_irqsave(&priv->lock, flags); - iwl3945_rx_queue_restock(priv); + il3945_rx_queue_restock(priv); spin_unlock_irqrestore(&priv->lock, flags); } -static void iwl3945_rx_replenish_now(struct iwl_priv *priv) +static void il3945_rx_replenish_now(struct il_priv *priv) { - iwl3945_rx_allocate(priv, GFP_ATOMIC); + il3945_rx_allocate(priv, GFP_ATOMIC); - iwl3945_rx_queue_restock(priv); + il3945_rx_queue_restock(priv); } @@ -1133,7 +1133,7 @@ static void iwl3945_rx_replenish_now(struct iwl_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +static void il3945_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { @@ -1141,14 +1141,14 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } } dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status), + dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; @@ -1173,7 +1173,7 @@ static u8 ratio2dB[100] = { /* Calculates a relative dB value from a ratio of linear * (i.e. not dB) signal levels. * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ -int iwl3945_calc_db_from_ratio(int sig_ratio) +int il3945_calc_db_from_ratio(int sig_ratio) { /* 1000:1 or higher just report as 60 dB */ if (sig_ratio >= 1000) @@ -1193,17 +1193,17 @@ int iwl3945_calc_db_from_ratio(int sig_ratio) } /** - * iwl3945_rx_handle - Main entry function for receiving responses from uCode + * il3945_rx_handle - Main entry function for receiving responses from uCode * * Uses the priv->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -static void iwl3945_rx_handle(struct iwl_priv *priv) +static void il3945_rx_handle(struct il_priv *priv) { - struct iwl_rx_mem_buffer *rxb; - struct iwl_rx_packet *pkt; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_mem_buffer *rxb; + struct il_rx_packet *pkt; + struct il_rx_queue *rxq = &priv->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -1225,7 +1225,7 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) fill_rx = 1; /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); while (i != r) { int len; @@ -1259,17 +1259,17 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See iwl3945_setup_rx_handlers() */ + * rx_handlers table. See il3945_setup_rx_handlers() */ if (priv->rx_handlers[pkt->hdr.cmd]) { - IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, i, - iwl_legacy_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, i, + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); } else { /* No handling needed */ - IWL_DEBUG_RX(priv, + IL_DEBUG_RX(priv, "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, iwl_legacy_get_cmd_string(pkt->hdr.cmd), + r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } @@ -1282,12 +1282,12 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) if (reclaim) { /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking iwl_legacy_send_cmd() + * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - iwl_legacy_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(priv, rxb); else - IWL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(priv, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -1312,7 +1312,7 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) count++; if (count >= 8) { rxq->read = i; - iwl3945_rx_replenish_now(priv); + il3945_rx_replenish_now(priv); count = 0; } } @@ -1321,20 +1321,20 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - iwl3945_rx_replenish_now(priv); + il3945_rx_replenish_now(priv); else - iwl3945_rx_queue_restock(priv); + il3945_rx_queue_restock(priv); } /* call this function to flush any scheduled tasklet */ -static inline void iwl3945_synchronize_irq(struct iwl_priv *priv) +static inline void il3945_synchronize_irq(struct il_priv *priv) { /* wait to make sure we flush pending tasklet*/ synchronize_irq(priv->pci_dev->irq); tasklet_kill(&priv->irq_tasklet); } -static const char *iwl3945_desc_lookup(int i) +static const char *il3945_desc_lookup(int i) { switch (i) { case 1: @@ -1357,7 +1357,7 @@ static const char *iwl3945_desc_lookup(int i) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void iwl3945_dump_nic_error_log(struct iwl_priv *priv) +void il3945_dump_nic_error_log(struct il_priv *priv) { u32 i; u32 desc, time, count, base, data1; @@ -1365,47 +1365,47 @@ void iwl3945_dump_nic_error_log(struct iwl_priv *priv) base = le32_to_cpu(priv->card_alive.error_event_table_ptr); - if (!iwl3945_hw_valid_rtc_data_addr(base)) { - IWL_ERR(priv, "Not valid error log pointer 0x%08X\n", base); + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR(priv, "Not valid error log pointer 0x%08X\n", base); return; } - count = iwl_legacy_read_targ_mem(priv, base); + count = il_read_targ_mem(priv, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IWL_ERR(priv, "Start IWL Error Log Dump:\n"); - IWL_ERR(priv, "Status: 0x%08lX, count: %d\n", + IL_ERR(priv, "Start IWL Error Log Dump:\n"); + IL_ERR(priv, "Status: 0x%08lX, count: %d\n", priv->status, count); } - IWL_ERR(priv, "Desc Time asrtPC blink2 " + IL_ERR(priv, "Desc Time asrtPC blink2 " "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; i += ERROR_ELEM_SIZE) { - desc = iwl_legacy_read_targ_mem(priv, base + i); + desc = il_read_targ_mem(priv, base + i); time = - iwl_legacy_read_targ_mem(priv, base + i + 1 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 1 * sizeof(u32)); blink1 = - iwl_legacy_read_targ_mem(priv, base + i + 2 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 2 * sizeof(u32)); blink2 = - iwl_legacy_read_targ_mem(priv, base + i + 3 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 3 * sizeof(u32)); ilink1 = - iwl_legacy_read_targ_mem(priv, base + i + 4 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 4 * sizeof(u32)); ilink2 = - iwl_legacy_read_targ_mem(priv, base + i + 5 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 5 * sizeof(u32)); data1 = - iwl_legacy_read_targ_mem(priv, base + i + 6 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 6 * sizeof(u32)); - IWL_ERR(priv, + IL_ERR(priv, "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", - iwl3945_desc_lookup(desc), desc, time, blink1, blink2, + il3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); } } -static void iwl3945_irq_tasklet(struct iwl_priv *priv) +static void il3945_irq_tasklet(struct il_priv *priv) { u32 inta, handled = 0; u32 inta_fh; @@ -1419,20 +1419,20 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = iwl_read32(priv, CSR_INT); - iwl_write32(priv, CSR_INT, inta); + inta = il_read32(priv, CSR_INT); + il_write32(priv, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - iwl_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + il_write32(priv, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & IWL_DL_ISR) { + if (il_get_debug_level(priv) & IL_DL_ISR) { /* just for debug */ - inta_mask = iwl_read32(priv, CSR_INT_MASK); - IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(priv, CSR_INT_MASK); + IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -1450,13 +1450,13 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IWL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(priv, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); priv->isr_stats.hw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_HW_ERR; @@ -1464,17 +1464,17 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { + if (il_get_debug_level(priv) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IWL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(priv, "Scheduler finished to transmit " "the frame/frames.\n"); priv->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IWL_DEBUG_ISR(priv, "Alive interrupt\n"); + IL_DEBUG_ISR(priv, "Alive interrupt\n"); priv->isr_stats.alive++; } } @@ -1484,23 +1484,23 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IWL_ERR(priv, "Microcode SW error detected. " + IL_ERR(priv, "Microcode SW error detected. " "Restarting 0x%X.\n", inta); priv->isr_stats.sw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_SW_ERR; } /* uCode wakes up after power-down sleep */ if (inta & CSR_INT_BIT_WAKEUP) { - IWL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - iwl_legacy_rx_queue_update_write_ptr(priv, &priv->rxq); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[0]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[1]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[2]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[3]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[4]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[5]); + IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(priv, &priv->rxq); + il_txq_update_write_ptr(priv, &priv->txq[0]); + il_txq_update_write_ptr(priv, &priv->txq[1]); + il_txq_update_write_ptr(priv, &priv->txq[2]); + il_txq_update_write_ptr(priv, &priv->txq[3]); + il_txq_update_write_ptr(priv, &priv->txq[4]); + il_txq_update_write_ptr(priv, &priv->txq[5]); priv->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; @@ -1510,67 +1510,67 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - iwl3945_rx_handle(priv); + il3945_rx_handle(priv); priv->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } if (inta & CSR_INT_BIT_FH_TX) { - IWL_DEBUG_ISR(priv, "Tx interrupt\n"); + IL_DEBUG_ISR(priv, "Tx interrupt\n"); priv->isr_stats.tx++; - iwl_write32(priv, CSR_FH_INT_STATUS, (1 << 6)); - iwl_legacy_write_direct32(priv, FH39_TCSR_CREDIT + il_write32(priv, CSR_FH_INT_STATUS, (1 << 6)); + il_write_direct32(priv, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } if (inta & ~handled) { - IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); priv->isr_stats.unhandled++; } if (inta & ~priv->inta_mask) { - IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", inta & ~priv->inta_mask); - IWL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ if (test_bit(STATUS_INT_ENABLED, &priv->status)) - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { - inta = iwl_read32(priv, CSR_INT); - inta_mask = iwl_read32(priv, CSR_INT_MASK); - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - IWL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + if (il_get_debug_level(priv) & (IL_DL_ISR)) { + inta = il_read32(priv, CSR_INT); + inta_mask = il_read32(priv, CSR_INT_MASK); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } -static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, +static int il3945_get_channels_for_scan(struct il_priv *priv, enum ieee80211_band band, u8 is_active, u8 n_probes, - struct iwl3945_scan_channel *scan_ch, + struct il3945_scan_channel *scan_ch, struct ieee80211_vif *vif) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; u16 passive_dwell = 0; u16 active_dwell = 0; int added, i; - sband = iwl_get_hw_mode(priv, band); + sband = il_get_hw_mode(priv, band); if (!sband) return 0; - active_dwell = iwl_legacy_get_active_dwell_time(priv, band, n_probes); - passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(priv, band, n_probes); + passive_dwell = il_get_passive_dwell_time(priv, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; @@ -1583,10 +1583,10 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, scan_ch->channel = chan->hw_value; - ch_info = iwl_legacy_get_channel_info(priv, band, + ch_info = il_get_channel_info(priv, band, scan_ch->channel); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_SCAN(priv, + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n", scan_ch->channel); continue; @@ -1597,10 +1597,10 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, /* If passive , set up for auto-switch * and use long active_dwell time. */ - if (!is_active || iwl_legacy_is_channel_passive(ch_info) || + if (!is_active || il_is_channel_passive(ch_info) || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { scan_ch->type = 0; /* passive */ - if (IWL_UCODE_API(priv->ucode_ver) == 1) + if (IL_UCODE_API(priv->ucode_ver) == 1) scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); } else { scan_ch->type = 1; /* active */ @@ -1610,7 +1610,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, * scan channels (probes gets sent right away), * or for passive channels (probes get se sent only after * hearing clear Rx packet).*/ - if (IWL_UCODE_API(priv->ucode_ver) >= 2) { + if (IL_UCODE_API(priv->ucode_ver) >= 2) { if (n_probes) scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); } else { @@ -1635,7 +1635,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, */ } - IWL_DEBUG_SCAN(priv, "Scanning %d [%s %d]\n", + IL_DEBUG_SCAN(priv, "Scanning %d [%s %d]\n", scan_ch->channel, (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", (scan_ch->type & 1) ? @@ -1645,25 +1645,25 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, added++; } - IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); return added; } -static void iwl3945_init_hw_rates(struct iwl_priv *priv, +static void il3945_init_hw_rates(struct il_priv *priv, struct ieee80211_rate *rates) { int i; - for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = iwl3945_rates[i].ieee * 5; + for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { + rates[i].bitrate = il3945_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if ((i > IWL39_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) { + if ((i > IWL39_LAST_OFDM_RATE) || (i < IL_FIRST_OFDM_RATE)) { /* * If CCK != 1M then set short preamble rate flag. */ - rates[i].flags |= (iwl3945_rates[i].plcp == 10) ? + rates[i].flags |= (il3945_rates[i].plcp == 10) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } @@ -1675,40 +1675,40 @@ static void iwl3945_init_hw_rates(struct iwl_priv *priv, * ******************************************************************************/ -static void iwl3945_dealloc_ucode_pci(struct iwl_priv *priv) +static void il3945_dealloc_ucode_pci(struct il_priv *priv) { - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_code); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(priv->pci_dev, &priv->ucode_code); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); } /** - * iwl3945_verify_inst_full - verify runtime uCode image in card vs. host, + * il3945_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) { u32 val; u32 save_len = len; int rc = 0; u32 errcnt; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + * if IL_DL_IO is set */ + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(priv, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); rc = -EIO; @@ -1720,7 +1720,7 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le if (!errcnt) - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "ucode image in INSTRUCTION memory is good\n"); return rc; @@ -1728,29 +1728,29 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le /** - * iwl3945_verify_inst_sparse - verify runtime uCode image in card vs. host, + * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ -static int iwl3945_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) { u32 val; int rc = 0; u32 errcnt = 0; u32 i; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + * if IL_DL_IO is set */ + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ - IWL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(priv, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, *image); #endif @@ -1766,10 +1766,10 @@ static int iwl3945_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 /** - * iwl3945_verify_ucode - determine which instruction image is in SRAM, + * il3945_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int iwl3945_verify_ucode(struct iwl_priv *priv) +static int il3945_verify_ucode(struct il_priv *priv) { __le32 *image; u32 len; @@ -1778,60 +1778,60 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv) /* Try bootstrap */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - rc = iwl3945_verify_inst_sparse(priv, image, len); + rc = il3945_verify_inst_sparse(priv, image, len); if (rc == 0) { - IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ image = (__le32 *)priv->ucode_init.v_addr; len = priv->ucode_init.len; - rc = iwl3945_verify_inst_sparse(priv, image, len); + rc = il3945_verify_inst_sparse(priv, image, len); if (rc == 0) { - IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ image = (__le32 *)priv->ucode_code.v_addr; len = priv->ucode_code.len; - rc = iwl3945_verify_inst_sparse(priv, image, len); + rc = il3945_verify_inst_sparse(priv, image, len); if (rc == 0) { - IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); return 0; } - IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - rc = iwl3945_verify_inst_full(priv, image, len); + rc = il3945_verify_inst_full(priv, image, len); return rc; } -static void iwl3945_nic_start(struct iwl_priv *priv) +static void il3945_nic_start(struct il_priv *priv) { /* Remove all resets to allow NIC to operate */ - iwl_write32(priv, CSR_RESET, 0); + il_write32(priv, CSR_RESET, 0); } #define IWL3945_UCODE_GET(item) \ -static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode)\ +static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ { \ return le32_to_cpu(ucode->v1.item); \ } -static u32 iwl3945_ucode_get_header_size(u32 api_ver) +static u32 il3945_ucode_get_header_size(u32 api_ver) { return 24; } -static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode) +static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) { return (u8 *) ucode->v1.data; } @@ -1843,13 +1843,13 @@ IWL3945_UCODE_GET(init_data_size); IWL3945_UCODE_GET(boot_size); /** - * iwl3945_read_ucode - Read uCode images from disk file. + * il3945_read_ucode - Read uCode images from disk file. * * Copy into buffers for card to fetch via bus-mastering */ -static int iwl3945_read_ucode(struct iwl_priv *priv) +static int il3945_read_ucode(struct il_priv *priv) { - const struct iwl_ucode_header *ucode; + const struct il_ucode_header *ucode; int ret = -EINVAL, index; const struct firmware *ucode_raw; /* firmware file name contains uCode/driver compatibility version */ @@ -1867,7 +1867,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev); if (ret < 0) { - IWL_ERR(priv, "%s firmware file req failed: %d\n", + IL_ERR(priv, "%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; @@ -1875,11 +1875,11 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) goto error; } else { if (index < api_max) - IWL_ERR(priv, "Loaded firmware %s, " + IL_ERR(priv, "Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); - IWL_DEBUG_INFO(priv, "Got firmware '%s' file " + IL_DEBUG_INFO(priv, "Got firmware '%s' file " "(%zd bytes) from disk\n", buf, ucode_raw->size); break; @@ -1890,30 +1890,30 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) goto error; /* Make sure that we got at least our header! */ - if (ucode_raw->size < iwl3945_ucode_get_header_size(1)) { - IWL_ERR(priv, "File size way too small!\n"); + if (ucode_raw->size < il3945_ucode_get_header_size(1)) { + IL_ERR(priv, "File size way too small!\n"); ret = -EINVAL; goto err_release; } /* Data from ucode file: header followed by uCode images */ - ucode = (struct iwl_ucode_header *)ucode_raw->data; + ucode = (struct il_ucode_header *)ucode_raw->data; priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IWL_UCODE_API(priv->ucode_ver); - inst_size = iwl3945_ucode_get_inst_size(ucode); - data_size = iwl3945_ucode_get_data_size(ucode); - init_size = iwl3945_ucode_get_init_size(ucode); - init_data_size = iwl3945_ucode_get_init_data_size(ucode); - boot_size = iwl3945_ucode_get_boot_size(ucode); - src = iwl3945_ucode_get_data(ucode); + api_ver = IL_UCODE_API(priv->ucode_ver); + inst_size = il3945_ucode_get_inst_size(ucode); + data_size = il3945_ucode_get_data_size(ucode); + init_size = il3945_ucode_get_init_size(ucode); + init_data_size = il3945_ucode_get_init_data_size(ucode); + boot_size = il3945_ucode_get_boot_size(ucode); + src = il3945_ucode_get_data(ucode); /* api_ver should match the api version forming part of the * firmware filename ... but we don't check for that and only rely * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(priv, "Driver unable to support your firmware API. " + IL_ERR(priv, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); priv->ucode_ver = 0; @@ -1921,45 +1921,45 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) goto err_release; } if (api_ver != api_max) - IWL_ERR(priv, "Firmware has old API version. Expected %u, " + IL_ERR(priv, "Firmware has old API version. Expected %u, " "got %u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); snprintf(priv->hw->wiphy->fw_version, sizeof(priv->hw->wiphy->fw_version), "%u.%u.%u.%u", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); - IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", + IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", priv->ucode_ver); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n", inst_size); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n", data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n", init_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n", init_data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n", boot_size); /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != iwl3945_ucode_get_header_size(api_ver) + + if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + inst_size + data_size + init_size + init_data_size + boot_size) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode file size %zd does not match expected size\n", ucode_raw->size); ret = -EINVAL; @@ -1968,34 +1968,34 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IWL39_MAX_INST_SIZE) { - IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", + IL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IWL39_MAX_DATA_SIZE) { - IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", + IL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IWL39_MAX_INST_SIZE) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IWL39_MAX_DATA_SIZE) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IWL39_MAX_BSM_SIZE) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode boot instr len %d too large to fit in\n", boot_size); ret = -EINVAL; @@ -2008,13 +2008,13 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ priv->ucode_code.len = inst_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); priv->ucode_data.len = data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); priv->ucode_data_backup.len = data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || !priv->ucode_data_backup.v_addr) @@ -2023,10 +2023,10 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Initialization instructions and data */ if (init_size && init_data_size) { priv->ucode_init.len = init_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); priv->ucode_init_data.len = init_data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) goto err_pci_alloc; @@ -2035,7 +2035,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Bootstrap (instructions only, no data) */ if (boot_size) { priv->ucode_boot.len = boot_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); if (!priv->ucode_boot.v_addr) goto err_pci_alloc; @@ -2045,18 +2045,18 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Runtime instructions (first block of data in file) */ len = inst_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %zd\n", len); memcpy(priv->ucode_code.v_addr, src, len); src += len; - IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); /* Runtime data (2nd block) - * NOTE: Copy into backup buffer will be done in iwl3945_up() */ + * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %zd\n", len); memcpy(priv->ucode_data.v_addr, src, len); memcpy(priv->ucode_data_backup.v_addr, src, len); @@ -2065,7 +2065,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %zd\n", len); memcpy(priv->ucode_init.v_addr, src, len); src += len; @@ -2074,7 +2074,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init data len %zd\n", len); memcpy(priv->ucode_init_data.v_addr, src, len); src += len; @@ -2082,7 +2082,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Bootstrap instructions (5th block) */ len = boot_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %zd\n", len); memcpy(priv->ucode_boot.v_addr, src, len); @@ -2091,9 +2091,9 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) return 0; err_pci_alloc: - IWL_ERR(priv, "failed to allocate pci memory\n"); + IL_ERR(priv, "failed to allocate pci memory\n"); ret = -ENOMEM; - iwl3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(priv); err_release: release_firmware(ucode_raw); @@ -2104,7 +2104,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /** - * iwl3945_set_ucode_ptrs - Set uCode address location + * il3945_set_ucode_ptrs - Set uCode address location * * Tell initialization uCode where to find runtime uCode. * @@ -2112,7 +2112,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int iwl3945_set_ucode_ptrs(struct iwl_priv *priv) +static int il3945_set_ucode_ptrs(struct il_priv *priv) { dma_addr_t pinst; dma_addr_t pdata; @@ -2122,56 +2122,56 @@ static int iwl3945_set_ucode_ptrs(struct iwl_priv *priv) pdata = priv->ucode_data_backup.p_addr; /* Tell bootstrap uCode where to find image to load */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, priv->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, priv->ucode_code.len | BSM_DRAM_INST_LOAD); - IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); return 0; } /** - * iwl3945_init_alive_start - Called after REPLY_ALIVE notification received + * il3945_init_alive_start - Called after REPLY_ALIVE notification received * * Called after REPLY_ALIVE notification received from "initialize" uCode. * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void iwl3945_init_alive_start(struct iwl_priv *priv) +static void il3945_init_alive_start(struct il_priv *priv) { /* Check alive response for "valid" sign from uCode */ if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Initialize Alive failed.\n"); + IL_DEBUG_INFO(priv, "Initialize Alive failed.\n"); goto restart; } /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (iwl3945_verify_ucode(priv)) { + if (il3945_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (iwl3945_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + if (il3945_set_ucode_ptrs(priv)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -2181,49 +2181,49 @@ static void iwl3945_init_alive_start(struct iwl_priv *priv) } /** - * iwl3945_alive_start - called after REPLY_ALIVE notification received + * il3945_alive_start - called after REPLY_ALIVE notification received * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by iwl3945_init_alive_start()). + * Alive gets handled by il3945_init_alive_start()). */ -static void iwl3945_alive_start(struct iwl_priv *priv) +static void il3945_alive_start(struct il_priv *priv) { int thermal_spin = 0; u32 rfkill; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); if (priv->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(priv, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (iwl3945_verify_ucode(priv)) { + if (il3945_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); goto restart; } - rfkill = iwl_legacy_read_prph(priv, APMG_RFKILL_REG); - IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); + rfkill = il_read_prph(priv, APMG_RFKILL_REG); + IL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { clear_bit(STATUS_RF_KILL_HW, &priv->status); /* if RFKILL is not on, then wait for thermal * sensor in adapter to kick in */ - while (iwl3945_hw_get_temperature(priv) == 0) { + while (il3945_hw_get_temperature(priv) == 0) { thermal_spin++; udelay(10); } if (thermal_spin) - IWL_DEBUG_INFO(priv, "Thermal calibration took %dus\n", + IL_DEBUG_INFO(priv, "Thermal calibration took %dus\n", thermal_spin * 10); } else set_bit(STATUS_RF_KILL_HW, &priv->status); @@ -2232,39 +2232,39 @@ static void iwl3945_alive_start(struct iwl_priv *priv) set_bit(STATUS_ALIVE, &priv->status); /* Enable watchdog to monitor the driver tx queues */ - iwl_legacy_setup_watchdog(priv); + il_setup_watchdog(priv); - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) return; ieee80211_wake_queues(priv->hw); - priv->active_rate = IWL_RATES_MASK_3945; + priv->active_rate = IL_RATES_MASK_3945; - iwl_legacy_power_update_mode(priv, true); + il_power_update_mode(priv, true); - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { - struct iwl3945_rxon_cmd *active_rxon = - (struct iwl3945_rxon_cmd *)(&ctx->active); + if (il_is_associated(priv, IL_RXON_CTX_BSS)) { + struct il3945_rxon_cmd *active_rxon = + (struct il3945_rxon_cmd *)(&ctx->active); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { /* Initialize our rx_config data */ - iwl_legacy_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(priv, ctx); } /* Configure Bluetooth device coexistence support */ - iwl_legacy_send_bt_config(priv); + il_send_bt_config(priv); set_bit(STATUS_READY, &priv->status); /* Configure the adapter for unassociated operation */ - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); - iwl3945_reg_txpower_periodic(priv); + il3945_reg_txpower_periodic(priv); - IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); + IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); wake_up(&priv->wait_command_queue); return; @@ -2273,16 +2273,16 @@ static void iwl3945_alive_start(struct iwl_priv *priv) queue_work(priv->workqueue, &priv->restart); } -static void iwl3945_cancel_deferred_work(struct iwl_priv *priv); +static void il3945_cancel_deferred_work(struct il_priv *priv); -static void __iwl3945_down(struct iwl_priv *priv) +static void __il3945_down(struct il_priv *priv) { unsigned long flags; int exit_pending; - IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); @@ -2291,9 +2291,9 @@ static void __iwl3945_down(struct iwl_priv *priv) del_timer_sync(&priv->watchdog); /* Station information will now be cleared in device */ - iwl_legacy_clear_ucode_stations(priv, NULL); - iwl_legacy_dealloc_bcast_stations(priv); - iwl_legacy_clear_driver_stations(priv); + il_clear_ucode_stations(priv, NULL); + il_dealloc_bcast_stations(priv); + il_clear_driver_stations(priv); /* Unblock any waiting calls */ wake_up_all(&priv->wait_command_queue); @@ -2304,20 +2304,20 @@ static void __iwl3945_down(struct iwl_priv *priv) clear_bit(STATUS_EXIT_PENDING, &priv->status); /* stop and reset the on-board processor */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl3945_synchronize_irq(priv); + il3945_synchronize_irq(priv); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); - /* If we have not previously called iwl3945_init() then + /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ - if (!iwl_legacy_is_init(priv)) { + if (!il_is_init(priv)) { priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << STATUS_RF_KILL_HW | test_bit(STATUS_GEO_CONFIGURED, &priv->status) << @@ -2338,109 +2338,109 @@ static void __iwl3945_down(struct iwl_priv *priv) test_bit(STATUS_EXIT_PENDING, &priv->status) << STATUS_EXIT_PENDING; - iwl3945_hw_txq_ctx_stop(priv); - iwl3945_hw_rxq_stop(priv); + il3945_hw_txq_ctx_stop(priv); + il3945_hw_rxq_stop(priv); /* Power-down device's busmaster DMA clocks */ - iwl_legacy_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Stop the device, and put it in low power state */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); exit: - memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); + memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); if (priv->beacon_skb) dev_kfree_skb(priv->beacon_skb); priv->beacon_skb = NULL; /* clear out any free frames */ - iwl3945_clear_free_frames(priv); + il3945_clear_free_frames(priv); } -static void iwl3945_down(struct iwl_priv *priv) +static void il3945_down(struct il_priv *priv) { mutex_lock(&priv->mutex); - __iwl3945_down(priv); + __il3945_down(priv); mutex_unlock(&priv->mutex); - iwl3945_cancel_deferred_work(priv); + il3945_cancel_deferred_work(priv); } #define MAX_HW_RESTARTS 5 -static int iwl3945_alloc_bcast_station(struct iwl_priv *priv) +static int il3945_alloc_bcast_station(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; unsigned long flags; u8 sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = iwl_legacy_prep_station(priv, ctx, + sta_id = il_prep_station(priv, ctx, iwlegacy_bcast_addr, false, NULL); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Unable to prepare broadcast station\n"); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&priv->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IWL_STA_BCAST; + priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used |= IL_STA_BCAST; spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } -static int __iwl3945_up(struct iwl_priv *priv) +static int __il3945_up(struct il_priv *priv) { int rc, i; - rc = iwl3945_alloc_bcast_station(priv); + rc = il3945_alloc_bcast_station(priv); if (rc) return rc; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); return -EIO; } if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IWL_ERR(priv, "ucode not available for device bring up\n"); + IL_ERR(priv, "ucode not available for device bring up\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(priv, CSR_GP_CNTRL) & + if (il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &priv->status); else { set_bit(STATUS_RF_KILL_HW, &priv->status); - IWL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); return -ENODEV; } - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(priv, CSR_INT, 0xFFFFFFFF); - rc = iwl3945_hw_nic_init(priv); + rc = il3945_hw_nic_init(priv); if (rc) { - IWL_ERR(priv, "Unable to int nic\n"); + IL_ERR(priv, "Unable to int nic\n"); return rc; } /* make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); - iwl_legacy_enable_interrupts(priv); + il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(priv); /* really make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2460,26 +2460,26 @@ static int __iwl3945_up(struct iwl_priv *priv) rc = priv->cfg->ops->lib->load_ucode(priv); if (rc) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", rc); continue; } /* start card; "initialize" will load runtime ucode */ - iwl3945_nic_start(priv); + il3945_nic_start(priv); - IWL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); return 0; } set_bit(STATUS_EXIT_PENDING, &priv->status); - __iwl3945_down(priv); + __il3945_down(priv); clear_bit(STATUS_EXIT_PENDING, &priv->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IWL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2490,30 +2490,30 @@ static int __iwl3945_up(struct iwl_priv *priv) * *****************************************************************************/ -static void iwl3945_bg_init_alive_start(struct work_struct *data) +static void il3945_bg_init_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, init_alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl3945_init_alive_start(priv); + il3945_init_alive_start(priv); out: mutex_unlock(&priv->mutex); } -static void iwl3945_bg_alive_start(struct work_struct *data) +static void il3945_bg_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl3945_alive_start(priv); + il3945_alive_start(priv); out: mutex_unlock(&priv->mutex); } @@ -2524,12 +2524,12 @@ out: * *is* readable even when device has been SW_RESET into low power mode * (e.g. during RF KILL). */ -static void iwl3945_rfkill_poll(struct work_struct *data) +static void il3945_rfkill_poll(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, _3945.rfkill_poll.work); + struct il_priv *priv = + container_of(data, struct il_priv, _3945.rfkill_poll.work); bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status); - bool new_rfkill = !(iwl_read32(priv, CSR_GP_CNTRL) + bool new_rfkill = !(il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { @@ -2540,7 +2540,7 @@ static void iwl3945_rfkill_poll(struct work_struct *data) wiphy_rfkill_set_hw_state(priv->hw->wiphy, new_rfkill); - IWL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n", + IL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n", new_rfkill ? "disable radio" : "enable radio"); } @@ -2551,14 +2551,14 @@ static void iwl3945_rfkill_poll(struct work_struct *data) } -int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) +int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, - .len = sizeof(struct iwl3945_scan_cmd), + .len = sizeof(struct il3945_scan_cmd), .flags = CMD_SIZE_HUGE, }; - struct iwl3945_scan_cmd *scan; + struct il3945_scan_cmd *scan; u8 n_probes = 0; enum ieee80211_band band; bool is_active = false; @@ -2568,26 +2568,26 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) lockdep_assert_held(&priv->mutex); if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) + - IWL_MAX_SCAN_SIZE, GFP_KERNEL); + priv->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!priv->scan_cmd) { - IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); + IL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); return -ENOMEM; } } scan = priv->scan_cmd; - memset(scan, 0, sizeof(struct iwl3945_scan_cmd) + IWL_MAX_SCAN_SIZE); + memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); - scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; - scan->quiet_time = IWL_ACTIVE_QUIET_TIME; + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { + if (il_is_associated(priv, IL_RXON_CTX_BSS)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(priv, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; @@ -2607,13 +2607,13 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (priv->scan_request->n_ssids) { int i, p = 0; - IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); + IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); for (i = 0; i < priv->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!priv->scan_request->ssids[i].ssid_len) @@ -2629,12 +2629,12 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) } is_active = true; } else - IWL_DEBUG_SCAN(priv, "Kicking off passive scan.\n"); + IL_DEBUG_SCAN(priv, "Kicking off passive scan.\n"); /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id; + scan->tx_cmd.sta_id = priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; /* flags + rate selection */ @@ -2642,15 +2642,15 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) switch (priv->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - scan->tx_cmd.rate = IWL_RATE_1M_PLCP; + scan->tx_cmd.rate = IL_RATE_1M_PLCP; band = IEEE80211_BAND_2GHZ; break; case IEEE80211_BAND_5GHZ: - scan->tx_cmd.rate = IWL_RATE_6M_PLCP; + scan->tx_cmd.rate = IL_RATE_6M_PLCP; band = IEEE80211_BAND_5GHZ; break; default: - IWL_WARN(priv, "Invalid scan band\n"); + IL_WARN(priv, "Invalid scan band\n"); return -EIO; } @@ -2659,67 +2659,67 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) * is marked passive, we can do active scanning if we * detect transmissions. */ - scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT : - IWL_GOOD_CRC_TH_DISABLED; + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_DISABLED; - len = iwl_legacy_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, + len = il_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, vif->addr, priv->scan_request->ie, priv->scan_request->ie_len, - IWL_MAX_SCAN_SIZE - sizeof(*scan)); + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(len); /* select Rx antennas */ - scan->flags |= iwl3945_get_antenna_flags(priv); + scan->flags |= il3945_get_antenna_flags(priv); - scan->channel_count = iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, + scan->channel_count = il3945_get_channels_for_scan(priv, band, is_active, n_probes, (void *)&scan->data[len], vif); if (scan->channel_count == 0) { - IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); return -EIO; } cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct iwl3945_scan_channel); + scan->channel_count * sizeof(struct il3945_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); set_bit(STATUS_SCAN_HW, &priv->status); - ret = iwl_legacy_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(priv, &cmd); if (ret) clear_bit(STATUS_SCAN_HW, &priv->status); return ret; } -void iwl3945_post_scan(struct iwl_priv *priv) +void il3945_post_scan(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } -static void iwl3945_bg_restart(struct work_struct *data) +static void il3945_bg_restart(struct work_struct *data) { - struct iwl_priv *priv = container_of(data, struct iwl_priv, restart); + struct il_priv *priv = container_of(data, struct il_priv, restart); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; mutex_lock(&priv->mutex); for_each_context(priv, ctx) ctx->vif = NULL; priv->is_open = 0; mutex_unlock(&priv->mutex); - iwl3945_down(priv); + il3945_down(priv); ieee80211_restart_hw(priv->hw); } else { - iwl3945_down(priv); + il3945_down(priv); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { @@ -2727,57 +2727,57 @@ static void iwl3945_bg_restart(struct work_struct *data) return; } - __iwl3945_up(priv); + __il3945_up(priv); mutex_unlock(&priv->mutex); } } -static void iwl3945_bg_rx_replenish(struct work_struct *data) +static void il3945_bg_rx_replenish(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, rx_replenish); + struct il_priv *priv = + container_of(data, struct il_priv, rx_replenish); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl3945_rx_replenish(priv); + il3945_rx_replenish(priv); out: mutex_unlock(&priv->mutex); } -void iwl3945_post_associate(struct iwl_priv *priv) +void il3945_post_associate(struct il_priv *priv) { int rc = 0; struct ieee80211_conf *conf = NULL; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (!ctx->vif || !priv->is_open) return; - IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); - conf = iwl_legacy_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(priv->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); - rc = iwl_legacy_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(priv, ctx); if (rc) - IWL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(priv, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) @@ -2792,17 +2792,17 @@ void iwl3945_post_associate(struct iwl_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); switch (ctx->vif->type) { case NL80211_IFTYPE_STATION: - iwl3945_rate_scale_init(priv->hw, IWL_AP_ID); + il3945_rate_scale_init(priv->hw, IL_AP_ID); break; case NL80211_IFTYPE_ADHOC: - iwl3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(priv); break; default: - IWL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(priv, "%s Should not be called in %d mode\n", __func__, ctx->vif->type); break; } @@ -2816,12 +2816,12 @@ void iwl3945_post_associate(struct iwl_priv *priv) #define UCODE_READY_TIMEOUT (2 * HZ) -static int iwl3945_mac_start(struct ieee80211_hw *hw) +static int il3945_mac_start(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&priv->mutex); @@ -2830,22 +2830,22 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw) * ucode filename and max sizes are card-specific. */ if (!priv->ucode_code.len) { - ret = iwl3945_read_ucode(priv); + ret = il3945_read_ucode(priv); if (ret) { - IWL_ERR(priv, "Could not read microcode: %d\n", ret); + IL_ERR(priv, "Could not read microcode: %d\n", ret); mutex_unlock(&priv->mutex); goto out_release_irq; } } - ret = __iwl3945_up(priv); + ret = __il3945_up(priv); mutex_unlock(&priv->mutex); if (ret) goto out_release_irq; - IWL_DEBUG_INFO(priv, "Start UP work.\n"); + IL_DEBUG_INFO(priv, "Start UP work.\n"); /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2854,7 +2854,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &priv->status)) { - IWL_ERR(priv, + IL_ERR(priv, "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; @@ -2867,29 +2867,29 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw) cancel_delayed_work(&priv->_3945.rfkill_poll); priv->is_open = 1; - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return 0; out_release_irq: priv->is_open = 0; - IWL_DEBUG_MAC80211(priv, "leave - failed\n"); + IL_DEBUG_MAC80211(priv, "leave - failed\n"); return ret; } -static void iwl3945_mac_stop(struct ieee80211_hw *hw) +static void il3945_mac_stop(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (!priv->is_open) { - IWL_DEBUG_MAC80211(priv, "leave - skip\n"); + IL_DEBUG_MAC80211(priv, "leave - skip\n"); return; } priv->is_open = 0; - iwl3945_down(priv); + il3945_down(priv); flush_workqueue(priv->workqueue); @@ -2897,27 +2897,27 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw) queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -static void iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (iwl3945_tx_skb(priv, skb)) + if (il3945_tx_skb(priv, skb)) dev_kfree_skb_any(skb); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -void iwl3945_config_ap(struct iwl_priv *priv) +void il3945_config_ap(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int rc = 0; @@ -2925,16 +2925,16 @@ void iwl3945_config_ap(struct iwl_priv *priv) return; /* The following should be done only at AP bring up */ - if (!(iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS))) { + if (!(il_is_associated(priv, IL_RXON_CTX_BSS))) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); /* RXON Timing */ - rc = iwl_legacy_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(priv, ctx); if (rc) - IWL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(priv, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -2956,25 +2956,25 @@ void iwl3945_config_ap(struct iwl_priv *priv) } /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } - iwl3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(priv); } -static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, +static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret = 0; - u8 sta_id = IWL_INVALID_STATION; + u8 sta_id = IL_INVALID_STATION; u8 static_key; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - if (iwl3945_mod_params.sw_crypto) { - IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + if (il3945_mod_params.sw_crypto) { + IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -2986,66 +2986,66 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) return -EOPNOTSUPP; - static_key = !iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS); + static_key = !il_is_associated(priv, IL_RXON_CTX_BSS); if (!static_key) { - sta_id = iwl_legacy_sta_id_or_broadcast( - priv, &priv->contexts[IWL_RXON_CTX_BSS], sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id_or_broadcast( + priv, &priv->contexts[IL_RXON_CTX_BSS], sta); + if (sta_id == IL_INVALID_STATION) return -EINVAL; } mutex_lock(&priv->mutex); - iwl_legacy_scan_cancel_timeout(priv, 100); + il_scan_cancel_timeout(priv, 100); switch (cmd) { case SET_KEY: if (static_key) - ret = iwl3945_set_static_key(priv, key); + ret = il3945_set_static_key(priv, key); else - ret = iwl3945_set_dynamic_key(priv, key, sta_id); - IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + ret = il3945_set_dynamic_key(priv, key, sta_id); + IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (static_key) - ret = iwl3945_remove_static_key(priv); + ret = il3945_remove_static_key(priv); else - ret = iwl3945_clear_sta_key_info(priv, sta_id); - IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + ret = il3945_clear_sta_key_info(priv, sta_id); + IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return ret; } -static int iwl3945_mac_sta_add(struct ieee80211_hw *hw, +static int il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; - struct iwl3945_sta_priv *sta_priv = (void *)sta->drv_priv; + struct il_priv *priv = hw->priv; + struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; int ret; bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - IWL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(priv, "received request to add station %pM\n", sta->addr); mutex_lock(&priv->mutex); - IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", sta->addr); - sta_priv->common.sta_id = IWL_INVALID_STATION; + sta_priv->common.sta_id = IL_INVALID_STATION; - ret = iwl_legacy_add_station_common(priv, - &priv->contexts[IWL_RXON_CTX_BSS], + ret = il_add_station_common(priv, + &priv->contexts[IL_RXON_CTX_BSS], sta->addr, is_ap, sta, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(priv, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&priv->mutex); @@ -3055,22 +3055,22 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", sta->addr); - iwl3945_rs_rate_init(priv, sta, sta_id); + il3945_rs_rate_init(priv, sta, sta_id); mutex_unlock(&priv->mutex); return 0; } -static void iwl3945_configure_filter(struct ieee80211_hw *hw, +static void il3945_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, unsigned int *total_flags, u64 multicast) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -3079,7 +3079,7 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -3103,7 +3103,7 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw, /* * Receiving all multicast frames is always enabled by the - * default flags setup in iwl_legacy_connection_init_rx_config() + * default flags setup in il_connection_init_rx_config() * since we currently do not support programming multicast * filters into the device. */ @@ -3131,103 +3131,103 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw, * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t iwl3945_show_debug_level(struct device *d, +static ssize_t il3945_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", iwl_legacy_get_debug_level(priv)); + struct il_priv *priv = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); } -static ssize_t iwl3945_store_debug_level(struct device *d, +static ssize_t il3945_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IWL_INFO(priv, "%s is not in hex or decimal form.\n", buf); + IL_INFO(priv, "%s is not in hex or decimal form.\n", buf); else { priv->debug_level = val; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - iwl3945_show_debug_level, iwl3945_store_debug_level); + il3945_show_debug_level, il3945_store_debug_level); #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ -static ssize_t iwl3945_show_temperature(struct device *d, +static ssize_t il3945_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; - return sprintf(buf, "%d\n", iwl3945_hw_get_temperature(priv)); + return sprintf(buf, "%d\n", il3945_hw_get_temperature(priv)); } -static DEVICE_ATTR(temperature, S_IRUGO, iwl3945_show_temperature, NULL); +static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); -static ssize_t iwl3945_show_tx_power(struct device *d, +static ssize_t il3945_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); return sprintf(buf, "%d\n", priv->tx_power_user_lmt); } -static ssize_t iwl3945_store_tx_power(struct device *d, +static ssize_t il3945_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); char *p = (char *)buf; u32 val; val = simple_strtoul(p, &p, 10); if (p == buf) - IWL_INFO(priv, ": %s is not in decimal form.\n", buf); + IL_INFO(priv, ": %s is not in decimal form.\n", buf); else - iwl3945_hw_reg_set_txpower(priv, val); + il3945_hw_reg_set_txpower(priv, val); return count; } -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, iwl3945_show_tx_power, iwl3945_store_tx_power); +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); -static ssize_t iwl3945_show_flags(struct device *d, +static ssize_t il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", ctx->active.flags); } -static ssize_t iwl3945_store_flags(struct device *d, +static ssize_t il3945_store_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; mutex_lock(&priv->mutex); if (le32_to_cpu(ctx->staging.flags) != flags) { /* Cancel any currently running scans... */ - if (iwl_legacy_scan_cancel_timeout(priv, 100)) - IWL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(priv, 100)) + IL_WARN(priv, "Could not cancel scan.\n"); else { - IWL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n", + IL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } } mutex_unlock(&priv->mutex); @@ -3235,37 +3235,37 @@ static ssize_t iwl3945_store_flags(struct device *d, return count; } -static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, iwl3945_show_flags, iwl3945_store_flags); +static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); -static ssize_t iwl3945_show_filter_flags(struct device *d, +static ssize_t il3945_show_filter_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); } -static ssize_t iwl3945_store_filter_flags(struct device *d, +static ssize_t il3945_store_filter_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; u32 filter_flags = simple_strtoul(buf, NULL, 0); mutex_lock(&priv->mutex); if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { /* Cancel any currently running scans... */ - if (iwl_legacy_scan_cancel_timeout(priv, 100)) - IWL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(priv, 100)) + IL_WARN(priv, "Could not cancel scan.\n"); else { - IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = " + IL_DEBUG_INFO(priv, "Committing rxon.filter_flags = " "0x%04X\n", filter_flags); ctx->staging.filter_flags = cpu_to_le32(filter_flags); - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } } mutex_unlock(&priv->mutex); @@ -3273,14 +3273,14 @@ static ssize_t iwl3945_store_filter_flags(struct device *d, return count; } -static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, iwl3945_show_filter_flags, - iwl3945_store_filter_flags); +static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, + il3945_store_filter_flags); -static ssize_t iwl3945_show_measurement(struct device *d, +static ssize_t il3945_show_measurement(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_spectrum_notification measure_report; + struct il_priv *priv = dev_get_drvdata(d); + struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; u8 *data = (u8 *)&measure_report; unsigned long flags; @@ -3308,18 +3308,18 @@ static ssize_t iwl3945_show_measurement(struct device *d, return len; } -static ssize_t iwl3945_store_measurement(struct device *d, +static ssize_t il3945_store_measurement(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_measurement_params params = { .channel = le16_to_cpu(ctx->active.channel), .start_time = cpu_to_le64(priv->_3945.last_tsf), .duration = cpu_to_le16(1), }; - u8 type = IWL_MEASURE_BASIC; + u8 type = IL_MEASURE_BASIC; u8 buffer[32]; u8 channel; @@ -3337,21 +3337,21 @@ static ssize_t iwl3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - IWL_DEBUG_INFO(priv, "Invoking measurement of type %d on " + IL_DEBUG_INFO(priv, "Invoking measurement of type %d on " "channel %d (for '%s')\n", type, params.channel, buf); - iwl3945_get_measurement(priv, ¶ms, type); + il3945_get_measurement(priv, ¶ms, type); return count; } static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, - iwl3945_show_measurement, iwl3945_store_measurement); + il3945_show_measurement, il3945_store_measurement); -static ssize_t iwl3945_store_retry_rate(struct device *d, +static ssize_t il3945_store_retry_rate(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); priv->retry_rate = simple_strtoul(buf, NULL, 0); if (priv->retry_rate <= 0) @@ -3360,89 +3360,89 @@ static ssize_t iwl3945_store_retry_rate(struct device *d, return count; } -static ssize_t iwl3945_show_retry_rate(struct device *d, +static ssize_t il3945_show_retry_rate(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); return sprintf(buf, "%d", priv->retry_rate); } -static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, iwl3945_show_retry_rate, - iwl3945_store_retry_rate); +static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, + il3945_store_retry_rate); -static ssize_t iwl3945_show_channels(struct device *d, +static ssize_t il3945_show_channels(struct device *d, struct device_attribute *attr, char *buf) { /* all this shit doesn't belong into sysfs anyway */ return 0; } -static DEVICE_ATTR(channels, S_IRUSR, iwl3945_show_channels, NULL); +static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); -static ssize_t iwl3945_show_antenna(struct device *d, +static ssize_t il3945_show_antenna(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; - return sprintf(buf, "%d\n", iwl3945_mod_params.antenna); + return sprintf(buf, "%d\n", il3945_mod_params.antenna); } -static ssize_t iwl3945_store_antenna(struct device *d, +static ssize_t il3945_store_antenna(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv __maybe_unused = dev_get_drvdata(d); + struct il_priv *priv __maybe_unused = dev_get_drvdata(d); int ant; if (count == 0) return 0; if (sscanf(buf, "%1i", &ant) != 1) { - IWL_DEBUG_INFO(priv, "not in hex or decimal form.\n"); + IL_DEBUG_INFO(priv, "not in hex or decimal form.\n"); return count; } if ((ant >= 0) && (ant <= 2)) { - IWL_DEBUG_INFO(priv, "Setting antenna select to %d.\n", ant); - iwl3945_mod_params.antenna = (enum iwl3945_antenna)ant; + IL_DEBUG_INFO(priv, "Setting antenna select to %d.\n", ant); + il3945_mod_params.antenna = (enum il3945_antenna)ant; } else - IWL_DEBUG_INFO(priv, "Bad antenna select value %d.\n", ant); + IL_DEBUG_INFO(priv, "Bad antenna select value %d.\n", ant); return count; } -static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, iwl3945_show_antenna, iwl3945_store_antenna); +static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); -static ssize_t iwl3945_show_status(struct device *d, +static ssize_t il3945_show_status(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + struct il_priv *priv = dev_get_drvdata(d); + if (!il_is_alive(priv)) return -EAGAIN; return sprintf(buf, "0x%08x\n", (int)priv->status); } -static DEVICE_ATTR(status, S_IRUGO, iwl3945_show_status, NULL); +static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); -static ssize_t iwl3945_dump_error_log(struct device *d, +static ssize_t il3945_dump_error_log(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); char *p = (char *)buf; if (p[0] == '1') - iwl3945_dump_nic_error_log(priv); + il3945_dump_nic_error_log(priv); return strnlen(buf, count); } -static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, iwl3945_dump_error_log); +static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); /***************************************************************************** * @@ -3450,41 +3450,41 @@ static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, iwl3945_dump_error_log); * *****************************************************************************/ -static void iwl3945_setup_deferred_work(struct iwl_priv *priv) +static void il3945_setup_deferred_work(struct il_priv *priv) { priv->workqueue = create_singlethread_workqueue(DRV_NAME); init_waitqueue_head(&priv->wait_command_queue); - INIT_WORK(&priv->restart, iwl3945_bg_restart); - INIT_WORK(&priv->rx_replenish, iwl3945_bg_rx_replenish); - INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); - INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll); + INIT_WORK(&priv->restart, il3945_bg_restart); + INIT_WORK(&priv->rx_replenish, il3945_bg_rx_replenish); + INIT_DELAYED_WORK(&priv->init_alive_start, il3945_bg_init_alive_start); + INIT_DELAYED_WORK(&priv->alive_start, il3945_bg_alive_start); + INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, il3945_rfkill_poll); - iwl_legacy_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(priv); - iwl3945_hw_setup_deferred_work(priv); + il3945_hw_setup_deferred_work(priv); init_timer(&priv->watchdog); priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = iwl_legacy_bg_watchdog; + priv->watchdog.function = il_bg_watchdog; tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - iwl3945_irq_tasklet, (unsigned long)priv); + il3945_irq_tasklet, (unsigned long)priv); } -static void iwl3945_cancel_deferred_work(struct iwl_priv *priv) +static void il3945_cancel_deferred_work(struct il_priv *priv) { - iwl3945_hw_cancel_deferred_work(priv); + il3945_hw_cancel_deferred_work(priv); cancel_delayed_work_sync(&priv->init_alive_start); cancel_delayed_work(&priv->alive_start); - iwl_legacy_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(priv); } -static struct attribute *iwl3945_sysfs_entries[] = { +static struct attribute *il3945_sysfs_entries[] = { &dev_attr_antenna.attr, &dev_attr_channels.attr, &dev_attr_dump_errors.attr, @@ -3501,34 +3501,34 @@ static struct attribute *iwl3945_sysfs_entries[] = { NULL }; -static struct attribute_group iwl3945_attribute_group = { +static struct attribute_group il3945_attribute_group = { .name = NULL, /* put in device directory */ - .attrs = iwl3945_sysfs_entries, + .attrs = il3945_sysfs_entries, }; -struct ieee80211_ops iwl3945_hw_ops = { - .tx = iwl3945_mac_tx, - .start = iwl3945_mac_start, - .stop = iwl3945_mac_stop, - .add_interface = iwl_legacy_mac_add_interface, - .remove_interface = iwl_legacy_mac_remove_interface, - .change_interface = iwl_legacy_mac_change_interface, - .config = iwl_legacy_mac_config, - .configure_filter = iwl3945_configure_filter, - .set_key = iwl3945_mac_set_key, - .conf_tx = iwl_legacy_mac_conf_tx, - .reset_tsf = iwl_legacy_mac_reset_tsf, - .bss_info_changed = iwl_legacy_mac_bss_info_changed, - .hw_scan = iwl_legacy_mac_hw_scan, - .sta_add = iwl3945_mac_sta_add, - .sta_remove = iwl_legacy_mac_sta_remove, - .tx_last_beacon = iwl_legacy_mac_tx_last_beacon, +struct ieee80211_ops il3945_hw_ops = { + .tx = il3945_mac_tx, + .start = il3945_mac_start, + .stop = il3945_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il3945_configure_filter, + .set_key = il3945_mac_set_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .hw_scan = il_mac_hw_scan, + .sta_add = il3945_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .tx_last_beacon = il_mac_tx_last_beacon, }; -static int iwl3945_init_drv(struct iwl_priv *priv) +static int il3945_init_drv(struct il_priv *priv) { int ret; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; priv->retry_rate = 1; priv->beacon_skb = NULL; @@ -3545,61 +3545,61 @@ static int iwl3945_init_drv(struct iwl_priv *priv) priv->band = IEEE80211_BAND_2GHZ; priv->iw_mode = NL80211_IFTYPE_STATION; - priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; + priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD; + priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", + IL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", eeprom->version); ret = -EINVAL; goto err; } - ret = iwl_legacy_init_channel_map(priv); + ret = il_init_channel_map(priv); if (ret) { - IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(priv, "initializing regulatory failed: %d\n", ret); goto err; } /* Set up txpower settings in driver for all channels */ - if (iwl3945_txpower_set_from_eeprom(priv)) { + if (il3945_txpower_set_from_eeprom(priv)) { ret = -EIO; goto err_free_channel_map; } - ret = iwl_legacy_init_geos(priv); + ret = il_init_geos(priv); if (ret) { - IWL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(priv, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - iwl3945_init_hw_rates(priv, priv->ieee_rates); + il3945_init_hw_rates(priv, priv->ieee_rates); return 0; err_free_channel_map: - iwl_legacy_free_channel_map(priv); + il_free_channel_map(priv); err: return ret; } #define IWL3945_MAX_PROBE_REQUEST 200 -static int iwl3945_setup_mac(struct iwl_priv *priv) +static int il3945_setup_mac(struct il_priv *priv) { int ret; struct ieee80211_hw *hw = priv->hw; hw->rate_control_algorithm = "iwl-3945-rs"; - hw->sta_data_size = sizeof(struct iwl3945_sta_priv); - hw->vif_data_size = sizeof(struct iwl_vif_priv); + hw->sta_data_size = sizeof(struct il3945_sta_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); /* Tell mac80211 our characteristics */ hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SPECTRUM_MGMT; hw->wiphy->interface_modes = - priv->contexts[IWL_RXON_CTX_BSS].interface_modes; + priv->contexts[IL_RXON_CTX_BSS].interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | @@ -3620,11 +3620,11 @@ static int iwl3945_setup_mac(struct iwl_priv *priv) priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; - iwl_legacy_leds_init(priv); + il_leds_init(priv); ret = ieee80211_register_hw(priv->hw); if (ret) { - IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(priv, "Failed to register hw (error %d)\n", ret); return ret; } priv->mac80211_registered = 1; @@ -3632,13 +3632,13 @@ static int iwl3945_setup_mac(struct iwl_priv *priv) return 0; } -static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct iwl_priv *priv; + struct il_priv *priv; struct ieee80211_hw *hw; - struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); - struct iwl3945_eeprom *eeprom; + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); + struct il3945_eeprom *eeprom; unsigned long flags; /*********************** @@ -3647,7 +3647,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e /* mac80211 allocates memory for this device instance, including * space for this driver's private structure */ - hw = iwl_legacy_alloc_all(cfg); + hw = il_alloc_all(cfg); if (hw == NULL) { pr_err("Can not allocate network device\n"); err = -ENOMEM; @@ -3659,40 +3659,40 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e priv->cmd_queue = IWL39_CMD_QUEUE_NUM; /* 3945 has only one valid context */ - priv->valid_contexts = BIT(IWL_RXON_CTX_BSS); + priv->valid_contexts = BIT(IL_RXON_CTX_BSS); - for (i = 0; i < NUM_IWL_RXON_CTX; i++) + for (i = 0; i < NUM_IL_RXON_CTX; i++) priv->contexts[i].ctxid = i; - priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID; - priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IWL_RXON_CTX_BSS].interface_modes = + priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + priv->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IWL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IWL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; /* * Disabling hardware scan means that mac80211 will perform scans * "the hard way", rather than using device's scan. */ - if (iwl3945_mod_params.disable_hw_scan) { - IWL_DEBUG_INFO(priv, "Disabling hw_scan\n"); - iwl3945_hw_ops.hw_scan = NULL; + if (il3945_mod_params.disable_hw_scan) { + IL_DEBUG_INFO(priv, "Disabling hw_scan\n"); + il3945_hw_ops.hw_scan = NULL; } - IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); priv->cfg = cfg; priv->pci_dev = pdev; priv->inta_mask = CSR_INI_SET_MASK; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); /*************************** * 2. Initializing PCI bus @@ -3711,7 +3711,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e if (!err) err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); if (err) { - IWL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(priv, "No suitable DMA available.\n"); goto out_pci_disable_device; } @@ -3729,9 +3729,9 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e goto out_pci_release_regions; } - IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -3748,29 +3748,29 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /*********************** * 4. Read EEPROM * ********************/ /* Read the EEPROM */ - err = iwl_legacy_eeprom_init(priv); + err = il_eeprom_init(priv); if (err) { - IWL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(priv, "Unable to init EEPROM\n"); goto out_iounmap; } /* MAC Address location in EEPROM same for 3945/4965 */ - eeprom = (struct iwl3945_eeprom *)priv->eeprom; - IWL_DEBUG_INFO(priv, "MAC address: %pM\n", eeprom->mac_address); + eeprom = (struct il3945_eeprom *)priv->eeprom; + IL_DEBUG_INFO(priv, "MAC address: %pM\n", eeprom->mac_address); SET_IEEE80211_PERM_ADDR(priv->hw, eeprom->mac_address); /*********************** * 5. Setup HW Constants * ********************/ /* Device-specific setup */ - if (iwl3945_hw_set_hw_params(priv)) { - IWL_ERR(priv, "failed to set hw settings\n"); + if (il3945_hw_set_hw_params(priv)) { + IL_ERR(priv, "failed to set hw settings\n"); goto out_eeprom_free; } @@ -3778,13 +3778,13 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e * 6. Setup priv * ********************/ - err = iwl3945_init_drv(priv); + err = il3945_init_drv(priv); if (err) { - IWL_ERR(priv, "initializing driver failed\n"); + IL_ERR(priv, "initializing driver failed\n"); goto out_unset_hw_params; } - IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", + IL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", priv->cfg->name); /*********************** @@ -3792,44 +3792,44 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e * ********************/ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); pci_enable_msi(priv->pci_dev); - err = request_irq(priv->pci_dev->irq, iwl_legacy_isr, + err = request_irq(priv->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, priv); if (err) { - IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); goto out_disable_msi; } - err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group); + err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); if (err) { - IWL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(priv, "failed to create sysfs device attributes\n"); goto out_release_irq; } - iwl_legacy_set_rxon_channel(priv, + il_set_rxon_channel(priv, &priv->bands[IEEE80211_BAND_2GHZ].channels[5], - &priv->contexts[IWL_RXON_CTX_BSS]); - iwl3945_setup_deferred_work(priv); - iwl3945_setup_rx_handlers(priv); - iwl_legacy_power_initialize(priv); + &priv->contexts[IL_RXON_CTX_BSS]); + il3945_setup_deferred_work(priv); + il3945_setup_rx_handlers(priv); + il_power_initialize(priv); /********************************* * 8. Setup and Register mac80211 * *******************************/ - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); - err = iwl3945_setup_mac(priv); + err = il3945_setup_mac(priv); if (err) goto out_remove_sysfs; - err = iwl_legacy_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(priv, DRV_NAME); if (err) - IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); /* Start monitoring the killswitch */ queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, @@ -3840,17 +3840,17 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e out_remove_sysfs: destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); out_release_irq: free_irq(priv->pci_dev->irq, priv); out_disable_msi: pci_disable_msi(priv->pci_dev); - iwl_legacy_free_geos(priv); - iwl_legacy_free_channel_map(priv); + il_free_geos(priv); + il_free_channel_map(priv); out_unset_hw_params: - iwl3945_unset_hw_params(priv); + il3945_unset_hw_params(priv); out_eeprom_free: - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); out_iounmap: pci_iounmap(pdev, priv->hw_base); out_pci_release_regions: @@ -3859,74 +3859,74 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); out_ieee80211_free_hw: - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); ieee80211_free_hw(priv->hw); out: return err; } -static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) +static void __devexit il3945_pci_remove(struct pci_dev *pdev) { - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); unsigned long flags; if (!priv) return; - IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); - iwl_legacy_dbgfs_unregister(priv); + il_dbgfs_unregister(priv); set_bit(STATUS_EXIT_PENDING, &priv->status); - iwl_legacy_leds_exit(priv); + il_leds_exit(priv); if (priv->mac80211_registered) { ieee80211_unregister_hw(priv->hw); priv->mac80211_registered = 0; } else { - iwl3945_down(priv); + il3945_down(priv); } /* * Make sure device is reset to low power before unloading driver. - * This may be redundant with iwl_down(), but there are paths to - * run iwl_down() without calling apm_ops.stop(), and there are - * paths to avoid running iwl_down() at all before leaving driver. + * This may be redundant with il_down(), but there are paths to + * run il_down() without calling apm_ops.stop(), and there are + * paths to avoid running il_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); /* make sure we flush any pending irq or * tasklet for the driver */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl3945_synchronize_irq(priv); + il3945_synchronize_irq(priv); - sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); cancel_delayed_work_sync(&priv->_3945.rfkill_poll); - iwl3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(priv); if (priv->rxq.bd) - iwl3945_rx_queue_free(priv, &priv->rxq); - iwl3945_hw_txq_ctx_free(priv); + il3945_rx_queue_free(priv, &priv->rxq); + il3945_hw_txq_ctx_free(priv); - iwl3945_unset_hw_params(priv); + il3945_unset_hw_params(priv); /*netif_stop_queue(dev); */ flush_workqueue(priv->workqueue); - /* ieee80211_unregister_hw calls iwl3945_mac_stop, which flushes + /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes * priv->workqueue... so we can't take down the workqueue * until now... */ destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); free_irq(pdev->irq, priv); pci_disable_msi(pdev); @@ -3936,8 +3936,8 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - iwl_legacy_free_channel_map(priv); - iwl_legacy_free_geos(priv); + il_free_channel_map(priv); + il_free_geos(priv); kfree(priv->scan_cmd); if (priv->beacon_skb) dev_kfree_skb(priv->beacon_skb); @@ -3952,28 +3952,28 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) * *****************************************************************************/ -static struct pci_driver iwl3945_driver = { +static struct pci_driver il3945_driver = { .name = DRV_NAME, - .id_table = iwl3945_hw_card_ids, - .probe = iwl3945_pci_probe, - .remove = __devexit_p(iwl3945_pci_remove), - .driver.pm = IWL_LEGACY_PM_OPS, + .id_table = il3945_hw_card_ids, + .probe = il3945_pci_probe, + .remove = __devexit_p(il3945_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init iwl3945_init(void) +static int __init il3945_init(void) { int ret; pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); pr_info(DRV_COPYRIGHT "\n"); - ret = iwl3945_rate_control_register(); + ret = il3945_rate_control_register(); if (ret) { pr_err("Unable to register rate control algorithm: %d\n", ret); return ret; } - ret = pci_register_driver(&iwl3945_driver); + ret = pci_register_driver(&il3945_driver); if (ret) { pr_err("Unable to initialize PCI module\n"); goto error_register; @@ -3982,32 +3982,32 @@ static int __init iwl3945_init(void) return ret; error_register: - iwl3945_rate_control_unregister(); + il3945_rate_control_unregister(); return ret; } -static void __exit iwl3945_exit(void) +static void __exit il3945_exit(void) { - pci_unregister_driver(&iwl3945_driver); - iwl3945_rate_control_unregister(); + pci_unregister_driver(&il3945_driver); + il3945_rate_control_unregister(); } MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX)); -module_param_named(antenna, iwl3945_mod_params.antenna, int, S_IRUGO); +module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); -module_param_named(swcrypto, iwl3945_mod_params.sw_crypto, int, S_IRUGO); +module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); MODULE_PARM_DESC(swcrypto, "using software crypto (default 1 [software])"); -module_param_named(disable_hw_scan, iwl3945_mod_params.disable_hw_scan, +module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -module_param_named(fw_restart, iwl3945_mod_params.restart_fw, int, S_IRUGO); +module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); -module_exit(iwl3945_exit); -module_init(iwl3945_init); +module_exit(il3945_exit); +module_init(il3945_init); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index fd2f7a4..bd37c92 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -87,48 +87,48 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); -void iwl4965_update_chain_flags(struct iwl_priv *priv) +void il4965_update_chain_flags(struct il_priv *priv) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; if (priv->cfg->ops->hcmd->set_rxon_chain) { for_each_context(priv, ctx) { priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); if (ctx->active.rx_chain != ctx->staging.rx_chain) - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } } } -static void iwl4965_clear_free_frames(struct iwl_priv *priv) +static void il4965_clear_free_frames(struct il_priv *priv) { struct list_head *element; - IWL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", + IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", priv->frames_count); while (!list_empty(&priv->free_frames)) { element = priv->free_frames.next; list_del(element); - kfree(list_entry(element, struct iwl_frame, list)); + kfree(list_entry(element, struct il_frame, list)); priv->frames_count--; } if (priv->frames_count) { - IWL_WARN(priv, "%d frames still in use. Did we lose one?\n", + IL_WARN(priv, "%d frames still in use. Did we lose one?\n", priv->frames_count); priv->frames_count = 0; } } -static struct iwl_frame *iwl4965_get_free_frame(struct iwl_priv *priv) +static struct il_frame *il4965_get_free_frame(struct il_priv *priv) { - struct iwl_frame *frame; + struct il_frame *frame; struct list_head *element; if (list_empty(&priv->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IWL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(priv, "Could not allocate frame!\n"); return NULL; } @@ -138,16 +138,16 @@ static struct iwl_frame *iwl4965_get_free_frame(struct iwl_priv *priv) element = priv->free_frames.next; list_del(element); - return list_entry(element, struct iwl_frame, list); + return list_entry(element, struct il_frame, list); } -static void iwl4965_free_frame(struct iwl_priv *priv, struct iwl_frame *frame) +static void il4965_free_frame(struct il_priv *priv, struct il_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &priv->free_frames); } -static u32 iwl4965_fill_beacon_frame(struct iwl_priv *priv, +static u32 il4965_fill_beacon_frame(struct il_priv *priv, struct ieee80211_hdr *hdr, int left) { @@ -165,8 +165,8 @@ static u32 iwl4965_fill_beacon_frame(struct iwl_priv *priv, } /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void iwl4965_set_beacon_tim(struct iwl_priv *priv, - struct iwl_tx_beacon_cmd *tx_beacon_cmd, +static void il4965_set_beacon_tim(struct il_priv *priv, + struct il_tx_beacon_cmd *tx_beacon_cmd, u8 *beacon, u32 frame_size) { u16 tim_idx; @@ -188,13 +188,13 @@ static void iwl4965_set_beacon_tim(struct iwl_priv *priv, tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); tx_beacon_cmd->tim_size = beacon[tim_idx+1]; } else - IWL_WARN(priv, "Unable to find TIM Element in beacon\n"); + IL_WARN(priv, "Unable to find TIM Element in beacon\n"); } -static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl_frame *frame) +static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, + struct il_frame *frame) { - struct iwl_tx_beacon_cmd *tx_beacon_cmd; + struct il_tx_beacon_cmd *tx_beacon_cmd; u32 frame_size; u32 rate_flags; u32 rate; @@ -206,7 +206,7 @@ static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, lockdep_assert_held(&priv->mutex); if (!priv->beacon_ctx) { - IWL_ERR(priv, "trying to build beacon w/o beacon context!\n"); + IL_ERR(priv, "trying to build beacon w/o beacon context!\n"); return 0; } @@ -215,7 +215,7 @@ static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); /* Set up TX beacon contents */ - frame_size = iwl4965_fill_beacon_frame(priv, tx_beacon_cmd->frame, + frame_size = il4965_fill_beacon_frame(priv, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) return 0; @@ -230,53 +230,53 @@ static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; /* Set up TX beacon command fields */ - iwl4965_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, + il4965_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, frame_size); /* Set up packet rate and flags */ - rate = iwl_legacy_get_lowest_plcp(priv, priv->beacon_ctx); - priv->mgmt_tx_ant = iwl4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, + rate = il_get_lowest_plcp(priv, priv->beacon_ctx); + priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, priv->hw_params.valid_tx_ant); - rate_flags = iwl4965_ant_idx_to_flags(priv->mgmt_tx_ant); - if ((rate >= IWL_FIRST_CCK_RATE) && (rate <= IWL_LAST_CCK_RATE)) + rate_flags = il4965_ant_idx_to_flags(priv->mgmt_tx_ant); + if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; - tx_beacon_cmd->tx.rate_n_flags = iwl4965_hw_set_rate_n_flags(rate, + tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); return sizeof(*tx_beacon_cmd) + frame_size; } -int iwl4965_send_beacon_cmd(struct iwl_priv *priv) +int il4965_send_beacon_cmd(struct il_priv *priv) { - struct iwl_frame *frame; + struct il_frame *frame; unsigned int frame_size; int rc; - frame = iwl4965_get_free_frame(priv); + frame = il4965_get_free_frame(priv); if (!frame) { - IWL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(priv, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - frame_size = iwl4965_hw_get_beacon_cmd(priv, frame); + frame_size = il4965_hw_get_beacon_cmd(priv, frame); if (!frame_size) { - IWL_ERR(priv, "Error configuring the beacon command\n"); - iwl4965_free_frame(priv, frame); + IL_ERR(priv, "Error configuring the beacon command\n"); + il4965_free_frame(priv, frame); return -EINVAL; } - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - iwl4965_free_frame(priv, frame); + il4965_free_frame(priv, frame); return rc; } -static inline dma_addr_t iwl4965_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx) +static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) { - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; + struct il_tfd_tb *tb = &tfd->tbs[idx]; dma_addr_t addr = get_unaligned_le32(&tb->lo); if (sizeof(dma_addr_t) > sizeof(u32)) @@ -286,17 +286,17 @@ static inline dma_addr_t iwl4965_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx) return addr; } -static inline u16 iwl4965_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx) +static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) { - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; + struct il_tfd_tb *tb = &tfd->tbs[idx]; return le16_to_cpu(tb->hi_n_len) >> 4; } -static inline void iwl4965_tfd_set_tb(struct iwl_tfd *tfd, u8 idx, +static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, dma_addr_t addr, u16 len) { - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; + struct il_tfd_tb *tb = &tfd->tbs[idx]; u16 hi_n_len = len << 4; put_unaligned_le32(addr, &tb->lo); @@ -308,23 +308,23 @@ static inline void iwl4965_tfd_set_tb(struct iwl_tfd *tfd, u8 idx, tfd->num_tbs = idx + 1; } -static inline u8 iwl4965_tfd_get_num_tbs(struct iwl_tfd *tfd) +static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) { return tfd->num_tbs & 0x1f; } /** - * iwl4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] + * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] * @priv - driver private data * @txq - tx queue * * Does NOT advance any TFD circular buffer read/write indexes * Does NOT free the TFD itself (which is within circular buffer) */ -void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) +void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) { - struct iwl_tfd *tfd_tmp = (struct iwl_tfd *)txq->tfds; - struct iwl_tfd *tfd; + struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; + struct il_tfd *tfd; struct pci_dev *dev = priv->pci_dev; int index = txq->q.read_ptr; int i; @@ -333,10 +333,10 @@ void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) tfd = &tfd_tmp[index]; /* Sanity check on number of chunks */ - num_tbs = iwl4965_tfd_get_num_tbs(tfd); + num_tbs = il4965_tfd_get_num_tbs(tfd); - if (num_tbs >= IWL_NUM_OF_TBS) { - IWL_ERR(priv, "Too many chunks: %i\n", num_tbs); + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR(priv, "Too many chunks: %i\n", num_tbs); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -350,8 +350,8 @@ void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* Unmap chunks, if any. */ for (i = 1; i < num_tbs; i++) - pci_unmap_single(dev, iwl4965_tfd_tb_get_addr(tfd, i), - iwl4965_tfd_tb_get_len(tfd, i), + pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), + il4965_tfd_tb_get_len(tfd, i), PCI_DMA_TODEVICE); /* free SKB */ @@ -368,37 +368,37 @@ void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) } } -int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) { - struct iwl_queue *q; - struct iwl_tfd *tfd, *tfd_tmp; + struct il_queue *q; + struct il_tfd *tfd, *tfd_tmp; u32 num_tbs; q = &txq->q; - tfd_tmp = (struct iwl_tfd *)txq->tfds; + tfd_tmp = (struct il_tfd *)txq->tfds; tfd = &tfd_tmp[q->write_ptr]; if (reset) memset(tfd, 0, sizeof(*tfd)); - num_tbs = iwl4965_tfd_get_num_tbs(tfd); + num_tbs = il4965_tfd_get_num_tbs(tfd); /* Each TFD can point to a maximum 20 Tx buffers */ - if (num_tbs >= IWL_NUM_OF_TBS) { - IWL_ERR(priv, "Error can not send more than %d chunks\n", - IWL_NUM_OF_TBS); + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR(priv, "Error can not send more than %d chunks\n", + IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); - if (unlikely(addr & ~IWL_TX_DMA_MASK)) - IWL_ERR(priv, "Unaligned address = %llx\n", + if (unlikely(addr & ~IL_TX_DMA_MASK)) + IL_ERR(priv, "Unaligned address = %llx\n", (unsigned long long)addr); - iwl4965_tfd_set_tb(tfd, num_tbs, addr, len); + il4965_tfd_set_tb(tfd, num_tbs, addr, len); return 0; } @@ -410,13 +410,13 @@ int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA * channels supported in hardware. */ -int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, - struct iwl_tx_queue *txq) +int il4965_hw_tx_queue_init(struct il_priv *priv, + struct il_tx_queue *txq) { int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - iwl_legacy_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), + il_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -427,30 +427,30 @@ int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, * Generic RX handler implementations * ******************************************************************************/ -static void iwl4965_rx_reply_alive(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_reply_alive(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_alive_resp *palive; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; struct delayed_work *pwork; palive = &pkt->u.alive_frame; - IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); memcpy(&priv->card_alive_init, &pkt->u.alive_frame, - sizeof(struct iwl_init_alive_resp)); + sizeof(struct il_init_alive_resp)); pwork = &priv->init_alive_start; } else { - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); memcpy(&priv->card_alive, &pkt->u.alive_frame, - sizeof(struct iwl_alive_resp)); + sizeof(struct il_alive_resp)); pwork = &priv->alive_start; } @@ -460,11 +460,11 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, queue_delayed_work(priv->workqueue, pwork, msecs_to_jiffies(5)); else - IWL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(priv, "uCode did not respond OK.\n"); } /** - * iwl4965_bg_statistics_periodic - Timer callback to queue statistics + * il4965_bg_statistics_periodic - Timer callback to queue statistics * * This callback is provided in order to send a statistics request. * @@ -473,30 +473,30 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, * was received. We need to ensure we receive the statistics in order * to update the temperature used for calibrating the TXPOWER. */ -static void iwl4965_bg_statistics_periodic(unsigned long data) +static void il4965_bg_statistics_periodic(unsigned long data) { - struct iwl_priv *priv = (struct iwl_priv *)data; + struct il_priv *priv = (struct il_priv *)data; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; /* dont send host command if rf-kill is on */ - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return; - iwl_legacy_send_statistics_request(priv, CMD_ASYNC, false); + il_send_statistics_request(priv, CMD_ASYNC, false); } -static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl4965_beacon_notif *beacon = - (struct iwl4965_beacon_notif *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = + (struct il4965_beacon_notif *)pkt->u.raw; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - u8 rate = iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IWL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -508,35 +508,35 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } -static void iwl4965_perform_ct_kill_task(struct iwl_priv *priv) +static void il4965_perform_ct_kill_task(struct il_priv *priv) { unsigned long flags; - IWL_DEBUG_POWER(priv, "Stop all queues\n"); + IL_DEBUG_POWER(priv, "Stop all queues\n"); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(priv, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - iwl_read32(priv, CSR_UCODE_DRV_GP1); + il_read32(priv, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&priv->reg_lock, flags); - if (!iwl_grab_nic_access(priv)) - iwl_release_nic_access(priv); + if (!il_grab_nic_access(priv)) + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, flags); } /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_card_state_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = priv->status; - IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", + IL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On", (flags & CT_CARD_DISABLED) ? @@ -545,22 +545,22 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(priv, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - iwl_legacy_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(priv, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - iwl_legacy_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(priv, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } if (flags & CT_CARD_DISABLED) - iwl4965_perform_ct_kill_task(priv); + il4965_perform_ct_kill_task(priv); if (flags & HW_CARD_DISABLED) set_bit(STATUS_RF_KILL_HW, &priv->status); @@ -568,7 +568,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, clear_bit(STATUS_RF_KILL_HW, &priv->status); if (!(flags & RXON_CARD_DISABLED)) - iwl_legacy_scan_cancel(priv); + il_scan_cancel(priv); if ((test_bit(STATUS_RF_KILL_HW, &status) != test_bit(STATUS_RF_KILL_HW, &priv->status))) @@ -579,7 +579,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, } /** - * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks + * il4965_setup_rx_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -587,55 +587,55 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) +static void il4965_setup_rx_handlers(struct il_priv *priv) { - priv->rx_handlers[REPLY_ALIVE] = iwl4965_rx_reply_alive; - priv->rx_handlers[REPLY_ERROR] = iwl_legacy_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_legacy_rx_csa; + priv->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; + priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - iwl_legacy_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl_legacy_rx_pm_sleep_notif; + il_rx_spectrum_measure_notif; + priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - iwl_legacy_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = iwl4965_rx_beacon_notif; + il_rx_pm_debug_statistics_notif; + priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_rx_statistics; + priv->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; + priv->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; - iwl_legacy_setup_rx_scan_handlers(priv); + il_setup_rx_scan_handlers(priv); /* status change handler */ priv->rx_handlers[CARD_STATE_NOTIFICATION] = - iwl4965_rx_card_state_notif; + il4965_rx_card_state_notif; priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = - iwl4965_rx_missed_beacon_notif; + il4965_rx_missed_beacon_notif; /* Rx handlers */ - priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy; - priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl4965_rx_reply_rx; + priv->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; + priv->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; /* block ack */ - priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl4965_rx_reply_compressed_ba; + priv->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ priv->cfg->ops->lib->rx_handler_setup(priv); } /** - * iwl4965_rx_handle - Main entry function for receiving responses from uCode + * il4965_rx_handle - Main entry function for receiving responses from uCode * * Uses the priv->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -void iwl4965_rx_handle(struct iwl_priv *priv) +void il4965_rx_handle(struct il_priv *priv) { - struct iwl_rx_mem_buffer *rxb; - struct iwl_rx_packet *pkt; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_mem_buffer *rxb; + struct il_rx_packet *pkt; + struct il_rx_queue *rxq = &priv->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -650,7 +650,7 @@ void iwl4965_rx_handle(struct iwl_priv *priv) /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); /* calculate total frames need to be restock after handling RX */ total_empty = r - rxq->write_actual; @@ -696,18 +696,18 @@ void iwl4965_rx_handle(struct iwl_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See iwl4965_setup_rx_handlers() */ + * rx_handlers table. See il4965_setup_rx_handlers() */ if (priv->rx_handlers[pkt->hdr.cmd]) { - IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, - i, iwl_legacy_get_cmd_string(pkt->hdr.cmd), + IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); } else { /* No handling needed */ - IWL_DEBUG_RX(priv, + IL_DEBUG_RX(priv, "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, iwl_legacy_get_cmd_string(pkt->hdr.cmd), + r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } @@ -720,12 +720,12 @@ void iwl4965_rx_handle(struct iwl_priv *priv) if (reclaim) { /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking iwl_legacy_send_cmd() + * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - iwl_legacy_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(priv, rxb); else - IWL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(priv, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -750,7 +750,7 @@ void iwl4965_rx_handle(struct iwl_priv *priv) count++; if (count >= 8) { rxq->read = i; - iwl4965_rx_replenish_now(priv); + il4965_rx_replenish_now(priv); count = 0; } } @@ -759,20 +759,20 @@ void iwl4965_rx_handle(struct iwl_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - iwl4965_rx_replenish_now(priv); + il4965_rx_replenish_now(priv); else - iwl4965_rx_queue_restock(priv); + il4965_rx_queue_restock(priv); } /* call this function to flush any scheduled tasklet */ -static inline void iwl4965_synchronize_irq(struct iwl_priv *priv) +static inline void il4965_synchronize_irq(struct il_priv *priv) { /* wait to make sure we flush pending tasklet*/ synchronize_irq(priv->pci_dev->irq); tasklet_kill(&priv->irq_tasklet); } -static void iwl4965_irq_tasklet(struct iwl_priv *priv) +static void il4965_irq_tasklet(struct il_priv *priv) { u32 inta, handled = 0; u32 inta_fh; @@ -787,20 +787,20 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = iwl_read32(priv, CSR_INT); - iwl_write32(priv, CSR_INT, inta); + inta = il_read32(priv, CSR_INT); + il_write32(priv, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - iwl_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + il_write32(priv, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & IWL_DL_ISR) { + if (il_get_debug_level(priv) & IL_DL_ISR) { /* just for debug */ - inta_mask = iwl_read32(priv, CSR_INT_MASK); - IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(priv, CSR_INT_MASK); + IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -818,13 +818,13 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IWL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(priv, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); priv->isr_stats.hw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_HW_ERR; @@ -832,17 +832,17 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { + if (il_get_debug_level(priv) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IWL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(priv, "Scheduler finished to transmit " "the frame/frames.\n"); priv->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IWL_DEBUG_ISR(priv, "Alive interrupt\n"); + IL_DEBUG_ISR(priv, "Alive interrupt\n"); priv->isr_stats.alive++; } } @@ -853,11 +853,11 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(iwl_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; - IWL_WARN(priv, "RF_KILL bit toggled to %s.\n", + IL_WARN(priv, "RF_KILL bit toggled to %s.\n", hw_rf_kill ? "disable radio" : "enable radio"); priv->isr_stats.rfkill++; @@ -880,17 +880,17 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* Chip got too hot and stopped itself */ if (inta & CSR_INT_BIT_CT_KILL) { - IWL_ERR(priv, "Microcode CT kill error detected.\n"); + IL_ERR(priv, "Microcode CT kill error detected.\n"); priv->isr_stats.ctkill++; handled |= CSR_INT_BIT_CT_KILL; } /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IWL_ERR(priv, "Microcode SW error detected. " + IL_ERR(priv, "Microcode SW error detected. " " Restarting 0x%X.\n", inta); priv->isr_stats.sw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_SW_ERR; } @@ -900,10 +900,10 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) * and about any Rx buffers made available while asleep. */ if (inta & CSR_INT_BIT_WAKEUP) { - IWL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - iwl_legacy_rx_queue_update_write_ptr(priv, &priv->rxq); + IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(priv, &priv->rxq); for (i = 0; i < priv->hw_params.max_txq_num; i++) - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[i]); + il_txq_update_write_ptr(priv, &priv->txq[i]); priv->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; } @@ -912,14 +912,14 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - iwl4965_rx_handle(priv); + il4965_rx_handle(priv); priv->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } /* This "Tx" DMA channel is used only for loading uCode */ if (inta & CSR_INT_BIT_FH_TX) { - IWL_DEBUG_ISR(priv, "uCode load interrupt\n"); + IL_DEBUG_ISR(priv, "uCode load interrupt\n"); priv->isr_stats.tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ @@ -928,30 +928,30 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) } if (inta & ~handled) { - IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); priv->isr_stats.unhandled++; } if (inta & ~(priv->inta_mask)) { - IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", inta & ~priv->inta_mask); - IWL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ if (test_bit(STATUS_INT_ENABLED, &priv->status)) - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); /* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) - iwl_legacy_enable_rfkill_int(priv); + il_enable_rfkill_int(priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { - inta = iwl_read32(priv, CSR_INT); - inta_mask = iwl_read32(priv, CSR_INT_MASK); - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - IWL_DEBUG_ISR(priv, + if (il_get_debug_level(priv) & (IL_DL_ISR)) { + inta = il_read32(priv, CSR_INT); + inta_mask = il_read32(priv, CSR_INT_MASK); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -977,78 +977,78 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t iwl4965_show_debug_level(struct device *d, +static ssize_t il4965_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", iwl_legacy_get_debug_level(priv)); + struct il_priv *priv = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); } -static ssize_t iwl4965_store_debug_level(struct device *d, +static ssize_t il4965_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IWL_ERR(priv, "%s is not in hex or decimal form.\n", buf); + IL_ERR(priv, "%s is not in hex or decimal form.\n", buf); else { priv->debug_level = val; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - iwl4965_show_debug_level, iwl4965_store_debug_level); + il4965_show_debug_level, il4965_store_debug_level); #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ -static ssize_t iwl4965_show_temperature(struct device *d, +static ssize_t il4965_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; return sprintf(buf, "%d\n", priv->temperature); } -static DEVICE_ATTR(temperature, S_IRUGO, iwl4965_show_temperature, NULL); +static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); -static ssize_t iwl4965_show_tx_power(struct device *d, +static ssize_t il4965_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return sprintf(buf, "off\n"); else return sprintf(buf, "%d\n", priv->tx_power_user_lmt); } -static ssize_t iwl4965_store_tx_power(struct device *d, +static ssize_t il4965_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 10, &val); if (ret) - IWL_INFO(priv, "%s is not in decimal form.\n", buf); + IL_INFO(priv, "%s is not in decimal form.\n", buf); else { - ret = iwl_legacy_set_tx_power(priv, val, false); + ret = il_set_tx_power(priv, val, false); if (ret) - IWL_ERR(priv, "failed setting tx power (0x%d).\n", + IL_ERR(priv, "failed setting tx power (0x%d).\n", ret); else ret = count; @@ -1057,9 +1057,9 @@ static ssize_t iwl4965_store_tx_power(struct device *d, } static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, - iwl4965_show_tx_power, iwl4965_store_tx_power); + il4965_show_tx_power, il4965_store_tx_power); -static struct attribute *iwl_sysfs_entries[] = { +static struct attribute *il_sysfs_entries[] = { &dev_attr_temperature.attr, &dev_attr_tx_power.attr, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1068,9 +1068,9 @@ static struct attribute *iwl_sysfs_entries[] = { NULL }; -static struct attribute_group iwl_attribute_group = { +static struct attribute_group il_attribute_group = { .name = NULL, /* put in device directory */ - .attrs = iwl_sysfs_entries, + .attrs = il_sysfs_entries, }; /****************************************************************************** @@ -1079,28 +1079,28 @@ static struct attribute_group iwl_attribute_group = { * ******************************************************************************/ -static void iwl4965_dealloc_ucode_pci(struct iwl_priv *priv) +static void il4965_dealloc_ucode_pci(struct il_priv *priv) { - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_code); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(priv->pci_dev, &priv->ucode_code); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); } -static void iwl4965_nic_start(struct iwl_priv *priv) +static void il4965_nic_start(struct il_priv *priv) { /* Remove all resets to allow NIC to operate */ - iwl_write32(priv, CSR_RESET, 0); + il_write32(priv, CSR_RESET, 0); } -static void iwl4965_ucode_callback(const struct firmware *ucode_raw, +static void il4965_ucode_callback(const struct firmware *ucode_raw, void *context); -static int iwl4965_mac_setup_register(struct iwl_priv *priv, +static int il4965_mac_setup_register(struct il_priv *priv, u32 max_probe_length); -static int __must_check iwl4965_request_firmware(struct iwl_priv *priv, bool first) +static int __must_check il4965_request_firmware(struct il_priv *priv, bool first) { const char *name_pre = priv->cfg->fw_name_pre; char tag[8]; @@ -1114,35 +1114,35 @@ static int __must_check iwl4965_request_firmware(struct iwl_priv *priv, bool fir } if (priv->fw_index < priv->cfg->ucode_api_min) { - IWL_ERR(priv, "no suitable firmware found!\n"); + IL_ERR(priv, "no suitable firmware found!\n"); return -ENOENT; } sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IWL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n", + IL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n", priv->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, &priv->pci_dev->dev, GFP_KERNEL, priv, - iwl4965_ucode_callback); + il4965_ucode_callback); } -struct iwl4965_firmware_pieces { +struct il4965_firmware_pieces { const void *inst, *data, *init, *init_data, *boot; size_t inst_size, data_size, init_size, init_data_size, boot_size; }; -static int iwl4965_load_firmware(struct iwl_priv *priv, +static int il4965_load_firmware(struct il_priv *priv, const struct firmware *ucode_raw, - struct iwl4965_firmware_pieces *pieces) + struct il4965_firmware_pieces *pieces) { - struct iwl_ucode_header *ucode = (void *)ucode_raw->data; + struct il_ucode_header *ucode = (void *)ucode_raw->data; u32 api_ver, hdr_size; const u8 *src; priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IWL_UCODE_API(priv->ucode_ver); + api_ver = IL_UCODE_API(priv->ucode_ver); switch (api_ver) { default: @@ -1151,7 +1151,7 @@ static int iwl4965_load_firmware(struct iwl_priv *priv, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IWL_ERR(priv, "File size too small!\n"); + IL_ERR(priv, "File size too small!\n"); return -EINVAL; } pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); @@ -1169,7 +1169,7 @@ static int iwl4965_load_firmware(struct iwl_priv *priv, pieces->data_size + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IWL_ERR(priv, + IL_ERR(priv, "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -1190,54 +1190,54 @@ static int iwl4965_load_firmware(struct iwl_priv *priv, } /** - * iwl4965_ucode_callback - callback when firmware was loaded + * il4965_ucode_callback - callback when firmware was loaded * * If loaded successfully, copies the firmware into buffers * for the card to fetch (via DMA). */ static void -iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) +il4965_ucode_callback(const struct firmware *ucode_raw, void *context) { - struct iwl_priv *priv = context; - struct iwl_ucode_header *ucode; + struct il_priv *priv = context; + struct il_ucode_header *ucode; int err; - struct iwl4965_firmware_pieces pieces; + struct il4965_firmware_pieces pieces; const unsigned int api_max = priv->cfg->ucode_api_max; const unsigned int api_min = priv->cfg->ucode_api_min; u32 api_ver; u32 max_probe_length = 200; u32 standard_phy_calibration_size = - IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; + IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { if (priv->fw_index <= priv->cfg->ucode_api_max) - IWL_ERR(priv, + IL_ERR(priv, "request for firmware file '%s' failed.\n", priv->firmware_name); goto try_again; } - IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", + IL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", priv->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { - IWL_ERR(priv, "File size way too small!\n"); + IL_ERR(priv, "File size way too small!\n"); goto try_again; } /* Data from ucode file: header followed by uCode images */ - ucode = (struct iwl_ucode_header *)ucode_raw->data; + ucode = (struct il_ucode_header *)ucode_raw->data; - err = iwl4965_load_firmware(priv, ucode_raw, &pieces); + err = il4965_load_firmware(priv, ucode_raw, &pieces); if (err) goto try_again; - api_ver = IWL_UCODE_API(priv->ucode_ver); + api_ver = IL_UCODE_API(priv->ucode_ver); /* * api_ver should match the api version forming part of the @@ -1245,7 +1245,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(priv, + IL_ERR(priv, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -1253,25 +1253,25 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) } if (api_ver != api_max) - IWL_ERR(priv, + IL_ERR(priv, "Firmware has old API version. Expected v%u, " "got v%u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); snprintf(priv->hw->wiphy->fw_version, sizeof(priv->hw->wiphy->fw_version), "%u.%u.%u.%u", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); /* * For any of the failures below (before allocating pci memory) @@ -1279,46 +1279,46 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", + IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", priv->ucode_ver); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", pieces.data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", pieces.init_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", pieces.init_data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ if (pieces.inst_size > priv->hw_params.max_inst_size) { - IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n", + IL_ERR(priv, "uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } if (pieces.data_size > priv->hw_params.max_data_size) { - IWL_ERR(priv, "uCode data len %Zd too large to fit in\n", + IL_ERR(priv, "uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } if (pieces.init_size > priv->hw_params.max_inst_size) { - IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", + IL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } if (pieces.init_data_size > priv->hw_params.max_data_size) { - IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n", + IL_ERR(priv, "uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } if (pieces.boot_size > priv->hw_params.max_bsm_size) { - IWL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n", + IL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n", pieces.boot_size); goto try_again; } @@ -1329,13 +1329,13 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ priv->ucode_code.len = pieces.inst_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); priv->ucode_data.len = pieces.data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); priv->ucode_data_backup.len = pieces.data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || !priv->ucode_data_backup.v_addr) @@ -1344,10 +1344,10 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { priv->ucode_init.len = pieces.init_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); priv->ucode_init_data.len = pieces.init_data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) goto err_pci_alloc; @@ -1356,7 +1356,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Bootstrap (instructions only, no data) */ if (pieces.boot_size) { priv->ucode_boot.len = pieces.boot_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); if (!priv->ucode_boot.v_addr) goto err_pci_alloc; @@ -1369,25 +1369,25 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Copy images into buffers for card's bus-master reads ... */ /* Runtime instructions (first block of data in file) */ - IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", pieces.inst_size); memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size); - IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); /* * Runtime data - * NOTE: Copy into backup buffer will be done in iwl_up() + * NOTE: Copy into backup buffer will be done in il_up() */ - IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", pieces.data_size); memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size); memcpy(priv->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n", pieces.init_size); memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size); @@ -1395,7 +1395,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Initialization data */ if (pieces.init_data_size) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n", pieces.init_data_size); memcpy(priv->ucode_init_data.v_addr, pieces.init_data, @@ -1403,7 +1403,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) } /* Bootstrap instructions */ - IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", + IL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", pieces.boot_size); memcpy(priv->ucode_boot.v_addr, pieces.boot, pieces.boot_size); @@ -1421,19 +1421,19 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * * 9. Setup and register with mac80211 and debugfs **************************************************/ - err = iwl4965_mac_setup_register(priv, max_probe_length); + err = il4965_mac_setup_register(priv, max_probe_length); if (err) goto out_unbind; - err = iwl_legacy_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(priv, DRV_NAME); if (err) - IWL_ERR(priv, + IL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); err = sysfs_create_group(&priv->pci_dev->dev.kobj, - &iwl_attribute_group); + &il_attribute_group); if (err) { - IWL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(priv, "failed to create sysfs device attributes\n"); goto out_unbind; } @@ -1444,14 +1444,14 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) try_again: /* try next, if any */ - if (iwl4965_request_firmware(priv, false)) + if (il4965_request_firmware(priv, false)) goto out_unbind; release_firmware(ucode_raw); return; err_pci_alloc: - IWL_ERR(priv, "failed to allocate pci memory\n"); - iwl4965_dealloc_ucode_pci(priv); + IL_ERR(priv, "failed to allocate pci memory\n"); + il4965_dealloc_ucode_pci(priv); out_unbind: complete(&priv->_4965.firmware_loading_complete); device_release_driver(&priv->pci_dev->dev); @@ -1508,7 +1508,7 @@ static struct { char *name; u8 num; } advanced_lookup[] = { { "ADVANCED_SYSASSERT", 0 }, }; -static const char *iwl4965_desc_lookup(u32 num) +static const char *il4965_desc_lookup(u32 num) { int i; int max = ARRAY_SIZE(desc_lookup_text); @@ -1527,7 +1527,7 @@ static const char *iwl4965_desc_lookup(u32 num) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void iwl4965_dump_nic_error_log(struct iwl_priv *priv) +void il4965_dump_nic_error_log(struct il_priv *priv) { u32 data2, line; u32 desc, time, count, base, data1; @@ -1541,78 +1541,78 @@ void iwl4965_dump_nic_error_log(struct iwl_priv *priv) } if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IWL_ERR(priv, + IL_ERR(priv, "Not valid error log pointer 0x%08X for %s uCode\n", base, (priv->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; } - count = iwl_legacy_read_targ_mem(priv, base); + count = il_read_targ_mem(priv, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IWL_ERR(priv, "Start IWL Error Log Dump:\n"); - IWL_ERR(priv, "Status: 0x%08lX, count: %d\n", + IL_ERR(priv, "Start IWL Error Log Dump:\n"); + IL_ERR(priv, "Status: 0x%08lX, count: %d\n", priv->status, count); } - desc = iwl_legacy_read_targ_mem(priv, base + 1 * sizeof(u32)); + desc = il_read_targ_mem(priv, base + 1 * sizeof(u32)); priv->isr_stats.err_code = desc; - pc = iwl_legacy_read_targ_mem(priv, base + 2 * sizeof(u32)); - blink1 = iwl_legacy_read_targ_mem(priv, base + 3 * sizeof(u32)); - blink2 = iwl_legacy_read_targ_mem(priv, base + 4 * sizeof(u32)); - ilink1 = iwl_legacy_read_targ_mem(priv, base + 5 * sizeof(u32)); - ilink2 = iwl_legacy_read_targ_mem(priv, base + 6 * sizeof(u32)); - data1 = iwl_legacy_read_targ_mem(priv, base + 7 * sizeof(u32)); - data2 = iwl_legacy_read_targ_mem(priv, base + 8 * sizeof(u32)); - line = iwl_legacy_read_targ_mem(priv, base + 9 * sizeof(u32)); - time = iwl_legacy_read_targ_mem(priv, base + 11 * sizeof(u32)); - hcmd = iwl_legacy_read_targ_mem(priv, base + 22 * sizeof(u32)); - - IWL_ERR(priv, "Desc Time " + pc = il_read_targ_mem(priv, base + 2 * sizeof(u32)); + blink1 = il_read_targ_mem(priv, base + 3 * sizeof(u32)); + blink2 = il_read_targ_mem(priv, base + 4 * sizeof(u32)); + ilink1 = il_read_targ_mem(priv, base + 5 * sizeof(u32)); + ilink2 = il_read_targ_mem(priv, base + 6 * sizeof(u32)); + data1 = il_read_targ_mem(priv, base + 7 * sizeof(u32)); + data2 = il_read_targ_mem(priv, base + 8 * sizeof(u32)); + line = il_read_targ_mem(priv, base + 9 * sizeof(u32)); + time = il_read_targ_mem(priv, base + 11 * sizeof(u32)); + hcmd = il_read_targ_mem(priv, base + 22 * sizeof(u32)); + + IL_ERR(priv, "Desc Time " "data1 data2 line\n"); - IWL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", - iwl4965_desc_lookup(desc), desc, time, data1, data2, line); - IWL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IWL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + IL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + il4965_desc_lookup(desc), desc, time, data1, data2, line); + IL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, blink2, ilink1, ilink2, hcmd); } -static void iwl4965_rf_kill_ct_config(struct iwl_priv *priv) +static void il4965_rf_kill_ct_config(struct il_priv *priv) { - struct iwl_ct_kill_config cmd; + struct il_ct_kill_config cmd; unsigned long flags; int ret = 0; spin_lock_irqsave(&priv->lock, flags); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); spin_unlock_irqrestore(&priv->lock, flags); cmd.critical_temperature_R = cpu_to_le32(priv->hw_params.ct_kill_threshold); - ret = iwl_legacy_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, + ret = il_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, sizeof(cmd), &cmd); if (ret) - IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); else - IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " + IL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " "succeeded, " "critical temperature is %d\n", priv->hw_params.ct_kill_threshold); } static const s8 default_queue_to_tx_fifo[] = { - IWL_TX_FIFO_VO, - IWL_TX_FIFO_VI, - IWL_TX_FIFO_BE, - IWL_TX_FIFO_BK, + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, IWL49_CMD_FIFO_NUM, - IWL_TX_FIFO_UNUSED, - IWL_TX_FIFO_UNUSED, + IL_TX_FIFO_UNUSED, + IL_TX_FIFO_UNUSED, }; -static int iwl4965_alive_notify(struct iwl_priv *priv) +static int il4965_alive_notify(struct il_priv *priv) { u32 a; unsigned long flags; @@ -1622,52 +1622,52 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) spin_lock_irqsave(&priv->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - priv->scd_base_addr = iwl_legacy_read_prph(priv, + priv->scd_base_addr = il_read_prph(priv, IWL49_SCD_SRAM_BASE_ADDR); a = priv->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; for (; a < priv->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) - iwl_legacy_write_targ_mem(priv, a, 0); + il_write_targ_mem(priv, a, 0); for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) - iwl_legacy_write_targ_mem(priv, a, 0); + il_write_targ_mem(priv, a, 0); for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4) - iwl_legacy_write_targ_mem(priv, a, 0); + il_write_targ_mem(priv, a, 0); /* Tel 4965 where to find Tx byte count tables */ - iwl_legacy_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, + il_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, priv->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - iwl_legacy_write_direct32(priv, + il_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = iwl_legacy_read_direct32(priv, FH_TX_CHICKEN_BITS_REG); - iwl_legacy_write_direct32(priv, FH_TX_CHICKEN_BITS_REG, + reg_val = il_read_direct32(priv, FH_TX_CHICKEN_BITS_REG); + il_write_direct32(priv, FH_TX_CHICKEN_BITS_REG, reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < priv->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(i), 0); - iwl_legacy_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); + il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ - iwl_legacy_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ - iwl_legacy_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i) + sizeof(u32), (SCD_FRAME_LIMIT << @@ -1675,13 +1675,13 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - iwl_legacy_write_prph(priv, IWL49_SCD_INTERRUPT_MASK, + il_write_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << priv->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ - iwl4965_txq_set_sched(priv, IWL_MASK(0, 6)); + il4965_txq_set_sched(priv, IL_MASK(0, 6)); - iwl4965_set_wr_ptrs(priv, IWL_DEFAULT_CMD_QUEUE_NUM, 0); + il4965_set_wr_ptrs(priv, IL_DEFAULT_CMD_QUEUE_NUM, 0); /* make sure all queue are not stopped */ memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped)); @@ -1696,12 +1696,12 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { int ac = default_queue_to_tx_fifo[i]; - iwl_txq_ctx_activate(priv, i); + il_txq_ctx_activate(priv, i); - if (ac == IWL_TX_FIFO_UNUSED) + if (ac == IL_TX_FIFO_UNUSED) continue; - iwl4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); + il4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); } spin_unlock_irqrestore(&priv->lock, flags); @@ -1710,37 +1710,37 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) } /** - * iwl4965_alive_start - called after REPLY_ALIVE notification received + * il4965_alive_start - called after REPLY_ALIVE notification received * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by iwl_init_alive_start()). + * Alive gets handled by il_init_alive_start()). */ -static void iwl4965_alive_start(struct iwl_priv *priv) +static void il4965_alive_start(struct il_priv *priv) { int ret = 0; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); if (priv->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(priv, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (iwl4965_verify_ucode(priv)) { + if (il4965_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); goto restart; } - ret = iwl4965_alive_notify(priv); + ret = il4965_alive_notify(priv); if (ret) { - IWL_WARN(priv, + IL_WARN(priv, "Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } @@ -1750,49 +1750,49 @@ static void iwl4965_alive_start(struct iwl_priv *priv) set_bit(STATUS_ALIVE, &priv->status); /* Enable watchdog to monitor the driver tx queues */ - iwl_legacy_setup_watchdog(priv); + il_setup_watchdog(priv); - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) return; ieee80211_wake_queues(priv->hw); - priv->active_rate = IWL_RATES_MASK; + priv->active_rate = IL_RATES_MASK; - if (iwl_legacy_is_associated_ctx(ctx)) { - struct iwl_legacy_rxon_cmd *active_rxon = - (struct iwl_legacy_rxon_cmd *)&ctx->active; + if (il_is_associated_ctx(ctx)) { + struct il_rxon_cmd *active_rxon = + (struct il_rxon_cmd *)&ctx->active; /* apply any changes in staging */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { - struct iwl_rxon_context *tmp; + struct il_rxon_context *tmp; /* Initialize our rx_config data */ for_each_context(priv, tmp) - iwl_legacy_connection_init_rx_config(priv, tmp); + il_connection_init_rx_config(priv, tmp); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); } /* Configure bluetooth coexistence if enabled */ - iwl_legacy_send_bt_config(priv); + il_send_bt_config(priv); - iwl4965_reset_run_time_calib(priv); + il4965_reset_run_time_calib(priv); set_bit(STATUS_READY, &priv->status); /* Configure the adapter for unassociated operation */ - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); /* At this point, the NIC is initialized and operational */ - iwl4965_rf_kill_ct_config(priv); + il4965_rf_kill_ct_config(priv); - IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); + IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); wake_up(&priv->wait_command_queue); - iwl_legacy_power_update_mode(priv, true); - IWL_DEBUG_INFO(priv, "Updated power mode\n"); + il_power_update_mode(priv, true); + IL_DEBUG_INFO(priv, "Updated power mode\n"); return; @@ -1800,16 +1800,16 @@ static void iwl4965_alive_start(struct iwl_priv *priv) queue_work(priv->workqueue, &priv->restart); } -static void iwl4965_cancel_deferred_work(struct iwl_priv *priv); +static void il4965_cancel_deferred_work(struct il_priv *priv); -static void __iwl4965_down(struct iwl_priv *priv) +static void __il4965_down(struct il_priv *priv) { unsigned long flags; int exit_pending; - IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); @@ -1817,9 +1817,9 @@ static void __iwl4965_down(struct iwl_priv *priv) * to prevent rearm timer */ del_timer_sync(&priv->watchdog); - iwl_legacy_clear_ucode_stations(priv, NULL); - iwl_legacy_dealloc_bcast_stations(priv); - iwl_legacy_clear_driver_stations(priv); + il_clear_ucode_stations(priv, NULL); + il_dealloc_bcast_stations(priv); + il_clear_driver_stations(priv); /* Unblock any waiting calls */ wake_up_all(&priv->wait_command_queue); @@ -1830,20 +1830,20 @@ static void __iwl4965_down(struct iwl_priv *priv) clear_bit(STATUS_EXIT_PENDING, &priv->status); /* stop and reset the on-board processor */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl4965_synchronize_irq(priv); + il4965_synchronize_irq(priv); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); - /* If we have not previously called iwl_init() then + /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ - if (!iwl_legacy_is_init(priv)) { + if (!il_is_init(priv)) { priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << STATUS_RF_KILL_HW | test_bit(STATUS_GEO_CONFIGURED, &priv->status) << @@ -1864,50 +1864,50 @@ static void __iwl4965_down(struct iwl_priv *priv) test_bit(STATUS_EXIT_PENDING, &priv->status) << STATUS_EXIT_PENDING; - iwl4965_txq_ctx_stop(priv); - iwl4965_rxq_stop(priv); + il4965_txq_ctx_stop(priv); + il4965_rxq_stop(priv); /* Power-down device's busmaster DMA clocks */ - iwl_legacy_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Make sure (redundant) we've released our request to stay awake */ - iwl_legacy_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); exit: - memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); + memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); dev_kfree_skb(priv->beacon_skb); priv->beacon_skb = NULL; /* clear out any free frames */ - iwl4965_clear_free_frames(priv); + il4965_clear_free_frames(priv); } -static void iwl4965_down(struct iwl_priv *priv) +static void il4965_down(struct il_priv *priv) { mutex_lock(&priv->mutex); - __iwl4965_down(priv); + __il4965_down(priv); mutex_unlock(&priv->mutex); - iwl4965_cancel_deferred_work(priv); + il4965_cancel_deferred_work(priv); } #define HW_READY_TIMEOUT (50) -static int iwl4965_set_hw_ready(struct iwl_priv *priv) +static int il4965_set_hw_ready(struct il_priv *priv) { int ret = 0; - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); @@ -1916,107 +1916,107 @@ static int iwl4965_set_hw_ready(struct iwl_priv *priv) else priv->hw_ready = false; - IWL_DEBUG_INFO(priv, "hardware %s\n", + IL_DEBUG_INFO(priv, "hardware %s\n", (priv->hw_ready == 1) ? "ready" : "not ready"); return ret; } -static int iwl4965_prepare_card_hw(struct iwl_priv *priv) +static int il4965_prepare_card_hw(struct il_priv *priv) { int ret = 0; - IWL_DEBUG_INFO(priv, "iwl4965_prepare_card_hw enter\n"); + IL_DEBUG_INFO(priv, "il4965_prepare_card_hw enter\n"); - ret = iwl4965_set_hw_ready(priv); + ret = il4965_set_hw_ready(priv); if (priv->hw_ready) return ret; /* If HW is not ready, prepare the conditions to check again */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); /* HW should be ready by now, check again. */ if (ret != -ETIMEDOUT) - iwl4965_set_hw_ready(priv); + il4965_set_hw_ready(priv); return ret; } #define MAX_HW_RESTARTS 5 -static int __iwl4965_up(struct iwl_priv *priv) +static int __il4965_up(struct il_priv *priv) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; int i; int ret; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); return -EIO; } if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IWL_ERR(priv, "ucode not available for device bringup\n"); + IL_ERR(priv, "ucode not available for device bringup\n"); return -EIO; } for_each_context(priv, ctx) { - ret = iwl4965_alloc_bcast_station(priv, ctx); + ret = il4965_alloc_bcast_station(priv, ctx); if (ret) { - iwl_legacy_dealloc_bcast_stations(priv); + il_dealloc_bcast_stations(priv); return ret; } } - iwl4965_prepare_card_hw(priv); + il4965_prepare_card_hw(priv); if (!priv->hw_ready) { - IWL_WARN(priv, "Exit HW not ready\n"); + IL_WARN(priv, "Exit HW not ready\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(priv, + if (il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &priv->status); else set_bit(STATUS_RF_KILL_HW, &priv->status); - if (iwl_legacy_is_rfkill(priv)) { + if (il_is_rfkill(priv)) { wiphy_rfkill_set_hw_state(priv->hw->wiphy, true); - iwl_legacy_enable_interrupts(priv); - IWL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + il_enable_interrupts(priv); + IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); return 0; } - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(priv, CSR_INT, 0xFFFFFFFF); - /* must be initialised before iwl_hw_nic_init */ - priv->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; + /* must be initialised before il_hw_nic_init */ + priv->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; - ret = iwl4965_hw_nic_init(priv); + ret = il4965_hw_nic_init(priv); if (ret) { - IWL_ERR(priv, "Unable to init nic\n"); + IL_ERR(priv, "Unable to init nic\n"); return ret; } /* make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); - iwl_legacy_enable_interrupts(priv); + il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(priv); /* really make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2032,26 +2032,26 @@ static int __iwl4965_up(struct iwl_priv *priv) ret = priv->cfg->ops->lib->load_ucode(priv); if (ret) { - IWL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", + IL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", ret); continue; } /* start card; "initialize" will load runtime ucode */ - iwl4965_nic_start(priv); + il4965_nic_start(priv); - IWL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); return 0; } set_bit(STATUS_EXIT_PENDING, &priv->status); - __iwl4965_down(priv); + __il4965_down(priv); clear_bit(STATUS_EXIT_PENDING, &priv->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IWL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2062,10 +2062,10 @@ static int __iwl4965_up(struct iwl_priv *priv) * *****************************************************************************/ -static void iwl4965_bg_init_alive_start(struct work_struct *data) +static void il4965_bg_init_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, init_alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) @@ -2076,23 +2076,23 @@ out: mutex_unlock(&priv->mutex); } -static void iwl4965_bg_alive_start(struct work_struct *data) +static void il4965_bg_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl4965_alive_start(priv); + il4965_alive_start(priv); out: mutex_unlock(&priv->mutex); } -static void iwl4965_bg_run_time_calib_work(struct work_struct *work) +static void il4965_bg_run_time_calib_work(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, + struct il_priv *priv = container_of(work, struct il_priv, run_time_calib_work); mutex_lock(&priv->mutex); @@ -2104,37 +2104,37 @@ static void iwl4965_bg_run_time_calib_work(struct work_struct *work) } if (priv->start_calib) { - iwl4965_chain_noise_calibration(priv, + il4965_chain_noise_calibration(priv, (void *)&priv->_4965.statistics); - iwl4965_sensitivity_calibration(priv, + il4965_sensitivity_calibration(priv, (void *)&priv->_4965.statistics); } mutex_unlock(&priv->mutex); } -static void iwl4965_bg_restart(struct work_struct *data) +static void il4965_bg_restart(struct work_struct *data) { - struct iwl_priv *priv = container_of(data, struct iwl_priv, restart); + struct il_priv *priv = container_of(data, struct il_priv, restart); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; mutex_lock(&priv->mutex); for_each_context(priv, ctx) ctx->vif = NULL; priv->is_open = 0; - __iwl4965_down(priv); + __il4965_down(priv); mutex_unlock(&priv->mutex); - iwl4965_cancel_deferred_work(priv); + il4965_cancel_deferred_work(priv); ieee80211_restart_hw(priv->hw); } else { - iwl4965_down(priv); + il4965_down(priv); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { @@ -2142,21 +2142,21 @@ static void iwl4965_bg_restart(struct work_struct *data) return; } - __iwl4965_up(priv); + __il4965_up(priv); mutex_unlock(&priv->mutex); } } -static void iwl4965_bg_rx_replenish(struct work_struct *data) +static void il4965_bg_rx_replenish(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, rx_replenish); + struct il_priv *priv = + container_of(data, struct il_priv, rx_replenish); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; mutex_lock(&priv->mutex); - iwl4965_rx_replenish(priv); + il4965_rx_replenish(priv); mutex_unlock(&priv->mutex); } @@ -2172,12 +2172,12 @@ static void iwl4965_bg_rx_replenish(struct work_struct *data) * Not a mac80211 entry point function, but it fits in with all the * other mac80211 functions grouped here. */ -static int iwl4965_mac_setup_register(struct iwl_priv *priv, +static int il4965_mac_setup_register(struct il_priv *priv, u32 max_probe_length) { int ret; struct ieee80211_hw *hw = priv->hw; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; hw->rate_control_algorithm = "iwl-4965-rs"; @@ -2188,12 +2188,12 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, IEEE80211_HW_SPECTRUM_MGMT | IEEE80211_HW_REPORTS_TX_ACK_STATUS; - if (priv->cfg->sku & IWL_SKU_N) + if (priv->cfg->sku & IL_SKU_N) hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_SUPPORTS_STATIC_SMPS; - hw->sta_data_size = sizeof(struct iwl_station_priv); - hw->vif_data_size = sizeof(struct iwl_vif_priv); + hw->sta_data_size = sizeof(struct il_station_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); for_each_context(priv, ctx) { hw->wiphy->interface_modes |= ctx->interface_modes; @@ -2216,7 +2216,7 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, /* Default value; 4 EDCA QOS priorities */ hw->queues = 4; - hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; + hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = @@ -2225,11 +2225,11 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; - iwl_legacy_leds_init(priv); + il_leds_init(priv); ret = ieee80211_register_hw(priv->hw); if (ret) { - IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(priv, "Failed to register hw (error %d)\n", ret); return ret; } priv->mac80211_registered = 1; @@ -2238,25 +2238,25 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, } -int iwl4965_mac_start(struct ieee80211_hw *hw) +int il4965_mac_start(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&priv->mutex); - ret = __iwl4965_up(priv); + ret = __il4965_up(priv); mutex_unlock(&priv->mutex); if (ret) return ret; - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) goto out; - IWL_DEBUG_INFO(priv, "Start UP work done.\n"); + IL_DEBUG_INFO(priv, "Start UP work done.\n"); /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2265,99 +2265,99 @@ int iwl4965_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &priv->status)) { - IWL_ERR(priv, "START_ALIVE timeout after %dms.\n", + IL_ERR(priv, "START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; } } - iwl4965_led_enable(priv); + il4965_led_enable(priv); out: priv->is_open = 1; - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return 0; } -void iwl4965_mac_stop(struct ieee80211_hw *hw) +void il4965_mac_stop(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (!priv->is_open) return; priv->is_open = 0; - iwl4965_down(priv); + il4965_down(priv); flush_workqueue(priv->workqueue); /* User space software may expect getting rfkill changes * even if interface is down */ - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); - iwl_legacy_enable_rfkill_int(priv); + il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_enable_rfkill_int(priv); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -void iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MACDUMP(priv, "enter\n"); + IL_DEBUG_MACDUMP(priv, "enter\n"); - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (iwl4965_tx_skb(priv, skb)) + if (il4965_tx_skb(priv, skb)) dev_kfree_skb_any(skb); - IWL_DEBUG_MACDUMP(priv, "leave\n"); + IL_DEBUG_MACDUMP(priv, "leave\n"); } -void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_priv *priv = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - iwl4965_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, + il4965_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, iv32, phase1key); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *ctx = vif_priv->ctx; + struct il_priv *priv = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_rxon_context *ctx = vif_priv->ctx; int ret; u8 sta_id; bool is_default_wep_key = false; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (priv->cfg->mod_params->sw_crypto) { - IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } - sta_id = iwl_legacy_sta_id_or_broadcast(priv, vif_priv->ctx, sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id_or_broadcast(priv, vif_priv->ctx, sta); + if (sta_id == IL_INVALID_STATION) return -EINVAL; mutex_lock(&priv->mutex); - iwl_legacy_scan_cancel_timeout(priv, 100); + il_scan_cancel_timeout(priv, 100); /* * If we are getting WEP group key and we didn't receive any key mapping @@ -2378,68 +2378,68 @@ int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (cmd) { case SET_KEY: if (is_default_wep_key) - ret = iwl4965_set_default_wep_key(priv, + ret = il4965_set_default_wep_key(priv, vif_priv->ctx, key); else - ret = iwl4965_set_dynamic_key(priv, vif_priv->ctx, + ret = il4965_set_dynamic_key(priv, vif_priv->ctx, key, sta_id); - IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (is_default_wep_key) - ret = iwl4965_remove_default_wep_key(priv, ctx, key); + ret = il4965_remove_default_wep_key(priv, ctx, key); else - ret = iwl4965_remove_dynamic_key(priv, ctx, + ret = il4965_remove_dynamic_key(priv, ctx, key, sta_id); - IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return ret; } -int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret = -EINVAL; - IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", + IL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", sta->addr, tid); - if (!(priv->cfg->sku & IWL_SKU_N)) + if (!(priv->cfg->sku & IL_SKU_N)) return -EACCES; mutex_lock(&priv->mutex); switch (action) { case IEEE80211_AMPDU_RX_START: - IWL_DEBUG_HT(priv, "start Rx\n"); - ret = iwl4965_sta_rx_agg_start(priv, sta, tid, *ssn); + IL_DEBUG_HT(priv, "start Rx\n"); + ret = il4965_sta_rx_agg_start(priv, sta, tid, *ssn); break; case IEEE80211_AMPDU_RX_STOP: - IWL_DEBUG_HT(priv, "stop Rx\n"); - ret = iwl4965_sta_rx_agg_stop(priv, sta, tid); + IL_DEBUG_HT(priv, "stop Rx\n"); + ret = il4965_sta_rx_agg_stop(priv, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: - IWL_DEBUG_HT(priv, "start Tx\n"); - ret = iwl4965_tx_agg_start(priv, vif, sta, tid, ssn); + IL_DEBUG_HT(priv, "start Tx\n"); + ret = il4965_tx_agg_start(priv, vif, sta, tid, ssn); break; case IEEE80211_AMPDU_TX_STOP: - IWL_DEBUG_HT(priv, "stop Tx\n"); - ret = iwl4965_tx_agg_stop(priv, vif, sta, tid); + IL_DEBUG_HT(priv, "stop Tx\n"); + ret = il4965_tx_agg_stop(priv, vif, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) ret = 0; break; @@ -2452,30 +2452,30 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, return ret; } -int iwl4965_mac_sta_add(struct ieee80211_hw *hw, +int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_priv *priv = hw->priv; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; bool is_ap = vif->type == NL80211_IFTYPE_STATION; int ret; u8 sta_id; - IWL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(priv, "received request to add station %pM\n", sta->addr); mutex_lock(&priv->mutex); - IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", sta->addr); - sta_priv->common.sta_id = IWL_INVALID_STATION; + sta_priv->common.sta_id = IL_INVALID_STATION; atomic_set(&sta_priv->pending_frames, 0); - ret = iwl_legacy_add_station_common(priv, vif_priv->ctx, sta->addr, + ret = il_add_station_common(priv, vif_priv->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(priv, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&priv->mutex); @@ -2485,31 +2485,31 @@ int iwl4965_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", sta->addr); - iwl4965_rs_rate_init(priv, sta, sta_id); + il4965_rs_rate_init(priv, sta, sta_id); mutex_unlock(&priv->mutex); return 0; } -void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, +void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch) { - struct iwl_priv *priv = hw->priv; - const struct iwl_channel_info *ch_info; + struct il_priv *priv = hw->priv; + const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = ch_switch->channel; - struct iwl_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &priv->current_ht_config; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; u16 ch; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->mutex); - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) goto out; if (test_bit(STATUS_EXIT_PENDING, &priv->status) || @@ -2517,7 +2517,7 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) goto out; - if (!iwl_legacy_is_associated_ctx(ctx)) + if (!il_is_associated_ctx(ctx)) goto out; if (!priv->cfg->ops->lib->set_channel_switch) @@ -2527,9 +2527,9 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, if (le16_to_cpu(ctx->active.channel) == ch) goto out; - ch_info = iwl_legacy_get_channel_info(priv, channel->band, ch); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_MAC80211(priv, "invalid channel\n"); + ch_info = il_get_channel_info(priv, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_MAC80211(priv, "invalid channel\n"); goto out; } @@ -2559,13 +2559,13 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - iwl_legacy_set_rxon_channel(priv, channel, ctx); - iwl_legacy_set_rxon_ht(priv, ht_conf); - iwl_legacy_set_flags_for_band(priv, ctx, channel->band, ctx->vif); + il_set_rxon_channel(priv, channel, ctx); + il_set_rxon_ht(priv, ht_conf); + il_set_flags_for_band(priv, ctx, channel->band, ctx->vif); spin_unlock_irq(&priv->lock); - iwl_legacy_set_rate(priv); + il_set_rate(priv); /* * at this point, staging_rxon has the * configuration for channel switch @@ -2580,17 +2580,17 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, out: mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -void iwl4965_configure_filter(struct ieee80211_hw *hw, +void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, unsigned int *total_flags, u64 multicast) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -2599,7 +2599,7 @@ void iwl4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -2625,7 +2625,7 @@ void iwl4965_configure_filter(struct ieee80211_hw *hw, /* * Receiving all multicast frames is always enabled by the - * default flags setup in iwl_legacy_connection_init_rx_config() + * default flags setup in il_connection_init_rx_config() * since we currently do not support programming multicast * filters into the device. */ @@ -2639,9 +2639,9 @@ void iwl4965_configure_filter(struct ieee80211_hw *hw, * *****************************************************************************/ -static void iwl4965_bg_txpower_work(struct work_struct *work) +static void il4965_bg_txpower_work(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, + struct il_priv *priv = container_of(work, struct il_priv, txpower_work); mutex_lock(&priv->mutex); @@ -2666,62 +2666,62 @@ out: mutex_unlock(&priv->mutex); } -static void iwl4965_setup_deferred_work(struct iwl_priv *priv) +static void il4965_setup_deferred_work(struct il_priv *priv) { priv->workqueue = create_singlethread_workqueue(DRV_NAME); init_waitqueue_head(&priv->wait_command_queue); - INIT_WORK(&priv->restart, iwl4965_bg_restart); - INIT_WORK(&priv->rx_replenish, iwl4965_bg_rx_replenish); - INIT_WORK(&priv->run_time_calib_work, iwl4965_bg_run_time_calib_work); - INIT_DELAYED_WORK(&priv->init_alive_start, iwl4965_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, iwl4965_bg_alive_start); + INIT_WORK(&priv->restart, il4965_bg_restart); + INIT_WORK(&priv->rx_replenish, il4965_bg_rx_replenish); + INIT_WORK(&priv->run_time_calib_work, il4965_bg_run_time_calib_work); + INIT_DELAYED_WORK(&priv->init_alive_start, il4965_bg_init_alive_start); + INIT_DELAYED_WORK(&priv->alive_start, il4965_bg_alive_start); - iwl_legacy_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(priv); - INIT_WORK(&priv->txpower_work, iwl4965_bg_txpower_work); + INIT_WORK(&priv->txpower_work, il4965_bg_txpower_work); init_timer(&priv->statistics_periodic); priv->statistics_periodic.data = (unsigned long)priv; - priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; + priv->statistics_periodic.function = il4965_bg_statistics_periodic; init_timer(&priv->watchdog); priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = iwl_legacy_bg_watchdog; + priv->watchdog.function = il_bg_watchdog; tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - iwl4965_irq_tasklet, (unsigned long)priv); + il4965_irq_tasklet, (unsigned long)priv); } -static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) +static void il4965_cancel_deferred_work(struct il_priv *priv) { cancel_work_sync(&priv->txpower_work); cancel_delayed_work_sync(&priv->init_alive_start); cancel_delayed_work(&priv->alive_start); cancel_work_sync(&priv->run_time_calib_work); - iwl_legacy_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(priv); del_timer_sync(&priv->statistics_periodic); } -static void iwl4965_init_hw_rates(struct iwl_priv *priv, +static void il4965_init_hw_rates(struct il_priv *priv, struct ieee80211_rate *rates) { int i; - for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) { + for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { rates[i].bitrate = iwlegacy_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if ((i >= IWL_FIRST_CCK_RATE) && (i <= IWL_LAST_CCK_RATE)) { + if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { /* * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (iwlegacy_rates[i].plcp == IWL_RATE_1M_PLCP) ? + (iwlegacy_rates[i].plcp == IL_RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } @@ -2729,15 +2729,15 @@ static void iwl4965_init_hw_rates(struct iwl_priv *priv, /* * Acquire priv->lock before calling this function ! */ -void iwl4965_set_wr_ptrs(struct iwl_priv *priv, int txq_id, u32 index) +void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index) { - iwl_legacy_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(priv, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } -void iwl4965_tx_queue_set_status(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il4965_tx_queue_set_status(struct il_priv *priv, + struct il_tx_queue *txq, int tx_fifo_id, int scd_retry) { int txq_id = txq->q.id; @@ -2746,7 +2746,7 @@ void iwl4965_tx_queue_set_status(struct iwl_priv *priv, int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), + il_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | @@ -2755,13 +2755,13 @@ void iwl4965_tx_queue_set_status(struct iwl_priv *priv, txq->sched_retry = scd_retry; - IWL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n", + IL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } -static int iwl4965_init_drv(struct iwl_priv *priv) +static int il4965_init_drv(struct il_priv *priv) { int ret; @@ -2778,91 +2778,91 @@ static int iwl4965_init_drv(struct iwl_priv *priv) priv->iw_mode = NL80211_IFTYPE_STATION; priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; - priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; + priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD; + priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; /* Choose which receivers/antennas to use */ if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + &priv->contexts[IL_RXON_CTX_BSS]); - iwl_legacy_init_scan_params(priv); + il_init_scan_params(priv); - ret = iwl_legacy_init_channel_map(priv); + ret = il_init_channel_map(priv); if (ret) { - IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(priv, "initializing regulatory failed: %d\n", ret); goto err; } - ret = iwl_legacy_init_geos(priv); + ret = il_init_geos(priv); if (ret) { - IWL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(priv, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - iwl4965_init_hw_rates(priv, priv->ieee_rates); + il4965_init_hw_rates(priv, priv->ieee_rates); return 0; err_free_channel_map: - iwl_legacy_free_channel_map(priv); + il_free_channel_map(priv); err: return ret; } -static void iwl4965_uninit_drv(struct iwl_priv *priv) +static void il4965_uninit_drv(struct il_priv *priv) { - iwl4965_calib_free_results(priv); - iwl_legacy_free_geos(priv); - iwl_legacy_free_channel_map(priv); + il4965_calib_free_results(priv); + il_free_geos(priv); + il_free_channel_map(priv); kfree(priv->scan_cmd); } -static void iwl4965_hw_detect(struct iwl_priv *priv) +static void il4965_hw_detect(struct il_priv *priv) { - priv->hw_rev = _iwl_legacy_read32(priv, CSR_HW_REV); - priv->hw_wa_rev = _iwl_legacy_read32(priv, CSR_HW_REV_WA_REG); + priv->hw_rev = _il_read32(priv, CSR_HW_REV); + priv->hw_wa_rev = _il_read32(priv, CSR_HW_REV_WA_REG); priv->rev_id = priv->pci_dev->revision; - IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", priv->rev_id); + IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", priv->rev_id); } -static int iwl4965_set_hw_params(struct iwl_priv *priv) +static int il4965_set_hw_params(struct il_priv *priv) { priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; if (priv->cfg->mod_params->amsdu_size_8K) - priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_8K); + priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); else - priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_4K); + priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); - priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL; + priv->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; if (priv->cfg->mod_params->disable_11n) - priv->cfg->sku &= ~IWL_SKU_N; + priv->cfg->sku &= ~IL_SKU_N; /* Device-specific setup */ return priv->cfg->ops->lib->set_hw_params(priv); } -static const u8 iwl4965_bss_ac_to_fifo[] = { - IWL_TX_FIFO_VO, - IWL_TX_FIFO_VI, - IWL_TX_FIFO_BE, - IWL_TX_FIFO_BK, +static const u8 il4965_bss_ac_to_fifo[] = { + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, }; -static const u8 iwl4965_bss_ac_to_queue[] = { +static const u8 il4965_bss_ac_to_queue[] = { 0, 1, 2, 3, }; static int -iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct iwl_priv *priv; + struct il_priv *priv; struct ieee80211_hw *hw; - struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); unsigned long flags; u16 pci_cmd; @@ -2870,7 +2870,7 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 1. Allocating HW data ************************/ - hw = iwl_legacy_alloc_all(cfg); + hw = il_alloc_all(cfg); if (!hw) { err = -ENOMEM; goto out; @@ -2883,41 +2883,41 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * more may be discovered when firmware * is loaded. */ - priv->valid_contexts = BIT(IWL_RXON_CTX_BSS); + priv->valid_contexts = BIT(IL_RXON_CTX_BSS); - for (i = 0; i < NUM_IWL_RXON_CTX; i++) + for (i = 0; i < NUM_IL_RXON_CTX; i++) priv->contexts[i].ctxid = i; - priv->contexts[IWL_RXON_CTX_BSS].always_active = true; - priv->contexts[IWL_RXON_CTX_BSS].is_active = true; - priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID; - priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IWL_RXON_CTX_BSS].ac_to_fifo = iwl4965_bss_ac_to_fifo; - priv->contexts[IWL_RXON_CTX_BSS].ac_to_queue = iwl4965_bss_ac_to_queue; - priv->contexts[IWL_RXON_CTX_BSS].exclusive_interface_modes = + priv->contexts[IL_RXON_CTX_BSS].always_active = true; + priv->contexts[IL_RXON_CTX_BSS].is_active = true; + priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + priv->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; + priv->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; + priv->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IWL_RXON_CTX_BSS].interface_modes = + priv->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION); - priv->contexts[IWL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; - priv->contexts[IWL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IWL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; + priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; - BUILD_BUG_ON(NUM_IWL_RXON_CTX != 1); + BUILD_BUG_ON(NUM_IL_RXON_CTX != 1); SET_IEEE80211_DEV(hw, &pdev->dev); - IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); priv->cfg = cfg; priv->pci_dev = pdev; priv->inta_mask = CSR_INI_SET_MASK; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); /************************** * 2. Initializing PCI bus @@ -2942,7 +2942,7 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { - IWL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(priv, "No suitable DMA available.\n"); goto out_pci_disable_device; } } @@ -2963,9 +2963,9 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_pci_release_regions; } - IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now @@ -2978,19 +2978,19 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - iwl4965_hw_detect(priv); - IWL_INFO(priv, "Detected %s, REV=0x%X\n", + il4965_hw_detect(priv); + IL_INFO(priv, "Detected %s, REV=0x%X\n", priv->cfg->name, priv->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - iwl4965_prepare_card_hw(priv); + il4965_prepare_card_hw(priv); if (!priv->hw_ready) { - IWL_WARN(priv, "Failed, HW not ready\n"); + IL_WARN(priv, "Failed, HW not ready\n"); goto out_iounmap; } @@ -2998,12 +2998,12 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 4. Read EEPROM *****************/ /* Read the EEPROM */ - err = iwl_legacy_eeprom_init(priv); + err = il_eeprom_init(priv); if (err) { - IWL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(priv, "Unable to init EEPROM\n"); goto out_iounmap; } - err = iwl4965_eeprom_check_version(priv); + err = il4965_eeprom_check_version(priv); if (err) goto out_free_eeprom; @@ -3011,16 +3011,16 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_free_eeprom; /* extract MAC Address */ - iwl4965_eeprom_get_mac(priv, priv->addresses[0].addr); - IWL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); + il4965_eeprom_get_mac(priv, priv->addresses[0].addr); + IL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); priv->hw->wiphy->addresses = priv->addresses; priv->hw->wiphy->n_addresses = 1; /************************ * 5. Setup HW constants ************************/ - if (iwl4965_set_hw_params(priv)) { - IWL_ERR(priv, "failed to set hw parameters\n"); + if (il4965_set_hw_params(priv)) { + IL_ERR(priv, "failed to set hw parameters\n"); goto out_free_eeprom; } @@ -3028,7 +3028,7 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 6. Setup priv *******************/ - err = iwl4965_init_drv(priv); + err = il4965_init_drv(priv); if (err) goto out_free_eeprom; /* At this point both hw and priv are initialized. */ @@ -3037,20 +3037,20 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 7. Setup services ********************/ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); pci_enable_msi(priv->pci_dev); - err = request_irq(priv->pci_dev->irq, iwl_legacy_isr, + err = request_irq(priv->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, priv); if (err) { - IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); goto out_disable_msi; } - iwl4965_setup_deferred_work(priv); - iwl4965_setup_rx_handlers(priv); + il4965_setup_deferred_work(priv); + il4965_setup_rx_handlers(priv); /********************************************* * 8. Enable interrupts and read RFKILL state @@ -3063,10 +3063,10 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); } - iwl_legacy_enable_rfkill_int(priv); + il_enable_rfkill_int(priv); /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(priv, CSR_GP_CNTRL) & + if (il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &priv->status); else @@ -3075,11 +3075,11 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) wiphy_rfkill_set_hw_state(priv->hw->wiphy, test_bit(STATUS_RF_KILL_HW, &priv->status)); - iwl_legacy_power_initialize(priv); + il_power_initialize(priv); init_completion(&priv->_4965.firmware_loading_complete); - err = iwl4965_request_firmware(priv, true); + err = il4965_request_firmware(priv, true); if (err) goto out_destroy_workqueue; @@ -3091,9 +3091,9 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) free_irq(priv->pci_dev->irq, priv); out_disable_msi: pci_disable_msi(priv->pci_dev); - iwl4965_uninit_drv(priv); + il4965_uninit_drv(priv); out_free_eeprom: - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); out_iounmap: pci_iounmap(pdev, priv->hw_base); out_pci_release_regions: @@ -3102,15 +3102,15 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_pci_disable_device: pci_disable_device(pdev); out_ieee80211_free_hw: - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); ieee80211_free_hw(priv->hw); out: return err; } -static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) +static void __devexit il4965_pci_remove(struct pci_dev *pdev) { - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); unsigned long flags; if (!priv) @@ -3118,62 +3118,62 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) wait_for_completion(&priv->_4965.firmware_loading_complete); - IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); - iwl_legacy_dbgfs_unregister(priv); - sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group); + il_dbgfs_unregister(priv); + sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); - /* ieee80211_unregister_hw call wil cause iwl_mac_stop to - * to be called and iwl4965_down since we are removing the device + /* ieee80211_unregister_hw call wil cause il_mac_stop to + * to be called and il4965_down since we are removing the device * we need to set STATUS_EXIT_PENDING bit. */ set_bit(STATUS_EXIT_PENDING, &priv->status); - iwl_legacy_leds_exit(priv); + il_leds_exit(priv); if (priv->mac80211_registered) { ieee80211_unregister_hw(priv->hw); priv->mac80211_registered = 0; } else { - iwl4965_down(priv); + il4965_down(priv); } /* * Make sure device is reset to low power before unloading driver. - * This may be redundant with iwl4965_down(), but there are paths to - * run iwl4965_down() without calling apm_ops.stop(), and there are - * paths to avoid running iwl4965_down() at all before leaving driver. + * This may be redundant with il4965_down(), but there are paths to + * run il4965_down() without calling apm_ops.stop(), and there are + * paths to avoid running il4965_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); /* make sure we flush any pending irq or * tasklet for the driver */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl4965_synchronize_irq(priv); + il4965_synchronize_irq(priv); - iwl4965_dealloc_ucode_pci(priv); + il4965_dealloc_ucode_pci(priv); if (priv->rxq.bd) - iwl4965_rx_queue_free(priv, &priv->rxq); - iwl4965_hw_txq_ctx_free(priv); + il4965_rx_queue_free(priv, &priv->rxq); + il4965_hw_txq_ctx_free(priv); - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); /*netif_stop_queue(dev); */ flush_workqueue(priv->workqueue); - /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes + /* ieee80211_unregister_hw calls il_mac_stop, which flushes * priv->workqueue... so we can't take down the workqueue * until now... */ destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); free_irq(priv->pci_dev->irq, priv); pci_disable_msi(priv->pci_dev); @@ -3182,7 +3182,7 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - iwl4965_uninit_drv(priv); + il4965_uninit_drv(priv); dev_kfree_skb(priv->beacon_skb); @@ -3193,9 +3193,9 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask * must be called under priv->lock and mac access */ -void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask) +void il4965_txq_set_sched(struct il_priv *priv, u32 mask) { - iwl_legacy_write_prph(priv, IWL49_SCD_TXFACT, mask); + il_write_prph(priv, IWL49_SCD_TXFACT, mask); } /***************************************************************************** @@ -3205,38 +3205,38 @@ void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask) *****************************************************************************/ /* Hardware specific file defines the PCI IDs table for that hardware module */ -static DEFINE_PCI_DEVICE_TABLE(iwl4965_hw_card_ids) = { +static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { #if defined(CONFIG_IWL4965_MODULE) || defined(CONFIG_IWL4965) - {IWL_PCI_DEVICE(0x4229, PCI_ANY_ID, iwl4965_cfg)}, - {IWL_PCI_DEVICE(0x4230, PCI_ANY_ID, iwl4965_cfg)}, + {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, + {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, #endif /* CONFIG_IWL4965 */ {0} }; -MODULE_DEVICE_TABLE(pci, iwl4965_hw_card_ids); +MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); -static struct pci_driver iwl4965_driver = { +static struct pci_driver il4965_driver = { .name = DRV_NAME, - .id_table = iwl4965_hw_card_ids, - .probe = iwl4965_pci_probe, - .remove = __devexit_p(iwl4965_pci_remove), - .driver.pm = IWL_LEGACY_PM_OPS, + .id_table = il4965_hw_card_ids, + .probe = il4965_pci_probe, + .remove = __devexit_p(il4965_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init iwl4965_init(void) +static int __init il4965_init(void) { int ret; pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); pr_info(DRV_COPYRIGHT "\n"); - ret = iwl4965_rate_control_register(); + ret = il4965_rate_control_register(); if (ret) { pr_err("Unable to register rate control algorithm: %d\n", ret); return ret; } - ret = pci_register_driver(&iwl4965_driver); + ret = pci_register_driver(&il4965_driver); if (ret) { pr_err("Unable to initialize PCI module\n"); goto error_register; @@ -3245,32 +3245,32 @@ static int __init iwl4965_init(void) return ret; error_register: - iwl4965_rate_control_unregister(); + il4965_rate_control_unregister(); return ret; } -static void __exit iwl4965_exit(void) +static void __exit il4965_exit(void) { - pci_unregister_driver(&iwl4965_driver); - iwl4965_rate_control_unregister(); + pci_unregister_driver(&il4965_driver); + il4965_rate_control_unregister(); } -module_exit(iwl4965_exit); -module_init(iwl4965_init); +module_exit(il4965_exit); +module_init(il4965_init); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -module_param_named(swcrypto, iwl4965_mod_params.sw_crypto, int, S_IRUGO); +module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO); MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); -module_param_named(queues_num, iwl4965_mod_params.num_of_queues, int, S_IRUGO); +module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); MODULE_PARM_DESC(queues_num, "number of hw queues."); -module_param_named(11n_disable, iwl4965_mod_params.disable_11n, int, S_IRUGO); +module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); -module_param_named(amsdu_size_8K, iwl4965_mod_params.amsdu_size_8K, +module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, int, S_IRUGO); MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); -module_param_named(fw_restart, iwl4965_mod_params.restart_fw, int, S_IRUGO); +module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); -- cgit v0.10.2 From 46bc8d4b0e73ac75de323646d75a2333f47b84c3 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 24 Oct 2011 16:49:25 +0200 Subject: iwlegacy: rename priv to il Make code shorter. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index 954aed4..b767979 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -29,22 +29,22 @@ #include "iwl-3945-debugfs.h" -static int il3945_statistics_flag(struct il_priv *priv, char *buf, int bufsz) +static int il3945_statistics_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", - le32_to_cpu(priv->_3945.statistics.flag)); - if (le32_to_cpu(priv->_3945.statistics.flag) & + le32_to_cpu(il->_3945.statistics.flag)); + if (le32_to_cpu(il->_3945.statistics.flag) & UCODE_STATISTICS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (le32_to_cpu(priv->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.statistics.flag) & UCODE_STATISTICS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (le32_to_cpu(priv->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.statistics.flag) & UCODE_STATISTICS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; @@ -54,7 +54,7 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 + @@ -66,12 +66,12 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, struct iwl39_statistics_rx_non_phy *general, *accum_general; struct iwl39_statistics_rx_non_phy *delta_general, *max_general; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -80,20 +80,20 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - ofdm = &priv->_3945.statistics.rx.ofdm; - cck = &priv->_3945.statistics.rx.cck; - general = &priv->_3945.statistics.rx.general; - accum_ofdm = &priv->_3945.accum_statistics.rx.ofdm; - accum_cck = &priv->_3945.accum_statistics.rx.cck; - accum_general = &priv->_3945.accum_statistics.rx.general; - delta_ofdm = &priv->_3945.delta_statistics.rx.ofdm; - delta_cck = &priv->_3945.delta_statistics.rx.cck; - delta_general = &priv->_3945.delta_statistics.rx.general; - max_ofdm = &priv->_3945.max_delta.rx.ofdm; - max_cck = &priv->_3945.max_delta.rx.cck; - max_general = &priv->_3945.max_delta.rx.general; + ofdm = &il->_3945.statistics.rx.ofdm; + cck = &il->_3945.statistics.rx.cck; + general = &il->_3945.statistics.rx.general; + accum_ofdm = &il->_3945.accum_statistics.rx.ofdm; + accum_cck = &il->_3945.accum_statistics.rx.cck; + accum_general = &il->_3945.accum_statistics.rx.general; + delta_ofdm = &il->_3945.delta_statistics.rx.ofdm; + delta_cck = &il->_3945.delta_statistics.rx.cck; + delta_general = &il->_3945.delta_statistics.rx.general; + max_ofdm = &il->_3945.max_delta.rx.ofdm; + max_cck = &il->_3945.max_delta.rx.cck; + max_general = &il->_3945.max_delta.rx.general; - pos += il3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Rx - OFDM:"); @@ -329,19 +329,19 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250; ssize_t ret; struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -350,11 +350,11 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - tx = &priv->_3945.statistics.tx; - accum_tx = &priv->_3945.accum_statistics.tx; - delta_tx = &priv->_3945.delta_statistics.tx; - max_tx = &priv->_3945.max_delta.tx; - pos += il3945_statistics_flag(priv, buf, bufsz); + tx = &il->_3945.statistics.tx; + accum_tx = &il->_3945.accum_statistics.tx; + delta_tx = &il->_3945.delta_statistics.tx; + max_tx = &il->_3945.max_delta.tx; + pos += il3945_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Tx:"); @@ -425,7 +425,7 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300; @@ -435,12 +435,12 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -449,19 +449,19 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - general = &priv->_3945.statistics.general; - dbg = &priv->_3945.statistics.general.dbg; - div = &priv->_3945.statistics.general.div; - accum_general = &priv->_3945.accum_statistics.general; - delta_general = &priv->_3945.delta_statistics.general; - max_general = &priv->_3945.max_delta.general; - accum_dbg = &priv->_3945.accum_statistics.general.dbg; - delta_dbg = &priv->_3945.delta_statistics.general.dbg; - max_dbg = &priv->_3945.max_delta.general.dbg; - accum_div = &priv->_3945.accum_statistics.general.div; - delta_div = &priv->_3945.delta_statistics.general.div; - max_div = &priv->_3945.max_delta.general.div; - pos += il3945_statistics_flag(priv, buf, bufsz); + general = &il->_3945.statistics.general; + dbg = &il->_3945.statistics.general.dbg; + div = &il->_3945.statistics.general.div; + accum_general = &il->_3945.accum_statistics.general; + delta_general = &il->_3945.delta_statistics.general; + max_general = &il->_3945.max_delta.general; + accum_dbg = &il->_3945.accum_statistics.general.dbg; + delta_dbg = &il->_3945.delta_statistics.general.dbg; + max_dbg = &il->_3945.max_delta.general.dbg; + accum_div = &il->_3945.accum_statistics.general.div; + delta_div = &il->_3945.delta_statistics.general.div; + max_div = &il->_3945.max_delta.general.div; + pos += il3945_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_General:"); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.c b/drivers/net/wireless/iwlegacy/iwl-3945-led.c index 69703b0..53ec463 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-led.c @@ -44,7 +44,7 @@ /* Send led command */ -static int il3945_send_led_cmd(struct il_priv *priv, +static int il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { @@ -55,7 +55,7 @@ static int il3945_send_led_cmd(struct il_priv *priv, .callback = NULL, }; - return il_send_cmd(priv, &cmd); + return il_send_cmd(il, &cmd); } const struct il_led_ops il3945_led_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index d97f24b..38f1b82 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -153,7 +153,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) int unflushed = 0; int i; unsigned long flags; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; /* * For each rate, if we have collected data on that rate @@ -167,7 +167,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + IL_RATE_WIN_FLUSH)) { - IL_DEBUG_RATE(priv, "flushing %d samples of rate " + IL_DEBUG_RATE(il, "flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); il3945_clear_window(&rs_sta->win[i]); @@ -186,12 +186,12 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) static void il3945_bg_rate_scale_flush(unsigned long data) { struct il3945_rs_sta *rs_sta = (void *)data; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; int unflushed = 0; unsigned long flags; u32 packet_count, duration, pps; - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); unflushed = il3945_rate_scale_flush_windows(rs_sta); @@ -206,7 +206,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - IL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n", + IL_DEBUG_RATE(il, "Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ @@ -226,7 +226,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->flush_time = msecs_to_jiffies(duration); - IL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n", + IL_DEBUG_RATE(il, "new flush period: %d msec ave %d\n", duration, packet_count); mod_timer(&rs_sta->rate_scale_flush, jiffies + @@ -244,7 +244,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "leave\n"); } /** @@ -260,10 +260,10 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, { unsigned long flags; s32 fail_count; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; if (!retries) { - IL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n"); + IL_DEBUG_RATE(il, "leave: retries == 0 -- should be at least 1\n"); return; } @@ -332,24 +332,24 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* * Called after adding a new station to initialize rate scaling */ -void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id) +void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { - struct ieee80211_hw *hw = priv->hw; - struct ieee80211_conf *conf = &priv->hw->conf; + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; struct il3945_sta_priv *psta; struct il3945_rs_sta *rs_sta; struct ieee80211_supported_band *sband; int i; - IL_DEBUG_INFO(priv, "enter\n"); - if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + IL_DEBUG_INFO(il, "enter\n"); + if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) goto out; psta = (struct il3945_sta_priv *) sta->drv_priv; rs_sta = &psta->rs_sta; sband = hw->wiphy->bands[conf->channel->band]; - rs_sta->priv = priv; + rs_sta->il = il; rs_sta->start_rate = IL_RATE_INVALID; @@ -379,18 +379,18 @@ void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta } } - priv->_3945.sta_supp_rates = sta->supp_rates[sband->band]; + il->_3945.sta_supp_rates = sta->supp_rates[sband->band]; /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ if (sband->band == IEEE80211_BAND_5GHZ) { rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - priv->_3945.sta_supp_rates = priv->_3945.sta_supp_rates << + il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << IL_FIRST_OFDM_RATE; } out: - priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - IL_DEBUG_INFO(priv, "leave\n"); + IL_DEBUG_INFO(il, "leave\n"); } static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) @@ -399,7 +399,7 @@ static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) } /* rate scale requires free function to be implemented */ -static void il3945_rs_free(void *priv) +static void il3945_rs_free(void *il) { return; } @@ -408,24 +408,24 @@ static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t { struct il3945_rs_sta *rs_sta; struct il3945_sta_priv *psta = (void *) sta->drv_priv; - struct il_priv *priv __maybe_unused = il_priv; + struct il_priv *il __maybe_unused = il_priv; - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); rs_sta = &psta->rs_sta; spin_lock_init(&rs_sta->lock); init_timer(&rs_sta->rate_scale_flush); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "leave\n"); return rs_sta; } static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, - void *priv_sta) + void *il_sta) { - struct il3945_rs_sta *rs_sta = priv_sta; + struct il3945_rs_sta *rs_sta = il_sta; /* * Be careful not to use any members of il3945_rs_sta (like trying @@ -442,18 +442,18 @@ static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, * NOTE: Uses il_priv->retry_rate for the # of retries attempted by * the hardware for each rate. */ -static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta, +static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, struct sk_buff *skb) { s8 retries = 0, current_count; int scale_rate_index, first_index, last_index; unsigned long flags; - struct il_priv *priv = (struct il_priv *)priv_rate; - struct il3945_rs_sta *rs_sta = priv_sta; + struct il_priv *il = (struct il_priv *)il_rate; + struct il3945_rs_sta *rs_sta = il_sta; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); retries = info->status.rates[0].count; /* Sanity Check for retries */ @@ -462,18 +462,18 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band first_index = sband->bitrates[info->status.rates[0].idx].hw_value; if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { - IL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index); + IL_DEBUG_RATE(il, "leave: Rate out of bounds: %d\n", first_index); return; } - if (!priv_sta) { - IL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n"); + if (!il_sta) { + IL_DEBUG_RATE(il, "leave: No STA il data to update!\n"); return; } /* Treat uninitialized rate scaling data same as non-existing. */ - if (!rs_sta->priv) { - IL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); + if (!rs_sta->il) { + IL_DEBUG_RATE(il, "leave: STA il data uninitialized!\n"); return; } @@ -487,19 +487,19 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band * Update the window for each rate. We determine which rates * were Tx'd based on the total number of retries vs. the number * of retries configured for each rate -- currently set to the - * priv value 'retry_rate' vs. rate specific + * il value 'retry_rate' vs. rate specific * * On exit from this while loop last_index indicates the rate * at which the frame was finally transmitted (or failed if no * ACK) */ while (retries > 1) { - if ((retries - 1) < priv->retry_rate) { + if ((retries - 1) < il->retry_rate) { current_count = (retries - 1); last_index = scale_rate_index; } else { - current_count = priv->retry_rate; - last_index = il3945_rs_next_rate(priv, + current_count = il->retry_rate; + last_index = il3945_rs_next_rate(il, scale_rate_index); } @@ -508,7 +508,7 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_index], 0, current_count, scale_rate_index); - IL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n", + IL_DEBUG_RATE(il, "Update rate %d for %d retries.\n", scale_rate_index, current_count); retries -= current_count; @@ -518,7 +518,7 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band /* Update the last index window with success/failure based on ACK */ - IL_DEBUG_RATE(priv, "Update rate %d with %s.\n", + IL_DEBUG_RATE(il, "Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); @@ -543,7 +543,7 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "leave\n"); } static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, @@ -551,7 +551,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, { u8 high = IL_RATE_INVALID; u8 low = IL_RATE_INVALID; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; /* 802.11A walks to the next literal adjacent rate in * the rate table */ @@ -591,7 +591,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); } high = index; @@ -604,7 +604,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -626,8 +626,8 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, * rate table and must reference the driver allocated rate table * */ -static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, - void *priv_sta, struct ieee80211_tx_rate_control *txrc) +static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, + void *il_sta, struct ieee80211_tx_rate_control *txrc) { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; @@ -635,7 +635,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, u8 high = IL_RATE_INVALID; u16 high_low; int index; - struct il3945_rs_sta *rs_sta = priv_sta; + struct il3945_rs_sta *rs_sta = il_sta; struct il3945_rate_scale_data *window = NULL; int current_tpt = IL_INVALID_VALUE; int low_tpt = IL_INVALID_VALUE; @@ -645,18 +645,18 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, unsigned long flags; u16 rate_mask; s8 max_rate_idx = -1; - struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); /* Treat uninitialized rate scaling data same as non-existing. */ - if (rs_sta && !rs_sta->priv) { - IL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); - priv_sta = NULL; + if (rs_sta && !rs_sta->il) { + IL_DEBUG_RATE(il, "Rate scaling information not initialized yet.\n"); + il_sta = NULL; } - if (rate_control_send_low(sta, priv_sta, txrc)) + if (rate_control_send_low(sta, il_sta, txrc)) return; rate_mask = sta->supp_rates[sband->band]; @@ -699,7 +699,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: " + IL_DEBUG_RATE(il, "Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, @@ -737,7 +737,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, /* Low success ratio , need to drop the rate */ if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { - IL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); + IL_DEBUG_RATE(il, "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ @@ -756,7 +756,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) { - IL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < " + IL_DEBUG_RATE(il, "No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; @@ -771,13 +771,13 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of high tpt\n"); scale_action = 0; } } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of low tpt\n"); scale_action = -1; } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { @@ -816,7 +816,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, break; } - IL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n", + IL_DEBUG_RATE(il, "Selected %d (action %d) - low %d high %d\n", index, scale_action, low, high); out: @@ -831,7 +831,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, info->control.rates[0].idx = rs_sta->last_txrate_idx; } - IL_DEBUG_RATE(priv, "leave: %d\n", index); + IL_DEBUG_RATE(il, "leave: %d\n", index); } #ifdef CONFIG_MAC80211_DEBUGFS @@ -878,10 +878,10 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { .llseek = default_llseek, }; -static void il3945_add_debugfs(void *priv, void *priv_sta, +static void il3945_add_debugfs(void *il, void *il_sta, struct dentry *dir) { - struct il3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_stats_table_file = debugfs_create_file("rate_stats_table", 0600, dir, @@ -889,9 +889,9 @@ static void il3945_add_debugfs(void *priv, void *priv_sta, } -static void il3945_remove_debugfs(void *priv, void *priv_sta) +static void il3945_remove_debugfs(void *il, void *il_sta) { - struct il3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); } #endif @@ -901,9 +901,9 @@ static void il3945_remove_debugfs(void *priv, void *priv_sta) * the station is added. Since mac80211 calls this function before a * station is added we ignore it. */ -static void il3945_rs_rate_init_stub(void *priv_r, +static void il3945_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta) + struct ieee80211_sta *sta, void *il_sta) { } @@ -925,21 +925,21 @@ static struct rate_control_ops rs_ops = { }; void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; s32 rssi = 0; unsigned long flags; struct il3945_rs_sta *rs_sta; struct ieee80211_sta *sta; struct il3945_sta_priv *psta; - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); rcu_read_lock(); - sta = ieee80211_find_sta(priv->contexts[IL_RXON_CTX_BSS].vif, - priv->stations[sta_id].sta.sta.addr); + sta = ieee80211_find_sta(il->contexts[IL_RXON_CTX_BSS].vif, + il->stations[sta_id].sta.sta.addr); if (!sta) { - IL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); + IL_DEBUG_RATE(il, "Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } @@ -950,10 +950,10 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) spin_lock_irqsave(&rs_sta->lock, flags); rs_sta->tgg = 0; - switch (priv->band) { + switch (il->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (priv->contexts[IL_RXON_CTX_BSS].active.flags & + if (il->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; rs_sta->expected_tpt = il3945_expected_tpt_g_prot; @@ -971,15 +971,15 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) spin_unlock_irqrestore(&rs_sta->lock, flags); - rssi = priv->_3945.last_rx_rssi; + rssi = il->_3945.last_rx_rssi; if (rssi == 0) rssi = IL_MIN_RSSI_VAL; - IL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi); + IL_DEBUG_RATE(il, "Network RSSI: %d\n", rssi); - rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, priv->band); + rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, il->band); - IL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: " + IL_DEBUG_RATE(il, "leave: rssi %d assign rate index: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 6d1740b..c9b5dcf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -108,7 +108,7 @@ static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) * Use for only special debugging. This function is just a placeholder as-is, * you'll need to provide the special bits! ... * ... and set IL_EVT_DISABLE to 1. */ -void il3945_disable_events(struct il_priv *priv) +void il3945_disable_events(struct il_priv *il) { int i; u32 base; /* SRAM address of event log header */ @@ -164,27 +164,27 @@ void il3945_disable_events(struct il_priv *priv) 0x00000000, /* 1503 - 1472 */ }; - base = le32_to_cpu(priv->card_alive.log_event_table_ptr); + base = le32_to_cpu(il->card_alive.log_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(priv, "Invalid event log pointer 0x%08X\n", base); + IL_ERR(il, "Invalid event log pointer 0x%08X\n", base); return; } - disable_ptr = il_read_targ_mem(priv, base + (4 * sizeof(u32))); - array_size = il_read_targ_mem(priv, base + (5 * sizeof(u32))); + disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); + array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { - IL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n", + IL_DEBUG_INFO(il, "Disabling selected uCode log events at 0x%x\n", disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) - il_write_targ_mem(priv, + il_write_targ_mem(il, disable_ptr + (i * sizeof(u32)), evt_disable[i]); } else { - IL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n"); - IL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n"); - IL_DEBUG_INFO(priv, " in SRAM at 0x%x, size %d u32s\n", + IL_DEBUG_INFO(il, "Selected uCode log events may be disabled\n"); + IL_DEBUG_INFO(il, " by writing \"1\"s into disable bitmap\n"); + IL_DEBUG_INFO(il, " in SRAM at 0x%x, size %d u32s\n", disable_ptr, array_size); } @@ -240,11 +240,11 @@ static inline const char *il3945_get_tx_fail_reason(u32 status) * for A and B mode we need to overright prev * value */ -int il3945_rs_next_rate(struct il_priv *priv, int rate) +int il3945_rs_next_rate(struct il_priv *il, int rate) { int next_rate = il3945_get_prev_ieee_rate(rate); - switch (priv->band) { + switch (il->band) { case IEEE80211_BAND_5GHZ: if (rate == IL_RATE_12M_INDEX) next_rate = IL_RATE_9M_INDEX; @@ -252,8 +252,8 @@ int il3945_rs_next_rate(struct il_priv *priv, int rate) next_rate = IL_RATE_6M_INDEX; break; case IEEE80211_BAND_2GHZ: - if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il, IL_RXON_CTX_BSS)) { if (rate == IL_RATE_11M_INDEX) next_rate = IL_RATE_5M_INDEX; } @@ -274,10 +274,10 @@ int il3945_rs_next_rate(struct il_priv *priv, int rate) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il3945_tx_queue_reclaim(struct il_priv *priv, +static void il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; struct il_tx_info *tx_info; @@ -288,28 +288,28 @@ static void il3945_tx_queue_reclaim(struct il_priv *priv, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; - ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); tx_info->skb = NULL; - priv->cfg->ops->lib->txq_free_tfd(priv, txq); + il->cfg->ops->lib->txq_free_tfd(il, txq); } if (il_queue_space(q) > q->low_mark && (txq_id >= 0) && (txq_id != IWL39_CMD_QUEUE_NUM) && - priv->mac80211_registered) - il_wake_queue(priv, txq); + il->mac80211_registered) + il_wake_queue(il, txq); } /** * il3945_rx_reply_tx - Handle Tx response */ -static void il3945_rx_reply_tx(struct il_priv *priv, +static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; u32 status = le32_to_cpu(tx_resp->status); @@ -317,7 +317,7 @@ static void il3945_rx_reply_tx(struct il_priv *priv, int fail; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -342,15 +342,15 @@ static void il3945_rx_reply_tx(struct il_priv *priv, info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - IL_DEBUG_TX(priv, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + IL_DEBUG_TX(il, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(priv, "Tx queue reclaim %d\n", index); - il3945_tx_queue_reclaim(priv, txq_id, index); + IL_DEBUG_TX_REPLY(il, "Tx queue reclaim %d\n", index); + il3945_tx_queue_reclaim(il, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) - IL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); + IL_ERR(il, "TODO: Implement Tx ABORT REQUIRED!!!\n"); } @@ -363,7 +363,7 @@ static void il3945_rx_reply_tx(struct il_priv *priv, * *****************************************************************************/ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -static void il3945_accumulative_statistics(struct il_priv *priv, +static void il3945_accumulative_statistics(struct il_priv *il, __le32 *stats) { int i; @@ -371,10 +371,10 @@ static void il3945_accumulative_statistics(struct il_priv *priv, u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *)&priv->_3945.statistics; - accum_stats = (u32 *)&priv->_3945.accum_statistics; - delta = (u32 *)&priv->_3945.delta_statistics; - max_delta = (u32 *)&priv->_3945.max_delta; + prev_stats = (__le32 *)&il->_3945.statistics; + accum_stats = (u32 *)&il->_3945.accum_statistics; + delta = (u32 *)&il->_3945.delta_statistics; + max_delta = (u32 *)&il->_3945.max_delta; for (i = sizeof(__le32); i < sizeof(struct il3945_notif_statistics); i += sizeof(__le32), stats++, prev_stats++, delta++, @@ -389,29 +389,29 @@ static void il3945_accumulative_statistics(struct il_priv *priv, } /* reset accumulative statistics for "no-counter" type statistics */ - priv->_3945.accum_statistics.general.temperature = - priv->_3945.statistics.general.temperature; - priv->_3945.accum_statistics.general.ttl_timestamp = - priv->_3945.statistics.general.ttl_timestamp; + il->_3945.accum_statistics.general.temperature = + il->_3945.statistics.general.temperature; + il->_3945.accum_statistics.general.ttl_timestamp = + il->_3945.statistics.general.ttl_timestamp; } #endif -void il3945_hw_rx_statistics(struct il_priv *priv, +void il3945_hw_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", + IL_DEBUG_RX(il, "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - il3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); + il3945_accumulative_statistics(il, (__le32 *)&pkt->u.raw); #endif - memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); + memcpy(&il->_3945.statistics, pkt->u.raw, sizeof(il->_3945.statistics)); } -void il3945_reply_statistics(struct il_priv *priv, +void il3945_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -419,16 +419,16 @@ void il3945_reply_statistics(struct il_priv *priv, if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - memset(&priv->_3945.accum_statistics, 0, + memset(&il->_3945.accum_statistics, 0, sizeof(struct il3945_notif_statistics)); - memset(&priv->_3945.delta_statistics, 0, + memset(&il->_3945.delta_statistics, 0, sizeof(struct il3945_notif_statistics)); - memset(&priv->_3945.max_delta, 0, + memset(&il->_3945.max_delta, 0, sizeof(struct il3945_notif_statistics)); #endif - IL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(il, "Statistics have been cleared\n"); } - il3945_hw_rx_statistics(priv, rxb); + il3945_hw_rx_statistics(il, rxb); } @@ -439,24 +439,24 @@ void il3945_reply_statistics(struct il_priv *priv, ******************************************************************************/ /* This is necessary only for a number of statistics, see the caller. */ -static int il3945_is_network_packet(struct il_priv *priv, +static int il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) { /* Filter incoming packets to determine if they are targeted toward * this network, discarding packets coming from ourselves */ - switch (priv->iw_mode) { + switch (il->iw_mode) { case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr3, priv->bssid); + return !compare_ether_addr(header->addr3, il->bssid); case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr2, priv->bssid); + return !compare_ether_addr(header->addr2, il->bssid); default: return 1; } } -static void il3945_pass_packet_to_mac80211(struct il_priv *priv, +static void il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { @@ -470,43 +470,43 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *priv, /* We received data from the HW, so stop the watchdog */ if (unlikely(len + IWL39_RX_FRAME_SIZE > - PAGE_SIZE << priv->hw_params.rx_page_order)) { - IL_DEBUG_DROP(priv, "Corruption detected!\n"); + PAGE_SIZE << il->hw_params.rx_page_order)) { + IL_DEBUG_DROP(il, "Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ - if (unlikely(!priv->is_open)) { - IL_DEBUG_DROP_LIMIT(priv, + if (unlikely(!il->is_open)) { + IL_DEBUG_DROP_LIMIT(il, "Dropping packet while interface is not open.\n"); return; } skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(il, "dev_alloc_skb failed\n"); return; } if (!il3945_mod_params.sw_crypto) - il_set_decrypted_flag(priv, + il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb), le32_to_cpu(rx_end->status), stats); skb_add_rx_frag(skb, 0, rxb->page, (void *)rx_hdr->payload - (void *)pkt, len); - il_update_stats(priv, false, fc, len); + il_update_stats(il, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - ieee80211_rx(priv->hw, skb); - priv->alloc_rxb_page--; + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; rxb->page = NULL; } #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void il3945_rx_reply_rx(struct il_priv *priv, +static void il3945_rx_reply_rx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; @@ -539,14 +539,14 @@ static void il3945_rx_reply_rx(struct il_priv *priv, rx_status.flag |= RX_FLAG_SHORTPRE; if ((unlikely(rx_stats->phy_count > 20))) { - IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", rx_stats->phy_count); return; } if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -555,34 +555,34 @@ static void il3945_rx_reply_rx(struct il_priv *priv, /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; - IL_DEBUG_STATS(priv, "Rssi %d sig_avg %d noise_diff %d\n", + IL_DEBUG_STATS(il, "Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, rx_stats_noise_diff); header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - network_packet = il3945_is_network_packet(priv, header); + network_packet = il3945_is_network_packet(il, header); - IL_DEBUG_STATS_LIMIT(priv, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + IL_DEBUG_STATS_LIMIT(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, rx_status.rate_idx); - il_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), + il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), header); if (network_packet) { - priv->_3945.last_beacon_time = + il->_3945.last_beacon_time = le32_to_cpu(rx_end->beacon_timestamp); - priv->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); - priv->_3945.last_rx_rssi = rx_status.signal; + il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); + il->_3945.last_rx_rssi = rx_status.signal; } - il3945_pass_packet_to_mac80211(priv, rxb, &rx_status); + il3945_pass_packet_to_mac80211(il, rxb, &rx_status); } -int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) { @@ -600,7 +600,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { - IL_ERR(priv, "Error can not send more than %d chunks\n", + IL_ERR(il, "Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; } @@ -621,19 +621,19 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, * * Does NOT advance any indexes */ -void il3945_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) +void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; int index = txq->q.read_ptr; struct il3945_tfd *tfd = &tfd_tmp[index]; - struct pci_dev *dev = priv->pci_dev; + struct pci_dev *dev = il->pci_dev; int i; int counter; /* sanity check */ counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if (counter > NUM_TFD_CHUNKS) { - IL_ERR(priv, "Too many chunks: %i\n", counter); + IL_ERR(il, "Too many chunks: %i\n", counter); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -669,13 +669,13 @@ void il3945_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: * */ -void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id) { - u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value; + u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; u16 rate_index = min(hw_value & 0xffff, IL_RATE_COUNT_3945); u16 rate_mask; int rate; @@ -718,13 +718,13 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); - IL_DEBUG_RATE(priv, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + IL_DEBUG_RATE(il, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); } -static u8 il3945_sync_sta(struct il_priv *priv, int sta_id, u16 tx_rate) +static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) { unsigned long flags_spin; struct il_station_entry *station; @@ -732,52 +732,52 @@ static u8 il3945_sync_sta(struct il_priv *priv, int sta_id, u16 tx_rate) if (sta_id == IL_INVALID_STATION) return IL_INVALID_STATION; - spin_lock_irqsave(&priv->sta_lock, flags_spin); - station = &priv->stations[sta_id]; + spin_lock_irqsave(&il->sta_lock, flags_spin); + station = &il->stations[sta_id]; station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; station->sta.rate_n_flags = cpu_to_le16(tx_rate); station->sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(priv, &station->sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + il_send_add_sta(il, &station->sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); - IL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n", + IL_DEBUG_RATE(il, "SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } -static void il3945_set_pwr_vmain(struct il_priv *priv) +static void il3945_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) * to set power to V_AUX, do - if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) { - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) { + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(priv, CSR_GPIO_IN, + il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VAUX_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); } */ - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } -static int il3945_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) +static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { - il_write_direct32(priv, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_write_direct32(priv, FH39_RCSR_RPTR_ADDR(0), + il_write_direct32(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_write_direct32(il, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); - il_write_direct32(priv, FH39_RCSR_WPTR(0), 0); - il_write_direct32(priv, FH39_RCSR_CONFIG(0), + il_write_direct32(il, FH39_RCSR_WPTR(0), 0); + il_write_direct32(il, FH39_RCSR_CONFIG(0), FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | @@ -788,32 +788,32 @@ static int il3945_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ - il_read_direct32(priv, FH39_RSSR_CTRL); + il_read_direct32(il, FH39_RSSR_CTRL); return 0; } -static int il3945_tx_reset(struct il_priv *priv) +static int il3945_tx_reset(struct il_priv *il) { /* bypass mode */ - il_write_prph(priv, ALM_SCD_MODE_REG, 0x2); + il_write_prph(il, ALM_SCD_MODE_REG, 0x2); /* RA 0 is active */ - il_write_prph(priv, ALM_SCD_ARASTAT_REG, 0x01); + il_write_prph(il, ALM_SCD_ARASTAT_REG, 0x01); /* all 6 fifo are active */ - il_write_prph(priv, ALM_SCD_TXFACT_REG, 0x3f); + il_write_prph(il, ALM_SCD_TXFACT_REG, 0x3f); - il_write_prph(priv, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - il_write_prph(priv, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - il_write_prph(priv, ALM_SCD_TXF4MF_REG, 0x000004); - il_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005); + il_write_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_write_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_write_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); + il_write_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - il_write_direct32(priv, FH39_TSSR_CBB_BASE, - priv->_3945.shared_phys); + il_write_direct32(il, FH39_TSSR_CBB_BASE, + il->_3945.shared_phys); - il_write_direct32(priv, FH39_TSSR_MSG_CONFIG, + il_write_direct32(il, FH39_TSSR_MSG_CONFIG, FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | @@ -831,31 +831,31 @@ static int il3945_tx_reset(struct il_priv *priv) * * Destroys all DMA structures and initialize them again */ -static int il3945_txq_ctx_reset(struct il_priv *priv) +static int il3945_txq_ctx_reset(struct il_priv *il) { int rc; int txq_id, slots_num; - il3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(il); /* allocate tx queue structure */ - rc = il_alloc_txq_mem(priv); + rc = il_alloc_txq_mem(il); if (rc) return rc; /* Tx CMD queue */ - rc = il3945_tx_reset(priv); + rc = il3945_tx_reset(il); if (rc) goto error; /* Tx queue(s) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { slots_num = (txq_id == IWL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = il_tx_queue_init(priv, &priv->txq[txq_id], + rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (rc) { - IL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(il, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -863,7 +863,7 @@ static int il3945_txq_ctx_reset(struct il_priv *priv) return rc; error: - il3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(il); return rc; } @@ -873,127 +873,127 @@ static int il3945_txq_ctx_reset(struct il_priv *priv) * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -static int il3945_apm_init(struct il_priv *priv) +static int il3945_apm_init(struct il_priv *il) { - int ret = il_apm_init(priv); + int ret = il_apm_init(il); /* Clear APMG (NIC's internal power management) interrupts */ - il_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0); - il_write_prph(priv, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + il_write_prph(il, APMG_RTC_INT_MSK_REG, 0x0); + il_write_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ - il_set_bits_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - il_clear_bits_prph(priv, APMG_PS_CTRL_REG, + il_clear_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); return ret; } -static void il3945_nic_config(struct il_priv *priv) +static void il3945_nic_config(struct il_priv *il) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; unsigned long flags; - u8 rev_id = priv->pci_dev->revision; + u8 rev_id = il->pci_dev->revision; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Determine HW type */ - IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); + IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", rev_id); if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - IL_DEBUG_INFO(priv, "RTP type\n"); + IL_DEBUG_INFO(il, "RTP type\n"); else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - IL_DEBUG_INFO(priv, "3945 RADIO-MB type\n"); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(il, "3945 RADIO-MB type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { - IL_DEBUG_INFO(priv, "3945 RADIO-MM type\n"); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(il, "3945 RADIO-MM type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - IL_DEBUG_INFO(priv, "SKU OP mode is mrc\n"); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(il, "SKU OP mode is mrc\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else - IL_DEBUG_INFO(priv, "SKU OP mode is basic\n"); + IL_DEBUG_INFO(il, "SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", eeprom->board_revision); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", eeprom->board_revision); - il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } if (eeprom->almgor_m_version <= 1) { - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - IL_DEBUG_INFO(priv, "Card M type A version is 0x%X\n", + IL_DEBUG_INFO(il, "Card M type A version is 0x%X\n", eeprom->almgor_m_version); } else { - IL_DEBUG_INFO(priv, "Card M type B version is 0x%X\n", + IL_DEBUG_INFO(il, "Card M type B version is 0x%X\n", eeprom->almgor_m_version); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(priv, "SW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(il, "SW RF KILL supported in EEPROM.\n"); if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(priv, "HW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(il, "HW RF KILL supported in EEPROM.\n"); } -int il3945_hw_nic_init(struct il_priv *priv) +int il3945_hw_nic_init(struct il_priv *il) { int rc; unsigned long flags; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; - spin_lock_irqsave(&priv->lock, flags); - priv->cfg->ops->lib->apm_ops.init(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); + spin_unlock_irqrestore(&il->lock, flags); - il3945_set_pwr_vmain(priv); + il3945_set_pwr_vmain(il); - priv->cfg->ops->lib->apm_ops.config(priv); + il->cfg->ops->lib->apm_ops.config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - rc = il_rx_queue_alloc(priv); + rc = il_rx_queue_alloc(il); if (rc) { - IL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(il, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - il3945_rx_queue_reset(priv, rxq); + il3945_rx_queue_reset(il, rxq); - il3945_rx_replenish(priv); + il3945_rx_replenish(il); - il3945_rx_init(priv, rxq); + il3945_rx_init(il, rxq); /* Look at using this instead: rxq->need_update = 1; - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); */ - il_write_direct32(priv, FH39_RCSR_WPTR(0), rxq->write & ~7); + il_write_direct32(il, FH39_RCSR_WPTR(0), rxq->write & ~7); - rc = il3945_txq_ctx_reset(priv); + rc = il3945_txq_ctx_reset(il); if (rc) return rc; - set_bit(STATUS_INIT, &priv->status); + set_bit(STATUS_INIT, &il->status); return 0; } @@ -1003,40 +1003,40 @@ int il3945_hw_nic_init(struct il_priv *priv) * * Destroy all TX DMA queues and structures */ -void il3945_hw_txq_ctx_free(struct il_priv *priv) +void il3945_hw_txq_ctx_free(struct il_priv *il) { int txq_id; /* Tx queues */ - if (priv->txq) - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; + if (il->txq) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) if (txq_id == IWL39_CMD_QUEUE_NUM) - il_cmd_queue_free(priv); + il_cmd_queue_free(il); else - il_tx_queue_free(priv, txq_id); + il_tx_queue_free(il, txq_id); /* free tx queue structure */ - il_txq_mem(priv); + il_txq_mem(il); } -void il3945_hw_txq_ctx_stop(struct il_priv *priv) +void il3945_hw_txq_ctx_stop(struct il_priv *il) { int txq_id; /* stop SCD */ - il_write_prph(priv, ALM_SCD_MODE_REG, 0); - il_write_prph(priv, ALM_SCD_TXFACT_REG, 0); + il_write_prph(il, ALM_SCD_MODE_REG, 0); + il_write_prph(il, ALM_SCD_TXFACT_REG, 0); /* reset TFD queues */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), 0x0); - il_poll_direct_bit(priv, FH39_TSSR_TX_STATUS, + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_direct_bit(il, FH39_TSSR_TX_STATUS, FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), 1000); } - il3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(il); } /** @@ -1056,36 +1056,36 @@ static inline int il3945_hw_reg_temp_out_of_range(int temperature) return ((temperature < -260) || (temperature > 25)) ? 1 : 0; } -int il3945_hw_get_temperature(struct il_priv *priv) +int il3945_hw_get_temperature(struct il_priv *il) { - return il_read32(priv, CSR_UCODE_DRV_GP2); + return il_read32(il, CSR_UCODE_DRV_GP2); } /** * il3945_hw_reg_txpower_get_temperature * get the current temperature by reading from NIC */ -static int il3945_hw_reg_txpower_get_temperature(struct il_priv *priv) +static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int temperature; - temperature = il3945_hw_get_temperature(priv); + temperature = il3945_hw_get_temperature(il); /* driver's okay range is -260 to +25. * human readable okay range is 0 to +285 */ - IL_DEBUG_INFO(priv, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); + IL_DEBUG_INFO(il, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); /* handle insane temp reading */ if (il3945_hw_reg_temp_out_of_range(temperature)) { - IL_ERR(priv, "Error bad temperature value %d\n", temperature); + IL_ERR(il, "Error bad temperature value %d\n", temperature); /* if really really hot(?), * substitute the 3rd band/group's temp measured at factory */ - if (priv->last_temperature > 100) + if (il->last_temperature > 100) temperature = eeprom->groups[2].temperature; else /* else use most recent "sane" value from driver */ - temperature = priv->last_temperature; + temperature = il->last_temperature; } return temperature; /* raw, not "human readable" */ @@ -1102,33 +1102,33 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *priv) * records new temperature in tx_mgr->temperature. * replaces tx_mgr->last_temperature *only* if calib needed * (assumes caller will actually do the calibration!). */ -static int il3945_is_temp_calib_needed(struct il_priv *priv) +static int il3945_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - priv->temperature = il3945_hw_reg_txpower_get_temperature(priv); - temp_diff = priv->temperature - priv->last_temperature; + il->temperature = il3945_hw_reg_txpower_get_temperature(il); + temp_diff = il->temperature - il->last_temperature; /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(priv, "Getting cooler, delta %d,\n", temp_diff); + IL_DEBUG_POWER(il, "Getting cooler, delta %d,\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(priv, "Same temp,\n"); + IL_DEBUG_POWER(il, "Same temp,\n"); else - IL_DEBUG_POWER(priv, "Getting warmer, delta %d,\n", temp_diff); + IL_DEBUG_POWER(il, "Getting warmer, delta %d,\n", temp_diff); /* if we don't need calibration, *don't* update last_temperature */ if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { - IL_DEBUG_POWER(priv, "Timed thermal calib not needed\n"); + IL_DEBUG_POWER(il, "Timed thermal calib not needed\n"); return 0; } - IL_DEBUG_POWER(priv, "Timed thermal calib needed\n"); + IL_DEBUG_POWER(il, "Timed thermal calib needed\n"); /* assume that caller will actually do calib ... * update the "last temperature" value */ - priv->last_temperature = priv->temperature; + il->last_temperature = il->temperature; return 1; } @@ -1317,7 +1317,7 @@ static inline u8 il3945_hw_reg_fix_power_index(int index) * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_index, +static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, s32 rate_index, const s8 *clip_pwrs, struct il_channel_info *ch_info, int band_index) @@ -1333,7 +1333,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_inde * based on eeprom channel data) for this channel. */ power = min(ch_info->scan_power, clip_pwrs[IL_RATE_6M_INDEX_TABLE]); - power = min(power, priv->tx_power_user_lmt); + power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; /* find difference between new scan *power* and current "normal" @@ -1370,32 +1370,32 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_inde * Configures power settings for all rates for the current channel, * using values from channel info struct, and send to NIC */ -static int il3945_send_tx_power(struct il_priv *priv) +static int il3945_send_tx_power(struct il_priv *il) { int rate_idx, i; const struct il_channel_info *ch_info = NULL; struct il3945_txpowertable_cmd txpower = { - .channel = priv->contexts[IL_RXON_CTX_BSS].active.channel, + .channel = il->contexts[IL_RXON_CTX_BSS].active.channel, }; u16 chan; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status), + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; - chan = le16_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.channel); + chan = le16_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.channel); - txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; - ch_info = il_get_channel_info(priv, priv->band, chan); + txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; + ch_info = il_get_channel_info(il, il->band, chan); if (!ch_info) { - IL_ERR(priv, + IL_ERR(il, "Failed to get channel info for channel %d [%d]\n", - chan, priv->band); + chan, il->band); return -EINVAL; } if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_POWER(priv, "Not calling TX_PWR_TABLE_CMD on " + IL_DEBUG_POWER(il, "Not calling TX_PWR_TABLE_CMD on " "non-Tx channel.\n"); return 0; } @@ -1408,7 +1408,7 @@ static int il3945_send_tx_power(struct il_priv *priv) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1421,7 +1421,7 @@ static int il3945_send_tx_power(struct il_priv *priv) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1429,7 +1429,7 @@ static int il3945_send_tx_power(struct il_priv *priv) txpower.power[i].rate); } - return il_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, + return il_send_cmd_pdu(il, REPLY_TX_PWR_TABLE_CMD, sizeof(struct il3945_txpowertable_cmd), &txpower); @@ -1451,7 +1451,7 @@ static int il3945_send_tx_power(struct il_priv *priv) * properly fill out the scan powers, and actual h/w gain settings, * and send changes to NIC */ -static int il3945_hw_reg_set_new_power(struct il_priv *priv, +static int il3945_hw_reg_set_new_power(struct il_priv *il, struct il_channel_info *ch_info) { struct il3945_channel_power_info *power_info; @@ -1461,7 +1461,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *priv, int power; /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; /* Get this channel's rate-to-current-power settings table */ power_info = ch_info->power_info; @@ -1542,10 +1542,10 @@ static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) * * If RxOn is "associated", this sends the new Txpower to NIC! */ -static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) +static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) { struct il_channel_info *ch_info = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int delta_index; const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; @@ -1553,16 +1553,16 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) u8 scan_tbl_index; u8 i; int ref_temp; - int temperature = priv->temperature; + int temperature = il->temperature; - if (priv->disable_tx_power_cal || - test_bit(STATUS_SCANNING, &priv->status)) { + if (il->disable_tx_power_cal || + test_bit(STATUS_SCANNING, &il->status)) { /* do not perform tx power calibration */ return 0; } /* set up new Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0; i < priv->channel_count; i++) { - ch_info = &priv->channel_info[i]; + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ @@ -1592,43 +1592,43 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) } /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; - il3945_hw_reg_set_scan_power(priv, scan_tbl_index, + il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } } /* send Txpower command for current channel to ucode */ - return priv->cfg->ops->lib->send_tx_power(priv); + return il->cfg->ops->lib->send_tx_power(il); } -int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power) +int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) { struct il_channel_info *ch_info; s8 max_power; u8 a_band; u8 i; - if (priv->tx_power_user_lmt == power) { - IL_DEBUG_POWER(priv, "Requested Tx power same as current " + if (il->tx_power_user_lmt == power) { + IL_DEBUG_POWER(il, "Requested Tx power same as current " "limit: %ddBm.\n", power); return 0; } - IL_DEBUG_POWER(priv, "Setting upper limit clamp to %ddBm.\n", power); - priv->tx_power_user_lmt = power; + IL_DEBUG_POWER(il, "Setting upper limit clamp to %ddBm.\n", power); + il->tx_power_user_lmt = power; /* set up new Tx powers for each and every channel, 2.4 and 5.x */ - for (i = 0; i < priv->channel_count; i++) { - ch_info = &priv->channel_info[i]; + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; a_band = il_is_channel_a_band(ch_info); /* find minimum power of all user and regulatory constraints @@ -1639,19 +1639,19 @@ int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power) ch_info->curr_txpow = max_power; /* this considers the h/w clipping limitations */ - il3945_hw_reg_set_new_power(priv, ch_info); + il3945_hw_reg_set_new_power(il, ch_info); } } /* update txpower settings for all channels, * send to NIC if associated. */ - il3945_is_temp_calib_needed(priv); - il3945_hw_reg_comp_txpower_temp(priv); + il3945_is_temp_calib_needed(il); + il3945_hw_reg_comp_txpower_temp(il); return 0; } -static int il3945_send_rxon_assoc(struct il_priv *priv, +static int il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int rc = 0; @@ -1670,7 +1670,7 @@ static int il3945_send_rxon_assoc(struct il_priv *priv, (rxon1->filter_flags == rxon2->filter_flags) && (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1680,17 +1680,17 @@ static int il3945_send_rxon_assoc(struct il_priv *priv, rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; rxon_assoc.reserved = 0; - rc = il_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(il, &cmd); if (rc) return rc; pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n"); + IL_ERR(il, "Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return rc; } @@ -1703,7 +1703,7 @@ static int il3945_send_rxon_assoc(struct il_priv *priv, * function correctly transitions out of the RXON_ASSOC_MSK state if * a HW tune is required based on the RXON structure changes. */ -int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) +int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; @@ -1711,10 +1711,10 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) int rc = 0; bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return -EINVAL; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -1; /* always get timestamp with Rx frame */ @@ -1723,23 +1723,23 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) /* select antenna */ staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); - staging_rxon->flags |= il3945_get_antenna_flags(priv); + staging_rxon->flags |= il3945_get_antenna_flags(il); - rc = il_check_rxon_cmd(priv, ctx); + rc = il_check_rxon_cmd(il, ctx); if (rc) { - IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } /* If we don't need to send a full RXON, we can use * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(priv, - &priv->contexts[IL_RXON_CTX_BSS])) { - rc = il_send_rxon_assoc(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + if (!il_full_rxon_required(il, + &il->contexts[IL_RXON_CTX_BSS])) { + rc = il_send_rxon_assoc(il, + &il->contexts[IL_RXON_CTX_BSS]); if (rc) { - IL_ERR(priv, "Error setting RXON_ASSOC " + IL_ERR(il, "Error setting RXON_ASSOC " "configuration (%d).\n", rc); return rc; } @@ -1749,7 +1749,7 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - il_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(il, il->tx_power_next, false); return 0; } @@ -1757,8 +1757,8 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (il_is_associated(priv, IL_RXON_CTX_BSS) && new_assoc) { - IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + if (il_is_associated(il, IL_RXON_CTX_BSS) && new_assoc) { + IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; /* @@ -1767,25 +1767,25 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(priv, REPLY_RXON, + rc = il_send_cmd_pdu(il, REPLY_RXON, sizeof(struct il3945_rxon_cmd), - &priv->contexts[IL_RXON_CTX_BSS].active); + &il->contexts[IL_RXON_CTX_BSS].active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(priv, "Error clearing ASSOC_MSK on current " + IL_ERR(il, "Error clearing ASSOC_MSK on current " "configuration (%d).\n", rc); return rc; } - il_clear_ucode_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); - il_restore_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + il_clear_ucode_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); } - IL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(il, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1800,38 +1800,38 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) staging_rxon->reserved4 = 0; staging_rxon->reserved5 = 0; - il_set_rxon_hwcrypto(priv, ctx, !il3945_mod_params.sw_crypto); + il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = il_send_cmd_pdu(priv, REPLY_RXON, + rc = il_send_cmd_pdu(il, REPLY_RXON, sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { - IL_ERR(priv, "Error setting new configuration (%d).\n", rc); + IL_ERR(il, "Error setting new configuration (%d).\n", rc); return rc; } memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); if (!new_assoc) { - il_clear_ucode_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); - il_restore_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + il_clear_ucode_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); } /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - rc = il_set_tx_power(priv, priv->tx_power_next, true); + rc = il_set_tx_power(il, il->tx_power_next, true); if (rc) { - IL_ERR(priv, "Error setting Tx power (%d).\n", rc); + IL_ERR(il, "Error setting Tx power (%d).\n", rc); return rc; } /* Init the hardware's rate fallback order based on the band */ - rc = il3945_init_hw_rate_table(priv); + rc = il3945_init_hw_rate_table(il); if (rc) { - IL_ERR(priv, "Error setting HW rate table: %02X\n", rc); + IL_ERR(il, "Error setting HW rate table: %02X\n", rc); return -EIO; } @@ -1848,34 +1848,34 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * -- send new set of gain settings to NIC * NOTE: This should continue working, even when we're not associated, * so we can keep our internal table of scan powers current. */ -void il3945_reg_txpower_periodic(struct il_priv *priv) +void il3945_reg_txpower_periodic(struct il_priv *il) { /* This will kick in the "brute force" * il3945_hw_reg_comp_txpower_temp() below */ - if (!il3945_is_temp_calib_needed(priv)) + if (!il3945_is_temp_calib_needed(il)) goto reschedule; /* Set up a new set of temp-adjusted TxPowers, send to NIC. * This is based *only* on current temperature, * ignoring any previous power measurements */ - il3945_hw_reg_comp_txpower_temp(priv); + il3945_hw_reg_comp_txpower_temp(il); reschedule: - queue_delayed_work(priv->workqueue, - &priv->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); + queue_delayed_work(il->workqueue, + &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); } static void il3945_bg_reg_txpower_periodic(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, + struct il_priv *il = container_of(work, struct il_priv, _3945.thermal_periodic.work); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - mutex_lock(&priv->mutex); - il3945_reg_txpower_periodic(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il3945_reg_txpower_periodic(il); + mutex_unlock(&il->mutex); } /** @@ -1889,10 +1889,10 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, +static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *il, const struct il_channel_info *ch_info) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; u8 group; u16 group_index = 0; /* based on factory calib frequencies */ @@ -1913,7 +1913,7 @@ static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, } else group_index = 0; /* 2.4 GHz, group 0 */ - IL_DEBUG_POWER(priv, "Chnl %d mapped to grp %d\n", ch_info->channel, + IL_DEBUG_POWER(il, "Chnl %d mapped to grp %d\n", ch_info->channel, group_index); return group_index; } @@ -1924,12 +1924,12 @@ static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, * Interpolate to get nominal (i.e. at factory calibration temperature) index * into radio/DSP gain settings table for requested power. */ -static int il3945_hw_reg_get_matched_power_index(struct il_priv *priv, +static int il3945_hw_reg_get_matched_power_index(struct il_priv *il, s8 requested_power, s32 setting_index, s32 *new_index) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; s32 index0, index1; s32 power = 2 * requested_power; s32 i; @@ -1973,14 +1973,14 @@ static int il3945_hw_reg_get_matched_power_index(struct il_priv *priv, return 0; } -static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) +static void il3945_hw_reg_init_channel_groups(struct il_priv *il) { u32 i; s32 rate_index; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; const struct il3945_eeprom_txpower_group *group; - IL_DEBUG_POWER(priv, "Initializing factory calib info from EEPROM\n"); + IL_DEBUG_POWER(il, "Initializing factory calib info from EEPROM\n"); for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { s8 *clip_pwrs; /* table of power levels for each rate */ @@ -1989,7 +1989,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { - IL_WARN(priv, "Error: saturation power is %d, " + IL_WARN(il, "Error: saturation power is %d, " "less than minimum expected 40\n", group->saturation_power); return; @@ -2004,7 +2004,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) * power peaks, without too much distortion (clipping). */ /* we'll fill in this array with h/w max power levels */ - clip_pwrs = (s8 *) priv->_3945.clip_groups[i].clip_powers; + clip_pwrs = (s8 *) il->_3945.clip_groups[i].clip_powers; /* divide factory saturation power by 2 to find -3dB level */ satur_pwr = (s8) (group->saturation_power >> 1); @@ -2042,7 +2042,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) /** * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM * - * Second pass (during init) to set up priv->channel_info + * Second pass (during init) to set up il->channel_info * * Set up Tx-power settings in our channel info database for each VALID * (for this geo/SKU) channel, at all Tx data rates, based on eeprom values @@ -2054,11 +2054,11 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) * * This does *not* write values to NIC, just sets up our internal table. */ -int il3945_txpower_set_from_eeprom(struct il_priv *priv) +int il3945_txpower_set_from_eeprom(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_channel_power_info *pwr_info; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int delta_index; u8 rate_index; u8 scan_tbl_index; @@ -2071,13 +2071,13 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) /* save temperature reference, * so we can determine next time to calibrate */ - temperature = il3945_hw_reg_txpower_get_temperature(priv); - priv->last_temperature = temperature; + temperature = il3945_hw_reg_txpower_get_temperature(il); + il->last_temperature = temperature; - il3945_hw_reg_init_channel_groups(priv); + il3945_hw_reg_init_channel_groups(il); /* initialize Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0, ch_info = priv->channel_info; i < priv->channel_count; + for (i = 0, ch_info = il->channel_info; i < il->channel_count; i++, ch_info++) { a_band = il_is_channel_a_band(ch_info); if (!il_is_channel_valid(ch_info)) @@ -2085,10 +2085,10 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) /* find this channel's channel group (*not* "band") index */ ch_info->group_index = - il3945_hw_reg_get_ch_grp_index(priv, ch_info); + il3945_hw_reg_get_ch_grp_index(il, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; /* calculate power index *adjustment* value according to * diff between current temperature and factory temperature */ @@ -2096,7 +2096,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) eeprom->groups[ch_info->group_index]. temperature); - IL_DEBUG_POWER(priv, "Delta index for channel %d: %d [%d]\n", + IL_DEBUG_POWER(il, "Delta index for channel %d: %d [%d]\n", ch_info->channel, delta_index, temperature + IL_TEMP_CONVERT); @@ -2115,11 +2115,11 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) /* get base (i.e. at factory-measured temperature) * power table index for this rate's power */ - rc = il3945_hw_reg_get_matched_power_index(priv, pwr, + rc = il3945_hw_reg_get_matched_power_index(il, pwr, ch_info->group_index, &power_idx); if (rc) { - IL_ERR(priv, "Invalid power index\n"); + IL_ERR(il, "Invalid power index\n"); return rc; } pwr_info->base_power_index = (u8) power_idx; @@ -2171,7 +2171,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; - il3945_hw_reg_set_scan_power(priv, scan_tbl_index, + il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } } @@ -2179,31 +2179,31 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) return 0; } -int il3945_hw_rxq_stop(struct il_priv *priv) +int il3945_hw_rxq_stop(struct il_priv *il) { int rc; - il_write_direct32(priv, FH39_RCSR_CONFIG(0), 0); - rc = il_poll_direct_bit(priv, FH39_RSSR_STATUS, + il_write_direct32(il, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_direct_bit(il, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) - IL_ERR(priv, "Can't stop Rx DMA.\n"); + IL_ERR(il, "Can't stop Rx DMA.\n"); return 0; } -int il3945_hw_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq) +int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; - struct il3945_shared *shared_data = priv->_3945.shared_virt; + struct il3945_shared *shared_data = il->_3945.shared_virt; shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - il_write_direct32(priv, FH39_CBCC_CTRL(txq_id), 0); - il_write_direct32(priv, FH39_CBCC_BASE(txq_id), 0); + il_write_direct32(il, FH39_CBCC_CTRL(txq_id), 0); + il_write_direct32(il, FH39_CBCC_BASE(txq_id), 0); - il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), + il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | @@ -2211,7 +2211,7 @@ int il3945_hw_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq) FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ - il_read32(priv, FH39_TSSR_CBB_BASE); + il_read32(il, FH39_TSSR_CBB_BASE); return 0; } @@ -2250,10 +2250,10 @@ static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, return (u16)sizeof(struct il3945_addsta_cmd); } -static int il3945_add_bssid_station(struct il_priv *priv, +static int il3945_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; int ret; u8 sta_id; unsigned long flags; @@ -2261,49 +2261,49 @@ static int il3945_add_bssid_station(struct il_priv *priv, if (sta_id_r) *sta_id_r = IL_INVALID_STATION; - ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(il, "Unable to add station %pM\n", addr); return ret; } if (sta_id_r) *sta_id_r = sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -static int il3945_manage_ibss_station(struct il_priv *priv, +static int il3945_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; int ret; if (add) { - ret = il3945_add_bssid_station(priv, vif->bss_conf.bssid, + ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); if (ret) return ret; - il3945_sync_sta(priv, vif_priv->ibss_bssid_sta_id, - (priv->band == IEEE80211_BAND_5GHZ) ? + il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, + (il->band == IEEE80211_BAND_5GHZ) ? IL_RATE_6M_PLCP : IL_RATE_1M_PLCP); - il3945_rate_scale_init(priv->hw, vif_priv->ibss_bssid_sta_id); + il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); return 0; } - return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } /** * il3945_init_hw_rate_table - Initialize the hardware rate fallback table */ -int il3945_init_hw_rate_table(struct il_priv *priv) +int il3945_init_hw_rate_table(struct il_priv *il) { int rc, i, index, prev_index; struct il3945_rate_scaling_cmd rate_cmd = { @@ -2316,15 +2316,15 @@ int il3945_init_hw_rate_table(struct il_priv *priv) table[index].rate_n_flags = il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); - table[index].try_cnt = priv->retry_rate; + table[index].try_cnt = il->retry_rate; prev_index = il3945_get_prev_ieee_rate(i); table[index].next_rate_index = il3945_rates[prev_index].table_rs_index; } - switch (priv->band) { + switch (il->band) { case IEEE80211_BAND_5GHZ: - IL_DEBUG_RATE(priv, "Select A mode rate scale\n"); + IL_DEBUG_RATE(il, "Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ for (i = IL_RATE_1M_INDEX_TABLE; @@ -2342,12 +2342,12 @@ int il3945_init_hw_rate_table(struct il_priv *priv) break; case IEEE80211_BAND_2GHZ: - IL_DEBUG_RATE(priv, "Select B/G mode rate scale\n"); + IL_DEBUG_RATE(il, "Select B/G mode rate scale\n"); /* If an OFDM rate is used, have it fall back to the * 1M CCK rates */ - if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il, IL_RXON_CTX_BSS)) { index = IL_FIRST_CCK_RATE; for (i = IL_RATE_6M_INDEX_TABLE; @@ -2368,52 +2368,52 @@ int il3945_init_hw_rate_table(struct il_priv *priv) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } /* Called when initializing driver */ -int il3945_hw_set_hw_params(struct il_priv *priv) +int il3945_hw_set_hw_params(struct il_priv *il) { - memset((void *)&priv->hw_params, 0, + memset((void *)&il->hw_params, 0, sizeof(struct il_hw_params)); - priv->_3945.shared_virt = - dma_alloc_coherent(&priv->pci_dev->dev, + il->_3945.shared_virt = + dma_alloc_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), - &priv->_3945.shared_phys, GFP_KERNEL); - if (!priv->_3945.shared_virt) { - IL_ERR(priv, "failed to allocate pci memory\n"); + &il->_3945.shared_phys, GFP_KERNEL); + if (!il->_3945.shared_virt) { + IL_ERR(il, "failed to allocate pci memory\n"); return -ENOMEM; } /* Assign number of Usable TX queues */ - priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; - priv->hw_params.tfd_size = sizeof(struct il3945_tfd); - priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); - priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; - priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - priv->hw_params.max_stations = IWL3945_STATION_COUNT; - priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; + il->hw_params.tfd_size = sizeof(struct il3945_tfd); + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + il->hw_params.max_stations = IWL3945_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; - priv->sta_key_max_num = STA_KEY_MAX_NUM; + il->sta_key_max_num = STA_KEY_MAX_NUM; - priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; - priv->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; - priv->hw_params.beacon_time_tsf_bits = IWL3945_EXT_BEACON_TIME_POS; + il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; + il->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.beacon_time_tsf_bits = IWL3945_EXT_BEACON_TIME_POS; return 0; } -unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, +unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame, u8 rate) { struct il3945_tx_beacon_cmd *tx_beacon_cmd; @@ -2423,10 +2423,10 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); tx_beacon_cmd->tx.sta_id = - priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - frame_size = il3945_fill_beacon_frame(priv, + frame_size = il3945_fill_beacon_frame(il, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); @@ -2447,41 +2447,41 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void il3945_hw_rx_handler_setup(struct il_priv *priv) +void il3945_hw_rx_handler_setup(struct il_priv *il) { - priv->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; - priv->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; + il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; + il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; } -void il3945_hw_setup_deferred_work(struct il_priv *priv) +void il3945_hw_setup_deferred_work(struct il_priv *il) { - INIT_DELAYED_WORK(&priv->_3945.thermal_periodic, + INIT_DELAYED_WORK(&il->_3945.thermal_periodic, il3945_bg_reg_txpower_periodic); } -void il3945_hw_cancel_deferred_work(struct il_priv *priv) +void il3945_hw_cancel_deferred_work(struct il_priv *il) { - cancel_delayed_work(&priv->_3945.thermal_periodic); + cancel_delayed_work(&il->_3945.thermal_periodic); } /* check contents of special bootstrap uCode SRAM */ -static int il3945_verify_bsm(struct il_priv *priv) +static int il3945_verify_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; u32 reg; u32 val; - IL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(il, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(priv, reg); + val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(il, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -2490,7 +2490,7 @@ static int il3945_verify_bsm(struct il_priv *priv) } } - IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); return 0; } @@ -2510,14 +2510,14 @@ static int il3945_verify_bsm(struct il_priv *priv) * simply claims ownership, which should be safe when this function is called * (i.e. before loading uCode!). */ -static int il3945_eeprom_acquire_semaphore(struct il_priv *priv) +static int il3945_eeprom_acquire_semaphore(struct il_priv *il) { - _il_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); + _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); return 0; } -static void il3945_eeprom_release_semaphore(struct il_priv *priv) +static void il3945_eeprom_release_semaphore(struct il_priv *il) { return; } @@ -2554,10 +2554,10 @@ static void il3945_eeprom_release_semaphore(struct il_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il3945_load_bsm(struct il_priv *priv) +static int il3945_load_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; dma_addr_t pinst; dma_addr_t pdata; u32 inst_len; @@ -2567,7 +2567,7 @@ static int il3945_load_bsm(struct il_priv *priv) u32 done; u32 reg_offset; - IL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(il, "Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL39_MAX_BSM_SIZE) @@ -2578,55 +2578,55 @@ static int il3945_load_bsm(struct il_priv *priv) * NOTE: il3945_initialize_alive_start() will replace these values, * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ - pinst = priv->ucode_init.p_addr; - pdata = priv->ucode_init_data.p_addr; - inst_len = priv->ucode_init.len; - data_len = priv->ucode_init_data.len; + pinst = il->ucode_init.p_addr; + pdata = il->ucode_init_data.p_addr; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(priv, reg_offset, + _il_write_prph(il, reg_offset, le32_to_cpu(*image)); - rc = il3945_verify_bsm(priv); + rc = il3945_verify_bsm(il); if (rc) return rc; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(priv, BSM_WR_MEM_DST_REG, + il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(il, BSM_WR_MEM_DST_REG, IWL39_RTC_INST_LOWER_BOUND); - il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); else { - IL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(il, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 167eedc..abe778b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -85,7 +85,7 @@ struct il3945_rate_scale_data { struct il3945_rs_sta { spinlock_t lock; - struct il_priv *priv; + struct il_priv *il; s32 *expected_tpt; unsigned long last_partial_flush; unsigned long last_flush; @@ -207,12 +207,12 @@ struct il3945_ibss_seq { *****************************************************************************/ extern int il3945_calc_db_from_ratio(int sig_ratio); extern void il3945_rx_replenish(void *data); -extern void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); -extern unsigned int il3945_fill_beacon_frame(struct il_priv *priv, +extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, int left); -extern int il3945_dump_nic_event_log(struct il_priv *priv, bool full_log, +extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, char **buf, bool display); -extern void il3945_dump_nic_error_log(struct il_priv *priv); +extern void il3945_dump_nic_error_log(struct il_priv *il); /****************************************************************************** * @@ -230,44 +230,44 @@ extern void il3945_dump_nic_error_log(struct il_priv *priv); * il3945_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void il3945_hw_rx_handler_setup(struct il_priv *priv); -extern void il3945_hw_setup_deferred_work(struct il_priv *priv); -extern void il3945_hw_cancel_deferred_work(struct il_priv *priv); -extern int il3945_hw_rxq_stop(struct il_priv *priv); -extern int il3945_hw_set_hw_params(struct il_priv *priv); -extern int il3945_hw_nic_init(struct il_priv *priv); -extern int il3945_hw_nic_stop_master(struct il_priv *priv); -extern void il3945_hw_txq_ctx_free(struct il_priv *priv); -extern void il3945_hw_txq_ctx_stop(struct il_priv *priv); -extern int il3945_hw_nic_reset(struct il_priv *priv); -extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +extern void il3945_hw_rx_handler_setup(struct il_priv *il); +extern void il3945_hw_setup_deferred_work(struct il_priv *il); +extern void il3945_hw_cancel_deferred_work(struct il_priv *il); +extern int il3945_hw_rxq_stop(struct il_priv *il); +extern int il3945_hw_set_hw_params(struct il_priv *il); +extern int il3945_hw_nic_init(struct il_priv *il); +extern int il3945_hw_nic_stop_master(struct il_priv *il); +extern void il3945_hw_txq_ctx_free(struct il_priv *il); +extern void il3945_hw_txq_ctx_stop(struct il_priv *il); +extern int il3945_hw_nic_reset(struct il_priv *il); +extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -extern void il3945_hw_txq_free_tfd(struct il_priv *priv, +extern void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); -extern int il3945_hw_get_temperature(struct il_priv *priv); -extern int il3945_hw_tx_queue_init(struct il_priv *priv, +extern int il3945_hw_get_temperature(struct il_priv *il); +extern int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); -extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, +extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame, u8 rate); -void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id); -extern int il3945_hw_reg_send_txpower(struct il_priv *priv); -extern int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power); -extern void il3945_hw_rx_statistics(struct il_priv *priv, +extern int il3945_hw_reg_send_txpower(struct il_priv *il); +extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); +extern void il3945_hw_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il3945_reply_statistics(struct il_priv *priv, +void il3945_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); -extern void il3945_disable_events(struct il_priv *priv); -extern int il4965_get_temperature(const struct il_priv *priv); -extern void il3945_post_associate(struct il_priv *priv); -extern void il3945_config_ap(struct il_priv *priv); +extern void il3945_disable_events(struct il_priv *il); +extern int il4965_get_temperature(const struct il_priv *il); +extern void il3945_post_associate(struct il_priv *il); +extern void il3945_config_ap(struct il_priv *il); -extern int il3945_commit_rxon(struct il_priv *priv, +extern int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx); /** @@ -278,26 +278,26 @@ extern int il3945_commit_rxon(struct il_priv *priv, * not yet been merged into a single common layer for managing the * station tables. */ -extern u8 il3945_hw_find_station(struct il_priv *priv, const u8 *bssid); +extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); extern struct ieee80211_ops il3945_hw_ops; /* * Forward declare iwl-3945.c functions for iwl3945-base.c */ -extern __le32 il3945_get_antenna_flags(const struct il_priv *priv); -extern int il3945_init_hw_rate_table(struct il_priv *priv); -extern void il3945_reg_txpower_periodic(struct il_priv *priv); -extern int il3945_txpower_set_from_eeprom(struct il_priv *priv); +extern __le32 il3945_get_antenna_flags(const struct il_priv *il); +extern int il3945_init_hw_rate_table(struct il_priv *il); +extern void il3945_reg_txpower_periodic(struct il_priv *il); +extern int il3945_txpower_set_from_eeprom(struct il_priv *il); extern const struct il_channel_info *il3945_get_channel_info( - const struct il_priv *priv, enum ieee80211_band band, u16 channel); + const struct il_priv *il, enum ieee80211_band band, u16 channel); -extern int il3945_rs_next_rate(struct il_priv *priv, int rate); +extern int il3945_rs_next_rate(struct il_priv *il, int rate); /* scanning */ -int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); -void il3945_post_scan(struct il_priv *priv); +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); +void il3945_post_scan(struct il_priv *il); /* rates */ extern const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945]; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 115eeb3..7807dc5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -80,14 +80,14 @@ struct statistics_general_data { u32 beacon_energy_c; }; -void il4965_calib_free_results(struct il_priv *priv) +void il4965_calib_free_results(struct il_priv *il) { int i; for (i = 0; i < IL_CALIB_MAX; i++) { - kfree(priv->calib_results[i].buf); - priv->calib_results[i].buf = NULL; - priv->calib_results[i].buf_len = 0; + kfree(il->calib_results[i].buf); + il->calib_results[i].buf = NULL; + il->calib_results[i].buf_len = 0; } } @@ -103,7 +103,7 @@ void il4965_calib_free_results(struct il_priv *priv) * enough to receive all of our own network traffic, but not so * high that our DSP gets too busy trying to lock onto non-network * activity/noise. */ -static int il4965_sens_energy_cck(struct il_priv *priv, +static int il4965_sens_energy_cck(struct il_priv *il, u32 norm_fa, u32 rx_enable_time, struct statistics_general_data *rx_info) @@ -130,9 +130,9 @@ static int il4965_sens_energy_cck(struct il_priv *priv, u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); data->nrg_auto_corr_silence_diff = 0; @@ -160,7 +160,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - IL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", + IL_DEBUG_CALIB(il, "silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, silence_rssi_b, silence_rssi_c, silence_ref); @@ -184,7 +184,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); max_nrg_cck += 6; - IL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + IL_DEBUG_CALIB(il, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", rx_info->beacon_energy_a, rx_info->beacon_energy_b, rx_info->beacon_energy_c, max_nrg_cck - 6); @@ -194,15 +194,15 @@ static int il4965_sens_energy_cck(struct il_priv *priv, data->num_in_cck_no_fa++; else data->num_in_cck_no_fa = 0; - IL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n", + IL_DEBUG_CALIB(il, "consecutive bcns with few false alarms = %u\n", data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if ((false_alarms > max_false_alarms) && (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { - IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n", + IL_DEBUG_CALIB(il, "norm FA %u > max FA %u\n", false_alarms, max_false_alarms); - IL_DEBUG_CALIB(priv, "... reducing sensitivity\n"); + IL_DEBUG_CALIB(il, "... reducing sensitivity\n"); data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ data->nrg_silence_ref = silence_ref; @@ -219,7 +219,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - (s32)silence_ref; - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "norm FA %u < min FA %u, silence diff %d\n", false_alarms, min_false_alarms, data->nrg_auto_corr_silence_diff); @@ -234,18 +234,18 @@ static int il4965_sens_energy_cck(struct il_priv *priv, ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { - IL_DEBUG_CALIB(priv, "... increasing sensitivity\n"); + IL_DEBUG_CALIB(il, "... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); } else { - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "... but not changing sensitivity\n"); } /* Else we got a healthy number of false alarms, keep status quo */ } else { - IL_DEBUG_CALIB(priv, " FA in safe zone\n"); + IL_DEBUG_CALIB(il, " FA in safe zone\n"); data->nrg_curr_state = IL_FA_GOOD_RANGE; /* Store for use in "fewer than desired" with later beacon */ @@ -255,7 +255,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, * give it some extra margin by reducing sensitivity again * (but don't go below measured energy of desired Rx) */ if (IL_FA_TOO_MANY == data->nrg_prev_state) { - IL_DEBUG_CALIB(priv, "... increasing margin\n"); + IL_DEBUG_CALIB(il, "... increasing margin\n"); if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) data->nrg_th_cck -= NRG_MARGIN; else @@ -269,7 +269,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, * Lower value is higher energy, so we use max()! */ data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - IL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); + IL_DEBUG_CALIB(il, "new nrg_th_cck %u\n", data->nrg_th_cck); data->nrg_prev_state = data->nrg_curr_state; @@ -306,7 +306,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, } -static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, +static int il4965_sens_auto_corr_ofdm(struct il_priv *il, u32 norm_fa, u32 rx_enable_time) { @@ -315,14 +315,14 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n", + IL_DEBUG_CALIB(il, "norm FA %u > max FA %u)\n", false_alarms, max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; @@ -345,7 +345,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - IL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n", + IL_DEBUG_CALIB(il, "norm FA %u < min FA %u\n", false_alarms, min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; @@ -364,13 +364,13 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, data->auto_corr_ofdm_mrc_x1 = max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); } else { - IL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n", + IL_DEBUG_CALIB(il, "min FA %u < norm FA %u < max FA %u OK\n", min_false_alarms, false_alarms, max_false_alarms); } return 0; } -static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv, +static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, struct il_sensitivity_data *data, __le16 *tbl) { @@ -400,18 +400,18 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv, tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = cpu_to_le16(data->nrg_th_cca); - IL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + IL_DEBUG_CALIB(il, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, data->nrg_th_ofdm); - IL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", + IL_DEBUG_CALIB(il, "cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, data->auto_corr_cck_mrc, data->nrg_th_cck); } /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ -static int il4965_sensitivity_write(struct il_priv *priv) +static int il4965_sensitivity_write(struct il_priv *il) { struct il_sensitivity_cmd cmd; struct il_sensitivity_data *data = NULL; @@ -422,43 +422,43 @@ static int il4965_sensitivity_write(struct il_priv *priv) .data = &cmd, }; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); memset(&cmd, 0, sizeof(cmd)); - il4965_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]); + il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; /* Don't send command to uCode if nothing has changed */ - if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]), + if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), sizeof(u16)*HD_TABLE_SIZE)) { - IL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n"); + IL_DEBUG_CALIB(il, "No change in SENSITIVITY_CMD\n"); return 0; } /* Copy table for comparison next time */ - memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), + memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), sizeof(u16)*HD_TABLE_SIZE); - return il_send_cmd(priv, &cmd_out); + return il_send_cmd(il, &cmd_out); } -void il4965_init_sensitivity(struct il_priv *priv) +void il4965_init_sensitivity(struct il_priv *il) { int ret = 0; int i; struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - if (priv->disable_sens_cal) + if (il->disable_sens_cal) return; - IL_DEBUG_CALIB(priv, "Start il4965_init_sensitivity\n"); + IL_DEBUG_CALIB(il, "Start il4965_init_sensitivity\n"); /* Clear driver's sensitivity algo data */ - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); if (ranges == NULL) return; @@ -495,11 +495,11 @@ void il4965_init_sensitivity(struct il_priv *priv) data->last_bad_plcp_cnt_cck = 0; data->last_fa_cnt_cck = 0; - ret |= il4965_sensitivity_write(priv); - IL_DEBUG_CALIB(priv, "<disable_sens_cal) + if (il->disable_sens_cal) return; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); - if (!il_is_any_associated(priv)) { - IL_DEBUG_CALIB(priv, "<< - not associated\n"); + if (!il_is_any_associated(il)) { + IL_DEBUG_CALIB(il, "<< - not associated\n"); return; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); rx_info = &(((struct il_notif_statistics *)resp)->rx.general); ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm); cck = &(((struct il_notif_statistics *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(priv, "<< invalid data.\n"); - spin_unlock_irqrestore(&priv->lock, flags); + IL_DEBUG_CALIB(il, "<< invalid data.\n"); + spin_unlock_irqrestore(&il->lock, flags); return; } @@ -556,12 +556,12 @@ void il4965_sensitivity_calibration(struct il_priv *priv, void *resp) statis.beacon_energy_c = le32_to_cpu(rx_info->beacon_energy_c); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); + IL_DEBUG_CALIB(il, "rx_enable_time = %u usecs\n", rx_enable_time); if (!rx_enable_time) { - IL_DEBUG_CALIB(priv, "<< RX Enable Time == 0!\n"); + IL_DEBUG_CALIB(il, "<< RX Enable Time == 0!\n"); return; } @@ -600,14 +600,14 @@ void il4965_sensitivity_calibration(struct il_priv *priv, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); - il4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); - il4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); + il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); + il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); - il4965_sensitivity_write(priv); + il4965_sensitivity_write(il); } static inline u8 il4965_find_first_chain(u8 mask) @@ -624,7 +624,7 @@ static inline u8 il4965_find_first_chain(u8 mask) * disconnected. */ static void -il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, +il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, struct il_chain_noise_data *data) { u32 active_chains = 0; @@ -635,11 +635,11 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, u16 i = 0; average_sig[0] = data->chain_signal_a / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_sig[1] = data->chain_signal_b / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_sig[2] = data->chain_signal_c / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; if (average_sig[0] >= average_sig[1]) { max_average_sig = average_sig[0]; @@ -657,9 +657,9 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - IL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], average_sig[2]); - IL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n", + IL_DEBUG_CALIB(il, "max_average_sig = %d, antenna %d\n", max_average_sig, max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ @@ -673,7 +673,7 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, data->disconn_array[i] = 1; else active_chains |= (1 << i); - IL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d " + IL_DEBUG_CALIB(il, "i = %d rssiDelta = %d " "disconn_array[i] = %d\n", i, rssi_delta, data->disconn_array[i]); } @@ -689,58 +689,58 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, * To be safe, simply mask out any chains that we know * are not on the device. */ - active_chains &= priv->hw_params.valid_rx_ant; + active_chains &= il->hw_params.valid_rx_ant; num_tx_chains = 0; for (i = 0; i < NUM_RX_CHAINS; i++) { /* loops on all the bits of - * priv->hw_setting.valid_tx_ant */ + * il->hw_setting.valid_tx_ant */ u8 ant_msk = (1 << i); - if (!(priv->hw_params.valid_tx_ant & ant_msk)) + if (!(il->hw_params.valid_tx_ant & ant_msk)) continue; num_tx_chains++; if (data->disconn_array[i] == 0) /* there is a Tx antenna connected */ break; - if (num_tx_chains == priv->hw_params.tx_chains_num && + if (num_tx_chains == il->hw_params.tx_chains_num && data->disconn_array[i]) { /* * If all chains are disconnected * connect the first valid tx chain */ first_chain = - il4965_find_first_chain(priv->cfg->valid_tx_ant); + il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "All Tx chains are disconnected W/A - declare %d as connected\n", first_chain); break; } } - if (active_chains != priv->hw_params.valid_rx_ant && - active_chains != priv->chain_noise_data.active_chains) - IL_DEBUG_CALIB(priv, + if (active_chains != il->hw_params.valid_rx_ant && + active_chains != il->chain_noise_data.active_chains) + IL_DEBUG_CALIB(il, "Detected that not all antennas are connected! " "Connected: %#x, valid: %#x.\n", - active_chains, priv->hw_params.valid_rx_ant); + active_chains, il->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - IL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n", + IL_DEBUG_CALIB(il, "active_chains (bitwise) = 0x%x\n", active_chains); } -static void il4965_gain_computation(struct il_priv *priv, +static void il4965_gain_computation(struct il_priv *il, u32 *average_noise, u16 min_average_noise_antenna_i, u32 min_average_noise, u8 default_chain) { int i, ret; - struct il_chain_noise_data *data = &priv->chain_noise_data; + struct il_chain_noise_data *data = &il->chain_noise_data; data->delta_gain_code[min_average_noise_antenna_i] = 0; @@ -762,7 +762,7 @@ static void il4965_gain_computation(struct il_priv *priv, data->delta_gain_code[i] = 0; } } - IL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], data->delta_gain_code[1], data->delta_gain_code[2]); @@ -777,10 +777,10 @@ static void il4965_gain_computation(struct il_priv *priv, cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd); if (ret) - IL_DEBUG_CALIB(priv, "fail sending cmd " + IL_DEBUG_CALIB(il, "fail sending cmd " "REPLY_PHY_CALIBRATION_CMD\n"); /* TODO we might want recalculate @@ -799,7 +799,7 @@ static void il4965_gain_computation(struct il_priv *priv, * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. */ -void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) { struct il_chain_noise_data *data = NULL; @@ -821,12 +821,12 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) unsigned long flags; struct statistics_rx_non_phy *rx_info; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (priv->disable_chain_noise_cal) + if (il->disable_chain_noise_cal) return; - data = &(priv->chain_noise_data); + data = &(il->chain_noise_data); /* * Accumulate just the first "chain_noise_num_beacons" after @@ -834,18 +834,18 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) */ if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { if (data->state == IL_CHAIN_NOISE_ALIVE) - IL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); + IL_DEBUG_CALIB(il, "Wait for noise calib reset\n"); return; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); rx_info = &(((struct il_notif_statistics *)stat_resp)-> rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); - spin_unlock_irqrestore(&priv->lock, flags); + IL_DEBUG_CALIB(il, " << Interference data unavailable\n"); + spin_unlock_irqrestore(&il->lock, flags); return; } @@ -861,9 +861,9 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { - IL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", + IL_DEBUG_CALIB(il, "Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return; } @@ -882,7 +882,7 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); data->beacon_count++; @@ -894,30 +894,30 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - IL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n", + IL_DEBUG_CALIB(il, "chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, data->beacon_count); - IL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, chain_sig_c); - IL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: * 1) Disconnected antennas (using signal strengths) * 2) Differential gain (using silence noise) to balance receivers */ if (data->beacon_count != - priv->cfg->base_params->chain_noise_num_beacons) + il->cfg->base_params->chain_noise_num_beacons) return; /* Analyze signal for disconnected antenna */ - il4965_find_disconn_antenna(priv, average_sig, data); + il4965_find_disconn_antenna(il, average_sig, data); /* Analyze noise for rx balance */ average_noise[0] = data->chain_noise_a / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_noise[1] = data->chain_noise_b / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_noise[2] = data->chain_noise_c / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; for (i = 0; i < NUM_RX_CHAINS; i++) { if (!(data->disconn_array[i]) && @@ -929,39 +929,39 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) } } - IL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "average_noise: a %d b %d c %d\n", average_noise[0], average_noise[1], average_noise[2]); - IL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", + IL_DEBUG_CALIB(il, "min_average_noise = %d, antenna %d\n", min_average_noise, min_average_noise_antenna_i); - il4965_gain_computation(priv, average_noise, + il4965_gain_computation(il, average_noise, min_average_noise_antenna_i, min_average_noise, - il4965_find_first_chain(priv->cfg->valid_rx_ant)); + il4965_find_first_chain(il->cfg->valid_rx_ant)); /* Some power changes may have been made during the calibration. * Update and commit the RXON */ - if (priv->cfg->ops->lib->update_chain_flags) - priv->cfg->ops->lib->update_chain_flags(priv); + if (il->cfg->ops->lib->update_chain_flags) + il->cfg->ops->lib->update_chain_flags(il); data->state = IL_CHAIN_NOISE_DONE; - il_power_update_mode(priv, false); + il_power_update_mode(il, false); } -void il4965_reset_run_time_calib(struct il_priv *priv) +void il4965_reset_run_time_calib(struct il_priv *il) { int i; - memset(&(priv->sensitivity_data), 0, + memset(&(il->sensitivity_data), 0, sizeof(struct il_sensitivity_data)); - memset(&(priv->chain_noise_data), 0, + memset(&(il->chain_noise_data), 0, sizeof(struct il_chain_noise_data)); for (i = 0; i < NUM_RX_CHAINS; i++) - priv->chain_noise_data.delta_gain_code[i] = + il->chain_noise_data.delta_gain_code[i] = CHAIN_NOISE_DELTA_GAIN_INIT_VAL; /* Ask for statistics now, the uCode will send notification * periodically after association */ - il_send_statistics_request(priv, CMD_ASYNC, true); + il_send_statistics_request(il, CMD_ASYNC, true); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h index a23081f..0e30ea7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h @@ -66,10 +66,10 @@ #include "iwl-core.h" #include "iwl-commands.h" -void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp); -void il4965_sensitivity_calibration(struct il_priv *priv, void *resp); -void il4965_init_sensitivity(struct il_priv *priv); -void il4965_reset_run_time_calib(struct il_priv *priv); -void il4965_calib_free_results(struct il_priv *priv); +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp); +void il4965_sensitivity_calibration(struct il_priv *il, void *resp); +void il4965_init_sensitivity(struct il_priv *il); +void il4965_reset_run_time_calib(struct il_priv *il); +void il4965_calib_free_results(struct il_priv *il); #endif /* __il_4965_calib_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index 3c2876f..8ea0ac2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -33,12 +33,12 @@ static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = "%-32s current cumulative delta max\n"; -static int il4965_statistics_flag(struct il_priv *priv, char *buf, int bufsz) +static int il4965_statistics_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; u32 flag; - flag = le32_to_cpu(priv->_4965.statistics.flag); + flag = le32_to_cpu(il->_4965.statistics.flag); p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); if (flag & UCODE_STATISTICS_CLEAR_MSK) @@ -57,7 +57,7 @@ static int il4965_statistics_flag(struct il_priv *priv, char *buf, int bufsz) ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_rx_phy) * 40 + @@ -70,12 +70,12 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, struct statistics_rx_non_phy *delta_general, *max_general; struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -84,24 +84,24 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, * the last statistics notification from uCode * might not reflect the current uCode activity */ - ofdm = &priv->_4965.statistics.rx.ofdm; - cck = &priv->_4965.statistics.rx.cck; - general = &priv->_4965.statistics.rx.general; - ht = &priv->_4965.statistics.rx.ofdm_ht; - accum_ofdm = &priv->_4965.accum_statistics.rx.ofdm; - accum_cck = &priv->_4965.accum_statistics.rx.cck; - accum_general = &priv->_4965.accum_statistics.rx.general; - accum_ht = &priv->_4965.accum_statistics.rx.ofdm_ht; - delta_ofdm = &priv->_4965.delta_statistics.rx.ofdm; - delta_cck = &priv->_4965.delta_statistics.rx.cck; - delta_general = &priv->_4965.delta_statistics.rx.general; - delta_ht = &priv->_4965.delta_statistics.rx.ofdm_ht; - max_ofdm = &priv->_4965.max_delta.rx.ofdm; - max_cck = &priv->_4965.max_delta.rx.cck; - max_general = &priv->_4965.max_delta.rx.general; - max_ht = &priv->_4965.max_delta.rx.ofdm_ht; + ofdm = &il->_4965.statistics.rx.ofdm; + cck = &il->_4965.statistics.rx.cck; + general = &il->_4965.statistics.rx.general; + ht = &il->_4965.statistics.rx.ofdm_ht; + accum_ofdm = &il->_4965.accum_statistics.rx.ofdm; + accum_cck = &il->_4965.accum_statistics.rx.cck; + accum_general = &il->_4965.accum_statistics.rx.general; + accum_ht = &il->_4965.accum_statistics.rx.ofdm_ht; + delta_ofdm = &il->_4965.delta_statistics.rx.ofdm; + delta_cck = &il->_4965.delta_statistics.rx.cck; + delta_general = &il->_4965.delta_statistics.rx.general; + delta_ht = &il->_4965.delta_statistics.rx.ofdm_ht; + max_ofdm = &il->_4965.max_delta.rx.ofdm; + max_cck = &il->_4965.max_delta.rx.cck; + max_general = &il->_4965.max_delta.rx.general; + max_ht = &il->_4965.max_delta.rx.ofdm_ht; - pos += il4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Rx - OFDM:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -489,19 +489,19 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct statistics_tx) * 48) + 250; ssize_t ret; struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -509,12 +509,12 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - tx = &priv->_4965.statistics.tx; - accum_tx = &priv->_4965.accum_statistics.tx; - delta_tx = &priv->_4965.delta_statistics.tx; - max_tx = &priv->_4965.max_delta.tx; + tx = &il->_4965.statistics.tx; + accum_tx = &il->_4965.accum_statistics.tx; + delta_tx = &il->_4965.delta_statistics.tx; + max_tx = &il->_4965.max_delta.tx; - pos += il4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -664,7 +664,7 @@ ssize_t il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_general) * 10 + 300; @@ -674,12 +674,12 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct statistics_div *div, *accum_div, *delta_div, *max_div; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -687,20 +687,20 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, * the last statistics notification from uCode * might not reflect the current uCode activity */ - general = &priv->_4965.statistics.general.common; - dbg = &priv->_4965.statistics.general.common.dbg; - div = &priv->_4965.statistics.general.common.div; - accum_general = &priv->_4965.accum_statistics.general.common; - accum_dbg = &priv->_4965.accum_statistics.general.common.dbg; - accum_div = &priv->_4965.accum_statistics.general.common.div; - delta_general = &priv->_4965.delta_statistics.general.common; - max_general = &priv->_4965.max_delta.general.common; - delta_dbg = &priv->_4965.delta_statistics.general.common.dbg; - max_dbg = &priv->_4965.max_delta.general.common.dbg; - delta_div = &priv->_4965.delta_statistics.general.common.div; - max_div = &priv->_4965.max_delta.general.common.div; + general = &il->_4965.statistics.general.common; + dbg = &il->_4965.statistics.general.common.dbg; + div = &il->_4965.statistics.general.common.div; + accum_general = &il->_4965.accum_statistics.general.common; + accum_dbg = &il->_4965.accum_statistics.general.common.dbg; + accum_div = &il->_4965.accum_statistics.general.common.div; + delta_general = &il->_4965.delta_statistics.general.common; + max_general = &il->_4965.max_delta.general.common; + delta_dbg = &il->_4965.delta_statistics.general.common.dbg; + max_dbg = &il->_4965.max_delta.general.common.dbg; + delta_div = &il->_4965.delta_statistics.general.common.div; + max_div = &il->_4965.max_delta.general.common.div; - pos += il4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_General:"); pos += scnprintf(buf + pos, bufsz - pos, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index e657b44..947475e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -87,23 +87,23 @@ * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ -int il4965_eeprom_acquire_semaphore(struct il_priv *priv) +int il4965_eeprom_acquire_semaphore(struct il_priv *il) { u16 count; int ret; for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); if (ret >= 0) { - IL_DEBUG_IO(priv, + IL_DEBUG_IO(il, "Acquired semaphore after %d tries.\n", count+1); return ret; @@ -113,42 +113,42 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *priv) return ret; } -void il4965_eeprom_release_semaphore(struct il_priv *priv) +void il4965_eeprom_release_semaphore(struct il_priv *il) { - il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } -int il4965_eeprom_check_version(struct il_priv *priv) +int il4965_eeprom_check_version(struct il_priv *il) { u16 eeprom_ver; u16 calib_ver; - eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); - calib_ver = il_eeprom_query16(priv, + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); + calib_ver = il_eeprom_query16(il, EEPROM_4965_CALIB_VERSION_OFFSET); - if (eeprom_ver < priv->cfg->eeprom_ver || - calib_ver < priv->cfg->eeprom_calib_ver) + if (eeprom_ver < il->cfg->eeprom_ver || + calib_ver < il->cfg->eeprom_calib_ver) goto err; - IL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", + IL_INFO(il, "device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: - IL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " + IL_ERR(il, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " "CALIB=0x%x < 0x%x\n", - eeprom_ver, priv->cfg->eeprom_ver, - calib_ver, priv->cfg->eeprom_calib_ver); + eeprom_ver, il->cfg->eeprom_ver, + calib_ver, il->cfg->eeprom_calib_ver); return -EINVAL; } -void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac) +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) { - const u8 *addr = il_eeprom_query_addr(priv, + const u8 *addr = il_eeprom_query_addr(il, EEPROM_MAC_ADDRESS); memcpy(mac, addr, ETH_ALEN); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c index d2c8eac..1436a1b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.c @@ -44,7 +44,7 @@ /* Send led command */ static int -il4965_send_led_cmd(struct il_priv *priv, struct il_led_cmd *led_cmd) +il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { .id = REPLY_LEDS_CMD, @@ -55,17 +55,17 @@ il4965_send_led_cmd(struct il_priv *priv, struct il_led_cmd *led_cmd) }; u32 reg; - reg = il_read32(priv, CSR_LED_REG); + reg = il_read32(il, CSR_LED_REG); if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - il_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + il_write32(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); - return il_send_cmd(priv, &cmd); + return il_send_cmd(il, &cmd); } /* Set led register off */ -void il4965_led_enable(struct il_priv *priv) +void il4965_led_enable(struct il_priv *il) { - il_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); + il_write32(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } const struct il_led_ops il4965_led_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.h b/drivers/net/wireless/iwlegacy/iwl-4965-led.h index ab03dff..e804fe1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.h @@ -28,6 +28,6 @@ #define __il_4965_led_h__ extern const struct il_led_ops il4965_led_ops; -void il4965_led_enable(struct il_priv *priv); +void il4965_led_enable(struct il_priv *il); #endif /* __il_4965_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 25f1d47..4d25590 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -40,13 +40,13 @@ #include "iwl-4965.h" #include "iwl-sta.h" -void il4965_check_abort_status(struct il_priv *priv, +void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IL_ERR(priv, "Tx flush command to flush out all frames\n"); - if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) - queue_work(priv->workqueue, &priv->tx_flush); + IL_ERR(il, "Tx flush command to flush out all frames\n"); + if (!test_bit(STATUS_EXIT_PENDING, &il->status)) + queue_work(il->workqueue, &il->tx_flush); } } @@ -59,7 +59,7 @@ struct il_mod_params il4965_mod_params = { /* the rest are 0 by default */ }; -void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -71,10 +71,10 @@ void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) /* In the reset function, these buffers may have been allocated * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -91,29 +91,29 @@ void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { u32 rb_size; const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ u32 rb_timeout = 0; - if (priv->cfg->mod_params->amsdu_size_8K) + if (il->cfg->mod_params->amsdu_size_8K) rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; else rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write index */ - il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_write_direct32(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -122,7 +122,7 @@ int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, + il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | @@ -131,77 +131,77 @@ int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ - il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); return 0; } -static void il4965_set_pwr_vmain(struct il_priv *priv) +static void il4965_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) * to set power to V_AUX, do: - if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); */ - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); } -int il4965_hw_nic_init(struct il_priv *priv) +int il4965_hw_nic_init(struct il_priv *il) { unsigned long flags; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; int ret; /* nic_init */ - spin_lock_irqsave(&priv->lock, flags); - priv->cfg->ops->lib->apm_ops.init(priv); + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); /* Set interrupt coalescing calibration timer to default (512 usecs) */ - il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - il4965_set_pwr_vmain(priv); + il4965_set_pwr_vmain(il); - priv->cfg->ops->lib->apm_ops.config(priv); + il->cfg->ops->lib->apm_ops.config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - ret = il_rx_queue_alloc(priv); + ret = il_rx_queue_alloc(il); if (ret) { - IL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(il, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - il4965_rx_queue_reset(priv, rxq); + il4965_rx_queue_reset(il, rxq); - il4965_rx_replenish(priv); + il4965_rx_replenish(il); - il4965_rx_init(priv, rxq); + il4965_rx_init(il, rxq); - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); rxq->need_update = 1; - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Allocate or reset and init all Tx and Command queues */ - if (!priv->txq) { - ret = il4965_txq_ctx_alloc(priv); + if (!il->txq) { + ret = il4965_txq_ctx_alloc(il); if (ret) return ret; } else - il4965_txq_ctx_reset(priv); + il4965_txq_ctx_reset(il); - set_bit(STATUS_INIT, &priv->status); + set_bit(STATUS_INIT, &il->status); return 0; } @@ -209,7 +209,7 @@ int il4965_hw_nic_init(struct il_priv *priv) /** * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *priv, +static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { return cpu_to_le32((u32)(dma_addr >> 8)); @@ -226,9 +226,9 @@ static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -void il4965_rx_queue_restock(struct il_priv *priv) +void il4965_rx_queue_restock(struct il_priv *il) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; unsigned long flags; @@ -245,7 +245,7 @@ void il4965_rx_queue_restock(struct il_priv *priv) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(priv, + rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; @@ -255,7 +255,7 @@ void il4965_rx_queue_restock(struct il_priv *priv) /* If the pre-allocated buffer pool is dropping low, schedule to * refill it */ if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(priv->workqueue, &priv->rx_replenish); + queue_work(il->workqueue, &il->rx_replenish); /* If we've added more space for the firmware to place data, tell it. @@ -264,7 +264,7 @@ void il4965_rx_queue_restock(struct il_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); } } @@ -276,9 +276,9 @@ void il4965_rx_queue_restock(struct il_priv *priv) * Also restock the Rx queue via il_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) +static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; struct page *page; @@ -296,20 +296,20 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) if (rxq->free_count > RX_LOW_WATERMARK) gfp_mask |= __GFP_NOWARN; - if (priv->hw_params.rx_page_order > 0) + if (il->hw_params.rx_page_order > 0) gfp_mask |= __GFP_COMP; /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(priv, "alloc_pages failed, " + IL_DEBUG_INFO(il, "alloc_pages failed, " "order: %d\n", - priv->hw_params.rx_page_order); + il->hw_params.rx_page_order); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(priv, + IL_CRIT(il, "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? @@ -325,7 +325,7 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) if (list_empty(&rxq->rx_used)) { spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, priv->hw_params.rx_page_order); + __free_pages(page, il->hw_params.rx_page_order); return; } element = rxq->rx_used.next; @@ -337,8 +337,8 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) BUG_ON(rxb->page); rxb->page = page; /* Get physical address of the RB */ - rxb->page_dma = pci_map_page(priv->pci_dev, page, 0, - PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); /* dma address must be no more than 36 bits */ BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); @@ -349,28 +349,28 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; - priv->alloc_rxb_page++; + il->alloc_rxb_page++; spin_unlock_irqrestore(&rxq->lock, flags); } } -void il4965_rx_replenish(struct il_priv *priv) +void il4965_rx_replenish(struct il_priv *il) { unsigned long flags; - il4965_rx_allocate(priv, GFP_KERNEL); + il4965_rx_allocate(il, GFP_KERNEL); - spin_lock_irqsave(&priv->lock, flags); - il4965_rx_queue_restock(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il4965_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); } -void il4965_rx_replenish_now(struct il_priv *priv) +void il4965_rx_replenish_now(struct il_priv *il) { - il4965_rx_allocate(priv, GFP_ATOMIC); + il4965_rx_allocate(il, GFP_ATOMIC); - il4965_rx_queue_restock(priv); + il4965_rx_queue_restock(il); } /* Assumes that the skb field of the buffers in 'pool' is kept accurate. @@ -378,33 +378,33 @@ void il4965_rx_replenish_now(struct il_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } } - dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; } -int il4965_rxq_stop(struct il_priv *priv) +int il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ - il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, + il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_direct_bit(il, FH_MEM_RSSR_RX_STATUS_REG, FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; @@ -431,7 +431,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) return -1; } -static int il4965_calc_rssi(struct il_priv *priv, +static int il4965_calc_rssi(struct il_priv *il, struct il_rx_phy_res *rx_resp) { /* data from PHY/DSP regarding signal strength, etc., @@ -456,7 +456,7 @@ static int il4965_calc_rssi(struct il_priv *priv, if (valid_antennae & (1 << i)) max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - IL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", + IL_DEBUG_STATS(il, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], max_rssi, agc); @@ -466,7 +466,7 @@ static int il4965_calc_rssi(struct il_priv *priv, } -static u32 il4965_translate_rx_status(struct il_priv *priv, u32 decrypt_in) +static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) { u32 decrypt_out = 0; @@ -519,13 +519,13 @@ static u32 il4965_translate_rx_status(struct il_priv *priv, u32 decrypt_in) break; } - IL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n", + IL_DEBUG_RX(il, "decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; } -static void il4965_pass_packet_to_mac80211(struct il_priv *priv, +static void il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, u16 len, u32 ampdu_status, @@ -536,36 +536,36 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *priv, __le16 fc = hdr->frame_control; /* We only process data packets if the interface is open */ - if (unlikely(!priv->is_open)) { - IL_DEBUG_DROP_LIMIT(priv, + if (unlikely(!il->is_open)) { + IL_DEBUG_DROP_LIMIT(il, "Dropping packet while interface is not open.\n"); return; } /* In case of HW accelerated crypto and bad decryption, drop */ - if (!priv->cfg->mod_params->sw_crypto && - il_set_decrypted_flag(priv, hdr, ampdu_status, stats)) + if (!il->cfg->mod_params->sw_crypto && + il_set_decrypted_flag(il, hdr, ampdu_status, stats)) return; skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(il, "dev_alloc_skb failed\n"); return; } skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); - il_update_stats(priv, false, fc, len); + il_update_stats(il, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - ieee80211_rx(priv->hw, skb); - priv->alloc_rxb_page--; + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; rxb->page = NULL; } /* Called for REPLY_RX (legacy ABG frames), or * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ -void il4965_rx_reply_rx(struct il_priv *priv, +void il4965_rx_reply_rx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; @@ -582,7 +582,7 @@ void il4965_rx_reply_rx(struct il_priv *priv, * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. * REPLY_RX: physical layer info is in this buffer * REPLY_RX_MPDU_CMD: physical layer info was sent in separate - * command and cached in priv->last_phy_res + * command and cached in il->last_phy_res * * Here we set up local variables depending on which command is * received. @@ -597,28 +597,28 @@ void il4965_rx_reply_rx(struct il_priv *priv, phy_res->cfg_phy_cnt + len); ampdu_status = le32_to_cpu(rx_pkt_status); } else { - if (!priv->_4965.last_phy_res_valid) { - IL_ERR(priv, "MPDU frame without cached PHY data\n"); + if (!il->_4965.last_phy_res_valid) { + IL_ERR(il, "MPDU frame without cached PHY data\n"); return; } - phy_res = &priv->_4965.last_phy_res; + phy_res = &il->_4965.last_phy_res; amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); len = le16_to_cpu(amsdu->byte_count); rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = il4965_translate_rx_status(priv, + ampdu_status = il4965_translate_rx_status(il, le32_to_cpu(rx_pkt_status)); } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", + IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -641,13 +641,13 @@ void il4965_rx_reply_rx(struct il_priv *priv, * this W/A doesn't propagate it to the mac80211 */ /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ - priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); + il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); /* Find max signal strength (dBm) among 3 antenna/receiver chains */ - rx_status.signal = il4965_calc_rssi(priv, phy_res); + rx_status.signal = il4965_calc_rssi(il, phy_res); - il_dbg_log_rx_data_frame(priv, len, header); - IL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", + il_dbg_log_rx_data_frame(il, len, header); + IL_DEBUG_STATS_LIMIT(il, "Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* @@ -679,22 +679,22 @@ void il4965_rx_reply_rx(struct il_priv *priv, if (rate_n_flags & RATE_MCS_SGI_MSK) rx_status.flag |= RX_FLAG_SHORT_GI; - il4965_pass_packet_to_mac80211(priv, header, len, ampdu_status, + il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, rxb, &rx_status); } /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ -void il4965_rx_reply_rx_phy(struct il_priv *priv, +void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); - priv->_4965.last_phy_res_valid = true; - memcpy(&priv->_4965.last_phy_res, pkt->u.raw, + il->_4965.last_phy_res_valid = true; + memcpy(&il->_4965.last_phy_res, pkt->u.raw, sizeof(struct il_rx_phy_res)); } -static int il4965_get_channels_for_scan(struct il_priv *priv, +static int il4965_get_channels_for_scan(struct il_priv *il, struct ieee80211_vif *vif, enum ieee80211_band band, u8 is_active, u8 n_probes, @@ -708,18 +708,18 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, int added, i; u16 channel; - sband = il_get_hw_mode(priv, band); + sband = il_get_hw_mode(il, band); if (!sband) return 0; - active_dwell = il_get_active_dwell_time(priv, band, n_probes); - passive_dwell = il_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; - for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) { - chan = priv->scan_request->channels[i]; + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; if (chan->band != band) continue; @@ -727,9 +727,9 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, channel = chan->hw_value; scan_ch->channel = cpu_to_le16(channel); - ch_info = il_get_channel_info(priv, band, channel); + ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(il, "Channel %d is INVALID for this band.\n", channel); continue; @@ -759,7 +759,7 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - IL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n", + IL_DEBUG_SCAN(il, "Scanning ch=%d prob=0x%X [%s %d]\n", channel, le32_to_cpu(scan_ch->type), (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", @@ -770,11 +770,11 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, added++; } - IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); return added; } -int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, @@ -782,47 +782,47 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) .flags = CMD_SIZE_HUGE, }; struct il_scan_cmd *scan; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u32 rate_flags = 0; u16 cmd_len; u16 rx_chain = 0; enum ieee80211_band band; u8 n_probes = 0; - u8 rx_ant = priv->hw_params.valid_rx_ant; + u8 rx_ant = il->hw_params.valid_rx_ant; u8 rate; bool is_active = false; int chan_mod; u8 active_chains; - u8 scan_tx_antennas = priv->hw_params.valid_tx_ant; + u8 scan_tx_antennas = il->hw_params.valid_tx_ant; int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); if (vif) ctx = il_rxon_ctx_from_vif(vif); - if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!priv->scan_cmd) { - IL_DEBUG_SCAN(priv, + if (!il->scan_cmd) { + IL_DEBUG_SCAN(il, "fail to allocate memory for scan\n"); return -ENOMEM; } } - scan = priv->scan_cmd; + scan = il->scan_cmd; memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (il_is_any_associated(priv)) { + if (il_is_any_associated(il)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(il, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; @@ -834,39 +834,39 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) scan_suspend_time = (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } - if (priv->scan_request->n_ssids) { + if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); - for (i = 0; i < priv->scan_request->n_ssids; i++) { + IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ - if (!priv->scan_request->ssids[i].ssid_len) + if (!il->scan_request->ssids[i].ssid_len) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - priv->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, - priv->scan_request->ssids[i].ssid, - priv->scan_request->ssids[i].ssid_len); + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); n_probes++; p++; } is_active = true; } else - IL_DEBUG_SCAN(priv, "Start passive scan.\n"); + IL_DEBUG_SCAN(il, "Start passive scan.\n"); scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; scan->tx_cmd.sta_id = ctx->bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - switch (priv->scan_band) { + switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; chan_mod = le32_to_cpu( - priv->contexts[IL_RXON_CTX_BSS].active.flags & + il->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { @@ -880,7 +880,7 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) rate = IL_RATE_6M_PLCP; break; default: - IL_WARN(priv, "Invalid scan band\n"); + IL_WARN(il, "Invalid scan band\n"); return -EIO; } @@ -904,54 +904,54 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_NEVER; - band = priv->scan_band; + band = il->scan_band; - if (priv->cfg->scan_rx_antennas[band]) - rx_ant = priv->cfg->scan_rx_antennas[band]; + if (il->cfg->scan_rx_antennas[band]) + rx_ant = il->cfg->scan_rx_antennas[band]; - priv->scan_tx_ant[band] = il4965_toggle_tx_ant(priv, - priv->scan_tx_ant[band], + il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, + il->scan_tx_ant[band], scan_tx_antennas); - rate_flags |= il4965_ant_idx_to_flags(priv->scan_tx_ant[band]); + rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ - if (test_bit(STATUS_POWER_PMI, &priv->status)) { + if (test_bit(STATUS_POWER_PMI, &il->status)) { /* rx_ant has been set to all valid chains previously */ active_chains = rx_ant & - ((u8)(priv->chain_noise_data.active_chains)); + ((u8)(il->chain_noise_data.active_chains)); if (!active_chains) active_chains = rx_ant; - IL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n", - priv->chain_noise_data.active_chains); + IL_DEBUG_SCAN(il, "chain_noise_data.active_chains: %u\n", + il->chain_noise_data.active_chains); rx_ant = il4965_first_antenna(active_chains); } /* MIMO is not used here, but value is required */ - rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; + rx_chain |= il->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; scan->rx_chain = cpu_to_le16(rx_chain); - cmd_len = il_fill_probe_req(priv, + cmd_len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, vif->addr, - priv->scan_request->ie, - priv->scan_request->ie_len, + il->scan_request->ie, + il->scan_request->ie_len, IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(cmd_len); scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | RXON_FILTER_BCON_AWARE_MSK); - scan->channel_count = il4965_get_channels_for_scan(priv, vif, band, + scan->channel_count = il4965_get_channels_for_scan(il, vif, band, is_active, n_probes, (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); return -EIO; } @@ -960,49 +960,49 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &priv->status); + set_bit(STATUS_SCAN_HW, &il->status); - ret = il_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &priv->status); + clear_bit(STATUS_SCAN_HW, &il->status); return ret; } -int il4965_manage_ibss_station(struct il_priv *priv, +int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; if (add) - return il4965_add_bssid_station(priv, vif_priv->ctx, + return il4965_add_bssid_station(il, vif_priv->ctx, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); - return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } -void il4965_free_tfds_in_queue(struct il_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, int freed) { - lockdep_assert_held(&priv->sta_lock); + lockdep_assert_held(&il->sta_lock); - if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed) - priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; + if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) + il->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { - IL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n", - priv->stations[sta_id].tid[tid].tfds_in_queue, + IL_DEBUG_TX(il, "free more than tfds_in_queue (%u:%d)\n", + il->stations[sta_id].tid[tid].tfds_in_queue, freed); - priv->stations[sta_id].tid[tid].tfds_in_queue = 0; + il->stations[sta_id].tid[tid].tfds_in_queue = 0; } } #define IL_TX_QUEUE_MSK 0xfffff -static bool il4965_is_single_rx_stream(struct il_priv *priv) +static bool il4965_is_single_rx_stream(struct il_priv *il) { - return priv->current_ht_config.smps == IEEE80211_SMPS_STATIC || - priv->current_ht_config.single_chain_sufficient; + return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || + il->current_ht_config.single_chain_sufficient; } #define IL_NUM_RX_CHAINS_MULTIPLE 3 @@ -1020,10 +1020,10 @@ static bool il4965_is_single_rx_stream(struct il_priv *priv) * MIMO (dual stream) requires at least 2, but works better with 3. * This does not determine *which* chains to use, just how many. */ -static int il4965_get_active_rx_chain_count(struct il_priv *priv) +static int il4965_get_active_rx_chain_count(struct il_priv *il) { /* # of Rx chains to use when expecting MIMO. */ - if (il4965_is_single_rx_stream(priv)) + if (il4965_is_single_rx_stream(il)) return IL_NUM_RX_CHAINS_SINGLE; else return IL_NUM_RX_CHAINS_MULTIPLE; @@ -1034,10 +1034,10 @@ static int il4965_get_active_rx_chain_count(struct il_priv *priv) * multiplexing power save, use the active count for rx chain count. */ static int -il4965_get_idle_rx_chain_count(struct il_priv *priv, int active_cnt) +il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) { /* # Rx chains when idling, depending on SMPS mode */ - switch (priv->current_ht_config.smps) { + switch (il->current_ht_config.smps) { case IEEE80211_SMPS_STATIC: case IEEE80211_SMPS_DYNAMIC: return IL_NUM_IDLE_CHAINS_SINGLE; @@ -1045,7 +1045,7 @@ il4965_get_idle_rx_chain_count(struct il_priv *priv, int active_cnt) return active_cnt; default: WARN(1, "invalid SMPS mode %d", - priv->current_ht_config.smps); + il->current_ht_config.smps); return active_cnt; } } @@ -1067,10 +1067,10 @@ static u8 il4965_count_chain_bitmap(u32 chain_bitmap) * Selects how many and which Rx receivers/antennas/chains to use. * This should not be used for scan command ... it puts data in wrong place. */ -void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) { - bool is_single = il4965_is_single_rx_stream(priv); - bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); + bool is_single = il4965_is_single_rx_stream(il); + bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; u32 active_chains; u16 rx_chain; @@ -1079,16 +1079,16 @@ void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) * Before first association, we assume all antennas are connected. * Just after first association, il4965_chain_noise_calibration() * checks which antennas actually *are* connected. */ - if (priv->chain_noise_data.active_chains) - active_chains = priv->chain_noise_data.active_chains; + if (il->chain_noise_data.active_chains) + active_chains = il->chain_noise_data.active_chains; else - active_chains = priv->hw_params.valid_rx_ant; + active_chains = il->hw_params.valid_rx_ant; rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; /* How many receivers should we use? */ - active_rx_cnt = il4965_get_active_rx_chain_count(priv); - idle_rx_cnt = il4965_get_idle_rx_chain_count(priv, active_rx_cnt); + active_rx_cnt = il4965_get_active_rx_chain_count(il); + idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); /* correct rx chain count according hw settings @@ -1111,7 +1111,7 @@ void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - IL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", + IL_DEBUG_ASSOC(il, "rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, active_rx_cnt, idle_rx_cnt); @@ -1119,7 +1119,7 @@ void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) active_rx_cnt < idle_rx_cnt); } -u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant, u8 valid) +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) { int i; u8 ind = ant; @@ -1149,7 +1149,7 @@ static const char *il4965_get_fh_string(int cmd) } } -int il4965_dump_fh(struct il_priv *priv, char **buf, bool display) +int il4965_dump_fh(struct il_priv *il, char **buf, bool display) { int i; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1179,16 +1179,16 @@ int il4965_dump_fh(struct il_priv *priv, char **buf, bool display) pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(priv, fh_tbl[i])); + il_read_direct32(il, fh_tbl[i])); } return pos; } #endif - IL_ERR(priv, "FH register values:\n"); + IL_ERR(il, "FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(priv, " %34s: 0X%08x\n", + IL_ERR(il, " %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(priv, fh_tbl[i])); + il_read_direct32(il, fh_tbl[i])); } return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index a7298f5..e53ed1a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -140,11 +140,11 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) return -1; } -static void il4965_rs_rate_scale_perform(struct il_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, struct ieee80211_sta *sta, struct il_lq_sta *lq_sta); -static void il4965_rs_fill_link_cmd(struct il_priv *priv, +static void il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, u32 rate_n_flags); static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search); @@ -348,7 +348,7 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) return tl->total; } -static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, +static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, struct il_lq_sta *lq_data, u8 tid, struct ieee80211_sta *sta) { @@ -358,7 +358,7 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, load = il4965_rs_tl_get_load(lq_data, tid); if (load > IL_AGG_LOAD_THRESHOLD) { - IL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", + IL_DEBUG_HT(il, "Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { @@ -367,25 +367,25 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, * this might be cause by reloading firmware * stop the tx ba session here */ - IL_ERR(priv, "Fail start Tx agg on tid: %d\n", + IL_ERR(il, "Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { - IL_ERR(priv, "Aggregation not enabled for tid %d " + IL_ERR(il, "Aggregation not enabled for tid %d " "because load = %u\n", tid, load); } return ret; } -static void il4965_rs_tl_turn_on_agg(struct il_priv *priv, u8 tid, +static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, struct il_lq_sta *lq_data, struct ieee80211_sta *sta) { if (tid < TID_MAX_LOAD_COUNT) - il4965_rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); + il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); else - IL_ERR(priv, "tid exceeds max load count: %d/%d\n", + IL_ERR(il, "tid exceeds max load count: %d/%d\n", tid, TID_MAX_LOAD_COUNT); } @@ -492,7 +492,7 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, /* * Fill uCode API rate_n_flags field, based on "search" or "active" table. */ -static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, +static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, struct il_scale_tbl_info *tbl, int index, u8 use_green) { @@ -505,7 +505,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, } else if (is_Ht(tbl->lq_type)) { if (index > IL_LAST_OFDM_RATE) { - IL_ERR(priv, "Invalid HT rate index %d\n", index); + IL_ERR(il, "Invalid HT rate index %d\n", index); index = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; @@ -515,7 +515,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, else rate_n_flags |= iwlegacy_rates[index].plcp_mimo2; } else { - IL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); + IL_ERR(il, "Invalid tbl->lq_type %d\n", tbl->lq_type); } rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & @@ -535,7 +535,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, rate_n_flags |= RATE_MCS_GF_MSK; if (is_siso(tbl->lq_type) && tbl->is_SGI) { rate_n_flags &= ~RATE_MCS_SGI_MSK; - IL_ERR(priv, "GF was set with SGI:SISO\n"); + IL_ERR(il, "GF was set with SGI:SISO\n"); } } } @@ -667,7 +667,7 @@ static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, } static u16 -il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, +il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, int rate_type) { u8 high = IL_RATE_INVALID; @@ -707,7 +707,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); } high = index; @@ -717,7 +717,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -732,7 +732,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, u16 high_low; u8 switch_to_legacy = 0; u8 is_green = lq_sta->is_green; - struct il_priv *priv = lq_sta->drv; + struct il_priv *il = lq_sta->drv; /* check if we need to switch from HT to legacy rates. * assumption is that mandatory rates (1Mbps or 6Mbps) @@ -747,7 +747,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, if (il4965_num_of_ant(tbl->ant_type) > 1) tbl->ant_type = - il4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); tbl->is_ht40 = 0; tbl->is_SGI = 0; @@ -798,17 +798,17 @@ static bool il4965_table_type_matches(struct il_scale_tbl_info *a, * mac80211 sends us Tx status */ static void -il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta, +il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, struct sk_buff *skb) { int legacy_success; int retries; int rs_index, mac_index, i; - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; struct il_link_quality_cmd *table; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct il_priv *priv = (struct il_priv *)priv_r; + struct il_priv *il = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); enum mac80211_rate_control_flags mac_flags; u32 tx_rate; @@ -817,15 +817,15 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE_LIMIT(priv, + IL_DEBUG_RATE_LIMIT(il, "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { - IL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n"); + IL_DEBUG_RATE(il, "Station rate scaling not created yet.\n"); return; } else if (!lq_sta->drv) { - IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); + IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); return; } @@ -849,8 +849,8 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, - priv->band, &tbl_type, &rs_index); - if (priv->band == IEEE80211_BAND_5GHZ) + il->band, &tbl_type, &rs_index); + if (il->band == IEEE80211_BAND_5GHZ) rs_index -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; mac_index = info->status.rates[0].idx; @@ -863,7 +863,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, * mac80211 HT index is always zero-indexed; we need to move * HT OFDM rates after CCK rates in 2.4 GHz band */ - if (priv->band == IEEE80211_BAND_2GHZ) + if (il->band == IEEE80211_BAND_2GHZ) mac_index += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ @@ -880,7 +880,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, (!!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || (rs_index != mac_index)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); /* @@ -891,7 +891,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter++; if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { lq_sta->missed_rate_counter = 0; - il_send_lq_cmd(priv, ctx, &lq_sta->lq, + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } /* Regardless, ignore this status info for outdated rate */ @@ -910,15 +910,15 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - IL_DEBUG_RATE(priv, "active- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(il, "active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - IL_DEBUG_RATE(priv, "search- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(il, "search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - IL_DEBUG_RATE(priv, "actual- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(il, "actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection @@ -937,7 +937,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, */ if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, &rs_index); il4965_rs_collect_tx_data(curr_tbl, rs_index, info->status.ampdu_len, @@ -962,7 +962,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, /* Collect data for each rate used during failed TX attempts */ for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, &rs_index); /* * Only collect stats if retried rate is in the same RS @@ -990,7 +990,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, done: /* See if there's a better rate or modulation mode to try. */ if (sta && sta->supp_rates[sband->band]) - il4965_rs_rate_scale_perform(priv, skb, sta, lq_sta); + il4965_rs_rate_scale_perform(il, skb, sta, lq_sta); } /* @@ -1001,10 +1001,10 @@ done: * These control how long we stay using same modulation mode before * searching for a new mode. */ -static void il4965_rs_set_stay_in_table(struct il_priv *priv, u8 is_legacy, +static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, struct il_lq_sta *lq_sta) { - IL_DEBUG_RATE(priv, "we are staying in the same table\n"); + IL_DEBUG_RATE(il, "we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; @@ -1077,7 +1077,7 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, * to decrease to match "active" throughput. When moving from MIMO to SISO, * bit rate will typically need to increase, but not if performance was bad. */ -static s32 il4965_rs_get_best_rate(struct il_priv *priv, +static s32 il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ u16 rate_mask, s8 index) @@ -1098,7 +1098,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *priv, new_rate = high = low = start_hi = IL_RATE_INVALID; for (; ;) { - high_low = il4965_rs_get_adjacent_rate(priv, rate, rate_mask, + high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -1171,7 +1171,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *priv, /* * Set up search table for MIMO2 */ -static int il4965_rs_switch_to_mimo2(struct il_priv *priv, +static int il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, @@ -1191,10 +1191,10 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *priv, return -1; /* Need both Tx chains/antennas to support MIMO */ - if (priv->hw_params.tx_chains_num < 2) + if (il->hw_params.tx_chains_num < 2) return -1; - IL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n"); + IL_DEBUG_RATE(il, "LQ: try to switch to MIMO2\n"); tbl->lq_type = LQ_MIMO2; tbl->is_dup = lq_sta->is_dup; @@ -1202,27 +1202,27 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *priv, tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_mimo2_rate; - if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", + IL_DEBUG_RATE(il, "LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "Can't switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1230,7 +1230,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *priv, /* * Set up search table for SISO */ -static int il4965_rs_switch_to_siso(struct il_priv *priv, +static int il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, @@ -1245,7 +1245,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - IL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n"); + IL_DEBUG_RATE(il, "LQ: try to switch to SISO\n"); tbl->is_dup = lq_sta->is_dup; tbl->lq_type = LQ_SISO; @@ -1253,7 +1253,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_siso_rate; - if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; @@ -1262,18 +1262,18 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask); + IL_DEBUG_RATE(il, "LQ: get best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "can not switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1281,7 +1281,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, /* * Try to switch to new modulation mode from legacy */ -static int il4965_rs_move_legacy_other(struct il_priv *priv, +static int il4965_rs_move_legacy_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, @@ -1294,8 +1294,8 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; - u8 valid_tx_ant = priv->hw_params.valid_tx_ant; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; int ret = 0; u8 update_search_tbl_counter = 0; @@ -1307,7 +1307,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, switch (tbl->action) { case IL_LEGACY_SWITCH_ANTENNA1: case IL_LEGACY_SWITCH_ANTENNA2: - IL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); + IL_DEBUG_RATE(il, "LQ: Legacy toggle Antenna\n"); if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && tx_chains_num <= 1) || @@ -1331,12 +1331,12 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, } break; case IL_LEGACY_SWITCH_SISO: - IL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n"); + IL_DEBUG_RATE(il, "LQ: Legacy switch to SISO\n"); /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - ret = il4965_rs_switch_to_siso(priv, lq_sta, conf, sta, + ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, search_tbl, index); if (!ret) { lq_sta->action_counter = 0; @@ -1347,7 +1347,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, case IL_LEGACY_SWITCH_MIMO2_AB: case IL_LEGACY_SWITCH_MIMO2_AC: case IL_LEGACY_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n"); + IL_DEBUG_RATE(il, "LQ: Legacy switch to MIMO2\n"); /* Set up search table to try MIMO */ memcpy(search_tbl, tbl, sz); @@ -1364,7 +1364,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, search_tbl, index); if (!ret) { @@ -1398,7 +1398,7 @@ out: /* * Try to switch to new modulation mode from SISO */ -static int il4965_rs_move_siso_to_other(struct il_priv *priv, +static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) @@ -1412,8 +1412,8 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; - u8 valid_tx_ant = priv->hw_params.valid_tx_ant; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; u8 update_search_tbl_counter = 0; int ret; @@ -1424,7 +1424,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, switch (tbl->action) { case IL_SISO_SWITCH_ANTENNA1: case IL_SISO_SWITCH_ANTENNA2: - IL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); + IL_DEBUG_RATE(il, "LQ: SISO toggle Antenna\n"); if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && tx_chains_num <= 1) || (tbl->action == IL_SISO_SWITCH_ANTENNA2 && @@ -1444,7 +1444,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, case IL_SISO_SWITCH_MIMO2_AB: case IL_SISO_SWITCH_MIMO2_AC: case IL_SISO_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n"); + IL_DEBUG_RATE(il, "LQ: SISO switch to MIMO2\n"); memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; @@ -1459,7 +1459,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, search_tbl, index); if (!ret) @@ -1473,14 +1473,14 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n"); + IL_DEBUG_RATE(il, "LQ: SISO toggle SGI/NGI\n"); memcpy(search_tbl, tbl, sz); if (is_green) { if (!tbl->is_SGI) break; else - IL_ERR(priv, + IL_ERR(il, "SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; @@ -1491,7 +1491,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(il, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; @@ -1520,7 +1520,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, /* * Try to switch to new modulation mode from MIMO2 */ -static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, +static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) @@ -1534,8 +1534,8 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; - u8 valid_tx_ant = priv->hw_params.valid_tx_ant; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; u8 update_search_tbl_counter = 0; int ret; @@ -1545,7 +1545,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, switch (tbl->action) { case IL_MIMO2_SWITCH_ANTENNA1: case IL_MIMO2_SWITCH_ANTENNA2: - IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle Antennas\n"); + IL_DEBUG_RATE(il, "LQ: MIMO2 toggle Antennas\n"); if (tx_chains_num <= 2) break; @@ -1563,7 +1563,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, case IL_MIMO2_SWITCH_SISO_A: case IL_MIMO2_SWITCH_SISO_B: case IL_MIMO2_SWITCH_SISO_C: - IL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n"); + IL_DEBUG_RATE(il, "LQ: MIMO2 switch to SISO\n"); /* Set up new search table for SISO */ memcpy(search_tbl, tbl, sz); @@ -1579,7 +1579,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_siso(priv, lq_sta, + ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, search_tbl, index); if (!ret) @@ -1595,7 +1595,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle SGI/NGI\n"); + IL_DEBUG_RATE(il, "LQ: MIMO2 toggle SGI/NGI\n"); /* Set up new search table for MIMO2 */ memcpy(search_tbl, tbl, sz); @@ -1613,7 +1613,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(il, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; @@ -1654,9 +1654,9 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) int i; int active_tbl; int flush_interval_passed = 0; - struct il_priv *priv; + struct il_priv *il; - priv = lq_sta->drv; + il = lq_sta->drv; active_tbl = lq_sta->active_tbl; tbl = &(lq_sta->lq_info[active_tbl]); @@ -1684,7 +1684,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) (lq_sta->total_success > lq_sta->max_success_limit) || ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) && (flush_interval_passed))) { - IL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:", + IL_DEBUG_RATE(il, "LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, flush_interval_passed); @@ -1707,7 +1707,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) lq_sta->table_count_limit) { lq_sta->table_count = 0; - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "LQ: stay in table clear win\n"); for (i = 0; i < IL_RATE_COUNT; i++) il4965_rs_rate_scale_clear_window( @@ -1730,7 +1730,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * setup rate table in uCode * return rate_n_flags as used in the table */ -static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, +static u32 il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, @@ -1739,9 +1739,9 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, u32 rate; /* Update uCode's rate table. */ - rate = il4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); - il4965_rs_fill_link_cmd(priv, lq_sta, rate); - il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); + rate = il4965_rate_n_flags_from_tbl(il, tbl, index, is_green); + il4965_rs_fill_link_cmd(il, lq_sta, rate); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); return rate; } @@ -1749,12 +1749,12 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, /* * Do rate scaling and search for new modulation mode. */ -static void il4965_rs_rate_scale_perform(struct il_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, struct ieee80211_sta *sta, struct il_lq_sta *lq_sta) { - struct ieee80211_hw *hw = priv->hw; + struct ieee80211_hw *hw = il->hw; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; @@ -1783,7 +1783,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ @@ -1798,7 +1798,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, tid = il4965_rs_tl_add_packet(lq_sta, hdr); if ((tid != MAX_TID_COUNT) && (lq_sta->tx_agg_tid_en & (1 << tid))) { - tid_data = &priv->stations[lq_sta->lq.sta_id].tid[tid]; + tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) lq_sta->is_agg = 0; else @@ -1826,13 +1826,13 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* current tx rate */ index = lq_sta->last_txrate_idx; - IL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index, + IL_DEBUG_RATE(il, "Rate scale index %d for type %d\n", index, tbl->lq_type); /* rates available for this association, and for modulation mode */ rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - IL_DEBUG_RATE(priv, "mask 0x%04X\n", rate_mask); + IL_DEBUG_RATE(il, "mask 0x%04X\n", rate_mask); /* mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { @@ -1851,7 +1851,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, rate_scale_index_msk = rate_mask; if (!((1 << index) & rate_scale_index_msk)) { - IL_ERR(priv, "Current Rate is not valid\n"); + IL_ERR(il, "Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ tbl->lq_type = LQ_NONE; @@ -1859,7 +1859,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, index, is_green); } return; @@ -1867,7 +1867,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* Get expected throughput table and history window for current rate */ if (!tbl->expected_tpt) { - IL_ERR(priv, "tbl->expected_tpt is NULL\n"); + IL_ERR(il, "tbl->expected_tpt is NULL\n"); return; } @@ -1892,7 +1892,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, fail_count = window->counter - window->success_counter; if ((fail_count < IL_RATE_MIN_FAILURE_TH) && (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { - IL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d " + IL_DEBUG_RATE(il, "LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); @@ -1909,7 +1909,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, * actual average throughput */ if (window->average_tpt != ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { - IL_ERR(priv, + IL_ERR(il, "expected_tpt should have been calculated by now\n"); window->average_tpt = ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128); @@ -1922,7 +1922,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, * continuing to use the setup that we've been trying. */ if (window->average_tpt > lq_sta->last_tpt) { - IL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE " + IL_DEBUG_RATE(il, "LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1938,7 +1938,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* Else poor success; go back to mode in "active" table */ } else { - IL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE " + IL_DEBUG_RATE(il, "LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1968,7 +1968,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(priv, index, + high_low = il4965_rs_get_adjacent_rate(il, index, rate_scale_index_msk, tbl->lq_type); low = high_low & 0xff; @@ -1992,7 +1992,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* Too many failures, decrease rate */ if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of low success_ratio\n"); scale_action = -1; @@ -2031,7 +2031,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of low tpt\n"); scale_action = -1; } else if (sr >= IL_RATE_INCREASE_TH) { @@ -2070,14 +2070,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, break; } - IL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d " + IL_DEBUG_RATE(il, "choose rate scale index %d action %d low %d " "high %d type %d\n", index, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) - rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, index, is_green); /* Should we stay with this modulation mode, @@ -2098,13 +2098,13 @@ lq_update: /* Select a new "search" modulation mode to try. * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) - il4965_rs_move_legacy_other(priv, lq_sta, + il4965_rs_move_legacy_other(il, lq_sta, conf, sta, index); else if (is_siso(tbl->lq_type)) - il4965_rs_move_siso_to_other(priv, lq_sta, + il4965_rs_move_siso_to_other(il, lq_sta, conf, sta, index); else /* (is_mimo2(tbl->lq_type)) */ - il4965_rs_move_mimo2_to_other(priv, lq_sta, + il4965_rs_move_mimo2_to_other(il, lq_sta, conf, sta, index); /* If new "search" mode was selected, set up in uCode table */ @@ -2118,12 +2118,12 @@ lq_update: /* Use new "search" start rate */ index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "Switch current mcs: %X index: %d\n", tbl->current_rate, index); - il4965_rs_fill_link_cmd(priv, lq_sta, + il4965_rs_fill_link_cmd(il, lq_sta, tbl->current_rate); - il_send_lq_cmd(priv, ctx, + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } else done_search = 1; @@ -2138,8 +2138,8 @@ lq_update: tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && lq_sta->action_counter > tbl1->max_search) { - IL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); - il4965_rs_set_stay_in_table(priv, 1, lq_sta); + IL_DEBUG_RATE(il, "LQ: STAY in legacy table\n"); + il4965_rs_set_stay_in_table(il, 1, lq_sta); } /* If we're in an HT mode, and all 3 mode switch actions @@ -2151,21 +2151,21 @@ lq_update: (lq_sta->tx_agg_tid_en & (1 << tid)) && (tid != MAX_TID_COUNT)) { tid_data = - &priv->stations[lq_sta->lq.sta_id].tid[tid]; + &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "try to aggregate tid %d\n", tid); - il4965_rs_tl_turn_on_agg(priv, tid, + il4965_rs_tl_turn_on_agg(il, tid, lq_sta, sta); } } - il4965_rs_set_stay_in_table(priv, 0, lq_sta); + il4965_rs_set_stay_in_table(il, 0, lq_sta); } } out: - tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, index, is_green); i = index; lq_sta->last_txrate_idx = i; @@ -2185,7 +2185,7 @@ out: * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ -static void il4965_rs_initialize_lq(struct il_priv *priv, +static void il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, struct ieee80211_sta *sta, struct il_lq_sta *lq_sta) @@ -2208,7 +2208,7 @@ static void il4965_rs_initialize_lq(struct il_priv *priv, i = lq_sta->last_txrate_idx; - valid_tx_ant = priv->hw_params.valid_tx_ant; + valid_tx_ant = il->hw_params.valid_tx_ant; if (!lq_sta->search_better_tbl) active_tbl = lq_sta->active_tbl; @@ -2227,31 +2227,31 @@ static void il4965_rs_initialize_lq(struct il_priv *priv, if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) rate |= RATE_MCS_CCK_MSK; - il4965_rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); + il4965_rs_get_tbl_info_from_mcs(rate, il->band, tbl, &rate_idx); if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); - rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate_idx, use_green); + rate = il4965_rate_n_flags_from_tbl(il, tbl, rate_idx, use_green); tbl->current_rate = rate; il4965_rs_set_expected_tpt_table(lq_sta, tbl); il4965_rs_fill_link_cmd(NULL, lq_sta, rate); - priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; - il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_SYNC, true); + il->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_SYNC, true); } static void -il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, +il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, struct ieee80211_tx_rate_control *txrc) { struct sk_buff *skb = txrc->skb; struct ieee80211_supported_band *sband = txrc->sband; - struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; int rate_idx; - IL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE_LIMIT(il, "rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { @@ -2266,12 +2266,12 @@ il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, /* Treat uninitialized rate scaling data same as non-existing. */ if (lq_sta && !lq_sta->drv) { - IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); - priv_sta = NULL; + IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); + il_sta = NULL; } /* Send management frames and NO_ACK data using lowest rate. */ - if (rate_control_send_low(sta, priv_sta, txrc)) + if (rate_control_send_low(sta, il_sta, txrc)) return; if (!lq_sta) @@ -2314,16 +2314,16 @@ il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, } -static void *il4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, +static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, gfp_t gfp) { struct il_lq_sta *lq_sta; struct il_station_priv *sta_priv = (struct il_station_priv *) sta->drv_priv; - struct il_priv *priv; + struct il_priv *il; - priv = (struct il_priv *)priv_rate; - IL_DEBUG_RATE(priv, "create station rate scale window\n"); + il = (struct il_priv *)il_rate; + IL_DEBUG_RATE(il, "create station rate scale window\n"); lq_sta = &sta_priv->lq_sta; @@ -2334,13 +2334,13 @@ static void *il4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, * Called after adding a new station to initialize rate scaling */ void -il4965_rs_rate_init(struct il_priv *priv, +il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { int i, j; - struct ieee80211_hw *hw = priv->hw; - struct ieee80211_conf *conf = &priv->hw->conf; + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; struct il_station_priv *sta_priv; struct il_lq_sta *lq_sta; @@ -2365,7 +2365,7 @@ il4965_rs_rate_init(struct il_priv *priv, il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); - IL_DEBUG_RATE(priv, "LQ:" + IL_DEBUG_RATE(il, "LQ:" "*** rate scale station global init for station %d ***\n", sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -2377,8 +2377,8 @@ il4965_rs_rate_init(struct il_priv *priv, lq_sta->max_rate_idx = -1; lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; lq_sta->is_green = il4965_rs_use_green(sta); - lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); - lq_sta->band = priv->band; + lq_sta->active_legacy_rate = il->active_rate & ~(0x1000); + lq_sta->band = il->band; /* * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), * supp_rates[] does not; shift to convert format, force 9 MBits off. @@ -2396,20 +2396,20 @@ il4965_rs_rate_init(struct il_priv *priv, /* These values will be overridden later */ lq_sta->lq.general_params.single_stream_ant_msk = - il4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); lq_sta->lq.general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant & - ~il4965_first_antenna(priv->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); if (!lq_sta->lq.general_params.dual_stream_ant_msk) { lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { lq_sta->lq.general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } /* as default allow aggregation for all tids */ lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; - lq_sta->drv = priv; + lq_sta->drv = il; /* Set last_txrate_idx to lowest rate */ lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); @@ -2421,10 +2421,10 @@ il4965_rs_rate_init(struct il_priv *priv, lq_sta->dbg_fixed_rate = 0; #endif - il4965_rs_initialize_lq(priv, conf, sta, lq_sta); + il4965_rs_initialize_lq(il, conf, sta, lq_sta); } -static void il4965_rs_fill_link_cmd(struct il_priv *priv, +static void il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, u32 new_rate) { struct il_scale_tbl_info tbl_type; @@ -2467,8 +2467,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *priv, index++; repeat_rate--; - if (priv) - valid_tx_ant = priv->hw_params.valid_tx_ant; + if (il) + valid_tx_ant = il->hw_params.valid_tx_ant; /* Fill rest of rate table */ while (index < LINK_QUAL_MAX_RETRY_NUM) { @@ -2479,7 +2479,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *priv, if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; - else if (priv && + else if (il && il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; @@ -2514,7 +2514,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *priv, if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; - else if (priv && + else if (il && il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; @@ -2551,18 +2551,18 @@ static void return hw->priv; } /* rate scale requires free function to be implemented */ -static void il4965_rs_free(void *priv_rate) +static void il4965_rs_free(void *il_rate) { return; } -static void il4965_rs_free_sta(void *priv_r, struct ieee80211_sta *sta, - void *priv_sta) +static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, + void *il_sta) { - struct il_priv *priv __maybe_unused = priv_r; + struct il_priv *il __maybe_unused = il_r; - IL_DEBUG_RATE(priv, "enter\n"); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "enter\n"); + IL_DEBUG_RATE(il, "leave\n"); } @@ -2575,28 +2575,28 @@ static int il4965_open_file_generic(struct inode *inode, struct file *file) static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index) { - struct il_priv *priv; + struct il_priv *il; u8 valid_tx_ant; u8 ant_sel_tx; - priv = lq_sta->drv; - valid_tx_ant = priv->hw_params.valid_tx_ant; + il = lq_sta->drv; + valid_tx_ant = il->hw_params.valid_tx_ant; if (lq_sta->dbg_fixed_rate) { ant_sel_tx = ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; - IL_DEBUG_RATE(priv, "Fixed rate ON\n"); + IL_DEBUG_RATE(il, "Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IL_ERR(priv, + IL_ERR(il, "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); - IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(il, "Fixed rate OFF\n"); } } else { - IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(il, "Fixed rate OFF\n"); } } @@ -2604,7 +2604,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *priv; + struct il_priv *il; char buf[64]; size_t buf_size; u32 parsed_rate; @@ -2612,7 +2612,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, container_of(lq_sta, struct il_station_priv, lq_sta); struct il_rxon_context *ctx = sta_priv->common.ctx; - priv = lq_sta->drv; + il = lq_sta->drv; memset(buf, 0, sizeof(buf)); buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) @@ -2627,7 +2627,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - IL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", + IL_DEBUG_RATE(il, "sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { @@ -2649,10 +2649,10 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, ssize_t ret; struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *priv; + struct il_priv *il; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - priv = lq_sta->drv; + il = lq_sta->drv; buff = kmalloc(1024, GFP_KERNEL); if (!buff) return -ENOMEM; @@ -2664,9 +2664,9 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, desc += sprintf(buff+desc, "fixed rate 0x%X\n", lq_sta->dbg_fixed_rate); desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", - (priv->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", - (priv->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", - (priv->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); + (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", + (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", + (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); desc += sprintf(buff+desc, "lq type %s\n", (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); if (is_Ht(tbl->lq_type)) { @@ -2781,10 +2781,10 @@ static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, ssize_t ret; struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *priv; + struct il_priv *il; struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; - priv = lq_sta->drv; + il = lq_sta->drv; if (is_Ht(tbl->lq_type)) desc += sprintf(buff+desc, @@ -2805,10 +2805,10 @@ static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { .llseek = default_llseek, }; -static void il4965_rs_add_debugfs(void *priv, void *priv_sta, +static void il4965_rs_add_debugfs(void *il, void *il_sta, struct dentry *dir) { - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_scale_table_file = debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, lq_sta, &rs_sta_dbgfs_scale_table_ops); @@ -2824,9 +2824,9 @@ static void il4965_rs_add_debugfs(void *priv, void *priv_sta, } -static void il4965_rs_remove_debugfs(void *priv, void *priv_sta) +static void il4965_rs_remove_debugfs(void *il, void *il_sta) { - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); @@ -2840,8 +2840,8 @@ static void il4965_rs_remove_debugfs(void *priv, void *priv_sta) * station is added we ignore it. */ static void -il4965_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta) +il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) { } static struct rate_control_ops rs_4965_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 47cbe56..c987c80 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -41,7 +41,7 @@ #include "iwl-4965-hw.h" #include "iwl-4965.h" -void il4965_rx_missed_beacon_notif(struct il_priv *priv, +void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { @@ -50,22 +50,22 @@ void il4965_rx_missed_beacon_notif(struct il_priv *priv, missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > - priv->missed_beacon_threshold) { - IL_DEBUG_CALIB(priv, + il->missed_beacon_threshold) { + IL_DEBUG_CALIB(il, "missed bcn cnsq %d totl %d rcd %d expctd %d\n", le32_to_cpu(missed_beacon->consecutive_missed_beacons), le32_to_cpu(missed_beacon->total_missed_becons), le32_to_cpu(missed_beacon->num_recvd_beacons), le32_to_cpu(missed_beacon->num_expected_beacons)); - if (!test_bit(STATUS_SCANNING, &priv->status)) - il4965_init_sensitivity(priv); + if (!test_bit(STATUS_SCANNING, &il->status)) + il4965_init_sensitivity(il); } } /* Calculate noise level, based on measurements during network silence just * before arriving beacon. This measurement can be done only if we know * exactly when to expect beacons, therefore only when we're associated. */ -static void il4965_rx_calc_noise(struct il_priv *priv) +static void il4965_rx_calc_noise(struct il_priv *il) { struct statistics_rx_non_phy *rx_info; int num_active_rx = 0; @@ -73,7 +73,7 @@ static void il4965_rx_calc_noise(struct il_priv *priv) int bcn_silence_a, bcn_silence_b, bcn_silence_c; int last_rx_noise; - rx_info = &(priv->_4965.statistics.rx.general); + rx_info = &(il->_4965.statistics.rx.general); bcn_silence_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; bcn_silence_b = @@ -100,7 +100,7 @@ static void il4965_rx_calc_noise(struct il_priv *priv) else last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - IL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", + IL_DEBUG_CALIB(il, "inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, bcn_silence_b, bcn_silence_c, last_rx_noise); } @@ -111,7 +111,7 @@ static void il4965_rx_calc_noise(struct il_priv *priv) * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void il4965_accumulative_statistics(struct il_priv *priv, +static void il4965_accumulative_statistics(struct il_priv *il, __le32 *stats) { int i, size; @@ -121,15 +121,15 @@ static void il4965_accumulative_statistics(struct il_priv *priv, struct statistics_general_common *general, *accum_general; struct statistics_tx *tx, *accum_tx; - prev_stats = (__le32 *)&priv->_4965.statistics; - accum_stats = (u32 *)&priv->_4965.accum_statistics; + prev_stats = (__le32 *)&il->_4965.statistics; + accum_stats = (u32 *)&il->_4965.accum_statistics; size = sizeof(struct il_notif_statistics); - general = &priv->_4965.statistics.general.common; - accum_general = &priv->_4965.accum_statistics.general.common; - tx = &priv->_4965.statistics.tx; - accum_tx = &priv->_4965.accum_statistics.tx; - delta = (u32 *)&priv->_4965.delta_statistics; - max_delta = (u32 *)&priv->_4965.max_delta; + general = &il->_4965.statistics.general.common; + accum_general = &il->_4965.accum_statistics.general.common; + tx = &il->_4965.statistics.tx; + accum_tx = &il->_4965.accum_statistics.tx; + delta = (u32 *)&il->_4965.delta_statistics; + max_delta = (u32 *)&il->_4965.max_delta; for (i = sizeof(__le32); i < size; i += sizeof(__le32), stats++, prev_stats++, delta++, @@ -151,65 +151,65 @@ static void il4965_accumulative_statistics(struct il_priv *priv, #define REG_RECALIB_PERIOD (60) -void il4965_rx_statistics(struct il_priv *priv, +void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { int change; struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(priv, + IL_DEBUG_RX(il, "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); - change = ((priv->_4965.statistics.general.common.temperature != + change = ((il->_4965.statistics.general.common.temperature != pkt->u.stats.general.common.temperature) || - ((priv->_4965.statistics.flag & + ((il->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - il4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); + il4965_accumulative_statistics(il, (__le32 *)&pkt->u.stats); #endif /* TODO: reading some of statistics is unneeded */ - memcpy(&priv->_4965.statistics, &pkt->u.stats, - sizeof(priv->_4965.statistics)); + memcpy(&il->_4965.statistics, &pkt->u.stats, + sizeof(il->_4965.statistics)); - set_bit(STATUS_STATISTICS, &priv->status); + set_bit(STATUS_STATISTICS, &il->status); /* Reschedule the statistics timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a * thermal update even if the uCode doesn't give * us one */ - mod_timer(&priv->statistics_periodic, jiffies + + mod_timer(&il->statistics_periodic, jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); - if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && + if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { - il4965_rx_calc_noise(priv); - queue_work(priv->workqueue, &priv->run_time_calib_work); + il4965_rx_calc_noise(il); + queue_work(il->workqueue, &il->run_time_calib_work); } - if (priv->cfg->ops->lib->temp_ops.temperature && change) - priv->cfg->ops->lib->temp_ops.temperature(priv); + if (il->cfg->ops->lib->temp_ops.temperature && change) + il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_reply_statistics(struct il_priv *priv, +void il4965_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - memset(&priv->_4965.accum_statistics, 0, + memset(&il->_4965.accum_statistics, 0, sizeof(struct il_notif_statistics)); - memset(&priv->_4965.delta_statistics, 0, + memset(&il->_4965.delta_statistics, 0, sizeof(struct il_notif_statistics)); - memset(&priv->_4965.max_delta, 0, + memset(&il->_4965.max_delta, 0, sizeof(struct il_notif_statistics)); #endif - IL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(il, "Statistics have been cleared\n"); } - il4965_rx_statistics(priv, rxb); + il4965_rx_statistics(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 3ac9aef..20290d2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -35,7 +35,7 @@ #include "iwl-4965.h" static struct il_link_quality_cmd * -il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) +il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) { int i, r; struct il_link_quality_cmd *link_cmd; @@ -44,12 +44,12 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); if (!link_cmd) { - IL_ERR(priv, "Unable to allocate memory for LQ cmd.\n"); + IL_ERR(il, "Unable to allocate memory for LQ cmd.\n"); return NULL; } /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ - if (priv->band == IEEE80211_BAND_5GHZ) + if (il->band == IEEE80211_BAND_5GHZ) r = IL_RATE_6M_INDEX; else r = IL_RATE_1M_INDEX; @@ -57,7 +57,7 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; - rate_flags |= il4965_first_antenna(priv->hw_params.valid_tx_ant) << + rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << RATE_MCS_ANT_POS; rate_n_flags = il4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, rate_flags); @@ -65,16 +65,16 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; link_cmd->general_params.single_stream_ant_msk = - il4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); link_cmd->general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant & - ~il4965_first_antenna(priv->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); if (!link_cmd->general_params.dual_stream_ant_msk) { link_cmd->general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { link_cmd->general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; @@ -92,7 +92,7 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) * Function sleeps. */ int -il4965_add_bssid_station(struct il_priv *priv, struct il_rxon_context *ctx, +il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r) { int ret; @@ -103,40 +103,40 @@ il4965_add_bssid_station(struct il_priv *priv, struct il_rxon_context *ctx, if (sta_id_r) *sta_id_r = IL_INVALID_STATION; - ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(il, "Unable to add station %pM\n", addr); return ret; } if (sta_id_r) *sta_id_r = sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); /* Set up default rate scaling table in device's station table */ - link_cmd = il4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(priv, + IL_ERR(il, "Unable to initialize rate scaling for station %pM.\n", addr); return -ENOMEM; } - ret = il_send_lq_cmd(priv, ctx, link_cmd, CMD_SYNC, true); + ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); if (ret) - IL_ERR(priv, "Link quality command failed (%d)\n", ret); + IL_ERR(il, "Link quality command failed (%d)\n", ret); - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -static int il4965_static_wepkey_cmd(struct il_priv *priv, +static int il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, bool send_if_empty) { @@ -178,74 +178,74 @@ static int il4965_static_wepkey_cmd(struct il_priv *priv, cmd.len = cmd_size; if (not_empty || send_if_empty) - return il_send_cmd(priv, &cmd); + return il_send_cmd(il, &cmd); else return 0; } -int il4965_restore_default_wep_keys(struct il_priv *priv, +int il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx) { - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - return il4965_static_wepkey_cmd(priv, ctx, false); + return il4965_static_wepkey_cmd(il, ctx, false); } -int il4965_remove_default_wep_key(struct il_priv *priv, +int il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - IL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", + IL_DEBUG_WEP(il, "Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); - if (il_is_rfkill(priv)) { - IL_DEBUG_WEP(priv, + if (il_is_rfkill(il)) { + IL_DEBUG_WEP(il, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } - ret = il4965_static_wepkey_cmd(priv, ctx, 1); - IL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(il, ctx, 1); + IL_DEBUG_WEP(il, "Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; } -int il4965_set_default_wep_key(struct il_priv *priv, +int il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); if (keyconf->keylen != WEP_KEY_LEN_128 && keyconf->keylen != WEP_KEY_LEN_64) { - IL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen); + IL_DEBUG_WEP(il, "Bad WEP key length %d\n", keyconf->keylen); return -EINVAL; } keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; keyconf->hw_key_idx = HW_KEY_DEFAULT; - priv->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, keyconf->keylen); - ret = il4965_static_wepkey_cmd(priv, ctx, false); - IL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(il, ctx, false); + IL_DEBUG_WEP(il, "Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, keyconf->keyidx, ret); return ret; } -static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, +static int il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -254,7 +254,7 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, __le16 key_flags = 0; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; @@ -268,40 +268,40 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, if (sta_id == ctx->bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = keyconf->keylen; - priv->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; - memcpy(priv->stations[sta_id].keyinfo.key, + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(&priv->stations[sta_id].sta.key.key[3], + memcpy(&il->stations[sta_id].sta.key.key[3], keyconf->key, keyconf->keylen); - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, +static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -310,7 +310,7 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, __le16 key_flags = 0; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); @@ -321,38 +321,38 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = keyconf->keylen; + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_tkip_dynamic_key_info(struct il_priv *priv, +static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -371,35 +371,35 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *priv, keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = 16; + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = 16; - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.key.key_flags = key_flags; /* This copy is acutally not needed: we get the key with each TX */ - memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); - memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16); + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -void il4965_update_tkip_key(struct il_priv *priv, +void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) @@ -408,34 +408,34 @@ void il4965_update_tkip_key(struct il_priv *priv, unsigned long flags; int i; - if (il_scan_cancel(priv)) { + if (il_scan_cancel(il)) { /* cancel scan failed, just live w/ bad key and rely briefly on SW decryption */ return; } - sta_id = il_sta_id_or_broadcast(priv, ctx, sta); + sta_id = il_sta_id_or_broadcast(il, ctx, sta); if (sta_id == IL_INVALID_STATION) return; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; + il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; for (i = 0; i < 5; i++) - priv->stations[sta_id].sta.key.tkip_rx_ttak[i] = + il->stations[sta_id].sta.key.tkip_rx_ttak[i] = cpu_to_le16(phase1key[i]); - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); + il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } -int il4965_remove_dynamic_key(struct il_priv *priv, +int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -445,15 +445,15 @@ int il4965_remove_dynamic_key(struct il_priv *priv, u8 keyidx; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); ctx->key_mapping_keys--; - spin_lock_irqsave(&priv->sta_lock, flags); - key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); + spin_lock_irqsave(&il->sta_lock, flags); + key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - IL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n", + IL_DEBUG_WEP(il, "Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { @@ -462,76 +462,76 @@ int il4965_remove_dynamic_key(struct il_priv *priv, * been replaced by another one with different index. * Don't do anything and return ok */ - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN(priv, "Removing wrong key %d 0x%x\n", + if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { + IL_WARN(il, "Removing wrong key %d 0x%x\n", keyconf->keyidx, key_flags); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset, - &priv->ucode_key_table)) - IL_ERR(priv, "index %d not used in uCode key table.\n", - priv->stations[sta_id].sta.key.key_offset); - memset(&priv->stations[sta_id].keyinfo, 0, + if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, + &il->ucode_key_table)) + IL_ERR(il, "index %d not used in uCode key table.\n", + il->stations[sta_id].sta.key.key_offset); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&priv->stations[sta_id].sta.key, 0, + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); - priv->stations[sta_id].sta.key.key_flags = + il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; - priv->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - if (il_is_rfkill(priv)) { - IL_DEBUG_WEP(priv, + if (il_is_rfkill(il)) { + IL_DEBUG_WEP(il, "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_set_dynamic_key(struct il_priv *priv, struct il_rxon_context *ctx, +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); ctx->key_mapping_keys++; keyconf->hw_key_idx = HW_KEY_DYNAMIC; switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = il4965_set_ccmp_dynamic_key_info(priv, ctx, + ret = il4965_set_ccmp_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = il4965_set_tkip_dynamic_key_info(priv, ctx, + ret = il4965_set_tkip_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = il4965_set_wep_dynamic_key_info(priv, ctx, + ret = il4965_set_wep_dynamic_key_info(il, ctx, keyconf, sta_id); break; default: - IL_ERR(priv, + IL_ERR(il, "Unknown alg: %s cipher = %x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IL_DEBUG_WEP(priv, + IL_DEBUG_WEP(il, "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -546,37 +546,37 @@ int il4965_set_dynamic_key(struct il_priv *priv, struct il_rxon_context *ctx, * and marks it driver active, so that it will be restored to the * device at the next best time. */ -int il4965_alloc_bcast_station(struct il_priv *priv, +int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { struct il_link_quality_cmd *link_cmd; unsigned long flags; u8 sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = il_prep_station(priv, ctx, iwlegacy_bcast_addr, + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, iwlegacy_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&priv->sta_lock, flags); + IL_ERR(il, "Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); - link_cmd = il4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(priv, + IL_ERR(il, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } @@ -587,39 +587,39 @@ int il4965_alloc_bcast_station(struct il_priv *priv, * Only used by iwl4965. Placed here to have all bcast station management * code together. */ -static int il4965_update_bcast_station(struct il_priv *priv, +static int il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { unsigned long flags; struct il_link_quality_cmd *link_cmd; u8 sta_id = ctx->bcast_sta_id; - link_cmd = il4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(priv, + IL_ERR(il, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } - spin_lock_irqsave(&priv->sta_lock, flags); - if (priv->stations[sta_id].lq) - kfree(priv->stations[sta_id].lq); + spin_lock_irqsave(&il->sta_lock, flags); + if (il->stations[sta_id].lq) + kfree(il->stations[sta_id].lq); else - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Bcast station rate scaling has not been initialized yet.\n"); - priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -int il4965_update_bcast_stations(struct il_priv *priv) +int il4965_update_bcast_stations(struct il_priv *il) { struct il_rxon_context *ctx; int ret = 0; - for_each_context(priv, ctx) { - ret = il4965_update_bcast_station(priv, ctx); + for_each_context(il, ctx) { + ret = il4965_update_bcast_station(il, ctx); if (ret) break; } @@ -630,92 +630,92 @@ int il4965_update_bcast_stations(struct il_priv *priv) /** * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table */ -int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, int sta_id, int tid) +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) { unsigned long flags; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); /* Remove "disable" flag, to enable Tx for this TID */ - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; - priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; + il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, u16 ssn) { unsigned long flags; int sta_id; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) return -ENXIO; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.station_flags_msk = 0; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; - priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; - priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; + il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, int tid) { unsigned long flags; int sta_id; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + IL_ERR(il, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.station_flags_msk = 0; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; - priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; + il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } void -il4965_sta_modify_sleep_tx_count(struct il_priv *priv, int sta_id, int cnt) +il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) { unsigned long flags; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; - priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; - priv->stations[sta_id].sta.sta.modify_mask = + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_SLEEP_TX_COUNT_MSK; - priv->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(priv, - &priv->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 3fdb9d9..59d7374 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -99,7 +99,7 @@ il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) /* * handle build REPLY_TX command notification. */ -static void il4965_tx_cmd_build_basic(struct il_priv *priv, +static void il4965_tx_cmd_build_basic(struct il_priv *il, struct sk_buff *skb, struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, @@ -137,7 +137,7 @@ static void il4965_tx_cmd_build_basic(struct il_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - il_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(il, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -156,7 +156,7 @@ static void il4965_tx_cmd_build_basic(struct il_priv *priv, #define RTS_DFAULT_RETRY_LIMIT 60 -static void il4965_tx_cmd_build_rate(struct il_priv *priv, +static void il4965_tx_cmd_build_rate(struct il_priv *il, struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, __le16 fc) @@ -197,7 +197,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *priv, rate_idx = info->control.rates[0].idx; if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || (rate_idx < 0) || (rate_idx > IL_RATE_COUNT_LEGACY)) - rate_idx = rate_lowest_index(&priv->bands[info->band], + rate_idx = rate_lowest_index(&il->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ if (info->band == IEEE80211_BAND_5GHZ) @@ -212,16 +212,16 @@ static void il4965_tx_cmd_build_rate(struct il_priv *priv, rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ - priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, - priv->hw_params.valid_tx_ant); + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); - rate_flags |= il4965_ant_idx_to_flags(priv->mgmt_tx_ant); + rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); /* Set the rate in the TX cmd */ tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); } -static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, +static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, struct il_tx_cmd *tx_cmd, struct sk_buff *skb_frag, @@ -235,13 +235,13 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); if (info->flags & IEEE80211_TX_CTL_AMPDU) tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - IL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); + IL_DEBUG_TX(il, "tx_cmd with tkip hwcrypto\n"); break; case WLAN_CIPHER_SUITE_WEP104: @@ -253,12 +253,12 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(il, "Configuring packet for WEP encryption " "with key %d\n", keyconf->keyidx); break; default: - IL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher); + IL_ERR(il, "Unknown encode cipher %x\n", keyconf->cipher); break; } } @@ -266,7 +266,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, /* * start REPLY_TX command process */ -int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -277,7 +277,7 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) struct il_device_cmd *out_cmd; struct il_cmd_meta *out_meta; struct il_tx_cmd *tx_cmd; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; int txq_id; dma_addr_t phys_addr; dma_addr_t txcmd_phys; @@ -296,9 +296,9 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) if (info->control.vif) ctx = il_rxon_ctx_from_vif(info->control.vif); - spin_lock_irqsave(&priv->lock, flags); - if (il_is_rfkill(priv)) { - IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); goto drop_unlock; } @@ -306,11 +306,11 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(il, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(il, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(il, "Sending REASSOC frame\n"); #endif hdr_len = ieee80211_hdrlen(fc); @@ -320,16 +320,16 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) sta_id = ctx->bcast_sta_id; else { /* Find index into station table for destination station */ - sta_id = il_sta_id_or_broadcast(priv, ctx, info->control.sta); + sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } - IL_DEBUG_TX(priv, "station Id %d\n", sta_id); + IL_DEBUG_TX(il, "station Id %d\n", sta_id); if (sta) sta_priv = (void *)sta->drv_priv; @@ -345,7 +345,7 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) * For now set the counter to just 1 since we do not * support uAPSD yet. */ - il4965_sta_modify_sleep_tx_count(priv, sta_id, 1); + il4965_sta_modify_sleep_tx_count(il, sta_id, 1); } /* @@ -363,17 +363,17 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) } else txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; - /* irqs already disabled/saved above when locking priv->lock */ - spin_lock(&priv->sta_lock); + /* irqs already disabled/saved above when locking il->lock */ + spin_lock(&il->sta_lock); if (ieee80211_is_data_qos(fc)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; if (WARN_ON_ONCE(tid >= MAX_TID_COUNT)) { - spin_unlock(&priv->sta_lock); + spin_unlock(&il->sta_lock); goto drop_unlock; } - seq_number = priv->stations[sta_id].tid[tid].seq_number; + seq_number = il->stations[sta_id].tid[tid].seq_number; seq_number &= IEEE80211_SCTL_SEQ; hdr->seq_ctrl = hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG); @@ -381,27 +381,27 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) seq_number += 0x10; /* aggregation is on for this */ if (info->flags & IEEE80211_TX_CTL_AMPDU && - priv->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { - txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; + il->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { + txq_id = il->stations[sta_id].tid[tid].agg.txq_id; is_agg = true; } } - txq = &priv->txq[txq_id]; + txq = &il->txq[txq_id]; q = &txq->q; if (unlikely(il_queue_space(q) < q->high_mark)) { - spin_unlock(&priv->sta_lock); + spin_unlock(&il->sta_lock); goto drop_unlock; } if (ieee80211_is_data_qos(fc)) { - priv->stations[sta_id].tid[tid].tfds_in_queue++; + il->stations[sta_id].tid[tid].tfds_in_queue++; if (!ieee80211_has_morefrags(fc)) - priv->stations[sta_id].tid[tid].seq_number = seq_number; + il->stations[sta_id].tid[tid].seq_number = seq_number; } - spin_unlock(&priv->sta_lock); + spin_unlock(&il->sta_lock); /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); @@ -434,15 +434,15 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) tx_cmd->len = cpu_to_le16(len); if (info->control.hw_key) - il4965_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); + il4965_tx_cmd_build_hwcrypto(il, info, tx_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - il4965_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); - il_dbg_log_tx_data_frame(priv, len, hdr); + il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id); + il_dbg_log_tx_data_frame(il, len, hdr); - il4965_tx_cmd_build_rate(priv, tx_cmd, info, fc); + il4965_tx_cmd_build_rate(il, tx_cmd, info, fc); - il_update_stats(priv, true, fc, len); + il_update_stats(il, true, fc, len); /* * Use the first empty entry in this queue's command buffer array * to contain the Tx command and MAC header concatenated together @@ -462,14 +462,14 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(priv->pci_dev, + txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, firstlen, PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, txcmd_phys); dma_unmap_len_set(out_meta, len, firstlen); /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0); if (!ieee80211_has_morefrags(hdr->frame_control)) { @@ -483,9 +483,9 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) * if any (802.11 null frames have no payload). */ secondlen = skb->len - hdr_len; if (secondlen > 0) { - phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen, PCI_DMA_TODEVICE); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen, 0, 0); } @@ -494,29 +494,29 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) offsetof(struct il_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ - pci_dma_sync_single_for_cpu(priv->pci_dev, txcmd_phys, + pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(il, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); /* Set up entry for this TFD in Tx byte-count array */ if (info->flags & IEEE80211_TX_CTL_AMPDU) - priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, le16_to_cpu(tx_cmd->len)); - pci_dma_sync_single_for_device(priv->pci_dev, txcmd_phys, + pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); /* Tell device the write index *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); /* * At this point the frame is "transmitted" successfully @@ -536,28 +536,28 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) atomic_inc(&sta_priv->pending_frames); if ((il_queue_space(q) < q->high_mark) && - priv->mac80211_registered) { + il->mac80211_registered) { if (wait_write_ptr) { - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); } else { - il_stop_queue(priv, txq); + il_stop_queue(il, txq); } } return 0; drop_unlock: - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return -1; } -static inline int il4965_alloc_dma_ptr(struct il_priv *priv, +static inline int il4965_alloc_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr, size_t size) { - ptr->addr = dma_alloc_coherent(&priv->pci_dev->dev, size, &ptr->dma, + ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, GFP_KERNEL); if (!ptr->addr) return -ENOMEM; @@ -565,13 +565,13 @@ static inline int il4965_alloc_dma_ptr(struct il_priv *priv, return 0; } -static inline void il4965_free_dma_ptr(struct il_priv *priv, +static inline void il4965_free_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr) { if (unlikely(!ptr->addr)) return; - dma_free_coherent(&priv->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); + dma_free_coherent(&il->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); memset(ptr, 0, sizeof(*ptr)); } @@ -580,79 +580,79 @@ static inline void il4965_free_dma_ptr(struct il_priv *priv, * * Destroy all TX DMA queues and structures */ -void il4965_hw_txq_ctx_free(struct il_priv *priv) +void il4965_hw_txq_ctx_free(struct il_priv *il) { int txq_id; /* Tx queues */ - if (priv->txq) { - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) - if (txq_id == priv->cmd_queue) - il_cmd_queue_free(priv); + if (il->txq) { + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_free(il); else - il_tx_queue_free(priv, txq_id); + il_tx_queue_free(il, txq_id); } - il4965_free_dma_ptr(priv, &priv->kw); + il4965_free_dma_ptr(il, &il->kw); - il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(il, &il->scd_bc_tbls); /* free tx queue structure */ - il_txq_mem(priv); + il_txq_mem(il); } /** * il4965_txq_ctx_alloc - allocate TX queue context * Allocate all Tx DMA structures and initialize them * - * @param priv + * @param il * @return error code */ -int il4965_txq_ctx_alloc(struct il_priv *priv) +int il4965_txq_ctx_alloc(struct il_priv *il) { int ret; int txq_id, slots_num; unsigned long flags; /* Free all tx/cmd queues and keep-warm buffer */ - il4965_hw_txq_ctx_free(priv); + il4965_hw_txq_ctx_free(il); - ret = il4965_alloc_dma_ptr(priv, &priv->scd_bc_tbls, - priv->hw_params.scd_bc_tbls_size); + ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, + il->hw_params.scd_bc_tbls_size); if (ret) { - IL_ERR(priv, "Scheduler BC Table allocation failed\n"); + IL_ERR(il, "Scheduler BC Table allocation failed\n"); goto error_bc_tbls; } /* Alloc keep-warm buffer */ - ret = il4965_alloc_dma_ptr(priv, &priv->kw, IL_KW_SIZE); + ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); if (ret) { - IL_ERR(priv, "Keep Warm allocation failed\n"); + IL_ERR(il, "Keep Warm allocation failed\n"); goto error_kw; } /* allocate tx queue structure */ - ret = il_alloc_txq_mem(priv); + ret = il_alloc_txq_mem(il); if (ret) goto error; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == priv->cmd_queue) ? + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = (txq_id == il->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = il_tx_queue_init(priv, - &priv->txq[txq_id], slots_num, + ret = il_tx_queue_init(il, + &il->txq[txq_id], slots_num, txq_id); if (ret) { - IL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(il, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -660,34 +660,34 @@ int il4965_txq_ctx_alloc(struct il_priv *priv) return ret; error: - il4965_hw_txq_ctx_free(priv); - il4965_free_dma_ptr(priv, &priv->kw); + il4965_hw_txq_ctx_free(il); + il4965_free_dma_ptr(il, &il->kw); error_kw: - il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(il, &il->scd_bc_tbls); error_bc_tbls: return ret; } -void il4965_txq_ctx_reset(struct il_priv *priv) +void il4965_txq_ctx_reset(struct il_priv *il) { int txq_id, slots_num; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Alloc and init all Tx queues, including the command queue (#4) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - slots_num = txq_id == priv->cmd_queue ? + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = txq_id == il->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - il_tx_queue_reset(priv, &priv->txq[txq_id], + il_tx_queue_reset(il, &il->txq[txq_id], slots_num, txq_id); } } @@ -695,39 +695,39 @@ void il4965_txq_ctx_reset(struct il_priv *priv) /** * il4965_txq_ctx_stop - Stop all Tx DMA channels */ -void il4965_txq_ctx_stop(struct il_priv *priv) +void il4965_txq_ctx_stop(struct il_priv *il) { int ch, txq_id; unsigned long flags; /* Turn off all Tx DMA fifos */ - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - il4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(il, 0); /* Stop each Tx DMA channel, and wait for it to be idle */ - for (ch = 0; ch < priv->hw_params.dma_chnl_num; ch++) { - il_write_direct32(priv, + for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { + il_write_direct32(il, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, + if (il_poll_direct_bit(il, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) - IL_ERR(priv, "Failing on timeout while stopping" + IL_ERR(il, "Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, - il_read_direct32(priv, + il_read_direct32(il, FH_TSSR_TX_STATUS_REG)); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - if (!priv->txq) + if (!il->txq) return; /* Unmap DMA from host system and free skb's */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) - if (txq_id == priv->cmd_queue) - il_cmd_queue_unmap(priv); + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_unmap(il); else - il_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(il, txq_id); } /* @@ -736,12 +736,12 @@ void il4965_txq_ctx_stop(struct il_priv *priv) * Should never return anything < 7, because they should already * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) */ -static int il4965_txq_ctx_activate_free(struct il_priv *priv) +static int il4965_txq_ctx_activate_free(struct il_priv *il) { int txq_id; - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) - if (!test_and_set_bit(txq_id, &priv->txq_ctx_active_msk)) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) return txq_id; return -1; } @@ -749,12 +749,12 @@ static int il4965_txq_ctx_activate_free(struct il_priv *priv) /** * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration */ -static void il4965_tx_queue_stop_scheduler(struct il_priv *priv, +static void il4965_tx_queue_stop_scheduler(struct il_priv *il, u16 txq_id) { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_write_prph(priv, + il_write_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); @@ -763,7 +763,7 @@ static void il4965_tx_queue_stop_scheduler(struct il_priv *priv, /** * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue */ -static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, +static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, u16 txq_id) { u32 tbl_dw_addr; @@ -772,17 +772,17 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; - tbl_dw_addr = priv->scd_base_addr + + tbl_dw_addr = il->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); - tbl_dw = il_read_targ_mem(priv, tbl_dw_addr); + tbl_dw = il_read_targ_mem(il, tbl_dw_addr); if (txq_id & 0x1) tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); else tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); - il_write_targ_mem(priv, tbl_dw_addr, tbl_dw); + il_write_targ_mem(il, tbl_dw_addr, tbl_dw); return 0; } @@ -793,7 +793,7 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ -static int il4965_txq_agg_enable(struct il_priv *priv, int txq_id, +static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, int tx_fifo, int sta_id, int tid, u16 ssn_idx) { unsigned long flags; @@ -802,62 +802,62 @@ static int il4965_txq_agg_enable(struct il_priv *priv, int txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(priv, + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN(il, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues - 1); + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } ra_tid = BUILD_RAxTID(sta_id, tid); /* Modify device's station table to Tx this TID */ - ret = il4965_sta_tx_modify_enable_tid(priv, sta_id, tid); + ret = il4965_sta_tx_modify_enable_tid(il, sta_id, tid); if (ret) return ret; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Stop this Tx queue before configuring it */ - il4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(il, txq_id); /* Map receiver-address / traffic-ID to this queue */ - il4965_tx_queue_set_q2ratid(priv, ra_tid, txq_id); + il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); /* Set this queue as a chain-building queue */ - il_set_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_set_bits_prph(il, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); /* Place first TFD at index corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ - priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - il4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + il4965_set_wr_ptrs(il, txq_id, ssn_idx); /* Set up Tx window size and frame limit for this queue */ - il_write_targ_mem(priv, - priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + il_write_targ_mem(il, + il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - il_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(il, il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), (SCD_FRAME_LIMIT << IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - il_set_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_set_bits_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ - il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return 0; } -int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn) { int sta_id; @@ -871,94 +871,94 @@ int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN(priv, "%s on ra = %pM tid = %d\n", + IL_WARN(il, "%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Start AGG on invalid station\n"); + IL_ERR(il, "Start AGG on invalid station\n"); return -ENXIO; } if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; - if (priv->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { - IL_ERR(priv, "Start AGG when state is not IL_AGG_OFF !\n"); + if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { + IL_ERR(il, "Start AGG when state is not IL_AGG_OFF !\n"); return -ENXIO; } - txq_id = il4965_txq_ctx_activate_free(priv); + txq_id = il4965_txq_ctx_activate_free(il); if (txq_id == -1) { - IL_ERR(priv, "No free aggregation queue available\n"); + IL_ERR(il, "No free aggregation queue available\n"); return -ENXIO; } - spin_lock_irqsave(&priv->sta_lock, flags); - tid_data = &priv->stations[sta_id].tid[tid]; + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; *ssn = SEQ_TO_SN(tid_data->seq_number); tid_data->agg.txq_id = txq_id; - il_set_swq_id(&priv->txq[txq_id], + il_set_swq_id(&il->txq[txq_id], il4965_get_ac_from_tid(tid), txq_id); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - ret = il4965_txq_agg_enable(priv, txq_id, tx_fifo, + ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, sta_id, tid, *ssn); if (ret) return ret; - spin_lock_irqsave(&priv->sta_lock, flags); - tid_data = &priv->stations[sta_id].tid[tid]; + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(priv, "HW queue is empty\n"); + IL_DEBUG_HT(il, "HW queue is empty\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - IL_DEBUG_HT(priv, + IL_DEBUG_HT(il, "HW queue is NOT empty: %d packets in HW queue\n", tid_data->tfds_in_queue); tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } /** * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE - * priv->lock must be held by the caller + * il->lock must be held by the caller */ -static int il4965_txq_agg_disable(struct il_priv *priv, u16 txq_id, +static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(priv, + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN(il, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues - 1); + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } - il4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(il, txq_id); - il_clear_bits_prph(priv, + il_clear_bits_prph(il, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); /* supposes that ssn_idx is valid (!= 0xFFF) */ - il4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il4965_set_wr_ptrs(il, txq_id, ssn_idx); - il_clear_bits_prph(priv, + il_clear_bits_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - il_txq_ctx_deactivate(priv, txq_id); - il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); + il_txq_ctx_deactivate(il, txq_id); + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); return 0; } -int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid) { int tx_fifo_id, txq_id, sta_id, ssn; @@ -973,17 +973,17 @@ int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + IL_ERR(il, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - tid_data = &priv->stations[sta_id].tid[tid]; + tid_data = &il->stations[sta_id].tid[tid]; ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; txq_id = tid_data->agg.txq_id; - switch (priv->stations[sta_id].tid[tid].agg.state) { + switch (il->stations[sta_id].tid[tid].agg.state) { case IL_EMPTYING_HW_QUEUE_ADDBA: /* * This can happen if the peer stops aggregation @@ -991,33 +991,33 @@ int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, * queue we selected previously, i.e. before the * session was really started completely. */ - IL_DEBUG_HT(priv, "AGG stop before setup done\n"); + IL_DEBUG_HT(il, "AGG stop before setup done\n"); goto turn_off; case IL_AGG_ON: break; default: - IL_WARN(priv, "Stopping AGG while state not ON or starting\n"); + IL_WARN(il, "Stopping AGG while state not ON or starting\n"); } - write_ptr = priv->txq[txq_id].q.write_ptr; - read_ptr = priv->txq[txq_id].q.read_ptr; + write_ptr = il->txq[txq_id].q.write_ptr; + read_ptr = il->txq[txq_id].q.read_ptr; /* The queue is not empty */ if (write_ptr != read_ptr) { - IL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n"); - priv->stations[sta_id].tid[tid].agg.state = + IL_DEBUG_HT(il, "Stopping a non empty AGG HW QUEUE\n"); + il->stations[sta_id].tid[tid].agg.state = IL_EMPTYING_HW_QUEUE_DELBA; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - IL_DEBUG_HT(priv, "HW queue is empty\n"); + IL_DEBUG_HT(il, "HW queue is empty\n"); turn_off: - priv->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; + il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; /* do not restore/save irqs */ - spin_unlock(&priv->sta_lock); - spin_lock(&priv->lock); + spin_unlock(&il->sta_lock); + spin_lock(&il->lock); /* * the only reason this call can fail is queue number out of range, @@ -1026,27 +1026,27 @@ int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, * to deactivate the uCode queue, just return "success" to allow * mac80211 to clean up it own data. */ - il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id); - spin_unlock_irqrestore(&priv->lock, flags); + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo_id); + spin_unlock_irqrestore(&il->lock, flags); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); return 0; } -int il4965_txq_check_empty(struct il_priv *priv, +int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id) { - struct il_queue *q = &priv->txq[txq_id].q; - u8 *addr = priv->stations[sta_id].sta.sta.addr; - struct il_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; + struct il_queue *q = &il->txq[txq_id].q; + u8 *addr = il->stations[sta_id].sta.sta.addr; + struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; struct il_rxon_context *ctx; - ctx = &priv->contexts[priv->stations[sta_id].ctxid]; + ctx = &il->contexts[il->stations[sta_id].ctxid]; - lockdep_assert_held(&priv->sta_lock); + lockdep_assert_held(&il->sta_lock); - switch (priv->stations[sta_id].tid[tid].agg.state) { + switch (il->stations[sta_id].tid[tid].agg.state) { case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ @@ -1054,9 +1054,9 @@ int il4965_txq_check_empty(struct il_priv *priv, (q->read_ptr == q->write_ptr)) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - IL_DEBUG_HT(priv, + IL_DEBUG_HT(il, "HW queue empty: continue DELBA flow\n"); - il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo); + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); tid_data->agg.state = IL_AGG_OFF; ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } @@ -1064,7 +1064,7 @@ int il4965_txq_check_empty(struct il_priv *priv, case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(priv, + IL_DEBUG_HT(il, "HW queue empty: continue ADDBA flow\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); @@ -1075,7 +1075,7 @@ int il4965_txq_check_empty(struct il_priv *priv, return 0; } -static void il4965_non_agg_tx_status(struct il_priv *priv, +static void il4965_non_agg_tx_status(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr1) { @@ -1089,33 +1089,33 @@ static void il4965_non_agg_tx_status(struct il_priv *priv, /* avoid atomic ops if this isn't a client */ if (sta_priv->client && atomic_dec_return(&sta_priv->pending_frames) == 0) - ieee80211_sta_block_awake(priv->hw, sta, false); + ieee80211_sta_block_awake(il->hw, sta, false); } rcu_read_unlock(); } static void -il4965_tx_status(struct il_priv *priv, struct il_tx_info *tx_info, +il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, bool is_agg) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; if (!is_agg) - il4965_non_agg_tx_status(priv, tx_info->ctx, hdr->addr1); + il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); - ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); } -int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; struct il_tx_info *tx_info; int nfreed = 0; struct ieee80211_hdr *hdr; if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); return 0; @@ -1134,11 +1134,11 @@ int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) if (ieee80211_is_data_qos(hdr->frame_control)) nfreed++; - il4965_tx_status(priv, tx_info, + il4965_tx_status(il, tx_info, txq_id >= IWL4965_FIRST_AMPDU_QUEUE); tx_info->skb = NULL; - priv->cfg->ops->lib->txq_free_tfd(priv, txq); + il->cfg->ops->lib->txq_free_tfd(il, txq); } return nfreed; } @@ -1149,7 +1149,7 @@ int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) * Go through block-ack's bitmap of ACK'd frames, update driver's record of * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. */ -static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, +static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct il_ht_agg *agg, struct il_compressed_ba_resp *ba_resp) @@ -1163,13 +1163,13 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) - IL_ERR(priv, "Received BA when not expected\n"); + IL_ERR(il, "Received BA when not expected\n"); return -EINVAL; } /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - IL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, + IL_DEBUG_TX_REPLY(il, "BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx window bits */ @@ -1178,7 +1178,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, sh += 0x100; if (agg->frame_count > (64 - sh)) { - IL_DEBUG_TX_REPLY(priv, "more frames than bitmap size"); + IL_DEBUG_TX_REPLY(il, "more frames than bitmap size"); return -1; } @@ -1195,7 +1195,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - IL_DEBUG_TX_REPLY(priv, "%s ON i=%d idx=%d raw=%d\n", + IL_DEBUG_TX_REPLY(il, "%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff, agg->start_idx + i); @@ -1203,16 +1203,16 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, ++i; } - IL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", + IL_DEBUG_TX_REPLY(il, "Bitmap %llx\n", (unsigned long long)bitmap); - info = IEEE80211_SKB_CB(priv->txq[scd_flow].txb[agg->start_idx].skb); + info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); memset(&info->status, 0, sizeof(info->status)); info->flags |= IEEE80211_TX_STAT_ACK; info->flags |= IEEE80211_TX_STAT_AMPDU; info->status.ampdu_ack_len = successes; info->status.ampdu_len = agg->frame_count; - il4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); + il4965_hwrate_to_tx_control(il, agg->rate_n_flags, info); return 0; } @@ -1220,7 +1220,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, /** * translate ucode response to mac80211 tx status control values */ -void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, struct ieee80211_tx_info *info) { struct ieee80211_tx_rate *r = &info->control.rates[0]; @@ -1246,7 +1246,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void il4965_rx_reply_compressed_ba(struct il_priv *priv, +void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -1265,16 +1265,16 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, * (in Tx queue's circular buffer) of first TFD/frame in window */ u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); - if (scd_flow >= priv->hw_params.max_txq_num) { - IL_ERR(priv, + if (scd_flow >= il->hw_params.max_txq_num) { + IL_ERR(il, "BUG_ON scd_flow is bigger than number of queues\n"); return; } - txq = &priv->txq[scd_flow]; + txq = &il->txq[scd_flow]; sta_id = ba_resp->sta_id; tid = ba_resp->tid; - agg = &priv->stations[sta_id].tid[tid].agg; + agg = &il->stations[sta_id].tid[tid].agg; if (unlikely(agg->txq_id != scd_flow)) { /* * FIXME: this is a uCode bug which need to be addressed, @@ -1282,7 +1282,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - IL_DEBUG_TX_REPLY(priv, + IL_DEBUG_TX_REPLY(il, "BA scd_flow %d does not match txq_id %d\n", scd_flow, agg->txq_id); return; @@ -1291,14 +1291,14 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, /* Find index just before block-ack window */ index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - IL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, " + IL_DEBUG_TX_REPLY(il, "REPLY_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); - IL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," + IL_DEBUG_TX_REPLY(il, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, @@ -1306,30 +1306,30 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, (unsigned long long)le64_to_cpu(ba_resp->bitmap), ba_resp->scd_flow, ba_resp->scd_ssn); - IL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx\n", + IL_DEBUG_TX_REPLY(il, "DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, (unsigned long long)agg->bitmap); /* Update driver's record of ACK vs. not for each frame in window */ - il4965_tx_status_reply_compressed_ba(priv, agg, ba_resp); + il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); /* Release all TFDs before the SSN, i.e. all TFDs in front of * block-ack window (we assume that they've been successfully * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ - int freed = il4965_tx_queue_reclaim(priv, scd_flow, index); - il4965_free_tfds_in_queue(priv, sta_id, tid, freed); + int freed = il4965_tx_queue_reclaim(il, scd_flow, index); + il4965_free_tfds_in_queue(il, sta_id, tid, freed); if ((il_queue_space(&txq->q) > txq->q.low_mark) && - priv->mac80211_registered && + il->mac80211_registered && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) - il_wake_queue(priv, txq); + il_wake_queue(il, txq); - il4965_txq_check_empty(priv, sta_id, tid, scd_flow); + il4965_txq_check_empty(il, sta_id, tid, scd_flow); } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 3c9df1b..d4dc597 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -48,22 +48,22 @@ * it's a pretty good bet that everything between them is good, too. */ static int -il4965_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) +il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) { u32 val; int ret = 0; u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; errcnt++; @@ -79,7 +79,7 @@ il4965_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) * il4965_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, +static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) { u32 val; @@ -87,9 +87,9 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, int ret = 0; u32 errcnt; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); errcnt = 0; @@ -97,9 +97,9 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(il, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); ret = -EIO; @@ -110,7 +110,7 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, } if (!errcnt) - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "ucode image in INSTRUCTION memory is good\n"); return ret; @@ -120,47 +120,47 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, * il4965_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -int il4965_verify_ucode(struct il_priv *priv) +int il4965_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int ret; /* Try bootstrap */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - ret = il4965_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ - image = (__le32 *)priv->ucode_init.v_addr; - len = priv->ucode_init.len; - ret = il4965_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ - image = (__le32 *)priv->ucode_code.v_addr; - len = priv->ucode_code.len; - ret = il4965_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); return 0; } - IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - ret = il4965_verify_inst_full(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_full(il, image, len); return ret; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 0f2bc5f..d3c8183 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -48,8 +48,8 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" -static int il4965_send_tx_power(struct il_priv *priv); -static int il4965_hw_get_temperature(struct il_priv *priv); +static int il4965_send_tx_power(struct il_priv *il); +static int il4965_hw_get_temperature(struct il_priv *il); /* Highest firmware API version supported */ #define IWL4965_UCODE_API_MAX 2 @@ -62,23 +62,23 @@ static int il4965_hw_get_temperature(struct il_priv *priv); #define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ -static int il4965_verify_bsm(struct il_priv *priv) +static int il4965_verify_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; u32 reg; u32 val; - IL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(il, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(priv, reg); + val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(il, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -87,7 +87,7 @@ static int il4965_verify_bsm(struct il_priv *priv) } } - IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); return 0; } @@ -124,10 +124,10 @@ static int il4965_verify_bsm(struct il_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il4965_load_bsm(struct il_priv *priv) +static int il4965_load_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; dma_addr_t pinst; dma_addr_t pdata; u32 inst_len; @@ -137,9 +137,9 @@ static int il4965_load_bsm(struct il_priv *priv) u32 reg_offset; int ret; - IL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(il, "Begin load bsm\n"); - priv->ucode_type = UCODE_RT; + il->ucode_type = UCODE_RT; /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL49_MAX_BSM_SIZE) @@ -151,53 +151,53 @@ static int il4965_load_bsm(struct il_priv *priv) * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ - pinst = priv->ucode_init.p_addr >> 4; - pdata = priv->ucode_init_data.p_addr >> 4; - inst_len = priv->ucode_init.len; - data_len = priv->ucode_init_data.len; + pinst = il->ucode_init.p_addr >> 4; + pdata = il->ucode_init_data.p_addr >> 4; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(priv, reg_offset, le32_to_cpu(*image)); + _il_write_prph(il, reg_offset, le32_to_cpu(*image)); - ret = il4965_verify_bsm(priv); + ret = il4965_verify_bsm(il); if (ret) return ret; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(priv, + il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(il, BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); - il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); else { - IL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(il, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(priv, + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); @@ -213,27 +213,27 @@ static int il4965_load_bsm(struct il_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il4965_set_ucode_ptrs(struct il_priv *priv) +static int il4965_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; int ret = 0; /* bits 35:4 for 4965 */ - pinst = priv->ucode_code.p_addr >> 4; - pdata = priv->ucode_data_backup.p_addr >> 4; + pinst = il->ucode_code.p_addr >> 4; + pdata = il->ucode_data_backup.p_addr >> 4; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, - priv->ucode_data.len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, - priv->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); + IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); return ret; } @@ -244,40 +244,40 @@ static int il4965_set_ucode_ptrs(struct il_priv *priv) * Called after REPLY_ALIVE notification received from "initialize" uCode. * * The 4965 "initialize" ALIVE reply contains calibration data for: - * Voltage, temperature, and MIMO tx gain correction, now stored in priv + * Voltage, temperature, and MIMO tx gain correction, now stored in il * (3945 does not contain this data). * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il4965_init_alive_start(struct il_priv *priv) +static void il4965_init_alive_start(struct il_priv *il) { /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(priv)) { + if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Calculate temperature */ - priv->temperature = il4965_hw_get_temperature(priv); + il->temperature = il4965_hw_get_temperature(il); /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (il4965_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + if (il4965_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); goto restart; } return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } static bool iw4965_is_ht40_channel(__le32 rxon_flags) @@ -288,43 +288,43 @@ static bool iw4965_is_ht40_channel(__le32 rxon_flags) (chan_mod == CHANNEL_MODE_MIXED)); } -static void il4965_nic_config(struct il_priv *priv) +static void il4965_nic_config(struct il_priv *il) { unsigned long flags; u16 radio_cfg; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - radio_cfg = il_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + radio_cfg = il_eeprom_query16(il, EEPROM_RADIO_CONFIG); /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | EEPROM_RF_CFG_STEP_MSK(radio_cfg) | EEPROM_RF_CFG_DASH_MSK(radio_cfg)); /* set CSR_HW_CONFIG_REG for uCode use */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - priv->calib_info = (struct il_eeprom_calib_info *) - il_eeprom_query_addr(priv, + il->calib_info = (struct il_eeprom_calib_info *) + il_eeprom_query_addr(il, EEPROM_4965_CALIB_TXPOWER_OFFSET); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); } /* Reset differential Rx gains in NIC to prepare for chain noise calibration. * Called after every association, but this runs only once! * ... once chain noise is calibrated the first time, it's good forever. */ -static void il4965_chain_noise_reset(struct il_priv *priv) +static void il4965_chain_noise_reset(struct il_priv *il) { - struct il_chain_noise_data *data = &(priv->chain_noise_data); + struct il_chain_noise_data *data = &(il->chain_noise_data); if ((data->state == IL_CHAIN_NOISE_ALIVE) && - il_is_any_associated(priv)) { + il_is_any_associated(il)) { struct il_calib_diff_gain_cmd cmd; /* clear data for chain noise calibration algorithm */ @@ -341,12 +341,12 @@ static void il4965_chain_noise_reset(struct il_priv *priv) cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd)) - IL_ERR(priv, + IL_ERR(il, "Could not send REPLY_PHY_CALIBRATION_CMD\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; - IL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); + IL_DEBUG_CALIB(il, "Run chain_noise_calibrate\n"); } } @@ -377,10 +377,10 @@ static struct il_sensitivity_ranges il4965_sensitivity = { .nrg_th_cca = 62, }; -static void il4965_set_ct_threshold(struct il_priv *priv) +static void il4965_set_ct_threshold(struct il_priv *il) { /* want Kelvin */ - priv->hw_params.ct_kill_threshold = + il->hw_params.ct_kill_threshold = CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); } @@ -389,37 +389,37 @@ static void il4965_set_ct_threshold(struct il_priv *priv) * * Called when initializing driver */ -static int il4965_hw_set_hw_params(struct il_priv *priv) +static int il4965_hw_set_hw_params(struct il_priv *il) { - if (priv->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && - priv->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) - priv->cfg->base_params->num_of_queues = - priv->cfg->mod_params->num_of_queues; - - priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; - priv->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; - priv->hw_params.scd_bc_tbls_size = - priv->cfg->base_params->num_of_queues * + if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && + il->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) + il->cfg->base_params->num_of_queues = + il->cfg->mod_params->num_of_queues; + + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; + il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; + il->hw_params.scd_bc_tbls_size = + il->cfg->base_params->num_of_queues * sizeof(struct il4965_scd_bc_tbl); - priv->hw_params.tfd_size = sizeof(struct il_tfd); - priv->hw_params.max_stations = IWL4965_STATION_COUNT; - priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; - priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; - priv->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; - priv->hw_params.max_bsm_size = BSM_SRAM_SIZE; - priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); + il->hw_params.tfd_size = sizeof(struct il_tfd); + il->hw_params.max_stations = IWL4965_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; + il->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; + il->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; + il->hw_params.max_bsm_size = BSM_SRAM_SIZE; + il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); - priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; + il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; - priv->hw_params.tx_chains_num = il4965_num_of_ant(priv->cfg->valid_tx_ant); - priv->hw_params.rx_chains_num = il4965_num_of_ant(priv->cfg->valid_rx_ant); - priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant; - priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant; + il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); + il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); + il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; + il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; - il4965_set_ct_threshold(priv); + il4965_set_ct_threshold(il); - priv->hw_params.sens = &il4965_sensitivity; - priv->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; + il->hw_params.sens = &il4965_sensitivity; + il->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; return 0; } @@ -498,16 +498,16 @@ static s32 il4965_get_tx_atten_grp(u16 channel) return -EINVAL; } -static u32 il4965_get_sub_band(const struct il_priv *priv, u32 channel) +static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) { s32 b = -1; for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { - if (priv->calib_info->band_info[b].ch_from == 0) + if (il->calib_info->band_info[b].ch_from == 0) continue; - if ((channel >= priv->calib_info->band_info[b].ch_from) - && (channel <= priv->calib_info->band_info[b].ch_to)) + if ((channel >= il->calib_info->band_info[b].ch_from) + && (channel <= il->calib_info->band_info[b].ch_to)) break; } @@ -534,7 +534,7 @@ static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) * differences in channel frequencies, which is proportional to differences * in channel number. */ -static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, +static int il4965_interpolate_chan(struct il_priv *il, u32 channel, struct il_eeprom_calib_ch_info *chan_info) { s32 s = -1; @@ -546,24 +546,24 @@ static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, u32 ch_i1; u32 ch_i2; - s = il4965_get_sub_band(priv, channel); + s = il4965_get_sub_band(il, channel); if (s >= EEPROM_TX_POWER_BANDS) { - IL_ERR(priv, "Tx Power can not find channel %d\n", channel); + IL_ERR(il, "Tx Power can not find channel %d\n", channel); return -1; } - ch_i1 = priv->calib_info->band_info[s].ch1.ch_num; - ch_i2 = priv->calib_info->band_info[s].ch2.ch_num; + ch_i1 = il->calib_info->band_info[s].ch1.ch_num; + ch_i2 = il->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - IL_DEBUG_TXPOWER(priv, "channel %d subband %d factory cal ch %d & %d\n", + IL_DEBUG_TXPOWER(il, "channel %d subband %d factory cal ch %d & %d\n", channel, s, ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { - m1 = &(priv->calib_info->band_info[s].ch1. + m1 = &(il->calib_info->band_info[s].ch1. measurements[c][m]); - m2 = &(priv->calib_info->band_info[s].ch2. + m2 = &(il->calib_info->band_info[s].ch2. measurements[c][m]); omeas = &(chan_info->measurements[c][m]); @@ -586,16 +586,16 @@ static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, m1->pa_det, ch_i2, m2->pa_det); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, m1->actual_pow, m2->actual_pow, omeas->actual_pow); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, m1->gain_idx, m2->gain_idx, omeas->gain_idx); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, m1->pa_det, m2->pa_det, omeas->pa_det); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, m1->temperature, m2->temperature, omeas->temperature); @@ -867,7 +867,7 @@ static const struct gain_entry gain_table[2][108] = { } }; -static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, +static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40, u8 ctrl_chan_high, struct il4965_tx_power_db *tx_power_tbl) { @@ -897,13 +897,13 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units * are used for indexing into txpower table) */ - user_target_power = 2 * priv->tx_power_user_lmt; + user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - IL_DEBUG_TXPOWER(priv, "chan %d band %d is_ht40 %d\n", channel, band, + IL_DEBUG_TXPOWER(il, "chan %d band %d is_ht40 %d\n", channel, band, is_ht40); - ch_info = il_get_channel_info(priv, priv->band, channel); + ch_info = il_get_channel_info(il, il->band, channel); if (!il_is_channel_valid(ch_info)) return -EINVAL; @@ -912,12 +912,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, * and 2) mimo txpower balance between Tx chains. */ txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IL_ERR(priv, "Can't find txatten group for channel %d.\n", + IL_ERR(il, "Can't find txatten group for channel %d.\n", channel); return txatten_grp; } - IL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n", + IL_DEBUG_TXPOWER(il, "channel %d belongs to txatten group %d\n", channel, txatten_grp); if (is_ht40) { @@ -930,9 +930,9 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* hardware txpower limits ... * saturation (clipping distortion) txpowers are in half-dBm */ if (band) - saturation_power = priv->calib_info->saturation_power24; + saturation_power = il->calib_info->saturation_power24; else - saturation_power = priv->calib_info->saturation_power52; + saturation_power = il->calib_info->saturation_power52; if (saturation_power < IL_TX_POWER_SATURATION_MIN || saturation_power > IL_TX_POWER_SATURATION_MAX) { @@ -959,21 +959,21 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* Interpolate txpower calibration values for this channel, * based on factory calibration tests on spaced channels. */ - il4965_interpolate_chan(priv, channel, &ch_eeprom_info); + il4965_interpolate_chan(il, channel, &ch_eeprom_info); /* calculate tx gain adjustment based on power supply voltage */ - voltage = le16_to_cpu(priv->calib_info->voltage); - init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage); + voltage = le16_to_cpu(il->calib_info->voltage); + init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); voltage_compensation = il4965_get_voltage_compensation(voltage, init_voltage); - IL_DEBUG_TXPOWER(priv, "curr volt %d eeprom volt %d volt comp %d\n", + IL_DEBUG_TXPOWER(il, "curr volt %d eeprom volt %d volt comp %d\n", init_voltage, voltage, voltage_compensation); /* get current temperature (Celsius) */ - current_temp = max(priv->temperature, IL_TX_POWER_TEMPERATURE_MIN); - current_temp = min(priv->temperature, IL_TX_POWER_TEMPERATURE_MAX); + current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); + current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); current_temp = KELVIN_TO_CELSIUS(current_temp); /* select thermal txpower adjustment params, based on channel group @@ -998,13 +998,13 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, factory_gain_index[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; - IL_DEBUG_TXPOWER(priv, "chain = %d\n", c); - IL_DEBUG_TXPOWER(priv, "fctry tmp %d, " + IL_DEBUG_TXPOWER(il, "chain = %d\n", c); + IL_DEBUG_TXPOWER(il, "fctry tmp %d, " "curr tmp %d, comp %d steps\n", factory_temp, current_temp, temperature_comp[c]); - IL_DEBUG_TXPOWER(priv, "fctry idx %d, fctry pwr %d\n", + IL_DEBUG_TXPOWER(il, "fctry idx %d, fctry pwr %d\n", factory_gain_index[c], factory_actual_pwr[c]); } @@ -1037,7 +1037,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - IL_DEBUG_TXPOWER(priv, "rate %d sat %d reg %d usr %d tgt %d\n", + IL_DEBUG_TXPOWER(il, "rate %d sat %d reg %d usr %d tgt %d\n", i, saturation_power - back_off_table[i], current_regulatory, user_target_power, target_power); @@ -1048,7 +1048,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, if (is_mimo_rate) atten_value = - (s32)le32_to_cpu(priv->card_alive_init. + (s32)le32_to_cpu(il->card_alive_init. tx_atten[txatten_grp][c]); else atten_value = 0; @@ -1061,7 +1061,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, voltage_compensation + atten_value); -/* IL_DEBUG_TXPOWER(priv, "calculated txpower index %d\n", +/* IL_DEBUG_TXPOWER(il, "calculated txpower index %d\n", power_index); */ if (power_index < get_min_power_index(i, band)) @@ -1078,12 +1078,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* stay within the table! */ if (power_index > 107) { - IL_WARN(priv, "txpower index %d > 107\n", + IL_WARN(il, "txpower index %d > 107\n", power_index); power_index = 107; } if (power_index < 0) { - IL_WARN(priv, "txpower index %d < 0\n", + IL_WARN(il, "txpower index %d < 0\n", power_index); power_index = 0; } @@ -1094,7 +1094,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, tx_power.s.dsp_predis_atten[c] = gain_table[band][power_index].dsp; - IL_DEBUG_TXPOWER(priv, "chain %d mimo %d index %d " + IL_DEBUG_TXPOWER(il, "chain %d mimo %d index %d " "gain 0x%02x dsp %d\n", c, atten_value, power_index, tx_power.s.radio_tx_gain[c], @@ -1112,22 +1112,22 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, * il4965_send_tx_power - Configure the TXPOWER level user limit * * Uses the active RXON for channel, band, and characteristics (ht40, high) - * The power limit is taken from priv->tx_power_user_lmt. + * The power limit is taken from il->tx_power_user_lmt. */ -static int il4965_send_tx_power(struct il_priv *priv) +static int il4965_send_tx_power(struct il_priv *il) { struct il4965_txpowertable_cmd cmd = { 0 }; int ret; u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status), + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; - band = priv->band == IEEE80211_BAND_2GHZ; + band = il->band == IEEE80211_BAND_2GHZ; is_ht40 = iw4965_is_ht40_channel(ctx->active.flags); @@ -1137,20 +1137,20 @@ static int il4965_send_tx_power(struct il_priv *priv) cmd.band = band; cmd.channel = ctx->active.channel; - ret = il4965_fill_txpower_tbl(priv, band, + ret = il4965_fill_txpower_tbl(il, band, le16_to_cpu(ctx->active.channel), is_ht40, ctrl_chan_high, &cmd.tx_power); if (ret) goto out; - ret = il_send_cmd_pdu(priv, + ret = il_send_cmd_pdu(il, REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd); out: return ret; } -static int il4965_send_rxon_assoc(struct il_priv *priv, +static int il4965_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int ret = 0; @@ -1167,7 +1167,7 @@ static int il4965_send_rxon_assoc(struct il_priv *priv, rxon2->ofdm_ht_dual_stream_basic_rates) && (rxon1->rx_chain == rxon2->rx_chain) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1182,13 +1182,13 @@ static int il4965_send_rxon_assoc(struct il_priv *priv, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = il_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, + ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, sizeof(rxon_assoc), &rxon_assoc, NULL); return ret; } -static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) +static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il_rxon_cmd *active_rxon = (void *)&ctx->active; @@ -1196,7 +1196,7 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EBUSY; if (!ctx->is_active) @@ -1205,9 +1205,9 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) /* always get timestamp with Rx frame */ ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; - ret = il_check_rxon_cmd(priv, ctx); + ret = il_check_rxon_cmd(il, ctx); if (ret) { - IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1215,30 +1215,30 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * receive commit_rxon request * abort any previous channel switch if still in process */ - if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status) && - (priv->switch_channel != ctx->staging.channel)) { - IL_DEBUG_11H(priv, "abort channel switch on %d\n", - le16_to_cpu(priv->switch_channel)); - il_chswitch_done(priv, false); + if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && + (il->switch_channel != ctx->staging.channel)) { + IL_DEBUG_11H(il, "abort channel switch on %d\n", + le16_to_cpu(il->switch_channel)); + il_chswitch_done(il, false); } /* If we don't need to send a full RXON, we can use * il_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(priv, ctx)) { - ret = il_send_rxon_assoc(priv, ctx); + if (!il_full_rxon_required(il, ctx)) { + ret = il_send_rxon_assoc(il, ctx); if (ret) { - IL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); + IL_ERR(il, "Error setting RXON_ASSOC (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(il, ctx); /* * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - il_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(il, il->tx_power_next, false); return 0; } @@ -1247,10 +1247,10 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * we must clear the associated from the active configuration * before we apply the new config */ if (il_is_associated_ctx(ctx) && new_assoc) { - IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), active_rxon); @@ -1258,19 +1258,19 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * active_rxon back to what it was previously */ if (ret) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); + IL_ERR(il, "Error clearing ASSOC_MSK (%d)\n", ret); return ret; } - il_clear_ucode_stations(priv, ctx); - il_restore_stations(priv, ctx); - ret = il4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); return ret; } } - IL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(il, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1278,62 +1278,62 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) le16_to_cpu(ctx->staging.channel), ctx->staging.bssid_addr); - il_set_rxon_hwcrypto(priv, ctx, - !priv->cfg->mod_params->sw_crypto); + il_set_rxon_hwcrypto(il, ctx, + !il->cfg->mod_params->sw_crypto); /* Apply the new configuration * RXON unassoc clears the station table in uCode so restoration of * stations is needed after it (the RXON command) completes */ if (!new_assoc) { - ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(il, "Error setting new RXON (%d)\n", ret); return ret; } - IL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); + IL_DEBUG_INFO(il, "Return from !new_assoc RXON.\n"); memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_clear_ucode_stations(priv, ctx); - il_restore_stations(priv, ctx); - ret = il4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); return ret; } } if (new_assoc) { - priv->start_calib = 0; + il->start_calib = 0; /* Apply the new configuration * RXON assoc doesn't clear the station table in uCode, */ - ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(il, "Error setting new RXON (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); } - il_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(il, ctx); - il4965_init_sensitivity(priv); + il4965_init_sensitivity(il); /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - ret = il_set_tx_power(priv, priv->tx_power_next, true); + ret = il_set_tx_power(il, il->tx_power_next, true); if (ret) { - IL_ERR(priv, "Error sending TX power (%d)\n", ret); + IL_ERR(il, "Error sending TX power (%d)\n", ret); return ret; } return 0; } -static int il4965_hw_channel_switch(struct il_priv *priv, +static int il4965_hw_channel_switch(struct il_priv *il, struct ieee80211_channel_switch *ch_switch) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; int rc; u8 band = 0; bool is_ht40 = false; @@ -1346,7 +1346,7 @@ static int il4965_hw_channel_switch(struct il_priv *priv, u8 switch_count; u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval); struct ieee80211_vif *vif = ctx->vif; - band = priv->band == IEEE80211_BAND_2GHZ; + band = il->band == IEEE80211_BAND_2GHZ; is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); @@ -1366,57 +1366,57 @@ static int il4965_hw_channel_switch(struct il_priv *priv, * calculate the ucode channel switch time * adding TSF as one of the factor for when to switch */ - if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) { - if (switch_count > ((priv->ucode_beacon_time - tsf_low) / + if ((il->ucode_beacon_time > tsf_low) && beacon_interval) { + if (switch_count > ((il->ucode_beacon_time - tsf_low) / beacon_interval)) { - switch_count -= (priv->ucode_beacon_time - + switch_count -= (il->ucode_beacon_time - tsf_low) / beacon_interval; } else switch_count = 0; } if (switch_count <= 1) - cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time); + cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); else { switch_time_in_usec = vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = il_usecs_to_beacons(priv, + ucode_switch_time = il_usecs_to_beacons(il, switch_time_in_usec, beacon_interval); - cmd.switch_time = il_add_beacon_time(priv, - priv->ucode_beacon_time, + cmd.switch_time = il_add_beacon_time(il, + il->ucode_beacon_time, ucode_switch_time, beacon_interval); } - IL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n", + IL_DEBUG_11H(il, "uCode time for the switch is 0x%x\n", cmd.switch_time); - ch_info = il_get_channel_info(priv, priv->band, ch); + ch_info = il_get_channel_info(il, il->band, ch); if (ch_info) cmd.expect_beacon = il_is_channel_radar(ch_info); else { - IL_ERR(priv, "invalid channel switch from %u to %u\n", + IL_ERR(il, "invalid channel switch from %u to %u\n", ctx->active.channel, ch); return -EFAULT; } - rc = il4965_fill_txpower_tbl(priv, band, ch, is_ht40, + rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, ctrl_chan_high, &cmd.tx_power); if (rc) { - IL_DEBUG_11H(priv, "error:%d fill txpower_tbl\n", rc); + IL_DEBUG_11H(il, "error:%d fill txpower_tbl\n", rc); return rc; } - return il_send_cmd_pdu(priv, + return il_send_cmd_pdu(il, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array */ -static void il4965_txq_update_byte_cnt_tbl(struct il_priv *priv, +static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, struct il_tx_queue *txq, u16 byte_cnt) { - struct il4965_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr; + struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; int txq_id = txq->q.id; int write_ptr = txq->q.write_ptr; int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; @@ -1440,27 +1440,27 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *priv, * * A return of <0 indicates bogus data in the statistics */ -static int il4965_hw_get_temperature(struct il_priv *priv) +static int il4965_hw_get_temperature(struct il_priv *il) { s32 temperature; s32 vt; s32 R1, R2, R3; u32 R4; - if (test_bit(STATUS_TEMPERATURE, &priv->status) && - (priv->_4965.statistics.flag & + if (test_bit(STATUS_TEMPERATURE, &il->status) && + (il->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - IL_DEBUG_TEMP(priv, "Running HT40 temperature calibration\n"); - R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[1]); - R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[1]); - R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[1]); - R4 = le32_to_cpu(priv->card_alive_init.therm_r4[1]); + IL_DEBUG_TEMP(il, "Running HT40 temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); } else { - IL_DEBUG_TEMP(priv, "Running temperature calibration\n"); - R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[0]); - R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[0]); - R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[0]); - R4 = le32_to_cpu(priv->card_alive_init.therm_r4[0]); + IL_DEBUG_TEMP(il, "Running temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); } /* @@ -1470,16 +1470,16 @@ static int il4965_hw_get_temperature(struct il_priv *priv) * with an updated temperature, use R4 provided to us in the * "initialize" ALIVE response. */ - if (!test_bit(STATUS_TEMPERATURE, &priv->status)) + if (!test_bit(STATUS_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else - vt = sign_extend32(le32_to_cpu(priv->_4965.statistics. + vt = sign_extend32(le32_to_cpu(il->_4965.statistics. general.common.temperature), 23); - IL_DEBUG_TEMP(priv, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + IL_DEBUG_TEMP(il, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { - IL_ERR(priv, "Calibration conflict R1 == R3\n"); + IL_ERR(il, "Calibration conflict R1 == R3\n"); return -1; } @@ -1489,7 +1489,7 @@ static int il4965_hw_get_temperature(struct il_priv *priv) temperature /= (R3 - R1); temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - IL_DEBUG_TEMP(priv, "Calibrated temperature: %dK, %dC\n", + IL_DEBUG_TEMP(il, "Calibrated temperature: %dK, %dC\n", temperature, KELVIN_TO_CELSIUS(temperature)); return temperature; @@ -1504,66 +1504,66 @@ static int il4965_hw_get_temperature(struct il_priv *priv) * If the temperature changed has changed sufficiently, then a recalibration * is needed. * - * Assumes caller will replace priv->last_temperature once calibration + * Assumes caller will replace il->last_temperature once calibration * executed. */ -static int il4965_is_temp_calib_needed(struct il_priv *priv) +static int il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - if (!test_bit(STATUS_STATISTICS, &priv->status)) { - IL_DEBUG_TEMP(priv, "Temperature not updated -- no statistics.\n"); + if (!test_bit(STATUS_STATISTICS, &il->status)) { + IL_DEBUG_TEMP(il, "Temperature not updated -- no statistics.\n"); return 0; } - temp_diff = priv->temperature - priv->last_temperature; + temp_diff = il->temperature - il->last_temperature; /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(priv, "Getting cooler, delta %d\n", temp_diff); + IL_DEBUG_POWER(il, "Getting cooler, delta %d\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(priv, "Temperature unchanged\n"); + IL_DEBUG_POWER(il, "Temperature unchanged\n"); else - IL_DEBUG_POWER(priv, "Getting warmer, delta %d\n", temp_diff); + IL_DEBUG_POWER(il, "Getting warmer, delta %d\n", temp_diff); if (temp_diff < IL_TEMPERATURE_THRESHOLD) { - IL_DEBUG_POWER(priv, " => thermal txpower calib not needed\n"); + IL_DEBUG_POWER(il, " => thermal txpower calib not needed\n"); return 0; } - IL_DEBUG_POWER(priv, " => thermal txpower calib needed\n"); + IL_DEBUG_POWER(il, " => thermal txpower calib needed\n"); return 1; } -static void il4965_temperature_calib(struct il_priv *priv) +static void il4965_temperature_calib(struct il_priv *il) { s32 temp; - temp = il4965_hw_get_temperature(priv); + temp = il4965_hw_get_temperature(il); if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) return; - if (priv->temperature != temp) { - if (priv->temperature) - IL_DEBUG_TEMP(priv, "Temperature changed " + if (il->temperature != temp) { + if (il->temperature) + IL_DEBUG_TEMP(il, "Temperature changed " "from %dC to %dC\n", - KELVIN_TO_CELSIUS(priv->temperature), + KELVIN_TO_CELSIUS(il->temperature), KELVIN_TO_CELSIUS(temp)); else - IL_DEBUG_TEMP(priv, "Temperature " + IL_DEBUG_TEMP(il, "Temperature " "initialized to %dC\n", KELVIN_TO_CELSIUS(temp)); } - priv->temperature = temp; - set_bit(STATUS_TEMPERATURE, &priv->status); + il->temperature = temp; + set_bit(STATUS_TEMPERATURE, &il->status); - if (!priv->disable_tx_power_cal && - unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && - il4965_is_temp_calib_needed(priv)) - queue_work(priv->workqueue, &priv->txpower_work); + if (!il->disable_tx_power_cal && + unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + il4965_is_temp_calib_needed(il)) + queue_work(il->workqueue, &il->txpower_work); } static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) @@ -1604,7 +1604,7 @@ static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) /** * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ -static int il4965_tx_status_reply_tx(struct il_priv *priv, +static int il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, struct il4965_tx_resp *tx_resp, int txq_id, u16 start_idx) @@ -1617,7 +1617,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, int i, sh, idx; u16 seq; if (agg->wait_for_ba) - IL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n"); + IL_DEBUG_TX_REPLY(il, "got tx response w/o block-ack\n"); agg->frame_count = tx_resp->frame_count; agg->start_idx = start_idx; @@ -1630,18 +1630,18 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, status = le16_to_cpu(frame_status[0].status); idx = start_idx; - IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n", + IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, StartIdx=%d idx=%d\n", agg->frame_count, agg->start_idx, idx); - info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb); + info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags &= ~IEEE80211_TX_CTL_AMPDU; info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(priv, rate_n_flags, info); + il4965_hwrate_to_tx_control(il, rate_n_flags, info); - IL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n", + IL_DEBUG_TX_REPLY(il, "1 Frame 0x%x failure :%d\n", status & 0xff, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags); + IL_DEBUG_TX_REPLY(il, "Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; } else { @@ -1661,12 +1661,12 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, AGG_TX_STATE_ABORT_MSK)) continue; - IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n", + IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, txq_id=%d idx=%d\n", agg->frame_count, txq_id, idx); - hdr = il_tx_queue_get_hdr(priv, txq_id, idx); + hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (!hdr) { - IL_ERR(priv, + IL_ERR(il, "BUG_ON idx doesn't point to valid skb" " idx=%d, txq_id=%d\n", idx, txq_id); return -1; @@ -1674,14 +1674,14 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR(priv, + IL_ERR(il, "BUG_ON idx doesn't match seq control" " idx=%d, seq_idx=%d, seq=%d\n", idx, SEQ_TO_SN(sc), hdr->seq_ctrl); return -1; } - IL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n", + IL_DEBUG_TX_REPLY(il, "AGG Frame i=%d idx %d seq=%d\n", i, idx, SEQ_TO_SN(sc)); sh = idx - start; @@ -1699,13 +1699,13 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, sh = 0; } bitmap |= 1ULL << sh; - IL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(il, "start=%d bitmap=0x%llx\n", start, (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; - IL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(il, "Frames %d start_idx=%d bitmap=0x%llx\n", agg->frame_count, agg->start_idx, (unsigned long long)agg->bitmap); @@ -1715,30 +1715,30 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, return 0; } -static u8 il4965_find_station(struct il_priv *priv, const u8 *addr) +static u8 il4965_find_station(struct il_priv *il, const u8 *addr) { int i; int start = 0; int ret = IL_INVALID_STATION; unsigned long flags; - if ((priv->iw_mode == NL80211_IFTYPE_ADHOC)) + if ((il->iw_mode == NL80211_IFTYPE_ADHOC)) start = IL_STA_ID; if (is_broadcast_ether_addr(addr)) - return priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + return il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - for (i = start; i < priv->hw_params.max_stations; i++) - if (priv->stations[i].used && - (!compare_ether_addr(priv->stations[i].sta.sta.addr, + spin_lock_irqsave(&il->sta_lock, flags); + for (i = start; i < il->hw_params.max_stations; i++) + if (il->stations[i].used && + (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) { ret = i; goto out; } - IL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n", - addr, priv->num_stations); + IL_DEBUG_ASSOC_LIMIT(il, "can not find STA %pM total %d\n", + addr, il->num_stations); out: /* @@ -1747,38 +1747,38 @@ static u8 il4965_find_station(struct il_priv *priv, const u8 *addr) * station */ if (ret != IL_INVALID_STATION && - (!(priv->stations[ret].used & IL_STA_UCODE_ACTIVE) || - ((priv->stations[ret].used & IL_STA_UCODE_ACTIVE) && - (priv->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { - IL_ERR(priv, "Requested station info for sta %d before ready.\n", + (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || + ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && + (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { + IL_ERR(il, "Requested station info for sta %d before ready.\n", ret); ret = IL_INVALID_STATION; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il4965_get_ra_sta_id(struct il_priv *priv, struct ieee80211_hdr *hdr) +static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) { - if (priv->iw_mode == NL80211_IFTYPE_STATION) { + if (il->iw_mode == NL80211_IFTYPE_STATION) { return IL_AP_ID; } else { u8 *da = ieee80211_get_DA(hdr); - return il4965_find_station(priv, da); + return il4965_find_station(il, da); } } /** * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response */ -static void il4965_rx_reply_tx(struct il_priv *priv, +static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; @@ -1790,7 +1790,7 @@ static void il4965_rx_reply_tx(struct il_priv *priv, unsigned long flags; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -1801,27 +1801,27 @@ static void il4965_rx_reply_tx(struct il_priv *priv, info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); memset(&info->status, 0, sizeof(info->status)); - hdr = il_tx_queue_get_hdr(priv, txq_id, index); + hdr = il_tx_queue_get_hdr(il, txq_id, index); if (ieee80211_is_data_qos(hdr->frame_control)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; } - sta_id = il4965_get_ra_sta_id(priv, hdr); + sta_id = il4965_get_ra_sta_id(il, hdr); if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { - IL_ERR(priv, "Station not known\n"); + IL_ERR(il, "Station not known\n"); return; } - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); if (txq->sched_retry) { const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); struct il_ht_agg *agg = NULL; WARN_ON(!qc); - agg = &priv->stations[sta_id].tid[tid].agg; + agg = &il->stations[sta_id].tid[tid].agg; - il4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); + il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, index); /* check if BAR is needed */ if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) @@ -1830,51 +1830,51 @@ static void il4965_rx_reply_tx(struct il_priv *priv, if (txq->q.read_ptr != (scd_ssn & 0xff)) { index = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); - IL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn " + IL_DEBUG_TX_REPLY(il, "Retry scheduler reclaim scd_ssn " "%d index %d\n", scd_ssn , index); - freed = il4965_tx_queue_reclaim(priv, txq_id, index); + freed = il4965_tx_queue_reclaim(il, txq_id, index); if (qc) - il4965_free_tfds_in_queue(priv, sta_id, + il4965_free_tfds_in_queue(il, sta_id, tid, freed); - if (priv->mac80211_registered && + if (il->mac80211_registered && (il_queue_space(&txq->q) > txq->q.low_mark) && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) - il_wake_queue(priv, txq); + il_wake_queue(il, txq); } } else { info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(priv, + il4965_hwrate_to_tx_control(il, le32_to_cpu(tx_resp->rate_n_flags), info); - IL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " + IL_DEBUG_TX_REPLY(il, "TXQ %d status %s (0x%08x) " "rate_n_flags 0x%x retries %d\n", txq_id, il4965_get_tx_fail_reason(status), status, le32_to_cpu(tx_resp->rate_n_flags), tx_resp->failure_frame); - freed = il4965_tx_queue_reclaim(priv, txq_id, index); + freed = il4965_tx_queue_reclaim(il, txq_id, index); if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_free_tfds_in_queue(priv, sta_id, tid, freed); + il4965_free_tfds_in_queue(il, sta_id, tid, freed); else if (sta_id == IL_INVALID_STATION) - IL_DEBUG_TX_REPLY(priv, "Station not known\n"); + IL_DEBUG_TX_REPLY(il, "Station not known\n"); - if (priv->mac80211_registered && + if (il->mac80211_registered && (il_queue_space(&txq->q) > txq->q.low_mark)) - il_wake_queue(priv, txq); + il_wake_queue(il, txq); } if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_txq_check_empty(priv, sta_id, tid, txq_id); + il4965_txq_check_empty(il, sta_id, tid, txq_id); - il4965_check_abort_status(priv, tx_resp->frame_count, status); + il4965_check_abort_status(il, tx_resp->frame_count, status); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } -static void il4965_rx_beacon_notif(struct il_priv *priv, +static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -1882,7 +1882,7 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, u8 rate __maybe_unused = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d " + IL_DEBUG_RX(il, "beacon status %#x, retries:%d ibssmgr:%d " "tsf:0x%.8x%.8x rate:%d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1890,17 +1890,17 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); - priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } /* Set up 4965-specific Rx frame reply handlers */ -static void il4965_rx_handler_setup(struct il_priv *priv) +static void il4965_rx_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - priv->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; + il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; /* Tx response */ - priv->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; - priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; } static struct il_hcmd_ops il4965_hcmd = { @@ -1909,53 +1909,53 @@ static struct il_hcmd_ops il4965_hcmd = { .set_rxon_chain = il4965_set_rxon_chain, }; -static void il4965_post_scan(struct il_priv *priv) +static void il4965_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } -static void il4965_post_associate(struct il_priv *priv) +static void il4965_post_associate(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; struct ieee80211_conf *conf = NULL; int ret = 0; - if (!vif || !priv->is_open) + if (!vif || !il->is_open) return; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(il->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); - ret = il_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(priv, "RXON timing - " + IL_WARN(il, "RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il_set_rxon_ht(priv, &priv->current_ht_config); + il_set_rxon_ht(il, &il->current_ht_config); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", vif->bss_conf.aid, vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) @@ -1970,19 +1970,19 @@ static void il4965_post_associate(struct il_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); - IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", vif->bss_conf.aid, ctx->active.bssid_addr); switch (vif->type) { case NL80211_IFTYPE_STATION: break; case NL80211_IFTYPE_ADHOC: - il4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(il); break; default: - IL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(il, "%s Should not be called in %d mode\n", __func__, vif->type); break; } @@ -1990,23 +1990,23 @@ static void il4965_post_associate(struct il_priv *priv) /* the chain noise calibration will enabled PM upon completion * If chain noise has already been run, then we need to enable * power management here */ - if (priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE) - il_power_update_mode(priv, false); + if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE) + il_power_update_mode(il, false); /* Enable Rx differential gain and sensitivity calibrations */ - il4965_chain_noise_reset(priv); - priv->start_calib = 1; + il4965_chain_noise_reset(il); + il->start_calib = 1; } -static void il4965_config_ap(struct il_priv *priv) +static void il4965_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int ret = 0; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ @@ -2014,20 +2014,20 @@ static void il4965_config_ap(struct il_priv *priv) /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); /* RXON Timing */ - ret = il_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(priv, "RXON timing failed - " + IL_WARN(il, "RXON timing failed - " "Attempting to continue.\n"); /* AP has all antennas */ - priv->chain_noise_data.active_chains = - priv->hw_params.valid_rx_ant; - il_set_rxon_ht(priv, &priv->current_ht_config); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + il->chain_noise_data.active_chains = + il->hw_params.valid_rx_ant; + il_set_rxon_ht(il, &il->current_ht_config); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); ctx->staging.assoc_id = 0; @@ -2047,12 +2047,12 @@ static void il4965_config_ap(struct il_priv *priv) ~RXON_FLG_SHORT_SLOT_MSK; } /* need to send beacon cmd before committing assoc RXON! */ - il4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(il); /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } - il4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(il); } static struct il_hcmd_utils_ops il4965_hcmd_utils = { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 7b32216..ea2a98e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -73,75 +73,75 @@ extern struct il_mod_params il4965_mod_params; extern struct ieee80211_ops il4965_hw_ops; /* tx queue */ -void il4965_free_tfds_in_queue(struct il_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, int freed); /* RXON */ -void il4965_set_rxon_chain(struct il_priv *priv, +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx); /* uCode */ -int il4965_verify_ucode(struct il_priv *priv); +int il4965_verify_ucode(struct il_priv *il); /* lib */ -void il4965_check_abort_status(struct il_priv *priv, +void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status); -void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); -int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq); -int il4965_hw_nic_init(struct il_priv *priv); -int il4965_dump_fh(struct il_priv *priv, char **buf, bool display); +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_hw_nic_init(struct il_priv *il); +int il4965_dump_fh(struct il_priv *il, char **buf, bool display); /* rx */ -void il4965_rx_queue_restock(struct il_priv *priv); -void il4965_rx_replenish(struct il_priv *priv); -void il4965_rx_replenish_now(struct il_priv *priv); -void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq); -int il4965_rxq_stop(struct il_priv *priv); +void il4965_rx_queue_restock(struct il_priv *il); +void il4965_rx_replenish(struct il_priv *il); +void il4965_rx_replenish_now(struct il_priv *il); +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_rx_reply_rx(struct il_priv *priv, +void il4965_rx_reply_rx(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il4965_rx_reply_rx_phy(struct il_priv *priv, +void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il4965_rx_handle(struct il_priv *priv); +void il4965_rx_handle(struct il_priv *il); /* tx */ -void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq); -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -int il4965_hw_tx_queue_init(struct il_priv *priv, +int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); -void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, struct ieee80211_tx_info *info); -int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb); -int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn); -int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); -int il4965_txq_check_empty(struct il_priv *priv, +int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); -void il4965_rx_reply_compressed_ba(struct il_priv *priv, +void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_mem_buffer *rxb); -int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index); -void il4965_hw_txq_ctx_free(struct il_priv *priv); -int il4965_txq_ctx_alloc(struct il_priv *priv); -void il4965_txq_ctx_reset(struct il_priv *priv); -void il4965_txq_ctx_stop(struct il_priv *priv); -void il4965_txq_set_sched(struct il_priv *priv, u32 mask); +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index); +void il4965_hw_txq_ctx_free(struct il_priv *il); +int il4965_txq_ctx_alloc(struct il_priv *il); +void il4965_txq_ctx_reset(struct il_priv *il); +void il4965_txq_ctx_stop(struct il_priv *il); +void il4965_txq_set_sched(struct il_priv *il, u32 mask); /* - * Acquire priv->lock before calling this function ! + * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index); +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index); /** * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed * @scd_retry: (1) Indicates queue will be used in aggregation mode * - * NOTE: Acquire priv->lock before calling this function ! + * NOTE: Acquire il->lock before calling this function ! */ -void il4965_tx_queue_set_status(struct il_priv *priv, +void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, int tx_fifo_id, int scd_retry); @@ -167,27 +167,27 @@ static inline bool il4965_is_tx_success(u32 status) (status == TX_STATUS_DIRECT_DONE); } -u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant_idx, u8 valid); +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ -void il4965_rx_missed_beacon_notif(struct il_priv *priv, +void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -bool il4965_good_plcp_health(struct il_priv *priv, +bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_packet *pkt); -void il4965_rx_statistics(struct il_priv *priv, +void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il4965_reply_statistics(struct il_priv *priv, +void il4965_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); /* scan */ -int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); /* station mgmt */ -int il4965_manage_ibss_station(struct il_priv *priv, +int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, bool add); /* hcmd */ -int il4965_send_beacon_cmd(struct il_priv *priv); +int il4965_send_beacon_cmd(struct il_priv *il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG const char *il4965_get_tx_fail_reason(u32 status); @@ -197,38 +197,38 @@ il4965_get_tx_fail_reason(u32 status) { return ""; } #endif /* station management */ -int il4965_alloc_bcast_station(struct il_priv *priv, +int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx); -int il4965_add_bssid_station(struct il_priv *priv, +int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r); -int il4965_remove_default_wep_key(struct il_priv *priv, +int il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int il4965_set_default_wep_key(struct il_priv *priv, +int il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int il4965_restore_default_wep_keys(struct il_priv *priv, +int il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx); -int il4965_set_dynamic_key(struct il_priv *priv, +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -int il4965_remove_dynamic_key(struct il_priv *priv, +int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -void il4965_update_tkip_key(struct il_priv *priv, +void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid); -int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, u16 ssn); -int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, int tid); -void il4965_sta_modify_sleep_tx_count(struct il_priv *priv, +void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt); -int il4965_update_bcast_stations(struct il_priv *priv); +int il4965_update_bcast_stations(struct il_priv *il); /* rate */ static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) @@ -247,10 +247,10 @@ static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) } /* eeprom */ -void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac); -int il4965_eeprom_acquire_semaphore(struct il_priv *priv); -void il4965_eeprom_release_semaphore(struct il_priv *priv); -int il4965_eeprom_check_version(struct il_priv *priv); +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); +int il4965_eeprom_acquire_semaphore(struct il_priv *il); +void il4965_eeprom_release_semaphore(struct il_priv *il); +int il4965_eeprom_check_version(struct il_priv *il); /* mac80211 handlers (for 4965) */ void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 7eae279..80ec543 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -75,12 +75,12 @@ const u8 iwlegacy_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; EXPORT_SYMBOL(iwlegacy_bcast_addr); -/* This function both allocates and initializes hw and priv. */ +/* This function both allocates and initializes hw and il. */ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) { - struct il_priv *priv; + struct il_priv *il; /* mac80211 allocates memory for this device instance, including - * space for this driver's private structure */ + * space for this driver's ilate structure */ struct ieee80211_hw *hw; hw = ieee80211_alloc_hw(sizeof(struct il_priv), @@ -91,8 +91,8 @@ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) goto out; } - priv = hw->priv; - priv->hw = hw; + il = hw->priv; + il->hw = hw; out: return hw; @@ -101,13 +101,13 @@ EXPORT_SYMBOL(il_alloc_all); #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void il_init_ht_hw_capab(const struct il_priv *priv, +static void il_init_ht_hw_capab(const struct il_priv *il, struct ieee80211_sta_ht_cap *ht_info, enum ieee80211_band band) { u16 max_bit_rate = 0; - u8 rx_chains_num = priv->hw_params.rx_chains_num; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 rx_chains_num = il->hw_params.rx_chains_num; + u8 tx_chains_num = il->hw_params.tx_chains_num; ht_info->cap = 0; memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); @@ -116,14 +116,14 @@ static void il_init_ht_hw_capab(const struct il_priv *priv, ht_info->cap |= IEEE80211_HT_CAP_SGI_20; max_bit_rate = MAX_BIT_RATE_20_MHZ; - if (priv->hw_params.ht40_channel & BIT(band)) { + if (il->hw_params.ht40_channel & BIT(band)) { ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; ht_info->cap |= IEEE80211_HT_CAP_SGI_40; ht_info->mcs.rx_mask[4] = 0x01; max_bit_rate = MAX_BIT_RATE_40_MHZ; } - if (priv->cfg->mod_params->amsdu_size_8K) + if (il->cfg->mod_params->amsdu_size_8K) ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; @@ -152,7 +152,7 @@ static void il_init_ht_hw_capab(const struct il_priv *priv, /** * il_init_geos - Initialize mac80211's geo/channel info based from eeprom */ -int il_init_geos(struct il_priv *priv) +int il_init_geos(struct il_priv *il) { struct il_channel_info *ch; struct ieee80211_supported_band *sband; @@ -162,15 +162,15 @@ int il_init_geos(struct il_priv *priv) int i = 0; s8 max_tx_power = 0; - if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || - priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - IL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); - set_bit(STATUS_GEO_CONFIGURED, &priv->status); + if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || + il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { + IL_DEBUG_INFO(il, "Geography modes already initialized.\n"); + set_bit(STATUS_GEO_CONFIGURED, &il->status); return 0; } channels = kzalloc(sizeof(struct ieee80211_channel) * - priv->channel_count, GFP_KERNEL); + il->channel_count, GFP_KERNEL); if (!channels) return -ENOMEM; @@ -182,36 +182,36 @@ int il_init_geos(struct il_priv *priv) } /* 5.2GHz channels start after the 2.4GHz channels */ - sband = &priv->bands[IEEE80211_BAND_5GHZ]; + sband = &il->bands[IEEE80211_BAND_5GHZ]; sband->channels = &channels[ARRAY_SIZE(iwlegacy_eeprom_band_1)]; /* just OFDM */ sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; - if (priv->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(priv, &sband->ht_cap, + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_5GHZ); - sband = &priv->bands[IEEE80211_BAND_2GHZ]; + sband = &il->bands[IEEE80211_BAND_2GHZ]; sband->channels = channels; /* OFDM & CCK */ sband->bitrates = rates; sband->n_bitrates = IL_RATE_COUNT_LEGACY; - if (priv->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(priv, &sband->ht_cap, + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_2GHZ); - priv->ieee_channels = channels; - priv->ieee_rates = rates; + il->ieee_channels = channels; + il->ieee_rates = rates; - for (i = 0; i < priv->channel_count; i++) { - ch = &priv->channel_info[i]; + for (i = 0; i < il->channel_count; i++) { + ch = &il->channel_info[i]; if (!il_is_channel_valid(ch)) continue; - sband = &priv->bands[ch->band]; + sband = &il->bands[ch->band]; geo_ch = &sband->channels[sband->n_channels++]; @@ -239,7 +239,7 @@ int il_init_geos(struct il_priv *priv) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - IL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + IL_DEBUG_INFO(il, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, geo_ch->center_freq, il_is_channel_a_band(ch) ? "5.2" : "2.4", geo_ch->flags & IEEE80211_CHAN_DISABLED ? @@ -247,24 +247,24 @@ int il_init_geos(struct il_priv *priv) geo_ch->flags); } - priv->tx_power_device_lmt = max_tx_power; - priv->tx_power_user_lmt = max_tx_power; - priv->tx_power_next = max_tx_power; + il->tx_power_device_lmt = max_tx_power; + il->tx_power_user_lmt = max_tx_power; + il->tx_power_next = max_tx_power; - if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - priv->cfg->sku & IL_SKU_A) { - IL_INFO(priv, "Incorrectly detected BG card as ABG. " + if ((il->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && + il->cfg->sku & IL_SKU_A) { + IL_INFO(il, "Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", - priv->pci_dev->device, - priv->pci_dev->subsystem_device); - priv->cfg->sku &= ~IL_SKU_A; + il->pci_dev->device, + il->pci_dev->subsystem_device); + il->cfg->sku &= ~IL_SKU_A; } - IL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", - priv->bands[IEEE80211_BAND_2GHZ].n_channels, - priv->bands[IEEE80211_BAND_5GHZ].n_channels); + IL_INFO(il, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", + il->bands[IEEE80211_BAND_2GHZ].n_channels, + il->bands[IEEE80211_BAND_5GHZ].n_channels); - set_bit(STATUS_GEO_CONFIGURED, &priv->status); + set_bit(STATUS_GEO_CONFIGURED, &il->status); return 0; } @@ -273,21 +273,21 @@ EXPORT_SYMBOL(il_init_geos); /* * il_free_geos - undo allocations in il_init_geos */ -void il_free_geos(struct il_priv *priv) +void il_free_geos(struct il_priv *il) { - kfree(priv->ieee_channels); - kfree(priv->ieee_rates); - clear_bit(STATUS_GEO_CONFIGURED, &priv->status); + kfree(il->ieee_channels); + kfree(il->ieee_rates); + clear_bit(STATUS_GEO_CONFIGURED, &il->status); } EXPORT_SYMBOL(il_free_geos); -static bool il_is_channel_extension(struct il_priv *priv, +static bool il_is_channel_extension(struct il_priv *il, enum ieee80211_band band, u16 channel, u8 extension_chan_offset) { const struct il_channel_info *ch_info; - ch_info = il_get_channel_info(priv, band, channel); + ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) return false; @@ -301,7 +301,7 @@ static bool il_is_channel_extension(struct il_priv *priv, return false; } -bool il_is_ht40_tx_allowed(struct il_priv *priv, +bool il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap) { @@ -316,11 +316,11 @@ bool il_is_ht40_tx_allowed(struct il_priv *priv, return false; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - if (priv->disable_ht40) + if (il->disable_ht40) return false; #endif - return il_is_channel_extension(priv, priv->band, + return il_is_channel_extension(il, il->band, le16_to_cpu(ctx->staging.channel), ctx->ht.extension_chan_offset); } @@ -360,7 +360,7 @@ static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) } int -il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) +il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) { u64 tsf; s32 interval_tm, rem; @@ -368,13 +368,13 @@ il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) u16 beacon_int; struct ieee80211_vif *vif = ctx->vif; - conf = il_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(il->hw); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); - ctx->timing.timestamp = cpu_to_le64(priv->timestamp); + ctx->timing.timestamp = cpu_to_le64(il->timestamp); ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); beacon_int = vif ? vif->bss_conf.beacon_int : 0; @@ -386,29 +386,29 @@ il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) ctx->timing.atim_window = 0; beacon_int = il_adjust_beacon_interval(beacon_int, - priv->hw_params.max_beacon_itrvl * TIME_UNIT); + il->hw_params.max_beacon_itrvl * TIME_UNIT); ctx->timing.beacon_interval = cpu_to_le16(beacon_int); - tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ + tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ interval_tm = beacon_int * TIME_UNIT; rem = do_div(tsf, interval_tm); ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - IL_DEBUG_ASSOC(priv, + IL_DEBUG_ASSOC(il, "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), le16_to_cpu(ctx->timing.atim_window)); - return il_send_cmd_pdu(priv, ctx->rxon_timing_cmd, + return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); } EXPORT_SYMBOL(il_send_rxon_timing); void -il_set_rxon_hwcrypto(struct il_priv *priv, +il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, int hw_decrypt) { @@ -424,72 +424,72 @@ EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ int -il_check_rxon_cmd(struct il_priv *priv, struct il_rxon_context *ctx) +il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; bool error = false; if (rxon->flags & RXON_FLG_BAND_24G_MSK) { if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IL_WARN(priv, "check 2.4G: wrong narrow\n"); + IL_WARN(il, "check 2.4G: wrong narrow\n"); error = true; } if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IL_WARN(priv, "check 2.4G: wrong radar\n"); + IL_WARN(il, "check 2.4G: wrong radar\n"); error = true; } } else { if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(priv, "check 5.2G: not short slot!\n"); + IL_WARN(il, "check 5.2G: not short slot!\n"); error = true; } if (rxon->flags & RXON_FLG_CCK_MSK) { - IL_WARN(priv, "check 5.2G: CCK!\n"); + IL_WARN(il, "check 5.2G: CCK!\n"); error = true; } } if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IL_WARN(priv, "mac/bssid mcast!\n"); + IL_WARN(il, "mac/bssid mcast!\n"); error = true; } /* make sure basic rates 6Mbps and 1Mbps are supported */ if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { - IL_WARN(priv, "neither 1 nor 6 are basic\n"); + IL_WARN(il, "neither 1 nor 6 are basic\n"); error = true; } if (le16_to_cpu(rxon->assoc_id) > 2007) { - IL_WARN(priv, "aid > 2007\n"); + IL_WARN(il, "aid > 2007\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(priv, "CCK and short slot\n"); + IL_WARN(il, "CCK and short slot\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IL_WARN(priv, "CCK and auto detect"); + IL_WARN(il, "CCK and auto detect"); error = true; } if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK) { - IL_WARN(priv, "TGg but no auto-detect\n"); + IL_WARN(il, "TGg but no auto-detect\n"); error = true; } if (error) - IL_WARN(priv, "Tuning to channel %d\n", + IL_WARN(il, "Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { - IL_ERR(priv, "Invalid RXON\n"); + IL_ERR(il, "Invalid RXON\n"); return -EINVAL; } return 0; @@ -498,13 +498,13 @@ EXPORT_SYMBOL(il_check_rxon_cmd); /** * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed - * @priv: staging_rxon is compared to active_rxon + * @il: staging_rxon is compared to active_rxon * * If the RXON structure is changing enough to require a new tune, * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. */ -int il_full_rxon_required(struct il_priv *priv, +int il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_rxon_cmd *staging = &ctx->staging; @@ -512,13 +512,13 @@ int il_full_rxon_required(struct il_priv *priv, #define CHK(cond) \ if ((cond)) { \ - IL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ + IL_DEBUG_INFO(il, "need full RXON - " #cond "\n"); \ return 1; \ } #define CHK_NEQ(c1, c2) \ if ((c1) != (c2)) { \ - IL_DEBUG_INFO(priv, "need full RXON - " \ + IL_DEBUG_INFO(il, "need full RXON - " \ #c1 " != " #c2 " - %d != %d\n", \ (c1), (c2)); \ return 1; \ @@ -558,7 +558,7 @@ int il_full_rxon_required(struct il_priv *priv, } EXPORT_SYMBOL(il_full_rxon_required); -u8 il_get_lowest_plcp(struct il_priv *priv, +u8 il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx) { /* @@ -572,7 +572,7 @@ u8 il_get_lowest_plcp(struct il_priv *priv, } EXPORT_SYMBOL(il_get_lowest_plcp); -static void _il_set_rxon_ht(struct il_priv *priv, +static void _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, struct il_rxon_context *ctx) { @@ -594,7 +594,7 @@ static void _il_set_rxon_ht(struct il_priv *priv, /* clear the HT channel mode before set the mode */ rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - if (il_is_ht40_tx_allowed(priv, ctx, NULL)) { + if (il_is_ht40_tx_allowed(il, ctx, NULL)) { /* pure ht40 */ if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { @@ -626,7 +626,7 @@ static void _il_set_rxon_ht(struct il_priv *priv, case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IL_ERR(priv, + IL_ERR(il, "invalid extension channel offset\n"); break; } @@ -635,26 +635,26 @@ static void _il_set_rxon_ht(struct il_priv *priv, rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; } - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - IL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " + IL_DEBUG_ASSOC(il, "rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), ctx->ht.protection, ctx->ht.extension_chan_offset); } -void il_set_rxon_ht(struct il_priv *priv, struct il_ht_config *ht_conf) +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { struct il_rxon_context *ctx; - for_each_context(priv, ctx) - _il_set_rxon_ht(priv, ht_conf, ctx); + for_each_context(il, ctx) + _il_set_rxon_ht(il, ht_conf, ctx); } EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ -u8 il_get_single_channel_number(struct il_priv *priv, +u8 il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band) { const struct il_channel_info *ch_info; @@ -665,7 +665,7 @@ u8 il_get_single_channel_number(struct il_priv *priv, if (band == IEEE80211_BAND_5GHZ) { min = 14; - max = priv->channel_count; + max = il->channel_count; } else { min = 0; max = 14; @@ -674,8 +674,8 @@ u8 il_get_single_channel_number(struct il_priv *priv, for (i = min; i < max; i++) { bool busy = false; - for_each_context(priv, ctx) { - busy = priv->channel_info[i].channel == + for_each_context(il, ctx) { + busy = il->channel_info[i].channel == le16_to_cpu(ctx->staging.channel); if (busy) break; @@ -684,8 +684,8 @@ u8 il_get_single_channel_number(struct il_priv *priv, if (busy) continue; - channel = priv->channel_info[i].channel; - ch_info = il_get_channel_info(priv, band, channel); + channel = il->channel_info[i].channel; + ch_info = il_get_channel_info(il, band, channel); if (il_is_channel_valid(ch_info)) break; } @@ -702,14 +702,14 @@ EXPORT_SYMBOL(il_get_single_channel_number); * in the staging RXON flag structure based on the ch->band */ int -il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, +il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, struct il_rxon_context *ctx) { enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; if ((le16_to_cpu(ctx->staging.channel) == channel) && - (priv->band == band)) + (il->band == band)) return 0; ctx->staging.channel = cpu_to_le16(channel); @@ -718,15 +718,15 @@ il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, else ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; - priv->band = band; + il->band = band; - IL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); + IL_DEBUG_INFO(il, "Staging channel set to %d [%d]\n", channel, band); return 0; } EXPORT_SYMBOL(il_set_rxon_channel); -void il_set_flags_for_band(struct il_priv *priv, +void il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif) @@ -753,7 +753,7 @@ EXPORT_SYMBOL(il_set_flags_for_band); /* * initialize rxon structure with default values from eeprom */ -void il_connection_init_rx_config(struct il_priv *priv, +void il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_channel_info *ch_info; @@ -778,7 +778,7 @@ void il_connection_init_rx_config(struct il_priv *priv, break; default: - IL_ERR(priv, "Unsupported interface type %d\n", + IL_ERR(il, "Unsupported interface type %d\n", ctx->vif->type); break; } @@ -786,22 +786,22 @@ void il_connection_init_rx_config(struct il_priv *priv, #if 0 /* TODO: Figure out when short_preamble would be set and cache from * that */ - if (!hw_to_local(priv->hw)->short_preamble) + if (!hw_to_local(il->hw)->short_preamble) ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; else ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; #endif - ch_info = il_get_channel_info(priv, priv->band, + ch_info = il_get_channel_info(il, il->band, le16_to_cpu(ctx->active.channel)); if (!ch_info) - ch_info = &priv->channel_info[0]; + ch_info = &il->channel_info[0]; ctx->staging.channel = cpu_to_le16(ch_info->channel); - priv->band = ch_info->band; + il->band = ch_info->band; - il_set_flags_for_band(priv, ctx, priv->band, ctx->vif); + il_set_flags_for_band(il, ctx, il->band, ctx->vif); ctx->staging.ofdm_basic_rates = (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; @@ -819,30 +819,30 @@ void il_connection_init_rx_config(struct il_priv *priv, } EXPORT_SYMBOL(il_connection_init_rx_config); -void il_set_rate(struct il_priv *priv) +void il_set_rate(struct il_priv *il) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; struct il_rxon_context *ctx; int i; - hw = il_get_hw_mode(priv, priv->band); + hw = il_get_hw_mode(il, il->band); if (!hw) { - IL_ERR(priv, "Failed to set rate: unable to get hw mode\n"); + IL_ERR(il, "Failed to set rate: unable to get hw mode\n"); return; } - priv->active_rate = 0; + il->active_rate = 0; for (i = 0; i < hw->n_bitrates; i++) { rate = &(hw->bitrates[i]); if (rate->hw_value < IL_RATE_COUNT_LEGACY) - priv->active_rate |= (1 << rate->hw_value); + il->active_rate |= (1 << rate->hw_value); } - IL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); + IL_DEBUG_RATE(il, "Set active_rate = %0x\n", il->active_rate); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { ctx->staging.cck_basic_rates = (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; @@ -852,64 +852,64 @@ void il_set_rate(struct il_priv *priv) } EXPORT_SYMBOL(il_set_rate); -void il_chswitch_done(struct il_priv *priv, bool is_success) +void il_chswitch_done(struct il_priv *il, bool is_success) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) + if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } EXPORT_SYMBOL(il_chswitch_done); -void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb) +void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct il_rxon_cmd *rxon = (void *)&ctx->active; - if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) + if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) return; - if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) { + if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - IL_DEBUG_11H(priv, "CSA notif: channel %d\n", + IL_DEBUG_11H(il, "CSA notif: channel %d\n", le16_to_cpu(csa->channel)); - il_chswitch_done(priv, true); + il_chswitch_done(il, true); } else { - IL_ERR(priv, "CSA notif (fail) : channel %d\n", + IL_ERR(il, "CSA notif (fail) : channel %d\n", le16_to_cpu(csa->channel)); - il_chswitch_done(priv, false); + il_chswitch_done(il, false); } } EXPORT_SYMBOL(il_rx_csa); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *priv, +void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; - IL_DEBUG_RADIO(priv, "RX CONFIG:\n"); - il_print_hex_dump(priv, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - IL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", + IL_DEBUG_RADIO(il, "RX CONFIG:\n"); + il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); + IL_DEBUG_RADIO(il, "u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); - IL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - IL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n", + IL_DEBUG_RADIO(il, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + IL_DEBUG_RADIO(il, "u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); - IL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); - IL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(il, "u8 dev_type: 0x%x\n", rxon->dev_type); + IL_DEBUG_RADIO(il, "u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); - IL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(il, "u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); - IL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); - IL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - IL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", + IL_DEBUG_RADIO(il, "u8[6] node_addr: %pM\n", rxon->node_addr); + IL_DEBUG_RADIO(il, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + IL_DEBUG_RADIO(il, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } EXPORT_SYMBOL(il_print_rx_config_cmd); @@ -917,68 +917,68 @@ EXPORT_SYMBOL(il_print_rx_config_cmd); /** * il_irq_handle_error - called for HW or SW error interrupt from card */ -void il_irq_handle_error(struct il_priv *priv) +void il_irq_handle_error(struct il_priv *il) { /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &priv->status); + set_bit(STATUS_FW_ERROR, &il->status); /* Cancel currently queued command. */ - clear_bit(STATUS_HCMD_ACTIVE, &priv->status); + clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_ERR(priv, "Loaded firmware version: %s\n", - priv->hw->wiphy->fw_version); + IL_ERR(il, "Loaded firmware version: %s\n", + il->hw->wiphy->fw_version); - priv->cfg->ops->lib->dump_nic_error_log(priv); - if (priv->cfg->ops->lib->dump_fh) - priv->cfg->ops->lib->dump_fh(priv, NULL, false); + il->cfg->ops->lib->dump_nic_error_log(il); + if (il->cfg->ops->lib->dump_fh) + il->cfg->ops->lib->dump_fh(il, NULL, false); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & IL_DL_FW_ERRORS) - il_print_rx_config_cmd(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + if (il_get_debug_level(il) & IL_DL_FW_ERRORS) + il_print_rx_config_cmd(il, + &il->contexts[IL_RXON_CTX_BSS]); #endif - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); /* Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &priv->status); + clear_bit(STATUS_READY, &il->status); - if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IL_DEBUG(priv, IL_DL_FW_ERRORS, + if (!test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_DEBUG(il, IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); - if (priv->cfg->mod_params->restart_fw) - queue_work(priv->workqueue, &priv->restart); + if (il->cfg->mod_params->restart_fw) + queue_work(il->workqueue, &il->restart); } } EXPORT_SYMBOL(il_irq_handle_error); -static int il_apm_stop_master(struct il_priv *priv) +static int il_apm_stop_master(struct il_priv *il) { int ret = 0; /* stop device's busmaster DMA activity */ - il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = il_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + ret = il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) - IL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); + IL_WARN(il, "Master Disable Timed Out, 100 usec\n"); - IL_DEBUG_INFO(priv, "stop master\n"); + IL_DEBUG_INFO(il, "stop master\n"); return ret; } -void il_apm_stop(struct il_priv *priv) +void il_apm_stop(struct il_priv *il) { - IL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); + IL_DEBUG_INFO(il, "Stop card, put in low power state\n"); /* Stop device's DMA activity */ - il_apm_stop_master(priv); + il_apm_stop_master(il); /* Reset the entire device */ - il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); udelay(10); @@ -986,7 +986,7 @@ void il_apm_stop(struct il_priv *priv) * Clear "initialization complete" bit to move adapter from * D0A* (powered-up Active) --> D0U* (Uninitialized) state. */ - il_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } EXPORT_SYMBOL(il_apm_stop); @@ -997,12 +997,12 @@ EXPORT_SYMBOL(il_apm_stop); * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -int il_apm_init(struct il_priv *priv) +int il_apm_init(struct il_priv *il) { int ret = 0; u16 lctl; - IL_DEBUG_INFO(priv, "Init card's basic functions\n"); + IL_DEBUG_INFO(il, "Init card's basic functions\n"); /* * Use "set_bit" below rather than "write", to preserve any hardware @@ -1010,18 +1010,18 @@ int il_apm_init(struct il_priv *priv) */ /* Disable L0S exit timer (platform NMI Work/Around) */ - il_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(il, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); /* * Disable L0s without affecting L1; * don't wait for ICH L0s (ICH bug W/A) */ - il_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(il, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); /* Set FH wait threshold to maximum (HW error during stress W/A) */ - il_set_bit(priv, CSR_DBG_HPET_MEM_REG, + il_set_bit(il, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); /* @@ -1029,7 +1029,7 @@ int il_apm_init(struct il_priv *priv) * wake device's PCI Express link L1a -> L0s * NOTE: This is no-op for 3945 (non-existent bit) */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); /* @@ -1040,43 +1040,43 @@ int il_apm_init(struct il_priv *priv) * If not (unlikely), enable L0S, so there is at least some * power savings, even without L1. */ - if (priv->cfg->base_params->set_l0s) { - lctl = il_pcie_link_ctl(priv); + if (il->cfg->base_params->set_l0s) { + lctl = il_pcie_link_ctl(il); if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) { /* L1-ASPM enabled; disable(!) L0S */ - il_set_bit(priv, CSR_GIO_REG, + il_set_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); + IL_DEBUG_POWER(il, "L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ - il_clear_bit(priv, CSR_GIO_REG, + il_clear_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); + IL_DEBUG_POWER(il, "L1 Disabled; Enabling L0S\n"); } } /* Configure analog phase-lock-loop before activating to D0A */ - if (priv->cfg->base_params->pll_cfg_val) - il_set_bit(priv, CSR_ANA_PLL_CFG, - priv->cfg->base_params->pll_cfg_val); + if (il->cfg->base_params->pll_cfg_val) + il_set_bit(il, CSR_ANA_PLL_CFG, + il->cfg->base_params->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from * D0U* --> D0A* (powered-up active) state. */ - il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); /* * Wait for clock stabilization; once stabilized, access to * device-internal resources is supported, e.g. il_write_prph() * and accesses to uCode SRAM. */ - ret = il_poll_bit(priv, CSR_GP_CNTRL, + ret = il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { - IL_DEBUG_INFO(priv, "Failed to init the card\n"); + IL_DEBUG_INFO(il, "Failed to init the card\n"); goto out; } @@ -1088,16 +1088,16 @@ int il_apm_init(struct il_priv *priv) * do not disable clocks. This preserves any hardware bits already * set by default in "CLK_CTRL_REG" after reset. */ - if (priv->cfg->base_params->use_bsm) - il_write_prph(priv, APMG_CLK_EN_REG, + if (il->cfg->base_params->use_bsm) + il_write_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - il_write_prph(priv, APMG_CLK_EN_REG, + il_write_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); /* Disable L1-Active */ - il_set_bits_prph(priv, APMG_PCIDEV_STT_REG, + il_set_bits_prph(il, APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_L1_ACT_DIS); out: @@ -1106,66 +1106,66 @@ out: EXPORT_SYMBOL(il_apm_init); -int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force) +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) { int ret; s8 prev_tx_power; bool defer; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (priv->tx_power_user_lmt == tx_power && !force) + if (il->tx_power_user_lmt == tx_power && !force) return 0; - if (!priv->cfg->ops->lib->send_tx_power) + if (!il->cfg->ops->lib->send_tx_power) return -EOPNOTSUPP; /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IL_WARN(priv, + IL_WARN(il, "Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } - if (tx_power > priv->tx_power_device_lmt) { - IL_WARN(priv, + if (tx_power > il->tx_power_device_lmt) { + IL_WARN(il, "Requested user TXPOWER %d above upper limit %d.\n", - tx_power, priv->tx_power_device_lmt); + tx_power, il->tx_power_device_lmt); return -EINVAL; } - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return -EIO; /* scan complete and commit_rxon use tx_power_next value, * it always need to be updated for newest request */ - priv->tx_power_next = tx_power; + il->tx_power_next = tx_power; /* do not set tx power when scanning or channel changing */ - defer = test_bit(STATUS_SCANNING, &priv->status) || + defer = test_bit(STATUS_SCANNING, &il->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { - IL_DEBUG_INFO(priv, "Deferring tx power set\n"); + IL_DEBUG_INFO(il, "Deferring tx power set\n"); return 0; } - prev_tx_power = priv->tx_power_user_lmt; - priv->tx_power_user_lmt = tx_power; + prev_tx_power = il->tx_power_user_lmt; + il->tx_power_user_lmt = tx_power; - ret = priv->cfg->ops->lib->send_tx_power(priv); + ret = il->cfg->ops->lib->send_tx_power(il); /* if fail to set tx_power, restore the orig. tx power */ if (ret) { - priv->tx_power_user_lmt = prev_tx_power; - priv->tx_power_next = prev_tx_power; + il->tx_power_user_lmt = prev_tx_power; + il->tx_power_next = prev_tx_power; } return ret; } EXPORT_SYMBOL(il_set_tx_power); -void il_send_bt_config(struct il_priv *priv) +void il_send_bt_config(struct il_priv *il) { struct il_bt_cmd bt_cmd = { .lead_time = BT_LEAD_TIME_DEF, @@ -1179,16 +1179,16 @@ void il_send_bt_config(struct il_priv *priv) else bt_cmd.flags = BT_COEX_ENABLE; - IL_DEBUG_INFO(priv, "BT coex %s\n", + IL_DEBUG_INFO(il, "BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (il_send_cmd_pdu(priv, REPLY_BT_CONFIG, + if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) - IL_ERR(priv, "failed to send BT Coex Config\n"); + IL_ERR(il, "failed to send BT Coex Config\n"); } EXPORT_SYMBOL(il_send_bt_config); -int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear) +int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear) { struct il_statistics_cmd statistics_cmd = { .configuration_flags = @@ -1196,46 +1196,46 @@ int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear) }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu_async(il, REPLY_STATISTICS_CMD, sizeof(struct il_statistics_cmd), &statistics_cmd, NULL); else - return il_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu(il, REPLY_STATISTICS_CMD, sizeof(struct il_statistics_cmd), &statistics_cmd); } EXPORT_SYMBOL(il_send_statistics_request); -void il_rx_pm_sleep_notif(struct il_priv *priv, +void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); - IL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", + IL_DEBUG_RX(il, "sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } EXPORT_SYMBOL(il_rx_pm_sleep_notif); -void il_rx_pm_debug_statistics_notif(struct il_priv *priv, +void il_rx_pm_debug_statistics_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - IL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " + IL_DEBUG_RADIO(il, "Dumping %d bytes of unhandled " "notification for %s:\n", len, il_get_cmd_string(pkt->hdr.cmd)); - il_print_hex_dump(priv, IL_DL_RADIO, pkt->u.raw, len); + il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); -void il_rx_reply_error(struct il_priv *priv, +void il_rx_reply_error(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " + IL_ERR(il, "Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", le32_to_cpu(pkt->u.err_resp.error_type), il_get_cmd_string(pkt->u.err_resp.cmd_id), @@ -1245,37 +1245,37 @@ void il_rx_reply_error(struct il_priv *priv, } EXPORT_SYMBOL(il_rx_reply_error); -void il_clear_isr_stats(struct il_priv *priv) +void il_clear_isr_stats(struct il_priv *il) { - memset(&priv->isr_stats, 0, sizeof(priv->isr_stats)); + memset(&il->isr_stats, 0, sizeof(il->isr_stats)); } int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx; unsigned long flags; int q; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (!il_is_ready_rf(priv)) { - IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(il)) { + IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); return -EIO; } if (queue >= AC_NUM) { - IL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); + IL_DEBUG_MAC80211(il, "leave - queue >= AC_NUM %d\n", queue); return 0; } q = AC_NUM - 1 - queue; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { ctx->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min); ctx->qos_data.def_qos_parm.ac[q].cw_max = @@ -1287,50 +1287,50 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); return 0; } EXPORT_SYMBOL(il_mac_conf_tx); int il_mac_tx_last_beacon(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - return priv->ibss_manager == IL_IBSS_MANAGER; + return il->ibss_manager == IL_IBSS_MANAGER; } EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int -il_set_mode(struct il_priv *priv, struct il_rxon_context *ctx) +il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) { - il_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(il, ctx); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - return il_commit_rxon(priv, ctx); + return il_commit_rxon(il, ctx); } -static int il_setup_interface(struct il_priv *priv, +static int il_setup_interface(struct il_priv *il, struct il_rxon_context *ctx) { struct ieee80211_vif *vif = ctx->vif; int err; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); /* * This variable will be correct only when there's just * a single context, but all code using it is for hardware * that supports only one context. */ - priv->iw_mode = vif->type; + il->iw_mode = vif->type; ctx->is_active = true; - err = il_set_mode(priv, ctx); + err = il_set_mode(il, ctx); if (err) { if (!ctx->always_active) ctx->is_active = false; @@ -1343,23 +1343,23 @@ static int il_setup_interface(struct il_priv *priv, int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; struct il_rxon_context *tmp, *ctx = NULL; int err; - IL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", + IL_DEBUG_MAC80211(il, "enter: type %d, addr %pM\n", vif->type, vif->addr); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (!il_is_ready_rf(priv)) { - IL_WARN(priv, "Try to add interface when device not ready\n"); + if (!il_is_ready_rf(il)) { + IL_WARN(il, "Try to add interface when device not ready\n"); err = -EINVAL; goto out; } - for_each_context(priv, tmp) { + for_each_context(il, tmp) { u32 possible_modes = tmp->interface_modes | tmp->exclusive_interface_modes; @@ -1389,35 +1389,35 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) vif_priv->ctx = ctx; ctx->vif = vif; - err = il_setup_interface(priv, ctx); + err = il_setup_interface(il, ctx); if (!err) goto out; ctx->vif = NULL; - priv->iw_mode = NL80211_IFTYPE_STATION; + il->iw_mode = NL80211_IFTYPE_STATION; out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); return err; } EXPORT_SYMBOL(il_mac_add_interface); -static void il_teardown_interface(struct il_priv *priv, +static void il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, bool mode_change) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (priv->scan_vif == vif) { - il_scan_cancel_timeout(priv, 200); - il_force_scan_end(priv); + if (il->scan_vif == vif) { + il_scan_cancel_timeout(il, 200); + il_force_scan_end(il); } if (!mode_change) { - il_set_mode(priv, ctx); + il_set_mode(il, ctx); if (!ctx->always_active) ctx->is_active = false; } @@ -1426,45 +1426,45 @@ static void il_teardown_interface(struct il_priv *priv, void il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); WARN_ON(ctx->vif != vif); ctx->vif = NULL; - il_teardown_interface(priv, vif, false); + il_teardown_interface(il, vif, false); - memset(priv->bssid, 0, ETH_ALEN); - mutex_unlock(&priv->mutex); + memset(il->bssid, 0, ETH_ALEN); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } EXPORT_SYMBOL(il_mac_remove_interface); -int il_alloc_txq_mem(struct il_priv *priv) +int il_alloc_txq_mem(struct il_priv *il) { - if (!priv->txq) - priv->txq = kzalloc( + if (!il->txq) + il->txq = kzalloc( sizeof(struct il_tx_queue) * - priv->cfg->base_params->num_of_queues, + il->cfg->base_params->num_of_queues, GFP_KERNEL); - if (!priv->txq) { - IL_ERR(priv, "Not enough memory for txq\n"); + if (!il->txq) { + IL_ERR(il, "Not enough memory for txq\n"); return -ENOMEM; } return 0; } EXPORT_SYMBOL(il_alloc_txq_mem); -void il_txq_mem(struct il_priv *priv) +void il_txq_mem(struct il_priv *il) { - kfree(priv->txq); - priv->txq = NULL; + kfree(il->txq); + il->txq = NULL; } EXPORT_SYMBOL(il_txq_mem); @@ -1472,52 +1472,52 @@ EXPORT_SYMBOL(il_txq_mem); #define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) -void il_reset_traffic_log(struct il_priv *priv) +void il_reset_traffic_log(struct il_priv *il) { - priv->tx_traffic_idx = 0; - priv->rx_traffic_idx = 0; - if (priv->tx_traffic) - memset(priv->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); - if (priv->rx_traffic) - memset(priv->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); + il->tx_traffic_idx = 0; + il->rx_traffic_idx = 0; + if (il->tx_traffic) + memset(il->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); + if (il->rx_traffic) + memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); } -int il_alloc_traffic_mem(struct il_priv *priv) +int il_alloc_traffic_mem(struct il_priv *il) { u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; if (iwlegacy_debug_level & IL_DL_TX) { - if (!priv->tx_traffic) { - priv->tx_traffic = + if (!il->tx_traffic) { + il->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); - if (!priv->tx_traffic) + if (!il->tx_traffic) return -ENOMEM; } } if (iwlegacy_debug_level & IL_DL_RX) { - if (!priv->rx_traffic) { - priv->rx_traffic = + if (!il->rx_traffic) { + il->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); - if (!priv->rx_traffic) + if (!il->rx_traffic) return -ENOMEM; } } - il_reset_traffic_log(priv); + il_reset_traffic_log(il); return 0; } EXPORT_SYMBOL(il_alloc_traffic_mem); -void il_free_traffic_mem(struct il_priv *priv) +void il_free_traffic_mem(struct il_priv *il) { - kfree(priv->tx_traffic); - priv->tx_traffic = NULL; + kfree(il->tx_traffic); + il->tx_traffic = NULL; - kfree(priv->rx_traffic); - priv->rx_traffic = NULL; + kfree(il->rx_traffic); + il->rx_traffic = NULL; } EXPORT_SYMBOL(il_free_traffic_mem); -void il_dbg_log_tx_data_frame(struct il_priv *priv, +void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { __le16 fc; @@ -1526,23 +1526,23 @@ void il_dbg_log_tx_data_frame(struct il_priv *priv, if (likely(!(iwlegacy_debug_level & IL_DL_TX))) return; - if (!priv->tx_traffic) + if (!il->tx_traffic) return; fc = header->frame_control; if (ieee80211_is_data(fc)) { len = (length > IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((priv->tx_traffic + - (priv->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + memcpy((il->tx_traffic + + (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); - priv->tx_traffic_idx = - (priv->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + il->tx_traffic_idx = + (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } EXPORT_SYMBOL(il_dbg_log_tx_data_frame); -void il_dbg_log_rx_data_frame(struct il_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { __le16 fc; @@ -1551,18 +1551,18 @@ void il_dbg_log_rx_data_frame(struct il_priv *priv, if (likely(!(iwlegacy_debug_level & IL_DL_RX))) return; - if (!priv->rx_traffic) + if (!il->rx_traffic) return; fc = header->frame_control; if (ieee80211_is_data(fc)) { len = (length > IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((priv->rx_traffic + - (priv->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + memcpy((il->rx_traffic + + (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); - priv->rx_traffic_idx = - (priv->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + il->rx_traffic_idx = + (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } EXPORT_SYMBOL(il_dbg_log_rx_data_frame); @@ -1605,10 +1605,10 @@ const char *il_get_ctrl_string(int cmd) } } -void il_clear_traffic_stats(struct il_priv *priv) +void il_clear_traffic_stats(struct il_priv *il) { - memset(&priv->tx_stats, 0, sizeof(struct traffic_stats)); - memset(&priv->rx_stats, 0, sizeof(struct traffic_stats)); + memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); + memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); } /* @@ -1623,14 +1623,14 @@ void il_clear_traffic_stats(struct il_priv *priv) * */ void -il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) +il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { struct traffic_stats *stats; if (is_tx) - stats = &priv->tx_stats; + stats = &il->tx_stats; else - stats = &priv->rx_stats; + stats = &il->rx_stats; if (ieee80211_is_mgmt(fc)) { switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { @@ -1707,20 +1707,20 @@ il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) EXPORT_SYMBOL(il_update_stats); #endif -int il_force_reset(struct il_priv *priv, bool external) +int il_force_reset(struct il_priv *il, bool external) { struct il_force_reset *force_reset; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return -EINVAL; - force_reset = &priv->force_reset; + force_reset = &il->force_reset; force_reset->reset_request_count++; if (!external) { if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + force_reset->reset_duration, jiffies)) { - IL_DEBUG_INFO(priv, "force reset rejected\n"); + IL_DEBUG_INFO(il, "force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; } @@ -1737,23 +1737,23 @@ int il_force_reset(struct il_priv *priv, bool external) * need to be check before performing firmware reload */ - if (!external && !priv->cfg->mod_params->restart_fw) { - IL_DEBUG_INFO(priv, "Cancel firmware reload based on " + if (!external && !il->cfg->mod_params->restart_fw) { + IL_DEBUG_INFO(il, "Cancel firmware reload based on " "module parameter setting\n"); return 0; } - IL_ERR(priv, "On demand firmware reload\n"); + IL_ERR(il, "On demand firmware reload\n"); /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &priv->status); - wake_up(&priv->wait_command_queue); + set_bit(STATUS_FW_ERROR, &il->status); + wake_up(&il->wait_command_queue); /* * Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &priv->status); - queue_work(priv->workqueue, &priv->restart); + clear_bit(STATUS_READY, &il->status); + queue_work(il->workqueue, &il->restart); return 0; } @@ -1763,7 +1763,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); struct il_rxon_context *tmp; u32 interface_modes; @@ -1771,9 +1771,9 @@ il_mac_change_interface(struct ieee80211_hw *hw, newtype = ieee80211_iftype_p2p(newtype, newp2p); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (!ctx->vif || !il_is_ready_rf(priv)) { + if (!ctx->vif || !il_is_ready_rf(il)) { /* * Huh? But wait ... this can maybe happen when * we're in the middle of a firmware restart! @@ -1790,7 +1790,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, } if (ctx->exclusive_interface_modes & BIT(newtype)) { - for_each_context(priv, tmp) { + for_each_context(il, tmp) { if (ctx == tmp) continue; @@ -1807,10 +1807,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, } /* success */ - il_teardown_interface(priv, vif, true); + il_teardown_interface(il, vif, true); vif->type = newtype; vif->p2p = newp2p; - err = il_setup_interface(priv, ctx); + err = il_setup_interface(il, ctx); WARN_ON(err); /* * We've switched internally, but submitting to the @@ -1822,7 +1822,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, err = 0; out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return err; } EXPORT_SYMBOL(il_mac_change_interface); @@ -1831,9 +1831,9 @@ EXPORT_SYMBOL(il_mac_change_interface); * On every watchdog tick we check (latest) time stamp. If it does not * change during timeout period and queue is not empty we reset firmware. */ -static int il_check_stuck_queue(struct il_priv *priv, int cnt) +static int il_check_stuck_queue(struct il_priv *il, int cnt) { - struct il_tx_queue *txq = &priv->txq[cnt]; + struct il_tx_queue *txq = &il->txq[cnt]; struct il_queue *q = &txq->q; unsigned long timeout; int ret; @@ -1844,12 +1844,12 @@ static int il_check_stuck_queue(struct il_priv *priv, int cnt) } timeout = txq->time_stamp + - msecs_to_jiffies(priv->cfg->base_params->wd_timeout); + msecs_to_jiffies(il->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IL_ERR(priv, "Queue %d stuck for %u ms.\n", - q->id, priv->cfg->base_params->wd_timeout); - ret = il_force_reset(priv, false); + IL_ERR(il, "Queue %d stuck for %u ms.\n", + q->id, il->cfg->base_params->wd_timeout); + ret = il_force_reset(il, false); return (ret == -EAGAIN) ? 0 : 1; } @@ -1868,46 +1868,46 @@ static int il_check_stuck_queue(struct il_priv *priv, int cnt) */ void il_bg_watchdog(unsigned long data) { - struct il_priv *priv = (struct il_priv *)data; + struct il_priv *il = (struct il_priv *)data; int cnt; unsigned long timeout; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - timeout = priv->cfg->base_params->wd_timeout; + timeout = il->cfg->base_params->wd_timeout; if (timeout == 0) return; /* monitor and check for stuck cmd queue */ - if (il_check_stuck_queue(priv, priv->cmd_queue)) + if (il_check_stuck_queue(il, il->cmd_queue)) return; /* monitor and check for other stuck queues */ - if (il_is_any_associated(priv)) { - for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { + if (il_is_any_associated(il)) { + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { /* skip as we already checked the command queue */ - if (cnt == priv->cmd_queue) + if (cnt == il->cmd_queue) continue; - if (il_check_stuck_queue(priv, cnt)) + if (il_check_stuck_queue(il, cnt)) return; } } - mod_timer(&priv->watchdog, jiffies + + mod_timer(&il->watchdog, jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); } EXPORT_SYMBOL(il_bg_watchdog); -void il_setup_watchdog(struct il_priv *priv) +void il_setup_watchdog(struct il_priv *il) { - unsigned int timeout = priv->cfg->base_params->wd_timeout; + unsigned int timeout = il->cfg->base_params->wd_timeout; if (timeout) - mod_timer(&priv->watchdog, + mod_timer(&il->watchdog, jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); else - del_timer(&priv->watchdog); + del_timer(&il->watchdog); } EXPORT_SYMBOL(il_setup_watchdog); @@ -1918,7 +1918,7 @@ EXPORT_SYMBOL(il_setup_watchdog); * the internal part is the time in usec within one beacon interval */ u32 -il_usecs_to_beacons(struct il_priv *priv, +il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval) { u32 quot; @@ -1929,39 +1929,39 @@ il_usecs_to_beacons(struct il_priv *priv, return 0; quot = (usec / interval) & - (il_beacon_time_mask_high(priv, - priv->hw_params.beacon_time_tsf_bits) >> - priv->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & il_beacon_time_mask_low(priv, - priv->hw_params.beacon_time_tsf_bits); + (il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits) >> + il->hw_params.beacon_time_tsf_bits); + rem = (usec % interval) & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); - return (quot << priv->hw_params.beacon_time_tsf_bits) + rem; + return (quot << il->hw_params.beacon_time_tsf_bits) + rem; } EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ -__le32 il_add_beacon_time(struct il_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, u32 beacon_interval) { - u32 base_low = base & il_beacon_time_mask_low(priv, - priv->hw_params.beacon_time_tsf_bits); - u32 addon_low = addon & il_beacon_time_mask_low(priv, - priv->hw_params.beacon_time_tsf_bits); + u32 base_low = base & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + u32 addon_low = addon & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); u32 interval = beacon_interval * TIME_UNIT; - u32 res = (base & il_beacon_time_mask_high(priv, - priv->hw_params.beacon_time_tsf_bits)) + - (addon & il_beacon_time_mask_high(priv, - priv->hw_params.beacon_time_tsf_bits)); + u32 res = (base & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)) + + (addon & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)); if (base_low > addon_low) res += base_low - addon_low; else if (base_low < addon_low) { res += interval + base_low - addon_low; - res += (1 << priv->hw_params.beacon_time_tsf_bits); + res += (1 << il->hw_params.beacon_time_tsf_bits); } else - res += (1 << priv->hw_params.beacon_time_tsf_bits); + res += (1 << il->hw_params.beacon_time_tsf_bits); return cpu_to_le32(res); } @@ -1972,7 +1972,7 @@ EXPORT_SYMBOL(il_add_beacon_time); int il_pci_suspend(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); /* * This function is called when system goes into suspend state @@ -1981,7 +1981,7 @@ int il_pci_suspend(struct device *device) * it will not call apm_ops.stop() to stop the DMA operation. * Calling apm_ops.stop here to make sure we stop the DMA. */ - il_apm_stop(priv); + il_apm_stop(il); return 0; } @@ -1990,7 +1990,7 @@ EXPORT_SYMBOL(il_pci_suspend); int il_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); bool hw_rfkill = false; /* @@ -1999,18 +1999,18 @@ int il_pci_resume(struct device *device) */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - il_enable_interrupts(priv); + il_enable_interrupts(il); - if (!(il_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; if (hw_rfkill) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rfkill); + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); return 0; } @@ -2029,9 +2029,9 @@ EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ static void -il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) +il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) { - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; if (!ctx->is_active) @@ -2046,11 +2046,11 @@ il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - IL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", + IL_DEBUG_QOS(il, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); - il_send_cmd_pdu_async(priv, ctx->qos_cmd, + il_send_cmd_pdu_async(il, ctx->qos_cmd, sizeof(struct il_qosparam_cmd), &ctx->qos_data.def_qos_parm, NULL); } @@ -2060,11 +2060,11 @@ il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) */ int il_mac_config(struct ieee80211_hw *hw, u32 changed) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = conf->channel; - struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &il->current_ht_config; struct il_rxon_context *ctx; unsigned long flags = 0; int ret = 0; @@ -2072,23 +2072,23 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) int scan_active = 0; bool ht_changed[NUM_IL_RXON_CTX] = {}; - if (WARN_ON(!priv->cfg->ops->legacy)) + if (WARN_ON(!il->cfg->ops->legacy)) return -EOPNOTSUPP; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - IL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n", + IL_DEBUG_MAC80211(il, "enter to channel %d changed 0x%X\n", channel->hw_value, changed); - if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) { + if (unlikely(test_bit(STATUS_SCANNING, &il->status))) { scan_active = 1; - IL_DEBUG_MAC80211(priv, "scan active\n"); + IL_DEBUG_MAC80211(il, "scan active\n"); } if (changed & (IEEE80211_CONF_CHANGE_SMPS | IEEE80211_CONF_CHANGE_CHANNEL)) { /* mac80211 uses static for non-HT which is what we want */ - priv->current_ht_config.smps = conf->smps_mode; + il->current_ht_config.smps = conf->smps_mode; /* * Recalculate chain counts. @@ -2097,9 +2097,9 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) * set up the SM PS mode to OFF if an HT channel is * configured. */ - if (priv->cfg->ops->hcmd->set_rxon_chain) - for_each_context(priv, ctx) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + for_each_context(il, ctx) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); } /* during scanning mac80211 will delay channel setting until @@ -2110,23 +2110,23 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) goto set_ch_out; ch = channel->hw_value; - ch_info = il_get_channel_info(priv, channel->band, ch); + ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); + IL_DEBUG_MAC80211(il, "leave - invalid channel\n"); ret = -EINVAL; goto set_ch_out; } - if (priv->iw_mode == NL80211_IFTYPE_ADHOC && + if (il->iw_mode == NL80211_IFTYPE_ADHOC && !il_is_channel_ibss(ch_info)) { - IL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n"); + IL_DEBUG_MAC80211(il, "leave - not IBSS channel\n"); ret = -EINVAL; goto set_ch_out; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { /* Configure HT40 channels */ if (ctx->ht.enabled != conf_is_ht(conf)) { ctx->ht.enabled = conf_is_ht(conf); @@ -2162,61 +2162,61 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - il_set_rxon_channel(priv, channel, ctx); - il_set_rxon_ht(priv, ht_conf); + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(priv, ctx, channel->band, + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - if (priv->cfg->ops->legacy->update_bcast_stations) + if (il->cfg->ops->legacy->update_bcast_stations) ret = - priv->cfg->ops->legacy->update_bcast_stations(priv); + il->cfg->ops->legacy->update_bcast_stations(il); set_ch_out: /* The list of supported rates and rate mask can be different * for each band; since the band may have changed, reset * the rate mask to what mac80211 lists */ - il_set_rate(priv); + il_set_rate(il); } if (changed & (IEEE80211_CONF_CHANGE_PS | IEEE80211_CONF_CHANGE_IDLE)) { - ret = il_power_update_mode(priv, false); + ret = il_power_update_mode(il, false); if (ret) - IL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); + IL_DEBUG_MAC80211(il, "Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - IL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", - priv->tx_power_user_lmt, conf->power_level); + IL_DEBUG_MAC80211(il, "TX Power old=%d new=%d\n", + il->tx_power_user_lmt, conf->power_level); - il_set_tx_power(priv, conf->power_level, false); + il_set_tx_power(il, conf->power_level, false); } - if (!il_is_ready(priv)) { - IL_DEBUG_MAC80211(priv, "leave - not ready\n"); + if (!il_is_ready(il)) { + IL_DEBUG_MAC80211(il, "leave - not ready\n"); goto out; } if (scan_active) goto out; - for_each_context(priv, ctx) { + for_each_context(il, ctx) { if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); else - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Not re-sending same RXON configuration.\n"); if (ht_changed[ctx->ctxid]) - il_update_qos(priv, ctx); + il_update_qos(il, ctx); } out: - IL_DEBUG_MAC80211(priv, "leave\n"); - mutex_unlock(&priv->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); + mutex_unlock(&il->mutex); return ret; } EXPORT_SYMBOL(il_mac_config); @@ -2224,37 +2224,37 @@ EXPORT_SYMBOL(il_mac_config); void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; unsigned long flags; /* IBSS can only be the IL_RXON_CTX_BSS context */ - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (WARN_ON(!priv->cfg->ops->legacy)) + if (WARN_ON(!il->cfg->ops->legacy)) return; - mutex_lock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&il->mutex); + IL_DEBUG_MAC80211(il, "enter\n"); - spin_lock_irqsave(&priv->lock, flags); - memset(&priv->current_ht_config, 0, sizeof(struct il_ht_config)); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); + spin_unlock_irqrestore(&il->lock, flags); - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* new association get rid of ibss beacon skb */ - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); - priv->beacon_skb = NULL; + il->beacon_skb = NULL; - priv->timestamp = 0; + il->timestamp = 0; - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - il_scan_cancel_timeout(priv, 100); - if (!il_is_ready_rf(priv)) { - IL_DEBUG_MAC80211(priv, "leave - not ready\n"); - mutex_unlock(&priv->mutex); + il_scan_cancel_timeout(il, 100); + if (!il_is_ready_rf(il)) { + IL_DEBUG_MAC80211(il, "leave - not ready\n"); + mutex_unlock(&il->mutex); return; } @@ -2262,25 +2262,25 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, * clear RXON_FILTER_ASSOC_MSK bit */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); - il_set_rate(priv); + il_set_rate(il); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } EXPORT_SYMBOL(il_mac_reset_tsf); -static void il_ht_conf(struct il_priv *priv, +static void il_ht_conf(struct il_priv *il, struct ieee80211_vif *vif) { - struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &il->current_ht_config; struct ieee80211_sta *sta; struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_ASSOC(priv, "enter:\n"); + IL_DEBUG_ASSOC(il, "enter:\n"); if (!ctx->ht.enabled) return; @@ -2329,10 +2329,10 @@ static void il_ht_conf(struct il_priv *priv, break; } - IL_DEBUG_ASSOC(priv, "leave\n"); + IL_DEBUG_ASSOC(il, "leave\n"); } -static inline void il_set_no_assoc(struct il_priv *priv, +static inline void il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -2344,13 +2344,13 @@ static inline void il_set_no_assoc(struct il_priv *priv, */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = 0; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } static void il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; unsigned long flags; __le64 timestamp; struct sk_buff *skb = ieee80211_beacon_get(hw, vif); @@ -2358,35 +2358,35 @@ static void il_beacon_update(struct ieee80211_hw *hw, if (!skb) return; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->beacon_ctx) { - IL_ERR(priv, "update beacon but no beacon context!\n"); + if (!il->beacon_ctx) { + IL_ERR(il, "update beacon but no beacon context!\n"); dev_kfree_skb(skb); return; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); - priv->beacon_skb = skb; + il->beacon_skb = skb; timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; - priv->timestamp = le64_to_cpu(timestamp); + il->timestamp = le64_to_cpu(timestamp); - IL_DEBUG_MAC80211(priv, "leave\n"); - spin_unlock_irqrestore(&priv->lock, flags); + IL_DEBUG_MAC80211(il, "leave\n"); + spin_unlock_irqrestore(&il->lock, flags); - if (!il_is_ready_rf(priv)) { - IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(il)) { + IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); return; } - priv->cfg->ops->legacy->post_associate(priv); + il->cfg->ops->legacy->post_associate(il); } void il_mac_bss_info_changed(struct ieee80211_hw *hw, @@ -2394,29 +2394,29 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_bss_conf *bss_conf, u32 changes) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); int ret; - if (WARN_ON(!priv->cfg->ops->legacy)) + if (WARN_ON(!il->cfg->ops->legacy)) return; - IL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); + IL_DEBUG_MAC80211(il, "changes = 0x%X\n", changes); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (!il_is_alive(priv)) { - mutex_unlock(&priv->mutex); + if (!il_is_alive(il)) { + mutex_unlock(&il->mutex); return; } if (changes & BSS_CHANGED_QOS) { unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); ctx->qos_data.qos_active = bss_conf->qos; - il_update_qos(priv, ctx); - spin_unlock_irqrestore(&priv->lock, flags); + il_update_qos(il, ctx); + spin_unlock_irqrestore(&il->lock, flags); } if (changes & BSS_CHANGED_BEACON_ENABLED) { @@ -2426,25 +2426,25 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * any time. */ if (vif->bss_conf.enable_beacon) - priv->beacon_ctx = ctx; + il->beacon_ctx = ctx; else - priv->beacon_ctx = NULL; + il->beacon_ctx = NULL; } if (changes & BSS_CHANGED_BSSID) { - IL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); + IL_DEBUG_MAC80211(il, "BSSID %pM\n", bss_conf->bssid); /* * If there is currently a HW scan going on in the * background then we need to cancel it else the RXON * below/in post_associate will fail. */ - if (il_scan_cancel_timeout(priv, 100)) { - IL_WARN(priv, + if (il_scan_cancel_timeout(il, 100)) { + IL_WARN(il, "Aborted scan still in progress after 100ms\n"); - IL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(il, "leaving - scan abort failed.\n"); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return; } @@ -2454,7 +2454,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, bss_conf->bssid, ETH_ALEN); /* currently needed in a few places */ - memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); } else { ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -2471,7 +2471,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - IL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", + IL_DEBUG_MAC80211(il, "ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2480,10 +2480,10 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - IL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(il, "ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && - (priv->band != IEEE80211_BAND_5GHZ)) + (il->band != IEEE80211_BAND_5GHZ)) ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; else ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; @@ -2511,27 +2511,27 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_HT) { - il_ht_conf(priv, vif); + il_ht_conf(il, vif); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); } if (changes & BSS_CHANGED_ASSOC) { - IL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); + IL_DEBUG_MAC80211(il, "ASSOC %d\n", bss_conf->assoc); if (bss_conf->assoc) { - priv->timestamp = bss_conf->timestamp; + il->timestamp = bss_conf->timestamp; - if (!il_is_rfkill(priv)) - priv->cfg->ops->legacy->post_associate(priv); + if (!il_is_rfkill(il)) + il->cfg->ops->legacy->post_associate(il); } else - il_set_no_assoc(priv, vif); + il_set_no_assoc(il, vif); } if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - IL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", + IL_DEBUG_MAC80211(il, "Changes (%#x) while associated\n", changes); - ret = il_send_rxon_assoc(priv, ctx); + ret = il_send_rxon_assoc(il, ctx); if (!ret) { /* Sync active_rxon with latest change. */ memcpy((void *)&ctx->active, @@ -2544,54 +2544,54 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (vif->bss_conf.enable_beacon) { memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); - memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); - priv->cfg->ops->legacy->config_ap(priv); + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); + il->cfg->ops->legacy->config_ap(il); } else - il_set_no_assoc(priv, vif); + il_set_no_assoc(il, vif); } if (changes & BSS_CHANGED_IBSS) { - ret = priv->cfg->ops->legacy->manage_ibss_station(priv, vif, + ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, bss_conf->ibss_joined); if (ret) - IL_ERR(priv, "failed to %s IBSS station %pM\n", + IL_ERR(il, "failed to %s IBSS station %pM\n", bss_conf->ibss_joined ? "add" : "remove", bss_conf->bssid); } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } EXPORT_SYMBOL(il_mac_bss_info_changed); irqreturn_t il_isr(int irq, void *data) { - struct il_priv *priv = data; + struct il_priv *il = data; u32 inta, inta_mask; u32 inta_fh; unsigned long flags; - if (!priv) + if (!il) return IRQ_NONE; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Disable (but don't clear!) interrupts here to avoid * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = il_read32(priv, CSR_INT_MASK); /* just for debug */ - il_write32(priv, CSR_INT_MASK, 0x00000000); + inta_mask = il_read32(il, CSR_INT_MASK); /* just for debug */ + il_write32(il, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ - inta = il_read32(priv, CSR_INT); - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + inta = il_read32(il, CSR_INT); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); /* Ignore interrupt if there's nothing in NIC to service. * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - IL_DEBUG_ISR(priv, + IL_DEBUG_ISR(il, "Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -2599,29 +2599,29 @@ irqreturn_t il_isr(int irq, void *data) if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { /* Hardware disappeared. It might have already raised * an interrupt */ - IL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); + IL_WARN(il, "HARDWARE GONE?? INTA == 0x%08x\n", inta); goto unplugged; } - IL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + IL_DEBUG_ISR(il, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); inta &= ~CSR_INT_BIT_SCD; /* il_irq_tasklet() will service interrupts and re-enable them */ if (likely(inta || inta_fh)) - tasklet_schedule(&priv->irq_tasklet); + tasklet_schedule(&il->irq_tasklet); unplugged: - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return IRQ_HANDLED; none: /* re-enable interrupts here since we don't have anything to service. */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &priv->status)) - il_enable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; } EXPORT_SYMBOL(il_isr); @@ -2630,7 +2630,7 @@ EXPORT_SYMBOL(il_isr); * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this * function. */ -void il_tx_cmd_protection(struct il_priv *priv, +void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags) { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 92f37c9..1803954 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -88,9 +88,9 @@ struct il_cmd; #define IL_CMD(x) case x: return #x struct il_hcmd_ops { - int (*rxon_assoc)(struct il_priv *priv, struct il_rxon_context *ctx); - int (*commit_rxon)(struct il_priv *priv, struct il_rxon_context *ctx); - void (*set_rxon_chain)(struct il_priv *priv, + int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); + int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); + void (*set_rxon_chain)(struct il_priv *il, struct il_rxon_context *ctx); }; @@ -98,13 +98,13 @@ struct il_hcmd_utils_ops { u16 (*get_hcmd_size)(u8 cmd_id, u16 len); u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, u8 *data); - int (*request_scan)(struct il_priv *priv, struct ieee80211_vif *vif); - void (*post_scan)(struct il_priv *priv); + int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); + void (*post_scan)(struct il_priv *il); }; struct il_apm_ops { - int (*init)(struct il_priv *priv); - void (*config)(struct il_priv *priv); + int (*init)(struct il_priv *il); + void (*config)(struct il_priv *il); }; struct il_debugfs_ops { @@ -117,43 +117,43 @@ struct il_debugfs_ops { }; struct il_temp_ops { - void (*temperature)(struct il_priv *priv); + void (*temperature)(struct il_priv *il); }; struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params)(struct il_priv *priv); + int (*set_hw_params)(struct il_priv *il); /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct il_priv *priv, + void (*txq_update_byte_cnt_tbl)(struct il_priv *il, struct il_tx_queue *txq, u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct il_priv *priv, + int (*txq_attach_buf_to_tfd)(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct il_priv *priv, + void (*txq_free_tfd)(struct il_priv *il, struct il_tx_queue *txq); - int (*txq_init)(struct il_priv *priv, + int (*txq_init)(struct il_priv *il, struct il_tx_queue *txq); /* setup Rx handler */ - void (*rx_handler_setup)(struct il_priv *priv); + void (*rx_handler_setup)(struct il_priv *il); /* alive notification after init uCode load */ - void (*init_alive_start)(struct il_priv *priv); + void (*init_alive_start)(struct il_priv *il); /* check validity of rtc data address */ int (*is_valid_rtc_data_addr)(u32 addr); /* 1st ucode load */ - int (*load_ucode)(struct il_priv *priv); + int (*load_ucode)(struct il_priv *il); - void (*dump_nic_error_log)(struct il_priv *priv); - int (*dump_fh)(struct il_priv *priv, char **buf, bool display); - int (*set_channel_switch)(struct il_priv *priv, + void (*dump_nic_error_log)(struct il_priv *il); + int (*dump_fh)(struct il_priv *il, char **buf, bool display); + int (*set_channel_switch)(struct il_priv *il, struct ieee80211_channel_switch *ch_switch); /* power management */ struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct il_priv *priv); - void (*update_chain_flags)(struct il_priv *priv); + int (*send_tx_power) (struct il_priv *il); + void (*update_chain_flags)(struct il_priv *il); /* eeprom operations (as defined in iwl-eeprom.h) */ struct il_eeprom_ops eeprom_ops; @@ -166,15 +166,15 @@ struct il_lib_ops { }; struct il_led_ops { - int (*cmd)(struct il_priv *priv, struct il_led_cmd *led_cmd); + int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); }; struct il_legacy_ops { - void (*post_associate)(struct il_priv *priv); - void (*config_ap)(struct il_priv *priv); + void (*post_associate)(struct il_priv *il); + void (*config_ap)(struct il_priv *il); /* station management */ - int (*update_bcast_stations)(struct il_priv *priv); - int (*manage_ibss_station)(struct il_priv *priv, + int (*update_bcast_stations)(struct il_priv *il); + int (*manage_ibss_station)(struct il_priv *il, struct ieee80211_vif *vif, bool add); }; @@ -247,7 +247,7 @@ struct il_base_params { * on firmware version used. * * For example, - * if (IL_UCODE_API(priv->ucode_ver) >= 2) { + * if (IL_UCODE_API(il->ucode_ver) >= 2) { * Driver interacts with Firmware API version >= 2. * } else { * Driver interacts with Firmware API version 1. @@ -290,35 +290,35 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params); int il_mac_tx_last_beacon(struct ieee80211_hw *hw); -void il_set_rxon_hwcrypto(struct il_priv *priv, +void il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, int hw_decrypt); -int il_check_rxon_cmd(struct il_priv *priv, +int il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx); -int il_full_rxon_required(struct il_priv *priv, +int il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx); -int il_set_rxon_channel(struct il_priv *priv, +int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, struct il_rxon_context *ctx); -void il_set_flags_for_band(struct il_priv *priv, +void il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif); -u8 il_get_single_channel_number(struct il_priv *priv, +u8 il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band); -void il_set_rxon_ht(struct il_priv *priv, +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf); -bool il_is_ht40_tx_allowed(struct il_priv *priv, +bool il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap); -void il_connection_init_rx_config(struct il_priv *priv, +void il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx); -void il_set_rate(struct il_priv *priv); -int il_set_decrypted_flag(struct il_priv *priv, +void il_set_rate(struct il_priv *il); +int il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats); -void il_irq_handle_error(struct il_priv *priv); +void il_irq_handle_error(struct il_priv *il); int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void il_mac_remove_interface(struct ieee80211_hw *hw, @@ -326,42 +326,42 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, int il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p); -int il_alloc_txq_mem(struct il_priv *priv); -void il_txq_mem(struct il_priv *priv); +int il_alloc_txq_mem(struct il_priv *il); +void il_txq_mem(struct il_priv *il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int il_alloc_traffic_mem(struct il_priv *priv); -void il_free_traffic_mem(struct il_priv *priv); -void il_reset_traffic_log(struct il_priv *priv); -void il_dbg_log_tx_data_frame(struct il_priv *priv, +int il_alloc_traffic_mem(struct il_priv *il); +void il_free_traffic_mem(struct il_priv *il); +void il_reset_traffic_log(struct il_priv *il); +void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header); -void il_dbg_log_rx_data_frame(struct il_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header); const char *il_get_mgmt_string(int cmd); const char *il_get_ctrl_string(int cmd); -void il_clear_traffic_stats(struct il_priv *priv); -void il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, +void il_clear_traffic_stats(struct il_priv *il); +void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len); #else -static inline int il_alloc_traffic_mem(struct il_priv *priv) +static inline int il_alloc_traffic_mem(struct il_priv *il) { return 0; } -static inline void il_free_traffic_mem(struct il_priv *priv) +static inline void il_free_traffic_mem(struct il_priv *il) { } -static inline void il_reset_traffic_log(struct il_priv *priv) +static inline void il_reset_traffic_log(struct il_priv *il) { } -static inline void il_dbg_log_tx_data_frame(struct il_priv *priv, +static inline void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { } -static inline void il_dbg_log_rx_data_frame(struct il_priv *priv, +static inline void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { } -static inline void il_update_stats(struct il_priv *priv, bool is_tx, +static inline void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { } @@ -369,83 +369,83 @@ static inline void il_update_stats(struct il_priv *priv, bool is_tx, /***************************************************** * RX handlers. * **************************************************/ -void il_rx_pm_sleep_notif(struct il_priv *priv, +void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il_rx_pm_debug_statistics_notif(struct il_priv *priv, +void il_rx_pm_debug_statistics_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il_rx_reply_error(struct il_priv *priv, +void il_rx_reply_error(struct il_priv *il, struct il_rx_mem_buffer *rxb); /***************************************************** * RX ******************************************************/ -void il_cmd_queue_unmap(struct il_priv *priv); -void il_cmd_queue_free(struct il_priv *priv); -int il_rx_queue_alloc(struct il_priv *priv); -void il_rx_queue_update_write_ptr(struct il_priv *priv, +void il_cmd_queue_unmap(struct il_priv *il); +void il_cmd_queue_free(struct il_priv *il); +int il_rx_queue_alloc(struct il_priv *il); +void il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q); int il_rx_queue_space(const struct il_rx_queue *q); -void il_tx_cmd_complete(struct il_priv *priv, +void il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb); /* Handlers */ -void il_rx_spectrum_measure_notif(struct il_priv *priv, +void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il_recover_from_statistics(struct il_priv *priv, +void il_recover_from_statistics(struct il_priv *il, struct il_rx_packet *pkt); -void il_chswitch_done(struct il_priv *priv, bool is_success); -void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb); +void il_chswitch_done(struct il_priv *il, bool is_success); +void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb); /* TX helpers */ /***************************************************** * TX ******************************************************/ -void il_txq_update_write_ptr(struct il_priv *priv, +void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq); -int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id); -void il_tx_queue_reset(struct il_priv *priv, +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id); -void il_tx_queue_unmap(struct il_priv *priv, int txq_id); -void il_tx_queue_free(struct il_priv *priv, int txq_id); -void il_setup_watchdog(struct il_priv *priv); +void il_tx_queue_unmap(struct il_priv *il, int txq_id); +void il_tx_queue_free(struct il_priv *il, int txq_id); +void il_setup_watchdog(struct il_priv *il); /***************************************************** * TX power ****************************************************/ -int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force); +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); /******************************************************************************* * Rate ******************************************************************************/ -u8 il_get_lowest_plcp(struct il_priv *priv, +u8 il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx); /******************************************************************************* * Scanning ******************************************************************************/ -void il_init_scan_params(struct il_priv *priv); -int il_scan_cancel(struct il_priv *priv); -int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms); -void il_force_scan_end(struct il_priv *priv); +void il_init_scan_params(struct il_priv *il); +int il_scan_cancel(struct il_priv *il); +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); +void il_force_scan_end(struct il_priv *il); int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req); -void il_internal_short_hw_scan(struct il_priv *priv); -int il_force_reset(struct il_priv *priv, bool external); -u16 il_fill_probe_req(struct il_priv *priv, +void il_internal_short_hw_scan(struct il_priv *il); +int il_force_reset(struct il_priv *il, bool external); +u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ie, int ie_len, int left); -void il_setup_rx_scan_handlers(struct il_priv *priv); -u16 il_get_active_dwell_time(struct il_priv *priv, +void il_setup_rx_scan_handlers(struct il_priv *il); +u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, u8 n_probes); -u16 il_get_passive_dwell_time(struct il_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, struct ieee80211_vif *vif); -void il_setup_scan_deferred_work(struct il_priv *priv); -void il_cancel_scan_deferred_work(struct il_priv *priv); +void il_setup_scan_deferred_work(struct il_priv *il); +void il_cancel_scan_deferred_work(struct il_priv *il); /* For faster active scanning, scan will move to the next channel if fewer than * PLCP_QUIET_THRESH packets are heard on this channel within @@ -463,37 +463,37 @@ void il_cancel_scan_deferred_work(struct il_priv *priv); *****************************************************/ const char *il_get_cmd_string(u8 cmd); -int __must_check il_send_cmd_sync(struct il_priv *priv, +int __must_check il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd); -int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd); -int __must_check il_send_cmd_pdu(struct il_priv *priv, u8 id, +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); +int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data); -int il_send_cmd_pdu_async(struct il_priv *priv, u8 id, u16 len, +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt)); -int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd); +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); /***************************************************** * PCI * *****************************************************/ -static inline u16 il_pcie_link_ctl(struct il_priv *priv) +static inline u16 il_pcie_link_ctl(struct il_priv *il) { int pos; u16 pci_lnk_ctl; - pos = pci_pcie_cap(priv->pci_dev); - pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); + pos = pci_pcie_cap(il->pci_dev); + pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); return pci_lnk_ctl; } void il_bg_watchdog(unsigned long data); -u32 il_usecs_to_beacons(struct il_priv *priv, +u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval); -__le32 il_add_beacon_time(struct il_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, u32 beacon_interval); #ifdef CONFIG_PM @@ -512,24 +512,24 @@ extern const struct dev_pm_ops il_pm_ops; /***************************************************** * Error Handling Debugging ******************************************************/ -void il4965_dump_nic_error_log(struct il_priv *priv); +void il4965_dump_nic_error_log(struct il_priv *il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *priv, +void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx); #else -static inline void il_print_rx_config_cmd(struct il_priv *priv, +static inline void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { } #endif -void il_clear_isr_stats(struct il_priv *priv); +void il_clear_isr_stats(struct il_priv *il); /***************************************************** * GEOS ******************************************************/ -int il_init_geos(struct il_priv *priv); -void il_free_geos(struct il_priv *priv); +int il_init_geos(struct il_priv *il); +void il_free_geos(struct il_priv *il); /*************** DRIVER STATUS FUNCTIONS *****/ @@ -552,71 +552,71 @@ void il_free_geos(struct il_priv *priv); #define STATUS_FW_ERROR 17 #define STATUS_CHANNEL_SWITCH_PENDING 18 -static inline int il_is_ready(struct il_priv *priv) +static inline int il_is_ready(struct il_priv *il) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ - return test_bit(STATUS_READY, &priv->status) && - test_bit(STATUS_GEO_CONFIGURED, &priv->status) && - !test_bit(STATUS_EXIT_PENDING, &priv->status); + return test_bit(STATUS_READY, &il->status) && + test_bit(STATUS_GEO_CONFIGURED, &il->status) && + !test_bit(STATUS_EXIT_PENDING, &il->status); } -static inline int il_is_alive(struct il_priv *priv) +static inline int il_is_alive(struct il_priv *il) { - return test_bit(STATUS_ALIVE, &priv->status); + return test_bit(STATUS_ALIVE, &il->status); } -static inline int il_is_init(struct il_priv *priv) +static inline int il_is_init(struct il_priv *il) { - return test_bit(STATUS_INIT, &priv->status); + return test_bit(STATUS_INIT, &il->status); } -static inline int il_is_rfkill_hw(struct il_priv *priv) +static inline int il_is_rfkill_hw(struct il_priv *il) { - return test_bit(STATUS_RF_KILL_HW, &priv->status); + return test_bit(STATUS_RF_KILL_HW, &il->status); } -static inline int il_is_rfkill(struct il_priv *priv) +static inline int il_is_rfkill(struct il_priv *il) { - return il_is_rfkill_hw(priv); + return il_is_rfkill_hw(il); } -static inline int il_is_ctkill(struct il_priv *priv) +static inline int il_is_ctkill(struct il_priv *il) { - return test_bit(STATUS_CT_KILL, &priv->status); + return test_bit(STATUS_CT_KILL, &il->status); } -static inline int il_is_ready_rf(struct il_priv *priv) +static inline int il_is_ready_rf(struct il_priv *il) { - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) return 0; - return il_is_ready(priv); + return il_is_ready(il); } -extern void il_send_bt_config(struct il_priv *priv); -extern int il_send_statistics_request(struct il_priv *priv, +extern void il_send_bt_config(struct il_priv *il); +extern int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear); -void il_apm_stop(struct il_priv *priv); -int il_apm_init(struct il_priv *priv); +void il_apm_stop(struct il_priv *il); +int il_apm_init(struct il_priv *il); -int il_send_rxon_timing(struct il_priv *priv, +int il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx); -static inline int il_send_rxon_assoc(struct il_priv *priv, +static inline int il_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { - return priv->cfg->ops->hcmd->rxon_assoc(priv, ctx); + return il->cfg->ops->hcmd->rxon_assoc(il, ctx); } -static inline int il_commit_rxon(struct il_priv *priv, +static inline int il_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { - return priv->cfg->ops->hcmd->commit_rxon(priv, ctx); + return il->cfg->ops->hcmd->commit_rxon(il, ctx); } static inline const struct ieee80211_supported_band *il_get_hw_mode( - struct il_priv *priv, enum ieee80211_band band) + struct il_priv *il, enum ieee80211_band band) { - return priv->hw->wiphy->bands[band]; + return il->hw->wiphy->bands[band]; } /* mac80211 handlers */ @@ -627,7 +627,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); -void il_tx_cmd_protection(struct il_priv *priv, +void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 1bbad76..657da25 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -37,7 +37,7 @@ extern u32 iwlegacy_debug_level; #define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) #define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) -#define il_print_hex_error(priv, p, len) \ +#define il_print_hex_error(il, p, len) \ do { \ print_hex_dump(KERN_ERR, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ @@ -60,9 +60,9 @@ do { \ __func__ , ## args); \ } while (0) -#define il_print_hex_dump(priv, level, p, len) \ +#define il_print_hex_dump(il, level, p, len) \ do { \ - if (il_get_debug_level(priv) & level) \ + if (il_get_debug_level(il) & level) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) @@ -70,21 +70,21 @@ do { \ #else #define IL_DEBUG(__priv, level, fmt, args...) #define IL_DEBUG_LIMIT(__priv, level, fmt, args...) -static inline void il_print_hex_dump(struct il_priv *priv, int level, +static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int il_dbgfs_register(struct il_priv *priv, const char *name); -void il_dbgfs_unregister(struct il_priv *priv); +int il_dbgfs_register(struct il_priv *il, const char *name); +void il_dbgfs_unregister(struct il_priv *il); #else static inline int -il_dbgfs_register(struct il_priv *priv, const char *name) +il_dbgfs_register(struct il_priv *il, const char *name) { return 0; } -static inline void il_dbgfs_unregister(struct il_priv *priv) +static inline void il_dbgfs_unregister(struct il_priv *il) { } #endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 057dec5..f2f2eba 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -36,7 +36,7 @@ /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ - if (!debugfs_create_file(#name, mode, parent, priv, \ + if (!debugfs_create_file(#name, mode, parent, il, \ &il_dbgfs_##name##_ops)) \ goto err; \ } while (0) @@ -106,7 +106,7 @@ static ssize_t il_dbgfs_tx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char *buf; int pos = 0; @@ -122,20 +122,20 @@ static ssize_t il_dbgfs_tx_statistics_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_mgmt_string(cnt), - priv->tx_stats.mgmt[cnt]); + il->tx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_ctrl_string(cnt), - priv->tx_stats.ctrl[cnt]); + il->tx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - priv->tx_stats.data_cnt); + il->tx_stats.data_cnt); pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - priv->tx_stats.data_bytes); + il->tx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; @@ -146,7 +146,7 @@ il_dbgfs_clear_traffic_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; u32 clear_flag; char buf[8]; int buf_size; @@ -157,7 +157,7 @@ il_dbgfs_clear_traffic_statistics_write(struct file *file, return -EFAULT; if (sscanf(buf, "%x", &clear_flag) != 1) return -EFAULT; - il_clear_traffic_stats(priv); + il_clear_traffic_stats(il); return count; } @@ -166,7 +166,7 @@ static ssize_t il_dbgfs_rx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char *buf; int pos = 0; int cnt; @@ -182,20 +182,20 @@ static ssize_t il_dbgfs_rx_statistics_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_mgmt_string(cnt), - priv->rx_stats.mgmt[cnt]); + il->rx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_ctrl_string(cnt), - priv->rx_stats.ctrl[cnt]); + il->rx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - priv->rx_stats.data_cnt); + il->rx_stats.data_cnt); pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - priv->rx_stats.data_bytes); + il->rx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -214,28 +214,28 @@ static ssize_t il_dbgfs_sram_read(struct file *file, ssize_t ret; int i; int pos = 0; - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; size_t bufsz; /* default is to dump the entire data segment */ - if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { - priv->dbgfs_sram_offset = 0x800000; - if (priv->ucode_type == UCODE_INIT) - priv->dbgfs_sram_len = priv->ucode_init_data.len; + if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) { + il->dbgfs_sram_offset = 0x800000; + if (il->ucode_type == UCODE_INIT) + il->dbgfs_sram_len = il->ucode_init_data.len; else - priv->dbgfs_sram_len = priv->ucode_data.len; + il->dbgfs_sram_len = il->ucode_data.len; } - bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10; + bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; buf = kmalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", - priv->dbgfs_sram_len); + il->dbgfs_sram_len); pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", - priv->dbgfs_sram_offset); - for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { - val = il_read_targ_mem(priv, priv->dbgfs_sram_offset + \ - priv->dbgfs_sram_len - i); + il->dbgfs_sram_offset); + for (i = il->dbgfs_sram_len; i > 0; i -= 4) { + val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ + il->dbgfs_sram_len - i); if (i < 4) { switch (i) { case 1: @@ -264,7 +264,7 @@ static ssize_t il_dbgfs_sram_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[64]; int buf_size; u32 offset, len; @@ -275,11 +275,11 @@ static ssize_t il_dbgfs_sram_write(struct file *file, return -EFAULT; if (sscanf(buf, "%x,%x", &offset, &len) == 2) { - priv->dbgfs_sram_offset = offset; - priv->dbgfs_sram_len = len; + il->dbgfs_sram_offset = offset; + il->dbgfs_sram_len = len; } else { - priv->dbgfs_sram_offset = 0; - priv->dbgfs_sram_len = 0; + il->dbgfs_sram_offset = 0; + il->dbgfs_sram_len = 0; } return count; @@ -289,24 +289,24 @@ static ssize_t il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct il_station_entry *station; - int max_sta = priv->hw_params.max_stations; + int max_sta = il->hw_params.max_stations; char *buf; int i, j, pos = 0; ssize_t ret; /* Add 30 for initial string */ - const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); + const size_t bufsz = 30 + sizeof(char) * 500 * (il->num_stations); buf = kmalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", - priv->num_stations); + il->num_stations); for (i = 0; i < max_sta; i++) { - station = &priv->stations[i]; + station = &il->stations[i]; if (!station->used) continue; pos += scnprintf(buf + pos, bufsz - pos, @@ -349,32 +349,32 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, loff_t *ppos) { ssize_t ret; - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0, ofs = 0, buf_size = 0; const u8 *ptr; char *buf; u16 eeprom_ver; - size_t eeprom_len = priv->cfg->base_params->eeprom_size; + size_t eeprom_len = il->cfg->base_params->eeprom_size; buf_size = 4 * eeprom_len + 256; if (eeprom_len % 16) { - IL_ERR(priv, "NVM size is not multiple of 16.\n"); + IL_ERR(il, "NVM size is not multiple of 16.\n"); return -ENODATA; } - ptr = priv->eeprom; + ptr = il->eeprom; if (!ptr) { - IL_ERR(priv, "Invalid EEPROM memory\n"); + IL_ERR(il, "Invalid EEPROM memory\n"); return -ENOMEM; } /* 4 characters for byte 0xYY */ buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } - eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n", eeprom_ver); for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { @@ -395,23 +395,23 @@ static ssize_t il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct ieee80211_channel *channels = NULL; const struct ieee80211_supported_band *supp_band = NULL; int pos = 0, i, bufsz = PAGE_SIZE; char *buf; ssize_t ret; - if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) + if (!test_bit(STATUS_GEO_CONFIGURED, &il->status)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } - supp_band = il_get_hw_mode(priv, IEEE80211_BAND_2GHZ); + supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ); if (supp_band) { channels = supp_band->channels; @@ -434,7 +434,7 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, IEEE80211_CHAN_PASSIVE_SCAN ? "passive only" : "active/passive"); } - supp_band = il_get_hw_mode(priv, IEEE80211_BAND_5GHZ); + supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); if (supp_band) { channels = supp_band->channels; @@ -466,43 +466,43 @@ static ssize_t il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[512]; int pos = 0; const size_t bufsz = sizeof(buf); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", - test_bit(STATUS_HCMD_ACTIVE, &priv->status)); + test_bit(STATUS_HCMD_ACTIVE, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", - test_bit(STATUS_INT_ENABLED, &priv->status)); + test_bit(STATUS_INT_ENABLED, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", - test_bit(STATUS_RF_KILL_HW, &priv->status)); + test_bit(STATUS_RF_KILL_HW, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", - test_bit(STATUS_CT_KILL, &priv->status)); + test_bit(STATUS_CT_KILL, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", - test_bit(STATUS_INIT, &priv->status)); + test_bit(STATUS_INIT, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", - test_bit(STATUS_ALIVE, &priv->status)); + test_bit(STATUS_ALIVE, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", - test_bit(STATUS_READY, &priv->status)); + test_bit(STATUS_READY, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", - test_bit(STATUS_TEMPERATURE, &priv->status)); + test_bit(STATUS_TEMPERATURE, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", - test_bit(STATUS_GEO_CONFIGURED, &priv->status)); + test_bit(STATUS_GEO_CONFIGURED, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", - test_bit(STATUS_EXIT_PENDING, &priv->status)); + test_bit(STATUS_EXIT_PENDING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", - test_bit(STATUS_STATISTICS, &priv->status)); + test_bit(STATUS_STATISTICS, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", - test_bit(STATUS_SCANNING, &priv->status)); + test_bit(STATUS_SCANNING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", - test_bit(STATUS_SCAN_ABORTING, &priv->status)); + test_bit(STATUS_SCAN_ABORTING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", - test_bit(STATUS_SCAN_HW, &priv->status)); + test_bit(STATUS_SCAN_HW, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", - test_bit(STATUS_POWER_PMI, &priv->status)); + test_bit(STATUS_POWER_PMI, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", - test_bit(STATUS_FW_ERROR, &priv->status)); + test_bit(STATUS_FW_ERROR, &il->status)); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -510,7 +510,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -519,7 +519,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -527,46 +527,46 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, "Interrupt Statistics Report:\n"); pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", - priv->isr_stats.hw); + il->isr_stats.hw); pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", - priv->isr_stats.sw); - if (priv->isr_stats.sw || priv->isr_stats.hw) { + il->isr_stats.sw); + if (il->isr_stats.sw || il->isr_stats.hw) { pos += scnprintf(buf + pos, bufsz - pos, "\tLast Restarting Code: 0x%X\n", - priv->isr_stats.err_code); + il->isr_stats.err_code); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", - priv->isr_stats.sch); + il->isr_stats.sch); pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", - priv->isr_stats.alive); + il->isr_stats.alive); #endif pos += scnprintf(buf + pos, bufsz - pos, "HW RF KILL switch toggled:\t %u\n", - priv->isr_stats.rfkill); + il->isr_stats.rfkill); pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", - priv->isr_stats.ctkill); + il->isr_stats.ctkill); pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", - priv->isr_stats.wakeup); + il->isr_stats.wakeup); pos += scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n", - priv->isr_stats.rx); + il->isr_stats.rx); for (cnt = 0; cnt < REPLY_MAX; cnt++) { - if (priv->isr_stats.rx_handlers[cnt] > 0) + if (il->isr_stats.rx_handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", il_get_cmd_string(cnt), - priv->isr_stats.rx_handlers[cnt]); + il->isr_stats.rx_handlers[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", - priv->isr_stats.tx); + il->isr_stats.tx); pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", - priv->isr_stats.unhandled); + il->isr_stats.unhandled); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -577,7 +577,7 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; u32 reset_flag; @@ -589,7 +589,7 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, if (sscanf(buf, "%x", &reset_flag) != 1) return -EFAULT; if (reset_flag == 0) - il_clear_isr_stats(priv); + il_clear_isr_stats(il); return count; } @@ -598,13 +598,13 @@ static ssize_t il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct il_rxon_context *ctx; int pos = 0, i; char buf[256 * NUM_IL_RXON_CTX]; const size_t bufsz = sizeof(buf); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", ctx->ctxid); for (i = 0; i < AC_NUM; i++) { @@ -626,7 +626,7 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int ht40; @@ -637,10 +637,10 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, return -EFAULT; if (sscanf(buf, "%d", &ht40) != 1) return -EFAULT; - if (!il_is_any_associated(priv)) - priv->disable_ht40 = ht40 ? true : false; + if (!il_is_any_associated(il)) + il->disable_ht40 = ht40 ? true : false; else { - IL_ERR(priv, "Sta associated with AP - " + IL_ERR(il, "Sta associated with AP - " "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } @@ -652,14 +652,14 @@ static ssize_t il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[100]; int pos = 0; const size_t bufsz = sizeof(buf); pos += scnprintf(buf + pos, bufsz - pos, "11n 40MHz Mode: %s\n", - priv->disable_ht40 ? "Disabled" : "Enabled"); + il->disable_ht40 ? "Disabled" : "Enabled"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -676,39 +676,39 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0, ofs = 0; int cnt = 0, entry; struct il_tx_queue *txq; struct il_queue *q; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; char *buf; int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (priv->cfg->base_params->num_of_queues * 32 * 8) + 400; + (il->cfg->base_params->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; - if (!priv->txq) { - IL_ERR(priv, "txq not ready\n"); + if (!il->txq) { + IL_ERR(il, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate buffer\n"); + IL_ERR(il, "Can not allocate buffer\n"); return -ENOMEM; } pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); - for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { - txq = &priv->txq[cnt]; + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; q = &txq->q; pos += scnprintf(buf + pos, bufsz - pos, "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, q->read_ptr, q->write_ptr); } - if (priv->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { - ptr = priv->tx_traffic; + if (il->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { + ptr = il->tx_traffic; pos += scnprintf(buf + pos, bufsz - pos, - "Tx Traffic idx: %u\n", priv->tx_traffic_idx); + "Tx Traffic idx: %u\n", il->tx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { @@ -728,10 +728,10 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, "read: %u, write: %u\n", rxq->read, rxq->write); - if (priv->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { - ptr = priv->rx_traffic; + if (il->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { + ptr = il->rx_traffic; pos += scnprintf(buf + pos, bufsz - pos, - "Rx Traffic idx: %u\n", priv->rx_traffic_idx); + "Rx Traffic idx: %u\n", il->rx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { @@ -755,7 +755,7 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int traffic_log; @@ -767,7 +767,7 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, if (sscanf(buf, "%d", &traffic_log) != 1) return -EFAULT; if (traffic_log == 0) - il_reset_traffic_log(priv); + il_reset_traffic_log(il); return count; } @@ -776,7 +776,7 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct il_tx_queue *txq; struct il_queue *q; char *buf; @@ -784,24 +784,24 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, int cnt; int ret; const size_t bufsz = sizeof(char) * 64 * - priv->cfg->base_params->num_of_queues; + il->cfg->base_params->num_of_queues; - if (!priv->txq) { - IL_ERR(priv, "txq not ready\n"); + if (!il->txq) { + IL_ERR(il, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; - for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { - txq = &priv->txq[cnt]; + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; q = &txq->q; pos += scnprintf(buf + pos, bufsz - pos, "hwq %.2d: read=%u write=%u stop=%d" " swq_id=%#.2x (ac %d/hwq %d)\n", cnt, q->read_ptr, q->write_ptr, - !!test_bit(cnt, priv->queue_stopped), + !!test_bit(cnt, il->queue_stopped), txq->swq_id, txq->swq_id & 3, (txq->swq_id >> 2) & 0x1f); if (cnt >= 4) @@ -809,7 +809,7 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, /* for the ACs, display the stop count too */ pos += scnprintf(buf + pos, bufsz - pos, " stop-count: %d\n", - atomic_read(&priv->queue_stop_count[cnt])); + atomic_read(&il->queue_stop_count[cnt])); } ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -820,8 +820,8 @@ static ssize_t il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - struct il_rx_queue *rxq = &priv->rxq; + struct il_priv *il = file->private_data; + struct il_rx_queue *rxq = &il->rxq; char buf[256]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -846,8 +846,8 @@ static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, count, ppos); } @@ -855,8 +855,8 @@ static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, count, ppos); } @@ -864,8 +864,8 @@ static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, count, ppos); } @@ -873,7 +873,7 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -881,10 +881,10 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, ssize_t ret; struct il_sensitivity_data *data; - data = &priv->sensitivity_data; + data = &il->sensitivity_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -954,7 +954,7 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -962,10 +962,10 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, ssize_t ret; struct il_chain_noise_data *data; - data = &priv->chain_noise_data; + data = &il->chain_noise_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -1012,13 +1012,13 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[60]; int pos = 0; const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = il_read32(priv, CSR_GP_CNTRL) & + pwrsave_status = il_read32(il, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); @@ -1035,7 +1035,7 @@ static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int clear; @@ -1048,9 +1048,9 @@ static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, return -EFAULT; /* make request to uCode to retrieve statistics information */ - mutex_lock(&priv->mutex); - il_send_statistics_request(priv, CMD_SYNC, true); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il_send_statistics_request(il, CMD_SYNC, true); + mutex_unlock(&il->mutex); return count; } @@ -1059,12 +1059,12 @@ static ssize_t il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.flags)); + le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1072,12 +1072,12 @@ static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.filter_flags)); + le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1085,13 +1085,13 @@ static ssize_t il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char *buf; int pos = 0; ssize_t ret = -EFAULT; - if (priv->cfg->ops->lib->dump_fh) { - ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true); + if (il->cfg->ops->lib->dump_fh) { + ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); if (buf) { ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); @@ -1106,13 +1106,13 @@ static ssize_t il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char buf[12]; const size_t bufsz = sizeof(buf); pos += scnprintf(buf + pos, bufsz - pos, "%d\n", - priv->missed_beacon_threshold); + il->missed_beacon_threshold); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -1121,7 +1121,7 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int missed; @@ -1135,10 +1135,10 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || missed > IL_MISSED_BEACON_THRESHOLD_MAX) - priv->missed_beacon_threshold = + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; else - priv->missed_beacon_threshold = missed; + il->missed_beacon_threshold = missed; return count; } @@ -1147,13 +1147,13 @@ static ssize_t il_dbgfs_force_reset_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char buf[300]; const size_t bufsz = sizeof(buf); struct il_force_reset *force_reset; - force_reset = &priv->force_reset; + force_reset = &il->force_reset; pos += scnprintf(buf + pos, bufsz - pos, "\tnumber of reset request: %d\n", @@ -1176,9 +1176,9 @@ static ssize_t il_dbgfs_force_reset_write(struct file *file, size_t count, loff_t *ppos) { int ret; - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; - ret = il_force_reset(priv, true); + ret = il_force_reset(il, true); return ret ? ret : count; } @@ -1187,7 +1187,7 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int timeout; @@ -1201,8 +1201,8 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) timeout = IL_DEF_WD_TIMEOUT; - priv->cfg->base_params->wd_timeout = timeout; - il_setup_watchdog(priv); + il->cfg->base_params->wd_timeout = timeout; + il_setup_watchdog(il); return count; } @@ -1230,16 +1230,16 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout); * Create the debugfs files and directories * */ -int il_dbgfs_register(struct il_priv *priv, const char *name) +int il_dbgfs_register(struct il_priv *il, const char *name) { - struct dentry *phyd = priv->hw->wiphy->debugfsdir; + struct dentry *phyd = il->hw->wiphy->debugfsdir; struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; dir_drv = debugfs_create_dir(name, phyd); if (!dir_drv) return -ENOMEM; - priv->debugfs_dir = dir_drv; + il->debugfs_dir = dir_drv; dir_data = debugfs_create_dir("data", dir_drv); if (!dir_data) @@ -1274,26 +1274,26 @@ int il_dbgfs_register(struct il_priv *priv, const char *name) DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); - if (priv->cfg->base_params->sensitivity_calib_by_driver) + if (il->cfg->base_params->sensitivity_calib_by_driver) DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); - if (priv->cfg->base_params->chain_noise_calib_by_driver) + if (il->cfg->base_params->chain_noise_calib_by_driver) DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); - if (priv->cfg->base_params->sensitivity_calib_by_driver) + if (il->cfg->base_params->sensitivity_calib_by_driver) DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, - &priv->disable_sens_cal); - if (priv->cfg->base_params->chain_noise_calib_by_driver) + &il->disable_sens_cal); + if (il->cfg->base_params->chain_noise_calib_by_driver) DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, - &priv->disable_chain_noise_cal); + &il->disable_chain_noise_cal); DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, - &priv->disable_tx_power_cal); + &il->disable_tx_power_cal); return 0; err: - IL_ERR(priv, "Can't create the debugfs directory\n"); - il_dbgfs_unregister(priv); + IL_ERR(il, "Can't create the debugfs directory\n"); + il_dbgfs_unregister(il); return -ENOMEM; } EXPORT_SYMBOL(il_dbgfs_register); @@ -1302,12 +1302,12 @@ EXPORT_SYMBOL(il_dbgfs_register); * Remove the debugfs files and directories * */ -void il_dbgfs_unregister(struct il_priv *priv) +void il_dbgfs_unregister(struct il_priv *il) { - if (!priv->debugfs_dir) + if (!il->debugfs_dir) return; - debugfs_remove_recursive(priv->debugfs_dir); - priv->debugfs_dir = NULL; + debugfs_remove_recursive(il->debugfs_dir); + il->debugfs_dir = NULL; } EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 20c44f3..824d193 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -106,7 +106,7 @@ struct il_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt); @@ -321,7 +321,7 @@ struct il_device_cmd { struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt); u32 flags; @@ -476,7 +476,7 @@ struct il_station_priv_common { }; /* - * il_station_priv: Driver's private station information + * il_station_priv: Driver's ilate station information * * When mac80211 creates a station it reserves some space (hw->sta_data_size) * in the structure for use by driver. This structure is places in that @@ -494,7 +494,7 @@ struct il_station_priv { }; /** - * struct il_vif_priv - driver's private per-interface information + * struct il_vif_priv - driver's ilate per-interface information * * When mac80211 allocates a virtual interface, it can allocate * space for us to put data into. @@ -625,7 +625,7 @@ struct il_hw_params { * il4965_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void il4965_update_chain_flags(struct il_priv *priv); +extern void il4965_update_chain_flags(struct il_priv *il); extern const u8 iwlegacy_bcast_addr[ETH_ALEN]; extern int il_queue_space(const struct il_queue *q); static inline int il_queue_used(const struct il_queue *q, int i) @@ -973,7 +973,7 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[REPLY_MAX])(struct il_priv *priv, + void (*rx_handlers[REPLY_MAX])(struct il_priv *il, struct il_rx_mem_buffer *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -1247,14 +1247,14 @@ struct il_priv { bool led_registered; }; /*il_priv */ -static inline void il_txq_ctx_activate(struct il_priv *priv, int txq_id) +static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) { - set_bit(txq_id, &priv->txq_ctx_active_msk); + set_bit(txq_id, &il->txq_ctx_active_msk); } -static inline void il_txq_ctx_deactivate(struct il_priv *priv, int txq_id) +static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) { - clear_bit(txq_id, &priv->txq_ctx_active_msk); + clear_bit(txq_id, &il->txq_ctx_active_msk); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1265,15 +1265,15 @@ static inline void il_txq_ctx_deactivate(struct il_priv *priv, int txq_id) * level will be used if set, otherwise the global debug level which can be * set via module parameter is used. */ -static inline u32 il_get_debug_level(struct il_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *il) { - if (priv->debug_level) - return priv->debug_level; + if (il->debug_level) + return il->debug_level; else return iwlegacy_debug_level; } #else -static inline u32 il_get_debug_level(struct il_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *il) { return iwlegacy_debug_level; } @@ -1281,11 +1281,11 @@ static inline u32 il_get_debug_level(struct il_priv *priv) static inline struct ieee80211_hdr * -il_tx_queue_get_hdr(struct il_priv *priv, +il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx) { - if (priv->txq[txq_id].txb[idx].skb) - return (struct ieee80211_hdr *)priv->txq[txq_id]. + if (il->txq[txq_id].txb[idx].skb) + return (struct ieee80211_hdr *)il->txq[txq_id]. txb[idx].skb->data; return NULL; } @@ -1298,21 +1298,21 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif) return vif_priv->ctx; } -#define for_each_context(priv, ctx) \ - for (ctx = &priv->contexts[IL_RXON_CTX_BSS]; \ - ctx < &priv->contexts[NUM_IL_RXON_CTX]; ctx++) \ - if (priv->valid_contexts & BIT(ctx->ctxid)) +#define for_each_context(il, ctx) \ + for (ctx = &il->contexts[IL_RXON_CTX_BSS]; \ + ctx < &il->contexts[NUM_IL_RXON_CTX]; ctx++) \ + if (il->valid_contexts & BIT(ctx->ctxid)) -static inline int il_is_associated(struct il_priv *priv, +static inline int il_is_associated(struct il_priv *il, enum il_rxon_context_id ctxid) { - return (priv->contexts[ctxid].active.filter_flags & + return (il->contexts[ctxid].active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int il_is_any_associated(struct il_priv *priv) +static inline int il_is_any_associated(struct il_priv *il) { - return il_is_associated(priv, IL_RXON_CTX_BSS); + return il_is_associated(il, IL_RXON_CTX_BSS); } static inline int il_is_associated_ctx(struct il_rxon_context *ctx) @@ -1350,15 +1350,15 @@ il_is_channel_ibss(const struct il_channel_info *ch) } static inline void -__il_free_pages(struct il_priv *priv, struct page *page) +__il_free_pages(struct il_priv *il, struct page *page) { - __free_pages(page, priv->hw_params.rx_page_order); - priv->alloc_rxb_page--; + __free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; } -static inline void il_free_pages(struct il_priv *priv, unsigned long page) +static inline void il_free_pages(struct il_priv *il, unsigned long page) { - free_pages(page, priv->hw_params.rx_page_order); - priv->alloc_rxb_page--; + free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; } #endif /* __il_dev_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 1075f1d..5edec73 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -87,7 +87,7 @@ * is contained in the eeprom map itself. * * During init, we copy the eeprom information and channel map - * information into priv->channel_info_24/52 and priv->channel_map_24/52 + * information into il->channel_info_24/52 and il->channel_map_24/52 * * channel_map_24/52 provides the index in the channel_info array for a * given channel. We have to have two separate maps as there is channel @@ -142,18 +142,18 @@ static const u8 iwlegacy_eeprom_band_7[] = { /* 5.2 ht40 channel */ * ******************************************************************************/ -static int il_eeprom_verify_signature(struct il_priv *priv) +static int il_eeprom_verify_signature(struct il_priv *il) { - u32 gp = il_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = il_read32(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; - IL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); + IL_DEBUG_EEPROM(il, "EEPROM signature=0x%08x\n", gp); switch (gp) { case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IL_ERR(priv, "bad EEPROM signature," + IL_ERR(il, "bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; @@ -162,59 +162,59 @@ static int il_eeprom_verify_signature(struct il_priv *priv) } const u8 -*il_eeprom_query_addr(const struct il_priv *priv, size_t offset) +*il_eeprom_query_addr(const struct il_priv *il, size_t offset) { - BUG_ON(offset >= priv->cfg->base_params->eeprom_size); - return &priv->eeprom[offset]; + BUG_ON(offset >= il->cfg->base_params->eeprom_size); + return &il->eeprom[offset]; } EXPORT_SYMBOL(il_eeprom_query_addr); -u16 il_eeprom_query16(const struct il_priv *priv, size_t offset) +u16 il_eeprom_query16(const struct il_priv *il, size_t offset) { - if (!priv->eeprom) + if (!il->eeprom) return 0; - return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8); + return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); } EXPORT_SYMBOL(il_eeprom_query16); /** * il_eeprom_init - read EEPROM contents * - * Load the EEPROM contents from adapter into priv->eeprom + * Load the EEPROM contents from adapter into il->eeprom * * NOTE: This routine uses the non-debug IO access functions. */ -int il_eeprom_init(struct il_priv *priv) +int il_eeprom_init(struct il_priv *il) { __le16 *e; - u32 gp = il_read32(priv, CSR_EEPROM_GP); + u32 gp = il_read32(il, CSR_EEPROM_GP); int sz; int ret; u16 addr; /* allocate eeprom */ - sz = priv->cfg->base_params->eeprom_size; - IL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); - priv->eeprom = kzalloc(sz, GFP_KERNEL); - if (!priv->eeprom) { + sz = il->cfg->base_params->eeprom_size; + IL_DEBUG_EEPROM(il, "NVM size = %d\n", sz); + il->eeprom = kzalloc(sz, GFP_KERNEL); + if (!il->eeprom) { ret = -ENOMEM; goto alloc_err; } - e = (__le16 *)priv->eeprom; + e = (__le16 *)il->eeprom; - priv->cfg->ops->lib->apm_ops.init(priv); + il->cfg->ops->lib->apm_ops.init(il); - ret = il_eeprom_verify_signature(priv); + ret = il_eeprom_verify_signature(il); if (ret < 0) { - IL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); + IL_ERR(il, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; goto err; } /* Make sure driver (instead of uCode) is allowed to read EEPROM */ - ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv); + ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); if (ret < 0) { - IL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); + IL_ERR(il, "Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; goto err; } @@ -223,95 +223,95 @@ int il_eeprom_init(struct il_priv *priv) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - _il_write32(priv, CSR_EEPROM_REG, + _il_write32(il, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = il_poll_bit(priv, CSR_EEPROM_REG, + ret = il_poll_bit(il, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IL_ERR(priv, "Time out reading EEPROM[%d]\n", + IL_ERR(il, "Time out reading EEPROM[%d]\n", addr); goto done; } - r = _il_read_direct32(priv, CSR_EEPROM_REG); + r = _il_read_direct32(il, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } - IL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", + IL_DEBUG_EEPROM(il, "NVM Type: %s, version: 0x%x\n", "EEPROM", - il_eeprom_query16(priv, EEPROM_VERSION)); + il_eeprom_query16(il, EEPROM_VERSION)); ret = 0; done: - priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv); + il->cfg->ops->lib->eeprom_ops.release_semaphore(il); err: if (ret) - il_eeprom_free(priv); + il_eeprom_free(il); /* Reset chip to save power until we load uCode during "up". */ - il_apm_stop(priv); + il_apm_stop(il); alloc_err: return ret; } EXPORT_SYMBOL(il_eeprom_init); -void il_eeprom_free(struct il_priv *priv) +void il_eeprom_free(struct il_priv *il) { - kfree(priv->eeprom); - priv->eeprom = NULL; + kfree(il->eeprom); + il->eeprom = NULL; } EXPORT_SYMBOL(il_eeprom_free); -static void il_init_band_reference(const struct il_priv *priv, +static void il_init_band_reference(const struct il_priv *il, int eep_band, int *eeprom_ch_count, const struct il_eeprom_channel **eeprom_ch_info, const u8 **eeprom_ch_index) { - u32 offset = priv->cfg->ops->lib-> + u32 offset = il->cfg->ops->lib-> eeprom_ops.regulatory_bands[eep_band - 1]; switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_1); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_2); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_3); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_4); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_5); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_6); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_7); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_7; break; default: @@ -322,11 +322,11 @@ static void il_init_band_reference(const struct il_priv *priv, #define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ ? # x " " : "") /** - * il_mod_ht40_chan_info - Copy ht40 channel info into driver's priv. + * il_mod_ht40_chan_info - Copy ht40 channel info into driver's il. * * Does not set up a command, or touch hardware. */ -static int il_mod_ht40_chan_info(struct il_priv *priv, +static int il_mod_ht40_chan_info(struct il_priv *il, enum ieee80211_band band, u16 channel, const struct il_eeprom_channel *eeprom_ch, u8 clear_ht40_extension_channel) @@ -334,12 +334,12 @@ static int il_mod_ht40_chan_info(struct il_priv *priv, struct il_channel_info *ch_info; ch_info = (struct il_channel_info *) - il_get_channel_info(priv, band, channel); + il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) return -1; - IL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + IL_DEBUG_EEPROM(il, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, il_is_channel_a_band(ch_info) ? @@ -371,7 +371,7 @@ static int il_mod_ht40_chan_info(struct il_priv *priv, /** * il_init_channel_map - Set up driver's info for all possible channels */ -int il_init_channel_map(struct il_priv *priv) +int il_init_channel_map(struct il_priv *il) { int eeprom_ch_count = 0; const u8 *eeprom_ch_index = NULL; @@ -379,39 +379,39 @@ int il_init_channel_map(struct il_priv *priv) int band, ch; struct il_channel_info *ch_info; - if (priv->channel_count) { - IL_DEBUG_EEPROM(priv, "Channel map already initialized.\n"); + if (il->channel_count) { + IL_DEBUG_EEPROM(il, "Channel map already initialized.\n"); return 0; } - IL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n"); + IL_DEBUG_EEPROM(il, "Initializing regulatory info from EEPROM\n"); - priv->channel_count = + il->channel_count = ARRAY_SIZE(iwlegacy_eeprom_band_1) + ARRAY_SIZE(iwlegacy_eeprom_band_2) + ARRAY_SIZE(iwlegacy_eeprom_band_3) + ARRAY_SIZE(iwlegacy_eeprom_band_4) + ARRAY_SIZE(iwlegacy_eeprom_band_5); - IL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n", - priv->channel_count); + IL_DEBUG_EEPROM(il, "Parsing data for %d channels.\n", + il->channel_count); - priv->channel_info = kzalloc(sizeof(struct il_channel_info) * - priv->channel_count, GFP_KERNEL); - if (!priv->channel_info) { - IL_ERR(priv, "Could not allocate channel_info\n"); - priv->channel_count = 0; + il->channel_info = kzalloc(sizeof(struct il_channel_info) * + il->channel_count, GFP_KERNEL); + if (!il->channel_info) { + IL_ERR(il, "Could not allocate channel_info\n"); + il->channel_count = 0; return -ENOMEM; } - ch_info = priv->channel_info; + ch_info = il->channel_info; /* Loop through the 5 EEPROM bands adding them in order to the * channel map we maintain (that contains additional information than * what just in the EEPROM) */ for (band = 1; band <= 5; band++) { - il_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(il, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* Loop through each band adding each of the channels */ @@ -433,7 +433,7 @@ int il_init_channel_map(struct il_priv *priv) IEEE80211_CHAN_NO_HT40; if (!(il_is_channel_valid(ch_info))) { - IL_DEBUG_EEPROM(priv, + IL_DEBUG_EEPROM(il, "Ch. %d Flags %x [%sGHz] - " "No traffic\n", ch_info->channel, @@ -450,7 +450,7 @@ int il_init_channel_map(struct il_priv *priv) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - IL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] " + IL_DEBUG_EEPROM(il, "Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, @@ -475,9 +475,9 @@ int il_init_channel_map(struct il_priv *priv) } /* Check if we do have HT40 channels */ - if (priv->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == + if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == EEPROM_REGULATORY_BAND_NO_HT40 && - priv->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == + il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == EEPROM_REGULATORY_BAND_NO_HT40) return 0; @@ -485,7 +485,7 @@ int il_init_channel_map(struct il_priv *priv) for (band = 6; band <= 7; band++) { enum ieee80211_band ieeeband; - il_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(il, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ @@ -495,13 +495,13 @@ int il_init_channel_map(struct il_priv *priv) /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ - il_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(il, ieeeband, eeprom_ch_index[ch], &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ - il_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(il, ieeeband, eeprom_ch_index[ch] + 4, &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40MINUS); @@ -515,34 +515,34 @@ EXPORT_SYMBOL(il_init_channel_map); /* * il_free_channel_map - undo allocations in il_init_channel_map */ -void il_free_channel_map(struct il_priv *priv) +void il_free_channel_map(struct il_priv *il) { - kfree(priv->channel_info); - priv->channel_count = 0; + kfree(il->channel_info); + il->channel_count = 0; } EXPORT_SYMBOL(il_free_channel_map); /** - * il_get_channel_info - Find driver's private channel info + * il_get_channel_info - Find driver's ilate channel info * * Based on band and channel number. */ const struct -il_channel_info *il_get_channel_info(const struct il_priv *priv, +il_channel_info *il_get_channel_info(const struct il_priv *il, enum ieee80211_band band, u16 channel) { int i; switch (band) { case IEEE80211_BAND_5GHZ: - for (i = 14; i < priv->channel_count; i++) { - if (priv->channel_info[i].channel == channel) - return &priv->channel_info[i]; + for (i = 14; i < il->channel_count; i++) { + if (il->channel_info[i].channel == channel) + return &il->channel_info[i]; } break; case IEEE80211_BAND_2GHZ: if (channel >= 1 && channel <= 14) - return &priv->channel_info[channel - 1]; + return &il->channel_info[channel - 1]; break; default: BUG(); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index 9ad6871..acb5ec1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -325,20 +325,20 @@ struct il_eeprom_calib_info { struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv *priv); - void (*release_semaphore) (struct il_priv *priv); + int (*acquire_semaphore) (struct il_priv *il); + void (*release_semaphore) (struct il_priv *il); }; -int il_eeprom_init(struct il_priv *priv); -void il_eeprom_free(struct il_priv *priv); -const u8 *il_eeprom_query_addr(const struct il_priv *priv, +int il_eeprom_init(struct il_priv *il); +void il_eeprom_free(struct il_priv *il); +const u8 *il_eeprom_query_addr(const struct il_priv *il, size_t offset); -u16 il_eeprom_query16(const struct il_priv *priv, size_t offset); -int il_init_channel_map(struct il_priv *priv); -void il_free_channel_map(struct il_priv *priv); +u16 il_eeprom_query16(const struct il_priv *il, size_t offset); +int il_init_channel_map(struct il_priv *il); +void il_free_channel_map(struct il_priv *il); const struct il_channel_info *il_get_channel_info( - const struct il_priv *priv, + const struct il_priv *il, enum ieee80211_band band, u16 channel); #endif /* __il_eeprom_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 515befc..f16e311 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -90,12 +90,12 @@ EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) -static void il_generic_cmd_callback(struct il_priv *priv, +static void il_generic_cmd_callback(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from %s (0x%08X)\n", + IL_ERR(il, "Bad return from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } @@ -104,18 +104,18 @@ static void il_generic_cmd_callback(struct il_priv *priv, switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n", + IL_DEBUG_HC_DUMP(il, "back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - IL_DEBUG_HC(priv, "back from %s (0x%08X)\n", + IL_DEBUG_HC(il, "back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); } #endif } static int -il_send_cmd_async(struct il_priv *priv, struct il_host_cmd *cmd) +il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) { int ret; @@ -128,57 +128,57 @@ il_send_cmd_async(struct il_priv *priv, struct il_host_cmd *cmd) if (!cmd->callback) cmd->callback = il_generic_cmd_callback; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return -EBUSY; - ret = il_enqueue_hcmd(priv, cmd); + ret = il_enqueue_hcmd(il, cmd); if (ret < 0) { - IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); return ret; } return 0; } -int il_send_cmd_sync(struct il_priv *priv, struct il_host_cmd *cmd) +int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) { int cmd_idx; int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); BUG_ON(cmd->flags & CMD_ASYNC); /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); - IL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", + IL_DEBUG_INFO(il, "Attempting to send sync command %s\n", il_get_cmd_string(cmd->id)); - set_bit(STATUS_HCMD_ACTIVE, &priv->status); - IL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n", + set_bit(STATUS_HCMD_ACTIVE, &il->status); + IL_DEBUG_INFO(il, "Setting HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); - cmd_idx = il_enqueue_hcmd(priv, cmd); + cmd_idx = il_enqueue_hcmd(il, cmd); if (cmd_idx < 0) { ret = cmd_idx; - IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); goto out; } - ret = wait_event_timeout(priv->wait_command_queue, - !test_bit(STATUS_HCMD_ACTIVE, &priv->status), + ret = wait_event_timeout(il->wait_command_queue, + !test_bit(STATUS_HCMD_ACTIVE, &il->status), HOST_COMPLETE_TIMEOUT); if (!ret) { - if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) { - IL_ERR(priv, + if (test_bit(STATUS_HCMD_ACTIVE, &il->status)) { + IL_ERR(il, "Error sending %s: time out after %dms.\n", il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IL_DEBUG_INFO(priv, + clear_bit(STATUS_HCMD_ACTIVE, &il->status); + IL_DEBUG_INFO(il, "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; @@ -186,20 +186,20 @@ int il_send_cmd_sync(struct il_priv *priv, struct il_host_cmd *cmd) } } - if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { - IL_ERR(priv, "Command %s aborted: RF KILL Switch\n", + if (test_bit(STATUS_RF_KILL_HW, &il->status)) { + IL_ERR(il, "Command %s aborted: RF KILL Switch\n", il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } - if (test_bit(STATUS_FW_ERROR, &priv->status)) { - IL_ERR(priv, "Command %s failed: FW Error\n", + if (test_bit(STATUS_FW_ERROR, &il->status)) { + IL_ERR(il, "Command %s failed: FW Error\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IL_ERR(priv, "Error: Response NULL in '%s'\n", + IL_ERR(il, "Error: Response NULL in '%s'\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; @@ -216,12 +216,12 @@ cancel: * in later, it will possibly set an invalid * address (cmd->meta.source). */ - priv->txq[priv->cmd_queue].meta[cmd_idx].flags &= + il->txq[il->cmd_queue].meta[cmd_idx].flags &= ~CMD_WANT_SKB; } fail: if (cmd->reply_page) { - il_free_pages(priv, cmd->reply_page); + il_free_pages(il, cmd->reply_page); cmd->reply_page = 0; } out: @@ -229,17 +229,17 @@ out: } EXPORT_SYMBOL(il_send_cmd_sync); -int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd) +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) { if (cmd->flags & CMD_ASYNC) - return il_send_cmd_async(priv, cmd); + return il_send_cmd_async(il, cmd); - return il_send_cmd_sync(priv, cmd); + return il_send_cmd_sync(il, cmd); } EXPORT_SYMBOL(il_send_cmd); int -il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data) +il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) { struct il_host_cmd cmd = { .id = id, @@ -247,13 +247,13 @@ il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data) .data = data, }; - return il_send_cmd_sync(priv, &cmd); + return il_send_cmd_sync(il, &cmd); } EXPORT_SYMBOL(il_send_cmd_pdu); -int il_send_cmd_pdu_async(struct il_priv *priv, +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt)) { @@ -266,6 +266,6 @@ int il_send_cmd_pdu_async(struct il_priv *priv, cmd.flags |= CMD_ASYNC; cmd.callback = callback; - return il_send_cmd_async(priv, &cmd); + return il_send_cmd_async(il, &cmd); } EXPORT_SYMBOL(il_send_cmd_pdu_async); diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index e4e63b5..e55f2ef 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -108,28 +108,28 @@ il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) txq->swq_id = (hwq << 2) | ac; } -static inline void il_wake_queue(struct il_priv *priv, +static inline void il_wake_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; u8 hwq = (queue >> 2) & 0x1f; - if (test_and_clear_bit(hwq, priv->queue_stopped)) - if (atomic_dec_return(&priv->queue_stop_count[ac]) <= 0) - ieee80211_wake_queue(priv->hw, ac); + if (test_and_clear_bit(hwq, il->queue_stopped)) + if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0) + ieee80211_wake_queue(il->hw, ac); } -static inline void il_stop_queue(struct il_priv *priv, +static inline void il_stop_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; u8 hwq = (queue >> 2) & 0x1f; - if (!test_and_set_bit(hwq, priv->queue_stopped)) - if (atomic_inc_return(&priv->queue_stop_count[ac]) > 0) - ieee80211_stop_queue(priv->hw, ac); + if (!test_and_set_bit(hwq, il->queue_stopped)) + if (atomic_inc_return(&il->queue_stop_count[ac]) > 0) + ieee80211_stop_queue(il->hw, ac); } #ifdef ieee80211_stop_queue @@ -144,39 +144,39 @@ static inline void il_stop_queue(struct il_priv *priv, #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue -static inline void il_disable_interrupts(struct il_priv *priv) +static inline void il_disable_interrupts(struct il_priv *il) { - clear_bit(STATUS_INT_ENABLED, &priv->status); + clear_bit(STATUS_INT_ENABLED, &il->status); /* disable interrupts from uCode/NIC to host */ - il_write32(priv, CSR_INT_MASK, 0x00000000); + il_write32(il, CSR_INT_MASK, 0x00000000); /* acknowledge/clear/reset any interrupts still pending * from uCode or flow handler (Rx/Tx DMA) */ - il_write32(priv, CSR_INT, 0xffffffff); - il_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); - IL_DEBUG_ISR(priv, "Disabled interrupts\n"); + il_write32(il, CSR_INT, 0xffffffff); + il_write32(il, CSR_FH_INT_STATUS, 0xffffffff); + IL_DEBUG_ISR(il, "Disabled interrupts\n"); } -static inline void il_enable_rfkill_int(struct il_priv *priv) +static inline void il_enable_rfkill_int(struct il_priv *il) { - IL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); - il_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + IL_DEBUG_ISR(il, "Enabling rfkill interrupt\n"); + il_write32(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } -static inline void il_enable_interrupts(struct il_priv *priv) +static inline void il_enable_interrupts(struct il_priv *il) { - IL_DEBUG_ISR(priv, "Enabling interrupts\n"); - set_bit(STATUS_INT_ENABLED, &priv->status); - il_write32(priv, CSR_INT_MASK, priv->inta_mask); + IL_DEBUG_ISR(il, "Enabling interrupts\n"); + set_bit(STATUS_INT_ENABLED, &il->status); + il_write32(il, CSR_INT_MASK, il->inta_mask); } /** * il_beacon_time_mask_low - mask of lower 32 bit of beacon time - * @priv -- pointer to il_priv data structure + * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_low(struct il_priv *priv, +static inline u32 il_beacon_time_mask_low(struct il_priv *il, u16 tsf_bits) { return (1 << tsf_bits) - 1; @@ -184,10 +184,10 @@ static inline u32 il_beacon_time_mask_low(struct il_priv *priv, /** * il_beacon_time_mask_high - mask of higher 32 bit of beacon time - * @priv -- pointer to il_priv data structure + * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_high(struct il_priv *priv, +static inline u32 il_beacon_time_mask_high(struct il_priv *il, u16 tsf_bits) { return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index ebeb6e2..42d241f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -62,72 +62,72 @@ * */ -static inline void _il_write8(struct il_priv *priv, u32 ofs, u8 val) +static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) { - iowrite8(val, priv->hw_base + ofs); + iowrite8(val, il->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__il_write8(const char *f, u32 l, struct il_priv *priv, +__il_write8(const char *f, u32 l, struct il_priv *il, u32 ofs, u8 val) { - IL_DEBUG_IO(priv, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); - _il_write8(priv, ofs, val); + IL_DEBUG_IO(il, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); + _il_write8(il, ofs, val); } -#define il_write8(priv, ofs, val) \ - __il_write8(__FILE__, __LINE__, priv, ofs, val) +#define il_write8(il, ofs, val) \ + __il_write8(__FILE__, __LINE__, il, ofs, val) #else -#define il_write8(priv, ofs, val) _il_write8(priv, ofs, val) +#define il_write8(il, ofs, val) _il_write8(il, ofs, val) #endif -static inline void _il_write32(struct il_priv *priv, u32 ofs, u32 val) +static inline void _il_write32(struct il_priv *il, u32 ofs, u32 val) { - iowrite32(val, priv->hw_base + ofs); + iowrite32(val, il->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__il_write32(const char *f, u32 l, struct il_priv *priv, +__il_write32(const char *f, u32 l, struct il_priv *il, u32 ofs, u32 val) { - IL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); - _il_write32(priv, ofs, val); + IL_DEBUG_IO(il, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); + _il_write32(il, ofs, val); } -#define il_write32(priv, ofs, val) \ - __il_write32(__FILE__, __LINE__, priv, ofs, val) +#define il_write32(il, ofs, val) \ + __il_write32(__FILE__, __LINE__, il, ofs, val) #else -#define il_write32(priv, ofs, val) _il_write32(priv, ofs, val) +#define il_write32(il, ofs, val) _il_write32(il, ofs, val) #endif -static inline u32 _il_read32(struct il_priv *priv, u32 ofs) +static inline u32 _il_read32(struct il_priv *il, u32 ofs) { - u32 val = ioread32(priv->hw_base + ofs); + u32 val = ioread32(il->hw_base + ofs); return val; } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline u32 -__il_read32(char *f, u32 l, struct il_priv *priv, u32 ofs) +__il_read32(char *f, u32 l, struct il_priv *il, u32 ofs) { - IL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); - return _il_read32(priv, ofs); + IL_DEBUG_IO(il, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); + return _il_read32(il, ofs); } -#define il_read32(priv, ofs) __il_read32(__FILE__, __LINE__, priv, ofs) +#define il_read32(il, ofs) __il_read32(__FILE__, __LINE__, il, ofs) #else #define il_read32(p, o) _il_read32(p, o) #endif #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int -_il_poll_bit(struct il_priv *priv, u32 addr, +_il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) { int t = 0; do { - if ((_il_read32(priv, addr) & mask) == (bits & mask)) + if ((_il_read32(il, addr) & mask) == (bits & mask)) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -137,34 +137,34 @@ _il_poll_bit(struct il_priv *priv, u32 addr, } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline int __il_poll_bit(const char *f, u32 l, - struct il_priv *priv, u32 addr, + struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) { - int ret = _il_poll_bit(priv, addr, bits, mask, timeout); - IL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", + int ret = _il_poll_bit(il, addr, bits, mask, timeout); + IL_DEBUG_IO(il, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", addr, bits, mask, unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l); return ret; } -#define il_poll_bit(priv, addr, bits, mask, timeout) \ - __il_poll_bit(__FILE__, __LINE__, priv, addr, \ +#define il_poll_bit(il, addr, bits, mask, timeout) \ + __il_poll_bit(__FILE__, __LINE__, il, addr, \ bits, mask, timeout) #else #define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) #endif -static inline void _il_set_bit(struct il_priv *priv, u32 reg, u32 mask) +static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(priv, reg, _il_read32(priv, reg) | mask); + _il_write32(il, reg, _il_read32(il, reg) | mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void __il_set_bit(const char *f, u32 l, - struct il_priv *priv, u32 reg, u32 mask) + struct il_priv *il, u32 reg, u32 mask) { - u32 val = _il_read32(priv, reg) | mask; - IL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, + u32 val = _il_read32(il, reg) | mask; + IL_DEBUG_IO(il, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _il_write32(priv, reg, val); + _il_write32(il, reg, val); } static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { @@ -186,18 +186,18 @@ static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) #endif static inline void -_il_clear_bit(struct il_priv *priv, u32 reg, u32 mask) +_il_clear_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(priv, reg, _il_read32(priv, reg) & ~mask); + _il_write32(il, reg, _il_read32(il, reg) & ~mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void __il_clear_bit(const char *f, u32 l, - struct il_priv *priv, u32 reg, u32 mask) + struct il_priv *il, u32 reg, u32 mask) { - u32 val = _il_read32(priv, reg) & ~mask; - IL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _il_write32(priv, reg, val); + u32 val = _il_read32(il, reg) & ~mask; + IL_DEBUG_IO(il, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); + _il_write32(il, reg, val); } static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { @@ -218,13 +218,13 @@ static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) } #endif -static inline int _il_grab_nic_access(struct il_priv *priv) +static inline int _il_grab_nic_access(struct il_priv *il) { int ret; u32 val; /* this bit wakes up the NIC */ - _il_set_bit(priv, CSR_GP_CNTRL, + _il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* @@ -244,15 +244,15 @@ static inline int _il_grab_nic_access(struct il_priv *priv) * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). * */ - ret = _il_poll_bit(priv, CSR_GP_CNTRL, + ret = _il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { - val = _il_read32(priv, CSR_GP_CNTRL); - IL_ERR(priv, + val = _il_read32(il, CSR_GP_CNTRL); + IL_ERR(il, "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_write32(priv, CSR_RESET, + _il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } @@ -262,117 +262,117 @@ static inline int _il_grab_nic_access(struct il_priv *priv) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline int __il_grab_nic_access(const char *f, u32 l, - struct il_priv *priv) + struct il_priv *il) { - IL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l); - return _il_grab_nic_access(priv); + IL_DEBUG_IO(il, "grabbing nic access - %s %d\n", f, l); + return _il_grab_nic_access(il); } -#define il_grab_nic_access(priv) \ - __il_grab_nic_access(__FILE__, __LINE__, priv) +#define il_grab_nic_access(il) \ + __il_grab_nic_access(__FILE__, __LINE__, il) #else -#define il_grab_nic_access(priv) \ - _il_grab_nic_access(priv) +#define il_grab_nic_access(il) \ + _il_grab_nic_access(il) #endif -static inline void _il_release_nic_access(struct il_priv *priv) +static inline void _il_release_nic_access(struct il_priv *il) { - _il_clear_bit(priv, CSR_GP_CNTRL, + _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void __il_release_nic_access(const char *f, u32 l, - struct il_priv *priv) + struct il_priv *il) { - IL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l); - _il_release_nic_access(priv); + IL_DEBUG_IO(il, "releasing nic access - %s %d\n", f, l); + _il_release_nic_access(il); } -#define il_release_nic_access(priv) \ - __il_release_nic_access(__FILE__, __LINE__, priv) +#define il_release_nic_access(il) \ + __il_release_nic_access(__FILE__, __LINE__, il) #else -#define il_release_nic_access(priv) \ - _il_release_nic_access(priv) +#define il_release_nic_access(il) \ + _il_release_nic_access(il) #endif -static inline u32 _il_read_direct32(struct il_priv *priv, u32 reg) +static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { - return _il_read32(priv, reg); + return _il_read32(il, reg); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline u32 __il_read_direct32(const char *f, u32 l, - struct il_priv *priv, u32 reg) + struct il_priv *il, u32 reg) { - u32 value = _il_read_direct32(priv, reg); - IL_DEBUG_IO(priv, + u32 value = _il_read_direct32(il, reg); + IL_DEBUG_IO(il, "read_direct32(0x%4X) = 0x%08x - %s %d\n", reg, value, f, l); return value; } -static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - value = __il_read_direct32(__FILE__, __LINE__, priv, reg); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + value = __il_read_direct32(__FILE__, __LINE__, il, reg); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } #else -static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - value = _il_read_direct32(priv, reg); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + value = _il_read_direct32(il, reg); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } #endif -static inline void _il_write_direct32(struct il_priv *priv, +static inline void _il_write_direct32(struct il_priv *il, u32 reg, u32 value) { - _il_write32(priv, reg, value); + _il_write32(il, reg, value); } static inline void -il_write_direct32(struct il_priv *priv, u32 reg, u32 value) +il_write_direct32(struct il_priv *il, u32 reg, u32 value) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_direct32(priv, reg, value); - il_release_nic_access(priv); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_direct32(il, reg, value); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline void il_write_reg_buf(struct il_priv *priv, +static inline void il_write_reg_buf(struct il_priv *il, u32 reg, u32 len, u32 *values) { u32 count = sizeof(u32); - if ((priv != NULL) && (values != NULL)) { + if ((il != NULL) && (values != NULL)) { for (; 0 < len; len -= count, reg += count, values++) - il_write_direct32(priv, reg, *values); + il_write_direct32(il, reg, *values); } } -static inline int _il_poll_direct_bit(struct il_priv *priv, u32 addr, +static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) { int t = 0; do { - if ((il_read_direct32(priv, addr) & mask) == mask) + if ((il_read_direct32(il, addr) & mask) == mask) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -383,159 +383,159 @@ static inline int _il_poll_direct_bit(struct il_priv *priv, u32 addr, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline int __il_poll_direct_bit(const char *f, u32 l, - struct il_priv *priv, + struct il_priv *il, u32 addr, u32 mask, int timeout) { - int ret = _il_poll_direct_bit(priv, addr, mask, timeout); + int ret = _il_poll_direct_bit(il, addr, mask, timeout); if (unlikely(ret == -ETIMEDOUT)) - IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - " + IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) - " "timedout - %s %d\n", addr, mask, f, l); else - IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " + IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " "- %s %d\n", addr, mask, ret, f, l); return ret; } -#define il_poll_direct_bit(priv, addr, mask, timeout) \ -__il_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout) +#define il_poll_direct_bit(il, addr, mask, timeout) \ +__il_poll_direct_bit(__FILE__, __LINE__, il, addr, mask, timeout) #else #define il_poll_direct_bit _il_poll_direct_bit #endif -static inline u32 _il_read_prph(struct il_priv *priv, u32 reg) +static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { - _il_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + _il_write_direct32(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); - return _il_read_direct32(priv, HBUS_TARG_PRPH_RDAT); + return _il_read_direct32(il, HBUS_TARG_PRPH_RDAT); } -static inline u32 il_read_prph(struct il_priv *priv, u32 reg) +static inline u32 il_read_prph(struct il_priv *il, u32 reg) { unsigned long reg_flags; u32 val; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - val = _il_read_prph(priv, reg); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + val = _il_read_prph(il, reg); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return val; } -static inline void _il_write_prph(struct il_priv *priv, +static inline void _il_write_prph(struct il_priv *il, u32 addr, u32 val) { - _il_write_direct32(priv, HBUS_TARG_PRPH_WADDR, + _il_write_direct32(il, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); - _il_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val); + _il_write_direct32(il, HBUS_TARG_PRPH_WDAT, val); } static inline void -il_write_prph(struct il_priv *priv, u32 addr, u32 val) +il_write_prph(struct il_priv *il, u32 addr, u32 val) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_prph(priv, addr, val); - il_release_nic_access(priv); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_prph(il, addr, val); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -#define _il_set_bits_prph(priv, reg, mask) \ -_il_write_prph(priv, reg, (_il_read_prph(priv, reg) | mask)) +#define _il_set_bits_prph(il, reg, mask) \ +_il_write_prph(il, reg, (_il_read_prph(il, reg) | mask)) static inline void -il_set_bits_prph(struct il_priv *priv, u32 reg, u32 mask) +il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - _il_set_bits_prph(priv, reg, mask); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + _il_set_bits_prph(il, reg, mask); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -#define _il_set_bits_mask_prph(priv, reg, bits, mask) \ -_il_write_prph(priv, reg, \ - ((_il_read_prph(priv, reg) & mask) | bits)) +#define _il_set_bits_mask_prph(il, reg, bits, mask) \ +_il_write_prph(il, reg, \ + ((_il_read_prph(il, reg) & mask) | bits)) -static inline void il_set_bits_mask_prph(struct il_priv *priv, u32 reg, +static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - _il_set_bits_mask_prph(priv, reg, bits, mask); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + _il_set_bits_mask_prph(il, reg, bits, mask); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } static inline void il_clear_bits_prph(struct il_priv - *priv, u32 reg, u32 mask) + *il, u32 reg, u32 mask) { unsigned long reg_flags; u32 val; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - val = _il_read_prph(priv, reg); - _il_write_prph(priv, reg, (val & ~mask)); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + val = _il_read_prph(il, reg); + _il_write_prph(il, reg, (val & ~mask)); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline u32 il_read_targ_mem(struct il_priv *priv, u32 addr) +static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) { unsigned long reg_flags; u32 value; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); - _il_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr); + _il_write_direct32(il, HBUS_TARG_MEM_RADDR, addr); rmb(); - value = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + value = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } static inline void -il_write_targ_mem(struct il_priv *priv, u32 addr, u32 val) +il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); - _il_write_direct32(priv, HBUS_TARG_MEM_WDAT, val); - il_release_nic_access(priv); + _il_write_direct32(il, HBUS_TARG_MEM_WDAT, val); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } static inline void -il_write_targ_mem_buf(struct il_priv *priv, u32 addr, +il_write_targ_mem_buf(struct il_priv *il, u32 addr, u32 len, u32 *values) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _il_write_direct32(priv, + _il_write_direct32(il, HBUS_TARG_MEM_WDAT, *values); - il_release_nic_access(priv); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 490b183..13add43 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -84,11 +84,11 @@ static const struct ieee80211_tpt_blink il_blink[] = { * compensation = (100 - averageDeviation) * 64 / 100 * NewBlinkTime = (compensation * BlinkTime) / 64 */ -static inline u8 il_blink_compensation(struct il_priv *priv, +static inline u8 il_blink_compensation(struct il_priv *il, u8 time, u16 compensation) { if (!compensation) { - IL_ERR(priv, "undefined blink compensation: " + IL_ERR(il, "undefined blink compensation: " "use pre-defined blinking time\n"); return time; } @@ -97,7 +97,7 @@ static inline u8 il_blink_compensation(struct il_priv *priv, } /* Set led pattern command */ -static int il_led_cmd(struct il_priv *priv, +static int il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off) { @@ -107,10 +107,10 @@ static int il_led_cmd(struct il_priv *priv, }; int ret; - if (!test_bit(STATUS_READY, &priv->status)) + if (!test_bit(STATUS_READY, &il->status)) return -EBUSY; - if (priv->blink_on == on && priv->blink_off == off) + if (il->blink_on == on && il->blink_off == off) return 0; if (off == 0) { @@ -118,17 +118,17 @@ static int il_led_cmd(struct il_priv *priv, on = IL_LED_SOLID; } - IL_DEBUG_LED(priv, "Led blink time compensation=%u\n", - priv->cfg->base_params->led_compensation); - led_cmd.on = il_blink_compensation(priv, on, - priv->cfg->base_params->led_compensation); - led_cmd.off = il_blink_compensation(priv, off, - priv->cfg->base_params->led_compensation); + IL_DEBUG_LED(il, "Led blink time compensation=%u\n", + il->cfg->base_params->led_compensation); + led_cmd.on = il_blink_compensation(il, on, + il->cfg->base_params->led_compensation); + led_cmd.off = il_blink_compensation(il, off, + il->cfg->base_params->led_compensation); - ret = priv->cfg->ops->led->cmd(priv, &led_cmd); + ret = il->cfg->ops->led->cmd(il, &led_cmd); if (!ret) { - priv->blink_on = on; - priv->blink_off = off; + il->blink_on = on; + il->blink_off = off; } return ret; } @@ -136,70 +136,70 @@ static int il_led_cmd(struct il_priv *priv, static void il_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness) { - struct il_priv *priv = container_of(led_cdev, struct il_priv, led); + struct il_priv *il = container_of(led_cdev, struct il_priv, led); unsigned long on = 0; if (brightness > 0) on = IL_LED_SOLID; - il_led_cmd(priv, on, 0); + il_led_cmd(il, on, 0); } static int il_led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - struct il_priv *priv = container_of(led_cdev, struct il_priv, led); + struct il_priv *il = container_of(led_cdev, struct il_priv, led); - return il_led_cmd(priv, *delay_on, *delay_off); + return il_led_cmd(il, *delay_on, *delay_off); } -void il_leds_init(struct il_priv *priv) +void il_leds_init(struct il_priv *il) { int mode = led_mode; int ret; if (mode == IL_LED_DEFAULT) - mode = priv->cfg->led_mode; + mode = il->cfg->led_mode; - priv->led.name = kasprintf(GFP_KERNEL, "%s-led", - wiphy_name(priv->hw->wiphy)); - priv->led.brightness_set = il_led_brightness_set; - priv->led.blink_set = il_led_blink_set; - priv->led.max_brightness = 1; + il->led.name = kasprintf(GFP_KERNEL, "%s-led", + wiphy_name(il->hw->wiphy)); + il->led.brightness_set = il_led_brightness_set; + il->led.blink_set = il_led_blink_set; + il->led.max_brightness = 1; switch (mode) { case IL_LED_DEFAULT: WARN_ON(1); break; case IL_LED_BLINK: - priv->led.default_trigger = - ieee80211_create_tpt_led_trigger(priv->hw, + il->led.default_trigger = + ieee80211_create_tpt_led_trigger(il->hw, IEEE80211_TPT_LEDTRIG_FL_CONNECTED, il_blink, ARRAY_SIZE(il_blink)); break; case IL_LED_RF_STATE: - priv->led.default_trigger = - ieee80211_get_radio_led_name(priv->hw); + il->led.default_trigger = + ieee80211_get_radio_led_name(il->hw); break; } - ret = led_classdev_register(&priv->pci_dev->dev, &priv->led); + ret = led_classdev_register(&il->pci_dev->dev, &il->led); if (ret) { - kfree(priv->led.name); + kfree(il->led.name); return; } - priv->led_registered = true; + il->led_registered = true; } EXPORT_SYMBOL(il_leds_init); -void il_leds_exit(struct il_priv *priv) +void il_leds_exit(struct il_priv *il) { - if (!priv->led_registered) + if (!il->led_registered) return; - led_classdev_unregister(&priv->led); - kfree(priv->led.name); + led_classdev_unregister(&il->led); + kfree(il->led.name); } EXPORT_SYMBOL(il_leds_exit); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.h b/drivers/net/wireless/iwlegacy/iwl-led.h index ea7a8ea..d3aba57 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-led.h @@ -50,7 +50,7 @@ enum il_led_mode { IL_LED_BLINK, }; -void il_leds_init(struct il_priv *priv); -void il_leds_exit(struct il_priv *priv); +void il_leds_init(struct il_priv *il); +void il_leds_exit(struct il_priv *il); #endif /* __il_leds_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 72ef91e..4282ed5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -346,7 +346,7 @@ struct il_traffic_load { }; /** - * struct il_lq_sta -- driver's rate scaling private structure + * struct il_lq_sta -- driver's rate scaling ilate structure * * Pointer to this gets passed back and forth between driver and mac80211. */ @@ -400,11 +400,9 @@ struct il_lq_sta { u8 is_agg; }; -static inline u8 il4965_num_of_ant(u8 mask) +static inline u8 il4965_num_of_ant(u8 m) { - return !!((mask) & ANT_A) + - !!((mask) & ANT_B) + - !!((mask) & ANT_C); + return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); } static inline u8 il4965_first_antenna(u8 mask) @@ -426,9 +424,9 @@ static inline u8 il4965_first_antenna(u8 mask) extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); /* Initialize station's rate scaling information after adding station */ -extern void il4965_rs_rate_init(struct il_priv *priv, +extern void il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id); -extern void il3945_rs_rate_init(struct il_priv *priv, +extern void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id); /** diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 7ccff25..6386246 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -60,27 +60,27 @@ struct il_power_vec_entry { u8 no_dtim; /* number of skip dtim */ }; -static void il_power_sleep_cam_cmd(struct il_priv *priv, +static void il_power_sleep_cam_cmd(struct il_priv *il, struct il_powertable_cmd *cmd) { memset(cmd, 0, sizeof(*cmd)); - if (priv->power_data.pci_pm) + if (il->power_data.pci_pm) cmd->flags |= IL_POWER_PCI_PM_MSK; - IL_DEBUG_POWER(priv, "Sleep command for CAM\n"); + IL_DEBUG_POWER(il, "Sleep command for CAM\n"); } static int -il_set_power(struct il_priv *priv, struct il_powertable_cmd *cmd) +il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) { - IL_DEBUG_POWER(priv, "Sending power/sleep command\n"); - IL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); - IL_DEBUG_POWER(priv, "Tx timeout = %u\n", + IL_DEBUG_POWER(il, "Sending power/sleep command\n"); + IL_DEBUG_POWER(il, "Flags value = 0x%08X\n", cmd->flags); + IL_DEBUG_POWER(il, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); - IL_DEBUG_POWER(priv, "Rx timeout = %u\n", + IL_DEBUG_POWER(il, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); - IL_DEBUG_POWER(priv, + IL_DEBUG_POWER(il, "Sleep interval vector = { %d , %d , %d , %d , %d }\n", le32_to_cpu(cmd->sleep_interval[0]), le32_to_cpu(cmd->sleep_interval[1]), @@ -88,78 +88,78 @@ il_set_power(struct il_priv *priv, struct il_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return il_send_cmd_pdu(priv, POWER_TABLE_CMD, + return il_send_cmd_pdu(il, POWER_TABLE_CMD, sizeof(struct il_powertable_cmd), cmd); } int -il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force) { int ret; bool update_chains; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); /* Don't update the RX chain when chain noise calibration is running */ - update_chains = priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE || - priv->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; + update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || + il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; - if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) + if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) return 0; - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return -EIO; /* scan complete use sleep_power_next, need to be updated */ - memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); - if (test_bit(STATUS_SCANNING, &priv->status) && !force) { - IL_DEBUG_INFO(priv, "Defer power set mode while scanning\n"); + memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); + if (test_bit(STATUS_SCANNING, &il->status) && !force) { + IL_DEBUG_INFO(il, "Defer power set mode while scanning\n"); return 0; } if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) - set_bit(STATUS_POWER_PMI, &priv->status); + set_bit(STATUS_POWER_PMI, &il->status); - ret = il_set_power(priv, cmd); + ret = il_set_power(il, cmd); if (!ret) { if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) - clear_bit(STATUS_POWER_PMI, &priv->status); + clear_bit(STATUS_POWER_PMI, &il->status); - if (priv->cfg->ops->lib->update_chain_flags && update_chains) - priv->cfg->ops->lib->update_chain_flags(priv); - else if (priv->cfg->ops->lib->update_chain_flags) - IL_DEBUG_POWER(priv, + if (il->cfg->ops->lib->update_chain_flags && update_chains) + il->cfg->ops->lib->update_chain_flags(il); + else if (il->cfg->ops->lib->update_chain_flags) + IL_DEBUG_POWER(il, "Cannot update the power, chain noise " "calibration running: %d\n", - priv->chain_noise_data.state); + il->chain_noise_data.state); - memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)); + memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else - IL_ERR(priv, "set power fail, ret = %d", ret); + IL_ERR(il, "set power fail, ret = %d", ret); return ret; } -int il_power_update_mode(struct il_priv *priv, bool force) +int il_power_update_mode(struct il_priv *il, bool force) { struct il_powertable_cmd cmd; - il_power_sleep_cam_cmd(priv, &cmd); - return il_power_set_mode(priv, &cmd, force); + il_power_sleep_cam_cmd(il, &cmd); + return il_power_set_mode(il, &cmd, force); } EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ -void il_power_initialize(struct il_priv *priv) +void il_power_initialize(struct il_priv *il) { - u16 lctl = il_pcie_link_ctl(priv); + u16 lctl = il_pcie_link_ctl(il); - priv->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); + il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); - priv->power_data.debug_sleep_level_override = -1; + il->power_data.debug_sleep_level_override = -1; - memset(&priv->power_data.sleep_cmd, 0, - sizeof(priv->power_data.sleep_cmd)); + memset(&il->power_data.sleep_cmd, 0, + sizeof(il->power_data.sleep_cmd)); } EXPORT_SYMBOL(il_power_initialize); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index dba4ca9..e149f78 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -47,9 +47,9 @@ struct il_power_mgr { }; int -il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force); -int il_power_update_mode(struct il_priv *priv, bool force); -void il_power_initialize(struct il_priv *priv); +int il_power_update_mode(struct il_priv *il, bool force); +void il_power_initialize(struct il_priv *il); #endif /* __il_power_setting_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 9a2714c..b6c5dd0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -124,11 +124,11 @@ EXPORT_SYMBOL(il_rx_queue_space); * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue */ void -il_rx_queue_update_write_ptr(struct il_priv *priv, +il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q) { unsigned long flags; - u32 rx_wrt_ptr_reg = priv->hw_params.rx_wrt_ptr_reg; + u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; u32 reg; spin_lock_irqsave(&q->lock, flags); @@ -137,27 +137,27 @@ il_rx_queue_update_write_ptr(struct il_priv *priv, goto exit_unlock; /* If power-saving is in use, make sure device is awake */ - if (test_bit(STATUS_POWER_PMI, &priv->status)) { - reg = il_read32(priv, CSR_UCODE_DRV_GP1); + if (test_bit(STATUS_POWER_PMI, &il->status)) { + reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Rx queue requesting wakeup," " GP1 = 0x%x\n", reg); - il_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); goto exit_unlock; } q->write_actual = (q->write & ~0x7); - il_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(il, rx_wrt_ptr_reg, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - il_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(il, rx_wrt_ptr_reg, q->write_actual); } @@ -168,10 +168,10 @@ il_rx_queue_update_write_ptr(struct il_priv *priv, } EXPORT_SYMBOL(il_rx_queue_update_write_ptr); -int il_rx_queue_alloc(struct il_priv *priv) +int il_rx_queue_alloc(struct il_priv *il) { - struct il_rx_queue *rxq = &priv->rxq; - struct device *dev = &priv->pci_dev->dev; + struct il_rx_queue *rxq = &il->rxq; + struct device *dev = &il->pci_dev->dev; int i; spin_lock_init(&rxq->lock); @@ -202,7 +202,7 @@ int il_rx_queue_alloc(struct il_priv *priv) return 0; err_rb: - dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); err_bd: return -ENOMEM; @@ -210,27 +210,27 @@ err_bd: EXPORT_SYMBOL(il_rx_queue_alloc); -void il_rx_spectrum_measure_notif(struct il_priv *priv, +void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - IL_DEBUG_11H(priv, + IL_DEBUG_11H(il, "Spectrum Measure Notification: Start\n"); return; } - memcpy(&priv->measure_report, report, sizeof(*report)); - priv->measurement_status |= MEASUREMENT_READY; + memcpy(&il->measure_report, report, sizeof(*report)); + il->measurement_status |= MEASUREMENT_READY; } EXPORT_SYMBOL(il_rx_spectrum_measure_notif); /* * returns non-zero if packet should be dropped */ -int il_set_decrypted_flag(struct il_priv *priv, +int il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats) @@ -241,14 +241,14 @@ int il_set_decrypted_flag(struct il_priv *priv, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (priv->contexts[IL_RXON_CTX_BSS].active.filter_flags & + if (il->contexts[IL_RXON_CTX_BSS].active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; if (!(fc & IEEE80211_FCTL_PROTECTED)) return 0; - IL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res); + IL_DEBUG_RX(il, "decrypt_res:0x%x\n", decrypt_res); switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { case RX_RES_STATUS_SEC_TYPE_TKIP: /* The uCode has got a bad phase 1 Key, pushes the packet. @@ -262,13 +262,13 @@ int il_set_decrypted_flag(struct il_priv *priv, RX_RES_STATUS_BAD_ICV_MIC) { /* bad ICV, the packet is destroyed since the * decryption is inplace, drop it */ - IL_DEBUG_RX(priv, "Packet destroyed\n"); + IL_DEBUG_RX(il, "Packet destroyed\n"); return -1; } case RX_RES_STATUS_SEC_TYPE_CCMP: if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == RX_RES_STATUS_DECRYPT_OK) { - IL_DEBUG_RX(priv, "hw decrypt successfully!!!\n"); + IL_DEBUG_RX(il, "hw decrypt successfully!!!\n"); stats->flag |= RX_FLAG_DECRYPTED; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 93e939c..0184d5b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -54,7 +54,7 @@ #define IL_PASSIVE_DWELL_BASE (100) #define IL_CHANNEL_TUNE_TIME 5 -static int il_send_scan_abort(struct il_priv *priv) +static int il_send_scan_abort(struct il_priv *il) { int ret; struct il_rx_packet *pkt; @@ -66,14 +66,14 @@ static int il_send_scan_abort(struct il_priv *priv) /* Exit instantly with error when device is not ready * to receive scan abort command or it does not perform * hardware scan currently */ - if (!test_bit(STATUS_READY, &priv->status) || - !test_bit(STATUS_GEO_CONFIGURED, &priv->status) || - !test_bit(STATUS_SCAN_HW, &priv->status) || - test_bit(STATUS_FW_ERROR, &priv->status) || - test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (!test_bit(STATUS_READY, &il->status) || + !test_bit(STATUS_GEO_CONFIGURED, &il->status) || + !test_bit(STATUS_SCAN_HW, &il->status) || + test_bit(STATUS_FW_ERROR, &il->status) || + test_bit(STATUS_EXIT_PENDING, &il->status)) return -EIO; - ret = il_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(il, &cmd); if (ret) return ret; @@ -85,73 +85,73 @@ static int il_send_scan_abort(struct il_priv *priv) * can occur if we send the scan abort before we * the microcode has notified us that a scan is * completed. */ - IL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status); + IL_DEBUG_SCAN(il, "SCAN_ABORT ret %d.\n", pkt->u.status); ret = -EIO; } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return ret; } -static void il_complete_scan(struct il_priv *priv, bool aborted) +static void il_complete_scan(struct il_priv *il, bool aborted) { /* check if scan was requested from mac80211 */ - if (priv->scan_request) { - IL_DEBUG_SCAN(priv, "Complete scan in mac80211\n"); - ieee80211_scan_completed(priv->hw, aborted); + if (il->scan_request) { + IL_DEBUG_SCAN(il, "Complete scan in mac80211\n"); + ieee80211_scan_completed(il->hw, aborted); } - priv->scan_vif = NULL; - priv->scan_request = NULL; + il->scan_vif = NULL; + il->scan_request = NULL; } -void il_force_scan_end(struct il_priv *priv) +void il_force_scan_end(struct il_priv *il) { - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); + if (!test_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Forcing scan end while not scanning\n"); return; } - IL_DEBUG_SCAN(priv, "Forcing scan end\n"); - clear_bit(STATUS_SCANNING, &priv->status); - clear_bit(STATUS_SCAN_HW, &priv->status); - clear_bit(STATUS_SCAN_ABORTING, &priv->status); - il_complete_scan(priv, true); + IL_DEBUG_SCAN(il, "Forcing scan end\n"); + clear_bit(STATUS_SCANNING, &il->status); + clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(STATUS_SCAN_ABORTING, &il->status); + il_complete_scan(il, true); } -static void il_do_scan_abort(struct il_priv *priv) +static void il_do_scan_abort(struct il_priv *il) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); + if (!test_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Not performing scan to abort\n"); return; } - if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan abort in progress\n"); + if (test_and_set_bit(STATUS_SCAN_ABORTING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan abort in progress\n"); return; } - ret = il_send_scan_abort(priv); + ret = il_send_scan_abort(il); if (ret) { - IL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret); - il_force_scan_end(priv); + IL_DEBUG_SCAN(il, "Send scan abort failed %d\n", ret); + il_force_scan_end(il); } else - IL_DEBUG_SCAN(priv, "Successfully send scan abort\n"); + IL_DEBUG_SCAN(il, "Successfully send scan abort\n"); } /** * il_scan_cancel - Cancel any currently executing HW scan */ -int il_scan_cancel(struct il_priv *priv) +int il_scan_cancel(struct il_priv *il) { - IL_DEBUG_SCAN(priv, "Queuing abort scan\n"); - queue_work(priv->workqueue, &priv->abort_scan); + IL_DEBUG_SCAN(il, "Queuing abort scan\n"); + queue_work(il->workqueue, &il->abort_scan); return 0; } EXPORT_SYMBOL(il_scan_cancel); @@ -161,28 +161,28 @@ EXPORT_SYMBOL(il_scan_cancel); * @ms: amount of time to wait (in milliseconds) for scan to abort * */ -int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms) +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) { unsigned long timeout = jiffies + msecs_to_jiffies(ms); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - IL_DEBUG_SCAN(priv, "Scan cancel timeout\n"); + IL_DEBUG_SCAN(il, "Scan cancel timeout\n"); - il_do_scan_abort(priv); + il_do_scan_abort(il); while (time_before_eq(jiffies, timeout)) { - if (!test_bit(STATUS_SCAN_HW, &priv->status)) + if (!test_bit(STATUS_SCAN_HW, &il->status)) break; msleep(20); } - return test_bit(STATUS_SCAN_HW, &priv->status); + return test_bit(STATUS_SCAN_HW, &il->status); } EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to REPLY_SCAN_CMD (0x80) */ -static void il_rx_reply_scan(struct il_priv *priv, +static void il_rx_reply_scan(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -190,19 +190,19 @@ static void il_rx_reply_scan(struct il_priv *priv, struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; - IL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status); + IL_DEBUG_SCAN(il, "Scan request status = 0x%x\n", notif->status); #endif } /* Service SCAN_START_NOTIFICATION (0x82) */ -static void il_rx_scan_start_notif(struct il_priv *priv, +static void il_rx_scan_start_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; - priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); - IL_DEBUG_SCAN(priv, "Scan start: " + il->scan_start_tsf = le32_to_cpu(notif->tsf_low); + IL_DEBUG_SCAN(il, "Scan start: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, @@ -213,7 +213,7 @@ static void il_rx_scan_start_notif(struct il_priv *priv, } /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ -static void il_rx_scan_results_notif(struct il_priv *priv, +static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -221,7 +221,7 @@ static void il_rx_scan_results_notif(struct il_priv *priv, struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; - IL_DEBUG_SCAN(priv, "Scan ch.res: " + IL_DEBUG_SCAN(il, "Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " "elapsed=%lu usec\n", @@ -230,12 +230,12 @@ static void il_rx_scan_results_notif(struct il_priv *priv, le32_to_cpu(notif->tsf_high), le32_to_cpu(notif->tsf_low), le32_to_cpu(notif->statistics[0]), - le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf); + le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); #endif } /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ -static void il_rx_scan_complete_notif(struct il_priv *priv, +static void il_rx_scan_complete_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { @@ -244,36 +244,36 @@ static void il_rx_scan_complete_notif(struct il_priv *priv, struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - IL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(il, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", scan_notif->scanned_channels, scan_notif->tsf_low, scan_notif->tsf_high, scan_notif->status); /* The HW is no longer scanning */ - clear_bit(STATUS_SCAN_HW, &priv->status); + clear_bit(STATUS_SCAN_HW, &il->status); - IL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n", - (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", - jiffies_to_msecs(jiffies - priv->scan_start)); + IL_DEBUG_SCAN(il, "Scan on %sGHz took %dms\n", + (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", + jiffies_to_msecs(jiffies - il->scan_start)); - queue_work(priv->workqueue, &priv->scan_completed); + queue_work(il->workqueue, &il->scan_completed); } -void il_setup_rx_scan_handlers(struct il_priv *priv) +void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - priv->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; - priv->rx_handlers[SCAN_START_NOTIFICATION] = + il->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; + il->rx_handlers[SCAN_START_NOTIFICATION] = il_rx_scan_start_notif; - priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = + il->rx_handlers[SCAN_RESULTS_NOTIFICATION] = il_rx_scan_results_notif; - priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = + il->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = il_rx_scan_complete_notif; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); -inline u16 il_get_active_dwell_time(struct il_priv *priv, +inline u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, u8 n_probes) { @@ -286,7 +286,7 @@ inline u16 il_get_active_dwell_time(struct il_priv *priv, } EXPORT_SYMBOL(il_get_active_dwell_time); -u16 il_get_passive_dwell_time(struct il_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, struct ieee80211_vif *vif) { @@ -295,13 +295,13 @@ u16 il_get_passive_dwell_time(struct il_priv *priv, IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; - if (il_is_any_associated(priv)) { + if (il_is_any_associated(il)) { /* * If we're associated, we clamp the maximum passive * dwell time to be 98% of the smallest beacon interval * (minus 2 * channel tune time) */ - for_each_context(priv, ctx) { + for_each_context(il, ctx) { u16 value; if (!il_is_associated_ctx(ctx)) @@ -318,56 +318,56 @@ u16 il_get_passive_dwell_time(struct il_priv *priv, } EXPORT_SYMBOL(il_get_passive_dwell_time); -void il_init_scan_params(struct il_priv *priv) +void il_init_scan_params(struct il_priv *il) { - u8 ant_idx = fls(priv->hw_params.valid_tx_ant) - 1; - if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ]) - priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; - if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ]) - priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; + u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; + if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) + il->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; + if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) + il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } EXPORT_SYMBOL(il_init_scan_params); -static int il_scan_initiate(struct il_priv *priv, +static int il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (WARN_ON(!priv->cfg->ops->utils->request_scan)) + if (WARN_ON(!il->cfg->ops->utils->request_scan)) return -EOPNOTSUPP; - cancel_delayed_work(&priv->scan_check); + cancel_delayed_work(&il->scan_check); - if (!il_is_ready_rf(priv)) { - IL_WARN(priv, "Request scan called when driver not ready.\n"); + if (!il_is_ready_rf(il)) { + IL_WARN(il, "Request scan called when driver not ready.\n"); return -EIO; } - if (test_bit(STATUS_SCAN_HW, &priv->status)) { - IL_DEBUG_SCAN(priv, + if (test_bit(STATUS_SCAN_HW, &il->status)) { + IL_DEBUG_SCAN(il, "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } - if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan request while abort pending.\n"); + if (test_bit(STATUS_SCAN_ABORTING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan request while abort pending.\n"); return -EBUSY; } - IL_DEBUG_SCAN(priv, "Starting scan...\n"); + IL_DEBUG_SCAN(il, "Starting scan...\n"); - set_bit(STATUS_SCANNING, &priv->status); - priv->scan_start = jiffies; + set_bit(STATUS_SCANNING, &il->status); + il->scan_start = jiffies; - ret = priv->cfg->ops->utils->request_scan(priv, vif); + ret = il->cfg->ops->utils->request_scan(il, vif); if (ret) { - clear_bit(STATUS_SCANNING, &priv->status); + clear_bit(STATUS_SCANNING, &il->status); return ret; } - queue_delayed_work(priv->workqueue, &priv->scan_check, + queue_delayed_work(il->workqueue, &il->scan_check, IL_SCAN_CHECK_WATCHDOG); return 0; @@ -377,33 +377,33 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); if (req->n_channels == 0) return -EINVAL; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (test_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan already in progress.\n"); + if (test_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; } /* mac80211 will only ask for one band at a time */ - priv->scan_request = req; - priv->scan_vif = vif; - priv->scan_band = req->channels[0]->band; + il->scan_request = req; + il->scan_vif = vif; + il->scan_band = req->channels[0]->band; - ret = il_scan_initiate(priv, vif); + ret = il_scan_initiate(il, vif); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); out_unlock: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } @@ -411,17 +411,17 @@ EXPORT_SYMBOL(il_mac_hw_scan); static void il_bg_scan_check(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, scan_check.work); - IL_DEBUG_SCAN(priv, "Scan check work\n"); + IL_DEBUG_SCAN(il, "Scan check work\n"); /* Since we are here firmware does not finish scan and * most likely is in bad shape, so we don't bother to * send abort command, just force scan complete to mac80211 */ - mutex_lock(&priv->mutex); - il_force_scan_end(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); } /** @@ -429,7 +429,7 @@ static void il_bg_scan_check(struct work_struct *data) */ u16 -il_fill_probe_req(struct il_priv *priv, struct ieee80211_mgmt *frame, +il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ies, int ie_len, int left) { int len = 0; @@ -475,75 +475,75 @@ EXPORT_SYMBOL(il_fill_probe_req); static void il_bg_abort_scan(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, abort_scan); + struct il_priv *il = container_of(work, struct il_priv, abort_scan); - IL_DEBUG_SCAN(priv, "Abort scan work\n"); + IL_DEBUG_SCAN(il, "Abort scan work\n"); /* We keep scan_check work queued in case when firmware will not * report back scan completed notification */ - mutex_lock(&priv->mutex); - il_scan_cancel_timeout(priv, 200); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 200); + mutex_unlock(&il->mutex); } static void il_bg_scan_completed(struct work_struct *work) { - struct il_priv *priv = + struct il_priv *il = container_of(work, struct il_priv, scan_completed); bool aborted; - IL_DEBUG_SCAN(priv, "Completed scan.\n"); + IL_DEBUG_SCAN(il, "Completed scan.\n"); - cancel_delayed_work(&priv->scan_check); + cancel_delayed_work(&il->scan_check); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status); + aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &il->status); if (aborted) - IL_DEBUG_SCAN(priv, "Aborted scan completed.\n"); + IL_DEBUG_SCAN(il, "Aborted scan completed.\n"); - if (!test_and_clear_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan already completed.\n"); + if (!test_and_clear_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan already completed.\n"); goto out_settings; } - il_complete_scan(priv, aborted); + il_complete_scan(il, aborted); out_settings: /* Can we still talk to firmware ? */ - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) goto out; /* * We do not commit power settings while scan is pending, * do it now if the settings changed. */ - il_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); - il_set_tx_power(priv, priv->tx_power_next, false); + il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); + il_set_tx_power(il, il->tx_power_next, false); - priv->cfg->ops->utils->post_scan(priv); + il->cfg->ops->utils->post_scan(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } -void il_setup_scan_deferred_work(struct il_priv *priv) +void il_setup_scan_deferred_work(struct il_priv *il) { - INIT_WORK(&priv->scan_completed, il_bg_scan_completed); - INIT_WORK(&priv->abort_scan, il_bg_abort_scan); - INIT_DELAYED_WORK(&priv->scan_check, il_bg_scan_check); + INIT_WORK(&il->scan_completed, il_bg_scan_completed); + INIT_WORK(&il->abort_scan, il_bg_abort_scan); + INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); } EXPORT_SYMBOL(il_setup_scan_deferred_work); -void il_cancel_scan_deferred_work(struct il_priv *priv) +void il_cancel_scan_deferred_work(struct il_priv *il) { - cancel_work_sync(&priv->abort_scan); - cancel_work_sync(&priv->scan_completed); + cancel_work_sync(&il->abort_scan); + cancel_work_sync(&il->scan_completed); - if (cancel_delayed_work_sync(&priv->scan_check)) { - mutex_lock(&priv->mutex); - il_force_scan_end(priv); - mutex_unlock(&priv->mutex); + if (cancel_delayed_work_sync(&il->scan_check)) { + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); } } EXPORT_SYMBOL(il_cancel_scan_deferred_work); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 3773f7d..7d66e79 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -36,28 +36,28 @@ #include "iwl-core.h" #include "iwl-sta.h" -/* priv->sta_lock must be held */ -static void il_sta_ucode_activate(struct il_priv *priv, u8 sta_id) +/* il->sta_lock must be held */ +static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) { - if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) - IL_ERR(priv, + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) + IL_ERR(il, "ACTIVATE a non DRIVER active station id %u addr %pM\n", - sta_id, priv->stations[sta_id].sta.sta.addr); + sta_id, il->stations[sta_id].sta.sta.addr); - if (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_ASSOC(priv, + if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_ASSOC(il, "STA id %u addr %pM already present" " in uCode (according to driver)\n", - sta_id, priv->stations[sta_id].sta.sta.addr); + sta_id, il->stations[sta_id].sta.sta.addr); } else { - priv->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; - IL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", - sta_id, priv->stations[sta_id].sta.sta.addr); + il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; + IL_DEBUG_ASSOC(il, "Added STA id %u addr %pM to uCode\n", + sta_id, il->stations[sta_id].sta.sta.addr); } } -static int il_process_add_sta_resp(struct il_priv *priv, +static int il_process_add_sta_resp(struct il_priv *il, struct il_addsta_cmd *addsta, struct il_rx_packet *pkt, bool sync) @@ -67,45 +67,45 @@ static int il_process_add_sta_resp(struct il_priv *priv, int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n", + IL_ERR(il, "Bad return from REPLY_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } - IL_DEBUG_INFO(priv, "Processing response for adding station %u\n", + IL_DEBUG_INFO(il, "Processing response for adding station %u\n", sta_id); - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - IL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); - il_sta_ucode_activate(priv, sta_id); + IL_DEBUG_INFO(il, "REPLY_ADD_STA PASSED\n"); + il_sta_ucode_activate(il, sta_id); ret = 0; break; case ADD_STA_NO_ROOM_IN_TABLE: - IL_ERR(priv, "Adding station %d failed, no room in table.\n", + IL_ERR(il, "Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IL_ERR(priv, + IL_ERR(il, "Adding station %d failed, no block ack resource.\n", sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: - IL_ERR(priv, "Attempting to modify non-existing station %d\n", + IL_ERR(il, "Attempting to modify non-existing station %d\n", sta_id); break; default: - IL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n", + IL_DEBUG_ASSOC(il, "Received REPLY_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } - IL_DEBUG_INFO(priv, "%s station id %u addr %pM\n", - priv->stations[sta_id].sta.mode == + IL_DEBUG_INFO(il, "%s station id %u addr %pM\n", + il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", - sta_id, priv->stations[sta_id].sta.sta.addr); + sta_id, il->stations[sta_id].sta.sta.addr); /* * XXX: The MAC address in the command buffer is often changed from @@ -115,27 +115,27 @@ static int il_process_add_sta_resp(struct il_priv *priv, * issue has not yet been resolved and this debugging is left to * observe the problem. */ - IL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n", - priv->stations[sta_id].sta.mode == + IL_DEBUG_INFO(il, "%s station according to cmd buffer %pM\n", + il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static void il_add_sta_callback(struct il_priv *priv, +static void il_add_sta_callback(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt) { struct il_addsta_cmd *addsta = (struct il_addsta_cmd *)cmd->cmd.payload; - il_process_add_sta_resp(priv, addsta, pkt, false); + il_process_add_sta_resp(il, addsta, pkt, false); } -int il_send_add_sta(struct il_priv *priv, +int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) { struct il_rx_packet *pkt = NULL; @@ -148,7 +148,7 @@ int il_send_add_sta(struct il_priv *priv, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - IL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", + IL_DEBUG_INFO(il, "Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) @@ -158,23 +158,23 @@ int il_send_add_sta(struct il_priv *priv, might_sleep(); } - cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); - ret = il_send_cmd(priv, &cmd); + cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); + ret = il_send_cmd(il, &cmd); if (ret || (flags & CMD_ASYNC)) return ret; if (ret == 0) { pkt = (struct il_rx_packet *)cmd.reply_page; - ret = il_process_add_sta_resp(priv, sta, pkt, true); + ret = il_process_add_sta_resp(il, sta, pkt, true); } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return ret; } EXPORT_SYMBOL(il_send_add_sta); -static void il_set_ht_add_station(struct il_priv *priv, u8 index, +static void il_set_ht_add_station(struct il_priv *il, u8 index, struct ieee80211_sta *sta, struct il_rxon_context *ctx) { @@ -186,13 +186,13 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, goto done; mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; - IL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n", + IL_DEBUG_ASSOC(il, "spatial multiplexing power save mode: %s\n", (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? "dynamic" : "disabled"); - sta_flags = priv->stations[index].sta.station_flags; + sta_flags = il->stations[index].sta.station_flags; sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); @@ -206,7 +206,7 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, case WLAN_HT_CAP_SM_PS_DISABLED: break; default: - IL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode); + IL_WARN(il, "Invalid MIMO PS mode %d\n", mimo_ps_mode); break; } @@ -216,12 +216,12 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, sta_flags |= cpu_to_le32( (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); - if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) sta_flags |= STA_FLG_HT40_EN_MSK; else sta_flags &= ~STA_FLG_HT40_EN_MSK; - priv->stations[index].sta.station_flags = sta_flags; + il->stations[index].sta.station_flags = sta_flags; done: return; } @@ -231,7 +231,7 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, * * should be called with sta_lock held */ -u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta) { struct il_station_entry *station; @@ -244,14 +244,14 @@ u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, else if (is_broadcast_ether_addr(addr)) sta_id = ctx->bcast_sta_id; else - for (i = IL_STA_ID; i < priv->hw_params.max_stations; i++) { - if (!compare_ether_addr(priv->stations[i].sta.sta.addr, + for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { + if (!compare_ether_addr(il->stations[i].sta.sta.addr, addr)) { sta_id = i; break; } - if (!priv->stations[i].used && + if (!il->stations[i].used && sta_id == IL_INVALID_STATION) sta_id = i; } @@ -268,27 +268,27 @@ u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(priv, + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(il, "STA %d already in process of being added.\n", sta_id); return sta_id; } - if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && - !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) { - IL_DEBUG_ASSOC(priv, + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && + !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { + IL_DEBUG_ASSOC(il, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); return sta_id; } - station = &priv->stations[sta_id]; + station = &il->stations[sta_id]; station->used = IL_STA_DRIVER_ACTIVE; - IL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", + IL_DEBUG_ASSOC(il, "Add STA to driver ID %d: %pM\n", sta_id, addr); - priv->num_stations++; + il->num_stations++; /* Set up the REPLY_ADD_STA command to send to device */ memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); @@ -310,10 +310,10 @@ u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, * STA and broadcast STA) pass in a NULL sta, and mac80211 * doesn't allow HT IBSS. */ - il_set_ht_add_station(priv, sta_id, sta, ctx); + il_set_ht_add_station(il, sta_id, sta, ctx); /* 3945 only */ - rate = (priv->band == IEEE80211_BAND_5GHZ) ? + rate = (il->band == IEEE80211_BAND_5GHZ) ? IL_RATE_6M_PLCP : IL_RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); @@ -329,7 +329,7 @@ EXPORT_SYMBOL_GPL(il_prep_station); * il_add_station_common - */ int -il_add_station_common(struct il_priv *priv, +il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r) @@ -340,12 +340,12 @@ il_add_station_common(struct il_priv *priv, struct il_addsta_cmd sta_cmd; *sta_id_r = 0; - spin_lock_irqsave(&priv->sta_lock, flags_spin); - sta_id = il_prep_station(priv, ctx, addr, is_ap, sta); + spin_lock_irqsave(&il->sta_lock, flags_spin); + sta_id = il_prep_station(il, ctx, addr, is_ap, sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Unable to prepare station %pM for addition\n", + IL_ERR(il, "Unable to prepare station %pM for addition\n", addr); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; } @@ -354,37 +354,37 @@ il_add_station_common(struct il_priv *priv, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(priv, + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(il, "STA %d already in process of being added.\n", sta_id); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; } - if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(priv, + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(il, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; } - priv->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); /* Add station to device's station table */ - ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { - spin_lock_irqsave(&priv->sta_lock, flags_spin); - IL_ERR(priv, "Adding station %pM failed.\n", - priv->stations[sta_id].sta.sta.addr); - priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR(il, "Adding station %pM failed.\n", + il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } *sta_id_r = sta_id; return ret; @@ -394,23 +394,23 @@ EXPORT_SYMBOL(il_add_station_common); /** * il_sta_ucode_deactivate - deactivate ucode status for a station * - * priv->sta_lock must be held + * il->sta_lock must be held */ -static void il_sta_ucode_deactivate(struct il_priv *priv, u8 sta_id) +static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) { /* Ucode must be active and driver must be non active */ - if ((priv->stations[sta_id].used & + if ((il->stations[sta_id].used & (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != IL_STA_UCODE_ACTIVE) - IL_ERR(priv, "removed non active STA %u\n", sta_id); + IL_ERR(il, "removed non active STA %u\n", sta_id); - priv->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; - memset(&priv->stations[sta_id], 0, sizeof(struct il_station_entry)); - IL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id); + memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); + IL_DEBUG_ASSOC(il, "Removed STA %u\n", sta_id); } -static int il_send_remove_station(struct il_priv *priv, +static int il_send_remove_station(struct il_priv *il, const u8 *addr, int sta_id, bool temporary) { @@ -433,14 +433,14 @@ static int il_send_remove_station(struct il_priv *priv, cmd.flags |= CMD_WANT_SKB; - ret = il_send_cmd(priv, &cmd); + ret = il_send_cmd(il, &cmd); if (ret) return ret; pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", + IL_ERR(il, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -449,20 +449,20 @@ static int il_send_remove_station(struct il_priv *priv, switch (pkt->u.rem_sta.status) { case REM_STA_SUCCESS_MSK: if (!temporary) { - spin_lock_irqsave(&priv->sta_lock, flags_spin); - il_sta_ucode_deactivate(priv, sta_id); - spin_unlock_irqrestore(&priv->sta_lock, + spin_lock_irqsave(&il->sta_lock, flags_spin); + il_sta_ucode_deactivate(il, sta_id); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } - IL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); + IL_DEBUG_ASSOC(il, "REPLY_REMOVE_STA PASSED\n"); break; default: ret = -EIO; - IL_ERR(priv, "REPLY_REMOVE_STA failed\n"); + IL_ERR(il, "REPLY_REMOVE_STA failed\n"); break; } } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return ret; } @@ -470,13 +470,13 @@ static int il_send_remove_station(struct il_priv *priv, /** * il_remove_station - Remove driver's knowledge of station. */ -int il_remove_station(struct il_priv *priv, const u8 sta_id, +int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 *addr) { unsigned long flags; - if (!il_is_ready(priv)) { - IL_DEBUG_INFO(priv, + if (!il_is_ready(il)) { + IL_DEBUG_INFO(il, "Unable to remove station %pM, device not ready.\n", addr); /* @@ -487,42 +487,42 @@ int il_remove_station(struct il_priv *priv, const u8 sta_id, return 0; } - IL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", + IL_DEBUG_ASSOC(il, "Removing STA from driver:%d %pM\n", sta_id, addr); if (WARN_ON(sta_id == IL_INVALID_STATION)) return -EINVAL; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { - IL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { + IL_DEBUG_INFO(il, "Removing %pM but non DRIVER active\n", addr); goto out_err; } - if (!(priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", + if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_INFO(il, "Removing %pM but non UCODE active\n", addr); goto out_err; } - if (priv->stations[sta_id].used & IL_STA_LOCAL) { - kfree(priv->stations[sta_id].lq); - priv->stations[sta_id].lq = NULL; + if (il->stations[sta_id].used & IL_STA_LOCAL) { + kfree(il->stations[sta_id].lq); + il->stations[sta_id].lq = NULL; } - priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; - priv->num_stations--; + il->num_stations--; - BUG_ON(priv->num_stations < 0); + BUG_ON(il->num_stations < 0); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_remove_station(priv, addr, sta_id, false); + return il_send_remove_station(il, addr, sta_id, false); out_err: - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } EXPORT_SYMBOL_GPL(il_remove_station); @@ -535,31 +535,31 @@ EXPORT_SYMBOL_GPL(il_remove_station); * other than explicit station management would cause this in * the ucode, e.g. unassociated RXON. */ -void il_clear_ucode_stations(struct il_priv *priv, +void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) { int i; unsigned long flags_spin; bool cleared = false; - IL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n"); + IL_DEBUG_INFO(il, "Clearing ucode stations in driver\n"); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - for (i = 0; i < priv->hw_params.max_stations; i++) { - if (ctx && ctx->ctxid != priv->stations[i].ctxid) + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx && ctx->ctxid != il->stations[i].ctxid) continue; - if (priv->stations[i].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_INFO(priv, + if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_INFO(il, "Clearing ucode active for station %d\n", i); - priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; } } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!cleared) - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "No active stations found to be cleared\n"); } EXPORT_SYMBOL(il_clear_ucode_stations); @@ -573,7 +573,7 @@ EXPORT_SYMBOL(il_clear_ucode_stations); * Function sleeps. */ void -il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) +il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) { struct il_addsta_cmd sta_cmd; struct il_link_quality_cmd lq; @@ -583,48 +583,48 @@ il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) int ret; bool send_lq; - if (!il_is_ready(priv)) { - IL_DEBUG_INFO(priv, + if (!il_is_ready(il)) { + IL_DEBUG_INFO(il, "Not ready yet, not restoring any stations.\n"); return; } - IL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - for (i = 0; i < priv->hw_params.max_stations; i++) { - if (ctx->ctxid != priv->stations[i].ctxid) + IL_DEBUG_ASSOC(il, "Restoring all known stations ... start.\n"); + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx->ctxid != il->stations[i].ctxid) continue; - if ((priv->stations[i].used & IL_STA_DRIVER_ACTIVE) && - !(priv->stations[i].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(priv, "Restoring sta %pM\n", - priv->stations[i].sta.sta.addr); - priv->stations[i].sta.mode = 0; - priv->stations[i].used |= IL_STA_UCODE_INPROGRESS; + if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && + !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(il, "Restoring sta %pM\n", + il->stations[i].sta.sta.addr); + il->stations[i].sta.mode = 0; + il->stations[i].used |= IL_STA_UCODE_INPROGRESS; found = true; } } - for (i = 0; i < priv->hw_params.max_stations; i++) { - if ((priv->stations[i].used & IL_STA_UCODE_INPROGRESS)) { - memcpy(&sta_cmd, &priv->stations[i].sta, + for (i = 0; i < il->hw_params.max_stations; i++) { + if ((il->stations[i].used & IL_STA_UCODE_INPROGRESS)) { + memcpy(&sta_cmd, &il->stations[i].sta, sizeof(struct il_addsta_cmd)); send_lq = false; - if (priv->stations[i].lq) { - memcpy(&lq, priv->stations[i].lq, + if (il->stations[i].lq) { + memcpy(&lq, il->stations[i].lq, sizeof(struct il_link_quality_cmd)); send_lq = true; } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { - spin_lock_irqsave(&priv->sta_lock, flags_spin); - IL_ERR(priv, "Adding station %pM failed.\n", - priv->stations[i].sta.sta.addr); - priv->stations[i].used &= + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR(il, "Adding station %pM failed.\n", + il->stations[i].sta.sta.addr); + il->stations[i].used &= ~IL_STA_DRIVER_ACTIVE; - priv->stations[i].used &= + il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->sta_lock, + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } /* @@ -632,71 +632,71 @@ il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) * current LQ command */ if (send_lq) - il_send_lq_cmd(priv, ctx, &lq, + il_send_lq_cmd(il, ctx, &lq, CMD_SYNC, true); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; } } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!found) - IL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(il, "Restoring all known stations" " .... no stations to be restored.\n"); else - IL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(il, "Restoring all known stations" " .... complete.\n"); } EXPORT_SYMBOL(il_restore_stations); -int il_get_free_ucode_key_index(struct il_priv *priv) +int il_get_free_ucode_key_index(struct il_priv *il) { int i; - for (i = 0; i < priv->sta_key_max_num; i++) - if (!test_and_set_bit(i, &priv->ucode_key_table)) + for (i = 0; i < il->sta_key_max_num; i++) + if (!test_and_set_bit(i, &il->ucode_key_table)) return i; return WEP_INVALID_OFFSET; } EXPORT_SYMBOL(il_get_free_ucode_key_index); -void il_dealloc_bcast_stations(struct il_priv *priv) +void il_dealloc_bcast_stations(struct il_priv *il) { unsigned long flags; int i; - spin_lock_irqsave(&priv->sta_lock, flags); - for (i = 0; i < priv->hw_params.max_stations; i++) { - if (!(priv->stations[i].used & IL_STA_BCAST)) + spin_lock_irqsave(&il->sta_lock, flags); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (!(il->stations[i].used & IL_STA_BCAST)) continue; - priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; - priv->num_stations--; - BUG_ON(priv->num_stations < 0); - kfree(priv->stations[i].lq); - priv->stations[i].lq = NULL; + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + il->num_stations--; + BUG_ON(il->num_stations < 0); + kfree(il->stations[i].lq); + il->stations[i].lq = NULL; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static void il_dump_lq_cmd(struct il_priv *priv, +static void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { int i; - IL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id); - IL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n", + IL_DEBUG_RATE(il, "lq station id 0x%x\n", lq->sta_id); + IL_DEBUG_RATE(il, "lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - IL_DEBUG_RATE(priv, "lq index %d 0x%X\n", + IL_DEBUG_RATE(il, "lq index %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else -static inline void il_dump_lq_cmd(struct il_priv *priv, +static inline void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { } @@ -713,7 +713,7 @@ static inline void il_dump_lq_cmd(struct il_priv *priv, * Test for this to prevent driver from sending LQ command between the time * RXON flags are updated and when LQ command is updated. */ -static bool il_is_lq_table_valid(struct il_priv *priv, +static bool il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq) { @@ -722,12 +722,12 @@ static bool il_is_lq_table_valid(struct il_priv *priv, if (ctx->ht.enabled) return true; - IL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n", + IL_DEBUG_INFO(il, "Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "index %d of LQ expects HT channel\n", i); return false; @@ -746,7 +746,7 @@ static bool il_is_lq_table_valid(struct il_priv *priv, * this case to clear the state indicating that station creation is in * progress. */ -int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq, u8 flags, bool init) { int ret = 0; @@ -763,18 +763,18 @@ int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, return -EINVAL; - spin_lock_irqsave(&priv->sta_lock, flags_spin); - if (!(priv->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_lock_irqsave(&il->sta_lock, flags_spin); + if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); - il_dump_lq_cmd(priv, lq); + il_dump_lq_cmd(il, lq); BUG_ON(init && (cmd.flags & CMD_ASYNC)); - if (il_is_lq_table_valid(priv, ctx, lq)) - ret = il_send_cmd(priv, &cmd); + if (il_is_lq_table_valid(il, ctx, lq)) + ret = il_send_cmd(il, &cmd); else ret = -EINVAL; @@ -782,12 +782,12 @@ int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, return ret; if (init) { - IL_DEBUG_INFO(priv, "init LQ command complete," + IL_DEBUG_INFO(il, "init LQ command complete," " clearing sta addition status for sta %d\n", lq->sta_id); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } return ret; } @@ -797,20 +797,20 @@ int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - IL_DEBUG_INFO(priv, "received request to remove station %pM\n", + IL_DEBUG_INFO(il, "received request to remove station %pM\n", sta->addr); - mutex_lock(&priv->mutex); - IL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", + mutex_lock(&il->mutex); + IL_DEBUG_INFO(il, "proceeding to remove station %pM\n", sta->addr); - ret = il_remove_station(priv, sta_common->sta_id, sta->addr); + ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) - IL_ERR(priv, "Error removing station %pM\n", + IL_ERR(il, "Error removing station %pM\n", sta->addr); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } EXPORT_SYMBOL(il_mac_sta_remove); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index 555b060..77cdfd4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -43,56 +43,56 @@ #define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ -void il_restore_stations(struct il_priv *priv, +void il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx); -void il_clear_ucode_stations(struct il_priv *priv, +void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx); -void il_dealloc_bcast_stations(struct il_priv *priv); -int il_get_free_ucode_key_index(struct il_priv *priv); -int il_send_add_sta(struct il_priv *priv, +void il_dealloc_bcast_stations(struct il_priv *il); +int il_get_free_ucode_key_index(struct il_priv *il); +int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); -int il_add_station_common(struct il_priv *priv, +int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r); -int il_remove_station(struct il_priv *priv, +int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 *addr); int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -u8 il_prep_station(struct il_priv *priv, +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta); -int il_send_lq_cmd(struct il_priv *priv, +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq, u8 flags, bool init); /** * il_clear_driver_stations - clear knowledge of all stations from driver - * @priv: iwl priv struct + * @il: iwl il struct * * This is called during il_down() to make sure that in the case * we're coming there from a hardware restart mac80211 will be * able to reconfigure stations -- if we're getting there in the * normal down flow then the stations will already be cleared. */ -static inline void il_clear_driver_stations(struct il_priv *priv) +static inline void il_clear_driver_stations(struct il_priv *il) { unsigned long flags; struct il_rxon_context *ctx; - spin_lock_irqsave(&priv->sta_lock, flags); - memset(priv->stations, 0, sizeof(priv->stations)); - priv->num_stations = 0; + spin_lock_irqsave(&il->sta_lock, flags); + memset(il->stations, 0, sizeof(il->stations)); + il->num_stations = 0; - priv->ucode_key_table = 0; + il->ucode_key_table = 0; - for_each_context(priv, ctx) { + for_each_context(il, ctx) { /* * Remove all key information that is not stored as part * of station information since mac80211 may not have had @@ -104,7 +104,7 @@ static inline void il_clear_driver_stations(struct il_priv *priv) ctx->key_mapping_keys = 0; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } static inline int il_sta_id(struct ieee80211_sta *sta) @@ -117,7 +117,7 @@ static inline int il_sta_id(struct ieee80211_sta *sta) /** * il_sta_id_or_broadcast - return sta_id or broadcast sta - * @priv: iwl priv + * @il: iwl il * @context: the current context * @sta: mac80211 station * @@ -126,7 +126,7 @@ static inline int il_sta_id(struct ieee80211_sta *sta) * that case, we need to use the broadcast station, so this * inline wraps that pattern. */ -static inline int il_sta_id_or_broadcast(struct il_priv *priv, +static inline int il_sta_id_or_broadcast(struct il_priv *il, struct il_rxon_context *context, struct ieee80211_sta *sta) { diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 1c27c60..af6ac4f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -42,7 +42,7 @@ * il_txq_update_write_ptr - Send new write index to hardware */ void -il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) +il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) { u32 reg = 0; int txq_id = txq->q.id; @@ -51,22 +51,22 @@ il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) return; /* if we're trying to save power */ - if (test_bit(STATUS_POWER_PMI, &priv->status)) { + if (test_bit(STATUS_POWER_PMI, &il->status)) { /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ - reg = il_read32(priv, CSR_UCODE_DRV_GP1); + reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Tx queue %d requesting wakeup," " GP1 = 0x%x\n", txq_id, reg); - il_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); return; } - il_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* @@ -75,7 +75,7 @@ il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - il_write32(priv, HBUS_TARG_WRPTR, + il_write32(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } @@ -84,16 +84,16 @@ EXPORT_SYMBOL(il_txq_update_write_ptr); /** * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's */ -void il_tx_queue_unmap(struct il_priv *priv, int txq_id) +void il_tx_queue_unmap(struct il_priv *il, int txq_id) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; if (q->n_bd == 0) return; while (q->write_ptr != q->read_ptr) { - priv->cfg->ops->lib->txq_free_tfd(priv, txq); + il->cfg->ops->lib->txq_free_tfd(il, txq); q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } @@ -107,13 +107,13 @@ EXPORT_SYMBOL(il_tx_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_tx_queue_free(struct il_priv *priv, int txq_id) +void il_tx_queue_free(struct il_priv *il, int txq_id) { - struct il_tx_queue *txq = &priv->txq[txq_id]; - struct device *dev = &priv->pci_dev->dev; + struct il_tx_queue *txq = &il->txq[txq_id]; + struct device *dev = &il->pci_dev->dev; int i; - il_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(il, txq_id); /* De-alloc array of command/tx buffers */ for (i = 0; i < TFD_TX_CMD_SLOTS; i++) @@ -121,7 +121,7 @@ void il_tx_queue_free(struct il_priv *priv, int txq_id) /* De-alloc circular buffer of TFDs */ if (txq->q.n_bd) - dma_free_coherent(dev, priv->hw_params.tfd_size * + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, txq->tfds, txq->q.dma_addr); /* De-alloc array of per-TFD driver data */ @@ -142,9 +142,9 @@ EXPORT_SYMBOL(il_tx_queue_free); /** * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue */ -void il_cmd_queue_unmap(struct il_priv *priv) +void il_cmd_queue_unmap(struct il_priv *il) { - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; int i; @@ -155,7 +155,7 @@ void il_cmd_queue_unmap(struct il_priv *priv) i = il_get_cmd_index(q, q->read_ptr, 0); if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(priv->pci_dev, + pci_unmap_single(il->pci_dev, dma_unmap_addr(&txq->meta[i], mapping), dma_unmap_len(&txq->meta[i], len), PCI_DMA_BIDIRECTIONAL); @@ -167,7 +167,7 @@ void il_cmd_queue_unmap(struct il_priv *priv) i = q->n_window; if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(priv->pci_dev, + pci_unmap_single(il->pci_dev, dma_unmap_addr(&txq->meta[i], mapping), dma_unmap_len(&txq->meta[i], len), PCI_DMA_BIDIRECTIONAL); @@ -184,13 +184,13 @@ EXPORT_SYMBOL(il_cmd_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_cmd_queue_free(struct il_priv *priv) +void il_cmd_queue_free(struct il_priv *il) { - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; - struct device *dev = &priv->pci_dev->dev; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct device *dev = &il->pci_dev->dev; int i; - il_cmd_queue_unmap(priv); + il_cmd_queue_unmap(il); /* De-alloc array of command/tx buffers */ for (i = 0; i <= TFD_CMD_SLOTS; i++) @@ -198,7 +198,7 @@ void il_cmd_queue_free(struct il_priv *priv) /* De-alloc circular buffer of TFDs */ if (txq->q.n_bd) - dma_free_coherent(dev, priv->hw_params.tfd_size * txq->q.n_bd, + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, txq->tfds, txq->q.dma_addr); /* deallocate arrays */ @@ -256,7 +256,7 @@ EXPORT_SYMBOL(il_queue_space); /** * il_queue_init - Initialize queue's high/low-water and read/write indexes */ -static int il_queue_init(struct il_priv *priv, struct il_queue *q, +static int il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, u32 id) { q->n_bd = count; @@ -287,19 +287,19 @@ static int il_queue_init(struct il_priv *priv, struct il_queue *q, /** * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue */ -static int il_tx_queue_alloc(struct il_priv *priv, +static int il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id) { - struct device *dev = &priv->pci_dev->dev; - size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; + struct device *dev = &il->pci_dev->dev; + size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; - /* Driver private data, only for Tx (not command) queues, + /* Driver ilate data, only for Tx (not command) queues, * not shared with device. */ - if (id != priv->cmd_queue) { + if (id != il->cmd_queue) { txq->txb = kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, GFP_KERNEL); if (!txq->txb) { - IL_ERR(priv, "kmalloc for auxiliary BD " + IL_ERR(il, "kmalloc for auxiliary BD " "structures failed\n"); goto error; } @@ -312,7 +312,7 @@ static int il_tx_queue_alloc(struct il_priv *priv, txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { - IL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); + IL_ERR(il, "pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; } txq->q.id = id; @@ -329,7 +329,7 @@ static int il_tx_queue_alloc(struct il_priv *priv, /** * il_tx_queue_init - Allocate and initialize one tx/cmd queue */ -int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int i, len; @@ -344,7 +344,7 @@ int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, * For normal Tx queues (all other queues), no super-size command * space is needed. */ - if (txq_id == priv->cmd_queue) + if (txq_id == il->cmd_queue) actual_slots++; txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, @@ -367,7 +367,7 @@ int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, } /* Alloc driver data array and TFD circular buffer */ - ret = il_tx_queue_alloc(priv, txq, txq_id); + ret = il_tx_queue_alloc(il, txq, txq_id); if (ret) goto err; @@ -386,11 +386,11 @@ int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); /* Initialize queue's high/low-water marks, and head/tail indexes */ - il_queue_init(priv, &txq->q, + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ - priv->cfg->ops->lib->txq_init(priv, txq); + il->cfg->ops->lib->txq_init(il, txq); return 0; err: @@ -404,12 +404,12 @@ out_free_arrays: } EXPORT_SYMBOL(il_tx_queue_init); -void il_tx_queue_reset(struct il_priv *priv, struct il_tx_queue *txq, +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int actual_slots = slots_num; - if (txq_id == priv->cmd_queue) + if (txq_id == il->cmd_queue) actual_slots++; memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); @@ -417,11 +417,11 @@ void il_tx_queue_reset(struct il_priv *priv, struct il_tx_queue *txq, txq->need_update = 0; /* Initialize queue's high/low-water marks, and head/tail indexes */ - il_queue_init(priv, &txq->q, + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ - priv->cfg->ops->lib->txq_init(priv, txq); + il->cfg->ops->lib->txq_init(il, txq); } EXPORT_SYMBOL(il_tx_queue_reset); @@ -429,16 +429,16 @@ EXPORT_SYMBOL(il_tx_queue_reset); /** * il_enqueue_hcmd - enqueue a uCode command - * @priv: device private data point + * @il: device ilate data point * @cmd: a point to the ucode command structure * * The function returns < 0 values to indicate the operation is * failed. On success, it turns the index (> 0) of command in the * command queue. */ -int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) { - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; struct il_device_cmd *out_cmd; struct il_cmd_meta *out_meta; @@ -448,7 +448,7 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) u32 idx; u16 fix_size; - cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); + cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); /* If any of the command structures end up being larger than @@ -460,19 +460,19 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) !(cmd->flags & CMD_SIZE_HUGE)); BUG_ON(fix_size > IL_MAX_CMD_SIZE); - if (il_is_rfkill(priv) || il_is_ctkill(priv)) { - IL_WARN(priv, "Not sending command - %s KILL\n", - il_is_rfkill(priv) ? "RF" : "CT"); + if (il_is_rfkill(il) || il_is_ctkill(il)) { + IL_WARN(il, "Not sending command - %s KILL\n", + il_is_rfkill(il) ? "RF" : "CT"); return -EIO; } - spin_lock_irqsave(&priv->hcmd_lock, flags); + spin_lock_irqsave(&il->hcmd_lock, flags); if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); - IL_ERR(priv, "Restarting adapter due to command queue full\n"); - queue_work(priv->workqueue, &priv->restart); + IL_ERR(il, "Restarting adapter due to command queue full\n"); + queue_work(il->workqueue, &il->restart); return -ENOSPC; } @@ -481,7 +481,7 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) out_meta = &txq->meta[idx]; if (WARN_ON(out_meta->flags & CMD_MAPPED)) { - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); return -ENOSPC; } @@ -499,7 +499,7 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) * information */ out_cmd->hdr.flags = 0; - out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(priv->cmd_queue) | + out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | INDEX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; @@ -511,43 +511,43 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(priv, + IL_DEBUG_HC_DUMP(il, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, priv->cmd_queue); + q->write_ptr, idx, il->cmd_queue); break; default: - IL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, " + IL_DEBUG_HC(il, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, priv->cmd_queue); + q->write_ptr, idx, il->cmd_queue); } #endif txq->need_update = 1; - if (priv->cfg->ops->lib->txq_update_byte_cnt_tbl) + if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) /* Set up entry in queue's byte count circular buffer */ - priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, 0); + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); - phys_addr = pci_map_single(priv->pci_dev, &out_cmd->hdr, + phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, phys_addr); dma_unmap_len_set(out_meta, len, fix_size); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1, U32_PAD(cmd->len)); /* Increment and update queue's write index */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(priv, txq); + il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); return idx; } @@ -558,15 +558,15 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, +static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int idx, int cmd_idx) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; int nfreed = 0; if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; @@ -576,9 +576,9 @@ static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IL_ERR(priv, "HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR(il, "HCMD skipped: index (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } } @@ -593,7 +593,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, * if the callback returns 1 */ void -il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) +il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -603,18 +603,18 @@ il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); struct il_device_cmd *cmd; struct il_cmd_meta *meta; - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; unsigned long flags; /* If a Tx command is being handled and it isn't in the actual * command queue then there a command routing bug has been introduced * in the queue management code. */ - if (WARN(txq_id != priv->cmd_queue, + if (WARN(txq_id != il->cmd_queue, "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", - txq_id, priv->cmd_queue, sequence, - priv->txq[priv->cmd_queue].q.read_ptr, - priv->txq[priv->cmd_queue].q.write_ptr)) { - il_print_hex_error(priv, pkt, 32); + txq_id, il->cmd_queue, sequence, + il->txq[il->cmd_queue].q.read_ptr, + il->txq[il->cmd_queue].q.write_ptr)) { + il_print_hex_error(il, pkt, 32); return; } @@ -624,7 +624,7 @@ il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) txq->time_stamp = jiffies; - pci_unmap_single(priv->pci_dev, + pci_unmap_single(il->pci_dev, dma_unmap_addr(meta, mapping), dma_unmap_len(meta, len), PCI_DMA_BIDIRECTIONAL); @@ -634,22 +634,22 @@ il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) meta->source->reply_page = (unsigned long)rxb_addr(rxb); rxb->page = NULL; } else if (meta->callback) - meta->callback(priv, cmd, pkt); + meta->callback(il, cmd, pkt); - spin_lock_irqsave(&priv->hcmd_lock, flags); + spin_lock_irqsave(&il->hcmd_lock, flags); - il_hcmd_queue_reclaim(priv, txq_id, index, cmd_index); + il_hcmd_queue_reclaim(il, txq_id, index, cmd_index); if (!(meta->flags & CMD_ASYNC)) { - clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", + clear_bit(STATUS_HCMD_ACTIVE, &il->status); + IL_DEBUG_INFO(il, "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->hdr.cmd)); - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); } /* Mark as unmapped */ meta->flags = 0; - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); } EXPORT_SYMBOL(il_tx_cmd_complete); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index d24937a..2c336a7 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -98,18 +98,18 @@ struct il_mod_params il3945_mod_params = { /** * il3945_get_antenna_flags - Get antenna flags for RXON command - * @priv: eeprom and antenna fields are used to determine antenna flags + * @il: eeprom and antenna fields are used to determine antenna flags * - * priv->eeprom39 is used to determine if antenna AUX/MAIN are reversed + * il->eeprom39 is used to determine if antenna AUX/MAIN are reversed * il3945_mod_params.antenna specifies the antenna diversity mode: * * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself * IL_ANTENNA_MAIN - Force MAIN antenna * IL_ANTENNA_AUX - Force AUX antenna */ -__le32 il3945_get_antenna_flags(const struct il_priv *priv) +__le32 il3945_get_antenna_flags(const struct il_priv *il) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; switch (il3945_mod_params.antenna) { case IL_ANTENNA_DIVERSITY: @@ -127,13 +127,13 @@ __le32 il3945_get_antenna_flags(const struct il_priv *priv) } /* bad antenna selector value */ - IL_ERR(priv, "Bad antenna selector value (0x%x)\n", + IL_ERR(il, "Bad antenna selector value (0x%x)\n", il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ } -static int il3945_set_ccmp_dynamic_key_info(struct il_priv *priv, +static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { @@ -144,80 +144,80 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *priv, key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; keyconf->hw_key_idx = keyconf->keyidx; key_flags &= ~STA_KEY_FLG_INVALID; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - IL_DEBUG_INFO(priv, "hwcrypto: modify ucode station key info\n"); + IL_DEBUG_INFO(il, "hwcrypto: modify ucode station key info\n"); - ret = il_send_add_sta(priv, - &priv->stations[sta_id].sta, CMD_ASYNC); + ret = il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il3945_set_tkip_dynamic_key_info(struct il_priv *priv, +static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_set_wep_dynamic_key_info(struct il_priv *priv, +static int il3945_set_wep_dynamic_key_info(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_clear_sta_key_info(struct il_priv *priv, u8 sta_id) +static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) { unsigned long flags; struct il_addsta_cmd sta_cmd; - spin_lock_irqsave(&priv->sta_lock, flags); - memset(&priv->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&priv->stations[sta_id].sta.key, 0, + spin_lock_irqsave(&il->sta_lock, flags); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); - priv->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); - IL_DEBUG_INFO(priv, "hwcrypto: clear ucode station key info\n"); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + IL_DEBUG_INFO(il, "hwcrypto: clear ucode station key info\n"); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il3945_set_dynamic_key(struct il_priv *priv, +static int il3945_set_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret = 0; @@ -226,154 +226,154 @@ static int il3945_set_dynamic_key(struct il_priv *priv, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = il3945_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_ccmp_dynamic_key_info(il, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = il3945_set_tkip_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_tkip_dynamic_key_info(il, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = il3945_set_wep_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); break; default: - IL_ERR(priv, "Unknown alg: %s alg=%x\n", __func__, + IL_ERR(il, "Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IL_DEBUG_WEP(priv, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + IL_DEBUG_WEP(il, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } -static int il3945_remove_static_key(struct il_priv *priv) +static int il3945_remove_static_key(struct il_priv *il) { int ret = -EOPNOTSUPP; return ret; } -static int il3945_set_static_key(struct il_priv *priv, +static int il3945_set_static_key(struct il_priv *il, struct ieee80211_key_conf *key) { if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) return -EOPNOTSUPP; - IL_ERR(priv, "Static key invalid: cipher %x\n", key->cipher); + IL_ERR(il, "Static key invalid: cipher %x\n", key->cipher); return -EINVAL; } -static void il3945_clear_free_frames(struct il_priv *priv) +static void il3945_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", - priv->frames_count); + IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + il->frames_count); - while (!list_empty(&priv->free_frames)) { - element = priv->free_frames.next; + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; list_del(element); kfree(list_entry(element, struct il3945_frame, list)); - priv->frames_count--; + il->frames_count--; } - if (priv->frames_count) { - IL_WARN(priv, "%d frames still in use. Did we lose one?\n", - priv->frames_count); - priv->frames_count = 0; + if (il->frames_count) { + IL_WARN(il, "%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; } } -static struct il3945_frame *il3945_get_free_frame(struct il_priv *priv) +static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) { struct il3945_frame *frame; struct list_head *element; - if (list_empty(&priv->free_frames)) { + if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(il, "Could not allocate frame!\n"); return NULL; } - priv->frames_count++; + il->frames_count++; return frame; } - element = priv->free_frames.next; + element = il->free_frames.next; list_del(element); return list_entry(element, struct il3945_frame, list); } -static void il3945_free_frame(struct il_priv *priv, struct il3945_frame *frame) +static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) { memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &priv->free_frames); + list_add(&frame->list, &il->free_frames); } -unsigned int il3945_fill_beacon_frame(struct il_priv *priv, +unsigned int il3945_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, int left) { - if (!il_is_associated(priv, IL_RXON_CTX_BSS) || !priv->beacon_skb) + if (!il_is_associated(il, IL_RXON_CTX_BSS) || !il->beacon_skb) return 0; - if (priv->beacon_skb->len > left) + if (il->beacon_skb->len > left) return 0; - memcpy(hdr, priv->beacon_skb->data, priv->beacon_skb->len); + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - return priv->beacon_skb->len; + return il->beacon_skb->len; } -static int il3945_send_beacon_cmd(struct il_priv *priv) +static int il3945_send_beacon_cmd(struct il_priv *il) { struct il3945_frame *frame; unsigned int frame_size; int rc; u8 rate; - frame = il3945_get_free_frame(priv); + frame = il3945_get_free_frame(il); if (!frame) { - IL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(il, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - rate = il_get_lowest_plcp(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + rate = il_get_lowest_plcp(il, + &il->contexts[IL_RXON_CTX_BSS]); - frame_size = il3945_hw_get_beacon_cmd(priv, frame, rate); + frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - il3945_free_frame(priv, frame); + il3945_free_frame(il, frame); return rc; } -static void il3945_unset_hw_params(struct il_priv *priv) +static void il3945_unset_hw_params(struct il_priv *il) { - if (priv->_3945.shared_virt) - dma_free_coherent(&priv->pci_dev->dev, + if (il->_3945.shared_virt) + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), - priv->_3945.shared_virt, - priv->_3945.shared_phys); + il->_3945.shared_virt, + il->_3945.shared_phys); } -static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, +static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, struct il_device_cmd *cmd, struct sk_buff *skb_frag, int sta_id) { struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - struct il_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; + struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; tx_cmd->sec_ctl = 0; @@ -381,7 +381,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, case WLAN_CIPHER_SUITE_CCMP: tx_cmd->sec_ctl = TX_CMD_SEC_CCM; memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: @@ -396,12 +396,12 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(il, "Configuring packet for WEP encryption " "with key %d\n", info->control.hw_key->hw_key_idx); break; default: - IL_ERR(priv, "Unknown encode cipher %x\n", keyinfo->cipher); + IL_ERR(il, "Unknown encode cipher %x\n", keyinfo->cipher); break; } } @@ -409,7 +409,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, /* * handle build REPLY_TX command notification. */ -static void il3945_build_tx_cmd_basic(struct il_priv *priv, +static void il3945_build_tx_cmd_basic(struct il_priv *il, struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, u8 std_id) @@ -443,7 +443,7 @@ static void il3945_build_tx_cmd_basic(struct il_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - il_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(il, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -463,7 +463,7 @@ static void il3945_build_tx_cmd_basic(struct il_priv *priv, /* * start REPLY_TX command process */ -static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) +static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -484,14 +484,14 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) u8 wait_write_ptr = 0; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); - if (il_is_rfkill(priv)) { - IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); goto drop_unlock; } - if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { - IL_ERR(priv, "ERROR: No TX rate available.\n"); + if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + IL_ERR(il, "ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -502,28 +502,28 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(il, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(il, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(il, "Sending REASSOC frame\n"); #endif - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); hdr_len = ieee80211_hdrlen(fc); /* Find index into station table for destination station */ sta_id = il_sta_id_or_broadcast( - priv, &priv->contexts[IL_RXON_CTX_BSS], + il, &il->contexts[IL_RXON_CTX_BSS], info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } - IL_DEBUG_RATE(priv, "station Id %d\n", sta_id); + IL_DEBUG_RATE(il, "station Id %d\n", sta_id); if (ieee80211_is_data_qos(fc)) { u8 *qc = ieee80211_get_qos_ctl(hdr); @@ -533,20 +533,20 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) } /* Descriptor for chosen Tx queue */ - txq = &priv->txq[txq_id]; + txq = &il->txq[txq_id]; q = &txq->q; if ((il_queue_space(q) < q->high_mark)) goto drop; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); idx = il_get_cmd_index(q, q->write_ptr, 0); /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &priv->contexts[IL_RXON_CTX_BSS]; + txq->txb[q->write_ptr].ctx = &il->contexts[IL_RXON_CTX_BSS]; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; @@ -570,20 +570,20 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) if (info->control.hw_key) - il3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, sta_id); + il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - il3945_build_tx_cmd_basic(priv, out_cmd, info, hdr, sta_id); + il3945_build_tx_cmd_basic(il, out_cmd, info, hdr, sta_id); /* set is_hcca to 0; it probably will never be implemented */ - il3945_hw_build_tx_cmd_rate(priv, out_cmd, info, hdr, sta_id, 0); + il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); /* Total # bytes to be transmitted */ len = (u16)skb->len; tx_cmd->len = cpu_to_le16(len); - il_dbg_log_tx_data_frame(priv, len, hdr); - il_update_stats(priv, true, fc, len); + il_dbg_log_tx_data_frame(il, len, hdr); + il_update_stats(il, true, fc, len); tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; @@ -594,11 +594,11 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) txq->need_update = 0; } - IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(il, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(priv, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, + IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, ieee80211_hdrlen(fc)); /* @@ -616,7 +616,7 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(priv->pci_dev, &out_cmd->hdr, + txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, len, PCI_DMA_TODEVICE); /* we do not map meta data ... so we can safely access address to * provide to unmap command*/ @@ -625,7 +625,7 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, 0); @@ -633,9 +633,9 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) * if any (802.11 null frames have no payload). */ len = skb->len - hdr_len; if (len) { - phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, len, PCI_DMA_TODEVICE); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, len, 0, U32_PAD(len)); } @@ -643,30 +643,30 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Tell device the write index *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); if ((il_queue_space(q) < q->high_mark) - && priv->mac80211_registered) { + && il->mac80211_registered) { if (wait_write_ptr) { - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); } - il_stop_queue(priv, txq); + il_stop_queue(il, txq); } return 0; drop_unlock: - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); drop: return -1; } -static int il3945_get_measurement(struct il_priv *priv, +static int il3945_get_measurement(struct il_priv *il, struct ieee80211_measurement_params *params, u8 type) { @@ -681,11 +681,11 @@ static int il3945_get_measurement(struct il_priv *priv, int rc; int spectrum_resp_status; int duration = le16_to_cpu(params->duration); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (il_is_associated(priv, IL_RXON_CTX_BSS)) - add_time = il_usecs_to_beacons(priv, - le64_to_cpu(params->start_time) - priv->_3945.last_tsf, + if (il_is_associated(il, IL_RXON_CTX_BSS)) + add_time = il_usecs_to_beacons(il, + le64_to_cpu(params->start_time) - il->_3945.last_tsf, le16_to_cpu(ctx->timing.beacon_interval)); memset(&spectrum, 0, sizeof(spectrum)); @@ -697,10 +697,10 @@ static int il3945_get_measurement(struct il_priv *priv, cmd.len = sizeof(spectrum); spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - if (il_is_associated(priv, IL_RXON_CTX_BSS)) + if (il_is_associated(il, IL_RXON_CTX_BSS)) spectrum.start_time = - il_add_beacon_time(priv, - priv->_3945.last_beacon_time, add_time, + il_add_beacon_time(il, + il->_3945.last_beacon_time, add_time, le16_to_cpu(ctx->timing.beacon_interval)); else spectrum.start_time = 0; @@ -712,13 +712,13 @@ static int il3945_get_measurement(struct il_priv *priv, spectrum.flags |= RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; - rc = il_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(il, &cmd); if (rc) return rc; pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_RX_ON_ASSOC command\n"); + IL_ERR(il, "Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -726,11 +726,11 @@ static int il3945_get_measurement(struct il_priv *priv, switch (spectrum_resp_status) { case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { - IL_DEBUG_INFO(priv, "Replaced existing measurement: %d\n", + IL_DEBUG_INFO(il, "Replaced existing measurement: %d\n", pkt->u.spectrum.id); - priv->measurement_status &= ~MEASUREMENT_READY; + il->measurement_status &= ~MEASUREMENT_READY; } - priv->measurement_status |= MEASUREMENT_ACTIVE; + il->measurement_status |= MEASUREMENT_ACTIVE; rc = 0; break; @@ -739,12 +739,12 @@ static int il3945_get_measurement(struct il_priv *priv, break; } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return rc; } -static void il3945_rx_reply_alive(struct il_priv *priv, +static void il3945_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -753,44 +753,44 @@ static void il3945_rx_reply_alive(struct il_priv *priv, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - memcpy(&priv->card_alive_init, &pkt->u.alive_frame, + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); - pwork = &priv->init_alive_start; + pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); - memcpy(&priv->card_alive, &pkt->u.alive_frame, + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); - pwork = &priv->alive_start; - il3945_disable_events(priv); + pwork = &il->alive_start; + il3945_disable_events(il); } /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(priv->workqueue, pwork, + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(il, "uCode did not respond OK.\n"); } -static void il3945_rx_reply_add_sta(struct il_priv *priv, +static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); #endif - IL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + IL_DEBUG_RX(il, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); } -static void il3945_rx_beacon_notif(struct il_priv *priv, +static void il3945_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -798,7 +798,7 @@ static void il3945_rx_beacon_notif(struct il_priv *priv, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -807,40 +807,40 @@ static void il3945_rx_beacon_notif(struct il_priv *priv, le32_to_cpu(beacon->low_tsf), rate); #endif - priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il3945_rx_card_state_notif(struct il_priv *priv, +static void il3945_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = priv->status; + unsigned long status = il->status; - IL_WARN(priv, "Card state received: HW:%s SW:%s\n", + IL_WARN(il, "Card state received: HW:%s SW:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - il_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); - il_scan_cancel(priv); + il_scan_cancel(il); if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &priv->status))) - wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->status)); + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); else - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); } /** @@ -852,32 +852,32 @@ static void il3945_rx_card_state_notif(struct il_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il3945_setup_rx_handlers(struct il_priv *priv) +static void il3945_setup_rx_handlers(struct il_priv *il) { - priv->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; - priv->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; - priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; + il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = il_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = il_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; + il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; - il_setup_rx_scan_handlers(priv); - priv->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; + il_setup_rx_scan_handlers(il); + il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ - il3945_hw_rx_handler_setup(priv); + il3945_hw_rx_handler_setup(il); } /************************** RX-FUNCTIONS ****************************/ @@ -947,7 +947,7 @@ static void il3945_setup_rx_handlers(struct il_priv *priv) /** * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *priv, +static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { return cpu_to_le32((u32)dma_addr); @@ -964,9 +964,9 @@ static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -static void il3945_rx_queue_restock(struct il_priv *priv) +static void il3945_rx_queue_restock(struct il_priv *il) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; unsigned long flags; @@ -981,7 +981,7 @@ static void il3945_rx_queue_restock(struct il_priv *priv) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(priv, rxb->page_dma); + rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -990,7 +990,7 @@ static void il3945_rx_queue_restock(struct il_priv *priv) /* If the pre-allocated buffer pool is dropping low, schedule to * refill it */ if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(priv->workqueue, &priv->rx_replenish); + queue_work(il->workqueue, &il->rx_replenish); /* If we've added more space for the firmware to place data, tell it. @@ -1000,7 +1000,7 @@ static void il3945_rx_queue_restock(struct il_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); } } @@ -1012,9 +1012,9 @@ static void il3945_rx_queue_restock(struct il_priv *priv) * Also restock the Rx queue via il3945_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) +static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; struct page *page; @@ -1033,17 +1033,17 @@ static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) if (rxq->free_count > RX_LOW_WATERMARK) gfp_mask |= __GFP_NOWARN; - if (priv->hw_params.rx_page_order > 0) + if (il->hw_params.rx_page_order > 0) gfp_mask |= __GFP_COMP; /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n"); + IL_DEBUG_INFO(il, "Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_CRIT(il, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will @@ -1055,7 +1055,7 @@ static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) spin_lock_irqsave(&rxq->lock, flags); if (list_empty(&rxq->rx_used)) { spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, priv->hw_params.rx_page_order); + __free_pages(page, il->hw_params.rx_page_order); return; } element = rxq->rx_used.next; @@ -1065,21 +1065,21 @@ static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) rxb->page = page; /* Get physical address of RB/SKB */ - rxb->page_dma = pci_map_page(priv->pci_dev, page, 0, - PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); spin_lock_irqsave(&rxq->lock, flags); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; - priv->alloc_rxb_page++; + il->alloc_rxb_page++; spin_unlock_irqrestore(&rxq->lock, flags); } } -void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) +void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -1091,10 +1091,10 @@ void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) /* In the reset function, these buffers may have been allocated * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -1110,21 +1110,21 @@ void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) void il3945_rx_replenish(void *data) { - struct il_priv *priv = data; + struct il_priv *il = data; unsigned long flags; - il3945_rx_allocate(priv, GFP_KERNEL); + il3945_rx_allocate(il, GFP_KERNEL); - spin_lock_irqsave(&priv->lock, flags); - il3945_rx_queue_restock(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il3945_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); } -static void il3945_rx_replenish_now(struct il_priv *priv) +static void il3945_rx_replenish_now(struct il_priv *il) { - il3945_rx_allocate(priv, GFP_ATOMIC); + il3945_rx_allocate(il, GFP_ATOMIC); - il3945_rx_queue_restock(priv); + il3945_rx_queue_restock(il); } @@ -1133,22 +1133,22 @@ static void il3945_rx_replenish_now(struct il_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void il3945_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) +static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } } - dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; @@ -1195,15 +1195,15 @@ int il3945_calc_db_from_ratio(int sig_ratio) /** * il3945_rx_handle - Main entry function for receiving responses from uCode * - * Uses the priv->rx_handlers callback function array to invoke + * Uses the il->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -static void il3945_rx_handle(struct il_priv *priv) +static void il3945_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; struct il_rx_packet *pkt; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -1225,7 +1225,7 @@ static void il3945_rx_handle(struct il_priv *priv) fill_rx = 1; /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); while (i != r) { int len; @@ -1239,8 +1239,8 @@ static void il3945_rx_handle(struct il_priv *priv) rxq->queue[i] = NULL; - pci_unmap_page(priv->pci_dev, rxb->page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); @@ -1260,14 +1260,14 @@ static void il3945_rx_handle(struct il_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in * rx_handlers table. See il3945_setup_rx_handlers() */ - if (priv->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, i, + if (il->rx_handlers[pkt->hdr.cmd]) { + IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; - priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(priv, + IL_DEBUG_RX(il, "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -1285,9 +1285,9 @@ static void il3945_rx_handle(struct il_priv *priv) * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - il_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(il, rxb); else - IL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(il, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -1295,8 +1295,8 @@ static void il3945_rx_handle(struct il_priv *priv) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(priv->pci_dev, rxb->page, - 0, PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; @@ -1312,7 +1312,7 @@ static void il3945_rx_handle(struct il_priv *priv) count++; if (count >= 8) { rxq->read = i; - il3945_rx_replenish_now(priv); + il3945_rx_replenish_now(il); count = 0; } } @@ -1321,17 +1321,17 @@ static void il3945_rx_handle(struct il_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - il3945_rx_replenish_now(priv); + il3945_rx_replenish_now(il); else - il3945_rx_queue_restock(priv); + il3945_rx_queue_restock(il); } /* call this function to flush any scheduled tasklet */ -static inline void il3945_synchronize_irq(struct il_priv *priv) +static inline void il3945_synchronize_irq(struct il_priv *il) { /* wait to make sure we flush pending tasklet*/ - synchronize_irq(priv->pci_dev->irq); - tasklet_kill(&priv->irq_tasklet); + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); } static const char *il3945_desc_lookup(int i) @@ -1357,55 +1357,55 @@ static const char *il3945_desc_lookup(int i) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il3945_dump_nic_error_log(struct il_priv *priv) +void il3945_dump_nic_error_log(struct il_priv *il) { u32 i; u32 desc, time, count, base, data1; u32 blink1, blink2, ilink1, ilink2; - base = le32_to_cpu(priv->card_alive.error_event_table_ptr); + base = le32_to_cpu(il->card_alive.error_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(priv, "Not valid error log pointer 0x%08X\n", base); + IL_ERR(il, "Not valid error log pointer 0x%08X\n", base); return; } - count = il_read_targ_mem(priv, base); + count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(priv, "Start IWL Error Log Dump:\n"); - IL_ERR(priv, "Status: 0x%08lX, count: %d\n", - priv->status, count); + IL_ERR(il, "Start IWL Error Log Dump:\n"); + IL_ERR(il, "Status: 0x%08lX, count: %d\n", + il->status, count); } - IL_ERR(priv, "Desc Time asrtPC blink2 " + IL_ERR(il, "Desc Time asrtPC blink2 " "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; i += ERROR_ELEM_SIZE) { - desc = il_read_targ_mem(priv, base + i); + desc = il_read_targ_mem(il, base + i); time = - il_read_targ_mem(priv, base + i + 1 * sizeof(u32)); + il_read_targ_mem(il, base + i + 1 * sizeof(u32)); blink1 = - il_read_targ_mem(priv, base + i + 2 * sizeof(u32)); + il_read_targ_mem(il, base + i + 2 * sizeof(u32)); blink2 = - il_read_targ_mem(priv, base + i + 3 * sizeof(u32)); + il_read_targ_mem(il, base + i + 3 * sizeof(u32)); ilink1 = - il_read_targ_mem(priv, base + i + 4 * sizeof(u32)); + il_read_targ_mem(il, base + i + 4 * sizeof(u32)); ilink2 = - il_read_targ_mem(priv, base + i + 5 * sizeof(u32)); + il_read_targ_mem(il, base + i + 5 * sizeof(u32)); data1 = - il_read_targ_mem(priv, base + i + 6 * sizeof(u32)); + il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - IL_ERR(priv, + IL_ERR(il, "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", il3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); } } -static void il3945_irq_tasklet(struct il_priv *priv) +static void il3945_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -1414,30 +1414,30 @@ static void il3945_irq_tasklet(struct il_priv *priv) u32 inta_mask; #endif - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(priv, CSR_INT); - il_write32(priv, CSR_INT, inta); + inta = il_read32(il, CSR_INT); + il_write32(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - il_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + il_write32(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & IL_DL_ISR) { + if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(priv, CSR_INT_MASK); - IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(il, CSR_INT_MASK); + IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not * atomic, make sure that inta covers all the interrupts that @@ -1450,13 +1450,13 @@ static void il3945_irq_tasklet(struct il_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(il, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - il_disable_interrupts(priv); + il_disable_interrupts(il); - priv->isr_stats.hw++; - il_irq_handle_error(priv); + il->isr_stats.hw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_HW_ERR; @@ -1464,18 +1464,18 @@ static void il3945_irq_tasklet(struct il_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { + if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(il, "Scheduler finished to transmit " "the frame/frames.\n"); - priv->isr_stats.sch++; + il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(priv, "Alive interrupt\n"); - priv->isr_stats.alive++; + IL_DEBUG_ISR(il, "Alive interrupt\n"); + il->isr_stats.alive++; } } #endif @@ -1484,25 +1484,25 @@ static void il3945_irq_tasklet(struct il_priv *priv) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(priv, "Microcode SW error detected. " + IL_ERR(il, "Microcode SW error detected. " "Restarting 0x%X.\n", inta); - priv->isr_stats.sw++; - il_irq_handle_error(priv); + il->isr_stats.sw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; } /* uCode wakes up after power-down sleep */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(priv, &priv->rxq); - il_txq_update_write_ptr(priv, &priv->txq[0]); - il_txq_update_write_ptr(priv, &priv->txq[1]); - il_txq_update_write_ptr(priv, &priv->txq[2]); - il_txq_update_write_ptr(priv, &priv->txq[3]); - il_txq_update_write_ptr(priv, &priv->txq[4]); - il_txq_update_write_ptr(priv, &priv->txq[5]); - - priv->isr_stats.wakeup++; + IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + il_txq_update_write_ptr(il, &il->txq[0]); + il_txq_update_write_ptr(il, &il->txq[1]); + il_txq_update_write_ptr(il, &il->txq[2]); + il_txq_update_write_ptr(il, &il->txq[3]); + il_txq_update_write_ptr(il, &il->txq[4]); + il_txq_update_write_ptr(il, &il->txq[5]); + + il->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; } @@ -1510,49 +1510,49 @@ static void il3945_irq_tasklet(struct il_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il3945_rx_handle(priv); - priv->isr_stats.rx++; + il3945_rx_handle(il); + il->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(priv, "Tx interrupt\n"); - priv->isr_stats.tx++; + IL_DEBUG_ISR(il, "Tx interrupt\n"); + il->isr_stats.tx++; - il_write32(priv, CSR_FH_INT_STATUS, (1 << 6)); - il_write_direct32(priv, FH39_TCSR_CREDIT + il_write32(il, CSR_FH_INT_STATUS, (1 << 6)); + il_write_direct32(il, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } if (inta & ~handled) { - IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); - priv->isr_stats.unhandled++; + IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; } - if (inta & ~priv->inta_mask) { - IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", - inta & ~priv->inta_mask); - IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + if (inta & ~il->inta_mask) { + IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &priv->status)) - il_enable_interrupts(priv); + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { - inta = il_read32(priv, CSR_INT); - inta_mask = il_read32(priv, CSR_INT_MASK); - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = il_read32(il, CSR_INT); + inta_mask = il_read32(il, CSR_INT_MASK); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(il, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } -static int il3945_get_channels_for_scan(struct il_priv *priv, +static int il3945_get_channels_for_scan(struct il_priv *il, enum ieee80211_band band, u8 is_active, u8 n_probes, struct il3945_scan_channel *scan_ch, @@ -1565,28 +1565,28 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, u16 active_dwell = 0; int added, i; - sband = il_get_hw_mode(priv, band); + sband = il_get_hw_mode(il, band); if (!sband) return 0; - active_dwell = il_get_active_dwell_time(priv, band, n_probes); - passive_dwell = il_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; - for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) { - chan = priv->scan_request->channels[i]; + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; if (chan->band != band) continue; scan_ch->channel = chan->hw_value; - ch_info = il_get_channel_info(priv, band, + ch_info = il_get_channel_info(il, band, scan_ch->channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(il, "Channel %d is INVALID for this band.\n", scan_ch->channel); continue; @@ -1600,7 +1600,7 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, if (!is_active || il_is_channel_passive(ch_info) || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { scan_ch->type = 0; /* passive */ - if (IL_UCODE_API(priv->ucode_ver) == 1) + if (IL_UCODE_API(il->ucode_ver) == 1) scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); } else { scan_ch->type = 1; /* active */ @@ -1610,7 +1610,7 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, * scan channels (probes gets sent right away), * or for passive channels (probes get se sent only after * hearing clear Rx packet).*/ - if (IL_UCODE_API(priv->ucode_ver) >= 2) { + if (IL_UCODE_API(il->ucode_ver) >= 2) { if (n_probes) scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); } else { @@ -1635,7 +1635,7 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, */ } - IL_DEBUG_SCAN(priv, "Scanning %d [%s %d]\n", + IL_DEBUG_SCAN(il, "Scanning %d [%s %d]\n", scan_ch->channel, (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", (scan_ch->type & 1) ? @@ -1645,11 +1645,11 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, added++; } - IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); return added; } -static void il3945_init_hw_rates(struct il_priv *priv, +static void il3945_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; @@ -1675,30 +1675,30 @@ static void il3945_init_hw_rates(struct il_priv *priv, * ******************************************************************************/ -static void il3945_dealloc_ucode_pci(struct il_priv *priv) +static void il3945_dealloc_ucode_pci(struct il_priv *il) { - il_free_fw_desc(priv->pci_dev, &priv->ucode_code); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); } /** * il3945_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) { u32 val; u32 save_len = len; int rc = 0; u32 errcnt; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); errcnt = 0; @@ -1706,9 +1706,9 @@ static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(il, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); rc = -EIO; @@ -1720,7 +1720,7 @@ static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) if (!errcnt) - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "ucode image in INSTRUCTION memory is good\n"); return rc; @@ -1732,25 +1732,25 @@ static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ -static int il3945_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) { u32 val; int rc = 0; u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ - IL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(il, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, *image); #endif @@ -1769,55 +1769,55 @@ static int il3945_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 le * il3945_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int il3945_verify_ucode(struct il_priv *priv) +static int il3945_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int rc = 0; /* Try bootstrap */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - rc = il3945_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ - image = (__le32 *)priv->ucode_init.v_addr; - len = priv->ucode_init.len; - rc = il3945_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ - image = (__le32 *)priv->ucode_code.v_addr; - len = priv->ucode_code.len; - rc = il3945_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); return 0; } - IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - rc = il3945_verify_inst_full(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_full(il, image, len); return rc; } -static void il3945_nic_start(struct il_priv *priv) +static void il3945_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(priv, CSR_RESET, 0); + il_write32(il, CSR_RESET, 0); } #define IWL3945_UCODE_GET(item) \ @@ -1847,15 +1847,15 @@ IWL3945_UCODE_GET(boot_size); * * Copy into buffers for card to fetch via bus-mastering */ -static int il3945_read_ucode(struct il_priv *priv) +static int il3945_read_ucode(struct il_priv *il) { const struct il_ucode_header *ucode; int ret = -EINVAL, index; const struct firmware *ucode_raw; /* firmware file name contains uCode/driver compatibility version */ - const char *name_pre = priv->cfg->fw_name_pre; - const unsigned int api_max = priv->cfg->ucode_api_max; - const unsigned int api_min = priv->cfg->ucode_api_min; + const char *name_pre = il->cfg->fw_name_pre; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; char buf[25]; u8 *src; size_t len; @@ -1865,9 +1865,9 @@ static int il3945_read_ucode(struct il_priv *priv) * request_firmware() is synchronous, file is in memory on return. */ for (index = api_max; index >= api_min; index--) { sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); - ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev); + ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { - IL_ERR(priv, "%s firmware file req failed: %d\n", + IL_ERR(il, "%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; @@ -1875,11 +1875,11 @@ static int il3945_read_ucode(struct il_priv *priv) goto error; } else { if (index < api_max) - IL_ERR(priv, "Loaded firmware %s, " + IL_ERR(il, "Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); - IL_DEBUG_INFO(priv, "Got firmware '%s' file " + IL_DEBUG_INFO(il, "Got firmware '%s' file " "(%zd bytes) from disk\n", buf, ucode_raw->size); break; @@ -1891,7 +1891,7 @@ static int il3945_read_ucode(struct il_priv *priv) /* Make sure that we got at least our header! */ if (ucode_raw->size < il3945_ucode_get_header_size(1)) { - IL_ERR(priv, "File size way too small!\n"); + IL_ERR(il, "File size way too small!\n"); ret = -EINVAL; goto err_release; } @@ -1899,8 +1899,8 @@ static int il3945_read_ucode(struct il_priv *priv) /* Data from ucode file: header followed by uCode images */ ucode = (struct il_ucode_header *)ucode_raw->data; - priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(priv->ucode_ver); + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); inst_size = il3945_ucode_get_inst_size(ucode); data_size = il3945_ucode_get_data_size(ucode); init_size = il3945_ucode_get_init_size(ucode); @@ -1913,44 +1913,44 @@ static int il3945_read_ucode(struct il_priv *priv) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(priv, "Driver unable to support your firmware API. " + IL_ERR(il, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); - priv->ucode_ver = 0; + il->ucode_ver = 0; ret = -EINVAL; goto err_release; } if (api_ver != api_max) - IL_ERR(priv, "Firmware has old API version. Expected %u, " + IL_ERR(il, "Firmware has old API version. Expected %u, " "got %u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); - snprintf(priv->hw->wiphy->fw_version, - sizeof(priv->hw->wiphy->fw_version), + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), "%u.%u.%u.%u", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); - - IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", - priv->ucode_ver); - IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %u\n", inst_size); - IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %u\n", data_size); - IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr init inst size = %u\n", init_size); - IL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr init data size = %u\n", init_data_size); - IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %u\n", boot_size); @@ -1959,7 +1959,7 @@ static int il3945_read_ucode(struct il_priv *priv) inst_size + data_size + init_size + init_data_size + boot_size) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode file size %zd does not match expected size\n", ucode_raw->size); ret = -EINVAL; @@ -1968,34 +1968,34 @@ static int il3945_read_ucode(struct il_priv *priv) /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", + IL_DEBUG_INFO(il, "uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", + IL_DEBUG_INFO(il, "uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IWL39_MAX_BSM_SIZE) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode boot instr len %d too large to fit in\n", boot_size); ret = -EINVAL; @@ -2007,37 +2007,37 @@ static int il3945_read_ucode(struct il_priv *priv) /* Runtime instructions and 2 copies of data: * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ - priv->ucode_code.len = inst_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il->ucode_code.len = inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - priv->ucode_data.len = data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il->ucode_data.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - priv->ucode_data_backup.len = data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il->ucode_data_backup.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || - !priv->ucode_data_backup.v_addr) + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) goto err_pci_alloc; /* Initialization instructions and data */ if (init_size && init_data_size) { - priv->ucode_init.len = init_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il->ucode_init.len = init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - priv->ucode_init_data.len = init_data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il->ucode_init_data.len = init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) goto err_pci_alloc; } /* Bootstrap (instructions only, no data) */ if (boot_size) { - priv->ucode_boot.len = boot_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il->ucode_boot.len = boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - if (!priv->ucode_boot.v_addr) + if (!il->ucode_boot.v_addr) goto err_pci_alloc; } @@ -2045,55 +2045,55 @@ static int il3945_read_ucode(struct il_priv *priv) /* Runtime instructions (first block of data in file) */ len = inst_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) uCode instr len %zd\n", len); - memcpy(priv->ucode_code.v_addr, src, len); + memcpy(il->ucode_code.v_addr, src, len); src += len; - IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); + IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* Runtime data (2nd block) * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) uCode data len %zd\n", len); - memcpy(priv->ucode_data.v_addr, src, len); - memcpy(priv->ucode_data_backup.v_addr, src, len); + memcpy(il->ucode_data.v_addr, src, len); + memcpy(il->ucode_data_backup.v_addr, src, len); src += len; /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init instr len %zd\n", len); - memcpy(priv->ucode_init.v_addr, src, len); + memcpy(il->ucode_init.v_addr, src, len); src += len; } /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init data len %zd\n", len); - memcpy(priv->ucode_init_data.v_addr, src, len); + memcpy(il->ucode_init_data.v_addr, src, len); src += len; } /* Bootstrap instructions (5th block) */ len = boot_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) boot instr len %zd\n", len); - memcpy(priv->ucode_boot.v_addr, src, len); + memcpy(il->ucode_boot.v_addr, src, len); /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); return 0; err_pci_alloc: - IL_ERR(priv, "failed to allocate pci memory\n"); + IL_ERR(il, "failed to allocate pci memory\n"); ret = -ENOMEM; - il3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(il); err_release: release_firmware(ucode_raw); @@ -2112,27 +2112,27 @@ static int il3945_read_ucode(struct il_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il3945_set_ucode_ptrs(struct il_priv *priv) +static int il3945_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; /* bits 31:0 for 3945 */ - pinst = priv->ucode_code.p_addr; - pdata = priv->ucode_data_backup.p_addr; + pinst = il->ucode_code.p_addr; + pdata = il->ucode_data_backup.p_addr; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, - priv->ucode_data.len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, - priv->ucode_code.len | BSM_DRAM_INST_LOAD); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); return 0; } @@ -2144,40 +2144,40 @@ static int il3945_set_ucode_ptrs(struct il_priv *priv) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il3945_init_alive_start(struct il_priv *priv) +static void il3945_init_alive_start(struct il_priv *il) { /* Check alive response for "valid" sign from uCode */ - if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { + if (il->card_alive_init.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Initialize Alive failed.\n"); + IL_DEBUG_INFO(il, "Initialize Alive failed.\n"); goto restart; } /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(priv)) { + if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (il3945_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + if (il3945_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); goto restart; } return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } /** @@ -2185,65 +2185,65 @@ static void il3945_init_alive_start(struct il_priv *priv) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il3945_init_alive_start()). */ -static void il3945_alive_start(struct il_priv *priv) +static void il3945_alive_start(struct il_priv *il) { int thermal_spin = 0; u32 rfkill; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); - if (priv->card_alive.is_valid != UCODE_VALID_OK) { + if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(il, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(priv)) { + if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); goto restart; } - rfkill = il_read_prph(priv, APMG_RFKILL_REG); - IL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); + rfkill = il_read_prph(il, APMG_RFKILL_REG); + IL_DEBUG_INFO(il, "RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); /* if RFKILL is not on, then wait for thermal * sensor in adapter to kick in */ - while (il3945_hw_get_temperature(priv) == 0) { + while (il3945_hw_get_temperature(il) == 0) { thermal_spin++; udelay(10); } if (thermal_spin) - IL_DEBUG_INFO(priv, "Thermal calibration took %dus\n", + IL_DEBUG_INFO(il, "Thermal calibration took %dus\n", thermal_spin * 10); } else - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); /* After the ALIVE response, we can send commands to 3945 uCode */ - set_bit(STATUS_ALIVE, &priv->status); + set_bit(STATUS_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(priv); + il_setup_watchdog(il); - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) return; - ieee80211_wake_queues(priv->hw); + ieee80211_wake_queues(il->hw); - priv->active_rate = IL_RATES_MASK_3945; + il->active_rate = IL_RATES_MASK_3945; - il_power_update_mode(priv, true); + il_power_update_mode(il, true); - if (il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (il_is_associated(il, IL_RXON_CTX_BSS)) { struct il3945_rxon_cmd *active_rxon = (struct il3945_rxon_cmd *)(&ctx->active); @@ -2251,205 +2251,205 @@ static void il3945_alive_start(struct il_priv *priv) active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { /* Initialize our rx_config data */ - il_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(il, ctx); } /* Configure Bluetooth device coexistence support */ - il_send_bt_config(priv); + il_send_bt_config(il); - set_bit(STATUS_READY, &priv->status); + set_bit(STATUS_READY, &il->status); /* Configure the adapter for unassociated operation */ - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); - il3945_reg_txpower_periodic(priv); + il3945_reg_txpower_periodic(il); - IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); - wake_up(&priv->wait_command_queue); + IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } -static void il3945_cancel_deferred_work(struct il_priv *priv); +static void il3945_cancel_deferred_work(struct il_priv *il); -static void __il3945_down(struct il_priv *priv) +static void __il3945_down(struct il_priv *il) { unsigned long flags; int exit_pending; - IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set * to prevent rearm timer */ - del_timer_sync(&priv->watchdog); + del_timer_sync(&il->watchdog); /* Station information will now be cleared in device */ - il_clear_ucode_stations(priv, NULL); - il_dealloc_bcast_stations(priv); - il_clear_driver_stations(priv); + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); /* Unblock any waiting calls */ - wake_up_all(&priv->wait_command_queue); + wake_up_all(&il->wait_command_queue); /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &priv->status); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); - il3945_synchronize_irq(priv); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il3945_synchronize_irq(il); - if (priv->mac80211_registered) - ieee80211_stop_queues(priv->hw); + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ - if (!il_is_init(priv)) { - priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) << + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &priv->status) << + test_bit(STATUS_FW_ERROR, &il->status) << STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; - il3945_hw_txq_ctx_stop(priv); - il3945_hw_rxq_stop(priv); + il3945_hw_txq_ctx_stop(il); + il3945_hw_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Stop the device, and put it in low power state */ - il_apm_stop(priv); + il_apm_stop(il); exit: - memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); - priv->beacon_skb = NULL; + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; /* clear out any free frames */ - il3945_clear_free_frames(priv); + il3945_clear_free_frames(il); } -static void il3945_down(struct il_priv *priv) +static void il3945_down(struct il_priv *il) { - mutex_lock(&priv->mutex); - __il3945_down(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + __il3945_down(il); + mutex_unlock(&il->mutex); - il3945_cancel_deferred_work(priv); + il3945_cancel_deferred_work(il); } #define MAX_HW_RESTARTS 5 -static int il3945_alloc_bcast_station(struct il_priv *priv) +static int il3945_alloc_bcast_station(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; unsigned long flags; u8 sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = il_prep_station(priv, ctx, + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, iwlegacy_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&priv->sta_lock, flags); + IL_ERR(il, "Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -static int __il3945_up(struct il_priv *priv) +static int __il3945_up(struct il_priv *il) { int rc, i; - rc = il3945_alloc_bcast_station(priv); + rc = il3945_alloc_bcast_station(il); if (rc) return rc; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN(il, "Exit pending; will not bring the NIC up\n"); return -EIO; } - if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IL_ERR(priv, "ucode not available for device bring up\n"); + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR(il, "ucode not available for device bring up\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(priv, CSR_GP_CNTRL) & + if (il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); else { - set_bit(STATUS_RF_KILL_HW, &priv->status); - IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + set_bit(STATUS_RF_KILL_HW, &il->status); + IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); return -ENODEV; } - il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(il, CSR_INT, 0xFFFFFFFF); - rc = il3945_hw_nic_init(priv); + rc = il3945_hw_nic_init(il); if (rc) { - IL_ERR(priv, "Unable to int nic\n"); + IL_ERR(il, "Unable to int nic\n"); return rc; } /* make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(priv, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(priv); + il_write32(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's * data SRAM for a clean start when the runtime program first loads. */ - memcpy(priv->ucode_data_backup.v_addr, priv->ucode_data.v_addr, - priv->ucode_data.len); + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); /* We return success when we resume from suspend and rf_kill is on. */ - if (test_bit(STATUS_RF_KILL_HW, &priv->status)) + if (test_bit(STATUS_RF_KILL_HW, &il->status)) return 0; for (i = 0; i < MAX_HW_RESTARTS; i++) { @@ -2457,29 +2457,29 @@ static int __il3945_up(struct il_priv *priv) /* load bootstrap state machine, * load bootstrap program into processor's memory, * prepare to load the "initialize" uCode */ - rc = priv->cfg->ops->lib->load_ucode(priv); + rc = il->cfg->ops->lib->load_ucode(il); if (rc) { - IL_ERR(priv, + IL_ERR(il, "Unable to set up bootstrap uCode: %d\n", rc); continue; } /* start card; "initialize" will load runtime ucode */ - il3945_nic_start(priv); + il3945_nic_start(il); - IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); return 0; } - set_bit(STATUS_EXIT_PENDING, &priv->status); - __il3945_down(priv); - clear_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); + __il3945_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2492,30 +2492,30 @@ static int __il3945_up(struct il_priv *priv) static void il3945_bg_init_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il3945_init_alive_start(priv); + il3945_init_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il3945_bg_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il3945_alive_start(priv); + il3945_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } /* @@ -2526,32 +2526,32 @@ out: */ static void il3945_rfkill_poll(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); - bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status); - bool new_rfkill = !(il_read32(priv, CSR_GP_CNTRL) + bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); + bool new_rfkill = !(il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { if (new_rfkill) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, new_rfkill); + wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); - IL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n", + IL_DEBUG_RF_KILL(il, "RF_KILL bit toggled to %s.\n", new_rfkill ? "disable radio" : "enable radio"); } /* Keep this running, even if radio now enabled. This will be * cancelled in mac_start() if system decides to start again */ - queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); } -int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, @@ -2565,29 +2565,29 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) int ret; u16 len; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!priv->scan_cmd) { - IL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); + if (!il->scan_cmd) { + IL_DEBUG_SCAN(il, "Fail to allocate scan memory\n"); return -ENOMEM; } } - scan = priv->scan_cmd; + scan = il->scan_cmd; memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (il_is_associated(il, IL_RXON_CTX_BSS)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(il, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; @@ -2607,39 +2607,39 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } - if (priv->scan_request->n_ssids) { + if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); - for (i = 0; i < priv->scan_request->n_ssids; i++) { + IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ - if (!priv->scan_request->ssids[i].ssid_len) + if (!il->scan_request->ssids[i].ssid_len) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - priv->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, - priv->scan_request->ssids[i].ssid, - priv->scan_request->ssids[i].ssid_len); + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); n_probes++; p++; } is_active = true; } else - IL_DEBUG_SCAN(priv, "Kicking off passive scan.\n"); + IL_DEBUG_SCAN(il, "Kicking off passive scan.\n"); /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + scan->tx_cmd.sta_id = il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; /* flags + rate selection */ - switch (priv->scan_band) { + switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; scan->tx_cmd.rate = IL_RATE_1M_PLCP; @@ -2650,7 +2650,7 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) band = IEEE80211_BAND_5GHZ; break; default: - IL_WARN(priv, "Invalid scan band\n"); + IL_WARN(il, "Invalid scan band\n"); return -EIO; } @@ -2662,19 +2662,19 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_DISABLED; - len = il_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, - vif->addr, priv->scan_request->ie, - priv->scan_request->ie_len, + len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(len); /* select Rx antennas */ - scan->flags |= il3945_get_antenna_flags(priv); + scan->flags |= il3945_get_antenna_flags(il); - scan->channel_count = il3945_get_channels_for_scan(priv, band, is_active, n_probes, + scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, (void *)&scan->data[len], vif); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); return -EIO; } @@ -2683,101 +2683,101 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &priv->status); - ret = il_send_cmd_sync(priv, &cmd); + set_bit(STATUS_SCAN_HW, &il->status); + ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &priv->status); + clear_bit(STATUS_SCAN_HW, &il->status); return ret; } -void il3945_post_scan(struct il_priv *priv) +void il3945_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } static void il3945_bg_restart(struct work_struct *data) { - struct il_priv *priv = container_of(data, struct il_priv, restart); + struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { struct il_rxon_context *ctx; - mutex_lock(&priv->mutex); - for_each_context(priv, ctx) + mutex_lock(&il->mutex); + for_each_context(il, ctx) ctx->vif = NULL; - priv->is_open = 0; - mutex_unlock(&priv->mutex); - il3945_down(priv); - ieee80211_restart_hw(priv->hw); + il->is_open = 0; + mutex_unlock(&il->mutex); + il3945_down(il); + ieee80211_restart_hw(il->hw); } else { - il3945_down(priv); + il3945_down(il); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); return; } - __il3945_up(priv); - mutex_unlock(&priv->mutex); + __il3945_up(il); + mutex_unlock(&il->mutex); } } static void il3945_bg_rx_replenish(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il3945_rx_replenish(priv); + il3945_rx_replenish(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } -void il3945_post_associate(struct il_priv *priv) +void il3945_post_associate(struct il_priv *il) { int rc = 0; struct ieee80211_conf *conf = NULL; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (!ctx->vif || !priv->is_open) + if (!ctx->vif || !il->is_open) return; - IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(il->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); - rc = il_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(il, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) @@ -2792,17 +2792,17 @@ void il3945_post_associate(struct il_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); switch (ctx->vif->type) { case NL80211_IFTYPE_STATION: - il3945_rate_scale_init(priv->hw, IL_AP_ID); + il3945_rate_scale_init(il->hw, IL_AP_ID); break; case NL80211_IFTYPE_ADHOC: - il3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(il); break; default: - IL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(il, "%s Should not be called in %d mode\n", __func__, ctx->vif->type); break; } @@ -2818,43 +2818,43 @@ void il3945_post_associate(struct il_priv *priv) static int il3945_mac_start(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); /* we should be verifying the device is ready to be opened */ - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); /* fetch ucode file from disk, alloc and copy to bus-master buffers ... * ucode filename and max sizes are card-specific. */ - if (!priv->ucode_code.len) { - ret = il3945_read_ucode(priv); + if (!il->ucode_code.len) { + ret = il3945_read_ucode(il); if (ret) { - IL_ERR(priv, "Could not read microcode: %d\n", ret); - mutex_unlock(&priv->mutex); + IL_ERR(il, "Could not read microcode: %d\n", ret); + mutex_unlock(&il->mutex); goto out_release_irq; } } - ret = __il3945_up(priv); + ret = __il3945_up(il); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); if (ret) goto out_release_irq; - IL_DEBUG_INFO(priv, "Start UP work.\n"); + IL_DEBUG_INFO(il, "Start UP work.\n"); /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ - ret = wait_event_timeout(priv->wait_command_queue, - test_bit(STATUS_READY, &priv->status), + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &priv->status)) { - IL_ERR(priv, + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR(il, "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; @@ -2864,77 +2864,77 @@ static int il3945_mac_start(struct ieee80211_hw *hw) /* ucode is running and will send rfkill notifications, * no need to poll the killswitch state anymore */ - cancel_delayed_work(&priv->_3945.rfkill_poll); + cancel_delayed_work(&il->_3945.rfkill_poll); - priv->is_open = 1; - IL_DEBUG_MAC80211(priv, "leave\n"); + il->is_open = 1; + IL_DEBUG_MAC80211(il, "leave\n"); return 0; out_release_irq: - priv->is_open = 0; - IL_DEBUG_MAC80211(priv, "leave - failed\n"); + il->is_open = 0; + IL_DEBUG_MAC80211(il, "leave - failed\n"); return ret; } static void il3945_mac_stop(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (!priv->is_open) { - IL_DEBUG_MAC80211(priv, "leave - skip\n"); + if (!il->is_open) { + IL_DEBUG_MAC80211(il, "leave - skip\n"); return; } - priv->is_open = 0; + il->is_open = 0; - il3945_down(priv); + il3945_down(il); - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* start polling the killswitch state again */ - queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (il3945_tx_skb(priv, skb)) + if (il3945_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } -void il3945_config_ap(struct il_priv *priv) +void il3945_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int rc = 0; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ - if (!(il_is_associated(priv, IL_RXON_CTX_BSS))) { + if (!(il_is_associated(il, IL_RXON_CTX_BSS))) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); /* RXON Timing */ - rc = il_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(il, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -2956,9 +2956,9 @@ void il3945_config_ap(struct il_priv *priv) } /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } - il3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(il); } static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, @@ -2966,15 +2966,15 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret = 0; u8 sta_id = IL_INVALID_STATION; u8 static_key; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); if (il3945_mod_params.sw_crypto) { - IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -2986,39 +2986,39 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) return -EOPNOTSUPP; - static_key = !il_is_associated(priv, IL_RXON_CTX_BSS); + static_key = !il_is_associated(il, IL_RXON_CTX_BSS); if (!static_key) { sta_id = il_sta_id_or_broadcast( - priv, &priv->contexts[IL_RXON_CTX_BSS], sta); + il, &il->contexts[IL_RXON_CTX_BSS], sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; } - mutex_lock(&priv->mutex); - il_scan_cancel_timeout(priv, 100); + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); switch (cmd) { case SET_KEY: if (static_key) - ret = il3945_set_static_key(priv, key); + ret = il3945_set_static_key(il, key); else - ret = il3945_set_dynamic_key(priv, key, sta_id); - IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + ret = il3945_set_dynamic_key(il, key, sta_id); + IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (static_key) - ret = il3945_remove_static_key(priv); + ret = il3945_remove_static_key(il); else - ret = il3945_clear_sta_key_info(priv, sta_id); - IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + ret = il3945_clear_sta_key_info(il, sta_id); + IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } - mutex_unlock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + mutex_unlock(&il->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); return ret; } @@ -3027,38 +3027,38 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; int ret; bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - IL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(il, "received request to add station %pM\n", sta->addr); - mutex_lock(&priv->mutex); - IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + mutex_lock(&il->mutex); + IL_DEBUG_INFO(il, "proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; - ret = il_add_station_common(priv, - &priv->contexts[IL_RXON_CTX_BSS], + ret = il_add_station_common(il, + &il->contexts[IL_RXON_CTX_BSS], sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(il, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", sta->addr); - il3945_rs_rate_init(priv, sta, sta_id); - mutex_unlock(&priv->mutex); + il3945_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); return 0; } @@ -3068,9 +3068,9 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, unsigned int *total_flags, u64 multicast) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -3079,7 +3079,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -3088,7 +3088,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, #undef CHK - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); ctx->staging.filter_flags &= ~filter_nand; ctx->staging.filter_flags |= filter_or; @@ -3099,7 +3099,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * we'll eventually commit the filter flags change anyway. */ - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); /* * Receiving all multicast frames is always enabled by the @@ -3134,24 +3134,24 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, static ssize_t il3945_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } static ssize_t il3945_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IL_INFO(priv, "%s is not in hex or decimal form.\n", buf); + IL_INFO(il, "%s is not in hex or decimal form.\n", buf); else { - priv->debug_level = val; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -3165,12 +3165,12 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, static ssize_t il3945_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; - return sprintf(buf, "%d\n", il3945_hw_get_temperature(priv)); + return sprintf(buf, "%d\n", il3945_hw_get_temperature(il)); } static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); @@ -3178,23 +3178,23 @@ static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); static ssize_t il3945_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "%d\n", priv->tx_power_user_lmt); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d\n", il->tx_power_user_lmt); } static ssize_t il3945_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; u32 val; val = simple_strtoul(p, &p, 10); if (p == buf) - IL_INFO(priv, ": %s is not in decimal form.\n", buf); + IL_INFO(il, ": %s is not in decimal form.\n", buf); else - il3945_hw_reg_set_txpower(priv, val); + il3945_hw_reg_set_txpower(il, val); return count; } @@ -3204,8 +3204,8 @@ static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_sto static ssize_t il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", ctx->active.flags); } @@ -3214,23 +3214,23 @@ static ssize_t il3945_store_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); if (le32_to_cpu(ctx->staging.flags) != flags) { /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(priv, 100)) - IL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(il, 100)) + IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n", + IL_DEBUG_INFO(il, "Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return count; } @@ -3240,8 +3240,8 @@ static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_fla static ssize_t il3945_show_filter_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); @@ -3251,24 +3251,24 @@ static ssize_t il3945_store_filter_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u32 filter_flags = simple_strtoul(buf, NULL, 0); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(priv, 100)) - IL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(il, 100)) + IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(priv, "Committing rxon.filter_flags = " + IL_DEBUG_INFO(il, "Committing rxon.filter_flags = " "0x%04X\n", filter_flags); ctx->staging.filter_flags = cpu_to_le32(filter_flags); - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return count; } @@ -3279,20 +3279,20 @@ static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, static ssize_t il3945_show_measurement(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; u8 *data = (u8 *)&measure_report; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); - if (!(priv->measurement_status & MEASUREMENT_READY)) { - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + if (!(il->measurement_status & MEASUREMENT_READY)) { + spin_unlock_irqrestore(&il->lock, flags); return 0; } - memcpy(&measure_report, &priv->measure_report, size); - priv->measurement_status = 0; - spin_unlock_irqrestore(&priv->lock, flags); + memcpy(&measure_report, &il->measure_report, size); + il->measurement_status = 0; + spin_unlock_irqrestore(&il->lock, flags); while (size && (PAGE_SIZE - len)) { hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, @@ -3312,11 +3312,11 @@ static ssize_t il3945_store_measurement(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_measurement_params params = { .channel = le16_to_cpu(ctx->active.channel), - .start_time = cpu_to_le64(priv->_3945.last_tsf), + .start_time = cpu_to_le64(il->_3945.last_tsf), .duration = cpu_to_le16(1), }; u8 type = IL_MEASURE_BASIC; @@ -3337,9 +3337,9 @@ static ssize_t il3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - IL_DEBUG_INFO(priv, "Invoking measurement of type %d on " + IL_DEBUG_INFO(il, "Invoking measurement of type %d on " "channel %d (for '%s')\n", type, params.channel, buf); - il3945_get_measurement(priv, ¶ms, type); + il3945_get_measurement(il, ¶ms, type); return count; } @@ -3351,11 +3351,11 @@ static ssize_t il3945_store_retry_rate(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - priv->retry_rate = simple_strtoul(buf, NULL, 0); - if (priv->retry_rate <= 0) - priv->retry_rate = 1; + il->retry_rate = simple_strtoul(buf, NULL, 0); + if (il->retry_rate <= 0) + il->retry_rate = 1; return count; } @@ -3363,8 +3363,8 @@ static ssize_t il3945_store_retry_rate(struct device *d, static ssize_t il3945_show_retry_rate(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "%d", priv->retry_rate); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d", il->retry_rate); } static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, @@ -3383,9 +3383,9 @@ static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); static ssize_t il3945_show_antenna(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; return sprintf(buf, "%d\n", il3945_mod_params.antenna); @@ -3395,22 +3395,22 @@ static ssize_t il3945_store_antenna(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv __maybe_unused = dev_get_drvdata(d); + struct il_priv *il __maybe_unused = dev_get_drvdata(d); int ant; if (count == 0) return 0; if (sscanf(buf, "%1i", &ant) != 1) { - IL_DEBUG_INFO(priv, "not in hex or decimal form.\n"); + IL_DEBUG_INFO(il, "not in hex or decimal form.\n"); return count; } if ((ant >= 0) && (ant <= 2)) { - IL_DEBUG_INFO(priv, "Setting antenna select to %d.\n", ant); + IL_DEBUG_INFO(il, "Setting antenna select to %d.\n", ant); il3945_mod_params.antenna = (enum il3945_antenna)ant; } else - IL_DEBUG_INFO(priv, "Bad antenna select value %d.\n", ant); + IL_DEBUG_INFO(il, "Bad antenna select value %d.\n", ant); return count; @@ -3421,10 +3421,10 @@ static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store static ssize_t il3945_show_status(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - if (!il_is_alive(priv)) + struct il_priv *il = dev_get_drvdata(d); + if (!il_is_alive(il)) return -EAGAIN; - return sprintf(buf, "0x%08x\n", (int)priv->status); + return sprintf(buf, "0x%08x\n", (int)il->status); } static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); @@ -3433,11 +3433,11 @@ static ssize_t il3945_dump_error_log(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; if (p[0] == '1') - il3945_dump_nic_error_log(priv); + il3945_dump_nic_error_log(il); return strnlen(buf, count); } @@ -3450,38 +3450,38 @@ static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); * *****************************************************************************/ -static void il3945_setup_deferred_work(struct il_priv *priv) +static void il3945_setup_deferred_work(struct il_priv *il) { - priv->workqueue = create_singlethread_workqueue(DRV_NAME); + il->workqueue = create_singlethread_workqueue(DRV_NAME); - init_waitqueue_head(&priv->wait_command_queue); + init_waitqueue_head(&il->wait_command_queue); - INIT_WORK(&priv->restart, il3945_bg_restart); - INIT_WORK(&priv->rx_replenish, il3945_bg_rx_replenish); - INIT_DELAYED_WORK(&priv->init_alive_start, il3945_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, il3945_bg_alive_start); - INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, il3945_rfkill_poll); + INIT_WORK(&il->restart, il3945_bg_restart); + INIT_WORK(&il->rx_replenish, il3945_bg_rx_replenish); + INIT_DELAYED_WORK(&il->init_alive_start, il3945_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il3945_bg_alive_start); + INIT_DELAYED_WORK(&il->_3945.rfkill_poll, il3945_rfkill_poll); - il_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(il); - il3945_hw_setup_deferred_work(priv); + il3945_hw_setup_deferred_work(il); - init_timer(&priv->watchdog); - priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = il_bg_watchdog; + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; - tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - il3945_irq_tasklet, (unsigned long)priv); + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il3945_irq_tasklet, (unsigned long)il); } -static void il3945_cancel_deferred_work(struct il_priv *priv) +static void il3945_cancel_deferred_work(struct il_priv *il) { - il3945_hw_cancel_deferred_work(priv); + il3945_hw_cancel_deferred_work(il); - cancel_delayed_work_sync(&priv->init_alive_start); - cancel_delayed_work(&priv->alive_start); + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); - il_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(il); } static struct attribute *il3945_sysfs_entries[] = { @@ -3525,70 +3525,70 @@ struct ieee80211_ops il3945_hw_ops = { .tx_last_beacon = il_mac_tx_last_beacon, }; -static int il3945_init_drv(struct il_priv *priv) +static int il3945_init_drv(struct il_priv *il) { int ret; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - priv->retry_rate = 1; - priv->beacon_skb = NULL; + il->retry_rate = 1; + il->beacon_skb = NULL; - spin_lock_init(&priv->sta_lock); - spin_lock_init(&priv->hcmd_lock); + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); - INIT_LIST_HEAD(&priv->free_frames); + INIT_LIST_HEAD(&il->free_frames); - mutex_init(&priv->mutex); + mutex_init(&il->mutex); - priv->ieee_channels = NULL; - priv->ieee_rates = NULL; - priv->band = IEEE80211_BAND_2GHZ; + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; - priv->iw_mode = NL80211_IFTYPE_STATION; - priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + il->iw_mode = NL80211_IFTYPE_STATION; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", + IL_WARN(il, "Unsupported EEPROM version: 0x%04X\n", eeprom->version); ret = -EINVAL; goto err; } - ret = il_init_channel_map(priv); + ret = il_init_channel_map(il); if (ret) { - IL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(il, "initializing regulatory failed: %d\n", ret); goto err; } /* Set up txpower settings in driver for all channels */ - if (il3945_txpower_set_from_eeprom(priv)) { + if (il3945_txpower_set_from_eeprom(il)) { ret = -EIO; goto err_free_channel_map; } - ret = il_init_geos(priv); + ret = il_init_geos(il); if (ret) { - IL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(il, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - il3945_init_hw_rates(priv, priv->ieee_rates); + il3945_init_hw_rates(il, il->ieee_rates); return 0; err_free_channel_map: - il_free_channel_map(priv); + il_free_channel_map(il); err: return ret; } #define IWL3945_MAX_PROBE_REQUEST 200 -static int il3945_setup_mac(struct il_priv *priv) +static int il3945_setup_mac(struct il_priv *il) { int ret; - struct ieee80211_hw *hw = priv->hw; + struct ieee80211_hw *hw = il->hw; hw->rate_control_algorithm = "iwl-3945-rs"; hw->sta_data_size = sizeof(struct il3945_sta_priv); @@ -3599,7 +3599,7 @@ static int il3945_setup_mac(struct il_priv *priv) IEEE80211_HW_SPECTRUM_MGMT; hw->wiphy->interface_modes = - priv->contexts[IL_RXON_CTX_BSS].interface_modes; + il->contexts[IL_RXON_CTX_BSS].interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | @@ -3612,22 +3612,22 @@ static int il3945_setup_mac(struct il_priv *priv) /* Default value; 4 EDCA QOS priorities */ hw->queues = 4; - if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &priv->bands[IEEE80211_BAND_2GHZ]; + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; - if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &priv->bands[IEEE80211_BAND_5GHZ]; + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; - il_leds_init(priv); + il_leds_init(il); - ret = ieee80211_register_hw(priv->hw); + ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(il, "Failed to register hw (error %d)\n", ret); return ret; } - priv->mac80211_registered = 1; + il->mac80211_registered = 1; return 0; } @@ -3635,7 +3635,7 @@ static int il3945_setup_mac(struct il_priv *priv) static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct il_priv *priv; + struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); struct il3945_eeprom *eeprom; @@ -3646,53 +3646,53 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * ********************/ /* mac80211 allocates memory for this device instance, including - * space for this driver's private structure */ + * space for this driver's ilate structure */ hw = il_alloc_all(cfg); if (hw == NULL) { pr_err("Can not allocate network device\n"); err = -ENOMEM; goto out; } - priv = hw->priv; + il = hw->priv; SET_IEEE80211_DEV(hw, &pdev->dev); - priv->cmd_queue = IWL39_CMD_QUEUE_NUM; + il->cmd_queue = IWL39_CMD_QUEUE_NUM; /* 3945 has only one valid context */ - priv->valid_contexts = BIT(IL_RXON_CTX_BSS); + il->valid_contexts = BIT(IL_RXON_CTX_BSS); for (i = 0; i < NUM_IL_RXON_CTX; i++) - priv->contexts[i].ctxid = i; - - priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IL_RXON_CTX_BSS].interface_modes = + il->contexts[i].ctxid = i; + + il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + il->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; /* * Disabling hardware scan means that mac80211 will perform scans * "the hard way", rather than using device's scan. */ if (il3945_mod_params.disable_hw_scan) { - IL_DEBUG_INFO(priv, "Disabling hw_scan\n"); + IL_DEBUG_INFO(il, "Disabling hw_scan\n"); il3945_hw_ops.hw_scan = NULL; } - IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); - priv->cfg = cfg; - priv->pci_dev = pdev; - priv->inta_mask = CSR_INI_SET_MASK; + IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); /*************************** * 2. Initializing PCI bus @@ -3711,11 +3711,11 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en if (!err) err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); if (err) { - IL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(il, "No suitable DMA available.\n"); goto out_pci_disable_device; } - pci_set_drvdata(pdev, priv); + pci_set_drvdata(pdev, il); err = pci_request_regions(pdev, DRV_NAME); if (err) goto out_pci_disable_device; @@ -3723,15 +3723,15 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /*********************** * 3. Read REV Register * ********************/ - priv->hw_base = pci_iomap(pdev, 0, 0); - if (!priv->hw_base) { + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { err = -ENODEV; goto out_pci_release_regions; } - IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -3740,152 +3740,152 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now */ - spin_lock_init(&priv->reg_lock); - spin_lock_init(&priv->lock); + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); /* * stop and reset the on-board processor just in case it is in a * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /*********************** * 4. Read EEPROM * ********************/ /* Read the EEPROM */ - err = il_eeprom_init(priv); + err = il_eeprom_init(il); if (err) { - IL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(il, "Unable to init EEPROM\n"); goto out_iounmap; } /* MAC Address location in EEPROM same for 3945/4965 */ - eeprom = (struct il3945_eeprom *)priv->eeprom; - IL_DEBUG_INFO(priv, "MAC address: %pM\n", eeprom->mac_address); - SET_IEEE80211_PERM_ADDR(priv->hw, eeprom->mac_address); + eeprom = (struct il3945_eeprom *)il->eeprom; + IL_DEBUG_INFO(il, "MAC address: %pM\n", eeprom->mac_address); + SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); /*********************** * 5. Setup HW Constants * ********************/ /* Device-specific setup */ - if (il3945_hw_set_hw_params(priv)) { - IL_ERR(priv, "failed to set hw settings\n"); + if (il3945_hw_set_hw_params(il)) { + IL_ERR(il, "failed to set hw settings\n"); goto out_eeprom_free; } /*********************** - * 6. Setup priv + * 6. Setup il * ********************/ - err = il3945_init_drv(priv); + err = il3945_init_drv(il); if (err) { - IL_ERR(priv, "initializing driver failed\n"); + IL_ERR(il, "initializing driver failed\n"); goto out_unset_hw_params; } - IL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", - priv->cfg->name); + IL_INFO(il, "Detected Intel Wireless WiFi Link %s\n", + il->cfg->name); /*********************** * 7. Setup Services * ********************/ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - pci_enable_msi(priv->pci_dev); + pci_enable_msi(il->pci_dev); - err = request_irq(priv->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, priv); + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); if (err) { - IL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(il, "failed to create sysfs device attributes\n"); goto out_release_irq; } - il_set_rxon_channel(priv, - &priv->bands[IEEE80211_BAND_2GHZ].channels[5], - &priv->contexts[IL_RXON_CTX_BSS]); - il3945_setup_deferred_work(priv); - il3945_setup_rx_handlers(priv); - il_power_initialize(priv); + il_set_rxon_channel(il, + &il->bands[IEEE80211_BAND_2GHZ].channels[5], + &il->contexts[IL_RXON_CTX_BSS]); + il3945_setup_deferred_work(il); + il3945_setup_rx_handlers(il); + il_power_initialize(il); /********************************* * 8. Setup and Register mac80211 * *******************************/ - il_enable_interrupts(priv); + il_enable_interrupts(il); - err = il3945_setup_mac(priv); + err = il3945_setup_mac(il); if (err) goto out_remove_sysfs; - err = il_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR(il, "failed to create debugfs files. Ignoring error: %d\n", err); /* Start monitoring the killswitch */ - queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ); return 0; out_remove_sysfs: - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; + destroy_workqueue(il->workqueue); + il->workqueue = NULL; sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); out_release_irq: - free_irq(priv->pci_dev->irq, priv); + free_irq(il->pci_dev->irq, il); out_disable_msi: - pci_disable_msi(priv->pci_dev); - il_free_geos(priv); - il_free_channel_map(priv); + pci_disable_msi(il->pci_dev); + il_free_geos(il); + il_free_channel_map(il); out_unset_hw_params: - il3945_unset_hw_params(priv); + il3945_unset_hw_params(il); out_eeprom_free: - il_eeprom_free(priv); + il_eeprom_free(il); out_iounmap: - pci_iounmap(pdev, priv->hw_base); + pci_iounmap(pdev, il->hw_base); out_pci_release_regions: pci_release_regions(pdev); out_pci_disable_device: pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); out_ieee80211_free_hw: - il_free_traffic_mem(priv); - ieee80211_free_hw(priv->hw); + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); out: return err; } static void __devexit il3945_pci_remove(struct pci_dev *pdev) { - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; - if (!priv) + if (!il) return; - IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); - il_dbgfs_unregister(priv); + il_dbgfs_unregister(il); - set_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); - il_leds_exit(priv); + il_leds_exit(il); - if (priv->mac80211_registered) { - ieee80211_unregister_hw(priv->hw); - priv->mac80211_registered = 0; + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; } else { - il3945_down(priv); + il3945_down(il); } /* @@ -3895,54 +3895,54 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) * paths to avoid running il_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - il_apm_stop(priv); + il_apm_stop(il); /* make sure we flush any pending irq or * tasklet for the driver */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - il3945_synchronize_irq(priv); + il3945_synchronize_irq(il); sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - cancel_delayed_work_sync(&priv->_3945.rfkill_poll); + cancel_delayed_work_sync(&il->_3945.rfkill_poll); - il3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(il); - if (priv->rxq.bd) - il3945_rx_queue_free(priv, &priv->rxq); - il3945_hw_txq_ctx_free(priv); + if (il->rxq.bd) + il3945_rx_queue_free(il, &il->rxq); + il3945_hw_txq_ctx_free(il); - il3945_unset_hw_params(priv); + il3945_unset_hw_params(il); /*netif_stop_queue(dev); */ - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes - * priv->workqueue... so we can't take down the workqueue + * il->workqueue... so we can't take down the workqueue * until now... */ - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; - il_free_traffic_mem(priv); + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); - free_irq(pdev->irq, priv); + free_irq(pdev->irq, il); pci_disable_msi(pdev); - pci_iounmap(pdev, priv->hw_base); + pci_iounmap(pdev, il->hw_base); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - il_free_channel_map(priv); - il_free_geos(priv); - kfree(priv->scan_cmd); - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); + il_free_channel_map(il); + il_free_geos(il); + kfree(il->scan_cmd); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); - ieee80211_free_hw(priv->hw); + ieee80211_free_hw(il->hw); } diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index bd37c92..ae8a937 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -87,85 +87,85 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); -void il4965_update_chain_flags(struct il_priv *priv) +void il4965_update_chain_flags(struct il_priv *il) { struct il_rxon_context *ctx; - if (priv->cfg->ops->hcmd->set_rxon_chain) { - for_each_context(priv, ctx) { - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) { + for_each_context(il, ctx) { + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); if (ctx->active.rx_chain != ctx->staging.rx_chain) - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } } } -static void il4965_clear_free_frames(struct il_priv *priv) +static void il4965_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", - priv->frames_count); + IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + il->frames_count); - while (!list_empty(&priv->free_frames)) { - element = priv->free_frames.next; + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; list_del(element); kfree(list_entry(element, struct il_frame, list)); - priv->frames_count--; + il->frames_count--; } - if (priv->frames_count) { - IL_WARN(priv, "%d frames still in use. Did we lose one?\n", - priv->frames_count); - priv->frames_count = 0; + if (il->frames_count) { + IL_WARN(il, "%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; } } -static struct il_frame *il4965_get_free_frame(struct il_priv *priv) +static struct il_frame *il4965_get_free_frame(struct il_priv *il) { struct il_frame *frame; struct list_head *element; - if (list_empty(&priv->free_frames)) { + if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(il, "Could not allocate frame!\n"); return NULL; } - priv->frames_count++; + il->frames_count++; return frame; } - element = priv->free_frames.next; + element = il->free_frames.next; list_del(element); return list_entry(element, struct il_frame, list); } -static void il4965_free_frame(struct il_priv *priv, struct il_frame *frame) +static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) { memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &priv->free_frames); + list_add(&frame->list, &il->free_frames); } -static u32 il4965_fill_beacon_frame(struct il_priv *priv, +static u32 il4965_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, int left) { - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->beacon_skb) + if (!il->beacon_skb) return 0; - if (priv->beacon_skb->len > left) + if (il->beacon_skb->len > left) return 0; - memcpy(hdr, priv->beacon_skb->data, priv->beacon_skb->len); + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - return priv->beacon_skb->len; + return il->beacon_skb->len; } /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void il4965_set_beacon_tim(struct il_priv *priv, +static void il4965_set_beacon_tim(struct il_priv *il, struct il_tx_beacon_cmd *tx_beacon_cmd, u8 *beacon, u32 frame_size) { @@ -188,10 +188,10 @@ static void il4965_set_beacon_tim(struct il_priv *priv, tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); tx_beacon_cmd->tim_size = beacon[tim_idx+1]; } else - IL_WARN(priv, "Unable to find TIM Element in beacon\n"); + IL_WARN(il, "Unable to find TIM Element in beacon\n"); } -static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, +static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame) { struct il_tx_beacon_cmd *tx_beacon_cmd; @@ -203,10 +203,10 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, * beacon contents. */ - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->beacon_ctx) { - IL_ERR(priv, "trying to build beacon w/o beacon context!\n"); + if (!il->beacon_ctx) { + IL_ERR(il, "trying to build beacon w/o beacon context!\n"); return 0; } @@ -215,7 +215,7 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); /* Set up TX beacon contents */ - frame_size = il4965_fill_beacon_frame(priv, tx_beacon_cmd->frame, + frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) return 0; @@ -224,20 +224,20 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, /* Set up TX command fields */ tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); - tx_beacon_cmd->tx.sta_id = priv->beacon_ctx->bcast_sta_id; + tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; /* Set up TX beacon command fields */ - il4965_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, + il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, frame_size); /* Set up packet rate and flags */ - rate = il_get_lowest_plcp(priv, priv->beacon_ctx); - priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, - priv->hw_params.valid_tx_ant); - rate_flags = il4965_ant_idx_to_flags(priv->mgmt_tx_ant); + rate = il_get_lowest_plcp(il, il->beacon_ctx); + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); + rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, @@ -246,30 +246,30 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, return sizeof(*tx_beacon_cmd) + frame_size; } -int il4965_send_beacon_cmd(struct il_priv *priv) +int il4965_send_beacon_cmd(struct il_priv *il) { struct il_frame *frame; unsigned int frame_size; int rc; - frame = il4965_get_free_frame(priv); + frame = il4965_get_free_frame(il); if (!frame) { - IL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(il, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - frame_size = il4965_hw_get_beacon_cmd(priv, frame); + frame_size = il4965_hw_get_beacon_cmd(il, frame); if (!frame_size) { - IL_ERR(priv, "Error configuring the beacon command\n"); - il4965_free_frame(priv, frame); + IL_ERR(il, "Error configuring the beacon command\n"); + il4965_free_frame(il, frame); return -EINVAL; } - rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - il4965_free_frame(priv, frame); + il4965_free_frame(il, frame); return rc; } @@ -315,17 +315,17 @@ static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) /** * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] - * @priv - driver private data + * @il - driver ilate data * @txq - tx queue * * Does NOT advance any TFD circular buffer read/write indexes * Does NOT free the TFD itself (which is within circular buffer) */ -void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; struct il_tfd *tfd; - struct pci_dev *dev = priv->pci_dev; + struct pci_dev *dev = il->pci_dev; int index = txq->q.read_ptr; int i; int num_tbs; @@ -336,7 +336,7 @@ void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) num_tbs = il4965_tfd_get_num_tbs(tfd); if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(priv, "Too many chunks: %i\n", num_tbs); + IL_ERR(il, "Too many chunks: %i\n", num_tbs); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -368,7 +368,7 @@ void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) } } -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) @@ -388,14 +388,14 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, /* Each TFD can point to a maximum 20 Tx buffers */ if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(priv, "Error can not send more than %d chunks\n", + IL_ERR(il, "Error can not send more than %d chunks\n", IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR(priv, "Unaligned address = %llx\n", + IL_ERR(il, "Unaligned address = %llx\n", (unsigned long long)addr); il4965_tfd_set_tb(tfd, num_tbs, addr, len); @@ -410,13 +410,13 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA * channels supported in hardware. */ -int il4965_hw_tx_queue_init(struct il_priv *priv, +int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), + il_write_direct32(il, FH_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -427,7 +427,7 @@ int il4965_hw_tx_queue_init(struct il_priv *priv, * Generic RX handler implementations * ******************************************************************************/ -static void il4965_rx_reply_alive(struct il_priv *priv, +static void il4965_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -436,31 +436,31 @@ static void il4965_rx_reply_alive(struct il_priv *priv, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - memcpy(&priv->card_alive_init, + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_init_alive_resp)); - pwork = &priv->init_alive_start; + pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); - memcpy(&priv->card_alive, &pkt->u.alive_frame, + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); - pwork = &priv->alive_start; + pwork = &il->alive_start; } /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(priv->workqueue, pwork, + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(il, "uCode did not respond OK.\n"); } /** @@ -475,19 +475,19 @@ static void il4965_rx_reply_alive(struct il_priv *priv, */ static void il4965_bg_statistics_periodic(unsigned long data) { - struct il_priv *priv = (struct il_priv *)data; + struct il_priv *il = (struct il_priv *)data; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; /* dont send host command if rf-kill is on */ - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return; - il_send_statistics_request(priv, CMD_ASYNC, false); + il_send_statistics_request(il, CMD_ASYNC, false); } -static void il4965_rx_beacon_notif(struct il_priv *priv, +static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -496,7 +496,7 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -505,38 +505,38 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, le32_to_cpu(beacon->low_tsf), rate); #endif - priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } -static void il4965_perform_ct_kill_task(struct il_priv *priv) +static void il4965_perform_ct_kill_task(struct il_priv *il) { unsigned long flags; - IL_DEBUG_POWER(priv, "Stop all queues\n"); + IL_DEBUG_POWER(il, "Stop all queues\n"); - if (priv->mac80211_registered) - ieee80211_stop_queues(priv->hw); + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); - il_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - il_read32(priv, CSR_UCODE_DRV_GP1); + il_read32(il, CSR_UCODE_DRV_GP1); - spin_lock_irqsave(&priv->reg_lock, flags); - if (!il_grab_nic_access(priv)) - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, flags); + spin_lock_irqsave(&il->reg_lock, flags); + if (!il_grab_nic_access(il)) + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, flags); } /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il4965_rx_card_state_notif(struct il_priv *priv, +static void il4965_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = priv->status; + unsigned long status = il->status; - IL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", + IL_DEBUG_RF_KILL(il, "Card state received: HW:%s SW:%s CT:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On", (flags & CT_CARD_DISABLED) ? @@ -545,37 +545,37 @@ static void il4965_rx_card_state_notif(struct il_priv *priv, if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { - il_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } if (flags & CT_CARD_DISABLED) - il4965_perform_ct_kill_task(priv); + il4965_perform_ct_kill_task(il); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); if (!(flags & RXON_CARD_DISABLED)) - il_scan_cancel(priv); + il_scan_cancel(il); if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &priv->status))) - wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->status)); + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); else - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); } /** @@ -587,55 +587,55 @@ static void il4965_rx_card_state_notif(struct il_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il4965_setup_rx_handlers(struct il_priv *priv) +static void il4965_setup_rx_handlers(struct il_priv *il) { - priv->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; - priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = il_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = il_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; + il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; - il_setup_rx_scan_handlers(priv); + il_setup_rx_scan_handlers(il); /* status change handler */ - priv->rx_handlers[CARD_STATE_NOTIFICATION] = + il->rx_handlers[CARD_STATE_NOTIFICATION] = il4965_rx_card_state_notif; - priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = + il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - priv->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; - priv->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; + il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; + il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; /* block ack */ - priv->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ - priv->cfg->ops->lib->rx_handler_setup(priv); + il->cfg->ops->lib->rx_handler_setup(il); } /** * il4965_rx_handle - Main entry function for receiving responses from uCode * - * Uses the priv->rx_handlers callback function array to invoke + * Uses the il->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -void il4965_rx_handle(struct il_priv *priv) +void il4965_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; struct il_rx_packet *pkt; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -650,7 +650,7 @@ void il4965_rx_handle(struct il_priv *priv) /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); /* calculate total frames need to be restock after handling RX */ total_empty = r - rxq->write_actual; @@ -672,8 +672,8 @@ void il4965_rx_handle(struct il_priv *priv) rxq->queue[i] = NULL; - pci_unmap_page(priv->pci_dev, rxb->page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); @@ -697,15 +697,15 @@ void il4965_rx_handle(struct il_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in * rx_handlers table. See il4965_setup_rx_handlers() */ - if (priv->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, + if (il->rx_handlers[pkt->hdr.cmd]) { + IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; - priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(priv, + IL_DEBUG_RX(il, "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -723,9 +723,9 @@ void il4965_rx_handle(struct il_priv *priv) * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - il_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(il, rxb); else - IL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(il, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -733,8 +733,8 @@ void il4965_rx_handle(struct il_priv *priv) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(priv->pci_dev, rxb->page, - 0, PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; @@ -750,7 +750,7 @@ void il4965_rx_handle(struct il_priv *priv) count++; if (count >= 8) { rxq->read = i; - il4965_rx_replenish_now(priv); + il4965_rx_replenish_now(il); count = 0; } } @@ -759,20 +759,20 @@ void il4965_rx_handle(struct il_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - il4965_rx_replenish_now(priv); + il4965_rx_replenish_now(il); else - il4965_rx_queue_restock(priv); + il4965_rx_queue_restock(il); } /* call this function to flush any scheduled tasklet */ -static inline void il4965_synchronize_irq(struct il_priv *priv) +static inline void il4965_synchronize_irq(struct il_priv *il) { /* wait to make sure we flush pending tasklet*/ - synchronize_irq(priv->pci_dev->irq); - tasklet_kill(&priv->irq_tasklet); + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); } -static void il4965_irq_tasklet(struct il_priv *priv) +static void il4965_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -782,30 +782,30 @@ static void il4965_irq_tasklet(struct il_priv *priv) u32 inta_mask; #endif - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(priv, CSR_INT); - il_write32(priv, CSR_INT, inta); + inta = il_read32(il, CSR_INT); + il_write32(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - il_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + il_write32(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & IL_DL_ISR) { + if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(priv, CSR_INT_MASK); - IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(il, CSR_INT_MASK); + IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not * atomic, make sure that inta covers all the interrupts that @@ -818,13 +818,13 @@ static void il4965_irq_tasklet(struct il_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(il, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - il_disable_interrupts(priv); + il_disable_interrupts(il); - priv->isr_stats.hw++; - il_irq_handle_error(priv); + il->isr_stats.hw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_HW_ERR; @@ -832,18 +832,18 @@ static void il4965_irq_tasklet(struct il_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { + if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(il, "Scheduler finished to transmit " "the frame/frames.\n"); - priv->isr_stats.sch++; + il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(priv, "Alive interrupt\n"); - priv->isr_stats.alive++; + IL_DEBUG_ISR(il, "Alive interrupt\n"); + il->isr_stats.alive++; } } #endif @@ -853,26 +853,26 @@ static void il4965_irq_tasklet(struct il_priv *priv) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(il_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; - IL_WARN(priv, "RF_KILL bit toggled to %s.\n", + IL_WARN(il, "RF_KILL bit toggled to %s.\n", hw_rf_kill ? "disable radio" : "enable radio"); - priv->isr_stats.rfkill++; + il->isr_stats.rfkill++; /* driver only loads ucode once setting the interface up. * the driver allows loading the ucode even if the radio * is killed. Hence update the killswitch state here. The * rfkill handler will care about restarting if needed. */ - if (!test_bit(STATUS_ALIVE, &priv->status)) { + if (!test_bit(STATUS_ALIVE, &il->status)) { if (hw_rf_kill) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rf_kill); + clear_bit(STATUS_RF_KILL_HW, &il->status); + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); } handled |= CSR_INT_BIT_RF_KILL; @@ -880,17 +880,17 @@ static void il4965_irq_tasklet(struct il_priv *priv) /* Chip got too hot and stopped itself */ if (inta & CSR_INT_BIT_CT_KILL) { - IL_ERR(priv, "Microcode CT kill error detected.\n"); - priv->isr_stats.ctkill++; + IL_ERR(il, "Microcode CT kill error detected.\n"); + il->isr_stats.ctkill++; handled |= CSR_INT_BIT_CT_KILL; } /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(priv, "Microcode SW error detected. " + IL_ERR(il, "Microcode SW error detected. " " Restarting 0x%X.\n", inta); - priv->isr_stats.sw++; - il_irq_handle_error(priv); + il->isr_stats.sw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; } @@ -900,11 +900,11 @@ static void il4965_irq_tasklet(struct il_priv *priv) * and about any Rx buffers made available while asleep. */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(priv, &priv->rxq); - for (i = 0; i < priv->hw_params.max_txq_num; i++) - il_txq_update_write_ptr(priv, &priv->txq[i]); - priv->isr_stats.wakeup++; + IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + for (i = 0; i < il->hw_params.max_txq_num; i++) + il_txq_update_write_ptr(il, &il->txq[i]); + il->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; } @@ -912,46 +912,46 @@ static void il4965_irq_tasklet(struct il_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il4965_rx_handle(priv); - priv->isr_stats.rx++; + il4965_rx_handle(il); + il->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } /* This "Tx" DMA channel is used only for loading uCode */ if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(priv, "uCode load interrupt\n"); - priv->isr_stats.tx++; + IL_DEBUG_ISR(il, "uCode load interrupt\n"); + il->isr_stats.tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ - priv->ucode_write_complete = 1; - wake_up(&priv->wait_command_queue); + il->ucode_write_complete = 1; + wake_up(&il->wait_command_queue); } if (inta & ~handled) { - IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); - priv->isr_stats.unhandled++; + IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; } - if (inta & ~(priv->inta_mask)) { - IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", - inta & ~priv->inta_mask); - IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + if (inta & ~(il->inta_mask)) { + IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &priv->status)) - il_enable_interrupts(priv); + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); /* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) - il_enable_rfkill_int(priv); + il_enable_rfkill_int(il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { - inta = il_read32(priv, CSR_INT); - inta_mask = il_read32(priv, CSR_INT_MASK); - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(priv, + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = il_read32(il, CSR_INT); + inta_mask = il_read32(il, CSR_INT_MASK); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(il, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -980,24 +980,24 @@ static void il4965_irq_tasklet(struct il_priv *priv) static ssize_t il4965_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } static ssize_t il4965_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IL_ERR(priv, "%s is not in hex or decimal form.\n", buf); + IL_ERR(il, "%s is not in hex or decimal form.\n", buf); else { - priv->debug_level = val; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -1013,12 +1013,12 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, static ssize_t il4965_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; - return sprintf(buf, "%d\n", priv->temperature); + return sprintf(buf, "%d\n", il->temperature); } static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); @@ -1026,29 +1026,29 @@ static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); static ssize_t il4965_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return sprintf(buf, "off\n"); else - return sprintf(buf, "%d\n", priv->tx_power_user_lmt); + return sprintf(buf, "%d\n", il->tx_power_user_lmt); } static ssize_t il4965_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 10, &val); if (ret) - IL_INFO(priv, "%s is not in decimal form.\n", buf); + IL_INFO(il, "%s is not in decimal form.\n", buf); else { - ret = il_set_tx_power(priv, val, false); + ret = il_set_tx_power(il, val, false); if (ret) - IL_ERR(priv, "failed setting tx power (0x%d).\n", + IL_ERR(il, "failed setting tx power (0x%d).\n", ret); else ret = count; @@ -1079,52 +1079,52 @@ static struct attribute_group il_attribute_group = { * ******************************************************************************/ -static void il4965_dealloc_ucode_pci(struct il_priv *priv) +static void il4965_dealloc_ucode_pci(struct il_priv *il) { - il_free_fw_desc(priv->pci_dev, &priv->ucode_code); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); } -static void il4965_nic_start(struct il_priv *priv) +static void il4965_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(priv, CSR_RESET, 0); + il_write32(il, CSR_RESET, 0); } static void il4965_ucode_callback(const struct firmware *ucode_raw, void *context); -static int il4965_mac_setup_register(struct il_priv *priv, +static int il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length); -static int __must_check il4965_request_firmware(struct il_priv *priv, bool first) +static int __must_check il4965_request_firmware(struct il_priv *il, bool first) { - const char *name_pre = priv->cfg->fw_name_pre; + const char *name_pre = il->cfg->fw_name_pre; char tag[8]; if (first) { - priv->fw_index = priv->cfg->ucode_api_max; - sprintf(tag, "%d", priv->fw_index); + il->fw_index = il->cfg->ucode_api_max; + sprintf(tag, "%d", il->fw_index); } else { - priv->fw_index--; - sprintf(tag, "%d", priv->fw_index); + il->fw_index--; + sprintf(tag, "%d", il->fw_index); } - if (priv->fw_index < priv->cfg->ucode_api_min) { - IL_ERR(priv, "no suitable firmware found!\n"); + if (il->fw_index < il->cfg->ucode_api_min) { + IL_ERR(il, "no suitable firmware found!\n"); return -ENOENT; } - sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); + sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n", - priv->firmware_name); + IL_DEBUG_INFO(il, "attempting to load firmware '%s'\n", + il->firmware_name); - return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, - &priv->pci_dev->dev, GFP_KERNEL, priv, + return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, + &il->pci_dev->dev, GFP_KERNEL, il, il4965_ucode_callback); } @@ -1133,7 +1133,7 @@ struct il4965_firmware_pieces { size_t inst_size, data_size, init_size, init_data_size, boot_size; }; -static int il4965_load_firmware(struct il_priv *priv, +static int il4965_load_firmware(struct il_priv *il, const struct firmware *ucode_raw, struct il4965_firmware_pieces *pieces) { @@ -1141,8 +1141,8 @@ static int il4965_load_firmware(struct il_priv *priv, u32 api_ver, hdr_size; const u8 *src; - priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(priv->ucode_ver); + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); switch (api_ver) { default: @@ -1151,7 +1151,7 @@ static int il4965_load_firmware(struct il_priv *priv, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IL_ERR(priv, "File size too small!\n"); + IL_ERR(il, "File size too small!\n"); return -EINVAL; } pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); @@ -1169,7 +1169,7 @@ static int il4965_load_firmware(struct il_priv *priv, pieces->data_size + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IL_ERR(priv, + IL_ERR(il, "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -1198,12 +1198,12 @@ static int il4965_load_firmware(struct il_priv *priv, static void il4965_ucode_callback(const struct firmware *ucode_raw, void *context) { - struct il_priv *priv = context; + struct il_priv *il = context; struct il_ucode_header *ucode; int err; struct il4965_firmware_pieces pieces; - const unsigned int api_max = priv->cfg->ucode_api_max; - const unsigned int api_min = priv->cfg->ucode_api_min; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; u32 api_ver; u32 max_probe_length = 200; @@ -1213,31 +1213,31 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { - if (priv->fw_index <= priv->cfg->ucode_api_max) - IL_ERR(priv, + if (il->fw_index <= il->cfg->ucode_api_max) + IL_ERR(il, "request for firmware file '%s' failed.\n", - priv->firmware_name); + il->firmware_name); goto try_again; } - IL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", - priv->firmware_name, ucode_raw->size); + IL_DEBUG_INFO(il, "Loaded firmware file '%s' (%zd bytes).\n", + il->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { - IL_ERR(priv, "File size way too small!\n"); + IL_ERR(il, "File size way too small!\n"); goto try_again; } /* Data from ucode file: header followed by uCode images */ ucode = (struct il_ucode_header *)ucode_raw->data; - err = il4965_load_firmware(priv, ucode_raw, &pieces); + err = il4965_load_firmware(il, ucode_raw, &pieces); if (err) goto try_again; - api_ver = IL_UCODE_API(priv->ucode_ver); + api_ver = IL_UCODE_API(il->ucode_ver); /* * api_ver should match the api version forming part of the @@ -1245,7 +1245,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(priv, + IL_ERR(il, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -1253,25 +1253,25 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) } if (api_ver != api_max) - IL_ERR(priv, + IL_ERR(il, "Firmware has old API version. Expected v%u, " "got v%u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); - snprintf(priv->hw->wiphy->fw_version, - sizeof(priv->hw->wiphy->fw_version), + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), "%u.%u.%u.%u", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); /* * For any of the failures below (before allocating pci memory) @@ -1279,46 +1279,46 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", - priv->ucode_ver); - IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); - IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %Zd\n", pieces.data_size); - IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr init inst size = %Zd\n", pieces.init_size); - IL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr init data size = %Zd\n", pieces.init_data_size); - IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > priv->hw_params.max_inst_size) { - IL_ERR(priv, "uCode instr len %Zd too large to fit in\n", + if (pieces.inst_size > il->hw_params.max_inst_size) { + IL_ERR(il, "uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } - if (pieces.data_size > priv->hw_params.max_data_size) { - IL_ERR(priv, "uCode data len %Zd too large to fit in\n", + if (pieces.data_size > il->hw_params.max_data_size) { + IL_ERR(il, "uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } - if (pieces.init_size > priv->hw_params.max_inst_size) { - IL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", + if (pieces.init_size > il->hw_params.max_inst_size) { + IL_ERR(il, "uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } - if (pieces.init_data_size > priv->hw_params.max_data_size) { - IL_ERR(priv, "uCode init data len %Zd too large to fit in\n", + if (pieces.init_data_size > il->hw_params.max_data_size) { + IL_ERR(il, "uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } - if (pieces.boot_size > priv->hw_params.max_bsm_size) { - IL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n", + if (pieces.boot_size > il->hw_params.max_bsm_size) { + IL_ERR(il, "uCode boot instr len %Zd too large to fit in\n", pieces.boot_size); goto try_again; } @@ -1328,92 +1328,92 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Runtime instructions and 2 copies of data: * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ - priv->ucode_code.len = pieces.inst_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il->ucode_code.len = pieces.inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - priv->ucode_data.len = pieces.data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il->ucode_data.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - priv->ucode_data_backup.len = pieces.data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il->ucode_data_backup.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || - !priv->ucode_data_backup.v_addr) + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - priv->ucode_init.len = pieces.init_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il->ucode_init.len = pieces.init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - priv->ucode_init_data.len = pieces.init_data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il->ucode_init_data.len = pieces.init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) goto err_pci_alloc; } /* Bootstrap (instructions only, no data) */ if (pieces.boot_size) { - priv->ucode_boot.len = pieces.boot_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il->ucode_boot.len = pieces.boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - if (!priv->ucode_boot.v_addr) + if (!il->ucode_boot.v_addr) goto err_pci_alloc; } /* Now that we can no longer fail, copy information */ - priv->sta_key_max_num = STA_KEY_MAX_NUM; + il->sta_key_max_num = STA_KEY_MAX_NUM; /* Copy images into buffers for card's bus-master reads ... */ /* Runtime instructions (first block of data in file) */ - IL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", + IL_DEBUG_INFO(il, "Copying (but not loading) uCode instr len %Zd\n", pieces.inst_size); - memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size); + memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); - IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); + IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* * Runtime data * NOTE: Copy into backup buffer will be done in il_up() */ - IL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", + IL_DEBUG_INFO(il, "Copying (but not loading) uCode data len %Zd\n", pieces.data_size); - memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size); - memcpy(priv->ucode_data_backup.v_addr, pieces.data, pieces.data_size); + memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); + memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init instr len %Zd\n", pieces.init_size); - memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size); + memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); } /* Initialization data */ if (pieces.init_data_size) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init data len %Zd\n", pieces.init_data_size); - memcpy(priv->ucode_init_data.v_addr, pieces.init_data, + memcpy(il->ucode_init_data.v_addr, pieces.init_data, pieces.init_data_size); } /* Bootstrap instructions */ - IL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", + IL_DEBUG_INFO(il, "Copying (but not loading) boot instr len %Zd\n", pieces.boot_size); - memcpy(priv->ucode_boot.v_addr, pieces.boot, pieces.boot_size); + memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); /* * figure out the offset of chain noise reset and gain commands * base on the size of standard phy calibration commands table size */ - priv->_4965.phy_calib_chain_noise_reset_cmd = + il->_4965.phy_calib_chain_noise_reset_cmd = standard_phy_calibration_size; - priv->_4965.phy_calib_chain_noise_gain_cmd = + il->_4965.phy_calib_chain_noise_gain_cmd = standard_phy_calibration_size + 1; /************************************************** @@ -1421,40 +1421,40 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * * 9. Setup and register with mac80211 and debugfs **************************************************/ - err = il4965_mac_setup_register(priv, max_probe_length); + err = il4965_mac_setup_register(il, max_probe_length); if (err) goto out_unbind; - err = il_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(priv, + IL_ERR(il, "failed to create debugfs files. Ignoring error: %d\n", err); - err = sysfs_create_group(&priv->pci_dev->dev.kobj, + err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); if (err) { - IL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(il, "failed to create sysfs device attributes\n"); goto out_unbind; } /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); - complete(&priv->_4965.firmware_loading_complete); + complete(&il->_4965.firmware_loading_complete); return; try_again: /* try next, if any */ - if (il4965_request_firmware(priv, false)) + if (il4965_request_firmware(il, false)) goto out_unbind; release_firmware(ucode_raw); return; err_pci_alloc: - IL_ERR(priv, "failed to allocate pci memory\n"); - il4965_dealloc_ucode_pci(priv); + IL_ERR(il, "failed to allocate pci memory\n"); + il4965_dealloc_ucode_pci(il); out_unbind: - complete(&priv->_4965.firmware_loading_complete); - device_release_driver(&priv->pci_dev->dev); + complete(&il->_4965.firmware_loading_complete); + device_release_driver(&il->pci_dev->dev); release_firmware(ucode_raw); } @@ -1527,79 +1527,79 @@ static const char *il4965_desc_lookup(u32 num) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il4965_dump_nic_error_log(struct il_priv *priv) +void il4965_dump_nic_error_log(struct il_priv *il) { u32 data2, line; u32 desc, time, count, base, data1; u32 blink1, blink2, ilink1, ilink2; u32 pc, hcmd; - if (priv->ucode_type == UCODE_INIT) { - base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr); + if (il->ucode_type == UCODE_INIT) { + base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); } else { - base = le32_to_cpu(priv->card_alive.error_event_table_ptr); + base = le32_to_cpu(il->card_alive.error_event_table_ptr); } - if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR(priv, + if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { + IL_ERR(il, "Not valid error log pointer 0x%08X for %s uCode\n", - base, (priv->ucode_type == UCODE_INIT) ? "Init" : "RT"); + base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; } - count = il_read_targ_mem(priv, base); + count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(priv, "Start IWL Error Log Dump:\n"); - IL_ERR(priv, "Status: 0x%08lX, count: %d\n", - priv->status, count); - } - - desc = il_read_targ_mem(priv, base + 1 * sizeof(u32)); - priv->isr_stats.err_code = desc; - pc = il_read_targ_mem(priv, base + 2 * sizeof(u32)); - blink1 = il_read_targ_mem(priv, base + 3 * sizeof(u32)); - blink2 = il_read_targ_mem(priv, base + 4 * sizeof(u32)); - ilink1 = il_read_targ_mem(priv, base + 5 * sizeof(u32)); - ilink2 = il_read_targ_mem(priv, base + 6 * sizeof(u32)); - data1 = il_read_targ_mem(priv, base + 7 * sizeof(u32)); - data2 = il_read_targ_mem(priv, base + 8 * sizeof(u32)); - line = il_read_targ_mem(priv, base + 9 * sizeof(u32)); - time = il_read_targ_mem(priv, base + 11 * sizeof(u32)); - hcmd = il_read_targ_mem(priv, base + 22 * sizeof(u32)); - - IL_ERR(priv, "Desc Time " + IL_ERR(il, "Start IWL Error Log Dump:\n"); + IL_ERR(il, "Status: 0x%08lX, count: %d\n", + il->status, count); + } + + desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); + il->isr_stats.err_code = desc; + pc = il_read_targ_mem(il, base + 2 * sizeof(u32)); + blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32)); + blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32)); + ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32)); + ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32)); + data1 = il_read_targ_mem(il, base + 7 * sizeof(u32)); + data2 = il_read_targ_mem(il, base + 8 * sizeof(u32)); + line = il_read_targ_mem(il, base + 9 * sizeof(u32)); + time = il_read_targ_mem(il, base + 11 * sizeof(u32)); + hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); + + IL_ERR(il, "Desc Time " "data1 data2 line\n"); - IL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + IL_ERR(il, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", il4965_desc_lookup(desc), desc, time, data1, data2, line); - IL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + IL_ERR(il, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR(il, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, blink2, ilink1, ilink2, hcmd); } -static void il4965_rf_kill_ct_config(struct il_priv *priv) +static void il4965_rf_kill_ct_config(struct il_priv *il) { struct il_ct_kill_config cmd; unsigned long flags; int ret = 0; - spin_lock_irqsave(&priv->lock, flags); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + spin_lock_irqsave(&il->lock, flags); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); cmd.critical_temperature_R = - cpu_to_le32(priv->hw_params.ct_kill_threshold); + cpu_to_le32(il->hw_params.ct_kill_threshold); - ret = il_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, + ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, sizeof(cmd), &cmd); if (ret) - IL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR(il, "REPLY_CT_KILL_CONFIG_CMD failed\n"); else - IL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " + IL_DEBUG_INFO(il, "REPLY_CT_KILL_CONFIG_CMD " "succeeded, " "critical temperature is %d\n", - priv->hw_params.ct_kill_threshold); + il->hw_params.ct_kill_threshold); } static const s8 default_queue_to_tx_fifo[] = { @@ -1612,62 +1612,62 @@ static const s8 default_queue_to_tx_fifo[] = { IL_TX_FIFO_UNUSED, }; -static int il4965_alive_notify(struct il_priv *priv) +static int il4965_alive_notify(struct il_priv *il) { u32 a; unsigned long flags; int i, chan; u32 reg_val; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - priv->scd_base_addr = il_read_prph(priv, + il->scd_base_addr = il_read_prph(il, IWL49_SCD_SRAM_BASE_ADDR); - a = priv->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; - for (; a < priv->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) - il_write_targ_mem(priv, a, 0); - for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) - il_write_targ_mem(priv, a, 0); - for (; a < priv->scd_base_addr + - IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4) - il_write_targ_mem(priv, a, 0); + a = il->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; + for (; a < il->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, - priv->scd_bc_tbls.dma >> 10); + il_write_prph(il, IWL49_SCD_DRAM_BASE_ADDR, + il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_write_direct32(priv, + il_write_direct32(il, FH_TCSR_CHNL_TX_CONFIG_REG(chan), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = il_read_direct32(priv, FH_TX_CHICKEN_BITS_REG); - il_write_direct32(priv, FH_TX_CHICKEN_BITS_REG, + reg_val = il_read_direct32(il, FH_TX_CHICKEN_BITS_REG); + il_write_direct32(il, FH_TX_CHICKEN_BITS_REG, reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - il_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_write_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ - for (i = 0; i < priv->hw_params.max_txq_num; i++) { + for (i = 0; i < il->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(i), 0); - il_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); + il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_write_direct32(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ - il_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(il, il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ - il_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(il, il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i) + sizeof(u32), (SCD_FRAME_LIMIT << @@ -1675,36 +1675,36 @@ static int il4965_alive_notify(struct il_priv *priv) IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - il_write_prph(priv, IWL49_SCD_INTERRUPT_MASK, - (1 << priv->hw_params.max_txq_num) - 1); + il_write_prph(il, IWL49_SCD_INTERRUPT_MASK, + (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ - il4965_txq_set_sched(priv, IL_MASK(0, 6)); + il4965_txq_set_sched(il, IL_MASK(0, 6)); - il4965_set_wr_ptrs(priv, IL_DEFAULT_CMD_QUEUE_NUM, 0); + il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0); /* make sure all queue are not stopped */ - memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped)); + memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); for (i = 0; i < 4; i++) - atomic_set(&priv->queue_stop_count[i], 0); + atomic_set(&il->queue_stop_count[i], 0); /* reset to 0 to enable all the queue first */ - priv->txq_ctx_active_msk = 0; + il->txq_ctx_active_msk = 0; /* Map each Tx/cmd queue to its corresponding fifo */ BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { int ac = default_queue_to_tx_fifo[i]; - il_txq_ctx_activate(priv, i); + il_txq_ctx_activate(il, i); if (ac == IL_TX_FIFO_UNUSED) continue; - il4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); + il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return 0; } @@ -1714,50 +1714,50 @@ static int il4965_alive_notify(struct il_priv *priv) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il_init_alive_start()). */ -static void il4965_alive_start(struct il_priv *priv) +static void il4965_alive_start(struct il_priv *il) { int ret = 0; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); - if (priv->card_alive.is_valid != UCODE_VALID_OK) { + if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(il, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(priv)) { + if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); goto restart; } - ret = il4965_alive_notify(priv); + ret = il4965_alive_notify(il); if (ret) { - IL_WARN(priv, + IL_WARN(il, "Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } /* After the ALIVE response, we can send host commands to the uCode */ - set_bit(STATUS_ALIVE, &priv->status); + set_bit(STATUS_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(priv); + il_setup_watchdog(il); - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) return; - ieee80211_wake_queues(priv->hw); + ieee80211_wake_queues(il->hw); - priv->active_rate = IL_RATES_MASK; + il->active_rate = IL_RATES_MASK; if (il_is_associated_ctx(ctx)) { struct il_rxon_cmd *active_rxon = @@ -1768,290 +1768,290 @@ static void il4965_alive_start(struct il_priv *priv) } else { struct il_rxon_context *tmp; /* Initialize our rx_config data */ - for_each_context(priv, tmp) - il_connection_init_rx_config(priv, tmp); + for_each_context(il, tmp) + il_connection_init_rx_config(il, tmp); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); } /* Configure bluetooth coexistence if enabled */ - il_send_bt_config(priv); + il_send_bt_config(il); - il4965_reset_run_time_calib(priv); + il4965_reset_run_time_calib(il); - set_bit(STATUS_READY, &priv->status); + set_bit(STATUS_READY, &il->status); /* Configure the adapter for unassociated operation */ - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); /* At this point, the NIC is initialized and operational */ - il4965_rf_kill_ct_config(priv); + il4965_rf_kill_ct_config(il); - IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); - wake_up(&priv->wait_command_queue); + IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); - il_power_update_mode(priv, true); - IL_DEBUG_INFO(priv, "Updated power mode\n"); + il_power_update_mode(il, true); + IL_DEBUG_INFO(il, "Updated power mode\n"); return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } -static void il4965_cancel_deferred_work(struct il_priv *priv); +static void il4965_cancel_deferred_work(struct il_priv *il); -static void __il4965_down(struct il_priv *priv) +static void __il4965_down(struct il_priv *il) { unsigned long flags; int exit_pending; - IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set * to prevent rearm timer */ - del_timer_sync(&priv->watchdog); + del_timer_sync(&il->watchdog); - il_clear_ucode_stations(priv, NULL); - il_dealloc_bcast_stations(priv); - il_clear_driver_stations(priv); + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); /* Unblock any waiting calls */ - wake_up_all(&priv->wait_command_queue); + wake_up_all(&il->wait_command_queue); /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &priv->status); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); - il4965_synchronize_irq(priv); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il4965_synchronize_irq(il); - if (priv->mac80211_registered) - ieee80211_stop_queues(priv->hw); + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ - if (!il_is_init(priv)) { - priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) << + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &priv->status) << + test_bit(STATUS_FW_ERROR, &il->status) << STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; - il4965_txq_ctx_stop(priv); - il4965_rxq_stop(priv); + il4965_txq_ctx_stop(il); + il4965_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Make sure (redundant) we've released our request to stay awake */ - il_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ - il_apm_stop(priv); + il_apm_stop(il); exit: - memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - dev_kfree_skb(priv->beacon_skb); - priv->beacon_skb = NULL; + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; /* clear out any free frames */ - il4965_clear_free_frames(priv); + il4965_clear_free_frames(il); } -static void il4965_down(struct il_priv *priv) +static void il4965_down(struct il_priv *il) { - mutex_lock(&priv->mutex); - __il4965_down(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + __il4965_down(il); + mutex_unlock(&il->mutex); - il4965_cancel_deferred_work(priv); + il4965_cancel_deferred_work(il); } #define HW_READY_TIMEOUT (50) -static int il4965_set_hw_ready(struct il_priv *priv) +static int il4965_set_hw_ready(struct il_priv *il) { int ret = 0; - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); if (ret != -ETIMEDOUT) - priv->hw_ready = true; + il->hw_ready = true; else - priv->hw_ready = false; + il->hw_ready = false; - IL_DEBUG_INFO(priv, "hardware %s\n", - (priv->hw_ready == 1) ? "ready" : "not ready"); + IL_DEBUG_INFO(il, "hardware %s\n", + (il->hw_ready == 1) ? "ready" : "not ready"); return ret; } -static int il4965_prepare_card_hw(struct il_priv *priv) +static int il4965_prepare_card_hw(struct il_priv *il) { int ret = 0; - IL_DEBUG_INFO(priv, "il4965_prepare_card_hw enter\n"); + IL_DEBUG_INFO(il, "il4965_prepare_card_hw enter\n"); - ret = il4965_set_hw_ready(priv); - if (priv->hw_ready) + ret = il4965_set_hw_ready(il); + if (il->hw_ready) return ret; /* If HW is not ready, prepare the conditions to check again */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); /* HW should be ready by now, check again. */ if (ret != -ETIMEDOUT) - il4965_set_hw_ready(priv); + il4965_set_hw_ready(il); return ret; } #define MAX_HW_RESTARTS 5 -static int __il4965_up(struct il_priv *priv) +static int __il4965_up(struct il_priv *il) { struct il_rxon_context *ctx; int i; int ret; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN(il, "Exit pending; will not bring the NIC up\n"); return -EIO; } - if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IL_ERR(priv, "ucode not available for device bringup\n"); + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR(il, "ucode not available for device bringup\n"); return -EIO; } - for_each_context(priv, ctx) { - ret = il4965_alloc_bcast_station(priv, ctx); + for_each_context(il, ctx) { + ret = il4965_alloc_bcast_station(il, ctx); if (ret) { - il_dealloc_bcast_stations(priv); + il_dealloc_bcast_stations(il); return ret; } } - il4965_prepare_card_hw(priv); + il4965_prepare_card_hw(il); - if (!priv->hw_ready) { - IL_WARN(priv, "Exit HW not ready\n"); + if (!il->hw_ready) { + IL_WARN(il, "Exit HW not ready\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(priv, + if (il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); - if (il_is_rfkill(priv)) { - wiphy_rfkill_set_hw_state(priv->hw->wiphy, true); + if (il_is_rfkill(il)) { + wiphy_rfkill_set_hw_state(il->hw->wiphy, true); - il_enable_interrupts(priv); - IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + il_enable_interrupts(il); + IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); return 0; } - il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(il, CSR_INT, 0xFFFFFFFF); /* must be initialised before il_hw_nic_init */ - priv->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; + il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; - ret = il4965_hw_nic_init(priv); + ret = il4965_hw_nic_init(il); if (ret) { - IL_ERR(priv, "Unable to init nic\n"); + IL_ERR(il, "Unable to init nic\n"); return ret; } /* make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(priv, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(priv); + il_write32(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's * data SRAM for a clean start when the runtime program first loads. */ - memcpy(priv->ucode_data_backup.v_addr, priv->ucode_data.v_addr, - priv->ucode_data.len); + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); for (i = 0; i < MAX_HW_RESTARTS; i++) { /* load bootstrap state machine, * load bootstrap program into processor's memory, * prepare to load the "initialize" uCode */ - ret = priv->cfg->ops->lib->load_ucode(priv); + ret = il->cfg->ops->lib->load_ucode(il); if (ret) { - IL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", + IL_ERR(il, "Unable to set up bootstrap uCode: %d\n", ret); continue; } /* start card; "initialize" will load runtime ucode */ - il4965_nic_start(priv); + il4965_nic_start(il); - IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); return 0; } - set_bit(STATUS_EXIT_PENDING, &priv->status); - __il4965_down(priv); - clear_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); + __il4965_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2064,100 +2064,100 @@ static int __il4965_up(struct il_priv *priv) static void il4965_bg_init_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - priv->cfg->ops->lib->init_alive_start(priv); + il->cfg->ops->lib->init_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il4965_bg_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il4965_alive_start(priv); + il4965_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il4965_bg_run_time_calib_work(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, + struct il_priv *il = container_of(work, struct il_priv, run_time_calib_work); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status) || - test_bit(STATUS_SCANNING, &priv->status)) { - mutex_unlock(&priv->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) { + mutex_unlock(&il->mutex); return; } - if (priv->start_calib) { - il4965_chain_noise_calibration(priv, - (void *)&priv->_4965.statistics); - il4965_sensitivity_calibration(priv, - (void *)&priv->_4965.statistics); + if (il->start_calib) { + il4965_chain_noise_calibration(il, + (void *)&il->_4965.statistics); + il4965_sensitivity_calibration(il, + (void *)&il->_4965.statistics); } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il4965_bg_restart(struct work_struct *data) { - struct il_priv *priv = container_of(data, struct il_priv, restart); + struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { struct il_rxon_context *ctx; - mutex_lock(&priv->mutex); - for_each_context(priv, ctx) + mutex_lock(&il->mutex); + for_each_context(il, ctx) ctx->vif = NULL; - priv->is_open = 0; + il->is_open = 0; - __il4965_down(priv); + __il4965_down(il); - mutex_unlock(&priv->mutex); - il4965_cancel_deferred_work(priv); - ieee80211_restart_hw(priv->hw); + mutex_unlock(&il->mutex); + il4965_cancel_deferred_work(il); + ieee80211_restart_hw(il->hw); } else { - il4965_down(priv); + il4965_down(il); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); return; } - __il4965_up(priv); - mutex_unlock(&priv->mutex); + __il4965_up(il); + mutex_unlock(&il->mutex); } } static void il4965_bg_rx_replenish(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - mutex_lock(&priv->mutex); - il4965_rx_replenish(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il4965_rx_replenish(il); + mutex_unlock(&il->mutex); } /***************************************************************************** @@ -2172,11 +2172,11 @@ static void il4965_bg_rx_replenish(struct work_struct *data) * Not a mac80211 entry point function, but it fits in with all the * other mac80211 functions grouped here. */ -static int il4965_mac_setup_register(struct il_priv *priv, +static int il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length) { int ret; - struct ieee80211_hw *hw = priv->hw; + struct ieee80211_hw *hw = il->hw; struct il_rxon_context *ctx; hw->rate_control_algorithm = "iwl-4965-rs"; @@ -2188,14 +2188,14 @@ static int il4965_mac_setup_register(struct il_priv *priv, IEEE80211_HW_SPECTRUM_MGMT | IEEE80211_HW_REPORTS_TX_ACK_STATUS; - if (priv->cfg->sku & IL_SKU_N) + if (il->cfg->sku & IL_SKU_N) hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_SUPPORTS_STATIC_SMPS; hw->sta_data_size = sizeof(struct il_station_priv); hw->vif_data_size = sizeof(struct il_vif_priv); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { hw->wiphy->interface_modes |= ctx->interface_modes; hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; } @@ -2218,21 +2218,21 @@ static int il4965_mac_setup_register(struct il_priv *priv, hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; - if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &priv->bands[IEEE80211_BAND_2GHZ]; - if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &priv->bands[IEEE80211_BAND_5GHZ]; + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; - il_leds_init(priv); + il_leds_init(il); - ret = ieee80211_register_hw(priv->hw); + ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(il, "Failed to register hw (error %d)\n", ret); return ret; } - priv->mac80211_registered = 1; + il->mac80211_registered = 1; return 0; } @@ -2240,81 +2240,81 @@ static int il4965_mac_setup_register(struct il_priv *priv, int il4965_mac_start(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); /* we should be verifying the device is ready to be opened */ - mutex_lock(&priv->mutex); - ret = __il4965_up(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + ret = __il4965_up(il); + mutex_unlock(&il->mutex); if (ret) return ret; - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) goto out; - IL_DEBUG_INFO(priv, "Start UP work done.\n"); + IL_DEBUG_INFO(il, "Start UP work done.\n"); /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ - ret = wait_event_timeout(priv->wait_command_queue, - test_bit(STATUS_READY, &priv->status), + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &priv->status)) { - IL_ERR(priv, "START_ALIVE timeout after %dms.\n", + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR(il, "START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; } } - il4965_led_enable(priv); + il4965_led_enable(il); out: - priv->is_open = 1; - IL_DEBUG_MAC80211(priv, "leave\n"); + il->is_open = 1; + IL_DEBUG_MAC80211(il, "leave\n"); return 0; } void il4965_mac_stop(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (!priv->is_open) + if (!il->is_open) return; - priv->is_open = 0; + il->is_open = 0; - il4965_down(priv); + il4965_down(il); - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* User space software may expect getting rfkill changes * even if interface is down */ - il_write32(priv, CSR_INT, 0xFFFFFFFF); - il_enable_rfkill_int(priv); + il_write32(il, CSR_INT, 0xFFFFFFFF); + il_enable_rfkill_int(il); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MACDUMP(priv, "enter\n"); + IL_DEBUG_MACDUMP(il, "enter\n"); - IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (il4965_tx_skb(priv, skb)) + if (il4965_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MACDUMP(priv, "leave\n"); + IL_DEBUG_MACDUMP(il, "leave\n"); } void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, @@ -2323,41 +2323,41 @@ void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - il4965_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, + il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, iv32, phase1key); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; struct il_rxon_context *ctx = vif_priv->ctx; int ret; u8 sta_id; bool is_default_wep_key = false; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (priv->cfg->mod_params->sw_crypto) { - IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + if (il->cfg->mod_params->sw_crypto) { + IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } - sta_id = il_sta_id_or_broadcast(priv, vif_priv->ctx, sta); + sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; - mutex_lock(&priv->mutex); - il_scan_cancel_timeout(priv, 100); + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); /* * If we are getting WEP group key and we didn't receive any key mapping @@ -2378,29 +2378,29 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (cmd) { case SET_KEY: if (is_default_wep_key) - ret = il4965_set_default_wep_key(priv, + ret = il4965_set_default_wep_key(il, vif_priv->ctx, key); else - ret = il4965_set_dynamic_key(priv, vif_priv->ctx, + ret = il4965_set_dynamic_key(il, vif_priv->ctx, key, sta_id); - IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (is_default_wep_key) - ret = il4965_remove_default_wep_key(priv, ctx, key); + ret = il4965_remove_default_wep_key(il, ctx, key); else - ret = il4965_remove_dynamic_key(priv, ctx, + ret = il4965_remove_dynamic_key(il, ctx, key, sta_id); - IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } - mutex_unlock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + mutex_unlock(&il->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); return ret; } @@ -2411,43 +2411,43 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret = -EINVAL; - IL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", + IL_DEBUG_HT(il, "A-MPDU action on addr %pM tid %d\n", sta->addr, tid); - if (!(priv->cfg->sku & IL_SKU_N)) + if (!(il->cfg->sku & IL_SKU_N)) return -EACCES; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); switch (action) { case IEEE80211_AMPDU_RX_START: - IL_DEBUG_HT(priv, "start Rx\n"); - ret = il4965_sta_rx_agg_start(priv, sta, tid, *ssn); + IL_DEBUG_HT(il, "start Rx\n"); + ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); break; case IEEE80211_AMPDU_RX_STOP: - IL_DEBUG_HT(priv, "stop Rx\n"); - ret = il4965_sta_rx_agg_stop(priv, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + IL_DEBUG_HT(il, "stop Rx\n"); + ret = il4965_sta_rx_agg_stop(il, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: - IL_DEBUG_HT(priv, "start Tx\n"); - ret = il4965_tx_agg_start(priv, vif, sta, tid, ssn); + IL_DEBUG_HT(il, "start Tx\n"); + ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); break; case IEEE80211_AMPDU_TX_STOP: - IL_DEBUG_HT(priv, "stop Tx\n"); - ret = il4965_tx_agg_stop(priv, vif, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + IL_DEBUG_HT(il, "stop Tx\n"); + ret = il4965_tx_agg_stop(il, vif, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_OPERATIONAL: ret = 0; break; } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } @@ -2456,39 +2456,39 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; bool is_ap = vif->type == NL80211_IFTYPE_STATION; int ret; u8 sta_id; - IL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(il, "received request to add station %pM\n", sta->addr); - mutex_lock(&priv->mutex); - IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + mutex_lock(&il->mutex); + IL_DEBUG_INFO(il, "proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; atomic_set(&sta_priv->pending_frames, 0); - ret = il_add_station_common(priv, vif_priv->ctx, sta->addr, + ret = il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(il, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", sta->addr); - il4965_rs_rate_init(priv, sta, sta_id); - mutex_unlock(&priv->mutex); + il4965_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); return 0; } @@ -2496,46 +2496,46 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = ch_switch->channel; - struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u16 ch; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) goto out; - if (test_bit(STATUS_EXIT_PENDING, &priv->status) || - test_bit(STATUS_SCANNING, &priv->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status) || + test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) goto out; if (!il_is_associated_ctx(ctx)) goto out; - if (!priv->cfg->ops->lib->set_channel_switch) + if (!il->cfg->ops->lib->set_channel_switch) goto out; ch = channel->hw_value; if (le16_to_cpu(ctx->active.channel) == ch) goto out; - ch_info = il_get_channel_info(priv, channel->band, ch); + ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(priv, "invalid channel\n"); + IL_DEBUG_MAC80211(il, "invalid channel\n"); goto out; } - spin_lock_irq(&priv->lock); + spin_lock_irq(&il->lock); - priv->current_ht_config.smps = conf->smps_mode; + il->current_ht_config.smps = conf->smps_mode; /* Configure HT40 channels */ ctx->ht.enabled = conf_is_ht(conf); @@ -2559,28 +2559,28 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - il_set_rxon_channel(priv, channel, ctx); - il_set_rxon_ht(priv, ht_conf); - il_set_flags_for_band(priv, ctx, channel->band, ctx->vif); + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); - spin_unlock_irq(&priv->lock); + spin_unlock_irq(&il->lock); - il_set_rate(priv); + il_set_rate(il); /* * at this point, staging_rxon has the * configuration for channel switch */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); - priv->switch_channel = cpu_to_le16(ch); - if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); - priv->switch_channel = 0; + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = cpu_to_le16(ch); + if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = 0; ieee80211_chswitch_done(ctx->vif, false); } out: - mutex_unlock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + mutex_unlock(&il->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); } void il4965_configure_filter(struct ieee80211_hw *hw, @@ -2588,7 +2588,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int *total_flags, u64 multicast) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; struct il_rxon_context *ctx; @@ -2599,7 +2599,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -2609,9 +2609,9 @@ void il4965_configure_filter(struct ieee80211_hw *hw, #undef CHK - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { ctx->staging.filter_flags &= ~filter_nand; ctx->staging.filter_flags |= filter_or; @@ -2621,7 +2621,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, */ } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); /* * Receiving all multicast frames is always enabled by the @@ -2641,72 +2641,72 @@ void il4965_configure_filter(struct ieee80211_hw *hw, static void il4965_bg_txpower_work(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, + struct il_priv *il = container_of(work, struct il_priv, txpower_work); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); /* If a scan happened to start before we got here * then just return; the statistics notification will * kick off another scheduled work to compensate for * any temperature delta we missed here. */ - if (test_bit(STATUS_EXIT_PENDING, &priv->status) || - test_bit(STATUS_SCANNING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) goto out; /* Regardless of if we are associated, we must reconfigure the * TX power since frames can be sent on non-radar channels while * not associated */ - priv->cfg->ops->lib->send_tx_power(priv); + il->cfg->ops->lib->send_tx_power(il); /* Update last_temperature to keep is_calib_needed from running * when it isn't needed... */ - priv->last_temperature = priv->temperature; + il->last_temperature = il->temperature; out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } -static void il4965_setup_deferred_work(struct il_priv *priv) +static void il4965_setup_deferred_work(struct il_priv *il) { - priv->workqueue = create_singlethread_workqueue(DRV_NAME); + il->workqueue = create_singlethread_workqueue(DRV_NAME); - init_waitqueue_head(&priv->wait_command_queue); + init_waitqueue_head(&il->wait_command_queue); - INIT_WORK(&priv->restart, il4965_bg_restart); - INIT_WORK(&priv->rx_replenish, il4965_bg_rx_replenish); - INIT_WORK(&priv->run_time_calib_work, il4965_bg_run_time_calib_work); - INIT_DELAYED_WORK(&priv->init_alive_start, il4965_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, il4965_bg_alive_start); + INIT_WORK(&il->restart, il4965_bg_restart); + INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); + INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); + INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); - il_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(il); - INIT_WORK(&priv->txpower_work, il4965_bg_txpower_work); + INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); - init_timer(&priv->statistics_periodic); - priv->statistics_periodic.data = (unsigned long)priv; - priv->statistics_periodic.function = il4965_bg_statistics_periodic; + init_timer(&il->statistics_periodic); + il->statistics_periodic.data = (unsigned long)il; + il->statistics_periodic.function = il4965_bg_statistics_periodic; - init_timer(&priv->watchdog); - priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = il_bg_watchdog; + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; - tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - il4965_irq_tasklet, (unsigned long)priv); + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il4965_irq_tasklet, (unsigned long)il); } -static void il4965_cancel_deferred_work(struct il_priv *priv) +static void il4965_cancel_deferred_work(struct il_priv *il) { - cancel_work_sync(&priv->txpower_work); - cancel_delayed_work_sync(&priv->init_alive_start); - cancel_delayed_work(&priv->alive_start); - cancel_work_sync(&priv->run_time_calib_work); + cancel_work_sync(&il->txpower_work); + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); + cancel_work_sync(&il->run_time_calib_work); - il_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(il); - del_timer_sync(&priv->statistics_periodic); + del_timer_sync(&il->statistics_periodic); } -static void il4965_init_hw_rates(struct il_priv *priv, +static void il4965_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; @@ -2727,26 +2727,26 @@ static void il4965_init_hw_rates(struct il_priv *priv, } } /* - * Acquire priv->lock before calling this function ! + * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index) +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { - il_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } -void il4965_tx_queue_set_status(struct il_priv *priv, +void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, int tx_fifo_id, int scd_retry) { int txq_id = txq->q.id; /* Find out whether to activate Tx queue */ - int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0; + int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - il_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), + il_write_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | @@ -2755,94 +2755,94 @@ void il4965_tx_queue_set_status(struct il_priv *priv, txq->sched_retry = scd_retry; - IL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n", + IL_DEBUG_INFO(il, "%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } -static int il4965_init_drv(struct il_priv *priv) +static int il4965_init_drv(struct il_priv *il) { int ret; - spin_lock_init(&priv->sta_lock); - spin_lock_init(&priv->hcmd_lock); + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); - INIT_LIST_HEAD(&priv->free_frames); + INIT_LIST_HEAD(&il->free_frames); - mutex_init(&priv->mutex); + mutex_init(&il->mutex); - priv->ieee_channels = NULL; - priv->ieee_rates = NULL; - priv->band = IEEE80211_BAND_2GHZ; + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; - priv->iw_mode = NL80211_IFTYPE_STATION; - priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; - priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + il->iw_mode = NL80211_IFTYPE_STATION; + il->current_ht_config.smps = IEEE80211_SMPS_STATIC; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; /* Choose which receivers/antennas to use */ - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, + &il->contexts[IL_RXON_CTX_BSS]); - il_init_scan_params(priv); + il_init_scan_params(il); - ret = il_init_channel_map(priv); + ret = il_init_channel_map(il); if (ret) { - IL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(il, "initializing regulatory failed: %d\n", ret); goto err; } - ret = il_init_geos(priv); + ret = il_init_geos(il); if (ret) { - IL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(il, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - il4965_init_hw_rates(priv, priv->ieee_rates); + il4965_init_hw_rates(il, il->ieee_rates); return 0; err_free_channel_map: - il_free_channel_map(priv); + il_free_channel_map(il); err: return ret; } -static void il4965_uninit_drv(struct il_priv *priv) +static void il4965_uninit_drv(struct il_priv *il) { - il4965_calib_free_results(priv); - il_free_geos(priv); - il_free_channel_map(priv); - kfree(priv->scan_cmd); + il4965_calib_free_results(il); + il_free_geos(il); + il_free_channel_map(il); + kfree(il->scan_cmd); } -static void il4965_hw_detect(struct il_priv *priv) +static void il4965_hw_detect(struct il_priv *il) { - priv->hw_rev = _il_read32(priv, CSR_HW_REV); - priv->hw_wa_rev = _il_read32(priv, CSR_HW_REV_WA_REG); - priv->rev_id = priv->pci_dev->revision; - IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", priv->rev_id); + il->hw_rev = _il_read32(il, CSR_HW_REV); + il->hw_wa_rev = _il_read32(il, CSR_HW_REV_WA_REG); + il->rev_id = il->pci_dev->revision; + IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", il->rev_id); } -static int il4965_set_hw_params(struct il_priv *priv) +static int il4965_set_hw_params(struct il_priv *il) { - priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; - priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - if (priv->cfg->mod_params->amsdu_size_8K) - priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + if (il->cfg->mod_params->amsdu_size_8K) + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); else - priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); - priv->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; - if (priv->cfg->mod_params->disable_11n) - priv->cfg->sku &= ~IL_SKU_N; + if (il->cfg->mod_params->disable_11n) + il->cfg->sku &= ~IL_SKU_N; /* Device-specific setup */ - return priv->cfg->ops->lib->set_hw_params(priv); + return il->cfg->ops->lib->set_hw_params(il); } static const u8 il4965_bss_ac_to_fifo[] = { @@ -2860,7 +2860,7 @@ static int il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct il_priv *priv; + struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); unsigned long flags; @@ -2875,49 +2875,49 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = -ENOMEM; goto out; } - priv = hw->priv; - /* At this point both hw and priv are allocated. */ + il = hw->priv; + /* At this point both hw and il are allocated. */ /* * The default context is always valid, * more may be discovered when firmware * is loaded. */ - priv->valid_contexts = BIT(IL_RXON_CTX_BSS); + il->valid_contexts = BIT(IL_RXON_CTX_BSS); for (i = 0; i < NUM_IL_RXON_CTX; i++) - priv->contexts[i].ctxid = i; - - priv->contexts[IL_RXON_CTX_BSS].always_active = true; - priv->contexts[IL_RXON_CTX_BSS].is_active = true; - priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; - priv->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; - priv->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = + il->contexts[i].ctxid = i; + + il->contexts[IL_RXON_CTX_BSS].always_active = true; + il->contexts[IL_RXON_CTX_BSS].is_active = true; + il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + il->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; + il->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; + il->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IL_RXON_CTX_BSS].interface_modes = + il->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION); - priv->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; - priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; + il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; BUILD_BUG_ON(NUM_IL_RXON_CTX != 1); SET_IEEE80211_DEV(hw, &pdev->dev); - IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); - priv->cfg = cfg; - priv->pci_dev = pdev; - priv->inta_mask = CSR_INI_SET_MASK; + IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); /************************** * 2. Initializing PCI bus @@ -2942,7 +2942,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { - IL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(il, "No suitable DMA available.\n"); goto out_pci_disable_device; } } @@ -2951,46 +2951,46 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) goto out_pci_disable_device; - pci_set_drvdata(pdev, priv); + pci_set_drvdata(pdev, il); /*********************** * 3. Read REV register ***********************/ - priv->hw_base = pci_iomap(pdev, 0, 0); - if (!priv->hw_base) { + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { err = -ENODEV; goto out_pci_release_regions; } - IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now */ - spin_lock_init(&priv->reg_lock); - spin_lock_init(&priv->lock); + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); /* * stop and reset the on-board processor just in case it is in a * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - il4965_hw_detect(priv); - IL_INFO(priv, "Detected %s, REV=0x%X\n", - priv->cfg->name, priv->hw_rev); + il4965_hw_detect(il); + IL_INFO(il, "Detected %s, REV=0x%X\n", + il->cfg->name, il->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - il4965_prepare_card_hw(priv); - if (!priv->hw_ready) { - IL_WARN(priv, "Failed, HW not ready\n"); + il4965_prepare_card_hw(il); + if (!il->hw_ready) { + IL_WARN(il, "Failed, HW not ready\n"); goto out_iounmap; } @@ -2998,12 +2998,12 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 4. Read EEPROM *****************/ /* Read the EEPROM */ - err = il_eeprom_init(priv); + err = il_eeprom_init(il); if (err) { - IL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(il, "Unable to init EEPROM\n"); goto out_iounmap; } - err = il4965_eeprom_check_version(priv); + err = il4965_eeprom_check_version(il); if (err) goto out_free_eeprom; @@ -3011,131 +3011,131 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_free_eeprom; /* extract MAC Address */ - il4965_eeprom_get_mac(priv, priv->addresses[0].addr); - IL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); - priv->hw->wiphy->addresses = priv->addresses; - priv->hw->wiphy->n_addresses = 1; + il4965_eeprom_get_mac(il, il->addresses[0].addr); + IL_DEBUG_INFO(il, "MAC address: %pM\n", il->addresses[0].addr); + il->hw->wiphy->addresses = il->addresses; + il->hw->wiphy->n_addresses = 1; /************************ * 5. Setup HW constants ************************/ - if (il4965_set_hw_params(priv)) { - IL_ERR(priv, "failed to set hw parameters\n"); + if (il4965_set_hw_params(il)) { + IL_ERR(il, "failed to set hw parameters\n"); goto out_free_eeprom; } /******************* - * 6. Setup priv + * 6. Setup il *******************/ - err = il4965_init_drv(priv); + err = il4965_init_drv(il); if (err) goto out_free_eeprom; - /* At this point both hw and priv are initialized. */ + /* At this point both hw and il are initialized. */ /******************** * 7. Setup services ********************/ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - pci_enable_msi(priv->pci_dev); + pci_enable_msi(il->pci_dev); - err = request_irq(priv->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, priv); + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } - il4965_setup_deferred_work(priv); - il4965_setup_rx_handlers(priv); + il4965_setup_deferred_work(il); + il4965_setup_rx_handlers(il); /********************************************* * 8. Enable interrupts and read RFKILL state *********************************************/ /* enable rfkill interrupt: hw bug w/a */ - pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd); + pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); + pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); } - il_enable_rfkill_int(priv); + il_enable_rfkill_int(il); /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(priv, CSR_GP_CNTRL) & + if (il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->status)); + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); - il_power_initialize(priv); + il_power_initialize(il); - init_completion(&priv->_4965.firmware_loading_complete); + init_completion(&il->_4965.firmware_loading_complete); - err = il4965_request_firmware(priv, true); + err = il4965_request_firmware(il, true); if (err) goto out_destroy_workqueue; return 0; out_destroy_workqueue: - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; - free_irq(priv->pci_dev->irq, priv); + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + free_irq(il->pci_dev->irq, il); out_disable_msi: - pci_disable_msi(priv->pci_dev); - il4965_uninit_drv(priv); + pci_disable_msi(il->pci_dev); + il4965_uninit_drv(il); out_free_eeprom: - il_eeprom_free(priv); + il_eeprom_free(il); out_iounmap: - pci_iounmap(pdev, priv->hw_base); + pci_iounmap(pdev, il->hw_base); out_pci_release_regions: pci_set_drvdata(pdev, NULL); pci_release_regions(pdev); out_pci_disable_device: pci_disable_device(pdev); out_ieee80211_free_hw: - il_free_traffic_mem(priv); - ieee80211_free_hw(priv->hw); + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); out: return err; } static void __devexit il4965_pci_remove(struct pci_dev *pdev) { - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; - if (!priv) + if (!il) return; - wait_for_completion(&priv->_4965.firmware_loading_complete); + wait_for_completion(&il->_4965.firmware_loading_complete); - IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); - il_dbgfs_unregister(priv); + il_dbgfs_unregister(il); sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); /* ieee80211_unregister_hw call wil cause il_mac_stop to * to be called and il4965_down since we are removing the device * we need to set STATUS_EXIT_PENDING bit. */ - set_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); - il_leds_exit(priv); + il_leds_exit(il); - if (priv->mac80211_registered) { - ieee80211_unregister_hw(priv->hw); - priv->mac80211_registered = 0; + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; } else { - il4965_down(priv); + il4965_down(il); } /* @@ -3145,57 +3145,57 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) * paths to avoid running il4965_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - il_apm_stop(priv); + il_apm_stop(il); /* make sure we flush any pending irq or * tasklet for the driver */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - il4965_synchronize_irq(priv); + il4965_synchronize_irq(il); - il4965_dealloc_ucode_pci(priv); + il4965_dealloc_ucode_pci(il); - if (priv->rxq.bd) - il4965_rx_queue_free(priv, &priv->rxq); - il4965_hw_txq_ctx_free(priv); + if (il->rxq.bd) + il4965_rx_queue_free(il, &il->rxq); + il4965_hw_txq_ctx_free(il); - il_eeprom_free(priv); + il_eeprom_free(il); /*netif_stop_queue(dev); */ - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* ieee80211_unregister_hw calls il_mac_stop, which flushes - * priv->workqueue... so we can't take down the workqueue + * il->workqueue... so we can't take down the workqueue * until now... */ - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; - il_free_traffic_mem(priv); + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); - free_irq(priv->pci_dev->irq, priv); - pci_disable_msi(priv->pci_dev); - pci_iounmap(pdev, priv->hw_base); + free_irq(il->pci_dev->irq, il); + pci_disable_msi(il->pci_dev); + pci_iounmap(pdev, il->hw_base); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - il4965_uninit_drv(priv); + il4965_uninit_drv(il); - dev_kfree_skb(priv->beacon_skb); + dev_kfree_skb(il->beacon_skb); - ieee80211_free_hw(priv->hw); + ieee80211_free_hw(il->hw); } /* * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask - * must be called under priv->lock and mac access + * must be called under il->lock and mac access */ -void il4965_txq_set_sched(struct il_priv *priv, u32 mask) +void il4965_txq_set_sched(struct il_priv *il, u32 mask) { - il_write_prph(priv, IWL49_SCD_TXFACT, mask); + il_write_prph(il, IWL49_SCD_TXFACT, mask); } /***************************************************************************** -- cgit v0.10.2 From d2ddf621aa45ac4cf4cce6359bfac6b49a8c6b34 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 16 Aug 2011 14:17:04 +0200 Subject: iwlegacy: rename iwlegacy to il More renaming to make code shorter. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 4d25590..647399e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -424,7 +424,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) if (band == IEEE80211_BAND_5GHZ) band_offset = IL_FIRST_OFDM_RATE; for (idx = band_offset; idx < IL_RATE_COUNT_LEGACY; idx++) - if (iwlegacy_rates[idx].plcp == (rate_n_flags & 0xFF)) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx - band_offset; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index e53ed1a..60ff0cd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -96,7 +96,7 @@ static const u8 ant_toggle_lookup[] = { * maps to IL_RATE_INVALID * */ -const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT] = { +const struct il_rate_info il_rates[IL_RATE_COUNT] = { IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ @@ -132,8 +132,8 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) /* legacy rate format, search for match in table */ } else { - for (idx = 0; idx < ARRAY_SIZE(iwlegacy_rates); idx++) - if (iwlegacy_rates[idx].plcp == (rate_n_flags & 0xFF)) + for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx; } @@ -499,7 +499,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, u32 rate_n_flags = 0; if (is_legacy(tbl->lq_type)) { - rate_n_flags = iwlegacy_rates[index].plcp; + rate_n_flags = il_rates[index].plcp; if (index >= IL_FIRST_CCK_RATE && index <= IL_LAST_CCK_RATE) rate_n_flags |= RATE_MCS_CCK_MSK; @@ -511,9 +511,9 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, rate_n_flags = RATE_MCS_HT_MSK; if (is_siso(tbl->lq_type)) - rate_n_flags |= iwlegacy_rates[index].plcp_siso; + rate_n_flags |= il_rates[index].plcp_siso; else - rate_n_flags |= iwlegacy_rates[index].plcp_mimo2; + rate_n_flags |= il_rates[index].plcp_mimo2; } else { IL_ERR(il, "Invalid tbl->lq_type %d\n", tbl->lq_type); } @@ -702,7 +702,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, low = index; while (low != IL_RATE_INVALID) { - low = iwlegacy_rates[low].prev_rs; + low = il_rates[low].prev_rs; if (low == IL_RATE_INVALID) break; if (rate_mask & (1 << low)) @@ -712,7 +712,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, high = index; while (high != IL_RATE_INVALID) { - high = iwlegacy_rates[high].next_rs; + high = il_rates[high].next_rs; if (high == IL_RATE_INVALID) break; if (rate_mask & (1 << high)) @@ -2220,7 +2220,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, if ((i < 0) || (i >= IL_RATE_COUNT)) i = 0; - rate = iwlegacy_rates[i].plcp; + rate = il_rates[i].plcp; tbl->ant_type = il4965_first_antenna(valid_tx_ant); rate |= tbl->ant_type << RATE_MCS_ANT_POS; @@ -2793,7 +2793,7 @@ static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, else desc += sprintf(buff+desc, "Bit Rate= %d Mb/s\n", - iwlegacy_rates[lq_sta->last_txrate_idx].ieee >> 1); + il_rates[lq_sta->last_txrate_idx].ieee >> 1); ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 20290d2..0fbc991 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -59,7 +59,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << RATE_MCS_ANT_POS; - rate_n_flags = il4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, + rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, rate_flags); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; @@ -554,7 +554,7 @@ int il4965_alloc_bcast_station(struct il_priv *il, u8 sta_id; spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, iwlegacy_bcast_addr, + sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR(il, "Unable to prepare broadcast station\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 59d7374..fcc938e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -203,7 +203,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, if (info->band == IEEE80211_BAND_5GHZ) rate_idx += IL_FIRST_OFDM_RATE; /* Get PLCP rate for tx_cmd->rate_n_flags */ - rate_plcp = iwlegacy_rates[rate_idx].plcp; + rate_plcp = il_rates[rate_idx].plcp; /* Zero out flags for this packet */ rate_flags = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 80ec543..a768e78 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -68,11 +68,11 @@ static bool bt_coex_active = true; module_param(bt_coex_active, bool, S_IRUGO); MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); -u32 iwlegacy_debug_level; -EXPORT_SYMBOL(iwlegacy_debug_level); +u32 il_debug_level; +EXPORT_SYMBOL(il_debug_level); -const u8 iwlegacy_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -EXPORT_SYMBOL(iwlegacy_bcast_addr); +const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +EXPORT_SYMBOL(il_bcast_addr); /* This function both allocates and initializes hw and il. */ @@ -183,7 +183,7 @@ int il_init_geos(struct il_priv *il) /* 5.2GHz channels start after the 2.4GHz channels */ sband = &il->bands[IEEE80211_BAND_5GHZ]; - sband->channels = &channels[ARRAY_SIZE(iwlegacy_eeprom_band_1)]; + sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; /* just OFDM */ sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; @@ -1486,7 +1486,7 @@ int il_alloc_traffic_mem(struct il_priv *il) { u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; - if (iwlegacy_debug_level & IL_DL_TX) { + if (il_debug_level & IL_DL_TX) { if (!il->tx_traffic) { il->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1494,7 +1494,7 @@ int il_alloc_traffic_mem(struct il_priv *il) return -ENOMEM; } } - if (iwlegacy_debug_level & IL_DL_RX) { + if (il_debug_level & IL_DL_RX) { if (!il->rx_traffic) { il->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1523,7 +1523,7 @@ void il_dbg_log_tx_data_frame(struct il_priv *il, __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IL_DL_TX))) + if (likely(!(il_debug_level & IL_DL_TX))) return; if (!il->tx_traffic) @@ -1548,7 +1548,7 @@ void il_dbg_log_rx_data_frame(struct il_priv *il, __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IL_DL_RX))) + if (likely(!(il_debug_level & IL_DL_RX))) return; if (!il->rx_traffic) diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 657da25..05a7933 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -30,7 +30,7 @@ #define __il_debug_h__ struct il_priv; -extern u32 iwlegacy_debug_level; +extern u32 il_debug_level; #define IL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) #define IL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index f2f2eba..a811c17 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -705,7 +705,7 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, q->read_ptr, q->write_ptr); } - if (il->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { + if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { ptr = il->tx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", il->tx_traffic_idx); @@ -728,7 +728,7 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, "read: %u, write: %u\n", rxq->read, rxq->write); - if (il->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { + if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { ptr = il->rx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", il->rx_traffic_idx); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 824d193..2e2e3f3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -626,7 +626,7 @@ struct il_hw_params { * ****************************************************************************/ extern void il4965_update_chain_flags(struct il_priv *il); -extern const u8 iwlegacy_bcast_addr[ETH_ALEN]; +extern const u8 il_bcast_addr[ETH_ALEN]; extern int il_queue_space(const struct il_queue *q); static inline int il_queue_used(const struct il_queue *q, int i) { @@ -1220,7 +1220,7 @@ struct il_priv { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG /* debugging info */ u32 debug_level; /* per device debugging will override global - iwlegacy_debug_level if set */ + il_debug_level if set */ #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS /* debugfs */ @@ -1270,12 +1270,12 @@ static inline u32 il_get_debug_level(struct il_priv *il) if (il->debug_level) return il->debug_level; else - return iwlegacy_debug_level; + return il_debug_level; } #else static inline u32 il_get_debug_level(struct il_priv *il) { - return iwlegacy_debug_level; + return il_debug_level; } #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5edec73..f6b9d6d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -77,7 +77,7 @@ /************************** EEPROM BANDS **************************** * - * The iwlegacy_eeprom_band definitions below provide the mapping from the + * The il_eeprom_band definitions below provide the mapping from the * EEPROM contents to the specific channel number supported for each * band. * @@ -107,32 +107,32 @@ *********************************************************************/ /* 2.4 GHz */ -const u8 iwlegacy_eeprom_band_1[14] = { +const u8 il_eeprom_band_1[14] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; /* 5.2 GHz bands */ -static const u8 iwlegacy_eeprom_band_2[] = { /* 4915-5080MHz */ +static const u8 il_eeprom_band_2[] = { /* 4915-5080MHz */ 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 }; -static const u8 iwlegacy_eeprom_band_3[] = { /* 5170-5320MHz */ +static const u8 il_eeprom_band_3[] = { /* 5170-5320MHz */ 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 }; -static const u8 iwlegacy_eeprom_band_4[] = { /* 5500-5700MHz */ +static const u8 il_eeprom_band_4[] = { /* 5500-5700MHz */ 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 }; -static const u8 iwlegacy_eeprom_band_5[] = { /* 5725-5825MHz */ +static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ 145, 149, 153, 157, 161, 165 }; -static const u8 iwlegacy_eeprom_band_6[] = { /* 2.4 ht40 channel */ +static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ 1, 2, 3, 4, 5, 6, 7 }; -static const u8 iwlegacy_eeprom_band_7[] = { /* 5.2 ht40 channel */ +static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 }; @@ -273,46 +273,46 @@ static void il_init_band_reference(const struct il_priv *il, eeprom_ops.regulatory_bands[eep_band - 1]; switch (eep_band) { case 1: /* 2.4GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_1); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_1; + *eeprom_ch_index = il_eeprom_band_1; break; case 2: /* 4.9GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_2); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_2; + *eeprom_ch_index = il_eeprom_band_2; break; case 3: /* 5.2GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_3); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_3; + *eeprom_ch_index = il_eeprom_band_3; break; case 4: /* 5.5GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_4); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_4; + *eeprom_ch_index = il_eeprom_band_4; break; case 5: /* 5.7GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_5); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_5; + *eeprom_ch_index = il_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_6); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_6; + *eeprom_ch_index = il_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_7); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_7; + *eeprom_ch_index = il_eeprom_band_7; break; default: BUG(); @@ -387,11 +387,11 @@ int il_init_channel_map(struct il_priv *il) IL_DEBUG_EEPROM(il, "Initializing regulatory info from EEPROM\n"); il->channel_count = - ARRAY_SIZE(iwlegacy_eeprom_band_1) + - ARRAY_SIZE(iwlegacy_eeprom_band_2) + - ARRAY_SIZE(iwlegacy_eeprom_band_3) + - ARRAY_SIZE(iwlegacy_eeprom_band_4) + - ARRAY_SIZE(iwlegacy_eeprom_band_5); + ARRAY_SIZE(il_eeprom_band_1) + + ARRAY_SIZE(il_eeprom_band_2) + + ARRAY_SIZE(il_eeprom_band_3) + + ARRAY_SIZE(il_eeprom_band_4) + + ARRAY_SIZE(il_eeprom_band_5); IL_DEBUG_EEPROM(il, "Parsing data for %d channels.\n", il->channel_count); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index acb5ec1..b97c837 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -144,7 +144,7 @@ struct il_eeprom_channel { #define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ /* 2.4 GHz */ -extern const u8 iwlegacy_eeprom_band_1[14]; +extern const u8 il_eeprom_band_1[14]; /* * factory calibration data for one txpower level, on one channel, diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 4282ed5..744829a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -56,7 +56,7 @@ struct il3945_rate_info { /* * These serve as indexes into - * struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; + * struct il_rate_info il_rates[IL_RATE_COUNT]; */ enum { IL_RATE_1M_INDEX = 0, @@ -268,7 +268,7 @@ enum { #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) -extern const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; +extern const struct il_rate_info il_rates[IL_RATE_COUNT]; enum il_table_type { LQ_NONE, diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 0184d5b..5a967d2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -442,9 +442,9 @@ il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, return 0; frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - memcpy(frame->da, iwlegacy_bcast_addr, ETH_ALEN); + memcpy(frame->da, il_bcast_addr, ETH_ALEN); memcpy(frame->sa, ta, ETH_ALEN); - memcpy(frame->bssid, iwlegacy_bcast_addr, ETH_ALEN); + memcpy(frame->bssid, il_bcast_addr, ETH_ALEN); frame->seq_ctrl = 0; len += 24; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 2c336a7..af3f194 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -2378,7 +2378,7 @@ static int il3945_alloc_bcast_station(struct il_priv *il) spin_lock_irqsave(&il->sta_lock, flags); sta_id = il_prep_station(il, ctx, - iwlegacy_bcast_addr, false, NULL); + il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR(il, "Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); @@ -4003,7 +4003,7 @@ module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index ae8a937..d4eacc3 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -2712,7 +2712,7 @@ static void il4965_init_hw_rates(struct il_priv *il, int i; for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = iwlegacy_rates[i].ieee * 5; + rates[i].bitrate = il_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; @@ -2721,7 +2721,7 @@ static void il4965_init_hw_rates(struct il_priv *il, * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (iwlegacy_rates[i].plcp == IL_RATE_1M_PLCP) ? + (il_rates[i].plcp == IL_RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } @@ -3259,7 +3259,7 @@ module_exit(il4965_exit); module_init(il4965_init); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -- cgit v0.10.2 From 46f16c492e5ca905c2170c11177fb90a58074eab Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 16 Aug 2011 15:00:23 +0200 Subject: iwlegacy: remove DEBUG_IO Nothing useful at present. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index 947475e..ef8b0d5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -102,12 +102,8 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); - if (ret >= 0) { - IL_DEBUG_IO(il, - "Acquired semaphore after %d tries.\n", - count+1); + if (ret >= 0) return ret; - } } return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 05a7933..a825051d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -146,7 +146,6 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DL_RX (1 << 24) #define IL_DL_ISR (1 << 25) #define IL_DL_HT (1 << 26) -#define IL_DL_IO (1 << 27) /* 0xF0000000 - 0x10000000 */ #define IL_DL_11H (1 << 28) #define IL_DL_STATS (1 << 29) @@ -174,7 +173,6 @@ static inline void il_dbgfs_unregister(struct il_priv *il) IL_DEBUG_LIMIT(p, IL_DL_DROP, f, ## a) #define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) #define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) -#define IL_DEBUG_IO(p, f, a...) IL_DEBUG(p, IL_DL_IO, f, ## a) #define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) #define IL_DEBUG_RATE_LIMIT(p, f, a...) \ IL_DEBUG_LIMIT(p, IL_DL_RATE, f, ## a) diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 42d241f..d6aae8d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -34,90 +34,24 @@ #include "iwl-dev.h" #include "iwl-debug.h" -/* - * IO, register, and NIC memory access functions - * - * NOTE on naming convention and macro usage for these - * - * A single _ prefix before a an access function means that no state - * check or debug information is printed when that function is called. - * - * A double __ prefix before an access function means that state is checked - * and the current line number and caller function name are printed in addition - * to any other debug output. - * - * The non-prefixed name is the #define that maps the caller into a - * #define that provides the caller's name and __LINE__ to the double - * prefix version. - * - * If you wish to call the function without any debug or state checking, - * you should use the single _ prefix version (as is used by dependent IO - * routines, for example _il_read_direct32 calls the non-check version of - * _il_read32.) - * - * These declarations are *extremely* useful in quickly isolating code deltas - * which result in misconfiguration of the hardware I/O. In combination with - * git-bisect and the IO debug level you can quickly determine the specific - * commit which breaks the IO sequence to the hardware. - * - */ - static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) { iowrite8(val, il->hw_base + ofs); } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void -__il_write8(const char *f, u32 l, struct il_priv *il, - u32 ofs, u8 val) -{ - IL_DEBUG_IO(il, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); - _il_write8(il, ofs, val); -} -#define il_write8(il, ofs, val) \ - __il_write8(__FILE__, __LINE__, il, ofs, val) -#else #define il_write8(il, ofs, val) _il_write8(il, ofs, val) -#endif - static inline void _il_write32(struct il_priv *il, u32 ofs, u32 val) { iowrite32(val, il->hw_base + ofs); } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void -__il_write32(const char *f, u32 l, struct il_priv *il, - u32 ofs, u32 val) -{ - IL_DEBUG_IO(il, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); - _il_write32(il, ofs, val); -} -#define il_write32(il, ofs, val) \ - __il_write32(__FILE__, __LINE__, il, ofs, val) -#else #define il_write32(il, ofs, val) _il_write32(il, ofs, val) -#endif static inline u32 _il_read32(struct il_priv *il, u32 ofs) { u32 val = ioread32(il->hw_base + ofs); return val; } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline u32 -__il_read32(char *f, u32 l, struct il_priv *il, u32 ofs) -{ - IL_DEBUG_IO(il, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); - return _il_read32(il, ofs); -} -#define il_read32(il, ofs) __il_read32(__FILE__, __LINE__, il, ofs) -#else #define il_read32(p, o) _il_read32(p, o) -#endif #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int @@ -135,46 +69,13 @@ _il_poll_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __il_poll_bit(const char *f, u32 l, - struct il_priv *il, u32 addr, - u32 bits, u32 mask, int timeout) -{ - int ret = _il_poll_bit(il, addr, bits, mask, timeout); - IL_DEBUG_IO(il, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", - addr, bits, mask, - unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l); - return ret; -} -#define il_poll_bit(il, addr, bits, mask, timeout) \ - __il_poll_bit(__FILE__, __LINE__, il, addr, \ - bits, mask, timeout) -#else #define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) -#endif static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { _il_write32(il, reg, _il_read32(il, reg) | mask); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __il_set_bit(const char *f, u32 l, - struct il_priv *il, u32 reg, u32 mask) -{ - u32 val = _il_read32(il, reg) | mask; - IL_DEBUG_IO(il, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, - mask, val); - _il_write32(il, reg, val); -} -static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - spin_lock_irqsave(&p->reg_lock, reg_flags); - __il_set_bit(__FILE__, __LINE__, p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} -#else static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -183,31 +84,13 @@ static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) _il_set_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } -#endif static inline void _il_clear_bit(struct il_priv *il, u32 reg, u32 mask) { _il_write32(il, reg, _il_read32(il, reg) & ~mask); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void -__il_clear_bit(const char *f, u32 l, - struct il_priv *il, u32 reg, u32 mask) -{ - u32 val = _il_read32(il, reg) & ~mask; - IL_DEBUG_IO(il, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _il_write32(il, reg, val); -} -static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - spin_lock_irqsave(&p->reg_lock, reg_flags); - __il_clear_bit(__FILE__, __LINE__, p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} -#else static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -216,7 +99,6 @@ static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) _il_clear_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } -#endif static inline int _il_grab_nic_access(struct il_priv *il) { @@ -259,69 +141,20 @@ static inline int _il_grab_nic_access(struct il_priv *il) return 0; } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __il_grab_nic_access(const char *f, u32 l, - struct il_priv *il) -{ - IL_DEBUG_IO(il, "grabbing nic access - %s %d\n", f, l); - return _il_grab_nic_access(il); -} -#define il_grab_nic_access(il) \ - __il_grab_nic_access(__FILE__, __LINE__, il) -#else -#define il_grab_nic_access(il) \ - _il_grab_nic_access(il) -#endif +#define il_grab_nic_access(il) _il_grab_nic_access(il) static inline void _il_release_nic_access(struct il_priv *il) { _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __il_release_nic_access(const char *f, u32 l, - struct il_priv *il) -{ - - IL_DEBUG_IO(il, "releasing nic access - %s %d\n", f, l); - _il_release_nic_access(il); -} -#define il_release_nic_access(il) \ - __il_release_nic_access(__FILE__, __LINE__, il) -#else -#define il_release_nic_access(il) \ - _il_release_nic_access(il) -#endif +#define il_release_nic_access(il) _il_release_nic_access(il) static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { return _il_read32(il, reg); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline u32 __il_read_direct32(const char *f, u32 l, - struct il_priv *il, u32 reg) -{ - u32 value = _il_read_direct32(il, reg); - IL_DEBUG_IO(il, - "read_direct32(0x%4X) = 0x%08x - %s %d\n", reg, value, - f, l); - return value; -} -static inline u32 il_read_direct32(struct il_priv *il, u32 reg) -{ - u32 value; - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); - value = __il_read_direct32(__FILE__, __LINE__, il, reg); - il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return value; -} -#else static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; @@ -335,7 +168,6 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) return value; } -#endif static inline void _il_write_direct32(struct il_priv *il, u32 reg, u32 value) @@ -380,27 +212,7 @@ static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __il_poll_direct_bit(const char *f, u32 l, - struct il_priv *il, - u32 addr, u32 mask, int timeout) -{ - int ret = _il_poll_direct_bit(il, addr, mask, timeout); - - if (unlikely(ret == -ETIMEDOUT)) - IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) - " - "timedout - %s %d\n", addr, mask, f, l); - else - IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " - "- %s %d\n", addr, mask, ret, f, l); - return ret; -} -#define il_poll_direct_bit(il, addr, mask, timeout) \ -__il_poll_direct_bit(__FILE__, __LINE__, il, addr, mask, timeout) -#else #define il_poll_direct_bit _il_poll_direct_bit -#endif static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { -- cgit v0.10.2 From 2d27c5dbd696e7e3a162bba7b948486a9856abca Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 16 Aug 2011 15:36:33 +0200 Subject: iwlegacy: remove DEBUG_LIMIT Even if messages are generating fast we want to see all of them when debugging. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index c9b5dcf..628adf5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -477,7 +477,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP_LIMIT(il, + IL_DEBUG_DROP(il, "Dropping packet while interface is not open.\n"); return; } @@ -563,7 +563,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, network_packet = il3945_is_network_packet(il, header); - IL_DEBUG_STATS_LIMIT(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + IL_DEBUG_STATS(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 647399e..1564629 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -537,7 +537,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP_LIMIT(il, + IL_DEBUG_DROP(il, "Dropping packet while interface is not open.\n"); return; } @@ -647,7 +647,7 @@ void il4965_rx_reply_rx(struct il_priv *il, rx_status.signal = il4965_calc_rssi(il, phy_res); il_dbg_log_rx_data_frame(il, len, header); - IL_DEBUG_STATS_LIMIT(il, "Rssi %d, TSF %llu\n", + IL_DEBUG_STATS(il, "Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 60ff0cd..782ec77 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -817,7 +817,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE_LIMIT(il, + IL_DEBUG_RATE(il, "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ @@ -2251,7 +2251,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, struct il_lq_sta *lq_sta = il_sta; int rate_idx; - IL_DEBUG_RATE_LIMIT(il, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index d3c8183..01fa6c8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1737,7 +1737,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) goto out; } - IL_DEBUG_ASSOC_LIMIT(il, "can not find STA %pM total %d\n", + IL_DEBUG_ASSOC(il, "can not find STA %pM total %d\n", addr, il->num_stations); out: diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index a825051d..c6dcbf3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -52,14 +52,6 @@ do { \ __func__ , ## args); \ } while (0) -#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) \ -do { \ - if ((il_get_debug_level(__priv) & (level)) && net_ratelimit()) \ - dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ - "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ - __func__ , ## args); \ -} while (0) - #define il_print_hex_dump(il, level, p, len) \ do { \ if (il_get_debug_level(il) & level) \ @@ -69,7 +61,6 @@ do { \ #else #define IL_DEBUG(__priv, level, fmt, args...) -#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} @@ -169,25 +160,14 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DEBUG_FW(p, f, a...) IL_DEBUG(p, IL_DL_FW, f, ## a) #define IL_DEBUG_RF_KILL(p, f, a...) IL_DEBUG(p, IL_DL_RF_KILL, f, ## a) #define IL_DEBUG_DROP(p, f, a...) IL_DEBUG(p, IL_DL_DROP, f, ## a) -#define IL_DEBUG_DROP_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_DROP, f, ## a) #define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) #define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) #define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) -#define IL_DEBUG_RATE_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_RATE, f, ## a) #define IL_DEBUG_NOTIF(p, f, a...) IL_DEBUG(p, IL_DL_NOTIF, f, ## a) -#define IL_DEBUG_ASSOC(p, f, a...) \ - IL_DEBUG(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) -#define IL_DEBUG_ASSOC_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) +#define IL_DEBUG_ASSOC(p, f, a...) IL_DEBUG(p, IL_DL_ASSOC, f, ## a) #define IL_DEBUG_HT(p, f, a...) IL_DEBUG(p, IL_DL_HT, f, ## a) #define IL_DEBUG_STATS(p, f, a...) IL_DEBUG(p, IL_DL_STATS, f, ## a) -#define IL_DEBUG_STATS_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_STATS, f, ## a) #define IL_DEBUG_TX_REPLY(p, f, a...) IL_DEBUG(p, IL_DL_TX_REPLY, f, ## a) -#define IL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_TX_REPLY, f, ## a) #define IL_DEBUG_QOS(p, f, a...) IL_DEBUG(p, IL_DL_QOS, f, ## a) #define IL_DEBUG_RADIO(p, f, a...) IL_DEBUG(p, IL_DL_RADIO, f, ## a) #define IL_DEBUG_POWER(p, f, a...) IL_DEBUG(p, IL_DL_POWER, f, ## a) -- cgit v0.10.2 From 58de00a464f1e7cf0b108341dc6cc49276d19d7a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 11:21:01 +0100 Subject: iwlegacy: rename IL_DEBUG_ to D_ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 38f1b82..d05da7a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -167,7 +167,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + IL_RATE_WIN_FLUSH)) { - IL_DEBUG_RATE(il, "flushing %d samples of rate " + D_RATE("flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); il3945_clear_window(&rs_sta->win[i]); @@ -191,7 +191,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) unsigned long flags; u32 packet_count, duration, pps; - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); unflushed = il3945_rate_scale_flush_windows(rs_sta); @@ -206,7 +206,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - IL_DEBUG_RATE(il, "Tx'd %d packets in %dms\n", + D_RATE("Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ @@ -226,7 +226,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->flush_time = msecs_to_jiffies(duration); - IL_DEBUG_RATE(il, "new flush period: %d msec ave %d\n", + D_RATE("new flush period: %d msec ave %d\n", duration, packet_count); mod_timer(&rs_sta->rate_scale_flush, jiffies + @@ -244,7 +244,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("leave\n"); } /** @@ -263,7 +263,7 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, struct il_priv *il __maybe_unused = rs_sta->il; if (!retries) { - IL_DEBUG_RATE(il, "leave: retries == 0 -- should be at least 1\n"); + D_RATE("leave: retries == 0 -- should be at least 1\n"); return; } @@ -341,7 +341,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i struct ieee80211_supported_band *sband; int i; - IL_DEBUG_INFO(il, "enter\n"); + D_INFO("enter\n"); if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) goto out; @@ -390,7 +390,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i out: il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - IL_DEBUG_INFO(il, "leave\n"); + D_INFO("leave\n"); } static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) @@ -410,14 +410,14 @@ static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t struct il3945_sta_priv *psta = (void *) sta->drv_priv; struct il_priv *il __maybe_unused = il_priv; - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); rs_sta = &psta->rs_sta; spin_lock_init(&rs_sta->lock); init_timer(&rs_sta->rate_scale_flush); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("leave\n"); return rs_sta; } @@ -453,7 +453,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * struct il3945_rs_sta *rs_sta = il_sta; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); retries = info->status.rates[0].count; /* Sanity Check for retries */ @@ -462,18 +462,18 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * first_index = sband->bitrates[info->status.rates[0].idx].hw_value; if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { - IL_DEBUG_RATE(il, "leave: Rate out of bounds: %d\n", first_index); + D_RATE("leave: Rate out of bounds: %d\n", first_index); return; } if (!il_sta) { - IL_DEBUG_RATE(il, "leave: No STA il data to update!\n"); + D_RATE("leave: No STA il data to update!\n"); return; } /* Treat uninitialized rate scaling data same as non-existing. */ if (!rs_sta->il) { - IL_DEBUG_RATE(il, "leave: STA il data uninitialized!\n"); + D_RATE("leave: STA il data uninitialized!\n"); return; } @@ -508,7 +508,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_index], 0, current_count, scale_rate_index); - IL_DEBUG_RATE(il, "Update rate %d for %d retries.\n", + D_RATE("Update rate %d for %d retries.\n", scale_rate_index, current_count); retries -= current_count; @@ -518,7 +518,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * /* Update the last index window with success/failure based on ACK */ - IL_DEBUG_RATE(il, "Update rate %d with %s.\n", + D_RATE("Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); @@ -543,7 +543,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("leave\n"); } static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, @@ -591,7 +591,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); + D_RATE("Skipping masked lower rate: %d\n", low); } high = index; @@ -604,7 +604,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); + D_RATE("Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -648,11 +648,11 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, struct il_priv *il __maybe_unused = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (rs_sta && !rs_sta->il) { - IL_DEBUG_RATE(il, "Rate scaling information not initialized yet.\n"); + D_RATE("Rate scaling information not initialized yet.\n"); il_sta = NULL; } @@ -699,7 +699,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(il, "Invalid average_tpt on rate %d: " + D_RATE("Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, @@ -737,7 +737,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Low success ratio , need to drop the rate */ if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { - IL_DEBUG_RATE(il, "decrease rate because of low success_ratio\n"); + D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ @@ -756,7 +756,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) { - IL_DEBUG_RATE(il, "No action -- low [%d] & high [%d] < " + D_RATE("No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; @@ -771,13 +771,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of high tpt\n"); scale_action = 0; } } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { @@ -816,7 +816,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, break; } - IL_DEBUG_RATE(il, "Selected %d (action %d) - low %d high %d\n", + D_RATE("Selected %d (action %d) - low %d high %d\n", index, scale_action, low, high); out: @@ -831,7 +831,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, info->control.rates[0].idx = rs_sta->last_txrate_idx; } - IL_DEBUG_RATE(il, "leave: %d\n", index); + D_RATE("leave: %d\n", index); } #ifdef CONFIG_MAC80211_DEBUGFS @@ -932,14 +932,14 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) struct ieee80211_sta *sta; struct il3945_sta_priv *psta; - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); rcu_read_lock(); sta = ieee80211_find_sta(il->contexts[IL_RXON_CTX_BSS].vif, il->stations[sta_id].sta.sta.addr); if (!sta) { - IL_DEBUG_RATE(il, "Unable to find station to initialize rate scaling.\n"); + D_RATE("Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } @@ -975,11 +975,11 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) if (rssi == 0) rssi = IL_MIN_RSSI_VAL; - IL_DEBUG_RATE(il, "Network RSSI: %d\n", rssi); + D_RATE("Network RSSI: %d\n", rssi); rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, il->band); - IL_DEBUG_RATE(il, "leave: rssi %d assign rate index: " + D_RATE("leave: rssi %d assign rate index: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 628adf5..a1e2a42 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -174,7 +174,7 @@ void il3945_disable_events(struct il_priv *il) array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { - IL_DEBUG_INFO(il, "Disabling selected uCode log events at 0x%x\n", + D_INFO("Disabling selected uCode log events at 0x%x\n", disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) il_write_targ_mem(il, @@ -182,9 +182,9 @@ void il3945_disable_events(struct il_priv *il) evt_disable[i]); } else { - IL_DEBUG_INFO(il, "Selected uCode log events may be disabled\n"); - IL_DEBUG_INFO(il, " by writing \"1\"s into disable bitmap\n"); - IL_DEBUG_INFO(il, " in SRAM at 0x%x, size %d u32s\n", + D_INFO("Selected uCode log events may be disabled\n"); + D_INFO(" by writing \"1\"s into disable bitmap\n"); + D_INFO(" in SRAM at 0x%x, size %d u32s\n", disable_ptr, array_size); } @@ -342,11 +342,11 @@ static void il3945_rx_reply_tx(struct il_priv *il, info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - IL_DEBUG_TX(il, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(il, "Tx queue reclaim %d\n", index); + D_TX_REPLY("Tx queue reclaim %d\n", index); il3945_tx_queue_reclaim(il, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) @@ -401,7 +401,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(il, "Statistics notification received (%d vs %d).\n", + D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS @@ -426,7 +426,7 @@ void il3945_reply_statistics(struct il_priv *il, memset(&il->_3945.max_delta, 0, sizeof(struct il3945_notif_statistics)); #endif - IL_DEBUG_RX(il, "Statistics have been cleared\n"); + D_RX("Statistics have been cleared\n"); } il3945_hw_rx_statistics(il, rxb); } @@ -471,13 +471,13 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, /* We received data from the HW, so stop the watchdog */ if (unlikely(len + IWL39_RX_FRAME_SIZE > PAGE_SIZE << il->hw_params.rx_page_order)) { - IL_DEBUG_DROP(il, "Corruption detected!\n"); + D_DROP("Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP(il, + D_DROP( "Dropping packet while interface is not open.\n"); return; } @@ -539,14 +539,14 @@ static void il3945_rx_reply_rx(struct il_priv *il, rx_status.flag |= RX_FLAG_SHORTPRE; if ((unlikely(rx_stats->phy_count > 20))) { - IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", + D_DROP("dsp size out of range [0,20]: %d/n", rx_stats->phy_count); return; } if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -555,7 +555,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; - IL_DEBUG_STATS(il, "Rssi %d sig_avg %d noise_diff %d\n", + D_STATS("Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, rx_stats_noise_diff); @@ -563,7 +563,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, network_packet = il3945_is_network_packet(il, header); - IL_DEBUG_STATS(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, @@ -718,7 +718,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); - IL_DEBUG_RATE(il, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); @@ -741,7 +741,7 @@ static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) il_send_add_sta(il, &station->sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags_spin); - IL_DEBUG_RATE(il, "SCALE sync station %d to rate %d\n", + D_RATE("SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } @@ -900,34 +900,34 @@ static void il3945_nic_config(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); /* Determine HW type */ - IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", rev_id); + D_INFO("HW Revision ID = 0x%X\n", rev_id); if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - IL_DEBUG_INFO(il, "RTP type\n"); + D_INFO("RTP type\n"); else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - IL_DEBUG_INFO(il, "3945 RADIO-MB type\n"); + D_INFO("3945 RADIO-MB type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { - IL_DEBUG_INFO(il, "3945 RADIO-MM type\n"); + D_INFO("3945 RADIO-MM type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - IL_DEBUG_INFO(il, "SKU OP mode is mrc\n"); + D_INFO("SKU OP mode is mrc\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else - IL_DEBUG_INFO(il, "SKU OP mode is basic\n"); + D_INFO("SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_clear_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); @@ -936,10 +936,10 @@ static void il3945_nic_config(struct il_priv *il) if (eeprom->almgor_m_version <= 1) { il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - IL_DEBUG_INFO(il, "Card M type A version is 0x%X\n", + D_INFO("Card M type A version is 0x%X\n", eeprom->almgor_m_version); } else { - IL_DEBUG_INFO(il, "Card M type B version is 0x%X\n", + D_INFO("Card M type B version is 0x%X\n", eeprom->almgor_m_version); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); @@ -947,10 +947,10 @@ static void il3945_nic_config(struct il_priv *il) spin_unlock_irqrestore(&il->lock, flags); if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(il, "SW RF KILL supported in EEPROM.\n"); + D_RF_KILL("SW RF KILL supported in EEPROM.\n"); if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(il, "HW RF KILL supported in EEPROM.\n"); + D_RF_KILL("HW RF KILL supported in EEPROM.\n"); } int il3945_hw_nic_init(struct il_priv *il) @@ -1074,7 +1074,7 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) /* driver's okay range is -260 to +25. * human readable okay range is 0 to +285 */ - IL_DEBUG_INFO(il, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); + D_INFO("Temperature: %d\n", temperature + IL_TEMP_CONVERT); /* handle insane temp reading */ if (il3945_hw_reg_temp_out_of_range(temperature)) { @@ -1111,20 +1111,20 @@ static int il3945_is_temp_calib_needed(struct il_priv *il) /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(il, "Getting cooler, delta %d,\n", temp_diff); + D_POWER("Getting cooler, delta %d,\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(il, "Same temp,\n"); + D_POWER("Same temp,\n"); else - IL_DEBUG_POWER(il, "Getting warmer, delta %d,\n", temp_diff); + D_POWER("Getting warmer, delta %d,\n", temp_diff); /* if we don't need calibration, *don't* update last_temperature */ if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { - IL_DEBUG_POWER(il, "Timed thermal calib not needed\n"); + D_POWER("Timed thermal calib not needed\n"); return 0; } - IL_DEBUG_POWER(il, "Timed thermal calib needed\n"); + D_POWER("Timed thermal calib needed\n"); /* assume that caller will actually do calib ... * update the "last temperature" value */ @@ -1395,7 +1395,7 @@ static int il3945_send_tx_power(struct il_priv *il) } if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_POWER(il, "Not calling TX_PWR_TABLE_CMD on " + D_POWER("Not calling TX_PWR_TABLE_CMD on " "non-Tx channel.\n"); return 0; } @@ -1408,7 +1408,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1421,7 +1421,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1617,12 +1617,12 @@ int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) u8 i; if (il->tx_power_user_lmt == power) { - IL_DEBUG_POWER(il, "Requested Tx power same as current " + D_POWER("Requested Tx power same as current " "limit: %ddBm.\n", power); return 0; } - IL_DEBUG_POWER(il, "Setting upper limit clamp to %ddBm.\n", power); + D_POWER("Setting upper limit clamp to %ddBm.\n", power); il->tx_power_user_lmt = power; /* set up new Tx powers for each and every channel, 2.4 and 5.x */ @@ -1670,7 +1670,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, (rxon1->filter_flags == rxon2->filter_flags) && (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); + D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1758,7 +1758,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * we must clear the associated from the active configuration * before we apply the new config */ if (il_is_associated(il, IL_RXON_CTX_BSS) && new_assoc) { - IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); + D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; /* @@ -1785,7 +1785,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) &il->contexts[IL_RXON_CTX_BSS]); } - IL_DEBUG_INFO(il, "Sending RXON\n" + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1913,7 +1913,7 @@ static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *il, } else group_index = 0; /* 2.4 GHz, group 0 */ - IL_DEBUG_POWER(il, "Chnl %d mapped to grp %d\n", ch_info->channel, + D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, group_index); return group_index; } @@ -1980,7 +1980,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; const struct il3945_eeprom_txpower_group *group; - IL_DEBUG_POWER(il, "Initializing factory calib info from EEPROM\n"); + D_POWER("Initializing factory calib info from EEPROM\n"); for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { s8 *clip_pwrs; /* table of power levels for each rate */ @@ -2096,7 +2096,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) eeprom->groups[ch_info->group_index]. temperature); - IL_DEBUG_POWER(il, "Delta index for channel %d: %d [%d]\n", + D_POWER("Delta index for channel %d: %d [%d]\n", ch_info->channel, delta_index, temperature + IL_TEMP_CONVERT); @@ -2324,7 +2324,7 @@ int il3945_init_hw_rate_table(struct il_priv *il) switch (il->band) { case IEEE80211_BAND_5GHZ: - IL_DEBUG_RATE(il, "Select A mode rate scale\n"); + D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ for (i = IL_RATE_1M_INDEX_TABLE; @@ -2342,7 +2342,7 @@ int il3945_init_hw_rate_table(struct il_priv *il) break; case IEEE80211_BAND_2GHZ: - IL_DEBUG_RATE(il, "Select B/G mode rate scale\n"); + D_RATE("Select B/G mode rate scale\n"); /* If an OFDM rate is used, have it fall back to the * 1M CCK rates */ @@ -2472,7 +2472,7 @@ static int il3945_verify_bsm(struct il_priv *il) u32 reg; u32 val; - IL_DEBUG_INFO(il, "Begin verify bsm\n"); + D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ val = il_read_prph(il, BSM_WR_DWCOUNT_REG); @@ -2490,7 +2490,7 @@ static int il3945_verify_bsm(struct il_priv *il) } } - IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); + D_INFO("BSM bootstrap uCode image OK\n"); return 0; } @@ -2567,7 +2567,7 @@ static int il3945_load_bsm(struct il_priv *il) u32 done; u32 reg_offset; - IL_DEBUG_INFO(il, "Begin load bsm\n"); + D_INFO("Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL39_MAX_BSM_SIZE) @@ -2618,7 +2618,7 @@ static int il3945_load_bsm(struct il_priv *il) udelay(10); } if (i < 100) - IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); + D_INFO("BSM write complete, poll %d iterations\n", i); else { IL_ERR(il, "BSM write did not complete!\n"); return -EIO; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 7807dc5..7f85834 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -160,7 +160,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - IL_DEBUG_CALIB(il, "silence a %u, b %u, c %u, 20-bcn max %u\n", + D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, silence_rssi_b, silence_rssi_c, silence_ref); @@ -184,7 +184,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); max_nrg_cck += 6; - IL_DEBUG_CALIB(il, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", rx_info->beacon_energy_a, rx_info->beacon_energy_b, rx_info->beacon_energy_c, max_nrg_cck - 6); @@ -194,15 +194,15 @@ static int il4965_sens_energy_cck(struct il_priv *il, data->num_in_cck_no_fa++; else data->num_in_cck_no_fa = 0; - IL_DEBUG_CALIB(il, "consecutive bcns with few false alarms = %u\n", + D_CALIB("consecutive bcns with few false alarms = %u\n", data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if ((false_alarms > max_false_alarms) && (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { - IL_DEBUG_CALIB(il, "norm FA %u > max FA %u\n", + D_CALIB("norm FA %u > max FA %u\n", false_alarms, max_false_alarms); - IL_DEBUG_CALIB(il, "... reducing sensitivity\n"); + D_CALIB("... reducing sensitivity\n"); data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ data->nrg_silence_ref = silence_ref; @@ -219,7 +219,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - (s32)silence_ref; - IL_DEBUG_CALIB(il, + D_CALIB( "norm FA %u < min FA %u, silence diff %d\n", false_alarms, min_false_alarms, data->nrg_auto_corr_silence_diff); @@ -234,18 +234,18 @@ static int il4965_sens_energy_cck(struct il_priv *il, ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { - IL_DEBUG_CALIB(il, "... increasing sensitivity\n"); + D_CALIB("... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); } else { - IL_DEBUG_CALIB(il, + D_CALIB( "... but not changing sensitivity\n"); } /* Else we got a healthy number of false alarms, keep status quo */ } else { - IL_DEBUG_CALIB(il, " FA in safe zone\n"); + D_CALIB(" FA in safe zone\n"); data->nrg_curr_state = IL_FA_GOOD_RANGE; /* Store for use in "fewer than desired" with later beacon */ @@ -255,7 +255,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, * give it some extra margin by reducing sensitivity again * (but don't go below measured energy of desired Rx) */ if (IL_FA_TOO_MANY == data->nrg_prev_state) { - IL_DEBUG_CALIB(il, "... increasing margin\n"); + D_CALIB("... increasing margin\n"); if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) data->nrg_th_cck -= NRG_MARGIN; else @@ -269,7 +269,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, * Lower value is higher energy, so we use max()! */ data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - IL_DEBUG_CALIB(il, "new nrg_th_cck %u\n", data->nrg_th_cck); + D_CALIB("new nrg_th_cck %u\n", data->nrg_th_cck); data->nrg_prev_state = data->nrg_curr_state; @@ -322,7 +322,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - IL_DEBUG_CALIB(il, "norm FA %u > max FA %u)\n", + D_CALIB("norm FA %u > max FA %u)\n", false_alarms, max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; @@ -345,7 +345,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - IL_DEBUG_CALIB(il, "norm FA %u < min FA %u\n", + D_CALIB("norm FA %u < min FA %u\n", false_alarms, min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; @@ -364,7 +364,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, data->auto_corr_ofdm_mrc_x1 = max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); } else { - IL_DEBUG_CALIB(il, "min FA %u < norm FA %u < max FA %u OK\n", + D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", min_false_alarms, false_alarms, max_false_alarms); } return 0; @@ -400,12 +400,12 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = cpu_to_le16(data->nrg_th_cca); - IL_DEBUG_CALIB(il, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, data->nrg_th_ofdm); - IL_DEBUG_CALIB(il, "cck: ac %u mrc %u thresh %u\n", + D_CALIB("cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, data->auto_corr_cck_mrc, data->nrg_th_cck); } @@ -434,7 +434,7 @@ static int il4965_sensitivity_write(struct il_priv *il) /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), sizeof(u16)*HD_TABLE_SIZE)) { - IL_DEBUG_CALIB(il, "No change in SENSITIVITY_CMD\n"); + D_CALIB("No change in SENSITIVITY_CMD\n"); return 0; } @@ -455,7 +455,7 @@ void il4965_init_sensitivity(struct il_priv *il) if (il->disable_sens_cal) return; - IL_DEBUG_CALIB(il, "Start il4965_init_sensitivity\n"); + D_CALIB("Start il4965_init_sensitivity\n"); /* Clear driver's sensitivity algo data */ data = &(il->sensitivity_data); @@ -496,7 +496,7 @@ void il4965_init_sensitivity(struct il_priv *il) data->last_fa_cnt_cck = 0; ret |= il4965_sensitivity_write(il); - IL_DEBUG_CALIB(il, "<sensitivity_data); if (!il_is_any_associated(il)) { - IL_DEBUG_CALIB(il, "<< - not associated\n"); + D_CALIB("<< - not associated\n"); return; } @@ -531,7 +531,7 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) cck = &(((struct il_notif_statistics *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(il, "<< invalid data.\n"); + D_CALIB("<< invalid data.\n"); spin_unlock_irqrestore(&il->lock, flags); return; } @@ -558,10 +558,10 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_CALIB(il, "rx_enable_time = %u usecs\n", rx_enable_time); + D_CALIB("rx_enable_time = %u usecs\n", rx_enable_time); if (!rx_enable_time) { - IL_DEBUG_CALIB(il, "<< RX Enable Time == 0!\n"); + D_CALIB("<< RX Enable Time == 0!\n"); return; } @@ -600,7 +600,7 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - IL_DEBUG_CALIB(il, + D_CALIB( "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); @@ -657,9 +657,9 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - IL_DEBUG_CALIB(il, "average_sig: a %d b %d c %d\n", + D_CALIB("average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], average_sig[2]); - IL_DEBUG_CALIB(il, "max_average_sig = %d, antenna %d\n", + D_CALIB("max_average_sig = %d, antenna %d\n", max_average_sig, max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ @@ -673,7 +673,7 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, data->disconn_array[i] = 1; else active_chains |= (1 << i); - IL_DEBUG_CALIB(il, "i = %d rssiDelta = %d " + D_CALIB("i = %d rssiDelta = %d " "disconn_array[i] = %d\n", i, rssi_delta, data->disconn_array[i]); } @@ -713,7 +713,7 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - IL_DEBUG_CALIB(il, + D_CALIB( "All Tx chains are disconnected W/A - declare %d as connected\n", first_chain); break; @@ -722,14 +722,14 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, if (active_chains != il->hw_params.valid_rx_ant && active_chains != il->chain_noise_data.active_chains) - IL_DEBUG_CALIB(il, + D_CALIB( "Detected that not all antennas are connected! " "Connected: %#x, valid: %#x.\n", active_chains, il->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - IL_DEBUG_CALIB(il, "active_chains (bitwise) = 0x%x\n", + D_CALIB("active_chains (bitwise) = 0x%x\n", active_chains); } @@ -762,7 +762,7 @@ static void il4965_gain_computation(struct il_priv *il, data->delta_gain_code[i] = 0; } } - IL_DEBUG_CALIB(il, "delta_gain_codes: a %d b %d c %d\n", + D_CALIB("delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], data->delta_gain_code[1], data->delta_gain_code[2]); @@ -780,7 +780,7 @@ static void il4965_gain_computation(struct il_priv *il, ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd); if (ret) - IL_DEBUG_CALIB(il, "fail sending cmd " + D_CALIB("fail sending cmd " "REPLY_PHY_CALIBRATION_CMD\n"); /* TODO we might want recalculate @@ -834,7 +834,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) */ if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { if (data->state == IL_CHAIN_NOISE_ALIVE) - IL_DEBUG_CALIB(il, "Wait for noise calib reset\n"); + D_CALIB("Wait for noise calib reset\n"); return; } @@ -844,7 +844,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(il, " << Interference data unavailable\n"); + D_CALIB(" << Interference data unavailable\n"); spin_unlock_irqrestore(&il->lock, flags); return; } @@ -861,7 +861,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { - IL_DEBUG_CALIB(il, "Stats not from chan=%d, band24=%d\n", + D_CALIB("Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); spin_unlock_irqrestore(&il->lock, flags); return; @@ -894,11 +894,11 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - IL_DEBUG_CALIB(il, "chan=%d, band24=%d, beacon=%d\n", + D_CALIB("chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, data->beacon_count); - IL_DEBUG_CALIB(il, "chain_sig: a %d b %d c %d\n", + D_CALIB("chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, chain_sig_c); - IL_DEBUG_CALIB(il, "chain_noise: a %d b %d c %d\n", + D_CALIB("chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: @@ -929,11 +929,11 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) } } - IL_DEBUG_CALIB(il, "average_noise: a %d b %d c %d\n", + D_CALIB("average_noise: a %d b %d c %d\n", average_noise[0], average_noise[1], average_noise[2]); - IL_DEBUG_CALIB(il, "min_average_noise = %d, antenna %d\n", + D_CALIB("min_average_noise = %d, antenna %d\n", min_average_noise, min_average_noise_antenna_i); il4965_gain_computation(il, average_noise, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 1564629..b51ae3d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -303,7 +303,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(il, "alloc_pages failed, " + D_INFO("alloc_pages failed, " "order: %d\n", il->hw_params.rx_page_order); @@ -456,7 +456,7 @@ static int il4965_calc_rssi(struct il_priv *il, if (valid_antennae & (1 << i)) max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - IL_DEBUG_STATS(il, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", + D_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], max_rssi, agc); @@ -519,7 +519,7 @@ static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) break; } - IL_DEBUG_RX(il, "decrypt_in:0x%x decrypt_out = 0x%x\n", + D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; @@ -537,7 +537,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP(il, + D_DROP( "Dropping packet while interface is not open.\n"); return; } @@ -611,14 +611,14 @@ void il4965_rx_reply_rx(struct il_priv *il, } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", + D_DROP("dsp size out of range [0,20]: %d/n", phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", + D_RX("Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -647,7 +647,7 @@ void il4965_rx_reply_rx(struct il_priv *il, rx_status.signal = il4965_calc_rssi(il, phy_res); il_dbg_log_rx_data_frame(il, len, header); - IL_DEBUG_STATS(il, "Rssi %d, TSF %llu\n", + D_STATS("Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* @@ -729,7 +729,7 @@ static int il4965_get_channels_for_scan(struct il_priv *il, ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(il, + D_SCAN( "Channel %d is INVALID for this band.\n", channel); continue; @@ -759,7 +759,7 @@ static int il4965_get_channels_for_scan(struct il_priv *il, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - IL_DEBUG_SCAN(il, "Scanning ch=%d prob=0x%X [%s %d]\n", + D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", channel, le32_to_cpu(scan_ch->type), (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", @@ -770,7 +770,7 @@ static int il4965_get_channels_for_scan(struct il_priv *il, added++; } - IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); + D_SCAN("total channels to scan %d\n", added); return added; } @@ -805,7 +805,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!il->scan_cmd) { - IL_DEBUG_SCAN(il, + D_SCAN( "fail to allocate memory for scan\n"); return -ENOMEM; } @@ -822,7 +822,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(il, "Scanning while associated...\n"); + D_INFO("Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; @@ -834,13 +834,13 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan_suspend_time = (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", + D_SCAN("suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + D_SCAN("Kicking off active scan\n"); for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!il->scan_request->ssids[i].ssid_len) @@ -856,7 +856,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) } is_active = true; } else - IL_DEBUG_SCAN(il, "Start passive scan.\n"); + D_SCAN("Start passive scan.\n"); scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; scan->tx_cmd.sta_id = ctx->bcast_sta_id; @@ -923,7 +923,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) if (!active_chains) active_chains = rx_ant; - IL_DEBUG_SCAN(il, "chain_noise_data.active_chains: %u\n", + D_SCAN("chain_noise_data.active_chains: %u\n", il->chain_noise_data.active_chains); rx_ant = il4965_first_antenna(active_chains); @@ -951,7 +951,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) is_active, n_probes, (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); + D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } @@ -990,7 +990,7 @@ void il4965_free_tfds_in_queue(struct il_priv *il, if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) il->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { - IL_DEBUG_TX(il, "free more than tfds_in_queue (%u:%d)\n", + D_TX("free more than tfds_in_queue (%u:%d)\n", il->stations[sta_id].tid[tid].tfds_in_queue, freed); il->stations[sta_id].tid[tid].tfds_in_queue = 0; @@ -1111,7 +1111,7 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - IL_DEBUG_ASSOC(il, "rx_chain=0x%X active=%d idle=%d\n", + D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, active_rx_cnt, idle_rx_cnt); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 782ec77..b53cf1b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -358,7 +358,7 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, load = il4965_rs_tl_get_load(lq_data, tid); if (load > IL_AGG_LOAD_THRESHOLD) { - IL_DEBUG_HT(il, "Starting Tx agg: STA: %pM tid: %d\n", + D_HT("Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { @@ -707,7 +707,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); + D_RATE("Skipping masked lower rate: %d\n", low); } high = index; @@ -717,7 +717,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); + D_RATE("Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -817,15 +817,15 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE(il, + D_RATE( "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { - IL_DEBUG_RATE(il, "Station rate scaling not created yet.\n"); + D_RATE("Station rate scaling not created yet.\n"); return; } else if (!lq_sta->drv) { - IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); + D_RATE("Rate scaling not initialized yet.\n"); return; } @@ -880,7 +880,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, (!!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || (rs_index != mac_index)) { - IL_DEBUG_RATE(il, + D_RATE( "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); /* @@ -910,15 +910,15 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - IL_DEBUG_RATE(il, + D_RATE( "Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - IL_DEBUG_RATE(il, "active- lq:%x, ant:%x, SGI:%d\n", + D_RATE("active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - IL_DEBUG_RATE(il, "search- lq:%x, ant:%x, SGI:%d\n", + D_RATE("search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - IL_DEBUG_RATE(il, "actual- lq:%x, ant:%x, SGI:%d\n", + D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection @@ -1004,7 +1004,7 @@ done: static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, struct il_lq_sta *lq_sta) { - IL_DEBUG_RATE(il, "we are staying in the same table\n"); + D_RATE("we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; @@ -1194,7 +1194,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, if (il->hw_params.tx_chains_num < 2) return -1; - IL_DEBUG_RATE(il, "LQ: try to switch to MIMO2\n"); + D_RATE("LQ: try to switch to MIMO2\n"); tbl->lq_type = LQ_MIMO2; tbl->is_dup = lq_sta->is_dup; @@ -1211,10 +1211,10 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(il, "LQ: MIMO2 best rate %d mask %X\n", + D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(il, + D_RATE( "Can't switch with index %d rate mask %x\n", rate, rate_mask); return -1; @@ -1222,7 +1222,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1245,7 +1245,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - IL_DEBUG_RATE(il, "LQ: try to switch to SISO\n"); + D_RATE("LQ: try to switch to SISO\n"); tbl->is_dup = lq_sta->is_dup; tbl->lq_type = LQ_SISO; @@ -1264,16 +1264,16 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, il4965_rs_set_expected_tpt_table(lq_sta, tbl); rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(il, "LQ: get best rate %d mask %X\n", rate, rate_mask); + D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(il, + D_RATE( "can not switch with index %d rate mask %x\n", rate, rate_mask); return -1; } tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1307,7 +1307,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, switch (tbl->action) { case IL_LEGACY_SWITCH_ANTENNA1: case IL_LEGACY_SWITCH_ANTENNA2: - IL_DEBUG_RATE(il, "LQ: Legacy toggle Antenna\n"); + D_RATE("LQ: Legacy toggle Antenna\n"); if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && tx_chains_num <= 1) || @@ -1331,7 +1331,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, } break; case IL_LEGACY_SWITCH_SISO: - IL_DEBUG_RATE(il, "LQ: Legacy switch to SISO\n"); + D_RATE("LQ: Legacy switch to SISO\n"); /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); @@ -1347,7 +1347,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, case IL_LEGACY_SWITCH_MIMO2_AB: case IL_LEGACY_SWITCH_MIMO2_AC: case IL_LEGACY_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(il, "LQ: Legacy switch to MIMO2\n"); + D_RATE("LQ: Legacy switch to MIMO2\n"); /* Set up search table to try MIMO */ memcpy(search_tbl, tbl, sz); @@ -1424,7 +1424,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, switch (tbl->action) { case IL_SISO_SWITCH_ANTENNA1: case IL_SISO_SWITCH_ANTENNA2: - IL_DEBUG_RATE(il, "LQ: SISO toggle Antenna\n"); + D_RATE("LQ: SISO toggle Antenna\n"); if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && tx_chains_num <= 1) || (tbl->action == IL_SISO_SWITCH_ANTENNA2 && @@ -1444,7 +1444,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, case IL_SISO_SWITCH_MIMO2_AB: case IL_SISO_SWITCH_MIMO2_AC: case IL_SISO_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(il, "LQ: SISO switch to MIMO2\n"); + D_RATE("LQ: SISO switch to MIMO2\n"); memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; @@ -1473,7 +1473,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(il, "LQ: SISO toggle SGI/NGI\n"); + D_RATE("LQ: SISO toggle SGI/NGI\n"); memcpy(search_tbl, tbl, sz); if (is_green) { @@ -1545,7 +1545,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, switch (tbl->action) { case IL_MIMO2_SWITCH_ANTENNA1: case IL_MIMO2_SWITCH_ANTENNA2: - IL_DEBUG_RATE(il, "LQ: MIMO2 toggle Antennas\n"); + D_RATE("LQ: MIMO2 toggle Antennas\n"); if (tx_chains_num <= 2) break; @@ -1563,7 +1563,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, case IL_MIMO2_SWITCH_SISO_A: case IL_MIMO2_SWITCH_SISO_B: case IL_MIMO2_SWITCH_SISO_C: - IL_DEBUG_RATE(il, "LQ: MIMO2 switch to SISO\n"); + D_RATE("LQ: MIMO2 switch to SISO\n"); /* Set up new search table for SISO */ memcpy(search_tbl, tbl, sz); @@ -1595,7 +1595,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(il, "LQ: MIMO2 toggle SGI/NGI\n"); + D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); /* Set up new search table for MIMO2 */ memcpy(search_tbl, tbl, sz); @@ -1684,7 +1684,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) (lq_sta->total_success > lq_sta->max_success_limit) || ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) && (flush_interval_passed))) { - IL_DEBUG_RATE(il, "LQ: stay is expired %d %d %d\n:", + D_RATE("LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, flush_interval_passed); @@ -1707,7 +1707,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) lq_sta->table_count_limit) { lq_sta->table_count = 0; - IL_DEBUG_RATE(il, + D_RATE( "LQ: stay in table clear win\n"); for (i = 0; i < IL_RATE_COUNT; i++) il4965_rs_rate_scale_clear_window( @@ -1783,7 +1783,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); + D_RATE("rate scale calculate new rate for skb\n"); /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ @@ -1826,13 +1826,13 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* current tx rate */ index = lq_sta->last_txrate_idx; - IL_DEBUG_RATE(il, "Rate scale index %d for type %d\n", index, + D_RATE("Rate scale index %d for type %d\n", index, tbl->lq_type); /* rates available for this association, and for modulation mode */ rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - IL_DEBUG_RATE(il, "mask 0x%04X\n", rate_mask); + D_RATE("mask 0x%04X\n", rate_mask); /* mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { @@ -1892,7 +1892,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, fail_count = window->counter - window->success_counter; if ((fail_count < IL_RATE_MIN_FAILURE_TH) && (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { - IL_DEBUG_RATE(il, "LQ: still below TH. succ=%d total=%d " + D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); @@ -1922,7 +1922,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * continuing to use the setup that we've been trying. */ if (window->average_tpt > lq_sta->last_tpt) { - IL_DEBUG_RATE(il, "LQ: SWITCHING TO NEW TABLE " + D_RATE("LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1938,7 +1938,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Else poor success; go back to mode in "active" table */ } else { - IL_DEBUG_RATE(il, "LQ: GOING BACK TO THE OLD TABLE " + D_RATE("LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1992,7 +1992,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Too many failures, decrease rate */ if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of low success_ratio\n"); scale_action = -1; @@ -2031,7 +2031,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; } else if (sr >= IL_RATE_INCREASE_TH) { @@ -2070,7 +2070,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; } - IL_DEBUG_RATE(il, "choose rate scale index %d action %d low %d " + D_RATE("choose rate scale index %d action %d low %d " "high %d type %d\n", index, scale_action, low, high, tbl->lq_type); @@ -2118,7 +2118,7 @@ lq_update: /* Use new "search" start rate */ index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - IL_DEBUG_RATE(il, + D_RATE( "Switch current mcs: %X index: %d\n", tbl->current_rate, index); il4965_rs_fill_link_cmd(il, lq_sta, @@ -2138,7 +2138,7 @@ lq_update: tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && lq_sta->action_counter > tbl1->max_search) { - IL_DEBUG_RATE(il, "LQ: STAY in legacy table\n"); + D_RATE("LQ: STAY in legacy table\n"); il4965_rs_set_stay_in_table(il, 1, lq_sta); } @@ -2153,7 +2153,7 @@ lq_update: tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { - IL_DEBUG_RATE(il, + D_RATE( "try to aggregate tid %d\n", tid); il4965_rs_tl_turn_on_agg(il, tid, @@ -2251,7 +2251,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, struct il_lq_sta *lq_sta = il_sta; int rate_idx; - IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); + D_RATE("rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { @@ -2266,7 +2266,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, /* Treat uninitialized rate scaling data same as non-existing. */ if (lq_sta && !lq_sta->drv) { - IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); + D_RATE("Rate scaling not initialized yet.\n"); il_sta = NULL; } @@ -2323,7 +2323,7 @@ static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, struct il_priv *il; il = (struct il_priv *)il_rate; - IL_DEBUG_RATE(il, "create station rate scale window\n"); + D_RATE("create station rate scale window\n"); lq_sta = &sta_priv->lq_sta; @@ -2365,7 +2365,7 @@ il4965_rs_rate_init(struct il_priv *il, il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); - IL_DEBUG_RATE(il, "LQ:" + D_RATE("LQ:" "*** rate scale station global init for station %d ***\n", sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -2561,8 +2561,8 @@ static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, { struct il_priv *il __maybe_unused = il_r; - IL_DEBUG_RATE(il, "enter\n"); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("enter\n"); + D_RATE("leave\n"); } @@ -2587,16 +2587,16 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, >> RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; - IL_DEBUG_RATE(il, "Fixed rate ON\n"); + D_RATE("Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; IL_ERR(il, "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); - IL_DEBUG_RATE(il, "Fixed rate OFF\n"); + D_RATE("Fixed rate OFF\n"); } } else { - IL_DEBUG_RATE(il, "Fixed rate OFF\n"); + D_RATE("Fixed rate OFF\n"); } } @@ -2627,7 +2627,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - IL_DEBUG_RATE(il, "sta_id %d rate 0x%X\n", + D_RATE("sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index c987c80..45e8a24 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -51,7 +51,7 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > il->missed_beacon_threshold) { - IL_DEBUG_CALIB(il, + D_CALIB( "missed bcn cnsq %d totl %d rcd %d expctd %d\n", le32_to_cpu(missed_beacon->consecutive_missed_beacons), le32_to_cpu(missed_beacon->total_missed_becons), @@ -100,7 +100,7 @@ static void il4965_rx_calc_noise(struct il_priv *il) else last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - IL_DEBUG_CALIB(il, "inband silence a %u, b %u, c %u, dBm %d\n", + D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, bcn_silence_b, bcn_silence_c, last_rx_noise); } @@ -157,7 +157,7 @@ void il4965_rx_statistics(struct il_priv *il, int change; struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(il, + D_RX( "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il_notif_statistics), le32_to_cpu(pkt->len_n_flags) & @@ -209,7 +209,7 @@ void il4965_reply_statistics(struct il_priv *il, memset(&il->_4965.max_delta, 0, sizeof(struct il_notif_statistics)); #endif - IL_DEBUG_RX(il, "Statistics have been cleared\n"); + D_RX("Statistics have been cleared\n"); } il4965_rx_statistics(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 0fbc991..3019baf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -199,18 +199,18 @@ int il4965_remove_default_wep_key(struct il_priv *il, lockdep_assert_held(&il->mutex); - IL_DEBUG_WEP(il, "Removing default WEP key: idx=%d\n", + D_WEP("Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); if (il_is_rfkill(il)) { - IL_DEBUG_WEP(il, + D_WEP( "Not sending REPLY_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } ret = il4965_static_wepkey_cmd(il, ctx, 1); - IL_DEBUG_WEP(il, "Remove default WEP key: idx=%d ret=%d\n", + D_WEP("Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; @@ -226,7 +226,7 @@ int il4965_set_default_wep_key(struct il_priv *il, if (keyconf->keylen != WEP_KEY_LEN_128 && keyconf->keylen != WEP_KEY_LEN_64) { - IL_DEBUG_WEP(il, "Bad WEP key length %d\n", keyconf->keylen); + D_WEP("Bad WEP key length %d\n", keyconf->keylen); return -EINVAL; } @@ -239,7 +239,7 @@ int il4965_set_default_wep_key(struct il_priv *il, keyconf->keylen); ret = il4965_static_wepkey_cmd(il, ctx, false); - IL_DEBUG_WEP(il, "Set default WEP key: len=%d idx=%d ret=%d\n", + D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, keyconf->keyidx, ret); return ret; @@ -453,7 +453,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - IL_DEBUG_WEP(il, "Remove dynamic key: idx=%d sta=%d\n", + D_WEP("Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { @@ -488,7 +488,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; if (il_is_rfkill(il)) { - IL_DEBUG_WEP(il, + D_WEP( "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; @@ -531,7 +531,7 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, ret = -EINVAL; } - IL_DEBUG_WEP(il, + D_WEP( "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -605,7 +605,7 @@ static int il4965_update_bcast_station(struct il_priv *il, if (il->stations[sta_id].lq) kfree(il->stations[sta_id].lq); else - IL_DEBUG_INFO(il, + D_INFO( "Bcast station rate scaling has not been initialized yet.\n"); il->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&il->sta_lock, flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index fcc938e..efc21be 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -235,13 +235,13 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); if (info->flags & IEEE80211_TX_CTL_AMPDU) tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); + D_TX("tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - IL_DEBUG_TX(il, "tx_cmd with tkip hwcrypto\n"); + D_TX("tx_cmd with tkip hwcrypto\n"); break; case WLAN_CIPHER_SUITE_WEP104: @@ -253,7 +253,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - IL_DEBUG_TX(il, "Configuring packet for WEP encryption " + D_TX("Configuring packet for WEP encryption " "with key %d\n", keyconf->keyidx); break; @@ -298,7 +298,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) spin_lock_irqsave(&il->lock, flags); if (il_is_rfkill(il)) { - IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); + D_DROP("Dropping - RF KILL\n"); goto drop_unlock; } @@ -306,11 +306,11 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(il, "Sending AUTH frame\n"); + D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(il, "Sending ASSOC frame\n"); + D_TX("Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(il, "Sending REASSOC frame\n"); + D_TX("Sending REASSOC frame\n"); #endif hdr_len = ieee80211_hdrlen(fc); @@ -323,13 +323,13 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } - IL_DEBUG_TX(il, "station Id %d\n", sta_id); + D_TX("station Id %d\n", sta_id); if (sta) sta_priv = (void *)sta->drv_priv; @@ -499,9 +499,9 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - IL_DEBUG_TX(il, "sequence nr = 0X%x\n", + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); @@ -909,11 +909,11 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, spin_lock_irqsave(&il->sta_lock, flags); tid_data = &il->stations[sta_id].tid[tid]; if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(il, "HW queue is empty\n"); + D_HT("HW queue is empty\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - IL_DEBUG_HT(il, + D_HT( "HW queue is NOT empty: %d packets in HW queue\n", tid_data->tfds_in_queue); tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; @@ -991,7 +991,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, * queue we selected previously, i.e. before the * session was really started completely. */ - IL_DEBUG_HT(il, "AGG stop before setup done\n"); + D_HT("AGG stop before setup done\n"); goto turn_off; case IL_AGG_ON: break; @@ -1004,14 +1004,14 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, /* The queue is not empty */ if (write_ptr != read_ptr) { - IL_DEBUG_HT(il, "Stopping a non empty AGG HW QUEUE\n"); + D_HT("Stopping a non empty AGG HW QUEUE\n"); il->stations[sta_id].tid[tid].agg.state = IL_EMPTYING_HW_QUEUE_DELBA; spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - IL_DEBUG_HT(il, "HW queue is empty\n"); + D_HT("HW queue is empty\n"); turn_off: il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; @@ -1054,7 +1054,7 @@ int il4965_txq_check_empty(struct il_priv *il, (q->read_ptr == q->write_ptr)) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - IL_DEBUG_HT(il, + D_HT( "HW queue empty: continue DELBA flow\n"); il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); tid_data->agg.state = IL_AGG_OFF; @@ -1064,7 +1064,7 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(il, + D_HT( "HW queue empty: continue ADDBA flow\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); @@ -1169,7 +1169,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - IL_DEBUG_TX_REPLY(il, "BA %d %d\n", agg->start_idx, + D_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx window bits */ @@ -1178,7 +1178,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, sh += 0x100; if (agg->frame_count > (64 - sh)) { - IL_DEBUG_TX_REPLY(il, "more frames than bitmap size"); + D_TX_REPLY("more frames than bitmap size"); return -1; } @@ -1195,7 +1195,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - IL_DEBUG_TX_REPLY(il, "%s ON i=%d idx=%d raw=%d\n", + D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff, agg->start_idx + i); @@ -1203,7 +1203,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, ++i; } - IL_DEBUG_TX_REPLY(il, "Bitmap %llx\n", + D_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); @@ -1282,7 +1282,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - IL_DEBUG_TX_REPLY(il, + D_TX_REPLY( "BA scd_flow %d does not match txq_id %d\n", scd_flow, agg->txq_id); return; @@ -1293,12 +1293,12 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); - IL_DEBUG_TX_REPLY(il, "REPLY_COMPRESSED_BA [%d] Received from %pM, " + D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); - IL_DEBUG_TX_REPLY(il, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," + D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, @@ -1306,7 +1306,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, (unsigned long long)le64_to_cpu(ba_resp->bitmap), ba_resp->scd_flow, ba_resp->scd_ssn); - IL_DEBUG_TX_REPLY(il, "DAT start_idx = %d, bitmap = 0x%llx\n", + D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, (unsigned long long)agg->bitmap); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index d4dc597..d1e1775 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -55,7 +55,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ @@ -87,7 +87,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, int ret = 0; u32 errcnt; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); @@ -110,7 +110,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, } if (!errcnt) - IL_DEBUG_INFO(il, + D_INFO( "ucode image in INSTRUCTION memory is good\n"); return ret; @@ -131,7 +131,7 @@ int il4965_verify_ucode(struct il_priv *il) len = il->ucode_boot.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); + D_INFO("Bootstrap uCode is good in inst SRAM\n"); return 0; } @@ -140,7 +140,7 @@ int il4965_verify_ucode(struct il_priv *il) len = il->ucode_init.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); + D_INFO("Initialize uCode is good in inst SRAM\n"); return 0; } @@ -149,7 +149,7 @@ int il4965_verify_ucode(struct il_priv *il) len = il->ucode_code.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); + D_INFO("Runtime uCode is good in inst SRAM\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 01fa6c8..cc28e0e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -69,7 +69,7 @@ static int il4965_verify_bsm(struct il_priv *il) u32 reg; u32 val; - IL_DEBUG_INFO(il, "Begin verify bsm\n"); + D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ val = il_read_prph(il, BSM_WR_DWCOUNT_REG); @@ -87,7 +87,7 @@ static int il4965_verify_bsm(struct il_priv *il) } } - IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); + D_INFO("BSM bootstrap uCode image OK\n"); return 0; } @@ -137,7 +137,7 @@ static int il4965_load_bsm(struct il_priv *il) u32 reg_offset; int ret; - IL_DEBUG_INFO(il, "Begin load bsm\n"); + D_INFO("Begin load bsm\n"); il->ucode_type = UCODE_RT; @@ -189,7 +189,7 @@ static int il4965_load_bsm(struct il_priv *il) udelay(10); } if (i < 100) - IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); + D_INFO("BSM write complete, poll %d iterations\n", i); else { IL_ERR(il, "BSM write did not complete!\n"); return -EIO; @@ -233,7 +233,7 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) * that all new ptr/size info is in place */ il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); + D_INFO("Runtime uCode pointers are set.\n"); return ret; } @@ -257,7 +257,7 @@ static void il4965_init_alive_start(struct il_priv *il) if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); + D_INFO("Bad \"initialize\" uCode load.\n"); goto restart; } @@ -267,11 +267,11 @@ static void il4965_init_alive_start(struct il_priv *il) /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); if (il4965_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); + D_INFO("Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -346,7 +346,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) IL_ERR(il, "Could not send REPLY_PHY_CALIBRATION_CMD\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; - IL_DEBUG_CALIB(il, "Run chain_noise_calibrate\n"); + D_CALIB("Run chain_noise_calibrate\n"); } } @@ -556,7 +556,7 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, ch_i2 = il->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - IL_DEBUG_TXPOWER(il, "channel %d subband %d factory cal ch %d & %d\n", + D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", channel, s, ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { @@ -586,16 +586,16 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, m1->pa_det, ch_i2, m2->pa_det); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, m1->actual_pow, m2->actual_pow, omeas->actual_pow); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, m1->gain_idx, m2->gain_idx, omeas->gain_idx); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, m1->pa_det, m2->pa_det, omeas->pa_det); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, m1->temperature, m2->temperature, omeas->temperature); @@ -900,7 +900,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - IL_DEBUG_TXPOWER(il, "chan %d band %d is_ht40 %d\n", channel, band, + D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, is_ht40); ch_info = il_get_channel_info(il, il->band, channel); @@ -917,7 +917,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, return txatten_grp; } - IL_DEBUG_TXPOWER(il, "channel %d belongs to txatten group %d\n", + D_TXPOWER("channel %d belongs to txatten group %d\n", channel, txatten_grp); if (is_ht40) { @@ -967,7 +967,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, voltage_compensation = il4965_get_voltage_compensation(voltage, init_voltage); - IL_DEBUG_TXPOWER(il, "curr volt %d eeprom volt %d volt comp %d\n", + D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", init_voltage, voltage, voltage_compensation); @@ -998,13 +998,13 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, factory_gain_index[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; - IL_DEBUG_TXPOWER(il, "chain = %d\n", c); - IL_DEBUG_TXPOWER(il, "fctry tmp %d, " + D_TXPOWER("chain = %d\n", c); + D_TXPOWER("fctry tmp %d, " "curr tmp %d, comp %d steps\n", factory_temp, current_temp, temperature_comp[c]); - IL_DEBUG_TXPOWER(il, "fctry idx %d, fctry pwr %d\n", + D_TXPOWER("fctry idx %d, fctry pwr %d\n", factory_gain_index[c], factory_actual_pwr[c]); } @@ -1037,7 +1037,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - IL_DEBUG_TXPOWER(il, "rate %d sat %d reg %d usr %d tgt %d\n", + D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", i, saturation_power - back_off_table[i], current_regulatory, user_target_power, target_power); @@ -1061,7 +1061,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, voltage_compensation + atten_value); -/* IL_DEBUG_TXPOWER(il, "calculated txpower index %d\n", +/* D_TXPOWER("calculated txpower index %d\n", power_index); */ if (power_index < get_min_power_index(i, band)) @@ -1094,7 +1094,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, tx_power.s.dsp_predis_atten[c] = gain_table[band][power_index].dsp; - IL_DEBUG_TXPOWER(il, "chain %d mimo %d index %d " + D_TXPOWER("chain %d mimo %d index %d " "gain 0x%02x dsp %d\n", c, atten_value, power_index, tx_power.s.radio_tx_gain[c], @@ -1167,7 +1167,7 @@ static int il4965_send_rxon_assoc(struct il_priv *il, rxon2->ofdm_ht_dual_stream_basic_rates) && (rxon1->rx_chain == rxon2->rx_chain) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); + D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1217,7 +1217,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) */ if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && (il->switch_channel != ctx->staging.channel)) { - IL_DEBUG_11H(il, "abort channel switch on %d\n", + D_11H("abort channel switch on %d\n", le16_to_cpu(il->switch_channel)); il_chswitch_done(il, false); } @@ -1247,7 +1247,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * we must clear the associated from the active configuration * before we apply the new config */ if (il_is_associated_ctx(ctx) && new_assoc) { - IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); + D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; ret = il_send_cmd_pdu(il, ctx->rxon_cmd, @@ -1270,7 +1270,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) } } - IL_DEBUG_INFO(il, "Sending RXON\n" + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1292,7 +1292,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) IL_ERR(il, "Error setting new RXON (%d)\n", ret); return ret; } - IL_DEBUG_INFO(il, "Return from !new_assoc RXON.\n"); + D_INFO("Return from !new_assoc RXON.\n"); memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); il_clear_ucode_stations(il, ctx); il_restore_stations(il, ctx); @@ -1387,7 +1387,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, ucode_switch_time, beacon_interval); } - IL_DEBUG_11H(il, "uCode time for the switch is 0x%x\n", + D_11H("uCode time for the switch is 0x%x\n", cmd.switch_time); ch_info = il_get_channel_info(il, il->band, ch); if (ch_info) @@ -1401,7 +1401,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, ctrl_chan_high, &cmd.tx_power); if (rc) { - IL_DEBUG_11H(il, "error:%d fill txpower_tbl\n", rc); + D_11H("error:%d fill txpower_tbl\n", rc); return rc; } @@ -1450,13 +1450,13 @@ static int il4965_hw_get_temperature(struct il_priv *il) if (test_bit(STATUS_TEMPERATURE, &il->status) && (il->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - IL_DEBUG_TEMP(il, "Running HT40 temperature calibration\n"); + D_TEMP("Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); } else { - IL_DEBUG_TEMP(il, "Running temperature calibration\n"); + D_TEMP("Running temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); @@ -1476,7 +1476,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) vt = sign_extend32(le32_to_cpu(il->_4965.statistics. general.common.temperature), 23); - IL_DEBUG_TEMP(il, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { IL_ERR(il, "Calibration conflict R1 == R3\n"); @@ -1489,7 +1489,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) temperature /= (R3 - R1); temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - IL_DEBUG_TEMP(il, "Calibrated temperature: %dK, %dC\n", + D_TEMP("Calibrated temperature: %dK, %dC\n", temperature, KELVIN_TO_CELSIUS(temperature)); return temperature; @@ -1512,7 +1512,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) int temp_diff; if (!test_bit(STATUS_STATISTICS, &il->status)) { - IL_DEBUG_TEMP(il, "Temperature not updated -- no statistics.\n"); + D_TEMP("Temperature not updated -- no statistics.\n"); return 0; } @@ -1520,19 +1520,19 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(il, "Getting cooler, delta %d\n", temp_diff); + D_POWER("Getting cooler, delta %d\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(il, "Temperature unchanged\n"); + D_POWER("Temperature unchanged\n"); else - IL_DEBUG_POWER(il, "Getting warmer, delta %d\n", temp_diff); + D_POWER("Getting warmer, delta %d\n", temp_diff); if (temp_diff < IL_TEMPERATURE_THRESHOLD) { - IL_DEBUG_POWER(il, " => thermal txpower calib not needed\n"); + D_POWER(" => thermal txpower calib not needed\n"); return 0; } - IL_DEBUG_POWER(il, " => thermal txpower calib needed\n"); + D_POWER(" => thermal txpower calib needed\n"); return 1; } @@ -1547,12 +1547,12 @@ static void il4965_temperature_calib(struct il_priv *il) if (il->temperature != temp) { if (il->temperature) - IL_DEBUG_TEMP(il, "Temperature changed " + D_TEMP("Temperature changed " "from %dC to %dC\n", KELVIN_TO_CELSIUS(il->temperature), KELVIN_TO_CELSIUS(temp)); else - IL_DEBUG_TEMP(il, "Temperature " + D_TEMP("Temperature " "initialized to %dC\n", KELVIN_TO_CELSIUS(temp)); } @@ -1617,7 +1617,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, int i, sh, idx; u16 seq; if (agg->wait_for_ba) - IL_DEBUG_TX_REPLY(il, "got tx response w/o block-ack\n"); + D_TX_REPLY("got tx response w/o block-ack\n"); agg->frame_count = tx_resp->frame_count; agg->start_idx = start_idx; @@ -1630,7 +1630,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, status = le16_to_cpu(frame_status[0].status); idx = start_idx; - IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, StartIdx=%d idx=%d\n", + D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", agg->frame_count, agg->start_idx, idx); info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); @@ -1639,9 +1639,9 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, info->flags |= il4965_tx_status_to_mac80211(status); il4965_hwrate_to_tx_control(il, rate_n_flags, info); - IL_DEBUG_TX_REPLY(il, "1 Frame 0x%x failure :%d\n", + D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(il, "Rate Info rate_n_flags=%x\n", rate_n_flags); + D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; } else { @@ -1661,7 +1661,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, AGG_TX_STATE_ABORT_MSK)) continue; - IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, txq_id=%d idx=%d\n", + D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", agg->frame_count, txq_id, idx); hdr = il_tx_queue_get_hdr(il, txq_id, idx); @@ -1681,7 +1681,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, return -1; } - IL_DEBUG_TX_REPLY(il, "AGG Frame i=%d idx %d seq=%d\n", + D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx, SEQ_TO_SN(sc)); sh = idx - start; @@ -1699,13 +1699,13 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sh = 0; } bitmap |= 1ULL << sh; - IL_DEBUG_TX_REPLY(il, "start=%d bitmap=0x%llx\n", + D_TX_REPLY("start=%d bitmap=0x%llx\n", start, (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; - IL_DEBUG_TX_REPLY(il, "Frames %d start_idx=%d bitmap=0x%llx\n", + D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", agg->frame_count, agg->start_idx, (unsigned long long)agg->bitmap); @@ -1737,7 +1737,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) goto out; } - IL_DEBUG_ASSOC(il, "can not find STA %pM total %d\n", + D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations); out: @@ -1830,7 +1830,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, if (txq->q.read_ptr != (scd_ssn & 0xff)) { index = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); - IL_DEBUG_TX_REPLY(il, "Retry scheduler reclaim scd_ssn " + D_TX_REPLY("Retry scheduler reclaim scd_ssn " "%d index %d\n", scd_ssn , index); freed = il4965_tx_queue_reclaim(il, txq_id, index); if (qc) @@ -1849,7 +1849,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, le32_to_cpu(tx_resp->rate_n_flags), info); - IL_DEBUG_TX_REPLY(il, "TXQ %d status %s (0x%08x) " + D_TX_REPLY("TXQ %d status %s (0x%08x) " "rate_n_flags 0x%x retries %d\n", txq_id, il4965_get_tx_fail_reason(status), status, @@ -1860,7 +1860,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, if (qc && likely(sta_id != IL_INVALID_STATION)) il4965_free_tfds_in_queue(il, sta_id, tid, freed); else if (sta_id == IL_INVALID_STATION) - IL_DEBUG_TX_REPLY(il, "Station not known\n"); + D_TX_REPLY("Station not known\n"); if (il->mac80211_registered && (il_queue_space(&txq->q) > txq->q.low_mark)) @@ -1882,7 +1882,7 @@ static void il4965_rx_beacon_notif(struct il_priv *il, u8 rate __maybe_unused = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(il, "beacon status %#x, retries:%d ibssmgr:%d " + D_RX("beacon status %#x, retries:%d ibssmgr:%d " "tsf:0x%.8x%.8x rate:%d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1955,7 +1955,7 @@ static void il4965_post_associate(struct il_priv *il) ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", + D_ASSOC("assoc id %d beacon interval %d\n", vif->bss_conf.aid, vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) @@ -1972,7 +1972,7 @@ static void il4965_post_associate(struct il_priv *il) il_commit_rxon(il, ctx); - IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", + D_ASSOC("Associated as %d to: %pM\n", vif->bss_conf.aid, ctx->active.bssid_addr); switch (vif->type) { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index a768e78..e6c7e9d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -164,7 +164,7 @@ int il_init_geos(struct il_priv *il) if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - IL_DEBUG_INFO(il, "Geography modes already initialized.\n"); + D_INFO("Geography modes already initialized.\n"); set_bit(STATUS_GEO_CONFIGURED, &il->status); return 0; } @@ -239,7 +239,7 @@ int il_init_geos(struct il_priv *il) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - IL_DEBUG_INFO(il, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, geo_ch->center_freq, il_is_channel_a_band(ch) ? "5.2" : "2.4", geo_ch->flags & IEEE80211_CHAN_DISABLED ? @@ -396,7 +396,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - IL_DEBUG_ASSOC(il, + D_ASSOC( "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), @@ -512,13 +512,13 @@ int il_full_rxon_required(struct il_priv *il, #define CHK(cond) \ if ((cond)) { \ - IL_DEBUG_INFO(il, "need full RXON - " #cond "\n"); \ + D_INFO("need full RXON - " #cond "\n"); \ return 1; \ } #define CHK_NEQ(c1, c2) \ if ((c1) != (c2)) { \ - IL_DEBUG_INFO(il, "need full RXON - " \ + D_INFO("need full RXON - " \ #c1 " != " #c2 " - %d != %d\n", \ (c1), (c2)); \ return 1; \ @@ -638,7 +638,7 @@ static void _il_set_rxon_ht(struct il_priv *il, if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - IL_DEBUG_ASSOC(il, "rxon flags 0x%X operation mode :0x%X " + D_ASSOC("rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), ctx->ht.protection, ctx->ht.extension_chan_offset); @@ -720,7 +720,7 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, il->band = band; - IL_DEBUG_INFO(il, "Staging channel set to %d [%d]\n", channel, band); + D_INFO("Staging channel set to %d [%d]\n", channel, band); return 0; } @@ -840,7 +840,7 @@ void il_set_rate(struct il_priv *il) il->active_rate |= (1 << rate->hw_value); } - IL_DEBUG_RATE(il, "Set active_rate = %0x\n", il->active_rate); + D_RATE("Set active_rate = %0x\n", il->active_rate); for_each_context(il, ctx) { ctx->staging.cck_basic_rates = @@ -878,7 +878,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - IL_DEBUG_11H(il, "CSA notif: channel %d\n", + D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel)); il_chswitch_done(il, true); } else { @@ -895,21 +895,21 @@ void il_print_rx_config_cmd(struct il_priv *il, { struct il_rxon_cmd *rxon = &ctx->staging; - IL_DEBUG_RADIO(il, "RX CONFIG:\n"); + D_RADIO("RX CONFIG:\n"); il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - IL_DEBUG_RADIO(il, "u16 channel: 0x%x\n", + D_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); - IL_DEBUG_RADIO(il, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - IL_DEBUG_RADIO(il, "u32 filter_flags: 0x%08x\n", + D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + D_RADIO("u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); - IL_DEBUG_RADIO(il, "u8 dev_type: 0x%x\n", rxon->dev_type); - IL_DEBUG_RADIO(il, "u8 ofdm_basic_rates: 0x%02x\n", + D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); + D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); - IL_DEBUG_RADIO(il, "u8 cck_basic_rates: 0x%02x\n", + D_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); - IL_DEBUG_RADIO(il, "u8[6] node_addr: %pM\n", rxon->node_addr); - IL_DEBUG_RADIO(il, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - IL_DEBUG_RADIO(il, "u16 assoc_id: 0x%x\n", + D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); + D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + D_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } EXPORT_SYMBOL(il_print_rx_config_cmd); @@ -944,7 +944,7 @@ void il_irq_handle_error(struct il_priv *il) clear_bit(STATUS_READY, &il->status); if (!test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_DEBUG(il, IL_DL_FW_ERRORS, + IL_DBG(IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); if (il->cfg->mod_params->restart_fw) @@ -965,14 +965,14 @@ static int il_apm_stop_master(struct il_priv *il) if (ret) IL_WARN(il, "Master Disable Timed Out, 100 usec\n"); - IL_DEBUG_INFO(il, "stop master\n"); + D_INFO("stop master\n"); return ret; } void il_apm_stop(struct il_priv *il) { - IL_DEBUG_INFO(il, "Stop card, put in low power state\n"); + D_INFO("Stop card, put in low power state\n"); /* Stop device's DMA activity */ il_apm_stop_master(il); @@ -1002,7 +1002,7 @@ int il_apm_init(struct il_priv *il) int ret = 0; u16 lctl; - IL_DEBUG_INFO(il, "Init card's basic functions\n"); + D_INFO("Init card's basic functions\n"); /* * Use "set_bit" below rather than "write", to preserve any hardware @@ -1047,12 +1047,12 @@ int il_apm_init(struct il_priv *il) /* L1-ASPM enabled; disable(!) L0S */ il_set_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(il, "L1 Enabled; Disabling L0S\n"); + D_POWER("L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ il_clear_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(il, "L1 Disabled; Enabling L0S\n"); + D_POWER("L1 Disabled; Enabling L0S\n"); } } @@ -1076,7 +1076,7 @@ int il_apm_init(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { - IL_DEBUG_INFO(il, "Failed to init the card\n"); + D_INFO("Failed to init the card\n"); goto out; } @@ -1147,7 +1147,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) defer = test_bit(STATUS_SCANNING, &il->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { - IL_DEBUG_INFO(il, "Deferring tx power set\n"); + D_INFO("Deferring tx power set\n"); return 0; } @@ -1179,7 +1179,7 @@ void il_send_bt_config(struct il_priv *il) else bt_cmd.flags = BT_COEX_ENABLE; - IL_DEBUG_INFO(il, "BT coex %s\n", + D_INFO("BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, @@ -1212,7 +1212,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); - IL_DEBUG_RX(il, "sleep mode: %d, src: %d\n", + D_RX("sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } @@ -1223,7 +1223,7 @@ void il_rx_pm_debug_statistics_notif(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - IL_DEBUG_RADIO(il, "Dumping %d bytes of unhandled " + D_RADIO("Dumping %d bytes of unhandled " "notification for %s:\n", len, il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); @@ -1259,15 +1259,15 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, unsigned long flags; int q; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (!il_is_ready_rf(il)) { - IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); + D_MAC80211("leave - RF not ready\n"); return -EIO; } if (queue >= AC_NUM) { - IL_DEBUG_MAC80211(il, "leave - queue >= AC_NUM %d\n", queue); + D_MAC80211("leave - queue >= AC_NUM %d\n", queue); return 0; } @@ -1289,7 +1289,7 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return 0; } EXPORT_SYMBOL(il_mac_conf_tx); @@ -1348,7 +1348,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct il_rxon_context *tmp, *ctx = NULL; int err; - IL_DEBUG_MAC80211(il, "enter: type %d, addr %pM\n", + D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); mutex_lock(&il->mutex); @@ -1398,7 +1398,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) out: mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return err; } EXPORT_SYMBOL(il_mac_add_interface); @@ -1429,7 +1429,7 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); mutex_lock(&il->mutex); @@ -1441,7 +1441,7 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, memset(il->bssid, 0, ETH_ALEN); mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } EXPORT_SYMBOL(il_mac_remove_interface); @@ -1720,7 +1720,7 @@ int il_force_reset(struct il_priv *il, bool external) if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + force_reset->reset_duration, jiffies)) { - IL_DEBUG_INFO(il, "force reset rejected\n"); + D_INFO("force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; } @@ -1738,7 +1738,7 @@ int il_force_reset(struct il_priv *il, bool external) */ if (!external && !il->cfg->mod_params->restart_fw) { - IL_DEBUG_INFO(il, "Cancel firmware reload based on " + D_INFO("Cancel firmware reload based on " "module parameter setting\n"); return 0; } @@ -2046,7 +2046,7 @@ il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - IL_DEBUG_QOS(il, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", + D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); @@ -2077,12 +2077,12 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&il->mutex); - IL_DEBUG_MAC80211(il, "enter to channel %d changed 0x%X\n", + D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, changed); if (unlikely(test_bit(STATUS_SCANNING, &il->status))) { scan_active = 1; - IL_DEBUG_MAC80211(il, "scan active\n"); + D_MAC80211("scan active\n"); } if (changed & (IEEE80211_CONF_CHANGE_SMPS | @@ -2112,14 +2112,14 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) ch = channel->hw_value; ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(il, "leave - invalid channel\n"); + D_MAC80211("leave - invalid channel\n"); ret = -EINVAL; goto set_ch_out; } if (il->iw_mode == NL80211_IFTYPE_ADHOC && !il_is_channel_ibss(ch_info)) { - IL_DEBUG_MAC80211(il, "leave - not IBSS channel\n"); + D_MAC80211("leave - not IBSS channel\n"); ret = -EINVAL; goto set_ch_out; } @@ -2186,18 +2186,18 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) IEEE80211_CONF_CHANGE_IDLE)) { ret = il_power_update_mode(il, false); if (ret) - IL_DEBUG_MAC80211(il, "Error setting sleep level\n"); + D_MAC80211("Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - IL_DEBUG_MAC80211(il, "TX Power old=%d new=%d\n", + D_MAC80211("TX Power old=%d new=%d\n", il->tx_power_user_lmt, conf->power_level); il_set_tx_power(il, conf->power_level, false); } if (!il_is_ready(il)) { - IL_DEBUG_MAC80211(il, "leave - not ready\n"); + D_MAC80211("leave - not ready\n"); goto out; } @@ -2208,14 +2208,14 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) il_commit_rxon(il, ctx); else - IL_DEBUG_INFO(il, + D_INFO( "Not re-sending same RXON configuration.\n"); if (ht_changed[ctx->ctxid]) il_update_qos(il, ctx); } out: - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); mutex_unlock(&il->mutex); return ret; } @@ -2233,7 +2233,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, return; mutex_lock(&il->mutex); - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); spin_lock_irqsave(&il->lock, flags); memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); @@ -2253,7 +2253,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, il_scan_cancel_timeout(il, 100); if (!il_is_ready_rf(il)) { - IL_DEBUG_MAC80211(il, "leave - not ready\n"); + D_MAC80211("leave - not ready\n"); mutex_unlock(&il->mutex); return; } @@ -2268,7 +2268,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } EXPORT_SYMBOL(il_mac_reset_tsf); @@ -2280,7 +2280,7 @@ static void il_ht_conf(struct il_priv *il, struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_ASSOC(il, "enter:\n"); + D_ASSOC("enter:\n"); if (!ctx->ht.enabled) return; @@ -2329,7 +2329,7 @@ static void il_ht_conf(struct il_priv *il, break; } - IL_DEBUG_ASSOC(il, "leave\n"); + D_ASSOC("leave\n"); } static inline void il_set_no_assoc(struct il_priv *il, @@ -2358,7 +2358,7 @@ static void il_beacon_update(struct ieee80211_hw *hw, if (!skb) return; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); lockdep_assert_held(&il->mutex); @@ -2378,11 +2378,11 @@ static void il_beacon_update(struct ieee80211_hw *hw, timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; il->timestamp = le64_to_cpu(timestamp); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); spin_unlock_irqrestore(&il->lock, flags); if (!il_is_ready_rf(il)) { - IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); + D_MAC80211("leave - RF not ready\n"); return; } @@ -2401,7 +2401,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (WARN_ON(!il->cfg->ops->legacy)) return; - IL_DEBUG_MAC80211(il, "changes = 0x%X\n", changes); + D_MAC80211("changes = 0x%X\n", changes); mutex_lock(&il->mutex); @@ -2432,7 +2432,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_BSSID) { - IL_DEBUG_MAC80211(il, "BSSID %pM\n", bss_conf->bssid); + D_MAC80211("BSSID %pM\n", bss_conf->bssid); /* * If there is currently a HW scan going on in the @@ -2442,7 +2442,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (il_scan_cancel_timeout(il, 100)) { IL_WARN(il, "Aborted scan still in progress after 100ms\n"); - IL_DEBUG_MAC80211(il, + D_MAC80211( "leaving - scan abort failed.\n"); mutex_unlock(&il->mutex); return; @@ -2471,7 +2471,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - IL_DEBUG_MAC80211(il, "ERP_PREAMBLE %d\n", + D_MAC80211("ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2480,7 +2480,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - IL_DEBUG_MAC80211(il, + D_MAC80211( "ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && (il->band != IEEE80211_BAND_5GHZ)) @@ -2518,7 +2518,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ASSOC) { - IL_DEBUG_MAC80211(il, "ASSOC %d\n", bss_conf->assoc); + D_MAC80211("ASSOC %d\n", bss_conf->assoc); if (bss_conf->assoc) { il->timestamp = bss_conf->timestamp; @@ -2529,7 +2529,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - IL_DEBUG_MAC80211(il, "Changes (%#x) while associated\n", + D_MAC80211("Changes (%#x) while associated\n", changes); ret = il_send_rxon_assoc(il, ctx); if (!ret) { @@ -2561,7 +2561,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } EXPORT_SYMBOL(il_mac_bss_info_changed); @@ -2591,7 +2591,7 @@ irqreturn_t il_isr(int irq, void *data) * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - IL_DEBUG_ISR(il, + D_ISR( "Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -2603,7 +2603,7 @@ irqreturn_t il_isr(int irq, void *data) goto unplugged; } - IL_DEBUG_ISR(il, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); inta &= ~CSR_INT_BIT_SCD; diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index c6dcbf3..2c5c42f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -37,17 +37,17 @@ extern u32 il_debug_level; #define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) #define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) -#define il_print_hex_error(il, p, len) \ +#define il_print_hex_error(il, p, len) \ do { \ print_hex_dump(KERN_ERR, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -#define IL_DEBUG(__priv, level, fmt, args...) \ +#define IL_DBG(level, fmt, args...) \ do { \ - if (il_get_debug_level(__priv) & (level)) \ - dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ + if (il_get_debug_level(il) & level) \ + dev_printk(KERN_ERR, &il->hw->wiphy->dev, \ "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ __func__ , ## args); \ } while (0) @@ -60,7 +60,7 @@ do { \ } while (0) #else -#define IL_DEBUG(__priv, level, fmt, args...) +#define IL_DBG(level, fmt, args...) static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} @@ -91,12 +91,12 @@ static inline void il_dbgfs_unregister(struct il_priv *il) * where xxxx should be the name of the classification (for example, WEP). * * You then need to either add a IL_xxxx_DEBUG() macro definition for your - * classification, or use IL_DEBUG(IL_DL_xxxx, ...) whenever you want + * classification, or use IL_DBG(IL_DL_xxxx, ...) whenever you want * to send output to that classification. * * The active debug levels can be accessed via files * - * /sys/module/iwl4965/parameters/debug{50} + * /sys/module/iwl4965/parameters/debug * /sys/module/iwl3945/parameters/debug * /sys/class/net/wlan0/device/debug_level * @@ -110,7 +110,7 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ #define IL_DL_MACDUMP (1 << 4) -#define IL_DL_HCMD_DUMP (1 << 5) +#define IL_DL_HCMD_DUMP (1 << 5) #define IL_DL_EEPROM (1 << 6) #define IL_DL_RADIO (1 << 7) /* 0x00000F00 - 0x00000100 */ @@ -126,7 +126,7 @@ static inline void il_dbgfs_unregister(struct il_priv *il) /* 0x000F0000 - 0x00010000 */ #define IL_DL_FW (1 << 16) #define IL_DL_RF_KILL (1 << 17) -#define IL_DL_FW_ERRORS (1 << 18) +#define IL_DL_FW_ERRORS (1 << 18) #define IL_DL_LED (1 << 19) /* 0x00F00000 - 0x00100000 */ #define IL_DL_RATE (1 << 20) @@ -143,34 +143,34 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DL_TX_REPLY (1 << 30) #define IL_DL_QOS (1 << 31) -#define IL_DEBUG_INFO(p, f, a...) IL_DEBUG(p, IL_DL_INFO, f, ## a) -#define IL_DEBUG_MAC80211(p, f, a...) IL_DEBUG(p, IL_DL_MAC80211, f, ## a) -#define IL_DEBUG_MACDUMP(p, f, a...) IL_DEBUG(p, IL_DL_MACDUMP, f, ## a) -#define IL_DEBUG_TEMP(p, f, a...) IL_DEBUG(p, IL_DL_TEMP, f, ## a) -#define IL_DEBUG_SCAN(p, f, a...) IL_DEBUG(p, IL_DL_SCAN, f, ## a) -#define IL_DEBUG_RX(p, f, a...) IL_DEBUG(p, IL_DL_RX, f, ## a) -#define IL_DEBUG_TX(p, f, a...) IL_DEBUG(p, IL_DL_TX, f, ## a) -#define IL_DEBUG_ISR(p, f, a...) IL_DEBUG(p, IL_DL_ISR, f, ## a) -#define IL_DEBUG_LED(p, f, a...) IL_DEBUG(p, IL_DL_LED, f, ## a) -#define IL_DEBUG_WEP(p, f, a...) IL_DEBUG(p, IL_DL_WEP, f, ## a) -#define IL_DEBUG_HC(p, f, a...) IL_DEBUG(p, IL_DL_HCMD, f, ## a) -#define IL_DEBUG_HC_DUMP(p, f, a...) IL_DEBUG(p, IL_DL_HCMD_DUMP, f, ## a) -#define IL_DEBUG_EEPROM(p, f, a...) IL_DEBUG(p, IL_DL_EEPROM, f, ## a) -#define IL_DEBUG_CALIB(p, f, a...) IL_DEBUG(p, IL_DL_CALIB, f, ## a) -#define IL_DEBUG_FW(p, f, a...) IL_DEBUG(p, IL_DL_FW, f, ## a) -#define IL_DEBUG_RF_KILL(p, f, a...) IL_DEBUG(p, IL_DL_RF_KILL, f, ## a) -#define IL_DEBUG_DROP(p, f, a...) IL_DEBUG(p, IL_DL_DROP, f, ## a) -#define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) -#define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) -#define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) -#define IL_DEBUG_NOTIF(p, f, a...) IL_DEBUG(p, IL_DL_NOTIF, f, ## a) -#define IL_DEBUG_ASSOC(p, f, a...) IL_DEBUG(p, IL_DL_ASSOC, f, ## a) -#define IL_DEBUG_HT(p, f, a...) IL_DEBUG(p, IL_DL_HT, f, ## a) -#define IL_DEBUG_STATS(p, f, a...) IL_DEBUG(p, IL_DL_STATS, f, ## a) -#define IL_DEBUG_TX_REPLY(p, f, a...) IL_DEBUG(p, IL_DL_TX_REPLY, f, ## a) -#define IL_DEBUG_QOS(p, f, a...) IL_DEBUG(p, IL_DL_QOS, f, ## a) -#define IL_DEBUG_RADIO(p, f, a...) IL_DEBUG(p, IL_DL_RADIO, f, ## a) -#define IL_DEBUG_POWER(p, f, a...) IL_DEBUG(p, IL_DL_POWER, f, ## a) -#define IL_DEBUG_11H(p, f, a...) IL_DEBUG(p, IL_DL_11H, f, ## a) +#define D_INFO(f, a...) IL_DBG(IL_DL_INFO, f, ## a) +#define D_MAC80211(f, a...) IL_DBG(IL_DL_MAC80211, f, ## a) +#define D_MACDUMP(f, a...) IL_DBG(IL_DL_MACDUMP, f, ## a) +#define D_TEMP(f, a...) IL_DBG(IL_DL_TEMP, f, ## a) +#define D_SCAN(f, a...) IL_DBG(IL_DL_SCAN, f, ## a) +#define D_RX(f, a...) IL_DBG(IL_DL_RX, f, ## a) +#define D_TX(f, a...) IL_DBG(IL_DL_TX, f, ## a) +#define D_ISR(f, a...) IL_DBG(IL_DL_ISR, f, ## a) +#define D_LED(f, a...) IL_DBG(IL_DL_LED, f, ## a) +#define D_WEP(f, a...) IL_DBG(IL_DL_WEP, f, ## a) +#define D_HC(f, a...) IL_DBG(IL_DL_HCMD, f, ## a) +#define D_HC_DUMP(f, a...) IL_DBG(IL_DL_HCMD_DUMP, f, ## a) +#define D_EEPROM(f, a...) IL_DBG(IL_DL_EEPROM, f, ## a) +#define D_CALIB(f, a...) IL_DBG(IL_DL_CALIB, f, ## a) +#define D_FW(f, a...) IL_DBG(IL_DL_FW, f, ## a) +#define D_RF_KILL(f, a...) IL_DBG(IL_DL_RF_KILL, f, ## a) +#define D_DROP(f, a...) IL_DBG(IL_DL_DROP, f, ## a) +#define D_AP(f, a...) IL_DBG(IL_DL_AP, f, ## a) +#define D_TXPOWER(f, a...) IL_DBG(IL_DL_TXPOWER, f, ## a) +#define D_RATE(f, a...) IL_DBG(IL_DL_RATE, f, ## a) +#define D_NOTIF(f, a...) IL_DBG(IL_DL_NOTIF, f, ## a) +#define D_ASSOC(f, a...) IL_DBG(IL_DL_ASSOC, f, ## a) +#define D_HT(f, a...) IL_DBG(IL_DL_HT, f, ## a) +#define D_STATS(f, a...) IL_DBG(IL_DL_STATS, f, ## a) +#define D_TX_REPLY(f, a...) IL_DBG(IL_DL_TX_REPLY, f, ## a) +#define D_QOS(f, a...) IL_DBG(IL_DL_QOS, f, ## a) +#define D_RADIO(f, a...) IL_DBG(IL_DL_RADIO, f, ## a) +#define D_POWER(f, a...) IL_DBG(IL_DL_POWER, f, ## a) +#define D_11H(f, a...) IL_DBG(IL_DL_11H, f, ## a) #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index f6b9d6d..33fe598 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -147,7 +147,7 @@ static int il_eeprom_verify_signature(struct il_priv *il) u32 gp = il_read32(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; - IL_DEBUG_EEPROM(il, "EEPROM signature=0x%08x\n", gp); + D_EEPROM("EEPROM signature=0x%08x\n", gp); switch (gp) { case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: @@ -194,7 +194,7 @@ int il_eeprom_init(struct il_priv *il) /* allocate eeprom */ sz = il->cfg->base_params->eeprom_size; - IL_DEBUG_EEPROM(il, "NVM size = %d\n", sz); + D_EEPROM("NVM size = %d\n", sz); il->eeprom = kzalloc(sz, GFP_KERNEL); if (!il->eeprom) { ret = -ENOMEM; @@ -239,7 +239,7 @@ int il_eeprom_init(struct il_priv *il) e[addr / 2] = cpu_to_le16(r >> 16); } - IL_DEBUG_EEPROM(il, "NVM Type: %s, version: 0x%x\n", + D_EEPROM("NVM Type: %s, version: 0x%x\n", "EEPROM", il_eeprom_query16(il, EEPROM_VERSION)); @@ -339,7 +339,7 @@ static int il_mod_ht40_chan_info(struct il_priv *il, if (!il_is_channel_valid(ch_info)) return -1; - IL_DEBUG_EEPROM(il, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, il_is_channel_a_band(ch_info) ? @@ -380,11 +380,11 @@ int il_init_channel_map(struct il_priv *il) struct il_channel_info *ch_info; if (il->channel_count) { - IL_DEBUG_EEPROM(il, "Channel map already initialized.\n"); + D_EEPROM("Channel map already initialized.\n"); return 0; } - IL_DEBUG_EEPROM(il, "Initializing regulatory info from EEPROM\n"); + D_EEPROM("Initializing regulatory info from EEPROM\n"); il->channel_count = ARRAY_SIZE(il_eeprom_band_1) + @@ -393,7 +393,7 @@ int il_init_channel_map(struct il_priv *il) ARRAY_SIZE(il_eeprom_band_4) + ARRAY_SIZE(il_eeprom_band_5); - IL_DEBUG_EEPROM(il, "Parsing data for %d channels.\n", + D_EEPROM("Parsing data for %d channels.\n", il->channel_count); il->channel_info = kzalloc(sizeof(struct il_channel_info) * @@ -433,7 +433,7 @@ int il_init_channel_map(struct il_priv *il) IEEE80211_CHAN_NO_HT40; if (!(il_is_channel_valid(ch_info))) { - IL_DEBUG_EEPROM(il, + D_EEPROM( "Ch. %d Flags %x [%sGHz] - " "No traffic\n", ch_info->channel, @@ -450,7 +450,7 @@ int il_init_channel_map(struct il_priv *il) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - IL_DEBUG_EEPROM(il, "Ch. %d [%sGHz] " + D_EEPROM("Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index f16e311..61cf0d8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -104,11 +104,11 @@ static void il_generic_cmd_callback(struct il_priv *il, switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(il, "back from %s (0x%08X)\n", + D_HC_DUMP("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - IL_DEBUG_HC(il, "back from %s (0x%08X)\n", + D_HC("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); } #endif @@ -152,11 +152,11 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); - IL_DEBUG_INFO(il, "Attempting to send sync command %s\n", + D_INFO("Attempting to send sync command %s\n", il_get_cmd_string(cmd->id)); set_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_DEBUG_INFO(il, "Setting HCMD_ACTIVE for command %s\n", + D_INFO("Setting HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); cmd_idx = il_enqueue_hcmd(il, cmd); @@ -178,7 +178,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_DEBUG_INFO(il, + D_INFO( "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index e55f2ef..a0a84b2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -155,18 +155,18 @@ static inline void il_disable_interrupts(struct il_priv *il) * from uCode or flow handler (Rx/Tx DMA) */ il_write32(il, CSR_INT, 0xffffffff); il_write32(il, CSR_FH_INT_STATUS, 0xffffffff); - IL_DEBUG_ISR(il, "Disabled interrupts\n"); + D_ISR("Disabled interrupts\n"); } static inline void il_enable_rfkill_int(struct il_priv *il) { - IL_DEBUG_ISR(il, "Enabling rfkill interrupt\n"); + D_ISR("Enabling rfkill interrupt\n"); il_write32(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } static inline void il_enable_interrupts(struct il_priv *il) { - IL_DEBUG_ISR(il, "Enabling interrupts\n"); + D_ISR("Enabling interrupts\n"); set_bit(STATUS_INT_ENABLED, &il->status); il_write32(il, CSR_INT_MASK, il->inta_mask); } diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 13add43..b4d71cf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -118,7 +118,7 @@ static int il_led_cmd(struct il_priv *il, on = IL_LED_SOLID; } - IL_DEBUG_LED(il, "Led blink time compensation=%u\n", + D_LED("Led blink time compensation=%u\n", il->cfg->base_params->led_compensation); led_cmd.on = il_blink_compensation(il, on, il->cfg->base_params->led_compensation); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 6386246..33aec39 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -68,19 +68,19 @@ static void il_power_sleep_cam_cmd(struct il_priv *il, if (il->power_data.pci_pm) cmd->flags |= IL_POWER_PCI_PM_MSK; - IL_DEBUG_POWER(il, "Sleep command for CAM\n"); + D_POWER("Sleep command for CAM\n"); } static int il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) { - IL_DEBUG_POWER(il, "Sending power/sleep command\n"); - IL_DEBUG_POWER(il, "Flags value = 0x%08X\n", cmd->flags); - IL_DEBUG_POWER(il, "Tx timeout = %u\n", + D_POWER("Sending power/sleep command\n"); + D_POWER("Flags value = 0x%08X\n", cmd->flags); + D_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); - IL_DEBUG_POWER(il, "Rx timeout = %u\n", + D_POWER("Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); - IL_DEBUG_POWER(il, + D_POWER( "Sleep interval vector = { %d , %d , %d , %d , %d }\n", le32_to_cpu(cmd->sleep_interval[0]), le32_to_cpu(cmd->sleep_interval[1]), @@ -114,7 +114,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, /* scan complete use sleep_power_next, need to be updated */ memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); if (test_bit(STATUS_SCANNING, &il->status) && !force) { - IL_DEBUG_INFO(il, "Defer power set mode while scanning\n"); + D_INFO("Defer power set mode while scanning\n"); return 0; } @@ -129,7 +129,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, if (il->cfg->ops->lib->update_chain_flags && update_chains) il->cfg->ops->lib->update_chain_flags(il); else if (il->cfg->ops->lib->update_chain_flags) - IL_DEBUG_POWER(il, + D_POWER( "Cannot update the power, chain noise " "calibration running: %d\n", il->chain_noise_data.state); diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index b6c5dd0..183acdc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -141,7 +141,7 @@ il_rx_queue_update_write_ptr(struct il_priv *il, reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(il, + D_INFO( "Rx queue requesting wakeup," " GP1 = 0x%x\n", reg); il_set_bit(il, CSR_GP_CNTRL, @@ -217,7 +217,7 @@ void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - IL_DEBUG_11H(il, + D_11H( "Spectrum Measure Notification: Start\n"); return; } @@ -248,7 +248,7 @@ int il_set_decrypted_flag(struct il_priv *il, if (!(fc & IEEE80211_FCTL_PROTECTED)) return 0; - IL_DEBUG_RX(il, "decrypt_res:0x%x\n", decrypt_res); + D_RX("decrypt_res:0x%x\n", decrypt_res); switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { case RX_RES_STATUS_SEC_TYPE_TKIP: /* The uCode has got a bad phase 1 Key, pushes the packet. @@ -262,13 +262,13 @@ int il_set_decrypted_flag(struct il_priv *il, RX_RES_STATUS_BAD_ICV_MIC) { /* bad ICV, the packet is destroyed since the * decryption is inplace, drop it */ - IL_DEBUG_RX(il, "Packet destroyed\n"); + D_RX("Packet destroyed\n"); return -1; } case RX_RES_STATUS_SEC_TYPE_CCMP: if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == RX_RES_STATUS_DECRYPT_OK) { - IL_DEBUG_RX(il, "hw decrypt successfully!!!\n"); + D_RX("hw decrypt successfully!!!\n"); stats->flag |= RX_FLAG_DECRYPTED; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 5a967d2..c534dce 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -85,7 +85,7 @@ static int il_send_scan_abort(struct il_priv *il) * can occur if we send the scan abort before we * the microcode has notified us that a scan is * completed. */ - IL_DEBUG_SCAN(il, "SCAN_ABORT ret %d.\n", pkt->u.status); + D_SCAN("SCAN_ABORT ret %d.\n", pkt->u.status); ret = -EIO; } @@ -97,7 +97,7 @@ static void il_complete_scan(struct il_priv *il, bool aborted) { /* check if scan was requested from mac80211 */ if (il->scan_request) { - IL_DEBUG_SCAN(il, "Complete scan in mac80211\n"); + D_SCAN("Complete scan in mac80211\n"); ieee80211_scan_completed(il->hw, aborted); } @@ -110,11 +110,11 @@ void il_force_scan_end(struct il_priv *il) lockdep_assert_held(&il->mutex); if (!test_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Forcing scan end while not scanning\n"); + D_SCAN("Forcing scan end while not scanning\n"); return; } - IL_DEBUG_SCAN(il, "Forcing scan end\n"); + D_SCAN("Forcing scan end\n"); clear_bit(STATUS_SCANNING, &il->status); clear_bit(STATUS_SCAN_HW, &il->status); clear_bit(STATUS_SCAN_ABORTING, &il->status); @@ -128,21 +128,21 @@ static void il_do_scan_abort(struct il_priv *il) lockdep_assert_held(&il->mutex); if (!test_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Not performing scan to abort\n"); + D_SCAN("Not performing scan to abort\n"); return; } if (test_and_set_bit(STATUS_SCAN_ABORTING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan abort in progress\n"); + D_SCAN("Scan abort in progress\n"); return; } ret = il_send_scan_abort(il); if (ret) { - IL_DEBUG_SCAN(il, "Send scan abort failed %d\n", ret); + D_SCAN("Send scan abort failed %d\n", ret); il_force_scan_end(il); } else - IL_DEBUG_SCAN(il, "Successfully send scan abort\n"); + D_SCAN("Successfully send scan abort\n"); } /** @@ -150,7 +150,7 @@ static void il_do_scan_abort(struct il_priv *il) */ int il_scan_cancel(struct il_priv *il) { - IL_DEBUG_SCAN(il, "Queuing abort scan\n"); + D_SCAN("Queuing abort scan\n"); queue_work(il->workqueue, &il->abort_scan); return 0; } @@ -167,7 +167,7 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) lockdep_assert_held(&il->mutex); - IL_DEBUG_SCAN(il, "Scan cancel timeout\n"); + D_SCAN("Scan cancel timeout\n"); il_do_scan_abort(il); @@ -190,7 +190,7 @@ static void il_rx_reply_scan(struct il_priv *il, struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; - IL_DEBUG_SCAN(il, "Scan request status = 0x%x\n", notif->status); + D_SCAN("Scan request status = 0x%x\n", notif->status); #endif } @@ -202,7 +202,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; il->scan_start_tsf = le32_to_cpu(notif->tsf_low); - IL_DEBUG_SCAN(il, "Scan start: " + D_SCAN("Scan start: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, @@ -221,7 +221,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; - IL_DEBUG_SCAN(il, "Scan ch.res: " + D_SCAN("Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " "elapsed=%lu usec\n", @@ -244,7 +244,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - IL_DEBUG_SCAN(il, + D_SCAN( "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", scan_notif->scanned_channels, scan_notif->tsf_low, @@ -253,7 +253,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, /* The HW is no longer scanning */ clear_bit(STATUS_SCAN_HW, &il->status); - IL_DEBUG_SCAN(il, "Scan on %sGHz took %dms\n", + D_SCAN("Scan on %sGHz took %dms\n", (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", jiffies_to_msecs(jiffies - il->scan_start)); @@ -346,17 +346,17 @@ static int il_scan_initiate(struct il_priv *il, } if (test_bit(STATUS_SCAN_HW, &il->status)) { - IL_DEBUG_SCAN(il, + D_SCAN( "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } if (test_bit(STATUS_SCAN_ABORTING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan request while abort pending.\n"); + D_SCAN("Scan request while abort pending.\n"); return -EBUSY; } - IL_DEBUG_SCAN(il, "Starting scan...\n"); + D_SCAN("Starting scan...\n"); set_bit(STATUS_SCANNING, &il->status); il->scan_start = jiffies; @@ -380,7 +380,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (req->n_channels == 0) return -EINVAL; @@ -388,7 +388,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, mutex_lock(&il->mutex); if (test_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan already in progress.\n"); + D_SCAN("Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; } @@ -400,7 +400,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, ret = il_scan_initiate(il, vif); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); out_unlock: mutex_unlock(&il->mutex); @@ -414,7 +414,7 @@ static void il_bg_scan_check(struct work_struct *data) struct il_priv *il = container_of(data, struct il_priv, scan_check.work); - IL_DEBUG_SCAN(il, "Scan check work\n"); + D_SCAN("Scan check work\n"); /* Since we are here firmware does not finish scan and * most likely is in bad shape, so we don't bother to @@ -477,7 +477,7 @@ static void il_bg_abort_scan(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, abort_scan); - IL_DEBUG_SCAN(il, "Abort scan work\n"); + D_SCAN("Abort scan work\n"); /* We keep scan_check work queued in case when firmware will not * report back scan completed notification */ @@ -492,7 +492,7 @@ static void il_bg_scan_completed(struct work_struct *work) container_of(work, struct il_priv, scan_completed); bool aborted; - IL_DEBUG_SCAN(il, "Completed scan.\n"); + D_SCAN("Completed scan.\n"); cancel_delayed_work(&il->scan_check); @@ -500,10 +500,10 @@ static void il_bg_scan_completed(struct work_struct *work) aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &il->status); if (aborted) - IL_DEBUG_SCAN(il, "Aborted scan completed.\n"); + D_SCAN("Aborted scan completed.\n"); if (!test_and_clear_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan already completed.\n"); + D_SCAN("Scan already completed.\n"); goto out_settings; } diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 7d66e79..a48af85 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -46,13 +46,13 @@ static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) sta_id, il->stations[sta_id].sta.sta.addr); if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_ASSOC(il, + D_ASSOC( "STA id %u addr %pM already present" " in uCode (according to driver)\n", sta_id, il->stations[sta_id].sta.sta.addr); } else { il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; - IL_DEBUG_ASSOC(il, "Added STA id %u addr %pM to uCode\n", + D_ASSOC("Added STA id %u addr %pM to uCode\n", sta_id, il->stations[sta_id].sta.sta.addr); } } @@ -72,14 +72,14 @@ static int il_process_add_sta_resp(struct il_priv *il, return ret; } - IL_DEBUG_INFO(il, "Processing response for adding station %u\n", + D_INFO("Processing response for adding station %u\n", sta_id); spin_lock_irqsave(&il->sta_lock, flags); switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - IL_DEBUG_INFO(il, "REPLY_ADD_STA PASSED\n"); + D_INFO("REPLY_ADD_STA PASSED\n"); il_sta_ucode_activate(il, sta_id); ret = 0; break; @@ -97,12 +97,12 @@ static int il_process_add_sta_resp(struct il_priv *il, sta_id); break; default: - IL_DEBUG_ASSOC(il, "Received REPLY_ADD_STA:(0x%08X)\n", + D_ASSOC("Received REPLY_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } - IL_DEBUG_INFO(il, "%s station id %u addr %pM\n", + D_INFO("%s station id %u addr %pM\n", il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", sta_id, il->stations[sta_id].sta.sta.addr); @@ -115,7 +115,7 @@ static int il_process_add_sta_resp(struct il_priv *il, * issue has not yet been resolved and this debugging is left to * observe the problem. */ - IL_DEBUG_INFO(il, "%s station according to cmd buffer %pM\n", + D_INFO("%s station according to cmd buffer %pM\n", il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); @@ -148,7 +148,7 @@ int il_send_add_sta(struct il_priv *il, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - IL_DEBUG_INFO(il, "Adding sta %u (%pM) %ssynchronously\n", + D_INFO("Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) @@ -186,7 +186,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, goto done; mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; - IL_DEBUG_ASSOC(il, "spatial multiplexing power save mode: %s\n", + D_ASSOC("spatial multiplexing power save mode: %s\n", (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? @@ -269,7 +269,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(il, + D_INFO( "STA %d already in process of being added.\n", sta_id); return sta_id; @@ -278,7 +278,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { - IL_DEBUG_ASSOC(il, + D_ASSOC( "STA %d (%pM) already added, not adding again.\n", sta_id, addr); return sta_id; @@ -286,7 +286,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, station = &il->stations[sta_id]; station->used = IL_STA_DRIVER_ACTIVE; - IL_DEBUG_ASSOC(il, "Add STA to driver ID %d: %pM\n", + D_ASSOC("Add STA to driver ID %d: %pM\n", sta_id, addr); il->num_stations++; @@ -355,7 +355,7 @@ il_add_station_common(struct il_priv *il, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(il, + D_INFO( "STA %d already in process of being added.\n", sta_id); spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -364,7 +364,7 @@ il_add_station_common(struct il_priv *il, if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(il, + D_ASSOC( "STA %d (%pM) already added, not adding again.\n", sta_id, addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -407,7 +407,7 @@ static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); - IL_DEBUG_ASSOC(il, "Removed STA %u\n", sta_id); + D_ASSOC("Removed STA %u\n", sta_id); } static int il_send_remove_station(struct il_priv *il, @@ -454,7 +454,7 @@ static int il_send_remove_station(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); } - IL_DEBUG_ASSOC(il, "REPLY_REMOVE_STA PASSED\n"); + D_ASSOC("REPLY_REMOVE_STA PASSED\n"); break; default: ret = -EIO; @@ -476,7 +476,7 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, unsigned long flags; if (!il_is_ready(il)) { - IL_DEBUG_INFO(il, + D_INFO( "Unable to remove station %pM, device not ready.\n", addr); /* @@ -487,7 +487,7 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, return 0; } - IL_DEBUG_ASSOC(il, "Removing STA from driver:%d %pM\n", + D_ASSOC("Removing STA from driver:%d %pM\n", sta_id, addr); if (WARN_ON(sta_id == IL_INVALID_STATION)) @@ -496,13 +496,13 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, spin_lock_irqsave(&il->sta_lock, flags); if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { - IL_DEBUG_INFO(il, "Removing %pM but non DRIVER active\n", + D_INFO("Removing %pM but non DRIVER active\n", addr); goto out_err; } if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_INFO(il, "Removing %pM but non UCODE active\n", + D_INFO("Removing %pM but non UCODE active\n", addr); goto out_err; } @@ -542,7 +542,7 @@ void il_clear_ucode_stations(struct il_priv *il, unsigned long flags_spin; bool cleared = false; - IL_DEBUG_INFO(il, "Clearing ucode stations in driver\n"); + D_INFO("Clearing ucode stations in driver\n"); spin_lock_irqsave(&il->sta_lock, flags_spin); for (i = 0; i < il->hw_params.max_stations; i++) { @@ -550,7 +550,7 @@ void il_clear_ucode_stations(struct il_priv *il, continue; if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_INFO(il, + D_INFO( "Clearing ucode active for station %d\n", i); il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; @@ -559,7 +559,7 @@ void il_clear_ucode_stations(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!cleared) - IL_DEBUG_INFO(il, + D_INFO( "No active stations found to be cleared\n"); } EXPORT_SYMBOL(il_clear_ucode_stations); @@ -584,19 +584,19 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) bool send_lq; if (!il_is_ready(il)) { - IL_DEBUG_INFO(il, + D_INFO( "Not ready yet, not restoring any stations.\n"); return; } - IL_DEBUG_ASSOC(il, "Restoring all known stations ... start.\n"); + D_ASSOC("Restoring all known stations ... start.\n"); spin_lock_irqsave(&il->sta_lock, flags_spin); for (i = 0; i < il->hw_params.max_stations; i++) { if (ctx->ctxid != il->stations[i].ctxid) continue; if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(il, "Restoring sta %pM\n", + D_ASSOC("Restoring sta %pM\n", il->stations[i].sta.sta.addr); il->stations[i].sta.mode = 0; il->stations[i].used |= IL_STA_UCODE_INPROGRESS; @@ -641,10 +641,10 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!found) - IL_DEBUG_INFO(il, "Restoring all known stations" + D_INFO("Restoring all known stations" " .... no stations to be restored.\n"); else - IL_DEBUG_INFO(il, "Restoring all known stations" + D_INFO("Restoring all known stations" " .... complete.\n"); } EXPORT_SYMBOL(il_restore_stations); @@ -686,13 +686,13 @@ static void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { int i; - IL_DEBUG_RATE(il, "lq station id 0x%x\n", lq->sta_id); - IL_DEBUG_RATE(il, "lq ant 0x%X 0x%X\n", + D_RATE("lq station id 0x%x\n", lq->sta_id); + D_RATE("lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - IL_DEBUG_RATE(il, "lq index %d 0x%X\n", + D_RATE("lq index %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else @@ -722,12 +722,12 @@ static bool il_is_lq_table_valid(struct il_priv *il, if (ctx->ht.enabled) return true; - IL_DEBUG_INFO(il, "Channel %u is not an HT channel\n", + D_INFO("Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { - IL_DEBUG_INFO(il, + D_INFO( "index %d of LQ expects HT channel\n", i); return false; @@ -782,7 +782,7 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, return ret; if (init) { - IL_DEBUG_INFO(il, "init LQ command complete," + D_INFO("init LQ command complete," " clearing sta addition status for sta %d\n", lq->sta_id); spin_lock_irqsave(&il->sta_lock, flags_spin); @@ -801,10 +801,10 @@ int il_mac_sta_remove(struct ieee80211_hw *hw, struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - IL_DEBUG_INFO(il, "received request to remove station %pM\n", + D_INFO("received request to remove station %pM\n", sta->addr); mutex_lock(&il->mutex); - IL_DEBUG_INFO(il, "proceeding to remove station %pM\n", + D_INFO("proceeding to remove station %pM\n", sta->addr); ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index af6ac4f..22617c4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -58,7 +58,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(il, + D_INFO( "Tx queue %d requesting wakeup," " GP1 = 0x%x\n", txq_id, reg); il_set_bit(il, CSR_GP_CNTRL, @@ -511,7 +511,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(il, + D_HC_DUMP( "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), @@ -520,7 +520,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) q->write_ptr, idx, il->cmd_queue); break; default: - IL_DEBUG_HC(il, "Sending command %s (#%x), seq: 0x%04X, " + D_HC("Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, @@ -642,7 +642,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) if (!(meta->flags & CMD_ASYNC)) { clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_DEBUG_INFO(il, "Clearing HCMD_ACTIVE for command %s\n", + D_INFO("Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->hdr.cmd)); wake_up(&il->wait_command_queue); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index af3f194..8aa22a0 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -174,7 +174,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - IL_DEBUG_INFO(il, "hwcrypto: modify ucode station key info\n"); + D_INFO("hwcrypto: modify ucode station key info\n"); ret = il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); @@ -213,7 +213,7 @@ static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); - IL_DEBUG_INFO(il, "hwcrypto: clear ucode station key info\n"); + D_INFO("hwcrypto: clear ucode station key info\n"); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } @@ -241,7 +241,7 @@ static int il3945_set_dynamic_key(struct il_priv *il, ret = -EINVAL; } - IL_DEBUG_WEP(il, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -270,7 +270,7 @@ static void il3945_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { @@ -381,7 +381,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, case WLAN_CIPHER_SUITE_CCMP: tx_cmd->sec_ctl = TX_CMD_SEC_CCM; memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); + D_TX("tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: @@ -396,7 +396,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(il, "Configuring packet for WEP encryption " + D_TX("Configuring packet for WEP encryption " "with key %d\n", info->control.hw_key->hw_key_idx); break; @@ -486,7 +486,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) spin_lock_irqsave(&il->lock, flags); if (il_is_rfkill(il)) { - IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); + D_DROP("Dropping - RF KILL\n"); goto drop_unlock; } @@ -502,11 +502,11 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(il, "Sending AUTH frame\n"); + D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(il, "Sending ASSOC frame\n"); + D_TX("Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(il, "Sending REASSOC frame\n"); + D_TX("Sending REASSOC frame\n"); #endif spin_unlock_irqrestore(&il->lock, flags); @@ -518,12 +518,12 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) il, &il->contexts[IL_RXON_CTX_BSS], info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } - IL_DEBUG_RATE(il, "station Id %d\n", sta_id); + D_RATE("station Id %d\n", sta_id); if (ieee80211_is_data_qos(fc)) { u8 *qc = ieee80211_get_qos_ctl(hdr); @@ -594,9 +594,9 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) txq->need_update = 0; } - IL_DEBUG_TX(il, "sequence nr = 0X%x\n", + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, ieee80211_hdrlen(fc)); @@ -726,7 +726,7 @@ static int il3945_get_measurement(struct il_priv *il, switch (spectrum_resp_status) { case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { - IL_DEBUG_INFO(il, "Replaced existing measurement: %d\n", + D_INFO("Replaced existing measurement: %d\n", pkt->u.spectrum.id); il->measurement_status &= ~MEASUREMENT_READY; } @@ -753,18 +753,18 @@ static void il3945_rx_reply_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); pwork = &il->alive_start; @@ -787,7 +787,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_packet *pkt = rxb_addr(rxb); #endif - IL_DEBUG_RX(il, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); } static void il3945_rx_beacon_notif(struct il_priv *il, @@ -798,7 +798,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1040,7 +1040,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(il, "Failed to allocate SKB buffer.\n"); + D_INFO("Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) IL_CRIT(il, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", @@ -1225,7 +1225,7 @@ static void il3945_rx_handle(struct il_priv *il) fill_rx = 1; /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); + D_RX("r = %d, i = %d\n", r, i); while (i != r) { int len; @@ -1261,13 +1261,13 @@ static void il3945_rx_handle(struct il_priv *il) * handle those that need handling via function in * rx_handlers table. See il3945_setup_rx_handlers() */ if (il->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, i, + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.rx_handlers[pkt->hdr.cmd]++; il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(il, + D_RX( "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -1432,7 +1432,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = il_read32(il, CSR_INT_MASK); - IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -1467,14 +1467,14 @@ static void il3945_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(il, "Scheduler finished to transmit " + D_ISR("Scheduler finished to transmit " "the frame/frames.\n"); il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(il, "Alive interrupt\n"); + D_ISR("Alive interrupt\n"); il->isr_stats.alive++; } } @@ -1493,7 +1493,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* uCode wakes up after power-down sleep */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + D_ISR("Wakeup interrupt\n"); il_rx_queue_update_write_ptr(il, &il->rxq); il_txq_update_write_ptr(il, &il->txq[0]); il_txq_update_write_ptr(il, &il->txq[1]); @@ -1516,7 +1516,7 @@ static void il3945_irq_tasklet(struct il_priv *il) } if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(il, "Tx interrupt\n"); + D_ISR("Tx interrupt\n"); il->isr_stats.tx++; il_write32(il, CSR_FH_INT_STATUS, (1 << 6)); @@ -1546,7 +1546,7 @@ static void il3945_irq_tasklet(struct il_priv *il) inta = il_read32(il, CSR_INT); inta_mask = il_read32(il, CSR_INT_MASK); inta_fh = il_read32(il, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(il, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif @@ -1586,7 +1586,7 @@ static int il3945_get_channels_for_scan(struct il_priv *il, ch_info = il_get_channel_info(il, band, scan_ch->channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(il, + D_SCAN( "Channel %d is INVALID for this band.\n", scan_ch->channel); continue; @@ -1635,7 +1635,7 @@ static int il3945_get_channels_for_scan(struct il_priv *il, */ } - IL_DEBUG_SCAN(il, "Scanning %d [%s %d]\n", + D_SCAN("Scanning %d [%s %d]\n", scan_ch->channel, (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", (scan_ch->type & 1) ? @@ -1645,7 +1645,7 @@ static int il3945_get_channels_for_scan(struct il_priv *il, added++; } - IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); + D_SCAN("total channels to scan %d\n", added); return added; } @@ -1696,7 +1696,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) int rc = 0; u32 errcnt; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); @@ -1720,7 +1720,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) if (!errcnt) - IL_DEBUG_INFO(il, + D_INFO( "ucode image in INSTRUCTION memory is good\n"); return rc; @@ -1739,7 +1739,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ @@ -1780,7 +1780,7 @@ static int il3945_verify_ucode(struct il_priv *il) len = il->ucode_boot.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); + D_INFO("Bootstrap uCode is good in inst SRAM\n"); return 0; } @@ -1789,7 +1789,7 @@ static int il3945_verify_ucode(struct il_priv *il) len = il->ucode_init.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); + D_INFO("Initialize uCode is good in inst SRAM\n"); return 0; } @@ -1798,7 +1798,7 @@ static int il3945_verify_ucode(struct il_priv *il) len = il->ucode_code.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); + D_INFO("Runtime uCode is good in inst SRAM\n"); return 0; } @@ -1879,7 +1879,7 @@ static int il3945_read_ucode(struct il_priv *il) "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); - IL_DEBUG_INFO(il, "Got firmware '%s' file " + D_INFO("Got firmware '%s' file " "(%zd bytes) from disk\n", buf, ucode_raw->size); break; @@ -1940,17 +1940,17 @@ static int il3945_read_ucode(struct il_priv *il) IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); - IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); - IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %u\n", + D_INFO("f/w package hdr runtime inst size = %u\n", inst_size); - IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %u\n", + D_INFO("f/w package hdr runtime data size = %u\n", data_size); - IL_DEBUG_INFO(il, "f/w package hdr init inst size = %u\n", + D_INFO("f/w package hdr init inst size = %u\n", init_size); - IL_DEBUG_INFO(il, "f/w package hdr init data size = %u\n", + D_INFO("f/w package hdr init data size = %u\n", init_data_size); - IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %u\n", + D_INFO("f/w package hdr boot inst size = %u\n", boot_size); @@ -1959,7 +1959,7 @@ static int il3945_read_ucode(struct il_priv *il) inst_size + data_size + init_size + init_data_size + boot_size) { - IL_DEBUG_INFO(il, + D_INFO( "uCode file size %zd does not match expected size\n", ucode_raw->size); ret = -EINVAL; @@ -1968,34 +1968,34 @@ static int il3945_read_ucode(struct il_priv *il) /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(il, "uCode instr len %d too large to fit in\n", + D_INFO("uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(il, "uCode data len %d too large to fit in\n", + D_INFO("uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(il, + D_INFO( "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(il, + D_INFO( "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IWL39_MAX_BSM_SIZE) { - IL_DEBUG_INFO(il, + D_INFO( "uCode boot instr len %d too large to fit in\n", boot_size); ret = -EINVAL; @@ -2045,18 +2045,18 @@ static int il3945_read_ucode(struct il_priv *il) /* Runtime instructions (first block of data in file) */ len = inst_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) uCode instr len %zd\n", len); memcpy(il->ucode_code.v_addr, src, len); src += len; - IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* Runtime data (2nd block) * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) uCode data len %zd\n", len); memcpy(il->ucode_data.v_addr, src, len); memcpy(il->ucode_data_backup.v_addr, src, len); @@ -2065,7 +2065,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init instr len %zd\n", len); memcpy(il->ucode_init.v_addr, src, len); src += len; @@ -2074,7 +2074,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init data len %zd\n", len); memcpy(il->ucode_init_data.v_addr, src, len); src += len; @@ -2082,7 +2082,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Bootstrap instructions (5th block) */ len = boot_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) boot instr len %zd\n", len); memcpy(il->ucode_boot.v_addr, src, len); @@ -2132,7 +2132,7 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); + D_INFO("Runtime uCode pointers are set.\n"); return 0; } @@ -2150,7 +2150,7 @@ static void il3945_init_alive_start(struct il_priv *il) if (il->card_alive_init.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Initialize Alive failed.\n"); + D_INFO("Initialize Alive failed.\n"); goto restart; } @@ -2160,18 +2160,18 @@ static void il3945_init_alive_start(struct il_priv *il) if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); + D_INFO("Bad \"initialize\" uCode load.\n"); goto restart; } /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); if (il3945_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); + D_INFO("Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -2191,12 +2191,12 @@ static void il3945_alive_start(struct il_priv *il) u32 rfkill; struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Alive failed.\n"); + D_INFO("Alive failed.\n"); goto restart; } @@ -2206,12 +2206,12 @@ static void il3945_alive_start(struct il_priv *il) if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); + D_INFO("Bad runtime uCode load.\n"); goto restart; } rfkill = il_read_prph(il, APMG_RFKILL_REG); - IL_DEBUG_INFO(il, "RFKILL status: 0x%x\n", rfkill); + D_INFO("RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { clear_bit(STATUS_RF_KILL_HW, &il->status); @@ -2223,7 +2223,7 @@ static void il3945_alive_start(struct il_priv *il) } if (thermal_spin) - IL_DEBUG_INFO(il, "Thermal calibration took %dus\n", + D_INFO("Thermal calibration took %dus\n", thermal_spin * 10); } else set_bit(STATUS_RF_KILL_HW, &il->status); @@ -2264,7 +2264,7 @@ static void il3945_alive_start(struct il_priv *il) il3945_reg_txpower_periodic(il); - IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + D_INFO("ALIVE processing complete.\n"); wake_up(&il->wait_command_queue); return; @@ -2280,7 +2280,7 @@ static void __il3945_down(struct il_priv *il) unsigned long flags; int exit_pending; - IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); + D_INFO(DRV_NAME " is going down\n"); il_scan_cancel_timeout(il, 200); @@ -2468,7 +2468,7 @@ static int __il3945_up(struct il_priv *il) /* start card; "initialize" will load runtime ucode */ il3945_nic_start(il); - IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); + D_INFO(DRV_NAME " is coming up\n"); return 0; } @@ -2540,7 +2540,7 @@ static void il3945_rfkill_poll(struct work_struct *data) wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); - IL_DEBUG_RF_KILL(il, "RF_KILL bit toggled to %s.\n", + D_RF_KILL("RF_KILL bit toggled to %s.\n", new_rfkill ? "disable radio" : "enable radio"); } @@ -2571,7 +2571,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!il->scan_cmd) { - IL_DEBUG_SCAN(il, "Fail to allocate scan memory\n"); + D_SCAN("Fail to allocate scan memory\n"); return -ENOMEM; } } @@ -2587,7 +2587,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(il, "Scanning while associated...\n"); + D_INFO("Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; @@ -2607,13 +2607,13 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", + D_SCAN("suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + D_SCAN("Kicking off active scan\n"); for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!il->scan_request->ssids[i].ssid_len) @@ -2629,7 +2629,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) } is_active = true; } else - IL_DEBUG_SCAN(il, "Kicking off passive scan.\n"); + D_SCAN("Kicking off passive scan.\n"); /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ @@ -2674,7 +2674,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, (void *)&scan->data[len], vif); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); + D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } @@ -2755,7 +2755,7 @@ void il3945_post_associate(struct il_priv *il) if (!ctx->vif || !il->is_open) return; - IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", + D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); if (test_bit(STATUS_EXIT_PENDING, &il->status)) @@ -2777,7 +2777,7 @@ void il3945_post_associate(struct il_priv *il) ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", + D_ASSOC("assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) @@ -2821,7 +2821,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&il->mutex); @@ -2845,7 +2845,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) if (ret) goto out_release_irq; - IL_DEBUG_INFO(il, "Start UP work.\n"); + D_INFO("Start UP work.\n"); /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2867,12 +2867,12 @@ static int il3945_mac_start(struct ieee80211_hw *hw) cancel_delayed_work(&il->_3945.rfkill_poll); il->is_open = 1; - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return 0; out_release_irq: il->is_open = 0; - IL_DEBUG_MAC80211(il, "leave - failed\n"); + D_MAC80211("leave - failed\n"); return ret; } @@ -2880,10 +2880,10 @@ static void il3945_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (!il->is_open) { - IL_DEBUG_MAC80211(il, "leave - skip\n"); + D_MAC80211("leave - skip\n"); return; } @@ -2897,22 +2897,22 @@ static void il3945_mac_stop(struct ieee80211_hw *hw) queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); - IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il3945_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } void il3945_config_ap(struct il_priv *il) @@ -2971,10 +2971,10 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, u8 sta_id = IL_INVALID_STATION; u8 static_key; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (il3945_mod_params.sw_crypto) { - IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); + D_MAC80211("leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -3004,21 +3004,21 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = il3945_set_static_key(il, key); else ret = il3945_set_dynamic_key(il, key, sta_id); - IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); + D_MAC80211("enable hwcrypto key\n"); break; case DISABLE_KEY: if (static_key) ret = il3945_remove_static_key(il); else ret = il3945_clear_sta_key_info(il, sta_id); - IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); + D_MAC80211("disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return ret; } @@ -3033,10 +3033,10 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - IL_DEBUG_INFO(il, "received request to add station %pM\n", + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - IL_DEBUG_INFO(il, "proceeding to add station %pM\n", + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; @@ -3055,7 +3055,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il3945_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); @@ -3079,7 +3079,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -3224,7 +3224,7 @@ static ssize_t il3945_store_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(il, "Committing rxon.flags = 0x%04X\n", + D_INFO("Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); il3945_commit_rxon(il, ctx); @@ -3261,7 +3261,7 @@ static ssize_t il3945_store_filter_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(il, "Committing rxon.filter_flags = " + D_INFO("Committing rxon.filter_flags = " "0x%04X\n", filter_flags); ctx->staging.filter_flags = cpu_to_le32(filter_flags); @@ -3337,7 +3337,7 @@ static ssize_t il3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - IL_DEBUG_INFO(il, "Invoking measurement of type %d on " + D_INFO("Invoking measurement of type %d on " "channel %d (for '%s')\n", type, params.channel, buf); il3945_get_measurement(il, ¶ms, type); @@ -3402,15 +3402,15 @@ static ssize_t il3945_store_antenna(struct device *d, return 0; if (sscanf(buf, "%1i", &ant) != 1) { - IL_DEBUG_INFO(il, "not in hex or decimal form.\n"); + D_INFO("not in hex or decimal form.\n"); return count; } if ((ant >= 0) && (ant <= 2)) { - IL_DEBUG_INFO(il, "Setting antenna select to %d.\n", ant); + D_INFO("Setting antenna select to %d.\n", ant); il3945_mod_params.antenna = (enum il3945_antenna)ant; } else - IL_DEBUG_INFO(il, "Bad antenna select value %d.\n", ant); + D_INFO("Bad antenna select value %d.\n", ant); return count; @@ -3682,11 +3682,11 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * "the hard way", rather than using device's scan. */ if (il3945_mod_params.disable_hw_scan) { - IL_DEBUG_INFO(il, "Disabling hw_scan\n"); + D_INFO("Disabling hw_scan\n"); il3945_hw_ops.hw_scan = NULL; } - IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; @@ -3729,9 +3729,9 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en goto out_pci_release_regions; } - IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", + D_INFO("pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); + D_INFO("pci_resource_base = %p\n", il->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -3762,7 +3762,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en } /* MAC Address location in EEPROM same for 3945/4965 */ eeprom = (struct il3945_eeprom *)il->eeprom; - IL_DEBUG_INFO(il, "MAC address: %pM\n", eeprom->mac_address); + D_INFO("MAC address: %pM\n", eeprom->mac_address); SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); /*********************** @@ -3873,7 +3873,7 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) if (!il) return; - IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); + D_INFO("*** UNLOAD DRIVER ***\n"); il_dbgfs_unregister(il); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d4eacc3..88dc8db 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -104,7 +104,7 @@ static void il4965_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { @@ -436,19 +436,19 @@ static void il4965_rx_reply_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_init_alive_resp)); pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); pwork = &il->alive_start; @@ -496,7 +496,7 @@ static void il4965_rx_beacon_notif(struct il_priv *il, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -512,7 +512,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) { unsigned long flags; - IL_DEBUG_POWER(il, "Stop all queues\n"); + D_POWER("Stop all queues\n"); if (il->mac80211_registered) ieee80211_stop_queues(il->hw); @@ -536,7 +536,7 @@ static void il4965_rx_card_state_notif(struct il_priv *il, u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; - IL_DEBUG_RF_KILL(il, "Card state received: HW:%s SW:%s CT:%s\n", + D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On", (flags & CT_CARD_DISABLED) ? @@ -650,7 +650,7 @@ void il4965_rx_handle(struct il_priv *il) /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); + D_RX("r = %d, i = %d\n", r, i); /* calculate total frames need to be restock after handling RX */ total_empty = r - rxq->write_actual; @@ -698,14 +698,14 @@ void il4965_rx_handle(struct il_priv *il) * handle those that need handling via function in * rx_handlers table. See il4965_setup_rx_handlers() */ if (il->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.rx_handlers[pkt->hdr.cmd]++; il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(il, + D_RX( "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -800,7 +800,7 @@ static void il4965_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = il_read32(il, CSR_INT_MASK); - IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -835,14 +835,14 @@ static void il4965_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(il, "Scheduler finished to transmit " + D_ISR("Scheduler finished to transmit " "the frame/frames.\n"); il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(il, "Alive interrupt\n"); + D_ISR("Alive interrupt\n"); il->isr_stats.alive++; } } @@ -900,7 +900,7 @@ static void il4965_irq_tasklet(struct il_priv *il) * and about any Rx buffers made available while asleep. */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + D_ISR("Wakeup interrupt\n"); il_rx_queue_update_write_ptr(il, &il->rxq); for (i = 0; i < il->hw_params.max_txq_num; i++) il_txq_update_write_ptr(il, &il->txq[i]); @@ -919,7 +919,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* This "Tx" DMA channel is used only for loading uCode */ if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(il, "uCode load interrupt\n"); + D_ISR("uCode load interrupt\n"); il->isr_stats.tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ @@ -951,7 +951,7 @@ static void il4965_irq_tasklet(struct il_priv *il) inta = il_read32(il, CSR_INT); inta_mask = il_read32(il, CSR_INT_MASK); inta_fh = il_read32(il, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(il, + D_ISR( "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -1120,7 +1120,7 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IL_DEBUG_INFO(il, "attempting to load firmware '%s'\n", + D_INFO("attempting to load firmware '%s'\n", il->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, @@ -1220,7 +1220,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) goto try_again; } - IL_DEBUG_INFO(il, "Loaded firmware file '%s' (%zd bytes).\n", + D_INFO("Loaded firmware file '%s' (%zd bytes).\n", il->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ @@ -1279,17 +1279,17 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); - IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %Zd\n", + D_INFO("f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); - IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %Zd\n", + D_INFO("f/w package hdr runtime data size = %Zd\n", pieces.data_size); - IL_DEBUG_INFO(il, "f/w package hdr init inst size = %Zd\n", + D_INFO("f/w package hdr init inst size = %Zd\n", pieces.init_size); - IL_DEBUG_INFO(il, "f/w package hdr init data size = %Zd\n", + D_INFO("f/w package hdr init data size = %Zd\n", pieces.init_data_size); - IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %Zd\n", + D_INFO("f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ @@ -1369,25 +1369,25 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Copy images into buffers for card's bus-master reads ... */ /* Runtime instructions (first block of data in file) */ - IL_DEBUG_INFO(il, "Copying (but not loading) uCode instr len %Zd\n", + D_INFO("Copying (but not loading) uCode instr len %Zd\n", pieces.inst_size); memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); - IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* * Runtime data * NOTE: Copy into backup buffer will be done in il_up() */ - IL_DEBUG_INFO(il, "Copying (but not loading) uCode data len %Zd\n", + D_INFO("Copying (but not loading) uCode data len %Zd\n", pieces.data_size); memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init instr len %Zd\n", pieces.init_size); memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); @@ -1395,7 +1395,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Initialization data */ if (pieces.init_data_size) { - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init data len %Zd\n", pieces.init_data_size); memcpy(il->ucode_init_data.v_addr, pieces.init_data, @@ -1403,7 +1403,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) } /* Bootstrap instructions */ - IL_DEBUG_INFO(il, "Copying (but not loading) boot instr len %Zd\n", + D_INFO("Copying (but not loading) boot instr len %Zd\n", pieces.boot_size); memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); @@ -1596,7 +1596,7 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) if (ret) IL_ERR(il, "REPLY_CT_KILL_CONFIG_CMD failed\n"); else - IL_DEBUG_INFO(il, "REPLY_CT_KILL_CONFIG_CMD " + D_INFO("REPLY_CT_KILL_CONFIG_CMD " "succeeded, " "critical temperature is %d\n", il->hw_params.ct_kill_threshold); @@ -1719,12 +1719,12 @@ static void il4965_alive_start(struct il_priv *il) int ret = 0; struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Alive failed.\n"); + D_INFO("Alive failed.\n"); goto restart; } @@ -1734,7 +1734,7 @@ static void il4965_alive_start(struct il_priv *il) if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); + D_INFO("Bad runtime uCode load.\n"); goto restart; } @@ -1788,11 +1788,11 @@ static void il4965_alive_start(struct il_priv *il) /* At this point, the NIC is initialized and operational */ il4965_rf_kill_ct_config(il); - IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + D_INFO("ALIVE processing complete.\n"); wake_up(&il->wait_command_queue); il_power_update_mode(il, true); - IL_DEBUG_INFO(il, "Updated power mode\n"); + D_INFO("Updated power mode\n"); return; @@ -1807,7 +1807,7 @@ static void __il4965_down(struct il_priv *il) unsigned long flags; int exit_pending; - IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); + D_INFO(DRV_NAME " is going down\n"); il_scan_cancel_timeout(il, 200); @@ -1916,7 +1916,7 @@ static int il4965_set_hw_ready(struct il_priv *il) else il->hw_ready = false; - IL_DEBUG_INFO(il, "hardware %s\n", + D_INFO("hardware %s\n", (il->hw_ready == 1) ? "ready" : "not ready"); return ret; } @@ -1925,7 +1925,7 @@ static int il4965_prepare_card_hw(struct il_priv *il) { int ret = 0; - IL_DEBUG_INFO(il, "il4965_prepare_card_hw enter\n"); + D_INFO("il4965_prepare_card_hw enter\n"); ret = il4965_set_hw_ready(il); if (il->hw_ready) @@ -2040,7 +2040,7 @@ static int __il4965_up(struct il_priv *il) /* start card; "initialize" will load runtime ucode */ il4965_nic_start(il); - IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); + D_INFO(DRV_NAME " is coming up\n"); return 0; } @@ -2243,7 +2243,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&il->mutex); @@ -2256,7 +2256,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) if (il_is_rfkill(il)) goto out; - IL_DEBUG_INFO(il, "Start UP work done.\n"); + D_INFO("Start UP work done.\n"); /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2275,7 +2275,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) out: il->is_open = 1; - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return 0; } @@ -2283,7 +2283,7 @@ void il4965_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (!il->is_open) return; @@ -2299,22 +2299,22 @@ void il4965_mac_stop(struct ieee80211_hw *hw) il_write32(il, CSR_INT, 0xFFFFFFFF); il_enable_rfkill_int(il); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; - IL_DEBUG_MACDUMP(il, "enter\n"); + D_MACDUMP("enter\n"); - IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il4965_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MACDUMP(il, "leave\n"); + D_MACDUMP("leave\n"); } void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, @@ -2326,12 +2326,12 @@ void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, iv32, phase1key); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, @@ -2345,10 +2345,10 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, u8 sta_id; bool is_default_wep_key = false; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (il->cfg->mod_params->sw_crypto) { - IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); + D_MAC80211("leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -2384,7 +2384,7 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = il4965_set_dynamic_key(il, vif_priv->ctx, key, sta_id); - IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); + D_MAC80211("enable hwcrypto key\n"); break; case DISABLE_KEY: if (is_default_wep_key) @@ -2393,14 +2393,14 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = il4965_remove_dynamic_key(il, ctx, key, sta_id); - IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); + D_MAC80211("disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return ret; } @@ -2414,7 +2414,7 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; int ret = -EINVAL; - IL_DEBUG_HT(il, "A-MPDU action on addr %pM tid %d\n", + D_HT("A-MPDU action on addr %pM tid %d\n", sta->addr, tid); if (!(il->cfg->sku & IL_SKU_N)) @@ -2424,21 +2424,21 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, switch (action) { case IEEE80211_AMPDU_RX_START: - IL_DEBUG_HT(il, "start Rx\n"); + D_HT("start Rx\n"); ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); break; case IEEE80211_AMPDU_RX_STOP: - IL_DEBUG_HT(il, "stop Rx\n"); + D_HT("stop Rx\n"); ret = il4965_sta_rx_agg_stop(il, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: - IL_DEBUG_HT(il, "start Tx\n"); + D_HT("start Tx\n"); ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); break; case IEEE80211_AMPDU_TX_STOP: - IL_DEBUG_HT(il, "stop Tx\n"); + D_HT("stop Tx\n"); ret = il4965_tx_agg_stop(il, vif, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; @@ -2463,10 +2463,10 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, int ret; u8 sta_id; - IL_DEBUG_INFO(il, "received request to add station %pM\n", + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - IL_DEBUG_INFO(il, "proceeding to add station %pM\n", + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; @@ -2485,7 +2485,7 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il4965_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); @@ -2505,7 +2505,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u16 ch; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); mutex_lock(&il->mutex); @@ -2529,7 +2529,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(il, "invalid channel\n"); + D_MAC80211("invalid channel\n"); goto out; } @@ -2580,7 +2580,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, out: mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } void il4965_configure_filter(struct ieee80211_hw *hw, @@ -2599,7 +2599,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -2755,7 +2755,7 @@ void il4965_tx_queue_set_status(struct il_priv *il, txq->sched_retry = scd_retry; - IL_DEBUG_INFO(il, "%s %s Queue %d on AC %d\n", + D_INFO("%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } @@ -2824,7 +2824,7 @@ static void il4965_hw_detect(struct il_priv *il) il->hw_rev = _il_read32(il, CSR_HW_REV); il->hw_wa_rev = _il_read32(il, CSR_HW_REV_WA_REG); il->rev_id = il->pci_dev->revision; - IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", il->rev_id); + D_INFO("HW Revision ID = 0x%X\n", il->rev_id); } static int il4965_set_hw_params(struct il_priv *il) @@ -2911,7 +2911,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) SET_IEEE80211_DEV(hw, &pdev->dev); - IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; @@ -2963,9 +2963,9 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_pci_release_regions; } - IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", + D_INFO("pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); + D_INFO("pci_resource_base = %p\n", il->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now @@ -3012,7 +3012,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* extract MAC Address */ il4965_eeprom_get_mac(il, il->addresses[0].addr); - IL_DEBUG_INFO(il, "MAC address: %pM\n", il->addresses[0].addr); + D_INFO("MAC address: %pM\n", il->addresses[0].addr); il->hw->wiphy->addresses = il->addresses; il->hw->wiphy->n_addresses = 1; @@ -3118,7 +3118,7 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) wait_for_completion(&il->_4965.firmware_loading_complete); - IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); + D_INFO("*** UNLOAD DRIVER ***\n"); il_dbgfs_unregister(il); sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); -- cgit v0.10.2 From 9406f79775a5374b932ac45ae9e84a71032a9d33 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Thu, 18 Aug 2011 22:07:57 +0200 Subject: iwlegacy: remove il argument from IWL_ERR/INFO/WARN/CRIT Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index b767979..40e3a70 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -71,7 +71,7 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -341,7 +341,7 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -440,7 +440,7 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index a1e2a42..cf47fdb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -166,7 +166,7 @@ void il3945_disable_events(struct il_priv *il) base = le32_to_cpu(il->card_alive.log_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(il, "Invalid event log pointer 0x%08X\n", base); + IL_ERR("Invalid event log pointer 0x%08X\n", base); return; } @@ -317,7 +317,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, int fail; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -350,7 +350,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, il3945_tx_queue_reclaim(il, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) - IL_ERR(il, "TODO: Implement Tx ABORT REQUIRED!!!\n"); + IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); } @@ -484,7 +484,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(il, "dev_alloc_skb failed\n"); + IL_ERR("dev_alloc_skb failed\n"); return; } @@ -600,7 +600,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { - IL_ERR(il, "Error can not send more than %d chunks\n", + IL_ERR("Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; } @@ -633,7 +633,7 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* sanity check */ counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if (counter > NUM_TFD_CHUNKS) { - IL_ERR(il, "Too many chunks: %i\n", counter); + IL_ERR("Too many chunks: %i\n", counter); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -855,7 +855,7 @@ static int il3945_txq_ctx_reset(struct il_priv *il) rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (rc) { - IL_ERR(il, "Tx %d queue init failed\n", txq_id); + IL_ERR("Tx %d queue init failed\n", txq_id); goto error; } } @@ -971,7 +971,7 @@ int il3945_hw_nic_init(struct il_priv *il) if (!rxq->bd) { rc = il_rx_queue_alloc(il); if (rc) { - IL_ERR(il, "Unable to initialize Rx queue\n"); + IL_ERR("Unable to initialize Rx queue\n"); return -ENOMEM; } } else @@ -1078,7 +1078,7 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) /* handle insane temp reading */ if (il3945_hw_reg_temp_out_of_range(temperature)) { - IL_ERR(il, "Error bad temperature value %d\n", temperature); + IL_ERR("Error bad temperature value %d\n", temperature); /* if really really hot(?), * substitute the 3rd band/group's temp measured at factory */ @@ -1388,7 +1388,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; ch_info = il_get_channel_info(il, il->band, chan); if (!ch_info) { - IL_ERR(il, + IL_ERR( "Failed to get channel info for channel %d [%d]\n", chan, il->band); return -EINVAL; @@ -1686,7 +1686,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_RXON_ASSOC command\n"); + IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; } @@ -1727,7 +1727,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) rc = il_check_rxon_cmd(il, ctx); if (rc) { - IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); + IL_ERR("Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1739,7 +1739,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) rc = il_send_rxon_assoc(il, &il->contexts[IL_RXON_CTX_BSS]); if (rc) { - IL_ERR(il, "Error setting RXON_ASSOC " + IL_ERR("Error setting RXON_ASSOC " "configuration (%d).\n", rc); return rc; } @@ -1775,7 +1775,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(il, "Error clearing ASSOC_MSK on current " + IL_ERR("Error clearing ASSOC_MSK on current " "configuration (%d).\n", rc); return rc; } @@ -1807,7 +1807,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { - IL_ERR(il, "Error setting new configuration (%d).\n", rc); + IL_ERR("Error setting new configuration (%d).\n", rc); return rc; } @@ -1824,14 +1824,14 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * send a new TXPOWER command or we won't be able to Tx any frames */ rc = il_set_tx_power(il, il->tx_power_next, true); if (rc) { - IL_ERR(il, "Error setting Tx power (%d).\n", rc); + IL_ERR("Error setting Tx power (%d).\n", rc); return rc; } /* Init the hardware's rate fallback order based on the band */ rc = il3945_init_hw_rate_table(il); if (rc) { - IL_ERR(il, "Error setting HW rate table: %02X\n", rc); + IL_ERR("Error setting HW rate table: %02X\n", rc); return -EIO; } @@ -1989,7 +1989,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { - IL_WARN(il, "Error: saturation power is %d, " + IL_WARN("Error: saturation power is %d, " "less than minimum expected 40\n", group->saturation_power); return; @@ -2119,7 +2119,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) ch_info->group_index, &power_idx); if (rc) { - IL_ERR(il, "Invalid power index\n"); + IL_ERR("Invalid power index\n"); return rc; } pwr_info->base_power_index = (u8) power_idx; @@ -2187,7 +2187,7 @@ int il3945_hw_rxq_stop(struct il_priv *il) rc = il_poll_direct_bit(il, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) - IL_ERR(il, "Can't stop Rx DMA.\n"); + IL_ERR("Can't stop Rx DMA.\n"); return 0; } @@ -2263,7 +2263,7 @@ static int il3945_add_bssid_station(struct il_priv *il, ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM\n", addr); + IL_ERR("Unable to add station %pM\n", addr); return ret; } @@ -2390,7 +2390,7 @@ int il3945_hw_set_hw_params(struct il_priv *il) sizeof(struct il3945_shared), &il->_3945.shared_phys, GFP_KERNEL); if (!il->_3945.shared_virt) { - IL_ERR(il, "failed to allocate pci memory\n"); + IL_ERR("failed to allocate pci memory\n"); return -ENOMEM; } @@ -2481,7 +2481,7 @@ static int il3945_verify_bsm(struct il_priv *il) reg += sizeof(u32), image++) { val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "BSM uCode verification failed at " + IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -2620,7 +2620,7 @@ static int il3945_load_bsm(struct il_priv *il) if (i < 100) D_INFO("BSM write complete, poll %d iterations\n", i); else { - IL_ERR(il, "BSM write did not complete!\n"); + IL_ERR("BSM write did not complete!\n"); return -EIO; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index 8ea0ac2..ebb71a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -75,7 +75,7 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -501,7 +501,7 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -679,7 +679,7 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index ef8b0d5..016472d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -129,12 +129,12 @@ int il4965_eeprom_check_version(struct il_priv *il) calib_ver < il->cfg->eeprom_calib_ver) goto err; - IL_INFO(il, "device EEPROM VER=0x%x, CALIB=0x%x\n", + IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: - IL_ERR(il, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " + IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " "CALIB=0x%x < 0x%x\n", eeprom_ver, il->cfg->eeprom_ver, calib_ver, il->cfg->eeprom_calib_ver); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index b51ae3d..f4df28d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -44,7 +44,7 @@ void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IL_ERR(il, "Tx flush command to flush out all frames\n"); + IL_ERR("Tx flush command to flush out all frames\n"); if (!test_bit(STATUS_EXIT_PENDING, &il->status)) queue_work(il->workqueue, &il->tx_flush); } @@ -176,7 +176,7 @@ int il4965_hw_nic_init(struct il_priv *il) if (!rxq->bd) { ret = il_rx_queue_alloc(il); if (ret) { - IL_ERR(il, "Unable to initialize Rx queue\n"); + IL_ERR("Unable to initialize Rx queue\n"); return -ENOMEM; } } else @@ -309,7 +309,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(il, + IL_CRIT( "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? @@ -549,7 +549,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(il, "dev_alloc_skb failed\n"); + IL_ERR("dev_alloc_skb failed\n"); return; } @@ -598,7 +598,7 @@ void il4965_rx_reply_rx(struct il_priv *il, ampdu_status = le32_to_cpu(rx_pkt_status); } else { if (!il->_4965.last_phy_res_valid) { - IL_ERR(il, "MPDU frame without cached PHY data\n"); + IL_ERR("MPDU frame without cached PHY data\n"); return; } phy_res = &il->_4965.last_phy_res; @@ -880,7 +880,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) rate = IL_RATE_6M_PLCP; break; default: - IL_WARN(il, "Invalid scan band\n"); + IL_WARN("Invalid scan band\n"); return -EIO; } @@ -1184,9 +1184,9 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) return pos; } #endif - IL_ERR(il, "FH register values:\n"); + IL_ERR("FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(il, " %34s: 0X%08x\n", + IL_ERR(" %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), il_read_direct32(il, fh_tbl[i])); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index b53cf1b..93bb31d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -367,12 +367,12 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, * this might be cause by reloading firmware * stop the tx ba session here */ - IL_ERR(il, "Fail start Tx agg on tid: %d\n", + IL_ERR("Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { - IL_ERR(il, "Aggregation not enabled for tid %d " + IL_ERR("Aggregation not enabled for tid %d " "because load = %u\n", tid, load); } return ret; @@ -385,7 +385,7 @@ static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, if (tid < TID_MAX_LOAD_COUNT) il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); else - IL_ERR(il, "tid exceeds max load count: %d/%d\n", + IL_ERR("tid exceeds max load count: %d/%d\n", tid, TID_MAX_LOAD_COUNT); } @@ -505,7 +505,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, } else if (is_Ht(tbl->lq_type)) { if (index > IL_LAST_OFDM_RATE) { - IL_ERR(il, "Invalid HT rate index %d\n", index); + IL_ERR("Invalid HT rate index %d\n", index); index = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; @@ -515,7 +515,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, else rate_n_flags |= il_rates[index].plcp_mimo2; } else { - IL_ERR(il, "Invalid tbl->lq_type %d\n", tbl->lq_type); + IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); } rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & @@ -535,7 +535,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, rate_n_flags |= RATE_MCS_GF_MSK; if (is_siso(tbl->lq_type) && tbl->is_SGI) { rate_n_flags &= ~RATE_MCS_SGI_MSK; - IL_ERR(il, "GF was set with SGI:SISO\n"); + IL_ERR("GF was set with SGI:SISO\n"); } } } @@ -1480,7 +1480,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, if (!tbl->is_SGI) break; else - IL_ERR(il, + IL_ERR( "SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; @@ -1851,7 +1851,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, rate_scale_index_msk = rate_mask; if (!((1 << index) & rate_scale_index_msk)) { - IL_ERR(il, "Current Rate is not valid\n"); + IL_ERR("Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ tbl->lq_type = LQ_NONE; @@ -1867,7 +1867,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Get expected throughput table and history window for current rate */ if (!tbl->expected_tpt) { - IL_ERR(il, "tbl->expected_tpt is NULL\n"); + IL_ERR("tbl->expected_tpt is NULL\n"); return; } @@ -1909,7 +1909,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * actual average throughput */ if (window->average_tpt != ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { - IL_ERR(il, + IL_ERR( "expected_tpt should have been calculated by now\n"); window->average_tpt = ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128); @@ -2590,7 +2590,7 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, D_RATE("Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IL_ERR(il, + IL_ERR( "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); D_RATE("Fixed rate OFF\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 3019baf..a82d444 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -44,7 +44,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); if (!link_cmd) { - IL_ERR(il, "Unable to allocate memory for LQ cmd.\n"); + IL_ERR("Unable to allocate memory for LQ cmd.\n"); return NULL; } /* Set up the rate scaling to start at selected rate, fall back @@ -105,7 +105,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM\n", addr); + IL_ERR("Unable to add station %pM\n", addr); return ret; } @@ -119,7 +119,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, /* Set up default rate scaling table in device's station table */ link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(il, + IL_ERR( "Unable to initialize rate scaling for station %pM.\n", addr); return -ENOMEM; @@ -127,7 +127,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); if (ret) - IL_ERR(il, "Link quality command failed (%d)\n", ret); + IL_ERR("Link quality command failed (%d)\n", ret); spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].lq = link_cmd; @@ -467,7 +467,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, } if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN(il, "Removing wrong key %d 0x%x\n", + IL_WARN("Removing wrong key %d 0x%x\n", keyconf->keyidx, key_flags); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; @@ -475,7 +475,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, &il->ucode_key_table)) - IL_ERR(il, "index %d not used in uCode key table.\n", + IL_ERR("index %d not used in uCode key table.\n", il->stations[sta_id].sta.key.key_offset); memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); @@ -525,7 +525,7 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, keyconf, sta_id); break; default: - IL_ERR(il, + IL_ERR( "Unknown alg: %s cipher = %x\n", __func__, keyconf->cipher); ret = -EINVAL; @@ -557,7 +557,7 @@ int il4965_alloc_bcast_station(struct il_priv *il, sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Unable to prepare broadcast station\n"); + IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; @@ -569,7 +569,7 @@ int il4965_alloc_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(il, + IL_ERR( "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -596,7 +596,7 @@ static int il4965_update_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(il, + IL_ERR( "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -686,7 +686,7 @@ int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Invalid station for AGG tid %d\n", tid); + IL_ERR("Invalid station for AGG tid %d\n", tid); return -ENXIO; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index efc21be..66dd172 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -258,7 +258,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, break; default: - IL_ERR(il, "Unknown encode cipher %x\n", keyconf->cipher); + IL_ERR("Unknown encode cipher %x\n", keyconf->cipher); break; } } @@ -619,13 +619,13 @@ int il4965_txq_ctx_alloc(struct il_priv *il) ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, il->hw_params.scd_bc_tbls_size); if (ret) { - IL_ERR(il, "Scheduler BC Table allocation failed\n"); + IL_ERR("Scheduler BC Table allocation failed\n"); goto error_bc_tbls; } /* Alloc keep-warm buffer */ ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); if (ret) { - IL_ERR(il, "Keep Warm allocation failed\n"); + IL_ERR("Keep Warm allocation failed\n"); goto error_kw; } @@ -652,7 +652,7 @@ int il4965_txq_ctx_alloc(struct il_priv *il) &il->txq[txq_id], slots_num, txq_id); if (ret) { - IL_ERR(il, "Tx %d queue init failed\n", txq_id); + IL_ERR("Tx %d queue init failed\n", txq_id); goto error; } } @@ -712,7 +712,7 @@ void il4965_txq_ctx_stop(struct il_priv *il) if (il_poll_direct_bit(il, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) - IL_ERR(il, "Failing on timeout while stopping" + IL_ERR("Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, il_read_direct32(il, FH_TSSR_TX_STATUS_REG)); @@ -803,7 +803,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(il, + IL_WARN( "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -871,25 +871,25 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN(il, "%s on ra = %pM tid = %d\n", + IL_WARN("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Start AGG on invalid station\n"); + IL_ERR("Start AGG on invalid station\n"); return -ENXIO; } if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { - IL_ERR(il, "Start AGG when state is not IL_AGG_OFF !\n"); + IL_ERR("Start AGG when state is not IL_AGG_OFF !\n"); return -ENXIO; } txq_id = il4965_txq_ctx_activate_free(il); if (txq_id == -1) { - IL_ERR(il, "No free aggregation queue available\n"); + IL_ERR("No free aggregation queue available\n"); return -ENXIO; } @@ -932,7 +932,7 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(il, + IL_WARN( "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -973,7 +973,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Invalid station for AGG tid %d\n", tid); + IL_ERR("Invalid station for AGG tid %d\n", tid); return -ENXIO; } @@ -996,7 +996,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, case IL_AGG_ON: break; default: - IL_WARN(il, "Stopping AGG while state not ON or starting\n"); + IL_WARN("Stopping AGG while state not ON or starting\n"); } write_ptr = il->txq[txq_id].q.write_ptr; @@ -1115,7 +1115,7 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) struct ieee80211_hdr *hdr; if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { - IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); return 0; @@ -1163,7 +1163,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) - IL_ERR(il, "Received BA when not expected\n"); + IL_ERR("Received BA when not expected\n"); return -EINVAL; } @@ -1266,7 +1266,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= il->hw_params.max_txq_num) { - IL_ERR(il, + IL_ERR( "BUG_ON scd_flow is bigger than number of queues\n"); return; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index d1e1775..3fa939e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -99,7 +99,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, * if IL_DL_IO is set */ val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "uCode INST section is invalid at " + IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); ret = -EIO; @@ -153,7 +153,7 @@ int il4965_verify_ucode(struct il_priv *il) return 0; } - IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index cc28e0e..7b422f2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -78,7 +78,7 @@ static int il4965_verify_bsm(struct il_priv *il) reg += sizeof(u32), image++) { val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "BSM uCode verification failed at " + IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -191,7 +191,7 @@ static int il4965_load_bsm(struct il_priv *il) if (i < 100) D_INFO("BSM write complete, poll %d iterations\n", i); else { - IL_ERR(il, "BSM write did not complete!\n"); + IL_ERR("BSM write did not complete!\n"); return -EIO; } @@ -343,7 +343,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) cmd.diff_gain_c = 0; if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd)) - IL_ERR(il, + IL_ERR( "Could not send REPLY_PHY_CALIBRATION_CMD\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; D_CALIB("Run chain_noise_calibrate\n"); @@ -548,7 +548,7 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, s = il4965_get_sub_band(il, channel); if (s >= EEPROM_TX_POWER_BANDS) { - IL_ERR(il, "Tx Power can not find channel %d\n", channel); + IL_ERR("Tx Power can not find channel %d\n", channel); return -1; } @@ -912,7 +912,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * and 2) mimo txpower balance between Tx chains. */ txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IL_ERR(il, "Can't find txatten group for channel %d.\n", + IL_ERR("Can't find txatten group for channel %d.\n", channel); return txatten_grp; } @@ -1078,12 +1078,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* stay within the table! */ if (power_index > 107) { - IL_WARN(il, "txpower index %d > 107\n", + IL_WARN("txpower index %d > 107\n", power_index); power_index = 107; } if (power_index < 0) { - IL_WARN(il, "txpower index %d < 0\n", + IL_WARN("txpower index %d < 0\n", power_index); power_index = 0; } @@ -1207,7 +1207,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) ret = il_check_rxon_cmd(il, ctx); if (ret) { - IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); + IL_ERR("Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1228,7 +1228,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) if (!il_full_rxon_required(il, ctx)) { ret = il_send_rxon_assoc(il, ctx); if (ret) { - IL_ERR(il, "Error setting RXON_ASSOC (%d)\n", ret); + IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); return ret; } @@ -1258,14 +1258,14 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * active_rxon back to what it was previously */ if (ret) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(il, "Error clearing ASSOC_MSK (%d)\n", ret); + IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret); return ret; } il_clear_ucode_stations(il, ctx); il_restore_stations(il, ctx); ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret; } } @@ -1289,7 +1289,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(il, "Error setting new RXON (%d)\n", ret); + IL_ERR("Error setting new RXON (%d)\n", ret); return ret; } D_INFO("Return from !new_assoc RXON.\n"); @@ -1298,7 +1298,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) il_restore_stations(il, ctx); ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret; } } @@ -1310,7 +1310,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(il, "Error setting new RXON (%d)\n", ret); + IL_ERR("Error setting new RXON (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); @@ -1323,7 +1323,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * send a new TXPOWER command or we won't be able to Tx any frames */ ret = il_set_tx_power(il, il->tx_power_next, true); if (ret) { - IL_ERR(il, "Error sending TX power (%d)\n", ret); + IL_ERR("Error sending TX power (%d)\n", ret); return ret; } @@ -1393,7 +1393,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, if (ch_info) cmd.expect_beacon = il_is_channel_radar(ch_info); else { - IL_ERR(il, "invalid channel switch from %u to %u\n", + IL_ERR("invalid channel switch from %u to %u\n", ctx->active.channel, ch); return -EFAULT; } @@ -1479,7 +1479,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { - IL_ERR(il, "Calibration conflict R1 == R3\n"); + IL_ERR("Calibration conflict R1 == R3\n"); return -1; } @@ -1666,7 +1666,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (!hdr) { - IL_ERR(il, + IL_ERR( "BUG_ON idx doesn't point to valid skb" " idx=%d, txq_id=%d\n", idx, txq_id); return -1; @@ -1674,7 +1674,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR(il, + IL_ERR( "BUG_ON idx doesn't match seq control" " idx=%d, seq_idx=%d, seq=%d\n", idx, SEQ_TO_SN(sc), hdr->seq_ctrl); @@ -1750,7 +1750,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { - IL_ERR(il, "Requested station info for sta %d before ready.\n", + IL_ERR("Requested station info for sta %d before ready.\n", ret); ret = IL_INVALID_STATION; } @@ -1790,7 +1790,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, unsigned long flags; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -1809,7 +1809,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, sta_id = il4965_get_ra_sta_id(il, hdr); if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { - IL_ERR(il, "Station not known\n"); + IL_ERR("Station not known\n"); return; } @@ -1943,7 +1943,7 @@ static void il4965_post_associate(struct il_priv *il) ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(il, "RXON timing - " + IL_WARN("RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -1982,7 +1982,7 @@ static void il4965_post_associate(struct il_priv *il) il4965_send_beacon_cmd(il); break; default: - IL_ERR(il, "%s Should not be called in %d mode\n", + IL_ERR("%s Should not be called in %d mode\n", __func__, vif->type); break; } @@ -2019,7 +2019,7 @@ static void il4965_config_ap(struct il_priv *il) /* RXON Timing */ ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(il, "RXON timing failed - " + IL_WARN("RXON timing failed - " "Attempting to continue.\n"); /* AP has all antennas */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index e6c7e9d..42be833 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -253,14 +253,14 @@ int il_init_geos(struct il_priv *il) if ((il->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && il->cfg->sku & IL_SKU_A) { - IL_INFO(il, "Incorrectly detected BG card as ABG. " + IL_INFO("Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", il->pci_dev->device, il->pci_dev->subsystem_device); il->cfg->sku &= ~IL_SKU_A; } - IL_INFO(il, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", + IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", il->bands[IEEE80211_BAND_2GHZ].n_channels, il->bands[IEEE80211_BAND_5GHZ].n_channels); @@ -431,65 +431,65 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) if (rxon->flags & RXON_FLG_BAND_24G_MSK) { if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IL_WARN(il, "check 2.4G: wrong narrow\n"); + IL_WARN("check 2.4G: wrong narrow\n"); error = true; } if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IL_WARN(il, "check 2.4G: wrong radar\n"); + IL_WARN("check 2.4G: wrong radar\n"); error = true; } } else { if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(il, "check 5.2G: not short slot!\n"); + IL_WARN("check 5.2G: not short slot!\n"); error = true; } if (rxon->flags & RXON_FLG_CCK_MSK) { - IL_WARN(il, "check 5.2G: CCK!\n"); + IL_WARN("check 5.2G: CCK!\n"); error = true; } } if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IL_WARN(il, "mac/bssid mcast!\n"); + IL_WARN("mac/bssid mcast!\n"); error = true; } /* make sure basic rates 6Mbps and 1Mbps are supported */ if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { - IL_WARN(il, "neither 1 nor 6 are basic\n"); + IL_WARN("neither 1 nor 6 are basic\n"); error = true; } if (le16_to_cpu(rxon->assoc_id) > 2007) { - IL_WARN(il, "aid > 2007\n"); + IL_WARN("aid > 2007\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(il, "CCK and short slot\n"); + IL_WARN("CCK and short slot\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IL_WARN(il, "CCK and auto detect"); + IL_WARN("CCK and auto detect"); error = true; } if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK) { - IL_WARN(il, "TGg but no auto-detect\n"); + IL_WARN("TGg but no auto-detect\n"); error = true; } if (error) - IL_WARN(il, "Tuning to channel %d\n", + IL_WARN("Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { - IL_ERR(il, "Invalid RXON\n"); + IL_ERR("Invalid RXON\n"); return -EINVAL; } return 0; @@ -626,7 +626,7 @@ static void _il_set_rxon_ht(struct il_priv *il, case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IL_ERR(il, + IL_ERR( "invalid extension channel offset\n"); break; } @@ -778,7 +778,7 @@ void il_connection_init_rx_config(struct il_priv *il, break; default: - IL_ERR(il, "Unsupported interface type %d\n", + IL_ERR("Unsupported interface type %d\n", ctx->vif->type); break; } @@ -828,7 +828,7 @@ void il_set_rate(struct il_priv *il) hw = il_get_hw_mode(il, il->band); if (!hw) { - IL_ERR(il, "Failed to set rate: unable to get hw mode\n"); + IL_ERR("Failed to set rate: unable to get hw mode\n"); return; } @@ -882,7 +882,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) le16_to_cpu(csa->channel)); il_chswitch_done(il, true); } else { - IL_ERR(il, "CSA notif (fail) : channel %d\n", + IL_ERR("CSA notif (fail) : channel %d\n", le16_to_cpu(csa->channel)); il_chswitch_done(il, false); } @@ -925,7 +925,7 @@ void il_irq_handle_error(struct il_priv *il) /* Cancel currently queued command. */ clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_ERR(il, "Loaded firmware version: %s\n", + IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); il->cfg->ops->lib->dump_nic_error_log(il); @@ -963,7 +963,7 @@ static int il_apm_stop_master(struct il_priv *il) ret = il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) - IL_WARN(il, "Master Disable Timed Out, 100 usec\n"); + IL_WARN("Master Disable Timed Out, 100 usec\n"); D_INFO("stop master\n"); @@ -1123,14 +1123,14 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IL_WARN(il, + IL_WARN( "Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } if (tx_power > il->tx_power_device_lmt) { - IL_WARN(il, + IL_WARN( "Requested user TXPOWER %d above upper limit %d.\n", tx_power, il->tx_power_device_lmt); return -EINVAL; @@ -1184,7 +1184,7 @@ void il_send_bt_config(struct il_priv *il) if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) - IL_ERR(il, "failed to send BT Coex Config\n"); + IL_ERR("failed to send BT Coex Config\n"); } EXPORT_SYMBOL(il_send_bt_config); @@ -1235,7 +1235,7 @@ void il_rx_reply_error(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_ERR(il, "Error Reply type 0x%08X cmd %s (0x%02X) " + IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", le32_to_cpu(pkt->u.err_resp.error_type), il_get_cmd_string(pkt->u.err_resp.cmd_id), @@ -1354,7 +1354,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mutex_lock(&il->mutex); if (!il_is_ready_rf(il)) { - IL_WARN(il, "Try to add interface when device not ready\n"); + IL_WARN("Try to add interface when device not ready\n"); err = -EINVAL; goto out; } @@ -1454,7 +1454,7 @@ int il_alloc_txq_mem(struct il_priv *il) il->cfg->base_params->num_of_queues, GFP_KERNEL); if (!il->txq) { - IL_ERR(il, "Not enough memory for txq\n"); + IL_ERR("Not enough memory for txq\n"); return -ENOMEM; } return 0; @@ -1743,7 +1743,7 @@ int il_force_reset(struct il_priv *il, bool external) return 0; } - IL_ERR(il, "On demand firmware reload\n"); + IL_ERR("On demand firmware reload\n"); /* Set the FW error flag -- cleared on il_down */ set_bit(STATUS_FW_ERROR, &il->status); @@ -1847,7 +1847,7 @@ static int il_check_stuck_queue(struct il_priv *il, int cnt) msecs_to_jiffies(il->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IL_ERR(il, "Queue %d stuck for %u ms.\n", + IL_ERR("Queue %d stuck for %u ms.\n", q->id, il->cfg->base_params->wd_timeout); ret = il_force_reset(il, false); return (ret == -EAGAIN) ? 0 : 1; @@ -2363,7 +2363,7 @@ static void il_beacon_update(struct ieee80211_hw *hw, lockdep_assert_held(&il->mutex); if (!il->beacon_ctx) { - IL_ERR(il, "update beacon but no beacon context!\n"); + IL_ERR("update beacon but no beacon context!\n"); dev_kfree_skb(skb); return; } @@ -2440,7 +2440,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * below/in post_associate will fail. */ if (il_scan_cancel_timeout(il, 100)) { - IL_WARN(il, + IL_WARN( "Aborted scan still in progress after 100ms\n"); D_MAC80211( "leaving - scan abort failed.\n"); @@ -2554,7 +2554,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, bss_conf->ibss_joined); if (ret) - IL_ERR(il, "failed to %s IBSS station %pM\n", + IL_ERR("failed to %s IBSS station %pM\n", bss_conf->ibss_joined ? "add" : "remove", bss_conf->bssid); } @@ -2599,7 +2599,7 @@ irqreturn_t il_isr(int irq, void *data) if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { /* Hardware disappeared. It might have already raised * an interrupt */ - IL_WARN(il, "HARDWARE GONE?? INTA == 0x%08x\n", inta); + IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); goto unplugged; } diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 2c5c42f..373188d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -32,10 +32,10 @@ struct il_priv; extern u32 il_debug_level; -#define IL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) -#define IL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) -#define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) -#define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) +#define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) +#define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) +#define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) +#define IL_CRIT(f, a...) dev_crit(&il->pci_dev->dev, f, ## a) #define il_print_hex_error(il, p, len) \ do { \ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index a811c17..45b71a8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -358,20 +358,20 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, buf_size = 4 * eeprom_len + 256; if (eeprom_len % 16) { - IL_ERR(il, "NVM size is not multiple of 16.\n"); + IL_ERR("NVM size is not multiple of 16.\n"); return -ENODATA; } ptr = il->eeprom; if (!ptr) { - IL_ERR(il, "Invalid EEPROM memory\n"); + IL_ERR("Invalid EEPROM memory\n"); return -ENOMEM; } /* 4 characters for byte 0xYY */ buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); @@ -407,7 +407,7 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -519,7 +519,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -640,7 +640,7 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, if (!il_is_any_associated(il)) il->disable_ht40 = ht40 ? true : false; else { - IL_ERR(il, "Sta associated with AP - " + IL_ERR("Sta associated with AP - " "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } @@ -689,12 +689,12 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, ssize_t ret; if (!il->txq) { - IL_ERR(il, "txq not ready\n"); + IL_ERR("txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate buffer\n"); + IL_ERR("Can not allocate buffer\n"); return -ENOMEM; } pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); @@ -787,7 +787,7 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, il->cfg->base_params->num_of_queues; if (!il->txq) { - IL_ERR(il, "txq not ready\n"); + IL_ERR("txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); @@ -884,7 +884,7 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, data = &il->sensitivity_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -965,7 +965,7 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, data = &il->chain_noise_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -1292,7 +1292,7 @@ int il_dbgfs_register(struct il_priv *il, const char *name) return 0; err: - IL_ERR(il, "Can't create the debugfs directory\n"); + IL_ERR("Can't create the debugfs directory\n"); il_dbgfs_unregister(il); return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 33fe598..5f0fd2a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -153,7 +153,7 @@ static int il_eeprom_verify_signature(struct il_priv *il) case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IL_ERR(il, "bad EEPROM signature," + IL_ERR("bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; @@ -206,7 +206,7 @@ int il_eeprom_init(struct il_priv *il) ret = il_eeprom_verify_signature(il); if (ret < 0) { - IL_ERR(il, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); + IL_ERR("EEPROM not found, EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; goto err; } @@ -214,7 +214,7 @@ int il_eeprom_init(struct il_priv *il) /* Make sure driver (instead of uCode) is allowed to read EEPROM */ ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); if (ret < 0) { - IL_ERR(il, "Failed to acquire EEPROM semaphore.\n"); + IL_ERR("Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; goto err; } @@ -231,7 +231,7 @@ int il_eeprom_init(struct il_priv *il) CSR_EEPROM_REG_READ_VALID_MSK, IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IL_ERR(il, "Time out reading EEPROM[%d]\n", + IL_ERR("Time out reading EEPROM[%d]\n", addr); goto done; } @@ -399,7 +399,7 @@ int il_init_channel_map(struct il_priv *il) il->channel_info = kzalloc(sizeof(struct il_channel_info) * il->channel_count, GFP_KERNEL); if (!il->channel_info) { - IL_ERR(il, "Could not allocate channel_info\n"); + IL_ERR("Could not allocate channel_info\n"); il->channel_count = 0; return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 61cf0d8..8f87bd8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -95,7 +95,7 @@ static void il_generic_cmd_callback(struct il_priv *il, struct il_rx_packet *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from %s (0x%08X)\n", + IL_ERR("Bad return from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } @@ -133,7 +133,7 @@ il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) ret = il_enqueue_hcmd(il, cmd); if (ret < 0) { - IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); return ret; } @@ -162,7 +162,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) cmd_idx = il_enqueue_hcmd(il, cmd); if (cmd_idx < 0) { ret = cmd_idx; - IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); goto out; } @@ -172,7 +172,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) HOST_COMPLETE_TIMEOUT); if (!ret) { if (test_bit(STATUS_HCMD_ACTIVE, &il->status)) { - IL_ERR(il, + IL_ERR( "Error sending %s: time out after %dms.\n", il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); @@ -187,19 +187,19 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) } if (test_bit(STATUS_RF_KILL_HW, &il->status)) { - IL_ERR(il, "Command %s aborted: RF KILL Switch\n", + IL_ERR("Command %s aborted: RF KILL Switch\n", il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } if (test_bit(STATUS_FW_ERROR, &il->status)) { - IL_ERR(il, "Command %s failed: FW Error\n", + IL_ERR("Command %s failed: FW Error\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IL_ERR(il, "Error: Response NULL in '%s'\n", + IL_ERR("Error: Response NULL in '%s'\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index d6aae8d..1afd5c0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -132,7 +132,7 @@ static inline int _il_grab_nic_access(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { val = _il_read32(il, CSR_GP_CNTRL); - IL_ERR(il, + IL_ERR( "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); _il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index b4d71cf..a283804 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -88,7 +88,7 @@ static inline u8 il_blink_compensation(struct il_priv *il, u8 time, u16 compensation) { if (!compensation) { - IL_ERR(il, "undefined blink compensation: " + IL_ERR("undefined blink compensation: " "use pre-defined blinking time\n"); return time; } diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 33aec39..6c6e5e7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -136,7 +136,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else - IL_ERR(il, "set power fail, ret = %d", ret); + IL_ERR("set power fail, ret = %d", ret); return ret; } diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index c534dce..3687104 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -341,7 +341,7 @@ static int il_scan_initiate(struct il_priv *il, cancel_delayed_work(&il->scan_check); if (!il_is_ready_rf(il)) { - IL_WARN(il, "Request scan called when driver not ready.\n"); + IL_WARN("Request scan called when driver not ready.\n"); return -EIO; } diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index a48af85..42033d2e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -41,7 +41,7 @@ static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) { if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) - IL_ERR(il, + IL_ERR( "ACTIVATE a non DRIVER active station id %u addr %pM\n", sta_id, il->stations[sta_id].sta.sta.addr); @@ -67,7 +67,7 @@ static int il_process_add_sta_resp(struct il_priv *il, int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_ADD_STA (0x%08X)\n", + IL_ERR("Bad return from REPLY_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } @@ -84,16 +84,16 @@ static int il_process_add_sta_resp(struct il_priv *il, ret = 0; break; case ADD_STA_NO_ROOM_IN_TABLE: - IL_ERR(il, "Adding station %d failed, no room in table.\n", + IL_ERR("Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IL_ERR(il, + IL_ERR( "Adding station %d failed, no block ack resource.\n", sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: - IL_ERR(il, "Attempting to modify non-existing station %d\n", + IL_ERR("Attempting to modify non-existing station %d\n", sta_id); break; default: @@ -206,7 +206,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, case WLAN_HT_CAP_SM_PS_DISABLED: break; default: - IL_WARN(il, "Invalid MIMO PS mode %d\n", mimo_ps_mode); + IL_WARN("Invalid MIMO PS mode %d\n", mimo_ps_mode); break; } @@ -343,7 +343,7 @@ il_add_station_common(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags_spin); sta_id = il_prep_station(il, ctx, addr, is_ap, sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Unable to prepare station %pM for addition\n", + IL_ERR("Unable to prepare station %pM for addition\n", addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; @@ -380,7 +380,7 @@ il_add_station_common(struct il_priv *il, ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); - IL_ERR(il, "Adding station %pM failed.\n", + IL_ERR("Adding station %pM failed.\n", il->stations[sta_id].sta.sta.addr); il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; @@ -402,7 +402,7 @@ static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) if ((il->stations[sta_id].used & (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != IL_STA_UCODE_ACTIVE) - IL_ERR(il, "removed non active STA %u\n", sta_id); + IL_ERR("removed non active STA %u\n", sta_id); il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; @@ -440,7 +440,7 @@ static int il_send_remove_station(struct il_priv *il, pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", + IL_ERR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -458,7 +458,7 @@ static int il_send_remove_station(struct il_priv *il, break; default: ret = -EIO; - IL_ERR(il, "REPLY_REMOVE_STA failed\n"); + IL_ERR("REPLY_REMOVE_STA failed\n"); break; } } @@ -618,7 +618,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); - IL_ERR(il, "Adding station %pM failed.\n", + IL_ERR("Adding station %pM failed.\n", il->stations[i].sta.sta.addr); il->stations[i].used &= ~IL_STA_DRIVER_ACTIVE; @@ -808,7 +808,7 @@ int il_mac_sta_remove(struct ieee80211_hw *hw, sta->addr); ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) - IL_ERR(il, "Error removing station %pM\n", + IL_ERR("Error removing station %pM\n", sta->addr); mutex_unlock(&il->mutex); return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 22617c4..cfc015a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -299,7 +299,7 @@ static int il_tx_queue_alloc(struct il_priv *il, txq->txb = kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, GFP_KERNEL); if (!txq->txb) { - IL_ERR(il, "kmalloc for auxiliary BD " + IL_ERR("kmalloc for auxiliary BD " "structures failed\n"); goto error; } @@ -312,7 +312,7 @@ static int il_tx_queue_alloc(struct il_priv *il, txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { - IL_ERR(il, "pci_alloc_consistent(%zd) failed\n", tfd_sz); + IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; } txq->q.id = id; @@ -461,7 +461,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) BUG_ON(fix_size > IL_MAX_CMD_SIZE); if (il_is_rfkill(il) || il_is_ctkill(il)) { - IL_WARN(il, "Not sending command - %s KILL\n", + IL_WARN("Not sending command - %s KILL\n", il_is_rfkill(il) ? "RF" : "CT"); return -EIO; } @@ -471,7 +471,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { spin_unlock_irqrestore(&il->hcmd_lock, flags); - IL_ERR(il, "Restarting adapter due to command queue full\n"); + IL_ERR("Restarting adapter due to command queue full\n"); queue_work(il->workqueue, &il->restart); return -ENOSPC; } @@ -566,7 +566,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int nfreed = 0; if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { - IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; @@ -576,7 +576,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IL_ERR(il, "HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR("HCMD skipped: index (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); queue_work(il->workqueue, &il->restart); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 8aa22a0..8a6b193 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -127,7 +127,7 @@ __le32 il3945_get_antenna_flags(const struct il_priv *il) } /* bad antenna selector value */ - IL_ERR(il, "Bad antenna selector value (0x%x)\n", + IL_ERR("Bad antenna selector value (0x%x)\n", il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ @@ -236,7 +236,7 @@ static int il3945_set_dynamic_key(struct il_priv *il, ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); break; default: - IL_ERR(il, "Unknown alg: %s alg=%x\n", __func__, + IL_ERR("Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } @@ -262,7 +262,7 @@ static int il3945_set_static_key(struct il_priv *il, key->cipher == WLAN_CIPHER_SUITE_WEP104) return -EOPNOTSUPP; - IL_ERR(il, "Static key invalid: cipher %x\n", key->cipher); + IL_ERR("Static key invalid: cipher %x\n", key->cipher); return -EINVAL; } @@ -281,7 +281,7 @@ static void il3945_clear_free_frames(struct il_priv *il) } if (il->frames_count) { - IL_WARN(il, "%d frames still in use. Did we lose one?\n", + IL_WARN("%d frames still in use. Did we lose one?\n", il->frames_count); il->frames_count = 0; } @@ -294,7 +294,7 @@ static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(il, "Could not allocate frame!\n"); + IL_ERR("Could not allocate frame!\n"); return NULL; } @@ -339,7 +339,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il) frame = il3945_get_free_frame(il); if (!frame) { - IL_ERR(il, "Could not obtain free frame buffer for beacon " + IL_ERR("Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } @@ -401,7 +401,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, break; default: - IL_ERR(il, "Unknown encode cipher %x\n", keyinfo->cipher); + IL_ERR("Unknown encode cipher %x\n", keyinfo->cipher); break; } } @@ -491,7 +491,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) } if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { - IL_ERR(il, "ERROR: No TX rate available.\n"); + IL_ERR("ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -718,7 +718,7 @@ static int il3945_get_measurement(struct il_priv *il, pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_RX_ON_ASSOC command\n"); + IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -777,7 +777,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(il, "uCode did not respond OK.\n"); + IL_WARN("uCode did not respond OK.\n"); } static void il3945_rx_reply_add_sta(struct il_priv *il, @@ -820,7 +820,7 @@ static void il3945_rx_card_state_notif(struct il_priv *il, u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; - IL_WARN(il, "Card state received: HW:%s SW:%s\n", + IL_WARN("Card state received: HW:%s SW:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); @@ -1043,7 +1043,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(il, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_CRIT("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will @@ -1287,7 +1287,7 @@ static void il3945_rx_handle(struct il_priv *il) if (rxb->page) il_tx_cmd_complete(il, rxb); else - IL_WARN(il, "Claim null rxb?\n"); + IL_WARN("Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -1366,7 +1366,7 @@ void il3945_dump_nic_error_log(struct il_priv *il) base = le32_to_cpu(il->card_alive.error_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(il, "Not valid error log pointer 0x%08X\n", base); + IL_ERR("Not valid error log pointer 0x%08X\n", base); return; } @@ -1374,12 +1374,12 @@ void il3945_dump_nic_error_log(struct il_priv *il) count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(il, "Start IWL Error Log Dump:\n"); - IL_ERR(il, "Status: 0x%08lX, count: %d\n", + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } - IL_ERR(il, "Desc Time asrtPC blink2 " + IL_ERR("Desc Time asrtPC blink2 " "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; @@ -1398,7 +1398,7 @@ void il3945_dump_nic_error_log(struct il_priv *il) data1 = il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - IL_ERR(il, + IL_ERR( "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", il3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); @@ -1450,7 +1450,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(il, "Hardware error detected. Restarting.\n"); + IL_ERR("Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ il_disable_interrupts(il); @@ -1484,7 +1484,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(il, "Microcode SW error detected. " + IL_ERR("Microcode SW error detected. " "Restarting 0x%X.\n", inta); il->isr_stats.sw++; il_irq_handle_error(il); @@ -1526,14 +1526,14 @@ static void il3945_irq_tasklet(struct il_priv *il) } if (inta & ~handled) { - IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); il->isr_stats.unhandled++; } if (inta & ~il->inta_mask) { - IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ @@ -1708,7 +1708,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) * if IL_DL_IO is set */ val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "uCode INST section is invalid at " + IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); rc = -EIO; @@ -1750,7 +1750,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ - IL_ERR(il, "uCode INST section is invalid at " + IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, *image); #endif @@ -1802,7 +1802,7 @@ static int il3945_verify_ucode(struct il_priv *il) return 0; } - IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. @@ -1867,7 +1867,7 @@ static int il3945_read_ucode(struct il_priv *il) sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { - IL_ERR(il, "%s firmware file req failed: %d\n", + IL_ERR("%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; @@ -1875,7 +1875,7 @@ static int il3945_read_ucode(struct il_priv *il) goto error; } else { if (index < api_max) - IL_ERR(il, "Loaded firmware %s, " + IL_ERR("Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); @@ -1891,7 +1891,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Make sure that we got at least our header! */ if (ucode_raw->size < il3945_ucode_get_header_size(1)) { - IL_ERR(il, "File size way too small!\n"); + IL_ERR("File size way too small!\n"); ret = -EINVAL; goto err_release; } @@ -1913,7 +1913,7 @@ static int il3945_read_ucode(struct il_priv *il) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(il, "Driver unable to support your firmware API. " + IL_ERR("Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); il->ucode_ver = 0; @@ -1921,12 +1921,12 @@ static int il3945_read_ucode(struct il_priv *il) goto err_release; } if (api_ver != api_max) - IL_ERR(il, "Firmware has old API version. Expected %u, " + IL_ERR("Firmware has old API version. Expected %u, " "got %u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_INFO("loaded firmware version %u.%u.%u.%u\n", IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), @@ -2091,7 +2091,7 @@ static int il3945_read_ucode(struct il_priv *il) return 0; err_pci_alloc: - IL_ERR(il, "failed to allocate pci memory\n"); + IL_ERR("failed to allocate pci memory\n"); ret = -ENOMEM; il3945_dealloc_ucode_pci(il); @@ -2380,7 +2380,7 @@ static int il3945_alloc_bcast_station(struct il_priv *il) sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Unable to prepare broadcast station\n"); + IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; @@ -2402,12 +2402,12 @@ static int __il3945_up(struct il_priv *il) return rc; if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN(il, "Exit pending; will not bring the NIC up\n"); + IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR(il, "ucode not available for device bring up\n"); + IL_ERR("ucode not available for device bring up\n"); return -EIO; } @@ -2417,7 +2417,7 @@ static int __il3945_up(struct il_priv *il) clear_bit(STATUS_RF_KILL_HW, &il->status); else { set_bit(STATUS_RF_KILL_HW, &il->status); - IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); + IL_WARN("Radio disabled by HW RF Kill switch\n"); return -ENODEV; } @@ -2425,7 +2425,7 @@ static int __il3945_up(struct il_priv *il) rc = il3945_hw_nic_init(il); if (rc) { - IL_ERR(il, "Unable to int nic\n"); + IL_ERR("Unable to int nic\n"); return rc; } @@ -2460,7 +2460,7 @@ static int __il3945_up(struct il_priv *il) rc = il->cfg->ops->lib->load_ucode(il); if (rc) { - IL_ERR(il, + IL_ERR( "Unable to set up bootstrap uCode: %d\n", rc); continue; } @@ -2479,7 +2479,7 @@ static int __il3945_up(struct il_priv *il) /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); + IL_ERR("Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2650,7 +2650,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) band = IEEE80211_BAND_5GHZ; break; default: - IL_WARN(il, "Invalid scan band\n"); + IL_WARN("Invalid scan band\n"); return -EIO; } @@ -2770,7 +2770,7 @@ void il3945_post_associate(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(il, "REPLY_RXON_TIMING failed - " + IL_WARN("REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2802,7 +2802,7 @@ void il3945_post_associate(struct il_priv *il) il3945_send_beacon_cmd(il); break; default: - IL_ERR(il, "%s Should not be called in %d mode\n", + IL_ERR("%s Should not be called in %d mode\n", __func__, ctx->vif->type); break; } @@ -2832,7 +2832,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) if (!il->ucode_code.len) { ret = il3945_read_ucode(il); if (ret) { - IL_ERR(il, "Could not read microcode: %d\n", ret); + IL_ERR("Could not read microcode: %d\n", ret); mutex_unlock(&il->mutex); goto out_release_irq; } @@ -2854,7 +2854,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR(il, + IL_ERR( "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; @@ -2934,7 +2934,7 @@ void il3945_config_ap(struct il_priv *il) /* RXON Timing */ rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(il, "REPLY_RXON_TIMING failed - " + IL_WARN("REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -3045,7 +3045,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, &il->contexts[IL_RXON_CTX_BSS], sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM (%d)\n", + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); @@ -3147,11 +3147,11 @@ static ssize_t il3945_store_debug_level(struct device *d, ret = strict_strtoul(buf, 0, &val); if (ret) - IL_INFO(il, "%s is not in hex or decimal form.\n", buf); + IL_INFO("%s is not in hex or decimal form.\n", buf); else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR(il, + IL_ERR( "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -3192,7 +3192,7 @@ static ssize_t il3945_store_tx_power(struct device *d, val = simple_strtoul(p, &p, 10); if (p == buf) - IL_INFO(il, ": %s is not in decimal form.\n", buf); + IL_INFO(": %s is not in decimal form.\n", buf); else il3945_hw_reg_set_txpower(il, val); @@ -3222,7 +3222,7 @@ static ssize_t il3945_store_flags(struct device *d, if (le32_to_cpu(ctx->staging.flags) != flags) { /* Cancel any currently running scans... */ if (il_scan_cancel_timeout(il, 100)) - IL_WARN(il, "Could not cancel scan.\n"); + IL_WARN("Could not cancel scan.\n"); else { D_INFO("Committing rxon.flags = 0x%04X\n", flags); @@ -3259,7 +3259,7 @@ static ssize_t il3945_store_filter_flags(struct device *d, if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { /* Cancel any currently running scans... */ if (il_scan_cancel_timeout(il, 100)) - IL_WARN(il, "Could not cancel scan.\n"); + IL_WARN("Could not cancel scan.\n"); else { D_INFO("Committing rxon.filter_flags = " "0x%04X\n", filter_flags); @@ -3551,14 +3551,14 @@ static int il3945_init_drv(struct il_priv *il) il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IL_WARN(il, "Unsupported EEPROM version: 0x%04X\n", + IL_WARN("Unsupported EEPROM version: 0x%04X\n", eeprom->version); ret = -EINVAL; goto err; } ret = il_init_channel_map(il); if (ret) { - IL_ERR(il, "initializing regulatory failed: %d\n", ret); + IL_ERR("initializing regulatory failed: %d\n", ret); goto err; } @@ -3570,7 +3570,7 @@ static int il3945_init_drv(struct il_priv *il) ret = il_init_geos(il); if (ret) { - IL_ERR(il, "initializing geos failed: %d\n", ret); + IL_ERR("initializing geos failed: %d\n", ret); goto err_free_channel_map; } il3945_init_hw_rates(il, il->ieee_rates); @@ -3624,7 +3624,7 @@ static int il3945_setup_mac(struct il_priv *il) ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(il, "Failed to register hw (error %d)\n", ret); + IL_ERR("Failed to register hw (error %d)\n", ret); return ret; } il->mac80211_registered = 1; @@ -3692,7 +3692,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->inta_mask = CSR_INI_SET_MASK; if (il_alloc_traffic_mem(il)) - IL_ERR(il, "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); /*************************** * 2. Initializing PCI bus @@ -3711,7 +3711,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en if (!err) err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); if (err) { - IL_WARN(il, "No suitable DMA available.\n"); + IL_WARN("No suitable DMA available.\n"); goto out_pci_disable_device; } @@ -3757,7 +3757,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /* Read the EEPROM */ err = il_eeprom_init(il); if (err) { - IL_ERR(il, "Unable to init EEPROM\n"); + IL_ERR("Unable to init EEPROM\n"); goto out_iounmap; } /* MAC Address location in EEPROM same for 3945/4965 */ @@ -3770,7 +3770,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * ********************/ /* Device-specific setup */ if (il3945_hw_set_hw_params(il)) { - IL_ERR(il, "failed to set hw settings\n"); + IL_ERR("failed to set hw settings\n"); goto out_eeprom_free; } @@ -3780,11 +3780,11 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = il3945_init_drv(il); if (err) { - IL_ERR(il, "initializing driver failed\n"); + IL_ERR("initializing driver failed\n"); goto out_unset_hw_params; } - IL_INFO(il, "Detected Intel Wireless WiFi Link %s\n", + IL_INFO("Detected Intel Wireless WiFi Link %s\n", il->cfg->name); /*********************** @@ -3800,13 +3800,13 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); if (err) { - IL_ERR(il, "failed to create sysfs device attributes\n"); + IL_ERR("failed to create sysfs device attributes\n"); goto out_release_irq; } @@ -3829,7 +3829,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(il, "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); /* Start monitoring the killswitch */ queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 88dc8db..df7e0a4 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -115,7 +115,7 @@ static void il4965_clear_free_frames(struct il_priv *il) } if (il->frames_count) { - IL_WARN(il, "%d frames still in use. Did we lose one?\n", + IL_WARN("%d frames still in use. Did we lose one?\n", il->frames_count); il->frames_count = 0; } @@ -128,7 +128,7 @@ static struct il_frame *il4965_get_free_frame(struct il_priv *il) if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(il, "Could not allocate frame!\n"); + IL_ERR("Could not allocate frame!\n"); return NULL; } @@ -188,7 +188,7 @@ static void il4965_set_beacon_tim(struct il_priv *il, tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); tx_beacon_cmd->tim_size = beacon[tim_idx+1]; } else - IL_WARN(il, "Unable to find TIM Element in beacon\n"); + IL_WARN("Unable to find TIM Element in beacon\n"); } static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, @@ -206,7 +206,7 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, lockdep_assert_held(&il->mutex); if (!il->beacon_ctx) { - IL_ERR(il, "trying to build beacon w/o beacon context!\n"); + IL_ERR("trying to build beacon w/o beacon context!\n"); return 0; } @@ -254,14 +254,14 @@ int il4965_send_beacon_cmd(struct il_priv *il) frame = il4965_get_free_frame(il); if (!frame) { - IL_ERR(il, "Could not obtain free frame buffer for beacon " + IL_ERR("Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } frame_size = il4965_hw_get_beacon_cmd(il, frame); if (!frame_size) { - IL_ERR(il, "Error configuring the beacon command\n"); + IL_ERR("Error configuring the beacon command\n"); il4965_free_frame(il, frame); return -EINVAL; } @@ -336,7 +336,7 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) num_tbs = il4965_tfd_get_num_tbs(tfd); if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(il, "Too many chunks: %i\n", num_tbs); + IL_ERR("Too many chunks: %i\n", num_tbs); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -388,14 +388,14 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, /* Each TFD can point to a maximum 20 Tx buffers */ if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(il, "Error can not send more than %d chunks\n", + IL_ERR("Error can not send more than %d chunks\n", IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR(il, "Unaligned address = %llx\n", + IL_ERR("Unaligned address = %llx\n", (unsigned long long)addr); il4965_tfd_set_tb(tfd, num_tbs, addr, len); @@ -460,7 +460,7 @@ static void il4965_rx_reply_alive(struct il_priv *il, queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(il, "uCode did not respond OK.\n"); + IL_WARN("uCode did not respond OK.\n"); } /** @@ -725,7 +725,7 @@ void il4965_rx_handle(struct il_priv *il) if (rxb->page) il_tx_cmd_complete(il, rxb); else - IL_WARN(il, "Claim null rxb?\n"); + IL_WARN("Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -818,7 +818,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(il, "Hardware error detected. Restarting.\n"); + IL_ERR("Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ il_disable_interrupts(il); @@ -857,7 +857,7 @@ static void il4965_irq_tasklet(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; - IL_WARN(il, "RF_KILL bit toggled to %s.\n", + IL_WARN("RF_KILL bit toggled to %s.\n", hw_rf_kill ? "disable radio" : "enable radio"); il->isr_stats.rfkill++; @@ -880,14 +880,14 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Chip got too hot and stopped itself */ if (inta & CSR_INT_BIT_CT_KILL) { - IL_ERR(il, "Microcode CT kill error detected.\n"); + IL_ERR("Microcode CT kill error detected.\n"); il->isr_stats.ctkill++; handled |= CSR_INT_BIT_CT_KILL; } /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(il, "Microcode SW error detected. " + IL_ERR("Microcode SW error detected. " " Restarting 0x%X.\n", inta); il->isr_stats.sw++; il_irq_handle_error(il); @@ -928,14 +928,14 @@ static void il4965_irq_tasklet(struct il_priv *il) } if (inta & ~handled) { - IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); il->isr_stats.unhandled++; } if (inta & ~(il->inta_mask)) { - IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ @@ -993,11 +993,11 @@ static ssize_t il4965_store_debug_level(struct device *d, ret = strict_strtoul(buf, 0, &val); if (ret) - IL_ERR(il, "%s is not in hex or decimal form.\n", buf); + IL_ERR("%s is not in hex or decimal form.\n", buf); else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR(il, + IL_ERR( "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -1044,11 +1044,11 @@ static ssize_t il4965_store_tx_power(struct device *d, ret = strict_strtoul(buf, 10, &val); if (ret) - IL_INFO(il, "%s is not in decimal form.\n", buf); + IL_INFO("%s is not in decimal form.\n", buf); else { ret = il_set_tx_power(il, val, false); if (ret) - IL_ERR(il, "failed setting tx power (0x%d).\n", + IL_ERR("failed setting tx power (0x%d).\n", ret); else ret = count; @@ -1114,7 +1114,7 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) } if (il->fw_index < il->cfg->ucode_api_min) { - IL_ERR(il, "no suitable firmware found!\n"); + IL_ERR("no suitable firmware found!\n"); return -ENOENT; } @@ -1151,7 +1151,7 @@ static int il4965_load_firmware(struct il_priv *il, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IL_ERR(il, "File size too small!\n"); + IL_ERR("File size too small!\n"); return -EINVAL; } pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); @@ -1169,7 +1169,7 @@ static int il4965_load_firmware(struct il_priv *il, pieces->data_size + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IL_ERR(il, + IL_ERR( "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -1214,7 +1214,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) if (!ucode_raw) { if (il->fw_index <= il->cfg->ucode_api_max) - IL_ERR(il, + IL_ERR( "request for firmware file '%s' failed.\n", il->firmware_name); goto try_again; @@ -1225,7 +1225,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { - IL_ERR(il, "File size way too small!\n"); + IL_ERR("File size way too small!\n"); goto try_again; } @@ -1245,7 +1245,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(il, + IL_ERR( "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -1253,13 +1253,13 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) } if (api_ver != api_max) - IL_ERR(il, + IL_ERR( "Firmware has old API version. Expected v%u, " "got v%u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_INFO("loaded firmware version %u.%u.%u.%u\n", IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), @@ -1294,31 +1294,31 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Verify that uCode images will fit in card's SRAM */ if (pieces.inst_size > il->hw_params.max_inst_size) { - IL_ERR(il, "uCode instr len %Zd too large to fit in\n", + IL_ERR("uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } if (pieces.data_size > il->hw_params.max_data_size) { - IL_ERR(il, "uCode data len %Zd too large to fit in\n", + IL_ERR("uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } if (pieces.init_size > il->hw_params.max_inst_size) { - IL_ERR(il, "uCode init instr len %Zd too large to fit in\n", + IL_ERR("uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } if (pieces.init_data_size > il->hw_params.max_data_size) { - IL_ERR(il, "uCode init data len %Zd too large to fit in\n", + IL_ERR("uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } if (pieces.boot_size > il->hw_params.max_bsm_size) { - IL_ERR(il, "uCode boot instr len %Zd too large to fit in\n", + IL_ERR("uCode boot instr len %Zd too large to fit in\n", pieces.boot_size); goto try_again; } @@ -1427,13 +1427,13 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(il, + IL_ERR( "failed to create debugfs files. Ignoring error: %d\n", err); err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); if (err) { - IL_ERR(il, "failed to create sysfs device attributes\n"); + IL_ERR("failed to create sysfs device attributes\n"); goto out_unbind; } @@ -1450,7 +1450,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) return; err_pci_alloc: - IL_ERR(il, "failed to allocate pci memory\n"); + IL_ERR("failed to allocate pci memory\n"); il4965_dealloc_ucode_pci(il); out_unbind: complete(&il->_4965.firmware_loading_complete); @@ -1541,7 +1541,7 @@ void il4965_dump_nic_error_log(struct il_priv *il) } if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR(il, + IL_ERR( "Not valid error log pointer 0x%08X for %s uCode\n", base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; @@ -1550,8 +1550,8 @@ void il4965_dump_nic_error_log(struct il_priv *il) count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(il, "Start IWL Error Log Dump:\n"); - IL_ERR(il, "Status: 0x%08lX, count: %d\n", + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } @@ -1568,12 +1568,12 @@ void il4965_dump_nic_error_log(struct il_priv *il) time = il_read_targ_mem(il, base + 11 * sizeof(u32)); hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); - IL_ERR(il, "Desc Time " + IL_ERR("Desc Time " "data1 data2 line\n"); - IL_ERR(il, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", il4965_desc_lookup(desc), desc, time, data1, data2, line); - IL_ERR(il, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR(il, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, blink2, ilink1, ilink2, hcmd); } @@ -1594,7 +1594,7 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, sizeof(cmd), &cmd); if (ret) - IL_ERR(il, "REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); else D_INFO("REPLY_CT_KILL_CONFIG_CMD " "succeeded, " @@ -1740,7 +1740,7 @@ static void il4965_alive_start(struct il_priv *il) ret = il4965_alive_notify(il); if (ret) { - IL_WARN(il, + IL_WARN( "Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } @@ -1955,12 +1955,12 @@ static int __il4965_up(struct il_priv *il) int ret; if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN(il, "Exit pending; will not bring the NIC up\n"); + IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR(il, "ucode not available for device bringup\n"); + IL_ERR("ucode not available for device bringup\n"); return -EIO; } @@ -1975,7 +1975,7 @@ static int __il4965_up(struct il_priv *il) il4965_prepare_card_hw(il); if (!il->hw_ready) { - IL_WARN(il, "Exit HW not ready\n"); + IL_WARN("Exit HW not ready\n"); return -EIO; } @@ -1990,7 +1990,7 @@ static int __il4965_up(struct il_priv *il) wiphy_rfkill_set_hw_state(il->hw->wiphy, true); il_enable_interrupts(il); - IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); + IL_WARN("Radio disabled by HW RF Kill switch\n"); return 0; } @@ -2001,7 +2001,7 @@ static int __il4965_up(struct il_priv *il) ret = il4965_hw_nic_init(il); if (ret) { - IL_ERR(il, "Unable to init nic\n"); + IL_ERR("Unable to init nic\n"); return ret; } @@ -2032,7 +2032,7 @@ static int __il4965_up(struct il_priv *il) ret = il->cfg->ops->lib->load_ucode(il); if (ret) { - IL_ERR(il, "Unable to set up bootstrap uCode: %d\n", + IL_ERR("Unable to set up bootstrap uCode: %d\n", ret); continue; } @@ -2051,7 +2051,7 @@ static int __il4965_up(struct il_priv *il) /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); + IL_ERR("Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2229,7 +2229,7 @@ static int il4965_mac_setup_register(struct il_priv *il, ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(il, "Failed to register hw (error %d)\n", ret); + IL_ERR("Failed to register hw (error %d)\n", ret); return ret; } il->mac80211_registered = 1; @@ -2265,7 +2265,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR(il, "START_ALIVE timeout after %dms.\n", + IL_ERR("START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; } @@ -2475,7 +2475,7 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, ret = il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM (%d)\n", + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); @@ -2792,13 +2792,13 @@ static int il4965_init_drv(struct il_priv *il) ret = il_init_channel_map(il); if (ret) { - IL_ERR(il, "initializing regulatory failed: %d\n", ret); + IL_ERR("initializing regulatory failed: %d\n", ret); goto err; } ret = il_init_geos(il); if (ret) { - IL_ERR(il, "initializing geos failed: %d\n", ret); + IL_ERR("initializing geos failed: %d\n", ret); goto err_free_channel_map; } il4965_init_hw_rates(il, il->ieee_rates); @@ -2917,7 +2917,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->inta_mask = CSR_INI_SET_MASK; if (il_alloc_traffic_mem(il)) - IL_ERR(il, "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); /************************** * 2. Initializing PCI bus @@ -2942,7 +2942,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { - IL_WARN(il, "No suitable DMA available.\n"); + IL_WARN("No suitable DMA available.\n"); goto out_pci_disable_device; } } @@ -2981,7 +2981,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); il4965_hw_detect(il); - IL_INFO(il, "Detected %s, REV=0x%X\n", + IL_INFO("Detected %s, REV=0x%X\n", il->cfg->name, il->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep @@ -2990,7 +2990,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il4965_prepare_card_hw(il); if (!il->hw_ready) { - IL_WARN(il, "Failed, HW not ready\n"); + IL_WARN("Failed, HW not ready\n"); goto out_iounmap; } @@ -3000,7 +3000,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Read the EEPROM */ err = il_eeprom_init(il); if (err) { - IL_ERR(il, "Unable to init EEPROM\n"); + IL_ERR("Unable to init EEPROM\n"); goto out_iounmap; } err = il4965_eeprom_check_version(il); @@ -3020,7 +3020,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 5. Setup HW constants ************************/ if (il4965_set_hw_params(il)) { - IL_ERR(il, "failed to set hw parameters\n"); + IL_ERR("failed to set hw parameters\n"); goto out_free_eeprom; } @@ -3045,7 +3045,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } -- cgit v0.10.2 From b6297cd2aa4ec318b3634e6c1ca4cf063a0042c9 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Thu, 18 Aug 2011 22:27:04 +0200 Subject: iwlegacy: remove IL_CRIT Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index f4df28d..6503b8f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -309,7 +309,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT( + IL_ERR( "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 373188d..77467de 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -35,7 +35,6 @@ extern u32 il_debug_level; #define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) #define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) #define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) -#define IL_CRIT(f, a...) dev_crit(&il->pci_dev->dev, f, ## a) #define il_print_hex_error(il, p, len) \ do { \ diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 8a6b193..66aa850 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1043,7 +1043,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will -- cgit v0.10.2 From 841b2ccac3251fdbf7a0bc26724874cdc35df96c Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:14:03 +0200 Subject: iwlegacy: rename il_{read,write}32 to _il_{rd,wr} Introduce rule that underscore at the beginning mean unlocked I/O method. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index cf47fdb..6e2e71a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -1058,7 +1058,7 @@ static inline int il3945_hw_reg_temp_out_of_range(int temperature) int il3945_hw_get_temperature(struct il_priv *il) { - return il_read32(il, CSR_UCODE_DRV_GP2); + return _il_rd(il, CSR_UCODE_DRV_GP2); } /** @@ -2211,7 +2211,7 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ - il_read32(il, FH39_TSSR_CBB_BASE); + _il_rd(il, FH39_TSSR_CBB_BASE); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c index 1436a1b..4854157 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.c @@ -55,9 +55,9 @@ il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) }; u32 reg; - reg = il_read32(il, CSR_LED_REG); + reg = _il_rd(il, CSR_LED_REG); if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - il_write32(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + _il_wr(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); return il_send_cmd(il, &cmd); } @@ -65,7 +65,7 @@ il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) /* Set led register off */ void il4965_led_enable(struct il_priv *il) { - il_write32(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); + _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } const struct il_led_ops il4965_led_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 42be833..c5ffd91 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -2001,7 +2001,7 @@ int il_pci_resume(struct device *device) il_enable_interrupts(il); - if (!(il_read32(il, CSR_GP_CNTRL) & + if (!(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; @@ -2580,12 +2580,12 @@ irqreturn_t il_isr(int irq, void *data) * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = il_read32(il, CSR_INT_MASK); /* just for debug */ - il_write32(il, CSR_INT_MASK, 0x00000000); + inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ + _il_wr(il, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ - inta = il_read32(il, CSR_INT); - inta_fh = il_read32(il, CSR_FH_INT_STATUS); + inta = _il_rd(il, CSR_INT); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); /* Ignore interrupt if there's nothing in NIC to service. * This may be due to IRQ shared with another device, diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index 24b71ae..faffb8e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -70,7 +70,7 @@ * low power states due to driver-invoked device resets * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. * - * Use il_write32() and il_read32() family to access these registers; + * Use _il_wr() and _il_rd() family to access these registers; * these provide simple PCI bus access, without waking up the MAC. * Do not use il_write_direct32() family for these registers; * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. @@ -91,7 +91,7 @@ #define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ #define CSR_GP_CNTRL (CSR_BASE+0x024) -/* 2nd byte of CSR_INT_COALESCING, not accessible via il_write32()! */ +/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ #define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) /* @@ -374,7 +374,7 @@ * to make sure the MAC (uCode processor, etc.) is powered up for accessing * internal resources. * - * Do not use il_write32()/il_read32() family to access these registers; + * Do not use _il_wr()/_il_rd() family to access these registers; * these provide only simple PCI bus access, without waking up the MAC. */ #define HBUS_BASE (0x400) diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 45b71a8..cd15e67 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -1018,7 +1018,7 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = il_read32(il, CSR_GP_CNTRL) & + pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5f0fd2a..26cf506 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -144,7 +144,7 @@ static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ static int il_eeprom_verify_signature(struct il_priv *il) { - u32 gp = il_read32(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; D_EEPROM("EEPROM signature=0x%08x\n", gp); @@ -187,7 +187,7 @@ EXPORT_SYMBOL(il_eeprom_query16); int il_eeprom_init(struct il_priv *il) { __le16 *e; - u32 gp = il_read32(il, CSR_EEPROM_GP); + u32 gp = _il_rd(il, CSR_EEPROM_GP); int sz; int ret; u16 addr; @@ -223,7 +223,7 @@ int il_eeprom_init(struct il_priv *il) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - _il_write32(il, CSR_EEPROM_REG, + _il_wr(il, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); ret = il_poll_bit(il, CSR_EEPROM_REG, diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index a0a84b2..a9d8702 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -149,26 +149,26 @@ static inline void il_disable_interrupts(struct il_priv *il) clear_bit(STATUS_INT_ENABLED, &il->status); /* disable interrupts from uCode/NIC to host */ - il_write32(il, CSR_INT_MASK, 0x00000000); + _il_wr(il, CSR_INT_MASK, 0x00000000); /* acknowledge/clear/reset any interrupts still pending * from uCode or flow handler (Rx/Tx DMA) */ - il_write32(il, CSR_INT, 0xffffffff); - il_write32(il, CSR_FH_INT_STATUS, 0xffffffff); + _il_wr(il, CSR_INT, 0xffffffff); + _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); D_ISR("Disabled interrupts\n"); } static inline void il_enable_rfkill_int(struct il_priv *il) { D_ISR("Enabling rfkill interrupt\n"); - il_write32(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } static inline void il_enable_interrupts(struct il_priv *il) { D_ISR("Enabling interrupts\n"); set_bit(STATUS_INT_ENABLED, &il->status); - il_write32(il, CSR_INT_MASK, il->inta_mask); + _il_wr(il, CSR_INT_MASK, il->inta_mask); } /** diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 1afd5c0..cdbcfde 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -40,18 +40,15 @@ static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) } #define il_write8(il, ofs, val) _il_write8(il, ofs, val) -static inline void _il_write32(struct il_priv *il, u32 ofs, u32 val) +static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) { iowrite32(val, il->hw_base + ofs); } -#define il_write32(il, ofs, val) _il_write32(il, ofs, val) -static inline u32 _il_read32(struct il_priv *il, u32 ofs) +static inline u32 _il_rd(struct il_priv *il, u32 ofs) { - u32 val = ioread32(il->hw_base + ofs); - return val; + return ioread32(il->hw_base + ofs); } -#define il_read32(p, o) _il_read32(p, o) #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int @@ -61,7 +58,7 @@ _il_poll_bit(struct il_priv *il, u32 addr, int t = 0; do { - if ((_il_read32(il, addr) & mask) == (bits & mask)) + if ((_il_rd(il, addr) & mask) == (bits & mask)) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -73,7 +70,7 @@ _il_poll_bit(struct il_priv *il, u32 addr, static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(il, reg, _il_read32(il, reg) | mask); + _il_wr(il, reg, _il_rd(il, reg) | mask); } static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) @@ -88,7 +85,7 @@ static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) static inline void _il_clear_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(il, reg, _il_read32(il, reg) & ~mask); + _il_wr(il, reg, _il_rd(il, reg) & ~mask); } static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) @@ -131,10 +128,10 @@ static inline int _il_grab_nic_access(struct il_priv *il) (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { - val = _il_read32(il, CSR_GP_CNTRL); + val = _il_rd(il, CSR_GP_CNTRL); IL_ERR( "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_write32(il, CSR_RESET, + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } @@ -152,7 +149,7 @@ static inline void _il_release_nic_access(struct il_priv *il) static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { - return _il_read32(il, reg); + return _il_rd(il, reg); } static inline u32 il_read_direct32(struct il_priv *il, u32 reg) @@ -172,7 +169,7 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) static inline void _il_write_direct32(struct il_priv *il, u32 reg, u32 value) { - _il_write32(il, reg, value); + _il_wr(il, reg, value); } static inline void il_write_direct32(struct il_priv *il, u32 reg, u32 value) diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 183acdc..e481ca8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -138,7 +138,7 @@ il_rx_queue_update_write_ptr(struct il_priv *il, /* If power-saving is in use, make sure device is awake */ if (test_bit(STATUS_POWER_PMI, &il->status)) { - reg = il_read32(il, CSR_UCODE_DRV_GP1); + reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { D_INFO( diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index cfc015a..6b5e652 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -55,7 +55,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ - reg = il_read32(il, CSR_UCODE_DRV_GP1); + reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { D_INFO( @@ -75,7 +75,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - il_write32(il, HBUS_TARG_WRPTR, + _il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 66aa850..def3140 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -824,7 +824,7 @@ static void il3945_rx_card_state_notif(struct il_priv *il, (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - il_write32(il, CSR_UCODE_DRV_GP1_SET, + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) @@ -1419,19 +1419,19 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(il, CSR_INT); - il_write32(il, CSR_INT, inta); + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(il, CSR_FH_INT_STATUS); - il_write32(il, CSR_FH_INT_STATUS, inta_fh); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(il, CSR_INT_MASK); + inta_mask = _il_rd(il, CSR_INT_MASK); D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } @@ -1519,7 +1519,7 @@ static void il3945_irq_tasklet(struct il_priv *il) D_ISR("Tx interrupt\n"); il->isr_stats.tx++; - il_write32(il, CSR_FH_INT_STATUS, (1 << 6)); + _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); il_write_direct32(il, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; @@ -1543,9 +1543,9 @@ static void il3945_irq_tasklet(struct il_priv *il) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = il_read32(il, CSR_INT); - inta_mask = il_read32(il, CSR_INT_MASK); - inta_fh = il_read32(il, CSR_FH_INT_STATUS); + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -1817,7 +1817,7 @@ static int il3945_verify_ucode(struct il_priv *il) static void il3945_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(il, CSR_RESET, 0); + _il_wr(il, CSR_RESET, 0); } #define IWL3945_UCODE_GET(item) \ @@ -2304,7 +2304,7 @@ static void __il3945_down(struct il_priv *il) clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&il->lock, flags); @@ -2412,7 +2412,7 @@ static int __il3945_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(il, CSR_GP_CNTRL) & + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &il->status); else { @@ -2421,7 +2421,7 @@ static int __il3945_up(struct il_priv *il) return -ENODEV; } - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); rc = il3945_hw_nic_init(il); if (rc) { @@ -2430,17 +2430,17 @@ static int __il3945_up(struct il_priv *il) } /* make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2529,7 +2529,7 @@ static void il3945_rfkill_poll(struct work_struct *data) struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); - bool new_rfkill = !(il_read32(il, CSR_GP_CNTRL) + bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { @@ -3748,7 +3748,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /*********************** * 4. Read EEPROM diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index df7e0a4..a774373 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -517,9 +517,9 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) if (il->mac80211_registered) ieee80211_stop_queues(il->hw); - il_write32(il, CSR_UCODE_DRV_GP1_SET, + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - il_read32(il, CSR_UCODE_DRV_GP1); + _il_rd(il, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&il->reg_lock, flags); if (!il_grab_nic_access(il)) @@ -545,14 +545,14 @@ static void il4965_rx_card_state_notif(struct il_priv *il, if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { - il_write32(il, CSR_UCODE_DRV_GP1_SET, + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); @@ -787,19 +787,19 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(il, CSR_INT); - il_write32(il, CSR_INT, inta); + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(il, CSR_FH_INT_STATUS); - il_write32(il, CSR_FH_INT_STATUS, inta_fh); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(il, CSR_INT_MASK); + inta_mask = _il_rd(il, CSR_INT_MASK); D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } @@ -853,7 +853,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(il_read32(il, CSR_GP_CNTRL) & + if (!(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; @@ -948,9 +948,9 @@ static void il4965_irq_tasklet(struct il_priv *il) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = il_read32(il, CSR_INT); - inta_mask = il_read32(il, CSR_INT_MASK); - inta_fh = il_read32(il, CSR_FH_INT_STATUS); + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); D_ISR( "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); @@ -1092,7 +1092,7 @@ static void il4965_dealloc_ucode_pci(struct il_priv *il) static void il4965_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(il, CSR_RESET, 0); + _il_wr(il, CSR_RESET, 0); } static void il4965_ucode_callback(const struct firmware *ucode_raw, @@ -1584,7 +1584,7 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) int ret = 0; spin_lock_irqsave(&il->lock, flags); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); spin_unlock_irqrestore(&il->lock, flags); @@ -1830,7 +1830,7 @@ static void __il4965_down(struct il_priv *il) clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&il->lock, flags); @@ -1980,7 +1980,7 @@ static int __il4965_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(il, + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &il->status); else @@ -1994,7 +1994,7 @@ static int __il4965_up(struct il_priv *il) return 0; } - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); /* must be initialised before il_hw_nic_init */ il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; @@ -2006,17 +2006,17 @@ static int __il4965_up(struct il_priv *il) } /* make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2296,7 +2296,7 @@ void il4965_mac_stop(struct ieee80211_hw *hw) /* User space software may expect getting rfkill changes * even if interface is down */ - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); il_enable_rfkill_int(il); D_MAC80211("leave\n"); @@ -2821,8 +2821,8 @@ static void il4965_uninit_drv(struct il_priv *il) static void il4965_hw_detect(struct il_priv *il) { - il->hw_rev = _il_read32(il, CSR_HW_REV); - il->hw_wa_rev = _il_read32(il, CSR_HW_REV_WA_REG); + il->hw_rev = _il_rd(il, CSR_HW_REV); + il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); il->rev_id = il->pci_dev->revision; D_INFO("HW Revision ID = 0x%X\n", il->rev_id); } @@ -2978,7 +2978,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); il4965_hw_detect(il); IL_INFO("Detected %s, REV=0x%X\n", @@ -3066,7 +3066,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il_enable_rfkill_int(il); /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(il, CSR_GP_CNTRL) & + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &il->status); else -- cgit v0.10.2 From 142b343f6eb4898289c402afb6237def8e252a3e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:22:57 +0200 Subject: iwlegacy: mark poll bit as unlocked function We do not take reg_lock during poll bit, so mark it such using underscore. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 6e2e71a..8c3ae39 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -757,7 +757,7 @@ static void il3945_set_pwr_vmain(struct il_priv *il) APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(il, CSR_GPIO_IN, + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VAUX_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); } @@ -767,7 +767,7 @@ static void il3945_set_pwr_vmain(struct il_priv *il) APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index 016472d..a519257 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -98,7 +98,7 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index c5ffd91..d2534fb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -960,7 +960,7 @@ static int il_apm_stop_master(struct il_priv *il) /* stop device's busmaster DMA activity */ il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) IL_WARN("Master Disable Timed Out, 100 usec\n"); @@ -1072,7 +1072,7 @@ int il_apm_init(struct il_priv *il) * device-internal resources is supported, e.g. il_write_prph() * and accesses to uCode SRAM. */ - ret = il_poll_bit(il, CSR_GP_CNTRL, + ret = _il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 26cf506..ba2be7b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -226,7 +226,7 @@ int il_eeprom_init(struct il_priv *il) _il_wr(il, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = il_poll_bit(il, CSR_EEPROM_REG, + ret = _il_poll_bit(il, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IL_EEPROM_ACCESS_TIMEOUT); diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index cdbcfde..7ad262e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -66,7 +66,6 @@ _il_poll_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -#define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index a774373..f3ec8bb 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1907,7 +1907,7 @@ static int il4965_set_hw_ready(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); @@ -1935,7 +1935,7 @@ static int il4965_prepare_card_hw(struct il_priv *il) il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); -- cgit v0.10.2 From 138822698fc16bd4c5b509da28a9b08faac4367b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:39:23 +0200 Subject: iwlegacy: mark il_{grab,release}_nic_access as unlocked Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 7ad262e..c2e32ed 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -137,14 +137,12 @@ static inline int _il_grab_nic_access(struct il_priv *il) return 0; } -#define il_grab_nic_access(il) _il_grab_nic_access(il) static inline void _il_release_nic_access(struct il_priv *il) { _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -#define il_release_nic_access(il) _il_release_nic_access(il) static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { @@ -157,9 +155,9 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); value = _il_read_direct32(il, reg); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; @@ -176,9 +174,9 @@ il_write_direct32(struct il_priv *il, u32 reg, u32 value) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_direct32(il, reg, value); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -222,9 +220,9 @@ static inline u32 il_read_prph(struct il_priv *il, u32 reg) u32 val; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); val = _il_read_prph(il, reg); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return val; } @@ -244,9 +242,9 @@ il_write_prph(struct il_priv *il, u32 addr, u32 val) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_prph(il, addr, val); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -260,9 +258,9 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); _il_set_bits_prph(il, reg, mask); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -276,9 +274,9 @@ static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); _il_set_bits_mask_prph(il, reg, bits, mask); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -289,10 +287,10 @@ static inline void il_clear_bits_prph(struct il_priv u32 val; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); val = _il_read_prph(il, reg); _il_write_prph(il, reg, (val & ~mask)); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -302,13 +300,13 @@ static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) u32 value; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); _il_write_direct32(il, HBUS_TARG_MEM_RADDR, addr); rmb(); value = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } @@ -319,11 +317,11 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); _il_write_direct32(il, HBUS_TARG_MEM_WDAT, val); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -335,14 +333,14 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) _il_write_direct32(il, HBUS_TARG_MEM_WDAT, *values); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index f3ec8bb..f4eb037 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -522,8 +522,8 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) _il_rd(il, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&il->reg_lock, flags); - if (!il_grab_nic_access(il)) - il_release_nic_access(il); + if (!_il_grab_nic_access(il)) + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, flags); } -- cgit v0.10.2 From 1c8cae575b14ffad6af9c80927a08aa783f0ed78 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:46:03 +0200 Subject: iwlegacy: remove _il_{read,write}_direct32 Use _il_{rd,wr} instead of another name of these operations. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 3fa939e..4f0e6fe 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -63,7 +63,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) * if IL_DL_IO is set */ il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; errcnt++; @@ -97,7 +97,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index ba2be7b..5786abd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -235,7 +235,7 @@ int il_eeprom_init(struct il_priv *il) addr); goto done; } - r = _il_read_direct32(il, CSR_EEPROM_REG); + r = _il_rd(il, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index c2e32ed..ecf799d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -144,11 +144,6 @@ static inline void _il_release_nic_access(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) -{ - return _il_rd(il, reg); -} - static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; @@ -156,18 +151,13 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - value = _il_read_direct32(il, reg); + value = _il_rd(il, reg); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } -static inline void _il_write_direct32(struct il_priv *il, - u32 reg, u32 value) -{ - _il_wr(il, reg, value); -} static inline void il_write_direct32(struct il_priv *il, u32 reg, u32 value) { @@ -175,7 +165,7 @@ il_write_direct32(struct il_priv *il, u32 reg, u32 value) spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_direct32(il, reg, value); + _il_wr(il, reg, value); _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); @@ -210,9 +200,9 @@ static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { - _il_write_direct32(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); - return _il_read_direct32(il, HBUS_TARG_PRPH_RDAT); + return _il_rd(il, HBUS_TARG_PRPH_RDAT); } static inline u32 il_read_prph(struct il_priv *il, u32 reg) { @@ -230,10 +220,10 @@ static inline u32 il_read_prph(struct il_priv *il, u32 reg) static inline void _il_write_prph(struct il_priv *il, u32 addr, u32 val) { - _il_write_direct32(il, HBUS_TARG_PRPH_WADDR, + _il_wr(il, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); - _il_write_direct32(il, HBUS_TARG_PRPH_WDAT, val); + _il_wr(il, HBUS_TARG_PRPH_WDAT, val); } static inline void @@ -302,9 +292,9 @@ static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - _il_write_direct32(il, HBUS_TARG_MEM_RADDR, addr); + _il_wr(il, HBUS_TARG_MEM_RADDR, addr); rmb(); - value = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + value = _il_rd(il, HBUS_TARG_MEM_RDAT); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); @@ -318,9 +308,9 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); wmb(); - _il_write_direct32(il, HBUS_TARG_MEM_WDAT, val); + _il_wr(il, HBUS_TARG_MEM_WDAT, val); _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); @@ -334,10 +324,10 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _il_write_direct32(il, + _il_wr(il, HBUS_TARG_MEM_WDAT, *values); _il_release_nic_access(il); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index def3140..d45e9f5 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1706,7 +1706,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", @@ -1747,7 +1747,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) * if IL_DL_IO is set */ il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ IL_ERR("uCode INST section is invalid at " -- cgit v0.10.2 From 0c1a94e299eed7ea11ebc407d1e08a26c594abe5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 17:37:16 +0200 Subject: iwlegacy: rename i/o direct methods Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 8c3ae39..fc8ddb6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -773,11 +773,11 @@ static void il3945_set_pwr_vmain(struct il_priv *il) static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { - il_write_direct32(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_write_direct32(il, FH39_RCSR_RPTR_ADDR(0), + il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_wr(il, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); - il_write_direct32(il, FH39_RCSR_WPTR(0), 0); - il_write_direct32(il, FH39_RCSR_CONFIG(0), + il_wr(il, FH39_RCSR_WPTR(0), 0); + il_wr(il, FH39_RCSR_CONFIG(0), FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | @@ -788,7 +788,7 @@ static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ - il_read_direct32(il, FH39_RSSR_CTRL); + il_rd(il, FH39_RSSR_CTRL); return 0; } @@ -810,10 +810,10 @@ static int il3945_tx_reset(struct il_priv *il) il_write_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); il_write_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - il_write_direct32(il, FH39_TSSR_CBB_BASE, + il_wr(il, FH39_TSSR_CBB_BASE, il->_3945.shared_phys); - il_write_direct32(il, FH39_TSSR_MSG_CONFIG, + il_wr(il, FH39_TSSR_MSG_CONFIG, FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | @@ -987,7 +987,7 @@ int il3945_hw_nic_init(struct il_priv *il) il_rx_queue_update_write_ptr(il, rxq); */ - il_write_direct32(il, FH39_RCSR_WPTR(0), rxq->write & ~7); + il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); rc = il3945_txq_ctx_reset(il); if (rc) @@ -1030,8 +1030,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) /* reset TFD queues */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), 0x0); - il_poll_direct_bit(il, FH39_TSSR_TX_STATUS, + il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_bit(il, FH39_TSSR_TX_STATUS, FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), 1000); } @@ -2183,8 +2183,8 @@ int il3945_hw_rxq_stop(struct il_priv *il) { int rc; - il_write_direct32(il, FH39_RCSR_CONFIG(0), 0); - rc = il_poll_direct_bit(il, FH39_RSSR_STATUS, + il_wr(il, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_bit(il, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) IL_ERR("Can't stop Rx DMA.\n"); @@ -2200,10 +2200,10 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - il_write_direct32(il, FH39_CBCC_CTRL(txq_id), 0); - il_write_direct32(il, FH39_CBCC_BASE(txq_id), 0); + il_wr(il, FH39_CBCC_CTRL(txq_id), 0); + il_wr(il, FH39_CBCC_BASE(txq_id), 0); - il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), + il_wr(il, FH39_TCSR_CONFIG(txq_id), FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 6503b8f..8fafd20 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -103,17 +103,17 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write index */ - il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_write_direct32(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -122,7 +122,7 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | @@ -403,8 +403,8 @@ int il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ - il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_direct_bit(il, FH_MEM_RSSR_RX_STATUS_REG, + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; @@ -1179,7 +1179,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(il, fh_tbl[i])); + il_rd(il, fh_tbl[i])); } return pos; } @@ -1188,7 +1188,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { IL_ERR(" %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(il, fh_tbl[i])); + il_rd(il, fh_tbl[i])); } return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 66dd172..25c9b71 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -640,7 +640,7 @@ int il4965_txq_ctx_alloc(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -679,7 +679,7 @@ void il4965_txq_ctx_reset(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -707,14 +707,14 @@ void il4965_txq_ctx_stop(struct il_priv *il) /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { - il_write_direct32(il, + il_wr(il, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_direct_bit(il, FH_TSSR_TX_STATUS_REG, + if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, - il_read_direct32(il, + il_rd(il, FH_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 4f0e6fe..bb0b7f5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -61,7 +61,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { @@ -89,7 +89,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, D_INFO("ucode inst image size is %u\n", len); - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); errcnt = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index faffb8e..c00ec35 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -72,7 +72,7 @@ * * Use _il_wr() and _il_rd() family to access these registers; * these provide simple PCI bus access, without waking up the MAC. - * Do not use il_write_direct32() family for these registers; + * Do not use il_wr() family for these registers; * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. * The MAC (uCode processor, etc.) does not need to be powered up for accessing * the CSR registers. @@ -368,7 +368,7 @@ * to indirectly access device's internal memory or registers that * may be powered-down. * - * Use il_write_direct32()/il_read_direct32() family + * Use il_wr()/il_rd() family * for these registers; * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ * to make sure the MAC (uCode processor, etc.) is powered up for accessing diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index ecf799d..f435942 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -144,7 +144,7 @@ static inline void _il_release_nic_access(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -static inline u32 il_read_direct32(struct il_priv *il, u32 reg) +static inline u32 il_rd(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; @@ -159,7 +159,7 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) } static inline void -il_write_direct32(struct il_priv *il, u32 reg, u32 value) +il_wr(struct il_priv *il, u32 reg, u32 value) { unsigned long reg_flags; @@ -178,17 +178,17 @@ static inline void il_write_reg_buf(struct il_priv *il, if ((il != NULL) && (values != NULL)) { for (; 0 < len; len -= count, reg += count, values++) - il_write_direct32(il, reg, *values); + il_wr(il, reg, *values); } } -static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, +static inline int il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) { int t = 0; do { - if ((il_read_direct32(il, addr) & mask) == mask) + if ((il_rd(il, addr) & mask) == mask) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -196,7 +196,6 @@ static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -#define il_poll_direct_bit _il_poll_direct_bit static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index e481ca8..b2ec2a2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -150,14 +150,14 @@ il_rx_queue_update_write_ptr(struct il_priv *il, } q->write_actual = (q->write & ~0x7); - il_write_direct32(il, rx_wrt_ptr_reg, + il_wr(il, rx_wrt_ptr_reg, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - il_write_direct32(il, rx_wrt_ptr_reg, + il_wr(il, rx_wrt_ptr_reg, q->write_actual); } diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 6b5e652..fa23c98 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -66,7 +66,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) return; } - il_write_direct32(il, HBUS_TARG_WRPTR, + il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index d45e9f5..a0b5a74 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1520,7 +1520,7 @@ static void il3945_irq_tasklet(struct il_priv *il) il->isr_stats.tx++; _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); - il_write_direct32(il, FH39_TCSR_CREDIT + il_wr(il, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } @@ -1698,7 +1698,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); errcnt = 0; @@ -1745,7 +1745,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index f4eb037..b0668ea 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -416,7 +416,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_write_direct32(il, FH_MEM_CBBC_QUEUE(txq_id), + il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -548,13 +548,13 @@ static void il4965_rx_card_state_notif(struct il_priv *il, _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(il, HBUS_TARG_MBX_C, + il_wr(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(il, HBUS_TARG_MBX_C, + il_wr(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } @@ -1639,14 +1639,14 @@ static int il4965_alive_notify(struct il_priv *il) /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_write_direct32(il, + il_wr(il, FH_TCSR_CHNL_TX_CONFIG_REG(chan), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = il_read_direct32(il, FH_TX_CHICKEN_BITS_REG); - il_write_direct32(il, FH_TX_CHICKEN_BITS_REG, + reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); + il_wr(il, FH_TX_CHICKEN_BITS_REG, reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ @@ -1657,7 +1657,7 @@ static int il4965_alive_notify(struct il_priv *il) /* TFD circular buffer read/write indexes */ il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); - il_write_direct32(il, HBUS_TARG_WRPTR, 0 | (i << 8)); + il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ il_write_targ_mem(il, il->scd_base_addr + @@ -2731,7 +2731,7 @@ static void il4965_init_hw_rates(struct il_priv *il, */ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { - il_write_direct32(il, HBUS_TARG_WRPTR, + il_wr(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } -- cgit v0.10.2 From db54eb57ce5edeebd621b12e23f3e1cdea7fe3ee Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 21:06:33 +0200 Subject: iwlegacy: rename il_{read,write}_prph Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index fc8ddb6..cdea5b0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -797,18 +797,18 @@ static int il3945_tx_reset(struct il_priv *il) { /* bypass mode */ - il_write_prph(il, ALM_SCD_MODE_REG, 0x2); + il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); /* RA 0 is active */ - il_write_prph(il, ALM_SCD_ARASTAT_REG, 0x01); + il_wr_prph(il, ALM_SCD_ARASTAT_REG, 0x01); /* all 6 fifo are active */ - il_write_prph(il, ALM_SCD_TXFACT_REG, 0x3f); + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0x3f); - il_write_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - il_write_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - il_write_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); - il_write_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); + il_wr_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_wr_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); + il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); il_wr(il, FH39_TSSR_CBB_BASE, il->_3945.shared_phys); @@ -878,8 +878,8 @@ static int il3945_apm_init(struct il_priv *il) int ret = il_apm_init(il); /* Clear APMG (NIC's internal power management) interrupts */ - il_write_prph(il, APMG_RTC_INT_MSK_REG, 0x0); - il_write_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + il_wr_prph(il, APMG_RTC_INT_MSK_REG, 0x0); + il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ il_set_bits_prph(il, APMG_PS_CTRL_REG, @@ -1025,8 +1025,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) int txq_id; /* stop SCD */ - il_write_prph(il, ALM_SCD_MODE_REG, 0); - il_write_prph(il, ALM_SCD_TXFACT_REG, 0); + il_wr_prph(il, ALM_SCD_MODE_REG, 0); + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0); /* reset TFD queues */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { @@ -2475,11 +2475,11 @@ static int il3945_verify_bsm(struct il_priv *il) D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(il, BSM_WR_DWCOUNT_REG); + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(il, reg); + val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", @@ -2583,16 +2583,16 @@ static int il3945_load_bsm(struct il_priv *il) inst_len = il->ucode_init.len; data_len = il->ucode_init_data.len; - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(il, reg_offset, + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); rc = il3945_verify_bsm(il); @@ -2600,19 +2600,19 @@ static int il3945_load_bsm(struct il_priv *il) return rc; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(il, BSM_WR_MEM_DST_REG, + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IWL39_RTC_INST_LOWER_BOUND); - il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(il, BSM_WR_CTRL_REG, + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(il, BSM_WR_CTRL_REG); + done = il_rd_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); @@ -2626,7 +2626,7 @@ static int il3945_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(il, BSM_WR_CTRL_REG, + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 25c9b71..f86a3b9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -754,7 +754,7 @@ static void il4965_tx_queue_stop_scheduler(struct il_priv *il, { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_write_prph(il, + il_wr_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 7b422f2..a745032 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -72,11 +72,11 @@ static int il4965_verify_bsm(struct il_priv *il) D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(il, BSM_WR_DWCOUNT_REG); + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(il, reg); + val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", @@ -156,34 +156,34 @@ static int il4965_load_bsm(struct il_priv *il) inst_len = il->ucode_init.len; data_len = il->ucode_init_data.len; - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(il, reg_offset, le32_to_cpu(*image)); + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); ret = il4965_verify_bsm(il); if (ret) return ret; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(il, + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); - il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(il, BSM_WR_CTRL_REG); + done = il_rd_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); @@ -197,7 +197,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(il, + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); @@ -224,14 +224,14 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) pdata = il->ucode_data_backup.p_addr >> 4; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index d2534fb..ed44159 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1069,7 +1069,7 @@ int il_apm_init(struct il_priv *il) /* * Wait for clock stabilization; once stabilized, access to - * device-internal resources is supported, e.g. il_write_prph() + * device-internal resources is supported, e.g. il_wr_prph() * and accesses to uCode SRAM. */ ret = _il_poll_bit(il, CSR_GP_CNTRL, @@ -1089,10 +1089,10 @@ int il_apm_init(struct il_priv *il) * set by default in "CLK_CTRL_REG" after reset. */ if (il->cfg->base_params->use_bsm) - il_write_prph(il, APMG_CLK_EN_REG, + il_wr_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - il_write_prph(il, APMG_CLK_EN_REG, + il_wr_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index f435942..8cb924d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -197,26 +197,27 @@ static inline int il_poll_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -static inline u32 _il_read_prph(struct il_priv *il, u32 reg) +static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) { _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); return _il_rd(il, HBUS_TARG_PRPH_RDAT); } -static inline u32 il_read_prph(struct il_priv *il, u32 reg) + +static inline u32 il_rd_prph(struct il_priv *il, u32 reg) { unsigned long reg_flags; u32 val; spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - val = _il_read_prph(il, reg); + val = _il_rd_prph(il, reg); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return val; } -static inline void _il_write_prph(struct il_priv *il, +static inline void _il_wr_prph(struct il_priv *il, u32 addr, u32 val) { _il_wr(il, HBUS_TARG_PRPH_WADDR, @@ -226,20 +227,20 @@ static inline void _il_write_prph(struct il_priv *il, } static inline void -il_write_prph(struct il_priv *il, u32 addr, u32 val) +il_wr_prph(struct il_priv *il, u32 addr, u32 val) { unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_prph(il, addr, val); + _il_wr_prph(il, addr, val); _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } #define _il_set_bits_prph(il, reg, mask) \ -_il_write_prph(il, reg, (_il_read_prph(il, reg) | mask)) +_il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)) static inline void il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) @@ -254,8 +255,8 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) } #define _il_set_bits_mask_prph(il, reg, bits, mask) \ -_il_write_prph(il, reg, \ - ((_il_read_prph(il, reg) & mask) | bits)) +_il_wr_prph(il, reg, \ + ((_il_rd_prph(il, reg) & mask) | bits)) static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask) @@ -277,8 +278,8 @@ static inline void il_clear_bits_prph(struct il_priv spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - val = _il_read_prph(il, reg); - _il_write_prph(il, reg, (val & ~mask)); + val = _il_rd_prph(il, reg); + _il_wr_prph(il, reg, (val & ~mask)); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index a0b5a74..5037216 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -2122,14 +2122,14 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) pdata = il->ucode_data_backup.p_addr; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); @@ -2210,7 +2210,7 @@ static void il3945_alive_start(struct il_priv *il) goto restart; } - rfkill = il_read_prph(il, APMG_RFKILL_REG); + rfkill = il_rd_prph(il, APMG_RFKILL_REG); D_INFO("RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { @@ -2342,7 +2342,7 @@ static void __il3945_down(struct il_priv *il) il3945_hw_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Stop the device, and put it in low power state */ diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index b0668ea..0f7d44c 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1622,7 +1622,7 @@ static int il4965_alive_notify(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - il->scd_base_addr = il_read_prph(il, + il->scd_base_addr = il_rd_prph(il, IWL49_SCD_SRAM_BASE_ADDR); a = il->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; for (; a < il->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) @@ -1634,7 +1634,7 @@ static int il4965_alive_notify(struct il_priv *il) il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_write_prph(il, IWL49_SCD_DRAM_BASE_ADDR, + il_wr_prph(il, IWL49_SCD_DRAM_BASE_ADDR, il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ @@ -1650,13 +1650,13 @@ static int il4965_alive_notify(struct il_priv *il) reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - il_write_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_wr_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < il->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ @@ -1675,7 +1675,7 @@ static int il4965_alive_notify(struct il_priv *il) IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - il_write_prph(il, IWL49_SCD_INTERRUPT_MASK, + il_wr_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ @@ -1868,7 +1868,7 @@ static void __il4965_down(struct il_priv *il) il4965_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Make sure (redundant) we've released our request to stay awake */ @@ -2733,7 +2733,7 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { il_wr(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } void il4965_tx_queue_set_status(struct il_priv *il, @@ -2746,7 +2746,7 @@ void il4965_tx_queue_set_status(struct il_priv *il, int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - il_write_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), + il_wr_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | @@ -3195,7 +3195,7 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) */ void il4965_txq_set_sched(struct il_priv *il, u32 mask) { - il_write_prph(il, IWL49_SCD_TXFACT, mask); + il_wr_prph(il, IWL49_SCD_TXFACT, mask); } /***************************************************************************** -- cgit v0.10.2 From 232913b51e6f6e7105184b23a436dfc6b942491b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 10:45:16 +0200 Subject: iwlegacy: remove not needed parentheses Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index ad05093..67650ff 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -264,8 +264,8 @@ struct il3945_eeprom { static inline int il3945_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL39_RTC_DATA_LOWER_BOUND) && - (addr < IWL39_RTC_DATA_UPPER_BOUND); + return (addr >= IWL39_RTC_DATA_LOWER_BOUND && + addr < IWL39_RTC_DATA_UPPER_BOUND); } /* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index d05da7a..afa6be8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -104,7 +104,7 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) u32 table_size = 0; struct il3945_tpt_entry *tpt_table = NULL; - if ((rssi < IL_MIN_RSSI_VAL) || (rssi > IL_MAX_RSSI_VAL)) + if (rssi < IL_MIN_RSSI_VAL || rssi > IL_MAX_RSSI_VAL) rssi = IL_MIN_RSSI_VAL; switch (band) { @@ -123,7 +123,7 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) break; } - while ((index < table_size) && (rssi < tpt_table[index].min_rssi)) + while (index < table_size && rssi < tpt_table[index].min_rssi) index++; index = min(index, (table_size - 1)); @@ -315,8 +315,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) + if (fail_count >= IL_RATE_MIN_FAILURE_TH || + window->success_counter >= IL_RATE_MIN_SUCCESS_TH) window->average_tpt = ((window->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else @@ -461,7 +461,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * retries = IL_RATE_RETRY_TH; first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { + if (first_index < 0 || first_index >= IL_RATE_COUNT_3945) { D_RATE("leave: Rate out of bounds: %d\n", first_index); return; } @@ -663,9 +663,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* get user max rate if set */ max_rate_idx = txrc->max_rate_idx; - if ((sband->band == IEEE80211_BAND_5GHZ) && (max_rate_idx != -1)) + if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) max_rate_idx += IL_FIRST_OFDM_RATE; - if ((max_rate_idx < 0) || (max_rate_idx >= IL_RATE_COUNT)) + if (max_rate_idx < 0 || max_rate_idx >= IL_RATE_COUNT) max_rate_idx = -1; index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1); @@ -686,7 +686,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } /* force user max rate if set by user */ - if ((max_rate_idx != -1) && (max_rate_idx < index)) { + if (max_rate_idx != -1 && max_rate_idx < index) { if (rate_mask & (1 << max_rate_idx)) index = max_rate_idx; } @@ -695,8 +695,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, fail_count = window->counter - window->success_counter; - if (((fail_count < IL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { + if (fail_count < IL_RATE_MIN_FAILURE_TH && + window->success_counter < IL_RATE_MIN_SUCCESS_TH) { spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " @@ -721,7 +721,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ - if ((max_rate_idx != -1) && (max_rate_idx < high)) + if (max_rate_idx != -1 && max_rate_idx < high) high = IL_RATE_INVALID; /* Collect Measured throughputs of adjacent rates */ @@ -736,13 +736,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { + if (window->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ - } else if ((low_tpt == IL_INVALID_VALUE) && - (high_tpt == IL_INVALID_VALUE)) { + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; @@ -752,9 +752,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Both adjacent throughputs are measured, but neither one has * better throughput; we're using the best rate, don't change * it! */ - } else if ((low_tpt != IL_INVALID_VALUE) && - (high_tpt != IL_INVALID_VALUE) && - (low_tpt < current_tpt) && (high_tpt < current_tpt)) { + } else if (low_tpt != IL_INVALID_VALUE && + high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) { D_RATE("No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", @@ -790,9 +790,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IL_RATE_INVALID) && - ((window->success_ratio > IL_RATE_HIGH_TH) || - (current_tpt > (100 * rs_sta->expected_tpt[low])))) + if (scale_action == -1 && low != IL_RATE_INVALID && + (window->success_ratio > IL_RATE_HIGH_TH || + current_tpt > 100 * rs_sta->expected_tpt[low])) scale_action = 0; switch (scale_action) { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index cdea5b0..fb69b74 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -173,7 +173,7 @@ void il3945_disable_events(struct il_priv *il) disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); - if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { + if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { D_INFO("Disabling selected uCode log events at 0x%x\n", disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) @@ -293,9 +293,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, il->cfg->ops->lib->txq_free_tfd(il, txq); } - if (il_queue_space(q) > q->low_mark && (txq_id >= 0) && - (txq_id != IWL39_CMD_QUEUE_NUM) && - il->mac80211_registered) + if (il_queue_space(q) > q->low_mark && txq_id >= 0 && + txq_id != IWL39_CMD_QUEUE_NUM && il->mac80211_registered) il_wake_queue(il, txq); } @@ -316,7 +315,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, int rate_idx; int fail; - if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, @@ -544,8 +543,8 @@ static void il3945_rx_reply_rx(struct il_priv *il, return; } - if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) - || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { + if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || + !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -599,7 +598,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); - if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { + if (count >= NUM_TFD_CHUNKS || count < 0) { IL_ERR("Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; @@ -1053,7 +1052,7 @@ static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) */ static inline int il3945_hw_reg_temp_out_of_range(int temperature) { - return ((temperature < -260) || (temperature > 25)) ? 1 : 0; + return (temperature < -260 || temperature > 25) ? 1 : 0; } int il3945_hw_get_temperature(struct il_priv *il) @@ -1666,10 +1665,10 @@ static int il3945_send_rxon_assoc(struct il_priv *il, const struct il_rxon_cmd *rxon1 = &ctx->staging; const struct il_rxon_cmd *rxon2 = &ctx->active; - if ((rxon1->flags == rxon2->flags) && - (rxon1->filter_flags == rxon2->filter_flags) && - (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && - (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 7f85834..c055a15 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -198,8 +198,8 @@ static int il4965_sens_energy_cck(struct il_priv *il, data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ - if ((false_alarms > max_false_alarms) && - (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { + if (false_alarms > max_false_alarms && + data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { D_CALIB("norm FA %u > max FA %u\n", false_alarms, max_false_alarms); D_CALIB("... reducing sensitivity\n"); @@ -230,9 +230,9 @@ static int il4965_sens_energy_cck(struct il_priv *il, * from a previous beacon with too many, or healthy # FAs * OR 2) We've seen a lot of beacons (100) with too few * false alarms */ - if ((data->nrg_prev_state != IL_FA_TOO_MANY) && - ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || - (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { + if (data->nrg_prev_state != IL_FA_TOO_MANY && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { D_CALIB("... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ @@ -289,9 +289,9 @@ static int il4965_sens_energy_cck(struct il_priv *il, val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; data->auto_corr_cck_mrc = min((u32)ranges->auto_corr_max_cck_mrc, val); - } else if ((false_alarms < min_false_alarms) && - ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || - (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { + } else if (false_alarms < min_false_alarms && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { /* Decrease auto_corr values to increase sensitivity */ val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; @@ -747,9 +747,8 @@ static void il4965_gain_computation(struct il_priv *il, for (i = default_chain; i < NUM_RX_CHAINS; i++) { s32 delta_g = 0; - if (!(data->disconn_array[i]) && - (data->delta_gain_code[i] == - CHAIN_NOISE_DELTA_GAIN_INIT_VAL)) { + if (!data->disconn_array[i] && + data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { delta_g = average_noise[i] - min_average_noise; data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); data->delta_gain_code[i] = @@ -860,7 +859,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* Make sure we accumulate data for just the associated channel * (even if scanning). */ - if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { + if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { D_CALIB("Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); spin_unlock_irqrestore(&il->lock, flags); @@ -920,8 +919,8 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) il->cfg->base_params->chain_noise_num_beacons; for (i = 0; i < NUM_RX_CHAINS; i++) { - if (!(data->disconn_array[i]) && - (average_noise[i] <= min_average_noise)) { + if (!data->disconn_array[i] && + average_noise[i] <= min_average_noise) { /* This means that chain i is active and has * lower noise values so far: */ min_average_noise = average_noise[i]; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index b6b7fe2..b21c004 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -102,8 +102,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL49_RTC_DATA_LOWER_BOUND) && - (addr < IWL49_RTC_DATA_UPPER_BOUND); + return (addr >= IWL49_RTC_DATA_LOWER_BOUND && + addr < IWL49_RTC_DATA_UPPER_BOUND); } /********************* START TEMPERATURE *************************************/ @@ -147,8 +147,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) #define IL_TX_POWER_TEMPERATURE_MAX (410) #define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ - (((t) < IL_TX_POWER_TEMPERATURE_MIN) || \ - ((t) > IL_TX_POWER_TEMPERATURE_MAX)) + ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ + (t) > IL_TX_POWER_TEMPERATURE_MAX) /********************* END TEMPERATURE ***************************************/ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 8fafd20..8bb2b62 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -234,7 +234,7 @@ void il4965_rx_queue_restock(struct il_priv *il) unsigned long flags; spin_lock_irqsave(&rxq->lock, flags); - while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { /* The overwritten rxb must be a used one */ rxb = rxq->queue[rxq->write]; BUG_ON(rxb && rxb->page); @@ -307,7 +307,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) "order: %d\n", il->hw_params.rx_page_order); - if ((rxq->free_count <= RX_LOW_WATERMARK) && + if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) IL_ERR( "Failed to alloc_pages with %s. " @@ -1106,7 +1106,7 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) ctx->staging.rx_chain = cpu_to_le16(rx_chain); - if (!is_single && (active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE) && is_cam) + if (!is_single && active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE && is_cam) ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 93bb31d..c2f4230 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -127,7 +127,7 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) /* skip 9M not supported in ht*/ if (idx >= IL_RATE_9M_INDEX) idx += 1; - if ((idx >= IL_FIRST_OFDM_RATE) && (idx <= IL_LAST_OFDM_RATE)) + if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; /* legacy rate format, search for match in table */ @@ -251,8 +251,7 @@ il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) /* The oldest age we want to keep */ u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; - while (tl->queue_count && - (tl->time_stamp < oldest_time)) { + while (tl->queue_count && tl->time_stamp < oldest_time) { tl->total -= tl->packet_count[tl->head]; tl->packet_count[tl->head] = 0; tl->time_stamp += TID_QUEUE_CELL_SPACING; @@ -477,8 +476,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) + if (fail_count >= IL_RATE_MIN_FAILURE_TH || + window->success_counter >= IL_RATE_MIN_SUCCESS_TH) window->average_tpt = (window->success_ratio * tpt + 64) / 128; else window->average_tpt = IL_INVALID_VALUE; @@ -619,7 +618,7 @@ static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, new_ant_type = ant_toggle_lookup[tbl->ant_type]; - while ((new_ant_type != tbl->ant_type) && + while (new_ant_type != tbl->ant_type && !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) new_ant_type = ant_toggle_lookup[new_ant_type]; @@ -790,8 +789,8 @@ out: static bool il4965_table_type_matches(struct il_scale_tbl_info *a, struct il_scale_tbl_info *b) { - return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && - (a->is_SGI == b->is_SGI); + return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && + a->is_SGI == b->is_SGI); } /* @@ -830,7 +829,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, } if (!ieee80211_is_data(hdr->frame_control) || - info->flags & IEEE80211_TX_CTL_NO_ACK) + (info->flags & IEEE80211_TX_CTL_NO_ACK)) return; /* This packet was aggregated but doesn't carry status info */ @@ -867,19 +866,14 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, mac_index += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ - if ((mac_index < 0) || - (tbl_type.is_SGI != - !!(mac_flags & IEEE80211_TX_RC_SHORT_GI)) || - (tbl_type.is_ht40 != - !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH)) || - (tbl_type.is_dup != - !!(mac_flags & IEEE80211_TX_RC_DUP_DATA)) || - (tbl_type.ant_type != info->antenna_sel_tx) || - (!!(tx_rate & RATE_MCS_HT_MSK) != - !!(mac_flags & IEEE80211_TX_RC_MCS)) || - (!!(tx_rate & RATE_MCS_GF_MSK) != - !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || - (rs_index != mac_index)) { + if (mac_index < 0 || + tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || + tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || + tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || + tbl_type.ant_type != info->antenna_sel_tx || + !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || + !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || + rs_index != mac_index) { D_RATE( "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); @@ -1119,12 +1113,12 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, * conditions) at candidate rate is above expected * "active" throughput (under perfect conditions). */ - if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && - ((active_sr > IL_RATE_DECREASE_TH) && - (active_sr <= IL_RATE_HIGH_TH) && - (tpt_tbl[rate] <= active_tpt))) || - ((active_sr >= IL_RATE_SCALE_SWITCH) && - (tpt_tbl[rate] > active_tpt))) { + if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && + (active_sr > IL_RATE_DECREASE_TH && + active_sr <= IL_RATE_HIGH_TH && + tpt_tbl[rate] <= active_tpt)) || + (active_sr >= IL_RATE_SCALE_SWITCH && + tpt_tbl[rate] > active_tpt)) { /* (2nd or later pass) * If we've already tried to raise the rate, and are @@ -1213,7 +1207,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); - if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "Can't switch with index %d rate mask %x\n", rate, rate_mask); @@ -1265,7 +1259,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); - if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "can not switch with index %d rate mask %x\n", rate, rate_mask); @@ -1680,10 +1674,10 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * stats in active history. */ if (force_search || - (lq_sta->total_failed > lq_sta->max_failure_limit) || - (lq_sta->total_success > lq_sta->max_success_limit) || - ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) - && (flush_interval_passed))) { + lq_sta->total_failed > lq_sta->max_failure_limit || + lq_sta->total_success > lq_sta->max_success_limit || + (!lq_sta->search_better_tbl && lq_sta->flush_timer && + flush_interval_passed)) { D_RATE("LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, @@ -1788,7 +1782,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ if (!ieee80211_is_data(hdr->frame_control) || - info->flags & IEEE80211_TX_CTL_NO_ACK) + (info->flags & IEEE80211_TX_CTL_NO_ACK)) return; if (!sta || !lq_sta) @@ -1797,7 +1791,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; tid = il4965_rs_tl_add_packet(lq_sta, hdr); - if ((tid != MAX_TID_COUNT) && (lq_sta->tx_agg_tid_en & (1 << tid))) { + if (tid != MAX_TID_COUNT && (lq_sta->tx_agg_tid_en & (1 << tid))) { tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) lq_sta->is_agg = 0; @@ -1872,8 +1866,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* force user max rate if set by user */ - if ((lq_sta->max_rate_idx != -1) && - (lq_sta->max_rate_idx < index)) { + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < index) { index = lq_sta->max_rate_idx; update_lq = 1; window = &(tbl->win[index]); @@ -1890,8 +1884,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * in current association (use new rate found above). */ fail_count = window->counter - window->success_counter; - if ((fail_count < IL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { + if (fail_count < IL_RATE_MIN_FAILURE_TH && + window->success_counter < IL_RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); @@ -1975,8 +1969,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ - if ((lq_sta->max_rate_idx != -1) && - (lq_sta->max_rate_idx < high)) + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < high) high = IL_RATE_INVALID; sr = window->success_ratio; @@ -1991,14 +1985,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, scale_action = 0; /* Too many failures, decrease rate */ - if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { + if (sr <= IL_RATE_DECREASE_TH || current_tpt == 0) { D_RATE( "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates; try increase. */ - } else if ((low_tpt == IL_INVALID_VALUE) && - (high_tpt == IL_INVALID_VALUE)) { + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH) scale_action = 1; @@ -2008,10 +2002,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Both adjacent throughputs are measured, but neither one has better * throughput; we're using the best rate, don't change it! */ - else if ((low_tpt != IL_INVALID_VALUE) && - (high_tpt != IL_INVALID_VALUE) && - (low_tpt < current_tpt) && - (high_tpt < current_tpt)) + else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) scale_action = 0; /* At least one adjacent rate's throughput is measured, @@ -2021,7 +2013,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ if (high_tpt > current_tpt && - sr >= IL_RATE_INCREASE_TH) { + sr >= IL_RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; @@ -2042,9 +2034,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IL_RATE_INVALID) && - ((sr > IL_RATE_HIGH_TH) || - (current_tpt > (100 * tbl->expected_tpt[low])))) + if (scale_action == -1 && low != IL_RATE_INVALID && + (sr > IL_RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) scale_action = 0; switch (scale_action) { @@ -2090,8 +2081,8 @@ lq_update: * 2) Not just finishing up a search * 3) Allowing a new search */ - if (!update_lq && !done_search && - !lq_sta->stay_in_tbl && window->counter) { + if (!update_lq && !done_search && !lq_sta->stay_in_tbl && + window->counter) { /* Save current throughput to compare with "search" throughput*/ lq_sta->last_tpt = current_tpt; @@ -2146,10 +2137,10 @@ lq_update: * have been tried and compared, stay in this best modulation * mode for a while before next round of mode comparisons. */ if (lq_sta->enable_counter && - (lq_sta->action_counter >= tbl1->max_search)) { - if ((lq_sta->last_tpt > IL_AGG_TPT_THREHOLD) && + lq_sta->action_counter >= tbl1->max_search) { + if (lq_sta->last_tpt > IL_AGG_TPT_THREHOLD && (lq_sta->tx_agg_tid_en & (1 << tid)) && - (tid != MAX_TID_COUNT)) { + tid != MAX_TID_COUNT) { tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { @@ -2217,7 +2208,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, tbl = &(lq_sta->lq_info[active_tbl]); - if ((i < 0) || (i >= IL_RATE_COUNT)) + if (i < 0 || i >= IL_RATE_COUNT) i = 0; rate = il_rates[i].plcp; @@ -2256,11 +2247,11 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, /* Get max rate if user set max rate */ if (lq_sta) { lq_sta->max_rate_idx = txrc->max_rate_idx; - if ((sband->band == IEEE80211_BAND_5GHZ) && - (lq_sta->max_rate_idx != -1)) + if (sband->band == IEEE80211_BAND_5GHZ && + lq_sta->max_rate_idx != -1) lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; - if ((lq_sta->max_rate_idx < 0) || - (lq_sta->max_rate_idx >= IL_RATE_COUNT)) + if (lq_sta->max_rate_idx < 0 || + lq_sta->max_rate_idx >= IL_RATE_COUNT) lq_sta->max_rate_idx = -1; } @@ -2301,9 +2292,9 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ - if ((rate_idx < 0) || (rate_idx >= IL_RATE_COUNT_LEGACY) || - ((sband->band == IEEE80211_BAND_5GHZ) && - (rate_idx < IL_FIRST_OFDM_RATE))) + if (rate_idx < 0 || rate_idx >= IL_RATE_COUNT_LEGACY || + (sband->band == IEEE80211_BAND_5GHZ && + rate_idx < IL_FIRST_OFDM_RATE)) rate_idx = rate_lowest_index(sband, sta); /* On valid 5 GHz rate, adjust index */ else if (sband->band == IEEE80211_BAND_5GHZ) @@ -2475,7 +2466,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, /* Repeat initial/next rate. * For legacy IL_NUMBER_TRY == 1, this loop will not execute. * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ - while (repeat_rate > 0 && (index < LINK_QUAL_MAX_RETRY_NUM)) { + while (repeat_rate > 0 && index < LINK_QUAL_MAX_RETRY_NUM) { if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index f86a3b9..a32a4f3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -195,8 +195,8 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, * index is invalid. */ rate_idx = info->control.rates[0].idx; - if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || - (rate_idx < 0) || (rate_idx > IL_RATE_COUNT_LEGACY)) + if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || + rate_idx < 0 || rate_idx > IL_RATE_COUNT_LEGACY) rate_idx = rate_lowest_index(&il->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ @@ -208,7 +208,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, rate_flags = 0; /* Set CCK flag as needed */ - if ((rate_idx >= IL_FIRST_CCK_RATE) && (rate_idx <= IL_LAST_CCK_RATE)) + if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ @@ -535,8 +535,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) if (sta_priv && sta_priv->client && !is_agg) atomic_inc(&sta_priv->pending_frames); - if ((il_queue_space(q) < q->high_mark) && - il->mac80211_registered) { + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; @@ -1050,8 +1049,8 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ - if ((txq_id == tid_data->agg.txq_id) && - (q->read_ptr == q->write_ptr)) { + if (txq_id == tid_data->agg.txq_id && + q->read_ptr == q->write_ptr) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); D_HT( @@ -1114,7 +1113,7 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) int nfreed = 0; struct ieee80211_hdr *hdr; - if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { + if (index >= q->n_bd || il_queue_used(q, index) == 0) { IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); @@ -1321,9 +1320,9 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, int freed = il4965_tx_queue_reclaim(il, scd_flow, index); il4965_free_tfds_in_queue(il, sta_id, tid, freed); - if ((il_queue_space(&txq->q) > txq->q.low_mark) && + if (il_queue_space(&txq->q) > txq->q.low_mark && il->mac80211_registered && - (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) il_wake_queue(il, txq); il4965_txq_check_empty(il, sta_id, tid, scd_flow); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index a745032..3706e47 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -284,8 +284,8 @@ static bool iw4965_is_ht40_channel(__le32 rxon_flags) { int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; - return ((chan_mod == CHANNEL_MODE_PURE_40) || - (chan_mod == CHANNEL_MODE_MIXED)); + return (chan_mod == CHANNEL_MODE_PURE_40 || + chan_mod == CHANNEL_MODE_MIXED); } static void il4965_nic_config(struct il_priv *il) @@ -323,7 +323,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) { struct il_chain_noise_data *data = &(il->chain_noise_data); - if ((data->state == IL_CHAIN_NOISE_ALIVE) && + if (data->state == IL_CHAIN_NOISE_ALIVE && il_is_any_associated(il)) { struct il_calib_diff_gain_cmd cmd; @@ -458,8 +458,8 @@ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, { s32 comp = 0; - if ((TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage) || - (TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage)) + if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage || + TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage) return 0; il4965_math_div_round(current_voltage - eeprom_voltage, @@ -506,8 +506,8 @@ static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) if (il->calib_info->band_info[b].ch_from == 0) continue; - if ((channel >= il->calib_info->band_info[b].ch_from) - && (channel <= il->calib_info->band_info[b].ch_to)) + if (channel >= il->calib_info->band_info[b].ch_from && + channel <= il->calib_info->band_info[b].ch_to) break; } @@ -1158,15 +1158,15 @@ static int il4965_send_rxon_assoc(struct il_priv *il, const struct il_rxon_cmd *rxon1 = &ctx->staging; const struct il_rxon_cmd *rxon2 = &ctx->active; - if ((rxon1->flags == rxon2->flags) && - (rxon1->filter_flags == rxon2->filter_flags) && - (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && - (rxon1->ofdm_ht_single_stream_basic_rates == - rxon2->ofdm_ht_single_stream_basic_rates) && - (rxon1->ofdm_ht_dual_stream_basic_rates == - rxon2->ofdm_ht_dual_stream_basic_rates) && - (rxon1->rx_chain == rxon2->rx_chain) && - (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_ht_single_stream_basic_rates == + rxon2->ofdm_ht_single_stream_basic_rates && + rxon1->ofdm_ht_dual_stream_basic_rates == + rxon2->ofdm_ht_dual_stream_basic_rates && + rxon1->rx_chain == rxon2->rx_chain && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1216,7 +1216,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * abort any previous channel switch if still in process */ if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && - (il->switch_channel != ctx->staging.channel)) { + il->switch_channel != ctx->staging.channel) { D_11H("abort channel switch on %d\n", le16_to_cpu(il->switch_channel)); il_chswitch_done(il, false); @@ -1366,7 +1366,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, * calculate the ucode channel switch time * adding TSF as one of the factor for when to switch */ - if ((il->ucode_beacon_time > tsf_low) && beacon_interval) { + if (il->ucode_beacon_time > tsf_low && beacon_interval) { if (switch_count > ((il->ucode_beacon_time - tsf_low) / beacon_interval)) { switch_count -= (il->ucode_beacon_time - @@ -1789,7 +1789,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, u8 *qc = NULL; unsigned long flags; - if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, @@ -1838,8 +1838,8 @@ static void il4965_rx_reply_tx(struct il_priv *il, tid, freed); if (il->mac80211_registered && - (il_queue_space(&txq->q) > txq->q.low_mark) - && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + il_queue_space(&txq->q) > txq->q.low_mark && + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) il_wake_queue(il, txq); } } else { @@ -1863,7 +1863,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, D_TX_REPLY("Station not known\n"); if (il->mac80211_registered && - (il_queue_space(&txq->q) > txq->q.low_mark)) + il_queue_space(&txq->q) > txq->q.low_mark) il_wake_queue(il, txq); } if (qc && likely(sta_id != IL_INVALID_STATION)) diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index ea2a98e..56bfdb0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -163,8 +163,8 @@ static inline u32 il4965_tx_status_to_mac80211(u32 status) static inline bool il4965_is_tx_success(u32 status) { status &= TX_STATUS_MSK; - return (status == TX_STATUS_SUCCESS) || - (status == TX_STATUS_DIRECT_DONE); + return (status == TX_STATUS_SUCCESS || + status == TX_STATUS_DIRECT_DONE); } u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index ed44159..acbd5a8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -251,8 +251,8 @@ int il_init_geos(struct il_priv *il) il->tx_power_user_lmt = max_tx_power; il->tx_power_next = max_tx_power; - if ((il->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - il->cfg->sku & IL_SKU_A) { + if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 && + (il->cfg->sku & IL_SKU_A)) { IL_INFO("Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", il->pci_dev->device, @@ -708,8 +708,7 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; - if ((le16_to_cpu(ctx->staging.channel) == channel) && - (il->band == band)) + if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) return 0; ctx->staging.channel = cpu_to_le16(channel); @@ -2306,8 +2305,8 @@ static void il_ht_conf(struct il_priv *il, >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; maxstreams += 1; - if ((ht_cap->mcs.rx_mask[1] == 0) && - (ht_cap->mcs.rx_mask[2] == 0)) + if (ht_cap->mcs.rx_mask[1] == 0 && + ht_cap->mcs.rx_mask[2] == 0) ht_conf->single_chain_sufficient = true; if (maxstreams <= 1) ht_conf->single_chain_sufficient = true; @@ -2467,7 +2466,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * mac80211 decides to do both changes at once because * it will invoke post_associate. */ - if (vif->type == NL80211_IFTYPE_ADHOC && changes & BSS_CHANGED_BEACON) + if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { @@ -2482,8 +2481,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (changes & BSS_CHANGED_ERP_CTS_PROT) { D_MAC80211( "ERP_CTS %d\n", bss_conf->use_cts_prot); - if (bss_conf->use_cts_prot && - (il->band != IEEE80211_BAND_5GHZ)) + if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; else ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; @@ -2596,7 +2594,7 @@ irqreturn_t il_isr(int irq, void *data) goto none; } - if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { + if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) { /* Hardware disappeared. It might have already raised * an interrupt */ IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 8cb924d..9d33da8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -176,7 +176,7 @@ static inline void il_write_reg_buf(struct il_priv *il, { u32 count = sizeof(u32); - if ((il != NULL) && (values != NULL)) { + if (il != NULL && values != NULL) { for (; 0 < len; len -= count, reg += count, values++) il_wr(il, reg, *values); } diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 744829a..5da7d41 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -279,7 +279,7 @@ enum il_table_type { LQ_MAX, }; -#define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A)) +#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A) #define is_siso(tbl) ((tbl) == LQ_SISO) #define is_mimo2(tbl) ((tbl) == LQ_MIMO2) #define is_mimo(tbl) (is_mimo2(tbl)) diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 3687104..e352a18 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -307,7 +307,7 @@ u16 il_get_passive_dwell_time(struct il_priv *il, if (!il_is_associated_ctx(ctx)) continue; value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if ((value > IL_PASSIVE_DWELL_BASE) || !value) + if (value > IL_PASSIVE_DWELL_BASE || !value) value = IL_PASSIVE_DWELL_BASE; value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; passive = min(value, passive); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 42033d2e..cca467c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -595,7 +595,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) if (ctx->ctxid != il->stations[i].ctxid) continue; if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && - !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { + !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { D_ASSOC("Restoring sta %pM\n", il->stations[i].sta.sta.addr); il->stations[i].sta.mode = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index fa23c98..0d3515d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -565,7 +565,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, struct il_queue *q = &txq->q; int nfreed = 0; - if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 5037216..ec9a93c 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -646,7 +646,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); - if ((il_queue_space(q) < q->high_mark) + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&il->lock, flags); @@ -974,7 +974,7 @@ static void il3945_rx_queue_restock(struct il_priv *il) spin_lock_irqsave(&rxq->lock, flags); write = rxq->write & ~0x7; - while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; rxb = list_entry(element, struct il_rx_mem_buffer, list); @@ -995,8 +995,8 @@ static void il3945_rx_queue_restock(struct il_priv *il) /* If we've added more space for the firmware to place data, tell it. * Increment device's write pointer in multiples of 8. */ - if ((rxq->write_actual != (rxq->write & ~0x7)) - || (abs(rxq->write - rxq->read) > 7)) { + if (rxq->write_actual != (rxq->write & ~0x7) || + abs(rxq->write - rxq->read) > 7) { spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); @@ -1041,7 +1041,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) if (!page) { if (net_ratelimit()) D_INFO("Failed to allocate SKB buffer.\n"); - if ((rxq->free_count <= RX_LOW_WATERMARK) && + if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", @@ -1254,8 +1254,8 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && - (pkt->hdr.cmd != REPLY_TX); + pkt->hdr.cmd != STATISTICS_NOTIFICATION && + pkt->hdr.cmd != REPLY_TX; /* Based on type of command response or notification, * handle those that need handling via function in @@ -1659,7 +1659,7 @@ static void il3945_init_hw_rates(struct il_priv *il, rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if ((i > IWL39_LAST_OFDM_RATE) || (i < IL_FIRST_OFDM_RATE)) { + if (i > IWL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { /* * If CCK != 1M then set short preamble rate flag. */ @@ -3294,7 +3294,7 @@ static ssize_t il3945_show_measurement(struct device *d, il->measurement_status = 0; spin_unlock_irqrestore(&il->lock, flags); - while (size && (PAGE_SIZE - len)) { + while (size && PAGE_SIZE - len) { hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, PAGE_SIZE - len, 1); len = strlen(buf); @@ -3406,7 +3406,7 @@ static ssize_t il3945_store_antenna(struct device *d, return count; } - if ((ant >= 0) && (ant <= 2)) { + if (ant >= 0 && ant <= 2) { D_INFO("Setting antenna select to %d.\n", ant); il3945_mod_params.antenna = (enum il3945_antenna)ant; } else -- cgit v0.10.2 From d31751679897441d89e6ae59da98f1424b3f7dfe Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 11:25:42 +0100 Subject: iwlegacy: rename remaining IWLs to ILs Also rename config names IWLWIFI_LEGACY to IWLEGACY Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile index c1c0678..98db7619 100644 --- a/drivers/net/wireless/Makefile +++ b/drivers/net/wireless/Makefile @@ -42,7 +42,7 @@ obj-$(CONFIG_ADM8211) += adm8211.o obj-$(CONFIG_MWL8K) += mwl8k.o obj-$(CONFIG_IWLWIFI) += iwlwifi/ -obj-$(CONFIG_IWLWIFI_LEGACY) += iwlegacy/ +obj-$(CONFIG_IWLEGACY) += iwlegacy/ obj-$(CONFIG_RT2X00) += rt2x00/ obj-$(CONFIG_P54_COMMON) += p54/ diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index 2a1ae10..b4be3b4 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -1,4 +1,4 @@ -config IWLWIFI_LEGACY +config IWLEGACY tristate select FW_LOADER select NEW_LEDS @@ -7,13 +7,13 @@ config IWLWIFI_LEGACY select MAC80211_LEDS menu "Debugging Options" - depends on IWLWIFI_LEGACY + depends on IWLEGACY -config IWLWIFI_LEGACY_DEBUG - bool "Enable full debugging output in 4965 and 3945 drivers" - depends on IWLWIFI_LEGACY +config IWLEGACY_DEBUG + bool "Enable full debugging output in iwlegacy (iwl 3945/4965) drivers" + depends on IWLEGACY ---help--- - This option will enable debug tracing output for the iwlwifilegacy + This option will enable debug tracing output for the iwlegacy drivers. This will result in the kernel module being ~100k larger. You can @@ -29,17 +29,17 @@ config IWLWIFI_LEGACY_DEBUG % echo 0x43fff > /sys/class/net/wlan0/device/debug_level You can find the list of debug mask values in: - drivers/net/wireless/iwlwifilegacy/iwl-debug.h + drivers/net/wireless/iwlegacy/iwl-debug.h If this is your first time using this driver, you should say Y here as the debug information can assist others in helping you resolve any problems you may encounter. -config IWLWIFI_LEGACY_DEBUGFS - bool "4965 and 3945 debugfs support" - depends on IWLWIFI_LEGACY && MAC80211_DEBUGFS +config IWLEGACY_DEBUGFS + bool "iwlegacy (iwl 3945/4965) debugfs support" + depends on IWLEGACY && MAC80211_DEBUGFS ---help--- - Enable creation of debugfs files for the iwlwifilegacy drivers. This + Enable creation of debugfs files for the iwlegacy drivers. This is a low-impact option that allows getting insight into the driver's state at runtime. @@ -48,7 +48,7 @@ endmenu config IWL4965 tristate "Intel Wireless WiFi 4965AGN (iwl4965)" depends on PCI && MAC80211 - select IWLWIFI_LEGACY + select IWLEGACY ---help--- This option enables support for @@ -76,7 +76,7 @@ config IWL4965 config IWL3945 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945)" depends on PCI && MAC80211 - select IWLWIFI_LEGACY + select IWLEGACY ---help--- Select to build the driver supporting the: diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 4f67e45..49c4b36 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,8 +1,8 @@ -obj-$(CONFIG_IWLWIFI_LEGACY) += iwl-legacy.o +obj-$(CONFIG_IWLEGACY) += iwl-legacy.o iwl-legacy-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-legacy-objs += iwl-scan.o iwl-led.o -iwl-legacy-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-debugfs.o +iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o iwl-legacy-objs += $(iwl-legacy-m) @@ -12,11 +12,11 @@ iwl4965-objs := iwl-4965.o iwl4965-base.o iwl-4965-rs.o iwl-4965-led.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o -iwl4965-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-4965-debugfs.o +iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o -iwl3945-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-3945-debugfs.o +iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h index 54334ac..9d1a4a0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h @@ -30,7 +30,7 @@ #include "iwl-core.h" #include "iwl-debug.h" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index 67650ff..fcb466a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -72,7 +72,7 @@ #include "iwl-eeprom.h" /* RSSI to dBm */ -#define IWL39_RSSI_OFFSET 95 +#define IL39_RSSI_OFFSET 95 /* * EEPROM related constants, enums, and structures. @@ -214,7 +214,7 @@ struct il3945_eeprom { u8 reserved16[172]; /* fill out to full 1024 byte block */ } __packed; -#define IWL3945_EEPROM_IMG_SIZE 1024 +#define IL3945_EEPROM_IMG_SIZE 1024 /* End of EEPROM */ @@ -222,8 +222,8 @@ struct il3945_eeprom { #define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */ /* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */ -#define IWL39_NUM_QUEUES 5 -#define IWL39_CMD_QUEUE_NUM 4 +#define IL39_NUM_QUEUES 5 +#define IL39_CMD_QUEUE_NUM 4 #define IL_DEFAULT_TX_RETRY 15 @@ -245,27 +245,27 @@ struct il3945_eeprom { /* Sizes and addresses for instruction and data memory (SRAM) in * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IWL39_RTC_INST_LOWER_BOUND (0x000000) -#define IWL39_RTC_INST_UPPER_BOUND (0x014000) +#define IL39_RTC_INST_LOWER_BOUND (0x000000) +#define IL39_RTC_INST_UPPER_BOUND (0x014000) -#define IWL39_RTC_DATA_LOWER_BOUND (0x800000) -#define IWL39_RTC_DATA_UPPER_BOUND (0x808000) +#define IL39_RTC_DATA_LOWER_BOUND (0x800000) +#define IL39_RTC_DATA_UPPER_BOUND (0x808000) -#define IWL39_RTC_INST_SIZE (IWL39_RTC_INST_UPPER_BOUND - \ - IWL39_RTC_INST_LOWER_BOUND) -#define IWL39_RTC_DATA_SIZE (IWL39_RTC_DATA_UPPER_BOUND - \ - IWL39_RTC_DATA_LOWER_BOUND) +#define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \ + IL39_RTC_INST_LOWER_BOUND) +#define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \ + IL39_RTC_DATA_LOWER_BOUND) -#define IWL39_MAX_INST_SIZE IWL39_RTC_INST_SIZE -#define IWL39_MAX_DATA_SIZE IWL39_RTC_DATA_SIZE +#define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE +#define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE /* Size of uCode instruction memory in bootstrap state machine */ -#define IWL39_MAX_BSM_SIZE IWL39_RTC_INST_SIZE +#define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE static inline int il3945_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL39_RTC_DATA_LOWER_BOUND && - addr < IWL39_RTC_DATA_UPPER_BOUND); + return (addr >= IL39_RTC_DATA_LOWER_BOUND && + addr < IL39_RTC_DATA_UPPER_BOUND); } /* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index afa6be8..345beb7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -90,7 +90,7 @@ static struct il3945_tpt_entry il3945_tpt_table_g[] = { #define IL_RATE_MAX_WINDOW 62 #define IL_RATE_FLUSH (3*HZ) #define IL_RATE_WIN_FLUSH (HZ/2) -#define IWL39_RATE_HIGH_TH 11520 +#define IL39_RATE_HIGH_TH 11520 #define IL_SUCCESS_UP_TH 8960 #define IL_SUCCESS_DOWN_TH 10880 #define IL_RATE_MIN_FAILURE_TH 6 diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index fb69b74..78e81b6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -200,7 +200,7 @@ static int il3945_hwrate_to_plcp_idx(u8 plcp) return -1; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x static const char *il3945_get_tx_fail_reason(u32 status) @@ -281,7 +281,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, struct il_queue *q = &txq->q; struct il_tx_info *tx_info; - BUG_ON(txq_id == IWL39_CMD_QUEUE_NUM); + BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); for (index = il_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; @@ -294,7 +294,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, } if (il_queue_space(q) > q->low_mark && txq_id >= 0 && - txq_id != IWL39_CMD_QUEUE_NUM && il->mac80211_registered) + txq_id != IL39_CMD_QUEUE_NUM && il->mac80211_registered) il_wake_queue(il, txq); } @@ -361,7 +361,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, * RX handler implementations * *****************************************************************************/ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS static void il3945_accumulative_statistics(struct il_priv *il, __le32 *stats) { @@ -403,7 +403,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS il3945_accumulative_statistics(il, (__le32 *)&pkt->u.raw); #endif @@ -417,7 +417,7 @@ void il3945_reply_statistics(struct il_priv *il, __le32 *flag = (__le32 *)&pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_3945.accum_statistics, 0, sizeof(struct il3945_notif_statistics)); memset(&il->_3945.delta_statistics, 0, @@ -468,7 +468,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, __le16 fc = hdr->frame_control; /* We received data from the HW, so stop the watchdog */ - if (unlikely(len + IWL39_RX_FRAME_SIZE > + if (unlikely(len + IL39_RX_FRAME_SIZE > PAGE_SIZE << il->hw_params.rx_page_order)) { D_DROP("Corruption detected!\n"); return; @@ -552,7 +552,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, /* Convert 3945's rssi indicator to dBm */ - rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; + rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; D_STATS("Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, @@ -698,7 +698,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, data_retry_limit = IL_DEFAULT_TX_RETRY; tx_cmd->data_retry_limit = data_retry_limit; - if (tx_id >= IWL39_CMD_QUEUE_NUM) + if (tx_id >= IL39_CMD_QUEUE_NUM) rts_retry_limit = 3; else rts_retry_limit = 7; @@ -849,7 +849,7 @@ static int il3945_txq_ctx_reset(struct il_priv *il) /* Tx queue(s) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == IWL39_CMD_QUEUE_NUM) ? + slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); @@ -1010,7 +1010,7 @@ void il3945_hw_txq_ctx_free(struct il_priv *il) if (il->txq) for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (txq_id == IWL39_CMD_QUEUE_NUM) + if (txq_id == IL39_CMD_QUEUE_NUM) il_cmd_queue_free(il); else il_tx_queue_free(il, txq_id); @@ -1402,7 +1402,7 @@ static int il3945_send_tx_power(struct il_priv *il) /* fill cmd with power settings for all rates for current channel */ /* Fill OFDM rate */ for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; - rate_idx <= IWL39_LAST_OFDM_RATE; rate_idx++, i++) { + rate_idx <= IL39_LAST_OFDM_RATE; rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; @@ -2400,14 +2400,14 @@ int il3945_hw_set_hw_params(struct il_priv *il) il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); il->hw_params.max_rxq_size = RX_QUEUE_SIZE; il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - il->hw_params.max_stations = IWL3945_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; + il->hw_params.max_stations = IL3945_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL3945_BROADCAST_ID; il->sta_key_max_num = STA_KEY_MAX_NUM; il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; - il->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; - il->hw_params.beacon_time_tsf_bits = IWL3945_EXT_BEACON_TIME_POS; + il->hw_params.max_beacon_itrvl = IL39_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.beacon_time_tsf_bits = IL3945_EXT_BEACON_TIME_POS; return 0; } @@ -2569,7 +2569,7 @@ static int il3945_load_bsm(struct il_priv *il) D_INFO("Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IWL39_MAX_BSM_SIZE) + if (len > IL39_MAX_BSM_SIZE) return -EINVAL; /* Tell bootstrap uCode where to find the "Initialize" uCode @@ -2601,7 +2601,7 @@ static int il3945_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); il_wr_prph(il, BSM_WR_MEM_DST_REG, - IWL39_RTC_INST_LOWER_BOUND); + IL39_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, @@ -2692,8 +2692,8 @@ static const struct il_ops il3945_ops = { }; static struct il_base_params il3945_base_params = { - .eeprom_size = IWL3945_EEPROM_IMG_SIZE, - .num_of_queues = IWL39_NUM_QUEUES, + .eeprom_size = IL3945_EEPROM_IMG_SIZE, + .num_of_queues = IL39_NUM_QUEUES, .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, .set_l0s = false, .use_bsm = true, @@ -2703,9 +2703,9 @@ static struct il_base_params il3945_base_params = { static struct il_cfg il3945_bg_cfg = { .name = "3945BG", - .fw_name_pre = IWL3945_FW_PRE, - .ucode_api_max = IWL3945_UCODE_API_MAX, - .ucode_api_min = IWL3945_UCODE_API_MIN, + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, .sku = IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .ops = &il3945_ops, @@ -2716,9 +2716,9 @@ static struct il_cfg il3945_bg_cfg = { static struct il_cfg il3945_abg_cfg = { .name = "3945ABG", - .fw_name_pre = IWL3945_FW_PRE, - .ucode_api_max = IWL3945_UCODE_API_MAX, - .ucode_api_min = IWL3945_UCODE_API_MIN, + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, .sku = IL_SKU_A|IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .ops = &il3945_ops, diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index abe778b..6c68f59 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -49,14 +49,14 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "iwl-led.h" /* Highest firmware API version supported */ -#define IWL3945_UCODE_API_MAX 2 +#define IL3945_UCODE_API_MAX 2 /* Lowest firmware API version supported */ -#define IWL3945_UCODE_API_MIN 1 +#define IL3945_UCODE_API_MIN 1 -#define IWL3945_FW_PRE "iwlwifi-3945-" -#define _IWL3945_MODULE_FIRMWARE(api) IWL3945_FW_PRE #api ".ucode" -#define IWL3945_MODULE_FIRMWARE(api) _IWL3945_MODULE_FIRMWARE(api) +#define IL3945_FW_PRE "iwlwifi-3945-" +#define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode" +#define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api) /* Default noise level to report when noise measurement is not available. * This may be because we're: diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h index ca1cf58..284604c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h @@ -30,7 +30,7 @@ #include "iwl-core.h" #include "iwl-debug.h" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index b21c004..ecebc69 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -72,38 +72,38 @@ #include "iwl-fh.h" /* EEPROM */ -#define IWL4965_EEPROM_IMG_SIZE 1024 +#define IL4965_EEPROM_IMG_SIZE 1024 /* * uCode queue management definitions ... * The first queue used for block-ack aggregation is #7 (4965 only). * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. */ -#define IWL49_FIRST_AMPDU_QUEUE 7 +#define IL49_FIRST_AMPDU_QUEUE 7 /* Sizes and addresses for instruction and data memory (SRAM) in * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IWL49_RTC_INST_LOWER_BOUND (0x000000) -#define IWL49_RTC_INST_UPPER_BOUND (0x018000) +#define IL49_RTC_INST_LOWER_BOUND (0x000000) +#define IL49_RTC_INST_UPPER_BOUND (0x018000) -#define IWL49_RTC_DATA_LOWER_BOUND (0x800000) -#define IWL49_RTC_DATA_UPPER_BOUND (0x80A000) +#define IL49_RTC_DATA_LOWER_BOUND (0x800000) +#define IL49_RTC_DATA_UPPER_BOUND (0x80A000) -#define IWL49_RTC_INST_SIZE (IWL49_RTC_INST_UPPER_BOUND - \ - IWL49_RTC_INST_LOWER_BOUND) -#define IWL49_RTC_DATA_SIZE (IWL49_RTC_DATA_UPPER_BOUND - \ - IWL49_RTC_DATA_LOWER_BOUND) +#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \ + IL49_RTC_INST_LOWER_BOUND) +#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \ + IL49_RTC_DATA_LOWER_BOUND) -#define IWL49_MAX_INST_SIZE IWL49_RTC_INST_SIZE -#define IWL49_MAX_DATA_SIZE IWL49_RTC_DATA_SIZE +#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE +#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE /* Size of uCode instruction memory in bootstrap state machine */ -#define IWL49_MAX_BSM_SIZE BSM_SRAM_SIZE +#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE static inline int il4965_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL49_RTC_DATA_LOWER_BOUND && - addr < IWL49_RTC_DATA_UPPER_BOUND); + return (addr >= IL49_RTC_DATA_LOWER_BOUND && + addr < IL49_RTC_DATA_UPPER_BOUND); } /********************* START TEMPERATURE *************************************/ @@ -760,10 +760,10 @@ enum { * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array * in DRAM containing 256 Transmit Frame Descriptors (TFDs). */ -#define IWL49_NUM_FIFOS 7 -#define IWL49_CMD_FIFO_NUM 4 -#define IWL49_NUM_QUEUES 16 -#define IWL49_NUM_AMPDU_QUEUES 8 +#define IL49_NUM_FIFOS 7 +#define IL49_CMD_FIFO_NUM 4 +#define IL49_NUM_QUEUES 16 +#define IL49_NUM_AMPDU_QUEUES 8 /** @@ -790,10 +790,10 @@ struct il4965_scd_bc_tbl { } __packed; -#define IWL4965_RTC_INST_LOWER_BOUND (0x000000) +#define IL4965_RTC_INST_LOWER_BOUND (0x000000) /* RSSI to dBm */ -#define IWL4965_RSSI_OFFSET 44 +#define IL4965_RSSI_OFFSET 44 /* PCI registers */ #define PCI_CFG_RETRY_TIMEOUT 0x041 @@ -802,10 +802,10 @@ struct il4965_scd_bc_tbl { #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 -#define IWL4965_DEFAULT_TX_RETRY 15 +#define IL4965_DEFAULT_TX_RETRY 15 /* EEPROM */ -#define IWL4965_FIRST_AMPDU_QUEUE 10 +#define IL4965_FIRST_AMPDU_QUEUE 10 #endif /* !__il_4965_hw_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 8bb2b62..964d9bb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -438,12 +438,12 @@ static int il4965_calc_rssi(struct il_priv *il, * contents are always there, not configurable by host. */ struct il4965_rx_non_cfg_phy *ncphy = (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; - u32 agc = (le16_to_cpu(ncphy->agc_info) & IWL49_AGC_DB_MASK) - >> IWL49_AGC_DB_POS; + u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) + >> IL49_AGC_DB_POS; u32 valid_antennae = - (le16_to_cpu(rx_resp->phy_flags) & IWL49_RX_PHY_FLAGS_ANTENNAE_MASK) - >> IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; + (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) + >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; u8 max_rssi = 0; u32 i; @@ -462,7 +462,7 @@ static int il4965_calc_rssi(struct il_priv *il, /* dBm = max_rssi dB - agc dB - constant. * Higher AGC (higher radio gain) means lower signal. */ - return max_rssi - agc - IWL4965_RSSI_OFFSET; + return max_rssi - agc - IL4965_RSSI_OFFSET; } @@ -1152,7 +1152,7 @@ static const char *il4965_get_fh_string(int cmd) int il4965_dump_fh(struct il_priv *il, char **buf, bool display) { int i; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG int pos = 0; size_t bufsz = 0; #endif @@ -1167,7 +1167,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_ERROR_REG }; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (display) { bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; *buf = kmalloc(bufsz, GFP_KERNEL); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index c2f4230..9c8cc32 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -40,7 +40,7 @@ #include "iwl-core.h" #include "iwl-4965.h" -#define IWL4965_RS_NAME "iwl-4965-rs" +#define IL4965_RS_NAME "iwl-4965-rs" #define NUM_TRY_BEFORE_ANT_TOGGLE 1 #define IL_NUMBER_TRY 1 @@ -2837,7 +2837,7 @@ il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, } static struct rate_control_ops rs_4965_ops = { .module = NULL, - .name = IWL4965_RS_NAME, + .name = IL4965_RS_NAME, .tx_status = il4965_rs_tx_status, .get_rate = il4965_rs_get_rate, .rate_init = il4965_rs_rate_init_stub, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 45e8a24..2181ec0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -105,7 +105,7 @@ static void il4965_rx_calc_noise(struct il_priv *il) last_rx_noise); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS /* * based on the assumption of all statistics counter are in DWORD * FIXME: This function is for debugging, do not deal with @@ -169,7 +169,7 @@ void il4965_rx_statistics(struct il_priv *il, STATISTICS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS il4965_accumulative_statistics(il, (__le32 *)&pkt->u.stats); #endif @@ -201,7 +201,7 @@ void il4965_reply_statistics(struct il_priv *il, struct il_rx_packet *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_4965.accum_statistics, 0, sizeof(struct il_notif_statistics)); memset(&il->_4965.delta_statistics, 0, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index a32a4f3..5f6a4ba 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -171,7 +171,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else - data_retry_limit = IWL4965_DEFAULT_TX_RETRY; + data_retry_limit = IL4965_DEFAULT_TX_RETRY; tx_cmd->data_retry_limit = data_retry_limit; /* Set retry limit on RTS packets */ @@ -304,7 +304,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) fc = hdr->frame_control; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (ieee80211_is_auth(fc)) D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) @@ -754,9 +754,9 @@ static void il4965_tx_queue_stop_scheduler(struct il_priv *il, /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ il_wr_prph(il, - IWL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| - (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); + IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| + (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** @@ -772,7 +772,7 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; tbl_dw_addr = il->scd_base_addr + - IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); tbl_dw = il_read_targ_mem(il, tbl_dw_addr); @@ -789,7 +789,7 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, /** * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue * - * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE, + * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, @@ -799,13 +799,13 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, u16 ra_tid; int ret; - if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || - (IWL49_FIRST_AMPDU_QUEUE + + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { IL_WARN( "queue number out of range: %d, must be %d to %d\n", - txq_id, IWL49_FIRST_AMPDU_QUEUE, - IWL49_FIRST_AMPDU_QUEUE + + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } @@ -826,7 +826,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); /* Set this queue as a chain-building queue */ - il_set_bits_prph(il, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); /* Place first TFD at index corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ @@ -836,16 +836,16 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, /* Set up Tx window size and frame limit for this queue */ il_write_targ_mem(il, - il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), - (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); il_write_targ_mem(il, il->scd_base_addr + - IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), - (SCD_FRAME_LIMIT << IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) - & IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), + (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) + & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - il_set_bits_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); @@ -922,19 +922,19 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, } /** - * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE + * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE * il->lock must be held by the caller */ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { - if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || - (IWL49_FIRST_AMPDU_QUEUE + + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { IL_WARN( "queue number out of range: %d, must be %d to %d\n", - txq_id, IWL49_FIRST_AMPDU_QUEUE, - IWL49_FIRST_AMPDU_QUEUE + + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } @@ -942,7 +942,7 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, il4965_tx_queue_stop_scheduler(il, txq_id); il_clear_bits_prph(il, - IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); @@ -950,7 +950,7 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, il4965_set_wr_ptrs(il, txq_id, ssn_idx); il_clear_bits_prph(il, - IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); il_txq_ctx_deactivate(il, txq_id); il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); @@ -1134,7 +1134,7 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) nfreed++; il4965_tx_status(il, tx_info, - txq_id >= IWL4965_FIRST_AMPDU_QUEUE); + txq_id >= IL4965_FIRST_AMPDU_QUEUE); tx_info->skb = NULL; il->cfg->ops->lib->txq_free_tfd(il, txq); @@ -1331,7 +1331,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG const char *il4965_get_tx_fail_reason(u32 status) { #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x @@ -1368,4 +1368,4 @@ const char *il4965_get_tx_fail_reason(u32 status) #undef TX_STATUS_FAIL #undef TX_STATUS_POSTPONE } -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index bb0b7f5..633caf5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -62,7 +62,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ il_wr(il, HBUS_TARG_MEM_RADDR, - i + IWL4965_RTC_INST_LOWER_BOUND); + i + IL4965_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; @@ -90,7 +90,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, D_INFO("ucode inst image size is %u\n", len); il_wr(il, HBUS_TARG_MEM_RADDR, - IWL4965_RTC_INST_LOWER_BOUND); + IL4965_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 3706e47..f345171 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -52,14 +52,14 @@ static int il4965_send_tx_power(struct il_priv *il); static int il4965_hw_get_temperature(struct il_priv *il); /* Highest firmware API version supported */ -#define IWL4965_UCODE_API_MAX 2 +#define IL4965_UCODE_API_MAX 2 /* Lowest firmware API version supported */ -#define IWL4965_UCODE_API_MIN 2 +#define IL4965_UCODE_API_MIN 2 -#define IWL4965_FW_PRE "iwlwifi-4965-" -#define _IWL4965_MODULE_FIRMWARE(api) IWL4965_FW_PRE #api ".ucode" -#define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api) +#define IL4965_FW_PRE "iwlwifi-4965-" +#define _IL4965_MODULE_FIRMWARE(api) IL4965_FW_PRE #api ".ucode" +#define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ static int il4965_verify_bsm(struct il_priv *il) @@ -142,7 +142,7 @@ static int il4965_load_bsm(struct il_priv *il) il->ucode_type = UCODE_RT; /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IWL49_MAX_BSM_SIZE) + if (len > IL49_MAX_BSM_SIZE) return -EINVAL; /* Tell bootstrap uCode where to find the "Initialize" uCode @@ -174,7 +174,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); il_wr_prph(il, - BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); + BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, @@ -392,7 +392,7 @@ static void il4965_set_ct_threshold(struct il_priv *il) static int il4965_hw_set_hw_params(struct il_priv *il) { if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && - il->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) + il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) il->cfg->base_params->num_of_queues = il->cfg->mod_params->num_of_queues; @@ -402,10 +402,10 @@ static int il4965_hw_set_hw_params(struct il_priv *il) il->cfg->base_params->num_of_queues * sizeof(struct il4965_scd_bc_tbl); il->hw_params.tfd_size = sizeof(struct il_tfd); - il->hw_params.max_stations = IWL4965_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; - il->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; - il->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; + il->hw_params.max_stations = IL4965_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL4965_BROADCAST_ID; + il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; + il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; il->hw_params.max_bsm_size = BSM_SRAM_SIZE; il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); @@ -419,7 +419,7 @@ static int il4965_hw_set_hw_params(struct il_priv *il) il4965_set_ct_threshold(il); il->hw_params.sens = &il4965_sensitivity; - il->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; + il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; return 0; } @@ -2143,14 +2143,14 @@ static const struct il_ops il4965_ops = { }; static struct il_base_params il4965_base_params = { - .eeprom_size = IWL4965_EEPROM_IMG_SIZE, - .num_of_queues = IWL49_NUM_QUEUES, - .num_of_ampdu_queues = IWL49_NUM_AMPDU_QUEUES, + .eeprom_size = IL4965_EEPROM_IMG_SIZE, + .num_of_queues = IL49_NUM_QUEUES, + .num_of_ampdu_queues = IL49_NUM_AMPDU_QUEUES, .pll_cfg_val = 0, .set_l0s = true, .use_bsm = true, .led_compensation = 61, - .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS, + .chain_noise_num_beacons = IL4965_CAL_NUM_BEACONS, .wd_timeout = IL_DEF_WD_TIMEOUT, .temperature_kelvin = true, .ucode_tracing = true, @@ -2160,9 +2160,9 @@ static struct il_base_params il4965_base_params = { struct il_cfg il4965_cfg = { .name = "Intel(R) Wireless WiFi Link 4965AGN", - .fw_name_pre = IWL4965_FW_PRE, - .ucode_api_max = IWL4965_UCODE_API_MAX, - .ucode_api_min = IWL4965_UCODE_API_MIN, + .fw_name_pre = IL4965_FW_PRE, + .ucode_api_max = IL4965_UCODE_API_MAX, + .ucode_api_min = IL4965_UCODE_API_MIN, .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, .valid_tx_ant = ANT_AB, .valid_rx_ant = ANT_ABC, @@ -2180,4 +2180,4 @@ struct il_cfg il4965_cfg = { }; /* Module firmware */ -MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE(IWL4965_UCODE_API_MAX)); +MODULE_FIRMWARE(IL4965_MODULE_FIRMWARE(IL4965_UCODE_API_MAX)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 56bfdb0..0b92c28 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -189,7 +189,7 @@ int il4965_manage_ibss_station(struct il_priv *il, /* hcmd */ int il4965_send_beacon_cmd(struct il_priv *il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG const char *il4965_get_tx_fail_reason(u32 status); #else static inline const char * diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 347d402..61acafb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -746,7 +746,7 @@ struct il4965_rxon_assoc_cmd { #define IL_CONN_MAX_LISTEN_INTERVAL 10 #define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ -#define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ +#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) @@ -854,10 +854,10 @@ struct il_qosparam_cmd { /* Special, dedicated locations within device's station table */ #define IL_AP_ID 0 #define IL_STA_ID 2 -#define IWL3945_BROADCAST_ID 24 -#define IWL3945_STATION_COUNT 25 -#define IWL4965_BROADCAST_ID 31 -#define IWL4965_STATION_COUNT 32 +#define IL3945_BROADCAST_ID 24 +#define IL3945_STATION_COUNT 25 +#define IL4965_BROADCAST_ID 31 +#define IL4965_STATION_COUNT 32 #define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ #define IL_INVALID_STATION 255 @@ -1208,15 +1208,15 @@ struct il3945_rx_frame { struct il3945_rx_frame_end end; } __packed; -#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) +#define IL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) /* Fixed (non-configurable) rx data from phy */ -#define IWL49_RX_RES_PHY_CNT 14 -#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) -#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) -#define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ -#define IWL49_AGC_DB_POS (7) +#define IL49_RX_RES_PHY_CNT 14 +#define IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) +#define IL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) +#define IL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ +#define IL49_AGC_DB_POS (7) struct il4965_rx_non_cfg_phy { __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ @@ -2407,7 +2407,7 @@ struct il3945_scan_channel { } __packed; /* set number of direct probes u8 type */ -#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) +#define IL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) struct il_scan_channel { /* diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index acbd5a8..395918e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -315,7 +315,7 @@ bool il_is_ht40_tx_allowed(struct il_priv *il, if (ht_cap && !ht_cap->ht_supported) return false; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS if (il->disable_ht40) return false; #endif @@ -888,7 +888,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) } EXPORT_SYMBOL(il_rx_csa); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { @@ -930,7 +930,7 @@ void il_irq_handle_error(struct il_priv *il) il->cfg->ops->lib->dump_nic_error_log(il); if (il->cfg->ops->lib->dump_fh) il->cfg->ops->lib->dump_fh(il, NULL, false); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_FW_ERRORS) il_print_rx_config_cmd(il, &il->contexts[IL_RXON_CTX_BSS]); @@ -1208,7 +1208,7 @@ EXPORT_SYMBOL(il_send_statistics_request); void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); D_RX("sleep mode: %d, src: %d\n", @@ -1467,7 +1467,7 @@ void il_txq_mem(struct il_priv *il) } EXPORT_SYMBOL(il_txq_mem); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS #define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) @@ -1611,11 +1611,11 @@ void il_clear_traffic_stats(struct il_priv *il) } /* - * if CONFIG_IWLWIFI_LEGACY_DEBUGFS defined, + * if CONFIG_IWLEGACY_DEBUGFS defined, * il_update_stats function will * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass * Use debugFs to display the rx/rx_statistics - * if CONFIG_IWLWIFI_LEGACY_DEBUGFS not being defined, then no MGMT and CTRL + * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL * information will be recorded, but DATA pkt still will be recorded * for the reason of il_led.c need to control the led blinking based on * number of tx and rx data. diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 1803954..487cebf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -329,7 +329,7 @@ int il_mac_change_interface(struct ieee80211_hw *hw, int il_alloc_txq_mem(struct il_priv *il); void il_txq_mem(struct il_priv *il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS int il_alloc_traffic_mem(struct il_priv *il); void il_free_traffic_mem(struct il_priv *il); void il_reset_traffic_log(struct il_priv *il); @@ -513,7 +513,7 @@ extern const struct dev_pm_ops il_pm_ops; * Error Handling Debugging ******************************************************/ void il4965_dump_nic_error_log(struct il_priv *il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx); #else diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 77467de..c58003a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -42,7 +42,7 @@ do { \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define IL_DBG(level, fmt, args...) \ do { \ if (il_get_debug_level(il) & level) \ @@ -63,9 +63,9 @@ do { \ static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS int il_dbgfs_register(struct il_priv *il, const char *name); void il_dbgfs_unregister(struct il_priv *il); #else @@ -77,7 +77,7 @@ il_dbgfs_register(struct il_priv *il, const char *name) static inline void il_dbgfs_unregister(struct il_priv *il) { } -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ /* * To use the debug system: @@ -99,7 +99,7 @@ static inline void il_dbgfs_unregister(struct il_priv *il) * /sys/module/iwl3945/parameters/debug * /sys/class/net/wlan0/device/debug_level * - * when CONFIG_IWLWIFI_LEGACY_DEBUG=y. + * when CONFIG_IWLEGACY_DEBUG=y. */ /* 0x0000000F - 0x00000001 */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index cd15e67..736b00b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -535,7 +535,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, "\tLast Restarting Code: 0x%X\n", il->isr_stats.err_code); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", il->isr_stats.sch); pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 2e2e3f3..0aa4a12 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -185,7 +185,7 @@ struct il4965_channel_tgh_info { s64 last_radar_time; }; -#define IWL4965_MAX_RATE (33) +#define IL4965_MAX_RATE (33) struct il3945_clip_group { /* maximum power level to prevent clipping for each rate, derived by @@ -246,7 +246,7 @@ struct il_channel_info { /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for * remembering/modifying gain settings (indexes). */ - struct il3945_channel_power_info power_info[IWL4965_MAX_RATE]; + struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; /* Radio/DSP gain settings for each scan rate, for directed scans. */ struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; @@ -670,7 +670,7 @@ struct il_dma_ptr { /* Sensitivity and chain noise calibration */ #define INITIALIZATION_VALUE 0xFFFF -#define IWL4965_CAL_NUM_BEACONS 20 +#define IL4965_CAL_NUM_BEACONS 20 #define IL_CAL_NUM_BEACONS 16 #define MAXIMUM_ALLOWED_PATHLOSS 15 @@ -847,7 +847,7 @@ enum il_ctrl_stats { }; struct traffic_stats { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS u32 mgmt[MANAGEMENT_MAX]; u32 ctrl[CONTROL_MAX]; u32 data_cnt; @@ -891,13 +891,13 @@ struct il_force_reset { * bits 31:24 - extended * bits 23:0 - interval */ -#define IWL3945_EXT_BEACON_TIME_POS 24 +#define IL3945_EXT_BEACON_TIME_POS 24 /* * for _4965 devices * bits 31:22 - extended * bits 21:0 - interval */ -#define IWL4965_EXT_BEACON_TIME_POS 22 +#define IL4965_EXT_BEACON_TIME_POS 22 enum il_rxon_context_id { IL_RXON_CTX_BSS, @@ -1141,7 +1141,7 @@ struct il_priv { struct delayed_work rfkill_poll; struct il3945_notif_statistics statistics; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS struct il3945_notif_statistics accum_statistics; struct il3945_notif_statistics delta_statistics; struct il3945_notif_statistics max_delta; @@ -1179,7 +1179,7 @@ struct il_priv { u8 phy_calib_chain_noise_gain_cmd; struct il_notif_statistics statistics; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS struct il_notif_statistics accum_statistics; struct il_notif_statistics delta_statistics; struct il_notif_statistics max_delta; @@ -1217,12 +1217,12 @@ struct il_priv { s8 tx_power_next; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* debugging info */ u32 debug_level; /* per device debugging will override global il_debug_level if set */ -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#endif /* CONFIG_IWLEGACY_DEBUG */ +#ifdef CONFIG_IWLEGACY_DEBUGFS /* debugfs */ u16 tx_traffic_idx; u16 rx_traffic_idx; @@ -1231,7 +1231,7 @@ struct il_priv { struct dentry *debugfs_dir; u32 dbgfs_sram_offset, dbgfs_sram_len; bool disable_ht40; -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ struct work_struct txpower_work; u32 disable_sens_cal; @@ -1257,7 +1257,7 @@ static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) clear_bit(txq_id, &il->txq_ctx_active_msk); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* * il_get_debug_level: Return active debug level for device * diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 8f87bd8..6ccd37f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -100,7 +100,7 @@ static void il_generic_cmd_callback(struct il_priv *il, return; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 5da7d41..f24b6b8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -97,7 +97,7 @@ enum { enum { IL_FIRST_OFDM_RATE = IL_RATE_6M_INDEX, - IWL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, + IL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, IL_LAST_OFDM_RATE = IL_RATE_60M_INDEX, IL_FIRST_CCK_RATE = IL_RATE_1M_INDEX, IL_LAST_CCK_RATE = IL_RATE_11M_INDEX, diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 96788a1..caa3837 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -320,19 +320,19 @@ * can keep track of at one time when creating block-ack chains of frames. * Note that "64" matches the number of ack bits in a block-ack packet. * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize - * IWL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. + * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. */ #define SCD_WIN_SIZE 64 #define SCD_FRAME_LIMIT 64 /* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ -#define IWL49_SCD_START_OFFSET 0xa02c00 +#define IL49_SCD_START_OFFSET 0xa02c00 /* * 4965 tells driver SRAM address for internal scheduler structs via this reg. * Value is valid only after "Alive" response from uCode. */ -#define IWL49_SCD_SRAM_BASE_ADDR (IWL49_SCD_START_OFFSET + 0x0) +#define IL49_SCD_SRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x0) /* * Driver may need to update queue-empty bits after changing queue's @@ -343,7 +343,7 @@ * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty * NOTE: This register is not used by Linux driver. */ -#define IWL49_SCD_EMPTY_BITS (IWL49_SCD_START_OFFSET + 0x4) +#define IL49_SCD_EMPTY_BITS (IL49_SCD_START_OFFSET + 0x4) /* * Physical base address of array of byte count (BC) circular buffers (CBs). @@ -355,7 +355,7 @@ * Bit fields: * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. */ -#define IWL49_SCD_DRAM_BASE_ADDR (IWL49_SCD_START_OFFSET + 0x10) +#define IL49_SCD_DRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x10) /* * Enables any/all Tx DMA/FIFO channels. @@ -364,7 +364,7 @@ * Bit fields: * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 */ -#define IWL49_SCD_TXFACT (IWL49_SCD_START_OFFSET + 0x1c) +#define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) /* * Queue (x) Write Pointers (indexes, really!), one for each Tx queue. * Initialized and updated by driver as new TFDs are added to queue. @@ -372,7 +372,7 @@ * Start Sequence Number; index = (SSN & 0xff) * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? */ -#define IWL49_SCD_QUEUE_WRPTR(x) (IWL49_SCD_START_OFFSET + 0x24 + (x) * 4) +#define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) /* * Queue (x) Read Pointers (indexes, really!), one for each Tx queue. @@ -380,7 +380,7 @@ * For Scheduler-ACK mode, index indicates first frame in Tx window. * Initialized by driver, updated by scheduler. */ -#define IWL49_SCD_QUEUE_RDPTR(x) (IWL49_SCD_START_OFFSET + 0x64 + (x) * 4) +#define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) /* * Select which queues work in chain mode (1) vs. not (0). @@ -391,7 +391,7 @@ * NOTE: If driver sets up queue for chain mode, it should be also set up * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). */ -#define IWL49_SCD_QUEUECHAIN_SEL (IWL49_SCD_START_OFFSET + 0xd0) +#define IL49_SCD_QUEUECHAIN_SEL (IL49_SCD_START_OFFSET + 0xd0) /* * Select which queues interrupt driver when scheduler increments @@ -402,7 +402,7 @@ * NOTE: This functionality is apparently a no-op; driver relies on interrupts * from Rx queue to read Tx command responses and update Tx queues. */ -#define IWL49_SCD_INTERRUPT_MASK (IWL49_SCD_START_OFFSET + 0xe4) +#define IL49_SCD_INTERRUPT_MASK (IL49_SCD_START_OFFSET + 0xe4) /* * Queue search status registers. One for each queue. @@ -423,18 +423,18 @@ * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled * via SCD_QUEUECHAIN_SEL. */ -#define IWL49_SCD_QUEUE_STATUS_BITS(x)\ - (IWL49_SCD_START_OFFSET + 0x104 + (x) * 4) +#define IL49_SCD_QUEUE_STATUS_BITS(x)\ + (IL49_SCD_START_OFFSET + 0x104 + (x) * 4) /* Bit field positions */ -#define IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) -#define IWL49_SCD_QUEUE_STTS_REG_POS_TXF (1) -#define IWL49_SCD_QUEUE_STTS_REG_POS_WSL (5) -#define IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) +#define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) +#define IL49_SCD_QUEUE_STTS_REG_POS_TXF (1) +#define IL49_SCD_QUEUE_STTS_REG_POS_WSL (5) +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) /* Write masks */ -#define IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) -#define IWL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) +#define IL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) /** * 4965 internal SRAM structures for scheduler, shared with driver ... @@ -470,14 +470,14 @@ * Init must be done after driver receives "Alive" response from 4965 uCode, * and when setting up queue for aggregation. */ -#define IWL49_SCD_CONTEXT_DATA_OFFSET 0x380 -#define IWL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ - (IWL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) +#define IL49_SCD_CONTEXT_DATA_OFFSET 0x380 +#define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ + (IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) -#define IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) -#define IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) -#define IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) -#define IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) /* * Tx Status Bitmap @@ -486,7 +486,7 @@ * "Alive" notification from uCode. Area is used only by device itself; * no other support (besides clearing) is required from driver. */ -#define IWL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 +#define IL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 /* * RAxTID to queue translation mapping. @@ -508,11 +508,11 @@ * must read a dword-aligned value from device SRAM, replace the 16-bit map * value of interest, and write the dword value back into device SRAM. */ -#define IWL49_SCD_TRANSLATE_TBL_OFFSET 0x500 +#define IL49_SCD_TRANSLATE_TBL_OFFSET 0x500 /* Find translation table dword to read/write for given queue */ -#define IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ - ((IWL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) +#define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ + ((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) #define IL_SCD_TXFIFO_POS_TID (0) #define IL_SCD_TXFIFO_POS_RA (4) diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index e352a18..e4e5fbb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -185,7 +185,7 @@ EXPORT_SYMBOL(il_scan_cancel_timeout); static void il_rx_reply_scan(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; @@ -216,7 +216,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; @@ -239,7 +239,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index cca467c..68c43b0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -681,7 +681,7 @@ void il_dealloc_bcast_stations(struct il_priv *il) } EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG static void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 0d3515d..5312059 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -507,7 +507,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) if (idx == TFD_CMD_SLOTS) len = IL_MAX_CMD_SIZE; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index ec9a93c..2d1f22a 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -68,7 +68,7 @@ #define DRV_DESCRIPTION \ "Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define VD "d" #else #define VD @@ -500,7 +500,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) fc = hdr->frame_control; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (ieee80211_is_auth(fc)) D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) @@ -783,7 +783,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); #endif @@ -795,7 +795,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; D_RX("beacon status %x retries %d iss %d " @@ -1410,7 +1410,7 @@ static void il3945_irq_tasklet(struct il_priv *il) u32 inta, handled = 0; u32 inta_fh; unsigned long flags; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u32 inta_mask; #endif @@ -1428,7 +1428,7 @@ static void il3945_irq_tasklet(struct il_priv *il) inta_fh = _il_rd(il, CSR_FH_INT_STATUS); _il_wr(il, CSR_FH_INT_STATUS, inta_fh); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); @@ -1463,7 +1463,7 @@ static void il3945_irq_tasklet(struct il_priv *il) return; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { @@ -1541,7 +1541,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (test_bit(STATUS_INT_ENABLED, &il->status)) il_enable_interrupts(il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { inta = _il_rd(il, CSR_INT); inta_mask = _il_rd(il, CSR_INT_MASK); @@ -1612,12 +1612,12 @@ static int il3945_get_channels_for_scan(struct il_priv *il, * hearing clear Rx packet).*/ if (IL_UCODE_API(il->ucode_ver) >= 2) { if (n_probes) - scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); } else { /* uCode v1 does not allow setting direct probe bits on * passive channel. */ if ((scan_ch->type & 1) && n_probes) - scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); } /* Set txpower levels to defaults */ @@ -1659,7 +1659,7 @@ static void il3945_init_hw_rates(struct il_priv *il, rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if (i > IWL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { + if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { /* * If CCK != 1M then set short preamble rate flag. */ @@ -1699,7 +1699,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); il_wr(il, HBUS_TARG_MEM_RADDR, - IWL39_RTC_INST_LOWER_BOUND); + IL39_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { @@ -1746,7 +1746,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ il_wr(il, HBUS_TARG_MEM_RADDR, - i + IWL39_RTC_INST_LOWER_BOUND); + i + IL39_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ @@ -1820,7 +1820,7 @@ static void il3945_nic_start(struct il_priv *il) _il_wr(il, CSR_RESET, 0); } -#define IWL3945_UCODE_GET(item) \ +#define IL3945_UCODE_GET(item) \ static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ { \ return le32_to_cpu(ucode->v1.item); \ @@ -1836,11 +1836,11 @@ static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) return (u8 *) ucode->v1.data; } -IWL3945_UCODE_GET(inst_size); -IWL3945_UCODE_GET(data_size); -IWL3945_UCODE_GET(init_size); -IWL3945_UCODE_GET(init_data_size); -IWL3945_UCODE_GET(boot_size); +IL3945_UCODE_GET(inst_size); +IL3945_UCODE_GET(data_size); +IL3945_UCODE_GET(init_size); +IL3945_UCODE_GET(init_data_size); +IL3945_UCODE_GET(boot_size); /** * il3945_read_ucode - Read uCode images from disk file. @@ -1967,34 +1967,34 @@ static int il3945_read_ucode(struct il_priv *il) } /* Verify that uCode images will fit in card's SRAM */ - if (inst_size > IWL39_MAX_INST_SIZE) { + if (inst_size > IL39_MAX_INST_SIZE) { D_INFO("uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } - if (data_size > IWL39_MAX_DATA_SIZE) { + if (data_size > IL39_MAX_DATA_SIZE) { D_INFO("uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } - if (init_size > IWL39_MAX_INST_SIZE) { + if (init_size > IL39_MAX_INST_SIZE) { D_INFO( "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } - if (init_data_size > IWL39_MAX_DATA_SIZE) { + if (init_data_size > IL39_MAX_DATA_SIZE) { D_INFO( "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } - if (boot_size > IWL39_MAX_BSM_SIZE) { + if (boot_size > IL39_MAX_BSM_SIZE) { D_INFO( "uCode boot instr len %d too large to fit in\n", boot_size); @@ -3118,7 +3118,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * *****************************************************************************/ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* * The following adds a new attribute to the sysfs representation @@ -3160,7 +3160,7 @@ static ssize_t il3945_store_debug_level(struct device *d, static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il3945_show_debug_level, il3945_store_debug_level); -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ static ssize_t il3945_show_temperature(struct device *d, struct device_attribute *attr, char *buf) @@ -3495,7 +3495,7 @@ static struct attribute *il3945_sysfs_entries[] = { &dev_attr_status.attr, &dev_attr_temperature.attr, &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG &dev_attr_debug_level.attr, #endif NULL @@ -3583,7 +3583,7 @@ err: return ret; } -#define IWL3945_MAX_PROBE_REQUEST 200 +#define IL3945_MAX_PROBE_REQUEST 200 static int il3945_setup_mac(struct il_priv *il) { @@ -3607,7 +3607,7 @@ static int il3945_setup_mac(struct il_priv *il) hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; /* we create the 802.11 header and a zero-length SSID element */ - hw->wiphy->max_scan_ie_len = IWL3945_MAX_PROBE_REQUEST - 24 - 2; + hw->wiphy->max_scan_ie_len = IL3945_MAX_PROBE_REQUEST - 24 - 2; /* Default value; 4 EDCA QOS priorities */ hw->queues = 4; @@ -3656,7 +3656,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il = hw->priv; SET_IEEE80211_DEV(hw, &pdev->dev); - il->cmd_queue = IWL39_CMD_QUEUE_NUM; + il->cmd_queue = IL39_CMD_QUEUE_NUM; /* 3945 has only one valid context */ il->valid_contexts = BIT(IL_RXON_CTX_BSS); @@ -3992,7 +3992,7 @@ static void __exit il3945_exit(void) il3945_rate_control_unregister(); } -MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX)); +MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); @@ -4002,7 +4002,7 @@ MODULE_PARM_DESC(swcrypto, module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 0f7d44c..ddf4200 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -72,7 +72,7 @@ */ #define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define VD "d" #else #define VD @@ -493,7 +493,7 @@ static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_packet *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (struct il4965_beacon_notif *)pkt->u.raw; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); D_RX("beacon status %x retries %d iss %d " @@ -778,7 +778,7 @@ static void il4965_irq_tasklet(struct il_priv *il) u32 inta_fh; unsigned long flags; u32 i; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u32 inta_mask; #endif @@ -796,7 +796,7 @@ static void il4965_irq_tasklet(struct il_priv *il) inta_fh = _il_rd(il, CSR_FH_INT_STATUS); _il_wr(il, CSR_FH_INT_STATUS, inta_fh); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); @@ -831,7 +831,7 @@ static void il4965_irq_tasklet(struct il_priv *il) return; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { @@ -946,7 +946,7 @@ static void il4965_irq_tasklet(struct il_priv *il) else if (handled & CSR_INT_BIT_RF_KILL) il_enable_rfkill_int(il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { inta = _il_rd(il, CSR_INT); inta_mask = _il_rd(il, CSR_INT_MASK); @@ -964,7 +964,7 @@ static void il4965_irq_tasklet(struct il_priv *il) * *****************************************************************************/ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* * The following adds a new attribute to the sysfs representation @@ -1007,7 +1007,7 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il4965_show_debug_level, il4965_store_debug_level); -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ static ssize_t il4965_show_temperature(struct device *d, @@ -1062,7 +1062,7 @@ static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, static struct attribute *il_sysfs_entries[] = { &dev_attr_temperature.attr, &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG &dev_attr_debug_level.attr, #endif NULL @@ -1607,7 +1607,7 @@ static const s8 default_queue_to_tx_fifo[] = { IL_TX_FIFO_VI, IL_TX_FIFO_BE, IL_TX_FIFO_BK, - IWL49_CMD_FIFO_NUM, + IL49_CMD_FIFO_NUM, IL_TX_FIFO_UNUSED, IL_TX_FIFO_UNUSED, }; @@ -1623,18 +1623,18 @@ static int il4965_alive_notify(struct il_priv *il) /* Clear 4965's internal Tx Scheduler data base */ il->scd_base_addr = il_rd_prph(il, - IWL49_SCD_SRAM_BASE_ADDR); - a = il->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; - for (; a < il->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) + IL49_SCD_SRAM_BASE_ADDR); + a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; + for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) + for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) il_write_targ_mem(il, a, 0); for (; a < il->scd_base_addr + - IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_wr_prph(il, IWL49_SCD_DRAM_BASE_ADDR, + il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ @@ -1650,32 +1650,32 @@ static int il4965_alive_notify(struct il_priv *il) reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - il_wr_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < il->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ il_write_targ_mem(il, il->scd_base_addr + - IWL49_SCD_CONTEXT_QUEUE_OFFSET(i), + IL49_SCD_CONTEXT_QUEUE_OFFSET(i), (SCD_WIN_SIZE << - IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ il_write_targ_mem(il, il->scd_base_addr + - IWL49_SCD_CONTEXT_QUEUE_OFFSET(i) + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + sizeof(u32), (SCD_FRAME_LIMIT << - IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & - IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - il_wr_prph(il, IWL49_SCD_INTERRUPT_MASK, + il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ @@ -2733,7 +2733,7 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { il_wr(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), index); } void il4965_tx_queue_set_status(struct il_priv *il, @@ -2746,12 +2746,12 @@ void il4965_tx_queue_set_status(struct il_priv *il, int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - il_wr_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | - (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | - (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | - (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | - IWL49_SCD_QUEUE_STTS_REG_MSK); + il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | + IL49_SCD_QUEUE_STTS_REG_MSK); txq->sched_retry = scd_retry; @@ -3195,7 +3195,7 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) */ void il4965_txq_set_sched(struct il_priv *il, u32 mask) { - il_wr_prph(il, IWL49_SCD_TXFACT, mask); + il_wr_prph(il, IL49_SCD_TXFACT, mask); } /***************************************************************************** @@ -3206,11 +3206,8 @@ void il4965_txq_set_sched(struct il_priv *il, u32 mask) /* Hardware specific file defines the PCI IDs table for that hardware module */ static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { -#if defined(CONFIG_IWL4965_MODULE) || defined(CONFIG_IWL4965) {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, -#endif /* CONFIG_IWL4965 */ - {0} }; MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); @@ -3258,7 +3255,7 @@ static void __exit il4965_exit(void) module_exit(il4965_exit); module_init(il4965_init); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -- cgit v0.10.2 From dcae1c641a4d7b7a00b1a566355ffaa517588aa6 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 14:36:21 +0200 Subject: iwlegacy: s/iwl_rx_packet/iwl_rx_pkt/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 78e81b6..98c74e0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -304,7 +304,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); @@ -398,7 +398,7 @@ static void il3945_accumulative_statistics(struct il_priv *il, void il3945_hw_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), @@ -413,7 +413,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, void il3945_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { @@ -459,7 +459,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); @@ -510,7 +510,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); @@ -1654,7 +1654,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int rc = 0; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il3945_rxon_assoc_cmd rxon_assoc; struct il_host_cmd cmd = { .id = REPLY_RXON_ASSOC, @@ -1683,7 +1683,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, if (rc) return rc; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 964d9bb..da4ea24 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -570,7 +570,7 @@ void il4965_rx_reply_rx(struct il_priv *il, { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_rx_phy_res *phy_res; __le32 rx_pkt_status; struct il_rx_mpdu_res_start *amsdu; @@ -688,7 +688,7 @@ void il4965_rx_reply_rx(struct il_priv *il, void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); il->_4965.last_phy_res_valid = true; memcpy(&il->_4965.last_phy_res, pkt->u.raw, sizeof(struct il_rx_phy_res)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 2181ec0..95b7b13 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -45,7 +45,7 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_missed_beacon_notif *missed_beacon; missed_beacon = &pkt->u.missed_beacon; @@ -155,7 +155,7 @@ void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { int change; - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX( "Statistics notification received (%d vs %d).\n", @@ -198,7 +198,7 @@ void il4965_rx_statistics(struct il_priv *il, void il4965_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 5f6a4ba..cbc6feb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -1248,7 +1248,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; struct il_tx_queue *txq = NULL; struct il_ht_agg *agg; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index f345171..4917b0d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1774,7 +1774,7 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); @@ -1877,7 +1877,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; u8 rate __maybe_unused = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 0b92c28..4427462 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -173,7 +173,7 @@ u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); bool il4965_good_plcp_health(struct il_priv *il, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); void il4965_reply_statistics(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 61acafb..d9873cb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -3360,7 +3360,7 @@ struct il_led_cmd { * *****************************************************************************/ -struct il_rx_packet { +struct il_rx_pkt { /* * The first 4 bytes of the RX frame header contain both the RX frame * size and some flags. diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 395918e..e9ca265 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -865,7 +865,7 @@ EXPORT_SYMBOL(il_chswitch_done); void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; @@ -1209,7 +1209,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); D_RX("sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); @@ -1220,7 +1220,7 @@ EXPORT_SYMBOL(il_rx_pm_sleep_notif); void il_rx_pm_debug_statistics_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; D_RADIO("Dumping %d bytes of unhandled " "notification for %s:\n", len, @@ -1232,7 +1232,7 @@ EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); void il_rx_reply_error(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 487cebf..f805ccf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -391,7 +391,7 @@ void il_tx_cmd_complete(struct il_priv *il, void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); void il_recover_from_statistics(struct il_priv *il, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb); @@ -472,7 +472,7 @@ int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt)); + struct il_rx_pkt *pkt)); int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 0aa4a12..4c7ccd5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -108,7 +108,7 @@ struct il_cmd_meta { */ void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ @@ -323,7 +323,7 @@ struct il_host_cmd { unsigned long reply_page; void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); u32 flags; u16 len; u8 id; diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 6ccd37f..e63777b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -92,7 +92,7 @@ EXPORT_SYMBOL(il_get_cmd_string); static void il_generic_cmd_callback(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt) + struct il_rx_pkt *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from %s (0x%08X)\n", @@ -255,7 +255,7 @@ int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt)) + struct il_rx_pkt *pkt)) { struct il_host_cmd cmd = { .id = id, diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index b2ec2a2..746b5a7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -213,7 +213,7 @@ EXPORT_SYMBOL(il_rx_queue_alloc); void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index e4e5fbb..96c90e7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -57,7 +57,7 @@ static int il_send_scan_abort(struct il_priv *il) { int ret; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_host_cmd cmd = { .id = REPLY_SCAN_ABORT_CMD, .flags = CMD_WANT_SKB, @@ -77,7 +77,7 @@ static int il_send_scan_abort(struct il_priv *il) if (ret) return ret; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->u.status != CAN_ABORT_STATUS) { /* The scan abort will return 1 for success or * 2 for "failure". A failure condition can be @@ -186,7 +186,7 @@ static void il_rx_reply_scan(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; @@ -198,7 +198,7 @@ static void il_rx_reply_scan(struct il_priv *il, static void il_rx_scan_start_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; il->scan_start_tsf = le32_to_cpu(notif->tsf_low); @@ -217,7 +217,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; @@ -240,7 +240,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 68c43b0..3c354a8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -59,7 +59,7 @@ static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) static int il_process_add_sta_resp(struct il_priv *il, struct il_addsta_cmd *addsta, - struct il_rx_packet *pkt, + struct il_rx_pkt *pkt, bool sync) { u8 sta_id = addsta->sta.sta_id; @@ -126,7 +126,7 @@ static int il_process_add_sta_resp(struct il_priv *il, static void il_add_sta_callback(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt) + struct il_rx_pkt *pkt) { struct il_addsta_cmd *addsta = (struct il_addsta_cmd *)cmd->cmd.payload; @@ -138,7 +138,7 @@ static void il_add_sta_callback(struct il_priv *il, int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) { - struct il_rx_packet *pkt = NULL; + struct il_rx_pkt *pkt = NULL; int ret = 0; u8 data[sizeof(*sta)]; struct il_host_cmd cmd = { @@ -165,7 +165,7 @@ int il_send_add_sta(struct il_priv *il, return ret; if (ret == 0) { - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; ret = il_process_add_sta_resp(il, sta, pkt, true); } il_free_pages(il, cmd.reply_page); @@ -414,7 +414,7 @@ static int il_send_remove_station(struct il_priv *il, const u8 *addr, int sta_id, bool temporary) { - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; int ret; unsigned long flags_spin; @@ -438,7 +438,7 @@ static int il_send_remove_station(struct il_priv *il, if (ret) return ret; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 5312059..0e900a4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -595,7 +595,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, void il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 2d1f22a..216c86f 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -671,7 +671,7 @@ static int il3945_get_measurement(struct il_priv *il, u8 type) { struct il_spectrum_cmd spectrum; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_host_cmd cmd = { .id = REPLY_SPECTRUM_MEASUREMENT_CMD, .data = (void *)&spectrum, @@ -716,7 +716,7 @@ static int il3945_get_measurement(struct il_priv *il, if (rc) return rc; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; @@ -747,7 +747,7 @@ static int il3945_get_measurement(struct il_priv *il, static void il3945_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; struct delayed_work *pwork; @@ -784,7 +784,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); #endif D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); @@ -793,7 +793,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, static void il3945_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); #ifdef CONFIG_IWLEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; @@ -816,7 +816,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, static void il3945_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; @@ -1202,7 +1202,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) static void il3945_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index ddf4200..d5f9180 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -430,7 +430,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, static void il4965_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; struct delayed_work *pwork; @@ -490,7 +490,7 @@ static void il4965_bg_statistics_periodic(unsigned long data) static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (struct il4965_beacon_notif *)pkt->u.raw; #ifdef CONFIG_IWLEGACY_DEBUG @@ -532,7 +532,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) static void il4965_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; @@ -634,7 +634,7 @@ static void il4965_setup_rx_handlers(struct il_priv *il) void il4965_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; -- cgit v0.10.2 From 7c2cde2ef278cb833581fe599c6654fc28b11a7e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 11:29:04 +0100 Subject: iwlegacy: partial rxon context cleanup Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 345beb7..0707301 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -342,7 +342,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i int i; D_INFO("enter\n"); - if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == il->ctx.bcast_sta_id) goto out; psta = (struct il3945_sta_priv *) sta->drv_priv; @@ -936,7 +936,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rcu_read_lock(); - sta = ieee80211_find_sta(il->contexts[IL_RXON_CTX_BSS].vif, + sta = ieee80211_find_sta(il->ctx.vif, il->stations[sta_id].sta.sta.addr); if (!sta) { D_RATE("Unable to find station to initialize rate scaling.\n"); @@ -953,7 +953,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) switch (il->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (il->contexts[IL_RXON_CTX_BSS].active.flags & + if (il->ctx.active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; rs_sta->expected_tpt = il3945_expected_tpt_g_prot; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 98c74e0..ff006e7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -253,7 +253,7 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) break; case IEEE80211_BAND_2GHZ: if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il, IL_RXON_CTX_BSS)) { + il_is_associated(il)) { if (rate == IL_RATE_11M_INDEX) next_rate = IL_RATE_5M_INDEX; } @@ -1374,7 +1374,7 @@ static int il3945_send_tx_power(struct il_priv *il) int rate_idx, i; const struct il_channel_info *ch_info = NULL; struct il3945_txpowertable_cmd txpower = { - .channel = il->contexts[IL_RXON_CTX_BSS].active.channel, + .channel = il->ctx.active.channel, }; u16 chan; @@ -1382,7 +1382,7 @@ static int il3945_send_tx_power(struct il_priv *il) "TX Power requested while scanning!\n")) return -EAGAIN; - chan = le16_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.channel); + chan = le16_to_cpu(il->ctx.active.channel); txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; ch_info = il_get_channel_info(il, il->band, chan); @@ -1734,9 +1734,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ if (!il_full_rxon_required(il, - &il->contexts[IL_RXON_CTX_BSS])) { + &il->ctx)) { rc = il_send_rxon_assoc(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); if (rc) { IL_ERR("Error setting RXON_ASSOC " "configuration (%d).\n", rc); @@ -1756,7 +1756,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (il_is_associated(il, IL_RXON_CTX_BSS) && new_assoc) { + if (il_is_associated(il) && new_assoc) { D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -1768,7 +1768,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) active_rxon->reserved5 = 0; rc = il_send_cmd_pdu(il, REPLY_RXON, sizeof(struct il3945_rxon_cmd), - &il->contexts[IL_RXON_CTX_BSS].active); + &il->ctx.active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ @@ -1779,9 +1779,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) return rc; } il_clear_ucode_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il_restore_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); } D_INFO("Sending RXON\n" @@ -1814,9 +1814,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) if (!new_assoc) { il_clear_ucode_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il_restore_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); } /* If we issue a new RXON command which required a tune then we must @@ -2252,7 +2252,7 @@ static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, static int il3945_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; int ret; u8 sta_id; unsigned long flags; @@ -2346,7 +2346,7 @@ int il3945_init_hw_rate_table(struct il_priv *il) * 1M CCK rates */ if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il, IL_RXON_CTX_BSS)) { + il_is_associated(il)) { index = IL_FIRST_CCK_RATE; for (i = IL_RATE_6M_INDEX_TABLE; @@ -2401,7 +2401,7 @@ int il3945_hw_set_hw_params(struct il_priv *il) il->hw_params.max_rxq_size = RX_QUEUE_SIZE; il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; il->hw_params.max_stations = IL3945_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL3945_BROADCAST_ID; + il->ctx.bcast_sta_id = IL3945_BROADCAST_ID; il->sta_key_max_num = STA_KEY_MAX_NUM; @@ -2422,7 +2422,7 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); tx_beacon_cmd->tx.sta_id = - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + il->ctx.bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; frame_size = il3945_fill_beacon_frame(il, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index c055a15..4c2b491 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -820,7 +820,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) unsigned long flags; struct statistics_rx_non_phy *rx_info; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (il->disable_chain_noise_cal) return; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index da4ea24..1182bc0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -782,7 +782,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) .flags = CMD_SIZE_HUGE, }; struct il_scan_cmd *scan; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; u32 rate_flags = 0; u16 cmd_len; u16 rx_chain = 0; @@ -866,7 +866,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; chan_mod = le32_to_cpu( - il->contexts[IL_RXON_CTX_BSS].active.flags & + il->ctx.active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index cbc6feb..94d77e2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -277,7 +277,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) struct il_device_cmd *out_cmd; struct il_cmd_meta *out_meta; struct il_tx_cmd *tx_cmd; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; int txq_id; dma_addr_t phys_addr; dma_addr_t txcmd_phys; @@ -1041,7 +1041,7 @@ int il4965_txq_check_empty(struct il_priv *il, struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; struct il_rxon_context *ctx; - ctx = &il->contexts[il->stations[sta_id].ctxid]; + ctx = &il->ctx; lockdep_assert_held(&il->sta_lock); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 4917b0d..457aa40 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -403,7 +403,7 @@ static int il4965_hw_set_hw_params(struct il_priv *il) sizeof(struct il4965_scd_bc_tbl); il->hw_params.tfd_size = sizeof(struct il_tfd); il->hw_params.max_stations = IL4965_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL4965_BROADCAST_ID; + il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; il->hw_params.max_bsm_size = BSM_SRAM_SIZE; @@ -1121,7 +1121,7 @@ static int il4965_send_tx_power(struct il_priv *il) u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) @@ -1333,7 +1333,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) static int il4965_hw_channel_switch(struct il_priv *il, struct ieee80211_channel_switch *ch_switch) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; int rc; u8 band = 0; bool is_ht40 = false; @@ -1726,7 +1726,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) start = IL_STA_ID; if (is_broadcast_ether_addr(addr)) - return il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + return il->ctx.bcast_sta_id; spin_lock_irqsave(&il->sta_lock, flags); for (i = start; i < il->hw_params.max_stations; i++) @@ -1911,7 +1911,7 @@ static struct il_hcmd_ops il4965_hcmd = { static void il4965_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; /* * Since setting the RXON may have been deferred while @@ -1923,7 +1923,7 @@ static void il4965_post_scan(struct il_priv *il) static void il4965_post_associate(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; struct ieee80211_conf *conf = NULL; int ret = 0; @@ -2000,7 +2000,7 @@ static void il4965_post_associate(struct il_priv *il) static void il4965_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; int ret = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index e9ca265..7afdd80 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -853,7 +853,7 @@ EXPORT_SYMBOL(il_set_rate); void il_chswitch_done(struct il_priv *il, bool is_success) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; @@ -868,7 +868,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct il_rxon_cmd *rxon = (void *)&ctx->active; if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) @@ -933,7 +933,7 @@ void il_irq_handle_error(struct il_priv *il) #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_FW_ERRORS) il_print_rx_config_cmd(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); #endif wake_up(&il->wait_command_queue); @@ -1110,7 +1110,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) int ret; s8 prev_tx_power; bool defer; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; lockdep_assert_held(&il->mutex); @@ -2069,7 +2069,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) int ret = 0; u16 ch; int scan_active = 0; - bool ht_changed[NUM_IL_RXON_CTX] = {}; + bool ht_changed = false; if (WARN_ON(!il->cfg->ops->legacy)) return -EOPNOTSUPP; @@ -2129,7 +2129,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) /* Configure HT40 channels */ if (ctx->ht.enabled != conf_is_ht(conf)) { ctx->ht.enabled = conf_is_ht(conf); - ht_changed[ctx->ctxid] = true; + ht_changed = true; } if (ctx->ht.enabled) { if (conf_is_ht40_minus(conf)) { @@ -2209,7 +2209,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) else D_INFO( "Not re-sending same RXON configuration.\n"); - if (ht_changed[ctx->ctxid]) + if (ht_changed) il_update_qos(il, ctx); } @@ -2225,8 +2225,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; unsigned long flags; - /* IBSS can only be the IL_RXON_CTX_BSS context */ - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (WARN_ON(!il->cfg->ops->legacy)) return; diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 736b00b..a4b1f37 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -601,7 +601,7 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, struct il_priv *il = file->private_data; struct il_rxon_context *ctx; int pos = 0, i; - char buf[256 * NUM_IL_RXON_CTX]; + char buf[256]; const size_t bufsz = sizeof(buf); for_each_context(il, ctx) { @@ -1064,7 +1064,7 @@ static ssize_t il_dbgfs_rxon_flags_read(struct file *file, char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.flags)); + le32_to_cpu(il->ctx.active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1077,7 +1077,7 @@ static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.filter_flags)); + le32_to_cpu(il->ctx.active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 4c7ccd5..d15dcbd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -899,12 +899,6 @@ struct il_force_reset { */ #define IL4965_EXT_BEACON_TIME_POS 22 -enum il_rxon_context_id { - IL_RXON_CTX_BSS, - - NUM_IL_RXON_CTX -}; - struct il_rxon_context { struct ieee80211_vif *vif; @@ -921,7 +915,7 @@ struct il_rxon_context { bool ht_need_multiple_chains; - enum il_rxon_context_id ctxid; + int ctxid; u32 interface_modes, exclusive_interface_modes; u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; @@ -1029,9 +1023,6 @@ struct il_priv { u32 hw_wa_rev; u8 rev_id; - /* microcode/device supports multiple contexts */ - u8 valid_contexts; - /* command queue number */ u8 cmd_queue; @@ -1055,7 +1046,7 @@ struct il_priv { u8 ucode_write_complete; /* the image write is complete */ char firmware_name[25]; - struct il_rxon_context contexts[NUM_IL_RXON_CTX]; + struct il_rxon_context ctx; __le16 switch_channel; @@ -1298,21 +1289,17 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif) return vif_priv->ctx; } -#define for_each_context(il, ctx) \ - for (ctx = &il->contexts[IL_RXON_CTX_BSS]; \ - ctx < &il->contexts[NUM_IL_RXON_CTX]; ctx++) \ - if (il->valid_contexts & BIT(ctx->ctxid)) +#define for_each_context(il, _ctx) \ + for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) -static inline int il_is_associated(struct il_priv *il, - enum il_rxon_context_id ctxid) +static inline int il_is_associated(struct il_priv *il) { - return (il->contexts[ctxid].active.filter_flags & - RXON_FILTER_ASSOC_MSK) ? 1 : 0; + return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } static inline int il_is_any_associated(struct il_priv *il) { - return il_is_associated(il, IL_RXON_CTX_BSS); + return il_is_associated(il); } static inline int il_is_associated_ctx(struct il_rxon_context *ctx) diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 746b5a7..2e7c87f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -241,7 +241,7 @@ int il_set_decrypted_flag(struct il_priv *il, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (il->contexts[IL_RXON_CTX_BSS].active.filter_flags & + if (il->ctx.active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 216c86f..dd8ce29 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -144,7 +144,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == il->ctx.bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; @@ -318,7 +318,7 @@ unsigned int il3945_fill_beacon_frame(struct il_priv *il, int left) { - if (!il_is_associated(il, IL_RXON_CTX_BSS) || !il->beacon_skb) + if (!il_is_associated(il) || !il->beacon_skb) return 0; if (il->beacon_skb->len > left) @@ -345,7 +345,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il) } rate = il_get_lowest_plcp(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); @@ -515,7 +515,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Find index into station table for destination station */ sta_id = il_sta_id_or_broadcast( - il, &il->contexts[IL_RXON_CTX_BSS], + il, &il->ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { D_DROP("Dropping - INVALID STATION: %pM\n", @@ -546,7 +546,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &il->contexts[IL_RXON_CTX_BSS]; + txq->txb[q->write_ptr].ctx = &il->ctx; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; @@ -681,9 +681,9 @@ static int il3945_get_measurement(struct il_priv *il, int rc; int spectrum_resp_status; int duration = le16_to_cpu(params->duration); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; - if (il_is_associated(il, IL_RXON_CTX_BSS)) + if (il_is_associated(il)) add_time = il_usecs_to_beacons(il, le64_to_cpu(params->start_time) - il->_3945.last_tsf, le16_to_cpu(ctx->timing.beacon_interval)); @@ -697,7 +697,7 @@ static int il3945_get_measurement(struct il_priv *il, cmd.len = sizeof(spectrum); spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - if (il_is_associated(il, IL_RXON_CTX_BSS)) + if (il_is_associated(il)) spectrum.start_time = il_add_beacon_time(il, il->_3945.last_beacon_time, add_time, @@ -2189,7 +2189,7 @@ static void il3945_alive_start(struct il_priv *il) { int thermal_spin = 0; u32 rfkill; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; D_INFO("Runtime Alive received.\n"); @@ -2243,7 +2243,7 @@ static void il3945_alive_start(struct il_priv *il) il_power_update_mode(il, true); - if (il_is_associated(il, IL_RXON_CTX_BSS)) { + if (il_is_associated(il)) { struct il3945_rxon_cmd *active_rxon = (struct il3945_rxon_cmd *)(&ctx->active); @@ -2372,7 +2372,7 @@ static void il3945_down(struct il_priv *il) static int il3945_alloc_bcast_station(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; unsigned long flags; u8 sta_id; @@ -2581,7 +2581,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (il_is_associated(il, IL_RXON_CTX_BSS)) { + if (il_is_associated(il)) { u16 interval; u32 extra; u32 suspend_time = 100; @@ -2634,7 +2634,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + scan->tx_cmd.sta_id = il->ctx.bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; /* flags + rate selection */ @@ -2692,7 +2692,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) void il3945_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; /* * Since setting the RXON may have been deferred while @@ -2750,7 +2750,7 @@ void il3945_post_associate(struct il_priv *il) { int rc = 0; struct ieee80211_conf *conf = NULL; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (!ctx->vif || !il->is_open) return; @@ -2917,7 +2917,7 @@ static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) void il3945_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; int rc = 0; @@ -2925,7 +2925,7 @@ void il3945_config_ap(struct il_priv *il) return; /* The following should be done only at AP bring up */ - if (!(il_is_associated(il, IL_RXON_CTX_BSS))) { + if (!(il_is_associated(il))) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -2986,11 +2986,11 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) return -EOPNOTSUPP; - static_key = !il_is_associated(il, IL_RXON_CTX_BSS); + static_key = !il_is_associated(il); if (!static_key) { sta_id = il_sta_id_or_broadcast( - il, &il->contexts[IL_RXON_CTX_BSS], sta); + il, &il->ctx, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; } @@ -3042,7 +3042,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, ret = il_add_station_common(il, - &il->contexts[IL_RXON_CTX_BSS], + &il->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { IL_ERR("Unable to add station %pM (%d)\n", @@ -3070,7 +3070,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -3205,7 +3205,7 @@ static ssize_t il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; return sprintf(buf, "0x%04X\n", ctx->active.flags); } @@ -3216,7 +3216,7 @@ static ssize_t il3945_store_flags(struct device *d, { struct il_priv *il = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; mutex_lock(&il->mutex); if (le32_to_cpu(ctx->staging.flags) != flags) { @@ -3241,7 +3241,7 @@ static ssize_t il3945_show_filter_flags(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); @@ -3252,7 +3252,7 @@ static ssize_t il3945_store_filter_flags(struct device *d, const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; u32 filter_flags = simple_strtoul(buf, NULL, 0); mutex_lock(&il->mutex); @@ -3313,7 +3313,7 @@ static ssize_t il3945_store_measurement(struct device *d, const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_measurement_params params = { .channel = le16_to_cpu(ctx->active.channel), .start_time = cpu_to_le64(il->_3945.last_tsf), @@ -3599,7 +3599,7 @@ static int il3945_setup_mac(struct il_priv *il) IEEE80211_HW_SPECTRUM_MGMT; hw->wiphy->interface_modes = - il->contexts[IL_RXON_CTX_BSS].interface_modes; + il->ctx.interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | @@ -3634,7 +3634,7 @@ static int il3945_setup_mac(struct il_priv *il) static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - int err = 0, i; + int err = 0; struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); @@ -3658,24 +3658,20 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->cmd_queue = IL39_CMD_QUEUE_NUM; - /* 3945 has only one valid context */ - il->valid_contexts = BIT(IL_RXON_CTX_BSS); + il->ctx.ctxid = 0; - for (i = 0; i < NUM_IL_RXON_CTX; i++) - il->contexts[i].ctxid = i; - - il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - il->contexts[IL_RXON_CTX_BSS].interface_modes = + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; /* * Disabling hardware scan means that mac80211 will perform scans @@ -3812,7 +3808,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il_set_rxon_channel(il, &il->bands[IEEE80211_BAND_2GHZ].channels[5], - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il3945_setup_deferred_work(il); il3945_setup_rx_handlers(il); il_power_initialize(il); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d5f9180..131d6e9 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1717,7 +1717,7 @@ static int il4965_alive_notify(struct il_priv *il) static void il4965_alive_start(struct il_priv *il) { int ret = 0; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; D_INFO("Runtime Alive received.\n"); @@ -2502,7 +2502,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel *channel = ch_switch->channel; struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; u16 ch; D_MAC80211("enter\n"); @@ -2786,7 +2786,7 @@ static int il4965_init_drv(struct il_priv *il) /* Choose which receivers/antennas to use */ if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il_init_scan_params(il); @@ -2859,7 +2859,7 @@ static const u8 il4965_bss_ac_to_queue[] = { static int il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - int err = 0, i; + int err = 0; struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); @@ -2878,36 +2878,26 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il = hw->priv; /* At this point both hw and il are allocated. */ - /* - * The default context is always valid, - * more may be discovered when firmware - * is loaded. - */ - il->valid_contexts = BIT(IL_RXON_CTX_BSS); - - for (i = 0; i < NUM_IL_RXON_CTX; i++) - il->contexts[i].ctxid = i; - - il->contexts[IL_RXON_CTX_BSS].always_active = true; - il->contexts[IL_RXON_CTX_BSS].is_active = true; - il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - il->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; - il->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; - il->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = + il->ctx.ctxid = 0; + + il->ctx.always_active = true; + il->ctx.is_active = true; + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; + il->ctx.ac_to_queue = il4965_bss_ac_to_queue; + il->ctx.exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); - il->contexts[IL_RXON_CTX_BSS].interface_modes = + il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION); - il->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; - il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; - - BUILD_BUG_ON(NUM_IL_RXON_CTX != 1); + il->ctx.ap_devtype = RXON_DEV_TYPE_AP; + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; SET_IEEE80211_DEV(hw, &pdev->dev); -- cgit v0.10.2 From b73bb5f13bb60735a846b73125e297ab6e3eece5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 14:37:54 +0200 Subject: iwlegacy: s/il_rx_mem_buffer/il_rx_buf/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index ff006e7..ad78d3f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -302,7 +302,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, * il3945_rx_reply_tx - Handle Tx response */ static void il3945_rx_reply_tx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -396,7 +396,7 @@ static void il3945_accumulative_statistics(struct il_priv *il, #endif void il3945_hw_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -411,7 +411,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, } void il3945_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; @@ -456,7 +456,7 @@ static int il3945_is_network_packet(struct il_priv *il, } static void il3945_pass_packet_to_mac80211(struct il_priv *il, - struct il_rx_mem_buffer *rxb, + struct il_rx_buf *rxb, struct ieee80211_rx_status *stats) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -506,7 +506,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) static void il3945_rx_reply_rx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 6c68f59..8a294ca 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -259,9 +259,9 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); extern void il3945_hw_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il3945_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); extern void il3945_post_associate(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 1182bc0..57fc190 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -230,7 +230,7 @@ void il4965_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; unsigned long flags; spin_lock_irqsave(&rxq->lock, flags); @@ -241,7 +241,7 @@ void il4965_rx_queue_restock(struct il_priv *il) /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ @@ -280,7 +280,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -329,7 +329,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -529,7 +529,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, u16 len, u32 ampdu_status, - struct il_rx_mem_buffer *rxb, + struct il_rx_buf *rxb, struct ieee80211_rx_status *stats) { struct sk_buff *skb; @@ -566,7 +566,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* Called for REPLY_RX (legacy ABG frames), or * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; @@ -686,7 +686,7 @@ void il4965_rx_reply_rx(struct il_priv *il, /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); il->_4965.last_phy_res_valid = true; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 95b7b13..9ccec09 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -42,7 +42,7 @@ #include "iwl-4965.h" void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -152,7 +152,7 @@ static void il4965_accumulative_statistics(struct il_priv *il, #define REG_RECALIB_PERIOD (60) void il4965_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { int change; struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -196,7 +196,7 @@ void il4965_rx_statistics(struct il_priv *il, } void il4965_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 94d77e2..dff48e8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -1246,7 +1246,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, * of frames sent via aggregation. */ void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 457aa40..5dd963e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1772,7 +1772,7 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response */ static void il4965_rx_reply_tx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -1875,7 +1875,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, } static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 4427462..b5b27f4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -100,9 +100,9 @@ void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il4965_rx_handle(struct il_priv *il); /* tx */ @@ -122,7 +122,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index); void il4965_hw_txq_ctx_free(struct il_priv *il); int il4965_txq_ctx_alloc(struct il_priv *il); @@ -171,13 +171,13 @@ u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); void il4965_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il4965_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); /* scan */ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 7afdd80..8feb2dd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -863,7 +863,7 @@ void il_chswitch_done(struct il_priv *il, bool is_success) } EXPORT_SYMBOL(il_chswitch_done); -void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) +void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); @@ -1206,7 +1206,7 @@ int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear) EXPORT_SYMBOL(il_send_statistics_request); void il_rx_pm_sleep_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1218,7 +1218,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, EXPORT_SYMBOL(il_rx_pm_sleep_notif); void il_rx_pm_debug_statistics_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; @@ -1230,7 +1230,7 @@ void il_rx_pm_debug_statistics_notif(struct il_priv *il, EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); void il_rx_reply_error(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index f805ccf..bc2ae06 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -370,11 +370,11 @@ static inline void il_update_stats(struct il_priv *il, bool is_tx, * RX handlers. * **************************************************/ void il_rx_pm_sleep_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il_rx_pm_debug_statistics_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il_rx_reply_error(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); /***************************************************** * RX @@ -386,14 +386,14 @@ void il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q); int il_rx_queue_space(const struct il_rx_queue *q); void il_tx_cmd_complete(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); /* Handlers */ void il_rx_spectrum_measure_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il_recover_from_statistics(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); -void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb); +void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb); /* TX helpers */ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index d15dcbd..ad72d39 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -85,7 +85,7 @@ struct il_tx_queue; #define DEFAULT_SHORT_RETRY_LIMIT 7U #define DEFAULT_LONG_RETRY_LIMIT 4U -struct il_rx_mem_buffer { +struct il_rx_buf { dma_addr_t page_dma; struct page *page; struct list_head list; @@ -346,13 +346,13 @@ struct il_host_cmd { * @rb_stts: driver's pointer to receive buffer status * @rb_stts_dma: bus address of receive buffer status * - * NOTE: rx_free and rx_used are used as a FIFO for il_rx_mem_buffers + * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs */ struct il_rx_queue { __le32 *bd; dma_addr_t bd_dma; - struct il_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; - struct il_rx_mem_buffer *queue[RX_QUEUE_SIZE]; + struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; + struct il_rx_buf *queue[RX_QUEUE_SIZE]; u32 read; u32 write; u32 free_count; @@ -968,7 +968,7 @@ struct il_priv { int alloc_rxb_page; void (*rx_handlers[REPLY_MAX])(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 2e7c87f..a6bee84 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -95,7 +95,7 @@ * are available, schedules il_rx_replenish * * -- enable interrupts -- - * ISR - il_rx() Detach il_rx_mem_buffers from pool up to the + * ISR - il_rx() Detach il_rx_bufs from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il_rx_queue_restock to refill any empty @@ -211,7 +211,7 @@ EXPORT_SYMBOL(il_rx_queue_alloc); void il_rx_spectrum_measure_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 96c90e7..dfc143107 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -183,7 +183,7 @@ EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to REPLY_SCAN_CMD (0x80) */ static void il_rx_reply_scan(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -196,7 +196,7 @@ static void il_rx_reply_scan(struct il_priv *il, /* Service SCAN_START_NOTIFICATION (0x82) */ static void il_rx_scan_start_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = @@ -214,7 +214,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ static void il_rx_scan_results_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -236,7 +236,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ static void il_rx_scan_complete_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 0e900a4..2e95b78 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -593,7 +593,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, * if the callback returns 1 */ void -il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) +il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index dd8ce29..446bdb5 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -745,7 +745,7 @@ static int il3945_get_measurement(struct il_priv *il, } static void il3945_rx_reply_alive(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -781,7 +781,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, } static void il3945_rx_reply_add_sta(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -791,7 +791,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, } static void il3945_rx_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); @@ -814,7 +814,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ static void il3945_rx_card_state_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); @@ -935,7 +935,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * are available, schedules il3945_rx_replenish * * -- enable interrupts -- - * ISR - il3945_rx() Detach il_rx_mem_buffers from pool up to the + * ISR - il3945_rx() Detach il_rx_bufs from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il3945_rx_queue_restock to refill any empty @@ -968,7 +968,7 @@ static void il3945_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; unsigned long flags; int write; @@ -977,7 +977,7 @@ static void il3945_rx_queue_restock(struct il_priv *il) while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ @@ -1016,7 +1016,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -1059,7 +1059,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -1201,7 +1201,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) */ static void il3945_rx_handle(struct il_priv *il) { - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 131d6e9..81613ed 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -428,7 +428,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, * ******************************************************************************/ static void il4965_rx_reply_alive(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -488,7 +488,7 @@ static void il4965_bg_statistics_periodic(unsigned long data) } static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = @@ -530,7 +530,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ static void il4965_rx_card_state_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); @@ -633,7 +633,7 @@ static void il4965_setup_rx_handlers(struct il_priv *il) */ void il4965_rx_handle(struct il_priv *il) { - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; -- cgit v0.10.2 From ebf0d90d12cf013019005a8ee7d1bc8599935356 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 15:43:47 +0200 Subject: iwlegacy: s/statistics/stats/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index 40e3a70..88b3d8f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -29,22 +29,22 @@ #include "iwl-3945-debugfs.h" -static int il3945_statistics_flag(struct il_priv *il, char *buf, int bufsz) +static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", - le32_to_cpu(il->_3945.statistics.flag)); - if (le32_to_cpu(il->_3945.statistics.flag) & + le32_to_cpu(il->_3945.stats.flag)); + if (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (le32_to_cpu(il->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATISTICS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (le32_to_cpu(il->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATISTICS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; @@ -57,14 +57,14 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 + - sizeof(struct iwl39_statistics_rx_non_phy) * 40 + 400; + int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + + sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; ssize_t ret; - struct iwl39_statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, + struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; - struct iwl39_statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct iwl39_statistics_rx_non_phy *general, *accum_general; - struct iwl39_statistics_rx_non_phy *delta_general, *max_general; + struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct iwl39_stats_rx_non_phy *general, *accum_general; + struct iwl39_stats_rx_non_phy *delta_general, *max_general; if (!il_is_alive(il)) return -EAGAIN; @@ -77,23 +77,23 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, /* * The statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - ofdm = &il->_3945.statistics.rx.ofdm; - cck = &il->_3945.statistics.rx.cck; - general = &il->_3945.statistics.rx.general; - accum_ofdm = &il->_3945.accum_statistics.rx.ofdm; - accum_cck = &il->_3945.accum_statistics.rx.cck; - accum_general = &il->_3945.accum_statistics.rx.general; - delta_ofdm = &il->_3945.delta_statistics.rx.ofdm; - delta_cck = &il->_3945.delta_statistics.rx.cck; - delta_general = &il->_3945.delta_statistics.rx.general; + ofdm = &il->_3945.stats.rx.ofdm; + cck = &il->_3945.stats.rx.cck; + general = &il->_3945.stats.rx.general; + accum_ofdm = &il->_3945.accum_stats.rx.ofdm; + accum_cck = &il->_3945.accum_stats.rx.cck; + accum_general = &il->_3945.accum_stats.rx.general; + delta_ofdm = &il->_3945.delta_stats.rx.ofdm; + delta_cck = &il->_3945.delta_stats.rx.cck; + delta_general = &il->_3945.delta_stats.rx.general; max_ofdm = &il->_3945.max_delta.rx.ofdm; max_cck = &il->_3945.max_delta.rx.cck; max_general = &il->_3945.max_delta.rx.general; - pos += il3945_statistics_flag(il, buf, bufsz); + pos += il3945_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Rx - OFDM:"); @@ -332,9 +332,9 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250; + int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250; ssize_t ret; - struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; + struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx; if (!il_is_alive(il)) return -EAGAIN; @@ -347,14 +347,14 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, /* * The statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - tx = &il->_3945.statistics.tx; - accum_tx = &il->_3945.accum_statistics.tx; - delta_tx = &il->_3945.delta_statistics.tx; + tx = &il->_3945.stats.tx; + accum_tx = &il->_3945.accum_stats.tx; + delta_tx = &il->_3945.delta_stats.tx; max_tx = &il->_3945.max_delta.tx; - pos += il3945_statistics_flag(il, buf, bufsz); + pos += il3945_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Tx:"); @@ -428,12 +428,12 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300; + int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300; ssize_t ret; - struct iwl39_statistics_general *general, *accum_general; - struct iwl39_statistics_general *delta_general, *max_general; - struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div; + struct iwl39_stats_general *general, *accum_general; + struct iwl39_stats_general *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div; if (!il_is_alive(il)) return -EAGAIN; @@ -446,22 +446,22 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, /* * The statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - general = &il->_3945.statistics.general; - dbg = &il->_3945.statistics.general.dbg; - div = &il->_3945.statistics.general.div; - accum_general = &il->_3945.accum_statistics.general; - delta_general = &il->_3945.delta_statistics.general; + general = &il->_3945.stats.general; + dbg = &il->_3945.stats.general.dbg; + div = &il->_3945.stats.general.div; + accum_general = &il->_3945.accum_stats.general; + delta_general = &il->_3945.delta_stats.general; max_general = &il->_3945.max_delta.general; - accum_dbg = &il->_3945.accum_statistics.general.dbg; - delta_dbg = &il->_3945.delta_statistics.general.dbg; + accum_dbg = &il->_3945.accum_stats.general.dbg; + delta_dbg = &il->_3945.delta_stats.general.dbg; max_dbg = &il->_3945.max_delta.general.dbg; - accum_div = &il->_3945.accum_statistics.general.div; - delta_div = &il->_3945.delta_statistics.general.div; + accum_div = &il->_3945.accum_stats.general.div; + delta_div = &il->_3945.delta_stats.general.div; max_div = &il->_3945.max_delta.general.div; - pos += il3945_statistics_flag(il, buf, bufsz); + pos += il3945_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_General:"); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 0707301..ebee6c3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -158,7 +158,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) /* * For each rate, if we have collected data on that rate * and it has been more than IL_RATE_WIN_FLUSH - * since we flushed, clear out the gathered statistics + * since we flushed, clear out the gathered stats */ for (i = 0; i < IL_RATE_COUNT_3945; i++) { if (!rs_sta->win[i].counter) diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index ad78d3f..fa4c33a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -362,7 +362,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, * *****************************************************************************/ #ifdef CONFIG_IWLEGACY_DEBUGFS -static void il3945_accumulative_statistics(struct il_priv *il, +static void il3945_accumulative_stats(struct il_priv *il, __le32 *stats) { int i; @@ -370,12 +370,12 @@ static void il3945_accumulative_statistics(struct il_priv *il, u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *)&il->_3945.statistics; - accum_stats = (u32 *)&il->_3945.accum_statistics; - delta = (u32 *)&il->_3945.delta_statistics; + prev_stats = (__le32 *)&il->_3945.stats; + accum_stats = (u32 *)&il->_3945.accum_stats; + delta = (u32 *)&il->_3945.delta_stats; max_delta = (u32 *)&il->_3945.max_delta; - for (i = sizeof(__le32); i < sizeof(struct il3945_notif_statistics); + for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); i += sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { @@ -387,30 +387,30 @@ static void il3945_accumulative_statistics(struct il_priv *il, } } - /* reset accumulative statistics for "no-counter" type statistics */ - il->_3945.accum_statistics.general.temperature = - il->_3945.statistics.general.temperature; - il->_3945.accum_statistics.general.ttl_timestamp = - il->_3945.statistics.general.ttl_timestamp; + /* reset accumulative stats for "no-counter" type stats */ + il->_3945.accum_stats.general.temperature = + il->_3945.stats.general.temperature; + il->_3945.accum_stats.general.ttl_timestamp = + il->_3945.stats.general.ttl_timestamp; } #endif -void il3945_hw_rx_statistics(struct il_priv *il, +void il3945_hw_rx_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX("Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il3945_notif_statistics), + (int)sizeof(struct il3945_notif_stats), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_statistics(il, (__le32 *)&pkt->u.raw); + il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); #endif - memcpy(&il->_3945.statistics, pkt->u.raw, sizeof(il->_3945.statistics)); + memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); } -void il3945_reply_statistics(struct il_priv *il, +void il3945_reply_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -418,16 +418,16 @@ void il3945_reply_statistics(struct il_priv *il, if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_3945.accum_statistics, 0, - sizeof(struct il3945_notif_statistics)); - memset(&il->_3945.delta_statistics, 0, - sizeof(struct il3945_notif_statistics)); + memset(&il->_3945.accum_stats, 0, + sizeof(struct il3945_notif_stats)); + memset(&il->_3945.delta_stats, 0, + sizeof(struct il3945_notif_stats)); memset(&il->_3945.max_delta, 0, - sizeof(struct il3945_notif_statistics)); + sizeof(struct il3945_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } - il3945_hw_rx_statistics(il, rxb); + il3945_hw_rx_stats(il, rxb); } @@ -437,7 +437,7 @@ void il3945_reply_statistics(struct il_priv *il, * ******************************************************************************/ -/* This is necessary only for a number of statistics, see the caller. */ +/* This is necessary only for a number of stats, see the caller. */ static int il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 8a294ca..967e733 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -60,7 +60,7 @@ extern const struct pci_device_id il3945_hw_card_ids[]; /* Default noise level to report when noise measurement is not available. * This may be because we're: - * 1) Not associated (4965, no beacon statistics being sent to driver) + * 1) Not associated (4965, no beacon stats being sent to driver) * 2) Scanning (noise measurement does not apply to associated channel) * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) * Use default noise value of -127 ... this is below the range of measurable @@ -258,9 +258,9 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id); extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hw_rx_statistics(struct il_priv *il, +extern void il3945_hw_rx_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il3945_reply_statistics(struct il_priv *il, +void il3945_reply_stats(struct il_priv *il, struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 4c2b491..bb3bc15 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -71,7 +71,7 @@ * INIT calibrations framework *****************************************************************************/ -struct statistics_general_data { +struct stats_general_data { u32 beacon_silence_rssi_a; u32 beacon_silence_rssi_b; u32 beacon_silence_rssi_c; @@ -106,7 +106,7 @@ void il4965_calib_free_results(struct il_priv *il) static int il4965_sens_energy_cck(struct il_priv *il, u32 norm_fa, u32 rx_enable_time, - struct statistics_general_data *rx_info) + struct stats_general_data *rx_info) { u32 max_nrg_cck = 0; int i = 0; @@ -509,10 +509,10 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) u32 norm_fa_ofdm; u32 norm_fa_cck; struct il_sensitivity_data *data = NULL; - struct statistics_rx_non_phy *rx_info; - struct statistics_rx_phy *ofdm, *cck; + struct stats_rx_non_phy *rx_info; + struct stats_rx_phy *ofdm, *cck; unsigned long flags; - struct statistics_general_data statis; + struct stats_general_data statis; if (il->disable_sens_cal) return; @@ -526,9 +526,9 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) spin_lock_irqsave(&il->lock, flags); - rx_info = &(((struct il_notif_statistics *)resp)->rx.general); - ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm); - cck = &(((struct il_notif_statistics *)resp)->rx.cck); + rx_info = &(((struct il_notif_stats *)resp)->rx.general); + ofdm = &(((struct il_notif_stats *)resp)->rx.ofdm); + cck = &(((struct il_notif_stats *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { D_CALIB("<< invalid data.\n"); @@ -565,9 +565,9 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) return; } - /* These statistics increase monotonically, and do not reset + /* These stats increase monotonically, and do not reset * at each beacon. Calculate difference from last value, or just - * use the new statistics value if it has reset or wrapped around. */ + * use the new stats value if it has reset or wrapped around. */ if (data->last_bad_plcp_cnt_cck > bad_plcp_cck) data->last_bad_plcp_cnt_cck = bad_plcp_cck; else { @@ -793,7 +793,7 @@ static void il4965_gain_computation(struct il_priv *il, /* - * Accumulate 16 beacons of signal and noise statistics for each of + * Accumulate 16 beacons of signal and noise stats for each of * 3 receivers/antennas/rx-chains, then figure out: * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. @@ -818,7 +818,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) u8 rxon_band24; u8 stat_band24; unsigned long flags; - struct statistics_rx_non_phy *rx_info; + struct stats_rx_non_phy *rx_info; struct il_rxon_context *ctx = &il->ctx; @@ -839,7 +839,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) spin_lock_irqsave(&il->lock, flags); - rx_info = &(((struct il_notif_statistics *)stat_resp)-> + rx_info = &(((struct il_notif_stats *)stat_resp)-> rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { @@ -851,10 +851,10 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); rxon_chnum = le16_to_cpu(ctx->staging.channel); - stat_band24 = !!(((struct il_notif_statistics *) + stat_band24 = !!(((struct il_notif_stats *) stat_resp)->flag & STATISTICS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct il_notif_statistics *) + stat_chnum = le32_to_cpu(((struct il_notif_stats *) stat_resp)->flag) >> 16; /* Make sure we accumulate data for just the associated channel @@ -867,7 +867,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) } /* - * Accumulate beacon statistics values across + * Accumulate beacon stats values across * "chain_noise_num_beacons" */ chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & @@ -960,7 +960,7 @@ void il4965_reset_run_time_calib(struct il_priv *il) il->chain_noise_data.delta_gain_code[i] = CHAIN_NOISE_DELTA_GAIN_INIT_VAL; - /* Ask for statistics now, the uCode will send notification + /* Ask for stats now, the uCode will send notification * periodically after association */ - il_send_statistics_request(il, CMD_ASYNC, true); + il_send_stats_request(il, CMD_ASYNC, true); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index ebb71a6..89e5828 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -33,12 +33,12 @@ static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = "%-32s current cumulative delta max\n"; -static int il4965_statistics_flag(struct il_priv *il, char *buf, int bufsz) +static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; u32 flag; - flag = le32_to_cpu(il->_4965.statistics.flag); + flag = le32_to_cpu(il->_4965.stats.flag); p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); if (flag & UCODE_STATISTICS_CLEAR_MSK) @@ -60,15 +60,15 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct statistics_rx_phy) * 40 + - sizeof(struct statistics_rx_non_phy) * 40 + - sizeof(struct statistics_rx_ht_phy) * 40 + 400; + int bufsz = sizeof(struct stats_rx_phy) * 40 + + sizeof(struct stats_rx_non_phy) * 40 + + sizeof(struct stats_rx_ht_phy) * 40 + 400; ssize_t ret; - struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; - struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct statistics_rx_non_phy *general, *accum_general; - struct statistics_rx_non_phy *delta_general, *max_general; - struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; + struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; + struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct stats_rx_non_phy *general, *accum_general; + struct stats_rx_non_phy *delta_general, *max_general; + struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; if (!il_is_alive(il)) return -EAGAIN; @@ -81,27 +81,27 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, /* * the statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - ofdm = &il->_4965.statistics.rx.ofdm; - cck = &il->_4965.statistics.rx.cck; - general = &il->_4965.statistics.rx.general; - ht = &il->_4965.statistics.rx.ofdm_ht; - accum_ofdm = &il->_4965.accum_statistics.rx.ofdm; - accum_cck = &il->_4965.accum_statistics.rx.cck; - accum_general = &il->_4965.accum_statistics.rx.general; - accum_ht = &il->_4965.accum_statistics.rx.ofdm_ht; - delta_ofdm = &il->_4965.delta_statistics.rx.ofdm; - delta_cck = &il->_4965.delta_statistics.rx.cck; - delta_general = &il->_4965.delta_statistics.rx.general; - delta_ht = &il->_4965.delta_statistics.rx.ofdm_ht; + ofdm = &il->_4965.stats.rx.ofdm; + cck = &il->_4965.stats.rx.cck; + general = &il->_4965.stats.rx.general; + ht = &il->_4965.stats.rx.ofdm_ht; + accum_ofdm = &il->_4965.accum_stats.rx.ofdm; + accum_cck = &il->_4965.accum_stats.rx.cck; + accum_general = &il->_4965.accum_stats.rx.general; + accum_ht = &il->_4965.accum_stats.rx.ofdm_ht; + delta_ofdm = &il->_4965.delta_stats.rx.ofdm; + delta_cck = &il->_4965.delta_stats.rx.cck; + delta_general = &il->_4965.delta_stats.rx.general; + delta_ht = &il->_4965.delta_stats.rx.ofdm_ht; max_ofdm = &il->_4965.max_delta.rx.ofdm; max_cck = &il->_4965.max_delta.rx.cck; max_general = &il->_4965.max_delta.rx.general; max_ht = &il->_4965.max_delta.rx.ofdm_ht; - pos += il4965_statistics_flag(il, buf, bufsz); + pos += il4965_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Rx - OFDM:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -492,9 +492,9 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = (sizeof(struct statistics_tx) * 48) + 250; + int bufsz = (sizeof(struct stats_tx) * 48) + 250; ssize_t ret; - struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; + struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx; if (!il_is_alive(il)) return -EAGAIN; @@ -506,15 +506,15 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, } /* the statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - tx = &il->_4965.statistics.tx; - accum_tx = &il->_4965.accum_statistics.tx; - delta_tx = &il->_4965.delta_statistics.tx; + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta_tx = &il->_4965.delta_stats.tx; max_tx = &il->_4965.max_delta.tx; - pos += il4965_statistics_flag(il, buf, bufsz); + pos += il4965_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -667,12 +667,12 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct statistics_general) * 10 + 300; + int bufsz = sizeof(struct stats_general) * 10 + 300; ssize_t ret; - struct statistics_general_common *general, *accum_general; - struct statistics_general_common *delta_general, *max_general; - struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct statistics_div *div, *accum_div, *delta_div, *max_div; + struct stats_general_common *general, *accum_general; + struct stats_general_common *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct stats_div *div, *accum_div, *delta_div, *max_div; if (!il_is_alive(il)) return -EAGAIN; @@ -684,23 +684,23 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, } /* the statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - general = &il->_4965.statistics.general.common; - dbg = &il->_4965.statistics.general.common.dbg; - div = &il->_4965.statistics.general.common.div; - accum_general = &il->_4965.accum_statistics.general.common; - accum_dbg = &il->_4965.accum_statistics.general.common.dbg; - accum_div = &il->_4965.accum_statistics.general.common.div; - delta_general = &il->_4965.delta_statistics.general.common; + general = &il->_4965.stats.general.common; + dbg = &il->_4965.stats.general.common.dbg; + div = &il->_4965.stats.general.common.div; + accum_general = &il->_4965.accum_stats.general.common; + accum_dbg = &il->_4965.accum_stats.general.common.dbg; + accum_div = &il->_4965.accum_stats.general.common.div; + delta_general = &il->_4965.delta_stats.general.common; max_general = &il->_4965.max_delta.general.common; - delta_dbg = &il->_4965.delta_statistics.general.common.dbg; + delta_dbg = &il->_4965.delta_stats.general.common.dbg; max_dbg = &il->_4965.max_delta.general.common.dbg; - delta_div = &il->_4965.delta_statistics.general.common.div; + delta_div = &il->_4965.delta_stats.general.common.div; max_div = &il->_4965.max_delta.general.common.div; - pos += il4965_statistics_flag(il, buf, bufsz); + pos += il4965_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_General:"); pos += scnprintf(buf + pos, bufsz - pos, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index ecebc69..21ff694 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -119,7 +119,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * uCode provides all 4 values to the driver via the "initialize alive" * notification (see struct il4965_init_alive_resp). After the runtime uCode - * image loads, uCode updates the R4 value via statistics notifications + * image loads, uCode updates the R4 value via stats notifications * (see STATISTICS_NOTIFICATION), which occur after each received beacon * when associated, or can be requested via REPLY_STATISTICS_CMD. * @@ -159,7 +159,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * 1) EEPROM * 2) "initialize" alive notification - * 3) statistics notifications + * 3) stats notifications * * EEPROM data consists of: * diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 9c8cc32..e99a20c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -242,7 +242,7 @@ static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) } /* - * removes the old data from the statistics. All data that is older than + * removes the old data from the stats. All data that is older than * TID_MAX_TIME_DIFF, will be deleted. */ static void @@ -991,7 +991,7 @@ done: * Begin a period of staying with a selected modulation mode. * Set "stay_in_tbl" flag to prevent any mode switches. * Set frame tx success limits according to legacy vs. high-throughput, - * and reset overall (spanning all rates) tx success history statistics. + * and reset overall (spanning all rates) tx success history stats. * These control how long we stay using same modulation mode before * searching for a new mode. */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 9ccec09..b322957 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -67,13 +67,13 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, * exactly when to expect beacons, therefore only when we're associated. */ static void il4965_rx_calc_noise(struct il_priv *il) { - struct statistics_rx_non_phy *rx_info; + struct stats_rx_non_phy *rx_info; int num_active_rx = 0; int total_silence = 0; int bcn_silence_a, bcn_silence_b, bcn_silence_c; int last_rx_noise; - rx_info = &(il->_4965.statistics.rx.general); + rx_info = &(il->_4965.stats.rx.general); bcn_silence_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; bcn_silence_b = @@ -107,28 +107,28 @@ static void il4965_rx_calc_noise(struct il_priv *il) #ifdef CONFIG_IWLEGACY_DEBUGFS /* - * based on the assumption of all statistics counter are in DWORD + * based on the assumption of all stats counter are in DWORD * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void il4965_accumulative_statistics(struct il_priv *il, +static void il4965_accumulative_stats(struct il_priv *il, __le32 *stats) { int i, size; __le32 *prev_stats; u32 *accum_stats; u32 *delta, *max_delta; - struct statistics_general_common *general, *accum_general; - struct statistics_tx *tx, *accum_tx; - - prev_stats = (__le32 *)&il->_4965.statistics; - accum_stats = (u32 *)&il->_4965.accum_statistics; - size = sizeof(struct il_notif_statistics); - general = &il->_4965.statistics.general.common; - accum_general = &il->_4965.accum_statistics.general.common; - tx = &il->_4965.statistics.tx; - accum_tx = &il->_4965.accum_statistics.tx; - delta = (u32 *)&il->_4965.delta_statistics; + struct stats_general_common *general, *accum_general; + struct stats_tx *tx, *accum_tx; + + prev_stats = (__le32 *)&il->_4965.stats; + accum_stats = (u32 *)&il->_4965.accum_stats; + size = sizeof(struct il_notif_stats); + general = &il->_4965.stats.general.common; + accum_general = &il->_4965.accum_stats.general.common; + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta = (u32 *)&il->_4965.delta_stats; max_delta = (u32 *)&il->_4965.max_delta; for (i = sizeof(__le32); i < size; @@ -143,7 +143,7 @@ static void il4965_accumulative_statistics(struct il_priv *il, } } - /* reset accumulative statistics for "no-counter" type statistics */ + /* reset accumulative stats for "no-counter" type stats */ accum_general->temperature = general->temperature; accum_general->ttl_timestamp = general->ttl_timestamp; } @@ -151,7 +151,7 @@ static void il4965_accumulative_statistics(struct il_priv *il, #define REG_RECALIB_PERIOD (60) -void il4965_rx_statistics(struct il_priv *il, +void il4965_rx_stats(struct il_priv *il, struct il_rx_buf *rxb) { int change; @@ -159,31 +159,31 @@ void il4965_rx_statistics(struct il_priv *il, D_RX( "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il_notif_statistics), + (int)sizeof(struct il_notif_stats), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); - change = ((il->_4965.statistics.general.common.temperature != + change = ((il->_4965.stats.general.common.temperature != pkt->u.stats.general.common.temperature) || - ((il->_4965.statistics.flag & + ((il->_4965.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_statistics(il, (__le32 *)&pkt->u.stats); + il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); #endif - /* TODO: reading some of statistics is unneeded */ - memcpy(&il->_4965.statistics, &pkt->u.stats, - sizeof(il->_4965.statistics)); + /* TODO: reading some of stats is unneeded */ + memcpy(&il->_4965.stats, &pkt->u.stats, + sizeof(il->_4965.stats)); set_bit(STATUS_STATISTICS, &il->status); - /* Reschedule the statistics timer to occur in + /* Reschedule the stats timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a * thermal update even if the uCode doesn't give * us one */ - mod_timer(&il->statistics_periodic, jiffies + + mod_timer(&il->stats_periodic, jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && @@ -195,21 +195,21 @@ void il4965_rx_statistics(struct il_priv *il, il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_reply_statistics(struct il_priv *il, +void il4965_reply_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_4965.accum_statistics, 0, - sizeof(struct il_notif_statistics)); - memset(&il->_4965.delta_statistics, 0, - sizeof(struct il_notif_statistics)); + memset(&il->_4965.accum_stats, 0, + sizeof(struct il_notif_stats)); + memset(&il->_4965.delta_stats, 0, + sizeof(struct il_notif_stats)); memset(&il->_4965.max_delta, 0, - sizeof(struct il_notif_statistics)); + sizeof(struct il_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } - il4965_rx_statistics(il, rxb); + il4965_rx_stats(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 5dd963e..9cfc140 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1436,9 +1436,9 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, /** * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) - * @statistics: Provides the temperature reading from the uCode + * @stats: Provides the temperature reading from the uCode * - * A return of <0 indicates bogus data in the statistics + * A return of <0 indicates bogus data in the stats */ static int il4965_hw_get_temperature(struct il_priv *il) { @@ -1448,7 +1448,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) u32 R4; if (test_bit(STATUS_TEMPERATURE, &il->status) && - (il->_4965.statistics.flag & + (il->_4965.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); @@ -1466,14 +1466,14 @@ static int il4965_hw_get_temperature(struct il_priv *il) /* * Temperature is only 23 bits, so sign extend out to 32. * - * NOTE If we haven't received a statistics notification yet + * NOTE If we haven't received a stats notification yet * with an updated temperature, use R4 provided to us in the * "initialize" ALIVE response. */ if (!test_bit(STATUS_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else - vt = sign_extend32(le32_to_cpu(il->_4965.statistics. + vt = sign_extend32(le32_to_cpu(il->_4965.stats. general.common.temperature), 23); D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); @@ -1512,7 +1512,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) int temp_diff; if (!test_bit(STATUS_STATISTICS, &il->status)) { - D_TEMP("Temperature not updated -- no statistics.\n"); + D_TEMP("Temperature not updated -- no stats.\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index b5b27f4..a75b62c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -174,9 +174,9 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_buf *rxb); bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); -void il4965_rx_statistics(struct il_priv *il, +void il4965_rx_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il4965_reply_statistics(struct il_priv *il, +void il4965_reply_stats(struct il_priv *il, struct il_rx_buf *rxb); /* scan */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index d9873cb..ea6c0f5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -2016,7 +2016,7 @@ struct il_link_qual_agg_params { * good performance; higher rate is sure to have poorer success. * * 6) Re-evaluate the rate after each tx frame. If working with block- - * acknowledge, history and statistics may be calculated for the entire + * acknowledge, history and stats may be calculated for the entire * block (including prior history that fits within the history windows), * before re-evaluation. * @@ -2637,7 +2637,7 @@ struct il_scanresults_notification { u8 num_probe_not_sent; /* not enough time to send */ __le32 tsf_low; __le32 tsf_high; - __le32 statistics[NUMBER_OF_STATISTICS]; + __le32 stats[NUMBER_OF_STATISTICS]; } __packed; /* @@ -2727,9 +2727,9 @@ struct rate_histogram { } failed; } __packed; -/* statistics command response */ +/* stats command response */ -struct iwl39_statistics_rx_phy { +struct iwl39_stats_rx_phy { __le32 ina_cnt; __le32 fina_cnt; __le32 plcp_err; @@ -2747,7 +2747,7 @@ struct iwl39_statistics_rx_phy { __le32 sent_cts_cnt; } __packed; -struct iwl39_statistics_rx_non_phy { +struct iwl39_stats_rx_non_phy { __le32 bogus_cts; /* CTS received when not expecting CTS */ __le32 bogus_ack; /* ACK received when not expecting ACK */ __le32 non_bssid_frames; /* number of frames with BSSID that @@ -2758,13 +2758,13 @@ struct iwl39_statistics_rx_non_phy { * our serving channel */ } __packed; -struct iwl39_statistics_rx { - struct iwl39_statistics_rx_phy ofdm; - struct iwl39_statistics_rx_phy cck; - struct iwl39_statistics_rx_non_phy general; +struct iwl39_stats_rx { + struct iwl39_stats_rx_phy ofdm; + struct iwl39_stats_rx_phy cck; + struct iwl39_stats_rx_non_phy general; } __packed; -struct iwl39_statistics_tx { +struct iwl39_stats_tx { __le32 preamble_cnt; __le32 rx_detected_cnt; __le32 bt_prio_defer_cnt; @@ -2776,31 +2776,31 @@ struct iwl39_statistics_tx { __le32 actual_ack_cnt; } __packed; -struct statistics_dbg { +struct stats_dbg { __le32 burst_check; __le32 burst_count; __le32 wait_for_silence_timeout_cnt; __le32 reserved[3]; } __packed; -struct iwl39_statistics_div { +struct iwl39_stats_div { __le32 tx_on_a; __le32 tx_on_b; __le32 exec_time; __le32 probe_time; } __packed; -struct iwl39_statistics_general { +struct iwl39_stats_general { __le32 temperature; - struct statistics_dbg dbg; + struct stats_dbg dbg; __le32 sleep_time; __le32 slots_out; __le32 slots_idle; __le32 ttl_timestamp; - struct iwl39_statistics_div div; + struct iwl39_stats_div div; } __packed; -struct statistics_rx_phy { +struct stats_rx_phy { __le32 ina_cnt; __le32 fina_cnt; __le32 plcp_err; @@ -2823,7 +2823,7 @@ struct statistics_rx_phy { __le32 reserved3; } __packed; -struct statistics_rx_ht_phy { +struct stats_rx_ht_phy { __le32 plcp_err; __le32 overrun_err; __le32 early_overrun_err; @@ -2838,7 +2838,7 @@ struct statistics_rx_ht_phy { #define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1) -struct statistics_rx_non_phy { +struct stats_rx_non_phy { __le32 bogus_cts; /* CTS received when not expecting CTS */ __le32 bogus_ack; /* ACK received when not expecting ACK */ __le32 non_bssid_frames; /* number of frames with BSSID that @@ -2871,28 +2871,28 @@ struct statistics_rx_non_phy { __le32 beacon_energy_c; } __packed; -struct statistics_rx { - struct statistics_rx_phy ofdm; - struct statistics_rx_phy cck; - struct statistics_rx_non_phy general; - struct statistics_rx_ht_phy ofdm_ht; +struct stats_rx { + struct stats_rx_phy ofdm; + struct stats_rx_phy cck; + struct stats_rx_non_phy general; + struct stats_rx_ht_phy ofdm_ht; } __packed; /** - * struct statistics_tx_power - current tx power + * struct stats_tx_power - current tx power * * @ant_a: current tx power on chain a in 1/2 dB step * @ant_b: current tx power on chain b in 1/2 dB step * @ant_c: current tx power on chain c in 1/2 dB step */ -struct statistics_tx_power { +struct stats_tx_power { u8 ant_a; u8 ant_b; u8 ant_c; u8 reserved; } __packed; -struct statistics_tx_non_phy_agg { +struct stats_tx_non_phy_agg { __le32 ba_timeout; __le32 ba_reschedule_frames; __le32 scd_query_agg_frame_cnt; @@ -2905,7 +2905,7 @@ struct statistics_tx_non_phy_agg { __le32 rx_ba_rsp_cnt; } __packed; -struct statistics_tx { +struct stats_tx { __le32 preamble_cnt; __le32 rx_detected_cnt; __le32 bt_prio_defer_cnt; @@ -2920,13 +2920,13 @@ struct statistics_tx { __le32 burst_abort_missing_next_frame_cnt; __le32 cts_timeout_collision; __le32 ack_or_ba_timeout_collision; - struct statistics_tx_non_phy_agg agg; + struct stats_tx_non_phy_agg agg; __le32 reserved1; } __packed; -struct statistics_div { +struct stats_div { __le32 tx_on_a; __le32 tx_on_b; __le32 exec_time; @@ -2935,14 +2935,14 @@ struct statistics_div { __le32 reserved2; } __packed; -struct statistics_general_common { +struct stats_general_common { __le32 temperature; /* radio temperature */ - struct statistics_dbg dbg; + struct stats_dbg dbg; __le32 sleep_time; __le32 slots_out; __le32 slots_idle; __le32 ttl_timestamp; - struct statistics_div div; + struct stats_div div; __le32 rx_enable_counter; /* * num_of_sos_states: @@ -2952,8 +2952,8 @@ struct statistics_general_common { __le32 num_of_sos_states; } __packed; -struct statistics_general { - struct statistics_general_common common; +struct stats_general { + struct stats_general_common common; __le32 reserved2; __le32 reserved3; } __packed; @@ -2966,11 +2966,11 @@ struct statistics_general { * REPLY_STATISTICS_CMD = 0x9c, * all devices identical. * - * This command triggers an immediate response containing uCode statistics. + * This command triggers an immediate response containing uCode stats. * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below. * * If the CLEAR_STATS configuration flag is set, uCode will clear its - * internal copy of the statistics (counters) after issuing the response. + * internal copy of the stats (counters) after issuing the response. * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below). * * If the DISABLE_NOTIF configuration flag is set, uCode will not issue @@ -2979,7 +2979,7 @@ struct statistics_general { */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ #define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ -struct il_statistics_cmd { +struct il_stats_cmd { __le32 configuration_flags; /* IL_STATS_CONF_* */ } __packed; @@ -2994,25 +2994,25 @@ struct il_statistics_cmd { * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD * 0x9c with CLEAR_STATS bit set (see above). * - * uCode also issues this notification during scans. uCode clears statistics - * appropriately so that each notification contains statistics for only the + * uCode also issues this notification during scans. uCode clears stats + * appropriately so that each notification contains stats for only the * one channel that has just been scanned. */ #define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) #define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) -struct il3945_notif_statistics { +struct il3945_notif_stats { __le32 flag; - struct iwl39_statistics_rx rx; - struct iwl39_statistics_tx tx; - struct iwl39_statistics_general general; + struct iwl39_stats_rx rx; + struct iwl39_stats_tx tx; + struct iwl39_stats_general general; } __packed; -struct il_notif_statistics { +struct il_notif_stats { __le32 flag; - struct statistics_rx rx; - struct statistics_tx tx; - struct statistics_general general; + struct stats_rx rx; + struct stats_tx tx; + struct stats_general general; } __packed; /* @@ -3078,10 +3078,10 @@ struct il_missed_beacon_notif { * * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each * received beacon. These provide information to the driver to analyze the - * sensitivity. Don't analyze statistics that come in from scanning, or any - * other non-associated-network source. Pertinent statistics include: + * sensitivity. Don't analyze stats that come in from scanning, or any + * other non-associated-network source. Pertinent stats include: * - * From "general" statistics (struct statistics_rx_non_phy): + * From "general" stats (struct stats_rx_non_phy): * * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level) * Measure of energy of desired signal. Used for establishing a level @@ -3094,7 +3094,7 @@ struct il_missed_beacon_notif { * uSecs of actual Rx time during beacon period (varies according to * how much time was spent transmitting). * - * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately: + * From "cck" and "ofdm" stats (struct stats_rx_phy), separately: * * false_alarm_cnt * Signal locks abandoned early (before phy-level header). @@ -3255,8 +3255,8 @@ struct il_sensitivity_cmd { * This command sets the relative gains of 4965 device's 3 radio receiver chains. * * After the first association, driver should accumulate signal and noise - * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20 - * beacons from the associated network (don't collect statistics that come + * stats from the STATISTICS_NOTIFICATIONs that follow the first 20 + * beacons from the associated network (don't collect stats that come * in from scanning, or any other non-network source). * * DISCONNECTED ANTENNA: @@ -3264,7 +3264,7 @@ struct il_sensitivity_cmd { * Driver should determine which antennas are actually connected, by comparing * average beacon signal levels for the 3 Rx chains. Accumulate (add) the * following values over 20 beacons, one accumulator for each of the chains - * a/b/c, from struct statistics_rx_non_phy: + * a/b/c, from struct stats_rx_non_phy: * * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB) * @@ -3283,7 +3283,7 @@ struct il_sensitivity_cmd { * to antennas, see above) for gain, by comparing the average signal levels * detected during the silence after each beacon (background noise). * Accumulate (add) the following values over 20 beacons, one accumulator for - * each of the chains a/b/c, from struct statistics_rx_non_phy: + * each of the chains a/b/c, from struct stats_rx_non_phy: * * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB) * @@ -3387,7 +3387,7 @@ struct il_rx_pkt { struct il_rem_sta_resp rem_sta; struct il_sleep_notification sleep_notif; struct il_spectrum_resp spectrum; - struct il_notif_statistics stats; + struct il_notif_stats stats; struct il_compressed_ba_resp compressed_ba; struct il_missed_beacon_notif missed_beacon; __le32 status; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 8feb2dd..475bcac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1187,23 +1187,23 @@ void il_send_bt_config(struct il_priv *il) } EXPORT_SYMBOL(il_send_bt_config); -int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear) +int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) { - struct il_statistics_cmd statistics_cmd = { + struct il_stats_cmd stats_cmd = { .configuration_flags = clear ? IL_STATS_CONF_CLEAR_STATS : 0, }; if (flags & CMD_ASYNC) return il_send_cmd_pdu_async(il, REPLY_STATISTICS_CMD, - sizeof(struct il_statistics_cmd), - &statistics_cmd, NULL); + sizeof(struct il_stats_cmd), + &stats_cmd, NULL); else return il_send_cmd_pdu(il, REPLY_STATISTICS_CMD, - sizeof(struct il_statistics_cmd), - &statistics_cmd); + sizeof(struct il_stats_cmd), + &stats_cmd); } -EXPORT_SYMBOL(il_send_statistics_request); +EXPORT_SYMBOL(il_send_stats_request); void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_buf *rxb) @@ -1217,7 +1217,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, } EXPORT_SYMBOL(il_rx_pm_sleep_notif); -void il_rx_pm_debug_statistics_notif(struct il_priv *il, +void il_rx_pm_debug_stats_notif(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1227,7 +1227,7 @@ void il_rx_pm_debug_statistics_notif(struct il_priv *il, il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } -EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); +EXPORT_SYMBOL(il_rx_pm_debug_stats_notif); void il_rx_reply_error(struct il_priv *il, struct il_rx_buf *rxb) @@ -1614,7 +1614,7 @@ void il_clear_traffic_stats(struct il_priv *il) * if CONFIG_IWLEGACY_DEBUGFS defined, * il_update_stats function will * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass - * Use debugFs to display the rx/rx_statistics + * Use debugFs to display the rx/rx_stats * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL * information will be recorded, but DATA pkt still will be recorded * for the reason of il_led.c need to control the led blinking based on diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index bc2ae06..8333761 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -371,7 +371,7 @@ static inline void il_update_stats(struct il_priv *il, bool is_tx, * **************************************************/ void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_buf *rxb); -void il_rx_pm_debug_statistics_notif(struct il_priv *il, +void il_rx_pm_debug_stats_notif(struct il_priv *il, struct il_rx_buf *rxb); void il_rx_reply_error(struct il_priv *il, struct il_rx_buf *rxb); @@ -390,7 +390,7 @@ void il_tx_cmd_complete(struct il_priv *il, /* Handlers */ void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_buf *rxb); -void il_recover_from_statistics(struct il_priv *il, +void il_recover_from_stats(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb); @@ -596,7 +596,7 @@ static inline int il_is_ready_rf(struct il_priv *il) } extern void il_send_bt_config(struct il_priv *il); -extern int il_send_statistics_request(struct il_priv *il, +extern int il_send_stats_request(struct il_priv *il, u8 flags, bool clear); void il_apm_stop(struct il_priv *il); int il_apm_init(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index a4b1f37..e8153b0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -102,7 +102,7 @@ static const struct file_operations il_dbgfs_##name##_ops = { \ .llseek = generic_file_llseek, \ }; -static ssize_t il_dbgfs_tx_statistics_read(struct file *file, +static ssize_t il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -142,7 +142,7 @@ static ssize_t il_dbgfs_tx_statistics_read(struct file *file, } static ssize_t -il_dbgfs_clear_traffic_statistics_write(struct file *file, +il_dbgfs_clear_traffic_stats_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { @@ -162,7 +162,7 @@ il_dbgfs_clear_traffic_statistics_write(struct file *file, return count; } -static ssize_t il_dbgfs_rx_statistics_read(struct file *file, +static ssize_t il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1031,7 +1031,7 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, +static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { @@ -1047,9 +1047,9 @@ static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, if (sscanf(buf, "%d", &clear) != 1) return -EFAULT; - /* make request to uCode to retrieve statistics information */ + /* make request to uCode to retrieve stats information */ mutex_lock(&il->mutex); - il_send_statistics_request(il, CMD_SYNC, true); + il_send_stats_request(il, CMD_SYNC, true); mutex_unlock(&il->mutex); return count; @@ -1206,8 +1206,8 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, return count; } -DEBUGFS_READ_FILE_OPS(rx_statistics); -DEBUGFS_READ_FILE_OPS(tx_statistics); +DEBUGFS_READ_FILE_OPS(rx_stats); +DEBUGFS_READ_FILE_OPS(tx_stats); DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); DEBUGFS_READ_FILE_OPS(rx_queue); DEBUGFS_READ_FILE_OPS(tx_queue); @@ -1217,8 +1217,8 @@ DEBUGFS_READ_FILE_OPS(ucode_general_stats); DEBUGFS_READ_FILE_OPS(sensitivity); DEBUGFS_READ_FILE_OPS(chain_noise); DEBUGFS_READ_FILE_OPS(power_save_status); -DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); -DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); +DEBUGFS_WRITE_FILE_OPS(clear_ucode_stats); +DEBUGFS_WRITE_FILE_OPS(clear_traffic_stats); DEBUGFS_READ_FILE_OPS(fh_reg); DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); DEBUGFS_READ_WRITE_FILE_OPS(force_reset); @@ -1259,14 +1259,14 @@ int il_dbgfs_register(struct il_priv *il, const char *name) DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(clear_ucode_stats, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(clear_traffic_stats, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index ad72d39..4388538 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -57,7 +57,7 @@ struct il_tx_queue; /* Default noise level to report when noise measurement is not available. * This may be because we're: - * 1) Not associated (4965, no beacon statistics being sent to driver) + * 1) Not associated (4965, no beacon stats being sent to driver) * 2) Scanning (noise measurement does not apply to associated channel) * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) * Use default noise value of -127 ... this is below the range of measurable @@ -801,8 +801,8 @@ enum { MEASUREMENT_ACTIVE = (1 << 1), }; -/* interrupt statistics */ -struct isr_statistics { +/* interrupt stats */ +struct isr_stats { u32 hw; u32 sw; u32 err_code; @@ -817,7 +817,7 @@ struct isr_statistics { u32 unhandled; }; -/* management statistics */ +/* management stats */ enum il_mgmt_stats { MANAGEMENT_ASSOC_REQ = 0, MANAGEMENT_ASSOC_RESP, @@ -833,7 +833,7 @@ enum il_mgmt_stats { MANAGEMENT_ACTION, MANAGEMENT_MAX, }; -/* control statistics */ +/* control stats */ enum il_ctrl_stats { CONTROL_BACK_REQ = 0, CONTROL_BACK, @@ -1087,7 +1087,7 @@ struct il_priv { struct traffic_stats rx_stats; /* counts interrupts */ - struct isr_statistics isr_stats; + struct isr_stats isr_stats; struct il_power_mgr power_data; @@ -1131,15 +1131,15 @@ struct il_priv { struct delayed_work thermal_periodic; struct delayed_work rfkill_poll; - struct il3945_notif_statistics statistics; + struct il3945_notif_stats stats; #ifdef CONFIG_IWLEGACY_DEBUGFS - struct il3945_notif_statistics accum_statistics; - struct il3945_notif_statistics delta_statistics; - struct il3945_notif_statistics max_delta; + struct il3945_notif_stats accum_stats; + struct il3945_notif_stats delta_stats; + struct il3945_notif_stats max_delta; #endif u32 sta_supp_rates; - int last_rx_rssi; /* From Rx packet statistics */ + int last_rx_rssi; /* From Rx packet stats */ /* Rx'd packet timing information */ u32 last_beacon_time; @@ -1169,11 +1169,11 @@ struct il_priv { u8 phy_calib_chain_noise_reset_cmd; u8 phy_calib_chain_noise_gain_cmd; - struct il_notif_statistics statistics; + struct il_notif_stats stats; #ifdef CONFIG_IWLEGACY_DEBUGFS - struct il_notif_statistics accum_statistics; - struct il_notif_statistics delta_statistics; - struct il_notif_statistics max_delta; + struct il_notif_stats accum_stats; + struct il_notif_stats delta_stats; + struct il_notif_stats max_delta; #endif } _4965; @@ -1229,7 +1229,7 @@ struct il_priv { u32 disable_chain_noise_cal; u32 disable_tx_power_cal; struct work_struct run_time_calib_work; - struct timer_list statistics_periodic; + struct timer_list stats_periodic; struct timer_list watchdog; bool hw_ready; diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index f24b6b8..19fa92d0e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -335,7 +335,7 @@ struct il_scale_tbl_info { }; struct il_traffic_load { - unsigned long time_stamp; /* age of the oldest statistics */ + unsigned long time_stamp; /* age of the oldest stats */ u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time * slice */ u32 total; /* total num of packets during the diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index dfc143107..71b2fac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -229,7 +229,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, notif->band ? "bg" : "a", le32_to_cpu(notif->tsf_high), le32_to_cpu(notif->tsf_low), - le32_to_cpu(notif->statistics[0]), + le32_to_cpu(notif->stats[0]), le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); #endif } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 446bdb5..c602570 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -862,16 +862,16 @@ static void il3945_setup_rx_handlers(struct il_priv *il) il_rx_spectrum_measure_notif; il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_statistics_notif; + il_rx_pm_debug_stats_notif; il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete - * statistics request from the host as well as for the periodic - * statistics notifications (after received beacons) from the uCode. + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; - il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 81613ed..736c2f5 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -464,16 +464,16 @@ static void il4965_rx_reply_alive(struct il_priv *il, } /** - * il4965_bg_statistics_periodic - Timer callback to queue statistics + * il4965_bg_stats_periodic - Timer callback to queue stats * - * This callback is provided in order to send a statistics request. + * This callback is provided in order to send a stats request. * * This timer function is continually reset to execute within * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION - * was received. We need to ensure we receive the statistics in order + * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ -static void il4965_bg_statistics_periodic(unsigned long data) +static void il4965_bg_stats_periodic(unsigned long data) { struct il_priv *il = (struct il_priv *)data; @@ -484,7 +484,7 @@ static void il4965_bg_statistics_periodic(unsigned long data) if (!il_is_ready_rf(il)) return; - il_send_statistics_request(il, CMD_ASYNC, false); + il_send_stats_request(il, CMD_ASYNC, false); } static void il4965_rx_beacon_notif(struct il_priv *il, @@ -596,16 +596,16 @@ static void il4965_setup_rx_handlers(struct il_priv *il) il_rx_spectrum_measure_notif; il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_statistics_notif; + il_rx_pm_debug_stats_notif; il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete - * statistics request from the host as well as for the periodic - * statistics notifications (after received beacons) from the uCode. + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; - il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; il_setup_rx_scan_handlers(il); @@ -2105,9 +2105,9 @@ static void il4965_bg_run_time_calib_work(struct work_struct *work) if (il->start_calib) { il4965_chain_noise_calibration(il, - (void *)&il->_4965.statistics); + (void *)&il->_4965.stats); il4965_sensitivity_calibration(il, - (void *)&il->_4965.statistics); + (void *)&il->_4965.stats); } mutex_unlock(&il->mutex); @@ -2647,7 +2647,7 @@ static void il4965_bg_txpower_work(struct work_struct *work) mutex_lock(&il->mutex); /* If a scan happened to start before we got here - * then just return; the statistics notification will + * then just return; the stats notification will * kick off another scheduled work to compensate for * any temperature delta we missed here. */ if (test_bit(STATUS_EXIT_PENDING, &il->status) || @@ -2682,9 +2682,9 @@ static void il4965_setup_deferred_work(struct il_priv *il) INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); - init_timer(&il->statistics_periodic); - il->statistics_periodic.data = (unsigned long)il; - il->statistics_periodic.function = il4965_bg_statistics_periodic; + init_timer(&il->stats_periodic); + il->stats_periodic.data = (unsigned long)il; + il->stats_periodic.function = il4965_bg_stats_periodic; init_timer(&il->watchdog); il->watchdog.data = (unsigned long)il; @@ -2703,7 +2703,7 @@ static void il4965_cancel_deferred_work(struct il_priv *il) il_cancel_scan_deferred_work(il); - del_timer_sync(&il->statistics_periodic); + del_timer_sync(&il->stats_periodic); } static void il4965_init_hw_rates(struct il_priv *il, -- cgit v0.10.2 From 6ce1dc45304eece672a36241cda587ba056d2b1f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 15:49:28 +0200 Subject: iwlegacy: s/window/win/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index ebee6c3..5c855e8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -131,24 +131,24 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) return tpt_table[index].index; } -static void il3945_clear_window(struct il3945_rate_scale_data *window) +static void il3945_clear_win(struct il3945_rate_scale_data *win) { - window->data = 0; - window->success_counter = 0; - window->success_ratio = -1; - window->counter = 0; - window->average_tpt = IL_INVALID_VALUE; - window->stamp = 0; + win->data = 0; + win->success_counter = 0; + win->success_ratio = -1; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; } /** - * il3945_rate_scale_flush_windows - flush out the rate scale windows + * il3945_rate_scale_flush_wins - flush out the rate scale wins * - * Returns the number of windows that have gathered data but were + * Returns the number of wins that have gathered data but were * not flushed. If there were any that were not flushed, then * reschedule the rate flushing routine. */ -static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) +static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) { int unflushed = 0; int i; @@ -170,7 +170,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) D_RATE("flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); - il3945_clear_window(&rs_sta->win[i]); + il3945_clear_win(&rs_sta->win[i]); } else unflushed++; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -193,7 +193,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) D_RATE("enter\n"); - unflushed = il3945_rate_scale_flush_windows(rs_sta); + unflushed = il3945_rate_scale_flush_wins(rs_sta); spin_lock_irqsave(&rs_sta->lock, flags); @@ -248,14 +248,14 @@ static void il3945_bg_rate_scale_flush(unsigned long data) } /** - * il3945_collect_tx_data - Update the success/failure sliding window + * il3945_collect_tx_data - Update the success/failure sliding win * - * We keep a sliding window of the last 64 packets transmitted - * at this rate. window->data contains the bitmask of successful + * We keep a sliding win of the last 64 packets transmitted + * at this rate. win->data contains the bitmask of successful * packets. */ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, - struct il3945_rate_scale_data *window, + struct il3945_rate_scale_data *win, int success, int retries, int index) { unsigned long flags; @@ -271,34 +271,34 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* * Keep track of only the latest 62 tx frame attempts in this rate's - * history window; anything older isn't really relevant any more. - * If we have filled up the sliding window, drop the oldest attempt; + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; * if the oldest attempt (highest bit in bitmap) shows "success", * subtract "1" from the success counter (this is the main reason * we keep these bitmaps!). * */ while (retries > 0) { - if (window->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = IL_RATE_MAX_WINDOW - 1; - if (window->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { - window->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); - window->success_counter--; + if (win->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { + win->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); + win->success_counter--; } } /* Increment frames-attempted counter */ - window->counter++; + win->counter++; /* Shift bitmap by one frame (throw away oldest history), * OR in "1", and increment "success" if this * frame was successful. */ - window->data <<= 1; + win->data <<= 1; if (success > 0) { - window->success_counter++; - window->data |= 0x1; + win->success_counter++; + win->data |= 0x1; success--; } @@ -306,24 +306,24 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, } /* Calculate current success ratio, avoid divide-by-0! */ - if (window->counter > 0) - window->success_ratio = 128 * (100 * window->success_counter) - / window->counter; + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; else - window->success_ratio = IL_INVALID_VALUE; + win->success_ratio = IL_INVALID_VALUE; - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ if (fail_count >= IL_RATE_MIN_FAILURE_TH || - window->success_counter >= IL_RATE_MIN_SUCCESS_TH) - window->average_tpt = ((window->success_ratio * + win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + win->average_tpt = ((win->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; - /* Tag this window as having been updated */ - window->stamp = jiffies; + /* Tag this win as having been updated */ + win->stamp = jiffies; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -365,7 +365,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; for (i = 0; i < IL_RATE_COUNT_3945; i++) - il3945_clear_window(&rs_sta->win[i]); + il3945_clear_win(&rs_sta->win[i]); /* TODO: what is a good starting rate for STA? About middle? Maybe not * the lowest or the highest rate.. Could consider using RSSI from @@ -484,7 +484,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * last_index = first_index; /* - * Update the window for each rate. We determine which rates + * Update the win for each rate. We determine which rates * were Tx'd based on the total number of retries vs. the number * of retries configured for each rate -- currently set to the * il value 'retry_rate' vs. rate specific @@ -517,7 +517,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * } - /* Update the last index window with success/failure based on ACK */ + /* Update the last index win with success/failure based on ACK */ D_RATE("Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? @@ -526,7 +526,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * &rs_sta->win[last_index], info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); - /* We updated the rate scale window -- if its been more than + /* We updated the rate scale win -- if its been more than * flush_time since the last run, schedule the flush * again */ spin_lock_irqsave(&rs_sta->lock, flags); @@ -636,7 +636,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, u16 high_low; int index; struct il3945_rs_sta *rs_sta = il_sta; - struct il3945_rate_scale_data *window = NULL; + struct il3945_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; int low_tpt = IL_INVALID_VALUE; int high_tpt = IL_INVALID_VALUE; @@ -691,29 +691,29 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, index = max_rate_idx; } - window = &(rs_sta->win[index]); + win = &(rs_sta->win[index]); - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; if (fail_count < IL_RATE_MIN_FAILURE_TH && - window->success_counter < IL_RATE_MIN_SUCCESS_TH) { + win->success_counter < IL_RATE_MIN_SUCCESS_TH) { spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, - window->counter, - window->success_counter, + win->counter, + win->success_counter, rs_sta->expected_tpt ? "not " : ""); /* Can't calculate this yet; not enough history */ - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; goto out; } - current_tpt = window->average_tpt; + current_tpt = win->average_tpt; high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask, sband->band); @@ -736,7 +736,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if (window->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { + if (win->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, @@ -744,7 +744,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) + if (high != IL_RATE_INVALID && win->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else if (low != IL_RATE_INVALID) scale_action = 0; @@ -768,7 +768,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - window->success_ratio >= IL_RATE_INCREASE_TH) + win->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { D_RATE( @@ -780,7 +780,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; - } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { + } else if (win->success_ratio >= IL_RATE_INCREASE_TH) { /* Lower rate has better * throughput,decrease rate */ scale_action = 1; @@ -791,7 +791,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ if (scale_action == -1 && low != IL_RATE_INVALID && - (window->success_ratio > IL_RATE_HIGH_TH || + (win->success_ratio > IL_RATE_HIGH_TH || current_tpt > 100 * rs_sta->expected_tpt[low])) scale_action = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index 21ff694..83748c7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -773,8 +773,8 @@ enum { * * Each Tx queue uses a byte-count table containing 320 entries: * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that - * duplicate the first 64 entries (to avoid wrap-around within a Tx window; - * max Tx window is 64 TFDs). + * duplicate the first 64 entries (to avoid wrap-around within a Tx win; + * max Tx win is 64 TFDs). * * When driver sets up a new TFD, it must also enter the total byte count * of the frame to be transmitted into the corresponding entry in the byte diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index e99a20c..5d88a45 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -46,7 +46,7 @@ #define IL_NUMBER_TRY 1 #define IL_HT_NUMBER_TRY 3 -#define IL_RATE_MAX_WINDOW 62 /* # tx in history window */ +#define IL_RATE_MAX_WINDOW 62 /* # tx in history win */ #define IL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ #define IL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ @@ -226,14 +226,14 @@ static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) } static void -il4965_rs_rate_scale_clear_window(struct il_rate_scale_data *window) +il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) { - window->data = 0; - window->success_counter = 0; - window->success_ratio = IL_INVALID_VALUE; - window->counter = 0; - window->average_tpt = IL_INVALID_VALUE; - window->stamp = 0; + win->data = 0; + win->success_counter = 0; + win->success_ratio = IL_INVALID_VALUE; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; } static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) @@ -408,58 +408,58 @@ il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) } /** - * il4965_rs_collect_tx_data - Update the success/failure sliding window + * il4965_rs_collect_tx_data - Update the success/failure sliding win * - * We keep a sliding window of the last 62 packets transmitted - * at this rate. window->data contains the bitmask of successful + * We keep a sliding win of the last 62 packets transmitted + * at this rate. win->data contains the bitmask of successful * packets. */ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_index, int attempts, int successes) { - struct il_rate_scale_data *window = NULL; + struct il_rate_scale_data *win = NULL; static const u64 mask = (((u64)1) << (IL_RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; if (scale_index < 0 || scale_index >= IL_RATE_COUNT) return -EINVAL; - /* Select window for current tx bit rate */ - window = &(tbl->win[scale_index]); + /* Select win for current tx bit rate */ + win = &(tbl->win[scale_index]); /* Get expected throughput */ tpt = il4965_get_expected_tpt(tbl, scale_index); /* * Keep track of only the latest 62 tx frame attempts in this rate's - * history window; anything older isn't really relevant any more. - * If we have filled up the sliding window, drop the oldest attempt; + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; * if the oldest attempt (highest bit in bitmap) shows "success", * subtract "1" from the success counter (this is the main reason * we keep these bitmaps!). */ while (attempts > 0) { - if (window->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = IL_RATE_MAX_WINDOW - 1; - if (window->data & mask) { - window->data &= ~mask; - window->success_counter--; + if (win->data & mask) { + win->data &= ~mask; + win->success_counter--; } } /* Increment frames-attempted counter */ - window->counter++; + win->counter++; /* Shift bitmap by one frame to throw away oldest history */ - window->data <<= 1; + win->data <<= 1; /* Mark the most recent #successes attempts as successful */ if (successes > 0) { - window->success_counter++; - window->data |= 0x1; + win->success_counter++; + win->data |= 0x1; successes--; } @@ -467,23 +467,23 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, } /* Calculate current success ratio, avoid divide-by-0! */ - if (window->counter > 0) - window->success_ratio = 128 * (100 * window->success_counter) - / window->counter; + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; else - window->success_ratio = IL_INVALID_VALUE; + win->success_ratio = IL_INVALID_VALUE; - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ if (fail_count >= IL_RATE_MIN_FAILURE_TH || - window->success_counter >= IL_RATE_MIN_SUCCESS_TH) - window->average_tpt = (window->success_ratio * tpt + 64) / 128; + win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + win->average_tpt = (win->success_ratio * tpt + 64) / 128; else - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; - /* Tag this window as having been updated */ - window->stamp = jiffies; + /* Tag this win as having been updated */ + win->stamp = jiffies; return 0; } @@ -817,7 +817,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_rxon_context *ctx = sta_priv->common.ctx; D_RATE( - "get frame ack response, update rate scale window\n"); + "get frame ack response, update rate scale win\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { @@ -1284,7 +1284,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[index]); u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; @@ -1310,7 +1310,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, break; /* Don't change antenna if success has been great */ - if (window->success_ratio >= IL_RS_GOOD_RATIO) + if (win->success_ratio >= IL_RS_GOOD_RATIO) break; /* Set up search table to try other antenna */ @@ -1401,7 +1401,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); @@ -1425,7 +1425,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, tx_chains_num <= 2)) break; - if (window->success_ratio >= IL_RS_GOOD_RATIO) + if (win->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); @@ -1523,7 +1523,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); @@ -1544,7 +1544,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, if (tx_chains_num <= 2) break; - if (window->success_ratio >= IL_RS_GOOD_RATIO) + if (win->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); @@ -1704,7 +1704,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) D_RATE( "LQ: stay in table clear win\n"); for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } } @@ -1714,7 +1714,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * "search" table). */ if (!lq_sta->stay_in_tbl) { for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } } @@ -1756,7 +1756,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, int high = IL_RATE_INVALID; int index; int i; - struct il_rate_scale_data *window = NULL; + struct il_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; int low_tpt = IL_INVALID_VALUE; int high_tpt = IL_INVALID_VALUE; @@ -1859,7 +1859,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, return; } - /* Get expected throughput table and history window for current rate */ + /* Get expected throughput table and history win for current rate */ if (!tbl->expected_tpt) { IL_ERR("tbl->expected_tpt is NULL\n"); return; @@ -1870,11 +1870,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->max_rate_idx < index) { index = lq_sta->max_rate_idx; update_lq = 1; - window = &(tbl->win[index]); + win = &(tbl->win[index]); goto lq_update; } - window = &(tbl->win[index]); + win = &(tbl->win[index]); /* * If there is not enough history to calculate actual average @@ -1883,15 +1883,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * Set up new rate table in uCode only if old rate is not supported * in current association (use new rate found above). */ - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; if (fail_count < IL_RATE_MIN_FAILURE_TH && - window->success_counter < IL_RATE_MIN_SUCCESS_TH) { + win->success_counter < IL_RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", - window->success_counter, window->counter, index); + win->success_counter, win->counter, index); /* Can't calculate this yet; not enough history */ - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; /* Should we stay with this modulation mode, * or search for a new one? */ @@ -1901,11 +1901,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* Else we have enough samples; calculate estimate of * actual average throughput */ - if (window->average_tpt != ((window->success_ratio * + if (win->average_tpt != ((win->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { IL_ERR( "expected_tpt should have been calculated by now\n"); - window->average_tpt = ((window->success_ratio * + win->average_tpt = ((win->success_ratio * tbl->expected_tpt[index] + 64) / 128); } @@ -1914,12 +1914,12 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* If good success, continue using the "search" mode; * no need to send new link quality command, since we're * continuing to use the setup that we've been trying. */ - if (window->average_tpt > lq_sta->last_tpt) { + if (win->average_tpt > lq_sta->last_tpt) { D_RATE("LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", - window->success_ratio, - window->average_tpt, + win->success_ratio, + win->average_tpt, lq_sta->last_tpt); if (!is_legacy(tbl->lq_type)) @@ -1927,15 +1927,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Swap tables; "search" becomes "active" */ lq_sta->active_tbl = active_tbl; - current_tpt = window->average_tpt; + current_tpt = win->average_tpt; /* Else poor success; go back to mode in "active" table */ } else { D_RATE("LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", - window->success_ratio, - window->average_tpt, + win->success_ratio, + win->average_tpt, lq_sta->last_tpt); /* Nullify "search" table */ @@ -1973,10 +1973,10 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->max_rate_idx < high) high = IL_RATE_INVALID; - sr = window->success_ratio; + sr = win->success_ratio; /* Collect measured throughputs for current and adjacent rates */ - current_tpt = window->average_tpt; + current_tpt = win->average_tpt; if (low != IL_RATE_INVALID) low_tpt = tbl->win[low].average_tpt; if (high != IL_RATE_INVALID) @@ -2082,7 +2082,7 @@ lq_update: * 3) Allowing a new search */ if (!update_lq && !done_search && !lq_sta->stay_in_tbl && - window->counter) { + win->counter) { /* Save current throughput to compare with "search" throughput*/ lq_sta->last_tpt = current_tpt; @@ -2103,7 +2103,7 @@ lq_update: /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &(tbl->win[i])); /* Use new "search" start rate */ @@ -2314,7 +2314,7 @@ static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, struct il_priv *il; il = (struct il_priv *)il_rate; - D_RATE("create station rate scale window\n"); + D_RATE("create station rate scale win\n"); lq_sta = &sta_priv->lq_sta; @@ -2346,14 +2346,14 @@ il4965_rs_rate_init(struct il_priv *il, for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); D_RATE("LQ:" diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index dff48e8..68c86e0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -834,7 +834,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); il4965_set_wr_ptrs(il, txq_id, ssn_idx); - /* Set up Tx window size and frame limit for this queue */ + /* Set up Tx win size and frame limit for this queue */ il_write_targ_mem(il, il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & @@ -1171,7 +1171,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, D_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); - /* Calculate shift to align block-ack bits with our Tx window bits */ + /* Calculate shift to align block-ack bits with our Tx win bits */ sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4); if (sh < 0) /* tbw something is wrong with indices */ sh += 0x100; @@ -1260,8 +1260,8 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, /* "flow" corresponds to Tx queue */ u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - /* "ssn" is start of block-ack Tx window, corresponds to index - * (in Tx queue's circular buffer) of first TFD/frame in window */ + /* "ssn" is start of block-ack Tx win, corresponds to index + * (in Tx queue's circular buffer) of first TFD/frame in win */ u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= il->hw_params.max_txq_num) { @@ -1287,7 +1287,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, return; } - /* Find index just before block-ack window */ + /* Find index just before block-ack win */ index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); spin_lock_irqsave(&il->sta_lock, flags); @@ -1309,11 +1309,11 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, agg->start_idx, (unsigned long long)agg->bitmap); - /* Update driver's record of ACK vs. not for each frame in window */ + /* Update driver's record of ACK vs. not for each frame in win */ il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); /* Release all TFDs before the SSN, i.e. all TFDs in front of - * block-ack window (we assume that they've been successfully + * block-ack win (we assume that they've been successfully * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 9cfc140..f62475d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1649,7 +1649,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, u64 bitmap = 0; int start = agg->start_idx; - /* Construct bit-map of pending frames within Tx window */ + /* Construct bit-map of pending frames within Tx win */ for (i = 0; i < agg->frame_count; i++) { u16 sc; status = le16_to_cpu(frame_status[i].status); diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index ea6c0f5..d1876d0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -754,7 +754,7 @@ struct il4965_rxon_assoc_cmd { struct il_rxon_time_cmd { __le64 timestamp; __le16 beacon_interval; - __le16 atim_window; + __le16 atim_win; __le32 beacon_init_val; __le16 listen_interval; u8 dtim_period; @@ -803,15 +803,15 @@ struct il_csa_notification { * struct il_ac_qos -- QOS timing params for REPLY_QOS_PARAM * One for each of 4 EDCA access categories in struct il_qosparam_cmd * - * @cw_min: Contention window, start value in numbers of slots. + * @cw_min: Contention win, start value in numbers of slots. * Should be a power-of-2, minus 1. Device's default is 0x0f. - * @cw_max: Contention window, max value in numbers of slots. + * @cw_max: Contention win, max value in numbers of slots. * Should be a power-of-2, minus 1. Device's default is 0x3f. * @aifsn: Number of slots in Arbitration Interframe Space (before * performing random backoff timing prior to Tx). Device default 1. * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. * - * Device will automatically increase contention window by (2*CW) + 1 for each + * Device will automatically increase contention win by (2*CW) + 1 for each * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW * value, to cap the CW value. */ @@ -1948,13 +1948,13 @@ struct il_link_qual_agg_params { * speculative mode as the new current active mode. * * Each history set contains, separately for each possible rate, data for a - * sliding window of the 62 most recent tx attempts at that rate. The data + * sliding win of the 62 most recent tx attempts at that rate. The data * includes a shifting bitmap of success(1)/failure(0), and sums of successful * and attempted frames, from which the driver can additionally calculate a * success ratio (success / attempted) and number of failures - * (attempted - success), and control the size of the window (attempted). + * (attempted - success), and control the size of the win (attempted). * The driver uses the bit map to remove successes from the success sum, as - * the oldest tx attempts fall out of the window. + * the oldest tx attempts fall out of the win. * * When the 4965 device makes multiple tx attempts for a given frame, each * attempt might be at a different rate, and have different modulation @@ -2017,7 +2017,7 @@ struct il_link_qual_agg_params { * * 6) Re-evaluate the rate after each tx frame. If working with block- * acknowledge, history and stats may be calculated for the entire - * block (including prior history that fits within the history windows), + * block (including prior history that fits within the history wins), * before re-evaluation. * * FINDING BEST STARTING MODULATION MODE: diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 475bcac..6742a65 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -380,10 +380,10 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) beacon_int = vif ? vif->bss_conf.beacon_int : 0; /* - * TODO: For IBSS we need to get atim_window from mac80211, + * TODO: For IBSS we need to get atim_win from mac80211, * for now just always use 0 */ - ctx->timing.atim_window = 0; + ctx->timing.atim_win = 0; beacon_int = il_adjust_beacon_interval(beacon_int, il->hw_params.max_beacon_itrvl * TIME_UNIT); @@ -400,7 +400,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), - le16_to_cpu(ctx->timing.atim_window)); + le16_to_cpu(ctx->timing.atim_win)); return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 4388538..18dd253 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -129,7 +129,7 @@ struct il_queue { int read_ptr; /* last used entry (index) host_r*/ /* use for monitoring and recovering the stuck queue */ dma_addr_t dma_addr; /* physical addr for BD's */ - int n_window; /* safe queue window */ + int n_win; /* safe queue win */ u32 id; int low_mark; /* low watermark, resume queue if free * space more than this */ @@ -377,9 +377,9 @@ struct il_rx_queue { * @txq_id: Tx queue used for Tx attempt * @frame_count: # frames attempted by Tx command * @wait_for_ba: Expect block-ack before next Tx reply - * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window - * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window - * @bitmap1: High order, one bit for each frame pending ACK in Tx window + * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win + * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win + * @bitmap1: High order, one bit for each frame pending ACK in Tx win * @rate_n_flags: Rate at which Tx was attempted * * If REPLY_TX indicates that aggregation was attempted, driver must wait @@ -645,10 +645,10 @@ static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, * the big buffer at end of command array */ if (is_huge) - return q->n_window; /* must be power of 2 */ + return q->n_win; /* must be power of 2 */ /* Otherwise, use normal size buffers */ - return index & (q->n_window - 1); + return index & (q->n_win - 1); } diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index caa3837..200f295 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -274,13 +274,13 @@ * The driver sets up each queue to work in one of two modes: * * 1) Scheduler-Ack, in which the scheduler automatically supports a - * block-ack (BA) window of up to 64 TFDs. In this mode, each queue + * block-ack (BA) win of up to 64 TFDs. In this mode, each queue * contains TFDs for a unique combination of Recipient Address (RA) * and Traffic Identifier (TID), that is, traffic of a given * Quality-Of-Service (QOS) priority, destined for a single station. * * In scheduler-ack mode, the scheduler keeps track of the Tx status of - * each frame within the BA window, including whether it's been transmitted, + * each frame within the BA win, including whether it's been transmitted, * and whether it's been acknowledged by the receiving station. The device * automatically processes block-acks received from the receiving STA, * and reschedules un-acked frames to be retransmitted (successful @@ -316,7 +316,7 @@ */ /** - * Max Tx window size is the max number of contiguous TFDs that the scheduler + * Max Tx win size is the max number of contiguous TFDs that the scheduler * can keep track of at one time when creating block-ack chains of frames. * Note that "64" matches the number of ack bits in a block-ack packet. * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize @@ -377,7 +377,7 @@ /* * Queue (x) Read Pointers (indexes, really!), one for each Tx queue. * For FIFO mode, index indicates next frame to transmit. - * For Scheduler-ACK mode, index indicates first frame in Tx window. + * For Scheduler-ACK mode, index indicates first frame in Tx win. * Initialized by driver, updated by scheduler. */ #define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) @@ -414,7 +414,7 @@ * Driver should init to "1" for aggregation mode, or "0" otherwise. * 7-6: Driver should init to "0" * 5: Window Size Left; indicates whether scheduler can request - * another TFD, based on window size, etc. Driver should init + * another TFD, based on win size, etc. Driver should init * this bit to "1" for aggregation mode, or "0" for non-agg. * 4-1: Tx FIFO to use (range 0-7). * 0: Queue is active (1), not active (0). @@ -460,7 +460,7 @@ * each queue's entry as follows: * * LS Dword bit fields: - * 0-06: Max Tx window size for Scheduler-ACK. Driver should init to 64. + * 0-06: Max Tx win size for Scheduler-ACK. Driver should init to 64. * * MS Dword bit fields: * 16-22: Frame limit. Driver should init to 10 (0xa). diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 2e95b78..b9c417c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -165,7 +165,7 @@ void il_cmd_queue_unmap(struct il_priv *il) q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } - i = q->n_window; + i = q->n_win; if (txq->meta[i].flags & CMD_MAPPED) { pci_unmap_single(il->pci_dev, dma_unmap_addr(&txq->meta[i], mapping), @@ -243,7 +243,7 @@ int il_queue_space(const struct il_queue *q) s -= q->n_bd; if (s <= 0) - s += q->n_window; + s += q->n_win; /* keep some reserve to not confuse empty and full situations */ s -= 2; if (s < 0) @@ -260,7 +260,7 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, u32 id) { q->n_bd = count; - q->n_window = slots_num; + q->n_win = slots_num; q->id = id; /* count must be power-of-two size, otherwise il_queue_inc_wrap @@ -271,11 +271,11 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, * il_get_cmd_index is broken. */ BUG_ON(!is_power_of_2(slots_num)); - q->low_mark = q->n_window / 4; + q->low_mark = q->n_win / 4; if (q->low_mark < 4) q->low_mark = 4; - q->high_mark = q->n_window / 8; + q->high_mark = q->n_win / 8; if (q->high_mark < 2) q->high_mark = 2; -- cgit v0.10.2 From 2eb058162ea8b72d5d8965520d05bcdc160010b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 16:07:43 +0200 Subject: iwlegacy: s/IL_RATE/RATE/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 5c855e8..92fa436 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -42,19 +42,19 @@ #define RS_NAME "iwl-3945-rs" -static s32 il3945_expected_tpt_g[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g[RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 }; -static s32 il3945_expected_tpt_g_prot[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g_prot[RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 }; -static s32 il3945_expected_tpt_a[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_a[RATE_COUNT_3945] = { 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 }; -static s32 il3945_expected_tpt_b[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -64,39 +64,39 @@ struct il3945_tpt_entry { }; static struct il3945_tpt_entry il3945_tpt_table_a[] = { - {-60, IL_RATE_54M_INDEX}, - {-64, IL_RATE_48M_INDEX}, - {-72, IL_RATE_36M_INDEX}, - {-80, IL_RATE_24M_INDEX}, - {-84, IL_RATE_18M_INDEX}, - {-85, IL_RATE_12M_INDEX}, - {-87, IL_RATE_9M_INDEX}, - {-89, IL_RATE_6M_INDEX} + {-60, RATE_54M_INDEX}, + {-64, RATE_48M_INDEX}, + {-72, RATE_36M_INDEX}, + {-80, RATE_24M_INDEX}, + {-84, RATE_18M_INDEX}, + {-85, RATE_12M_INDEX}, + {-87, RATE_9M_INDEX}, + {-89, RATE_6M_INDEX} }; static struct il3945_tpt_entry il3945_tpt_table_g[] = { - {-60, IL_RATE_54M_INDEX}, - {-64, IL_RATE_48M_INDEX}, - {-68, IL_RATE_36M_INDEX}, - {-80, IL_RATE_24M_INDEX}, - {-84, IL_RATE_18M_INDEX}, - {-85, IL_RATE_12M_INDEX}, - {-86, IL_RATE_11M_INDEX}, - {-88, IL_RATE_5M_INDEX}, - {-90, IL_RATE_2M_INDEX}, - {-92, IL_RATE_1M_INDEX} + {-60, RATE_54M_INDEX}, + {-64, RATE_48M_INDEX}, + {-68, RATE_36M_INDEX}, + {-80, RATE_24M_INDEX}, + {-84, RATE_18M_INDEX}, + {-85, RATE_12M_INDEX}, + {-86, RATE_11M_INDEX}, + {-88, RATE_5M_INDEX}, + {-90, RATE_2M_INDEX}, + {-92, RATE_1M_INDEX} }; -#define IL_RATE_MAX_WINDOW 62 -#define IL_RATE_FLUSH (3*HZ) -#define IL_RATE_WIN_FLUSH (HZ/2) +#define RATE_MAX_WINDOW 62 +#define RATE_FLUSH (3*HZ) +#define RATE_WIN_FLUSH (HZ/2) #define IL39_RATE_HIGH_TH 11520 #define IL_SUCCESS_UP_TH 8960 #define IL_SUCCESS_DOWN_TH 10880 -#define IL_RATE_MIN_FAILURE_TH 6 -#define IL_RATE_MIN_SUCCESS_TH 8 -#define IL_RATE_DECREASE_TH 1920 -#define IL_RATE_RETRY_TH 15 +#define RATE_MIN_FAILURE_TH 6 +#define RATE_MIN_SUCCESS_TH 8 +#define RATE_DECREASE_TH 1920 +#define RATE_RETRY_TH 15 static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) { @@ -157,16 +157,16 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) /* * For each rate, if we have collected data on that rate - * and it has been more than IL_RATE_WIN_FLUSH + * and it has been more than RATE_WIN_FLUSH * since we flushed, clear out the gathered stats */ - for (i = 0; i < IL_RATE_COUNT_3945; i++) { + for (i = 0; i < RATE_COUNT_3945; i++) { if (!rs_sta->win[i].counter) continue; spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + - IL_RATE_WIN_FLUSH)) { + RATE_WIN_FLUSH)) { D_RATE("flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); @@ -179,8 +179,8 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) return unflushed; } -#define IL_RATE_FLUSH_MAX 5000 /* msec */ -#define IL_RATE_FLUSH_MIN 50 /* msec */ +#define RATE_FLUSH_MAX 5000 /* msec */ +#define RATE_FLUSH_MIN 50 /* msec */ #define IL_AVERAGE_PACKETS 1500 static void il3945_bg_rate_scale_flush(unsigned long data) @@ -217,12 +217,12 @@ static void il3945_bg_rate_scale_flush(unsigned long data) if (pps) { duration = (IL_AVERAGE_PACKETS * 1000) / pps; - if (duration < IL_RATE_FLUSH_MIN) - duration = IL_RATE_FLUSH_MIN; - else if (duration > IL_RATE_FLUSH_MAX) - duration = IL_RATE_FLUSH_MAX; + if (duration < RATE_FLUSH_MIN) + duration = RATE_FLUSH_MIN; + else if (duration > RATE_FLUSH_MAX) + duration = RATE_FLUSH_MAX; } else - duration = IL_RATE_FLUSH_MAX; + duration = RATE_FLUSH_MAX; rs_sta->flush_time = msecs_to_jiffies(duration); @@ -234,7 +234,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->last_partial_flush = jiffies; } else { - rs_sta->flush_time = IL_RATE_FLUSH; + rs_sta->flush_time = RATE_FLUSH; rs_sta->flush_pending = 0; } /* If there weren't any unflushed entries, we don't schedule the timer @@ -278,13 +278,13 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, * we keep these bitmaps!). * */ while (retries > 0) { - if (win->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= RATE_MAX_WINDOW) { /* remove earliest */ - win->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = RATE_MAX_WINDOW - 1; - if (win->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { - win->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); + if (win->data & (1ULL << (RATE_MAX_WINDOW - 1))) { + win->data &= ~(1ULL << (RATE_MAX_WINDOW - 1)); win->success_counter--; } } @@ -315,8 +315,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ - if (fail_count >= IL_RATE_MIN_FAILURE_TH || - win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) win->average_tpt = ((win->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else @@ -351,20 +351,20 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i rs_sta->il = il; - rs_sta->start_rate = IL_RATE_INVALID; + rs_sta->start_rate = RATE_INVALID; /* default to just 802.11b */ rs_sta->expected_tpt = il3945_expected_tpt_b; rs_sta->last_partial_flush = jiffies; rs_sta->last_flush = jiffies; - rs_sta->flush_time = IL_RATE_FLUSH; + rs_sta->flush_time = RATE_FLUSH; rs_sta->last_tx_packets = 0; rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; - for (i = 0; i < IL_RATE_COUNT_3945; i++) + for (i = 0; i < RATE_COUNT_3945; i++) il3945_clear_win(&rs_sta->win[i]); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -457,11 +457,11 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * retries = info->status.rates[0].count; /* Sanity Check for retries */ - if (retries > IL_RATE_RETRY_TH) - retries = IL_RATE_RETRY_TH; + if (retries > RATE_RETRY_TH) + retries = RATE_RETRY_TH; first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if (first_index < 0 || first_index >= IL_RATE_COUNT_3945) { + if (first_index < 0 || first_index >= RATE_COUNT_3945) { D_RATE("leave: Rate out of bounds: %d\n", first_index); return; } @@ -549,8 +549,8 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u8 index, u16 rate_mask, enum ieee80211_band band) { - u8 high = IL_RATE_INVALID; - u8 low = IL_RATE_INVALID; + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; struct il_priv *il __maybe_unused = rs_sta->il; /* 802.11A walks to the next literal adjacent rate in @@ -570,7 +570,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IL_RATE_COUNT_3945; + for (mask = (1 << i); i < RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { high = i; @@ -582,12 +582,12 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, } low = index; - while (low != IL_RATE_INVALID) { + while (low != RATE_INVALID) { if (rs_sta->tgg) low = il3945_rates[low].prev_rs_tgg; else low = il3945_rates[low].prev_rs; - if (low == IL_RATE_INVALID) + if (low == RATE_INVALID) break; if (rate_mask & (1 << low)) break; @@ -595,12 +595,12 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, } high = index; - while (high != IL_RATE_INVALID) { + while (high != RATE_INVALID) { if (rs_sta->tgg) high = il3945_rates[high].next_rs_tgg; else high = il3945_rates[high].next_rs; - if (high == IL_RATE_INVALID) + if (high == RATE_INVALID) break; if (rate_mask & (1 << high)) break; @@ -631,8 +631,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; - u8 low = IL_RATE_INVALID; - u8 high = IL_RATE_INVALID; + u8 low = RATE_INVALID; + u8 high = RATE_INVALID; u16 high_low; int index; struct il3945_rs_sta *rs_sta = il_sta; @@ -665,10 +665,10 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, max_rate_idx = txrc->max_rate_idx; if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) max_rate_idx += IL_FIRST_OFDM_RATE; - if (max_rate_idx < 0 || max_rate_idx >= IL_RATE_COUNT) + if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) max_rate_idx = -1; - index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1); + index = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); if (sband->band == IEEE80211_BAND_5GHZ) rate_mask = rate_mask << IL_FIRST_OFDM_RATE; @@ -678,11 +678,11 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* for recent assoc, choose best rate regarding * to rssi value */ - if (rs_sta->start_rate != IL_RATE_INVALID) { + if (rs_sta->start_rate != RATE_INVALID) { if (rs_sta->start_rate < index && (rate_mask & (1 << rs_sta->start_rate))) index = rs_sta->start_rate; - rs_sta->start_rate = IL_RATE_INVALID; + rs_sta->start_rate = RATE_INVALID; } /* force user max rate if set by user */ @@ -695,8 +695,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, fail_count = win->counter - win->success_counter; - if (fail_count < IL_RATE_MIN_FAILURE_TH && - win->success_counter < IL_RATE_MIN_SUCCESS_TH) { + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " @@ -722,13 +722,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* If user set max rate, dont allow higher than user constrain */ if (max_rate_idx != -1 && max_rate_idx < high) - high = IL_RATE_INVALID; + high = RATE_INVALID; /* Collect Measured throughputs of adjacent rates */ - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) low_tpt = rs_sta->win[low].average_tpt; - if (high != IL_RATE_INVALID) + if (high != RATE_INVALID) high_tpt = rs_sta->win[high].average_tpt; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -736,7 +736,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if (win->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { + if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, @@ -744,9 +744,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != IL_RATE_INVALID && win->success_ratio >= IL_RATE_INCREASE_TH) + if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; - else if (low != IL_RATE_INVALID) + else if (low != RATE_INVALID) scale_action = 0; /* Both adjacent throughputs are measured, but neither one has @@ -768,7 +768,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - win->success_ratio >= IL_RATE_INCREASE_TH) + win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; else { D_RATE( @@ -780,7 +780,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; - } else if (win->success_ratio >= IL_RATE_INCREASE_TH) { + } else if (win->success_ratio >= RATE_INCREASE_TH) { /* Lower rate has better * throughput,decrease rate */ scale_action = 1; @@ -790,8 +790,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != IL_RATE_INVALID && - (win->success_ratio > IL_RATE_HIGH_TH || + if (scale_action == -1 && low != RATE_INVALID && + (win->success_ratio > RATE_HIGH_TH || current_tpt > 100 * rs_sta->expected_tpt[low])) scale_action = 0; @@ -799,13 +799,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, case -1: /* Decrese rate */ - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) index = low; break; case 1: /* Increase rate */ - if (high != IL_RATE_INVALID) + if (high != RATE_INVALID) index = high; break; @@ -860,7 +860,7 @@ static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, lq_sta->tx_packets, lq_sta->last_txrate_idx, lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); - for (j = 0; j < IL_RATE_COUNT_3945; j++) { + for (j = 0; j < RATE_COUNT_3945; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->win[j].counter, diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index fa4c33a..728a90c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -52,26 +52,26 @@ #include "iwl-3945-debugfs.h" #define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ - IL_RATE_##r##M_IEEE, \ - IL_RATE_##ip##M_INDEX, \ - IL_RATE_##in##M_INDEX, \ - IL_RATE_##rp##M_INDEX, \ - IL_RATE_##rn##M_INDEX, \ - IL_RATE_##pp##M_INDEX, \ - IL_RATE_##np##M_INDEX, \ - IL_RATE_##r##M_INDEX_TABLE, \ - IL_RATE_##ip##M_INDEX_TABLE } + [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + RATE_##r##M_IEEE, \ + RATE_##ip##M_INDEX, \ + RATE_##in##M_INDEX, \ + RATE_##rp##M_INDEX, \ + RATE_##rn##M_INDEX, \ + RATE_##pp##M_INDEX, \ + RATE_##np##M_INDEX, \ + RATE_##r##M_INDEX_TABLE, \ + RATE_##ip##M_INDEX_TABLE } /* * Parameter order: * rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IL_RATE_INVALID + * maps to RATE_INVALID * */ -const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945] = { +const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ @@ -90,7 +90,7 @@ static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) { u8 rate = il3945_rates[rate_index].prev_ieee; - if (rate == IL_RATE_INVALID) + if (rate == RATE_INVALID) rate = rate_index; return rate; } @@ -194,7 +194,7 @@ static int il3945_hwrate_to_plcp_idx(u8 plcp) { int idx; - for (idx = 0; idx < IL_RATE_COUNT_3945; idx++) + for (idx = 0; idx < RATE_COUNT_3945; idx++) if (il3945_rates[idx].plcp == plcp) return idx; return -1; @@ -246,16 +246,16 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) switch (il->band) { case IEEE80211_BAND_5GHZ: - if (rate == IL_RATE_12M_INDEX) - next_rate = IL_RATE_9M_INDEX; - else if (rate == IL_RATE_6M_INDEX) - next_rate = IL_RATE_6M_INDEX; + if (rate == RATE_12M_INDEX) + next_rate = RATE_9M_INDEX; + else if (rate == RATE_6M_INDEX) + next_rate = RATE_6M_INDEX; break; case IEEE80211_BAND_2GHZ: if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && il_is_associated(il)) { - if (rate == IL_RATE_11M_INDEX) - next_rate = IL_RATE_5M_INDEX; + if (rate == RATE_11M_INDEX) + next_rate = RATE_5M_INDEX; } break; @@ -675,7 +675,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; - u16 rate_index = min(hw_value & 0xffff, IL_RATE_COUNT_3945); + u16 rate_index = min(hw_value & 0xffff, RATE_COUNT_3945); u16 rate_mask; int rate; u8 rts_retry_limit; @@ -689,7 +689,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, /* We need to figure out how to get the sta->supp_rates while * in this running context */ - rate_mask = IL_RATES_MASK_3945; + rate_mask = RATES_MASK_3945; /* Set retry limit on DATA packets and Probe Responses*/ if (ieee80211_is_probe_resp(fc)) @@ -1330,7 +1330,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[IL_RATE_6M_INDEX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_INDEX_TABLE]); power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1342,7 +1342,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, * *index*. */ power_index = ch_info->power_info[rate_index].power_table_index - (power - ch_info->power_info - [IL_RATE_6M_INDEX_TABLE].requested_power) * 2; + [RATE_6M_INDEX_TABLE].requested_power) * 2; /* store reference index that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1466,7 +1466,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = IL_RATE_6M_INDEX_TABLE; i <= IL_RATE_54M_INDEX_TABLE; + for (i = RATE_6M_INDEX_TABLE; i <= RATE_54M_INDEX_TABLE; i++, ++power_info) { int delta_idx; @@ -1490,14 +1490,14 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + ch_info->power_info[RATE_12M_INDEX_TABLE]. requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ - for (i = IL_RATE_1M_INDEX_TABLE; i <= IL_RATE_11M_INDEX_TABLE; i++) { + for (i = RATE_1M_INDEX_TABLE; i <= RATE_11M_INDEX_TABLE; i++) { power_info->requested_power = power; power_info->base_power_index = - ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + ch_info->power_info[RATE_12M_INDEX_TABLE]. base_power_index + IL_CCK_FROM_OFDM_INDEX_DIFF; ++power_info; } @@ -1574,7 +1574,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_index = 0; rate_index < IL_RATE_COUNT_3945; + for (rate_index = 0; rate_index < RATE_COUNT_3945; rate_index++) { int power_idx = ch_info->power_info[rate_index].base_power_index; @@ -1597,7 +1597,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); @@ -2010,21 +2010,21 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) /* fill in channel group's nominal powers for each rate */ for (rate_index = 0; - rate_index < IL_RATE_COUNT_3945; rate_index++, clip_pwrs++) { + rate_index < RATE_COUNT_3945; rate_index++, clip_pwrs++) { switch (rate_index) { - case IL_RATE_36M_INDEX_TABLE: + case RATE_36M_INDEX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case IL_RATE_48M_INDEX_TABLE: + case RATE_48M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case IL_RATE_54M_INDEX_TABLE: + case RATE_54M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2139,7 +2139,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[IL_RATE_12M_INDEX_TABLE]; + pwr_info = &ch_info->power_info[RATE_12M_INDEX_TABLE]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_index = pwr_info->power_table_index + @@ -2169,7 +2169,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } @@ -2289,7 +2289,7 @@ static int il3945_manage_ibss_station(struct il_priv *il, il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, (il->band == IEEE80211_BAND_5GHZ) ? - IL_RATE_6M_PLCP : IL_RATE_1M_PLCP); + RATE_6M_PLCP : RATE_1M_PLCP); il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); return 0; @@ -2326,17 +2326,17 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = IL_RATE_1M_INDEX_TABLE; - i <= IL_RATE_11M_INDEX_TABLE; i++) + for (i = RATE_1M_INDEX_TABLE; + i <= RATE_11M_INDEX_TABLE; i++) table[i].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; /* Don't fall back to CCK rates */ - table[IL_RATE_12M_INDEX_TABLE].next_rate_index = - IL_RATE_9M_INDEX_TABLE; + table[RATE_12M_INDEX_TABLE].next_rate_index = + RATE_9M_INDEX_TABLE; /* Don't drop out of OFDM rates */ - table[IL_RATE_6M_INDEX_TABLE].next_rate_index = + table[RATE_6M_INDEX_TABLE].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; break; @@ -2349,14 +2349,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { index = IL_FIRST_CCK_RATE; - for (i = IL_RATE_6M_INDEX_TABLE; - i <= IL_RATE_54M_INDEX_TABLE; i++) + for (i = RATE_6M_INDEX_TABLE; + i <= RATE_54M_INDEX_TABLE; i++) table[i].next_rate_index = il3945_rates[index].table_rs_index; - index = IL_RATE_11M_INDEX_TABLE; + index = RATE_11M_INDEX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = IL_RATE_5M_INDEX_TABLE; + table[index].next_rate_index = RATE_5M_INDEX_TABLE; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 967e733..80fcbf8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -96,7 +96,7 @@ struct il3945_rs_sta { u8 flush_pending; u8 start_rate; struct timer_list rate_scale_flush; - struct il3945_rate_scale_data win[IL_RATE_COUNT_3945]; + struct il3945_rate_scale_data win[RATE_COUNT_3945]; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *rs_sta_dbgfs_stats_table_file; #endif @@ -300,7 +300,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); void il3945_post_scan(struct il_priv *il); /* rates */ -extern const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945]; +extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; /* Requires full declaration of il_priv before including */ #include "iwl-io.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 57fc190..ee04977 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -423,7 +423,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) } else { if (band == IEEE80211_BAND_5GHZ) band_offset = IL_FIRST_OFDM_RATE; - for (idx = band_offset; idx < IL_RATE_COUNT_LEGACY; idx++) + for (idx = band_offset; idx < RATE_COUNT_LEGACY; idx++) if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx - band_offset; } @@ -870,14 +870,14 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { - rate = IL_RATE_6M_PLCP; + rate = RATE_6M_PLCP; } else { - rate = IL_RATE_1M_PLCP; + rate = RATE_1M_PLCP; rate_flags = RATE_MCS_CCK_MSK; } break; case IEEE80211_BAND_5GHZ: - rate = IL_RATE_6M_PLCP; + rate = RATE_6M_PLCP; break; default: IL_WARN("Invalid scan band\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 5d88a45..e31ee20 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -46,23 +46,23 @@ #define IL_NUMBER_TRY 1 #define IL_HT_NUMBER_TRY 3 -#define IL_RATE_MAX_WINDOW 62 /* # tx in history win */ -#define IL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ -#define IL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ +#define RATE_MAX_WINDOW 62 /* # tx in history win */ +#define RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ +#define RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ /* max allowed rate miss before sync LQ cmd */ #define IL_MISSED_RATE_MAX 15 /* max time to accum history 2 seconds */ -#define IL_RATE_SCALE_FLUSH_INTVL (3*HZ) +#define RATE_SCALE_FLUSH_INTVL (3*HZ) static u8 rs_ht_to_legacy[] = { - IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, - IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, - IL_RATE_6M_INDEX, - IL_RATE_6M_INDEX, IL_RATE_9M_INDEX, - IL_RATE_12M_INDEX, IL_RATE_18M_INDEX, - IL_RATE_24M_INDEX, IL_RATE_36M_INDEX, - IL_RATE_48M_INDEX, IL_RATE_54M_INDEX + RATE_6M_INDEX, RATE_6M_INDEX, + RATE_6M_INDEX, RATE_6M_INDEX, + RATE_6M_INDEX, + RATE_6M_INDEX, RATE_9M_INDEX, + RATE_12M_INDEX, RATE_18M_INDEX, + RATE_24M_INDEX, RATE_36M_INDEX, + RATE_48M_INDEX, RATE_54M_INDEX }; static const u8 ant_toggle_lookup[] = { @@ -77,26 +77,26 @@ static const u8 ant_toggle_lookup[] = { }; #define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ - IL_RATE_SISO_##s##M_PLCP, \ - IL_RATE_MIMO2_##s##M_PLCP,\ - IL_RATE_##r##M_IEEE, \ - IL_RATE_##ip##M_INDEX, \ - IL_RATE_##in##M_INDEX, \ - IL_RATE_##rp##M_INDEX, \ - IL_RATE_##rn##M_INDEX, \ - IL_RATE_##pp##M_INDEX, \ - IL_RATE_##np##M_INDEX } + [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + RATE_SISO_##s##M_PLCP, \ + RATE_MIMO2_##s##M_PLCP,\ + RATE_##r##M_IEEE, \ + RATE_##ip##M_INDEX, \ + RATE_##in##M_INDEX, \ + RATE_##rp##M_INDEX, \ + RATE_##rn##M_INDEX, \ + RATE_##pp##M_INDEX, \ + RATE_##np##M_INDEX } /* * Parameter order: * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IL_RATE_INVALID + * maps to RATE_INVALID * */ -const struct il_rate_info il_rates[IL_RATE_COUNT] = { +const struct il_rate_info il_rates[RATE_COUNT] = { IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ @@ -120,12 +120,12 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) if (rate_n_flags & RATE_MCS_HT_MSK) { idx = (rate_n_flags & 0xff); - if (idx >= IL_RATE_MIMO2_6M_PLCP) - idx = idx - IL_RATE_MIMO2_6M_PLCP; + if (idx >= RATE_MIMO2_6M_PLCP) + idx = idx - RATE_MIMO2_6M_PLCP; idx += IL_FIRST_OFDM_RATE; /* skip 9M not supported in ht*/ - if (idx >= IL_RATE_9M_INDEX) + if (idx >= RATE_9M_INDEX) idx += 1; if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; @@ -169,32 +169,32 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, * (2.4 GHz) band. */ -static s32 expected_tpt_legacy[IL_RATE_COUNT] = { +static s32 expected_tpt_legacy[RATE_COUNT] = { 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 }; -static s32 expected_tpt_siso20MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ }; -static s32 expected_tpt_siso40MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ }; -static s32 expected_tpt_mimo2_20MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ }; -static s32 expected_tpt_mimo2_40MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ @@ -202,7 +202,7 @@ static s32 expected_tpt_mimo2_40MHz[4][IL_RATE_COUNT] = { }; /* mbps, mcs */ -static const struct il_rate_mcs_info il_rate_mcs[IL_RATE_COUNT] = { +static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { { "1", "BPSK DSSS"}, { "2", "QPSK DSSS"}, {"5.5", "BPSK CCK"}, @@ -418,10 +418,10 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_index, int attempts, int successes) { struct il_rate_scale_data *win = NULL; - static const u64 mask = (((u64)1) << (IL_RATE_MAX_WINDOW - 1)); + static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; - if (scale_index < 0 || scale_index >= IL_RATE_COUNT) + if (scale_index < 0 || scale_index >= RATE_COUNT) return -EINVAL; /* Select win for current tx bit rate */ @@ -439,10 +439,10 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, * we keep these bitmaps!). */ while (attempts > 0) { - if (win->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= RATE_MAX_WINDOW) { /* remove earliest */ - win->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = RATE_MAX_WINDOW - 1; if (win->data & mask) { win->data &= ~mask; @@ -476,8 +476,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ - if (fail_count >= IL_RATE_MIN_FAILURE_TH || - win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) win->average_tpt = (win->success_ratio * tpt + 64) / 128; else win->average_tpt = IL_INVALID_VALUE; @@ -557,7 +557,7 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, memset(tbl, 0, sizeof(struct il_scale_tbl_info)); *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - if (*rate_idx == IL_RATE_INVALID) { + if (*rate_idx == RATE_INVALID) { *rate_idx = -1; return -EINVAL; } @@ -591,7 +591,7 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, mcs = il4965_rs_extract_rate(rate_n_flags); /* SISO */ - if (mcs <= IL_RATE_SISO_60M_PLCP) { + if (mcs <= RATE_SISO_60M_PLCP) { if (il4965_num_of_ant == 1) tbl->lq_type = LQ_SISO; /*else NONE*/ /* MIMO2 */ @@ -669,8 +669,8 @@ static u16 il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, int rate_type) { - u8 high = IL_RATE_INVALID; - u8 low = IL_RATE_INVALID; + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; /* 802.11A or ht walks to the next literal adjacent rate in * the rate table */ @@ -689,7 +689,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IL_RATE_COUNT; i++, mask <<= 1) { + for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { if (rate_mask & mask) { high = i; break; @@ -700,9 +700,9 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, } low = index; - while (low != IL_RATE_INVALID) { + while (low != RATE_INVALID) { low = il_rates[low].prev_rs; - if (low == IL_RATE_INVALID) + if (low == RATE_INVALID) break; if (rate_mask & (1 << low)) break; @@ -710,9 +710,9 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, } high = index; - while (high != IL_RATE_INVALID) { + while (high != RATE_INVALID) { high = il_rates[high].next_rs; - if (high == IL_RATE_INVALID) + if (high == RATE_INVALID) break; if (rate_mask & (1 << high)) break; @@ -776,7 +776,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, tbl->lq_type); low = high_low & 0xff; - if (low == IL_RATE_INVALID) + if (low == RATE_INVALID) low = scale_index; out: @@ -856,7 +856,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (IL_RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) + if (mac_index >= (RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) mac_index++; /* * mac80211 HT index is always zero-indexed; we need to move @@ -1023,7 +1023,7 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl) { /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[IL_RATE_COUNT]; + s32 (*ht_tbl_pointer)[RATE_COUNT]; /* Check for invalid LQ type */ if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { @@ -1089,7 +1089,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, u16 high_low; s8 rate = index; - new_rate = high = low = start_hi = IL_RATE_INVALID; + new_rate = high = low = start_hi = RATE_INVALID; for (; ;) { high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, @@ -1114,16 +1114,16 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, * "active" throughput (under perfect conditions). */ if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && - (active_sr > IL_RATE_DECREASE_TH && - active_sr <= IL_RATE_HIGH_TH && + (active_sr > RATE_DECREASE_TH && + active_sr <= RATE_HIGH_TH && tpt_tbl[rate] <= active_tpt)) || - (active_sr >= IL_RATE_SCALE_SWITCH && + (active_sr >= RATE_SCALE_SWITCH && tpt_tbl[rate] > active_tpt)) { /* (2nd or later pass) * If we've already tried to raise the rate, and are * now trying to lower it, use the higher rate. */ - if (start_hi != IL_RATE_INVALID) { + if (start_hi != RATE_INVALID) { new_rate = start_hi; break; } @@ -1131,7 +1131,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, new_rate = rate; /* Loop again with lower rate */ - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) rate = low; /* Lower rate not available, use the original */ @@ -1143,11 +1143,11 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, /* (2nd or later pass) * If we've already tried to lower the rate, and are * now trying to raise it, use the lower rate. */ - if (new_rate != IL_RATE_INVALID) + if (new_rate != RATE_INVALID) break; /* Loop again with higher rate */ - else if (high != IL_RATE_INVALID) { + else if (high != RATE_INVALID) { start_hi = high; rate = high; @@ -1207,7 +1207,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); - if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "Can't switch with index %d rate mask %x\n", rate, rate_mask); @@ -1259,7 +1259,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); - if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "can not switch with index %d rate mask %x\n", rate, rate_mask); @@ -1286,7 +1286,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[index]); u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1404,7 +1404,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1526,7 +1526,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1663,7 +1663,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) flush_interval_passed = time_after(jiffies, (unsigned long)(lq_sta->flush_timer + - IL_RATE_SCALE_FLUSH_INTVL)); + RATE_SCALE_FLUSH_INTVL)); /* * Check if we should allow search for new modulation mode. @@ -1703,7 +1703,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) D_RATE( "LQ: stay in table clear win\n"); - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } @@ -1713,7 +1713,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * bitmaps and stats in active table (this will become the new * "search" table). */ if (!lq_sta->stay_in_tbl) { - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } @@ -1752,8 +1752,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, struct ieee80211_conf *conf = &hw->conf; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - int low = IL_RATE_INVALID; - int high = IL_RATE_INVALID; + int low = RATE_INVALID; + int high = RATE_INVALID; int index; int i; struct il_rate_scale_data *win = NULL; @@ -1884,8 +1884,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * in current association (use new rate found above). */ fail_count = win->counter - win->success_counter; - if (fail_count < IL_RATE_MIN_FAILURE_TH && - win->success_counter < IL_RATE_MIN_SUCCESS_TH) { + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", win->success_counter, win->counter, index); @@ -1971,21 +1971,21 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* If user set max rate, dont allow higher than user constrain */ if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < high) - high = IL_RATE_INVALID; + high = RATE_INVALID; sr = win->success_ratio; /* Collect measured throughputs for current and adjacent rates */ current_tpt = win->average_tpt; - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) low_tpt = tbl->win[low].average_tpt; - if (high != IL_RATE_INVALID) + if (high != RATE_INVALID) high_tpt = tbl->win[high].average_tpt; scale_action = 0; /* Too many failures, decrease rate */ - if (sr <= IL_RATE_DECREASE_TH || current_tpt == 0) { + if (sr <= RATE_DECREASE_TH || current_tpt == 0) { D_RATE( "decrease rate because of low success_ratio\n"); scale_action = -1; @@ -1994,9 +1994,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH) + if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) scale_action = 1; - else if (low != IL_RATE_INVALID) + else if (low != RATE_INVALID) scale_action = 0; } @@ -2013,7 +2013,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ if (high_tpt > current_tpt && - sr >= IL_RATE_INCREASE_TH) { + sr >= RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; @@ -2026,7 +2026,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; - } else if (sr >= IL_RATE_INCREASE_TH) { + } else if (sr >= RATE_INCREASE_TH) { scale_action = 1; } } @@ -2034,14 +2034,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != IL_RATE_INVALID && - (sr > IL_RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) + if (scale_action == -1 && low != RATE_INVALID && + (sr > RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) scale_action = 0; switch (scale_action) { case -1: /* Decrease starting rate, update uCode's rate table */ - if (low != IL_RATE_INVALID) { + if (low != RATE_INVALID) { update_lq = 1; index = low; } @@ -2049,7 +2049,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; case 1: /* Increase starting rate, update uCode's rate table */ - if (high != IL_RATE_INVALID) { + if (high != RATE_INVALID) { update_lq = 1; index = high; } @@ -2102,7 +2102,7 @@ lq_update: if (lq_sta->search_better_tbl) { /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &(tbl->win[i])); @@ -2208,7 +2208,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, tbl = &(lq_sta->lq_info[active_tbl]); - if (i < 0 || i >= IL_RATE_COUNT) + if (i < 0 || i >= RATE_COUNT) i = 0; rate = il_rates[i].plcp; @@ -2251,7 +2251,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, lq_sta->max_rate_idx != -1) lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; if (lq_sta->max_rate_idx < 0 || - lq_sta->max_rate_idx >= IL_RATE_COUNT) + lq_sta->max_rate_idx >= RATE_COUNT) lq_sta->max_rate_idx = -1; } @@ -2275,7 +2275,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, /* 6M and 9M shared same MCS index */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - IL_RATE_MIMO2_6M_PLCP) + RATE_MIMO2_6M_PLCP) rate_idx = rate_idx + MCS_INDEX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) @@ -2292,7 +2292,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ - if (rate_idx < 0 || rate_idx >= IL_RATE_COUNT_LEGACY || + if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || (sband->band == IEEE80211_BAND_5GHZ && rate_idx < IL_FIRST_OFDM_RATE)) rate_idx = rate_lowest_index(sband, sta); @@ -2345,14 +2345,14 @@ il4965_rs_rate_init(struct il_priv *il, lq_sta->lq.sta_id = sta_id; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); @@ -2745,7 +2745,7 @@ static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, lq_sta->lq_info[i].is_dup, lq_sta->is_green, lq_sta->lq_info[i].current_rate); - for (j = 0; j < IL_RATE_COUNT; j++) { + for (j = 0; j < RATE_COUNT; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->lq_info[i].win[j].counter, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index a82d444..278517c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -50,9 +50,9 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ if (il->band == IEEE80211_BAND_5GHZ) - r = IL_RATE_6M_INDEX; + r = RATE_6M_INDEX; else - r = IL_RATE_1M_INDEX; + r = RATE_1M_INDEX; if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 68c86e0..9671e10 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -196,7 +196,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, */ rate_idx = info->control.rates[0].idx; if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || - rate_idx < 0 || rate_idx > IL_RATE_COUNT_LEGACY) + rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) rate_idx = rate_lowest_index(&il->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index d1876d0..aed1101 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -2094,7 +2094,7 @@ struct il_link_quality_cmd { * 4965 devices works its way through table when retrying Tx. */ struct { - __le32 rate_n_flags; /* RATE_MCS_*, IL_RATE_* */ + __le32 rate_n_flags; /* RATE_MCS_*, RATE_* */ } rs_table[LINK_QUAL_MAX_RETRY_NUM]; __le32 reserved2; } __packed; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 6742a65..de952fb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -174,7 +174,7 @@ int il_init_geos(struct il_priv *il) if (!channels) return -ENOMEM; - rates = kzalloc((sizeof(struct ieee80211_rate) * IL_RATE_COUNT_LEGACY), + rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), GFP_KERNEL); if (!rates) { kfree(channels); @@ -186,7 +186,7 @@ int il_init_geos(struct il_priv *il) sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; /* just OFDM */ sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; - sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; + sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; if (il->cfg->sku & IL_SKU_N) il_init_ht_hw_capab(il, &sband->ht_cap, @@ -196,7 +196,7 @@ int il_init_geos(struct il_priv *il) sband->channels = channels; /* OFDM & CCK */ sband->bitrates = rates; - sband->n_bitrates = IL_RATE_COUNT_LEGACY; + sband->n_bitrates = RATE_COUNT_LEGACY; if (il->cfg->sku & IL_SKU_N) il_init_ht_hw_capab(il, &sband->ht_cap, @@ -454,8 +454,8 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) } /* make sure basic rates 6Mbps and 1Mbps are supported */ - if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && - (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { + if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && + (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { IL_WARN("neither 1 nor 6 are basic\n"); error = true; } @@ -566,9 +566,9 @@ u8 il_get_lowest_plcp(struct il_priv *il, * the beacon skb from mac80211. */ if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) - return IL_RATE_1M_PLCP; + return RATE_1M_PLCP; else - return IL_RATE_6M_PLCP; + return RATE_6M_PLCP; } EXPORT_SYMBOL(il_get_lowest_plcp); @@ -835,7 +835,7 @@ void il_set_rate(struct il_priv *il) for (i = 0; i < hw->n_bitrates; i++) { rate = &(hw->bitrates[i]); - if (rate->hw_value < IL_RATE_COUNT_LEGACY) + if (rate->hw_value < RATE_COUNT_LEGACY) il->active_rate |= (1 << rate->hw_value); } diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 19fa92d0e..6670f2e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -28,10 +28,10 @@ #define __il_rs_h__ struct il_rate_info { - u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: IL_RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: IL_RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -41,8 +41,8 @@ struct il_rate_info { }; struct il3945_rate_info { - u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -56,153 +56,153 @@ struct il3945_rate_info { /* * These serve as indexes into - * struct il_rate_info il_rates[IL_RATE_COUNT]; + * struct il_rate_info il_rates[RATE_COUNT]; */ enum { - IL_RATE_1M_INDEX = 0, - IL_RATE_2M_INDEX, - IL_RATE_5M_INDEX, - IL_RATE_11M_INDEX, - IL_RATE_6M_INDEX, - IL_RATE_9M_INDEX, - IL_RATE_12M_INDEX, - IL_RATE_18M_INDEX, - IL_RATE_24M_INDEX, - IL_RATE_36M_INDEX, - IL_RATE_48M_INDEX, - IL_RATE_54M_INDEX, - IL_RATE_60M_INDEX, - IL_RATE_COUNT, - IL_RATE_COUNT_LEGACY = IL_RATE_COUNT - 1, /* Excluding 60M */ - IL_RATE_COUNT_3945 = IL_RATE_COUNT - 1, - IL_RATE_INVM_INDEX = IL_RATE_COUNT, - IL_RATE_INVALID = IL_RATE_COUNT, + RATE_1M_INDEX = 0, + RATE_2M_INDEX, + RATE_5M_INDEX, + RATE_11M_INDEX, + RATE_6M_INDEX, + RATE_9M_INDEX, + RATE_12M_INDEX, + RATE_18M_INDEX, + RATE_24M_INDEX, + RATE_36M_INDEX, + RATE_48M_INDEX, + RATE_54M_INDEX, + RATE_60M_INDEX, + RATE_COUNT, + RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ + RATE_COUNT_3945 = RATE_COUNT - 1, + RATE_INVM_INDEX = RATE_COUNT, + RATE_INVALID = RATE_COUNT, }; enum { - IL_RATE_6M_INDEX_TABLE = 0, - IL_RATE_9M_INDEX_TABLE, - IL_RATE_12M_INDEX_TABLE, - IL_RATE_18M_INDEX_TABLE, - IL_RATE_24M_INDEX_TABLE, - IL_RATE_36M_INDEX_TABLE, - IL_RATE_48M_INDEX_TABLE, - IL_RATE_54M_INDEX_TABLE, - IL_RATE_1M_INDEX_TABLE, - IL_RATE_2M_INDEX_TABLE, - IL_RATE_5M_INDEX_TABLE, - IL_RATE_11M_INDEX_TABLE, - IL_RATE_INVM_INDEX_TABLE = IL_RATE_INVM_INDEX - 1, + RATE_6M_INDEX_TABLE = 0, + RATE_9M_INDEX_TABLE, + RATE_12M_INDEX_TABLE, + RATE_18M_INDEX_TABLE, + RATE_24M_INDEX_TABLE, + RATE_36M_INDEX_TABLE, + RATE_48M_INDEX_TABLE, + RATE_54M_INDEX_TABLE, + RATE_1M_INDEX_TABLE, + RATE_2M_INDEX_TABLE, + RATE_5M_INDEX_TABLE, + RATE_11M_INDEX_TABLE, + RATE_INVM_INDEX_TABLE = RATE_INVM_INDEX - 1, }; enum { - IL_FIRST_OFDM_RATE = IL_RATE_6M_INDEX, - IL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, - IL_LAST_OFDM_RATE = IL_RATE_60M_INDEX, - IL_FIRST_CCK_RATE = IL_RATE_1M_INDEX, - IL_LAST_CCK_RATE = IL_RATE_11M_INDEX, + IL_FIRST_OFDM_RATE = RATE_6M_INDEX, + IL39_LAST_OFDM_RATE = RATE_54M_INDEX, + IL_LAST_OFDM_RATE = RATE_60M_INDEX, + IL_FIRST_CCK_RATE = RATE_1M_INDEX, + IL_LAST_CCK_RATE = RATE_11M_INDEX, }; /* #define vs. enum to keep from defaulting to 'large integer' */ -#define IL_RATE_6M_MASK (1 << IL_RATE_6M_INDEX) -#define IL_RATE_9M_MASK (1 << IL_RATE_9M_INDEX) -#define IL_RATE_12M_MASK (1 << IL_RATE_12M_INDEX) -#define IL_RATE_18M_MASK (1 << IL_RATE_18M_INDEX) -#define IL_RATE_24M_MASK (1 << IL_RATE_24M_INDEX) -#define IL_RATE_36M_MASK (1 << IL_RATE_36M_INDEX) -#define IL_RATE_48M_MASK (1 << IL_RATE_48M_INDEX) -#define IL_RATE_54M_MASK (1 << IL_RATE_54M_INDEX) -#define IL_RATE_60M_MASK (1 << IL_RATE_60M_INDEX) -#define IL_RATE_1M_MASK (1 << IL_RATE_1M_INDEX) -#define IL_RATE_2M_MASK (1 << IL_RATE_2M_INDEX) -#define IL_RATE_5M_MASK (1 << IL_RATE_5M_INDEX) -#define IL_RATE_11M_MASK (1 << IL_RATE_11M_INDEX) +#define RATE_6M_MASK (1 << RATE_6M_INDEX) +#define RATE_9M_MASK (1 << RATE_9M_INDEX) +#define RATE_12M_MASK (1 << RATE_12M_INDEX) +#define RATE_18M_MASK (1 << RATE_18M_INDEX) +#define RATE_24M_MASK (1 << RATE_24M_INDEX) +#define RATE_36M_MASK (1 << RATE_36M_INDEX) +#define RATE_48M_MASK (1 << RATE_48M_INDEX) +#define RATE_54M_MASK (1 << RATE_54M_INDEX) +#define RATE_60M_MASK (1 << RATE_60M_INDEX) +#define RATE_1M_MASK (1 << RATE_1M_INDEX) +#define RATE_2M_MASK (1 << RATE_2M_INDEX) +#define RATE_5M_MASK (1 << RATE_5M_INDEX) +#define RATE_11M_MASK (1 << RATE_11M_INDEX) /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { - IL_RATE_6M_PLCP = 13, - IL_RATE_9M_PLCP = 15, - IL_RATE_12M_PLCP = 5, - IL_RATE_18M_PLCP = 7, - IL_RATE_24M_PLCP = 9, - IL_RATE_36M_PLCP = 11, - IL_RATE_48M_PLCP = 1, - IL_RATE_54M_PLCP = 3, - IL_RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - IL_RATE_1M_PLCP = 10, - IL_RATE_2M_PLCP = 20, - IL_RATE_5M_PLCP = 55, - IL_RATE_11M_PLCP = 110, - /*FIXME:RS:add IL_RATE_LEGACY_INVM_PLCP = 0,*/ + RATE_6M_PLCP = 13, + RATE_9M_PLCP = 15, + RATE_12M_PLCP = 5, + RATE_18M_PLCP = 7, + RATE_24M_PLCP = 9, + RATE_36M_PLCP = 11, + RATE_48M_PLCP = 1, + RATE_54M_PLCP = 3, + RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ + RATE_1M_PLCP = 10, + RATE_2M_PLCP = 20, + RATE_5M_PLCP = 55, + RATE_11M_PLCP = 110, + /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ }; /* uCode API values for OFDM high-throughput (HT) bit rates */ enum { - IL_RATE_SISO_6M_PLCP = 0, - IL_RATE_SISO_12M_PLCP = 1, - IL_RATE_SISO_18M_PLCP = 2, - IL_RATE_SISO_24M_PLCP = 3, - IL_RATE_SISO_36M_PLCP = 4, - IL_RATE_SISO_48M_PLCP = 5, - IL_RATE_SISO_54M_PLCP = 6, - IL_RATE_SISO_60M_PLCP = 7, - IL_RATE_MIMO2_6M_PLCP = 0x8, - IL_RATE_MIMO2_12M_PLCP = 0x9, - IL_RATE_MIMO2_18M_PLCP = 0xa, - IL_RATE_MIMO2_24M_PLCP = 0xb, - IL_RATE_MIMO2_36M_PLCP = 0xc, - IL_RATE_MIMO2_48M_PLCP = 0xd, - IL_RATE_MIMO2_54M_PLCP = 0xe, - IL_RATE_MIMO2_60M_PLCP = 0xf, - IL_RATE_SISO_INVM_PLCP, - IL_RATE_MIMO2_INVM_PLCP = IL_RATE_SISO_INVM_PLCP, + RATE_SISO_6M_PLCP = 0, + RATE_SISO_12M_PLCP = 1, + RATE_SISO_18M_PLCP = 2, + RATE_SISO_24M_PLCP = 3, + RATE_SISO_36M_PLCP = 4, + RATE_SISO_48M_PLCP = 5, + RATE_SISO_54M_PLCP = 6, + RATE_SISO_60M_PLCP = 7, + RATE_MIMO2_6M_PLCP = 0x8, + RATE_MIMO2_12M_PLCP = 0x9, + RATE_MIMO2_18M_PLCP = 0xa, + RATE_MIMO2_24M_PLCP = 0xb, + RATE_MIMO2_36M_PLCP = 0xc, + RATE_MIMO2_48M_PLCP = 0xd, + RATE_MIMO2_54M_PLCP = 0xe, + RATE_MIMO2_60M_PLCP = 0xf, + RATE_SISO_INVM_PLCP, + RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP, }; /* MAC header values for bit rates */ enum { - IL_RATE_6M_IEEE = 12, - IL_RATE_9M_IEEE = 18, - IL_RATE_12M_IEEE = 24, - IL_RATE_18M_IEEE = 36, - IL_RATE_24M_IEEE = 48, - IL_RATE_36M_IEEE = 72, - IL_RATE_48M_IEEE = 96, - IL_RATE_54M_IEEE = 108, - IL_RATE_60M_IEEE = 120, - IL_RATE_1M_IEEE = 2, - IL_RATE_2M_IEEE = 4, - IL_RATE_5M_IEEE = 11, - IL_RATE_11M_IEEE = 22, + RATE_6M_IEEE = 12, + RATE_9M_IEEE = 18, + RATE_12M_IEEE = 24, + RATE_18M_IEEE = 36, + RATE_24M_IEEE = 48, + RATE_36M_IEEE = 72, + RATE_48M_IEEE = 96, + RATE_54M_IEEE = 108, + RATE_60M_IEEE = 120, + RATE_1M_IEEE = 2, + RATE_2M_IEEE = 4, + RATE_5M_IEEE = 11, + RATE_11M_IEEE = 22, }; #define IL_CCK_BASIC_RATES_MASK \ - (IL_RATE_1M_MASK | \ - IL_RATE_2M_MASK) + (RATE_1M_MASK | \ + RATE_2M_MASK) #define IL_CCK_RATES_MASK \ (IL_CCK_BASIC_RATES_MASK | \ - IL_RATE_5M_MASK | \ - IL_RATE_11M_MASK) + RATE_5M_MASK | \ + RATE_11M_MASK) #define IL_OFDM_BASIC_RATES_MASK \ - (IL_RATE_6M_MASK | \ - IL_RATE_12M_MASK | \ - IL_RATE_24M_MASK) + (RATE_6M_MASK | \ + RATE_12M_MASK | \ + RATE_24M_MASK) #define IL_OFDM_RATES_MASK \ (IL_OFDM_BASIC_RATES_MASK | \ - IL_RATE_9M_MASK | \ - IL_RATE_18M_MASK | \ - IL_RATE_36M_MASK | \ - IL_RATE_48M_MASK | \ - IL_RATE_54M_MASK) + RATE_9M_MASK | \ + RATE_18M_MASK | \ + RATE_36M_MASK | \ + RATE_48M_MASK | \ + RATE_54M_MASK) #define IL_BASIC_RATES_MASK \ (IL_OFDM_BASIC_RATES_MASK | \ IL_CCK_BASIC_RATES_MASK) -#define IL_RATES_MASK ((1 << IL_RATE_COUNT) - 1) -#define IL_RATES_MASK_3945 ((1 << IL_RATE_COUNT_3945) - 1) +#define RATES_MASK ((1 << RATE_COUNT) - 1) +#define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1) #define IL_INVALID_VALUE -1 @@ -221,10 +221,10 @@ enum { /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ #define IL_RS_GOOD_RATIO 12800 /* 100% */ -#define IL_RATE_SCALE_SWITCH 10880 /* 85% */ -#define IL_RATE_HIGH_TH 10880 /* 85% */ -#define IL_RATE_INCREASE_TH 6400 /* 50% */ -#define IL_RATE_DECREASE_TH 1920 /* 15% */ +#define RATE_SCALE_SWITCH 10880 /* 85% */ +#define RATE_HIGH_TH 10880 /* 85% */ +#define RATE_INCREASE_TH 6400 /* 50% */ +#define RATE_DECREASE_TH 1920 /* 15% */ /* possible actions when in legacy mode */ #define IL_LEGACY_SWITCH_ANTENNA1 0 @@ -268,7 +268,7 @@ enum { #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) -extern const struct il_rate_info il_rates[IL_RATE_COUNT]; +extern const struct il_rate_info il_rates[RATE_COUNT]; enum il_table_type { LQ_NONE, @@ -331,7 +331,7 @@ struct il_scale_tbl_info { u8 max_search; /* maximun number of tables we can search */ s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ u32 current_rate; /* rate_n_flags, uCode API format */ - struct il_rate_scale_data win[IL_RATE_COUNT]; /* rate histories */ + struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ }; struct il_traffic_load { @@ -371,7 +371,7 @@ struct il_lq_sta { u8 is_dup; enum ieee80211_band band; - /* The following are bitmaps of rates; IL_RATE_6M_MASK, etc. */ + /* The following are bitmaps of rates; RATE_6M_MASK, etc. */ u32 supp_rates; u16 active_legacy_rate; u16 active_siso_rate; diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 3c354a8..dcaa3fb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -314,7 +314,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, /* 3945 only */ rate = (il->band == IEEE80211_BAND_5GHZ) ? - IL_RATE_6M_PLCP : IL_RATE_1M_PLCP; + RATE_6M_PLCP : RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index c602570..1fc9bfb 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1654,7 +1654,7 @@ static void il3945_init_hw_rates(struct il_priv *il, { int i; - for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { + for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il3945_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; @@ -2239,7 +2239,7 @@ static void il3945_alive_start(struct il_priv *il) ieee80211_wake_queues(il->hw); - il->active_rate = IL_RATES_MASK_3945; + il->active_rate = RATES_MASK_3945; il_power_update_mode(il, true); @@ -2642,11 +2642,11 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - scan->tx_cmd.rate = IL_RATE_1M_PLCP; + scan->tx_cmd.rate = RATE_1M_PLCP; band = IEEE80211_BAND_2GHZ; break; case IEEE80211_BAND_5GHZ: - scan->tx_cmd.rate = IL_RATE_6M_PLCP; + scan->tx_cmd.rate = RATE_6M_PLCP; band = IEEE80211_BAND_5GHZ; break; default: diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 736c2f5..bc5a008 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1757,7 +1757,7 @@ static void il4965_alive_start(struct il_priv *il) ieee80211_wake_queues(il->hw); - il->active_rate = IL_RATES_MASK; + il->active_rate = RATES_MASK; if (il_is_associated_ctx(ctx)) { struct il_rxon_cmd *active_rxon = @@ -2711,7 +2711,7 @@ static void il4965_init_hw_rates(struct il_priv *il, { int i; - for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { + for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; @@ -2721,7 +2721,7 @@ static void il4965_init_hw_rates(struct il_priv *il, * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (il_rates[i].plcp == IL_RATE_1M_PLCP) ? + (il_rates[i].plcp == RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } -- cgit v0.10.2 From 2d09b0624a1048f6424b2c7ff60ad3a42d8036ff Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 16:10:40 +0200 Subject: iwlegacy: s/INDEX/IDX/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 92fa436..4d83c62 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -64,27 +64,27 @@ struct il3945_tpt_entry { }; static struct il3945_tpt_entry il3945_tpt_table_a[] = { - {-60, RATE_54M_INDEX}, - {-64, RATE_48M_INDEX}, - {-72, RATE_36M_INDEX}, - {-80, RATE_24M_INDEX}, - {-84, RATE_18M_INDEX}, - {-85, RATE_12M_INDEX}, - {-87, RATE_9M_INDEX}, - {-89, RATE_6M_INDEX} + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-72, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-87, RATE_9M_IDX}, + {-89, RATE_6M_IDX} }; static struct il3945_tpt_entry il3945_tpt_table_g[] = { - {-60, RATE_54M_INDEX}, - {-64, RATE_48M_INDEX}, - {-68, RATE_36M_INDEX}, - {-80, RATE_24M_INDEX}, - {-84, RATE_18M_INDEX}, - {-85, RATE_12M_INDEX}, - {-86, RATE_11M_INDEX}, - {-88, RATE_5M_INDEX}, - {-90, RATE_2M_INDEX}, - {-92, RATE_1M_INDEX} + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-68, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-86, RATE_11M_IDX}, + {-88, RATE_5M_IDX}, + {-90, RATE_2M_IDX}, + {-92, RATE_1M_IDX} }; #define RATE_MAX_WINDOW 62 diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 728a90c..3908bff 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -52,16 +52,16 @@ #include "iwl-3945-debugfs.h" #define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ RATE_##r##M_IEEE, \ - RATE_##ip##M_INDEX, \ - RATE_##in##M_INDEX, \ - RATE_##rp##M_INDEX, \ - RATE_##rn##M_INDEX, \ - RATE_##pp##M_INDEX, \ - RATE_##np##M_INDEX, \ - RATE_##r##M_INDEX_TABLE, \ - RATE_##ip##M_INDEX_TABLE } + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX, \ + RATE_##r##M_IDX_TABLE, \ + RATE_##ip##M_IDX_TABLE } /* * Parameter order: @@ -246,16 +246,16 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) switch (il->band) { case IEEE80211_BAND_5GHZ: - if (rate == RATE_12M_INDEX) - next_rate = RATE_9M_INDEX; - else if (rate == RATE_6M_INDEX) - next_rate = RATE_6M_INDEX; + if (rate == RATE_12M_IDX) + next_rate = RATE_9M_IDX; + else if (rate == RATE_6M_IDX) + next_rate = RATE_6M_IDX; break; case IEEE80211_BAND_2GHZ: if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && il_is_associated(il)) { - if (rate == RATE_11M_INDEX) - next_rate = RATE_5M_INDEX; + if (rate == RATE_11M_IDX) + next_rate = RATE_5M_IDX; } break; @@ -307,7 +307,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_INDEX(sequence); + int index = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; @@ -1133,7 +1133,7 @@ static int il3945_is_temp_calib_needed(struct il_priv *il) #define IL_MAX_GAIN_ENTRIES 78 #define IL_CCK_FROM_OFDM_POWER_DIFF -5 -#define IL_CCK_FROM_OFDM_INDEX_DIFF (10) +#define IL_CCK_FROM_OFDM_IDX_DIFF (10) /* radio and DSP power table, each step is 1/2 dB. * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ @@ -1330,7 +1330,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[RATE_6M_INDEX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TABLE]); power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1342,7 +1342,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, * *index*. */ power_index = ch_info->power_info[rate_index].power_table_index - (power - ch_info->power_info - [RATE_6M_INDEX_TABLE].requested_power) * 2; + [RATE_6M_IDX_TABLE].requested_power) * 2; /* store reference index that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1466,7 +1466,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = RATE_6M_INDEX_TABLE; i <= RATE_54M_INDEX_TABLE; + for (i = RATE_6M_IDX_TABLE; i <= RATE_54M_IDX_TABLE; i++, ++power_info) { int delta_idx; @@ -1490,15 +1490,15 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[RATE_12M_INDEX_TABLE]. + ch_info->power_info[RATE_12M_IDX_TABLE]. requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ - for (i = RATE_1M_INDEX_TABLE; i <= RATE_11M_INDEX_TABLE; i++) { + for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) { power_info->requested_power = power; power_info->base_power_index = - ch_info->power_info[RATE_12M_INDEX_TABLE]. - base_power_index + IL_CCK_FROM_OFDM_INDEX_DIFF; + ch_info->power_info[RATE_12M_IDX_TABLE]. + base_power_index + IL_CCK_FROM_OFDM_IDX_DIFF; ++power_info; } } @@ -1597,7 +1597,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; + RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); @@ -2012,19 +2012,19 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) for (rate_index = 0; rate_index < RATE_COUNT_3945; rate_index++, clip_pwrs++) { switch (rate_index) { - case RATE_36M_INDEX_TABLE: + case RATE_36M_IDX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case RATE_48M_INDEX_TABLE: + case RATE_48M_IDX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case RATE_54M_INDEX_TABLE: + case RATE_54M_IDX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2139,13 +2139,13 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[RATE_12M_INDEX_TABLE]; + pwr_info = &ch_info->power_info[RATE_12M_IDX_TABLE]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_index = pwr_info->power_table_index + - IL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_IDX_DIFF; base_pwr_index = pwr_info->base_power_index + - IL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_IDX_DIFF; /* stay within table range */ pwr_index = il3945_hw_reg_fix_power_index(pwr_index); @@ -2169,7 +2169,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; + RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } @@ -2326,17 +2326,17 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_INDEX_TABLE; - i <= RATE_11M_INDEX_TABLE; i++) + for (i = RATE_1M_IDX_TABLE; + i <= RATE_11M_IDX_TABLE; i++) table[i].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; /* Don't fall back to CCK rates */ - table[RATE_12M_INDEX_TABLE].next_rate_index = - RATE_9M_INDEX_TABLE; + table[RATE_12M_IDX_TABLE].next_rate_index = + RATE_9M_IDX_TABLE; /* Don't drop out of OFDM rates */ - table[RATE_6M_INDEX_TABLE].next_rate_index = + table[RATE_6M_IDX_TABLE].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; break; @@ -2349,14 +2349,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { index = IL_FIRST_CCK_RATE; - for (i = RATE_6M_INDEX_TABLE; - i <= RATE_54M_INDEX_TABLE; i++) + for (i = RATE_6M_IDX_TABLE; + i <= RATE_54M_IDX_TABLE; i++) table[i].next_rate_index = il3945_rates[index].table_rs_index; - index = RATE_11M_INDEX_TABLE; + index = RATE_11M_IDX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = RATE_5M_INDEX_TABLE; + table[index].next_rate_index = RATE_5M_IDX_TABLE; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index bb3bc15..d622b27 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -374,30 +374,30 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, struct il_sensitivity_data *data, __le16 *tbl) { - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX] = + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm); - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm_mrc); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX] = + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm_x1); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX] = + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = cpu_to_le16((u16)data->auto_corr_cck); - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = cpu_to_le16((u16)data->auto_corr_cck_mrc); - tbl[HD_MIN_ENERGY_CCK_DET_INDEX] = + tbl[HD_MIN_ENERGY_CCK_DET_IDX] = cpu_to_le16((u16)data->nrg_th_cck); - tbl[HD_MIN_ENERGY_OFDM_DET_INDEX] = + tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = cpu_to_le16((u16)data->nrg_th_ofdm); - tbl[HD_BARKER_CORR_TH_ADD_MIN_INDEX] = + tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = cpu_to_le16(data->barker_corr_th_min); - tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = cpu_to_le16(data->barker_corr_th_min_mrc); - tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = + tbl[HD_OFDM_ENERGY_TH_IN_IDX] = cpu_to_le16(data->nrg_th_cca); D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index 83748c7..2c1b000 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -433,8 +433,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * present during factory calibration). A 5 Ghz EEPROM index of "40" * corresponds to the 49th entry in the table used by the driver. */ -#define MIN_TX_GAIN_INDEX (0) /* highest gain, lowest idx, 2.4 */ -#define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ +#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ +#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ /** * 2.4 GHz gain table diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index e31ee20..7478e91 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -56,13 +56,13 @@ #define RATE_SCALE_FLUSH_INTVL (3*HZ) static u8 rs_ht_to_legacy[] = { - RATE_6M_INDEX, RATE_6M_INDEX, - RATE_6M_INDEX, RATE_6M_INDEX, - RATE_6M_INDEX, - RATE_6M_INDEX, RATE_9M_INDEX, - RATE_12M_INDEX, RATE_18M_INDEX, - RATE_24M_INDEX, RATE_36M_INDEX, - RATE_48M_INDEX, RATE_54M_INDEX + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, + RATE_6M_IDX, RATE_9M_IDX, + RATE_12M_IDX, RATE_18M_IDX, + RATE_24M_IDX, RATE_36M_IDX, + RATE_48M_IDX, RATE_54M_IDX }; static const u8 ant_toggle_lookup[] = { @@ -77,16 +77,16 @@ static const u8 ant_toggle_lookup[] = { }; #define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ RATE_SISO_##s##M_PLCP, \ RATE_MIMO2_##s##M_PLCP,\ RATE_##r##M_IEEE, \ - RATE_##ip##M_INDEX, \ - RATE_##in##M_INDEX, \ - RATE_##rp##M_INDEX, \ - RATE_##rn##M_INDEX, \ - RATE_##pp##M_INDEX, \ - RATE_##np##M_INDEX } + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX } /* * Parameter order: @@ -125,7 +125,7 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) idx += IL_FIRST_OFDM_RATE; /* skip 9M not supported in ht*/ - if (idx >= RATE_9M_INDEX) + if (idx >= RATE_9M_IDX) idx += 1; if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; @@ -218,7 +218,7 @@ static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { { "60", "64QAM 5/6"}, }; -#define MCS_INDEX_PER_STREAM (8) +#define MCS_IDX_PER_STREAM (8) static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) { @@ -856,7 +856,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) + if (mac_index >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) mac_index++; /* * mac80211 HT index is always zero-indexed; we need to move @@ -2276,7 +2276,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= RATE_MIMO2_6M_PLCP) - rate_idx = rate_idx + MCS_INDEX_PER_STREAM; + rate_idx = rate_idx + MCS_IDX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) info->control.rates[0].flags |= diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 278517c..c50d639 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -50,9 +50,9 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ if (il->band == IEEE80211_BAND_5GHZ) - r = RATE_6M_INDEX; + r = RATE_6M_IDX; else - r = RATE_1M_INDEX; + r = RATE_1M_IDX; if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 9671e10..8f18d36 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -423,7 +423,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) */ out_cmd->hdr.cmd = REPLY_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - INDEX_TO_SEQ(q->write_ptr))); + IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); @@ -1172,7 +1172,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx win bits */ - sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4); + sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); if (sh < 0) /* tbw something is wrong with indices */ sh += 0x100; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index f62475d..58bdf93 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -632,9 +632,9 @@ static s32 get_min_power_index(s32 rate_power_index, u32 band) { if (!band) { if ((rate_power_index & 7) <= 4) - return MIN_TX_GAIN_INDEX_52GHZ_EXT; + return MIN_TX_GAIN_IDX_52GHZ_EXT; } - return MIN_TX_GAIN_INDEX; + return MIN_TX_GAIN_IDX; } struct gain_entry { @@ -1654,7 +1654,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, u16 sc; status = le16_to_cpu(frame_status[i].status); seq = le16_to_cpu(frame_status[i].sequence); - idx = SEQ_TO_INDEX(seq); + idx = SEQ_TO_IDX(seq); txq_id = SEQ_TO_QUEUE(seq); if (status & (AGG_TX_STATE_FEW_BYTES_MSK | @@ -1777,7 +1777,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_INDEX(sequence); + int index = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index aed1101..002f1d7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -168,8 +168,8 @@ enum { #define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) #define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) -#define SEQ_TO_INDEX(s) ((s) & 0xff) -#define INDEX_TO_SEQ(i) ((i) & 0xff) +#define SEQ_TO_IDX(s) ((s) & 0xff) +#define IDX_TO_SEQ(i) ((i) & 0xff) #define SEQ_HUGE_FRAME cpu_to_le16(0x4000) #define SEQ_RX_FRAME cpu_to_le16(0x8000) @@ -3116,10 +3116,10 @@ struct il_missed_beacon_notif { * maximum sensitivity): * * START / MIN / MAX - * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120 - * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270 + * HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX 90 / 85 / 120 + * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX 170 / 170 / 210 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX 105 / 105 / 140 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX 220 / 220 / 270 * * If actual rate of OFDM false alarms (+ plcp_errors) is too high * (greater than 50 for each 204.8 msecs listening), reduce sensitivity @@ -3156,26 +3156,26 @@ struct il_missed_beacon_notif { * (notice that the start points for CCK are at maximum sensitivity): * * START / MIN / MAX - * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200 - * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400 - * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100 + * HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX 125 / 125 / 200 + * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX 200 / 200 / 400 + * HD_MIN_ENERGY_CCK_DET_IDX 100 / 0 / 100 * * If actual rate of CCK false alarms (+ plcp_errors) is too high * (greater than 50 for each 204.8 msecs listening), method for reducing * sensitivity is: * - * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX, + * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, * up to max 400. * - * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160, + * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is < 160, * sensitivity has been reduced a significant amount; bring it up to * a moderate 161. Otherwise, *add* 3, up to max 200. * - * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160, + * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is > 160, * sensitivity has been reduced only a moderate or small amount; - * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX, + * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_IDX, * down to min 0. Otherwise (if gain has been significantly reduced), - * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value. + * don't change the HD_MIN_ENERGY_CCK_DET_IDX value. * * b) Save a snapshot of the "silence reference". * @@ -3191,13 +3191,13 @@ struct il_missed_beacon_notif { * * Method for increasing sensitivity: * - * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX, + * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX, * down to min 125. * - * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX, + * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, * down to min 200. * - * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100. + * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_IDX, up to max 100. * * If actual rate of CCK false alarms (+ plcp_errors) is within good range * (between 5 and 50 for each 204.8 msecs listening): @@ -3206,13 +3206,13 @@ struct il_missed_beacon_notif { * * 2) If previous beacon had too many CCK false alarms (+ plcp_errors), * give some extra margin to energy threshold by *subtracting* 8 - * from value in HD_MIN_ENERGY_CCK_DET_INDEX. + * from value in HD_MIN_ENERGY_CCK_DET_IDX. * * For all cases (too few, too many, good range), make sure that the CCK * detection threshold (energy) is below the energy level for robust * detection over the past 10 beacon periods, the "Max cck energy". * Lower values mean higher energy; this means making sure that the value - * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy". + * in HD_MIN_ENERGY_CCK_DET_IDX is at or *above* "Max cck energy". * */ @@ -3220,17 +3220,17 @@ struct il_missed_beacon_notif { * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ #define HD_TABLE_SIZE (11) /* number of entries */ -#define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */ -#define HD_MIN_ENERGY_OFDM_DET_INDEX (1) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6) -#define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7) -#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9) -#define HD_OFDM_ENERGY_TH_IN_INDEX (10) +#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table indexes */ +#define HD_MIN_ENERGY_OFDM_DET_IDX (1) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX (5) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6) +#define HD_BARKER_CORR_TH_ADD_MIN_IDX (7) +#define HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX (8) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX (9) +#define HD_OFDM_ENERGY_TH_IN_IDX (10) /* Control field in struct il_sensitivity_cmd */ #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0) diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index 0ae36df..e993e3e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -162,7 +162,7 @@ * RBs), should be 8 after preparing the first 8 RBs (for example), and must * wrap back to 0 at the end of the circular buffer (but don't wrap before * "read" index has advanced past 1! See below). - * NOTE: 4965 EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8. + * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. * * As the 4965 fills RBs (referenced from contiguous RBDs within the circular * buffer), it updates the Rx status buffer in host DRAM, 2) described above, diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 6670f2e..f3ee0dd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -59,64 +59,64 @@ struct il3945_rate_info { * struct il_rate_info il_rates[RATE_COUNT]; */ enum { - RATE_1M_INDEX = 0, - RATE_2M_INDEX, - RATE_5M_INDEX, - RATE_11M_INDEX, - RATE_6M_INDEX, - RATE_9M_INDEX, - RATE_12M_INDEX, - RATE_18M_INDEX, - RATE_24M_INDEX, - RATE_36M_INDEX, - RATE_48M_INDEX, - RATE_54M_INDEX, - RATE_60M_INDEX, + RATE_1M_IDX = 0, + RATE_2M_IDX, + RATE_5M_IDX, + RATE_11M_IDX, + RATE_6M_IDX, + RATE_9M_IDX, + RATE_12M_IDX, + RATE_18M_IDX, + RATE_24M_IDX, + RATE_36M_IDX, + RATE_48M_IDX, + RATE_54M_IDX, + RATE_60M_IDX, RATE_COUNT, RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ RATE_COUNT_3945 = RATE_COUNT - 1, - RATE_INVM_INDEX = RATE_COUNT, + RATE_INVM_IDX = RATE_COUNT, RATE_INVALID = RATE_COUNT, }; enum { - RATE_6M_INDEX_TABLE = 0, - RATE_9M_INDEX_TABLE, - RATE_12M_INDEX_TABLE, - RATE_18M_INDEX_TABLE, - RATE_24M_INDEX_TABLE, - RATE_36M_INDEX_TABLE, - RATE_48M_INDEX_TABLE, - RATE_54M_INDEX_TABLE, - RATE_1M_INDEX_TABLE, - RATE_2M_INDEX_TABLE, - RATE_5M_INDEX_TABLE, - RATE_11M_INDEX_TABLE, - RATE_INVM_INDEX_TABLE = RATE_INVM_INDEX - 1, + RATE_6M_IDX_TABLE = 0, + RATE_9M_IDX_TABLE, + RATE_12M_IDX_TABLE, + RATE_18M_IDX_TABLE, + RATE_24M_IDX_TABLE, + RATE_36M_IDX_TABLE, + RATE_48M_IDX_TABLE, + RATE_54M_IDX_TABLE, + RATE_1M_IDX_TABLE, + RATE_2M_IDX_TABLE, + RATE_5M_IDX_TABLE, + RATE_11M_IDX_TABLE, + RATE_INVM_IDX_TABLE = RATE_INVM_IDX - 1, }; enum { - IL_FIRST_OFDM_RATE = RATE_6M_INDEX, - IL39_LAST_OFDM_RATE = RATE_54M_INDEX, - IL_LAST_OFDM_RATE = RATE_60M_INDEX, - IL_FIRST_CCK_RATE = RATE_1M_INDEX, - IL_LAST_CCK_RATE = RATE_11M_INDEX, + IL_FIRST_OFDM_RATE = RATE_6M_IDX, + IL39_LAST_OFDM_RATE = RATE_54M_IDX, + IL_LAST_OFDM_RATE = RATE_60M_IDX, + IL_FIRST_CCK_RATE = RATE_1M_IDX, + IL_LAST_CCK_RATE = RATE_11M_IDX, }; /* #define vs. enum to keep from defaulting to 'large integer' */ -#define RATE_6M_MASK (1 << RATE_6M_INDEX) -#define RATE_9M_MASK (1 << RATE_9M_INDEX) -#define RATE_12M_MASK (1 << RATE_12M_INDEX) -#define RATE_18M_MASK (1 << RATE_18M_INDEX) -#define RATE_24M_MASK (1 << RATE_24M_INDEX) -#define RATE_36M_MASK (1 << RATE_36M_INDEX) -#define RATE_48M_MASK (1 << RATE_48M_INDEX) -#define RATE_54M_MASK (1 << RATE_54M_INDEX) -#define RATE_60M_MASK (1 << RATE_60M_INDEX) -#define RATE_1M_MASK (1 << RATE_1M_INDEX) -#define RATE_2M_MASK (1 << RATE_2M_INDEX) -#define RATE_5M_MASK (1 << RATE_5M_INDEX) -#define RATE_11M_MASK (1 << RATE_11M_INDEX) +#define RATE_6M_MASK (1 << RATE_6M_IDX) +#define RATE_9M_MASK (1 << RATE_9M_IDX) +#define RATE_12M_MASK (1 << RATE_12M_IDX) +#define RATE_18M_MASK (1 << RATE_18M_IDX) +#define RATE_24M_MASK (1 << RATE_24M_IDX) +#define RATE_36M_MASK (1 << RATE_36M_IDX) +#define RATE_48M_MASK (1 << RATE_48M_IDX) +#define RATE_54M_MASK (1 << RATE_54M_IDX) +#define RATE_60M_MASK (1 << RATE_60M_IDX) +#define RATE_1M_MASK (1 << RATE_1M_IDX) +#define RATE_2M_MASK (1 << RATE_2M_IDX) +#define RATE_5M_MASK (1 << RATE_5M_IDX) +#define RATE_11M_MASK (1 << RATE_11M_IDX) /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index e149f78..e4a0ef2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -31,11 +31,11 @@ #include "iwl-commands.h" enum il_power_level { - IL_POWER_INDEX_1, - IL_POWER_INDEX_2, - IL_POWER_INDEX_3, - IL_POWER_INDEX_4, - IL_POWER_INDEX_5, + IL_POWER_IDX_1, + IL_POWER_IDX_2, + IL_POWER_IDX_3, + IL_POWER_IDX_4, + IL_POWER_IDX_5, IL_POWER_NUM }; diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index a6bee84..5c0d131 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -62,7 +62,7 @@ * WRITE = READ. * * During initialization, the host sets up the READ queue position to the first - * INDEX position, and WRITE to the last (READ - 1 wrapped) + * IDX position, and WRITE to the last (READ - 1 wrapped) * * When the firmware places a packet in a buffer, it will advance the READ index * and fire the RX interrupt. The driver can then query the READ index and @@ -74,13 +74,13 @@ * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ INDEX is updated (updating the + * iwl->rxq is replenished and the READ IDX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, * detached from the iwl->rxq. The driver 'processed' index is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there * were enough free buffers and RX_STALLED is set it is cleared. * * @@ -96,7 +96,7 @@ * * -- enable interrupts -- * ISR - il_rx() Detach il_rx_bufs from pool up to the - * READ INDEX, detaching the SKB from the pool. + * READ IDX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il_rx_queue_restock to refill any empty * slots. diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index b9c417c..45114b4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -500,7 +500,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) out_cmd->hdr.flags = 0; out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | - INDEX_TO_SEQ(q->write_ptr)); + IDX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; len = sizeof(struct il_device_cmd); @@ -598,7 +598,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_INDEX(sequence); + int index = SEQ_TO_IDX(sequence); int cmd_index; bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); struct il_device_cmd *cmd; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 1fc9bfb..017b297 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -563,7 +563,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) */ out_cmd->hdr.cmd = REPLY_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - INDEX_TO_SEQ(q->write_ptr))); + IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); @@ -903,7 +903,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * WRITE = READ. * * During initialization, the host sets up the READ queue position to the first - * INDEX position, and WRITE to the last (READ - 1 wrapped) + * IDX position, and WRITE to the last (READ - 1 wrapped) * * When the firmware places a packet in a buffer, it will advance the READ index * and fire the RX interrupt. The driver can then query the READ index and @@ -915,13 +915,13 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ INDEX is updated (updating the + * iwl->rxq is replenished and the READ IDX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, * detached from the iwl->rxq. The driver 'processed' index is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there * were enough free buffers and RX_STALLED is set it is cleared. * * @@ -936,7 +936,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * * -- enable interrupts -- * ISR - il3945_rx() Detach il_rx_bufs from pool up to the - * READ INDEX, detaching the SKB from the pool. + * READ IDX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il3945_rx_queue_restock to refill any empty * slots. -- cgit v0.10.2 From 0c2c885200057c44ac5660d123e199192689ca5d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:30:17 +0100 Subject: iwlegacy: s/index/idx/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index fcb466a..53e5fb4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -81,7 +81,7 @@ /* * Mapping of a Tx power level, at factory calibration temperature, - * to a radio/DSP gain table index. + * to a radio/DSP gain table idx. * One for each of 5 "sample" power levels in each band. * v_det is measured at the factory, using the 3945's built-in power amplifier * (PA) output voltage detector. This same detector is used during Tx of @@ -91,13 +91,13 @@ * DO NOT ALTER THIS STRUCTURE!!! */ struct il3945_eeprom_txpower_sample { - u8 gain_index; /* index into power (gain) setup table ... */ + u8 gain_idx; /* idx into power (gain) setup table ... */ s8 power; /* ... for this pwr level for this chnl group */ u16 v_det; /* PA output voltage */ } __packed; /* - * Mappings of Tx power levels -> nominal radio/DSP gain table indexes. + * Mappings of Tx power levels -> nominal radio/DSP gain table idxes. * One for each channel group (a.k.a. "band") (1 for BG, 4 for A). * Tx power setup code interpolates between the 5 "sample" power levels * to determine the nominal setup for a requested power level. diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 4d83c62..f84ed5e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -60,7 +60,7 @@ static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { struct il3945_tpt_entry { s8 min_rssi; - u8 index; + u8 idx; }; static struct il3945_tpt_entry il3945_tpt_table_a[] = { @@ -98,9 +98,9 @@ static struct il3945_tpt_entry il3945_tpt_table_g[] = { #define RATE_DECREASE_TH 1920 #define RATE_RETRY_TH 15 -static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) +static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) { - u32 index = 0; + u32 idx = 0; u32 table_size = 0; struct il3945_tpt_entry *tpt_table = NULL; @@ -123,12 +123,12 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) break; } - while (index < table_size && rssi < tpt_table[index].min_rssi) - index++; + while (idx < table_size && rssi < tpt_table[idx].min_rssi) + idx++; - index = min(index, (table_size - 1)); + idx = min(idx, (table_size - 1)); - return tpt_table[index].index; + return tpt_table[idx].idx; } static void il3945_clear_win(struct il3945_rate_scale_data *win) @@ -168,7 +168,7 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) if (time_after(jiffies, rs_sta->win[i].stamp + RATE_WIN_FLUSH)) { D_RATE("flushing %d samples of rate " - "index %d\n", + "idx %d\n", rs_sta->win[i].counter, i); il3945_clear_win(&rs_sta->win[i]); } else @@ -256,7 +256,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) */ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, struct il3945_rate_scale_data *win, - int success, int retries, int index) + int success, int retries, int idx) { unsigned long flags; s32 fail_count; @@ -318,7 +318,7 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, if (fail_count >= RATE_MIN_FAILURE_TH || win->success_counter >= RATE_MIN_SUCCESS_TH) win->average_tpt = ((win->success_ratio * - rs_sta->expected_tpt[index] + 64) / 128); + rs_sta->expected_tpt[idx] + 64) / 128); else win->average_tpt = IL_INVALID_VALUE; @@ -447,7 +447,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * struct sk_buff *skb) { s8 retries = 0, current_count; - int scale_rate_index, first_index, last_index; + int scale_rate_idx, first_idx, last_idx; unsigned long flags; struct il_priv *il = (struct il_priv *)il_rate; struct il3945_rs_sta *rs_sta = il_sta; @@ -460,9 +460,9 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * if (retries > RATE_RETRY_TH) retries = RATE_RETRY_TH; - first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if (first_index < 0 || first_index >= RATE_COUNT_3945) { - D_RATE("leave: Rate out of bounds: %d\n", first_index); + first_idx = sband->bitrates[info->status.rates[0].idx].hw_value; + if (first_idx < 0 || first_idx >= RATE_COUNT_3945) { + D_RATE("leave: Rate out of bounds: %d\n", first_idx); return; } @@ -480,8 +480,8 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * rs_sta->tx_packets++; - scale_rate_index = first_index; - last_index = first_index; + scale_rate_idx = first_idx; + last_idx = first_idx; /* * Update the win for each rate. We determine which rates @@ -489,42 +489,42 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * * of retries configured for each rate -- currently set to the * il value 'retry_rate' vs. rate specific * - * On exit from this while loop last_index indicates the rate + * On exit from this while loop last_idx indicates the rate * at which the frame was finally transmitted (or failed if no * ACK) */ while (retries > 1) { if ((retries - 1) < il->retry_rate) { current_count = (retries - 1); - last_index = scale_rate_index; + last_idx = scale_rate_idx; } else { current_count = il->retry_rate; - last_index = il3945_rs_next_rate(il, - scale_rate_index); + last_idx = il3945_rs_next_rate(il, + scale_rate_idx); } /* Update this rate accounting for as many retries * as was used for it (per current_count) */ il3945_collect_tx_data(rs_sta, - &rs_sta->win[scale_rate_index], - 0, current_count, scale_rate_index); + &rs_sta->win[scale_rate_idx], + 0, current_count, scale_rate_idx); D_RATE("Update rate %d for %d retries.\n", - scale_rate_index, current_count); + scale_rate_idx, current_count); retries -= current_count; - scale_rate_index = last_index; + scale_rate_idx = last_idx; } - /* Update the last index win with success/failure based on ACK */ + /* Update the last idx win with success/failure based on ACK */ D_RATE("Update rate %d with %s.\n", - last_index, + last_idx, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); il3945_collect_tx_data(rs_sta, - &rs_sta->win[last_index], - info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); + &rs_sta->win[last_idx], + info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); /* We updated the rate scale win -- if its been more than * flush_time since the last run, schedule the flush @@ -547,7 +547,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * } static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, - u8 index, u16 rate_mask, enum ieee80211_band band) + u8 idx, u16 rate_mask, enum ieee80211_band band) { u8 high = RATE_INVALID; u8 low = RATE_INVALID; @@ -560,7 +560,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u32 mask; /* Find the previous rate that is in the rate mask */ - i = index - 1; + i = idx - 1; for (mask = (1 << i); i >= 0; i--, mask >>= 1) { if (rate_mask & mask) { low = i; @@ -569,7 +569,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, } /* Find the next rate that is in the rate mask */ - i = index + 1; + i = idx + 1; for (mask = (1 << i); i < RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { @@ -581,7 +581,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, return (high << 8) | low; } - low = index; + low = idx; while (low != RATE_INVALID) { if (rs_sta->tgg) low = il3945_rates[low].prev_rs_tgg; @@ -594,7 +594,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, D_RATE("Skipping masked lower rate: %d\n", low); } - high = index; + high = idx; while (high != RATE_INVALID) { if (rs_sta->tgg) high = il3945_rates[high].next_rs_tgg; @@ -622,7 +622,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, * the entire A/B/G spectrum vs. being limited to just one particular * hw_mode. * - * As such, we can't convert the index obtained below into the hw_mode's + * As such, we can't convert the idx obtained below into the hw_mode's * rate table and must reference the driver allocated rate table * */ @@ -634,7 +634,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, u8 low = RATE_INVALID; u8 high = RATE_INVALID; u16 high_low; - int index; + int idx; struct il3945_rs_sta *rs_sta = il_sta; struct il3945_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; @@ -668,7 +668,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) max_rate_idx = -1; - index = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); + idx = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); if (sband->band == IEEE80211_BAND_5GHZ) rate_mask = rate_mask << IL_FIRST_OFDM_RATE; @@ -679,19 +679,19 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, * to rssi value */ if (rs_sta->start_rate != RATE_INVALID) { - if (rs_sta->start_rate < index && + if (rs_sta->start_rate < idx && (rate_mask & (1 << rs_sta->start_rate))) - index = rs_sta->start_rate; + idx = rs_sta->start_rate; rs_sta->start_rate = RATE_INVALID; } /* force user max rate if set by user */ - if (max_rate_idx != -1 && max_rate_idx < index) { + if (max_rate_idx != -1 && max_rate_idx < idx) { if (rate_mask & (1 << max_rate_idx)) - index = max_rate_idx; + idx = max_rate_idx; } - win = &(rs_sta->win[index]); + win = &(rs_sta->win[idx]); fail_count = win->counter - win->success_counter; @@ -702,7 +702,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, D_RATE("Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", - index, + idx, win->counter, win->success_counter, rs_sta->expected_tpt ? "not " : ""); @@ -715,7 +715,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, current_tpt = win->average_tpt; - high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask, + high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, sband->band); low = high_low & 0xff; high = (high_low >> 8) & 0xff; @@ -800,13 +800,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Decrese rate */ if (low != RATE_INVALID) - index = low; + idx = low; break; case 1: /* Increase rate */ if (high != RATE_INVALID) - index = high; + idx = high; break; @@ -817,21 +817,21 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } D_RATE("Selected %d (action %d) - low %d high %d\n", - index, scale_action, low, high); + idx, scale_action, low, high); out: if (sband->band == IEEE80211_BAND_5GHZ) { - if (WARN_ON_ONCE(index < IL_FIRST_OFDM_RATE)) - index = IL_FIRST_OFDM_RATE; - rs_sta->last_txrate_idx = index; - info->control.rates[0].idx = index - IL_FIRST_OFDM_RATE; + if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) + idx = IL_FIRST_OFDM_RATE; + rs_sta->last_txrate_idx = idx; + info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE; } else { - rs_sta->last_txrate_idx = index; + rs_sta->last_txrate_idx = idx; info->control.rates[0].idx = rs_sta->last_txrate_idx; } - D_RATE("leave: %d\n", index); + D_RATE("leave: %d\n", idx); } #ifdef CONFIG_MAC80211_DEBUGFS @@ -855,7 +855,7 @@ static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, if (!buff) return -ENOMEM; - desc += sprintf(buff + desc, "tx packets=%d last rate index=%d\n" + desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" "rate=0x%X flush time %d\n", lq_sta->tx_packets, lq_sta->last_txrate_idx, @@ -977,9 +977,9 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) D_RATE("Network RSSI: %d\n", rssi); - rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, il->band); + rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); - D_RATE("leave: rssi %d assign rate index: " + D_RATE("leave: rssi %d assign rate idx: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 3908bff..96a7628 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -86,12 +86,12 @@ const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ }; -static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) +static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) { - u8 rate = il3945_rates[rate_index].prev_ieee; + u8 rate = il3945_rates[rate_idx].prev_ieee; if (rate == RATE_INVALID) - rate = rate_index; + rate = rate_idx; return rate; } @@ -270,12 +270,12 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) /** * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd * - * When FW advances 'R' index, all entries between old and new 'R' index + * When FW advances 'R' idx, all entries between old and new 'R' idx * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ static void il3945_tx_queue_reclaim(struct il_priv *il, - int txq_id, int index) + int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -283,8 +283,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); - for (index = il_queue_inc_wrap(index, q->n_bd); - q->read_ptr != index; + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -307,7 +307,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_IDX(sequence); + int idx = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; @@ -315,10 +315,10 @@ static void il3945_rx_reply_tx(struct il_priv *il, int rate_idx; int fail; - if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { - IL_ERR("Read index for DMA queue txq_id (%d) index %d " + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " "is out of range [0-%d] %d %d\n", txq_id, - index, txq->q.n_bd, txq->q.write_ptr, + idx, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -345,8 +345,8 @@ static void il3945_rx_reply_tx(struct il_priv *il, txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - D_TX_REPLY("Tx queue reclaim %d\n", index); - il3945_tx_queue_reclaim(il, txq_id, index); + D_TX_REPLY("Tx queue reclaim %d\n", idx); + il3945_tx_queue_reclaim(il, txq_id, idx); if (status & TX_ABORT_REQUIRED_MSK) IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); @@ -616,15 +616,15 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, } /** - * il3945_hw_txq_free_tfd - Free one TFD, those at index [txq->q.read_ptr] + * il3945_hw_txq_free_tfd - Free one TFD, those at idx [txq->q.read_ptr] * - * Does NOT advance any indexes + * Does NOT advance any idxes */ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; - int index = txq->q.read_ptr; - struct il3945_tfd *tfd = &tfd_tmp[index]; + int idx = txq->q.read_ptr; + struct il3945_tfd *tfd = &tfd_tmp[idx]; struct pci_dev *dev = il->pci_dev; int i; int counter; @@ -640,8 +640,8 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (counter) pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[index], mapping), - dma_unmap_len(&txq->meta[index], len), + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), PCI_DMA_TODEVICE); /* unmap chunks if any */ @@ -675,7 +675,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; - u16 rate_index = min(hw_value & 0xffff, RATE_COUNT_3945); + u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); u16 rate_mask; int rate; u8 rts_retry_limit; @@ -684,7 +684,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, __le16 fc = hdr->frame_control; struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - rate = il3945_rates[rate_index].plcp; + rate = il3945_rates[rate_idx].plcp; tx_flags = tx_cmd->tx_flags; /* We need to figure out how to get the sta->supp_rates while @@ -1040,7 +1040,7 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) /** * il3945_hw_reg_adjust_power_by_temp - * return index delta into power gain settings table + * return idx delta into power gain settings table */ static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) { @@ -1298,13 +1298,13 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {3, 120} } /* 5.x GHz, lowest power */ }; -static inline u8 il3945_hw_reg_fix_power_index(int index) +static inline u8 il3945_hw_reg_fix_power_idx(int idx) { - if (index < 0) + if (idx < 0) return 0; - if (index >= IL_MAX_GAIN_ENTRIES) + if (idx >= IL_MAX_GAIN_ENTRIES) return IL_MAX_GAIN_ENTRIES - 1; - return (u8) index; + return (u8) idx; } /* Kick off thermal recalibration check every 60 seconds */ @@ -1316,16 +1316,16 @@ static inline u8 il3945_hw_reg_fix_power_index(int index) * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, - s32 rate_index, const s8 *clip_pwrs, +static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, + s32 rate_idx, const s8 *clip_pwrs, struct il_channel_info *ch_info, - int band_index) + int band_idx) { struct il3945_scan_power_info *scan_power_info; s8 power; - u8 power_index; + u8 power_idx; - scan_power_info = &ch_info->scan_pwr_info[scan_tbl_index]; + scan_power_info = &ch_info->scan_pwr_info[scan_tbl_idx]; /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init @@ -1337,30 +1337,30 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, /* find difference between new scan *power* and current "normal" * Tx *power* for 6Mb. Use this difference (x2) to adjust the - * current "normal" temperature-compensated Tx power *index* for + * current "normal" temperature-compensated Tx power *idx* for * this rate (1Mb or 6Mb) to yield new temp-compensated scan power - * *index*. */ - power_index = ch_info->power_info[rate_index].power_table_index + * *idx*. */ + power_idx = ch_info->power_info[rate_idx].power_table_idx - (power - ch_info->power_info [RATE_6M_IDX_TABLE].requested_power) * 2; - /* store reference index that we use when adjusting *all* scan + /* store reference idx that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum * management (single channel) power changes "between" temperature * feedback compensation procedures. - * don't force fit this reference index into gain table; it may be a + * don't force fit this reference idx into gain table; it may be a * negative number. This will help avoid errors when we're at * the lower bounds (highest gains, for warmest temperatures) * of the table. */ /* don't exceed table bounds for "real" setting */ - power_index = il3945_hw_reg_fix_power_index(power_index); + power_idx = il3945_hw_reg_fix_power_idx(power_idx); - scan_power_info->power_table_index = power_index; + scan_power_info->power_table_idx = power_idx; scan_power_info->tpc.tx_gain = - power_gain_table[band_index][power_index].tx_gain; + power_gain_table[band_idx][power_idx].tx_gain; scan_power_info->tpc.dsp_atten = - power_gain_table[band_index][power_index].dsp_atten; + power_gain_table[band_idx][power_idx].dsp_atten; } /** @@ -1438,7 +1438,7 @@ static int il3945_send_tx_power(struct il_priv *il) * il3945_hw_reg_set_new_power - Configures power tables at new levels * @ch_info: Channel to update. Uses power_info.requested_power. * - * Replace requested_power and base_power_index ch_info fields for + * Replace requested_power and base_power_idx ch_info fields for * one channel. * * Called if user or spectrum management changes power preferences. @@ -1460,7 +1460,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, int power; /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* Get this channel's rate-to-current-power settings table */ power_info = ch_info->power_info; @@ -1476,9 +1476,9 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, continue; /* find difference between old and new requested powers, - * update base (non-temp-compensated) power index */ + * update base (non-temp-compensated) power idx */ delta_idx = (power - power_info->requested_power) * 2; - power_info->base_power_index -= delta_idx; + power_info->base_power_idx -= delta_idx; /* save new requested power value */ power_info->requested_power = power; @@ -1496,9 +1496,9 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, /* do all CCK rates' il3945_channel_power_info structures */ for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) { power_info->requested_power = power; - power_info->base_power_index = + power_info->base_power_idx = ch_info->power_info[RATE_12M_IDX_TABLE]. - base_power_index + IL_CCK_FROM_OFDM_IDX_DIFF; + base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; ++power_info; } } @@ -1537,7 +1537,7 @@ static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) * Compensate txpower settings of *all* channels for temperature. * This only accounts for the difference between current temperature * and the factory calibration temperatures, and bases the new settings - * on the channel's base_power_index. + * on the channel's base_power_idx. * * If RxOn is "associated", this sends the new Txpower to NIC! */ @@ -1545,11 +1545,11 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_index; + int delta_idx; const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; - u8 rate_index; - u8 scan_tbl_index; + u8 rate_idx; + u8 scan_tbl_idx; u8 i; int ref_temp; int temperature = il->temperature; @@ -1565,41 +1565,41 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ - ref_temp = (s16)eeprom->groups[ch_info->group_index]. + ref_temp = (s16)eeprom->groups[ch_info->group_idx]. temperature; - /* get power index adjustment based on current and factory + /* get power idx adjustment based on current and factory * temps */ - delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_index = 0; rate_index < RATE_COUNT_3945; - rate_index++) { + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; + rate_idx++) { int power_idx = - ch_info->power_info[rate_index].base_power_index; + ch_info->power_info[rate_idx].base_power_idx; /* temperature compensate */ - power_idx += delta_index; + power_idx += delta_idx; /* stay within table range */ - power_idx = il3945_hw_reg_fix_power_index(power_idx); - ch_info->power_info[rate_index]. - power_table_index = (u8) power_idx; - ch_info->power_info[rate_index].tpc = + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + ch_info->power_info[rate_idx]. + power_table_idx = (u8) power_idx; + ch_info->power_info[rate_idx].tpc = power_gain_table[a_band][power_idx]; } /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_index = 0; - scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { - s32 actual_index = (scan_tbl_index == 0) ? + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; - il3945_hw_reg_set_scan_power(il, scan_tbl_index, - actual_index, clip_pwrs, + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, ch_info, a_band); } } @@ -1878,7 +1878,7 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) } /** - * il3945_hw_reg_get_ch_grp_index - find the channel-group index (0-4) + * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) * for the channel. * * This function is used when initializing channel-info structs. @@ -1888,48 +1888,48 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *il, +static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, const struct il_channel_info *ch_info) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; u8 group; - u16 group_index = 0; /* based on factory calib frequencies */ + u16 group_idx = 0; /* based on factory calib frequencies */ u8 grp_channel; - /* Find the group index for the channel ... don't use index 1(?) */ + /* Find the group idx for the channel ... don't use idx 1(?) */ if (il_is_channel_a_band(ch_info)) { for (group = 1; group < 5; group++) { grp_channel = ch_grp[group].group_channel; if (ch_info->channel <= grp_channel) { - group_index = group; + group_idx = group; break; } } /* group 4 has a few channels *above* its factory cal freq */ if (group == 5) - group_index = 4; + group_idx = 4; } else - group_index = 0; /* 2.4 GHz, group 0 */ + group_idx = 0; /* 2.4 GHz, group 0 */ D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, - group_index); - return group_index; + group_idx); + return group_idx; } /** - * il3945_hw_reg_get_matched_power_index - Interpolate to get nominal index + * il3945_hw_reg_get_matched_power_idx - Interpolate to get nominal idx * - * Interpolate to get nominal (i.e. at factory calibration temperature) index + * Interpolate to get nominal (i.e. at factory calibration temperature) idx * into radio/DSP gain settings table for requested power. */ -static int il3945_hw_reg_get_matched_power_index(struct il_priv *il, +static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, s8 requested_power, - s32 setting_index, s32 *new_index) + s32 setting_idx, s32 *new_idx) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - s32 index0, index1; + s32 idx0, idx1; s32 power = 2 * requested_power; s32 i; const struct il3945_eeprom_txpower_sample *samples; @@ -1937,45 +1937,45 @@ static int il3945_hw_reg_get_matched_power_index(struct il_priv *il, s32 res; s32 denominator; - chnl_grp = &eeprom->groups[setting_index]; + chnl_grp = &eeprom->groups[setting_idx]; samples = chnl_grp->samples; for (i = 0; i < 5; i++) { if (power == samples[i].power) { - *new_index = samples[i].gain_index; + *new_idx = samples[i].gain_idx; return 0; } } if (power > samples[1].power) { - index0 = 0; - index1 = 1; + idx0 = 0; + idx1 = 1; } else if (power > samples[2].power) { - index0 = 1; - index1 = 2; + idx0 = 1; + idx1 = 2; } else if (power > samples[3].power) { - index0 = 2; - index1 = 3; + idx0 = 2; + idx1 = 3; } else { - index0 = 3; - index1 = 4; + idx0 = 3; + idx1 = 4; } - denominator = (s32) samples[index1].power - (s32) samples[index0].power; + denominator = (s32) samples[idx1].power - (s32) samples[idx0].power; if (denominator == 0) return -EINVAL; - gains0 = (s32) samples[index0].gain_index * (1 << 19); - gains1 = (s32) samples[index1].gain_index * (1 << 19); + gains0 = (s32) samples[idx0].gain_idx * (1 << 19); + gains1 = (s32) samples[idx1].gain_idx * (1 << 19); res = gains0 + (gains1 - gains0) * - ((s32) power - (s32) samples[index0].power) / denominator + + ((s32) power - (s32) samples[idx0].power) / denominator + (1 << 18); - *new_index = res >> 19; + *new_idx = res >> 19; return 0; } static void il3945_hw_reg_init_channel_groups(struct il_priv *il) { u32 i; - s32 rate_index; + s32 rate_idx; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; const struct il3945_eeprom_txpower_group *group; @@ -2009,9 +2009,9 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) satur_pwr = (s8) (group->saturation_power >> 1); /* fill in channel group's nominal powers for each rate */ - for (rate_index = 0; - rate_index < RATE_COUNT_3945; rate_index++, clip_pwrs++) { - switch (rate_index) { + for (rate_idx = 0; + rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { + switch (rate_idx) { case RATE_36M_IDX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; @@ -2058,13 +2058,13 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) struct il_channel_info *ch_info = NULL; struct il3945_channel_power_info *pwr_info; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_index; - u8 rate_index; - u8 scan_tbl_index; + int delta_idx; + u8 rate_idx; + u8 scan_tbl_idx; const s8 *clip_pwrs; /* array of power levels for each rate */ u8 gain, dsp_atten; s8 power; - u8 pwr_index, base_pwr_index, a_band; + u8 pwr_idx, base_pwr_idx, a_band; u8 i; int temperature; @@ -2082,56 +2082,56 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) if (!il_is_channel_valid(ch_info)) continue; - /* find this channel's channel group (*not* "band") index */ - ch_info->group_index = - il3945_hw_reg_get_ch_grp_index(il, ch_info); + /* find this channel's channel group (*not* "band") idx */ + ch_info->group_idx = + il3945_hw_reg_get_ch_grp_idx(il, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - /* calculate power index *adjustment* value according to + /* calculate power idx *adjustment* value according to * diff between current temperature and factory temperature */ - delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, - eeprom->groups[ch_info->group_index]. + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, + eeprom->groups[ch_info->group_idx]. temperature); - D_POWER("Delta index for channel %d: %d [%d]\n", - ch_info->channel, delta_index, temperature + + D_POWER("Delta idx for channel %d: %d [%d]\n", + ch_info->channel, delta_idx, temperature + IL_TEMP_CONVERT); /* set tx power value for all OFDM rates */ - for (rate_index = 0; rate_index < IL_OFDM_RATES; - rate_index++) { + for (rate_idx = 0; rate_idx < IL_OFDM_RATES; + rate_idx++) { s32 uninitialized_var(power_idx); int rc; /* use channel group's clip-power table, * but don't exceed channel's max power */ s8 pwr = min(ch_info->max_power_avg, - clip_pwrs[rate_index]); + clip_pwrs[rate_idx]); - pwr_info = &ch_info->power_info[rate_index]; + pwr_info = &ch_info->power_info[rate_idx]; /* get base (i.e. at factory-measured temperature) - * power table index for this rate's power */ - rc = il3945_hw_reg_get_matched_power_index(il, pwr, - ch_info->group_index, + * power table idx for this rate's power */ + rc = il3945_hw_reg_get_matched_power_idx(il, pwr, + ch_info->group_idx, &power_idx); if (rc) { - IL_ERR("Invalid power index\n"); + IL_ERR("Invalid power idx\n"); return rc; } - pwr_info->base_power_index = (u8) power_idx; + pwr_info->base_power_idx = (u8) power_idx; /* temperature compensate */ - power_idx += delta_index; + power_idx += delta_idx; /* stay within range of gain table */ - power_idx = il3945_hw_reg_fix_power_index(power_idx); + power_idx = il3945_hw_reg_fix_power_idx(power_idx); /* fill 1 OFDM rate's il3945_channel_power_info struct */ pwr_info->requested_power = pwr; - pwr_info->power_table_index = (u8) power_idx; + pwr_info->power_table_idx = (u8) power_idx; pwr_info->tpc.tx_gain = power_gain_table[a_band][power_idx].tx_gain; pwr_info->tpc.dsp_atten = @@ -2142,36 +2142,36 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) pwr_info = &ch_info->power_info[RATE_12M_IDX_TABLE]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; - pwr_index = pwr_info->power_table_index + + pwr_idx = pwr_info->power_table_idx + IL_CCK_FROM_OFDM_IDX_DIFF; - base_pwr_index = pwr_info->base_power_index + + base_pwr_idx = pwr_info->base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; /* stay within table range */ - pwr_index = il3945_hw_reg_fix_power_index(pwr_index); - gain = power_gain_table[a_band][pwr_index].tx_gain; - dsp_atten = power_gain_table[a_band][pwr_index].dsp_atten; + pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); + gain = power_gain_table[a_band][pwr_idx].tx_gain; + dsp_atten = power_gain_table[a_band][pwr_idx].dsp_atten; /* fill each CCK rate's il3945_channel_power_info structure * NOTE: All CCK-rate Txpwrs are the same for a given chnl! * NOTE: CCK rates start at end of OFDM rates! */ - for (rate_index = 0; - rate_index < IL_CCK_RATES; rate_index++) { - pwr_info = &ch_info->power_info[rate_index+IL_OFDM_RATES]; + for (rate_idx = 0; + rate_idx < IL_CCK_RATES; rate_idx++) { + pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; pwr_info->requested_power = power; - pwr_info->power_table_index = pwr_index; - pwr_info->base_power_index = base_pwr_index; + pwr_info->power_table_idx = pwr_idx; + pwr_info->base_power_idx = base_pwr_idx; pwr_info->tpc.tx_gain = gain; pwr_info->tpc.dsp_atten = dsp_atten; } /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_index = 0; - scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { - s32 actual_index = (scan_tbl_index == 0) ? + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; - il3945_hw_reg_set_scan_power(il, scan_tbl_index, - actual_index, clip_pwrs, ch_info, a_band); + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, ch_info, a_band); } } @@ -2304,21 +2304,21 @@ static int il3945_manage_ibss_station(struct il_priv *il, */ int il3945_init_hw_rate_table(struct il_priv *il) { - int rc, i, index, prev_index; + int rc, i, idx, prev_idx; struct il3945_rate_scaling_cmd rate_cmd = { .reserved = {0, 0, 0}, }; struct il3945_rate_scaling_info *table = rate_cmd.table; for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { - index = il3945_rates[i].table_rs_index; + idx = il3945_rates[i].table_rs_idx; - table[index].rate_n_flags = + table[idx].rate_n_flags = il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); - table[index].try_cnt = il->retry_rate; - prev_index = il3945_get_prev_ieee_rate(i); - table[index].next_rate_index = - il3945_rates[prev_index].table_rs_index; + table[idx].try_cnt = il->retry_rate; + prev_idx = il3945_get_prev_ieee_rate(i); + table[idx].next_rate_idx = + il3945_rates[prev_idx].table_rs_idx; } switch (il->band) { @@ -2328,16 +2328,16 @@ int il3945_init_hw_rate_table(struct il_priv *il) * have it fall back to the 6M OFDM rate */ for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) - table[i].next_rate_index = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; + table[i].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TABLE].next_rate_index = + table[RATE_12M_IDX_TABLE].next_rate_idx = RATE_9M_IDX_TABLE; /* Don't drop out of OFDM rates */ - table[RATE_6M_IDX_TABLE].next_rate_index = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; + table[RATE_6M_IDX_TABLE].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; break; case IEEE80211_BAND_2GHZ: @@ -2348,15 +2348,15 @@ int il3945_init_hw_rate_table(struct il_priv *il) if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && il_is_associated(il)) { - index = IL_FIRST_CCK_RATE; + idx = IL_FIRST_CCK_RATE; for (i = RATE_6M_IDX_TABLE; i <= RATE_54M_IDX_TABLE; i++) - table[i].next_rate_index = - il3945_rates[index].table_rs_index; + table[i].next_rate_idx = + il3945_rates[idx].table_rs_idx; - index = RATE_11M_IDX_TABLE; + idx = RATE_11M_IDX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = RATE_5M_IDX_TABLE; + table[idx].next_rate_idx = RATE_5M_IDX_TABLE; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index 2c1b000..5c8b8ba 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -203,7 +203,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. * Do not exceed regulatory limit; reduce target txpower if necessary. * - * If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), + * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), * 2 transmitters will be used simultaneously; driver must reduce the * regulatory limit by 3 dB (half-power) for each transmitter, so the * combined total output of the 2 transmitters is within regulatory limits. @@ -269,7 +269,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * be used (although only one at a time) even for non-MIMO transmissions. * * Driver should interpolate factory values for temperature, gain table - * index, and actual power. The power amplifier detector values are + * idx, and actual power. The power amplifier detector values are * not used by the driver. * * Sanity check: If the target channel happens to be one of the sample @@ -278,13 +278,13 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * * 5) Find difference between desired txpower and (interpolated) - * factory-measured txpower. Using (interpolated) factory gain table index - * (shown elsewhere) as a starting point, adjust this index lower to + * factory-measured txpower. Using (interpolated) factory gain table idx + * (shown elsewhere) as a starting point, adjust this idx lower to * increase txpower, or higher to decrease txpower, until the target * txpower is reached. Each step in the gain table is 1/2 dB. * * For example, if factory measured txpower is 16 dBm, and target txpower - * is 13 dBm, add 6 steps to the factory gain index to reduce txpower + * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower * by 3 dB. * * @@ -294,7 +294,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * "4965 temperature calculation". * * If current temperature is higher than factory temperature, driver must - * increase gain (lower gain table index), and vice verse. + * increase gain (lower gain table idx), and vice verse. * * Temperature affects gain differently for different channels: * @@ -313,16 +313,16 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * indicator (EEPROM). * * If the current voltage is higher (indicator is lower) than factory - * voltage, gain should be reduced (gain table index increased) by: + * voltage, gain should be reduced (gain table idx increased) by: * * (eeprom - current) / 7 * * If the current voltage is lower (indicator is higher) than factory - * voltage, gain should be increased (gain table index decreased) by: + * voltage, gain should be increased (gain table idx decreased) by: * * 2 * (current - eeprom) / 7 * - * If number of index steps in either direction turns out to be > 2, + * If number of idx steps in either direction turns out to be > 2, * something is wrong ... just use 0. * * NOTE: Voltage compensation is independent of band/channel. @@ -333,7 +333,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * may be calculated once and used until the next uCode bootload. * * - * 8) If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), + * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), * adjust txpower for each transmitter chain, so txpower is balanced * between the two chains. There are 5 pairs of tx_atten[group][chain] * values in "initialize alive", one pair for each of 5 channel ranges: @@ -344,7 +344,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * Group 3: 5 GHz channel 125-200 * Group 4: 2.4 GHz all channels * - * Add the tx_atten[group][chain] value to the index for the target chain. + * Add the tx_atten[group][chain] value to the idx for the target chain. * The values are signed, but are in pairs of 0 and a non-negative number, * so as to reduce gain (if necessary) of the "hotter" channel. This * avoids any need to double-check for regulatory compliance after @@ -352,7 +352,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation - * value to the index: + * value to the idx: * * Hardware rev B: 9 steps (4.5 dB) * Hardware rev C: 5 steps (2.5 dB) @@ -366,7 +366,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * 10) Select the gain table, based on band (2.4 vs 5 GHz). * - * Limit the adjusted index to stay within the table! + * Limit the adjusted idx to stay within the table! * * * 11) Read gain table entries for DSP and radio gain, place into appropriate @@ -389,7 +389,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * When calculating txpowers for CCK, after making sure that the target power * is within regulatory and saturation limits, driver must additionally - * back off gain by adding these values to the gain table index. + * back off gain by adding these values to the gain table idx. * * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, * bits [3:2], 1 = B, 2 = C. @@ -428,9 +428,9 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * driver work with the same table). * * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table - * has an extension (into negative indexes), in case the driver needs to + * has an extension (into negative idxes), in case the driver needs to * boost power setting for high device temperatures (higher than would be - * present during factory calibration). A 5 Ghz EEPROM index of "40" + * present during factory calibration). A 5 Ghz EEPROM idx of "40" * corresponds to the 49th entry in the table used by the driver. */ #define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ @@ -778,8 +778,8 @@ enum { * * When driver sets up a new TFD, it must also enter the total byte count * of the frame to be transmitted into the corresponding entry in the byte - * count table for the chosen Tx queue. If the TFD index is 0-63, the driver - * must duplicate the byte count entry in corresponding index 256-319. + * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver + * must duplicate the byte count entry in corresponding idx 256-319. * * padding puts each byte count table on a 1024-byte boundary; * 4965 assumes tables are separated by 1024 bytes. diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index ee04977..bbec6bd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -105,7 +105,7 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) /* Stop Rx DMA */ il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - /* Reset driver's Rx queue write index */ + /* Reset driver's Rx queue write idx */ il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ @@ -222,7 +222,7 @@ static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, * and we have free pre-allocated buffers, fill the ranks as much * as we can, pulling from rx_free. * - * This moves the 'write' index forward to catch up with 'processed', and + * This moves the 'write' idx forward to catch up with 'processed', and * also updates the memory address in the firmware to reference the new * target buffer. */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 7478e91..b8f8064 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -151,10 +151,10 @@ static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, #ifdef CONFIG_MAC80211_DEBUGFS static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int index); + u32 *rate_n_flags, int idx); #else static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int index) + u32 *rate_n_flags, int idx) {} #endif @@ -271,7 +271,7 @@ static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; - s32 index; + s32 idx; struct il_traffic_load *tl = NULL; u8 tid; @@ -299,19 +299,19 @@ static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, } time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - index = time_diff / TID_QUEUE_CELL_SPACING; + idx = time_diff / TID_QUEUE_CELL_SPACING; /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ - if (index >= TID_QUEUE_MAX_SIZE) + if (idx >= TID_QUEUE_MAX_SIZE) il4965_rs_tl_rm_old_stats(tl, curr_time); - index = (tl->head + index) % TID_QUEUE_MAX_SIZE; - tl->packet_count[index] = tl->packet_count[index] + 1; + idx = (tl->head + idx) % TID_QUEUE_MAX_SIZE; + tl->packet_count[idx] = tl->packet_count[idx] + 1; tl->total = tl->total + 1; - if ((index + 1) > tl->queue_count) - tl->queue_count = index + 1; + if ((idx + 1) > tl->queue_count) + tl->queue_count = idx + 1; return tid; } @@ -323,7 +323,7 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; - s32 index; + s32 idx; struct il_traffic_load *tl = NULL; if (tid >= TID_MAX_LOAD_COUNT) @@ -337,11 +337,11 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) return 0; time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - index = time_diff / TID_QUEUE_CELL_SPACING; + idx = time_diff / TID_QUEUE_CELL_SPACING; /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ - if (index >= TID_QUEUE_MAX_SIZE) + if (idx >= TID_QUEUE_MAX_SIZE) il4965_rs_tl_rm_old_stats(tl, curr_time); return tl->total; @@ -400,10 +400,10 @@ static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) * that wraps a NULL pointer check */ static s32 -il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) +il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) { if (tbl->expected_tpt) - return tbl->expected_tpt[rs_index]; + return tbl->expected_tpt[rs_idx]; return 0; } @@ -415,20 +415,20 @@ il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) * packets. */ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, - int scale_index, int attempts, int successes) + int scale_idx, int attempts, int successes) { struct il_rate_scale_data *win = NULL; static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; - if (scale_index < 0 || scale_index >= RATE_COUNT) + if (scale_idx < 0 || scale_idx >= RATE_COUNT) return -EINVAL; /* Select win for current tx bit rate */ - win = &(tbl->win[scale_index]); + win = &(tbl->win[scale_idx]); /* Get expected throughput */ - tpt = il4965_get_expected_tpt(tbl, scale_index); + tpt = il4965_get_expected_tpt(tbl, scale_idx); /* * Keep track of only the latest 62 tx frame attempts in this rate's @@ -493,26 +493,26 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, */ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, struct il_scale_tbl_info *tbl, - int index, u8 use_green) + int idx, u8 use_green) { u32 rate_n_flags = 0; if (is_legacy(tbl->lq_type)) { - rate_n_flags = il_rates[index].plcp; - if (index >= IL_FIRST_CCK_RATE && index <= IL_LAST_CCK_RATE) + rate_n_flags = il_rates[idx].plcp; + if (idx >= IL_FIRST_CCK_RATE && idx <= IL_LAST_CCK_RATE) rate_n_flags |= RATE_MCS_CCK_MSK; } else if (is_Ht(tbl->lq_type)) { - if (index > IL_LAST_OFDM_RATE) { - IL_ERR("Invalid HT rate index %d\n", index); - index = IL_LAST_OFDM_RATE; + if (idx > IL_LAST_OFDM_RATE) { + IL_ERR("Invalid HT rate idx %d\n", idx); + idx = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; if (is_siso(tbl->lq_type)) - rate_n_flags |= il_rates[index].plcp_siso; + rate_n_flags |= il_rates[idx].plcp_siso; else - rate_n_flags |= il_rates[index].plcp_mimo2; + rate_n_flags |= il_rates[idx].plcp_mimo2; } else { IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); } @@ -666,7 +666,7 @@ static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, } static u16 -il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, +il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, int rate_type) { u8 high = RATE_INVALID; @@ -679,7 +679,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, u32 mask; /* Find the previous rate that is in the rate mask */ - i = index - 1; + i = idx - 1; for (mask = (1 << i); i >= 0; i--, mask >>= 1) { if (rate_mask & mask) { low = i; @@ -688,7 +688,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, } /* Find the next rate that is in the rate mask */ - i = index + 1; + i = idx + 1; for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { if (rate_mask & mask) { high = i; @@ -699,7 +699,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, return (high << 8) | low; } - low = index; + low = idx; while (low != RATE_INVALID) { low = il_rates[low].prev_rs; if (low == RATE_INVALID) @@ -709,7 +709,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, D_RATE("Skipping masked lower rate: %d\n", low); } - high = index; + high = idx; while (high != RATE_INVALID) { high = il_rates[high].next_rs; if (high == RATE_INVALID) @@ -724,7 +724,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, - u8 scale_index, u8 ht_possible) + u8 scale_idx, u8 ht_possible) { s32 low; u16 rate_mask; @@ -736,9 +736,9 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, /* check if we need to switch from HT to legacy rates. * assumption is that mandatory rates (1Mbps or 6Mbps) * are always supported (spec demand) */ - if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { + if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_idx)) { switch_to_legacy = 1; - scale_index = rs_ht_to_legacy[scale_index]; + scale_idx = rs_ht_to_legacy[scale_idx]; if (lq_sta->band == IEEE80211_BAND_5GHZ) tbl->lq_type = LQ_A; else @@ -766,18 +766,18 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, } /* If we switched from HT to legacy, check current rate */ - if (switch_to_legacy && (rate_mask & (1 << scale_index))) { - low = scale_index; + if (switch_to_legacy && (rate_mask & (1 << scale_idx))) { + low = scale_idx; goto out; } high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, - scale_index, rate_mask, + scale_idx, rate_mask, tbl->lq_type); low = high_low & 0xff; if (low == RATE_INVALID) - low = scale_index; + low = scale_idx; out: return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); @@ -803,7 +803,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, { int legacy_success; int retries; - int rs_index, mac_index, i; + int rs_idx, mac_idx, i; struct il_lq_sta *lq_sta = il_sta; struct il_link_quality_cmd *table; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; @@ -848,35 +848,35 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, - il->band, &tbl_type, &rs_index); + il->band, &tbl_type, &rs_idx); if (il->band == IEEE80211_BAND_5GHZ) - rs_index -= IL_FIRST_OFDM_RATE; + rs_idx -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; - mac_index = info->status.rates[0].idx; + mac_idx = info->status.rates[0].idx; /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { - mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) - mac_index++; + mac_idx &= RATE_MCS_CODE_MSK; /* Remove # of streams */ + if (mac_idx >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) + mac_idx++; /* - * mac80211 HT index is always zero-indexed; we need to move + * mac80211 HT idx is always zero-idxed; we need to move * HT OFDM rates after CCK rates in 2.4 GHz band */ if (il->band == IEEE80211_BAND_2GHZ) - mac_index += IL_FIRST_OFDM_RATE; + mac_idx += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ - if (mac_index < 0 || + if (mac_idx < 0 || tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || tbl_type.ant_type != info->antenna_sel_tx || !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || - rs_index != mac_index) { + rs_idx != mac_idx) { D_RATE( "initial rate %d does not match %d (0x%x)\n", - mac_index, rs_index, tx_rate); + mac_idx, rs_idx, tx_rate); /* * Since rates mis-match, the last LQ command may have failed. * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with @@ -927,13 +927,13 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, * aggregated. * * For aggregation, all packets were transmitted at the same rate, the - * first index into rate scale table. + * first idx into rate scale table. */ if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, - &rs_index); - il4965_rs_collect_tx_data(curr_tbl, rs_index, + &rs_idx); + il4965_rs_collect_tx_data(curr_tbl, rs_idx, info->status.ampdu_len, info->status.ampdu_ack_len); @@ -957,7 +957,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, - &tbl_type, &rs_index); + &tbl_type, &rs_idx); /* * Only collect stats if retried rate is in the same RS * table as active/search. @@ -969,7 +969,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, tmp_tbl = other_tbl; else continue; - il4965_rs_collect_tx_data(tmp_tbl, rs_index, 1, + il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, i < retries ? 0 : legacy_success); } @@ -1074,20 +1074,20 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, static s32 il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ - u16 rate_mask, s8 index) + u16 rate_mask, s8 idx) { /* "active" values */ struct il_scale_tbl_info *active_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - s32 active_sr = active_tbl->win[index].success_ratio; - s32 active_tpt = active_tbl->expected_tpt[index]; + s32 active_sr = active_tbl->win[idx].success_ratio; + s32 active_tpt = active_tbl->expected_tpt[idx]; /* expected "search" throughput */ s32 *tpt_tbl = tbl->expected_tpt; s32 new_rate, high, low, start_hi; u16 high_low; - s8 rate = index; + s8 rate = idx; new_rate = high = low = start_hi = RATE_INVALID; @@ -1169,7 +1169,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; s32 rate; @@ -1203,20 +1203,20 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( - "Can't switch with index %d rate mask %x\n", + "Can't switch with idx %d rate mask %x\n", rate, rate_mask); return -1; } tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1228,7 +1228,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; u8 is_green = lq_sta->is_green; @@ -1256,18 +1256,18 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( - "can not switch with index %d rate mask %x\n", + "can not switch with idx %d rate mask %x\n", rate, rate_mask); return -1; } tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1279,12 +1279,12 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - int index) + int idx) { struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[idx]); u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; @@ -1331,7 +1331,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1360,7 +1360,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1395,13 +1395,13 @@ out: static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int index) + struct ieee80211_sta *sta, int idx) { u8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); @@ -1455,7 +1455,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) goto out; break; @@ -1481,12 +1481,12 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); if (tbl->is_SGI) { s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[index]) + if (tpt >= search_tbl->expected_tpt[idx]) break; } search_tbl->current_rate = il4965_rate_n_flags_from_tbl(il, search_tbl, - index, is_green); + idx, is_green); update_search_tbl_counter = 1; goto out; } @@ -1517,13 +1517,13 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int index) + struct ieee80211_sta *sta, int idx) { s8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); @@ -1575,7 +1575,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) goto out; @@ -1603,12 +1603,12 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, */ if (tbl->is_SGI) { s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[index]) + if (tpt >= search_tbl->expected_tpt[idx]) break; } search_tbl->current_rate = il4965_rate_n_flags_from_tbl(il, search_tbl, - index, is_green); + idx, is_green); update_search_tbl_counter = 1; goto out; @@ -1728,12 +1728,12 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, - int index, u8 is_green) + int idx, u8 is_green) { u32 rate; /* Update uCode's rate table. */ - rate = il4965_rate_n_flags_from_tbl(il, tbl, index, is_green); + rate = il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); il4965_rs_fill_link_cmd(il, lq_sta, rate); il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); @@ -1754,7 +1754,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; int low = RATE_INVALID; int high = RATE_INVALID; - int index; + int idx; int i; struct il_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; @@ -1765,7 +1765,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, u16 rate_mask; u8 update_lq = 0; struct il_scale_tbl_info *tbl, *tbl1; - u16 rate_scale_index_msk = 0; + u16 rate_scale_idx_msk = 0; u32 rate; u8 is_green = 0; u8 active_tbl = 0; @@ -1818,9 +1818,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, is_green = lq_sta->is_green; /* current tx rate */ - index = lq_sta->last_txrate_idx; + idx = lq_sta->last_txrate_idx; - D_RATE("Rate scale index %d for type %d\n", index, + D_RATE("Rate scale idx %d for type %d\n", idx, tbl->lq_type); /* rates available for this association, and for modulation mode */ @@ -1832,19 +1832,19 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (is_legacy(tbl->lq_type)) { if (lq_sta->band == IEEE80211_BAND_5GHZ) /* supp_rates has no CCK bits in A mode */ - rate_scale_index_msk = (u16) (rate_mask & + rate_scale_idx_msk = (u16) (rate_mask & (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else - rate_scale_index_msk = (u16) (rate_mask & + rate_scale_idx_msk = (u16) (rate_mask & lq_sta->supp_rates); } else - rate_scale_index_msk = rate_mask; + rate_scale_idx_msk = rate_mask; - if (!rate_scale_index_msk) - rate_scale_index_msk = rate_mask; + if (!rate_scale_idx_msk) + rate_scale_idx_msk = rate_mask; - if (!((1 << index) & rate_scale_index_msk)) { + if (!((1 << idx) & rate_scale_idx_msk)) { IL_ERR("Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ @@ -1852,9 +1852,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->search_better_tbl = 0; tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ - index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, index, is_green); + tbl, idx, is_green); } return; } @@ -1867,14 +1867,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* force user max rate if set by user */ if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < index) { - index = lq_sta->max_rate_idx; + lq_sta->max_rate_idx < idx) { + idx = lq_sta->max_rate_idx; update_lq = 1; - win = &(tbl->win[index]); + win = &(tbl->win[idx]); goto lq_update; } - win = &(tbl->win[index]); + win = &(tbl->win[idx]); /* * If there is not enough history to calculate actual average @@ -1887,8 +1887,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (fail_count < RATE_MIN_FAILURE_TH && win->success_counter < RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " - "for index %d\n", - win->success_counter, win->counter, index); + "for idx %d\n", + win->success_counter, win->counter, idx); /* Can't calculate this yet; not enough history */ win->average_tpt = IL_INVALID_VALUE; @@ -1902,11 +1902,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Else we have enough samples; calculate estimate of * actual average throughput */ if (win->average_tpt != ((win->success_ratio * - tbl->expected_tpt[index] + 64) / 128)) { + tbl->expected_tpt[idx] + 64) / 128)) { IL_ERR( "expected_tpt should have been calculated by now\n"); win->average_tpt = ((win->success_ratio * - tbl->expected_tpt[index] + 64) / 128); + tbl->expected_tpt[idx] + 64) / 128); } /* If we are searching for better modulation mode, check success. */ @@ -1946,7 +1946,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, tbl = &(lq_sta->lq_info[active_tbl]); /* Revert to "active" rate and throughput info */ - index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); current_tpt = lq_sta->last_tpt; /* Need to set up a new rate table in uCode */ @@ -1962,8 +1962,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(il, index, - rate_scale_index_msk, + high_low = il4965_rs_get_adjacent_rate(il, idx, + rate_scale_idx_msk, tbl->lq_type); low = high_low & 0xff; high = (high_low >> 8) & 0xff; @@ -2043,7 +2043,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Decrease starting rate, update uCode's rate table */ if (low != RATE_INVALID) { update_lq = 1; - index = low; + idx = low; } break; @@ -2051,7 +2051,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Increase starting rate, update uCode's rate table */ if (high != RATE_INVALID) { update_lq = 1; - index = high; + idx = high; } break; @@ -2061,15 +2061,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; } - D_RATE("choose rate scale index %d action %d low %d " + D_RATE("choose rate scale idx %d action %d low %d " "high %d type %d\n", - index, scale_action, low, high, tbl->lq_type); + idx, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, index, is_green); + tbl, idx, is_green); /* Should we stay with this modulation mode, * or search for a new one? */ @@ -2090,13 +2090,13 @@ lq_update: * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) il4965_rs_move_legacy_other(il, lq_sta, - conf, sta, index); + conf, sta, idx); else if (is_siso(tbl->lq_type)) il4965_rs_move_siso_to_other(il, lq_sta, - conf, sta, index); + conf, sta, idx); else /* (is_mimo2(tbl->lq_type)) */ il4965_rs_move_mimo2_to_other(il, lq_sta, - conf, sta, index); + conf, sta, idx); /* If new "search" mode was selected, set up in uCode table */ if (lq_sta->search_better_tbl) { @@ -2107,11 +2107,11 @@ lq_update: &(tbl->win[i])); /* Use new "search" start rate */ - index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); D_RATE( - "Switch current mcs: %X index: %d\n", - tbl->current_rate, index); + "Switch current mcs: %X idx: %d\n", + tbl->current_rate, idx); il4965_rs_fill_link_cmd(il, lq_sta, tbl->current_rate); il_send_lq_cmd(il, ctx, @@ -2157,8 +2157,8 @@ lq_update: out: tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, - index, is_green); - i = index; + idx, is_green); + i = idx; lq_sta->last_txrate_idx = i; } @@ -2272,7 +2272,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { rate_idx -= IL_FIRST_OFDM_RATE; - /* 6M and 9M shared same MCS index */ + /* 6M and 9M shared same MCS idx */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= RATE_MIMO2_6M_PLCP) @@ -2296,7 +2296,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, (sband->band == IEEE80211_BAND_5GHZ && rate_idx < IL_FIRST_OFDM_RATE)) rate_idx = rate_lowest_index(sband, sta); - /* On valid 5 GHz rate, adjust index */ + /* On valid 5 GHz rate, adjust idx */ else if (sband->band == IEEE80211_BAND_5GHZ) rate_idx -= IL_FIRST_OFDM_RATE; info->control.rates[0].flags = 0; @@ -2419,7 +2419,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, u32 new_rate) { struct il_scale_tbl_info tbl_type; - int index = 0; + int idx = 0; int rate_idx; int repeat_rate = 0; u8 ant_toggle_cnt = 0; @@ -2427,8 +2427,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, u8 valid_tx_ant = 0; struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; - /* Override starting rate (index 0) if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + /* Override starting rate (idx 0) if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Interpret new_rate (rate_n_flags) */ il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, @@ -2445,8 +2445,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, lq_cmd->general_params.mimo_delimiter = is_mimo(tbl_type.lq_type) ? 1 : 0; - /* Fill 1st table entry (index 0) */ - lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); + /* Fill 1st table entry (idx 0) */ + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); if (il4965_num_of_ant(tbl_type.ant_type) == 1) { lq_cmd->general_params.single_stream_ant_msk = @@ -2456,17 +2456,17 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, tbl_type.ant_type; } /* otherwise we don't modify the existing value */ - index++; + idx++; repeat_rate--; if (il) valid_tx_ant = il->hw_params.valid_tx_ant; /* Fill rest of rate table */ - while (index < LINK_QUAL_MAX_RETRY_NUM) { + while (idx < LINK_QUAL_MAX_RETRY_NUM) { /* Repeat initial/next rate. * For legacy IL_NUMBER_TRY == 1, this loop will not execute. * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ - while (repeat_rate > 0 && index < LINK_QUAL_MAX_RETRY_NUM) { + while (repeat_rate > 0 && idx < LINK_QUAL_MAX_RETRY_NUM) { if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; @@ -2477,13 +2477,13 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, } /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Fill next table entry */ - lq_cmd->rs_table[index].rate_n_flags = + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); repeat_rate--; - index++; + idx++; } il4965_rs_get_tbl_info_from_mcs(new_rate, @@ -2494,7 +2494,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, * If initial rate was MIMO, this will finally end up * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ if (is_mimo(tbl_type.lq_type)) - lq_cmd->general_params.mimo_delimiter = index; + lq_cmd->general_params.mimo_delimiter = idx; /* Get next rate */ new_rate = il4965_rs_get_lower_rate(lq_sta, @@ -2520,12 +2520,12 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, use_ht_possible = 0; /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Fill next table entry */ - lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); - index++; + idx++; repeat_rate--; } @@ -2564,7 +2564,7 @@ static int il4965_open_file_generic(struct inode *inode, struct file *file) return 0; } static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int index) + u32 *rate_n_flags, int idx) { struct il_priv *il; u8 valid_tx_ant; @@ -2636,7 +2636,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char *buff; int desc = 0; int i = 0; - int index = 0; + int idx = 0; ssize_t ret; struct il_lq_sta *lq_sta = file->private_data; @@ -2687,25 +2687,25 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, desc += sprintf(buff+desc, "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", - lq_sta->lq.general_params.start_rate_index[0], - lq_sta->lq.general_params.start_rate_index[1], - lq_sta->lq.general_params.start_rate_index[2], - lq_sta->lq.general_params.start_rate_index[3]); + lq_sta->lq.general_params.start_rate_idx[0], + lq_sta->lq.general_params.start_rate_idx[1], + lq_sta->lq.general_params.start_rate_idx[2], + lq_sta->lq.general_params.start_rate_idx[3]); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - index = il4965_hwrate_to_plcp_idx( + idx = il4965_hwrate_to_plcp_idx( le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); if (is_legacy(tbl->lq_type)) { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[index].mbps); + il_rate_mcs[idx].mbps); } else { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps (%s)\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[index].mbps, il_rate_mcs[index].mcs); + il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); } } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index c50d639..4cda277 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -157,7 +157,7 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); for (i = 0; i < WEP_KEYS_MAX ; i++) { - wep_cmd->key[i].key_index = i; + wep_cmd->key[i].key_idx = i; if (ctx->wep_keys[i].key_size) { wep_cmd->key[i].key_offset = i; not_empty = 1; @@ -283,7 +283,7 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -334,7 +334,7 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -379,7 +379,7 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -457,9 +457,9 @@ int il4965_remove_dynamic_key(struct il_priv *il, keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { - /* We need to remove a key with index different that the one + /* We need to remove a key with idx different that the one * in the uCode. This means that the key we need to remove has - * been replaced by another one with different index. + * been replaced by another one with different idx. * Don't do anything and return ok */ spin_unlock_irqrestore(&il->sta_lock, flags); @@ -475,7 +475,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, &il->ucode_key_table)) - IL_ERR("index %d not used in uCode key table.\n", + IL_ERR("idx %d not used in uCode key table.\n", il->stations[sta_id].sta.key.key_offset); memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 8f18d36..a6fa1c2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -183,7 +183,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, /* DATA packets will use the uCode station table for rate/antenna * selection */ if (ieee80211_is_data(fc)) { - tx_cmd->initial_rate_index = 0; + tx_cmd->initial_rate_idx = 0; tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; return; } @@ -192,7 +192,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, * If the current TX rate stored in mac80211 has the MCS bit set, it's * not really a TX rate. Thus, we use the lowest supported rate for * this band. Also use the lowest supported rate if the stored rate - * index is invalid. + * idx is invalid. */ rate_idx = info->control.rates[0].idx; if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || @@ -319,7 +319,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) if (!ieee80211_is_data(fc)) sta_id = ctx->bcast_sta_id; else { - /* Find index into station table for destination station */ + /* Find idx into station table for destination station */ sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { @@ -417,7 +417,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD index within the sequence field; + * Store the chosen Tx queue and TFD idx within the sequence field; * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ @@ -513,7 +513,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); - /* Tell device the write index *just past* this latest filled TFD */ + /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); @@ -828,7 +828,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, /* Set this queue as a chain-building queue */ il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - /* Place first TFD at index corresponding to start sequence number. + /* Place first TFD at idx corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); @@ -1105,7 +1105,7 @@ il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); } -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -1113,15 +1113,15 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) int nfreed = 0; struct ieee80211_hdr *hdr; - if (index >= q->n_bd || il_queue_used(q, index) == 0) { - IL_ERR("Read index for DMA queue txq id (%d), index %d, " + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " "is out of range [0-%d] %d %d.\n", txq_id, - index, q->n_bd, q->write_ptr, q->read_ptr); + idx, q->n_bd, q->write_ptr, q->read_ptr); return 0; } - for (index = il_queue_inc_wrap(index, q->n_bd); - q->read_ptr != index; + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -1252,7 +1252,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; struct il_tx_queue *txq = NULL; struct il_ht_agg *agg; - int index; + int idx; int sta_id; int tid; unsigned long flags; @@ -1260,7 +1260,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, /* "flow" corresponds to Tx queue */ u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - /* "ssn" is start of block-ack Tx win, corresponds to index + /* "ssn" is start of block-ack Tx win, corresponds to idx * (in Tx queue's circular buffer) of first TFD/frame in win */ u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); @@ -1287,8 +1287,8 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, return; } - /* Find index just before block-ack win */ - index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); + /* Find idx just before block-ack win */ + idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); spin_lock_irqsave(&il->sta_lock, flags); @@ -1317,7 +1317,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ - int freed = il4965_tx_queue_reclaim(il, scd_flow, index); + int freed = il4965_tx_queue_reclaim(il, scd_flow, idx); il4965_free_tfds_in_queue(il, sta_id, tid, freed); if (il_queue_space(&txq->q) > txq->q.low_mark && diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 58bdf93..8fd383e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -446,12 +446,12 @@ static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) * il4965_get_voltage_compensation - Power supply voltage comp for txpower * * Determines power supply voltage compensation for txpower calculations. - * Returns number of 1/2-dB steps to subtract from gain table index, + * Returns number of 1/2-dB steps to subtract from gain table idx, * to compensate for difference between power supply voltage during * factory measurements, vs. current power supply voltage. * * Voltage indication is higher for lower voltage. - * Lower voltage requires more gain (lower gain table index). + * Lower voltage requires more gain (lower gain table idx). */ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage) @@ -628,10 +628,10 @@ static struct il4965_txpower_comp_entry { {3, 1} /* group 4 2.4, ch all */ }; -static s32 get_min_power_index(s32 rate_power_index, u32 band) +static s32 get_min_power_idx(s32 rate_power_idx, u32 band) { if (!band) { - if ((rate_power_index & 7) <= 4) + if ((rate_power_idx & 7) <= 4) return MIN_TX_GAIN_IDX_52GHZ_EXT; } return MIN_TX_GAIN_IDX; @@ -643,7 +643,7 @@ struct gain_entry { }; static const struct gain_entry gain_table[2][108] = { - /* 5.2GHz power gain index table */ + /* 5.2GHz power gain idx table */ { {123, 0x3F}, /* highest txpower */ {117, 0x3F}, @@ -754,7 +754,7 @@ static const struct gain_entry gain_table[2][108] = { {83, 0x00}, {78, 0x00}, }, - /* 2.4GHz power gain index table */ + /* 2.4GHz power gain idx table */ { {110, 0x3f}, /* highest txpower */ {104, 0x3f}, @@ -891,12 +891,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, s32 degrees_per_05db_denom; s32 factory_temp; s32 temperature_comp[2]; - s32 factory_gain_index[2]; + s32 factory_gain_idx[2]; s32 factory_actual_pwr[2]; - s32 power_index; + s32 power_idx; /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units - * are used for indexing into txpower table) */ + * are used for idxing into txpower table) */ user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ @@ -995,7 +995,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, degrees_per_05db_num, &temperature_comp[c]); - factory_gain_index[c] = measurement->gain_idx; + factory_gain_idx[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; D_TXPOWER("chain = %d\n", c); @@ -1005,7 +1005,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, temperature_comp[c]); D_TXPOWER("fctry idx %d, fctry pwr %d\n", - factory_gain_index[c], + factory_gain_idx[c], factory_actual_pwr[c]); } @@ -1053,50 +1053,50 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, else atten_value = 0; - /* calculate index; higher index means lower txpower */ - power_index = (u8) (factory_gain_index[c] - + /* calculate idx; higher idx means lower txpower */ + power_idx = (u8) (factory_gain_idx[c] - (target_power - factory_actual_pwr[c]) - temperature_comp[c] - voltage_compensation + atten_value); -/* D_TXPOWER("calculated txpower index %d\n", - power_index); */ +/* D_TXPOWER("calculated txpower idx %d\n", + power_idx); */ - if (power_index < get_min_power_index(i, band)) - power_index = get_min_power_index(i, band); + if (power_idx < get_min_power_idx(i, band)) + power_idx = get_min_power_idx(i, band); - /* adjust 5 GHz index to support negative indexes */ + /* adjust 5 GHz idx to support negative idxes */ if (!band) - power_index += 9; + power_idx += 9; /* CCK, rate 32, reduce txpower for CCK */ if (i == POWER_TABLE_CCK_ENTRY) - power_index += + power_idx += IL_TX_POWER_CCK_COMPENSATION_C_STEP; /* stay within the table! */ - if (power_index > 107) { - IL_WARN("txpower index %d > 107\n", - power_index); - power_index = 107; + if (power_idx > 107) { + IL_WARN("txpower idx %d > 107\n", + power_idx); + power_idx = 107; } - if (power_index < 0) { - IL_WARN("txpower index %d < 0\n", - power_index); - power_index = 0; + if (power_idx < 0) { + IL_WARN("txpower idx %d < 0\n", + power_idx); + power_idx = 0; } /* fill txpower command for this rate/chain */ tx_power.s.radio_tx_gain[c] = - gain_table[band][power_index].radio; + gain_table[band][power_idx].radio; tx_power.s.dsp_predis_atten[c] = - gain_table[band][power_index].dsp; + gain_table[band][power_idx].dsp; - D_TXPOWER("chain %d mimo %d index %d " + D_TXPOWER("chain %d mimo %d idx %d " "gain 0x%02x dsp %d\n", - c, atten_value, power_index, + c, atten_value, power_idx, tx_power.s.radio_tx_gain[c], tx_power.s.dsp_predis_atten[c]); } /* for each chain */ @@ -1777,7 +1777,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_IDX(sequence); + int idx = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; @@ -1789,10 +1789,10 @@ static void il4965_rx_reply_tx(struct il_priv *il, u8 *qc = NULL; unsigned long flags; - if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { - IL_ERR("Read index for DMA queue txq_id (%d) index %d " + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " "is out of range [0-%d] %d %d\n", txq_id, - index, txq->q.n_bd, txq->q.write_ptr, + idx, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -1801,7 +1801,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); memset(&info->status, 0, sizeof(info->status)); - hdr = il_tx_queue_get_hdr(il, txq_id, index); + hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (ieee80211_is_data_qos(hdr->frame_control)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; @@ -1821,18 +1821,18 @@ static void il4965_rx_reply_tx(struct il_priv *il, agg = &il->stations[sta_id].tid[tid].agg; - il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, index); + il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); /* check if BAR is needed */ if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; if (txq->q.read_ptr != (scd_ssn & 0xff)) { - index = il_queue_dec_wrap(scd_ssn & 0xff, + idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); D_TX_REPLY("Retry scheduler reclaim scd_ssn " - "%d index %d\n", scd_ssn , index); - freed = il4965_tx_queue_reclaim(il, txq_id, index); + "%d idx %d\n", scd_ssn , idx); + freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc) il4965_free_tfds_in_queue(il, sta_id, tid, freed); @@ -1856,7 +1856,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, le32_to_cpu(tx_resp->rate_n_flags), tx_resp->failure_frame); - freed = il4965_tx_queue_reclaim(il, txq_id, index); + freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc && likely(sta_id != IL_INVALID_STATION)) il4965_free_tfds_in_queue(il, sta_id, tid, freed); else if (sta_id == IL_INVALID_STATION) diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index a75b62c..8076bbe 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -123,7 +123,7 @@ int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb); -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index); +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); void il4965_hw_txq_ctx_free(struct il_priv *il); int il4965_txq_ctx_alloc(struct il_priv *il); void il4965_txq_ctx_reset(struct il_priv *il); @@ -133,7 +133,7 @@ void il4965_txq_set_sched(struct il_priv *il, u32 mask); /* * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index); +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); /** * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 002f1d7..408391295 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -197,7 +197,7 @@ struct il_cmd_header { * * The Linux driver uses the following format: * - * 0:7 tfd index - position within TX queue + * 0:7 tfd idx - position within TX queue * 8:12 TX queue id * 13 reserved * 14 huge - driver sets this to indicate command is in the @@ -454,7 +454,7 @@ struct il_init_alive_resp { * __le32 log_size; log capacity (in number of entries) * __le32 type; (1) timestamp with each entry, (0) no timestamp * __le32 wraps; # times uCode has wrapped to top of circular buffer - * __le32 write_index; next circular buffer entry that uCode would fill + * __le32 write_idx; next circular buffer entry that uCode would fill * * The header is followed by the circular buffer of log entries. Entries * with timestamps have the following format: @@ -901,7 +901,7 @@ struct il_qosparam_cmd { #define STA_MODIFY_DELBA_TID_MSK 0x10 #define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20 -/* Receiver address (actually, Rx station's index into station table), +/* Receiver address (actually, Rx station's idx into station table), * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ #define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) @@ -918,12 +918,12 @@ struct il4965_keyinfo { /** * struct sta_id_modify * @addr[ETH_ALEN]: station's MAC address - * @sta_id: index of station in uCode's station table + * @sta_id: idx of station in uCode's station table * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change * - * Driver selects unused table index when adding new station, - * or the index to a pre-existing station entry when modifying that station. - * Some indexes have special purposes (IL_AP_ID, index 0, is for AP). + * Driver selects unused table idx when adding new station, + * or the idx to a pre-existing station entry when modifying that station. + * Some idxes have special purposes (IL_AP_ID, idx 0, is for AP). * * modify_mask flags select which parameters to modify vs. leave alone. */ @@ -959,7 +959,7 @@ struct sta_id_modify { * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP * are all that are needed for a BSS client station. If the device is * used as AP, or in an IBSS network, driver must set up station table - * entries for all STAs in network, starting with index IL_STA_ID. + * entries for all STAs in network, starting with idx IL_STA_ID. */ struct il3945_addsta_cmd { @@ -1109,7 +1109,7 @@ struct il_rem_sta_cmd { * REPLY_WEP_KEY = 0x20 */ struct il_wep_key { - u8 key_index; + u8 key_idx; u8 key_offset; u8 reserved1[2]; u8 key_size; @@ -1297,7 +1297,7 @@ struct il_rx_mpdu_res_start { /* For 4965 devices: * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD). - * Tx command's initial_rate_index indicates first rate to try; + * Tx command's initial_rate_idx indicates first rate to try; * uCode walks through table for additional Tx attempts. * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. * This rate will be used for all Tx attempts; it will not be scaled. */ @@ -1499,7 +1499,7 @@ struct il_tx_cmd { * rate (via non-0 value) for special frames (e.g. management), while * still supporting rate scaling for all frames. */ - u8 initial_rate_index; + u8 initial_rate_idx; u8 reserved; u8 key[16]; __le16 next_frame_flags; @@ -1792,7 +1792,7 @@ struct il4965_txpowertable_cmd { struct il3945_rate_scaling_info { __le16 rate_n_flags; u8 try_cnt; - u8 next_rate_index; + u8 next_rate_idx; } __packed; struct il3945_rate_scaling_cmd { @@ -1825,7 +1825,7 @@ struct il3945_rate_scaling_cmd { struct il_link_qual_general_params { u8 flags; - /* No entries at or above this (driver chosen) index contain MIMO */ + /* No entries at or above this (driver chosen) idx contain MIMO */ u8 mimo_delimiter; /* Best single antenna to use for single stream (legacy, SISO). */ @@ -1837,7 +1837,7 @@ struct il_link_qual_general_params { /* * If driver needs to use different initial rates for different * EDCA QOS access categories (as implemented by tx fifos 0-3), - * this table will set that up, by indicating the indexes in the + * this table will set that up, by indicating the idxes in the * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start. * Otherwise, driver should set all entries to 0. * @@ -1845,7 +1845,7 @@ struct il_link_qual_general_params { * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3. */ - u8 start_rate_index[LINK_QUAL_AC_NUM]; + u8 start_rate_idx[LINK_QUAL_AC_NUM]; } __packed; #define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ @@ -2089,8 +2089,8 @@ struct il_link_quality_cmd { struct il_link_qual_agg_params agg_params; /* - * Rate info; when using rate-scaling, Tx command's initial_rate_index - * specifies 1st Tx rate attempted, via index into this table. + * Rate info; when using rate-scaling, Tx command's initial_rate_idx + * specifies 1st Tx rate attempted, via idx into this table. * 4965 devices works its way through table when retrying Tx. */ struct { @@ -2233,7 +2233,7 @@ enum il_measure_type { struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ u8 token; - u8 channel_index; /* index in measurement channel list */ + u8 channel_idx; /* idx in measurement channel list */ u8 state; /* 0 - start, 1 - stop */ __le32 start_time; /* lower 32-bits of TSF */ u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ @@ -3220,7 +3220,7 @@ struct il_missed_beacon_notif { * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ #define HD_TABLE_SIZE (11) /* number of entries */ -#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table indexes */ +#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ #define HD_MIN_ENERGY_OFDM_DET_IDX (1) #define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) @@ -3239,13 +3239,13 @@ struct il_missed_beacon_notif { /** * struct il_sensitivity_cmd * @control: (1) updates working table, (0) updates default table - * @table: energy threshold values, use HD_* as index into table + * @table: energy threshold values, use HD_* as idx into table * * Always use "1" in "control" to update uCode's working table and DSP. */ struct il_sensitivity_cmd { __le16 control; /* always use "1" */ - __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */ + __le16 table[HD_TABLE_SIZE]; /* use HD_* as idx */ } __packed; diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index c00ec35..34edec3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -411,10 +411,10 @@ #define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050) /* - * Per-Tx-queue write pointer (index, really!) - * Indicates index to next TFD that driver will fill (1 past latest filled). + * Per-Tx-queue write pointer (idx, really!) + * Indicates idx to next TFD that driver will fill (1 past latest filled). * Bit usage: - * 0-7: queue write index + * 0-7: queue write idx * 11-8: queue selector */ #define HBUS_TARG_WRPTR (HBUS_BASE+0x060) diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 18dd253..2555f9f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -125,8 +125,8 @@ struct il_cmd_meta { */ struct il_queue { int n_bd; /* number of BDs in this queue */ - int write_ptr; /* 1-st empty entry (index) host_w*/ - int read_ptr; /* last used entry (index) host_r*/ + int write_ptr; /* 1-st empty entry (idx) host_w*/ + int read_ptr; /* last used entry (idx) host_r*/ /* use for monitoring and recovering the stuck queue */ dma_addr_t dma_addr; /* physical addr for BD's */ int n_win; /* safe queue win */ @@ -152,7 +152,7 @@ struct il_tx_info { * @dma_addr_cmd: physical address of cmd/tx buffer array * @txb: array of per-TFD driver data * @time_stamp: time (in jiffies) of last read_ptr change - * @need_update: indicates need to update read/write index + * @need_update: indicates need to update read/write idx * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled * * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame @@ -199,11 +199,11 @@ struct il3945_clip_group { * -- hardware capabilities (clip-powers) * -- spectrum management * -- user preference (e.g. iwconfig) - * when requested power is set, base power index must also be set. */ + * when requested power is set, base power idx must also be set. */ struct il3945_channel_power_info { struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_index; /* actual (compenst'd) index into gain table */ - s8 base_power_index; /* gain index for power at factory temp. */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ + s8 base_power_idx; /* gain idx for power at factory temp. */ s8 requested_power; /* power (dBm) requested for this chnl/rate */ }; @@ -211,7 +211,7 @@ struct il3945_channel_power_info { * channel. */ struct il3945_scan_power_info { struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_index; /* actual (compenst'd) index into gain table */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ }; @@ -234,8 +234,8 @@ struct il_channel_info { s8 min_power; /* always 0 */ s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ - u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ - u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ + u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ + u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ enum ieee80211_band band; /* HT40 channel info */ @@ -245,7 +245,7 @@ struct il_channel_info { /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for - * remembering/modifying gain settings (indexes). */ + * remembering/modifying gain settings (idxes). */ struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; /* Radio/DSP gain settings for each scan rate, for directed scans. */ @@ -337,12 +337,12 @@ struct il_host_cmd { * struct il_rx_queue - Rx queue * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) - * @read: Shared index to newest available Rx buffer - * @write: Shared index to oldest written Rx packet + * @read: Shared idx to newest available Rx buffer + * @write: Shared idx to oldest written Rx packet * @free_count: Number of pre-allocated buffers in rx_free * @rx_free: list of free SKBs for use * @rx_used: List of Rx buffers with no SKB - * @need_update: flag to indicate we need to update read/write index + * @need_update: flag to indicate we need to update read/write idx * @rb_stts: driver's pointer to receive buffer status * @rb_stts_dma: bus address of receive buffer status * @@ -636,7 +636,7 @@ static inline int il_queue_used(const struct il_queue *q, int i) } -static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, +static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, int is_huge) { /* @@ -648,7 +648,7 @@ static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, return q->n_win; /* must be power of 2 */ /* Otherwise, use normal size buffers */ - return index & (q->n_win - 1); + return idx & (q->n_win - 1); } @@ -987,7 +987,7 @@ struct il_priv { struct il_force_reset force_reset; /* we allocate array of il_channel_info for NIC's valid channels. - * Access via channel # using indirect index array */ + * Access via channel # using indirect idx array */ struct il_channel_info *channel_info; /* channel info array */ u8 channel_count; /* # of channels */ @@ -1033,7 +1033,7 @@ struct il_priv { struct mac_address addresses[1]; /* uCode images, save to reload in case of failure */ - int fw_index; /* firmware we're trying to load */ + int fw_idx; /* firmware we're trying to load */ u32 ucode_ver; /* version of ucode, copy of il_ucode.ver */ struct fw_desc ucode_code; /* runtime inst */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5786abd..ee5ad69 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -89,7 +89,7 @@ * During init, we copy the eeprom information and channel map * information into il->channel_info_24/52 and il->channel_map_24/52 * - * channel_map_24/52 provides the index in the channel_info array for a + * channel_map_24/52 provides the idx in the channel_info array for a * given channel. We have to have two separate maps as there is channel * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and * band_2 @@ -267,7 +267,7 @@ EXPORT_SYMBOL(il_eeprom_free); static void il_init_band_reference(const struct il_priv *il, int eep_band, int *eeprom_ch_count, const struct il_eeprom_channel **eeprom_ch_info, - const u8 **eeprom_ch_index) + const u8 **eeprom_ch_idx) { u32 offset = il->cfg->ops->lib-> eeprom_ops.regulatory_bands[eep_band - 1]; @@ -276,43 +276,43 @@ static void il_init_band_reference(const struct il_priv *il, *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_1; + *eeprom_ch_idx = il_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_2; + *eeprom_ch_idx = il_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_3; + *eeprom_ch_idx = il_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_4; + *eeprom_ch_idx = il_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_5; + *eeprom_ch_idx = il_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_6; + *eeprom_ch_idx = il_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_7; + *eeprom_ch_idx = il_eeprom_band_7; break; default: BUG(); @@ -374,7 +374,7 @@ static int il_mod_ht40_chan_info(struct il_priv *il, int il_init_channel_map(struct il_priv *il) { int eeprom_ch_count = 0; - const u8 *eeprom_ch_index = NULL; + const u8 *eeprom_ch_idx = NULL; const struct il_eeprom_channel *eeprom_ch_info = NULL; int band, ch; struct il_channel_info *ch_info; @@ -412,11 +412,11 @@ int il_init_channel_map(struct il_priv *il) for (band = 1; band <= 5; band++) { il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_index); + &eeprom_ch_info, &eeprom_ch_idx); /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { - ch_info->channel = eeprom_ch_index[ch]; + ch_info->channel = eeprom_ch_idx[ch]; ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; @@ -486,7 +486,7 @@ int il_init_channel_map(struct il_priv *il) enum ieee80211_band ieeeband; il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_index); + &eeprom_ch_info, &eeprom_ch_idx); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ ieeeband = @@ -496,13 +496,13 @@ int il_init_channel_map(struct il_priv *il) for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_index[ch], + eeprom_ch_idx[ch], &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_index[ch] + 4, + eeprom_ch_idx[ch] + 4, &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40MINUS); } diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index b97c837..eb868c0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -153,7 +153,7 @@ extern const u8 il_eeprom_band_1[14]; * * 1) Temperature (degrees Celsius) of device when measurement was made. * - * 2) Gain table index used to achieve the target measurement power. + * 2) Gain table idx used to achieve the target measurement power. * This refers to the "well-known" gain tables (see iwl-4965-hw.h). * * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index e993e3e..f53f1b8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -141,7 +141,7 @@ * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. * * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers - * (RBs) have been filled, via a "write pointer", actually the index of + * (RBs) have been filled, via a "write pointer", actually the idx of * the RB's corresponding RBD within the circular buffer. Driver sets * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. * @@ -153,33 +153,33 @@ * * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must * enter pointers to these RBs into contiguous RBD circular buffer entries, - * and update the 4965's "write" index register, + * and update the 4965's "write" idx register, * FH_RSCSR_CHNL0_RBDCB_WPTR_REG. * - * This "write" index corresponds to the *next* RBD that the driver will make + * This "write" idx corresponds to the *next* RBD that the driver will make * available, i.e. one RBD past the tail of the ready-to-fill RBDs within * the circular buffer. This value should initially be 0 (before preparing any * RBs), should be 8 after preparing the first 8 RBs (for example), and must * wrap back to 0 at the end of the circular buffer (but don't wrap before - * "read" index has advanced past 1! See below). + * "read" idx has advanced past 1! See below). * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. * * As the 4965 fills RBs (referenced from contiguous RBDs within the circular * buffer), it updates the Rx status buffer in host DRAM, 2) described above, - * to tell the driver the index of the latest filled RBD. The driver must - * read this "read" index from DRAM after receiving an Rx interrupt from 4965. + * to tell the driver the idx of the latest filled RBD. The driver must + * read this "read" idx from DRAM after receiving an Rx interrupt from 4965. * - * The driver must also internally keep track of a third index, which is the + * The driver must also internally keep track of a third idx, which is the * next RBD to process. When receiving an Rx interrupt, driver should process * all filled but unprocessed RBs up to, but not including, the RB - * corresponding to the "read" index. For example, if "read" index becomes "1", + * corresponding to the "read" idx. For example, if "read" idx becomes "1", * driver may process the RB pointed to by RBD 0. Depending on volume of * traffic, there may be many RBs to process. * - * If read index == write index, 4965 thinks there is no room to put new data. + * If read idx == write idx, 4965 thinks there is no room to put new data. * Due to this, the maximum number of filled RBs is 255, instead of 256. To * be safe, make sure that there is a gap of at least 2 RBDs between "write" - * and "read" indexes; that is, make sure that there are no more than 254 + * and "read" idxes; that is, make sure that there are no more than 254 * buffers waiting to be filled. */ #define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0) @@ -201,7 +201,7 @@ #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004) /** - * Rx write pointer (index, really!). + * Rx write pointer (idx, really!). * Bit fields: * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. * NOTE: For 256-entry circular buffer, use only bits [7:0]. @@ -431,11 +431,11 @@ /** * struct il_rb_status - reseve buffer status * host memory mapped FH registers - * @closed_rb_num [0:11] - Indicates the index of the RB which was closed - * @closed_fr_num [0:11] - Indicates the index of the RX Frame which was closed - * @finished_rb_num [0:11] - Indicates the index of the current RB + * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed + * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed + * @finished_rb_num [0:11] - Indicates the idx of the current RB * in which the last frame was written to - * @finished_fr_num [0:11] - Indicates the index of the RX Frame + * @finished_fr_num [0:11] - Indicates the idx of the RX Frame * which was transferred */ struct il_rb_status { diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index a9d8702..5fcb23e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -45,23 +45,23 @@ static inline struct ieee80211_conf *il_ieee80211_get_hw_conf( } /** - * il_queue_inc_wrap - increment queue index, wrap back to beginning - * @index -- current index + * il_queue_inc_wrap - increment queue idx, wrap back to beginning + * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_inc_wrap(int index, int n_bd) +static inline int il_queue_inc_wrap(int idx, int n_bd) { - return ++index & (n_bd - 1); + return ++idx & (n_bd - 1); } /** - * il_queue_dec_wrap - decrement queue index, wrap back to end - * @index -- current index + * il_queue_dec_wrap - decrement queue idx, wrap back to end + * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_dec_wrap(int index, int n_bd) +static inline int il_queue_dec_wrap(int idx, int n_bd) { - return --index & (n_bd - 1); + return --idx & (n_bd - 1); } /* TODO: Move fw_desc functions to iwl-pci.ko */ diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index a283804..3652cdc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -41,7 +41,7 @@ #include "iwl-core.h" #include "iwl-io.h" -/* default: IL_LED_BLINK(0) using blinking index table */ +/* default: IL_LED_BLINK(0) using blinking idx table */ static int led_mode; module_param(led_mode, int, S_IRUGO); MODULE_PARM_DESC(led_mode, "0=system default, " diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index f3ee0dd..bc09a5d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -49,13 +49,13 @@ struct il3945_rate_info { u8 next_rs; /* next rate used in rs algo */ u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ u8 next_rs_tgg; /* next rate used in TGG rs algo */ - u8 table_rs_index; /* index in rate scale table cmd */ + u8 table_rs_idx; /* idx in rate scale table cmd */ u8 prev_table_rs; /* prev in rate table cmd */ }; /* - * These serve as indexes into + * These serve as idxes into * struct il_rate_info il_rates[RATE_COUNT]; */ enum { @@ -351,7 +351,7 @@ struct il_traffic_load { * Pointer to this gets passed back and forth between driver and mac80211. */ struct il_lq_sta { - u8 active_tbl; /* index of active table, range 0-1 */ + u8 active_tbl; /* idx of active table, range 0-1 */ u8 enable_counter; /* indicates HT mode */ u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ u8 search_better_tbl; /* 1: currently trying alternate mode */ diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 200f295..8128c87 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -336,7 +336,7 @@ /* * Driver may need to update queue-empty bits after changing queue's - * write and read pointers (indexes) during (re-)initialization (i.e. when + * write and read pointers (idxes) during (re-)initialization (i.e. when * scheduler is not tracking what's happening). * Bit fields: * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit @@ -351,7 +351,7 @@ * This register points to BC CB for queue 0, must be on 1024-byte boundary. * Others are spaced by 1024 bytes. * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. - * (Index into a queue's BC CB) = (index into queue's TFD CB) = (SSN & 0xff). + * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff). * Bit fields: * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. */ @@ -366,18 +366,18 @@ */ #define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) /* - * Queue (x) Write Pointers (indexes, really!), one for each Tx queue. + * Queue (x) Write Pointers (idxes, really!), one for each Tx queue. * Initialized and updated by driver as new TFDs are added to queue. - * NOTE: If using Block Ack, index must correspond to frame's - * Start Sequence Number; index = (SSN & 0xff) + * NOTE: If using Block Ack, idx must correspond to frame's + * Start Sequence Number; idx = (SSN & 0xff) * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? */ #define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) /* - * Queue (x) Read Pointers (indexes, really!), one for each Tx queue. - * For FIFO mode, index indicates next frame to transmit. - * For Scheduler-ACK mode, index indicates first frame in Tx win. + * Queue (x) Read Pointers (idxes, really!), one for each Tx queue. + * For FIFO mode, idx indicates next frame to transmit. + * For Scheduler-ACK mode, idx indicates first frame in Tx win. * Initialized by driver, updated by scheduler. */ #define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) @@ -395,7 +395,7 @@ /* * Select which queues interrupt driver when scheduler increments - * a queue's read pointer (index). + * a queue's read pointer (idx). * Bit fields: * 31-16: Reserved * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 5c0d131..58d19c1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -45,17 +45,17 @@ * each of which point to Receive Buffers to be filled by the NIC. These get * used not only for Rx frames, but for any command response or notification * from the NIC. The driver and NIC manage the Rx buffers by means - * of indexes into the circular buffer. + * of idxes into the circular buffer. * * Rx Queue Indexes - * The host/firmware share two index registers for managing the Rx buffers. + * The host/firmware share two idx registers for managing the Rx buffers. * - * The READ index maps to the first position that the firmware may be writing + * The READ idx maps to the first position that the firmware may be writing * to -- the driver can read up to (but not including) this position and get * good data. - * The READ index is managed by the firmware once the card is enabled. + * The READ idx is managed by the firmware once the card is enabled. * - * The WRITE index maps to the last position the driver has read from -- the + * The WRITE idx maps to the last position the driver has read from -- the * position preceding WRITE is the last slot the firmware can place a packet. * * The queue is empty (no good data) if WRITE = READ - 1, and is full if @@ -64,9 +64,9 @@ * During initialization, the host sets up the READ queue position to the first * IDX position, and WRITE to the last (READ - 1 wrapped) * - * When the firmware places a packet in a buffer, it will advance the READ index - * and fire the RX interrupt. The driver can then query the READ index and - * process as many packets as possible, moving the WRITE index forward as it + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it * resets the Rx queue buffers with new memory. * * The management in the driver is as follows: @@ -75,9 +75,9 @@ * to replenish the iwl->rxq->rx_free. * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver indexes as well) + * 'processed' and 'read' driver idxes as well) * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' index is updated. + * detached from the iwl->rxq. The driver 'processed' idx is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ * IDX is not incremented and iwl->status(RX_STALLED) is set. If there @@ -91,7 +91,7 @@ * il_rx_queue_restock * il_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates - * the WRITE index. If insufficient rx_free buffers + * the WRITE idx. If insufficient rx_free buffers * are available, schedules il_rx_replenish * * -- enable interrupts -- diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index dcaa3fb..a7fe9ea 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -174,7 +174,7 @@ int il_send_add_sta(struct il_priv *il, } EXPORT_SYMBOL(il_send_add_sta); -static void il_set_ht_add_station(struct il_priv *il, u8 index, +static void il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, struct il_rxon_context *ctx) { @@ -192,7 +192,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? "dynamic" : "disabled"); - sta_flags = il->stations[index].sta.station_flags; + sta_flags = il->stations[idx].sta.station_flags; sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); @@ -221,7 +221,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, else sta_flags &= ~STA_FLG_HT40_EN_MSK; - il->stations[index].sta.station_flags = sta_flags; + il->stations[idx].sta.station_flags = sta_flags; done: return; } @@ -649,7 +649,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) } EXPORT_SYMBOL(il_restore_stations); -int il_get_free_ucode_key_index(struct il_priv *il) +int il_get_free_ucode_key_idx(struct il_priv *il) { int i; @@ -659,7 +659,7 @@ int il_get_free_ucode_key_index(struct il_priv *il) return WEP_INVALID_OFFSET; } -EXPORT_SYMBOL(il_get_free_ucode_key_index); +EXPORT_SYMBOL(il_get_free_ucode_key_idx); void il_dealloc_bcast_stations(struct il_priv *il) { @@ -692,7 +692,7 @@ static void il_dump_lq_cmd(struct il_priv *il, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - D_RATE("lq index %d 0x%X\n", + D_RATE("lq idx %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else @@ -728,7 +728,7 @@ static bool il_is_lq_table_valid(struct il_priv *il, if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { D_INFO( - "index %d of LQ expects HT channel\n", + "idx %d of LQ expects HT channel\n", i); return false; } diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index 77cdfd4..f07cd7f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -48,7 +48,7 @@ void il_restore_stations(struct il_priv *il, void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx); void il_dealloc_bcast_stations(struct il_priv *il); -int il_get_free_ucode_key_index(struct il_priv *il); +int il_get_free_ucode_key_idx(struct il_priv *il); int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); int il_add_station_common(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 45114b4..10a0914 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -39,7 +39,7 @@ #include "iwl-helpers.h" /** - * il_txq_update_write_ptr - Send new write index to hardware + * il_txq_update_write_ptr - Send new write idx to hardware */ void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) @@ -152,7 +152,7 @@ void il_cmd_queue_unmap(struct il_priv *il) return; while (q->read_ptr != q->write_ptr) { - i = il_get_cmd_index(q, q->read_ptr, 0); + i = il_get_cmd_idx(q, q->read_ptr, 0); if (txq->meta[i].flags & CMD_MAPPED) { pci_unmap_single(il->pci_dev, @@ -254,7 +254,7 @@ EXPORT_SYMBOL(il_queue_space); /** - * il_queue_init - Initialize queue's high/low-water and read/write indexes + * il_queue_init - Initialize queue's high/low-water and read/write idxes */ static int il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, u32 id) @@ -268,7 +268,7 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, BUG_ON(!is_power_of_2(count)); /* slots_num must be power-of-two size, otherwise - * il_get_cmd_index is broken. */ + * il_get_cmd_idx is broken. */ BUG_ON(!is_power_of_2(slots_num)); q->low_mark = q->n_win / 4; @@ -385,7 +385,7 @@ int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); - /* Initialize queue's high/low-water marks, and head/tail indexes */ + /* Initialize queue's high/low-water marks, and head/tail idxes */ il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); @@ -416,7 +416,7 @@ void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, txq->need_update = 0; - /* Initialize queue's high/low-water marks, and head/tail indexes */ + /* Initialize queue's high/low-water marks, and head/tail idxes */ il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); @@ -433,7 +433,7 @@ EXPORT_SYMBOL(il_tx_queue_reset); * @cmd: a point to the ucode command structure * * The function returns < 0 values to indicate the operation is - * failed. On success, it turns the index (> 0) of command in the + * failed. On success, it turns the idx (> 0) of command in the * command queue. */ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) @@ -476,7 +476,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) return -ENOSPC; } - idx = il_get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); + idx = il_get_cmd_idx(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); out_cmd = txq->cmd[idx]; out_meta = &txq->meta[idx]; @@ -543,7 +543,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) phys_addr, fix_size, 1, U32_PAD(cmd->len)); - /* Increment and update queue's write index */ + /* Increment and update queue's write idx */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); @@ -554,7 +554,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) /** * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd * - * When FW advances 'R' index, all entries between old and new 'R' index + * When FW advances 'R' idx, all entries between old and new 'R' idx * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ @@ -566,7 +566,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int nfreed = 0; if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { - IL_ERR("Read index for DMA queue txq id (%d), index %d, " + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; @@ -576,7 +576,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IL_ERR("HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); queue_work(il->workqueue, &il->restart); } @@ -598,8 +598,8 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_IDX(sequence); - int cmd_index; + int idx = SEQ_TO_IDX(sequence); + int cmd_idx; bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); struct il_device_cmd *cmd; struct il_cmd_meta *meta; @@ -618,9 +618,9 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) return; } - cmd_index = il_get_cmd_index(&txq->q, index, huge); - cmd = txq->cmd[cmd_index]; - meta = &txq->meta[cmd_index]; + cmd_idx = il_get_cmd_idx(&txq->q, idx, huge); + cmd = txq->cmd[cmd_idx]; + meta = &txq->meta[cmd_idx]; txq->time_stamp = jiffies; @@ -638,7 +638,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) spin_lock_irqsave(&il->hcmd_lock, flags); - il_hcmd_queue_reclaim(il, txq_id, index, cmd_index); + il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); if (!(meta->flags & CMD_ASYNC)) { clear_bit(STATUS_HCMD_ACTIVE, &il->status); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 017b297..9244208 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -163,7 +163,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -513,7 +513,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) hdr_len = ieee80211_hdrlen(fc); - /* Find index into station table for destination station */ + /* Find idx into station table for destination station */ sta_id = il_sta_id_or_broadcast( il, &il->ctx, info->control.sta); @@ -541,7 +541,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) spin_lock_irqsave(&il->lock, flags); - idx = il_get_cmd_index(q, q->write_ptr, 0); + idx = il_get_cmd_idx(q, q->write_ptr, 0); /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); @@ -557,7 +557,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD index within the sequence field; + * Store the chosen Tx queue and TFD idx within the sequence field; * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ @@ -641,7 +641,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) } - /* Tell device the write index *just past* this latest filled TFD */ + /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); @@ -889,14 +889,14 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * 0 to 31 * * Rx Queue Indexes - * The host/firmware share two index registers for managing the Rx buffers. + * The host/firmware share two idx registers for managing the Rx buffers. * - * The READ index maps to the first position that the firmware may be writing + * The READ idx maps to the first position that the firmware may be writing * to -- the driver can read up to (but not including) this position and get * good data. - * The READ index is managed by the firmware once the card is enabled. + * The READ idx is managed by the firmware once the card is enabled. * - * The WRITE index maps to the last position the driver has read from -- the + * The WRITE idx maps to the last position the driver has read from -- the * position preceding WRITE is the last slot the firmware can place a packet. * * The queue is empty (no good data) if WRITE = READ - 1, and is full if @@ -905,9 +905,9 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * During initialization, the host sets up the READ queue position to the first * IDX position, and WRITE to the last (READ - 1 wrapped) * - * When the firmware places a packet in a buffer, it will advance the READ index - * and fire the RX interrupt. The driver can then query the READ index and - * process as many packets as possible, moving the WRITE index forward as it + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it * resets the Rx queue buffers with new memory. * * The management in the driver is as follows: @@ -916,9 +916,9 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * to replenish the iwl->rxq->rx_free. * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver indexes as well) + * 'processed' and 'read' driver idxes as well) * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' index is updated. + * detached from the iwl->rxq. The driver 'processed' idx is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ * IDX is not incremented and iwl->status(RX_STALLED) is set. If there @@ -931,7 +931,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * il3945_rx_queue_restock * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates - * the WRITE index. If insufficient rx_free buffers + * the WRITE idx. If insufficient rx_free buffers * are available, schedules il3945_rx_replenish * * -- enable interrupts -- @@ -960,7 +960,7 @@ static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, * and we have free pre-allocated buffers, fill the ranks as much * as we can, pulling from rx_free. * - * This moves the 'write' index forward to catch up with 'processed', and + * This moves the 'write' idx forward to catch up with 'processed', and * also updates the memory address in the firmware to reference the new * target buffer. */ @@ -1211,7 +1211,7 @@ static void il3945_rx_handle(struct il_priv *il) u32 count = 8; int total_empty = 0; - /* uCode's read index (stored in shared DRAM) indicates the last Rx + /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; @@ -1656,7 +1656,7 @@ static void il3945_init_hw_rates(struct il_priv *il, for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il3945_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on indexes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { @@ -1850,7 +1850,7 @@ IL3945_UCODE_GET(boot_size); static int il3945_read_ucode(struct il_priv *il) { const struct il_ucode_header *ucode; - int ret = -EINVAL, index; + int ret = -EINVAL, idx; const struct firmware *ucode_raw; /* firmware file name contains uCode/driver compatibility version */ const char *name_pre = il->cfg->fw_name_pre; @@ -1863,8 +1863,8 @@ static int il3945_read_ucode(struct il_priv *il) /* Ask kernel firmware_class module to get the boot firmware off disk. * request_firmware() is synchronous, file is in memory on return. */ - for (index = api_max; index >= api_min; index--) { - sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); + for (idx = api_max; idx >= api_min; idx--) { + sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { IL_ERR("%s firmware file req failed: %d\n", @@ -1874,7 +1874,7 @@ static int il3945_read_ucode(struct il_priv *il) else goto error; } else { - if (index < api_max) + if (idx < api_max) IL_ERR("Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index bc5a008..afdec78 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -173,7 +173,7 @@ static void il4965_set_beacon_tim(struct il_priv *il, struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; /* - * The index is relative to frame start but we start looking at the + * The idx is relative to frame start but we start looking at the * variable-length part of the beacon. */ tim_idx = mgmt->u.beacon.variable - beacon; @@ -318,7 +318,7 @@ static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) * @il - driver ilate data * @txq - tx queue * - * Does NOT advance any TFD circular buffer read/write indexes + * Does NOT advance any TFD circular buffer read/write idxes * Does NOT free the TFD itself (which is within circular buffer) */ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) @@ -326,11 +326,11 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; struct il_tfd *tfd; struct pci_dev *dev = il->pci_dev; - int index = txq->q.read_ptr; + int idx = txq->q.read_ptr; int i; int num_tbs; - tfd = &tfd_tmp[index]; + tfd = &tfd_tmp[idx]; /* Sanity check on number of chunks */ num_tbs = il4965_tfd_get_num_tbs(tfd); @@ -344,8 +344,8 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (num_tbs) pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[index], mapping), - dma_unmap_len(&txq->meta[index], len), + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), PCI_DMA_BIDIRECTIONAL); /* Unmap chunks, if any. */ @@ -643,7 +643,7 @@ void il4965_rx_handle(struct il_priv *il) u32 count = 8; int total_empty; - /* uCode's read index (stored in shared DRAM) indicates the last Rx + /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; @@ -1106,14 +1106,14 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) char tag[8]; if (first) { - il->fw_index = il->cfg->ucode_api_max; - sprintf(tag, "%d", il->fw_index); + il->fw_idx = il->cfg->ucode_api_max; + sprintf(tag, "%d", il->fw_idx); } else { - il->fw_index--; - sprintf(tag, "%d", il->fw_index); + il->fw_idx--; + sprintf(tag, "%d", il->fw_idx); } - if (il->fw_index < il->cfg->ucode_api_min) { + if (il->fw_idx < il->cfg->ucode_api_min) { IL_ERR("no suitable firmware found!\n"); return -ENOENT; } @@ -1213,7 +1213,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { - if (il->fw_index <= il->cfg->ucode_api_max) + if (il->fw_idx <= il->cfg->ucode_api_max) IL_ERR( "request for firmware file '%s' failed.\n", il->firmware_name); @@ -1655,7 +1655,7 @@ static int il4965_alive_notify(struct il_priv *il) /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < il->hw_params.max_txq_num; i++) { - /* TFD circular buffer read/write indexes */ + /* TFD circular buffer read/write idxes */ il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); @@ -2713,7 +2713,7 @@ static void il4965_init_hw_rates(struct il_priv *il, for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on indexes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { @@ -2729,11 +2729,11 @@ static void il4965_init_hw_rates(struct il_priv *il, /* * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) { il_wr(il, HBUS_TARG_WRPTR, - (index & 0xff) | (txq_id << 8)); - il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), index); + (idx & 0xff) | (txq_id << 8)); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); } void il4965_tx_queue_set_status(struct il_priv *il, -- cgit v0.10.2 From 3b98c7f49b675eb13e723967cf1264e3d562c480 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 16:29:35 +0200 Subject: iwlegacy: s/TABLE/TBL/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h index b98cabb..aa44a90 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h @@ -74,25 +74,25 @@ #define FH39_MEM_LOWER_BOUND (0x0800) #define FH39_MEM_UPPER_BOUND (0x1000) -#define FH39_CBCC_TABLE (FH39_MEM_LOWER_BOUND + 0x140) -#define FH39_TFDB_TABLE (FH39_MEM_LOWER_BOUND + 0x180) -#define FH39_RCSR_TABLE (FH39_MEM_LOWER_BOUND + 0x400) -#define FH39_RSSR_TABLE (FH39_MEM_LOWER_BOUND + 0x4c0) -#define FH39_TCSR_TABLE (FH39_MEM_LOWER_BOUND + 0x500) -#define FH39_TSSR_TABLE (FH39_MEM_LOWER_BOUND + 0x680) +#define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140) +#define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180) +#define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400) +#define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0) +#define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500) +#define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680) /* TFDB (Transmit Frame Buffer Descriptor) */ -#define FH39_TFDB(_ch, buf) (FH39_TFDB_TABLE + \ +#define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \ ((_ch) * 2 + (buf)) * 0x28) -#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TABLE + 0x50 * (_ch)) +#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch)) /* CBCC channel is [0,2] */ -#define FH39_CBCC(_ch) (FH39_CBCC_TABLE + (_ch) * 0x8) +#define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8) #define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00) #define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04) /* RCSR channel is [0,2] */ -#define FH39_RCSR(_ch) (FH39_RCSR_TABLE + (_ch) * 0x40) +#define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40) #define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00) #define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04) #define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20) @@ -101,19 +101,19 @@ #define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0)) /* RSSR */ -#define FH39_RSSR_CTRL (FH39_RSSR_TABLE + 0x000) -#define FH39_RSSR_STATUS (FH39_RSSR_TABLE + 0x004) +#define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000) +#define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004) /* TCSR */ -#define FH39_TCSR(_ch) (FH39_TCSR_TABLE + (_ch) * 0x20) +#define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20) #define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00) #define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04) #define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08) /* TSSR */ -#define FH39_TSSR_CBB_BASE (FH39_TSSR_TABLE + 0x000) -#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TABLE + 0x008) -#define FH39_TSSR_TX_STATUS (FH39_TSSR_TABLE + 0x010) +#define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000) +#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) +#define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) /* DBM */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 96a7628..b6abf34 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -60,8 +60,8 @@ RATE_##rn##M_IDX, \ RATE_##pp##M_IDX, \ RATE_##np##M_IDX, \ - RATE_##r##M_IDX_TABLE, \ - RATE_##ip##M_IDX_TABLE } + RATE_##r##M_IDX_TBL, \ + RATE_##ip##M_IDX_TBL } /* * Parameter order: @@ -1330,7 +1330,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TBL]); power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1342,7 +1342,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, * *idx*. */ power_idx = ch_info->power_info[rate_idx].power_table_idx - (power - ch_info->power_info - [RATE_6M_IDX_TABLE].requested_power) * 2; + [RATE_6M_IDX_TBL].requested_power) * 2; /* store reference idx that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1394,7 +1394,7 @@ static int il3945_send_tx_power(struct il_priv *il) } if (!il_is_channel_valid(ch_info)) { - D_POWER("Not calling TX_PWR_TABLE_CMD on " + D_POWER("Not calling TX_PWR_TBL_CMD on " "non-Tx channel.\n"); return 0; } @@ -1428,7 +1428,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].rate); } - return il_send_cmd_pdu(il, REPLY_TX_PWR_TABLE_CMD, + return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, sizeof(struct il3945_txpowertable_cmd), &txpower); @@ -1466,7 +1466,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = RATE_6M_IDX_TABLE; i <= RATE_54M_IDX_TABLE; + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++, ++power_info) { int delta_idx; @@ -1490,14 +1490,14 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[RATE_12M_IDX_TABLE]. + ch_info->power_info[RATE_12M_IDX_TBL]. requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ - for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) { + for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { power_info->requested_power = power; power_info->base_power_idx = - ch_info->power_info[RATE_12M_IDX_TABLE]. + ch_info->power_info[RATE_12M_IDX_TBL]. base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; ++power_info; } @@ -1597,7 +1597,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, actual_idx, clip_pwrs, ch_info, a_band); @@ -2012,19 +2012,19 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) for (rate_idx = 0; rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { switch (rate_idx) { - case RATE_36M_IDX_TABLE: + case RATE_36M_IDX_TBL: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case RATE_48M_IDX_TABLE: + case RATE_48M_IDX_TBL: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case RATE_54M_IDX_TABLE: + case RATE_54M_IDX_TBL: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2139,7 +2139,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[RATE_12M_IDX_TABLE]; + pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_idx = pwr_info->power_table_idx + @@ -2169,7 +2169,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, actual_idx, clip_pwrs, ch_info, a_band); } @@ -2223,7 +2223,7 @@ static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) switch (cmd_id) { case REPLY_RXON: return sizeof(struct il3945_rxon_cmd); - case POWER_TABLE_CMD: + case POWER_TBL_CMD: return sizeof(struct il3945_powertable_cmd); default: return len; @@ -2326,17 +2326,17 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_IDX_TABLE; - i <= RATE_11M_IDX_TABLE; i++) + for (i = RATE_1M_IDX_TBL; + i <= RATE_11M_IDX_TBL; i++) table[i].next_rate_idx = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TABLE].next_rate_idx = - RATE_9M_IDX_TABLE; + table[RATE_12M_IDX_TBL].next_rate_idx = + RATE_9M_IDX_TBL; /* Don't drop out of OFDM rates */ - table[RATE_6M_IDX_TABLE].next_rate_idx = + table[RATE_6M_IDX_TBL].next_rate_idx = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; break; @@ -2349,14 +2349,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { idx = IL_FIRST_CCK_RATE; - for (i = RATE_6M_IDX_TABLE; - i <= RATE_54M_IDX_TABLE; i++) + for (i = RATE_6M_IDX_TBL; + i <= RATE_54M_IDX_TBL; i++) table[i].next_rate_idx = il3945_rates[idx].table_rs_idx; - idx = RATE_11M_IDX_TABLE; + idx = RATE_11M_IDX_TBL; /* CCK shouldn't fall back to OFDM... */ - table[idx].next_rate_idx = RATE_5M_IDX_TABLE; + table[idx].next_rate_idx = RATE_5M_IDX_TBL; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index d622b27..1d873a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -429,18 +429,18 @@ static int il4965_sensitivity_write(struct il_priv *il) il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ - cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; + cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), - sizeof(u16)*HD_TABLE_SIZE)) { + sizeof(u16)*HD_TBL_SIZE)) { D_CALIB("No change in SENSITIVITY_CMD\n"); return 0; } /* Copy table for comparison next time */ memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), - sizeof(u16)*HD_TABLE_SIZE); + sizeof(u16)*HD_TBL_SIZE); return il_send_cmd(il, &cmd_out); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index b8f8064..4a54311 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -1001,11 +1001,11 @@ static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, D_RATE("we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { - lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; + lq_sta->table_count_limit = IL_LEGACY_TBL_COUNT; lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; } else { - lq_sta->table_count_limit = IL_NONE_LEGACY_TABLE_COUNT; + lq_sta->table_count_limit = IL_NONE_LEGACY_TBL_COUNT; lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; } @@ -1916,7 +1916,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * continuing to use the setup that we've been trying. */ if (win->average_tpt > lq_sta->last_tpt) { - D_RATE("LQ: SWITCHING TO NEW TABLE " + D_RATE("LQ: SWITCHING TO NEW TBL " "suc=%d cur-tpt=%d old-tpt=%d\n", win->success_ratio, win->average_tpt, @@ -1932,7 +1932,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Else poor success; go back to mode in "active" table */ } else { - D_RATE("LQ: GOING BACK TO THE OLD TABLE " + D_RATE("LQ: GOING BACK TO THE OLD TBL " "suc=%d cur-tpt=%d old-tpt=%d\n", win->success_ratio, win->average_tpt, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 8fd383e..bdfb3a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1010,7 +1010,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, } /* for each of 33 bit-rates (including 1 for CCK) */ - for (i = 0; i < POWER_TABLE_NUM_ENTRIES; i++) { + for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) { u8 is_mimo_rate; union il4965_tx_power_dual_stream tx_power; @@ -1072,7 +1072,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, power_idx += 9; /* CCK, rate 32, reduce txpower for CCK */ - if (i == POWER_TABLE_CCK_ENTRY) + if (i == POWER_TBL_CCK_ENTRY) power_idx += IL_TX_POWER_CCK_COMPENSATION_C_STEP; @@ -1144,7 +1144,7 @@ static int il4965_send_tx_power(struct il_priv *il) goto out; ret = il_send_cmd_pdu(il, - REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd); + REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); out: return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 408391295..e6688b1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -114,7 +114,7 @@ enum { SPECTRUM_MEASURE_NOTIFICATION = 0x75, /* Power Management */ - POWER_TABLE_CMD = 0x77, + POWER_TBL_CMD = 0x77, PM_SLEEP_NOTIFICATION = 0x7A, PM_DEBUG_STATISTIC_NOTIFIC = 0x7B, @@ -130,7 +130,7 @@ enum { REPLY_TX_BEACON = 0x91, /* Miscellaneous commands */ - REPLY_TX_PWR_TABLE_CMD = 0x97, + REPLY_TX_PWR_TBL_CMD = 0x97, /* Bluetooth device coexistence config command */ REPLY_BT_CONFIG = 0x9b, @@ -214,7 +214,7 @@ struct il_cmd_header { /** * struct il3945_tx_power * - * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH + * Used in REPLY_TX_PWR_TBL_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH * * Each entry contains two values: * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained @@ -233,7 +233,7 @@ struct il3945_tx_power { /** * struct il3945_power_per_rate * - * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Used in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH */ struct il3945_power_per_rate { u8 rate; /* plcp */ @@ -326,9 +326,9 @@ struct il3945_power_per_rate { #define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK) #define RATE_ANT_NUM 3 -#define POWER_TABLE_NUM_ENTRIES 33 -#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32 -#define POWER_TABLE_CCK_ENTRY 32 +#define POWER_TBL_NUM_ENTRIES 33 +#define POWER_TBL_NUM_HT_OFDM_ENTRIES 32 +#define POWER_TBL_CCK_ENTRY 32 #define IL_PWR_NUM_HT_OFDM_ENTRIES 24 #define IL_PWR_CCK_ENTRIES 2 @@ -336,7 +336,7 @@ struct il3945_power_per_rate { /** * union il4965_tx_power_dual_stream * - * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Host format used for REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH * Use __le32 version (struct tx_power_dual_stream) when building command. * * Driver provides radio gain and DSP attenuation settings to device in pairs, @@ -360,7 +360,7 @@ union il4965_tx_power_dual_stream { /** * struct tx_power_dual_stream * - * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Table entries in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH * * Same format as il_tx_power_dual_stream, but __le32 */ @@ -371,10 +371,10 @@ struct tx_power_dual_stream { /** * struct il4965_tx_power_db * - * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Entire table within REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH */ struct il4965_tx_power_db { - struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES]; + struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; } __packed; /****************************************************************************** @@ -653,7 +653,7 @@ enum { * channel. * * NOTE: All RXONs wipe clean the internal txpower table. Driver must - * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10), + * issue a new REPLY_TX_PWR_TBL_CMD after each REPLY_RXON (0x10), * regardless of whether RXON_FILTER_ASSOC_MSK is set. */ @@ -1067,7 +1067,7 @@ struct il_addsta_cmd { #define ADD_STA_SUCCESS_MSK 0x1 -#define ADD_STA_NO_ROOM_IN_TABLE 0x2 +#define ADD_STA_NO_ROOM_IN_TBL 0x2 #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 #define ADD_STA_MODIFY_NON_EXIST_STA 0x8 /* @@ -1271,7 +1271,7 @@ struct il_rx_mpdu_res_start { * command, as set up by the REPLY_RATE_SCALE (for 3945) or * REPLY_TX_LINK_QUALITY_CMD (4965). * - * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD. + * Driver sets up transmit power for various rates via REPLY_TX_PWR_TBL_CMD. * This command must be executed after every RXON command, before Tx can occur. *****************************************************************************/ @@ -1754,7 +1754,7 @@ struct il_compressed_ba_resp { } __packed; /* - * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response) + * REPLY_TX_PWR_TBL_CMD = 0x97 (command, has simple generic response) * * See details under "TXPOWER" in iwl-4965-hw.h. */ @@ -1909,7 +1909,7 @@ struct il_link_qual_agg_params { * procedures are possible, and may work better for particular environments. * * - * FILLING THE RATE TABLE + * FILLING THE RATE TBL * * Given a particular initial rate and mode, as determined by the rate * scaling algorithm described below, the Linux driver uses the following @@ -2263,7 +2263,7 @@ struct il_spectrum_notification { * struct il_powertable_cmd - Power Table Command * @flags: See below: * - * POWER_TABLE_CMD = 0x77 (command, has simple generic response) + * POWER_TBL_CMD = 0x77 (command, has simple generic response) * * PM allow: * bit 0 - '0' Driver not allow power management @@ -2290,7 +2290,7 @@ struct il_spectrum_notification { * '10' force xtal sleep * '11' Illegal set * - * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then + * NOTE: if sleep_interval[SLEEP_INTRVL_TBL_SIZE-1] > DTIM period then * ucode assume sleep over DTIM is allowed and we don't need to wake up * for every DTIM. */ @@ -3219,7 +3219,7 @@ struct il_missed_beacon_notif { /* * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ -#define HD_TABLE_SIZE (11) /* number of entries */ +#define HD_TBL_SIZE (11) /* number of entries */ #define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ #define HD_MIN_ENERGY_OFDM_DET_IDX (1) #define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) @@ -3233,8 +3233,8 @@ struct il_missed_beacon_notif { #define HD_OFDM_ENERGY_TH_IN_IDX (10) /* Control field in struct il_sensitivity_cmd */ -#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0) -#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1) +#define SENSITIVITY_CMD_CONTROL_DEFAULT_TBL cpu_to_le16(0) +#define SENSITIVITY_CMD_CONTROL_WORK_TBL cpu_to_le16(1) /** * struct il_sensitivity_cmd @@ -3245,7 +3245,7 @@ struct il_missed_beacon_notif { */ struct il_sensitivity_cmd { __le16 control; /* always use "1" */ - __le16 table[HD_TABLE_SIZE]; /* use HD_* as idx */ + __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ } __packed; diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index 34edec3..4db0429 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -357,7 +357,7 @@ /* HPET MEM debug */ #define CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000) -/* DRAM INT TABLE */ +/* DRAM INT TBL */ #define CSR_DRAM_INT_TBL_ENABLE (1 << 31) #define CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27) diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 2555f9f..7c86d19 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -1060,7 +1060,7 @@ struct il_priv { u8 start_calib; struct il_sensitivity_data sensitivity_data; struct il_chain_noise_data chain_noise_data; - __le16 sensitivity_tbl[HD_TABLE_SIZE]; + __le16 sensitivity_tbl[HD_TBL_SIZE]; struct il_ht_config current_ht_config; diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index e63777b..0b11f2f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -58,7 +58,7 @@ const char *il_get_cmd_string(u8 cmd) IL_CMD(CHANNEL_SWITCH_NOTIFICATION); IL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); IL_CMD(SPECTRUM_MEASURE_NOTIFICATION); - IL_CMD(POWER_TABLE_CMD); + IL_CMD(POWER_TBL_CMD); IL_CMD(PM_SLEEP_NOTIFICATION); IL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); IL_CMD(REPLY_SCAN_CMD); @@ -68,7 +68,7 @@ const char *il_get_cmd_string(u8 cmd) IL_CMD(SCAN_COMPLETE_NOTIFICATION); IL_CMD(BEACON_NOTIFICATION); IL_CMD(REPLY_TX_BEACON); - IL_CMD(REPLY_TX_PWR_TABLE_CMD); + IL_CMD(REPLY_TX_PWR_TBL_CMD); IL_CMD(REPLY_BT_CONFIG); IL_CMD(REPLY_STATISTICS_CMD); IL_CMD(STATISTICS_NOTIFICATION); diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index bc09a5d..58e04cb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -80,19 +80,19 @@ enum { }; enum { - RATE_6M_IDX_TABLE = 0, - RATE_9M_IDX_TABLE, - RATE_12M_IDX_TABLE, - RATE_18M_IDX_TABLE, - RATE_24M_IDX_TABLE, - RATE_36M_IDX_TABLE, - RATE_48M_IDX_TABLE, - RATE_54M_IDX_TABLE, - RATE_1M_IDX_TABLE, - RATE_2M_IDX_TABLE, - RATE_5M_IDX_TABLE, - RATE_11M_IDX_TABLE, - RATE_INVM_IDX_TABLE = RATE_INVM_IDX - 1, + RATE_6M_IDX_TBL = 0, + RATE_9M_IDX_TBL, + RATE_12M_IDX_TBL, + RATE_18M_IDX_TBL, + RATE_24M_IDX_TBL, + RATE_36M_IDX_TBL, + RATE_48M_IDX_TBL, + RATE_54M_IDX_TBL, + RATE_1M_IDX_TBL, + RATE_2M_IDX_TBL, + RATE_5M_IDX_TBL, + RATE_11M_IDX_TBL, + RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1, }; enum { @@ -213,11 +213,11 @@ enum { * searching for a new modulation mode */ #define IL_LEGACY_FAILURE_LIMIT 160 #define IL_LEGACY_SUCCESS_LIMIT 480 -#define IL_LEGACY_TABLE_COUNT 160 +#define IL_LEGACY_TBL_COUNT 160 #define IL_NONE_LEGACY_FAILURE_LIMIT 400 #define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 -#define IL_NONE_LEGACY_TABLE_COUNT 1500 +#define IL_NONE_LEGACY_TBL_COUNT 1500 /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ #define IL_RS_GOOD_RATIO 12800 /* 100% */ diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 6c6e5e7..051623a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -88,7 +88,7 @@ il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return il_send_cmd_pdu(il, POWER_TABLE_CMD, + return il_send_cmd_pdu(il, POWER_TBL_CMD, sizeof(struct il_powertable_cmd), cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 8128c87..e34d907 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -189,7 +189,7 @@ * procedure. * * This save/restore method is mostly for autonomous power management during - * normal operation (result of POWER_TABLE_CMD). Platform suspend/resume and + * normal operation (result of POWER_TBL_CMD). Platform suspend/resume and * RFKILL should use complete restarts (with total re-initialization) of uCode, * allowing total shutdown (including BSM memory). * @@ -494,7 +494,7 @@ * When queue is in Scheduler-ACK mode, frames placed in a that queue must be * for only one combination of receiver address (RA) and traffic ID (TID), i.e. * one QOS priority level destined for one station (for this wireless link, - * not final destination). The SCD_TRANSLATE_TABLE area provides 16 16-bit + * not final destination). The SCD_TRANSLATE_TBL area provides 16 16-bit * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK * mode, the device ignores the mapping value. * diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index a7fe9ea..ffb966b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -83,7 +83,7 @@ static int il_process_add_sta_resp(struct il_priv *il, il_sta_ucode_activate(il, sta_id); ret = 0; break; - case ADD_STA_NO_ROOM_IN_TABLE: + case ADD_STA_NO_ROOM_IN_TBL: IL_ERR("Adding station %d failed, no room in table.\n", sta_id); break; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 9244208..41104e7 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -885,7 +885,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * Rx theory of operation * * The host allocates 32 DMA target addresses and passes the host address - * to the firmware at register IL_RFDS_TABLE_LOWER + N * RFD_SIZE where N is + * to the firmware at register IL_RFDS_TBL_LOWER + N * RFD_SIZE where N is * 0 to 31 * * Rx Queue Indexes diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index afdec78..043d51e 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1470,7 +1470,7 @@ static const char * const desc_lookup_text[] = { "HW_ERROR_TUNE_LOCK", "HW_ERROR_TEMPERATURE", "ILLEGAL_CHAN_FREQ", - "VCC_NOT_STABLE", + "VCC_NOT_STBL", "FH_ERROR", "NMI_INTERRUPT_HOST", "NMI_INTERRUPT_ACTION_PT", -- cgit v0.10.2 From 17d6e557359e0a4033bf0889e0b481519e145404 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 29 Aug 2011 12:52:20 +0200 Subject: iwlegacy: remove for_each_context We do not support many contexts. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 4cda277..337bf0c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -615,16 +615,7 @@ static int il4965_update_bcast_station(struct il_priv *il, int il4965_update_bcast_stations(struct il_priv *il) { - struct il_rxon_context *ctx; - int ret = 0; - - for_each_context(il, ctx) { - ret = il4965_update_bcast_station(il, ctx); - if (ret) - break; - } - - return ret; + return il4965_update_bcast_station(il, &il->ctx); } /** diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index de952fb..bd222f5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -646,10 +646,7 @@ static void _il_set_rxon_ht(struct il_priv *il, void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { - struct il_rxon_context *ctx; - - for_each_context(il, ctx) - _il_set_rxon_ht(il, ht_conf, ctx); + _il_set_rxon_ht(il, ht_conf, &il->ctx); } EXPORT_SYMBOL(il_set_rxon_ht); @@ -661,7 +658,6 @@ u8 il_get_single_channel_number(struct il_priv *il, int i; u8 channel = 0; u8 min, max; - struct il_rxon_context *ctx; if (band == IEEE80211_BAND_5GHZ) { min = 14; @@ -672,19 +668,10 @@ u8 il_get_single_channel_number(struct il_priv *il, } for (i = min; i < max; i++) { - bool busy = false; - - for_each_context(il, ctx) { - busy = il->channel_info[i].channel == - le16_to_cpu(ctx->staging.channel); - if (busy) - break; - } - - if (busy) + channel = il->channel_info[i].channel; + if (channel == le16_to_cpu(il->ctx.staging.channel)) continue; - channel = il->channel_info[i].channel; ch_info = il_get_channel_info(il, band, channel); if (il_is_channel_valid(ch_info)) break; @@ -822,7 +809,6 @@ void il_set_rate(struct il_priv *il) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; - struct il_rxon_context *ctx; int i; hw = il_get_hw_mode(il, il->band); @@ -841,13 +827,11 @@ void il_set_rate(struct il_priv *il) D_RATE("Set active_rate = %0x\n", il->active_rate); - for_each_context(il, ctx) { - ctx->staging.cck_basic_rates = + il->ctx.staging.cck_basic_rates = (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; - ctx->staging.ofdm_basic_rates = + il->ctx.staging.ofdm_basic_rates = (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - } } EXPORT_SYMBOL(il_set_rate); @@ -1254,7 +1238,6 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, const struct ieee80211_tx_queue_params *params) { struct il_priv *il = hw->priv; - struct il_rxon_context *ctx; unsigned long flags; int q; @@ -1274,17 +1257,15 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, spin_lock_irqsave(&il->lock, flags); - for_each_context(il, ctx) { - ctx->qos_data.def_qos_parm.ac[q].cw_min = + il->ctx.qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min); - ctx->qos_data.def_qos_parm.ac[q].cw_max = + il->ctx.qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max); - ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; - ctx->qos_data.def_qos_parm.ac[q].edca_txop = + il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; + il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = cpu_to_le16((params->txop * 32)); - ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; - } + il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; spin_unlock_irqrestore(&il->lock, flags); @@ -1344,8 +1325,8 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - struct il_rxon_context *tmp, *ctx = NULL; int err; + u32 modes; D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); @@ -1358,42 +1339,29 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) goto out; } - for_each_context(il, tmp) { - u32 possible_modes = - tmp->interface_modes | tmp->exclusive_interface_modes; - - if (tmp->vif) { - /* check if this busy context is exclusive */ - if (tmp->exclusive_interface_modes & - BIT(tmp->vif->type)) { - err = -EINVAL; - goto out; - } - continue; - } - if (!(possible_modes & BIT(vif->type))) - continue; - - /* have maybe usable context w/o interface */ - ctx = tmp; - break; + /* check if busy context is exclusive */ + if (il->ctx.vif && + (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { + err = -EINVAL; + goto out; } - if (!ctx) { + modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; + if (!(modes & BIT(vif->type))) { err = -EOPNOTSUPP; goto out; } - vif_priv->ctx = ctx; - ctx->vif = vif; + vif_priv->ctx = &il->ctx; + il->ctx.vif = vif; - err = il_setup_interface(il, ctx); - if (!err) - goto out; + err = il_setup_interface(il, &il->ctx); + if (err) { + il->ctx.vif = NULL; + il->iw_mode = NL80211_IFTYPE_STATION; + } - ctx->vif = NULL; - il->iw_mode = NL80211_IFTYPE_STATION; out: mutex_unlock(&il->mutex); @@ -1764,8 +1732,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - struct il_rxon_context *tmp; - u32 interface_modes; + u32 modes; int err; newtype = ieee80211_iftype_p2p(newtype, newp2p); @@ -1781,28 +1748,16 @@ il_mac_change_interface(struct ieee80211_hw *hw, goto out; } - interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; - - if (!(interface_modes & BIT(newtype))) { - err = -EBUSY; + modes = ctx->interface_modes | ctx->exclusive_interface_modes; + if (!(modes & BIT(newtype))) { + err = -EOPNOTSUPP; goto out; } - if (ctx->exclusive_interface_modes & BIT(newtype)) { - for_each_context(il, tmp) { - if (ctx == tmp) - continue; - - if (!tmp->vif) - continue; - - /* - * The current mode switch would be exclusive, but - * another context is active ... refuse the switch. - */ - err = -EBUSY; - goto out; - } + if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) || + (il->ctx.exclusive_interface_modes & BIT(newtype))) { + err = -EINVAL; + goto out; } /* success */ @@ -2064,7 +2019,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = conf->channel; struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; unsigned long flags = 0; int ret = 0; u16 ch; @@ -2097,14 +2052,14 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) * configured. */ if (il->cfg->ops->hcmd->set_rxon_chain) - for_each_context(il, ctx) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); } /* during scanning mac80211 will delay channel setting until * scan finish with changed = 0 */ if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { + if (scan_active) goto set_ch_out; @@ -2125,48 +2080,46 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) spin_lock_irqsave(&il->lock, flags); - for_each_context(il, ctx) { - /* Configure HT40 channels */ - if (ctx->ht.enabled != conf_is_ht(conf)) { - ctx->ht.enabled = conf_is_ht(conf); - ht_changed = true; - } - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else + /* Configure HT40 channels */ + if (ctx->ht.enabled != conf_is_ht(conf)) { + ctx->ht.enabled = conf_is_ht(conf); + ht_changed = true; + } + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; - /* - * Default to no protection. Protection mode will - * later be set from BSS config in il_ht_conf - */ - ctx->ht.protection = - IEEE80211_HT_OP_MODE_PROTECTION_NONE; + /* + * Default to no protection. Protection mode will + * later be set from BSS config in il_ht_conf + */ + ctx->ht.protection = + IEEE80211_HT_OP_MODE_PROTECTION_NONE; - /* if we are switching from ht to 2.4 clear flags - * from any ht related info since 2.4 does not - * support ht */ - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; + /* if we are switching from ht to 2.4 clear flags + * from any ht related info since 2.4 does not + * support ht */ + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; - il_set_rxon_channel(il, channel, ctx); - il_set_rxon_ht(il, ht_conf); + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, - ctx->vif); - } + il_set_flags_for_band(il, ctx, channel->band, + ctx->vif); spin_unlock_irqrestore(&il->lock, flags); @@ -2203,15 +2156,12 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if (scan_active) goto out; - for_each_context(il, ctx) { - if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - il_commit_rxon(il, ctx); - else - D_INFO( - "Not re-sending same RXON configuration.\n"); - if (ht_changed) - il_update_qos(il, ctx); - } + if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) + il_commit_rxon(il, ctx); + else + D_INFO("Not re-sending same RXON configuration.\n"); + if (ht_changed) + il_update_qos(il, ctx); out: D_MAC80211("leave\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index e8153b0..8448db7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -599,26 +599,24 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; int pos = 0, i; char buf[256]; const size_t bufsz = sizeof(buf); - for_each_context(il, ctx) { - pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", - ctx->ctxid); - for (i = 0; i < AC_NUM; i++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tcw_min\tcw_max\taifsn\ttxop\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "AC[%d]\t%u\t%u\t%u\t%u\n", i, - ctx->qos_data.def_qos_parm.ac[i].cw_min, - ctx->qos_data.def_qos_parm.ac[i].cw_max, - ctx->qos_data.def_qos_parm.ac[i].aifsn, - ctx->qos_data.def_qos_parm.ac[i].edca_txop); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", + ctx->ctxid); + for (i = 0; i < AC_NUM; i++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\tcw_min\tcw_max\taifsn\ttxop\n"); + pos += scnprintf(buf + pos, bufsz - pos, + "AC[%d]\t%u\t%u\t%u\t%u\n", i, + ctx->qos_data.def_qos_parm.ac[i].cw_min, + ctx->qos_data.def_qos_parm.ac[i].cw_max, + ctx->qos_data.def_qos_parm.ac[i].aifsn, + ctx->qos_data.def_qos_parm.ac[i].edca_txop); } + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 71b2fac..18226d1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -290,7 +290,9 @@ u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, struct ieee80211_vif *vif) { - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; + u16 value; + u16 passive = (band == IEEE80211_BAND_2GHZ) ? IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; @@ -301,17 +303,11 @@ u16 il_get_passive_dwell_time(struct il_priv *il, * dwell time to be 98% of the smallest beacon interval * (minus 2 * channel tune time) */ - for_each_context(il, ctx) { - u16 value; - - if (!il_is_associated_ctx(ctx)) - continue; - value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if (value > IL_PASSIVE_DWELL_BASE || !value) - value = IL_PASSIVE_DWELL_BASE; - value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; - passive = min(value, passive); - } + value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; + if (value > IL_PASSIVE_DWELL_BASE || !value) + value = IL_PASSIVE_DWELL_BASE; + value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; + passive = min(value, passive); } return passive; diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index f07cd7f..afd3003 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -84,7 +84,7 @@ int il_send_lq_cmd(struct il_priv *il, static inline void il_clear_driver_stations(struct il_priv *il) { unsigned long flags; - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; spin_lock_irqsave(&il->sta_lock, flags); memset(il->stations, 0, sizeof(il->stations)); @@ -92,17 +92,15 @@ static inline void il_clear_driver_stations(struct il_priv *il) il->ucode_key_table = 0; - for_each_context(il, ctx) { - /* - * Remove all key information that is not stored as part - * of station information since mac80211 may not have had - * a chance to remove all the keys. When device is - * reconfigured by mac80211 after an error all keys will - * be reconfigured. - */ - memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); - ctx->key_mapping_keys = 0; - } + /* + * Remove all key information that is not stored as part + * of station information since mac80211 may not have had + * a chance to remove all the keys. When device is + * reconfigured by mac80211 after an error all keys will + * be reconfigured. + */ + memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); + ctx->key_mapping_keys = 0; spin_unlock_irqrestore(&il->sta_lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 41104e7..151c8fa 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -2710,10 +2710,8 @@ static void il3945_bg_restart(struct work_struct *data) return; if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - struct il_rxon_context *ctx; mutex_lock(&il->mutex); - for_each_context(il, ctx) - ctx->vif = NULL; + il->ctx.vif = NULL; il->is_open = 0; mutex_unlock(&il->mutex); il3945_down(il); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 043d51e..df86431 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -89,14 +89,10 @@ MODULE_ALIAS("iwl4965"); void il4965_update_chain_flags(struct il_priv *il) { - struct il_rxon_context *ctx; - if (il->cfg->ops->hcmd->set_rxon_chain) { - for_each_context(il, ctx) { - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - if (ctx->active.rx_chain != ctx->staging.rx_chain) - il_commit_rxon(il, ctx); - } + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); + if (il->ctx.active.rx_chain != il->ctx.staging.rx_chain) + il_commit_rxon(il, &il->ctx); } } @@ -1766,10 +1762,8 @@ static void il4965_alive_start(struct il_priv *il) ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { - struct il_rxon_context *tmp; /* Initialize our rx_config data */ - for_each_context(il, tmp) - il_connection_init_rx_config(il, tmp); + il_connection_init_rx_config(il, &il->ctx); if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, ctx); @@ -1950,7 +1944,6 @@ static int il4965_prepare_card_hw(struct il_priv *il) static int __il4965_up(struct il_priv *il) { - struct il_rxon_context *ctx; int i; int ret; @@ -1964,12 +1957,10 @@ static int __il4965_up(struct il_priv *il) return -EIO; } - for_each_context(il, ctx) { - ret = il4965_alloc_bcast_station(il, ctx); - if (ret) { - il_dealloc_bcast_stations(il); - return ret; - } + ret = il4965_alloc_bcast_station(il, &il->ctx); + if (ret) { + il_dealloc_bcast_stations(il); + return ret; } il4965_prepare_card_hw(il); @@ -2121,11 +2112,8 @@ static void il4965_bg_restart(struct work_struct *data) return; if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - struct il_rxon_context *ctx; - mutex_lock(&il->mutex); - for_each_context(il, ctx) - ctx->vif = NULL; + il->ctx.vif = NULL; il->is_open = 0; __il4965_down(il); @@ -2177,7 +2165,6 @@ static int il4965_mac_setup_register(struct il_priv *il, { int ret; struct ieee80211_hw *hw = il->hw; - struct il_rxon_context *ctx; hw->rate_control_algorithm = "iwl-4965-rs"; @@ -2195,10 +2182,8 @@ static int il4965_mac_setup_register(struct il_priv *il, hw->sta_data_size = sizeof(struct il_station_priv); hw->vif_data_size = sizeof(struct il_vif_priv); - for_each_context(il, ctx) { - hw->wiphy->interface_modes |= ctx->interface_modes; - hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; - } + hw->wiphy->interface_modes |= il->ctx.interface_modes; + hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS; @@ -2590,7 +2575,6 @@ void il4965_configure_filter(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -2611,15 +2595,13 @@ void il4965_configure_filter(struct ieee80211_hw *hw, mutex_lock(&il->mutex); - for_each_context(il, ctx) { - ctx->staging.filter_flags &= ~filter_nand; - ctx->staging.filter_flags |= filter_or; + il->ctx.staging.filter_flags &= ~filter_nand; + il->ctx.staging.filter_flags |= filter_or; - /* - * Not committing directly because hardware can perform a scan, - * but we'll eventually commit the filter flags change anyway. - */ - } + /* + * Not committing directly because hardware can perform a scan, + * but we'll eventually commit the filter flags change anyway. + */ mutex_unlock(&il->mutex); -- cgit v0.10.2 From 61fe55f61fb48b691251e0f75505674db77f5d29 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:40:26 +0100 Subject: iwlegacy: rename base 4965 and 3945 file names Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c new file mode 100644 index 0000000..151c8fa --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -0,0 +1,4007 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * Portions of this file are derived from the ipw3945 project, as well + * as portions of the ieee80211 subsystem header files. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define DRV_NAME "iwl3945" + +#include "iwl-fh.h" +#include "iwl-3945-fh.h" +#include "iwl-commands.h" +#include "iwl-sta.h" +#include "iwl-3945.h" +#include "iwl-core.h" +#include "iwl-helpers.h" +#include "iwl-dev.h" +#include "iwl-spectrum.h" + +/* + * module name, copyright, version, etc. + */ + +#define DRV_DESCRIPTION \ +"Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux" + +#ifdef CONFIG_IWLEGACY_DEBUG +#define VD "d" +#else +#define VD +#endif + +/* + * add "s" to indicate spectrum measurement included. + * we add it here to be consistent with previous releases in which + * this was configurable. + */ +#define DRV_VERSION IWLWIFI_VERSION VD "s" +#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" +#define DRV_AUTHOR "" + +MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_VERSION(DRV_VERSION); +MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); +MODULE_LICENSE("GPL"); + + /* module parameters */ +struct il_mod_params il3945_mod_params = { + .sw_crypto = 1, + .restart_fw = 1, + .disable_hw_scan = 1, + /* the rest are 0 by default */ +}; + +/** + * il3945_get_antenna_flags - Get antenna flags for RXON command + * @il: eeprom and antenna fields are used to determine antenna flags + * + * il->eeprom39 is used to determine if antenna AUX/MAIN are reversed + * il3945_mod_params.antenna specifies the antenna diversity mode: + * + * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself + * IL_ANTENNA_MAIN - Force MAIN antenna + * IL_ANTENNA_AUX - Force AUX antenna + */ +__le32 il3945_get_antenna_flags(const struct il_priv *il) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + + switch (il3945_mod_params.antenna) { + case IL_ANTENNA_DIVERSITY: + return 0; + + case IL_ANTENNA_MAIN: + if (eeprom->antenna_switch_type) + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; + + case IL_ANTENNA_AUX: + if (eeprom->antenna_switch_type) + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; + } + + /* bad antenna selector value */ + IL_ERR("Bad antenna selector value (0x%x)\n", + il3945_mod_params.antenna); + + return 0; /* "diversity" is default if error */ +} + +static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + __le16 key_flags = 0; + int ret; + + key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + + if (sta_id == il->ctx.bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + keyconf->hw_key_idx = keyconf->keyidx; + key_flags &= ~STA_KEY_FLG_INVALID; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, + keyconf->keylen); + + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, + keyconf->keylen); + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + D_INFO("hwcrypto: modify ucode station key info\n"); + + ret = il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); + + spin_unlock_irqrestore(&il->sta_lock, flags); + + return ret; +} + +static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + return -EOPNOTSUPP; +} + +static int il3945_set_wep_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + return -EOPNOTSUPP; +} + +static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) +{ + unsigned long flags; + struct il_addsta_cmd sta_cmd; + + spin_lock_irqsave(&il->sta_lock, flags); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, + sizeof(struct il4965_keyinfo)); + il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + D_INFO("hwcrypto: clear ucode station key info\n"); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +static int il3945_set_dynamic_key(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) +{ + int ret = 0; + + keyconf->hw_key_idx = HW_KEY_DYNAMIC; + + switch (keyconf->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + ret = il3945_set_ccmp_dynamic_key_info(il, keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_TKIP: + ret = il3945_set_tkip_dynamic_key_info(il, keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); + break; + default: + IL_ERR("Unknown alg: %s alg=%x\n", __func__, + keyconf->cipher); + ret = -EINVAL; + } + + D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + keyconf->cipher, keyconf->keylen, keyconf->keyidx, + sta_id, ret); + + return ret; +} + +static int il3945_remove_static_key(struct il_priv *il) +{ + int ret = -EOPNOTSUPP; + + return ret; +} + +static int il3945_set_static_key(struct il_priv *il, + struct ieee80211_key_conf *key) +{ + if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) + return -EOPNOTSUPP; + + IL_ERR("Static key invalid: cipher %x\n", key->cipher); + return -EINVAL; +} + +static void il3945_clear_free_frames(struct il_priv *il) +{ + struct list_head *element; + + D_INFO("%d frames on pre-allocated heap on clear.\n", + il->frames_count); + + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; + list_del(element); + kfree(list_entry(element, struct il3945_frame, list)); + il->frames_count--; + } + + if (il->frames_count) { + IL_WARN("%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; + } +} + +static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) +{ + struct il3945_frame *frame; + struct list_head *element; + if (list_empty(&il->free_frames)) { + frame = kzalloc(sizeof(*frame), GFP_KERNEL); + if (!frame) { + IL_ERR("Could not allocate frame!\n"); + return NULL; + } + + il->frames_count++; + return frame; + } + + element = il->free_frames.next; + list_del(element); + return list_entry(element, struct il3945_frame, list); +} + +static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) +{ + memset(frame, 0, sizeof(*frame)); + list_add(&frame->list, &il->free_frames); +} + +unsigned int il3945_fill_beacon_frame(struct il_priv *il, + struct ieee80211_hdr *hdr, + int left) +{ + + if (!il_is_associated(il) || !il->beacon_skb) + return 0; + + if (il->beacon_skb->len > left) + return 0; + + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); + + return il->beacon_skb->len; +} + +static int il3945_send_beacon_cmd(struct il_priv *il) +{ + struct il3945_frame *frame; + unsigned int frame_size; + int rc; + u8 rate; + + frame = il3945_get_free_frame(il); + + if (!frame) { + IL_ERR("Could not obtain free frame buffer for beacon " + "command.\n"); + return -ENOMEM; + } + + rate = il_get_lowest_plcp(il, + &il->ctx); + + frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); + + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + &frame->u.cmd[0]); + + il3945_free_frame(il, frame); + + return rc; +} + +static void il3945_unset_hw_params(struct il_priv *il) +{ + if (il->_3945.shared_virt) + dma_free_coherent(&il->pci_dev->dev, + sizeof(struct il3945_shared), + il->_3945.shared_virt, + il->_3945.shared_phys); +} + +static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, + struct ieee80211_tx_info *info, + struct il_device_cmd *cmd, + struct sk_buff *skb_frag, + int sta_id) +{ + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; + + tx_cmd->sec_ctl = 0; + + switch (keyinfo->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + tx_cmd->sec_ctl = TX_CMD_SEC_CCM; + memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); + D_TX("tx_cmd with AES hwcrypto\n"); + break; + + case WLAN_CIPHER_SUITE_TKIP: + break; + + case WLAN_CIPHER_SUITE_WEP104: + tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; + /* fall through */ + case WLAN_CIPHER_SUITE_WEP40: + tx_cmd->sec_ctl |= TX_CMD_SEC_WEP | + (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; + + memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); + + D_TX("Configuring packet for WEP encryption " + "with key %d\n", info->control.hw_key->hw_key_idx); + break; + + default: + IL_ERR("Unknown encode cipher %x\n", keyinfo->cipher); + break; + } +} + +/* + * handle build REPLY_TX command notification. + */ +static void il3945_build_tx_cmd_basic(struct il_priv *il, + struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, u8 std_id) +{ + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + __le32 tx_flags = tx_cmd->tx_flags; + __le16 fc = hdr->frame_control; + + tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { + tx_flags |= TX_CMD_FLG_ACK_MSK; + if (ieee80211_is_mgmt(fc)) + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + if (ieee80211_is_probe_resp(fc) && + !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) + tx_flags |= TX_CMD_FLG_TSF_MSK; + } else { + tx_flags &= (~TX_CMD_FLG_ACK_MSK); + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + tx_cmd->sta_id = std_id; + if (ieee80211_has_morefrags(fc)) + tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; + + if (ieee80211_is_data_qos(fc)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tx_cmd->tid_tspec = qc[0] & 0xf; + tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; + } else { + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + il_tx_cmd_protection(il, info, fc, &tx_flags); + + tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); + if (ieee80211_is_mgmt(fc)) { + if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); + else + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); + } else { + tx_cmd->timeout.pm_frame_timeout = 0; + } + + tx_cmd->driver_txop = 0; + tx_cmd->tx_flags = tx_flags; + tx_cmd->next_frame_len = 0; +} + +/* + * start REPLY_TX command process + */ +static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct il3945_tx_cmd *tx_cmd; + struct il_tx_queue *txq = NULL; + struct il_queue *q = NULL; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + dma_addr_t phys_addr; + dma_addr_t txcmd_phys; + int txq_id = skb_get_queue_mapping(skb); + u16 len, idx, hdr_len; + u8 id; + u8 unicast; + u8 sta_id; + u8 tid = 0; + __le16 fc; + u8 wait_write_ptr = 0; + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + D_DROP("Dropping - RF KILL\n"); + goto drop_unlock; + } + + if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + IL_ERR("ERROR: No TX rate available.\n"); + goto drop_unlock; + } + + unicast = !is_multicast_ether_addr(hdr->addr1); + id = 0; + + fc = hdr->frame_control; + +#ifdef CONFIG_IWLEGACY_DEBUG + if (ieee80211_is_auth(fc)) + D_TX("Sending AUTH frame\n"); + else if (ieee80211_is_assoc_req(fc)) + D_TX("Sending ASSOC frame\n"); + else if (ieee80211_is_reassoc_req(fc)) + D_TX("Sending REASSOC frame\n"); +#endif + + spin_unlock_irqrestore(&il->lock, flags); + + hdr_len = ieee80211_hdrlen(fc); + + /* Find idx into station table for destination station */ + sta_id = il_sta_id_or_broadcast( + il, &il->ctx, + info->control.sta); + if (sta_id == IL_INVALID_STATION) { + D_DROP("Dropping - INVALID STATION: %pM\n", + hdr->addr1); + goto drop; + } + + D_RATE("station Id %d\n", sta_id); + + if (ieee80211_is_data_qos(fc)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; + if (unlikely(tid >= MAX_TID_COUNT)) + goto drop; + } + + /* Descriptor for chosen Tx queue */ + txq = &il->txq[txq_id]; + q = &txq->q; + + if ((il_queue_space(q) < q->high_mark)) + goto drop; + + spin_lock_irqsave(&il->lock, flags); + + idx = il_get_cmd_idx(q, q->write_ptr, 0); + + /* Set up driver data for this TFD */ + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); + txq->txb[q->write_ptr].skb = skb; + txq->txb[q->write_ptr].ctx = &il->ctx; + + /* Init first empty entry in queue's array of Tx/cmd buffers */ + out_cmd = txq->cmd[idx]; + out_meta = &txq->meta[idx]; + tx_cmd = (struct il3945_tx_cmd *)out_cmd->cmd.payload; + memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); + memset(tx_cmd, 0, sizeof(*tx_cmd)); + + /* + * Set up the Tx-command (not MAC!) header. + * Store the chosen Tx queue and TFD idx within the sequence field; + * after Tx, uCode's Tx response will return this value so driver can + * locate the frame within the tx queue and do post-tx processing. + */ + out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | + IDX_TO_SEQ(q->write_ptr))); + + /* Copy MAC header from skb into command buffer */ + memcpy(tx_cmd->hdr, hdr, hdr_len); + + + if (info->control.hw_key) + il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); + + /* TODO need this for burst mode later on */ + il3945_build_tx_cmd_basic(il, out_cmd, info, hdr, sta_id); + + /* set is_hcca to 0; it probably will never be implemented */ + il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); + + /* Total # bytes to be transmitted */ + len = (u16)skb->len; + tx_cmd->len = cpu_to_le16(len); + + il_dbg_log_tx_data_frame(il, len, hdr); + il_update_stats(il, true, fc, len); + tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; + tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; + + if (!ieee80211_has_morefrags(hdr->frame_control)) { + txq->need_update = 1; + } else { + wait_write_ptr = 1; + txq->need_update = 0; + } + + D_TX("sequence nr = 0X%x\n", + le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, + ieee80211_hdrlen(fc)); + + /* + * Use the first empty entry in this queue's command buffer array + * to contain the Tx command and MAC header concatenated together + * (payload data will be in another buffer). + * Size of this varies, due to varying MAC header length. + * If end is not dword aligned, we'll have 2 extra bytes at the end + * of the MAC header (device reads on dword boundaries). + * We'll tell device about this padding later. + */ + len = sizeof(struct il3945_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; + len = (len + 3) & ~3; + + /* Physical address of this Tx command's header (not MAC header!), + * within command buffer array. */ + txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, + len, PCI_DMA_TODEVICE); + /* we do not map meta data ... so we can safely access address to + * provide to unmap command*/ + dma_unmap_addr_set(out_meta, mapping, txcmd_phys); + dma_unmap_len_set(out_meta, len, len); + + /* Add buffer containing Tx command and MAC(!) header to TFD's + * first entry */ + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + txcmd_phys, len, 1, 0); + + + /* Set up TFD's 2nd entry to point directly to remainder of skb, + * if any (802.11 null frames have no payload). */ + len = skb->len - hdr_len; + if (len) { + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, + len, PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + phys_addr, len, + 0, U32_PAD(len)); + } + + + /* Tell device the write idx *just past* this latest filled TFD */ + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + + if (il_queue_space(q) < q->high_mark + && il->mac80211_registered) { + if (wait_write_ptr) { + spin_lock_irqsave(&il->lock, flags); + txq->need_update = 1; + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + } + + il_stop_queue(il, txq); + } + + return 0; + +drop_unlock: + spin_unlock_irqrestore(&il->lock, flags); +drop: + return -1; +} + +static int il3945_get_measurement(struct il_priv *il, + struct ieee80211_measurement_params *params, + u8 type) +{ + struct il_spectrum_cmd spectrum; + struct il_rx_pkt *pkt; + struct il_host_cmd cmd = { + .id = REPLY_SPECTRUM_MEASUREMENT_CMD, + .data = (void *)&spectrum, + .flags = CMD_WANT_SKB, + }; + u32 add_time = le64_to_cpu(params->start_time); + int rc; + int spectrum_resp_status; + int duration = le16_to_cpu(params->duration); + struct il_rxon_context *ctx = &il->ctx; + + if (il_is_associated(il)) + add_time = il_usecs_to_beacons(il, + le64_to_cpu(params->start_time) - il->_3945.last_tsf, + le16_to_cpu(ctx->timing.beacon_interval)); + + memset(&spectrum, 0, sizeof(spectrum)); + + spectrum.channel_count = cpu_to_le16(1); + spectrum.flags = + RXON_FLG_TSF2HOST_MSK | RXON_FLG_ANT_A_MSK | RXON_FLG_DIS_DIV_MSK; + spectrum.filter_flags = MEASUREMENT_FILTER_FLAG; + cmd.len = sizeof(spectrum); + spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); + + if (il_is_associated(il)) + spectrum.start_time = + il_add_beacon_time(il, + il->_3945.last_beacon_time, add_time, + le16_to_cpu(ctx->timing.beacon_interval)); + else + spectrum.start_time = 0; + + spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT); + spectrum.channels[0].channel = params->channel; + spectrum.channels[0].type = type; + if (ctx->active.flags & RXON_FLG_BAND_24G_MSK) + spectrum.flags |= RXON_FLG_BAND_24G_MSK | + RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; + + rc = il_send_cmd_sync(il, &cmd); + if (rc) + return rc; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); + rc = -EIO; + } + + spectrum_resp_status = le16_to_cpu(pkt->u.spectrum.status); + switch (spectrum_resp_status) { + case 0: /* Command will be handled */ + if (pkt->u.spectrum.id != 0xff) { + D_INFO("Replaced existing measurement: %d\n", + pkt->u.spectrum.id); + il->measurement_status &= ~MEASUREMENT_READY; + } + il->measurement_status |= MEASUREMENT_ACTIVE; + rc = 0; + break; + + case 1: /* Command will not be handled */ + rc = -EAGAIN; + break; + } + + il_free_pages(il, cmd.reply_page); + + return rc; +} + +static void il3945_rx_reply_alive(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; + struct delayed_work *pwork; + + palive = &pkt->u.alive_frame; + + D_INFO("Alive ucode status 0x%08X revision " + "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, + palive->ver_subtype); + + if (palive->ver_subtype == INITIALIZE_SUBTYPE) { + D_INFO("Initialization Alive received.\n"); + memcpy(&il->card_alive_init, &pkt->u.alive_frame, + sizeof(struct il_alive_resp)); + pwork = &il->init_alive_start; + } else { + D_INFO("Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, + sizeof(struct il_alive_resp)); + pwork = &il->alive_start; + il3945_disable_events(il); + } + + /* We delay the ALIVE response by 5ms to + * give the HW RF Kill time to activate... */ + if (palive->is_valid == UCODE_VALID_OK) + queue_delayed_work(il->workqueue, pwork, + msecs_to_jiffies(5)); + else + IL_WARN("uCode did not respond OK.\n"); +} + +static void il3945_rx_reply_add_sta(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); +#endif + + D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); +} + +static void il3945_rx_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); +#ifdef CONFIG_IWLEGACY_DEBUG + u8 rate = beacon->beacon_notify_hdr.rate; + + D_RX("beacon status %x retries %d iss %d " + "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), + le32_to_cpu(beacon->low_tsf), rate); +#endif + + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + +} + +/* Handle notification from uCode that card's power state is changing + * due to software, hardware, or critical temperature RFKILL */ +static void il3945_rx_card_state_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); + unsigned long status = il->status; + + IL_WARN("Card state received: HW:%s SW:%s\n", + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On"); + + _il_wr(il, CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + if (flags & HW_CARD_DISABLED) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + + + il_scan_cancel(il); + + if ((test_bit(STATUS_RF_KILL_HW, &status) != + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); + else + wake_up(&il->wait_command_queue); +} + +/** + * il3945_setup_rx_handlers - Initialize Rx handler callbacks + * + * Setup the RX handlers for each of the reply types sent from the uCode + * to the host. + * + * This function chains into the hardware specific files for them to setup + * any hardware specific handlers as well. + */ +static void il3945_setup_rx_handlers(struct il_priv *il) +{ + il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; + il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il_rx_spectrum_measure_notif; + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il_rx_pm_debug_stats_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; + + /* + * The same handler is used for both the REPLY to a discrete + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. + */ + il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; + + il_setup_rx_scan_handlers(il); + il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; + + /* Set up hardware specific Rx handlers */ + il3945_hw_rx_handler_setup(il); +} + +/************************** RX-FUNCTIONS ****************************/ +/* + * Rx theory of operation + * + * The host allocates 32 DMA target addresses and passes the host address + * to the firmware at register IL_RFDS_TBL_LOWER + N * RFD_SIZE where N is + * 0 to 31 + * + * Rx Queue Indexes + * The host/firmware share two idx registers for managing the Rx buffers. + * + * The READ idx maps to the first position that the firmware may be writing + * to -- the driver can read up to (but not including) this position and get + * good data. + * The READ idx is managed by the firmware once the card is enabled. + * + * The WRITE idx maps to the last position the driver has read from -- the + * position preceding WRITE is the last slot the firmware can place a packet. + * + * The queue is empty (no good data) if WRITE = READ - 1, and is full if + * WRITE = READ. + * + * During initialization, the host sets up the READ queue position to the first + * IDX position, and WRITE to the last (READ - 1 wrapped) + * + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it + * resets the Rx queue buffers with new memory. + * + * The management in the driver is as follows: + * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When + * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled + * to replenish the iwl->rxq->rx_free. + * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the + * iwl->rxq is replenished and the READ IDX is updated (updating the + * 'processed' and 'read' driver idxes as well) + * + A received packet is processed and handed to the kernel network stack, + * detached from the iwl->rxq. The driver 'processed' idx is updated. + * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free + * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there + * were enough free buffers and RX_STALLED is set it is cleared. + * + * + * Driver sequence: + * + * il3945_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il3945_rx_queue_restock + * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx + * queue, updates firmware pointers, and updates + * the WRITE idx. If insufficient rx_free buffers + * are available, schedules il3945_rx_replenish + * + * -- enable interrupts -- + * ISR - il3945_rx() Detach il_rx_bufs from pool up to the + * READ IDX, detaching the SKB from the pool. + * Moves the packet buffer from queue to rx_used. + * Calls il3945_rx_queue_restock to refill any empty + * slots. + * ... + * + */ + +/** + * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + */ +static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, + dma_addr_t dma_addr) +{ + return cpu_to_le32((u32)dma_addr); +} + +/** + * il3945_rx_queue_restock - refill RX queue from pre-allocated pool + * + * If there are slots in the RX queue that need to be restocked, + * and we have free pre-allocated buffers, fill the ranks as much + * as we can, pulling from rx_free. + * + * This moves the 'write' idx forward to catch up with 'processed', and + * also updates the memory address in the firmware to reference the new + * target buffer. + */ +static void il3945_rx_queue_restock(struct il_priv *il) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + unsigned long flags; + int write; + + spin_lock_irqsave(&rxq->lock, flags); + write = rxq->write & ~0x7; + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { + /* Get next free Rx buffer, remove from free list */ + element = rxq->rx_free.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + + /* Point to Rx buffer via next RBD in circular buffer */ + rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); + rxq->queue[rxq->write] = rxb; + rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; + rxq->free_count--; + } + spin_unlock_irqrestore(&rxq->lock, flags); + /* If the pre-allocated buffer pool is dropping low, schedule to + * refill it */ + if (rxq->free_count <= RX_LOW_WATERMARK) + queue_work(il->workqueue, &il->rx_replenish); + + + /* If we've added more space for the firmware to place data, tell it. + * Increment device's write pointer in multiples of 8. */ + if (rxq->write_actual != (rxq->write & ~0x7) || + abs(rxq->write - rxq->read) > 7) { + spin_lock_irqsave(&rxq->lock, flags); + rxq->need_update = 1; + spin_unlock_irqrestore(&rxq->lock, flags); + il_rx_queue_update_write_ptr(il, rxq); + } +} + +/** + * il3945_rx_replenish - Move all used packet from rx_used to rx_free + * + * When moving to rx_free an SKB is allocated for the slot. + * + * Also restock the Rx queue via il3945_rx_queue_restock. + * This is called as a scheduled work item (except for during initialization) + */ +static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + struct page *page; + unsigned long flags; + gfp_t gfp_mask = priority; + + while (1) { + spin_lock_irqsave(&rxq->lock, flags); + + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + return; + } + spin_unlock_irqrestore(&rxq->lock, flags); + + if (rxq->free_count > RX_LOW_WATERMARK) + gfp_mask |= __GFP_NOWARN; + + if (il->hw_params.rx_page_order > 0) + gfp_mask |= __GFP_COMP; + + /* Alloc a new receive buffer */ + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); + if (!page) { + if (net_ratelimit()) + D_INFO("Failed to allocate SKB buffer.\n"); + if (rxq->free_count <= RX_LOW_WATERMARK && + net_ratelimit()) + IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); + /* We don't reschedule replenish work here -- we will + * call the restock method and if it still needs + * more buffers it will schedule replenish */ + break; + } + + spin_lock_irqsave(&rxq->lock, flags); + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + __free_pages(page, il->hw_params.rx_page_order); + return; + } + element = rxq->rx_used.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + spin_unlock_irqrestore(&rxq->lock, flags); + + rxb->page = page; + /* Get physical address of RB/SKB */ + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + + spin_lock_irqsave(&rxq->lock, flags); + + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + il->alloc_rxb_page++; + + spin_unlock_irqrestore(&rxq->lock, flags); + } +} + +void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +{ + unsigned long flags; + int i; + spin_lock_irqsave(&rxq->lock, flags); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { + /* In the reset function, these buffers may have been allocated + * to an SKB, so we need to unmap and free potential storage */ + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + } + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + spin_unlock_irqrestore(&rxq->lock, flags); +} + +void il3945_rx_replenish(void *data) +{ + struct il_priv *il = data; + unsigned long flags; + + il3945_rx_allocate(il, GFP_KERNEL); + + spin_lock_irqsave(&il->lock, flags); + il3945_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); +} + +static void il3945_rx_replenish_now(struct il_priv *il) +{ + il3945_rx_allocate(il, GFP_ATOMIC); + + il3945_rx_queue_restock(il); +} + + +/* Assumes that the skb field of the buffers in 'pool' is kept accurate. + * If an SKB has been detached, the POOL needs to have its SKB set to NULL + * This free routine walks the list of POOL entries and if SKB is set to + * non NULL it is unmapped and freed + */ +static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +{ + int i; + for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + } + + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), + rxq->rb_stts, rxq->rb_stts_dma); + rxq->bd = NULL; + rxq->rb_stts = NULL; +} + + +/* Convert linear signal-to-noise ratio into dB */ +static u8 ratio2dB[100] = { +/* 0 1 2 3 4 5 6 7 8 9 */ + 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ + 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ + 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ + 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ + 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ + 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ + 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ + 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ + 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ + 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ +}; + +/* Calculates a relative dB value from a ratio of linear + * (i.e. not dB) signal levels. + * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ +int il3945_calc_db_from_ratio(int sig_ratio) +{ + /* 1000:1 or higher just report as 60 dB */ + if (sig_ratio >= 1000) + return 60; + + /* 100:1 or higher, divide by 10 and use table, + * add 20 dB to make up for divide by 10 */ + if (sig_ratio >= 100) + return 20 + (int)ratio2dB[sig_ratio/10]; + + /* We shouldn't see this */ + if (sig_ratio < 1) + return 0; + + /* Use table for ratios 1:1 - 99:1 */ + return (int)ratio2dB[sig_ratio]; +} + +/** + * il3945_rx_handle - Main entry function for receiving responses from uCode + * + * Uses the il->rx_handlers callback function array to invoke + * the appropriate handlers, including command responses, + * frame-received notifications, and other notifications. + */ +static void il3945_rx_handle(struct il_priv *il) +{ + struct il_rx_buf *rxb; + struct il_rx_pkt *pkt; + struct il_rx_queue *rxq = &il->rxq; + u32 r, i; + int reclaim; + unsigned long flags; + u8 fill_rx = 0; + u32 count = 8; + int total_empty = 0; + + /* uCode's read idx (stored in shared DRAM) indicates the last Rx + * buffer that the driver may process (last buffer filled by ucode). */ + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + i = rxq->read; + + /* calculate total frames need to be restock after handling RX */ + total_empty = r - rxq->write_actual; + if (total_empty < 0) + total_empty += RX_QUEUE_SIZE; + + if (total_empty > (RX_QUEUE_SIZE / 2)) + fill_rx = 1; + /* Rx interrupt, but nothing sent from uCode */ + if (i == r) + D_RX("r = %d, i = %d\n", r, i); + + while (i != r) { + int len; + + rxb = rxq->queue[i]; + + /* If an RXB doesn't have a Rx queue slot associated with it, + * then a bug has been introduced in the queue refilling + * routines -- catch it here */ + BUG_ON(rxb == NULL); + + rxq->queue[i] = NULL; + + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + pkt = rxb_addr(rxb); + + len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len += sizeof(u32); /* account for status word */ + + /* Reclaim a command buffer only if this packet is a response + * to a (driver-originated) command. + * If the packet (e.g. Rx frame) originated from uCode, + * there is no command buffer to reclaim. + * Ucode should set SEQ_RX_FRAME bit if ucode-originated, + * but apparently a few don't get set; catch them here. */ + reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && + pkt->hdr.cmd != STATISTICS_NOTIFICATION && + pkt->hdr.cmd != REPLY_TX; + + /* Based on type of command response or notification, + * handle those that need handling via function in + * rx_handlers table. See il3945_setup_rx_handlers() */ + if (il->rx_handlers[pkt->hdr.cmd]) { + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); + } else { + /* No handling needed */ + D_RX( + "r %d i %d No handler needed for %s, 0x%02x\n", + r, i, il_get_cmd_string(pkt->hdr.cmd), + pkt->hdr.cmd); + } + + /* + * XXX: After here, we should always check rxb->page + * against NULL before touching it or its virtual + * memory (pkt). Because some rx_handler might have + * already taken or freed the pages. + */ + + if (reclaim) { + /* Invoke any callbacks, transfer the buffer to caller, + * and fire off the (possibly) blocking il_send_cmd() + * as we reclaim the driver command queue */ + if (rxb->page) + il_tx_cmd_complete(il, rxb); + else + IL_WARN("Claim null rxb?\n"); + } + + /* Reuse the page if possible. For notification packets and + * SKBs that fail to Rx correctly, add them back into the + * rx_free list for reuse later. */ + spin_lock_irqsave(&rxq->lock, flags); + if (rxb->page != NULL) { + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + } else + list_add_tail(&rxb->list, &rxq->rx_used); + + spin_unlock_irqrestore(&rxq->lock, flags); + + i = (i + 1) & RX_QUEUE_MASK; + /* If there are a lot of unused frames, + * restock the Rx queue so ucode won't assert. */ + if (fill_rx) { + count++; + if (count >= 8) { + rxq->read = i; + il3945_rx_replenish_now(il); + count = 0; + } + } + } + + /* Backtrack one entry */ + rxq->read = i; + if (fill_rx) + il3945_rx_replenish_now(il); + else + il3945_rx_queue_restock(il); +} + +/* call this function to flush any scheduled tasklet */ +static inline void il3945_synchronize_irq(struct il_priv *il) +{ + /* wait to make sure we flush pending tasklet*/ + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); +} + +static const char *il3945_desc_lookup(int i) +{ + switch (i) { + case 1: + return "FAIL"; + case 2: + return "BAD_PARAM"; + case 3: + return "BAD_CHECKSUM"; + case 4: + return "NMI_INTERRUPT"; + case 5: + return "SYSASSERT"; + case 6: + return "FATAL_ERROR"; + } + + return "UNKNOWN"; +} + +#define ERROR_START_OFFSET (1 * sizeof(u32)) +#define ERROR_ELEM_SIZE (7 * sizeof(u32)) + +void il3945_dump_nic_error_log(struct il_priv *il) +{ + u32 i; + u32 desc, time, count, base, data1; + u32 blink1, blink2, ilink1, ilink2; + + base = le32_to_cpu(il->card_alive.error_event_table_ptr); + + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR("Not valid error log pointer 0x%08X\n", base); + return; + } + + + count = il_read_targ_mem(il, base); + + if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", + il->status, count); + } + + IL_ERR("Desc Time asrtPC blink2 " + "ilink1 nmiPC Line\n"); + for (i = ERROR_START_OFFSET; + i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; + i += ERROR_ELEM_SIZE) { + desc = il_read_targ_mem(il, base + i); + time = + il_read_targ_mem(il, base + i + 1 * sizeof(u32)); + blink1 = + il_read_targ_mem(il, base + i + 2 * sizeof(u32)); + blink2 = + il_read_targ_mem(il, base + i + 3 * sizeof(u32)); + ilink1 = + il_read_targ_mem(il, base + i + 4 * sizeof(u32)); + ilink2 = + il_read_targ_mem(il, base + i + 5 * sizeof(u32)); + data1 = + il_read_targ_mem(il, base + i + 6 * sizeof(u32)); + + IL_ERR( + "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", + il3945_desc_lookup(desc), desc, time, blink1, blink2, + ilink1, ilink2, data1); + } +} + +static void il3945_irq_tasklet(struct il_priv *il) +{ + u32 inta, handled = 0; + u32 inta_fh; + unsigned long flags; +#ifdef CONFIG_IWLEGACY_DEBUG + u32 inta_mask; +#endif + + spin_lock_irqsave(&il->lock, flags); + + /* Ack/clear/reset pending uCode interrupts. + * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, + * and will clear only when CSR_FH_INT_STATUS gets cleared. */ + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); + + /* Ack/clear/reset pending flow-handler (DMA) interrupts. + * Any new interrupts that happen after this, either while we're + * in this tasklet, or later, will show up in next ISR/tasklet. */ + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & IL_DL_ISR) { + /* just for debug */ + inta_mask = _il_rd(il, CSR_INT_MASK); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta, inta_mask, inta_fh); + } +#endif + + spin_unlock_irqrestore(&il->lock, flags); + + /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not + * atomic, make sure that inta covers all the interrupts that + * we've discovered, even if FH interrupt came in just after + * reading CSR_INT. */ + if (inta_fh & CSR39_FH_INT_RX_MASK) + inta |= CSR_INT_BIT_FH_RX; + if (inta_fh & CSR39_FH_INT_TX_MASK) + inta |= CSR_INT_BIT_FH_TX; + + /* Now service all interrupt bits discovered above. */ + if (inta & CSR_INT_BIT_HW_ERR) { + IL_ERR("Hardware error detected. Restarting.\n"); + + /* Tell the device to stop sending interrupts */ + il_disable_interrupts(il); + + il->isr_stats.hw++; + il_irq_handle_error(il); + + handled |= CSR_INT_BIT_HW_ERR; + + return; + } + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + /* NIC fires this, but we don't use it, redundant with WAKEUP */ + if (inta & CSR_INT_BIT_SCD) { + D_ISR("Scheduler finished to transmit " + "the frame/frames.\n"); + il->isr_stats.sch++; + } + + /* Alive notification via Rx interrupt will do the real work */ + if (inta & CSR_INT_BIT_ALIVE) { + D_ISR("Alive interrupt\n"); + il->isr_stats.alive++; + } + } +#endif + /* Safely ignore these bits for debug checks below */ + inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); + + /* Error detected by uCode */ + if (inta & CSR_INT_BIT_SW_ERR) { + IL_ERR("Microcode SW error detected. " + "Restarting 0x%X.\n", inta); + il->isr_stats.sw++; + il_irq_handle_error(il); + handled |= CSR_INT_BIT_SW_ERR; + } + + /* uCode wakes up after power-down sleep */ + if (inta & CSR_INT_BIT_WAKEUP) { + D_ISR("Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + il_txq_update_write_ptr(il, &il->txq[0]); + il_txq_update_write_ptr(il, &il->txq[1]); + il_txq_update_write_ptr(il, &il->txq[2]); + il_txq_update_write_ptr(il, &il->txq[3]); + il_txq_update_write_ptr(il, &il->txq[4]); + il_txq_update_write_ptr(il, &il->txq[5]); + + il->isr_stats.wakeup++; + handled |= CSR_INT_BIT_WAKEUP; + } + + /* All uCode command responses, including Tx command responses, + * Rx "responses" (frame-received notification), and other + * notifications from uCode come through here*/ + if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { + il3945_rx_handle(il); + il->isr_stats.rx++; + handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); + } + + if (inta & CSR_INT_BIT_FH_TX) { + D_ISR("Tx interrupt\n"); + il->isr_stats.tx++; + + _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); + il_wr(il, FH39_TCSR_CREDIT + (FH39_SRVC_CHNL), 0x0); + handled |= CSR_INT_BIT_FH_TX; + } + + if (inta & ~handled) { + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; + } + + if (inta & ~il->inta_mask) { + IL_WARN("Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + } + + /* Re-enable all interrupts */ + /* only Re-enable if disabled by irq */ + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + } +#endif +} + +static int il3945_get_channels_for_scan(struct il_priv *il, + enum ieee80211_band band, + u8 is_active, u8 n_probes, + struct il3945_scan_channel *scan_ch, + struct ieee80211_vif *vif) +{ + struct ieee80211_channel *chan; + const struct ieee80211_supported_band *sband; + const struct il_channel_info *ch_info; + u16 passive_dwell = 0; + u16 active_dwell = 0; + int added, i; + + sband = il_get_hw_mode(il, band); + if (!sband) + return 0; + + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); + + if (passive_dwell <= active_dwell) + passive_dwell = active_dwell + 1; + + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; + + if (chan->band != band) + continue; + + scan_ch->channel = chan->hw_value; + + ch_info = il_get_channel_info(il, band, + scan_ch->channel); + if (!il_is_channel_valid(ch_info)) { + D_SCAN( + "Channel %d is INVALID for this band.\n", + scan_ch->channel); + continue; + } + + scan_ch->active_dwell = cpu_to_le16(active_dwell); + scan_ch->passive_dwell = cpu_to_le16(passive_dwell); + /* If passive , set up for auto-switch + * and use long active_dwell time. + */ + if (!is_active || il_is_channel_passive(ch_info) || + (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { + scan_ch->type = 0; /* passive */ + if (IL_UCODE_API(il->ucode_ver) == 1) + scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); + } else { + scan_ch->type = 1; /* active */ + } + + /* Set direct probe bits. These may be used both for active + * scan channels (probes gets sent right away), + * or for passive channels (probes get se sent only after + * hearing clear Rx packet).*/ + if (IL_UCODE_API(il->ucode_ver) >= 2) { + if (n_probes) + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); + } else { + /* uCode v1 does not allow setting direct probe bits on + * passive channel. */ + if ((scan_ch->type & 1) && n_probes) + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); + } + + /* Set txpower levels to defaults */ + scan_ch->tpc.dsp_atten = 110; + /* scan_pwr_info->tpc.dsp_atten; */ + + /*scan_pwr_info->tpc.tx_gain; */ + if (band == IEEE80211_BAND_5GHZ) + scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; + else { + scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); + /* NOTE: if we were doing 6Mb OFDM for scans we'd use + * power level: + * scan_ch->tpc.tx_gain = ((1 << 5) | (2 << 3)) | 3; + */ + } + + D_SCAN("Scanning %d [%s %d]\n", + scan_ch->channel, + (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", + (scan_ch->type & 1) ? + active_dwell : passive_dwell); + + scan_ch++; + added++; + } + + D_SCAN("total channels to scan %d\n", added); + return added; +} + +static void il3945_init_hw_rates(struct il_priv *il, + struct ieee80211_rate *rates) +{ + int i; + + for (i = 0; i < RATE_COUNT_LEGACY; i++) { + rates[i].bitrate = il3945_rates[i].ieee * 5; + rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value_short = i; + rates[i].flags = 0; + if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { + /* + * If CCK != 1M then set short preamble rate flag. + */ + rates[i].flags |= (il3945_rates[i].plcp == 10) ? + 0 : IEEE80211_RATE_SHORT_PREAMBLE; + } + } +} + +/****************************************************************************** + * + * uCode download functions + * + ******************************************************************************/ + +static void il3945_dealloc_ucode_pci(struct il_priv *il) +{ + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); +} + +/** + * il3945_verify_inst_full - verify runtime uCode image in card vs. host, + * looking at all data. + */ +static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) +{ + u32 val; + u32 save_len = len; + int rc = 0; + u32 errcnt; + + D_INFO("ucode inst image size is %u\n", len); + + il_wr(il, HBUS_TARG_MEM_RADDR, + IL39_RTC_INST_LOWER_BOUND); + + errcnt = 0; + for (; len > 0; len -= sizeof(u32), image++) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + IL_ERR("uCode INST section is invalid at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); + rc = -EIO; + errcnt++; + if (errcnt >= 20) + break; + } + } + + + if (!errcnt) + D_INFO( + "ucode image in INSTRUCTION memory is good\n"); + + return rc; +} + + +/** + * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, + * using sample data 100 bytes apart. If these sample points are good, + * it's a pretty good bet that everything between them is good, too. + */ +static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +{ + u32 val; + int rc = 0; + u32 errcnt = 0; + u32 i; + + D_INFO("ucode inst image size is %u\n", len); + + for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + il_wr(il, HBUS_TARG_MEM_RADDR, + i + IL39_RTC_INST_LOWER_BOUND); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { +#if 0 /* Enable this if you want to see details */ + IL_ERR("uCode INST section is invalid at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + i, val, *image); +#endif + rc = -EIO; + errcnt++; + if (errcnt >= 3) + break; + } + } + + return rc; +} + + +/** + * il3945_verify_ucode - determine which instruction image is in SRAM, + * and verify its contents + */ +static int il3945_verify_ucode(struct il_priv *il) +{ + __le32 *image; + u32 len; + int rc = 0; + + /* Try bootstrap */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_sparse(il, image, len); + if (rc == 0) { + D_INFO("Bootstrap uCode is good in inst SRAM\n"); + return 0; + } + + /* Try initialize */ + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + rc = il3945_verify_inst_sparse(il, image, len); + if (rc == 0) { + D_INFO("Initialize uCode is good in inst SRAM\n"); + return 0; + } + + /* Try runtime/protocol */ + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + rc = il3945_verify_inst_sparse(il, image, len); + if (rc == 0) { + D_INFO("Runtime uCode is good in inst SRAM\n"); + return 0; + } + + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + + /* Since nothing seems to match, show first several data entries in + * instruction SRAM, so maybe visual inspection will give a clue. + * Selection of bootstrap image (vs. other images) is arbitrary. */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_full(il, image, len); + + return rc; +} + +static void il3945_nic_start(struct il_priv *il) +{ + /* Remove all resets to allow NIC to operate */ + _il_wr(il, CSR_RESET, 0); +} + +#define IL3945_UCODE_GET(item) \ +static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ +{ \ + return le32_to_cpu(ucode->v1.item); \ +} + +static u32 il3945_ucode_get_header_size(u32 api_ver) +{ + return 24; +} + +static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) +{ + return (u8 *) ucode->v1.data; +} + +IL3945_UCODE_GET(inst_size); +IL3945_UCODE_GET(data_size); +IL3945_UCODE_GET(init_size); +IL3945_UCODE_GET(init_data_size); +IL3945_UCODE_GET(boot_size); + +/** + * il3945_read_ucode - Read uCode images from disk file. + * + * Copy into buffers for card to fetch via bus-mastering + */ +static int il3945_read_ucode(struct il_priv *il) +{ + const struct il_ucode_header *ucode; + int ret = -EINVAL, idx; + const struct firmware *ucode_raw; + /* firmware file name contains uCode/driver compatibility version */ + const char *name_pre = il->cfg->fw_name_pre; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; + char buf[25]; + u8 *src; + size_t len; + u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size; + + /* Ask kernel firmware_class module to get the boot firmware off disk. + * request_firmware() is synchronous, file is in memory on return. */ + for (idx = api_max; idx >= api_min; idx--) { + sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); + ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); + if (ret < 0) { + IL_ERR("%s firmware file req failed: %d\n", + buf, ret); + if (ret == -ENOENT) + continue; + else + goto error; + } else { + if (idx < api_max) + IL_ERR("Loaded firmware %s, " + "which is deprecated. " + " Please use API v%u instead.\n", + buf, api_max); + D_INFO("Got firmware '%s' file " + "(%zd bytes) from disk\n", + buf, ucode_raw->size); + break; + } + } + + if (ret < 0) + goto error; + + /* Make sure that we got at least our header! */ + if (ucode_raw->size < il3945_ucode_get_header_size(1)) { + IL_ERR("File size way too small!\n"); + ret = -EINVAL; + goto err_release; + } + + /* Data from ucode file: header followed by uCode images */ + ucode = (struct il_ucode_header *)ucode_raw->data; + + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); + inst_size = il3945_ucode_get_inst_size(ucode); + data_size = il3945_ucode_get_data_size(ucode); + init_size = il3945_ucode_get_init_size(ucode); + init_data_size = il3945_ucode_get_init_data_size(ucode); + boot_size = il3945_ucode_get_boot_size(ucode); + src = il3945_ucode_get_data(ucode); + + /* api_ver should match the api version forming part of the + * firmware filename ... but we don't check for that and only rely + * on the API version read from firmware header from here on forward */ + + if (api_ver < api_min || api_ver > api_max) { + IL_ERR("Driver unable to support your firmware API. " + "Driver supports v%u, firmware is v%u.\n", + api_max, api_ver); + il->ucode_ver = 0; + ret = -EINVAL; + goto err_release; + } + if (api_ver != api_max) + IL_ERR("Firmware has old API version. Expected %u, " + "got %u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", + api_max, api_ver); + + IL_INFO("loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + D_INFO("f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %u\n", + inst_size); + D_INFO("f/w package hdr runtime data size = %u\n", + data_size); + D_INFO("f/w package hdr init inst size = %u\n", + init_size); + D_INFO("f/w package hdr init data size = %u\n", + init_data_size); + D_INFO("f/w package hdr boot inst size = %u\n", + boot_size); + + + /* Verify size of file vs. image size info in file's header */ + if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + + inst_size + data_size + init_size + + init_data_size + boot_size) { + + D_INFO( + "uCode file size %zd does not match expected size\n", + ucode_raw->size); + ret = -EINVAL; + goto err_release; + } + + /* Verify that uCode images will fit in card's SRAM */ + if (inst_size > IL39_MAX_INST_SIZE) { + D_INFO("uCode instr len %d too large to fit in\n", + inst_size); + ret = -EINVAL; + goto err_release; + } + + if (data_size > IL39_MAX_DATA_SIZE) { + D_INFO("uCode data len %d too large to fit in\n", + data_size); + ret = -EINVAL; + goto err_release; + } + if (init_size > IL39_MAX_INST_SIZE) { + D_INFO( + "uCode init instr len %d too large to fit in\n", + init_size); + ret = -EINVAL; + goto err_release; + } + if (init_data_size > IL39_MAX_DATA_SIZE) { + D_INFO( + "uCode init data len %d too large to fit in\n", + init_data_size); + ret = -EINVAL; + goto err_release; + } + if (boot_size > IL39_MAX_BSM_SIZE) { + D_INFO( + "uCode boot instr len %d too large to fit in\n", + boot_size); + ret = -EINVAL; + goto err_release; + } + + /* Allocate ucode buffers for card's bus-master loading ... */ + + /* Runtime instructions and 2 copies of data: + * 1) unmodified from disk + * 2) backup cache for save/restore during power-downs */ + il->ucode_code.len = inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); + + il->ucode_data.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); + + il->ucode_data_backup.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); + + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) + goto err_pci_alloc; + + /* Initialization instructions and data */ + if (init_size && init_data_size) { + il->ucode_init.len = init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); + + il->ucode_init_data.len = init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); + + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) + goto err_pci_alloc; + } + + /* Bootstrap (instructions only, no data) */ + if (boot_size) { + il->ucode_boot.len = boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); + + if (!il->ucode_boot.v_addr) + goto err_pci_alloc; + } + + /* Copy images into buffers for card's bus-master reads ... */ + + /* Runtime instructions (first block of data in file) */ + len = inst_size; + D_INFO( + "Copying (but not loading) uCode instr len %zd\n", len); + memcpy(il->ucode_code.v_addr, src, len); + src += len; + + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + + /* Runtime data (2nd block) + * NOTE: Copy into backup buffer will be done in il3945_up() */ + len = data_size; + D_INFO( + "Copying (but not loading) uCode data len %zd\n", len); + memcpy(il->ucode_data.v_addr, src, len); + memcpy(il->ucode_data_backup.v_addr, src, len); + src += len; + + /* Initialization instructions (3rd block) */ + if (init_size) { + len = init_size; + D_INFO( + "Copying (but not loading) init instr len %zd\n", len); + memcpy(il->ucode_init.v_addr, src, len); + src += len; + } + + /* Initialization data (4th block) */ + if (init_data_size) { + len = init_data_size; + D_INFO( + "Copying (but not loading) init data len %zd\n", len); + memcpy(il->ucode_init_data.v_addr, src, len); + src += len; + } + + /* Bootstrap instructions (5th block) */ + len = boot_size; + D_INFO( + "Copying (but not loading) boot instr len %zd\n", len); + memcpy(il->ucode_boot.v_addr, src, len); + + /* We have our copies now, allow OS release its copies */ + release_firmware(ucode_raw); + return 0; + + err_pci_alloc: + IL_ERR("failed to allocate pci memory\n"); + ret = -ENOMEM; + il3945_dealloc_ucode_pci(il); + + err_release: + release_firmware(ucode_raw); + + error: + return ret; +} + + +/** + * il3945_set_ucode_ptrs - Set uCode address location + * + * Tell initialization uCode where to find runtime uCode. + * + * BSM registers initially contain pointers to initialization uCode. + * We need to replace them to load runtime uCode inst and data, + * and to save runtime data when powering down. + */ +static int il3945_set_ucode_ptrs(struct il_priv *il) +{ + dma_addr_t pinst; + dma_addr_t pdata; + + /* bits 31:0 for 3945 */ + pinst = il->ucode_code.p_addr; + pdata = il->ucode_data_backup.p_addr; + + /* Tell bootstrap uCode where to find image to load */ + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); + + /* Inst byte count must be last to set up, bit 31 signals uCode + * that all new ptr/size info is in place */ + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); + + D_INFO("Runtime uCode pointers are set.\n"); + + return 0; +} + +/** + * il3945_init_alive_start - Called after REPLY_ALIVE notification received + * + * Called after REPLY_ALIVE notification received from "initialize" uCode. + * + * Tell "initialize" uCode to go ahead and load the runtime uCode. + */ +static void il3945_init_alive_start(struct il_priv *il) +{ + /* Check alive response for "valid" sign from uCode */ + if (il->card_alive_init.is_valid != UCODE_VALID_OK) { + /* We had an error bringing up the hardware, so take it + * all the way back down so we can try again */ + D_INFO("Initialize Alive failed.\n"); + goto restart; + } + + /* Bootstrap uCode has loaded initialize uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "initialize" alive if code weren't properly loaded. */ + if (il3945_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad \"initialize\" uCode load.\n"); + goto restart; + } + + /* Send pointers to protocol/runtime uCode image ... init code will + * load and launch runtime uCode, which will send us another "Alive" + * notification. */ + D_INFO("Initialization Alive received.\n"); + if (il3945_set_ucode_ptrs(il)) { + /* Runtime instruction load won't happen; + * take it all the way back down so we can try again */ + D_INFO("Couldn't set up uCode pointers.\n"); + goto restart; + } + return; + + restart: + queue_work(il->workqueue, &il->restart); +} + +/** + * il3945_alive_start - called after REPLY_ALIVE notification received + * from protocol/runtime uCode (initialization uCode's + * Alive gets handled by il3945_init_alive_start()). + */ +static void il3945_alive_start(struct il_priv *il) +{ + int thermal_spin = 0; + u32 rfkill; + struct il_rxon_context *ctx = &il->ctx; + + D_INFO("Runtime Alive received.\n"); + + if (il->card_alive.is_valid != UCODE_VALID_OK) { + /* We had an error bringing up the hardware, so take it + * all the way back down so we can try again */ + D_INFO("Alive failed.\n"); + goto restart; + } + + /* Initialize uCode has loaded Runtime uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "runtime" alive if code weren't properly loaded. */ + if (il3945_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad runtime uCode load.\n"); + goto restart; + } + + rfkill = il_rd_prph(il, APMG_RFKILL_REG); + D_INFO("RFKILL status: 0x%x\n", rfkill); + + if (rfkill & 0x1) { + clear_bit(STATUS_RF_KILL_HW, &il->status); + /* if RFKILL is not on, then wait for thermal + * sensor in adapter to kick in */ + while (il3945_hw_get_temperature(il) == 0) { + thermal_spin++; + udelay(10); + } + + if (thermal_spin) + D_INFO("Thermal calibration took %dus\n", + thermal_spin * 10); + } else + set_bit(STATUS_RF_KILL_HW, &il->status); + + /* After the ALIVE response, we can send commands to 3945 uCode */ + set_bit(STATUS_ALIVE, &il->status); + + /* Enable watchdog to monitor the driver tx queues */ + il_setup_watchdog(il); + + if (il_is_rfkill(il)) + return; + + ieee80211_wake_queues(il->hw); + + il->active_rate = RATES_MASK_3945; + + il_power_update_mode(il, true); + + if (il_is_associated(il)) { + struct il3945_rxon_cmd *active_rxon = + (struct il3945_rxon_cmd *)(&ctx->active); + + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + } else { + /* Initialize our rx_config data */ + il_connection_init_rx_config(il, ctx); + } + + /* Configure Bluetooth device coexistence support */ + il_send_bt_config(il); + + set_bit(STATUS_READY, &il->status); + + /* Configure the adapter for unassociated operation */ + il3945_commit_rxon(il, ctx); + + il3945_reg_txpower_periodic(il); + + D_INFO("ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); + + return; + + restart: + queue_work(il->workqueue, &il->restart); +} + +static void il3945_cancel_deferred_work(struct il_priv *il); + +static void __il3945_down(struct il_priv *il) +{ + unsigned long flags; + int exit_pending; + + D_INFO(DRV_NAME " is going down\n"); + + il_scan_cancel_timeout(il, 200); + + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + + /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + * to prevent rearm timer */ + del_timer_sync(&il->watchdog); + + /* Station information will now be cleared in device */ + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); + + /* Unblock any waiting calls */ + wake_up_all(&il->wait_command_queue); + + /* Wipe out the EXIT_PENDING status bit if we are not actually + * exiting the module */ + if (!exit_pending) + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* stop and reset the on-board processor */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + /* tell the device to stop sending interrupts */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il3945_synchronize_irq(il); + + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); + + /* If we have not previously called il3945_init() then + * clear all bits but the RF Kill bits and return */ + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + goto exit; + } + + /* ...otherwise clear out all the status bits but the RF Kill + * bit and continue taking the NIC down. */ + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_FW_ERROR, &il->status) << + STATUS_FW_ERROR | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + + il3945_hw_txq_ctx_stop(il); + il3945_hw_rxq_stop(il); + + /* Power-down device's busmaster DMA clocks */ + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + udelay(5); + + /* Stop the device, and put it in low power state */ + il_apm_stop(il); + + exit: + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); + + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; + + /* clear out any free frames */ + il3945_clear_free_frames(il); +} + +static void il3945_down(struct il_priv *il) +{ + mutex_lock(&il->mutex); + __il3945_down(il); + mutex_unlock(&il->mutex); + + il3945_cancel_deferred_work(il); +} + +#define MAX_HW_RESTARTS 5 + +static int il3945_alloc_bcast_station(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + unsigned long flags; + u8 sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, + il_bcast_addr, false, NULL); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return -EINVAL; + } + + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +static int __il3945_up(struct il_priv *il) +{ + int rc, i; + + rc = il3945_alloc_bcast_station(il); + if (rc) + return rc; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN("Exit pending; will not bring the NIC up\n"); + return -EIO; + } + + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR("ucode not available for device bring up\n"); + return -EIO; + } + + /* If platform's RF_KILL switch is NOT set to KILL */ + if (_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + clear_bit(STATUS_RF_KILL_HW, &il->status); + else { + set_bit(STATUS_RF_KILL_HW, &il->status); + IL_WARN("Radio disabled by HW RF Kill switch\n"); + return -ENODEV; + } + + _il_wr(il, CSR_INT, 0xFFFFFFFF); + + rc = il3945_hw_nic_init(il); + if (rc) { + IL_ERR("Unable to int nic\n"); + return rc; + } + + /* make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + /* clear (again), then enable host interrupts */ + _il_wr(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); + + /* really make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + + /* Copy original ucode data image from disk into backup cache. + * This will be used to initialize the on-board processor's + * data SRAM for a clean start when the runtime program first loads. */ + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); + + /* We return success when we resume from suspend and rf_kill is on. */ + if (test_bit(STATUS_RF_KILL_HW, &il->status)) + return 0; + + for (i = 0; i < MAX_HW_RESTARTS; i++) { + + /* load bootstrap state machine, + * load bootstrap program into processor's memory, + * prepare to load the "initialize" uCode */ + rc = il->cfg->ops->lib->load_ucode(il); + + if (rc) { + IL_ERR( + "Unable to set up bootstrap uCode: %d\n", rc); + continue; + } + + /* start card; "initialize" will load runtime ucode */ + il3945_nic_start(il); + + D_INFO(DRV_NAME " is coming up\n"); + + return 0; + } + + set_bit(STATUS_EXIT_PENDING, &il->status); + __il3945_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* tried to restart and config the device for as long as our + * patience could withstand */ + IL_ERR("Unable to initialize device after %d attempts.\n", i); + return -EIO; +} + + +/***************************************************************************** + * + * Workqueue callbacks + * + *****************************************************************************/ + +static void il3945_bg_init_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, init_alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il3945_init_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +static void il3945_bg_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il3945_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +/* + * 3945 cannot interrupt driver when hardware rf kill switch toggles; + * driver must poll CSR_GP_CNTRL_REG register for change. This register + * *is* readable even when device has been SW_RESET into low power mode + * (e.g. during RF KILL). + */ +static void il3945_rfkill_poll(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, _3945.rfkill_poll.work); + bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); + bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) + & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); + + if (new_rfkill != old_rfkill) { + if (new_rfkill) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + + wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); + + D_RF_KILL("RF_KILL bit toggled to %s.\n", + new_rfkill ? "disable radio" : "enable radio"); + } + + /* Keep this running, even if radio now enabled. This will be + * cancelled in mac_start() if system decides to start again */ + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, + round_jiffies_relative(2 * HZ)); + +} + +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +{ + struct il_host_cmd cmd = { + .id = REPLY_SCAN_CMD, + .len = sizeof(struct il3945_scan_cmd), + .flags = CMD_SIZE_HUGE, + }; + struct il3945_scan_cmd *scan; + u8 n_probes = 0; + enum ieee80211_band band; + bool is_active = false; + int ret; + u16 len; + + lockdep_assert_held(&il->mutex); + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); + if (!il->scan_cmd) { + D_SCAN("Fail to allocate scan memory\n"); + return -ENOMEM; + } + } + scan = il->scan_cmd; + memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); + + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; + + if (il_is_associated(il)) { + u16 interval; + u32 extra; + u32 suspend_time = 100; + u32 scan_suspend_time = 100; + + D_INFO("Scanning while associated...\n"); + + interval = vif->bss_conf.beacon_int; + + scan->suspend_time = 0; + scan->max_out_time = cpu_to_le32(200 * 1024); + if (!interval) + interval = suspend_time; + /* + * suspend time format: + * 0-19: beacon interval in usec (time before exec.) + * 20-23: 0 + * 24-31: number of beacons (suspend between channels) + */ + + extra = (suspend_time / interval) << 24; + scan_suspend_time = 0xFF0FFFFF & + (extra | ((suspend_time % interval) * 1024)); + + scan->suspend_time = cpu_to_le32(scan_suspend_time); + D_SCAN("suspend_time 0x%X beacon interval %d\n", + scan_suspend_time, interval); + } + + if (il->scan_request->n_ssids) { + int i, p = 0; + D_SCAN("Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { + /* always does wildcard anyway */ + if (!il->scan_request->ssids[i].ssid_len) + continue; + scan->direct_scan[p].id = WLAN_EID_SSID; + scan->direct_scan[p].len = + il->scan_request->ssids[i].ssid_len; + memcpy(scan->direct_scan[p].ssid, + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); + n_probes++; + p++; + } + is_active = true; + } else + D_SCAN("Kicking off passive scan.\n"); + + /* We don't build a direct scan probe request; the uCode will do + * that based on the direct_mask added to each channel entry */ + scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; + scan->tx_cmd.sta_id = il->ctx.bcast_sta_id; + scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + + /* flags + rate selection */ + + switch (il->scan_band) { + case IEEE80211_BAND_2GHZ: + scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; + scan->tx_cmd.rate = RATE_1M_PLCP; + band = IEEE80211_BAND_2GHZ; + break; + case IEEE80211_BAND_5GHZ: + scan->tx_cmd.rate = RATE_6M_PLCP; + band = IEEE80211_BAND_5GHZ; + break; + default: + IL_WARN("Invalid scan band\n"); + return -EIO; + } + + /* + * If active scaning is requested but a certain channel + * is marked passive, we can do active scanning if we + * detect transmissions. + */ + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_DISABLED; + + len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); + scan->tx_cmd.len = cpu_to_le16(len); + + /* select Rx antennas */ + scan->flags |= il3945_get_antenna_flags(il); + + scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, + (void *)&scan->data[len], vif); + if (scan->channel_count == 0) { + D_SCAN("channel count %d\n", scan->channel_count); + return -EIO; + } + + cmd.len += le16_to_cpu(scan->tx_cmd.len) + + scan->channel_count * sizeof(struct il3945_scan_channel); + cmd.data = scan; + scan->len = cpu_to_le16(cmd.len); + + set_bit(STATUS_SCAN_HW, &il->status); + ret = il_send_cmd_sync(il, &cmd); + if (ret) + clear_bit(STATUS_SCAN_HW, &il->status); + return ret; +} + +void il3945_post_scan(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + + /* + * Since setting the RXON may have been deferred while + * performing the scan, fire one off if needed + */ + if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) + il3945_commit_rxon(il, ctx); +} + +static void il3945_bg_restart(struct work_struct *data) +{ + struct il_priv *il = container_of(data, struct il_priv, restart); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + mutex_lock(&il->mutex); + il->ctx.vif = NULL; + il->is_open = 0; + mutex_unlock(&il->mutex); + il3945_down(il); + ieee80211_restart_hw(il->hw); + } else { + il3945_down(il); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); + return; + } + + __il3945_up(il); + mutex_unlock(&il->mutex); + } +} + +static void il3945_bg_rx_replenish(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, rx_replenish); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il3945_rx_replenish(il); +out: + mutex_unlock(&il->mutex); +} + +void il3945_post_associate(struct il_priv *il) +{ + int rc = 0; + struct ieee80211_conf *conf = NULL; + struct il_rxon_context *ctx = &il->ctx; + + if (!ctx->vif || !il->is_open) + return; + + D_ASSOC("Associated as %d to: %pM\n", + ctx->vif->bss_conf.aid, ctx->active.bssid_addr); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + il_scan_cancel_timeout(il, 200); + + conf = il_ieee80211_get_hw_conf(il->hw); + + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il3945_commit_rxon(il, ctx); + + rc = il_send_rxon_timing(il, ctx); + if (rc) + IL_WARN("REPLY_RXON_TIMING failed - " + "Attempting to continue.\n"); + + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + + ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); + + D_ASSOC("assoc id %d beacon interval %d\n", + ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); + + if (ctx->vif->bss_conf.use_short_preamble) + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (ctx->vif->bss_conf.use_short_slot) + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + } + + il3945_commit_rxon(il, ctx); + + switch (ctx->vif->type) { + case NL80211_IFTYPE_STATION: + il3945_rate_scale_init(il->hw, IL_AP_ID); + break; + case NL80211_IFTYPE_ADHOC: + il3945_send_beacon_cmd(il); + break; + default: + IL_ERR("%s Should not be called in %d mode\n", + __func__, ctx->vif->type); + break; + } +} + +/***************************************************************************** + * + * mac80211 entry point functions + * + *****************************************************************************/ + +#define UCODE_READY_TIMEOUT (2 * HZ) + +static int il3945_mac_start(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + int ret; + + D_MAC80211("enter\n"); + + /* we should be verifying the device is ready to be opened */ + mutex_lock(&il->mutex); + + /* fetch ucode file from disk, alloc and copy to bus-master buffers ... + * ucode filename and max sizes are card-specific. */ + + if (!il->ucode_code.len) { + ret = il3945_read_ucode(il); + if (ret) { + IL_ERR("Could not read microcode: %d\n", ret); + mutex_unlock(&il->mutex); + goto out_release_irq; + } + } + + ret = __il3945_up(il); + + mutex_unlock(&il->mutex); + + if (ret) + goto out_release_irq; + + D_INFO("Start UP work.\n"); + + /* Wait for START_ALIVE from ucode. Otherwise callbacks from + * mac80211 will not be run successfully. */ + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), + UCODE_READY_TIMEOUT); + if (!ret) { + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR( + "Wait for START_ALIVE timeout after %dms.\n", + jiffies_to_msecs(UCODE_READY_TIMEOUT)); + ret = -ETIMEDOUT; + goto out_release_irq; + } + } + + /* ucode is running and will send rfkill notifications, + * no need to poll the killswitch state anymore */ + cancel_delayed_work(&il->_3945.rfkill_poll); + + il->is_open = 1; + D_MAC80211("leave\n"); + return 0; + +out_release_irq: + il->is_open = 0; + D_MAC80211("leave - failed\n"); + return ret; +} + +static void il3945_mac_stop(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + + D_MAC80211("enter\n"); + + if (!il->is_open) { + D_MAC80211("leave - skip\n"); + return; + } + + il->is_open = 0; + + il3945_down(il); + + flush_workqueue(il->workqueue); + + /* start polling the killswitch state again */ + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, + round_jiffies_relative(2 * HZ)); + + D_MAC80211("leave\n"); +} + +static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct il_priv *il = hw->priv; + + D_MAC80211("enter\n"); + + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + + if (il3945_tx_skb(il, skb)) + dev_kfree_skb_any(skb); + + D_MAC80211("leave\n"); +} + +void il3945_config_ap(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_vif *vif = ctx->vif; + int rc = 0; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + /* The following should be done only at AP bring up */ + if (!(il_is_associated(il))) { + + /* RXON - unassoc (to set timing command) */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il3945_commit_rxon(il, ctx); + + /* RXON Timing */ + rc = il_send_rxon_timing(il, ctx); + if (rc) + IL_WARN("REPLY_RXON_TIMING failed - " + "Attempting to continue.\n"); + + ctx->staging.assoc_id = 0; + + if (vif->bss_conf.use_short_preamble) + ctx->staging.flags |= + RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (vif->bss_conf.use_short_slot) + ctx->staging.flags |= + RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_SLOT_MSK; + } + /* restore RXON assoc */ + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il3945_commit_rxon(il, ctx); + } + il3945_send_beacon_cmd(il); +} + +static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + struct il_priv *il = hw->priv; + int ret = 0; + u8 sta_id = IL_INVALID_STATION; + u8 static_key; + + D_MAC80211("enter\n"); + + if (il3945_mod_params.sw_crypto) { + D_MAC80211("leave - hwcrypto disabled\n"); + return -EOPNOTSUPP; + } + + /* + * To support IBSS RSN, don't program group keys in IBSS, the + * hardware will then not attempt to decrypt the frames. + */ + if (vif->type == NL80211_IFTYPE_ADHOC && + !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) + return -EOPNOTSUPP; + + static_key = !il_is_associated(il); + + if (!static_key) { + sta_id = il_sta_id_or_broadcast( + il, &il->ctx, sta); + if (sta_id == IL_INVALID_STATION) + return -EINVAL; + } + + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); + + switch (cmd) { + case SET_KEY: + if (static_key) + ret = il3945_set_static_key(il, key); + else + ret = il3945_set_dynamic_key(il, key, sta_id); + D_MAC80211("enable hwcrypto key\n"); + break; + case DISABLE_KEY: + if (static_key) + ret = il3945_remove_static_key(il); + else + ret = il3945_clear_sta_key_info(il, sta_id); + D_MAC80211("disable hwcrypto key\n"); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&il->mutex); + D_MAC80211("leave\n"); + + return ret; +} + +static int il3945_mac_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct il_priv *il = hw->priv; + struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; + int ret; + bool is_ap = vif->type == NL80211_IFTYPE_STATION; + u8 sta_id; + + D_INFO("received request to add station %pM\n", + sta->addr); + mutex_lock(&il->mutex); + D_INFO("proceeding to add station %pM\n", + sta->addr); + sta_priv->common.sta_id = IL_INVALID_STATION; + + + ret = il_add_station_common(il, + &il->ctx, + sta->addr, is_ap, sta, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM (%d)\n", + sta->addr, ret); + /* Should we return success if return code is EEXIST ? */ + mutex_unlock(&il->mutex); + return ret; + } + + sta_priv->common.sta_id = sta_id; + + /* Initialize rate scaling */ + D_INFO("Initializing rate scaling for station %pM\n", + sta->addr); + il3945_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); + + return 0; +} + +static void il3945_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 multicast) +{ + struct il_priv *il = hw->priv; + __le32 filter_or = 0, filter_nand = 0; + struct il_rxon_context *ctx = &il->ctx; + +#define CHK(test, flag) do { \ + if (*total_flags & (test)) \ + filter_or |= (flag); \ + else \ + filter_nand |= (flag); \ + } while (0) + + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", + changed_flags, *total_flags); + + CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); + CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); + CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); + +#undef CHK + + mutex_lock(&il->mutex); + + ctx->staging.filter_flags &= ~filter_nand; + ctx->staging.filter_flags |= filter_or; + + /* + * Not committing directly because hardware can perform a scan, + * but even if hw is ready, committing here breaks for some reason, + * we'll eventually commit the filter flags change anyway. + */ + + mutex_unlock(&il->mutex); + + /* + * Receiving all multicast frames is always enabled by the + * default flags setup in il_connection_init_rx_config() + * since we currently do not support programming multicast + * filters into the device. + */ + *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; +} + + +/***************************************************************************** + * + * sysfs attributes + * + *****************************************************************************/ + +#ifdef CONFIG_IWLEGACY_DEBUG + +/* + * The following adds a new attribute to the sysfs representation + * of this device driver (i.e. a new file in /sys/bus/pci/drivers/iwl/) + * used for controlling the debug level. + * + * See the level definitions in iwl for details. + * + * The debug_level being managed using sysfs below is a per device debug + * level that is used instead of the global debug level if it (the per + * device debug level) is set. + */ +static ssize_t il3945_show_debug_level(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); +} +static ssize_t il3945_store_debug_level(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + unsigned long val; + int ret; + + ret = strict_strtoul(buf, 0, &val); + if (ret) + IL_INFO("%s is not in hex or decimal form.\n", buf); + else { + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR( + "Not enough memory to generate traffic log\n"); + } + return strnlen(buf, count); +} + +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, + il3945_show_debug_level, il3945_store_debug_level); + +#endif /* CONFIG_IWLEGACY_DEBUG */ + +static ssize_t il3945_show_temperature(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_alive(il)) + return -EAGAIN; + + return sprintf(buf, "%d\n", il3945_hw_get_temperature(il)); +} + +static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); + +static ssize_t il3945_show_tx_power(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d\n", il->tx_power_user_lmt); +} + +static ssize_t il3945_store_tx_power(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + char *p = (char *)buf; + u32 val; + + val = simple_strtoul(p, &p, 10); + if (p == buf) + IL_INFO(": %s is not in decimal form.\n", buf); + else + il3945_hw_reg_set_txpower(il, val); + + return count; +} + +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); + +static ssize_t il3945_show_flags(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + + return sprintf(buf, "0x%04X\n", ctx->active.flags); +} + +static ssize_t il3945_store_flags(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + u32 flags = simple_strtoul(buf, NULL, 0); + struct il_rxon_context *ctx = &il->ctx; + + mutex_lock(&il->mutex); + if (le32_to_cpu(ctx->staging.flags) != flags) { + /* Cancel any currently running scans... */ + if (il_scan_cancel_timeout(il, 100)) + IL_WARN("Could not cancel scan.\n"); + else { + D_INFO("Committing rxon.flags = 0x%04X\n", + flags); + ctx->staging.flags = cpu_to_le32(flags); + il3945_commit_rxon(il, ctx); + } + } + mutex_unlock(&il->mutex); + + return count; +} + +static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); + +static ssize_t il3945_show_filter_flags(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + + return sprintf(buf, "0x%04X\n", + le32_to_cpu(ctx->active.filter_flags)); +} + +static ssize_t il3945_store_filter_flags(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + u32 filter_flags = simple_strtoul(buf, NULL, 0); + + mutex_lock(&il->mutex); + if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { + /* Cancel any currently running scans... */ + if (il_scan_cancel_timeout(il, 100)) + IL_WARN("Could not cancel scan.\n"); + else { + D_INFO("Committing rxon.filter_flags = " + "0x%04X\n", filter_flags); + ctx->staging.filter_flags = + cpu_to_le32(filter_flags); + il3945_commit_rxon(il, ctx); + } + } + mutex_unlock(&il->mutex); + + return count; +} + +static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, + il3945_store_filter_flags); + +static ssize_t il3945_show_measurement(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_spectrum_notification measure_report; + u32 size = sizeof(measure_report), len = 0, ofs = 0; + u8 *data = (u8 *)&measure_report; + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + if (!(il->measurement_status & MEASUREMENT_READY)) { + spin_unlock_irqrestore(&il->lock, flags); + return 0; + } + memcpy(&measure_report, &il->measure_report, size); + il->measurement_status = 0; + spin_unlock_irqrestore(&il->lock, flags); + + while (size && PAGE_SIZE - len) { + hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, + PAGE_SIZE - len, 1); + len = strlen(buf); + if (PAGE_SIZE - len) + buf[len++] = '\n'; + + ofs += 16; + size -= min(size, 16U); + } + + return len; +} + +static ssize_t il3945_store_measurement(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_measurement_params params = { + .channel = le16_to_cpu(ctx->active.channel), + .start_time = cpu_to_le64(il->_3945.last_tsf), + .duration = cpu_to_le16(1), + }; + u8 type = IL_MEASURE_BASIC; + u8 buffer[32]; + u8 channel; + + if (count) { + char *p = buffer; + strncpy(buffer, buf, min(sizeof(buffer), count)); + channel = simple_strtoul(p, NULL, 0); + if (channel) + params.channel = channel; + + p = buffer; + while (*p && *p != ' ') + p++; + if (*p) + type = simple_strtoul(p + 1, NULL, 0); + } + + D_INFO("Invoking measurement of type %d on " + "channel %d (for '%s')\n", type, params.channel, buf); + il3945_get_measurement(il, ¶ms, type); + + return count; +} + +static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, + il3945_show_measurement, il3945_store_measurement); + +static ssize_t il3945_store_retry_rate(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + + il->retry_rate = simple_strtoul(buf, NULL, 0); + if (il->retry_rate <= 0) + il->retry_rate = 1; + + return count; +} + +static ssize_t il3945_show_retry_rate(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d", il->retry_rate); +} + +static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, + il3945_store_retry_rate); + + +static ssize_t il3945_show_channels(struct device *d, + struct device_attribute *attr, char *buf) +{ + /* all this shit doesn't belong into sysfs anyway */ + return 0; +} + +static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); + +static ssize_t il3945_show_antenna(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_alive(il)) + return -EAGAIN; + + return sprintf(buf, "%d\n", il3945_mod_params.antenna); +} + +static ssize_t il3945_store_antenna(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il __maybe_unused = dev_get_drvdata(d); + int ant; + + if (count == 0) + return 0; + + if (sscanf(buf, "%1i", &ant) != 1) { + D_INFO("not in hex or decimal form.\n"); + return count; + } + + if (ant >= 0 && ant <= 2) { + D_INFO("Setting antenna select to %d.\n", ant); + il3945_mod_params.antenna = (enum il3945_antenna)ant; + } else + D_INFO("Bad antenna select value %d.\n", ant); + + + return count; +} + +static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); + +static ssize_t il3945_show_status(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + if (!il_is_alive(il)) + return -EAGAIN; + return sprintf(buf, "0x%08x\n", (int)il->status); +} + +static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); + +static ssize_t il3945_dump_error_log(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + char *p = (char *)buf; + + if (p[0] == '1') + il3945_dump_nic_error_log(il); + + return strnlen(buf, count); +} + +static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); + +/***************************************************************************** + * + * driver setup and tear down + * + *****************************************************************************/ + +static void il3945_setup_deferred_work(struct il_priv *il) +{ + il->workqueue = create_singlethread_workqueue(DRV_NAME); + + init_waitqueue_head(&il->wait_command_queue); + + INIT_WORK(&il->restart, il3945_bg_restart); + INIT_WORK(&il->rx_replenish, il3945_bg_rx_replenish); + INIT_DELAYED_WORK(&il->init_alive_start, il3945_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il3945_bg_alive_start); + INIT_DELAYED_WORK(&il->_3945.rfkill_poll, il3945_rfkill_poll); + + il_setup_scan_deferred_work(il); + + il3945_hw_setup_deferred_work(il); + + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; + + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il3945_irq_tasklet, (unsigned long)il); +} + +static void il3945_cancel_deferred_work(struct il_priv *il) +{ + il3945_hw_cancel_deferred_work(il); + + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); + + il_cancel_scan_deferred_work(il); +} + +static struct attribute *il3945_sysfs_entries[] = { + &dev_attr_antenna.attr, + &dev_attr_channels.attr, + &dev_attr_dump_errors.attr, + &dev_attr_flags.attr, + &dev_attr_filter_flags.attr, + &dev_attr_measurement.attr, + &dev_attr_retry_rate.attr, + &dev_attr_status.attr, + &dev_attr_temperature.attr, + &dev_attr_tx_power.attr, +#ifdef CONFIG_IWLEGACY_DEBUG + &dev_attr_debug_level.attr, +#endif + NULL +}; + +static struct attribute_group il3945_attribute_group = { + .name = NULL, /* put in device directory */ + .attrs = il3945_sysfs_entries, +}; + +struct ieee80211_ops il3945_hw_ops = { + .tx = il3945_mac_tx, + .start = il3945_mac_start, + .stop = il3945_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il3945_configure_filter, + .set_key = il3945_mac_set_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .hw_scan = il_mac_hw_scan, + .sta_add = il3945_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .tx_last_beacon = il_mac_tx_last_beacon, +}; + +static int il3945_init_drv(struct il_priv *il) +{ + int ret; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + + il->retry_rate = 1; + il->beacon_skb = NULL; + + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); + + INIT_LIST_HEAD(&il->free_frames); + + mutex_init(&il->mutex); + + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; + + il->iw_mode = NL80211_IFTYPE_STATION; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + + /* initialize force reset */ + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + + if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { + IL_WARN("Unsupported EEPROM version: 0x%04X\n", + eeprom->version); + ret = -EINVAL; + goto err; + } + ret = il_init_channel_map(il); + if (ret) { + IL_ERR("initializing regulatory failed: %d\n", ret); + goto err; + } + + /* Set up txpower settings in driver for all channels */ + if (il3945_txpower_set_from_eeprom(il)) { + ret = -EIO; + goto err_free_channel_map; + } + + ret = il_init_geos(il); + if (ret) { + IL_ERR("initializing geos failed: %d\n", ret); + goto err_free_channel_map; + } + il3945_init_hw_rates(il, il->ieee_rates); + + return 0; + +err_free_channel_map: + il_free_channel_map(il); +err: + return ret; +} + +#define IL3945_MAX_PROBE_REQUEST 200 + +static int il3945_setup_mac(struct il_priv *il) +{ + int ret; + struct ieee80211_hw *hw = il->hw; + + hw->rate_control_algorithm = "iwl-3945-rs"; + hw->sta_data_size = sizeof(struct il3945_sta_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); + + /* Tell mac80211 our characteristics */ + hw->flags = IEEE80211_HW_SIGNAL_DBM | + IEEE80211_HW_SPECTRUM_MGMT; + + hw->wiphy->interface_modes = + il->ctx.interface_modes; + + hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | + WIPHY_FLAG_DISABLE_BEACON_HINTS | + WIPHY_FLAG_IBSS_RSN; + + hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; + /* we create the 802.11 header and a zero-length SSID element */ + hw->wiphy->max_scan_ie_len = IL3945_MAX_PROBE_REQUEST - 24 - 2; + + /* Default value; 4 EDCA QOS priorities */ + hw->queues = 4; + + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; + + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; + + il_leds_init(il); + + ret = ieee80211_register_hw(il->hw); + if (ret) { + IL_ERR("Failed to register hw (error %d)\n", ret); + return ret; + } + il->mac80211_registered = 1; + + return 0; +} + +static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int err = 0; + struct il_priv *il; + struct ieee80211_hw *hw; + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); + struct il3945_eeprom *eeprom; + unsigned long flags; + + /*********************** + * 1. Allocating HW data + * ********************/ + + /* mac80211 allocates memory for this device instance, including + * space for this driver's ilate structure */ + hw = il_alloc_all(cfg); + if (hw == NULL) { + pr_err("Can not allocate network device\n"); + err = -ENOMEM; + goto out; + } + il = hw->priv; + SET_IEEE80211_DEV(hw, &pdev->dev); + + il->cmd_queue = IL39_CMD_QUEUE_NUM; + + il->ctx.ctxid = 0; + + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.interface_modes = + BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC); + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; + + /* + * Disabling hardware scan means that mac80211 will perform scans + * "the hard way", rather than using device's scan. + */ + if (il3945_mod_params.disable_hw_scan) { + D_INFO("Disabling hw_scan\n"); + il3945_hw_ops.hw_scan = NULL; + } + + D_INFO("*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; + + if (il_alloc_traffic_mem(il)) + IL_ERR("Not enough memory to generate traffic log\n"); + + /*************************** + * 2. Initializing PCI bus + * *************************/ + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); + + if (pci_enable_device(pdev)) { + err = -ENODEV; + goto out_ieee80211_free_hw; + } + + pci_set_master(pdev); + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (err) { + IL_WARN("No suitable DMA available.\n"); + goto out_pci_disable_device; + } + + pci_set_drvdata(pdev, il); + err = pci_request_regions(pdev, DRV_NAME); + if (err) + goto out_pci_disable_device; + + /*********************** + * 3. Read REV Register + * ********************/ + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { + err = -ENODEV; + goto out_pci_release_regions; + } + + D_INFO("pci_resource_len = 0x%08llx\n", + (unsigned long long) pci_resource_len(pdev, 0)); + D_INFO("pci_resource_base = %p\n", il->hw_base); + + /* We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state */ + pci_write_config_byte(pdev, 0x41, 0x00); + + /* these spin locks will be used in apm_ops.init and EEPROM access + * we should init now + */ + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); + + /* + * stop and reset the on-board processor just in case it is in a + * strange state ... like being left stranded by a primary kernel + * and this is now the kdump kernel trying to start up + */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + /*********************** + * 4. Read EEPROM + * ********************/ + + /* Read the EEPROM */ + err = il_eeprom_init(il); + if (err) { + IL_ERR("Unable to init EEPROM\n"); + goto out_iounmap; + } + /* MAC Address location in EEPROM same for 3945/4965 */ + eeprom = (struct il3945_eeprom *)il->eeprom; + D_INFO("MAC address: %pM\n", eeprom->mac_address); + SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); + + /*********************** + * 5. Setup HW Constants + * ********************/ + /* Device-specific setup */ + if (il3945_hw_set_hw_params(il)) { + IL_ERR("failed to set hw settings\n"); + goto out_eeprom_free; + } + + /*********************** + * 6. Setup il + * ********************/ + + err = il3945_init_drv(il); + if (err) { + IL_ERR("initializing driver failed\n"); + goto out_unset_hw_params; + } + + IL_INFO("Detected Intel Wireless WiFi Link %s\n", + il->cfg->name); + + /*********************** + * 7. Setup Services + * ********************/ + + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + pci_enable_msi(il->pci_dev); + + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); + if (err) { + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); + goto out_disable_msi; + } + + err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); + if (err) { + IL_ERR("failed to create sysfs device attributes\n"); + goto out_release_irq; + } + + il_set_rxon_channel(il, + &il->bands[IEEE80211_BAND_2GHZ].channels[5], + &il->ctx); + il3945_setup_deferred_work(il); + il3945_setup_rx_handlers(il); + il_power_initialize(il); + + /********************************* + * 8. Setup and Register mac80211 + * *******************************/ + + il_enable_interrupts(il); + + err = il3945_setup_mac(il); + if (err) + goto out_remove_sysfs; + + err = il_dbgfs_register(il, DRV_NAME); + if (err) + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); + + /* Start monitoring the killswitch */ + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, + 2 * HZ); + + return 0; + + out_remove_sysfs: + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); + out_release_irq: + free_irq(il->pci_dev->irq, il); + out_disable_msi: + pci_disable_msi(il->pci_dev); + il_free_geos(il); + il_free_channel_map(il); + out_unset_hw_params: + il3945_unset_hw_params(il); + out_eeprom_free: + il_eeprom_free(il); + out_iounmap: + pci_iounmap(pdev, il->hw_base); + out_pci_release_regions: + pci_release_regions(pdev); + out_pci_disable_device: + pci_set_drvdata(pdev, NULL); + pci_disable_device(pdev); + out_ieee80211_free_hw: + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); + out: + return err; +} + +static void __devexit il3945_pci_remove(struct pci_dev *pdev) +{ + struct il_priv *il = pci_get_drvdata(pdev); + unsigned long flags; + + if (!il) + return; + + D_INFO("*** UNLOAD DRIVER ***\n"); + + il_dbgfs_unregister(il); + + set_bit(STATUS_EXIT_PENDING, &il->status); + + il_leds_exit(il); + + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; + } else { + il3945_down(il); + } + + /* + * Make sure device is reset to low power before unloading driver. + * This may be redundant with il_down(), but there are paths to + * run il_down() without calling apm_ops.stop(), and there are + * paths to avoid running il_down() at all before leaving driver. + * This (inexpensive) call *makes sure* device is reset. + */ + il_apm_stop(il); + + /* make sure we flush any pending irq or + * tasklet for the driver + */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + il3945_synchronize_irq(il); + + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); + + cancel_delayed_work_sync(&il->_3945.rfkill_poll); + + il3945_dealloc_ucode_pci(il); + + if (il->rxq.bd) + il3945_rx_queue_free(il, &il->rxq); + il3945_hw_txq_ctx_free(il); + + il3945_unset_hw_params(il); + + /*netif_stop_queue(dev); */ + flush_workqueue(il->workqueue); + + /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes + * il->workqueue... so we can't take down the workqueue + * until now... */ + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); + + free_irq(pdev->irq, il); + pci_disable_msi(pdev); + + pci_iounmap(pdev, il->hw_base); + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + + il_free_channel_map(il); + il_free_geos(il); + kfree(il->scan_cmd); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + + ieee80211_free_hw(il->hw); +} + + +/***************************************************************************** + * + * driver and module entry point + * + *****************************************************************************/ + +static struct pci_driver il3945_driver = { + .name = DRV_NAME, + .id_table = il3945_hw_card_ids, + .probe = il3945_pci_probe, + .remove = __devexit_p(il3945_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, +}; + +static int __init il3945_init(void) +{ + + int ret; + pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); + pr_info(DRV_COPYRIGHT "\n"); + + ret = il3945_rate_control_register(); + if (ret) { + pr_err("Unable to register rate control algorithm: %d\n", ret); + return ret; + } + + ret = pci_register_driver(&il3945_driver); + if (ret) { + pr_err("Unable to initialize PCI module\n"); + goto error_register; + } + + return ret; + +error_register: + il3945_rate_control_unregister(); + return ret; +} + +static void __exit il3945_exit(void) +{ + pci_unregister_driver(&il3945_driver); + il3945_rate_control_unregister(); +} + +MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); + +module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); +MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); +module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); +MODULE_PARM_DESC(swcrypto, + "using software crypto (default 1 [software])"); +module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, + int, S_IRUGO); +MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); +#ifdef CONFIG_IWLEGACY_DEBUG +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(debug, "debug output mask"); +#endif +module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); +MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); + +module_exit(il3945_exit); +module_init(il3945_init); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c new file mode 100644 index 0000000..b6abf34 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -0,0 +1,2740 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iwl-fh.h" +#include "iwl-3945-fh.h" +#include "iwl-commands.h" +#include "iwl-sta.h" +#include "iwl-3945.h" +#include "iwl-eeprom.h" +#include "iwl-core.h" +#include "iwl-helpers.h" +#include "iwl-led.h" +#include "iwl-3945-led.h" +#include "iwl-3945-debugfs.h" + +#define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ + RATE_##r##M_IEEE, \ + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX, \ + RATE_##r##M_IDX_TBL, \ + RATE_##ip##M_IDX_TBL } + +/* + * Parameter order: + * rate, prev rate, next rate, prev tgg rate, next tgg rate + * + * If there isn't a valid next or previous rate then INV is used which + * maps to RATE_INVALID + * + */ +const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { + IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ +}; + +static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) +{ + u8 rate = il3945_rates[rate_idx].prev_ieee; + + if (rate == RATE_INVALID) + rate = rate_idx; + return rate; +} + +/* 1 = enable the il3945_disable_events() function */ +#define IL_EVT_DISABLE (0) +#define IL_EVT_DISABLE_SIZE (1532/32) + +/** + * il3945_disable_events - Disable selected events in uCode event log + * + * Disable an event by writing "1"s into "disable" + * bitmap in SRAM. Bit position corresponds to Event # (id/type). + * Default values of 0 enable uCode events to be logged. + * Use for only special debugging. This function is just a placeholder as-is, + * you'll need to provide the special bits! ... + * ... and set IL_EVT_DISABLE to 1. */ +void il3945_disable_events(struct il_priv *il) +{ + int i; + u32 base; /* SRAM address of event log header */ + u32 disable_ptr; /* SRAM address of event-disable bitmap array */ + u32 array_size; /* # of u32 entries in array */ + static const u32 evt_disable[IL_EVT_DISABLE_SIZE] = { + 0x00000000, /* 31 - 0 Event id numbers */ + 0x00000000, /* 63 - 32 */ + 0x00000000, /* 95 - 64 */ + 0x00000000, /* 127 - 96 */ + 0x00000000, /* 159 - 128 */ + 0x00000000, /* 191 - 160 */ + 0x00000000, /* 223 - 192 */ + 0x00000000, /* 255 - 224 */ + 0x00000000, /* 287 - 256 */ + 0x00000000, /* 319 - 288 */ + 0x00000000, /* 351 - 320 */ + 0x00000000, /* 383 - 352 */ + 0x00000000, /* 415 - 384 */ + 0x00000000, /* 447 - 416 */ + 0x00000000, /* 479 - 448 */ + 0x00000000, /* 511 - 480 */ + 0x00000000, /* 543 - 512 */ + 0x00000000, /* 575 - 544 */ + 0x00000000, /* 607 - 576 */ + 0x00000000, /* 639 - 608 */ + 0x00000000, /* 671 - 640 */ + 0x00000000, /* 703 - 672 */ + 0x00000000, /* 735 - 704 */ + 0x00000000, /* 767 - 736 */ + 0x00000000, /* 799 - 768 */ + 0x00000000, /* 831 - 800 */ + 0x00000000, /* 863 - 832 */ + 0x00000000, /* 895 - 864 */ + 0x00000000, /* 927 - 896 */ + 0x00000000, /* 959 - 928 */ + 0x00000000, /* 991 - 960 */ + 0x00000000, /* 1023 - 992 */ + 0x00000000, /* 1055 - 1024 */ + 0x00000000, /* 1087 - 1056 */ + 0x00000000, /* 1119 - 1088 */ + 0x00000000, /* 1151 - 1120 */ + 0x00000000, /* 1183 - 1152 */ + 0x00000000, /* 1215 - 1184 */ + 0x00000000, /* 1247 - 1216 */ + 0x00000000, /* 1279 - 1248 */ + 0x00000000, /* 1311 - 1280 */ + 0x00000000, /* 1343 - 1312 */ + 0x00000000, /* 1375 - 1344 */ + 0x00000000, /* 1407 - 1376 */ + 0x00000000, /* 1439 - 1408 */ + 0x00000000, /* 1471 - 1440 */ + 0x00000000, /* 1503 - 1472 */ + }; + + base = le32_to_cpu(il->card_alive.log_event_table_ptr); + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR("Invalid event log pointer 0x%08X\n", base); + return; + } + + disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); + array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); + + if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { + D_INFO("Disabling selected uCode log events at 0x%x\n", + disable_ptr); + for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) + il_write_targ_mem(il, + disable_ptr + (i * sizeof(u32)), + evt_disable[i]); + + } else { + D_INFO("Selected uCode log events may be disabled\n"); + D_INFO(" by writing \"1\"s into disable bitmap\n"); + D_INFO(" in SRAM at 0x%x, size %d u32s\n", + disable_ptr, array_size); + } + +} + +static int il3945_hwrate_to_plcp_idx(u8 plcp) +{ + int idx; + + for (idx = 0; idx < RATE_COUNT_3945; idx++) + if (il3945_rates[idx].plcp == plcp) + return idx; + return -1; +} + +#ifdef CONFIG_IWLEGACY_DEBUG +#define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x + +static const char *il3945_get_tx_fail_reason(u32 status) +{ + switch (status & TX_STATUS_MSK) { + case TX_3945_STATUS_SUCCESS: + return "SUCCESS"; + TX_STATUS_ENTRY(SHORT_LIMIT); + TX_STATUS_ENTRY(LONG_LIMIT); + TX_STATUS_ENTRY(FIFO_UNDERRUN); + TX_STATUS_ENTRY(MGMNT_ABORT); + TX_STATUS_ENTRY(NEXT_FRAG); + TX_STATUS_ENTRY(LIFE_EXPIRE); + TX_STATUS_ENTRY(DEST_PS); + TX_STATUS_ENTRY(ABORTED); + TX_STATUS_ENTRY(BT_RETRY); + TX_STATUS_ENTRY(STA_INVALID); + TX_STATUS_ENTRY(FRAG_DROPPED); + TX_STATUS_ENTRY(TID_DISABLE); + TX_STATUS_ENTRY(FRAME_FLUSHED); + TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL); + TX_STATUS_ENTRY(TX_LOCKED); + TX_STATUS_ENTRY(NO_BEACON_ON_RADAR); + } + + return "UNKNOWN"; +} +#else +static inline const char *il3945_get_tx_fail_reason(u32 status) +{ + return ""; +} +#endif + +/* + * get ieee prev rate from rate scale table. + * for A and B mode we need to overright prev + * value + */ +int il3945_rs_next_rate(struct il_priv *il, int rate) +{ + int next_rate = il3945_get_prev_ieee_rate(rate); + + switch (il->band) { + case IEEE80211_BAND_5GHZ: + if (rate == RATE_12M_IDX) + next_rate = RATE_9M_IDX; + else if (rate == RATE_6M_IDX) + next_rate = RATE_6M_IDX; + break; + case IEEE80211_BAND_2GHZ: + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il)) { + if (rate == RATE_11M_IDX) + next_rate = RATE_5M_IDX; + } + break; + + default: + break; + } + + return next_rate; +} + + +/** + * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd + * + * When FW advances 'R' idx, all entries between old and new 'R' idx + * need to be reclaimed. As result, some free space forms. If there is + * enough free space (> low mark), wake the stack that feeds us. + */ +static void il3945_tx_queue_reclaim(struct il_priv *il, + int txq_id, int idx) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; + + BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); + + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + + tx_info = &txq->txb[txq->q.read_ptr]; + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); + tx_info->skb = NULL; + il->cfg->ops->lib->txq_free_tfd(il, txq); + } + + if (il_queue_space(q) > q->low_mark && txq_id >= 0 && + txq_id != IL39_CMD_QUEUE_NUM && il->mac80211_registered) + il_wake_queue(il, txq); +} + +/** + * il3945_rx_reply_tx - Handle Tx response + */ +static void il3945_rx_reply_tx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int txq_id = SEQ_TO_QUEUE(sequence); + int idx = SEQ_TO_IDX(sequence); + struct il_tx_queue *txq = &il->txq[txq_id]; + struct ieee80211_tx_info *info; + struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + u32 status = le32_to_cpu(tx_resp->status); + int rate_idx; + int fail; + + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " + "is out of range [0-%d] %d %d\n", txq_id, + idx, txq->q.n_bd, txq->q.write_ptr, + txq->q.read_ptr); + return; + } + + txq->time_stamp = jiffies; + info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); + ieee80211_tx_info_clear_status(info); + + /* Fill the MRR chain with some info about on-chip retransmissions */ + rate_idx = il3945_hwrate_to_plcp_idx(tx_resp->rate); + if (info->band == IEEE80211_BAND_5GHZ) + rate_idx -= IL_FIRST_OFDM_RATE; + + fail = tx_resp->failure_frame; + + info->status.rates[0].idx = rate_idx; + info->status.rates[0].count = fail + 1; /* add final attempt */ + + /* tx_status->rts_retry_count = tx_resp->failure_rts; */ + info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? + IEEE80211_TX_STAT_ACK : 0; + + D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + txq_id, il3945_get_tx_fail_reason(status), status, + tx_resp->rate, tx_resp->failure_frame); + + D_TX_REPLY("Tx queue reclaim %d\n", idx); + il3945_tx_queue_reclaim(il, txq_id, idx); + + if (status & TX_ABORT_REQUIRED_MSK) + IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); +} + + + +/***************************************************************************** + * + * Intel PRO/Wireless 3945ABG/BG Network Connection + * + * RX handler implementations + * + *****************************************************************************/ +#ifdef CONFIG_IWLEGACY_DEBUGFS +static void il3945_accumulative_stats(struct il_priv *il, + __le32 *stats) +{ + int i; + __le32 *prev_stats; + u32 *accum_stats; + u32 *delta, *max_delta; + + prev_stats = (__le32 *)&il->_3945.stats; + accum_stats = (u32 *)&il->_3945.accum_stats; + delta = (u32 *)&il->_3945.delta_stats; + max_delta = (u32 *)&il->_3945.max_delta; + + for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); + i += sizeof(__le32), stats++, prev_stats++, delta++, + max_delta++, accum_stats++) { + if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { + *delta = (le32_to_cpu(*stats) - + le32_to_cpu(*prev_stats)); + *accum_stats += *delta; + if (*delta > *max_delta) + *max_delta = *delta; + } + } + + /* reset accumulative stats for "no-counter" type stats */ + il->_3945.accum_stats.general.temperature = + il->_3945.stats.general.temperature; + il->_3945.accum_stats.general.ttl_timestamp = + il->_3945.stats.general.ttl_timestamp; +} +#endif + +void il3945_hw_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + + D_RX("Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il3945_notif_stats), + le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); +#ifdef CONFIG_IWLEGACY_DEBUGFS + il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); +#endif + + memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); +} + +void il3945_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + __le32 *flag = (__le32 *)&pkt->u.raw; + + if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { +#ifdef CONFIG_IWLEGACY_DEBUGFS + memset(&il->_3945.accum_stats, 0, + sizeof(struct il3945_notif_stats)); + memset(&il->_3945.delta_stats, 0, + sizeof(struct il3945_notif_stats)); + memset(&il->_3945.max_delta, 0, + sizeof(struct il3945_notif_stats)); +#endif + D_RX("Statistics have been cleared\n"); + } + il3945_hw_rx_stats(il, rxb); +} + + +/****************************************************************************** + * + * Misc. internal state and helper functions + * + ******************************************************************************/ + +/* This is necessary only for a number of stats, see the caller. */ +static int il3945_is_network_packet(struct il_priv *il, + struct ieee80211_hdr *header) +{ + /* Filter incoming packets to determine if they are targeted toward + * this network, discarding packets coming from ourselves */ + switch (il->iw_mode) { + case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ + /* packets to our IBSS update information */ + return !compare_ether_addr(header->addr3, il->bssid); + case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ + /* packets to our IBSS update information */ + return !compare_ether_addr(header->addr2, il->bssid); + default: + return 1; + } +} + +static void il3945_pass_packet_to_mac80211(struct il_priv *il, + struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); + u16 len = le16_to_cpu(rx_hdr->len); + struct sk_buff *skb; + __le16 fc = hdr->frame_control; + + /* We received data from the HW, so stop the watchdog */ + if (unlikely(len + IL39_RX_FRAME_SIZE > + PAGE_SIZE << il->hw_params.rx_page_order)) { + D_DROP("Corruption detected!\n"); + return; + } + + /* We only process data packets if the interface is open */ + if (unlikely(!il->is_open)) { + D_DROP( + "Dropping packet while interface is not open.\n"); + return; + } + + skb = dev_alloc_skb(128); + if (!skb) { + IL_ERR("dev_alloc_skb failed\n"); + return; + } + + if (!il3945_mod_params.sw_crypto) + il_set_decrypted_flag(il, + (struct ieee80211_hdr *)rxb_addr(rxb), + le32_to_cpu(rx_end->status), stats); + + skb_add_rx_frag(skb, 0, rxb->page, + (void *)rx_hdr->payload - (void *)pkt, len); + + il_update_stats(il, false, fc, len); + memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); + + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; + rxb->page = NULL; +} + +#define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) + +static void il3945_rx_reply_rx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct ieee80211_hdr *header; + struct ieee80211_rx_status rx_status; + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); + u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); + u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); + u8 network_packet; + + rx_status.flag = 0; + rx_status.mactime = le64_to_cpu(rx_end->timestamp); + rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? + IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.freq = + ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), + rx_status.band); + + rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); + if (rx_status.band == IEEE80211_BAND_5GHZ) + rx_status.rate_idx -= IL_FIRST_OFDM_RATE; + + rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & + RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; + + /* set the preamble flag if appropriate */ + if (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) + rx_status.flag |= RX_FLAG_SHORTPRE; + + if ((unlikely(rx_stats->phy_count > 20))) { + D_DROP("dsp size out of range [0,20]: %d/n", + rx_stats->phy_count); + return; + } + + if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || + !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { + D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + return; + } + + + + /* Convert 3945's rssi indicator to dBm */ + rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; + + D_STATS("Rssi %d sig_avg %d noise_diff %d\n", + rx_status.signal, rx_stats_sig_avg, + rx_stats_noise_diff); + + header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); + + network_packet = il3945_is_network_packet(il, header); + + D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + network_packet ? '*' : ' ', + le16_to_cpu(rx_hdr->channel), + rx_status.signal, rx_status.signal, + rx_status.rate_idx); + + il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), + header); + + if (network_packet) { + il->_3945.last_beacon_time = + le32_to_cpu(rx_end->beacon_timestamp); + il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); + il->_3945.last_rx_rssi = rx_status.signal; + } + + il3945_pass_packet_to_mac80211(il, rxb, &rx_status); +} + +int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad) +{ + int count; + struct il_queue *q; + struct il3945_tfd *tfd, *tfd_tmp; + + q = &txq->q; + tfd_tmp = (struct il3945_tfd *)txq->tfds; + tfd = &tfd_tmp[q->write_ptr]; + + if (reset) + memset(tfd, 0, sizeof(*tfd)); + + count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); + + if (count >= NUM_TFD_CHUNKS || count < 0) { + IL_ERR("Error can not send more than %d chunks\n", + NUM_TFD_CHUNKS); + return -EINVAL; + } + + tfd->tbs[count].addr = cpu_to_le32(addr); + tfd->tbs[count].len = cpu_to_le32(len); + + count++; + + tfd->control_flags = cpu_to_le32(TFD_CTL_COUNT_SET(count) | + TFD_CTL_PAD_SET(pad)); + + return 0; +} + +/** + * il3945_hw_txq_free_tfd - Free one TFD, those at idx [txq->q.read_ptr] + * + * Does NOT advance any idxes + */ +void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +{ + struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; + int idx = txq->q.read_ptr; + struct il3945_tfd *tfd = &tfd_tmp[idx]; + struct pci_dev *dev = il->pci_dev; + int i; + int counter; + + /* sanity check */ + counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); + if (counter > NUM_TFD_CHUNKS) { + IL_ERR("Too many chunks: %i\n", counter); + /* @todo issue fatal error, it is quite serious situation */ + return; + } + + /* Unmap tx_cmd */ + if (counter) + pci_unmap_single(dev, + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_TODEVICE); + + /* unmap chunks if any */ + + for (i = 1; i < counter; i++) + pci_unmap_single(dev, le32_to_cpu(tfd->tbs[i].addr), + le32_to_cpu(tfd->tbs[i].len), PCI_DMA_TODEVICE); + + /* free SKB */ + if (txq->txb) { + struct sk_buff *skb; + + skb = txq->txb[txq->q.read_ptr].skb; + + /* can be called from irqs-disabled context */ + if (skb) { + dev_kfree_skb_any(skb); + txq->txb[txq->q.read_ptr].skb = NULL; + } + } +} + +/** + * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: + * +*/ +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, + struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, + int sta_id, int tx_id) +{ + u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; + u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); + u16 rate_mask; + int rate; + u8 rts_retry_limit; + u8 data_retry_limit; + __le32 tx_flags; + __le16 fc = hdr->frame_control; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + + rate = il3945_rates[rate_idx].plcp; + tx_flags = tx_cmd->tx_flags; + + /* We need to figure out how to get the sta->supp_rates while + * in this running context */ + rate_mask = RATES_MASK_3945; + + /* Set retry limit on DATA packets and Probe Responses*/ + if (ieee80211_is_probe_resp(fc)) + data_retry_limit = 3; + else + data_retry_limit = IL_DEFAULT_TX_RETRY; + tx_cmd->data_retry_limit = data_retry_limit; + + if (tx_id >= IL39_CMD_QUEUE_NUM) + rts_retry_limit = 3; + else + rts_retry_limit = 7; + + if (data_retry_limit < rts_retry_limit) + rts_retry_limit = data_retry_limit; + tx_cmd->rts_retry_limit = rts_retry_limit; + + tx_cmd->rate = rate; + tx_cmd->tx_flags = tx_flags; + + /* OFDM */ + tx_cmd->supp_rates[0] = + ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; + + /* CCK */ + tx_cmd->supp_rates[1] = (rate_mask & 0xF); + + D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + "cck/ofdm mask: 0x%x/0x%x\n", sta_id, + tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), + tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); +} + +static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) +{ + unsigned long flags_spin; + struct il_station_entry *station; + + if (sta_id == IL_INVALID_STATION) + return IL_INVALID_STATION; + + spin_lock_irqsave(&il->sta_lock, flags_spin); + station = &il->stations[sta_id]; + + station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; + station->sta.rate_n_flags = cpu_to_le16(tx_rate); + station->sta.mode = STA_CONTROL_MODIFY_MSK; + il_send_add_sta(il, &station->sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + D_RATE("SCALE sync station %d to rate %d\n", + sta_id, tx_rate); + return sta_id; +} + +static void il3945_set_pwr_vmain(struct il_priv *il) +{ +/* + * (for documentation purposes) + * to set power to V_AUX, do + + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) { + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VAUX, + ~APMG_PS_CTRL_MSK_PWR_SRC); + + _il_poll_bit(il, CSR_GPIO_IN, + CSR_GPIO_IN_VAL_VAUX_PWR_SRC, + CSR_GPIO_IN_BIT_AUX_POWER, 5000); + } + */ + + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); + + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ +} + +static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +{ + il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_wr(il, FH39_RCSR_RPTR_ADDR(0), + rxq->rb_stts_dma); + il_wr(il, FH39_RCSR_WPTR(0), 0); + il_wr(il, FH39_RCSR_CONFIG(0), + FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | + FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | + (RX_QUEUE_SIZE_LOG << FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) | + FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | + (1 << FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) | + FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); + + /* fake read to flush all prev I/O */ + il_rd(il, FH39_RSSR_CTRL); + + return 0; +} + +static int il3945_tx_reset(struct il_priv *il) +{ + + /* bypass mode */ + il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); + + /* RA 0 is active */ + il_wr_prph(il, ALM_SCD_ARASTAT_REG, 0x01); + + /* all 6 fifo are active */ + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0x3f); + + il_wr_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_wr_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); + il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); + + il_wr(il, FH39_TSSR_CBB_BASE, + il->_3945.shared_phys); + + il_wr(il, FH39_TSSR_MSG_CONFIG, + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); + + + return 0; +} + +/** + * il3945_txq_ctx_reset - Reset TX queue context + * + * Destroys all DMA structures and initialize them again + */ +static int il3945_txq_ctx_reset(struct il_priv *il) +{ + int rc; + int txq_id, slots_num; + + il3945_hw_txq_ctx_free(il); + + /* allocate tx queue structure */ + rc = il_alloc_txq_mem(il); + if (rc) + return rc; + + /* Tx CMD queue */ + rc = il3945_tx_reset(il); + if (rc) + goto error; + + /* Tx queue(s) */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + rc = il_tx_queue_init(il, &il->txq[txq_id], + slots_num, txq_id); + if (rc) { + IL_ERR("Tx %d queue init failed\n", txq_id); + goto error; + } + } + + return rc; + + error: + il3945_hw_txq_ctx_free(il); + return rc; +} + + +/* + * Start up 3945's basic functionality after it has been reset + * (e.g. after platform boot, or shutdown via il_apm_stop()) + * NOTE: This does not load uCode nor start the embedded processor + */ +static int il3945_apm_init(struct il_priv *il) +{ + int ret = il_apm_init(il); + + /* Clear APMG (NIC's internal power management) interrupts */ + il_wr_prph(il, APMG_RTC_INT_MSK_REG, 0x0); + il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + + /* Reset radio chip */ + il_set_bits_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_RESET_REQ); + udelay(5); + il_clear_bits_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_RESET_REQ); + + return ret; +} + +static void il3945_nic_config(struct il_priv *il) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + unsigned long flags; + u8 rev_id = il->pci_dev->revision; + + spin_lock_irqsave(&il->lock, flags); + + /* Determine HW type */ + D_INFO("HW Revision ID = 0x%X\n", rev_id); + + if (rev_id & PCI_CFG_REV_ID_BIT_RTP) + D_INFO("RTP type\n"); + else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { + D_INFO("3945 RADIO-MB type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); + } else { + D_INFO("3945 RADIO-MM type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); + } + + if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { + D_INFO("SKU OP mode is mrc\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); + } else + D_INFO("SKU OP mode is basic\n"); + + if ((eeprom->board_revision & 0xF0) == 0xD0) { + D_INFO("3945ABG revision is 0x%X\n", + eeprom->board_revision); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + } else { + D_INFO("3945ABG revision is 0x%X\n", + eeprom->board_revision); + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + } + + if (eeprom->almgor_m_version <= 1) { + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); + D_INFO("Card M type A version is 0x%X\n", + eeprom->almgor_m_version); + } else { + D_INFO("Card M type B version is 0x%X\n", + eeprom->almgor_m_version); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); + } + spin_unlock_irqrestore(&il->lock, flags); + + if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) + D_RF_KILL("SW RF KILL supported in EEPROM.\n"); + + if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) + D_RF_KILL("HW RF KILL supported in EEPROM.\n"); +} + +int il3945_hw_nic_init(struct il_priv *il) +{ + int rc; + unsigned long flags; + struct il_rx_queue *rxq = &il->rxq; + + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); + spin_unlock_irqrestore(&il->lock, flags); + + il3945_set_pwr_vmain(il); + + il->cfg->ops->lib->apm_ops.config(il); + + /* Allocate the RX queue, or reset if it is already allocated */ + if (!rxq->bd) { + rc = il_rx_queue_alloc(il); + if (rc) { + IL_ERR("Unable to initialize Rx queue\n"); + return -ENOMEM; + } + } else + il3945_rx_queue_reset(il, rxq); + + il3945_rx_replenish(il); + + il3945_rx_init(il, rxq); + + + /* Look at using this instead: + rxq->need_update = 1; + il_rx_queue_update_write_ptr(il, rxq); + */ + + il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); + + rc = il3945_txq_ctx_reset(il); + if (rc) + return rc; + + set_bit(STATUS_INIT, &il->status); + + return 0; +} + +/** + * il3945_hw_txq_ctx_free - Free TXQ Context + * + * Destroy all TX DMA queues and structures + */ +void il3945_hw_txq_ctx_free(struct il_priv *il) +{ + int txq_id; + + /* Tx queues */ + if (il->txq) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; + txq_id++) + if (txq_id == IL39_CMD_QUEUE_NUM) + il_cmd_queue_free(il); + else + il_tx_queue_free(il, txq_id); + + /* free tx queue structure */ + il_txq_mem(il); +} + +void il3945_hw_txq_ctx_stop(struct il_priv *il) +{ + int txq_id; + + /* stop SCD */ + il_wr_prph(il, ALM_SCD_MODE_REG, 0); + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0); + + /* reset TFD queues */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_bit(il, FH39_TSSR_TX_STATUS, + FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), + 1000); + } + + il3945_hw_txq_ctx_free(il); +} + +/** + * il3945_hw_reg_adjust_power_by_temp + * return idx delta into power gain settings table +*/ +static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) +{ + return (new_reading - old_reading) * (-11) / 100; +} + +/** + * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range + */ +static inline int il3945_hw_reg_temp_out_of_range(int temperature) +{ + return (temperature < -260 || temperature > 25) ? 1 : 0; +} + +int il3945_hw_get_temperature(struct il_priv *il) +{ + return _il_rd(il, CSR_UCODE_DRV_GP2); +} + +/** + * il3945_hw_reg_txpower_get_temperature + * get the current temperature by reading from NIC +*/ +static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + int temperature; + + temperature = il3945_hw_get_temperature(il); + + /* driver's okay range is -260 to +25. + * human readable okay range is 0 to +285 */ + D_INFO("Temperature: %d\n", temperature + IL_TEMP_CONVERT); + + /* handle insane temp reading */ + if (il3945_hw_reg_temp_out_of_range(temperature)) { + IL_ERR("Error bad temperature value %d\n", temperature); + + /* if really really hot(?), + * substitute the 3rd band/group's temp measured at factory */ + if (il->last_temperature > 100) + temperature = eeprom->groups[2].temperature; + else /* else use most recent "sane" value from driver */ + temperature = il->last_temperature; + } + + return temperature; /* raw, not "human readable" */ +} + +/* Adjust Txpower only if temperature variance is greater than threshold. + * + * Both are lower than older versions' 9 degrees */ +#define IL_TEMPERATURE_LIMIT_TIMER 6 + +/** + * il3945_is_temp_calib_needed - determines if new calibration is needed + * + * records new temperature in tx_mgr->temperature. + * replaces tx_mgr->last_temperature *only* if calib needed + * (assumes caller will actually do the calibration!). */ +static int il3945_is_temp_calib_needed(struct il_priv *il) +{ + int temp_diff; + + il->temperature = il3945_hw_reg_txpower_get_temperature(il); + temp_diff = il->temperature - il->last_temperature; + + /* get absolute value */ + if (temp_diff < 0) { + D_POWER("Getting cooler, delta %d,\n", temp_diff); + temp_diff = -temp_diff; + } else if (temp_diff == 0) + D_POWER("Same temp,\n"); + else + D_POWER("Getting warmer, delta %d,\n", temp_diff); + + /* if we don't need calibration, *don't* update last_temperature */ + if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { + D_POWER("Timed thermal calib not needed\n"); + return 0; + } + + D_POWER("Timed thermal calib needed\n"); + + /* assume that caller will actually do calib ... + * update the "last temperature" value */ + il->last_temperature = il->temperature; + return 1; +} + +#define IL_MAX_GAIN_ENTRIES 78 +#define IL_CCK_FROM_OFDM_POWER_DIFF -5 +#define IL_CCK_FROM_OFDM_IDX_DIFF (10) + +/* radio and DSP power table, each step is 1/2 dB. + * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ +static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { + { + {251, 127}, /* 2.4 GHz, highest power */ + {251, 127}, + {251, 127}, + {251, 127}, + {251, 125}, + {251, 110}, + {251, 105}, + {251, 98}, + {187, 125}, + {187, 115}, + {187, 108}, + {187, 99}, + {243, 119}, + {243, 111}, + {243, 105}, + {243, 97}, + {243, 92}, + {211, 106}, + {211, 100}, + {179, 120}, + {179, 113}, + {179, 107}, + {147, 125}, + {147, 119}, + {147, 112}, + {147, 106}, + {147, 101}, + {147, 97}, + {147, 91}, + {115, 107}, + {235, 121}, + {235, 115}, + {235, 109}, + {203, 127}, + {203, 121}, + {203, 115}, + {203, 108}, + {203, 102}, + {203, 96}, + {203, 92}, + {171, 110}, + {171, 104}, + {171, 98}, + {139, 116}, + {227, 125}, + {227, 119}, + {227, 113}, + {227, 107}, + {227, 101}, + {227, 96}, + {195, 113}, + {195, 106}, + {195, 102}, + {195, 95}, + {163, 113}, + {163, 106}, + {163, 102}, + {163, 95}, + {131, 113}, + {131, 106}, + {131, 102}, + {131, 95}, + {99, 113}, + {99, 106}, + {99, 102}, + {99, 95}, + {67, 113}, + {67, 106}, + {67, 102}, + {67, 95}, + {35, 113}, + {35, 106}, + {35, 102}, + {35, 95}, + {3, 113}, + {3, 106}, + {3, 102}, + {3, 95} }, /* 2.4 GHz, lowest power */ + { + {251, 127}, /* 5.x GHz, highest power */ + {251, 120}, + {251, 114}, + {219, 119}, + {219, 101}, + {187, 113}, + {187, 102}, + {155, 114}, + {155, 103}, + {123, 117}, + {123, 107}, + {123, 99}, + {123, 92}, + {91, 108}, + {59, 125}, + {59, 118}, + {59, 109}, + {59, 102}, + {59, 96}, + {59, 90}, + {27, 104}, + {27, 98}, + {27, 92}, + {115, 118}, + {115, 111}, + {115, 104}, + {83, 126}, + {83, 121}, + {83, 113}, + {83, 105}, + {83, 99}, + {51, 118}, + {51, 111}, + {51, 104}, + {51, 98}, + {19, 116}, + {19, 109}, + {19, 102}, + {19, 98}, + {19, 93}, + {171, 113}, + {171, 107}, + {171, 99}, + {139, 120}, + {139, 113}, + {139, 107}, + {139, 99}, + {107, 120}, + {107, 113}, + {107, 107}, + {107, 99}, + {75, 120}, + {75, 113}, + {75, 107}, + {75, 99}, + {43, 120}, + {43, 113}, + {43, 107}, + {43, 99}, + {11, 120}, + {11, 113}, + {11, 107}, + {11, 99}, + {131, 107}, + {131, 99}, + {99, 120}, + {99, 113}, + {99, 107}, + {99, 99}, + {67, 120}, + {67, 113}, + {67, 107}, + {67, 99}, + {35, 120}, + {35, 113}, + {35, 107}, + {35, 99}, + {3, 120} } /* 5.x GHz, lowest power */ +}; + +static inline u8 il3945_hw_reg_fix_power_idx(int idx) +{ + if (idx < 0) + return 0; + if (idx >= IL_MAX_GAIN_ENTRIES) + return IL_MAX_GAIN_ENTRIES - 1; + return (u8) idx; +} + +/* Kick off thermal recalibration check every 60 seconds */ +#define REG_RECALIB_PERIOD (60) + +/** + * il3945_hw_reg_set_scan_power - Set Tx power for scan probe requests + * + * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) + * or 6 Mbit (OFDM) rates. + */ +static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, + s32 rate_idx, const s8 *clip_pwrs, + struct il_channel_info *ch_info, + int band_idx) +{ + struct il3945_scan_power_info *scan_power_info; + s8 power; + u8 power_idx; + + scan_power_info = &ch_info->scan_pwr_info[scan_tbl_idx]; + + /* use this channel group's 6Mbit clipping/saturation pwr, + * but cap at regulatory scan power restriction (set during init + * based on eeprom channel data) for this channel. */ + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TBL]); + + power = min(power, il->tx_power_user_lmt); + scan_power_info->requested_power = power; + + /* find difference between new scan *power* and current "normal" + * Tx *power* for 6Mb. Use this difference (x2) to adjust the + * current "normal" temperature-compensated Tx power *idx* for + * this rate (1Mb or 6Mb) to yield new temp-compensated scan power + * *idx*. */ + power_idx = ch_info->power_info[rate_idx].power_table_idx + - (power - ch_info->power_info + [RATE_6M_IDX_TBL].requested_power) * 2; + + /* store reference idx that we use when adjusting *all* scan + * powers. So we can accommodate user (all channel) or spectrum + * management (single channel) power changes "between" temperature + * feedback compensation procedures. + * don't force fit this reference idx into gain table; it may be a + * negative number. This will help avoid errors when we're at + * the lower bounds (highest gains, for warmest temperatures) + * of the table. */ + + /* don't exceed table bounds for "real" setting */ + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + + scan_power_info->power_table_idx = power_idx; + scan_power_info->tpc.tx_gain = + power_gain_table[band_idx][power_idx].tx_gain; + scan_power_info->tpc.dsp_atten = + power_gain_table[band_idx][power_idx].dsp_atten; +} + +/** + * il3945_send_tx_power - fill in Tx Power command with gain settings + * + * Configures power settings for all rates for the current channel, + * using values from channel info struct, and send to NIC + */ +static int il3945_send_tx_power(struct il_priv *il) +{ + int rate_idx, i; + const struct il_channel_info *ch_info = NULL; + struct il3945_txpowertable_cmd txpower = { + .channel = il->ctx.active.channel, + }; + u16 chan; + + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) + return -EAGAIN; + + chan = le16_to_cpu(il->ctx.active.channel); + + txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; + ch_info = il_get_channel_info(il, il->band, chan); + if (!ch_info) { + IL_ERR( + "Failed to get channel info for channel %d [%d]\n", + chan, il->band); + return -EINVAL; + } + + if (!il_is_channel_valid(ch_info)) { + D_POWER("Not calling TX_PWR_TBL_CMD on " + "non-Tx channel.\n"); + return 0; + } + + /* fill cmd with power settings for all rates for current channel */ + /* Fill OFDM rate */ + for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; + rate_idx <= IL39_LAST_OFDM_RATE; rate_idx++, i++) { + + txpower.power[i].tpc = ch_info->power_info[i].tpc; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; + + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + le16_to_cpu(txpower.channel), + txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, + txpower.power[i].rate); + } + /* Fill CCK rates */ + for (rate_idx = IL_FIRST_CCK_RATE; + rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { + txpower.power[i].tpc = ch_info->power_info[i].tpc; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; + + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + le16_to_cpu(txpower.channel), + txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, + txpower.power[i].rate); + } + + return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, + sizeof(struct il3945_txpowertable_cmd), + &txpower); + +} + +/** + * il3945_hw_reg_set_new_power - Configures power tables at new levels + * @ch_info: Channel to update. Uses power_info.requested_power. + * + * Replace requested_power and base_power_idx ch_info fields for + * one channel. + * + * Called if user or spectrum management changes power preferences. + * Takes into account h/w and modulation limitations (clip power). + * + * This does *not* send anything to NIC, just sets up ch_info for one channel. + * + * NOTE: reg_compensate_for_temperature_dif() *must* be run after this to + * properly fill out the scan powers, and actual h/w gain settings, + * and send changes to NIC + */ +static int il3945_hw_reg_set_new_power(struct il_priv *il, + struct il_channel_info *ch_info) +{ + struct il3945_channel_power_info *power_info; + int power_changed = 0; + int i; + const s8 *clip_pwrs; + int power; + + /* Get this chnlgrp's rate-to-max/clip-powers table */ + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + + /* Get this channel's rate-to-current-power settings table */ + power_info = ch_info->power_info; + + /* update OFDM Txpower settings */ + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; + i++, ++power_info) { + int delta_idx; + + /* limit new power to be no more than h/w capability */ + power = min(ch_info->curr_txpow, clip_pwrs[i]); + if (power == power_info->requested_power) + continue; + + /* find difference between old and new requested powers, + * update base (non-temp-compensated) power idx */ + delta_idx = (power - power_info->requested_power) * 2; + power_info->base_power_idx -= delta_idx; + + /* save new requested power value */ + power_info->requested_power = power; + + power_changed = 1; + } + + /* update CCK Txpower settings, based on OFDM 12M setting ... + * ... all CCK power settings for a given channel are the *same*. */ + if (power_changed) { + power = + ch_info->power_info[RATE_12M_IDX_TBL]. + requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; + + /* do all CCK rates' il3945_channel_power_info structures */ + for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { + power_info->requested_power = power; + power_info->base_power_idx = + ch_info->power_info[RATE_12M_IDX_TBL]. + base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; + ++power_info; + } + } + + return 0; +} + +/** + * il3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel + * + * NOTE: Returned power limit may be less (but not more) than requested, + * based strictly on regulatory (eeprom and spectrum mgt) limitations + * (no consideration for h/w clipping limitations). + */ +static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) +{ + s8 max_power; + +#if 0 + /* if we're using TGd limits, use lower of TGd or EEPROM */ + if (ch_info->tgd_data.max_power != 0) + max_power = min(ch_info->tgd_data.max_power, + ch_info->eeprom.max_power_avg); + + /* else just use EEPROM limits */ + else +#endif + max_power = ch_info->eeprom.max_power_avg; + + return min(max_power, ch_info->max_power_avg); +} + +/** + * il3945_hw_reg_comp_txpower_temp - Compensate for temperature + * + * Compensate txpower settings of *all* channels for temperature. + * This only accounts for the difference between current temperature + * and the factory calibration temperatures, and bases the new settings + * on the channel's base_power_idx. + * + * If RxOn is "associated", this sends the new Txpower to NIC! + */ +static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) +{ + struct il_channel_info *ch_info = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + int delta_idx; + const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ + u8 a_band; + u8 rate_idx; + u8 scan_tbl_idx; + u8 i; + int ref_temp; + int temperature = il->temperature; + + if (il->disable_tx_power_cal || + test_bit(STATUS_SCANNING, &il->status)) { + /* do not perform tx power calibration */ + return 0; + } + /* set up new Tx power info for each and every channel, 2.4 and 5.x */ + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; + a_band = il_is_channel_a_band(ch_info); + + /* Get this chnlgrp's factory calibration temperature */ + ref_temp = (s16)eeprom->groups[ch_info->group_idx]. + temperature; + + /* get power idx adjustment based on current and factory + * temps */ + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, + ref_temp); + + /* set tx power value for all rates, OFDM and CCK */ + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; + rate_idx++) { + int power_idx = + ch_info->power_info[rate_idx].base_power_idx; + + /* temperature compensate */ + power_idx += delta_idx; + + /* stay within table range */ + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + ch_info->power_info[rate_idx]. + power_table_idx = (u8) power_idx; + ch_info->power_info[rate_idx].tpc = + power_gain_table[a_band][power_idx]; + } + + /* Get this chnlgrp's rate-to-max/clip-powers table */ + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + + /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, + ch_info, a_band); + } + } + + /* send Txpower command for current channel to ucode */ + return il->cfg->ops->lib->send_tx_power(il); +} + +int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) +{ + struct il_channel_info *ch_info; + s8 max_power; + u8 a_band; + u8 i; + + if (il->tx_power_user_lmt == power) { + D_POWER("Requested Tx power same as current " + "limit: %ddBm.\n", power); + return 0; + } + + D_POWER("Setting upper limit clamp to %ddBm.\n", power); + il->tx_power_user_lmt = power; + + /* set up new Tx powers for each and every channel, 2.4 and 5.x */ + + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; + a_band = il_is_channel_a_band(ch_info); + + /* find minimum power of all user and regulatory constraints + * (does not consider h/w clipping limitations) */ + max_power = il3945_hw_reg_get_ch_txpower_limit(ch_info); + max_power = min(power, max_power); + if (max_power != ch_info->curr_txpow) { + ch_info->curr_txpow = max_power; + + /* this considers the h/w clipping limitations */ + il3945_hw_reg_set_new_power(il, ch_info); + } + } + + /* update txpower settings for all channels, + * send to NIC if associated. */ + il3945_is_temp_calib_needed(il); + il3945_hw_reg_comp_txpower_temp(il); + + return 0; +} + +static int il3945_send_rxon_assoc(struct il_priv *il, + struct il_rxon_context *ctx) +{ + int rc = 0; + struct il_rx_pkt *pkt; + struct il3945_rxon_assoc_cmd rxon_assoc; + struct il_host_cmd cmd = { + .id = REPLY_RXON_ASSOC, + .len = sizeof(rxon_assoc), + .flags = CMD_WANT_SKB, + .data = &rxon_assoc, + }; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; + + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { + D_INFO("Using current RXON_ASSOC. Not resending.\n"); + return 0; + } + + rxon_assoc.flags = ctx->staging.flags; + rxon_assoc.filter_flags = ctx->staging.filter_flags; + rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; + rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; + rxon_assoc.reserved = 0; + + rc = il_send_cmd_sync(il, &cmd); + if (rc) + return rc; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); + rc = -EIO; + } + + il_free_pages(il, cmd.reply_page); + + return rc; +} + +/** + * il3945_commit_rxon - commit staging_rxon to hardware + * + * The RXON command in staging_rxon is committed to the hardware and + * the active_rxon structure is updated with the new data. This + * function correctly transitions out of the RXON_ASSOC_MSK state if + * a HW tune is required based on the RXON structure changes. + */ +int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +{ + /* cast away the const for active_rxon in this function */ + struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; + struct il3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; + int rc = 0; + bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return -EINVAL; + + if (!il_is_alive(il)) + return -1; + + /* always get timestamp with Rx frame */ + staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK; + + /* select antenna */ + staging_rxon->flags &= + ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); + staging_rxon->flags |= il3945_get_antenna_flags(il); + + rc = il_check_rxon_cmd(il, ctx); + if (rc) { + IL_ERR("Invalid RXON configuration. Not committing.\n"); + return -EINVAL; + } + + /* If we don't need to send a full RXON, we can use + * il3945_rxon_assoc_cmd which is used to reconfigure filter + * and other flags for the current radio configuration. */ + if (!il_full_rxon_required(il, + &il->ctx)) { + rc = il_send_rxon_assoc(il, + &il->ctx); + if (rc) { + IL_ERR("Error setting RXON_ASSOC " + "configuration (%d).\n", rc); + return rc; + } + + memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); + /* + * We do not commit tx power settings while channel changing, + * do it now if tx power changed. + */ + il_set_tx_power(il, il->tx_power_next, false); + return 0; + } + + /* If we are currently associated and the new config requires + * an RXON_ASSOC and the new config wants the associated mask enabled, + * we must clear the associated from the active configuration + * before we apply the new config */ + if (il_is_associated(il) && new_assoc) { + D_INFO("Toggling associated bit on current RXON\n"); + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + + /* + * reserved4 and 5 could have been filled by the iwlcore code. + * Let's clear them before pushing to the 3945. + */ + active_rxon->reserved4 = 0; + active_rxon->reserved5 = 0; + rc = il_send_cmd_pdu(il, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), + &il->ctx.active); + + /* If the mask clearing failed then we set + * active_rxon back to what it was previously */ + if (rc) { + active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; + IL_ERR("Error clearing ASSOC_MSK on current " + "configuration (%d).\n", rc); + return rc; + } + il_clear_ucode_stations(il, + &il->ctx); + il_restore_stations(il, + &il->ctx); + } + + D_INFO("Sending RXON\n" + "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" + "* bssid = %pM\n", + (new_assoc ? "" : "out"), + le16_to_cpu(staging_rxon->channel), + staging_rxon->bssid_addr); + + /* + * reserved4 and 5 could have been filled by the iwlcore code. + * Let's clear them before pushing to the 3945. + */ + staging_rxon->reserved4 = 0; + staging_rxon->reserved5 = 0; + + il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); + + /* Apply the new configuration */ + rc = il_send_cmd_pdu(il, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), + staging_rxon); + if (rc) { + IL_ERR("Error setting new configuration (%d).\n", rc); + return rc; + } + + memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); + + if (!new_assoc) { + il_clear_ucode_stations(il, + &il->ctx); + il_restore_stations(il, + &il->ctx); + } + + /* If we issue a new RXON command which required a tune then we must + * send a new TXPOWER command or we won't be able to Tx any frames */ + rc = il_set_tx_power(il, il->tx_power_next, true); + if (rc) { + IL_ERR("Error setting Tx power (%d).\n", rc); + return rc; + } + + /* Init the hardware's rate fallback order based on the band */ + rc = il3945_init_hw_rate_table(il); + if (rc) { + IL_ERR("Error setting HW rate table: %02X\n", rc); + return -EIO; + } + + return 0; +} + +/** + * il3945_reg_txpower_periodic - called when time to check our temperature. + * + * -- reset periodic timer + * -- see if temp has changed enough to warrant re-calibration ... if so: + * -- correct coeffs for temp (can reset temp timer) + * -- save this temp as "last", + * -- send new set of gain settings to NIC + * NOTE: This should continue working, even when we're not associated, + * so we can keep our internal table of scan powers current. */ +void il3945_reg_txpower_periodic(struct il_priv *il) +{ + /* This will kick in the "brute force" + * il3945_hw_reg_comp_txpower_temp() below */ + if (!il3945_is_temp_calib_needed(il)) + goto reschedule; + + /* Set up a new set of temp-adjusted TxPowers, send to NIC. + * This is based *only* on current temperature, + * ignoring any previous power measurements */ + il3945_hw_reg_comp_txpower_temp(il); + + reschedule: + queue_delayed_work(il->workqueue, + &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); +} + +static void il3945_bg_reg_txpower_periodic(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, + _3945.thermal_periodic.work); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + mutex_lock(&il->mutex); + il3945_reg_txpower_periodic(il); + mutex_unlock(&il->mutex); +} + +/** + * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) + * for the channel. + * + * This function is used when initializing channel-info structs. + * + * NOTE: These channel groups do *NOT* match the bands above! + * These channel groups are based on factory-tested channels; + * on A-band, EEPROM's "group frequency" entries represent the top + * channel in each group 1-4. Group 5 All B/G channels are in group 0. + */ +static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, + const struct il_channel_info *ch_info) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; + u8 group; + u16 group_idx = 0; /* based on factory calib frequencies */ + u8 grp_channel; + + /* Find the group idx for the channel ... don't use idx 1(?) */ + if (il_is_channel_a_band(ch_info)) { + for (group = 1; group < 5; group++) { + grp_channel = ch_grp[group].group_channel; + if (ch_info->channel <= grp_channel) { + group_idx = group; + break; + } + } + /* group 4 has a few channels *above* its factory cal freq */ + if (group == 5) + group_idx = 4; + } else + group_idx = 0; /* 2.4 GHz, group 0 */ + + D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, + group_idx); + return group_idx; +} + +/** + * il3945_hw_reg_get_matched_power_idx - Interpolate to get nominal idx + * + * Interpolate to get nominal (i.e. at factory calibration temperature) idx + * into radio/DSP gain settings table for requested power. + */ +static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, + s8 requested_power, + s32 setting_idx, s32 *new_idx) +{ + const struct il3945_eeprom_txpower_group *chnl_grp = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + s32 idx0, idx1; + s32 power = 2 * requested_power; + s32 i; + const struct il3945_eeprom_txpower_sample *samples; + s32 gains0, gains1; + s32 res; + s32 denominator; + + chnl_grp = &eeprom->groups[setting_idx]; + samples = chnl_grp->samples; + for (i = 0; i < 5; i++) { + if (power == samples[i].power) { + *new_idx = samples[i].gain_idx; + return 0; + } + } + + if (power > samples[1].power) { + idx0 = 0; + idx1 = 1; + } else if (power > samples[2].power) { + idx0 = 1; + idx1 = 2; + } else if (power > samples[3].power) { + idx0 = 2; + idx1 = 3; + } else { + idx0 = 3; + idx1 = 4; + } + + denominator = (s32) samples[idx1].power - (s32) samples[idx0].power; + if (denominator == 0) + return -EINVAL; + gains0 = (s32) samples[idx0].gain_idx * (1 << 19); + gains1 = (s32) samples[idx1].gain_idx * (1 << 19); + res = gains0 + (gains1 - gains0) * + ((s32) power - (s32) samples[idx0].power) / denominator + + (1 << 18); + *new_idx = res >> 19; + return 0; +} + +static void il3945_hw_reg_init_channel_groups(struct il_priv *il) +{ + u32 i; + s32 rate_idx; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + const struct il3945_eeprom_txpower_group *group; + + D_POWER("Initializing factory calib info from EEPROM\n"); + + for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { + s8 *clip_pwrs; /* table of power levels for each rate */ + s8 satur_pwr; /* saturation power for each chnl group */ + group = &eeprom->groups[i]; + + /* sanity check on factory saturation power value */ + if (group->saturation_power < 40) { + IL_WARN("Error: saturation power is %d, " + "less than minimum expected 40\n", + group->saturation_power); + return; + } + + /* + * Derive requested power levels for each rate, based on + * hardware capabilities (saturation power for band). + * Basic value is 3dB down from saturation, with further + * power reductions for highest 3 data rates. These + * backoffs provide headroom for high rate modulation + * power peaks, without too much distortion (clipping). + */ + /* we'll fill in this array with h/w max power levels */ + clip_pwrs = (s8 *) il->_3945.clip_groups[i].clip_powers; + + /* divide factory saturation power by 2 to find -3dB level */ + satur_pwr = (s8) (group->saturation_power >> 1); + + /* fill in channel group's nominal powers for each rate */ + for (rate_idx = 0; + rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { + switch (rate_idx) { + case RATE_36M_IDX_TBL: + if (i == 0) /* B/G */ + *clip_pwrs = satur_pwr; + else /* A */ + *clip_pwrs = satur_pwr - 5; + break; + case RATE_48M_IDX_TBL: + if (i == 0) + *clip_pwrs = satur_pwr - 7; + else + *clip_pwrs = satur_pwr - 10; + break; + case RATE_54M_IDX_TBL: + if (i == 0) + *clip_pwrs = satur_pwr - 9; + else + *clip_pwrs = satur_pwr - 12; + break; + default: + *clip_pwrs = satur_pwr; + break; + } + } + } +} + +/** + * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM + * + * Second pass (during init) to set up il->channel_info + * + * Set up Tx-power settings in our channel info database for each VALID + * (for this geo/SKU) channel, at all Tx data rates, based on eeprom values + * and current temperature. + * + * Since this is based on current temperature (at init time), these values may + * not be valid for very long, but it gives us a starting/default point, + * and allows us to active (i.e. using Tx) scan. + * + * This does *not* write values to NIC, just sets up our internal table. + */ +int il3945_txpower_set_from_eeprom(struct il_priv *il) +{ + struct il_channel_info *ch_info = NULL; + struct il3945_channel_power_info *pwr_info; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + int delta_idx; + u8 rate_idx; + u8 scan_tbl_idx; + const s8 *clip_pwrs; /* array of power levels for each rate */ + u8 gain, dsp_atten; + s8 power; + u8 pwr_idx, base_pwr_idx, a_band; + u8 i; + int temperature; + + /* save temperature reference, + * so we can determine next time to calibrate */ + temperature = il3945_hw_reg_txpower_get_temperature(il); + il->last_temperature = temperature; + + il3945_hw_reg_init_channel_groups(il); + + /* initialize Tx power info for each and every channel, 2.4 and 5.x */ + for (i = 0, ch_info = il->channel_info; i < il->channel_count; + i++, ch_info++) { + a_band = il_is_channel_a_band(ch_info); + if (!il_is_channel_valid(ch_info)) + continue; + + /* find this channel's channel group (*not* "band") idx */ + ch_info->group_idx = + il3945_hw_reg_get_ch_grp_idx(il, ch_info); + + /* Get this chnlgrp's rate->max/clip-powers table */ + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + + /* calculate power idx *adjustment* value according to + * diff between current temperature and factory temperature */ + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, + eeprom->groups[ch_info->group_idx]. + temperature); + + D_POWER("Delta idx for channel %d: %d [%d]\n", + ch_info->channel, delta_idx, temperature + + IL_TEMP_CONVERT); + + /* set tx power value for all OFDM rates */ + for (rate_idx = 0; rate_idx < IL_OFDM_RATES; + rate_idx++) { + s32 uninitialized_var(power_idx); + int rc; + + /* use channel group's clip-power table, + * but don't exceed channel's max power */ + s8 pwr = min(ch_info->max_power_avg, + clip_pwrs[rate_idx]); + + pwr_info = &ch_info->power_info[rate_idx]; + + /* get base (i.e. at factory-measured temperature) + * power table idx for this rate's power */ + rc = il3945_hw_reg_get_matched_power_idx(il, pwr, + ch_info->group_idx, + &power_idx); + if (rc) { + IL_ERR("Invalid power idx\n"); + return rc; + } + pwr_info->base_power_idx = (u8) power_idx; + + /* temperature compensate */ + power_idx += delta_idx; + + /* stay within range of gain table */ + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + + /* fill 1 OFDM rate's il3945_channel_power_info struct */ + pwr_info->requested_power = pwr; + pwr_info->power_table_idx = (u8) power_idx; + pwr_info->tpc.tx_gain = + power_gain_table[a_band][power_idx].tx_gain; + pwr_info->tpc.dsp_atten = + power_gain_table[a_band][power_idx].dsp_atten; + } + + /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ + pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; + power = pwr_info->requested_power + + IL_CCK_FROM_OFDM_POWER_DIFF; + pwr_idx = pwr_info->power_table_idx + + IL_CCK_FROM_OFDM_IDX_DIFF; + base_pwr_idx = pwr_info->base_power_idx + + IL_CCK_FROM_OFDM_IDX_DIFF; + + /* stay within table range */ + pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); + gain = power_gain_table[a_band][pwr_idx].tx_gain; + dsp_atten = power_gain_table[a_band][pwr_idx].dsp_atten; + + /* fill each CCK rate's il3945_channel_power_info structure + * NOTE: All CCK-rate Txpwrs are the same for a given chnl! + * NOTE: CCK rates start at end of OFDM rates! */ + for (rate_idx = 0; + rate_idx < IL_CCK_RATES; rate_idx++) { + pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; + pwr_info->requested_power = power; + pwr_info->power_table_idx = pwr_idx; + pwr_info->base_power_idx = base_pwr_idx; + pwr_info->tpc.tx_gain = gain; + pwr_info->tpc.dsp_atten = dsp_atten; + } + + /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, ch_info, a_band); + } + } + + return 0; +} + +int il3945_hw_rxq_stop(struct il_priv *il) +{ + int rc; + + il_wr(il, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_bit(il, FH39_RSSR_STATUS, + FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + if (rc < 0) + IL_ERR("Can't stop Rx DMA.\n"); + + return 0; +} + +int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) +{ + int txq_id = txq->q.id; + + struct il3945_shared *shared_data = il->_3945.shared_virt; + + shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); + + il_wr(il, FH39_CBCC_CTRL(txq_id), 0); + il_wr(il, FH39_CBCC_BASE(txq_id), 0); + + il_wr(il, FH39_TCSR_CONFIG(txq_id), + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | + FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); + + /* fake read to flush all prev. writes */ + _il_rd(il, FH39_TSSR_CBB_BASE); + + return 0; +} + +/* + * HCMD utils + */ +static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) +{ + switch (cmd_id) { + case REPLY_RXON: + return sizeof(struct il3945_rxon_cmd); + case POWER_TBL_CMD: + return sizeof(struct il3945_powertable_cmd); + default: + return len; + } +} + + +static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, + u8 *data) +{ + struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; + addsta->mode = cmd->mode; + memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); + addsta->station_flags = cmd->station_flags; + addsta->station_flags_msk = cmd->station_flags_msk; + addsta->tid_disable_tx = cpu_to_le16(0); + addsta->rate_n_flags = cmd->rate_n_flags; + addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; + addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; + addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; + + return (u16)sizeof(struct il3945_addsta_cmd); +} + +static int il3945_add_bssid_station(struct il_priv *il, + const u8 *addr, u8 *sta_id_r) +{ + struct il_rxon_context *ctx = &il->ctx; + int ret; + u8 sta_id; + unsigned long flags; + + if (sta_id_r) + *sta_id_r = IL_INVALID_STATION; + + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM\n", addr); + return ret; + } + + if (sta_id_r) + *sta_id_r = sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} +static int il3945_manage_ibss_station(struct il_priv *il, + struct ieee80211_vif *vif, bool add) +{ + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + int ret; + + if (add) { + ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, + &vif_priv->ibss_bssid_sta_id); + if (ret) + return ret; + + il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, + (il->band == IEEE80211_BAND_5GHZ) ? + RATE_6M_PLCP : RATE_1M_PLCP); + il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); + + return 0; + } + + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, + vif->bss_conf.bssid); +} + +/** + * il3945_init_hw_rate_table - Initialize the hardware rate fallback table + */ +int il3945_init_hw_rate_table(struct il_priv *il) +{ + int rc, i, idx, prev_idx; + struct il3945_rate_scaling_cmd rate_cmd = { + .reserved = {0, 0, 0}, + }; + struct il3945_rate_scaling_info *table = rate_cmd.table; + + for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { + idx = il3945_rates[i].table_rs_idx; + + table[idx].rate_n_flags = + il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); + table[idx].try_cnt = il->retry_rate; + prev_idx = il3945_get_prev_ieee_rate(i); + table[idx].next_rate_idx = + il3945_rates[prev_idx].table_rs_idx; + } + + switch (il->band) { + case IEEE80211_BAND_5GHZ: + D_RATE("Select A mode rate scale\n"); + /* If one of the following CCK rates is used, + * have it fall back to the 6M OFDM rate */ + for (i = RATE_1M_IDX_TBL; + i <= RATE_11M_IDX_TBL; i++) + table[i].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; + + /* Don't fall back to CCK rates */ + table[RATE_12M_IDX_TBL].next_rate_idx = + RATE_9M_IDX_TBL; + + /* Don't drop out of OFDM rates */ + table[RATE_6M_IDX_TBL].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; + break; + + case IEEE80211_BAND_2GHZ: + D_RATE("Select B/G mode rate scale\n"); + /* If an OFDM rate is used, have it fall back to the + * 1M CCK rates */ + + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il)) { + + idx = IL_FIRST_CCK_RATE; + for (i = RATE_6M_IDX_TBL; + i <= RATE_54M_IDX_TBL; i++) + table[i].next_rate_idx = + il3945_rates[idx].table_rs_idx; + + idx = RATE_11M_IDX_TBL; + /* CCK shouldn't fall back to OFDM... */ + table[idx].next_rate_idx = RATE_5M_IDX_TBL; + } + break; + + default: + WARN_ON(1); + break; + } + + /* Update the rate scaling for control frame Tx */ + rate_cmd.table_id = 0; + rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + &rate_cmd); + if (rc) + return rc; + + /* Update the rate scaling for data frame Tx */ + rate_cmd.table_id = 1; + return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + &rate_cmd); +} + +/* Called when initializing driver */ +int il3945_hw_set_hw_params(struct il_priv *il) +{ + memset((void *)&il->hw_params, 0, + sizeof(struct il_hw_params)); + + il->_3945.shared_virt = + dma_alloc_coherent(&il->pci_dev->dev, + sizeof(struct il3945_shared), + &il->_3945.shared_phys, GFP_KERNEL); + if (!il->_3945.shared_virt) { + IL_ERR("failed to allocate pci memory\n"); + return -ENOMEM; + } + + /* Assign number of Usable TX queues */ + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; + + il->hw_params.tfd_size = sizeof(struct il3945_tfd); + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + il->hw_params.max_stations = IL3945_STATION_COUNT; + il->ctx.bcast_sta_id = IL3945_BROADCAST_ID; + + il->sta_key_max_num = STA_KEY_MAX_NUM; + + il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; + il->hw_params.max_beacon_itrvl = IL39_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.beacon_time_tsf_bits = IL3945_EXT_BEACON_TIME_POS; + + return 0; +} + +unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, + struct il3945_frame *frame, u8 rate) +{ + struct il3945_tx_beacon_cmd *tx_beacon_cmd; + unsigned int frame_size; + + tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; + memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); + + tx_beacon_cmd->tx.sta_id = + il->ctx.bcast_sta_id; + tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + + frame_size = il3945_fill_beacon_frame(il, + tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + + BUG_ON(frame_size > MAX_MPDU_SIZE); + tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + + tx_beacon_cmd->tx.rate = rate; + tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | + TX_CMD_FLG_TSF_MSK); + + /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ + tx_beacon_cmd->tx.supp_rates[0] = + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + + tx_beacon_cmd->tx.supp_rates[1] = + (IL_CCK_BASIC_RATES_MASK & 0xF); + + return sizeof(struct il3945_tx_beacon_cmd) + frame_size; +} + +void il3945_hw_rx_handler_setup(struct il_priv *il) +{ + il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; + il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; +} + +void il3945_hw_setup_deferred_work(struct il_priv *il) +{ + INIT_DELAYED_WORK(&il->_3945.thermal_periodic, + il3945_bg_reg_txpower_periodic); +} + +void il3945_hw_cancel_deferred_work(struct il_priv *il) +{ + cancel_delayed_work(&il->_3945.thermal_periodic); +} + +/* check contents of special bootstrap uCode SRAM */ +static int il3945_verify_bsm(struct il_priv *il) + { + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + u32 reg; + u32 val; + + D_INFO("Begin verify bsm\n"); + + /* verify BSM SRAM contents */ + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); + for (reg = BSM_SRAM_LOWER_BOUND; + reg < BSM_SRAM_LOWER_BOUND + len; + reg += sizeof(u32), image++) { + val = il_rd_prph(il, reg); + if (val != le32_to_cpu(*image)) { + IL_ERR("BSM uCode verification failed at " + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, + reg - BSM_SRAM_LOWER_BOUND, len, + val, le32_to_cpu(*image)); + return -EIO; + } + } + + D_INFO("BSM bootstrap uCode image OK\n"); + + return 0; +} + + +/****************************************************************************** + * + * EEPROM related functions + * + ******************************************************************************/ + +/* + * Clear the OWNER_MSK, to establish driver (instead of uCode running on + * embedded controller) as EEPROM reader; each read is a series of pulses + * to/from the EEPROM chip, not a single event, so even reads could conflict + * if they weren't arbitrated by some ownership mechanism. Here, the driver + * simply claims ownership, which should be safe when this function is called + * (i.e. before loading uCode!). + */ +static int il3945_eeprom_acquire_semaphore(struct il_priv *il) +{ + _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); + return 0; +} + + +static void il3945_eeprom_release_semaphore(struct il_priv *il) +{ + return; +} + + /** + * il3945_load_bsm - Load bootstrap instructions + * + * BSM operation: + * + * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program + * in special SRAM that does not power down during RFKILL. When powering back + * up after power-saving sleeps (or during initial uCode load), the BSM loads + * the bootstrap program into the on-board processor, and starts it. + * + * The bootstrap program loads (via DMA) instructions and data for a new + * program from host DRAM locations indicated by the host driver in the + * BSM_DRAM_* registers. Once the new program is loaded, it starts + * automatically. + * + * When initializing the NIC, the host driver points the BSM to the + * "initialize" uCode image. This uCode sets up some internal data, then + * notifies host via "initialize alive" that it is complete. + * + * The host then replaces the BSM_DRAM_* pointer values to point to the + * normal runtime uCode instructions and a backup uCode data cache buffer + * (filled initially with starting data values for the on-board processor), + * then triggers the "initialize" uCode to load and launch the runtime uCode, + * which begins normal operation. + * + * When doing a power-save shutdown, runtime uCode saves data SRAM into + * the backup data cache in DRAM before SRAM is powered down. + * + * When powering back up, the BSM loads the bootstrap program. This reloads + * the runtime uCode instructions and the backup data cache into SRAM, + * and re-launches the runtime uCode from where it left off. + */ +static int il3945_load_bsm(struct il_priv *il) +{ + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + dma_addr_t pinst; + dma_addr_t pdata; + u32 inst_len; + u32 data_len; + int rc; + int i; + u32 done; + u32 reg_offset; + + D_INFO("Begin load bsm\n"); + + /* make sure bootstrap program is no larger than BSM's SRAM size */ + if (len > IL39_MAX_BSM_SIZE) + return -EINVAL; + + /* Tell bootstrap uCode where to find the "Initialize" uCode + * in host DRAM ... host DRAM physical address bits 31:0 for 3945. + * NOTE: il3945_initialize_alive_start() will replace these values, + * after the "initialize" uCode has run, to point to + * runtime/protocol instructions and backup data cache. */ + pinst = il->ucode_init.p_addr; + pdata = il->ucode_init_data.p_addr; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; + + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + + /* Fill BSM memory with bootstrap instructions */ + for (reg_offset = BSM_SRAM_LOWER_BOUND; + reg_offset < BSM_SRAM_LOWER_BOUND + len; + reg_offset += sizeof(u32), image++) + _il_wr_prph(il, reg_offset, + le32_to_cpu(*image)); + + rc = il3945_verify_bsm(il); + if (rc) + return rc; + + /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, BSM_WR_MEM_DST_REG, + IL39_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + + /* Load bootstrap code into instruction SRAM now, + * to prepare to load "initialize" uCode */ + il_wr_prph(il, BSM_WR_CTRL_REG, + BSM_WR_CTRL_REG_BIT_START); + + /* Wait for load of bootstrap uCode to finish */ + for (i = 0; i < 100; i++) { + done = il_rd_prph(il, BSM_WR_CTRL_REG); + if (!(done & BSM_WR_CTRL_REG_BIT_START)) + break; + udelay(10); + } + if (i < 100) + D_INFO("BSM write complete, poll %d iterations\n", i); + else { + IL_ERR("BSM write did not complete!\n"); + return -EIO; + } + + /* Enable future boot loads whenever power management unit triggers it + * (e.g. when powering back up after power-save shutdown) */ + il_wr_prph(il, BSM_WR_CTRL_REG, + BSM_WR_CTRL_REG_BIT_START_EN); + + return 0; +} + +static struct il_hcmd_ops il3945_hcmd = { + .rxon_assoc = il3945_send_rxon_assoc, + .commit_rxon = il3945_commit_rxon, +}; + +static struct il_lib_ops il3945_lib = { + .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il3945_hw_txq_free_tfd, + .txq_init = il3945_hw_tx_queue_init, + .load_ucode = il3945_load_bsm, + .dump_nic_error_log = il3945_dump_nic_error_log, + .apm_ops = { + .init = il3945_apm_init, + .config = il3945_nic_config, + }, + .eeprom_ops = { + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_REGULATORY_BAND_NO_HT40, + EEPROM_REGULATORY_BAND_NO_HT40, + }, + .acquire_semaphore = il3945_eeprom_acquire_semaphore, + .release_semaphore = il3945_eeprom_release_semaphore, + }, + .send_tx_power = il3945_send_tx_power, + .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, + + .debugfs_ops = { + .rx_stats_read = il3945_ucode_rx_stats_read, + .tx_stats_read = il3945_ucode_tx_stats_read, + .general_stats_read = il3945_ucode_general_stats_read, + }, +}; + +static const struct il_legacy_ops il3945_legacy_ops = { + .post_associate = il3945_post_associate, + .config_ap = il3945_config_ap, + .manage_ibss_station = il3945_manage_ibss_station, +}; + +static struct il_hcmd_utils_ops il3945_hcmd_utils = { + .get_hcmd_size = il3945_get_hcmd_size, + .build_addsta_hcmd = il3945_build_addsta_hcmd, + .request_scan = il3945_request_scan, + .post_scan = il3945_post_scan, +}; + +static const struct il_ops il3945_ops = { + .lib = &il3945_lib, + .hcmd = &il3945_hcmd, + .utils = &il3945_hcmd_utils, + .led = &il3945_led_ops, + .legacy = &il3945_legacy_ops, + .ieee80211_ops = &il3945_hw_ops, +}; + +static struct il_base_params il3945_base_params = { + .eeprom_size = IL3945_EEPROM_IMG_SIZE, + .num_of_queues = IL39_NUM_QUEUES, + .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, + .set_l0s = false, + .use_bsm = true, + .led_compensation = 64, + .wd_timeout = IL_DEF_WD_TIMEOUT, +}; + +static struct il_cfg il3945_bg_cfg = { + .name = "3945BG", + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, + .sku = IL_SKU_G, + .eeprom_ver = EEPROM_3945_EEPROM_VERSION, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, +}; + +static struct il_cfg il3945_abg_cfg = { + .name = "3945ABG", + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, + .sku = IL_SKU_A|IL_SKU_G, + .eeprom_ver = EEPROM_3945_EEPROM_VERSION, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, +}; + +DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { + {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, + {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, + {0} +}; + +MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c new file mode 100644 index 0000000..df86431 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -0,0 +1,3245 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * Portions of this file are derived from the ipw3945 project, as well + * as portions of the ieee80211 subsystem header files. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define DRV_NAME "iwl4965" + +#include "iwl-eeprom.h" +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-helpers.h" +#include "iwl-sta.h" +#include "iwl-4965-calib.h" +#include "iwl-4965.h" +#include "iwl-4965-led.h" + + +/****************************************************************************** + * + * module boiler plate + * + ******************************************************************************/ + +/* + * module name, copyright, version, etc. + */ +#define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux" + +#ifdef CONFIG_IWLEGACY_DEBUG +#define VD "d" +#else +#define VD +#endif + +#define DRV_VERSION IWLWIFI_VERSION VD + + +MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_VERSION(DRV_VERSION); +MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("iwl4965"); + +void il4965_update_chain_flags(struct il_priv *il) +{ + if (il->cfg->ops->hcmd->set_rxon_chain) { + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); + if (il->ctx.active.rx_chain != il->ctx.staging.rx_chain) + il_commit_rxon(il, &il->ctx); + } +} + +static void il4965_clear_free_frames(struct il_priv *il) +{ + struct list_head *element; + + D_INFO("%d frames on pre-allocated heap on clear.\n", + il->frames_count); + + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; + list_del(element); + kfree(list_entry(element, struct il_frame, list)); + il->frames_count--; + } + + if (il->frames_count) { + IL_WARN("%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; + } +} + +static struct il_frame *il4965_get_free_frame(struct il_priv *il) +{ + struct il_frame *frame; + struct list_head *element; + if (list_empty(&il->free_frames)) { + frame = kzalloc(sizeof(*frame), GFP_KERNEL); + if (!frame) { + IL_ERR("Could not allocate frame!\n"); + return NULL; + } + + il->frames_count++; + return frame; + } + + element = il->free_frames.next; + list_del(element); + return list_entry(element, struct il_frame, list); +} + +static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) +{ + memset(frame, 0, sizeof(*frame)); + list_add(&frame->list, &il->free_frames); +} + +static u32 il4965_fill_beacon_frame(struct il_priv *il, + struct ieee80211_hdr *hdr, + int left) +{ + lockdep_assert_held(&il->mutex); + + if (!il->beacon_skb) + return 0; + + if (il->beacon_skb->len > left) + return 0; + + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); + + return il->beacon_skb->len; +} + +/* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ +static void il4965_set_beacon_tim(struct il_priv *il, + struct il_tx_beacon_cmd *tx_beacon_cmd, + u8 *beacon, u32 frame_size) +{ + u16 tim_idx; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; + + /* + * The idx is relative to frame start but we start looking at the + * variable-length part of the beacon. + */ + tim_idx = mgmt->u.beacon.variable - beacon; + + /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ + while ((tim_idx < (frame_size - 2)) && + (beacon[tim_idx] != WLAN_EID_TIM)) + tim_idx += beacon[tim_idx+1] + 2; + + /* If TIM field was found, set variables */ + if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { + tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); + tx_beacon_cmd->tim_size = beacon[tim_idx+1]; + } else + IL_WARN("Unable to find TIM Element in beacon\n"); +} + +static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, + struct il_frame *frame) +{ + struct il_tx_beacon_cmd *tx_beacon_cmd; + u32 frame_size; + u32 rate_flags; + u32 rate; + /* + * We have to set up the TX command, the TX Beacon command, and the + * beacon contents. + */ + + lockdep_assert_held(&il->mutex); + + if (!il->beacon_ctx) { + IL_ERR("trying to build beacon w/o beacon context!\n"); + return 0; + } + + /* Initialize memory */ + tx_beacon_cmd = &frame->u.beacon; + memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); + + /* Set up TX beacon contents */ + frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) + return 0; + if (!frame_size) + return 0; + + /* Set up TX command fields */ + tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; + tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | + TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; + + /* Set up TX beacon command fields */ + il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, + frame_size); + + /* Set up packet rate and flags */ + rate = il_get_lowest_plcp(il, il->beacon_ctx); + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); + rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); + if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) + rate_flags |= RATE_MCS_CCK_MSK; + tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, + rate_flags); + + return sizeof(*tx_beacon_cmd) + frame_size; +} + +int il4965_send_beacon_cmd(struct il_priv *il) +{ + struct il_frame *frame; + unsigned int frame_size; + int rc; + + frame = il4965_get_free_frame(il); + if (!frame) { + IL_ERR("Could not obtain free frame buffer for beacon " + "command.\n"); + return -ENOMEM; + } + + frame_size = il4965_hw_get_beacon_cmd(il, frame); + if (!frame_size) { + IL_ERR("Error configuring the beacon command\n"); + il4965_free_frame(il, frame); + return -EINVAL; + } + + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + &frame->u.cmd[0]); + + il4965_free_frame(il, frame); + + return rc; +} + +static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) +{ + struct il_tfd_tb *tb = &tfd->tbs[idx]; + + dma_addr_t addr = get_unaligned_le32(&tb->lo); + if (sizeof(dma_addr_t) > sizeof(u32)) + addr |= + ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; + + return addr; +} + +static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) +{ + struct il_tfd_tb *tb = &tfd->tbs[idx]; + + return le16_to_cpu(tb->hi_n_len) >> 4; +} + +static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, + dma_addr_t addr, u16 len) +{ + struct il_tfd_tb *tb = &tfd->tbs[idx]; + u16 hi_n_len = len << 4; + + put_unaligned_le32(addr, &tb->lo); + if (sizeof(dma_addr_t) > sizeof(u32)) + hi_n_len |= ((addr >> 16) >> 16) & 0xF; + + tb->hi_n_len = cpu_to_le16(hi_n_len); + + tfd->num_tbs = idx + 1; +} + +static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) +{ + return tfd->num_tbs & 0x1f; +} + +/** + * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] + * @il - driver ilate data + * @txq - tx queue + * + * Does NOT advance any TFD circular buffer read/write idxes + * Does NOT free the TFD itself (which is within circular buffer) + */ +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +{ + struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; + struct il_tfd *tfd; + struct pci_dev *dev = il->pci_dev; + int idx = txq->q.read_ptr; + int i; + int num_tbs; + + tfd = &tfd_tmp[idx]; + + /* Sanity check on number of chunks */ + num_tbs = il4965_tfd_get_num_tbs(tfd); + + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR("Too many chunks: %i\n", num_tbs); + /* @todo issue fatal error, it is quite serious situation */ + return; + } + + /* Unmap tx_cmd */ + if (num_tbs) + pci_unmap_single(dev, + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_BIDIRECTIONAL); + + /* Unmap chunks, if any. */ + for (i = 1; i < num_tbs; i++) + pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), + il4965_tfd_tb_get_len(tfd, i), + PCI_DMA_TODEVICE); + + /* free SKB */ + if (txq->txb) { + struct sk_buff *skb; + + skb = txq->txb[txq->q.read_ptr].skb; + + /* can be called from irqs-disabled context */ + if (skb) { + dev_kfree_skb_any(skb); + txq->txb[txq->q.read_ptr].skb = NULL; + } + } +} + +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, + u8 reset, u8 pad) +{ + struct il_queue *q; + struct il_tfd *tfd, *tfd_tmp; + u32 num_tbs; + + q = &txq->q; + tfd_tmp = (struct il_tfd *)txq->tfds; + tfd = &tfd_tmp[q->write_ptr]; + + if (reset) + memset(tfd, 0, sizeof(*tfd)); + + num_tbs = il4965_tfd_get_num_tbs(tfd); + + /* Each TFD can point to a maximum 20 Tx buffers */ + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR("Error can not send more than %d chunks\n", + IL_NUM_OF_TBS); + return -EINVAL; + } + + BUG_ON(addr & ~DMA_BIT_MASK(36)); + if (unlikely(addr & ~IL_TX_DMA_MASK)) + IL_ERR("Unaligned address = %llx\n", + (unsigned long long)addr); + + il4965_tfd_set_tb(tfd, num_tbs, addr, len); + + return 0; +} + +/* + * Tell nic where to find circular buffer of Tx Frame Descriptors for + * given Tx queue, and enable the DMA channel used for that queue. + * + * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA + * channels supported in hardware. + */ +int il4965_hw_tx_queue_init(struct il_priv *il, + struct il_tx_queue *txq) +{ + int txq_id = txq->q.id; + + /* Circular buffer (TFD queue in DRAM) physical base address */ + il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), + txq->q.dma_addr >> 8); + + return 0; +} + +/****************************************************************************** + * + * Generic RX handler implementations + * + ******************************************************************************/ +static void il4965_rx_reply_alive(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; + struct delayed_work *pwork; + + palive = &pkt->u.alive_frame; + + D_INFO("Alive ucode status 0x%08X revision " + "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, + palive->ver_subtype); + + if (palive->ver_subtype == INITIALIZE_SUBTYPE) { + D_INFO("Initialization Alive received.\n"); + memcpy(&il->card_alive_init, + &pkt->u.alive_frame, + sizeof(struct il_init_alive_resp)); + pwork = &il->init_alive_start; + } else { + D_INFO("Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, + sizeof(struct il_alive_resp)); + pwork = &il->alive_start; + } + + /* We delay the ALIVE response by 5ms to + * give the HW RF Kill time to activate... */ + if (palive->is_valid == UCODE_VALID_OK) + queue_delayed_work(il->workqueue, pwork, + msecs_to_jiffies(5)); + else + IL_WARN("uCode did not respond OK.\n"); +} + +/** + * il4965_bg_stats_periodic - Timer callback to queue stats + * + * This callback is provided in order to send a stats request. + * + * This timer function is continually reset to execute within + * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION + * was received. We need to ensure we receive the stats in order + * to update the temperature used for calibrating the TXPOWER. + */ +static void il4965_bg_stats_periodic(unsigned long data) +{ + struct il_priv *il = (struct il_priv *)data; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + /* dont send host command if rf-kill is on */ + if (!il_is_ready_rf(il)) + return; + + il_send_stats_request(il, CMD_ASYNC, false); +} + +static void il4965_rx_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = + (struct il4965_beacon_notif *)pkt->u.raw; +#ifdef CONFIG_IWLEGACY_DEBUG + u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + + D_RX("beacon status %x retries %d iss %d " + "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), + le32_to_cpu(beacon->low_tsf), rate); +#endif + + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); +} + +static void il4965_perform_ct_kill_task(struct il_priv *il) +{ + unsigned long flags; + + D_POWER("Stop all queues\n"); + + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); + + _il_wr(il, CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + _il_rd(il, CSR_UCODE_DRV_GP1); + + spin_lock_irqsave(&il->reg_lock, flags); + if (!_il_grab_nic_access(il)) + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, flags); +} + +/* Handle notification from uCode that card's power state is changing + * due to software, hardware, or critical temperature RFKILL */ +static void il4965_rx_card_state_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); + unsigned long status = il->status; + + D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On", + (flags & CT_CARD_DISABLED) ? + "Reached" : "Not reached"); + + if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | + CT_CARD_DISABLED)) { + + _il_wr(il, CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + il_wr(il, HBUS_TARG_MBX_C, + HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + + if (!(flags & RXON_CARD_DISABLED)) { + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + il_wr(il, HBUS_TARG_MBX_C, + HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + } + } + + if (flags & CT_CARD_DISABLED) + il4965_perform_ct_kill_task(il); + + if (flags & HW_CARD_DISABLED) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + + if (!(flags & RXON_CARD_DISABLED)) + il_scan_cancel(il); + + if ((test_bit(STATUS_RF_KILL_HW, &status) != + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); + else + wake_up(&il->wait_command_queue); +} + +/** + * il4965_setup_rx_handlers - Initialize Rx handler callbacks + * + * Setup the RX handlers for each of the reply types sent from the uCode + * to the host. + * + * This function chains into the hardware specific files for them to setup + * any hardware specific handlers as well. + */ +static void il4965_setup_rx_handlers(struct il_priv *il) +{ + il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il_rx_spectrum_measure_notif; + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il_rx_pm_debug_stats_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + + /* + * The same handler is used for both the REPLY to a discrete + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. + */ + il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; + + il_setup_rx_scan_handlers(il); + + /* status change handler */ + il->rx_handlers[CARD_STATE_NOTIFICATION] = + il4965_rx_card_state_notif; + + il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = + il4965_rx_missed_beacon_notif; + /* Rx handlers */ + il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; + il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; + /* block ack */ + il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + /* Set up hardware specific Rx handlers */ + il->cfg->ops->lib->rx_handler_setup(il); +} + +/** + * il4965_rx_handle - Main entry function for receiving responses from uCode + * + * Uses the il->rx_handlers callback function array to invoke + * the appropriate handlers, including command responses, + * frame-received notifications, and other notifications. + */ +void il4965_rx_handle(struct il_priv *il) +{ + struct il_rx_buf *rxb; + struct il_rx_pkt *pkt; + struct il_rx_queue *rxq = &il->rxq; + u32 r, i; + int reclaim; + unsigned long flags; + u8 fill_rx = 0; + u32 count = 8; + int total_empty; + + /* uCode's read idx (stored in shared DRAM) indicates the last Rx + * buffer that the driver may process (last buffer filled by ucode). */ + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + i = rxq->read; + + /* Rx interrupt, but nothing sent from uCode */ + if (i == r) + D_RX("r = %d, i = %d\n", r, i); + + /* calculate total frames need to be restock after handling RX */ + total_empty = r - rxq->write_actual; + if (total_empty < 0) + total_empty += RX_QUEUE_SIZE; + + if (total_empty > (RX_QUEUE_SIZE / 2)) + fill_rx = 1; + + while (i != r) { + int len; + + rxb = rxq->queue[i]; + + /* If an RXB doesn't have a Rx queue slot associated with it, + * then a bug has been introduced in the queue refilling + * routines -- catch it here */ + BUG_ON(rxb == NULL); + + rxq->queue[i] = NULL; + + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + pkt = rxb_addr(rxb); + + len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len += sizeof(u32); /* account for status word */ + + /* Reclaim a command buffer only if this packet is a response + * to a (driver-originated) command. + * If the packet (e.g. Rx frame) originated from uCode, + * there is no command buffer to reclaim. + * Ucode should set SEQ_RX_FRAME bit if ucode-originated, + * but apparently a few don't get set; catch them here. */ + reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && + (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && + (pkt->hdr.cmd != REPLY_RX) && + (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && + (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && + (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && + (pkt->hdr.cmd != REPLY_TX); + + /* Based on type of command response or notification, + * handle those that need handling via function in + * rx_handlers table. See il4965_setup_rx_handlers() */ + if (il->rx_handlers[pkt->hdr.cmd]) { + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), + pkt->hdr.cmd); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); + } else { + /* No handling needed */ + D_RX( + "r %d i %d No handler needed for %s, 0x%02x\n", + r, i, il_get_cmd_string(pkt->hdr.cmd), + pkt->hdr.cmd); + } + + /* + * XXX: After here, we should always check rxb->page + * against NULL before touching it or its virtual + * memory (pkt). Because some rx_handler might have + * already taken or freed the pages. + */ + + if (reclaim) { + /* Invoke any callbacks, transfer the buffer to caller, + * and fire off the (possibly) blocking il_send_cmd() + * as we reclaim the driver command queue */ + if (rxb->page) + il_tx_cmd_complete(il, rxb); + else + IL_WARN("Claim null rxb?\n"); + } + + /* Reuse the page if possible. For notification packets and + * SKBs that fail to Rx correctly, add them back into the + * rx_free list for reuse later. */ + spin_lock_irqsave(&rxq->lock, flags); + if (rxb->page != NULL) { + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + } else + list_add_tail(&rxb->list, &rxq->rx_used); + + spin_unlock_irqrestore(&rxq->lock, flags); + + i = (i + 1) & RX_QUEUE_MASK; + /* If there are a lot of unused frames, + * restock the Rx queue so ucode wont assert. */ + if (fill_rx) { + count++; + if (count >= 8) { + rxq->read = i; + il4965_rx_replenish_now(il); + count = 0; + } + } + } + + /* Backtrack one entry */ + rxq->read = i; + if (fill_rx) + il4965_rx_replenish_now(il); + else + il4965_rx_queue_restock(il); +} + +/* call this function to flush any scheduled tasklet */ +static inline void il4965_synchronize_irq(struct il_priv *il) +{ + /* wait to make sure we flush pending tasklet*/ + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); +} + +static void il4965_irq_tasklet(struct il_priv *il) +{ + u32 inta, handled = 0; + u32 inta_fh; + unsigned long flags; + u32 i; +#ifdef CONFIG_IWLEGACY_DEBUG + u32 inta_mask; +#endif + + spin_lock_irqsave(&il->lock, flags); + + /* Ack/clear/reset pending uCode interrupts. + * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, + * and will clear only when CSR_FH_INT_STATUS gets cleared. */ + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); + + /* Ack/clear/reset pending flow-handler (DMA) interrupts. + * Any new interrupts that happen after this, either while we're + * in this tasklet, or later, will show up in next ISR/tasklet. */ + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & IL_DL_ISR) { + /* just for debug */ + inta_mask = _il_rd(il, CSR_INT_MASK); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta, inta_mask, inta_fh); + } +#endif + + spin_unlock_irqrestore(&il->lock, flags); + + /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not + * atomic, make sure that inta covers all the interrupts that + * we've discovered, even if FH interrupt came in just after + * reading CSR_INT. */ + if (inta_fh & CSR49_FH_INT_RX_MASK) + inta |= CSR_INT_BIT_FH_RX; + if (inta_fh & CSR49_FH_INT_TX_MASK) + inta |= CSR_INT_BIT_FH_TX; + + /* Now service all interrupt bits discovered above. */ + if (inta & CSR_INT_BIT_HW_ERR) { + IL_ERR("Hardware error detected. Restarting.\n"); + + /* Tell the device to stop sending interrupts */ + il_disable_interrupts(il); + + il->isr_stats.hw++; + il_irq_handle_error(il); + + handled |= CSR_INT_BIT_HW_ERR; + + return; + } + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + /* NIC fires this, but we don't use it, redundant with WAKEUP */ + if (inta & CSR_INT_BIT_SCD) { + D_ISR("Scheduler finished to transmit " + "the frame/frames.\n"); + il->isr_stats.sch++; + } + + /* Alive notification via Rx interrupt will do the real work */ + if (inta & CSR_INT_BIT_ALIVE) { + D_ISR("Alive interrupt\n"); + il->isr_stats.alive++; + } + } +#endif + /* Safely ignore these bits for debug checks below */ + inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); + + /* HW RF KILL switch toggled */ + if (inta & CSR_INT_BIT_RF_KILL) { + int hw_rf_kill = 0; + if (!(_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + hw_rf_kill = 1; + + IL_WARN("RF_KILL bit toggled to %s.\n", + hw_rf_kill ? "disable radio" : "enable radio"); + + il->isr_stats.rfkill++; + + /* driver only loads ucode once setting the interface up. + * the driver allows loading the ucode even if the radio + * is killed. Hence update the killswitch state here. The + * rfkill handler will care about restarting if needed. + */ + if (!test_bit(STATUS_ALIVE, &il->status)) { + if (hw_rf_kill) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); + } + + handled |= CSR_INT_BIT_RF_KILL; + } + + /* Chip got too hot and stopped itself */ + if (inta & CSR_INT_BIT_CT_KILL) { + IL_ERR("Microcode CT kill error detected.\n"); + il->isr_stats.ctkill++; + handled |= CSR_INT_BIT_CT_KILL; + } + + /* Error detected by uCode */ + if (inta & CSR_INT_BIT_SW_ERR) { + IL_ERR("Microcode SW error detected. " + " Restarting 0x%X.\n", inta); + il->isr_stats.sw++; + il_irq_handle_error(il); + handled |= CSR_INT_BIT_SW_ERR; + } + + /* + * uCode wakes up after power-down sleep. + * Tell device about any new tx or host commands enqueued, + * and about any Rx buffers made available while asleep. + */ + if (inta & CSR_INT_BIT_WAKEUP) { + D_ISR("Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + for (i = 0; i < il->hw_params.max_txq_num; i++) + il_txq_update_write_ptr(il, &il->txq[i]); + il->isr_stats.wakeup++; + handled |= CSR_INT_BIT_WAKEUP; + } + + /* All uCode command responses, including Tx command responses, + * Rx "responses" (frame-received notification), and other + * notifications from uCode come through here*/ + if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { + il4965_rx_handle(il); + il->isr_stats.rx++; + handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); + } + + /* This "Tx" DMA channel is used only for loading uCode */ + if (inta & CSR_INT_BIT_FH_TX) { + D_ISR("uCode load interrupt\n"); + il->isr_stats.tx++; + handled |= CSR_INT_BIT_FH_TX; + /* Wake up uCode load routine, now that load is complete */ + il->ucode_write_complete = 1; + wake_up(&il->wait_command_queue); + } + + if (inta & ~handled) { + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; + } + + if (inta & ~(il->inta_mask)) { + IL_WARN("Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + } + + /* Re-enable all interrupts */ + /* only Re-enable if disabled by irq */ + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + /* Re-enable RF_KILL if it occurred */ + else if (handled & CSR_INT_BIT_RF_KILL) + il_enable_rfkill_int(il); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + D_ISR( + "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + } +#endif +} + +/***************************************************************************** + * + * sysfs attributes + * + *****************************************************************************/ + +#ifdef CONFIG_IWLEGACY_DEBUG + +/* + * The following adds a new attribute to the sysfs representation + * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/) + * used for controlling the debug level. + * + * See the level definitions in iwl for details. + * + * The debug_level being managed using sysfs below is a per device debug + * level that is used instead of the global debug level if it (the per + * device debug level) is set. + */ +static ssize_t il4965_show_debug_level(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); +} +static ssize_t il4965_store_debug_level(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + unsigned long val; + int ret; + + ret = strict_strtoul(buf, 0, &val); + if (ret) + IL_ERR("%s is not in hex or decimal form.\n", buf); + else { + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR( + "Not enough memory to generate traffic log\n"); + } + return strnlen(buf, count); +} + +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, + il4965_show_debug_level, il4965_store_debug_level); + + +#endif /* CONFIG_IWLEGACY_DEBUG */ + + +static ssize_t il4965_show_temperature(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_alive(il)) + return -EAGAIN; + + return sprintf(buf, "%d\n", il->temperature); +} + +static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); + +static ssize_t il4965_show_tx_power(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_ready_rf(il)) + return sprintf(buf, "off\n"); + else + return sprintf(buf, "%d\n", il->tx_power_user_lmt); +} + +static ssize_t il4965_store_tx_power(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + unsigned long val; + int ret; + + ret = strict_strtoul(buf, 10, &val); + if (ret) + IL_INFO("%s is not in decimal form.\n", buf); + else { + ret = il_set_tx_power(il, val, false); + if (ret) + IL_ERR("failed setting tx power (0x%d).\n", + ret); + else + ret = count; + } + return ret; +} + +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, + il4965_show_tx_power, il4965_store_tx_power); + +static struct attribute *il_sysfs_entries[] = { + &dev_attr_temperature.attr, + &dev_attr_tx_power.attr, +#ifdef CONFIG_IWLEGACY_DEBUG + &dev_attr_debug_level.attr, +#endif + NULL +}; + +static struct attribute_group il_attribute_group = { + .name = NULL, /* put in device directory */ + .attrs = il_sysfs_entries, +}; + +/****************************************************************************** + * + * uCode download functions + * + ******************************************************************************/ + +static void il4965_dealloc_ucode_pci(struct il_priv *il) +{ + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); +} + +static void il4965_nic_start(struct il_priv *il) +{ + /* Remove all resets to allow NIC to operate */ + _il_wr(il, CSR_RESET, 0); +} + +static void il4965_ucode_callback(const struct firmware *ucode_raw, + void *context); +static int il4965_mac_setup_register(struct il_priv *il, + u32 max_probe_length); + +static int __must_check il4965_request_firmware(struct il_priv *il, bool first) +{ + const char *name_pre = il->cfg->fw_name_pre; + char tag[8]; + + if (first) { + il->fw_idx = il->cfg->ucode_api_max; + sprintf(tag, "%d", il->fw_idx); + } else { + il->fw_idx--; + sprintf(tag, "%d", il->fw_idx); + } + + if (il->fw_idx < il->cfg->ucode_api_min) { + IL_ERR("no suitable firmware found!\n"); + return -ENOENT; + } + + sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); + + D_INFO("attempting to load firmware '%s'\n", + il->firmware_name); + + return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, + &il->pci_dev->dev, GFP_KERNEL, il, + il4965_ucode_callback); +} + +struct il4965_firmware_pieces { + const void *inst, *data, *init, *init_data, *boot; + size_t inst_size, data_size, init_size, init_data_size, boot_size; +}; + +static int il4965_load_firmware(struct il_priv *il, + const struct firmware *ucode_raw, + struct il4965_firmware_pieces *pieces) +{ + struct il_ucode_header *ucode = (void *)ucode_raw->data; + u32 api_ver, hdr_size; + const u8 *src; + + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); + + switch (api_ver) { + default: + case 0: + case 1: + case 2: + hdr_size = 24; + if (ucode_raw->size < hdr_size) { + IL_ERR("File size too small!\n"); + return -EINVAL; + } + pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); + pieces->data_size = le32_to_cpu(ucode->v1.data_size); + pieces->init_size = le32_to_cpu(ucode->v1.init_size); + pieces->init_data_size = + le32_to_cpu(ucode->v1.init_data_size); + pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); + src = ucode->v1.data; + break; + } + + /* Verify size of file vs. image size info in file's header */ + if (ucode_raw->size != hdr_size + pieces->inst_size + + pieces->data_size + pieces->init_size + + pieces->init_data_size + pieces->boot_size) { + + IL_ERR( + "uCode file size %d does not match expected size\n", + (int)ucode_raw->size); + return -EINVAL; + } + + pieces->inst = src; + src += pieces->inst_size; + pieces->data = src; + src += pieces->data_size; + pieces->init = src; + src += pieces->init_size; + pieces->init_data = src; + src += pieces->init_data_size; + pieces->boot = src; + src += pieces->boot_size; + + return 0; +} + +/** + * il4965_ucode_callback - callback when firmware was loaded + * + * If loaded successfully, copies the firmware into buffers + * for the card to fetch (via DMA). + */ +static void +il4965_ucode_callback(const struct firmware *ucode_raw, void *context) +{ + struct il_priv *il = context; + struct il_ucode_header *ucode; + int err; + struct il4965_firmware_pieces pieces; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; + u32 api_ver; + + u32 max_probe_length = 200; + u32 standard_phy_calibration_size = + IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; + + memset(&pieces, 0, sizeof(pieces)); + + if (!ucode_raw) { + if (il->fw_idx <= il->cfg->ucode_api_max) + IL_ERR( + "request for firmware file '%s' failed.\n", + il->firmware_name); + goto try_again; + } + + D_INFO("Loaded firmware file '%s' (%zd bytes).\n", + il->firmware_name, ucode_raw->size); + + /* Make sure that we got at least the API version number */ + if (ucode_raw->size < 4) { + IL_ERR("File size way too small!\n"); + goto try_again; + } + + /* Data from ucode file: header followed by uCode images */ + ucode = (struct il_ucode_header *)ucode_raw->data; + + err = il4965_load_firmware(il, ucode_raw, &pieces); + + if (err) + goto try_again; + + api_ver = IL_UCODE_API(il->ucode_ver); + + /* + * api_ver should match the api version forming part of the + * firmware filename ... but we don't check for that and only rely + * on the API version read from firmware header from here on forward + */ + if (api_ver < api_min || api_ver > api_max) { + IL_ERR( + "Driver unable to support your firmware API. " + "Driver supports v%u, firmware is v%u.\n", + api_max, api_ver); + goto try_again; + } + + if (api_ver != api_max) + IL_ERR( + "Firmware has old API version. Expected v%u, " + "got v%u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", + api_max, api_ver); + + IL_INFO("loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + /* + * For any of the failures below (before allocating pci memory) + * we will try to load a version with a smaller API -- maybe the + * user just got a corrupted version of the latest API. + */ + + D_INFO("f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %Zd\n", + pieces.inst_size); + D_INFO("f/w package hdr runtime data size = %Zd\n", + pieces.data_size); + D_INFO("f/w package hdr init inst size = %Zd\n", + pieces.init_size); + D_INFO("f/w package hdr init data size = %Zd\n", + pieces.init_data_size); + D_INFO("f/w package hdr boot inst size = %Zd\n", + pieces.boot_size); + + /* Verify that uCode images will fit in card's SRAM */ + if (pieces.inst_size > il->hw_params.max_inst_size) { + IL_ERR("uCode instr len %Zd too large to fit in\n", + pieces.inst_size); + goto try_again; + } + + if (pieces.data_size > il->hw_params.max_data_size) { + IL_ERR("uCode data len %Zd too large to fit in\n", + pieces.data_size); + goto try_again; + } + + if (pieces.init_size > il->hw_params.max_inst_size) { + IL_ERR("uCode init instr len %Zd too large to fit in\n", + pieces.init_size); + goto try_again; + } + + if (pieces.init_data_size > il->hw_params.max_data_size) { + IL_ERR("uCode init data len %Zd too large to fit in\n", + pieces.init_data_size); + goto try_again; + } + + if (pieces.boot_size > il->hw_params.max_bsm_size) { + IL_ERR("uCode boot instr len %Zd too large to fit in\n", + pieces.boot_size); + goto try_again; + } + + /* Allocate ucode buffers for card's bus-master loading ... */ + + /* Runtime instructions and 2 copies of data: + * 1) unmodified from disk + * 2) backup cache for save/restore during power-downs */ + il->ucode_code.len = pieces.inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); + + il->ucode_data.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); + + il->ucode_data_backup.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); + + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) + goto err_pci_alloc; + + /* Initialization instructions and data */ + if (pieces.init_size && pieces.init_data_size) { + il->ucode_init.len = pieces.init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); + + il->ucode_init_data.len = pieces.init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); + + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) + goto err_pci_alloc; + } + + /* Bootstrap (instructions only, no data) */ + if (pieces.boot_size) { + il->ucode_boot.len = pieces.boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); + + if (!il->ucode_boot.v_addr) + goto err_pci_alloc; + } + + /* Now that we can no longer fail, copy information */ + + il->sta_key_max_num = STA_KEY_MAX_NUM; + + /* Copy images into buffers for card's bus-master reads ... */ + + /* Runtime instructions (first block of data in file) */ + D_INFO("Copying (but not loading) uCode instr len %Zd\n", + pieces.inst_size); + memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); + + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + + /* + * Runtime data + * NOTE: Copy into backup buffer will be done in il_up() + */ + D_INFO("Copying (but not loading) uCode data len %Zd\n", + pieces.data_size); + memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); + memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); + + /* Initialization instructions */ + if (pieces.init_size) { + D_INFO( + "Copying (but not loading) init instr len %Zd\n", + pieces.init_size); + memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); + } + + /* Initialization data */ + if (pieces.init_data_size) { + D_INFO( + "Copying (but not loading) init data len %Zd\n", + pieces.init_data_size); + memcpy(il->ucode_init_data.v_addr, pieces.init_data, + pieces.init_data_size); + } + + /* Bootstrap instructions */ + D_INFO("Copying (but not loading) boot instr len %Zd\n", + pieces.boot_size); + memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); + + /* + * figure out the offset of chain noise reset and gain commands + * base on the size of standard phy calibration commands table size + */ + il->_4965.phy_calib_chain_noise_reset_cmd = + standard_phy_calibration_size; + il->_4965.phy_calib_chain_noise_gain_cmd = + standard_phy_calibration_size + 1; + + /************************************************** + * This is still part of probe() in a sense... + * + * 9. Setup and register with mac80211 and debugfs + **************************************************/ + err = il4965_mac_setup_register(il, max_probe_length); + if (err) + goto out_unbind; + + err = il_dbgfs_register(il, DRV_NAME); + if (err) + IL_ERR( + "failed to create debugfs files. Ignoring error: %d\n", err); + + err = sysfs_create_group(&il->pci_dev->dev.kobj, + &il_attribute_group); + if (err) { + IL_ERR("failed to create sysfs device attributes\n"); + goto out_unbind; + } + + /* We have our copies now, allow OS release its copies */ + release_firmware(ucode_raw); + complete(&il->_4965.firmware_loading_complete); + return; + + try_again: + /* try next, if any */ + if (il4965_request_firmware(il, false)) + goto out_unbind; + release_firmware(ucode_raw); + return; + + err_pci_alloc: + IL_ERR("failed to allocate pci memory\n"); + il4965_dealloc_ucode_pci(il); + out_unbind: + complete(&il->_4965.firmware_loading_complete); + device_release_driver(&il->pci_dev->dev); + release_firmware(ucode_raw); +} + +static const char * const desc_lookup_text[] = { + "OK", + "FAIL", + "BAD_PARAM", + "BAD_CHECKSUM", + "NMI_INTERRUPT_WDG", + "SYSASSERT", + "FATAL_ERROR", + "BAD_COMMAND", + "HW_ERROR_TUNE_LOCK", + "HW_ERROR_TEMPERATURE", + "ILLEGAL_CHAN_FREQ", + "VCC_NOT_STBL", + "FH_ERROR", + "NMI_INTERRUPT_HOST", + "NMI_INTERRUPT_ACTION_PT", + "NMI_INTERRUPT_UNKNOWN", + "UCODE_VERSION_MISMATCH", + "HW_ERROR_ABS_LOCK", + "HW_ERROR_CAL_LOCK_FAIL", + "NMI_INTERRUPT_INST_ACTION_PT", + "NMI_INTERRUPT_DATA_ACTION_PT", + "NMI_TRM_HW_ER", + "NMI_INTERRUPT_TRM", + "NMI_INTERRUPT_BREAK_POINT", + "DEBUG_0", + "DEBUG_1", + "DEBUG_2", + "DEBUG_3", +}; + +static struct { char *name; u8 num; } advanced_lookup[] = { + { "NMI_INTERRUPT_WDG", 0x34 }, + { "SYSASSERT", 0x35 }, + { "UCODE_VERSION_MISMATCH", 0x37 }, + { "BAD_COMMAND", 0x38 }, + { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, + { "FATAL_ERROR", 0x3D }, + { "NMI_TRM_HW_ERR", 0x46 }, + { "NMI_INTERRUPT_TRM", 0x4C }, + { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, + { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, + { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, + { "NMI_INTERRUPT_HOST", 0x66 }, + { "NMI_INTERRUPT_ACTION_PT", 0x7C }, + { "NMI_INTERRUPT_UNKNOWN", 0x84 }, + { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, + { "ADVANCED_SYSASSERT", 0 }, +}; + +static const char *il4965_desc_lookup(u32 num) +{ + int i; + int max = ARRAY_SIZE(desc_lookup_text); + + if (num < max) + return desc_lookup_text[num]; + + max = ARRAY_SIZE(advanced_lookup) - 1; + for (i = 0; i < max; i++) { + if (advanced_lookup[i].num == num) + break; + } + return advanced_lookup[i].name; +} + +#define ERROR_START_OFFSET (1 * sizeof(u32)) +#define ERROR_ELEM_SIZE (7 * sizeof(u32)) + +void il4965_dump_nic_error_log(struct il_priv *il) +{ + u32 data2, line; + u32 desc, time, count, base, data1; + u32 blink1, blink2, ilink1, ilink2; + u32 pc, hcmd; + + if (il->ucode_type == UCODE_INIT) { + base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); + } else { + base = le32_to_cpu(il->card_alive.error_event_table_ptr); + } + + if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { + IL_ERR( + "Not valid error log pointer 0x%08X for %s uCode\n", + base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); + return; + } + + count = il_read_targ_mem(il, base); + + if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", + il->status, count); + } + + desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); + il->isr_stats.err_code = desc; + pc = il_read_targ_mem(il, base + 2 * sizeof(u32)); + blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32)); + blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32)); + ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32)); + ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32)); + data1 = il_read_targ_mem(il, base + 7 * sizeof(u32)); + data2 = il_read_targ_mem(il, base + 8 * sizeof(u32)); + line = il_read_targ_mem(il, base + 9 * sizeof(u32)); + time = il_read_targ_mem(il, base + 11 * sizeof(u32)); + hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); + + IL_ERR("Desc Time " + "data1 data2 line\n"); + IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + il4965_desc_lookup(desc), desc, time, data1, data2, line); + IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + pc, blink1, blink2, ilink1, ilink2, hcmd); +} + +static void il4965_rf_kill_ct_config(struct il_priv *il) +{ + struct il_ct_kill_config cmd; + unsigned long flags; + int ret = 0; + + spin_lock_irqsave(&il->lock, flags); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + spin_unlock_irqrestore(&il->lock, flags); + + cmd.critical_temperature_R = + cpu_to_le32(il->hw_params.ct_kill_threshold); + + ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, + sizeof(cmd), &cmd); + if (ret) + IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); + else + D_INFO("REPLY_CT_KILL_CONFIG_CMD " + "succeeded, " + "critical temperature is %d\n", + il->hw_params.ct_kill_threshold); +} + +static const s8 default_queue_to_tx_fifo[] = { + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, + IL49_CMD_FIFO_NUM, + IL_TX_FIFO_UNUSED, + IL_TX_FIFO_UNUSED, +}; + +static int il4965_alive_notify(struct il_priv *il) +{ + u32 a; + unsigned long flags; + int i, chan; + u32 reg_val; + + spin_lock_irqsave(&il->lock, flags); + + /* Clear 4965's internal Tx Scheduler data base */ + il->scd_base_addr = il_rd_prph(il, + IL49_SCD_SRAM_BASE_ADDR); + a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; + for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + il_write_targ_mem(il, a, 0); + + /* Tel 4965 where to find Tx byte count tables */ + il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, + il->scd_bc_tbls.dma >> 10); + + /* Enable DMA channel */ + for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) + il_wr(il, + FH_TCSR_CHNL_TX_CONFIG_REG(chan), + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); + + /* Update FH chicken bits */ + reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); + il_wr(il, FH_TX_CHICKEN_BITS_REG, + reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); + + /* Disable chain mode for all queues */ + il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); + + /* Initialize each Tx queue (including the command queue) */ + for (i = 0; i < il->hw_params.max_txq_num; i++) { + + /* TFD circular buffer read/write idxes */ + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); + il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); + + /* Max Tx Window size for Scheduler-ACK mode */ + il_write_targ_mem(il, il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i), + (SCD_WIN_SIZE << + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + + /* Frame limit */ + il_write_targ_mem(il, il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + + sizeof(u32), + (SCD_FRAME_LIMIT << + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + + } + il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, + (1 << il->hw_params.max_txq_num) - 1); + + /* Activate all Tx DMA/FIFO channels */ + il4965_txq_set_sched(il, IL_MASK(0, 6)); + + il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0); + + /* make sure all queue are not stopped */ + memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); + for (i = 0; i < 4; i++) + atomic_set(&il->queue_stop_count[i], 0); + + /* reset to 0 to enable all the queue first */ + il->txq_ctx_active_msk = 0; + /* Map each Tx/cmd queue to its corresponding fifo */ + BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); + + for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { + int ac = default_queue_to_tx_fifo[i]; + + il_txq_ctx_activate(il, i); + + if (ac == IL_TX_FIFO_UNUSED) + continue; + + il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); + } + + spin_unlock_irqrestore(&il->lock, flags); + + return 0; +} + +/** + * il4965_alive_start - called after REPLY_ALIVE notification received + * from protocol/runtime uCode (initialization uCode's + * Alive gets handled by il_init_alive_start()). + */ +static void il4965_alive_start(struct il_priv *il) +{ + int ret = 0; + struct il_rxon_context *ctx = &il->ctx; + + D_INFO("Runtime Alive received.\n"); + + if (il->card_alive.is_valid != UCODE_VALID_OK) { + /* We had an error bringing up the hardware, so take it + * all the way back down so we can try again */ + D_INFO("Alive failed.\n"); + goto restart; + } + + /* Initialize uCode has loaded Runtime uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "runtime" alive if code weren't properly loaded. */ + if (il4965_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad runtime uCode load.\n"); + goto restart; + } + + ret = il4965_alive_notify(il); + if (ret) { + IL_WARN( + "Could not complete ALIVE transition [ntf]: %d\n", ret); + goto restart; + } + + + /* After the ALIVE response, we can send host commands to the uCode */ + set_bit(STATUS_ALIVE, &il->status); + + /* Enable watchdog to monitor the driver tx queues */ + il_setup_watchdog(il); + + if (il_is_rfkill(il)) + return; + + ieee80211_wake_queues(il->hw); + + il->active_rate = RATES_MASK; + + if (il_is_associated_ctx(ctx)) { + struct il_rxon_cmd *active_rxon = + (struct il_rxon_cmd *)&ctx->active; + /* apply any changes in staging */ + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + } else { + /* Initialize our rx_config data */ + il_connection_init_rx_config(il, &il->ctx); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + } + + /* Configure bluetooth coexistence if enabled */ + il_send_bt_config(il); + + il4965_reset_run_time_calib(il); + + set_bit(STATUS_READY, &il->status); + + /* Configure the adapter for unassociated operation */ + il_commit_rxon(il, ctx); + + /* At this point, the NIC is initialized and operational */ + il4965_rf_kill_ct_config(il); + + D_INFO("ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); + + il_power_update_mode(il, true); + D_INFO("Updated power mode\n"); + + return; + + restart: + queue_work(il->workqueue, &il->restart); +} + +static void il4965_cancel_deferred_work(struct il_priv *il); + +static void __il4965_down(struct il_priv *il) +{ + unsigned long flags; + int exit_pending; + + D_INFO(DRV_NAME " is going down\n"); + + il_scan_cancel_timeout(il, 200); + + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + + /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + * to prevent rearm timer */ + del_timer_sync(&il->watchdog); + + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); + + /* Unblock any waiting calls */ + wake_up_all(&il->wait_command_queue); + + /* Wipe out the EXIT_PENDING status bit if we are not actually + * exiting the module */ + if (!exit_pending) + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* stop and reset the on-board processor */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + /* tell the device to stop sending interrupts */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il4965_synchronize_irq(il); + + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); + + /* If we have not previously called il_init() then + * clear all bits but the RF Kill bit and return */ + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + goto exit; + } + + /* ...otherwise clear out all the status bits but the RF Kill + * bit and continue taking the NIC down. */ + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_FW_ERROR, &il->status) << + STATUS_FW_ERROR | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + + il4965_txq_ctx_stop(il); + il4965_rxq_stop(il); + + /* Power-down device's busmaster DMA clocks */ + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + udelay(5); + + /* Make sure (redundant) we've released our request to stay awake */ + il_clear_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + + /* Stop the device, and put it in low power state */ + il_apm_stop(il); + + exit: + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); + + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; + + /* clear out any free frames */ + il4965_clear_free_frames(il); +} + +static void il4965_down(struct il_priv *il) +{ + mutex_lock(&il->mutex); + __il4965_down(il); + mutex_unlock(&il->mutex); + + il4965_cancel_deferred_work(il); +} + +#define HW_READY_TIMEOUT (50) + +static int il4965_set_hw_ready(struct il_priv *il) +{ + int ret = 0; + + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); + + /* See if we got it */ + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, + HW_READY_TIMEOUT); + if (ret != -ETIMEDOUT) + il->hw_ready = true; + else + il->hw_ready = false; + + D_INFO("hardware %s\n", + (il->hw_ready == 1) ? "ready" : "not ready"); + return ret; +} + +static int il4965_prepare_card_hw(struct il_priv *il) +{ + int ret = 0; + + D_INFO("il4965_prepare_card_hw enter\n"); + + ret = il4965_set_hw_ready(il); + if (il->hw_ready) + return ret; + + /* If HW is not ready, prepare the conditions to check again */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_PREPARE); + + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, + CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); + + /* HW should be ready by now, check again. */ + if (ret != -ETIMEDOUT) + il4965_set_hw_ready(il); + + return ret; +} + +#define MAX_HW_RESTARTS 5 + +static int __il4965_up(struct il_priv *il) +{ + int i; + int ret; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN("Exit pending; will not bring the NIC up\n"); + return -EIO; + } + + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR("ucode not available for device bringup\n"); + return -EIO; + } + + ret = il4965_alloc_bcast_station(il, &il->ctx); + if (ret) { + il_dealloc_bcast_stations(il); + return ret; + } + + il4965_prepare_card_hw(il); + + if (!il->hw_ready) { + IL_WARN("Exit HW not ready\n"); + return -EIO; + } + + /* If platform's RF_KILL switch is NOT set to KILL */ + if (_il_rd(il, + CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + clear_bit(STATUS_RF_KILL_HW, &il->status); + else + set_bit(STATUS_RF_KILL_HW, &il->status); + + if (il_is_rfkill(il)) { + wiphy_rfkill_set_hw_state(il->hw->wiphy, true); + + il_enable_interrupts(il); + IL_WARN("Radio disabled by HW RF Kill switch\n"); + return 0; + } + + _il_wr(il, CSR_INT, 0xFFFFFFFF); + + /* must be initialised before il_hw_nic_init */ + il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; + + ret = il4965_hw_nic_init(il); + if (ret) { + IL_ERR("Unable to init nic\n"); + return ret; + } + + /* make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + /* clear (again), then enable host interrupts */ + _il_wr(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); + + /* really make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + + /* Copy original ucode data image from disk into backup cache. + * This will be used to initialize the on-board processor's + * data SRAM for a clean start when the runtime program first loads. */ + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); + + for (i = 0; i < MAX_HW_RESTARTS; i++) { + + /* load bootstrap state machine, + * load bootstrap program into processor's memory, + * prepare to load the "initialize" uCode */ + ret = il->cfg->ops->lib->load_ucode(il); + + if (ret) { + IL_ERR("Unable to set up bootstrap uCode: %d\n", + ret); + continue; + } + + /* start card; "initialize" will load runtime ucode */ + il4965_nic_start(il); + + D_INFO(DRV_NAME " is coming up\n"); + + return 0; + } + + set_bit(STATUS_EXIT_PENDING, &il->status); + __il4965_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* tried to restart and config the device for as long as our + * patience could withstand */ + IL_ERR("Unable to initialize device after %d attempts.\n", i); + return -EIO; +} + + +/***************************************************************************** + * + * Workqueue callbacks + * + *****************************************************************************/ + +static void il4965_bg_init_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, init_alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il->cfg->ops->lib->init_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +static void il4965_bg_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il4965_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +static void il4965_bg_run_time_calib_work(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, + run_time_calib_work); + + mutex_lock(&il->mutex); + + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) { + mutex_unlock(&il->mutex); + return; + } + + if (il->start_calib) { + il4965_chain_noise_calibration(il, + (void *)&il->_4965.stats); + il4965_sensitivity_calibration(il, + (void *)&il->_4965.stats); + } + + mutex_unlock(&il->mutex); +} + +static void il4965_bg_restart(struct work_struct *data) +{ + struct il_priv *il = container_of(data, struct il_priv, restart); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + mutex_lock(&il->mutex); + il->ctx.vif = NULL; + il->is_open = 0; + + __il4965_down(il); + + mutex_unlock(&il->mutex); + il4965_cancel_deferred_work(il); + ieee80211_restart_hw(il->hw); + } else { + il4965_down(il); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); + return; + } + + __il4965_up(il); + mutex_unlock(&il->mutex); + } +} + +static void il4965_bg_rx_replenish(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, rx_replenish); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + mutex_lock(&il->mutex); + il4965_rx_replenish(il); + mutex_unlock(&il->mutex); +} + +/***************************************************************************** + * + * mac80211 entry point functions + * + *****************************************************************************/ + +#define UCODE_READY_TIMEOUT (4 * HZ) + +/* + * Not a mac80211 entry point function, but it fits in with all the + * other mac80211 functions grouped here. + */ +static int il4965_mac_setup_register(struct il_priv *il, + u32 max_probe_length) +{ + int ret; + struct ieee80211_hw *hw = il->hw; + + hw->rate_control_algorithm = "iwl-4965-rs"; + + /* Tell mac80211 our characteristics */ + hw->flags = IEEE80211_HW_SIGNAL_DBM | + IEEE80211_HW_AMPDU_AGGREGATION | + IEEE80211_HW_NEED_DTIM_PERIOD | + IEEE80211_HW_SPECTRUM_MGMT | + IEEE80211_HW_REPORTS_TX_ACK_STATUS; + + if (il->cfg->sku & IL_SKU_N) + hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | + IEEE80211_HW_SUPPORTS_STATIC_SMPS; + + hw->sta_data_size = sizeof(struct il_station_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); + + hw->wiphy->interface_modes |= il->ctx.interface_modes; + hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; + + hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | + WIPHY_FLAG_DISABLE_BEACON_HINTS; + + /* + * For now, disable PS by default because it affects + * RX performance significantly. + */ + hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + + hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; + /* we create the 802.11 header and a zero-length SSID element */ + hw->wiphy->max_scan_ie_len = max_probe_length - 24 - 2; + + /* Default value; 4 EDCA QOS priorities */ + hw->queues = 4; + + hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; + + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; + + il_leds_init(il); + + ret = ieee80211_register_hw(il->hw); + if (ret) { + IL_ERR("Failed to register hw (error %d)\n", ret); + return ret; + } + il->mac80211_registered = 1; + + return 0; +} + + +int il4965_mac_start(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + int ret; + + D_MAC80211("enter\n"); + + /* we should be verifying the device is ready to be opened */ + mutex_lock(&il->mutex); + ret = __il4965_up(il); + mutex_unlock(&il->mutex); + + if (ret) + return ret; + + if (il_is_rfkill(il)) + goto out; + + D_INFO("Start UP work done.\n"); + + /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from + * mac80211 will not be run successfully. */ + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), + UCODE_READY_TIMEOUT); + if (!ret) { + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR("START_ALIVE timeout after %dms.\n", + jiffies_to_msecs(UCODE_READY_TIMEOUT)); + return -ETIMEDOUT; + } + } + + il4965_led_enable(il); + +out: + il->is_open = 1; + D_MAC80211("leave\n"); + return 0; +} + +void il4965_mac_stop(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + + D_MAC80211("enter\n"); + + if (!il->is_open) + return; + + il->is_open = 0; + + il4965_down(il); + + flush_workqueue(il->workqueue); + + /* User space software may expect getting rfkill changes + * even if interface is down */ + _il_wr(il, CSR_INT, 0xFFFFFFFF); + il_enable_rfkill_int(il); + + D_MAC80211("leave\n"); +} + +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct il_priv *il = hw->priv; + + D_MACDUMP("enter\n"); + + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + + if (il4965_tx_skb(il, skb)) + dev_kfree_skb_any(skb); + + D_MACDUMP("leave\n"); +} + +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, + u32 iv32, u16 *phase1key) +{ + struct il_priv *il = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + + D_MAC80211("enter\n"); + + il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, + iv32, phase1key); + + D_MAC80211("leave\n"); +} + +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + struct il_priv *il = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_rxon_context *ctx = vif_priv->ctx; + int ret; + u8 sta_id; + bool is_default_wep_key = false; + + D_MAC80211("enter\n"); + + if (il->cfg->mod_params->sw_crypto) { + D_MAC80211("leave - hwcrypto disabled\n"); + return -EOPNOTSUPP; + } + + sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); + if (sta_id == IL_INVALID_STATION) + return -EINVAL; + + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); + + /* + * If we are getting WEP group key and we didn't receive any key mapping + * so far, we are in legacy wep mode (group key only), otherwise we are + * in 1X mode. + * In legacy wep mode, we use another host command to the uCode. + */ + if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) && + !sta) { + if (cmd == SET_KEY) + is_default_wep_key = !ctx->key_mapping_keys; + else + is_default_wep_key = + (key->hw_key_idx == HW_KEY_DEFAULT); + } + + switch (cmd) { + case SET_KEY: + if (is_default_wep_key) + ret = il4965_set_default_wep_key(il, + vif_priv->ctx, key); + else + ret = il4965_set_dynamic_key(il, vif_priv->ctx, + key, sta_id); + + D_MAC80211("enable hwcrypto key\n"); + break; + case DISABLE_KEY: + if (is_default_wep_key) + ret = il4965_remove_default_wep_key(il, ctx, key); + else + ret = il4965_remove_dynamic_key(il, ctx, + key, sta_id); + + D_MAC80211("disable hwcrypto key\n"); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&il->mutex); + D_MAC80211("leave\n"); + + return ret; +} + +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size) +{ + struct il_priv *il = hw->priv; + int ret = -EINVAL; + + D_HT("A-MPDU action on addr %pM tid %d\n", + sta->addr, tid); + + if (!(il->cfg->sku & IL_SKU_N)) + return -EACCES; + + mutex_lock(&il->mutex); + + switch (action) { + case IEEE80211_AMPDU_RX_START: + D_HT("start Rx\n"); + ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); + break; + case IEEE80211_AMPDU_RX_STOP: + D_HT("stop Rx\n"); + ret = il4965_sta_rx_agg_stop(il, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + ret = 0; + break; + case IEEE80211_AMPDU_TX_START: + D_HT("start Tx\n"); + ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); + break; + case IEEE80211_AMPDU_TX_STOP: + D_HT("stop Tx\n"); + ret = il4965_tx_agg_stop(il, vif, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + ret = 0; + break; + case IEEE80211_AMPDU_TX_OPERATIONAL: + ret = 0; + break; + } + mutex_unlock(&il->mutex); + + return ret; +} + +int il4965_mac_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct il_priv *il = hw->priv; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + bool is_ap = vif->type == NL80211_IFTYPE_STATION; + int ret; + u8 sta_id; + + D_INFO("received request to add station %pM\n", + sta->addr); + mutex_lock(&il->mutex); + D_INFO("proceeding to add station %pM\n", + sta->addr); + sta_priv->common.sta_id = IL_INVALID_STATION; + + atomic_set(&sta_priv->pending_frames, 0); + + ret = il_add_station_common(il, vif_priv->ctx, sta->addr, + is_ap, sta, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM (%d)\n", + sta->addr, ret); + /* Should we return success if return code is EEXIST ? */ + mutex_unlock(&il->mutex); + return ret; + } + + sta_priv->common.sta_id = sta_id; + + /* Initialize rate scaling */ + D_INFO("Initializing rate scaling for station %pM\n", + sta->addr); + il4965_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); + + return 0; +} + +void il4965_mac_channel_switch(struct ieee80211_hw *hw, + struct ieee80211_channel_switch *ch_switch) +{ + struct il_priv *il = hw->priv; + const struct il_channel_info *ch_info; + struct ieee80211_conf *conf = &hw->conf; + struct ieee80211_channel *channel = ch_switch->channel; + struct il_ht_config *ht_conf = &il->current_ht_config; + + struct il_rxon_context *ctx = &il->ctx; + u16 ch; + + D_MAC80211("enter\n"); + + mutex_lock(&il->mutex); + + if (il_is_rfkill(il)) + goto out; + + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status) || + test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + goto out; + + if (!il_is_associated_ctx(ctx)) + goto out; + + if (!il->cfg->ops->lib->set_channel_switch) + goto out; + + ch = channel->hw_value; + if (le16_to_cpu(ctx->active.channel) == ch) + goto out; + + ch_info = il_get_channel_info(il, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + D_MAC80211("invalid channel\n"); + goto out; + } + + spin_lock_irq(&il->lock); + + il->current_ht_config.smps = conf->smps_mode; + + /* Configure HT40 channels */ + ctx->ht.enabled = conf_is_ht(conf); + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; + + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; + + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); + + spin_unlock_irq(&il->lock); + + il_set_rate(il); + /* + * at this point, staging_rxon has the + * configuration for channel switch + */ + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = cpu_to_le16(ch); + if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = 0; + ieee80211_chswitch_done(ctx->vif, false); + } + +out: + mutex_unlock(&il->mutex); + D_MAC80211("leave\n"); +} + +void il4965_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 multicast) +{ + struct il_priv *il = hw->priv; + __le32 filter_or = 0, filter_nand = 0; + +#define CHK(test, flag) do { \ + if (*total_flags & (test)) \ + filter_or |= (flag); \ + else \ + filter_nand |= (flag); \ + } while (0) + + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", + changed_flags, *total_flags); + + CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); + /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ + CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); + CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); + +#undef CHK + + mutex_lock(&il->mutex); + + il->ctx.staging.filter_flags &= ~filter_nand; + il->ctx.staging.filter_flags |= filter_or; + + /* + * Not committing directly because hardware can perform a scan, + * but we'll eventually commit the filter flags change anyway. + */ + + mutex_unlock(&il->mutex); + + /* + * Receiving all multicast frames is always enabled by the + * default flags setup in il_connection_init_rx_config() + * since we currently do not support programming multicast + * filters into the device. + */ + *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; +} + +/***************************************************************************** + * + * driver setup and teardown + * + *****************************************************************************/ + +static void il4965_bg_txpower_work(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, + txpower_work); + + mutex_lock(&il->mutex); + + /* If a scan happened to start before we got here + * then just return; the stats notification will + * kick off another scheduled work to compensate for + * any temperature delta we missed here. */ + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) + goto out; + + /* Regardless of if we are associated, we must reconfigure the + * TX power since frames can be sent on non-radar channels while + * not associated */ + il->cfg->ops->lib->send_tx_power(il); + + /* Update last_temperature to keep is_calib_needed from running + * when it isn't needed... */ + il->last_temperature = il->temperature; +out: + mutex_unlock(&il->mutex); +} + +static void il4965_setup_deferred_work(struct il_priv *il) +{ + il->workqueue = create_singlethread_workqueue(DRV_NAME); + + init_waitqueue_head(&il->wait_command_queue); + + INIT_WORK(&il->restart, il4965_bg_restart); + INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); + INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); + INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); + + il_setup_scan_deferred_work(il); + + INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); + + init_timer(&il->stats_periodic); + il->stats_periodic.data = (unsigned long)il; + il->stats_periodic.function = il4965_bg_stats_periodic; + + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; + + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il4965_irq_tasklet, (unsigned long)il); +} + +static void il4965_cancel_deferred_work(struct il_priv *il) +{ + cancel_work_sync(&il->txpower_work); + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); + cancel_work_sync(&il->run_time_calib_work); + + il_cancel_scan_deferred_work(il); + + del_timer_sync(&il->stats_periodic); +} + +static void il4965_init_hw_rates(struct il_priv *il, + struct ieee80211_rate *rates) +{ + int i; + + for (i = 0; i < RATE_COUNT_LEGACY; i++) { + rates[i].bitrate = il_rates[i].ieee * 5; + rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value_short = i; + rates[i].flags = 0; + if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { + /* + * If CCK != 1M then set short preamble rate flag. + */ + rates[i].flags |= + (il_rates[i].plcp == RATE_1M_PLCP) ? + 0 : IEEE80211_RATE_SHORT_PREAMBLE; + } + } +} +/* + * Acquire il->lock before calling this function ! + */ +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) +{ + il_wr(il, HBUS_TARG_WRPTR, + (idx & 0xff) | (txq_id << 8)); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); +} + +void il4965_tx_queue_set_status(struct il_priv *il, + struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry) +{ + int txq_id = txq->q.id; + + /* Find out whether to activate Tx queue */ + int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; + + /* Set up and activate */ + il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | + IL49_SCD_QUEUE_STTS_REG_MSK); + + txq->sched_retry = scd_retry; + + D_INFO("%s %s Queue %d on AC %d\n", + active ? "Activate" : "Deactivate", + scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); +} + + +static int il4965_init_drv(struct il_priv *il) +{ + int ret; + + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); + + INIT_LIST_HEAD(&il->free_frames); + + mutex_init(&il->mutex); + + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; + + il->iw_mode = NL80211_IFTYPE_STATION; + il->current_ht_config.smps = IEEE80211_SMPS_STATIC; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + + /* initialize force reset */ + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + + /* Choose which receivers/antennas to use */ + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, + &il->ctx); + + il_init_scan_params(il); + + ret = il_init_channel_map(il); + if (ret) { + IL_ERR("initializing regulatory failed: %d\n", ret); + goto err; + } + + ret = il_init_geos(il); + if (ret) { + IL_ERR("initializing geos failed: %d\n", ret); + goto err_free_channel_map; + } + il4965_init_hw_rates(il, il->ieee_rates); + + return 0; + +err_free_channel_map: + il_free_channel_map(il); +err: + return ret; +} + +static void il4965_uninit_drv(struct il_priv *il) +{ + il4965_calib_free_results(il); + il_free_geos(il); + il_free_channel_map(il); + kfree(il->scan_cmd); +} + +static void il4965_hw_detect(struct il_priv *il) +{ + il->hw_rev = _il_rd(il, CSR_HW_REV); + il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); + il->rev_id = il->pci_dev->revision; + D_INFO("HW Revision ID = 0x%X\n", il->rev_id); +} + +static int il4965_set_hw_params(struct il_priv *il) +{ + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + if (il->cfg->mod_params->amsdu_size_8K) + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); + else + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); + + il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; + + if (il->cfg->mod_params->disable_11n) + il->cfg->sku &= ~IL_SKU_N; + + /* Device-specific setup */ + return il->cfg->ops->lib->set_hw_params(il); +} + +static const u8 il4965_bss_ac_to_fifo[] = { + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, +}; + +static const u8 il4965_bss_ac_to_queue[] = { + 0, 1, 2, 3, +}; + +static int +il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int err = 0; + struct il_priv *il; + struct ieee80211_hw *hw; + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); + unsigned long flags; + u16 pci_cmd; + + /************************ + * 1. Allocating HW data + ************************/ + + hw = il_alloc_all(cfg); + if (!hw) { + err = -ENOMEM; + goto out; + } + il = hw->priv; + /* At this point both hw and il are allocated. */ + + il->ctx.ctxid = 0; + + il->ctx.always_active = true; + il->ctx.is_active = true; + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; + il->ctx.ac_to_queue = il4965_bss_ac_to_queue; + il->ctx.exclusive_interface_modes = + BIT(NL80211_IFTYPE_ADHOC); + il->ctx.interface_modes = + BIT(NL80211_IFTYPE_STATION); + il->ctx.ap_devtype = RXON_DEV_TYPE_AP; + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; + + SET_IEEE80211_DEV(hw, &pdev->dev); + + D_INFO("*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; + + if (il_alloc_traffic_mem(il)) + IL_ERR("Not enough memory to generate traffic log\n"); + + /************************** + * 2. Initializing PCI bus + **************************/ + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); + + if (pci_enable_device(pdev)) { + err = -ENODEV; + goto out_ieee80211_free_hw; + } + + pci_set_master(pdev); + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); + if (err) { + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, + DMA_BIT_MASK(32)); + /* both attempts failed: */ + if (err) { + IL_WARN("No suitable DMA available.\n"); + goto out_pci_disable_device; + } + } + + err = pci_request_regions(pdev, DRV_NAME); + if (err) + goto out_pci_disable_device; + + pci_set_drvdata(pdev, il); + + + /*********************** + * 3. Read REV register + ***********************/ + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { + err = -ENODEV; + goto out_pci_release_regions; + } + + D_INFO("pci_resource_len = 0x%08llx\n", + (unsigned long long) pci_resource_len(pdev, 0)); + D_INFO("pci_resource_base = %p\n", il->hw_base); + + /* these spin locks will be used in apm_ops.init and EEPROM access + * we should init now + */ + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); + + /* + * stop and reset the on-board processor just in case it is in a + * strange state ... like being left stranded by a primary kernel + * and this is now the kdump kernel trying to start up + */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + il4965_hw_detect(il); + IL_INFO("Detected %s, REV=0x%X\n", + il->cfg->name, il->hw_rev); + + /* We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state */ + pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); + + il4965_prepare_card_hw(il); + if (!il->hw_ready) { + IL_WARN("Failed, HW not ready\n"); + goto out_iounmap; + } + + /***************** + * 4. Read EEPROM + *****************/ + /* Read the EEPROM */ + err = il_eeprom_init(il); + if (err) { + IL_ERR("Unable to init EEPROM\n"); + goto out_iounmap; + } + err = il4965_eeprom_check_version(il); + if (err) + goto out_free_eeprom; + + if (err) + goto out_free_eeprom; + + /* extract MAC Address */ + il4965_eeprom_get_mac(il, il->addresses[0].addr); + D_INFO("MAC address: %pM\n", il->addresses[0].addr); + il->hw->wiphy->addresses = il->addresses; + il->hw->wiphy->n_addresses = 1; + + /************************ + * 5. Setup HW constants + ************************/ + if (il4965_set_hw_params(il)) { + IL_ERR("failed to set hw parameters\n"); + goto out_free_eeprom; + } + + /******************* + * 6. Setup il + *******************/ + + err = il4965_init_drv(il); + if (err) + goto out_free_eeprom; + /* At this point both hw and il are initialized. */ + + /******************** + * 7. Setup services + ********************/ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + pci_enable_msi(il->pci_dev); + + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); + if (err) { + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); + goto out_disable_msi; + } + + il4965_setup_deferred_work(il); + il4965_setup_rx_handlers(il); + + /********************************************* + * 8. Enable interrupts and read RFKILL state + *********************************************/ + + /* enable rfkill interrupt: hw bug w/a */ + pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); + if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { + pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; + pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); + } + + il_enable_rfkill_int(il); + + /* If platform's RF_KILL switch is NOT set to KILL */ + if (_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + clear_bit(STATUS_RF_KILL_HW, &il->status); + else + set_bit(STATUS_RF_KILL_HW, &il->status); + + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); + + il_power_initialize(il); + + init_completion(&il->_4965.firmware_loading_complete); + + err = il4965_request_firmware(il, true); + if (err) + goto out_destroy_workqueue; + + return 0; + + out_destroy_workqueue: + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + free_irq(il->pci_dev->irq, il); + out_disable_msi: + pci_disable_msi(il->pci_dev); + il4965_uninit_drv(il); + out_free_eeprom: + il_eeprom_free(il); + out_iounmap: + pci_iounmap(pdev, il->hw_base); + out_pci_release_regions: + pci_set_drvdata(pdev, NULL); + pci_release_regions(pdev); + out_pci_disable_device: + pci_disable_device(pdev); + out_ieee80211_free_hw: + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); + out: + return err; +} + +static void __devexit il4965_pci_remove(struct pci_dev *pdev) +{ + struct il_priv *il = pci_get_drvdata(pdev); + unsigned long flags; + + if (!il) + return; + + wait_for_completion(&il->_4965.firmware_loading_complete); + + D_INFO("*** UNLOAD DRIVER ***\n"); + + il_dbgfs_unregister(il); + sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); + + /* ieee80211_unregister_hw call wil cause il_mac_stop to + * to be called and il4965_down since we are removing the device + * we need to set STATUS_EXIT_PENDING bit. + */ + set_bit(STATUS_EXIT_PENDING, &il->status); + + il_leds_exit(il); + + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; + } else { + il4965_down(il); + } + + /* + * Make sure device is reset to low power before unloading driver. + * This may be redundant with il4965_down(), but there are paths to + * run il4965_down() without calling apm_ops.stop(), and there are + * paths to avoid running il4965_down() at all before leaving driver. + * This (inexpensive) call *makes sure* device is reset. + */ + il_apm_stop(il); + + /* make sure we flush any pending irq or + * tasklet for the driver + */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + il4965_synchronize_irq(il); + + il4965_dealloc_ucode_pci(il); + + if (il->rxq.bd) + il4965_rx_queue_free(il, &il->rxq); + il4965_hw_txq_ctx_free(il); + + il_eeprom_free(il); + + + /*netif_stop_queue(dev); */ + flush_workqueue(il->workqueue); + + /* ieee80211_unregister_hw calls il_mac_stop, which flushes + * il->workqueue... so we can't take down the workqueue + * until now... */ + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); + + free_irq(il->pci_dev->irq, il); + pci_disable_msi(il->pci_dev); + pci_iounmap(pdev, il->hw_base); + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + + il4965_uninit_drv(il); + + dev_kfree_skb(il->beacon_skb); + + ieee80211_free_hw(il->hw); +} + +/* + * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask + * must be called under il->lock and mac access + */ +void il4965_txq_set_sched(struct il_priv *il, u32 mask) +{ + il_wr_prph(il, IL49_SCD_TXFACT, mask); +} + +/***************************************************************************** + * + * driver and module entry point + * + *****************************************************************************/ + +/* Hardware specific file defines the PCI IDs table for that hardware module */ +static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { + {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, + {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, + {0} +}; +MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); + +static struct pci_driver il4965_driver = { + .name = DRV_NAME, + .id_table = il4965_hw_card_ids, + .probe = il4965_pci_probe, + .remove = __devexit_p(il4965_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, +}; + +static int __init il4965_init(void) +{ + + int ret; + pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); + pr_info(DRV_COPYRIGHT "\n"); + + ret = il4965_rate_control_register(); + if (ret) { + pr_err("Unable to register rate control algorithm: %d\n", ret); + return ret; + } + + ret = pci_register_driver(&il4965_driver); + if (ret) { + pr_err("Unable to initialize PCI module\n"); + goto error_register; + } + + return ret; + +error_register: + il4965_rate_control_unregister(); + return ret; +} + +static void __exit il4965_exit(void) +{ + pci_unregister_driver(&il4965_driver); + il4965_rate_control_unregister(); +} + +module_exit(il4965_exit); +module_init(il4965_init); + +#ifdef CONFIG_IWLEGACY_DEBUG +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(debug, "debug output mask"); +#endif + +module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO); +MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); +module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); +MODULE_PARM_DESC(queues_num, "number of hw queues."); +module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); +MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); +module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, + int, S_IRUGO); +MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); +module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); +MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c new file mode 100644 index 0000000..bdfb3a6 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -0,0 +1,2183 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iwl-eeprom.h" +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-helpers.h" +#include "iwl-4965-calib.h" +#include "iwl-sta.h" +#include "iwl-4965-led.h" +#include "iwl-4965.h" +#include "iwl-4965-debugfs.h" + +static int il4965_send_tx_power(struct il_priv *il); +static int il4965_hw_get_temperature(struct il_priv *il); + +/* Highest firmware API version supported */ +#define IL4965_UCODE_API_MAX 2 + +/* Lowest firmware API version supported */ +#define IL4965_UCODE_API_MIN 2 + +#define IL4965_FW_PRE "iwlwifi-4965-" +#define _IL4965_MODULE_FIRMWARE(api) IL4965_FW_PRE #api ".ucode" +#define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) + +/* check contents of special bootstrap uCode SRAM */ +static int il4965_verify_bsm(struct il_priv *il) +{ + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + u32 reg; + u32 val; + + D_INFO("Begin verify bsm\n"); + + /* verify BSM SRAM contents */ + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); + for (reg = BSM_SRAM_LOWER_BOUND; + reg < BSM_SRAM_LOWER_BOUND + len; + reg += sizeof(u32), image++) { + val = il_rd_prph(il, reg); + if (val != le32_to_cpu(*image)) { + IL_ERR("BSM uCode verification failed at " + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, + reg - BSM_SRAM_LOWER_BOUND, len, + val, le32_to_cpu(*image)); + return -EIO; + } + } + + D_INFO("BSM bootstrap uCode image OK\n"); + + return 0; +} + +/** + * il4965_load_bsm - Load bootstrap instructions + * + * BSM operation: + * + * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program + * in special SRAM that does not power down during RFKILL. When powering back + * up after power-saving sleeps (or during initial uCode load), the BSM loads + * the bootstrap program into the on-board processor, and starts it. + * + * The bootstrap program loads (via DMA) instructions and data for a new + * program from host DRAM locations indicated by the host driver in the + * BSM_DRAM_* registers. Once the new program is loaded, it starts + * automatically. + * + * When initializing the NIC, the host driver points the BSM to the + * "initialize" uCode image. This uCode sets up some internal data, then + * notifies host via "initialize alive" that it is complete. + * + * The host then replaces the BSM_DRAM_* pointer values to point to the + * normal runtime uCode instructions and a backup uCode data cache buffer + * (filled initially with starting data values for the on-board processor), + * then triggers the "initialize" uCode to load and launch the runtime uCode, + * which begins normal operation. + * + * When doing a power-save shutdown, runtime uCode saves data SRAM into + * the backup data cache in DRAM before SRAM is powered down. + * + * When powering back up, the BSM loads the bootstrap program. This reloads + * the runtime uCode instructions and the backup data cache into SRAM, + * and re-launches the runtime uCode from where it left off. + */ +static int il4965_load_bsm(struct il_priv *il) +{ + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + dma_addr_t pinst; + dma_addr_t pdata; + u32 inst_len; + u32 data_len; + int i; + u32 done; + u32 reg_offset; + int ret; + + D_INFO("Begin load bsm\n"); + + il->ucode_type = UCODE_RT; + + /* make sure bootstrap program is no larger than BSM's SRAM size */ + if (len > IL49_MAX_BSM_SIZE) + return -EINVAL; + + /* Tell bootstrap uCode where to find the "Initialize" uCode + * in host DRAM ... host DRAM physical address bits 35:4 for 4965. + * NOTE: il_init_alive_start() will replace these values, + * after the "initialize" uCode has run, to point to + * runtime/protocol instructions and backup data cache. + */ + pinst = il->ucode_init.p_addr >> 4; + pdata = il->ucode_init_data.p_addr >> 4; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; + + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + + /* Fill BSM memory with bootstrap instructions */ + for (reg_offset = BSM_SRAM_LOWER_BOUND; + reg_offset < BSM_SRAM_LOWER_BOUND + len; + reg_offset += sizeof(u32), image++) + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); + + ret = il4965_verify_bsm(il); + if (ret) + return ret; + + /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, + BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + + /* Load bootstrap code into instruction SRAM now, + * to prepare to load "initialize" uCode */ + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + + /* Wait for load of bootstrap uCode to finish */ + for (i = 0; i < 100; i++) { + done = il_rd_prph(il, BSM_WR_CTRL_REG); + if (!(done & BSM_WR_CTRL_REG_BIT_START)) + break; + udelay(10); + } + if (i < 100) + D_INFO("BSM write complete, poll %d iterations\n", i); + else { + IL_ERR("BSM write did not complete!\n"); + return -EIO; + } + + /* Enable future boot loads whenever power management unit triggers it + * (e.g. when powering back up after power-save shutdown) */ + il_wr_prph(il, + BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); + + + return 0; +} + +/** + * il4965_set_ucode_ptrs - Set uCode address location + * + * Tell initialization uCode where to find runtime uCode. + * + * BSM registers initially contain pointers to initialization uCode. + * We need to replace them to load runtime uCode inst and data, + * and to save runtime data when powering down. + */ +static int il4965_set_ucode_ptrs(struct il_priv *il) +{ + dma_addr_t pinst; + dma_addr_t pdata; + int ret = 0; + + /* bits 35:4 for 4965 */ + pinst = il->ucode_code.p_addr >> 4; + pdata = il->ucode_data_backup.p_addr >> 4; + + /* Tell bootstrap uCode where to find image to load */ + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); + + /* Inst byte count must be last to set up, bit 31 signals uCode + * that all new ptr/size info is in place */ + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); + D_INFO("Runtime uCode pointers are set.\n"); + + return ret; +} + +/** + * il4965_init_alive_start - Called after REPLY_ALIVE notification received + * + * Called after REPLY_ALIVE notification received from "initialize" uCode. + * + * The 4965 "initialize" ALIVE reply contains calibration data for: + * Voltage, temperature, and MIMO tx gain correction, now stored in il + * (3945 does not contain this data). + * + * Tell "initialize" uCode to go ahead and load the runtime uCode. +*/ +static void il4965_init_alive_start(struct il_priv *il) +{ + /* Bootstrap uCode has loaded initialize uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "initialize" alive if code weren't properly loaded. */ + if (il4965_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad \"initialize\" uCode load.\n"); + goto restart; + } + + /* Calculate temperature */ + il->temperature = il4965_hw_get_temperature(il); + + /* Send pointers to protocol/runtime uCode image ... init code will + * load and launch runtime uCode, which will send us another "Alive" + * notification. */ + D_INFO("Initialization Alive received.\n"); + if (il4965_set_ucode_ptrs(il)) { + /* Runtime instruction load won't happen; + * take it all the way back down so we can try again */ + D_INFO("Couldn't set up uCode pointers.\n"); + goto restart; + } + return; + +restart: + queue_work(il->workqueue, &il->restart); +} + +static bool iw4965_is_ht40_channel(__le32 rxon_flags) +{ + int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) + >> RXON_FLG_CHANNEL_MODE_POS; + return (chan_mod == CHANNEL_MODE_PURE_40 || + chan_mod == CHANNEL_MODE_MIXED); +} + +static void il4965_nic_config(struct il_priv *il) +{ + unsigned long flags; + u16 radio_cfg; + + spin_lock_irqsave(&il->lock, flags); + + radio_cfg = il_eeprom_query16(il, EEPROM_RADIO_CONFIG); + + /* write radio config values to register */ + if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | + EEPROM_RF_CFG_STEP_MSK(radio_cfg) | + EEPROM_RF_CFG_DASH_MSK(radio_cfg)); + + /* set CSR_HW_CONFIG_REG for uCode use */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | + CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); + + il->calib_info = (struct il_eeprom_calib_info *) + il_eeprom_query_addr(il, + EEPROM_4965_CALIB_TXPOWER_OFFSET); + + spin_unlock_irqrestore(&il->lock, flags); +} + +/* Reset differential Rx gains in NIC to prepare for chain noise calibration. + * Called after every association, but this runs only once! + * ... once chain noise is calibrated the first time, it's good forever. */ +static void il4965_chain_noise_reset(struct il_priv *il) +{ + struct il_chain_noise_data *data = &(il->chain_noise_data); + + if (data->state == IL_CHAIN_NOISE_ALIVE && + il_is_any_associated(il)) { + struct il_calib_diff_gain_cmd cmd; + + /* clear data for chain noise calibration algorithm */ + data->chain_noise_a = 0; + data->chain_noise_b = 0; + data->chain_noise_c = 0; + data->chain_signal_a = 0; + data->chain_signal_b = 0; + data->chain_signal_c = 0; + data->beacon_count = 0; + + memset(&cmd, 0, sizeof(cmd)); + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.diff_gain_a = 0; + cmd.diff_gain_b = 0; + cmd.diff_gain_c = 0; + if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + sizeof(cmd), &cmd)) + IL_ERR( + "Could not send REPLY_PHY_CALIBRATION_CMD\n"); + data->state = IL_CHAIN_NOISE_ACCUMULATE; + D_CALIB("Run chain_noise_calibrate\n"); + } +} + +static struct il_sensitivity_ranges il4965_sensitivity = { + .min_nrg_cck = 97, + .max_nrg_cck = 0, /* not used, set to 0 */ + + .auto_corr_min_ofdm = 85, + .auto_corr_min_ofdm_mrc = 170, + .auto_corr_min_ofdm_x1 = 105, + .auto_corr_min_ofdm_mrc_x1 = 220, + + .auto_corr_max_ofdm = 120, + .auto_corr_max_ofdm_mrc = 210, + .auto_corr_max_ofdm_x1 = 140, + .auto_corr_max_ofdm_mrc_x1 = 270, + + .auto_corr_min_cck = 125, + .auto_corr_max_cck = 200, + .auto_corr_min_cck_mrc = 200, + .auto_corr_max_cck_mrc = 400, + + .nrg_th_cck = 100, + .nrg_th_ofdm = 100, + + .barker_corr_th_min = 190, + .barker_corr_th_min_mrc = 390, + .nrg_th_cca = 62, +}; + +static void il4965_set_ct_threshold(struct il_priv *il) +{ + /* want Kelvin */ + il->hw_params.ct_kill_threshold = + CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); +} + +/** + * il4965_hw_set_hw_params + * + * Called when initializing driver + */ +static int il4965_hw_set_hw_params(struct il_priv *il) +{ + if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && + il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) + il->cfg->base_params->num_of_queues = + il->cfg->mod_params->num_of_queues; + + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; + il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; + il->hw_params.scd_bc_tbls_size = + il->cfg->base_params->num_of_queues * + sizeof(struct il4965_scd_bc_tbl); + il->hw_params.tfd_size = sizeof(struct il_tfd); + il->hw_params.max_stations = IL4965_STATION_COUNT; + il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; + il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; + il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; + il->hw_params.max_bsm_size = BSM_SRAM_SIZE; + il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); + + il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; + + il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); + il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); + il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; + il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; + + il4965_set_ct_threshold(il); + + il->hw_params.sens = &il4965_sensitivity; + il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; + + return 0; +} + +static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) +{ + s32 sign = 1; + + if (num < 0) { + sign = -sign; + num = -num; + } + if (denom < 0) { + sign = -sign; + denom = -denom; + } + *res = 1; + *res = ((num * 2 + denom) / (denom * 2)) * sign; + + return 1; +} + +/** + * il4965_get_voltage_compensation - Power supply voltage comp for txpower + * + * Determines power supply voltage compensation for txpower calculations. + * Returns number of 1/2-dB steps to subtract from gain table idx, + * to compensate for difference between power supply voltage during + * factory measurements, vs. current power supply voltage. + * + * Voltage indication is higher for lower voltage. + * Lower voltage requires more gain (lower gain table idx). + */ +static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, + s32 current_voltage) +{ + s32 comp = 0; + + if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage || + TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage) + return 0; + + il4965_math_div_round(current_voltage - eeprom_voltage, + TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); + + if (current_voltage > eeprom_voltage) + comp *= 2; + if ((comp < -2) || (comp > 2)) + comp = 0; + + return comp; +} + +static s32 il4965_get_tx_atten_grp(u16 channel) +{ + if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && + channel <= CALIB_IL_TX_ATTEN_GR5_LCH) + return CALIB_CH_GROUP_5; + + if (channel >= CALIB_IL_TX_ATTEN_GR1_FCH && + channel <= CALIB_IL_TX_ATTEN_GR1_LCH) + return CALIB_CH_GROUP_1; + + if (channel >= CALIB_IL_TX_ATTEN_GR2_FCH && + channel <= CALIB_IL_TX_ATTEN_GR2_LCH) + return CALIB_CH_GROUP_2; + + if (channel >= CALIB_IL_TX_ATTEN_GR3_FCH && + channel <= CALIB_IL_TX_ATTEN_GR3_LCH) + return CALIB_CH_GROUP_3; + + if (channel >= CALIB_IL_TX_ATTEN_GR4_FCH && + channel <= CALIB_IL_TX_ATTEN_GR4_LCH) + return CALIB_CH_GROUP_4; + + return -EINVAL; +} + +static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) +{ + s32 b = -1; + + for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { + if (il->calib_info->band_info[b].ch_from == 0) + continue; + + if (channel >= il->calib_info->band_info[b].ch_from && + channel <= il->calib_info->band_info[b].ch_to) + break; + } + + return b; +} + +static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) +{ + s32 val; + + if (x2 == x1) + return y1; + else { + il4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); + return val + y2; + } +} + +/** + * il4965_interpolate_chan - Interpolate factory measurements for one channel + * + * Interpolates factory measurements from the two sample channels within a + * sub-band, to apply to channel of interest. Interpolation is proportional to + * differences in channel frequencies, which is proportional to differences + * in channel number. + */ +static int il4965_interpolate_chan(struct il_priv *il, u32 channel, + struct il_eeprom_calib_ch_info *chan_info) +{ + s32 s = -1; + u32 c; + u32 m; + const struct il_eeprom_calib_measure *m1; + const struct il_eeprom_calib_measure *m2; + struct il_eeprom_calib_measure *omeas; + u32 ch_i1; + u32 ch_i2; + + s = il4965_get_sub_band(il, channel); + if (s >= EEPROM_TX_POWER_BANDS) { + IL_ERR("Tx Power can not find channel %d\n", channel); + return -1; + } + + ch_i1 = il->calib_info->band_info[s].ch1.ch_num; + ch_i2 = il->calib_info->band_info[s].ch2.ch_num; + chan_info->ch_num = (u8) channel; + + D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", + channel, s, ch_i1, ch_i2); + + for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { + for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { + m1 = &(il->calib_info->band_info[s].ch1. + measurements[c][m]); + m2 = &(il->calib_info->band_info[s].ch2. + measurements[c][m]); + omeas = &(chan_info->measurements[c][m]); + + omeas->actual_pow = + (u8) il4965_interpolate_value(channel, ch_i1, + m1->actual_pow, + ch_i2, + m2->actual_pow); + omeas->gain_idx = + (u8) il4965_interpolate_value(channel, ch_i1, + m1->gain_idx, ch_i2, + m2->gain_idx); + omeas->temperature = + (u8) il4965_interpolate_value(channel, ch_i1, + m1->temperature, + ch_i2, + m2->temperature); + omeas->pa_det = + (s8) il4965_interpolate_value(channel, ch_i1, + m1->pa_det, ch_i2, + m2->pa_det); + + D_TXPOWER( + "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, + m1->actual_pow, m2->actual_pow, omeas->actual_pow); + D_TXPOWER( + "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, + m1->gain_idx, m2->gain_idx, omeas->gain_idx); + D_TXPOWER( + "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, + m1->pa_det, m2->pa_det, omeas->pa_det); + D_TXPOWER( + "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, + m1->temperature, m2->temperature, + omeas->temperature); + } + } + + return 0; +} + +/* bit-rate-dependent table to prevent Tx distortion, in half-dB units, + * for OFDM 6, 12, 18, 24, 36, 48, 54, 60 MBit, and CCK all rates. */ +static s32 back_off_table[] = { + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 20 MHz */ + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 20 MHz */ + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 40 MHz */ + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 40 MHz */ + 10 /* CCK */ +}; + +/* Thermal compensation values for txpower for various frequency ranges ... + * ratios from 3:1 to 4.5:1 of degrees (Celsius) per half-dB gain adjust */ +static struct il4965_txpower_comp_entry { + s32 degrees_per_05db_a; + s32 degrees_per_05db_a_denom; +} tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { + {9, 2}, /* group 0 5.2, ch 34-43 */ + {4, 1}, /* group 1 5.2, ch 44-70 */ + {4, 1}, /* group 2 5.2, ch 71-124 */ + {4, 1}, /* group 3 5.2, ch 125-200 */ + {3, 1} /* group 4 2.4, ch all */ +}; + +static s32 get_min_power_idx(s32 rate_power_idx, u32 band) +{ + if (!band) { + if ((rate_power_idx & 7) <= 4) + return MIN_TX_GAIN_IDX_52GHZ_EXT; + } + return MIN_TX_GAIN_IDX; +} + +struct gain_entry { + u8 dsp; + u8 radio; +}; + +static const struct gain_entry gain_table[2][108] = { + /* 5.2GHz power gain idx table */ + { + {123, 0x3F}, /* highest txpower */ + {117, 0x3F}, + {110, 0x3F}, + {104, 0x3F}, + {98, 0x3F}, + {110, 0x3E}, + {104, 0x3E}, + {98, 0x3E}, + {110, 0x3D}, + {104, 0x3D}, + {98, 0x3D}, + {110, 0x3C}, + {104, 0x3C}, + {98, 0x3C}, + {110, 0x3B}, + {104, 0x3B}, + {98, 0x3B}, + {110, 0x3A}, + {104, 0x3A}, + {98, 0x3A}, + {110, 0x39}, + {104, 0x39}, + {98, 0x39}, + {110, 0x38}, + {104, 0x38}, + {98, 0x38}, + {110, 0x37}, + {104, 0x37}, + {98, 0x37}, + {110, 0x36}, + {104, 0x36}, + {98, 0x36}, + {110, 0x35}, + {104, 0x35}, + {98, 0x35}, + {110, 0x34}, + {104, 0x34}, + {98, 0x34}, + {110, 0x33}, + {104, 0x33}, + {98, 0x33}, + {110, 0x32}, + {104, 0x32}, + {98, 0x32}, + {110, 0x31}, + {104, 0x31}, + {98, 0x31}, + {110, 0x30}, + {104, 0x30}, + {98, 0x30}, + {110, 0x25}, + {104, 0x25}, + {98, 0x25}, + {110, 0x24}, + {104, 0x24}, + {98, 0x24}, + {110, 0x23}, + {104, 0x23}, + {98, 0x23}, + {110, 0x22}, + {104, 0x18}, + {98, 0x18}, + {110, 0x17}, + {104, 0x17}, + {98, 0x17}, + {110, 0x16}, + {104, 0x16}, + {98, 0x16}, + {110, 0x15}, + {104, 0x15}, + {98, 0x15}, + {110, 0x14}, + {104, 0x14}, + {98, 0x14}, + {110, 0x13}, + {104, 0x13}, + {98, 0x13}, + {110, 0x12}, + {104, 0x08}, + {98, 0x08}, + {110, 0x07}, + {104, 0x07}, + {98, 0x07}, + {110, 0x06}, + {104, 0x06}, + {98, 0x06}, + {110, 0x05}, + {104, 0x05}, + {98, 0x05}, + {110, 0x04}, + {104, 0x04}, + {98, 0x04}, + {110, 0x03}, + {104, 0x03}, + {98, 0x03}, + {110, 0x02}, + {104, 0x02}, + {98, 0x02}, + {110, 0x01}, + {104, 0x01}, + {98, 0x01}, + {110, 0x00}, + {104, 0x00}, + {98, 0x00}, + {93, 0x00}, + {88, 0x00}, + {83, 0x00}, + {78, 0x00}, + }, + /* 2.4GHz power gain idx table */ + { + {110, 0x3f}, /* highest txpower */ + {104, 0x3f}, + {98, 0x3f}, + {110, 0x3e}, + {104, 0x3e}, + {98, 0x3e}, + {110, 0x3d}, + {104, 0x3d}, + {98, 0x3d}, + {110, 0x3c}, + {104, 0x3c}, + {98, 0x3c}, + {110, 0x3b}, + {104, 0x3b}, + {98, 0x3b}, + {110, 0x3a}, + {104, 0x3a}, + {98, 0x3a}, + {110, 0x39}, + {104, 0x39}, + {98, 0x39}, + {110, 0x38}, + {104, 0x38}, + {98, 0x38}, + {110, 0x37}, + {104, 0x37}, + {98, 0x37}, + {110, 0x36}, + {104, 0x36}, + {98, 0x36}, + {110, 0x35}, + {104, 0x35}, + {98, 0x35}, + {110, 0x34}, + {104, 0x34}, + {98, 0x34}, + {110, 0x33}, + {104, 0x33}, + {98, 0x33}, + {110, 0x32}, + {104, 0x32}, + {98, 0x32}, + {110, 0x31}, + {104, 0x31}, + {98, 0x31}, + {110, 0x30}, + {104, 0x30}, + {98, 0x30}, + {110, 0x6}, + {104, 0x6}, + {98, 0x6}, + {110, 0x5}, + {104, 0x5}, + {98, 0x5}, + {110, 0x4}, + {104, 0x4}, + {98, 0x4}, + {110, 0x3}, + {104, 0x3}, + {98, 0x3}, + {110, 0x2}, + {104, 0x2}, + {98, 0x2}, + {110, 0x1}, + {104, 0x1}, + {98, 0x1}, + {110, 0x0}, + {104, 0x0}, + {98, 0x0}, + {97, 0}, + {96, 0}, + {95, 0}, + {94, 0}, + {93, 0}, + {92, 0}, + {91, 0}, + {90, 0}, + {89, 0}, + {88, 0}, + {87, 0}, + {86, 0}, + {85, 0}, + {84, 0}, + {83, 0}, + {82, 0}, + {81, 0}, + {80, 0}, + {79, 0}, + {78, 0}, + {77, 0}, + {76, 0}, + {75, 0}, + {74, 0}, + {73, 0}, + {72, 0}, + {71, 0}, + {70, 0}, + {69, 0}, + {68, 0}, + {67, 0}, + {66, 0}, + {65, 0}, + {64, 0}, + {63, 0}, + {62, 0}, + {61, 0}, + {60, 0}, + {59, 0}, + } +}; + +static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, + u8 is_ht40, u8 ctrl_chan_high, + struct il4965_tx_power_db *tx_power_tbl) +{ + u8 saturation_power; + s32 target_power; + s32 user_target_power; + s32 power_limit; + s32 current_temp; + s32 reg_limit; + s32 current_regulatory; + s32 txatten_grp = CALIB_CH_GROUP_MAX; + int i; + int c; + const struct il_channel_info *ch_info = NULL; + struct il_eeprom_calib_ch_info ch_eeprom_info; + const struct il_eeprom_calib_measure *measurement; + s16 voltage; + s32 init_voltage; + s32 voltage_compensation; + s32 degrees_per_05db_num; + s32 degrees_per_05db_denom; + s32 factory_temp; + s32 temperature_comp[2]; + s32 factory_gain_idx[2]; + s32 factory_actual_pwr[2]; + s32 power_idx; + + /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units + * are used for idxing into txpower table) */ + user_target_power = 2 * il->tx_power_user_lmt; + + /* Get current (RXON) channel, band, width */ + D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, + is_ht40); + + ch_info = il_get_channel_info(il, il->band, channel); + + if (!il_is_channel_valid(ch_info)) + return -EINVAL; + + /* get txatten group, used to select 1) thermal txpower adjustment + * and 2) mimo txpower balance between Tx chains. */ + txatten_grp = il4965_get_tx_atten_grp(channel); + if (txatten_grp < 0) { + IL_ERR("Can't find txatten group for channel %d.\n", + channel); + return txatten_grp; + } + + D_TXPOWER("channel %d belongs to txatten group %d\n", + channel, txatten_grp); + + if (is_ht40) { + if (ctrl_chan_high) + channel -= 2; + else + channel += 2; + } + + /* hardware txpower limits ... + * saturation (clipping distortion) txpowers are in half-dBm */ + if (band) + saturation_power = il->calib_info->saturation_power24; + else + saturation_power = il->calib_info->saturation_power52; + + if (saturation_power < IL_TX_POWER_SATURATION_MIN || + saturation_power > IL_TX_POWER_SATURATION_MAX) { + if (band) + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24; + else + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52; + } + + /* regulatory txpower limits ... reg_limit values are in half-dBm, + * max_power_avg values are in dBm, convert * 2 */ + if (is_ht40) + reg_limit = ch_info->ht40_max_power_avg * 2; + else + reg_limit = ch_info->max_power_avg * 2; + + if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) || + (reg_limit > IL_TX_POWER_REGULATORY_MAX)) { + if (band) + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24; + else + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52; + } + + /* Interpolate txpower calibration values for this channel, + * based on factory calibration tests on spaced channels. */ + il4965_interpolate_chan(il, channel, &ch_eeprom_info); + + /* calculate tx gain adjustment based on power supply voltage */ + voltage = le16_to_cpu(il->calib_info->voltage); + init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); + voltage_compensation = + il4965_get_voltage_compensation(voltage, init_voltage); + + D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", + init_voltage, + voltage, voltage_compensation); + + /* get current temperature (Celsius) */ + current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); + current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); + current_temp = KELVIN_TO_CELSIUS(current_temp); + + /* select thermal txpower adjustment params, based on channel group + * (same frequency group used for mimo txatten adjustment) */ + degrees_per_05db_num = + tx_power_cmp_tble[txatten_grp].degrees_per_05db_a; + degrees_per_05db_denom = + tx_power_cmp_tble[txatten_grp].degrees_per_05db_a_denom; + + /* get per-chain txpower values from factory measurements */ + for (c = 0; c < 2; c++) { + measurement = &ch_eeprom_info.measurements[c][1]; + + /* txgain adjustment (in half-dB steps) based on difference + * between factory and current temperature */ + factory_temp = measurement->temperature; + il4965_math_div_round((current_temp - factory_temp) * + degrees_per_05db_denom, + degrees_per_05db_num, + &temperature_comp[c]); + + factory_gain_idx[c] = measurement->gain_idx; + factory_actual_pwr[c] = measurement->actual_pow; + + D_TXPOWER("chain = %d\n", c); + D_TXPOWER("fctry tmp %d, " + "curr tmp %d, comp %d steps\n", + factory_temp, current_temp, + temperature_comp[c]); + + D_TXPOWER("fctry idx %d, fctry pwr %d\n", + factory_gain_idx[c], + factory_actual_pwr[c]); + } + + /* for each of 33 bit-rates (including 1 for CCK) */ + for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) { + u8 is_mimo_rate; + union il4965_tx_power_dual_stream tx_power; + + /* for mimo, reduce each chain's txpower by half + * (3dB, 6 steps), so total output power is regulatory + * compliant. */ + if (i & 0x8) { + current_regulatory = reg_limit - + IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; + is_mimo_rate = 1; + } else { + current_regulatory = reg_limit; + is_mimo_rate = 0; + } + + /* find txpower limit, either hardware or regulatory */ + power_limit = saturation_power - back_off_table[i]; + if (power_limit > current_regulatory) + power_limit = current_regulatory; + + /* reduce user's txpower request if necessary + * for this rate on this channel */ + target_power = user_target_power; + if (target_power > power_limit) + target_power = power_limit; + + D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", + i, saturation_power - back_off_table[i], + current_regulatory, user_target_power, + target_power); + + /* for each of 2 Tx chains (radio transmitters) */ + for (c = 0; c < 2; c++) { + s32 atten_value; + + if (is_mimo_rate) + atten_value = + (s32)le32_to_cpu(il->card_alive_init. + tx_atten[txatten_grp][c]); + else + atten_value = 0; + + /* calculate idx; higher idx means lower txpower */ + power_idx = (u8) (factory_gain_idx[c] - + (target_power - + factory_actual_pwr[c]) - + temperature_comp[c] - + voltage_compensation + + atten_value); + +/* D_TXPOWER("calculated txpower idx %d\n", + power_idx); */ + + if (power_idx < get_min_power_idx(i, band)) + power_idx = get_min_power_idx(i, band); + + /* adjust 5 GHz idx to support negative idxes */ + if (!band) + power_idx += 9; + + /* CCK, rate 32, reduce txpower for CCK */ + if (i == POWER_TBL_CCK_ENTRY) + power_idx += + IL_TX_POWER_CCK_COMPENSATION_C_STEP; + + /* stay within the table! */ + if (power_idx > 107) { + IL_WARN("txpower idx %d > 107\n", + power_idx); + power_idx = 107; + } + if (power_idx < 0) { + IL_WARN("txpower idx %d < 0\n", + power_idx); + power_idx = 0; + } + + /* fill txpower command for this rate/chain */ + tx_power.s.radio_tx_gain[c] = + gain_table[band][power_idx].radio; + tx_power.s.dsp_predis_atten[c] = + gain_table[band][power_idx].dsp; + + D_TXPOWER("chain %d mimo %d idx %d " + "gain 0x%02x dsp %d\n", + c, atten_value, power_idx, + tx_power.s.radio_tx_gain[c], + tx_power.s.dsp_predis_atten[c]); + } /* for each chain */ + + tx_power_tbl->power_tbl[i].dw = cpu_to_le32(tx_power.dw); + + } /* for each rate */ + + return 0; +} + +/** + * il4965_send_tx_power - Configure the TXPOWER level user limit + * + * Uses the active RXON for channel, band, and characteristics (ht40, high) + * The power limit is taken from il->tx_power_user_lmt. + */ +static int il4965_send_tx_power(struct il_priv *il) +{ + struct il4965_txpowertable_cmd cmd = { 0 }; + int ret; + u8 band = 0; + bool is_ht40 = false; + u8 ctrl_chan_high = 0; + struct il_rxon_context *ctx = &il->ctx; + + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) + return -EAGAIN; + + band = il->band == IEEE80211_BAND_2GHZ; + + is_ht40 = iw4965_is_ht40_channel(ctx->active.flags); + + if (is_ht40 && (ctx->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + ctrl_chan_high = 1; + + cmd.band = band; + cmd.channel = ctx->active.channel; + + ret = il4965_fill_txpower_tbl(il, band, + le16_to_cpu(ctx->active.channel), + is_ht40, ctrl_chan_high, &cmd.tx_power); + if (ret) + goto out; + + ret = il_send_cmd_pdu(il, + REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); + +out: + return ret; +} + +static int il4965_send_rxon_assoc(struct il_priv *il, + struct il_rxon_context *ctx) +{ + int ret = 0; + struct il4965_rxon_assoc_cmd rxon_assoc; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; + + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_ht_single_stream_basic_rates == + rxon2->ofdm_ht_single_stream_basic_rates && + rxon1->ofdm_ht_dual_stream_basic_rates == + rxon2->ofdm_ht_dual_stream_basic_rates && + rxon1->rx_chain == rxon2->rx_chain && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { + D_INFO("Using current RXON_ASSOC. Not resending.\n"); + return 0; + } + + rxon_assoc.flags = ctx->staging.flags; + rxon_assoc.filter_flags = ctx->staging.filter_flags; + rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; + rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; + rxon_assoc.reserved = 0; + rxon_assoc.ofdm_ht_single_stream_basic_rates = + ctx->staging.ofdm_ht_single_stream_basic_rates; + rxon_assoc.ofdm_ht_dual_stream_basic_rates = + ctx->staging.ofdm_ht_dual_stream_basic_rates; + rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; + + ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, + sizeof(rxon_assoc), &rxon_assoc, NULL); + + return ret; +} + +static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +{ + /* cast away the const for active_rxon in this function */ + struct il_rxon_cmd *active_rxon = (void *)&ctx->active; + int ret; + bool new_assoc = + !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); + + if (!il_is_alive(il)) + return -EBUSY; + + if (!ctx->is_active) + return 0; + + /* always get timestamp with Rx frame */ + ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; + + ret = il_check_rxon_cmd(il, ctx); + if (ret) { + IL_ERR("Invalid RXON configuration. Not committing.\n"); + return -EINVAL; + } + + /* + * receive commit_rxon request + * abort any previous channel switch if still in process + */ + if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && + il->switch_channel != ctx->staging.channel) { + D_11H("abort channel switch on %d\n", + le16_to_cpu(il->switch_channel)); + il_chswitch_done(il, false); + } + + /* If we don't need to send a full RXON, we can use + * il_rxon_assoc_cmd which is used to reconfigure filter + * and other flags for the current radio configuration. */ + if (!il_full_rxon_required(il, ctx)) { + ret = il_send_rxon_assoc(il, ctx); + if (ret) { + IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); + return ret; + } + + memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + il_print_rx_config_cmd(il, ctx); + /* + * We do not commit tx power settings while channel changing, + * do it now if tx power changed. + */ + il_set_tx_power(il, il->tx_power_next, false); + return 0; + } + + /* If we are currently associated and the new config requires + * an RXON_ASSOC and the new config wants the associated mask enabled, + * we must clear the associated from the active configuration + * before we apply the new config */ + if (il_is_associated_ctx(ctx) && new_assoc) { + D_INFO("Toggling associated bit on current RXON\n"); + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), + active_rxon); + + /* If the mask clearing failed then we set + * active_rxon back to what it was previously */ + if (ret) { + active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; + IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret); + return ret; + } + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); + if (ret) { + IL_ERR("Failed to restore WEP keys (%d)\n", ret); + return ret; + } + } + + D_INFO("Sending RXON\n" + "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" + "* bssid = %pM\n", + (new_assoc ? "" : "out"), + le16_to_cpu(ctx->staging.channel), + ctx->staging.bssid_addr); + + il_set_rxon_hwcrypto(il, ctx, + !il->cfg->mod_params->sw_crypto); + + /* Apply the new configuration + * RXON unassoc clears the station table in uCode so restoration of + * stations is needed after it (the RXON command) completes + */ + if (!new_assoc) { + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); + if (ret) { + IL_ERR("Error setting new RXON (%d)\n", ret); + return ret; + } + D_INFO("Return from !new_assoc RXON.\n"); + memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); + if (ret) { + IL_ERR("Failed to restore WEP keys (%d)\n", ret); + return ret; + } + } + if (new_assoc) { + il->start_calib = 0; + /* Apply the new configuration + * RXON assoc doesn't clear the station table in uCode, + */ + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); + if (ret) { + IL_ERR("Error setting new RXON (%d)\n", ret); + return ret; + } + memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + } + il_print_rx_config_cmd(il, ctx); + + il4965_init_sensitivity(il); + + /* If we issue a new RXON command which required a tune then we must + * send a new TXPOWER command or we won't be able to Tx any frames */ + ret = il_set_tx_power(il, il->tx_power_next, true); + if (ret) { + IL_ERR("Error sending TX power (%d)\n", ret); + return ret; + } + + return 0; +} + +static int il4965_hw_channel_switch(struct il_priv *il, + struct ieee80211_channel_switch *ch_switch) +{ + struct il_rxon_context *ctx = &il->ctx; + int rc; + u8 band = 0; + bool is_ht40 = false; + u8 ctrl_chan_high = 0; + struct il4965_channel_switch_cmd cmd; + const struct il_channel_info *ch_info; + u32 switch_time_in_usec, ucode_switch_time; + u16 ch; + u32 tsf_low; + u8 switch_count; + u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval); + struct ieee80211_vif *vif = ctx->vif; + band = il->band == IEEE80211_BAND_2GHZ; + + is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); + + if (is_ht40 && + (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + ctrl_chan_high = 1; + + cmd.band = band; + cmd.expect_beacon = 0; + ch = ch_switch->channel->hw_value; + cmd.channel = cpu_to_le16(ch); + cmd.rxon_flags = ctx->staging.flags; + cmd.rxon_filter_flags = ctx->staging.filter_flags; + switch_count = ch_switch->count; + tsf_low = ch_switch->timestamp & 0x0ffffffff; + /* + * calculate the ucode channel switch time + * adding TSF as one of the factor for when to switch + */ + if (il->ucode_beacon_time > tsf_low && beacon_interval) { + if (switch_count > ((il->ucode_beacon_time - tsf_low) / + beacon_interval)) { + switch_count -= (il->ucode_beacon_time - + tsf_low) / beacon_interval; + } else + switch_count = 0; + } + if (switch_count <= 1) + cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); + else { + switch_time_in_usec = + vif->bss_conf.beacon_int * switch_count * TIME_UNIT; + ucode_switch_time = il_usecs_to_beacons(il, + switch_time_in_usec, + beacon_interval); + cmd.switch_time = il_add_beacon_time(il, + il->ucode_beacon_time, + ucode_switch_time, + beacon_interval); + } + D_11H("uCode time for the switch is 0x%x\n", + cmd.switch_time); + ch_info = il_get_channel_info(il, il->band, ch); + if (ch_info) + cmd.expect_beacon = il_is_channel_radar(ch_info); + else { + IL_ERR("invalid channel switch from %u to %u\n", + ctx->active.channel, ch); + return -EFAULT; + } + + rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, + ctrl_chan_high, &cmd.tx_power); + if (rc) { + D_11H("error:%d fill txpower_tbl\n", rc); + return rc; + } + + return il_send_cmd_pdu(il, + REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); +} + +/** + * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array + */ +static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, + struct il_tx_queue *txq, + u16 byte_cnt) +{ + struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; + int txq_id = txq->q.id; + int write_ptr = txq->q.write_ptr; + int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; + __le16 bc_ent; + + WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX); + + bc_ent = cpu_to_le16(len & 0xFFF); + /* Set up byte count within first 256 entries */ + scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent; + + /* If within first 64 entries, duplicate at end */ + if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) + scd_bc_tbl[txq_id]. + tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent; +} + +/** + * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) + * @stats: Provides the temperature reading from the uCode + * + * A return of <0 indicates bogus data in the stats + */ +static int il4965_hw_get_temperature(struct il_priv *il) +{ + s32 temperature; + s32 vt; + s32 R1, R2, R3; + u32 R4; + + if (test_bit(STATUS_TEMPERATURE, &il->status) && + (il->_4965.stats.flag & + STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { + D_TEMP("Running HT40 temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); + } else { + D_TEMP("Running temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); + } + + /* + * Temperature is only 23 bits, so sign extend out to 32. + * + * NOTE If we haven't received a stats notification yet + * with an updated temperature, use R4 provided to us in the + * "initialize" ALIVE response. + */ + if (!test_bit(STATUS_TEMPERATURE, &il->status)) + vt = sign_extend32(R4, 23); + else + vt = sign_extend32(le32_to_cpu(il->_4965.stats. + general.common.temperature), 23); + + D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + + if (R3 == R1) { + IL_ERR("Calibration conflict R1 == R3\n"); + return -1; + } + + /* Calculate temperature in degrees Kelvin, adjust by 97%. + * Add offset to center the adjustment around 0 degrees Centigrade. */ + temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); + temperature /= (R3 - R1); + temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; + + D_TEMP("Calibrated temperature: %dK, %dC\n", + temperature, KELVIN_TO_CELSIUS(temperature)); + + return temperature; +} + +/* Adjust Txpower only if temperature variance is greater than threshold. */ +#define IL_TEMPERATURE_THRESHOLD 3 + +/** + * il4965_is_temp_calib_needed - determines if new calibration is needed + * + * If the temperature changed has changed sufficiently, then a recalibration + * is needed. + * + * Assumes caller will replace il->last_temperature once calibration + * executed. + */ +static int il4965_is_temp_calib_needed(struct il_priv *il) +{ + int temp_diff; + + if (!test_bit(STATUS_STATISTICS, &il->status)) { + D_TEMP("Temperature not updated -- no stats.\n"); + return 0; + } + + temp_diff = il->temperature - il->last_temperature; + + /* get absolute value */ + if (temp_diff < 0) { + D_POWER("Getting cooler, delta %d\n", temp_diff); + temp_diff = -temp_diff; + } else if (temp_diff == 0) + D_POWER("Temperature unchanged\n"); + else + D_POWER("Getting warmer, delta %d\n", temp_diff); + + if (temp_diff < IL_TEMPERATURE_THRESHOLD) { + D_POWER(" => thermal txpower calib not needed\n"); + return 0; + } + + D_POWER(" => thermal txpower calib needed\n"); + + return 1; +} + +static void il4965_temperature_calib(struct il_priv *il) +{ + s32 temp; + + temp = il4965_hw_get_temperature(il); + if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) + return; + + if (il->temperature != temp) { + if (il->temperature) + D_TEMP("Temperature changed " + "from %dC to %dC\n", + KELVIN_TO_CELSIUS(il->temperature), + KELVIN_TO_CELSIUS(temp)); + else + D_TEMP("Temperature " + "initialized to %dC\n", + KELVIN_TO_CELSIUS(temp)); + } + + il->temperature = temp; + set_bit(STATUS_TEMPERATURE, &il->status); + + if (!il->disable_tx_power_cal && + unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + il4965_is_temp_calib_needed(il)) + queue_work(il->workqueue, &il->txpower_work); +} + +static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) +{ + switch (cmd_id) { + case REPLY_RXON: + return (u16) sizeof(struct il4965_rxon_cmd); + default: + return len; + } +} + +static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, + u8 *data) +{ + struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; + addsta->mode = cmd->mode; + memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); + addsta->station_flags = cmd->station_flags; + addsta->station_flags_msk = cmd->station_flags_msk; + addsta->tid_disable_tx = cmd->tid_disable_tx; + addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; + addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; + addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; + addsta->sleep_tx_count = cmd->sleep_tx_count; + addsta->reserved1 = cpu_to_le16(0); + addsta->reserved2 = cpu_to_le16(0); + + return (u16)sizeof(struct il4965_addsta_cmd); +} + +static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) +{ + return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; +} + +/** + * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue + */ +static int il4965_tx_status_reply_tx(struct il_priv *il, + struct il_ht_agg *agg, + struct il4965_tx_resp *tx_resp, + int txq_id, u16 start_idx) +{ + u16 status; + struct agg_tx_status *frame_status = tx_resp->u.agg_status; + struct ieee80211_tx_info *info = NULL; + struct ieee80211_hdr *hdr = NULL; + u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); + int i, sh, idx; + u16 seq; + if (agg->wait_for_ba) + D_TX_REPLY("got tx response w/o block-ack\n"); + + agg->frame_count = tx_resp->frame_count; + agg->start_idx = start_idx; + agg->rate_n_flags = rate_n_flags; + agg->bitmap = 0; + + /* num frames attempted by Tx command */ + if (agg->frame_count == 1) { + /* Only one frame was attempted; no block-ack will arrive */ + status = le16_to_cpu(frame_status[0].status); + idx = start_idx; + + D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", + agg->frame_count, agg->start_idx, idx); + + info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); + info->status.rates[0].count = tx_resp->failure_frame + 1; + info->flags &= ~IEEE80211_TX_CTL_AMPDU; + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(il, rate_n_flags, info); + + D_TX_REPLY("1 Frame 0x%x failure :%d\n", + status & 0xff, tx_resp->failure_frame); + D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); + + agg->wait_for_ba = 0; + } else { + /* Two or more frames were attempted; expect block-ack */ + u64 bitmap = 0; + int start = agg->start_idx; + + /* Construct bit-map of pending frames within Tx win */ + for (i = 0; i < agg->frame_count; i++) { + u16 sc; + status = le16_to_cpu(frame_status[i].status); + seq = le16_to_cpu(frame_status[i].sequence); + idx = SEQ_TO_IDX(seq); + txq_id = SEQ_TO_QUEUE(seq); + + if (status & (AGG_TX_STATE_FEW_BYTES_MSK | + AGG_TX_STATE_ABORT_MSK)) + continue; + + D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", + agg->frame_count, txq_id, idx); + + hdr = il_tx_queue_get_hdr(il, txq_id, idx); + if (!hdr) { + IL_ERR( + "BUG_ON idx doesn't point to valid skb" + " idx=%d, txq_id=%d\n", idx, txq_id); + return -1; + } + + sc = le16_to_cpu(hdr->seq_ctrl); + if (idx != (SEQ_TO_SN(sc) & 0xff)) { + IL_ERR( + "BUG_ON idx doesn't match seq control" + " idx=%d, seq_idx=%d, seq=%d\n", + idx, SEQ_TO_SN(sc), hdr->seq_ctrl); + return -1; + } + + D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", + i, idx, SEQ_TO_SN(sc)); + + sh = idx - start; + if (sh > 64) { + sh = (start - idx) + 0xff; + bitmap = bitmap << sh; + sh = 0; + start = idx; + } else if (sh < -64) + sh = 0xff - (start - idx); + else if (sh < 0) { + sh = start - idx; + start = idx; + bitmap = bitmap << sh; + sh = 0; + } + bitmap |= 1ULL << sh; + D_TX_REPLY("start=%d bitmap=0x%llx\n", + start, (unsigned long long)bitmap); + } + + agg->bitmap = bitmap; + agg->start_idx = start; + D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", + agg->frame_count, agg->start_idx, + (unsigned long long)agg->bitmap); + + if (bitmap) + agg->wait_for_ba = 1; + } + return 0; +} + +static u8 il4965_find_station(struct il_priv *il, const u8 *addr) +{ + int i; + int start = 0; + int ret = IL_INVALID_STATION; + unsigned long flags; + + if ((il->iw_mode == NL80211_IFTYPE_ADHOC)) + start = IL_STA_ID; + + if (is_broadcast_ether_addr(addr)) + return il->ctx.bcast_sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + for (i = start; i < il->hw_params.max_stations; i++) + if (il->stations[i].used && + (!compare_ether_addr(il->stations[i].sta.sta.addr, + addr))) { + ret = i; + goto out; + } + + D_ASSOC("can not find STA %pM total %d\n", + addr, il->num_stations); + + out: + /* + * It may be possible that more commands interacting with stations + * arrive before we completed processing the adding of + * station + */ + if (ret != IL_INVALID_STATION && + (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || + ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && + (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { + IL_ERR("Requested station info for sta %d before ready.\n", + ret); + ret = IL_INVALID_STATION; + } + spin_unlock_irqrestore(&il->sta_lock, flags); + return ret; +} + +static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) +{ + if (il->iw_mode == NL80211_IFTYPE_STATION) { + return IL_AP_ID; + } else { + u8 *da = ieee80211_get_DA(hdr); + return il4965_find_station(il, da); + } +} + +/** + * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response + */ +static void il4965_rx_reply_tx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int txq_id = SEQ_TO_QUEUE(sequence); + int idx = SEQ_TO_IDX(sequence); + struct il_tx_queue *txq = &il->txq[txq_id]; + struct ieee80211_hdr *hdr; + struct ieee80211_tx_info *info; + struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + u32 status = le32_to_cpu(tx_resp->u.status); + int uninitialized_var(tid); + int sta_id; + int freed; + u8 *qc = NULL; + unsigned long flags; + + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " + "is out of range [0-%d] %d %d\n", txq_id, + idx, txq->q.n_bd, txq->q.write_ptr, + txq->q.read_ptr); + return; + } + + txq->time_stamp = jiffies; + info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); + memset(&info->status, 0, sizeof(info->status)); + + hdr = il_tx_queue_get_hdr(il, txq_id, idx); + if (ieee80211_is_data_qos(hdr->frame_control)) { + qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & 0xf; + } + + sta_id = il4965_get_ra_sta_id(il, hdr); + if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { + IL_ERR("Station not known\n"); + return; + } + + spin_lock_irqsave(&il->sta_lock, flags); + if (txq->sched_retry) { + const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); + struct il_ht_agg *agg = NULL; + WARN_ON(!qc); + + agg = &il->stations[sta_id].tid[tid].agg; + + il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); + + /* check if BAR is needed */ + if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) + info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; + + if (txq->q.read_ptr != (scd_ssn & 0xff)) { + idx = il_queue_dec_wrap(scd_ssn & 0xff, + txq->q.n_bd); + D_TX_REPLY("Retry scheduler reclaim scd_ssn " + "%d idx %d\n", scd_ssn , idx); + freed = il4965_tx_queue_reclaim(il, txq_id, idx); + if (qc) + il4965_free_tfds_in_queue(il, sta_id, + tid, freed); + + if (il->mac80211_registered && + il_queue_space(&txq->q) > txq->q.low_mark && + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) + il_wake_queue(il, txq); + } + } else { + info->status.rates[0].count = tx_resp->failure_frame + 1; + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(il, + le32_to_cpu(tx_resp->rate_n_flags), + info); + + D_TX_REPLY("TXQ %d status %s (0x%08x) " + "rate_n_flags 0x%x retries %d\n", + txq_id, + il4965_get_tx_fail_reason(status), status, + le32_to_cpu(tx_resp->rate_n_flags), + tx_resp->failure_frame); + + freed = il4965_tx_queue_reclaim(il, txq_id, idx); + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_free_tfds_in_queue(il, sta_id, tid, freed); + else if (sta_id == IL_INVALID_STATION) + D_TX_REPLY("Station not known\n"); + + if (il->mac80211_registered && + il_queue_space(&txq->q) > txq->q.low_mark) + il_wake_queue(il, txq); + } + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_txq_check_empty(il, sta_id, tid, txq_id); + + il4965_check_abort_status(il, tx_resp->frame_count, status); + + spin_unlock_irqrestore(&il->sta_lock, flags); +} + +static void il4965_rx_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; + u8 rate __maybe_unused = + il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + + D_RX("beacon status %#x, retries:%d ibssmgr:%d " + "tsf:0x%.8x%.8x rate:%d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), + le32_to_cpu(beacon->low_tsf), rate); + + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); +} + +/* Set up 4965-specific Rx frame reply handlers */ +static void il4965_rx_handler_setup(struct il_priv *il) +{ + /* Legacy Rx frames */ + il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; + /* Tx response */ + il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; +} + +static struct il_hcmd_ops il4965_hcmd = { + .rxon_assoc = il4965_send_rxon_assoc, + .commit_rxon = il4965_commit_rxon, + .set_rxon_chain = il4965_set_rxon_chain, +}; + +static void il4965_post_scan(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + + /* + * Since setting the RXON may have been deferred while + * performing the scan, fire one off if needed + */ + if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) + il_commit_rxon(il, ctx); +} + +static void il4965_post_associate(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_vif *vif = ctx->vif; + struct ieee80211_conf *conf = NULL; + int ret = 0; + + if (!vif || !il->is_open) + return; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + il_scan_cancel_timeout(il, 200); + + conf = il_ieee80211_get_hw_conf(il->hw); + + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + + ret = il_send_rxon_timing(il, ctx); + if (ret) + IL_WARN("RXON timing - " + "Attempting to continue.\n"); + + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + + il_set_rxon_ht(il, &il->current_ht_config); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); + + D_ASSOC("assoc id %d beacon interval %d\n", + vif->bss_conf.aid, vif->bss_conf.beacon_int); + + if (vif->bss_conf.use_short_preamble) + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (vif->bss_conf.use_short_slot) + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + } + + il_commit_rxon(il, ctx); + + D_ASSOC("Associated as %d to: %pM\n", + vif->bss_conf.aid, ctx->active.bssid_addr); + + switch (vif->type) { + case NL80211_IFTYPE_STATION: + break; + case NL80211_IFTYPE_ADHOC: + il4965_send_beacon_cmd(il); + break; + default: + IL_ERR("%s Should not be called in %d mode\n", + __func__, vif->type); + break; + } + + /* the chain noise calibration will enabled PM upon completion + * If chain noise has already been run, then we need to enable + * power management here */ + if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE) + il_power_update_mode(il, false); + + /* Enable Rx differential gain and sensitivity calibrations */ + il4965_chain_noise_reset(il); + il->start_calib = 1; +} + +static void il4965_config_ap(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_vif *vif = ctx->vif; + int ret = 0; + + lockdep_assert_held(&il->mutex); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + /* The following should be done only at AP bring up */ + if (!il_is_associated_ctx(ctx)) { + + /* RXON - unassoc (to set timing command) */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + + /* RXON Timing */ + ret = il_send_rxon_timing(il, ctx); + if (ret) + IL_WARN("RXON timing failed - " + "Attempting to continue.\n"); + + /* AP has all antennas */ + il->chain_noise_data.active_chains = + il->hw_params.valid_rx_ant; + il_set_rxon_ht(il, &il->current_ht_config); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + ctx->staging.assoc_id = 0; + + if (vif->bss_conf.use_short_preamble) + ctx->staging.flags |= + RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (vif->bss_conf.use_short_slot) + ctx->staging.flags |= + RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_SLOT_MSK; + } + /* need to send beacon cmd before committing assoc RXON! */ + il4965_send_beacon_cmd(il); + /* restore RXON assoc */ + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + } + il4965_send_beacon_cmd(il); +} + +static struct il_hcmd_utils_ops il4965_hcmd_utils = { + .get_hcmd_size = il4965_get_hcmd_size, + .build_addsta_hcmd = il4965_build_addsta_hcmd, + .request_scan = il4965_request_scan, + .post_scan = il4965_post_scan, +}; + +static struct il_lib_ops il4965_lib = { + .set_hw_params = il4965_hw_set_hw_params, + .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl, + .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il4965_hw_txq_free_tfd, + .txq_init = il4965_hw_tx_queue_init, + .rx_handler_setup = il4965_rx_handler_setup, + .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, + .init_alive_start = il4965_init_alive_start, + .load_ucode = il4965_load_bsm, + .dump_nic_error_log = il4965_dump_nic_error_log, + .dump_fh = il4965_dump_fh, + .set_channel_switch = il4965_hw_channel_switch, + .apm_ops = { + .init = il_apm_init, + .config = il4965_nic_config, + }, + .eeprom_ops = { + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, + EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS + }, + .acquire_semaphore = il4965_eeprom_acquire_semaphore, + .release_semaphore = il4965_eeprom_release_semaphore, + }, + .send_tx_power = il4965_send_tx_power, + .update_chain_flags = il4965_update_chain_flags, + .temp_ops = { + .temperature = il4965_temperature_calib, + }, + .debugfs_ops = { + .rx_stats_read = il4965_ucode_rx_stats_read, + .tx_stats_read = il4965_ucode_tx_stats_read, + .general_stats_read = il4965_ucode_general_stats_read, + }, +}; + +static const struct il_legacy_ops il4965_legacy_ops = { + .post_associate = il4965_post_associate, + .config_ap = il4965_config_ap, + .manage_ibss_station = il4965_manage_ibss_station, + .update_bcast_stations = il4965_update_bcast_stations, +}; + +struct ieee80211_ops il4965_hw_ops = { + .tx = il4965_mac_tx, + .start = il4965_mac_start, + .stop = il4965_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il4965_configure_filter, + .set_key = il4965_mac_set_key, + .update_tkip_key = il4965_mac_update_tkip_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .ampdu_action = il4965_mac_ampdu_action, + .hw_scan = il_mac_hw_scan, + .sta_add = il4965_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .channel_switch = il4965_mac_channel_switch, + .tx_last_beacon = il_mac_tx_last_beacon, +}; + +static const struct il_ops il4965_ops = { + .lib = &il4965_lib, + .hcmd = &il4965_hcmd, + .utils = &il4965_hcmd_utils, + .led = &il4965_led_ops, + .legacy = &il4965_legacy_ops, + .ieee80211_ops = &il4965_hw_ops, +}; + +static struct il_base_params il4965_base_params = { + .eeprom_size = IL4965_EEPROM_IMG_SIZE, + .num_of_queues = IL49_NUM_QUEUES, + .num_of_ampdu_queues = IL49_NUM_AMPDU_QUEUES, + .pll_cfg_val = 0, + .set_l0s = true, + .use_bsm = true, + .led_compensation = 61, + .chain_noise_num_beacons = IL4965_CAL_NUM_BEACONS, + .wd_timeout = IL_DEF_WD_TIMEOUT, + .temperature_kelvin = true, + .ucode_tracing = true, + .sensitivity_calib_by_driver = true, + .chain_noise_calib_by_driver = true, +}; + +struct il_cfg il4965_cfg = { + .name = "Intel(R) Wireless WiFi Link 4965AGN", + .fw_name_pre = IL4965_FW_PRE, + .ucode_api_max = IL4965_UCODE_API_MAX, + .ucode_api_min = IL4965_UCODE_API_MIN, + .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, + .valid_tx_ant = ANT_AB, + .valid_rx_ant = ANT_ABC, + .eeprom_ver = EEPROM_4965_EEPROM_VERSION, + .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, + .ops = &il4965_ops, + .mod_params = &il4965_mod_params, + .base_params = &il4965_base_params, + .led_mode = IL_LED_BLINK, + /* + * Force use of chains B and C for scan RX on 5 GHz band + * because the device has off-channel reception on chain A. + */ + .scan_rx_antennas[IEEE80211_BAND_5GHZ] = ANT_BC, +}; + +/* Module firmware */ +MODULE_FIRMWARE(IL4965_MODULE_FIRMWARE(IL4965_UCODE_API_MAX)); diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 49c4b36..cd8ac73 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -8,7 +8,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -iwl4965-objs := iwl-4965.o iwl4965-base.o iwl-4965-rs.o iwl-4965-led.o +iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl-4965-led.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o @@ -16,7 +16,7 @@ iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o -iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o +iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o iwl-3945-led.o iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c deleted file mode 100644 index b6abf34..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ /dev/null @@ -1,2740 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-fh.h" -#include "iwl-3945-fh.h" -#include "iwl-commands.h" -#include "iwl-sta.h" -#include "iwl-3945.h" -#include "iwl-eeprom.h" -#include "iwl-core.h" -#include "iwl-helpers.h" -#include "iwl-led.h" -#include "iwl-3945-led.h" -#include "iwl-3945-debugfs.h" - -#define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ - RATE_##r##M_IEEE, \ - RATE_##ip##M_IDX, \ - RATE_##in##M_IDX, \ - RATE_##rp##M_IDX, \ - RATE_##rn##M_IDX, \ - RATE_##pp##M_IDX, \ - RATE_##np##M_IDX, \ - RATE_##r##M_IDX_TBL, \ - RATE_##ip##M_IDX_TBL } - -/* - * Parameter order: - * rate, prev rate, next rate, prev tgg rate, next tgg rate - * - * If there isn't a valid next or previous rate then INV is used which - * maps to RATE_INVALID - * - */ -const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { - IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ -}; - -static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) -{ - u8 rate = il3945_rates[rate_idx].prev_ieee; - - if (rate == RATE_INVALID) - rate = rate_idx; - return rate; -} - -/* 1 = enable the il3945_disable_events() function */ -#define IL_EVT_DISABLE (0) -#define IL_EVT_DISABLE_SIZE (1532/32) - -/** - * il3945_disable_events - Disable selected events in uCode event log - * - * Disable an event by writing "1"s into "disable" - * bitmap in SRAM. Bit position corresponds to Event # (id/type). - * Default values of 0 enable uCode events to be logged. - * Use for only special debugging. This function is just a placeholder as-is, - * you'll need to provide the special bits! ... - * ... and set IL_EVT_DISABLE to 1. */ -void il3945_disable_events(struct il_priv *il) -{ - int i; - u32 base; /* SRAM address of event log header */ - u32 disable_ptr; /* SRAM address of event-disable bitmap array */ - u32 array_size; /* # of u32 entries in array */ - static const u32 evt_disable[IL_EVT_DISABLE_SIZE] = { - 0x00000000, /* 31 - 0 Event id numbers */ - 0x00000000, /* 63 - 32 */ - 0x00000000, /* 95 - 64 */ - 0x00000000, /* 127 - 96 */ - 0x00000000, /* 159 - 128 */ - 0x00000000, /* 191 - 160 */ - 0x00000000, /* 223 - 192 */ - 0x00000000, /* 255 - 224 */ - 0x00000000, /* 287 - 256 */ - 0x00000000, /* 319 - 288 */ - 0x00000000, /* 351 - 320 */ - 0x00000000, /* 383 - 352 */ - 0x00000000, /* 415 - 384 */ - 0x00000000, /* 447 - 416 */ - 0x00000000, /* 479 - 448 */ - 0x00000000, /* 511 - 480 */ - 0x00000000, /* 543 - 512 */ - 0x00000000, /* 575 - 544 */ - 0x00000000, /* 607 - 576 */ - 0x00000000, /* 639 - 608 */ - 0x00000000, /* 671 - 640 */ - 0x00000000, /* 703 - 672 */ - 0x00000000, /* 735 - 704 */ - 0x00000000, /* 767 - 736 */ - 0x00000000, /* 799 - 768 */ - 0x00000000, /* 831 - 800 */ - 0x00000000, /* 863 - 832 */ - 0x00000000, /* 895 - 864 */ - 0x00000000, /* 927 - 896 */ - 0x00000000, /* 959 - 928 */ - 0x00000000, /* 991 - 960 */ - 0x00000000, /* 1023 - 992 */ - 0x00000000, /* 1055 - 1024 */ - 0x00000000, /* 1087 - 1056 */ - 0x00000000, /* 1119 - 1088 */ - 0x00000000, /* 1151 - 1120 */ - 0x00000000, /* 1183 - 1152 */ - 0x00000000, /* 1215 - 1184 */ - 0x00000000, /* 1247 - 1216 */ - 0x00000000, /* 1279 - 1248 */ - 0x00000000, /* 1311 - 1280 */ - 0x00000000, /* 1343 - 1312 */ - 0x00000000, /* 1375 - 1344 */ - 0x00000000, /* 1407 - 1376 */ - 0x00000000, /* 1439 - 1408 */ - 0x00000000, /* 1471 - 1440 */ - 0x00000000, /* 1503 - 1472 */ - }; - - base = le32_to_cpu(il->card_alive.log_event_table_ptr); - if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR("Invalid event log pointer 0x%08X\n", base); - return; - } - - disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); - array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); - - if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { - D_INFO("Disabling selected uCode log events at 0x%x\n", - disable_ptr); - for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) - il_write_targ_mem(il, - disable_ptr + (i * sizeof(u32)), - evt_disable[i]); - - } else { - D_INFO("Selected uCode log events may be disabled\n"); - D_INFO(" by writing \"1\"s into disable bitmap\n"); - D_INFO(" in SRAM at 0x%x, size %d u32s\n", - disable_ptr, array_size); - } - -} - -static int il3945_hwrate_to_plcp_idx(u8 plcp) -{ - int idx; - - for (idx = 0; idx < RATE_COUNT_3945; idx++) - if (il3945_rates[idx].plcp == plcp) - return idx; - return -1; -} - -#ifdef CONFIG_IWLEGACY_DEBUG -#define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x - -static const char *il3945_get_tx_fail_reason(u32 status) -{ - switch (status & TX_STATUS_MSK) { - case TX_3945_STATUS_SUCCESS: - return "SUCCESS"; - TX_STATUS_ENTRY(SHORT_LIMIT); - TX_STATUS_ENTRY(LONG_LIMIT); - TX_STATUS_ENTRY(FIFO_UNDERRUN); - TX_STATUS_ENTRY(MGMNT_ABORT); - TX_STATUS_ENTRY(NEXT_FRAG); - TX_STATUS_ENTRY(LIFE_EXPIRE); - TX_STATUS_ENTRY(DEST_PS); - TX_STATUS_ENTRY(ABORTED); - TX_STATUS_ENTRY(BT_RETRY); - TX_STATUS_ENTRY(STA_INVALID); - TX_STATUS_ENTRY(FRAG_DROPPED); - TX_STATUS_ENTRY(TID_DISABLE); - TX_STATUS_ENTRY(FRAME_FLUSHED); - TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL); - TX_STATUS_ENTRY(TX_LOCKED); - TX_STATUS_ENTRY(NO_BEACON_ON_RADAR); - } - - return "UNKNOWN"; -} -#else -static inline const char *il3945_get_tx_fail_reason(u32 status) -{ - return ""; -} -#endif - -/* - * get ieee prev rate from rate scale table. - * for A and B mode we need to overright prev - * value - */ -int il3945_rs_next_rate(struct il_priv *il, int rate) -{ - int next_rate = il3945_get_prev_ieee_rate(rate); - - switch (il->band) { - case IEEE80211_BAND_5GHZ: - if (rate == RATE_12M_IDX) - next_rate = RATE_9M_IDX; - else if (rate == RATE_6M_IDX) - next_rate = RATE_6M_IDX; - break; - case IEEE80211_BAND_2GHZ: - if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il)) { - if (rate == RATE_11M_IDX) - next_rate = RATE_5M_IDX; - } - break; - - default: - break; - } - - return next_rate; -} - - -/** - * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd - * - * When FW advances 'R' idx, all entries between old and new 'R' idx - * need to be reclaimed. As result, some free space forms. If there is - * enough free space (> low mark), wake the stack that feeds us. - */ -static void il3945_tx_queue_reclaim(struct il_priv *il, - int txq_id, int idx) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - struct il_tx_info *tx_info; - - BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); - - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { - - tx_info = &txq->txb[txq->q.read_ptr]; - ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); - tx_info->skb = NULL; - il->cfg->ops->lib->txq_free_tfd(il, txq); - } - - if (il_queue_space(q) > q->low_mark && txq_id >= 0 && - txq_id != IL39_CMD_QUEUE_NUM && il->mac80211_registered) - il_wake_queue(il, txq); -} - -/** - * il3945_rx_reply_tx - Handle Tx response - */ -static void il3945_rx_reply_tx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u16 sequence = le16_to_cpu(pkt->hdr.sequence); - int txq_id = SEQ_TO_QUEUE(sequence); - int idx = SEQ_TO_IDX(sequence); - struct il_tx_queue *txq = &il->txq[txq_id]; - struct ieee80211_tx_info *info; - struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->status); - int rate_idx; - int fail; - - if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); - return; - } - - txq->time_stamp = jiffies; - info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); - ieee80211_tx_info_clear_status(info); - - /* Fill the MRR chain with some info about on-chip retransmissions */ - rate_idx = il3945_hwrate_to_plcp_idx(tx_resp->rate); - if (info->band == IEEE80211_BAND_5GHZ) - rate_idx -= IL_FIRST_OFDM_RATE; - - fail = tx_resp->failure_frame; - - info->status.rates[0].idx = rate_idx; - info->status.rates[0].count = fail + 1; /* add final attempt */ - - /* tx_status->rts_retry_count = tx_resp->failure_rts; */ - info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? - IEEE80211_TX_STAT_ACK : 0; - - D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", - txq_id, il3945_get_tx_fail_reason(status), status, - tx_resp->rate, tx_resp->failure_frame); - - D_TX_REPLY("Tx queue reclaim %d\n", idx); - il3945_tx_queue_reclaim(il, txq_id, idx); - - if (status & TX_ABORT_REQUIRED_MSK) - IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); -} - - - -/***************************************************************************** - * - * Intel PRO/Wireless 3945ABG/BG Network Connection - * - * RX handler implementations - * - *****************************************************************************/ -#ifdef CONFIG_IWLEGACY_DEBUGFS -static void il3945_accumulative_stats(struct il_priv *il, - __le32 *stats) -{ - int i; - __le32 *prev_stats; - u32 *accum_stats; - u32 *delta, *max_delta; - - prev_stats = (__le32 *)&il->_3945.stats; - accum_stats = (u32 *)&il->_3945.accum_stats; - delta = (u32 *)&il->_3945.delta_stats; - max_delta = (u32 *)&il->_3945.max_delta; - - for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { - if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); - *accum_stats += *delta; - if (*delta > *max_delta) - *max_delta = *delta; - } - } - - /* reset accumulative stats for "no-counter" type stats */ - il->_3945.accum_stats.general.temperature = - il->_3945.stats.general.temperature; - il->_3945.accum_stats.general.ttl_timestamp = - il->_3945.stats.general.ttl_timestamp; -} -#endif - -void il3945_hw_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - - D_RX("Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il3945_notif_stats), - le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); -#ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); -#endif - - memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); -} - -void il3945_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - __le32 *flag = (__le32 *)&pkt->u.raw; - - if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_3945.accum_stats, 0, - sizeof(struct il3945_notif_stats)); - memset(&il->_3945.delta_stats, 0, - sizeof(struct il3945_notif_stats)); - memset(&il->_3945.max_delta, 0, - sizeof(struct il3945_notif_stats)); -#endif - D_RX("Statistics have been cleared\n"); - } - il3945_hw_rx_stats(il, rxb); -} - - -/****************************************************************************** - * - * Misc. internal state and helper functions - * - ******************************************************************************/ - -/* This is necessary only for a number of stats, see the caller. */ -static int il3945_is_network_packet(struct il_priv *il, - struct ieee80211_hdr *header) -{ - /* Filter incoming packets to determine if they are targeted toward - * this network, discarding packets coming from ourselves */ - switch (il->iw_mode) { - case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ - /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr3, il->bssid); - case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ - /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr2, il->bssid); - default: - return 1; - } -} - -static void il3945_pass_packet_to_mac80211(struct il_priv *il, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); - struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); - u16 len = le16_to_cpu(rx_hdr->len); - struct sk_buff *skb; - __le16 fc = hdr->frame_control; - - /* We received data from the HW, so stop the watchdog */ - if (unlikely(len + IL39_RX_FRAME_SIZE > - PAGE_SIZE << il->hw_params.rx_page_order)) { - D_DROP("Corruption detected!\n"); - return; - } - - /* We only process data packets if the interface is open */ - if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); - return; - } - - skb = dev_alloc_skb(128); - if (!skb) { - IL_ERR("dev_alloc_skb failed\n"); - return; - } - - if (!il3945_mod_params.sw_crypto) - il_set_decrypted_flag(il, - (struct ieee80211_hdr *)rxb_addr(rxb), - le32_to_cpu(rx_end->status), stats); - - skb_add_rx_frag(skb, 0, rxb->page, - (void *)rx_hdr->payload - (void *)pkt, len); - - il_update_stats(il, false, fc, len); - memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - - ieee80211_rx(il->hw, skb); - il->alloc_rxb_page--; - rxb->page = NULL; -} - -#define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) - -static void il3945_rx_reply_rx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct ieee80211_hdr *header; - struct ieee80211_rx_status rx_status; - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); - struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); - struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); - u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); - u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); - u8 network_packet; - - rx_status.flag = 0; - rx_status.mactime = le64_to_cpu(rx_end->timestamp); - rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; - rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), - rx_status.band); - - rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); - if (rx_status.band == IEEE80211_BAND_5GHZ) - rx_status.rate_idx -= IL_FIRST_OFDM_RATE; - - rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & - RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; - - /* set the preamble flag if appropriate */ - if (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) - rx_status.flag |= RX_FLAG_SHORTPRE; - - if ((unlikely(rx_stats->phy_count > 20))) { - D_DROP("dsp size out of range [0,20]: %d/n", - rx_stats->phy_count); - return; - } - - if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || - !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); - return; - } - - - - /* Convert 3945's rssi indicator to dBm */ - rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; - - D_STATS("Rssi %d sig_avg %d noise_diff %d\n", - rx_status.signal, rx_stats_sig_avg, - rx_stats_noise_diff); - - header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - - network_packet = il3945_is_network_packet(il, header); - - D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", - network_packet ? '*' : ' ', - le16_to_cpu(rx_hdr->channel), - rx_status.signal, rx_status.signal, - rx_status.rate_idx); - - il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), - header); - - if (network_packet) { - il->_3945.last_beacon_time = - le32_to_cpu(rx_end->beacon_timestamp); - il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); - il->_3945.last_rx_rssi = rx_status.signal; - } - - il3945_pass_packet_to_mac80211(il, rxb, &rx_status); -} - -int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad) -{ - int count; - struct il_queue *q; - struct il3945_tfd *tfd, *tfd_tmp; - - q = &txq->q; - tfd_tmp = (struct il3945_tfd *)txq->tfds; - tfd = &tfd_tmp[q->write_ptr]; - - if (reset) - memset(tfd, 0, sizeof(*tfd)); - - count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); - - if (count >= NUM_TFD_CHUNKS || count < 0) { - IL_ERR("Error can not send more than %d chunks\n", - NUM_TFD_CHUNKS); - return -EINVAL; - } - - tfd->tbs[count].addr = cpu_to_le32(addr); - tfd->tbs[count].len = cpu_to_le32(len); - - count++; - - tfd->control_flags = cpu_to_le32(TFD_CTL_COUNT_SET(count) | - TFD_CTL_PAD_SET(pad)); - - return 0; -} - -/** - * il3945_hw_txq_free_tfd - Free one TFD, those at idx [txq->q.read_ptr] - * - * Does NOT advance any idxes - */ -void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) -{ - struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; - int idx = txq->q.read_ptr; - struct il3945_tfd *tfd = &tfd_tmp[idx]; - struct pci_dev *dev = il->pci_dev; - int i; - int counter; - - /* sanity check */ - counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); - if (counter > NUM_TFD_CHUNKS) { - IL_ERR("Too many chunks: %i\n", counter); - /* @todo issue fatal error, it is quite serious situation */ - return; - } - - /* Unmap tx_cmd */ - if (counter) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_TODEVICE); - - /* unmap chunks if any */ - - for (i = 1; i < counter; i++) - pci_unmap_single(dev, le32_to_cpu(tfd->tbs[i].addr), - le32_to_cpu(tfd->tbs[i].len), PCI_DMA_TODEVICE); - - /* free SKB */ - if (txq->txb) { - struct sk_buff *skb; - - skb = txq->txb[txq->q.read_ptr].skb; - - /* can be called from irqs-disabled context */ - if (skb) { - dev_kfree_skb_any(skb); - txq->txb[txq->q.read_ptr].skb = NULL; - } - } -} - -/** - * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: - * -*/ -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id) -{ - u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; - u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); - u16 rate_mask; - int rate; - u8 rts_retry_limit; - u8 data_retry_limit; - __le32 tx_flags; - __le16 fc = hdr->frame_control; - struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - - rate = il3945_rates[rate_idx].plcp; - tx_flags = tx_cmd->tx_flags; - - /* We need to figure out how to get the sta->supp_rates while - * in this running context */ - rate_mask = RATES_MASK_3945; - - /* Set retry limit on DATA packets and Probe Responses*/ - if (ieee80211_is_probe_resp(fc)) - data_retry_limit = 3; - else - data_retry_limit = IL_DEFAULT_TX_RETRY; - tx_cmd->data_retry_limit = data_retry_limit; - - if (tx_id >= IL39_CMD_QUEUE_NUM) - rts_retry_limit = 3; - else - rts_retry_limit = 7; - - if (data_retry_limit < rts_retry_limit) - rts_retry_limit = data_retry_limit; - tx_cmd->rts_retry_limit = rts_retry_limit; - - tx_cmd->rate = rate; - tx_cmd->tx_flags = tx_flags; - - /* OFDM */ - tx_cmd->supp_rates[0] = - ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; - - /* CCK */ - tx_cmd->supp_rates[1] = (rate_mask & 0xF); - - D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " - "cck/ofdm mask: 0x%x/0x%x\n", sta_id, - tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), - tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); -} - -static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) -{ - unsigned long flags_spin; - struct il_station_entry *station; - - if (sta_id == IL_INVALID_STATION) - return IL_INVALID_STATION; - - spin_lock_irqsave(&il->sta_lock, flags_spin); - station = &il->stations[sta_id]; - - station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; - station->sta.rate_n_flags = cpu_to_le16(tx_rate); - station->sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(il, &station->sta, CMD_ASYNC); - spin_unlock_irqrestore(&il->sta_lock, flags_spin); - - D_RATE("SCALE sync station %d to rate %d\n", - sta_id, tx_rate); - return sta_id; -} - -static void il3945_set_pwr_vmain(struct il_priv *il) -{ -/* - * (for documentation purposes) - * to set power to V_AUX, do - - if (pci_pme_capable(il->pci_dev, PCI_D3cold)) { - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VAUX, - ~APMG_PS_CTRL_MSK_PWR_SRC); - - _il_poll_bit(il, CSR_GPIO_IN, - CSR_GPIO_IN_VAL_VAUX_PWR_SRC, - CSR_GPIO_IN_BIT_AUX_POWER, 5000); - } - */ - - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); - - _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, - CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ -} - -static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) -{ - il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_wr(il, FH39_RCSR_RPTR_ADDR(0), - rxq->rb_stts_dma); - il_wr(il, FH39_RCSR_WPTR(0), 0); - il_wr(il, FH39_RCSR_CONFIG(0), - FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | - FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | - (RX_QUEUE_SIZE_LOG << FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) | - FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | - (1 << FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) | - FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); - - /* fake read to flush all prev I/O */ - il_rd(il, FH39_RSSR_CTRL); - - return 0; -} - -static int il3945_tx_reset(struct il_priv *il) -{ - - /* bypass mode */ - il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); - - /* RA 0 is active */ - il_wr_prph(il, ALM_SCD_ARASTAT_REG, 0x01); - - /* all 6 fifo are active */ - il_wr_prph(il, ALM_SCD_TXFACT_REG, 0x3f); - - il_wr_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - il_wr_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); - il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - - il_wr(il, FH39_TSSR_CBB_BASE, - il->_3945.shared_phys); - - il_wr(il, FH39_TSSR_MSG_CONFIG, - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); - - - return 0; -} - -/** - * il3945_txq_ctx_reset - Reset TX queue context - * - * Destroys all DMA structures and initialize them again - */ -static int il3945_txq_ctx_reset(struct il_priv *il) -{ - int rc; - int txq_id, slots_num; - - il3945_hw_txq_ctx_free(il); - - /* allocate tx queue structure */ - rc = il_alloc_txq_mem(il); - if (rc) - return rc; - - /* Tx CMD queue */ - rc = il3945_tx_reset(il); - if (rc) - goto error; - - /* Tx queue(s) */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = il_tx_queue_init(il, &il->txq[txq_id], - slots_num, txq_id); - if (rc) { - IL_ERR("Tx %d queue init failed\n", txq_id); - goto error; - } - } - - return rc; - - error: - il3945_hw_txq_ctx_free(il); - return rc; -} - - -/* - * Start up 3945's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via il_apm_stop()) - * NOTE: This does not load uCode nor start the embedded processor - */ -static int il3945_apm_init(struct il_priv *il) -{ - int ret = il_apm_init(il); - - /* Clear APMG (NIC's internal power management) interrupts */ - il_wr_prph(il, APMG_RTC_INT_MSK_REG, 0x0); - il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); - - /* Reset radio chip */ - il_set_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); - udelay(5); - il_clear_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); - - return ret; -} - -static void il3945_nic_config(struct il_priv *il) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - unsigned long flags; - u8 rev_id = il->pci_dev->revision; - - spin_lock_irqsave(&il->lock, flags); - - /* Determine HW type */ - D_INFO("HW Revision ID = 0x%X\n", rev_id); - - if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - D_INFO("RTP type\n"); - else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - D_INFO("3945 RADIO-MB type\n"); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); - } else { - D_INFO("3945 RADIO-MM type\n"); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); - } - - if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - D_INFO("SKU OP mode is mrc\n"); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); - } else - D_INFO("SKU OP mode is basic\n"); - - if ((eeprom->board_revision & 0xF0) == 0xD0) { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); - } else { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); - il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); - } - - if (eeprom->almgor_m_version <= 1) { - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - D_INFO("Card M type A version is 0x%X\n", - eeprom->almgor_m_version); - } else { - D_INFO("Card M type B version is 0x%X\n", - eeprom->almgor_m_version); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); - } - spin_unlock_irqrestore(&il->lock, flags); - - if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - D_RF_KILL("SW RF KILL supported in EEPROM.\n"); - - if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - D_RF_KILL("HW RF KILL supported in EEPROM.\n"); -} - -int il3945_hw_nic_init(struct il_priv *il) -{ - int rc; - unsigned long flags; - struct il_rx_queue *rxq = &il->rxq; - - spin_lock_irqsave(&il->lock, flags); - il->cfg->ops->lib->apm_ops.init(il); - spin_unlock_irqrestore(&il->lock, flags); - - il3945_set_pwr_vmain(il); - - il->cfg->ops->lib->apm_ops.config(il); - - /* Allocate the RX queue, or reset if it is already allocated */ - if (!rxq->bd) { - rc = il_rx_queue_alloc(il); - if (rc) { - IL_ERR("Unable to initialize Rx queue\n"); - return -ENOMEM; - } - } else - il3945_rx_queue_reset(il, rxq); - - il3945_rx_replenish(il); - - il3945_rx_init(il, rxq); - - - /* Look at using this instead: - rxq->need_update = 1; - il_rx_queue_update_write_ptr(il, rxq); - */ - - il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); - - rc = il3945_txq_ctx_reset(il); - if (rc) - return rc; - - set_bit(STATUS_INIT, &il->status); - - return 0; -} - -/** - * il3945_hw_txq_ctx_free - Free TXQ Context - * - * Destroy all TX DMA queues and structures - */ -void il3945_hw_txq_ctx_free(struct il_priv *il) -{ - int txq_id; - - /* Tx queues */ - if (il->txq) - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; - txq_id++) - if (txq_id == IL39_CMD_QUEUE_NUM) - il_cmd_queue_free(il); - else - il_tx_queue_free(il, txq_id); - - /* free tx queue structure */ - il_txq_mem(il); -} - -void il3945_hw_txq_ctx_stop(struct il_priv *il) -{ - int txq_id; - - /* stop SCD */ - il_wr_prph(il, ALM_SCD_MODE_REG, 0); - il_wr_prph(il, ALM_SCD_TXFACT_REG, 0); - - /* reset TFD queues */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); - il_poll_bit(il, FH39_TSSR_TX_STATUS, - FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), - 1000); - } - - il3945_hw_txq_ctx_free(il); -} - -/** - * il3945_hw_reg_adjust_power_by_temp - * return idx delta into power gain settings table -*/ -static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) -{ - return (new_reading - old_reading) * (-11) / 100; -} - -/** - * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range - */ -static inline int il3945_hw_reg_temp_out_of_range(int temperature) -{ - return (temperature < -260 || temperature > 25) ? 1 : 0; -} - -int il3945_hw_get_temperature(struct il_priv *il) -{ - return _il_rd(il, CSR_UCODE_DRV_GP2); -} - -/** - * il3945_hw_reg_txpower_get_temperature - * get the current temperature by reading from NIC -*/ -static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int temperature; - - temperature = il3945_hw_get_temperature(il); - - /* driver's okay range is -260 to +25. - * human readable okay range is 0 to +285 */ - D_INFO("Temperature: %d\n", temperature + IL_TEMP_CONVERT); - - /* handle insane temp reading */ - if (il3945_hw_reg_temp_out_of_range(temperature)) { - IL_ERR("Error bad temperature value %d\n", temperature); - - /* if really really hot(?), - * substitute the 3rd band/group's temp measured at factory */ - if (il->last_temperature > 100) - temperature = eeprom->groups[2].temperature; - else /* else use most recent "sane" value from driver */ - temperature = il->last_temperature; - } - - return temperature; /* raw, not "human readable" */ -} - -/* Adjust Txpower only if temperature variance is greater than threshold. - * - * Both are lower than older versions' 9 degrees */ -#define IL_TEMPERATURE_LIMIT_TIMER 6 - -/** - * il3945_is_temp_calib_needed - determines if new calibration is needed - * - * records new temperature in tx_mgr->temperature. - * replaces tx_mgr->last_temperature *only* if calib needed - * (assumes caller will actually do the calibration!). */ -static int il3945_is_temp_calib_needed(struct il_priv *il) -{ - int temp_diff; - - il->temperature = il3945_hw_reg_txpower_get_temperature(il); - temp_diff = il->temperature - il->last_temperature; - - /* get absolute value */ - if (temp_diff < 0) { - D_POWER("Getting cooler, delta %d,\n", temp_diff); - temp_diff = -temp_diff; - } else if (temp_diff == 0) - D_POWER("Same temp,\n"); - else - D_POWER("Getting warmer, delta %d,\n", temp_diff); - - /* if we don't need calibration, *don't* update last_temperature */ - if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { - D_POWER("Timed thermal calib not needed\n"); - return 0; - } - - D_POWER("Timed thermal calib needed\n"); - - /* assume that caller will actually do calib ... - * update the "last temperature" value */ - il->last_temperature = il->temperature; - return 1; -} - -#define IL_MAX_GAIN_ENTRIES 78 -#define IL_CCK_FROM_OFDM_POWER_DIFF -5 -#define IL_CCK_FROM_OFDM_IDX_DIFF (10) - -/* radio and DSP power table, each step is 1/2 dB. - * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ -static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { - { - {251, 127}, /* 2.4 GHz, highest power */ - {251, 127}, - {251, 127}, - {251, 127}, - {251, 125}, - {251, 110}, - {251, 105}, - {251, 98}, - {187, 125}, - {187, 115}, - {187, 108}, - {187, 99}, - {243, 119}, - {243, 111}, - {243, 105}, - {243, 97}, - {243, 92}, - {211, 106}, - {211, 100}, - {179, 120}, - {179, 113}, - {179, 107}, - {147, 125}, - {147, 119}, - {147, 112}, - {147, 106}, - {147, 101}, - {147, 97}, - {147, 91}, - {115, 107}, - {235, 121}, - {235, 115}, - {235, 109}, - {203, 127}, - {203, 121}, - {203, 115}, - {203, 108}, - {203, 102}, - {203, 96}, - {203, 92}, - {171, 110}, - {171, 104}, - {171, 98}, - {139, 116}, - {227, 125}, - {227, 119}, - {227, 113}, - {227, 107}, - {227, 101}, - {227, 96}, - {195, 113}, - {195, 106}, - {195, 102}, - {195, 95}, - {163, 113}, - {163, 106}, - {163, 102}, - {163, 95}, - {131, 113}, - {131, 106}, - {131, 102}, - {131, 95}, - {99, 113}, - {99, 106}, - {99, 102}, - {99, 95}, - {67, 113}, - {67, 106}, - {67, 102}, - {67, 95}, - {35, 113}, - {35, 106}, - {35, 102}, - {35, 95}, - {3, 113}, - {3, 106}, - {3, 102}, - {3, 95} }, /* 2.4 GHz, lowest power */ - { - {251, 127}, /* 5.x GHz, highest power */ - {251, 120}, - {251, 114}, - {219, 119}, - {219, 101}, - {187, 113}, - {187, 102}, - {155, 114}, - {155, 103}, - {123, 117}, - {123, 107}, - {123, 99}, - {123, 92}, - {91, 108}, - {59, 125}, - {59, 118}, - {59, 109}, - {59, 102}, - {59, 96}, - {59, 90}, - {27, 104}, - {27, 98}, - {27, 92}, - {115, 118}, - {115, 111}, - {115, 104}, - {83, 126}, - {83, 121}, - {83, 113}, - {83, 105}, - {83, 99}, - {51, 118}, - {51, 111}, - {51, 104}, - {51, 98}, - {19, 116}, - {19, 109}, - {19, 102}, - {19, 98}, - {19, 93}, - {171, 113}, - {171, 107}, - {171, 99}, - {139, 120}, - {139, 113}, - {139, 107}, - {139, 99}, - {107, 120}, - {107, 113}, - {107, 107}, - {107, 99}, - {75, 120}, - {75, 113}, - {75, 107}, - {75, 99}, - {43, 120}, - {43, 113}, - {43, 107}, - {43, 99}, - {11, 120}, - {11, 113}, - {11, 107}, - {11, 99}, - {131, 107}, - {131, 99}, - {99, 120}, - {99, 113}, - {99, 107}, - {99, 99}, - {67, 120}, - {67, 113}, - {67, 107}, - {67, 99}, - {35, 120}, - {35, 113}, - {35, 107}, - {35, 99}, - {3, 120} } /* 5.x GHz, lowest power */ -}; - -static inline u8 il3945_hw_reg_fix_power_idx(int idx) -{ - if (idx < 0) - return 0; - if (idx >= IL_MAX_GAIN_ENTRIES) - return IL_MAX_GAIN_ENTRIES - 1; - return (u8) idx; -} - -/* Kick off thermal recalibration check every 60 seconds */ -#define REG_RECALIB_PERIOD (60) - -/** - * il3945_hw_reg_set_scan_power - Set Tx power for scan probe requests - * - * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) - * or 6 Mbit (OFDM) rates. - */ -static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, - s32 rate_idx, const s8 *clip_pwrs, - struct il_channel_info *ch_info, - int band_idx) -{ - struct il3945_scan_power_info *scan_power_info; - s8 power; - u8 power_idx; - - scan_power_info = &ch_info->scan_pwr_info[scan_tbl_idx]; - - /* use this channel group's 6Mbit clipping/saturation pwr, - * but cap at regulatory scan power restriction (set during init - * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TBL]); - - power = min(power, il->tx_power_user_lmt); - scan_power_info->requested_power = power; - - /* find difference between new scan *power* and current "normal" - * Tx *power* for 6Mb. Use this difference (x2) to adjust the - * current "normal" temperature-compensated Tx power *idx* for - * this rate (1Mb or 6Mb) to yield new temp-compensated scan power - * *idx*. */ - power_idx = ch_info->power_info[rate_idx].power_table_idx - - (power - ch_info->power_info - [RATE_6M_IDX_TBL].requested_power) * 2; - - /* store reference idx that we use when adjusting *all* scan - * powers. So we can accommodate user (all channel) or spectrum - * management (single channel) power changes "between" temperature - * feedback compensation procedures. - * don't force fit this reference idx into gain table; it may be a - * negative number. This will help avoid errors when we're at - * the lower bounds (highest gains, for warmest temperatures) - * of the table. */ - - /* don't exceed table bounds for "real" setting */ - power_idx = il3945_hw_reg_fix_power_idx(power_idx); - - scan_power_info->power_table_idx = power_idx; - scan_power_info->tpc.tx_gain = - power_gain_table[band_idx][power_idx].tx_gain; - scan_power_info->tpc.dsp_atten = - power_gain_table[band_idx][power_idx].dsp_atten; -} - -/** - * il3945_send_tx_power - fill in Tx Power command with gain settings - * - * Configures power settings for all rates for the current channel, - * using values from channel info struct, and send to NIC - */ -static int il3945_send_tx_power(struct il_priv *il) -{ - int rate_idx, i; - const struct il_channel_info *ch_info = NULL; - struct il3945_txpowertable_cmd txpower = { - .channel = il->ctx.active.channel, - }; - u16 chan; - - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) - return -EAGAIN; - - chan = le16_to_cpu(il->ctx.active.channel); - - txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; - ch_info = il_get_channel_info(il, il->band, chan); - if (!ch_info) { - IL_ERR( - "Failed to get channel info for channel %d [%d]\n", - chan, il->band); - return -EINVAL; - } - - if (!il_is_channel_valid(ch_info)) { - D_POWER("Not calling TX_PWR_TBL_CMD on " - "non-Tx channel.\n"); - return 0; - } - - /* fill cmd with power settings for all rates for current channel */ - /* Fill OFDM rate */ - for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; - rate_idx <= IL39_LAST_OFDM_RATE; rate_idx++, i++) { - - txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = il3945_rates[rate_idx].plcp; - - D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); - } - /* Fill CCK rates */ - for (rate_idx = IL_FIRST_CCK_RATE; - rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { - txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = il3945_rates[rate_idx].plcp; - - D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); - } - - return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, - sizeof(struct il3945_txpowertable_cmd), - &txpower); - -} - -/** - * il3945_hw_reg_set_new_power - Configures power tables at new levels - * @ch_info: Channel to update. Uses power_info.requested_power. - * - * Replace requested_power and base_power_idx ch_info fields for - * one channel. - * - * Called if user or spectrum management changes power preferences. - * Takes into account h/w and modulation limitations (clip power). - * - * This does *not* send anything to NIC, just sets up ch_info for one channel. - * - * NOTE: reg_compensate_for_temperature_dif() *must* be run after this to - * properly fill out the scan powers, and actual h/w gain settings, - * and send changes to NIC - */ -static int il3945_hw_reg_set_new_power(struct il_priv *il, - struct il_channel_info *ch_info) -{ - struct il3945_channel_power_info *power_info; - int power_changed = 0; - int i; - const s8 *clip_pwrs; - int power; - - /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - - /* Get this channel's rate-to-current-power settings table */ - power_info = ch_info->power_info; - - /* update OFDM Txpower settings */ - for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; - i++, ++power_info) { - int delta_idx; - - /* limit new power to be no more than h/w capability */ - power = min(ch_info->curr_txpow, clip_pwrs[i]); - if (power == power_info->requested_power) - continue; - - /* find difference between old and new requested powers, - * update base (non-temp-compensated) power idx */ - delta_idx = (power - power_info->requested_power) * 2; - power_info->base_power_idx -= delta_idx; - - /* save new requested power value */ - power_info->requested_power = power; - - power_changed = 1; - } - - /* update CCK Txpower settings, based on OFDM 12M setting ... - * ... all CCK power settings for a given channel are the *same*. */ - if (power_changed) { - power = - ch_info->power_info[RATE_12M_IDX_TBL]. - requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; - - /* do all CCK rates' il3945_channel_power_info structures */ - for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { - power_info->requested_power = power; - power_info->base_power_idx = - ch_info->power_info[RATE_12M_IDX_TBL]. - base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; - ++power_info; - } - } - - return 0; -} - -/** - * il3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel - * - * NOTE: Returned power limit may be less (but not more) than requested, - * based strictly on regulatory (eeprom and spectrum mgt) limitations - * (no consideration for h/w clipping limitations). - */ -static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) -{ - s8 max_power; - -#if 0 - /* if we're using TGd limits, use lower of TGd or EEPROM */ - if (ch_info->tgd_data.max_power != 0) - max_power = min(ch_info->tgd_data.max_power, - ch_info->eeprom.max_power_avg); - - /* else just use EEPROM limits */ - else -#endif - max_power = ch_info->eeprom.max_power_avg; - - return min(max_power, ch_info->max_power_avg); -} - -/** - * il3945_hw_reg_comp_txpower_temp - Compensate for temperature - * - * Compensate txpower settings of *all* channels for temperature. - * This only accounts for the difference between current temperature - * and the factory calibration temperatures, and bases the new settings - * on the channel's base_power_idx. - * - * If RxOn is "associated", this sends the new Txpower to NIC! - */ -static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) -{ - struct il_channel_info *ch_info = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_idx; - const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ - u8 a_band; - u8 rate_idx; - u8 scan_tbl_idx; - u8 i; - int ref_temp; - int temperature = il->temperature; - - if (il->disable_tx_power_cal || - test_bit(STATUS_SCANNING, &il->status)) { - /* do not perform tx power calibration */ - return 0; - } - /* set up new Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0; i < il->channel_count; i++) { - ch_info = &il->channel_info[i]; - a_band = il_is_channel_a_band(ch_info); - - /* Get this chnlgrp's factory calibration temperature */ - ref_temp = (s16)eeprom->groups[ch_info->group_idx]. - temperature; - - /* get power idx adjustment based on current and factory - * temps */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - ref_temp); - - /* set tx power value for all rates, OFDM and CCK */ - for (rate_idx = 0; rate_idx < RATE_COUNT_3945; - rate_idx++) { - int power_idx = - ch_info->power_info[rate_idx].base_power_idx; - - /* temperature compensate */ - power_idx += delta_idx; - - /* stay within table range */ - power_idx = il3945_hw_reg_fix_power_idx(power_idx); - ch_info->power_info[rate_idx]. - power_table_idx = (u8) power_idx; - ch_info->power_info[rate_idx].tpc = - power_gain_table[a_band][power_idx]; - } - - /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - - /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; - il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, - ch_info, a_band); - } - } - - /* send Txpower command for current channel to ucode */ - return il->cfg->ops->lib->send_tx_power(il); -} - -int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) -{ - struct il_channel_info *ch_info; - s8 max_power; - u8 a_band; - u8 i; - - if (il->tx_power_user_lmt == power) { - D_POWER("Requested Tx power same as current " - "limit: %ddBm.\n", power); - return 0; - } - - D_POWER("Setting upper limit clamp to %ddBm.\n", power); - il->tx_power_user_lmt = power; - - /* set up new Tx powers for each and every channel, 2.4 and 5.x */ - - for (i = 0; i < il->channel_count; i++) { - ch_info = &il->channel_info[i]; - a_band = il_is_channel_a_band(ch_info); - - /* find minimum power of all user and regulatory constraints - * (does not consider h/w clipping limitations) */ - max_power = il3945_hw_reg_get_ch_txpower_limit(ch_info); - max_power = min(power, max_power); - if (max_power != ch_info->curr_txpow) { - ch_info->curr_txpow = max_power; - - /* this considers the h/w clipping limitations */ - il3945_hw_reg_set_new_power(il, ch_info); - } - } - - /* update txpower settings for all channels, - * send to NIC if associated. */ - il3945_is_temp_calib_needed(il); - il3945_hw_reg_comp_txpower_temp(il); - - return 0; -} - -static int il3945_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) -{ - int rc = 0; - struct il_rx_pkt *pkt; - struct il3945_rxon_assoc_cmd rxon_assoc; - struct il_host_cmd cmd = { - .id = REPLY_RXON_ASSOC, - .len = sizeof(rxon_assoc), - .flags = CMD_WANT_SKB, - .data = &rxon_assoc, - }; - const struct il_rxon_cmd *rxon1 = &ctx->staging; - const struct il_rxon_cmd *rxon2 = &ctx->active; - - if (rxon1->flags == rxon2->flags && - rxon1->filter_flags == rxon2->filter_flags && - rxon1->cck_basic_rates == rxon2->cck_basic_rates && - rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { - D_INFO("Using current RXON_ASSOC. Not resending.\n"); - return 0; - } - - rxon_assoc.flags = ctx->staging.flags; - rxon_assoc.filter_flags = ctx->staging.filter_flags; - rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; - rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; - rxon_assoc.reserved = 0; - - rc = il_send_cmd_sync(il, &cmd); - if (rc) - return rc; - - pkt = (struct il_rx_pkt *)cmd.reply_page; - if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); - rc = -EIO; - } - - il_free_pages(il, cmd.reply_page); - - return rc; -} - -/** - * il3945_commit_rxon - commit staging_rxon to hardware - * - * The RXON command in staging_rxon is committed to the hardware and - * the active_rxon structure is updated with the new data. This - * function correctly transitions out of the RXON_ASSOC_MSK state if - * a HW tune is required based on the RXON structure changes. - */ -int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) -{ - /* cast away the const for active_rxon in this function */ - struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; - struct il3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; - int rc = 0; - bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return -EINVAL; - - if (!il_is_alive(il)) - return -1; - - /* always get timestamp with Rx frame */ - staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK; - - /* select antenna */ - staging_rxon->flags &= - ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); - staging_rxon->flags |= il3945_get_antenna_flags(il); - - rc = il_check_rxon_cmd(il, ctx); - if (rc) { - IL_ERR("Invalid RXON configuration. Not committing.\n"); - return -EINVAL; - } - - /* If we don't need to send a full RXON, we can use - * il3945_rxon_assoc_cmd which is used to reconfigure filter - * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(il, - &il->ctx)) { - rc = il_send_rxon_assoc(il, - &il->ctx); - if (rc) { - IL_ERR("Error setting RXON_ASSOC " - "configuration (%d).\n", rc); - return rc; - } - - memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); - /* - * We do not commit tx power settings while channel changing, - * do it now if tx power changed. - */ - il_set_tx_power(il, il->tx_power_next, false); - return 0; - } - - /* If we are currently associated and the new config requires - * an RXON_ASSOC and the new config wants the associated mask enabled, - * we must clear the associated from the active configuration - * before we apply the new config */ - if (il_is_associated(il) && new_assoc) { - D_INFO("Toggling associated bit on current RXON\n"); - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - - /* - * reserved4 and 5 could have been filled by the iwlcore code. - * Let's clear them before pushing to the 3945. - */ - active_rxon->reserved4 = 0; - active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(il, REPLY_RXON, - sizeof(struct il3945_rxon_cmd), - &il->ctx.active); - - /* If the mask clearing failed then we set - * active_rxon back to what it was previously */ - if (rc) { - active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR("Error clearing ASSOC_MSK on current " - "configuration (%d).\n", rc); - return rc; - } - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); - } - - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(staging_rxon->channel), - staging_rxon->bssid_addr); - - /* - * reserved4 and 5 could have been filled by the iwlcore code. - * Let's clear them before pushing to the 3945. - */ - staging_rxon->reserved4 = 0; - staging_rxon->reserved5 = 0; - - il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); - - /* Apply the new configuration */ - rc = il_send_cmd_pdu(il, REPLY_RXON, - sizeof(struct il3945_rxon_cmd), - staging_rxon); - if (rc) { - IL_ERR("Error setting new configuration (%d).\n", rc); - return rc; - } - - memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); - - if (!new_assoc) { - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); - } - - /* If we issue a new RXON command which required a tune then we must - * send a new TXPOWER command or we won't be able to Tx any frames */ - rc = il_set_tx_power(il, il->tx_power_next, true); - if (rc) { - IL_ERR("Error setting Tx power (%d).\n", rc); - return rc; - } - - /* Init the hardware's rate fallback order based on the band */ - rc = il3945_init_hw_rate_table(il); - if (rc) { - IL_ERR("Error setting HW rate table: %02X\n", rc); - return -EIO; - } - - return 0; -} - -/** - * il3945_reg_txpower_periodic - called when time to check our temperature. - * - * -- reset periodic timer - * -- see if temp has changed enough to warrant re-calibration ... if so: - * -- correct coeffs for temp (can reset temp timer) - * -- save this temp as "last", - * -- send new set of gain settings to NIC - * NOTE: This should continue working, even when we're not associated, - * so we can keep our internal table of scan powers current. */ -void il3945_reg_txpower_periodic(struct il_priv *il) -{ - /* This will kick in the "brute force" - * il3945_hw_reg_comp_txpower_temp() below */ - if (!il3945_is_temp_calib_needed(il)) - goto reschedule; - - /* Set up a new set of temp-adjusted TxPowers, send to NIC. - * This is based *only* on current temperature, - * ignoring any previous power measurements */ - il3945_hw_reg_comp_txpower_temp(il); - - reschedule: - queue_delayed_work(il->workqueue, - &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); -} - -static void il3945_bg_reg_txpower_periodic(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, - _3945.thermal_periodic.work); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - mutex_lock(&il->mutex); - il3945_reg_txpower_periodic(il); - mutex_unlock(&il->mutex); -} - -/** - * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) - * for the channel. - * - * This function is used when initializing channel-info structs. - * - * NOTE: These channel groups do *NOT* match the bands above! - * These channel groups are based on factory-tested channels; - * on A-band, EEPROM's "group frequency" entries represent the top - * channel in each group 1-4. Group 5 All B/G channels are in group 0. - */ -static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, - const struct il_channel_info *ch_info) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; - u8 group; - u16 group_idx = 0; /* based on factory calib frequencies */ - u8 grp_channel; - - /* Find the group idx for the channel ... don't use idx 1(?) */ - if (il_is_channel_a_band(ch_info)) { - for (group = 1; group < 5; group++) { - grp_channel = ch_grp[group].group_channel; - if (ch_info->channel <= grp_channel) { - group_idx = group; - break; - } - } - /* group 4 has a few channels *above* its factory cal freq */ - if (group == 5) - group_idx = 4; - } else - group_idx = 0; /* 2.4 GHz, group 0 */ - - D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, - group_idx); - return group_idx; -} - -/** - * il3945_hw_reg_get_matched_power_idx - Interpolate to get nominal idx - * - * Interpolate to get nominal (i.e. at factory calibration temperature) idx - * into radio/DSP gain settings table for requested power. - */ -static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, - s8 requested_power, - s32 setting_idx, s32 *new_idx) -{ - const struct il3945_eeprom_txpower_group *chnl_grp = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - s32 idx0, idx1; - s32 power = 2 * requested_power; - s32 i; - const struct il3945_eeprom_txpower_sample *samples; - s32 gains0, gains1; - s32 res; - s32 denominator; - - chnl_grp = &eeprom->groups[setting_idx]; - samples = chnl_grp->samples; - for (i = 0; i < 5; i++) { - if (power == samples[i].power) { - *new_idx = samples[i].gain_idx; - return 0; - } - } - - if (power > samples[1].power) { - idx0 = 0; - idx1 = 1; - } else if (power > samples[2].power) { - idx0 = 1; - idx1 = 2; - } else if (power > samples[3].power) { - idx0 = 2; - idx1 = 3; - } else { - idx0 = 3; - idx1 = 4; - } - - denominator = (s32) samples[idx1].power - (s32) samples[idx0].power; - if (denominator == 0) - return -EINVAL; - gains0 = (s32) samples[idx0].gain_idx * (1 << 19); - gains1 = (s32) samples[idx1].gain_idx * (1 << 19); - res = gains0 + (gains1 - gains0) * - ((s32) power - (s32) samples[idx0].power) / denominator + - (1 << 18); - *new_idx = res >> 19; - return 0; -} - -static void il3945_hw_reg_init_channel_groups(struct il_priv *il) -{ - u32 i; - s32 rate_idx; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - const struct il3945_eeprom_txpower_group *group; - - D_POWER("Initializing factory calib info from EEPROM\n"); - - for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { - s8 *clip_pwrs; /* table of power levels for each rate */ - s8 satur_pwr; /* saturation power for each chnl group */ - group = &eeprom->groups[i]; - - /* sanity check on factory saturation power value */ - if (group->saturation_power < 40) { - IL_WARN("Error: saturation power is %d, " - "less than minimum expected 40\n", - group->saturation_power); - return; - } - - /* - * Derive requested power levels for each rate, based on - * hardware capabilities (saturation power for band). - * Basic value is 3dB down from saturation, with further - * power reductions for highest 3 data rates. These - * backoffs provide headroom for high rate modulation - * power peaks, without too much distortion (clipping). - */ - /* we'll fill in this array with h/w max power levels */ - clip_pwrs = (s8 *) il->_3945.clip_groups[i].clip_powers; - - /* divide factory saturation power by 2 to find -3dB level */ - satur_pwr = (s8) (group->saturation_power >> 1); - - /* fill in channel group's nominal powers for each rate */ - for (rate_idx = 0; - rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { - switch (rate_idx) { - case RATE_36M_IDX_TBL: - if (i == 0) /* B/G */ - *clip_pwrs = satur_pwr; - else /* A */ - *clip_pwrs = satur_pwr - 5; - break; - case RATE_48M_IDX_TBL: - if (i == 0) - *clip_pwrs = satur_pwr - 7; - else - *clip_pwrs = satur_pwr - 10; - break; - case RATE_54M_IDX_TBL: - if (i == 0) - *clip_pwrs = satur_pwr - 9; - else - *clip_pwrs = satur_pwr - 12; - break; - default: - *clip_pwrs = satur_pwr; - break; - } - } - } -} - -/** - * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM - * - * Second pass (during init) to set up il->channel_info - * - * Set up Tx-power settings in our channel info database for each VALID - * (for this geo/SKU) channel, at all Tx data rates, based on eeprom values - * and current temperature. - * - * Since this is based on current temperature (at init time), these values may - * not be valid for very long, but it gives us a starting/default point, - * and allows us to active (i.e. using Tx) scan. - * - * This does *not* write values to NIC, just sets up our internal table. - */ -int il3945_txpower_set_from_eeprom(struct il_priv *il) -{ - struct il_channel_info *ch_info = NULL; - struct il3945_channel_power_info *pwr_info; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_idx; - u8 rate_idx; - u8 scan_tbl_idx; - const s8 *clip_pwrs; /* array of power levels for each rate */ - u8 gain, dsp_atten; - s8 power; - u8 pwr_idx, base_pwr_idx, a_band; - u8 i; - int temperature; - - /* save temperature reference, - * so we can determine next time to calibrate */ - temperature = il3945_hw_reg_txpower_get_temperature(il); - il->last_temperature = temperature; - - il3945_hw_reg_init_channel_groups(il); - - /* initialize Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0, ch_info = il->channel_info; i < il->channel_count; - i++, ch_info++) { - a_band = il_is_channel_a_band(ch_info); - if (!il_is_channel_valid(ch_info)) - continue; - - /* find this channel's channel group (*not* "band") idx */ - ch_info->group_idx = - il3945_hw_reg_get_ch_grp_idx(il, ch_info); - - /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - - /* calculate power idx *adjustment* value according to - * diff between current temperature and factory temperature */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - eeprom->groups[ch_info->group_idx]. - temperature); - - D_POWER("Delta idx for channel %d: %d [%d]\n", - ch_info->channel, delta_idx, temperature + - IL_TEMP_CONVERT); - - /* set tx power value for all OFDM rates */ - for (rate_idx = 0; rate_idx < IL_OFDM_RATES; - rate_idx++) { - s32 uninitialized_var(power_idx); - int rc; - - /* use channel group's clip-power table, - * but don't exceed channel's max power */ - s8 pwr = min(ch_info->max_power_avg, - clip_pwrs[rate_idx]); - - pwr_info = &ch_info->power_info[rate_idx]; - - /* get base (i.e. at factory-measured temperature) - * power table idx for this rate's power */ - rc = il3945_hw_reg_get_matched_power_idx(il, pwr, - ch_info->group_idx, - &power_idx); - if (rc) { - IL_ERR("Invalid power idx\n"); - return rc; - } - pwr_info->base_power_idx = (u8) power_idx; - - /* temperature compensate */ - power_idx += delta_idx; - - /* stay within range of gain table */ - power_idx = il3945_hw_reg_fix_power_idx(power_idx); - - /* fill 1 OFDM rate's il3945_channel_power_info struct */ - pwr_info->requested_power = pwr; - pwr_info->power_table_idx = (u8) power_idx; - pwr_info->tpc.tx_gain = - power_gain_table[a_band][power_idx].tx_gain; - pwr_info->tpc.dsp_atten = - power_gain_table[a_band][power_idx].dsp_atten; - } - - /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; - power = pwr_info->requested_power + - IL_CCK_FROM_OFDM_POWER_DIFF; - pwr_idx = pwr_info->power_table_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; - base_pwr_idx = pwr_info->base_power_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; - - /* stay within table range */ - pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); - gain = power_gain_table[a_band][pwr_idx].tx_gain; - dsp_atten = power_gain_table[a_band][pwr_idx].dsp_atten; - - /* fill each CCK rate's il3945_channel_power_info structure - * NOTE: All CCK-rate Txpwrs are the same for a given chnl! - * NOTE: CCK rates start at end of OFDM rates! */ - for (rate_idx = 0; - rate_idx < IL_CCK_RATES; rate_idx++) { - pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; - pwr_info->requested_power = power; - pwr_info->power_table_idx = pwr_idx; - pwr_info->base_power_idx = base_pwr_idx; - pwr_info->tpc.tx_gain = gain; - pwr_info->tpc.dsp_atten = dsp_atten; - } - - /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; - il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, ch_info, a_band); - } - } - - return 0; -} - -int il3945_hw_rxq_stop(struct il_priv *il) -{ - int rc; - - il_wr(il, FH39_RCSR_CONFIG(0), 0); - rc = il_poll_bit(il, FH39_RSSR_STATUS, - FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); - if (rc < 0) - IL_ERR("Can't stop Rx DMA.\n"); - - return 0; -} - -int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) -{ - int txq_id = txq->q.id; - - struct il3945_shared *shared_data = il->_3945.shared_virt; - - shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - - il_wr(il, FH39_CBCC_CTRL(txq_id), 0); - il_wr(il, FH39_CBCC_BASE(txq_id), 0); - - il_wr(il, FH39_TCSR_CONFIG(txq_id), - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | - FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); - - /* fake read to flush all prev. writes */ - _il_rd(il, FH39_TSSR_CBB_BASE); - - return 0; -} - -/* - * HCMD utils - */ -static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) -{ - switch (cmd_id) { - case REPLY_RXON: - return sizeof(struct il3945_rxon_cmd); - case POWER_TBL_CMD: - return sizeof(struct il3945_powertable_cmd); - default: - return len; - } -} - - -static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) -{ - struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; - addsta->mode = cmd->mode; - memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); - addsta->station_flags = cmd->station_flags; - addsta->station_flags_msk = cmd->station_flags_msk; - addsta->tid_disable_tx = cpu_to_le16(0); - addsta->rate_n_flags = cmd->rate_n_flags; - addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; - addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; - addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - - return (u16)sizeof(struct il3945_addsta_cmd); -} - -static int il3945_add_bssid_station(struct il_priv *il, - const u8 *addr, u8 *sta_id_r) -{ - struct il_rxon_context *ctx = &il->ctx; - int ret; - u8 sta_id; - unsigned long flags; - - if (sta_id_r) - *sta_id_r = IL_INVALID_STATION; - - ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM\n", addr); - return ret; - } - - if (sta_id_r) - *sta_id_r = sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} -static int il3945_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) -{ - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - int ret; - - if (add) { - ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, - &vif_priv->ibss_bssid_sta_id); - if (ret) - return ret; - - il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, - (il->band == IEEE80211_BAND_5GHZ) ? - RATE_6M_PLCP : RATE_1M_PLCP); - il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); - - return 0; - } - - return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); -} - -/** - * il3945_init_hw_rate_table - Initialize the hardware rate fallback table - */ -int il3945_init_hw_rate_table(struct il_priv *il) -{ - int rc, i, idx, prev_idx; - struct il3945_rate_scaling_cmd rate_cmd = { - .reserved = {0, 0, 0}, - }; - struct il3945_rate_scaling_info *table = rate_cmd.table; - - for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { - idx = il3945_rates[i].table_rs_idx; - - table[idx].rate_n_flags = - il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); - table[idx].try_cnt = il->retry_rate; - prev_idx = il3945_get_prev_ieee_rate(i); - table[idx].next_rate_idx = - il3945_rates[prev_idx].table_rs_idx; - } - - switch (il->band) { - case IEEE80211_BAND_5GHZ: - D_RATE("Select A mode rate scale\n"); - /* If one of the following CCK rates is used, - * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_IDX_TBL; - i <= RATE_11M_IDX_TBL; i++) - table[i].next_rate_idx = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; - - /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TBL].next_rate_idx = - RATE_9M_IDX_TBL; - - /* Don't drop out of OFDM rates */ - table[RATE_6M_IDX_TBL].next_rate_idx = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; - break; - - case IEEE80211_BAND_2GHZ: - D_RATE("Select B/G mode rate scale\n"); - /* If an OFDM rate is used, have it fall back to the - * 1M CCK rates */ - - if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il)) { - - idx = IL_FIRST_CCK_RATE; - for (i = RATE_6M_IDX_TBL; - i <= RATE_54M_IDX_TBL; i++) - table[i].next_rate_idx = - il3945_rates[idx].table_rs_idx; - - idx = RATE_11M_IDX_TBL; - /* CCK shouldn't fall back to OFDM... */ - table[idx].next_rate_idx = RATE_5M_IDX_TBL; - } - break; - - default: - WARN_ON(1); - break; - } - - /* Update the rate scaling for control frame Tx */ - rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); - if (rc) - return rc; - - /* Update the rate scaling for data frame Tx */ - rate_cmd.table_id = 1; - return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); -} - -/* Called when initializing driver */ -int il3945_hw_set_hw_params(struct il_priv *il) -{ - memset((void *)&il->hw_params, 0, - sizeof(struct il_hw_params)); - - il->_3945.shared_virt = - dma_alloc_coherent(&il->pci_dev->dev, - sizeof(struct il3945_shared), - &il->_3945.shared_phys, GFP_KERNEL); - if (!il->_3945.shared_virt) { - IL_ERR("failed to allocate pci memory\n"); - return -ENOMEM; - } - - /* Assign number of Usable TX queues */ - il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; - - il->hw_params.tfd_size = sizeof(struct il3945_tfd); - il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); - il->hw_params.max_rxq_size = RX_QUEUE_SIZE; - il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - il->hw_params.max_stations = IL3945_STATION_COUNT; - il->ctx.bcast_sta_id = IL3945_BROADCAST_ID; - - il->sta_key_max_num = STA_KEY_MAX_NUM; - - il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; - il->hw_params.max_beacon_itrvl = IL39_MAX_UCODE_BEACON_INTERVAL; - il->hw_params.beacon_time_tsf_bits = IL3945_EXT_BEACON_TIME_POS; - - return 0; -} - -unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate) -{ - struct il3945_tx_beacon_cmd *tx_beacon_cmd; - unsigned int frame_size; - - tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; - memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); - - tx_beacon_cmd->tx.sta_id = - il->ctx.bcast_sta_id; - tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - - frame_size = il3945_fill_beacon_frame(il, - tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); - - BUG_ON(frame_size > MAX_MPDU_SIZE); - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); - - tx_beacon_cmd->tx.rate = rate; - tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK); - - /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ - tx_beacon_cmd->tx.supp_rates[0] = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - - tx_beacon_cmd->tx.supp_rates[1] = - (IL_CCK_BASIC_RATES_MASK & 0xF); - - return sizeof(struct il3945_tx_beacon_cmd) + frame_size; -} - -void il3945_hw_rx_handler_setup(struct il_priv *il) -{ - il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; - il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; -} - -void il3945_hw_setup_deferred_work(struct il_priv *il) -{ - INIT_DELAYED_WORK(&il->_3945.thermal_periodic, - il3945_bg_reg_txpower_periodic); -} - -void il3945_hw_cancel_deferred_work(struct il_priv *il) -{ - cancel_delayed_work(&il->_3945.thermal_periodic); -} - -/* check contents of special bootstrap uCode SRAM */ -static int il3945_verify_bsm(struct il_priv *il) - { - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - u32 reg; - u32 val; - - D_INFO("Begin verify bsm\n"); - - /* verify BSM SRAM contents */ - val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; - reg += sizeof(u32), image++) { - val = il_rd_prph(il, reg); - if (val != le32_to_cpu(*image)) { - IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); - return -EIO; - } - } - - D_INFO("BSM bootstrap uCode image OK\n"); - - return 0; -} - - -/****************************************************************************** - * - * EEPROM related functions - * - ******************************************************************************/ - -/* - * Clear the OWNER_MSK, to establish driver (instead of uCode running on - * embedded controller) as EEPROM reader; each read is a series of pulses - * to/from the EEPROM chip, not a single event, so even reads could conflict - * if they weren't arbitrated by some ownership mechanism. Here, the driver - * simply claims ownership, which should be safe when this function is called - * (i.e. before loading uCode!). - */ -static int il3945_eeprom_acquire_semaphore(struct il_priv *il) -{ - _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); - return 0; -} - - -static void il3945_eeprom_release_semaphore(struct il_priv *il) -{ - return; -} - - /** - * il3945_load_bsm - Load bootstrap instructions - * - * BSM operation: - * - * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program - * in special SRAM that does not power down during RFKILL. When powering back - * up after power-saving sleeps (or during initial uCode load), the BSM loads - * the bootstrap program into the on-board processor, and starts it. - * - * The bootstrap program loads (via DMA) instructions and data for a new - * program from host DRAM locations indicated by the host driver in the - * BSM_DRAM_* registers. Once the new program is loaded, it starts - * automatically. - * - * When initializing the NIC, the host driver points the BSM to the - * "initialize" uCode image. This uCode sets up some internal data, then - * notifies host via "initialize alive" that it is complete. - * - * The host then replaces the BSM_DRAM_* pointer values to point to the - * normal runtime uCode instructions and a backup uCode data cache buffer - * (filled initially with starting data values for the on-board processor), - * then triggers the "initialize" uCode to load and launch the runtime uCode, - * which begins normal operation. - * - * When doing a power-save shutdown, runtime uCode saves data SRAM into - * the backup data cache in DRAM before SRAM is powered down. - * - * When powering back up, the BSM loads the bootstrap program. This reloads - * the runtime uCode instructions and the backup data cache into SRAM, - * and re-launches the runtime uCode from where it left off. - */ -static int il3945_load_bsm(struct il_priv *il) -{ - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - dma_addr_t pinst; - dma_addr_t pdata; - u32 inst_len; - u32 data_len; - int rc; - int i; - u32 done; - u32 reg_offset; - - D_INFO("Begin load bsm\n"); - - /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IL39_MAX_BSM_SIZE) - return -EINVAL; - - /* Tell bootstrap uCode where to find the "Initialize" uCode - * in host DRAM ... host DRAM physical address bits 31:0 for 3945. - * NOTE: il3945_initialize_alive_start() will replace these values, - * after the "initialize" uCode has run, to point to - * runtime/protocol instructions and backup data cache. */ - pinst = il->ucode_init.p_addr; - pdata = il->ucode_init_data.p_addr; - inst_len = il->ucode_init.len; - data_len = il->ucode_init_data.len; - - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); - - /* Fill BSM memory with bootstrap instructions */ - for (reg_offset = BSM_SRAM_LOWER_BOUND; - reg_offset < BSM_SRAM_LOWER_BOUND + len; - reg_offset += sizeof(u32), image++) - _il_wr_prph(il, reg_offset, - le32_to_cpu(*image)); - - rc = il3945_verify_bsm(il); - if (rc) - return rc; - - /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, BSM_WR_MEM_DST_REG, - IL39_RTC_INST_LOWER_BOUND); - il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); - - /* Load bootstrap code into instruction SRAM now, - * to prepare to load "initialize" uCode */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START); - - /* Wait for load of bootstrap uCode to finish */ - for (i = 0; i < 100; i++) { - done = il_rd_prph(il, BSM_WR_CTRL_REG); - if (!(done & BSM_WR_CTRL_REG_BIT_START)) - break; - udelay(10); - } - if (i < 100) - D_INFO("BSM write complete, poll %d iterations\n", i); - else { - IL_ERR("BSM write did not complete!\n"); - return -EIO; - } - - /* Enable future boot loads whenever power management unit triggers it - * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START_EN); - - return 0; -} - -static struct il_hcmd_ops il3945_hcmd = { - .rxon_assoc = il3945_send_rxon_assoc, - .commit_rxon = il3945_commit_rxon, -}; - -static struct il_lib_ops il3945_lib = { - .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = il3945_hw_txq_free_tfd, - .txq_init = il3945_hw_tx_queue_init, - .load_ucode = il3945_load_bsm, - .dump_nic_error_log = il3945_dump_nic_error_log, - .apm_ops = { - .init = il3945_apm_init, - .config = il3945_nic_config, - }, - .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_REGULATORY_BAND_NO_HT40, - EEPROM_REGULATORY_BAND_NO_HT40, - }, - .acquire_semaphore = il3945_eeprom_acquire_semaphore, - .release_semaphore = il3945_eeprom_release_semaphore, - }, - .send_tx_power = il3945_send_tx_power, - .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, - - .debugfs_ops = { - .rx_stats_read = il3945_ucode_rx_stats_read, - .tx_stats_read = il3945_ucode_tx_stats_read, - .general_stats_read = il3945_ucode_general_stats_read, - }, -}; - -static const struct il_legacy_ops il3945_legacy_ops = { - .post_associate = il3945_post_associate, - .config_ap = il3945_config_ap, - .manage_ibss_station = il3945_manage_ibss_station, -}; - -static struct il_hcmd_utils_ops il3945_hcmd_utils = { - .get_hcmd_size = il3945_get_hcmd_size, - .build_addsta_hcmd = il3945_build_addsta_hcmd, - .request_scan = il3945_request_scan, - .post_scan = il3945_post_scan, -}; - -static const struct il_ops il3945_ops = { - .lib = &il3945_lib, - .hcmd = &il3945_hcmd, - .utils = &il3945_hcmd_utils, - .led = &il3945_led_ops, - .legacy = &il3945_legacy_ops, - .ieee80211_ops = &il3945_hw_ops, -}; - -static struct il_base_params il3945_base_params = { - .eeprom_size = IL3945_EEPROM_IMG_SIZE, - .num_of_queues = IL39_NUM_QUEUES, - .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, - .set_l0s = false, - .use_bsm = true, - .led_compensation = 64, - .wd_timeout = IL_DEF_WD_TIMEOUT, -}; - -static struct il_cfg il3945_bg_cfg = { - .name = "3945BG", - .fw_name_pre = IL3945_FW_PRE, - .ucode_api_max = IL3945_UCODE_API_MAX, - .ucode_api_min = IL3945_UCODE_API_MIN, - .sku = IL_SKU_G, - .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &il3945_ops, - .mod_params = &il3945_mod_params, - .base_params = &il3945_base_params, - .led_mode = IL_LED_BLINK, -}; - -static struct il_cfg il3945_abg_cfg = { - .name = "3945ABG", - .fw_name_pre = IL3945_FW_PRE, - .ucode_api_max = IL3945_UCODE_API_MAX, - .ucode_api_min = IL3945_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G, - .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &il3945_ops, - .mod_params = &il3945_mod_params, - .base_params = &il3945_base_params, - .led_mode = IL_LED_BLINK, -}; - -DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { - {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, - {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, - {0} -}; - -MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c deleted file mode 100644 index bdfb3a6..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ /dev/null @@ -1,2183 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-calib.h" -#include "iwl-sta.h" -#include "iwl-4965-led.h" -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" - -static int il4965_send_tx_power(struct il_priv *il); -static int il4965_hw_get_temperature(struct il_priv *il); - -/* Highest firmware API version supported */ -#define IL4965_UCODE_API_MAX 2 - -/* Lowest firmware API version supported */ -#define IL4965_UCODE_API_MIN 2 - -#define IL4965_FW_PRE "iwlwifi-4965-" -#define _IL4965_MODULE_FIRMWARE(api) IL4965_FW_PRE #api ".ucode" -#define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) - -/* check contents of special bootstrap uCode SRAM */ -static int il4965_verify_bsm(struct il_priv *il) -{ - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - u32 reg; - u32 val; - - D_INFO("Begin verify bsm\n"); - - /* verify BSM SRAM contents */ - val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; - reg += sizeof(u32), image++) { - val = il_rd_prph(il, reg); - if (val != le32_to_cpu(*image)) { - IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); - return -EIO; - } - } - - D_INFO("BSM bootstrap uCode image OK\n"); - - return 0; -} - -/** - * il4965_load_bsm - Load bootstrap instructions - * - * BSM operation: - * - * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program - * in special SRAM that does not power down during RFKILL. When powering back - * up after power-saving sleeps (or during initial uCode load), the BSM loads - * the bootstrap program into the on-board processor, and starts it. - * - * The bootstrap program loads (via DMA) instructions and data for a new - * program from host DRAM locations indicated by the host driver in the - * BSM_DRAM_* registers. Once the new program is loaded, it starts - * automatically. - * - * When initializing the NIC, the host driver points the BSM to the - * "initialize" uCode image. This uCode sets up some internal data, then - * notifies host via "initialize alive" that it is complete. - * - * The host then replaces the BSM_DRAM_* pointer values to point to the - * normal runtime uCode instructions and a backup uCode data cache buffer - * (filled initially with starting data values for the on-board processor), - * then triggers the "initialize" uCode to load and launch the runtime uCode, - * which begins normal operation. - * - * When doing a power-save shutdown, runtime uCode saves data SRAM into - * the backup data cache in DRAM before SRAM is powered down. - * - * When powering back up, the BSM loads the bootstrap program. This reloads - * the runtime uCode instructions and the backup data cache into SRAM, - * and re-launches the runtime uCode from where it left off. - */ -static int il4965_load_bsm(struct il_priv *il) -{ - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - dma_addr_t pinst; - dma_addr_t pdata; - u32 inst_len; - u32 data_len; - int i; - u32 done; - u32 reg_offset; - int ret; - - D_INFO("Begin load bsm\n"); - - il->ucode_type = UCODE_RT; - - /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IL49_MAX_BSM_SIZE) - return -EINVAL; - - /* Tell bootstrap uCode where to find the "Initialize" uCode - * in host DRAM ... host DRAM physical address bits 35:4 for 4965. - * NOTE: il_init_alive_start() will replace these values, - * after the "initialize" uCode has run, to point to - * runtime/protocol instructions and backup data cache. - */ - pinst = il->ucode_init.p_addr >> 4; - pdata = il->ucode_init_data.p_addr >> 4; - inst_len = il->ucode_init.len; - data_len = il->ucode_init_data.len; - - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); - - /* Fill BSM memory with bootstrap instructions */ - for (reg_offset = BSM_SRAM_LOWER_BOUND; - reg_offset < BSM_SRAM_LOWER_BOUND + len; - reg_offset += sizeof(u32), image++) - _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); - - ret = il4965_verify_bsm(il); - if (ret) - return ret; - - /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, - BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); - il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); - - /* Load bootstrap code into instruction SRAM now, - * to prepare to load "initialize" uCode */ - il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); - - /* Wait for load of bootstrap uCode to finish */ - for (i = 0; i < 100; i++) { - done = il_rd_prph(il, BSM_WR_CTRL_REG); - if (!(done & BSM_WR_CTRL_REG_BIT_START)) - break; - udelay(10); - } - if (i < 100) - D_INFO("BSM write complete, poll %d iterations\n", i); - else { - IL_ERR("BSM write did not complete!\n"); - return -EIO; - } - - /* Enable future boot loads whenever power management unit triggers it - * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, - BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); - - - return 0; -} - -/** - * il4965_set_ucode_ptrs - Set uCode address location - * - * Tell initialization uCode where to find runtime uCode. - * - * BSM registers initially contain pointers to initialization uCode. - * We need to replace them to load runtime uCode inst and data, - * and to save runtime data when powering down. - */ -static int il4965_set_ucode_ptrs(struct il_priv *il) -{ - dma_addr_t pinst; - dma_addr_t pdata; - int ret = 0; - - /* bits 35:4 for 4965 */ - pinst = il->ucode_code.p_addr >> 4; - pdata = il->ucode_data_backup.p_addr >> 4; - - /* Tell bootstrap uCode where to find image to load */ - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); - - /* Inst byte count must be last to set up, bit 31 signals uCode - * that all new ptr/size info is in place */ - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); - D_INFO("Runtime uCode pointers are set.\n"); - - return ret; -} - -/** - * il4965_init_alive_start - Called after REPLY_ALIVE notification received - * - * Called after REPLY_ALIVE notification received from "initialize" uCode. - * - * The 4965 "initialize" ALIVE reply contains calibration data for: - * Voltage, temperature, and MIMO tx gain correction, now stored in il - * (3945 does not contain this data). - * - * Tell "initialize" uCode to go ahead and load the runtime uCode. -*/ -static void il4965_init_alive_start(struct il_priv *il) -{ - /* Bootstrap uCode has loaded initialize uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "initialize" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad \"initialize\" uCode load.\n"); - goto restart; - } - - /* Calculate temperature */ - il->temperature = il4965_hw_get_temperature(il); - - /* Send pointers to protocol/runtime uCode image ... init code will - * load and launch runtime uCode, which will send us another "Alive" - * notification. */ - D_INFO("Initialization Alive received.\n"); - if (il4965_set_ucode_ptrs(il)) { - /* Runtime instruction load won't happen; - * take it all the way back down so we can try again */ - D_INFO("Couldn't set up uCode pointers.\n"); - goto restart; - } - return; - -restart: - queue_work(il->workqueue, &il->restart); -} - -static bool iw4965_is_ht40_channel(__le32 rxon_flags) -{ - int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; - return (chan_mod == CHANNEL_MODE_PURE_40 || - chan_mod == CHANNEL_MODE_MIXED); -} - -static void il4965_nic_config(struct il_priv *il) -{ - unsigned long flags; - u16 radio_cfg; - - spin_lock_irqsave(&il->lock, flags); - - radio_cfg = il_eeprom_query16(il, EEPROM_RADIO_CONFIG); - - /* write radio config values to register */ - if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | - EEPROM_RF_CFG_STEP_MSK(radio_cfg) | - EEPROM_RF_CFG_DASH_MSK(radio_cfg)); - - /* set CSR_HW_CONFIG_REG for uCode use */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | - CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - - il->calib_info = (struct il_eeprom_calib_info *) - il_eeprom_query_addr(il, - EEPROM_4965_CALIB_TXPOWER_OFFSET); - - spin_unlock_irqrestore(&il->lock, flags); -} - -/* Reset differential Rx gains in NIC to prepare for chain noise calibration. - * Called after every association, but this runs only once! - * ... once chain noise is calibrated the first time, it's good forever. */ -static void il4965_chain_noise_reset(struct il_priv *il) -{ - struct il_chain_noise_data *data = &(il->chain_noise_data); - - if (data->state == IL_CHAIN_NOISE_ALIVE && - il_is_any_associated(il)) { - struct il_calib_diff_gain_cmd cmd; - - /* clear data for chain noise calibration algorithm */ - data->chain_noise_a = 0; - data->chain_noise_b = 0; - data->chain_noise_c = 0; - data->chain_signal_a = 0; - data->chain_signal_b = 0; - data->chain_signal_c = 0; - data->beacon_count = 0; - - memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; - cmd.diff_gain_a = 0; - cmd.diff_gain_b = 0; - cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, - sizeof(cmd), &cmd)) - IL_ERR( - "Could not send REPLY_PHY_CALIBRATION_CMD\n"); - data->state = IL_CHAIN_NOISE_ACCUMULATE; - D_CALIB("Run chain_noise_calibrate\n"); - } -} - -static struct il_sensitivity_ranges il4965_sensitivity = { - .min_nrg_cck = 97, - .max_nrg_cck = 0, /* not used, set to 0 */ - - .auto_corr_min_ofdm = 85, - .auto_corr_min_ofdm_mrc = 170, - .auto_corr_min_ofdm_x1 = 105, - .auto_corr_min_ofdm_mrc_x1 = 220, - - .auto_corr_max_ofdm = 120, - .auto_corr_max_ofdm_mrc = 210, - .auto_corr_max_ofdm_x1 = 140, - .auto_corr_max_ofdm_mrc_x1 = 270, - - .auto_corr_min_cck = 125, - .auto_corr_max_cck = 200, - .auto_corr_min_cck_mrc = 200, - .auto_corr_max_cck_mrc = 400, - - .nrg_th_cck = 100, - .nrg_th_ofdm = 100, - - .barker_corr_th_min = 190, - .barker_corr_th_min_mrc = 390, - .nrg_th_cca = 62, -}; - -static void il4965_set_ct_threshold(struct il_priv *il) -{ - /* want Kelvin */ - il->hw_params.ct_kill_threshold = - CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); -} - -/** - * il4965_hw_set_hw_params - * - * Called when initializing driver - */ -static int il4965_hw_set_hw_params(struct il_priv *il) -{ - if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && - il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) - il->cfg->base_params->num_of_queues = - il->cfg->mod_params->num_of_queues; - - il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; - il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; - il->hw_params.scd_bc_tbls_size = - il->cfg->base_params->num_of_queues * - sizeof(struct il4965_scd_bc_tbl); - il->hw_params.tfd_size = sizeof(struct il_tfd); - il->hw_params.max_stations = IL4965_STATION_COUNT; - il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; - il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; - il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; - il->hw_params.max_bsm_size = BSM_SRAM_SIZE; - il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); - - il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; - - il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); - il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); - il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; - il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; - - il4965_set_ct_threshold(il); - - il->hw_params.sens = &il4965_sensitivity; - il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; - - return 0; -} - -static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) -{ - s32 sign = 1; - - if (num < 0) { - sign = -sign; - num = -num; - } - if (denom < 0) { - sign = -sign; - denom = -denom; - } - *res = 1; - *res = ((num * 2 + denom) / (denom * 2)) * sign; - - return 1; -} - -/** - * il4965_get_voltage_compensation - Power supply voltage comp for txpower - * - * Determines power supply voltage compensation for txpower calculations. - * Returns number of 1/2-dB steps to subtract from gain table idx, - * to compensate for difference between power supply voltage during - * factory measurements, vs. current power supply voltage. - * - * Voltage indication is higher for lower voltage. - * Lower voltage requires more gain (lower gain table idx). - */ -static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, - s32 current_voltage) -{ - s32 comp = 0; - - if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage || - TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage) - return 0; - - il4965_math_div_round(current_voltage - eeprom_voltage, - TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); - - if (current_voltage > eeprom_voltage) - comp *= 2; - if ((comp < -2) || (comp > 2)) - comp = 0; - - return comp; -} - -static s32 il4965_get_tx_atten_grp(u16 channel) -{ - if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && - channel <= CALIB_IL_TX_ATTEN_GR5_LCH) - return CALIB_CH_GROUP_5; - - if (channel >= CALIB_IL_TX_ATTEN_GR1_FCH && - channel <= CALIB_IL_TX_ATTEN_GR1_LCH) - return CALIB_CH_GROUP_1; - - if (channel >= CALIB_IL_TX_ATTEN_GR2_FCH && - channel <= CALIB_IL_TX_ATTEN_GR2_LCH) - return CALIB_CH_GROUP_2; - - if (channel >= CALIB_IL_TX_ATTEN_GR3_FCH && - channel <= CALIB_IL_TX_ATTEN_GR3_LCH) - return CALIB_CH_GROUP_3; - - if (channel >= CALIB_IL_TX_ATTEN_GR4_FCH && - channel <= CALIB_IL_TX_ATTEN_GR4_LCH) - return CALIB_CH_GROUP_4; - - return -EINVAL; -} - -static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) -{ - s32 b = -1; - - for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { - if (il->calib_info->band_info[b].ch_from == 0) - continue; - - if (channel >= il->calib_info->band_info[b].ch_from && - channel <= il->calib_info->band_info[b].ch_to) - break; - } - - return b; -} - -static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) -{ - s32 val; - - if (x2 == x1) - return y1; - else { - il4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); - return val + y2; - } -} - -/** - * il4965_interpolate_chan - Interpolate factory measurements for one channel - * - * Interpolates factory measurements from the two sample channels within a - * sub-band, to apply to channel of interest. Interpolation is proportional to - * differences in channel frequencies, which is proportional to differences - * in channel number. - */ -static int il4965_interpolate_chan(struct il_priv *il, u32 channel, - struct il_eeprom_calib_ch_info *chan_info) -{ - s32 s = -1; - u32 c; - u32 m; - const struct il_eeprom_calib_measure *m1; - const struct il_eeprom_calib_measure *m2; - struct il_eeprom_calib_measure *omeas; - u32 ch_i1; - u32 ch_i2; - - s = il4965_get_sub_band(il, channel); - if (s >= EEPROM_TX_POWER_BANDS) { - IL_ERR("Tx Power can not find channel %d\n", channel); - return -1; - } - - ch_i1 = il->calib_info->band_info[s].ch1.ch_num; - ch_i2 = il->calib_info->band_info[s].ch2.ch_num; - chan_info->ch_num = (u8) channel; - - D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", - channel, s, ch_i1, ch_i2); - - for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { - for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { - m1 = &(il->calib_info->band_info[s].ch1. - measurements[c][m]); - m2 = &(il->calib_info->band_info[s].ch2. - measurements[c][m]); - omeas = &(chan_info->measurements[c][m]); - - omeas->actual_pow = - (u8) il4965_interpolate_value(channel, ch_i1, - m1->actual_pow, - ch_i2, - m2->actual_pow); - omeas->gain_idx = - (u8) il4965_interpolate_value(channel, ch_i1, - m1->gain_idx, ch_i2, - m2->gain_idx); - omeas->temperature = - (u8) il4965_interpolate_value(channel, ch_i1, - m1->temperature, - ch_i2, - m2->temperature); - omeas->pa_det = - (s8) il4965_interpolate_value(channel, ch_i1, - m1->pa_det, ch_i2, - m2->pa_det); - - D_TXPOWER( - "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, - m1->actual_pow, m2->actual_pow, omeas->actual_pow); - D_TXPOWER( - "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, - m1->gain_idx, m2->gain_idx, omeas->gain_idx); - D_TXPOWER( - "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, - m1->pa_det, m2->pa_det, omeas->pa_det); - D_TXPOWER( - "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, - m1->temperature, m2->temperature, - omeas->temperature); - } - } - - return 0; -} - -/* bit-rate-dependent table to prevent Tx distortion, in half-dB units, - * for OFDM 6, 12, 18, 24, 36, 48, 54, 60 MBit, and CCK all rates. */ -static s32 back_off_table[] = { - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 20 MHz */ - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 20 MHz */ - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 40 MHz */ - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 40 MHz */ - 10 /* CCK */ -}; - -/* Thermal compensation values for txpower for various frequency ranges ... - * ratios from 3:1 to 4.5:1 of degrees (Celsius) per half-dB gain adjust */ -static struct il4965_txpower_comp_entry { - s32 degrees_per_05db_a; - s32 degrees_per_05db_a_denom; -} tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { - {9, 2}, /* group 0 5.2, ch 34-43 */ - {4, 1}, /* group 1 5.2, ch 44-70 */ - {4, 1}, /* group 2 5.2, ch 71-124 */ - {4, 1}, /* group 3 5.2, ch 125-200 */ - {3, 1} /* group 4 2.4, ch all */ -}; - -static s32 get_min_power_idx(s32 rate_power_idx, u32 band) -{ - if (!band) { - if ((rate_power_idx & 7) <= 4) - return MIN_TX_GAIN_IDX_52GHZ_EXT; - } - return MIN_TX_GAIN_IDX; -} - -struct gain_entry { - u8 dsp; - u8 radio; -}; - -static const struct gain_entry gain_table[2][108] = { - /* 5.2GHz power gain idx table */ - { - {123, 0x3F}, /* highest txpower */ - {117, 0x3F}, - {110, 0x3F}, - {104, 0x3F}, - {98, 0x3F}, - {110, 0x3E}, - {104, 0x3E}, - {98, 0x3E}, - {110, 0x3D}, - {104, 0x3D}, - {98, 0x3D}, - {110, 0x3C}, - {104, 0x3C}, - {98, 0x3C}, - {110, 0x3B}, - {104, 0x3B}, - {98, 0x3B}, - {110, 0x3A}, - {104, 0x3A}, - {98, 0x3A}, - {110, 0x39}, - {104, 0x39}, - {98, 0x39}, - {110, 0x38}, - {104, 0x38}, - {98, 0x38}, - {110, 0x37}, - {104, 0x37}, - {98, 0x37}, - {110, 0x36}, - {104, 0x36}, - {98, 0x36}, - {110, 0x35}, - {104, 0x35}, - {98, 0x35}, - {110, 0x34}, - {104, 0x34}, - {98, 0x34}, - {110, 0x33}, - {104, 0x33}, - {98, 0x33}, - {110, 0x32}, - {104, 0x32}, - {98, 0x32}, - {110, 0x31}, - {104, 0x31}, - {98, 0x31}, - {110, 0x30}, - {104, 0x30}, - {98, 0x30}, - {110, 0x25}, - {104, 0x25}, - {98, 0x25}, - {110, 0x24}, - {104, 0x24}, - {98, 0x24}, - {110, 0x23}, - {104, 0x23}, - {98, 0x23}, - {110, 0x22}, - {104, 0x18}, - {98, 0x18}, - {110, 0x17}, - {104, 0x17}, - {98, 0x17}, - {110, 0x16}, - {104, 0x16}, - {98, 0x16}, - {110, 0x15}, - {104, 0x15}, - {98, 0x15}, - {110, 0x14}, - {104, 0x14}, - {98, 0x14}, - {110, 0x13}, - {104, 0x13}, - {98, 0x13}, - {110, 0x12}, - {104, 0x08}, - {98, 0x08}, - {110, 0x07}, - {104, 0x07}, - {98, 0x07}, - {110, 0x06}, - {104, 0x06}, - {98, 0x06}, - {110, 0x05}, - {104, 0x05}, - {98, 0x05}, - {110, 0x04}, - {104, 0x04}, - {98, 0x04}, - {110, 0x03}, - {104, 0x03}, - {98, 0x03}, - {110, 0x02}, - {104, 0x02}, - {98, 0x02}, - {110, 0x01}, - {104, 0x01}, - {98, 0x01}, - {110, 0x00}, - {104, 0x00}, - {98, 0x00}, - {93, 0x00}, - {88, 0x00}, - {83, 0x00}, - {78, 0x00}, - }, - /* 2.4GHz power gain idx table */ - { - {110, 0x3f}, /* highest txpower */ - {104, 0x3f}, - {98, 0x3f}, - {110, 0x3e}, - {104, 0x3e}, - {98, 0x3e}, - {110, 0x3d}, - {104, 0x3d}, - {98, 0x3d}, - {110, 0x3c}, - {104, 0x3c}, - {98, 0x3c}, - {110, 0x3b}, - {104, 0x3b}, - {98, 0x3b}, - {110, 0x3a}, - {104, 0x3a}, - {98, 0x3a}, - {110, 0x39}, - {104, 0x39}, - {98, 0x39}, - {110, 0x38}, - {104, 0x38}, - {98, 0x38}, - {110, 0x37}, - {104, 0x37}, - {98, 0x37}, - {110, 0x36}, - {104, 0x36}, - {98, 0x36}, - {110, 0x35}, - {104, 0x35}, - {98, 0x35}, - {110, 0x34}, - {104, 0x34}, - {98, 0x34}, - {110, 0x33}, - {104, 0x33}, - {98, 0x33}, - {110, 0x32}, - {104, 0x32}, - {98, 0x32}, - {110, 0x31}, - {104, 0x31}, - {98, 0x31}, - {110, 0x30}, - {104, 0x30}, - {98, 0x30}, - {110, 0x6}, - {104, 0x6}, - {98, 0x6}, - {110, 0x5}, - {104, 0x5}, - {98, 0x5}, - {110, 0x4}, - {104, 0x4}, - {98, 0x4}, - {110, 0x3}, - {104, 0x3}, - {98, 0x3}, - {110, 0x2}, - {104, 0x2}, - {98, 0x2}, - {110, 0x1}, - {104, 0x1}, - {98, 0x1}, - {110, 0x0}, - {104, 0x0}, - {98, 0x0}, - {97, 0}, - {96, 0}, - {95, 0}, - {94, 0}, - {93, 0}, - {92, 0}, - {91, 0}, - {90, 0}, - {89, 0}, - {88, 0}, - {87, 0}, - {86, 0}, - {85, 0}, - {84, 0}, - {83, 0}, - {82, 0}, - {81, 0}, - {80, 0}, - {79, 0}, - {78, 0}, - {77, 0}, - {76, 0}, - {75, 0}, - {74, 0}, - {73, 0}, - {72, 0}, - {71, 0}, - {70, 0}, - {69, 0}, - {68, 0}, - {67, 0}, - {66, 0}, - {65, 0}, - {64, 0}, - {63, 0}, - {62, 0}, - {61, 0}, - {60, 0}, - {59, 0}, - } -}; - -static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, - u8 is_ht40, u8 ctrl_chan_high, - struct il4965_tx_power_db *tx_power_tbl) -{ - u8 saturation_power; - s32 target_power; - s32 user_target_power; - s32 power_limit; - s32 current_temp; - s32 reg_limit; - s32 current_regulatory; - s32 txatten_grp = CALIB_CH_GROUP_MAX; - int i; - int c; - const struct il_channel_info *ch_info = NULL; - struct il_eeprom_calib_ch_info ch_eeprom_info; - const struct il_eeprom_calib_measure *measurement; - s16 voltage; - s32 init_voltage; - s32 voltage_compensation; - s32 degrees_per_05db_num; - s32 degrees_per_05db_denom; - s32 factory_temp; - s32 temperature_comp[2]; - s32 factory_gain_idx[2]; - s32 factory_actual_pwr[2]; - s32 power_idx; - - /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units - * are used for idxing into txpower table) */ - user_target_power = 2 * il->tx_power_user_lmt; - - /* Get current (RXON) channel, band, width */ - D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, - is_ht40); - - ch_info = il_get_channel_info(il, il->band, channel); - - if (!il_is_channel_valid(ch_info)) - return -EINVAL; - - /* get txatten group, used to select 1) thermal txpower adjustment - * and 2) mimo txpower balance between Tx chains. */ - txatten_grp = il4965_get_tx_atten_grp(channel); - if (txatten_grp < 0) { - IL_ERR("Can't find txatten group for channel %d.\n", - channel); - return txatten_grp; - } - - D_TXPOWER("channel %d belongs to txatten group %d\n", - channel, txatten_grp); - - if (is_ht40) { - if (ctrl_chan_high) - channel -= 2; - else - channel += 2; - } - - /* hardware txpower limits ... - * saturation (clipping distortion) txpowers are in half-dBm */ - if (band) - saturation_power = il->calib_info->saturation_power24; - else - saturation_power = il->calib_info->saturation_power52; - - if (saturation_power < IL_TX_POWER_SATURATION_MIN || - saturation_power > IL_TX_POWER_SATURATION_MAX) { - if (band) - saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24; - else - saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52; - } - - /* regulatory txpower limits ... reg_limit values are in half-dBm, - * max_power_avg values are in dBm, convert * 2 */ - if (is_ht40) - reg_limit = ch_info->ht40_max_power_avg * 2; - else - reg_limit = ch_info->max_power_avg * 2; - - if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) || - (reg_limit > IL_TX_POWER_REGULATORY_MAX)) { - if (band) - reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24; - else - reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52; - } - - /* Interpolate txpower calibration values for this channel, - * based on factory calibration tests on spaced channels. */ - il4965_interpolate_chan(il, channel, &ch_eeprom_info); - - /* calculate tx gain adjustment based on power supply voltage */ - voltage = le16_to_cpu(il->calib_info->voltage); - init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); - voltage_compensation = - il4965_get_voltage_compensation(voltage, init_voltage); - - D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", - init_voltage, - voltage, voltage_compensation); - - /* get current temperature (Celsius) */ - current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); - current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); - current_temp = KELVIN_TO_CELSIUS(current_temp); - - /* select thermal txpower adjustment params, based on channel group - * (same frequency group used for mimo txatten adjustment) */ - degrees_per_05db_num = - tx_power_cmp_tble[txatten_grp].degrees_per_05db_a; - degrees_per_05db_denom = - tx_power_cmp_tble[txatten_grp].degrees_per_05db_a_denom; - - /* get per-chain txpower values from factory measurements */ - for (c = 0; c < 2; c++) { - measurement = &ch_eeprom_info.measurements[c][1]; - - /* txgain adjustment (in half-dB steps) based on difference - * between factory and current temperature */ - factory_temp = measurement->temperature; - il4965_math_div_round((current_temp - factory_temp) * - degrees_per_05db_denom, - degrees_per_05db_num, - &temperature_comp[c]); - - factory_gain_idx[c] = measurement->gain_idx; - factory_actual_pwr[c] = measurement->actual_pow; - - D_TXPOWER("chain = %d\n", c); - D_TXPOWER("fctry tmp %d, " - "curr tmp %d, comp %d steps\n", - factory_temp, current_temp, - temperature_comp[c]); - - D_TXPOWER("fctry idx %d, fctry pwr %d\n", - factory_gain_idx[c], - factory_actual_pwr[c]); - } - - /* for each of 33 bit-rates (including 1 for CCK) */ - for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) { - u8 is_mimo_rate; - union il4965_tx_power_dual_stream tx_power; - - /* for mimo, reduce each chain's txpower by half - * (3dB, 6 steps), so total output power is regulatory - * compliant. */ - if (i & 0x8) { - current_regulatory = reg_limit - - IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; - is_mimo_rate = 1; - } else { - current_regulatory = reg_limit; - is_mimo_rate = 0; - } - - /* find txpower limit, either hardware or regulatory */ - power_limit = saturation_power - back_off_table[i]; - if (power_limit > current_regulatory) - power_limit = current_regulatory; - - /* reduce user's txpower request if necessary - * for this rate on this channel */ - target_power = user_target_power; - if (target_power > power_limit) - target_power = power_limit; - - D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", - i, saturation_power - back_off_table[i], - current_regulatory, user_target_power, - target_power); - - /* for each of 2 Tx chains (radio transmitters) */ - for (c = 0; c < 2; c++) { - s32 atten_value; - - if (is_mimo_rate) - atten_value = - (s32)le32_to_cpu(il->card_alive_init. - tx_atten[txatten_grp][c]); - else - atten_value = 0; - - /* calculate idx; higher idx means lower txpower */ - power_idx = (u8) (factory_gain_idx[c] - - (target_power - - factory_actual_pwr[c]) - - temperature_comp[c] - - voltage_compensation + - atten_value); - -/* D_TXPOWER("calculated txpower idx %d\n", - power_idx); */ - - if (power_idx < get_min_power_idx(i, band)) - power_idx = get_min_power_idx(i, band); - - /* adjust 5 GHz idx to support negative idxes */ - if (!band) - power_idx += 9; - - /* CCK, rate 32, reduce txpower for CCK */ - if (i == POWER_TBL_CCK_ENTRY) - power_idx += - IL_TX_POWER_CCK_COMPENSATION_C_STEP; - - /* stay within the table! */ - if (power_idx > 107) { - IL_WARN("txpower idx %d > 107\n", - power_idx); - power_idx = 107; - } - if (power_idx < 0) { - IL_WARN("txpower idx %d < 0\n", - power_idx); - power_idx = 0; - } - - /* fill txpower command for this rate/chain */ - tx_power.s.radio_tx_gain[c] = - gain_table[band][power_idx].radio; - tx_power.s.dsp_predis_atten[c] = - gain_table[band][power_idx].dsp; - - D_TXPOWER("chain %d mimo %d idx %d " - "gain 0x%02x dsp %d\n", - c, atten_value, power_idx, - tx_power.s.radio_tx_gain[c], - tx_power.s.dsp_predis_atten[c]); - } /* for each chain */ - - tx_power_tbl->power_tbl[i].dw = cpu_to_le32(tx_power.dw); - - } /* for each rate */ - - return 0; -} - -/** - * il4965_send_tx_power - Configure the TXPOWER level user limit - * - * Uses the active RXON for channel, band, and characteristics (ht40, high) - * The power limit is taken from il->tx_power_user_lmt. - */ -static int il4965_send_tx_power(struct il_priv *il) -{ - struct il4965_txpowertable_cmd cmd = { 0 }; - int ret; - u8 band = 0; - bool is_ht40 = false; - u8 ctrl_chan_high = 0; - struct il_rxon_context *ctx = &il->ctx; - - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) - return -EAGAIN; - - band = il->band == IEEE80211_BAND_2GHZ; - - is_ht40 = iw4965_is_ht40_channel(ctx->active.flags); - - if (is_ht40 && (ctx->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) - ctrl_chan_high = 1; - - cmd.band = band; - cmd.channel = ctx->active.channel; - - ret = il4965_fill_txpower_tbl(il, band, - le16_to_cpu(ctx->active.channel), - is_ht40, ctrl_chan_high, &cmd.tx_power); - if (ret) - goto out; - - ret = il_send_cmd_pdu(il, - REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); - -out: - return ret; -} - -static int il4965_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) -{ - int ret = 0; - struct il4965_rxon_assoc_cmd rxon_assoc; - const struct il_rxon_cmd *rxon1 = &ctx->staging; - const struct il_rxon_cmd *rxon2 = &ctx->active; - - if (rxon1->flags == rxon2->flags && - rxon1->filter_flags == rxon2->filter_flags && - rxon1->cck_basic_rates == rxon2->cck_basic_rates && - rxon1->ofdm_ht_single_stream_basic_rates == - rxon2->ofdm_ht_single_stream_basic_rates && - rxon1->ofdm_ht_dual_stream_basic_rates == - rxon2->ofdm_ht_dual_stream_basic_rates && - rxon1->rx_chain == rxon2->rx_chain && - rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { - D_INFO("Using current RXON_ASSOC. Not resending.\n"); - return 0; - } - - rxon_assoc.flags = ctx->staging.flags; - rxon_assoc.filter_flags = ctx->staging.filter_flags; - rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; - rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; - rxon_assoc.reserved = 0; - rxon_assoc.ofdm_ht_single_stream_basic_rates = - ctx->staging.ofdm_ht_single_stream_basic_rates; - rxon_assoc.ofdm_ht_dual_stream_basic_rates = - ctx->staging.ofdm_ht_dual_stream_basic_rates; - rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - - ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, - sizeof(rxon_assoc), &rxon_assoc, NULL); - - return ret; -} - -static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) -{ - /* cast away the const for active_rxon in this function */ - struct il_rxon_cmd *active_rxon = (void *)&ctx->active; - int ret; - bool new_assoc = - !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); - - if (!il_is_alive(il)) - return -EBUSY; - - if (!ctx->is_active) - return 0; - - /* always get timestamp with Rx frame */ - ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; - - ret = il_check_rxon_cmd(il, ctx); - if (ret) { - IL_ERR("Invalid RXON configuration. Not committing.\n"); - return -EINVAL; - } - - /* - * receive commit_rxon request - * abort any previous channel switch if still in process - */ - if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && - il->switch_channel != ctx->staging.channel) { - D_11H("abort channel switch on %d\n", - le16_to_cpu(il->switch_channel)); - il_chswitch_done(il, false); - } - - /* If we don't need to send a full RXON, we can use - * il_rxon_assoc_cmd which is used to reconfigure filter - * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(il, ctx)) { - ret = il_send_rxon_assoc(il, ctx); - if (ret) { - IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); - return ret; - } - - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_print_rx_config_cmd(il, ctx); - /* - * We do not commit tx power settings while channel changing, - * do it now if tx power changed. - */ - il_set_tx_power(il, il->tx_power_next, false); - return 0; - } - - /* If we are currently associated and the new config requires - * an RXON_ASSOC and the new config wants the associated mask enabled, - * we must clear the associated from the active configuration - * before we apply the new config */ - if (il_is_associated_ctx(ctx) && new_assoc) { - D_INFO("Toggling associated bit on current RXON\n"); - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), - active_rxon); - - /* If the mask clearing failed then we set - * active_rxon back to what it was previously */ - if (ret) { - active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret); - return ret; - } - il_clear_ucode_stations(il, ctx); - il_restore_stations(il, ctx); - ret = il4965_restore_default_wep_keys(il, ctx); - if (ret) { - IL_ERR("Failed to restore WEP keys (%d)\n", ret); - return ret; - } - } - - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(ctx->staging.channel), - ctx->staging.bssid_addr); - - il_set_rxon_hwcrypto(il, ctx, - !il->cfg->mod_params->sw_crypto); - - /* Apply the new configuration - * RXON unassoc clears the station table in uCode so restoration of - * stations is needed after it (the RXON command) completes - */ - if (!new_assoc) { - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); - if (ret) { - IL_ERR("Error setting new RXON (%d)\n", ret); - return ret; - } - D_INFO("Return from !new_assoc RXON.\n"); - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_clear_ucode_stations(il, ctx); - il_restore_stations(il, ctx); - ret = il4965_restore_default_wep_keys(il, ctx); - if (ret) { - IL_ERR("Failed to restore WEP keys (%d)\n", ret); - return ret; - } - } - if (new_assoc) { - il->start_calib = 0; - /* Apply the new configuration - * RXON assoc doesn't clear the station table in uCode, - */ - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); - if (ret) { - IL_ERR("Error setting new RXON (%d)\n", ret); - return ret; - } - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - } - il_print_rx_config_cmd(il, ctx); - - il4965_init_sensitivity(il); - - /* If we issue a new RXON command which required a tune then we must - * send a new TXPOWER command or we won't be able to Tx any frames */ - ret = il_set_tx_power(il, il->tx_power_next, true); - if (ret) { - IL_ERR("Error sending TX power (%d)\n", ret); - return ret; - } - - return 0; -} - -static int il4965_hw_channel_switch(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch) -{ - struct il_rxon_context *ctx = &il->ctx; - int rc; - u8 band = 0; - bool is_ht40 = false; - u8 ctrl_chan_high = 0; - struct il4965_channel_switch_cmd cmd; - const struct il_channel_info *ch_info; - u32 switch_time_in_usec, ucode_switch_time; - u16 ch; - u32 tsf_low; - u8 switch_count; - u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval); - struct ieee80211_vif *vif = ctx->vif; - band = il->band == IEEE80211_BAND_2GHZ; - - is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); - - if (is_ht40 && - (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) - ctrl_chan_high = 1; - - cmd.band = band; - cmd.expect_beacon = 0; - ch = ch_switch->channel->hw_value; - cmd.channel = cpu_to_le16(ch); - cmd.rxon_flags = ctx->staging.flags; - cmd.rxon_filter_flags = ctx->staging.filter_flags; - switch_count = ch_switch->count; - tsf_low = ch_switch->timestamp & 0x0ffffffff; - /* - * calculate the ucode channel switch time - * adding TSF as one of the factor for when to switch - */ - if (il->ucode_beacon_time > tsf_low && beacon_interval) { - if (switch_count > ((il->ucode_beacon_time - tsf_low) / - beacon_interval)) { - switch_count -= (il->ucode_beacon_time - - tsf_low) / beacon_interval; - } else - switch_count = 0; - } - if (switch_count <= 1) - cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); - else { - switch_time_in_usec = - vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = il_usecs_to_beacons(il, - switch_time_in_usec, - beacon_interval); - cmd.switch_time = il_add_beacon_time(il, - il->ucode_beacon_time, - ucode_switch_time, - beacon_interval); - } - D_11H("uCode time for the switch is 0x%x\n", - cmd.switch_time); - ch_info = il_get_channel_info(il, il->band, ch); - if (ch_info) - cmd.expect_beacon = il_is_channel_radar(ch_info); - else { - IL_ERR("invalid channel switch from %u to %u\n", - ctx->active.channel, ch); - return -EFAULT; - } - - rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, - ctrl_chan_high, &cmd.tx_power); - if (rc) { - D_11H("error:%d fill txpower_tbl\n", rc); - return rc; - } - - return il_send_cmd_pdu(il, - REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); -} - -/** - * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array - */ -static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt) -{ - struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; - int txq_id = txq->q.id; - int write_ptr = txq->q.write_ptr; - int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; - __le16 bc_ent; - - WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX); - - bc_ent = cpu_to_le16(len & 0xFFF); - /* Set up byte count within first 256 entries */ - scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent; - - /* If within first 64 entries, duplicate at end */ - if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) - scd_bc_tbl[txq_id]. - tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent; -} - -/** - * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) - * @stats: Provides the temperature reading from the uCode - * - * A return of <0 indicates bogus data in the stats - */ -static int il4965_hw_get_temperature(struct il_priv *il) -{ - s32 temperature; - s32 vt; - s32 R1, R2, R3; - u32 R4; - - if (test_bit(STATUS_TEMPERATURE, &il->status) && - (il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - D_TEMP("Running HT40 temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); - R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); - } else { - D_TEMP("Running temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); - R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); - } - - /* - * Temperature is only 23 bits, so sign extend out to 32. - * - * NOTE If we haven't received a stats notification yet - * with an updated temperature, use R4 provided to us in the - * "initialize" ALIVE response. - */ - if (!test_bit(STATUS_TEMPERATURE, &il->status)) - vt = sign_extend32(R4, 23); - else - vt = sign_extend32(le32_to_cpu(il->_4965.stats. - general.common.temperature), 23); - - D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); - - if (R3 == R1) { - IL_ERR("Calibration conflict R1 == R3\n"); - return -1; - } - - /* Calculate temperature in degrees Kelvin, adjust by 97%. - * Add offset to center the adjustment around 0 degrees Centigrade. */ - temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); - temperature /= (R3 - R1); - temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - - D_TEMP("Calibrated temperature: %dK, %dC\n", - temperature, KELVIN_TO_CELSIUS(temperature)); - - return temperature; -} - -/* Adjust Txpower only if temperature variance is greater than threshold. */ -#define IL_TEMPERATURE_THRESHOLD 3 - -/** - * il4965_is_temp_calib_needed - determines if new calibration is needed - * - * If the temperature changed has changed sufficiently, then a recalibration - * is needed. - * - * Assumes caller will replace il->last_temperature once calibration - * executed. - */ -static int il4965_is_temp_calib_needed(struct il_priv *il) -{ - int temp_diff; - - if (!test_bit(STATUS_STATISTICS, &il->status)) { - D_TEMP("Temperature not updated -- no stats.\n"); - return 0; - } - - temp_diff = il->temperature - il->last_temperature; - - /* get absolute value */ - if (temp_diff < 0) { - D_POWER("Getting cooler, delta %d\n", temp_diff); - temp_diff = -temp_diff; - } else if (temp_diff == 0) - D_POWER("Temperature unchanged\n"); - else - D_POWER("Getting warmer, delta %d\n", temp_diff); - - if (temp_diff < IL_TEMPERATURE_THRESHOLD) { - D_POWER(" => thermal txpower calib not needed\n"); - return 0; - } - - D_POWER(" => thermal txpower calib needed\n"); - - return 1; -} - -static void il4965_temperature_calib(struct il_priv *il) -{ - s32 temp; - - temp = il4965_hw_get_temperature(il); - if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) - return; - - if (il->temperature != temp) { - if (il->temperature) - D_TEMP("Temperature changed " - "from %dC to %dC\n", - KELVIN_TO_CELSIUS(il->temperature), - KELVIN_TO_CELSIUS(temp)); - else - D_TEMP("Temperature " - "initialized to %dC\n", - KELVIN_TO_CELSIUS(temp)); - } - - il->temperature = temp; - set_bit(STATUS_TEMPERATURE, &il->status); - - if (!il->disable_tx_power_cal && - unlikely(!test_bit(STATUS_SCANNING, &il->status)) && - il4965_is_temp_calib_needed(il)) - queue_work(il->workqueue, &il->txpower_work); -} - -static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) -{ - switch (cmd_id) { - case REPLY_RXON: - return (u16) sizeof(struct il4965_rxon_cmd); - default: - return len; - } -} - -static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) -{ - struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; - addsta->mode = cmd->mode; - memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); - addsta->station_flags = cmd->station_flags; - addsta->station_flags_msk = cmd->station_flags_msk; - addsta->tid_disable_tx = cmd->tid_disable_tx; - addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; - addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; - addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - addsta->sleep_tx_count = cmd->sleep_tx_count; - addsta->reserved1 = cpu_to_le16(0); - addsta->reserved2 = cpu_to_le16(0); - - return (u16)sizeof(struct il4965_addsta_cmd); -} - -static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) -{ - return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; -} - -/** - * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue - */ -static int il4965_tx_status_reply_tx(struct il_priv *il, - struct il_ht_agg *agg, - struct il4965_tx_resp *tx_resp, - int txq_id, u16 start_idx) -{ - u16 status; - struct agg_tx_status *frame_status = tx_resp->u.agg_status; - struct ieee80211_tx_info *info = NULL; - struct ieee80211_hdr *hdr = NULL; - u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); - int i, sh, idx; - u16 seq; - if (agg->wait_for_ba) - D_TX_REPLY("got tx response w/o block-ack\n"); - - agg->frame_count = tx_resp->frame_count; - agg->start_idx = start_idx; - agg->rate_n_flags = rate_n_flags; - agg->bitmap = 0; - - /* num frames attempted by Tx command */ - if (agg->frame_count == 1) { - /* Only one frame was attempted; no block-ack will arrive */ - status = le16_to_cpu(frame_status[0].status); - idx = start_idx; - - D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", - agg->frame_count, agg->start_idx, idx); - - info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); - info->status.rates[0].count = tx_resp->failure_frame + 1; - info->flags &= ~IEEE80211_TX_CTL_AMPDU; - info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(il, rate_n_flags, info); - - D_TX_REPLY("1 Frame 0x%x failure :%d\n", - status & 0xff, tx_resp->failure_frame); - D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); - - agg->wait_for_ba = 0; - } else { - /* Two or more frames were attempted; expect block-ack */ - u64 bitmap = 0; - int start = agg->start_idx; - - /* Construct bit-map of pending frames within Tx win */ - for (i = 0; i < agg->frame_count; i++) { - u16 sc; - status = le16_to_cpu(frame_status[i].status); - seq = le16_to_cpu(frame_status[i].sequence); - idx = SEQ_TO_IDX(seq); - txq_id = SEQ_TO_QUEUE(seq); - - if (status & (AGG_TX_STATE_FEW_BYTES_MSK | - AGG_TX_STATE_ABORT_MSK)) - continue; - - D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", - agg->frame_count, txq_id, idx); - - hdr = il_tx_queue_get_hdr(il, txq_id, idx); - if (!hdr) { - IL_ERR( - "BUG_ON idx doesn't point to valid skb" - " idx=%d, txq_id=%d\n", idx, txq_id); - return -1; - } - - sc = le16_to_cpu(hdr->seq_ctrl); - if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR( - "BUG_ON idx doesn't match seq control" - " idx=%d, seq_idx=%d, seq=%d\n", - idx, SEQ_TO_SN(sc), hdr->seq_ctrl); - return -1; - } - - D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", - i, idx, SEQ_TO_SN(sc)); - - sh = idx - start; - if (sh > 64) { - sh = (start - idx) + 0xff; - bitmap = bitmap << sh; - sh = 0; - start = idx; - } else if (sh < -64) - sh = 0xff - (start - idx); - else if (sh < 0) { - sh = start - idx; - start = idx; - bitmap = bitmap << sh; - sh = 0; - } - bitmap |= 1ULL << sh; - D_TX_REPLY("start=%d bitmap=0x%llx\n", - start, (unsigned long long)bitmap); - } - - agg->bitmap = bitmap; - agg->start_idx = start; - D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", - agg->frame_count, agg->start_idx, - (unsigned long long)agg->bitmap); - - if (bitmap) - agg->wait_for_ba = 1; - } - return 0; -} - -static u8 il4965_find_station(struct il_priv *il, const u8 *addr) -{ - int i; - int start = 0; - int ret = IL_INVALID_STATION; - unsigned long flags; - - if ((il->iw_mode == NL80211_IFTYPE_ADHOC)) - start = IL_STA_ID; - - if (is_broadcast_ether_addr(addr)) - return il->ctx.bcast_sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - for (i = start; i < il->hw_params.max_stations; i++) - if (il->stations[i].used && - (!compare_ether_addr(il->stations[i].sta.sta.addr, - addr))) { - ret = i; - goto out; - } - - D_ASSOC("can not find STA %pM total %d\n", - addr, il->num_stations); - - out: - /* - * It may be possible that more commands interacting with stations - * arrive before we completed processing the adding of - * station - */ - if (ret != IL_INVALID_STATION && - (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || - ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && - (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { - IL_ERR("Requested station info for sta %d before ready.\n", - ret); - ret = IL_INVALID_STATION; - } - spin_unlock_irqrestore(&il->sta_lock, flags); - return ret; -} - -static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) -{ - if (il->iw_mode == NL80211_IFTYPE_STATION) { - return IL_AP_ID; - } else { - u8 *da = ieee80211_get_DA(hdr); - return il4965_find_station(il, da); - } -} - -/** - * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response - */ -static void il4965_rx_reply_tx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u16 sequence = le16_to_cpu(pkt->hdr.sequence); - int txq_id = SEQ_TO_QUEUE(sequence); - int idx = SEQ_TO_IDX(sequence); - struct il_tx_queue *txq = &il->txq[txq_id]; - struct ieee80211_hdr *hdr; - struct ieee80211_tx_info *info; - struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->u.status); - int uninitialized_var(tid); - int sta_id; - int freed; - u8 *qc = NULL; - unsigned long flags; - - if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); - return; - } - - txq->time_stamp = jiffies; - info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); - memset(&info->status, 0, sizeof(info->status)); - - hdr = il_tx_queue_get_hdr(il, txq_id, idx); - if (ieee80211_is_data_qos(hdr->frame_control)) { - qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & 0xf; - } - - sta_id = il4965_get_ra_sta_id(il, hdr); - if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { - IL_ERR("Station not known\n"); - return; - } - - spin_lock_irqsave(&il->sta_lock, flags); - if (txq->sched_retry) { - const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); - struct il_ht_agg *agg = NULL; - WARN_ON(!qc); - - agg = &il->stations[sta_id].tid[tid].agg; - - il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); - - /* check if BAR is needed */ - if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) - info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; - - if (txq->q.read_ptr != (scd_ssn & 0xff)) { - idx = il_queue_dec_wrap(scd_ssn & 0xff, - txq->q.n_bd); - D_TX_REPLY("Retry scheduler reclaim scd_ssn " - "%d idx %d\n", scd_ssn , idx); - freed = il4965_tx_queue_reclaim(il, txq_id, idx); - if (qc) - il4965_free_tfds_in_queue(il, sta_id, - tid, freed); - - if (il->mac80211_registered && - il_queue_space(&txq->q) > txq->q.low_mark && - agg->state != IL_EMPTYING_HW_QUEUE_DELBA) - il_wake_queue(il, txq); - } - } else { - info->status.rates[0].count = tx_resp->failure_frame + 1; - info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(il, - le32_to_cpu(tx_resp->rate_n_flags), - info); - - D_TX_REPLY("TXQ %d status %s (0x%08x) " - "rate_n_flags 0x%x retries %d\n", - txq_id, - il4965_get_tx_fail_reason(status), status, - le32_to_cpu(tx_resp->rate_n_flags), - tx_resp->failure_frame); - - freed = il4965_tx_queue_reclaim(il, txq_id, idx); - if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_free_tfds_in_queue(il, sta_id, tid, freed); - else if (sta_id == IL_INVALID_STATION) - D_TX_REPLY("Station not known\n"); - - if (il->mac80211_registered && - il_queue_space(&txq->q) > txq->q.low_mark) - il_wake_queue(il, txq); - } - if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_txq_check_empty(il, sta_id, tid, txq_id); - - il4965_check_abort_status(il, tx_resp->frame_count, status); - - spin_unlock_irqrestore(&il->sta_lock, flags); -} - -static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; - u8 rate __maybe_unused = - il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - - D_RX("beacon status %#x, retries:%d ibssmgr:%d " - "tsf:0x%.8x%.8x rate:%d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); - - il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); -} - -/* Set up 4965-specific Rx frame reply handlers */ -static void il4965_rx_handler_setup(struct il_priv *il) -{ - /* Legacy Rx frames */ - il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; - /* Tx response */ - il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; -} - -static struct il_hcmd_ops il4965_hcmd = { - .rxon_assoc = il4965_send_rxon_assoc, - .commit_rxon = il4965_commit_rxon, - .set_rxon_chain = il4965_set_rxon_chain, -}; - -static void il4965_post_scan(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - - /* - * Since setting the RXON may have been deferred while - * performing the scan, fire one off if needed - */ - if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il_commit_rxon(il, ctx); -} - -static void il4965_post_associate(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_vif *vif = ctx->vif; - struct ieee80211_conf *conf = NULL; - int ret = 0; - - if (!vif || !il->is_open) - return; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - il_scan_cancel_timeout(il, 200); - - conf = il_ieee80211_get_hw_conf(il->hw); - - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - - ret = il_send_rxon_timing(il, ctx); - if (ret) - IL_WARN("RXON timing - " - "Attempting to continue.\n"); - - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - - il_set_rxon_ht(il, &il->current_ht_config); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - - D_ASSOC("assoc id %d beacon interval %d\n", - vif->bss_conf.aid, vif->bss_conf.beacon_int); - - if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; - } - - il_commit_rxon(il, ctx); - - D_ASSOC("Associated as %d to: %pM\n", - vif->bss_conf.aid, ctx->active.bssid_addr); - - switch (vif->type) { - case NL80211_IFTYPE_STATION: - break; - case NL80211_IFTYPE_ADHOC: - il4965_send_beacon_cmd(il); - break; - default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, vif->type); - break; - } - - /* the chain noise calibration will enabled PM upon completion - * If chain noise has already been run, then we need to enable - * power management here */ - if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE) - il_power_update_mode(il, false); - - /* Enable Rx differential gain and sensitivity calibrations */ - il4965_chain_noise_reset(il); - il->start_calib = 1; -} - -static void il4965_config_ap(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_vif *vif = ctx->vif; - int ret = 0; - - lockdep_assert_held(&il->mutex); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - /* The following should be done only at AP bring up */ - if (!il_is_associated_ctx(ctx)) { - - /* RXON - unassoc (to set timing command) */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - - /* RXON Timing */ - ret = il_send_rxon_timing(il, ctx); - if (ret) - IL_WARN("RXON timing failed - " - "Attempting to continue.\n"); - - /* AP has all antennas */ - il->chain_noise_data.active_chains = - il->hw_params.valid_rx_ant; - il_set_rxon_ht(il, &il->current_ht_config); - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - ctx->staging.assoc_id = 0; - - if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; - } - /* need to send beacon cmd before committing assoc RXON! */ - il4965_send_beacon_cmd(il); - /* restore RXON assoc */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - } - il4965_send_beacon_cmd(il); -} - -static struct il_hcmd_utils_ops il4965_hcmd_utils = { - .get_hcmd_size = il4965_get_hcmd_size, - .build_addsta_hcmd = il4965_build_addsta_hcmd, - .request_scan = il4965_request_scan, - .post_scan = il4965_post_scan, -}; - -static struct il_lib_ops il4965_lib = { - .set_hw_params = il4965_hw_set_hw_params, - .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl, - .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = il4965_hw_txq_free_tfd, - .txq_init = il4965_hw_tx_queue_init, - .rx_handler_setup = il4965_rx_handler_setup, - .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, - .init_alive_start = il4965_init_alive_start, - .load_ucode = il4965_load_bsm, - .dump_nic_error_log = il4965_dump_nic_error_log, - .dump_fh = il4965_dump_fh, - .set_channel_switch = il4965_hw_channel_switch, - .apm_ops = { - .init = il_apm_init, - .config = il4965_nic_config, - }, - .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, - EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS - }, - .acquire_semaphore = il4965_eeprom_acquire_semaphore, - .release_semaphore = il4965_eeprom_release_semaphore, - }, - .send_tx_power = il4965_send_tx_power, - .update_chain_flags = il4965_update_chain_flags, - .temp_ops = { - .temperature = il4965_temperature_calib, - }, - .debugfs_ops = { - .rx_stats_read = il4965_ucode_rx_stats_read, - .tx_stats_read = il4965_ucode_tx_stats_read, - .general_stats_read = il4965_ucode_general_stats_read, - }, -}; - -static const struct il_legacy_ops il4965_legacy_ops = { - .post_associate = il4965_post_associate, - .config_ap = il4965_config_ap, - .manage_ibss_station = il4965_manage_ibss_station, - .update_bcast_stations = il4965_update_bcast_stations, -}; - -struct ieee80211_ops il4965_hw_ops = { - .tx = il4965_mac_tx, - .start = il4965_mac_start, - .stop = il4965_mac_stop, - .add_interface = il_mac_add_interface, - .remove_interface = il_mac_remove_interface, - .change_interface = il_mac_change_interface, - .config = il_mac_config, - .configure_filter = il4965_configure_filter, - .set_key = il4965_mac_set_key, - .update_tkip_key = il4965_mac_update_tkip_key, - .conf_tx = il_mac_conf_tx, - .reset_tsf = il_mac_reset_tsf, - .bss_info_changed = il_mac_bss_info_changed, - .ampdu_action = il4965_mac_ampdu_action, - .hw_scan = il_mac_hw_scan, - .sta_add = il4965_mac_sta_add, - .sta_remove = il_mac_sta_remove, - .channel_switch = il4965_mac_channel_switch, - .tx_last_beacon = il_mac_tx_last_beacon, -}; - -static const struct il_ops il4965_ops = { - .lib = &il4965_lib, - .hcmd = &il4965_hcmd, - .utils = &il4965_hcmd_utils, - .led = &il4965_led_ops, - .legacy = &il4965_legacy_ops, - .ieee80211_ops = &il4965_hw_ops, -}; - -static struct il_base_params il4965_base_params = { - .eeprom_size = IL4965_EEPROM_IMG_SIZE, - .num_of_queues = IL49_NUM_QUEUES, - .num_of_ampdu_queues = IL49_NUM_AMPDU_QUEUES, - .pll_cfg_val = 0, - .set_l0s = true, - .use_bsm = true, - .led_compensation = 61, - .chain_noise_num_beacons = IL4965_CAL_NUM_BEACONS, - .wd_timeout = IL_DEF_WD_TIMEOUT, - .temperature_kelvin = true, - .ucode_tracing = true, - .sensitivity_calib_by_driver = true, - .chain_noise_calib_by_driver = true, -}; - -struct il_cfg il4965_cfg = { - .name = "Intel(R) Wireless WiFi Link 4965AGN", - .fw_name_pre = IL4965_FW_PRE, - .ucode_api_max = IL4965_UCODE_API_MAX, - .ucode_api_min = IL4965_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, - .valid_tx_ant = ANT_AB, - .valid_rx_ant = ANT_ABC, - .eeprom_ver = EEPROM_4965_EEPROM_VERSION, - .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, - .ops = &il4965_ops, - .mod_params = &il4965_mod_params, - .base_params = &il4965_base_params, - .led_mode = IL_LED_BLINK, - /* - * Force use of chains B and C for scan RX on 5 GHz band - * because the device has off-channel reception on chain A. - */ - .scan_rx_antennas[IEEE80211_BAND_5GHZ] = ANT_BC, -}; - -/* Module firmware */ -MODULE_FIRMWARE(IL4965_MODULE_FIRMWARE(IL4965_UCODE_API_MAX)); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c deleted file mode 100644 index 151c8fa..0000000 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ /dev/null @@ -1,4007 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#define DRV_NAME "iwl3945" - -#include "iwl-fh.h" -#include "iwl-3945-fh.h" -#include "iwl-commands.h" -#include "iwl-sta.h" -#include "iwl-3945.h" -#include "iwl-core.h" -#include "iwl-helpers.h" -#include "iwl-dev.h" -#include "iwl-spectrum.h" - -/* - * module name, copyright, version, etc. - */ - -#define DRV_DESCRIPTION \ -"Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux" - -#ifdef CONFIG_IWLEGACY_DEBUG -#define VD "d" -#else -#define VD -#endif - -/* - * add "s" to indicate spectrum measurement included. - * we add it here to be consistent with previous releases in which - * this was configurable. - */ -#define DRV_VERSION IWLWIFI_VERSION VD "s" -#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" -#define DRV_AUTHOR "" - -MODULE_DESCRIPTION(DRV_DESCRIPTION); -MODULE_VERSION(DRV_VERSION); -MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); -MODULE_LICENSE("GPL"); - - /* module parameters */ -struct il_mod_params il3945_mod_params = { - .sw_crypto = 1, - .restart_fw = 1, - .disable_hw_scan = 1, - /* the rest are 0 by default */ -}; - -/** - * il3945_get_antenna_flags - Get antenna flags for RXON command - * @il: eeprom and antenna fields are used to determine antenna flags - * - * il->eeprom39 is used to determine if antenna AUX/MAIN are reversed - * il3945_mod_params.antenna specifies the antenna diversity mode: - * - * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself - * IL_ANTENNA_MAIN - Force MAIN antenna - * IL_ANTENNA_AUX - Force AUX antenna - */ -__le32 il3945_get_antenna_flags(const struct il_priv *il) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - - switch (il3945_mod_params.antenna) { - case IL_ANTENNA_DIVERSITY: - return 0; - - case IL_ANTENNA_MAIN: - if (eeprom->antenna_switch_type) - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; - - case IL_ANTENNA_AUX: - if (eeprom->antenna_switch_type) - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; - } - - /* bad antenna selector value */ - IL_ERR("Bad antenna selector value (0x%x)\n", - il3945_mod_params.antenna); - - return 0; /* "diversity" is default if error */ -} - -static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - __le16 key_flags = 0; - int ret; - - key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - - if (sta_id == il->ctx.bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - keyconf->hw_key_idx = keyconf->keyidx; - key_flags &= ~STA_KEY_FLG_INVALID; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); - - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - D_INFO("hwcrypto: modify ucode station key info\n"); - - ret = il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); - - spin_unlock_irqrestore(&il->sta_lock, flags); - - return ret; -} - -static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - return -EOPNOTSUPP; -} - -static int il3945_set_wep_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - return -EOPNOTSUPP; -} - -static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) -{ - unsigned long flags; - struct il_addsta_cmd sta_cmd; - - spin_lock_irqsave(&il->sta_lock, flags); - memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); - il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - D_INFO("hwcrypto: clear ucode station key info\n"); - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -static int il3945_set_dynamic_key(struct il_priv *il, - struct ieee80211_key_conf *keyconf, u8 sta_id) -{ - int ret = 0; - - keyconf->hw_key_idx = HW_KEY_DYNAMIC; - - switch (keyconf->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - ret = il3945_set_ccmp_dynamic_key_info(il, keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_TKIP: - ret = il3945_set_tkip_dynamic_key_info(il, keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); - break; - default: - IL_ERR("Unknown alg: %s alg=%x\n", __func__, - keyconf->cipher); - ret = -EINVAL; - } - - D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); - - return ret; -} - -static int il3945_remove_static_key(struct il_priv *il) -{ - int ret = -EOPNOTSUPP; - - return ret; -} - -static int il3945_set_static_key(struct il_priv *il, - struct ieee80211_key_conf *key) -{ - if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) - return -EOPNOTSUPP; - - IL_ERR("Static key invalid: cipher %x\n", key->cipher); - return -EINVAL; -} - -static void il3945_clear_free_frames(struct il_priv *il) -{ - struct list_head *element; - - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); - - while (!list_empty(&il->free_frames)) { - element = il->free_frames.next; - list_del(element); - kfree(list_entry(element, struct il3945_frame, list)); - il->frames_count--; - } - - if (il->frames_count) { - IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); - il->frames_count = 0; - } -} - -static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) -{ - struct il3945_frame *frame; - struct list_head *element; - if (list_empty(&il->free_frames)) { - frame = kzalloc(sizeof(*frame), GFP_KERNEL); - if (!frame) { - IL_ERR("Could not allocate frame!\n"); - return NULL; - } - - il->frames_count++; - return frame; - } - - element = il->free_frames.next; - list_del(element); - return list_entry(element, struct il3945_frame, list); -} - -static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) -{ - memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &il->free_frames); -} - -unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) -{ - - if (!il_is_associated(il) || !il->beacon_skb) - return 0; - - if (il->beacon_skb->len > left) - return 0; - - memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - - return il->beacon_skb->len; -} - -static int il3945_send_beacon_cmd(struct il_priv *il) -{ - struct il3945_frame *frame; - unsigned int frame_size; - int rc; - u8 rate; - - frame = il3945_get_free_frame(il); - - if (!frame) { - IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); - return -ENOMEM; - } - - rate = il_get_lowest_plcp(il, - &il->ctx); - - frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, - &frame->u.cmd[0]); - - il3945_free_frame(il, frame); - - return rc; -} - -static void il3945_unset_hw_params(struct il_priv *il) -{ - if (il->_3945.shared_virt) - dma_free_coherent(&il->pci_dev->dev, - sizeof(struct il3945_shared), - il->_3945.shared_virt, - il->_3945.shared_phys); -} - -static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_device_cmd *cmd, - struct sk_buff *skb_frag, - int sta_id) -{ - struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; - - tx_cmd->sec_ctl = 0; - - switch (keyinfo->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - tx_cmd->sec_ctl = TX_CMD_SEC_CCM; - memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - D_TX("tx_cmd with AES hwcrypto\n"); - break; - - case WLAN_CIPHER_SUITE_TKIP: - break; - - case WLAN_CIPHER_SUITE_WEP104: - tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; - /* fall through */ - case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= TX_CMD_SEC_WEP | - (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; - - memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - - D_TX("Configuring packet for WEP encryption " - "with key %d\n", info->control.hw_key->hw_key_idx); - break; - - default: - IL_ERR("Unknown encode cipher %x\n", keyinfo->cipher); - break; - } -} - -/* - * handle build REPLY_TX command notification. - */ -static void il3945_build_tx_cmd_basic(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, u8 std_id) -{ - struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - __le32 tx_flags = tx_cmd->tx_flags; - __le16 fc = hdr->frame_control; - - tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { - tx_flags |= TX_CMD_FLG_ACK_MSK; - if (ieee80211_is_mgmt(fc)) - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - if (ieee80211_is_probe_resp(fc) && - !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) - tx_flags |= TX_CMD_FLG_TSF_MSK; - } else { - tx_flags &= (~TX_CMD_FLG_ACK_MSK); - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - tx_cmd->sta_id = std_id; - if (ieee80211_has_morefrags(fc)) - tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; - - if (ieee80211_is_data_qos(fc)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tx_cmd->tid_tspec = qc[0] & 0xf; - tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; - } else { - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - il_tx_cmd_protection(il, info, fc, &tx_flags); - - tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); - if (ieee80211_is_mgmt(fc)) { - if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); - else - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); - } else { - tx_cmd->timeout.pm_frame_timeout = 0; - } - - tx_cmd->driver_txop = 0; - tx_cmd->tx_flags = tx_flags; - tx_cmd->next_frame_len = 0; -} - -/* - * start REPLY_TX command process - */ -static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct il3945_tx_cmd *tx_cmd; - struct il_tx_queue *txq = NULL; - struct il_queue *q = NULL; - struct il_device_cmd *out_cmd; - struct il_cmd_meta *out_meta; - dma_addr_t phys_addr; - dma_addr_t txcmd_phys; - int txq_id = skb_get_queue_mapping(skb); - u16 len, idx, hdr_len; - u8 id; - u8 unicast; - u8 sta_id; - u8 tid = 0; - __le16 fc; - u8 wait_write_ptr = 0; - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - if (il_is_rfkill(il)) { - D_DROP("Dropping - RF KILL\n"); - goto drop_unlock; - } - - if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { - IL_ERR("ERROR: No TX rate available.\n"); - goto drop_unlock; - } - - unicast = !is_multicast_ether_addr(hdr->addr1); - id = 0; - - fc = hdr->frame_control; - -#ifdef CONFIG_IWLEGACY_DEBUG - if (ieee80211_is_auth(fc)) - D_TX("Sending AUTH frame\n"); - else if (ieee80211_is_assoc_req(fc)) - D_TX("Sending ASSOC frame\n"); - else if (ieee80211_is_reassoc_req(fc)) - D_TX("Sending REASSOC frame\n"); -#endif - - spin_unlock_irqrestore(&il->lock, flags); - - hdr_len = ieee80211_hdrlen(fc); - - /* Find idx into station table for destination station */ - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, - info->control.sta); - if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); - goto drop; - } - - D_RATE("station Id %d\n", sta_id); - - if (ieee80211_is_data_qos(fc)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; - if (unlikely(tid >= MAX_TID_COUNT)) - goto drop; - } - - /* Descriptor for chosen Tx queue */ - txq = &il->txq[txq_id]; - q = &txq->q; - - if ((il_queue_space(q) < q->high_mark)) - goto drop; - - spin_lock_irqsave(&il->lock, flags); - - idx = il_get_cmd_idx(q, q->write_ptr, 0); - - /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); - txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &il->ctx; - - /* Init first empty entry in queue's array of Tx/cmd buffers */ - out_cmd = txq->cmd[idx]; - out_meta = &txq->meta[idx]; - tx_cmd = (struct il3945_tx_cmd *)out_cmd->cmd.payload; - memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); - memset(tx_cmd, 0, sizeof(*tx_cmd)); - - /* - * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD idx within the sequence field; - * after Tx, uCode's Tx response will return this value so driver can - * locate the frame within the tx queue and do post-tx processing. - */ - out_cmd->hdr.cmd = REPLY_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); - - /* Copy MAC header from skb into command buffer */ - memcpy(tx_cmd->hdr, hdr, hdr_len); - - - if (info->control.hw_key) - il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); - - /* TODO need this for burst mode later on */ - il3945_build_tx_cmd_basic(il, out_cmd, info, hdr, sta_id); - - /* set is_hcca to 0; it probably will never be implemented */ - il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); - - /* Total # bytes to be transmitted */ - len = (u16)skb->len; - tx_cmd->len = cpu_to_le16(len); - - il_dbg_log_tx_data_frame(il, len, hdr); - il_update_stats(il, true, fc, len); - tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; - tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; - - if (!ieee80211_has_morefrags(hdr->frame_control)) { - txq->need_update = 1; - } else { - wait_write_ptr = 1; - txq->need_update = 0; - } - - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); - D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, - ieee80211_hdrlen(fc)); - - /* - * Use the first empty entry in this queue's command buffer array - * to contain the Tx command and MAC header concatenated together - * (payload data will be in another buffer). - * Size of this varies, due to varying MAC header length. - * If end is not dword aligned, we'll have 2 extra bytes at the end - * of the MAC header (device reads on dword boundaries). - * We'll tell device about this padding later. - */ - len = sizeof(struct il3945_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; - len = (len + 3) & ~3; - - /* Physical address of this Tx command's header (not MAC header!), - * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, - len, PCI_DMA_TODEVICE); - /* we do not map meta data ... so we can safely access address to - * provide to unmap command*/ - dma_unmap_addr_set(out_meta, mapping, txcmd_phys); - dma_unmap_len_set(out_meta, len, len); - - /* Add buffer containing Tx command and MAC(!) header to TFD's - * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, len, 1, 0); - - - /* Set up TFD's 2nd entry to point directly to remainder of skb, - * if any (802.11 null frames have no payload). */ - len = skb->len - hdr_len; - if (len) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - len, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, len, - 0, U32_PAD(len)); - } - - - /* Tell device the write idx *just past* this latest filled TFD */ - q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - - if (il_queue_space(q) < q->high_mark - && il->mac80211_registered) { - if (wait_write_ptr) { - spin_lock_irqsave(&il->lock, flags); - txq->need_update = 1; - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - } - - il_stop_queue(il, txq); - } - - return 0; - -drop_unlock: - spin_unlock_irqrestore(&il->lock, flags); -drop: - return -1; -} - -static int il3945_get_measurement(struct il_priv *il, - struct ieee80211_measurement_params *params, - u8 type) -{ - struct il_spectrum_cmd spectrum; - struct il_rx_pkt *pkt; - struct il_host_cmd cmd = { - .id = REPLY_SPECTRUM_MEASUREMENT_CMD, - .data = (void *)&spectrum, - .flags = CMD_WANT_SKB, - }; - u32 add_time = le64_to_cpu(params->start_time); - int rc; - int spectrum_resp_status; - int duration = le16_to_cpu(params->duration); - struct il_rxon_context *ctx = &il->ctx; - - if (il_is_associated(il)) - add_time = il_usecs_to_beacons(il, - le64_to_cpu(params->start_time) - il->_3945.last_tsf, - le16_to_cpu(ctx->timing.beacon_interval)); - - memset(&spectrum, 0, sizeof(spectrum)); - - spectrum.channel_count = cpu_to_le16(1); - spectrum.flags = - RXON_FLG_TSF2HOST_MSK | RXON_FLG_ANT_A_MSK | RXON_FLG_DIS_DIV_MSK; - spectrum.filter_flags = MEASUREMENT_FILTER_FLAG; - cmd.len = sizeof(spectrum); - spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - - if (il_is_associated(il)) - spectrum.start_time = - il_add_beacon_time(il, - il->_3945.last_beacon_time, add_time, - le16_to_cpu(ctx->timing.beacon_interval)); - else - spectrum.start_time = 0; - - spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT); - spectrum.channels[0].channel = params->channel; - spectrum.channels[0].type = type; - if (ctx->active.flags & RXON_FLG_BAND_24G_MSK) - spectrum.flags |= RXON_FLG_BAND_24G_MSK | - RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; - - rc = il_send_cmd_sync(il, &cmd); - if (rc) - return rc; - - pkt = (struct il_rx_pkt *)cmd.reply_page; - if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); - rc = -EIO; - } - - spectrum_resp_status = le16_to_cpu(pkt->u.spectrum.status); - switch (spectrum_resp_status) { - case 0: /* Command will be handled */ - if (pkt->u.spectrum.id != 0xff) { - D_INFO("Replaced existing measurement: %d\n", - pkt->u.spectrum.id); - il->measurement_status &= ~MEASUREMENT_READY; - } - il->measurement_status |= MEASUREMENT_ACTIVE; - rc = 0; - break; - - case 1: /* Command will not be handled */ - rc = -EAGAIN; - break; - } - - il_free_pages(il, cmd.reply_page); - - return rc; -} - -static void il3945_rx_reply_alive(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_alive_resp *palive; - struct delayed_work *pwork; - - palive = &pkt->u.alive_frame; - - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); - - if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - D_INFO("Initialization Alive received.\n"); - memcpy(&il->card_alive_init, &pkt->u.alive_frame, - sizeof(struct il_alive_resp)); - pwork = &il->init_alive_start; - } else { - D_INFO("Runtime Alive received.\n"); - memcpy(&il->card_alive, &pkt->u.alive_frame, - sizeof(struct il_alive_resp)); - pwork = &il->alive_start; - il3945_disable_events(il); - } - - /* We delay the ALIVE response by 5ms to - * give the HW RF Kill time to activate... */ - if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); - else - IL_WARN("uCode did not respond OK.\n"); -} - -static void il3945_rx_reply_add_sta(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); -#endif - - D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); -} - -static void il3945_rx_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); -#ifdef CONFIG_IWLEGACY_DEBUG - u8 rate = beacon->beacon_notify_hdr.rate; - - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); -#endif - - il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); - -} - -/* Handle notification from uCode that card's power state is changing - * due to software, hardware, or critical temperature RFKILL */ -static void il3945_rx_card_state_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = il->status; - - IL_WARN("Card state received: HW:%s SW:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - - - il_scan_cancel(il); - - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) - wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); - else - wake_up(&il->wait_command_queue); -} - -/** - * il3945_setup_rx_handlers - Initialize Rx handler callbacks - * - * Setup the RX handlers for each of the reply types sent from the uCode - * to the host. - * - * This function chains into the hardware specific files for them to setup - * any hardware specific handlers as well. - */ -static void il3945_setup_rx_handlers(struct il_priv *il) -{ - il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; - il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; - - /* - * The same handler is used for both the REPLY to a discrete - * stats request from the host as well as for the periodic - * stats notifications (after received beacons) from the uCode. - */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; - - il_setup_rx_scan_handlers(il); - il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; - - /* Set up hardware specific Rx handlers */ - il3945_hw_rx_handler_setup(il); -} - -/************************** RX-FUNCTIONS ****************************/ -/* - * Rx theory of operation - * - * The host allocates 32 DMA target addresses and passes the host address - * to the firmware at register IL_RFDS_TBL_LOWER + N * RFD_SIZE where N is - * 0 to 31 - * - * Rx Queue Indexes - * The host/firmware share two idx registers for managing the Rx buffers. - * - * The READ idx maps to the first position that the firmware may be writing - * to -- the driver can read up to (but not including) this position and get - * good data. - * The READ idx is managed by the firmware once the card is enabled. - * - * The WRITE idx maps to the last position the driver has read from -- the - * position preceding WRITE is the last slot the firmware can place a packet. - * - * The queue is empty (no good data) if WRITE = READ - 1, and is full if - * WRITE = READ. - * - * During initialization, the host sets up the READ queue position to the first - * IDX position, and WRITE to the last (READ - 1 wrapped) - * - * When the firmware places a packet in a buffer, it will advance the READ idx - * and fire the RX interrupt. The driver can then query the READ idx and - * process as many packets as possible, moving the WRITE idx forward as it - * resets the Rx queue buffers with new memory. - * - * The management in the driver is as follows: - * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When - * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled - * to replenish the iwl->rxq->rx_free. - * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver idxes as well) - * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' idx is updated. - * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free - * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * IDX is not incremented and iwl->status(RX_STALLED) is set. If there - * were enough free buffers and RX_STALLED is set it is cleared. - * - * - * Driver sequence: - * - * il3945_rx_replenish() Replenishes rx_free list from rx_used, and calls - * il3945_rx_queue_restock - * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx - * queue, updates firmware pointers, and updates - * the WRITE idx. If insufficient rx_free buffers - * are available, schedules il3945_rx_replenish - * - * -- enable interrupts -- - * ISR - il3945_rx() Detach il_rx_bufs from pool up to the - * READ IDX, detaching the SKB from the pool. - * Moves the packet buffer from queue to rx_used. - * Calls il3945_rx_queue_restock to refill any empty - * slots. - * ... - * - */ - -/** - * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr - */ -static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) -{ - return cpu_to_le32((u32)dma_addr); -} - -/** - * il3945_rx_queue_restock - refill RX queue from pre-allocated pool - * - * If there are slots in the RX queue that need to be restocked, - * and we have free pre-allocated buffers, fill the ranks as much - * as we can, pulling from rx_free. - * - * This moves the 'write' idx forward to catch up with 'processed', and - * also updates the memory address in the firmware to reference the new - * target buffer. - */ -static void il3945_rx_queue_restock(struct il_priv *il) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - unsigned long flags; - int write; - - spin_lock_irqsave(&rxq->lock, flags); - write = rxq->write & ~0x7; - while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { - /* Get next free Rx buffer, remove from free list */ - element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - - /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); - rxq->queue[rxq->write] = rxb; - rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; - rxq->free_count--; - } - spin_unlock_irqrestore(&rxq->lock, flags); - /* If the pre-allocated buffer pool is dropping low, schedule to - * refill it */ - if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(il->workqueue, &il->rx_replenish); - - - /* If we've added more space for the firmware to place data, tell it. - * Increment device's write pointer in multiples of 8. */ - if (rxq->write_actual != (rxq->write & ~0x7) || - abs(rxq->write - rxq->read) > 7) { - spin_lock_irqsave(&rxq->lock, flags); - rxq->need_update = 1; - spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(il, rxq); - } -} - -/** - * il3945_rx_replenish - Move all used packet from rx_used to rx_free - * - * When moving to rx_free an SKB is allocated for the slot. - * - * Also restock the Rx queue via il3945_rx_queue_restock. - * This is called as a scheduled work item (except for during initialization) - */ -static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - struct page *page; - unsigned long flags; - gfp_t gfp_mask = priority; - - while (1) { - spin_lock_irqsave(&rxq->lock, flags); - - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - return; - } - spin_unlock_irqrestore(&rxq->lock, flags); - - if (rxq->free_count > RX_LOW_WATERMARK) - gfp_mask |= __GFP_NOWARN; - - if (il->hw_params.rx_page_order > 0) - gfp_mask |= __GFP_COMP; - - /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); - if (!page) { - if (net_ratelimit()) - D_INFO("Failed to allocate SKB buffer.\n"); - if (rxq->free_count <= RX_LOW_WATERMARK && - net_ratelimit()) - IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); - /* We don't reschedule replenish work here -- we will - * call the restock method and if it still needs - * more buffers it will schedule replenish */ - break; - } - - spin_lock_irqsave(&rxq->lock, flags); - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, il->hw_params.rx_page_order); - return; - } - element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - spin_unlock_irqrestore(&rxq->lock, flags); - - rxb->page = page; - /* Get physical address of RB/SKB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - - spin_lock_irqsave(&rxq->lock, flags); - - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - il->alloc_rxb_page++; - - spin_unlock_irqrestore(&rxq->lock, flags); - } -} - -void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) -{ - unsigned long flags; - int i; - spin_lock_irqsave(&rxq->lock, flags); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - /* Fill the rx_used queue with _all_ of the Rx buffers */ - for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { - /* In the reset function, these buffers may have been allocated - * to an SKB, so we need to unmap and free potential storage */ - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - list_add_tail(&rxq->pool[i].list, &rxq->rx_used); - } - - /* Set us so that we have processed and used all buffers, but have - * not restocked the Rx queue with fresh buffers */ - rxq->read = rxq->write = 0; - rxq->write_actual = 0; - rxq->free_count = 0; - spin_unlock_irqrestore(&rxq->lock, flags); -} - -void il3945_rx_replenish(void *data) -{ - struct il_priv *il = data; - unsigned long flags; - - il3945_rx_allocate(il, GFP_KERNEL); - - spin_lock_irqsave(&il->lock, flags); - il3945_rx_queue_restock(il); - spin_unlock_irqrestore(&il->lock, flags); -} - -static void il3945_rx_replenish_now(struct il_priv *il) -{ - il3945_rx_allocate(il, GFP_ATOMIC); - - il3945_rx_queue_restock(il); -} - - -/* Assumes that the skb field of the buffers in 'pool' is kept accurate. - * If an SKB has been detached, the POOL needs to have its SKB set to NULL - * This free routine walks the list of POOL entries and if SKB is set to - * non NULL it is unmapped and freed - */ -static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) -{ - int i; - for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - } - - dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, - rxq->bd_dma); - dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), - rxq->rb_stts, rxq->rb_stts_dma); - rxq->bd = NULL; - rxq->rb_stts = NULL; -} - - -/* Convert linear signal-to-noise ratio into dB */ -static u8 ratio2dB[100] = { -/* 0 1 2 3 4 5 6 7 8 9 */ - 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ - 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ - 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ - 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ - 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ - 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ - 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ - 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ - 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ - 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ -}; - -/* Calculates a relative dB value from a ratio of linear - * (i.e. not dB) signal levels. - * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ -int il3945_calc_db_from_ratio(int sig_ratio) -{ - /* 1000:1 or higher just report as 60 dB */ - if (sig_ratio >= 1000) - return 60; - - /* 100:1 or higher, divide by 10 and use table, - * add 20 dB to make up for divide by 10 */ - if (sig_ratio >= 100) - return 20 + (int)ratio2dB[sig_ratio/10]; - - /* We shouldn't see this */ - if (sig_ratio < 1) - return 0; - - /* Use table for ratios 1:1 - 99:1 */ - return (int)ratio2dB[sig_ratio]; -} - -/** - * il3945_rx_handle - Main entry function for receiving responses from uCode - * - * Uses the il->rx_handlers callback function array to invoke - * the appropriate handlers, including command responses, - * frame-received notifications, and other notifications. - */ -static void il3945_rx_handle(struct il_priv *il) -{ - struct il_rx_buf *rxb; - struct il_rx_pkt *pkt; - struct il_rx_queue *rxq = &il->rxq; - u32 r, i; - int reclaim; - unsigned long flags; - u8 fill_rx = 0; - u32 count = 8; - int total_empty = 0; - - /* uCode's read idx (stored in shared DRAM) indicates the last Rx - * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; - i = rxq->read; - - /* calculate total frames need to be restock after handling RX */ - total_empty = r - rxq->write_actual; - if (total_empty < 0) - total_empty += RX_QUEUE_SIZE; - - if (total_empty > (RX_QUEUE_SIZE / 2)) - fill_rx = 1; - /* Rx interrupt, but nothing sent from uCode */ - if (i == r) - D_RX("r = %d, i = %d\n", r, i); - - while (i != r) { - int len; - - rxb = rxq->queue[i]; - - /* If an RXB doesn't have a Rx queue slot associated with it, - * then a bug has been introduced in the queue refilling - * routines -- catch it here */ - BUG_ON(rxb == NULL); - - rxq->queue[i] = NULL; - - pci_unmap_page(il->pci_dev, rxb->page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - pkt = rxb_addr(rxb); - - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ - - /* Reclaim a command buffer only if this packet is a response - * to a (driver-originated) command. - * If the packet (e.g. Rx frame) originated from uCode, - * there is no command buffer to reclaim. - * Ucode should set SEQ_RX_FRAME bit if ucode-originated, - * but apparently a few don't get set; catch them here. */ - reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != STATISTICS_NOTIFICATION && - pkt->hdr.cmd != REPLY_TX; - - /* Based on type of command response or notification, - * handle those that need handling via function in - * rx_handlers table. See il3945_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { - D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, - il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); - } else { - /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); - } - - /* - * XXX: After here, we should always check rxb->page - * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have - * already taken or freed the pages. - */ - - if (reclaim) { - /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking il_send_cmd() - * as we reclaim the driver command queue */ - if (rxb->page) - il_tx_cmd_complete(il, rxb); - else - IL_WARN("Claim null rxb?\n"); - } - - /* Reuse the page if possible. For notification packets and - * SKBs that fail to Rx correctly, add them back into the - * rx_free list for reuse later. */ - spin_lock_irqsave(&rxq->lock, flags); - if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - } else - list_add_tail(&rxb->list, &rxq->rx_used); - - spin_unlock_irqrestore(&rxq->lock, flags); - - i = (i + 1) & RX_QUEUE_MASK; - /* If there are a lot of unused frames, - * restock the Rx queue so ucode won't assert. */ - if (fill_rx) { - count++; - if (count >= 8) { - rxq->read = i; - il3945_rx_replenish_now(il); - count = 0; - } - } - } - - /* Backtrack one entry */ - rxq->read = i; - if (fill_rx) - il3945_rx_replenish_now(il); - else - il3945_rx_queue_restock(il); -} - -/* call this function to flush any scheduled tasklet */ -static inline void il3945_synchronize_irq(struct il_priv *il) -{ - /* wait to make sure we flush pending tasklet*/ - synchronize_irq(il->pci_dev->irq); - tasklet_kill(&il->irq_tasklet); -} - -static const char *il3945_desc_lookup(int i) -{ - switch (i) { - case 1: - return "FAIL"; - case 2: - return "BAD_PARAM"; - case 3: - return "BAD_CHECKSUM"; - case 4: - return "NMI_INTERRUPT"; - case 5: - return "SYSASSERT"; - case 6: - return "FATAL_ERROR"; - } - - return "UNKNOWN"; -} - -#define ERROR_START_OFFSET (1 * sizeof(u32)) -#define ERROR_ELEM_SIZE (7 * sizeof(u32)) - -void il3945_dump_nic_error_log(struct il_priv *il) -{ - u32 i; - u32 desc, time, count, base, data1; - u32 blink1, blink2, ilink1, ilink2; - - base = le32_to_cpu(il->card_alive.error_event_table_ptr); - - if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR("Not valid error log pointer 0x%08X\n", base); - return; - } - - - count = il_read_targ_mem(il, base); - - if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); - } - - IL_ERR("Desc Time asrtPC blink2 " - "ilink1 nmiPC Line\n"); - for (i = ERROR_START_OFFSET; - i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; - i += ERROR_ELEM_SIZE) { - desc = il_read_targ_mem(il, base + i); - time = - il_read_targ_mem(il, base + i + 1 * sizeof(u32)); - blink1 = - il_read_targ_mem(il, base + i + 2 * sizeof(u32)); - blink2 = - il_read_targ_mem(il, base + i + 3 * sizeof(u32)); - ilink1 = - il_read_targ_mem(il, base + i + 4 * sizeof(u32)); - ilink2 = - il_read_targ_mem(il, base + i + 5 * sizeof(u32)); - data1 = - il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - - IL_ERR( - "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", - il3945_desc_lookup(desc), desc, time, blink1, blink2, - ilink1, ilink2, data1); - } -} - -static void il3945_irq_tasklet(struct il_priv *il) -{ - u32 inta, handled = 0; - u32 inta_fh; - unsigned long flags; -#ifdef CONFIG_IWLEGACY_DEBUG - u32 inta_mask; -#endif - - spin_lock_irqsave(&il->lock, flags); - - /* Ack/clear/reset pending uCode interrupts. - * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, - * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = _il_rd(il, CSR_INT); - _il_wr(il, CSR_INT, inta); - - /* Ack/clear/reset pending flow-handler (DMA) interrupts. - * Any new interrupts that happen after this, either while we're - * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - _il_wr(il, CSR_FH_INT_STATUS, inta_fh); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & IL_DL_ISR) { - /* just for debug */ - inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); - } -#endif - - spin_unlock_irqrestore(&il->lock, flags); - - /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not - * atomic, make sure that inta covers all the interrupts that - * we've discovered, even if FH interrupt came in just after - * reading CSR_INT. */ - if (inta_fh & CSR39_FH_INT_RX_MASK) - inta |= CSR_INT_BIT_FH_RX; - if (inta_fh & CSR39_FH_INT_TX_MASK) - inta |= CSR_INT_BIT_FH_TX; - - /* Now service all interrupt bits discovered above. */ - if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR("Hardware error detected. Restarting.\n"); - - /* Tell the device to stop sending interrupts */ - il_disable_interrupts(il); - - il->isr_stats.hw++; - il_irq_handle_error(il); - - handled |= CSR_INT_BIT_HW_ERR; - - return; - } - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - /* NIC fires this, but we don't use it, redundant with WAKEUP */ - if (inta & CSR_INT_BIT_SCD) { - D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); - il->isr_stats.sch++; - } - - /* Alive notification via Rx interrupt will do the real work */ - if (inta & CSR_INT_BIT_ALIVE) { - D_ISR("Alive interrupt\n"); - il->isr_stats.alive++; - } - } -#endif - /* Safely ignore these bits for debug checks below */ - inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); - - /* Error detected by uCode */ - if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - "Restarting 0x%X.\n", inta); - il->isr_stats.sw++; - il_irq_handle_error(il); - handled |= CSR_INT_BIT_SW_ERR; - } - - /* uCode wakes up after power-down sleep */ - if (inta & CSR_INT_BIT_WAKEUP) { - D_ISR("Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(il, &il->rxq); - il_txq_update_write_ptr(il, &il->txq[0]); - il_txq_update_write_ptr(il, &il->txq[1]); - il_txq_update_write_ptr(il, &il->txq[2]); - il_txq_update_write_ptr(il, &il->txq[3]); - il_txq_update_write_ptr(il, &il->txq[4]); - il_txq_update_write_ptr(il, &il->txq[5]); - - il->isr_stats.wakeup++; - handled |= CSR_INT_BIT_WAKEUP; - } - - /* All uCode command responses, including Tx command responses, - * Rx "responses" (frame-received notification), and other - * notifications from uCode come through here*/ - if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il3945_rx_handle(il); - il->isr_stats.rx++; - handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); - } - - if (inta & CSR_INT_BIT_FH_TX) { - D_ISR("Tx interrupt\n"); - il->isr_stats.tx++; - - _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); - il_wr(il, FH39_TCSR_CREDIT - (FH39_SRVC_CHNL), 0x0); - handled |= CSR_INT_BIT_FH_TX; - } - - if (inta & ~handled) { - IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); - il->isr_stats.unhandled++; - } - - if (inta & ~il->inta_mask) { - IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); - } - - /* Re-enable all interrupts */ - /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) - il_enable_interrupts(il); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = _il_rd(il, CSR_INT); - inta_mask = _il_rd(il, CSR_INT_MASK); - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); - } -#endif -} - -static int il3945_get_channels_for_scan(struct il_priv *il, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il3945_scan_channel *scan_ch, - struct ieee80211_vif *vif) -{ - struct ieee80211_channel *chan; - const struct ieee80211_supported_band *sband; - const struct il_channel_info *ch_info; - u16 passive_dwell = 0; - u16 active_dwell = 0; - int added, i; - - sband = il_get_hw_mode(il, band); - if (!sband) - return 0; - - active_dwell = il_get_active_dwell_time(il, band, n_probes); - passive_dwell = il_get_passive_dwell_time(il, band, vif); - - if (passive_dwell <= active_dwell) - passive_dwell = active_dwell + 1; - - for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { - chan = il->scan_request->channels[i]; - - if (chan->band != band) - continue; - - scan_ch->channel = chan->hw_value; - - ch_info = il_get_channel_info(il, band, - scan_ch->channel); - if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", - scan_ch->channel); - continue; - } - - scan_ch->active_dwell = cpu_to_le16(active_dwell); - scan_ch->passive_dwell = cpu_to_le16(passive_dwell); - /* If passive , set up for auto-switch - * and use long active_dwell time. - */ - if (!is_active || il_is_channel_passive(ch_info) || - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { - scan_ch->type = 0; /* passive */ - if (IL_UCODE_API(il->ucode_ver) == 1) - scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); - } else { - scan_ch->type = 1; /* active */ - } - - /* Set direct probe bits. These may be used both for active - * scan channels (probes gets sent right away), - * or for passive channels (probes get se sent only after - * hearing clear Rx packet).*/ - if (IL_UCODE_API(il->ucode_ver) >= 2) { - if (n_probes) - scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); - } else { - /* uCode v1 does not allow setting direct probe bits on - * passive channel. */ - if ((scan_ch->type & 1) && n_probes) - scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); - } - - /* Set txpower levels to defaults */ - scan_ch->tpc.dsp_atten = 110; - /* scan_pwr_info->tpc.dsp_atten; */ - - /*scan_pwr_info->tpc.tx_gain; */ - if (band == IEEE80211_BAND_5GHZ) - scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; - else { - scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); - /* NOTE: if we were doing 6Mb OFDM for scans we'd use - * power level: - * scan_ch->tpc.tx_gain = ((1 << 5) | (2 << 3)) | 3; - */ - } - - D_SCAN("Scanning %d [%s %d]\n", - scan_ch->channel, - (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", - (scan_ch->type & 1) ? - active_dwell : passive_dwell); - - scan_ch++; - added++; - } - - D_SCAN("total channels to scan %d\n", added); - return added; -} - -static void il3945_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) -{ - int i; - - for (i = 0; i < RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = il3945_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ - rates[i].hw_value_short = i; - rates[i].flags = 0; - if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { - /* - * If CCK != 1M then set short preamble rate flag. - */ - rates[i].flags |= (il3945_rates[i].plcp == 10) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; - } - } -} - -/****************************************************************************** - * - * uCode download functions - * - ******************************************************************************/ - -static void il3945_dealloc_ucode_pci(struct il_priv *il) -{ - il_free_fw_desc(il->pci_dev, &il->ucode_code); - il_free_fw_desc(il->pci_dev, &il->ucode_data); - il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); - il_free_fw_desc(il->pci_dev, &il->ucode_init); - il_free_fw_desc(il->pci_dev, &il->ucode_init_data); - il_free_fw_desc(il->pci_dev, &il->ucode_boot); -} - -/** - * il3945_verify_inst_full - verify runtime uCode image in card vs. host, - * looking at all data. - */ -static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) -{ - u32 val; - u32 save_len = len; - int rc = 0; - u32 errcnt; - - D_INFO("ucode inst image size is %u\n", len); - - il_wr(il, HBUS_TARG_MEM_RADDR, - IL39_RTC_INST_LOWER_BOUND); - - errcnt = 0; - for (; len > 0; len -= sizeof(u32), image++) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); - rc = -EIO; - errcnt++; - if (errcnt >= 20) - break; - } - } - - - if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); - - return rc; -} - - -/** - * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, - * using sample data 100 bytes apart. If these sample points are good, - * it's a pretty good bet that everything between them is good, too. - */ -static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) -{ - u32 val; - int rc = 0; - u32 errcnt = 0; - u32 i; - - D_INFO("ucode inst image size is %u\n", len); - - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL39_RTC_INST_LOWER_BOUND); - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { -#if 0 /* Enable this if you want to see details */ - IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - i, val, *image); -#endif - rc = -EIO; - errcnt++; - if (errcnt >= 3) - break; - } - } - - return rc; -} - - -/** - * il3945_verify_ucode - determine which instruction image is in SRAM, - * and verify its contents - */ -static int il3945_verify_ucode(struct il_priv *il) -{ - __le32 *image; - u32 len; - int rc = 0; - - /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - rc = il3945_verify_inst_sparse(il, image, len); - if (rc == 0) { - D_INFO("Bootstrap uCode is good in inst SRAM\n"); - return 0; - } - - /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; - len = il->ucode_init.len; - rc = il3945_verify_inst_sparse(il, image, len); - if (rc == 0) { - D_INFO("Initialize uCode is good in inst SRAM\n"); - return 0; - } - - /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; - len = il->ucode_code.len; - rc = il3945_verify_inst_sparse(il, image, len); - if (rc == 0) { - D_INFO("Runtime uCode is good in inst SRAM\n"); - return 0; - } - - IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); - - /* Since nothing seems to match, show first several data entries in - * instruction SRAM, so maybe visual inspection will give a clue. - * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - rc = il3945_verify_inst_full(il, image, len); - - return rc; -} - -static void il3945_nic_start(struct il_priv *il) -{ - /* Remove all resets to allow NIC to operate */ - _il_wr(il, CSR_RESET, 0); -} - -#define IL3945_UCODE_GET(item) \ -static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ -{ \ - return le32_to_cpu(ucode->v1.item); \ -} - -static u32 il3945_ucode_get_header_size(u32 api_ver) -{ - return 24; -} - -static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) -{ - return (u8 *) ucode->v1.data; -} - -IL3945_UCODE_GET(inst_size); -IL3945_UCODE_GET(data_size); -IL3945_UCODE_GET(init_size); -IL3945_UCODE_GET(init_data_size); -IL3945_UCODE_GET(boot_size); - -/** - * il3945_read_ucode - Read uCode images from disk file. - * - * Copy into buffers for card to fetch via bus-mastering - */ -static int il3945_read_ucode(struct il_priv *il) -{ - const struct il_ucode_header *ucode; - int ret = -EINVAL, idx; - const struct firmware *ucode_raw; - /* firmware file name contains uCode/driver compatibility version */ - const char *name_pre = il->cfg->fw_name_pre; - const unsigned int api_max = il->cfg->ucode_api_max; - const unsigned int api_min = il->cfg->ucode_api_min; - char buf[25]; - u8 *src; - size_t len; - u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size; - - /* Ask kernel firmware_class module to get the boot firmware off disk. - * request_firmware() is synchronous, file is in memory on return. */ - for (idx = api_max; idx >= api_min; idx--) { - sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); - ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); - if (ret < 0) { - IL_ERR("%s firmware file req failed: %d\n", - buf, ret); - if (ret == -ENOENT) - continue; - else - goto error; - } else { - if (idx < api_max) - IL_ERR("Loaded firmware %s, " - "which is deprecated. " - " Please use API v%u instead.\n", - buf, api_max); - D_INFO("Got firmware '%s' file " - "(%zd bytes) from disk\n", - buf, ucode_raw->size); - break; - } - } - - if (ret < 0) - goto error; - - /* Make sure that we got at least our header! */ - if (ucode_raw->size < il3945_ucode_get_header_size(1)) { - IL_ERR("File size way too small!\n"); - ret = -EINVAL; - goto err_release; - } - - /* Data from ucode file: header followed by uCode images */ - ucode = (struct il_ucode_header *)ucode_raw->data; - - il->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(il->ucode_ver); - inst_size = il3945_ucode_get_inst_size(ucode); - data_size = il3945_ucode_get_data_size(ucode); - init_size = il3945_ucode_get_init_size(ucode); - init_data_size = il3945_ucode_get_init_data_size(ucode); - boot_size = il3945_ucode_get_boot_size(ucode); - src = il3945_ucode_get_data(ucode); - - /* api_ver should match the api version forming part of the - * firmware filename ... but we don't check for that and only rely - * on the API version read from firmware header from here on forward */ - - if (api_ver < api_min || api_ver > api_max) { - IL_ERR("Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); - il->ucode_ver = 0; - ret = -EINVAL; - goto err_release; - } - if (api_ver != api_max) - IL_ERR("Firmware has old API version. Expected %u, " - "got %u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); - - IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %u\n", - inst_size); - D_INFO("f/w package hdr runtime data size = %u\n", - data_size); - D_INFO("f/w package hdr init inst size = %u\n", - init_size); - D_INFO("f/w package hdr init data size = %u\n", - init_data_size); - D_INFO("f/w package hdr boot inst size = %u\n", - boot_size); - - - /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + - inst_size + data_size + init_size + - init_data_size + boot_size) { - - D_INFO( - "uCode file size %zd does not match expected size\n", - ucode_raw->size); - ret = -EINVAL; - goto err_release; - } - - /* Verify that uCode images will fit in card's SRAM */ - if (inst_size > IL39_MAX_INST_SIZE) { - D_INFO("uCode instr len %d too large to fit in\n", - inst_size); - ret = -EINVAL; - goto err_release; - } - - if (data_size > IL39_MAX_DATA_SIZE) { - D_INFO("uCode data len %d too large to fit in\n", - data_size); - ret = -EINVAL; - goto err_release; - } - if (init_size > IL39_MAX_INST_SIZE) { - D_INFO( - "uCode init instr len %d too large to fit in\n", - init_size); - ret = -EINVAL; - goto err_release; - } - if (init_data_size > IL39_MAX_DATA_SIZE) { - D_INFO( - "uCode init data len %d too large to fit in\n", - init_data_size); - ret = -EINVAL; - goto err_release; - } - if (boot_size > IL39_MAX_BSM_SIZE) { - D_INFO( - "uCode boot instr len %d too large to fit in\n", - boot_size); - ret = -EINVAL; - goto err_release; - } - - /* Allocate ucode buffers for card's bus-master loading ... */ - - /* Runtime instructions and 2 copies of data: - * 1) unmodified from disk - * 2) backup cache for save/restore during power-downs */ - il->ucode_code.len = inst_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - - il->ucode_data.len = data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - - il->ucode_data_backup.len = data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - - if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || - !il->ucode_data_backup.v_addr) - goto err_pci_alloc; - - /* Initialization instructions and data */ - if (init_size && init_data_size) { - il->ucode_init.len = init_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - - il->ucode_init_data.len = init_data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - - if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) - goto err_pci_alloc; - } - - /* Bootstrap (instructions only, no data) */ - if (boot_size) { - il->ucode_boot.len = boot_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - - if (!il->ucode_boot.v_addr) - goto err_pci_alloc; - } - - /* Copy images into buffers for card's bus-master reads ... */ - - /* Runtime instructions (first block of data in file) */ - len = inst_size; - D_INFO( - "Copying (but not loading) uCode instr len %zd\n", len); - memcpy(il->ucode_code.v_addr, src, len); - src += len; - - D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); - - /* Runtime data (2nd block) - * NOTE: Copy into backup buffer will be done in il3945_up() */ - len = data_size; - D_INFO( - "Copying (but not loading) uCode data len %zd\n", len); - memcpy(il->ucode_data.v_addr, src, len); - memcpy(il->ucode_data_backup.v_addr, src, len); - src += len; - - /* Initialization instructions (3rd block) */ - if (init_size) { - len = init_size; - D_INFO( - "Copying (but not loading) init instr len %zd\n", len); - memcpy(il->ucode_init.v_addr, src, len); - src += len; - } - - /* Initialization data (4th block) */ - if (init_data_size) { - len = init_data_size; - D_INFO( - "Copying (but not loading) init data len %zd\n", len); - memcpy(il->ucode_init_data.v_addr, src, len); - src += len; - } - - /* Bootstrap instructions (5th block) */ - len = boot_size; - D_INFO( - "Copying (but not loading) boot instr len %zd\n", len); - memcpy(il->ucode_boot.v_addr, src, len); - - /* We have our copies now, allow OS release its copies */ - release_firmware(ucode_raw); - return 0; - - err_pci_alloc: - IL_ERR("failed to allocate pci memory\n"); - ret = -ENOMEM; - il3945_dealloc_ucode_pci(il); - - err_release: - release_firmware(ucode_raw); - - error: - return ret; -} - - -/** - * il3945_set_ucode_ptrs - Set uCode address location - * - * Tell initialization uCode where to find runtime uCode. - * - * BSM registers initially contain pointers to initialization uCode. - * We need to replace them to load runtime uCode inst and data, - * and to save runtime data when powering down. - */ -static int il3945_set_ucode_ptrs(struct il_priv *il) -{ - dma_addr_t pinst; - dma_addr_t pdata; - - /* bits 31:0 for 3945 */ - pinst = il->ucode_code.p_addr; - pdata = il->ucode_data_backup.p_addr; - - /* Tell bootstrap uCode where to find image to load */ - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); - - /* Inst byte count must be last to set up, bit 31 signals uCode - * that all new ptr/size info is in place */ - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); - - D_INFO("Runtime uCode pointers are set.\n"); - - return 0; -} - -/** - * il3945_init_alive_start - Called after REPLY_ALIVE notification received - * - * Called after REPLY_ALIVE notification received from "initialize" uCode. - * - * Tell "initialize" uCode to go ahead and load the runtime uCode. - */ -static void il3945_init_alive_start(struct il_priv *il) -{ - /* Check alive response for "valid" sign from uCode */ - if (il->card_alive_init.is_valid != UCODE_VALID_OK) { - /* We had an error bringing up the hardware, so take it - * all the way back down so we can try again */ - D_INFO("Initialize Alive failed.\n"); - goto restart; - } - - /* Bootstrap uCode has loaded initialize uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "initialize" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad \"initialize\" uCode load.\n"); - goto restart; - } - - /* Send pointers to protocol/runtime uCode image ... init code will - * load and launch runtime uCode, which will send us another "Alive" - * notification. */ - D_INFO("Initialization Alive received.\n"); - if (il3945_set_ucode_ptrs(il)) { - /* Runtime instruction load won't happen; - * take it all the way back down so we can try again */ - D_INFO("Couldn't set up uCode pointers.\n"); - goto restart; - } - return; - - restart: - queue_work(il->workqueue, &il->restart); -} - -/** - * il3945_alive_start - called after REPLY_ALIVE notification received - * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by il3945_init_alive_start()). - */ -static void il3945_alive_start(struct il_priv *il) -{ - int thermal_spin = 0; - u32 rfkill; - struct il_rxon_context *ctx = &il->ctx; - - D_INFO("Runtime Alive received.\n"); - - if (il->card_alive.is_valid != UCODE_VALID_OK) { - /* We had an error bringing up the hardware, so take it - * all the way back down so we can try again */ - D_INFO("Alive failed.\n"); - goto restart; - } - - /* Initialize uCode has loaded Runtime uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "runtime" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad runtime uCode load.\n"); - goto restart; - } - - rfkill = il_rd_prph(il, APMG_RFKILL_REG); - D_INFO("RFKILL status: 0x%x\n", rfkill); - - if (rfkill & 0x1) { - clear_bit(STATUS_RF_KILL_HW, &il->status); - /* if RFKILL is not on, then wait for thermal - * sensor in adapter to kick in */ - while (il3945_hw_get_temperature(il) == 0) { - thermal_spin++; - udelay(10); - } - - if (thermal_spin) - D_INFO("Thermal calibration took %dus\n", - thermal_spin * 10); - } else - set_bit(STATUS_RF_KILL_HW, &il->status); - - /* After the ALIVE response, we can send commands to 3945 uCode */ - set_bit(STATUS_ALIVE, &il->status); - - /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(il); - - if (il_is_rfkill(il)) - return; - - ieee80211_wake_queues(il->hw); - - il->active_rate = RATES_MASK_3945; - - il_power_update_mode(il, true); - - if (il_is_associated(il)) { - struct il3945_rxon_cmd *active_rxon = - (struct il3945_rxon_cmd *)(&ctx->active); - - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - } else { - /* Initialize our rx_config data */ - il_connection_init_rx_config(il, ctx); - } - - /* Configure Bluetooth device coexistence support */ - il_send_bt_config(il); - - set_bit(STATUS_READY, &il->status); - - /* Configure the adapter for unassociated operation */ - il3945_commit_rxon(il, ctx); - - il3945_reg_txpower_periodic(il); - - D_INFO("ALIVE processing complete.\n"); - wake_up(&il->wait_command_queue); - - return; - - restart: - queue_work(il->workqueue, &il->restart); -} - -static void il3945_cancel_deferred_work(struct il_priv *il); - -static void __il3945_down(struct il_priv *il) -{ - unsigned long flags; - int exit_pending; - - D_INFO(DRV_NAME " is going down\n"); - - il_scan_cancel_timeout(il, 200); - - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); - - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set - * to prevent rearm timer */ - del_timer_sync(&il->watchdog); - - /* Station information will now be cleared in device */ - il_clear_ucode_stations(il, NULL); - il_dealloc_bcast_stations(il); - il_clear_driver_stations(il); - - /* Unblock any waiting calls */ - wake_up_all(&il->wait_command_queue); - - /* Wipe out the EXIT_PENDING status bit if we are not actually - * exiting the module */ - if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* stop and reset the on-board processor */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - il3945_synchronize_irq(il); - - if (il->mac80211_registered) - ieee80211_stop_queues(il->hw); - - /* If we have not previously called il3945_init() then - * clear all bits but the RF Kill bits and return */ - if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - goto exit; - } - - /* ...otherwise clear out all the status bits but the RF Kill - * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - - il3945_hw_txq_ctx_stop(il); - il3945_hw_rxq_stop(il); - - /* Power-down device's busmaster DMA clocks */ - il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); - udelay(5); - - /* Stop the device, and put it in low power state */ - il_apm_stop(il); - - exit: - memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - il->beacon_skb = NULL; - - /* clear out any free frames */ - il3945_clear_free_frames(il); -} - -static void il3945_down(struct il_priv *il) -{ - mutex_lock(&il->mutex); - __il3945_down(il); - mutex_unlock(&il->mutex); - - il3945_cancel_deferred_work(il); -} - -#define MAX_HW_RESTARTS 5 - -static int il3945_alloc_bcast_station(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - unsigned long flags; - u8 sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, - il_bcast_addr, false, NULL); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return -EINVAL; - } - - il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - il->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -static int __il3945_up(struct il_priv *il) -{ - int rc, i; - - rc = il3945_alloc_bcast_station(il); - if (rc) - return rc; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN("Exit pending; will not bring the NIC up\n"); - return -EIO; - } - - if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR("ucode not available for device bring up\n"); - return -EIO; - } - - /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); - else { - set_bit(STATUS_RF_KILL_HW, &il->status); - IL_WARN("Radio disabled by HW RF Kill switch\n"); - return -ENODEV; - } - - _il_wr(il, CSR_INT, 0xFFFFFFFF); - - rc = il3945_hw_nic_init(il); - if (rc) { - IL_ERR("Unable to int nic\n"); - return rc; - } - - /* make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - /* clear (again), then enable host interrupts */ - _il_wr(il, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(il); - - /* really make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - - /* Copy original ucode data image from disk into backup cache. - * This will be used to initialize the on-board processor's - * data SRAM for a clean start when the runtime program first loads. */ - memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, - il->ucode_data.len); - - /* We return success when we resume from suspend and rf_kill is on. */ - if (test_bit(STATUS_RF_KILL_HW, &il->status)) - return 0; - - for (i = 0; i < MAX_HW_RESTARTS; i++) { - - /* load bootstrap state machine, - * load bootstrap program into processor's memory, - * prepare to load the "initialize" uCode */ - rc = il->cfg->ops->lib->load_ucode(il); - - if (rc) { - IL_ERR( - "Unable to set up bootstrap uCode: %d\n", rc); - continue; - } - - /* start card; "initialize" will load runtime ucode */ - il3945_nic_start(il); - - D_INFO(DRV_NAME " is coming up\n"); - - return 0; - } - - set_bit(STATUS_EXIT_PENDING, &il->status); - __il3945_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* tried to restart and config the device for as long as our - * patience could withstand */ - IL_ERR("Unable to initialize device after %d attempts.\n", i); - return -EIO; -} - - -/***************************************************************************** - * - * Workqueue callbacks - * - *****************************************************************************/ - -static void il3945_bg_init_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, init_alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il3945_init_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -static void il3945_bg_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il3945_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -/* - * 3945 cannot interrupt driver when hardware rf kill switch toggles; - * driver must poll CSR_GP_CNTRL_REG register for change. This register - * *is* readable even when device has been SW_RESET into low power mode - * (e.g. during RF KILL). - */ -static void il3945_rfkill_poll(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, _3945.rfkill_poll.work); - bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); - bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) - & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); - - if (new_rfkill != old_rfkill) { - if (new_rfkill) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - - wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); - - D_RF_KILL("RF_KILL bit toggled to %s.\n", - new_rfkill ? "disable radio" : "enable radio"); - } - - /* Keep this running, even if radio now enabled. This will be - * cancelled in mac_start() if system decides to start again */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - round_jiffies_relative(2 * HZ)); - -} - -int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) -{ - struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, - .len = sizeof(struct il3945_scan_cmd), - .flags = CMD_SIZE_HUGE, - }; - struct il3945_scan_cmd *scan; - u8 n_probes = 0; - enum ieee80211_band band; - bool is_active = false; - int ret; - u16 len; - - lockdep_assert_held(&il->mutex); - - if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!il->scan_cmd) { - D_SCAN("Fail to allocate scan memory\n"); - return -ENOMEM; - } - } - scan = il->scan_cmd; - memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); - - scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; - scan->quiet_time = IL_ACTIVE_QUIET_TIME; - - if (il_is_associated(il)) { - u16 interval; - u32 extra; - u32 suspend_time = 100; - u32 scan_suspend_time = 100; - - D_INFO("Scanning while associated...\n"); - - interval = vif->bss_conf.beacon_int; - - scan->suspend_time = 0; - scan->max_out_time = cpu_to_le32(200 * 1024); - if (!interval) - interval = suspend_time; - /* - * suspend time format: - * 0-19: beacon interval in usec (time before exec.) - * 20-23: 0 - * 24-31: number of beacons (suspend between channels) - */ - - extra = (suspend_time / interval) << 24; - scan_suspend_time = 0xFF0FFFFF & - (extra | ((suspend_time % interval) * 1024)); - - scan->suspend_time = cpu_to_le32(scan_suspend_time); - D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); - } - - if (il->scan_request->n_ssids) { - int i, p = 0; - D_SCAN("Kicking off active scan\n"); - for (i = 0; i < il->scan_request->n_ssids; i++) { - /* always does wildcard anyway */ - if (!il->scan_request->ssids[i].ssid_len) - continue; - scan->direct_scan[p].id = WLAN_EID_SSID; - scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; - memcpy(scan->direct_scan[p].ssid, - il->scan_request->ssids[i].ssid, - il->scan_request->ssids[i].ssid_len); - n_probes++; - p++; - } - is_active = true; - } else - D_SCAN("Kicking off passive scan.\n"); - - /* We don't build a direct scan probe request; the uCode will do - * that based on the direct_mask added to each channel entry */ - scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = il->ctx.bcast_sta_id; - scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - - /* flags + rate selection */ - - switch (il->scan_band) { - case IEEE80211_BAND_2GHZ: - scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - scan->tx_cmd.rate = RATE_1M_PLCP; - band = IEEE80211_BAND_2GHZ; - break; - case IEEE80211_BAND_5GHZ: - scan->tx_cmd.rate = RATE_6M_PLCP; - band = IEEE80211_BAND_5GHZ; - break; - default: - IL_WARN("Invalid scan band\n"); - return -EIO; - } - - /* - * If active scaning is requested but a certain channel - * is marked passive, we can do active scanning if we - * detect transmissions. - */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_DISABLED; - - len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, - vif->addr, il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); - scan->tx_cmd.len = cpu_to_le16(len); - - /* select Rx antennas */ - scan->flags |= il3945_get_antenna_flags(il); - - scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, - (void *)&scan->data[len], vif); - if (scan->channel_count == 0) { - D_SCAN("channel count %d\n", scan->channel_count); - return -EIO; - } - - cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct il3945_scan_channel); - cmd.data = scan; - scan->len = cpu_to_le16(cmd.len); - - set_bit(STATUS_SCAN_HW, &il->status); - ret = il_send_cmd_sync(il, &cmd); - if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); - return ret; -} - -void il3945_post_scan(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - - /* - * Since setting the RXON may have been deferred while - * performing the scan, fire one off if needed - */ - if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il3945_commit_rxon(il, ctx); -} - -static void il3945_bg_restart(struct work_struct *data) -{ - struct il_priv *il = container_of(data, struct il_priv, restart); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - mutex_lock(&il->mutex); - il->ctx.vif = NULL; - il->is_open = 0; - mutex_unlock(&il->mutex); - il3945_down(il); - ieee80211_restart_hw(il->hw); - } else { - il3945_down(il); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - mutex_unlock(&il->mutex); - return; - } - - __il3945_up(il); - mutex_unlock(&il->mutex); - } -} - -static void il3945_bg_rx_replenish(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il3945_rx_replenish(il); -out: - mutex_unlock(&il->mutex); -} - -void il3945_post_associate(struct il_priv *il) -{ - int rc = 0; - struct ieee80211_conf *conf = NULL; - struct il_rxon_context *ctx = &il->ctx; - - if (!ctx->vif || !il->is_open) - return; - - D_ASSOC("Associated as %d to: %pM\n", - ctx->vif->bss_conf.aid, ctx->active.bssid_addr); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - il_scan_cancel_timeout(il, 200); - - conf = il_ieee80211_get_hw_conf(il->hw); - - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); - - rc = il_send_rxon_timing(il, ctx); - if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " - "Attempting to continue.\n"); - - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - - ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - - D_ASSOC("assoc id %d beacon interval %d\n", - ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); - - if (ctx->vif->bss_conf.use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (ctx->vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; - } - - il3945_commit_rxon(il, ctx); - - switch (ctx->vif->type) { - case NL80211_IFTYPE_STATION: - il3945_rate_scale_init(il->hw, IL_AP_ID); - break; - case NL80211_IFTYPE_ADHOC: - il3945_send_beacon_cmd(il); - break; - default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, ctx->vif->type); - break; - } -} - -/***************************************************************************** - * - * mac80211 entry point functions - * - *****************************************************************************/ - -#define UCODE_READY_TIMEOUT (2 * HZ) - -static int il3945_mac_start(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - int ret; - - D_MAC80211("enter\n"); - - /* we should be verifying the device is ready to be opened */ - mutex_lock(&il->mutex); - - /* fetch ucode file from disk, alloc and copy to bus-master buffers ... - * ucode filename and max sizes are card-specific. */ - - if (!il->ucode_code.len) { - ret = il3945_read_ucode(il); - if (ret) { - IL_ERR("Could not read microcode: %d\n", ret); - mutex_unlock(&il->mutex); - goto out_release_irq; - } - } - - ret = __il3945_up(il); - - mutex_unlock(&il->mutex); - - if (ret) - goto out_release_irq; - - D_INFO("Start UP work.\n"); - - /* Wait for START_ALIVE from ucode. Otherwise callbacks from - * mac80211 will not be run successfully. */ - ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), - UCODE_READY_TIMEOUT); - if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR( - "Wait for START_ALIVE timeout after %dms.\n", - jiffies_to_msecs(UCODE_READY_TIMEOUT)); - ret = -ETIMEDOUT; - goto out_release_irq; - } - } - - /* ucode is running and will send rfkill notifications, - * no need to poll the killswitch state anymore */ - cancel_delayed_work(&il->_3945.rfkill_poll); - - il->is_open = 1; - D_MAC80211("leave\n"); - return 0; - -out_release_irq: - il->is_open = 0; - D_MAC80211("leave - failed\n"); - return ret; -} - -static void il3945_mac_stop(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - - D_MAC80211("enter\n"); - - if (!il->is_open) { - D_MAC80211("leave - skip\n"); - return; - } - - il->is_open = 0; - - il3945_down(il); - - flush_workqueue(il->workqueue); - - /* start polling the killswitch state again */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - round_jiffies_relative(2 * HZ)); - - D_MAC80211("leave\n"); -} - -static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -{ - struct il_priv *il = hw->priv; - - D_MAC80211("enter\n"); - - D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - - if (il3945_tx_skb(il, skb)) - dev_kfree_skb_any(skb); - - D_MAC80211("leave\n"); -} - -void il3945_config_ap(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_vif *vif = ctx->vif; - int rc = 0; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - /* The following should be done only at AP bring up */ - if (!(il_is_associated(il))) { - - /* RXON - unassoc (to set timing command) */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); - - /* RXON Timing */ - rc = il_send_rxon_timing(il, ctx); - if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " - "Attempting to continue.\n"); - - ctx->staging.assoc_id = 0; - - if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; - } - /* restore RXON assoc */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); - } - il3945_send_beacon_cmd(il); -} - -static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) -{ - struct il_priv *il = hw->priv; - int ret = 0; - u8 sta_id = IL_INVALID_STATION; - u8 static_key; - - D_MAC80211("enter\n"); - - if (il3945_mod_params.sw_crypto) { - D_MAC80211("leave - hwcrypto disabled\n"); - return -EOPNOTSUPP; - } - - /* - * To support IBSS RSN, don't program group keys in IBSS, the - * hardware will then not attempt to decrypt the frames. - */ - if (vif->type == NL80211_IFTYPE_ADHOC && - !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) - return -EOPNOTSUPP; - - static_key = !il_is_associated(il); - - if (!static_key) { - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, sta); - if (sta_id == IL_INVALID_STATION) - return -EINVAL; - } - - mutex_lock(&il->mutex); - il_scan_cancel_timeout(il, 100); - - switch (cmd) { - case SET_KEY: - if (static_key) - ret = il3945_set_static_key(il, key); - else - ret = il3945_set_dynamic_key(il, key, sta_id); - D_MAC80211("enable hwcrypto key\n"); - break; - case DISABLE_KEY: - if (static_key) - ret = il3945_remove_static_key(il); - else - ret = il3945_clear_sta_key_info(il, sta_id); - D_MAC80211("disable hwcrypto key\n"); - break; - default: - ret = -EINVAL; - } - - mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); - - return ret; -} - -static int il3945_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct il_priv *il = hw->priv; - struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; - int ret; - bool is_ap = vif->type == NL80211_IFTYPE_STATION; - u8 sta_id; - - D_INFO("received request to add station %pM\n", - sta->addr); - mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); - sta_priv->common.sta_id = IL_INVALID_STATION; - - - ret = il_add_station_common(il, - &il->ctx, - sta->addr, is_ap, sta, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); - /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&il->mutex); - return ret; - } - - sta_priv->common.sta_id = sta_id; - - /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); - il3945_rs_rate_init(il, sta, sta_id); - mutex_unlock(&il->mutex); - - return 0; -} - -static void il3945_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) -{ - struct il_priv *il = hw->priv; - __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx = &il->ctx; - -#define CHK(test, flag) do { \ - if (*total_flags & (test)) \ - filter_or |= (flag); \ - else \ - filter_nand |= (flag); \ - } while (0) - - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); - - CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); - CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); - CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); - -#undef CHK - - mutex_lock(&il->mutex); - - ctx->staging.filter_flags &= ~filter_nand; - ctx->staging.filter_flags |= filter_or; - - /* - * Not committing directly because hardware can perform a scan, - * but even if hw is ready, committing here breaks for some reason, - * we'll eventually commit the filter flags change anyway. - */ - - mutex_unlock(&il->mutex); - - /* - * Receiving all multicast frames is always enabled by the - * default flags setup in il_connection_init_rx_config() - * since we currently do not support programming multicast - * filters into the device. - */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; -} - - -/***************************************************************************** - * - * sysfs attributes - * - *****************************************************************************/ - -#ifdef CONFIG_IWLEGACY_DEBUG - -/* - * The following adds a new attribute to the sysfs representation - * of this device driver (i.e. a new file in /sys/bus/pci/drivers/iwl/) - * used for controlling the debug level. - * - * See the level definitions in iwl for details. - * - * The debug_level being managed using sysfs below is a per device debug - * level that is used instead of the global debug level if it (the per - * device debug level) is set. - */ -static ssize_t il3945_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); -} -static ssize_t il3945_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - unsigned long val; - int ret; - - ret = strict_strtoul(buf, 0, &val); - if (ret) - IL_INFO("%s is not in hex or decimal form.\n", buf); - else { - il->debug_level = val; - if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); - } - return strnlen(buf, count); -} - -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il3945_show_debug_level, il3945_store_debug_level); - -#endif /* CONFIG_IWLEGACY_DEBUG */ - -static ssize_t il3945_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_alive(il)) - return -EAGAIN; - - return sprintf(buf, "%d\n", il3945_hw_get_temperature(il)); -} - -static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); - -static ssize_t il3945_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "%d\n", il->tx_power_user_lmt); -} - -static ssize_t il3945_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - char *p = (char *)buf; - u32 val; - - val = simple_strtoul(p, &p, 10); - if (p == buf) - IL_INFO(": %s is not in decimal form.\n", buf); - else - il3945_hw_reg_set_txpower(il, val); - - return count; -} - -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); - -static ssize_t il3945_show_flags(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - - return sprintf(buf, "0x%04X\n", ctx->active.flags); -} - -static ssize_t il3945_store_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - u32 flags = simple_strtoul(buf, NULL, 0); - struct il_rxon_context *ctx = &il->ctx; - - mutex_lock(&il->mutex); - if (le32_to_cpu(ctx->staging.flags) != flags) { - /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(il, 100)) - IL_WARN("Could not cancel scan.\n"); - else { - D_INFO("Committing rxon.flags = 0x%04X\n", - flags); - ctx->staging.flags = cpu_to_le32(flags); - il3945_commit_rxon(il, ctx); - } - } - mutex_unlock(&il->mutex); - - return count; -} - -static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); - -static ssize_t il3945_show_filter_flags(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - - return sprintf(buf, "0x%04X\n", - le32_to_cpu(ctx->active.filter_flags)); -} - -static ssize_t il3945_store_filter_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - u32 filter_flags = simple_strtoul(buf, NULL, 0); - - mutex_lock(&il->mutex); - if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { - /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(il, 100)) - IL_WARN("Could not cancel scan.\n"); - else { - D_INFO("Committing rxon.filter_flags = " - "0x%04X\n", filter_flags); - ctx->staging.filter_flags = - cpu_to_le32(filter_flags); - il3945_commit_rxon(il, ctx); - } - } - mutex_unlock(&il->mutex); - - return count; -} - -static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, - il3945_store_filter_flags); - -static ssize_t il3945_show_measurement(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_spectrum_notification measure_report; - u32 size = sizeof(measure_report), len = 0, ofs = 0; - u8 *data = (u8 *)&measure_report; - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - if (!(il->measurement_status & MEASUREMENT_READY)) { - spin_unlock_irqrestore(&il->lock, flags); - return 0; - } - memcpy(&measure_report, &il->measure_report, size); - il->measurement_status = 0; - spin_unlock_irqrestore(&il->lock, flags); - - while (size && PAGE_SIZE - len) { - hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, - PAGE_SIZE - len, 1); - len = strlen(buf); - if (PAGE_SIZE - len) - buf[len++] = '\n'; - - ofs += 16; - size -= min(size, 16U); - } - - return len; -} - -static ssize_t il3945_store_measurement(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_measurement_params params = { - .channel = le16_to_cpu(ctx->active.channel), - .start_time = cpu_to_le64(il->_3945.last_tsf), - .duration = cpu_to_le16(1), - }; - u8 type = IL_MEASURE_BASIC; - u8 buffer[32]; - u8 channel; - - if (count) { - char *p = buffer; - strncpy(buffer, buf, min(sizeof(buffer), count)); - channel = simple_strtoul(p, NULL, 0); - if (channel) - params.channel = channel; - - p = buffer; - while (*p && *p != ' ') - p++; - if (*p) - type = simple_strtoul(p + 1, NULL, 0); - } - - D_INFO("Invoking measurement of type %d on " - "channel %d (for '%s')\n", type, params.channel, buf); - il3945_get_measurement(il, ¶ms, type); - - return count; -} - -static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, - il3945_show_measurement, il3945_store_measurement); - -static ssize_t il3945_store_retry_rate(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - - il->retry_rate = simple_strtoul(buf, NULL, 0); - if (il->retry_rate <= 0) - il->retry_rate = 1; - - return count; -} - -static ssize_t il3945_show_retry_rate(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "%d", il->retry_rate); -} - -static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, - il3945_store_retry_rate); - - -static ssize_t il3945_show_channels(struct device *d, - struct device_attribute *attr, char *buf) -{ - /* all this shit doesn't belong into sysfs anyway */ - return 0; -} - -static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); - -static ssize_t il3945_show_antenna(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_alive(il)) - return -EAGAIN; - - return sprintf(buf, "%d\n", il3945_mod_params.antenna); -} - -static ssize_t il3945_store_antenna(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il __maybe_unused = dev_get_drvdata(d); - int ant; - - if (count == 0) - return 0; - - if (sscanf(buf, "%1i", &ant) != 1) { - D_INFO("not in hex or decimal form.\n"); - return count; - } - - if (ant >= 0 && ant <= 2) { - D_INFO("Setting antenna select to %d.\n", ant); - il3945_mod_params.antenna = (enum il3945_antenna)ant; - } else - D_INFO("Bad antenna select value %d.\n", ant); - - - return count; -} - -static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); - -static ssize_t il3945_show_status(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(il)) - return -EAGAIN; - return sprintf(buf, "0x%08x\n", (int)il->status); -} - -static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); - -static ssize_t il3945_dump_error_log(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - char *p = (char *)buf; - - if (p[0] == '1') - il3945_dump_nic_error_log(il); - - return strnlen(buf, count); -} - -static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); - -/***************************************************************************** - * - * driver setup and tear down - * - *****************************************************************************/ - -static void il3945_setup_deferred_work(struct il_priv *il) -{ - il->workqueue = create_singlethread_workqueue(DRV_NAME); - - init_waitqueue_head(&il->wait_command_queue); - - INIT_WORK(&il->restart, il3945_bg_restart); - INIT_WORK(&il->rx_replenish, il3945_bg_rx_replenish); - INIT_DELAYED_WORK(&il->init_alive_start, il3945_bg_init_alive_start); - INIT_DELAYED_WORK(&il->alive_start, il3945_bg_alive_start); - INIT_DELAYED_WORK(&il->_3945.rfkill_poll, il3945_rfkill_poll); - - il_setup_scan_deferred_work(il); - - il3945_hw_setup_deferred_work(il); - - init_timer(&il->watchdog); - il->watchdog.data = (unsigned long)il; - il->watchdog.function = il_bg_watchdog; - - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il3945_irq_tasklet, (unsigned long)il); -} - -static void il3945_cancel_deferred_work(struct il_priv *il) -{ - il3945_hw_cancel_deferred_work(il); - - cancel_delayed_work_sync(&il->init_alive_start); - cancel_delayed_work(&il->alive_start); - - il_cancel_scan_deferred_work(il); -} - -static struct attribute *il3945_sysfs_entries[] = { - &dev_attr_antenna.attr, - &dev_attr_channels.attr, - &dev_attr_dump_errors.attr, - &dev_attr_flags.attr, - &dev_attr_filter_flags.attr, - &dev_attr_measurement.attr, - &dev_attr_retry_rate.attr, - &dev_attr_status.attr, - &dev_attr_temperature.attr, - &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLEGACY_DEBUG - &dev_attr_debug_level.attr, -#endif - NULL -}; - -static struct attribute_group il3945_attribute_group = { - .name = NULL, /* put in device directory */ - .attrs = il3945_sysfs_entries, -}; - -struct ieee80211_ops il3945_hw_ops = { - .tx = il3945_mac_tx, - .start = il3945_mac_start, - .stop = il3945_mac_stop, - .add_interface = il_mac_add_interface, - .remove_interface = il_mac_remove_interface, - .change_interface = il_mac_change_interface, - .config = il_mac_config, - .configure_filter = il3945_configure_filter, - .set_key = il3945_mac_set_key, - .conf_tx = il_mac_conf_tx, - .reset_tsf = il_mac_reset_tsf, - .bss_info_changed = il_mac_bss_info_changed, - .hw_scan = il_mac_hw_scan, - .sta_add = il3945_mac_sta_add, - .sta_remove = il_mac_sta_remove, - .tx_last_beacon = il_mac_tx_last_beacon, -}; - -static int il3945_init_drv(struct il_priv *il) -{ - int ret; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - - il->retry_rate = 1; - il->beacon_skb = NULL; - - spin_lock_init(&il->sta_lock); - spin_lock_init(&il->hcmd_lock); - - INIT_LIST_HEAD(&il->free_frames); - - mutex_init(&il->mutex); - - il->ieee_channels = NULL; - il->ieee_rates = NULL; - il->band = IEEE80211_BAND_2GHZ; - - il->iw_mode = NL80211_IFTYPE_STATION; - il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; - - /* initialize force reset */ - il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; - - if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IL_WARN("Unsupported EEPROM version: 0x%04X\n", - eeprom->version); - ret = -EINVAL; - goto err; - } - ret = il_init_channel_map(il); - if (ret) { - IL_ERR("initializing regulatory failed: %d\n", ret); - goto err; - } - - /* Set up txpower settings in driver for all channels */ - if (il3945_txpower_set_from_eeprom(il)) { - ret = -EIO; - goto err_free_channel_map; - } - - ret = il_init_geos(il); - if (ret) { - IL_ERR("initializing geos failed: %d\n", ret); - goto err_free_channel_map; - } - il3945_init_hw_rates(il, il->ieee_rates); - - return 0; - -err_free_channel_map: - il_free_channel_map(il); -err: - return ret; -} - -#define IL3945_MAX_PROBE_REQUEST 200 - -static int il3945_setup_mac(struct il_priv *il) -{ - int ret; - struct ieee80211_hw *hw = il->hw; - - hw->rate_control_algorithm = "iwl-3945-rs"; - hw->sta_data_size = sizeof(struct il3945_sta_priv); - hw->vif_data_size = sizeof(struct il_vif_priv); - - /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_SPECTRUM_MGMT; - - hw->wiphy->interface_modes = - il->ctx.interface_modes; - - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS | - WIPHY_FLAG_IBSS_RSN; - - hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; - /* we create the 802.11 header and a zero-length SSID element */ - hw->wiphy->max_scan_ie_len = IL3945_MAX_PROBE_REQUEST - 24 - 2; - - /* Default value; 4 EDCA QOS priorities */ - hw->queues = 4; - - if (il->bands[IEEE80211_BAND_2GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; - - if (il->bands[IEEE80211_BAND_5GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; - - il_leds_init(il); - - ret = ieee80211_register_hw(il->hw); - if (ret) { - IL_ERR("Failed to register hw (error %d)\n", ret); - return ret; - } - il->mac80211_registered = 1; - - return 0; -} - -static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - int err = 0; - struct il_priv *il; - struct ieee80211_hw *hw; - struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); - struct il3945_eeprom *eeprom; - unsigned long flags; - - /*********************** - * 1. Allocating HW data - * ********************/ - - /* mac80211 allocates memory for this device instance, including - * space for this driver's ilate structure */ - hw = il_alloc_all(cfg); - if (hw == NULL) { - pr_err("Can not allocate network device\n"); - err = -ENOMEM; - goto out; - } - il = hw->priv; - SET_IEEE80211_DEV(hw, &pdev->dev); - - il->cmd_queue = IL39_CMD_QUEUE_NUM; - - il->ctx.ctxid = 0; - - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; - il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; - il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC); - il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; - il->ctx.station_devtype = RXON_DEV_TYPE_ESS; - il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; - - /* - * Disabling hardware scan means that mac80211 will perform scans - * "the hard way", rather than using device's scan. - */ - if (il3945_mod_params.disable_hw_scan) { - D_INFO("Disabling hw_scan\n"); - il3945_hw_ops.hw_scan = NULL; - } - - D_INFO("*** LOAD DRIVER ***\n"); - il->cfg = cfg; - il->pci_dev = pdev; - il->inta_mask = CSR_INI_SET_MASK; - - if (il_alloc_traffic_mem(il)) - IL_ERR("Not enough memory to generate traffic log\n"); - - /*************************** - * 2. Initializing PCI bus - * *************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); - - if (pci_enable_device(pdev)) { - err = -ENODEV; - goto out_ieee80211_free_hw; - } - - pci_set_master(pdev); - - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); - if (err) { - IL_WARN("No suitable DMA available.\n"); - goto out_pci_disable_device; - } - - pci_set_drvdata(pdev, il); - err = pci_request_regions(pdev, DRV_NAME); - if (err) - goto out_pci_disable_device; - - /*********************** - * 3. Read REV Register - * ********************/ - il->hw_base = pci_iomap(pdev, 0, 0); - if (!il->hw_base) { - err = -ENODEV; - goto out_pci_release_regions; - } - - D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); - D_INFO("pci_resource_base = %p\n", il->hw_base); - - /* We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state */ - pci_write_config_byte(pdev, 0x41, 0x00); - - /* these spin locks will be used in apm_ops.init and EEPROM access - * we should init now - */ - spin_lock_init(&il->reg_lock); - spin_lock_init(&il->lock); - - /* - * stop and reset the on-board processor just in case it is in a - * strange state ... like being left stranded by a primary kernel - * and this is now the kdump kernel trying to start up - */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - /*********************** - * 4. Read EEPROM - * ********************/ - - /* Read the EEPROM */ - err = il_eeprom_init(il); - if (err) { - IL_ERR("Unable to init EEPROM\n"); - goto out_iounmap; - } - /* MAC Address location in EEPROM same for 3945/4965 */ - eeprom = (struct il3945_eeprom *)il->eeprom; - D_INFO("MAC address: %pM\n", eeprom->mac_address); - SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); - - /*********************** - * 5. Setup HW Constants - * ********************/ - /* Device-specific setup */ - if (il3945_hw_set_hw_params(il)) { - IL_ERR("failed to set hw settings\n"); - goto out_eeprom_free; - } - - /*********************** - * 6. Setup il - * ********************/ - - err = il3945_init_drv(il); - if (err) { - IL_ERR("initializing driver failed\n"); - goto out_unset_hw_params; - } - - IL_INFO("Detected Intel Wireless WiFi Link %s\n", - il->cfg->name); - - /*********************** - * 7. Setup Services - * ********************/ - - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - pci_enable_msi(il->pci_dev); - - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); - if (err) { - IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); - goto out_disable_msi; - } - - err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); - if (err) { - IL_ERR("failed to create sysfs device attributes\n"); - goto out_release_irq; - } - - il_set_rxon_channel(il, - &il->bands[IEEE80211_BAND_2GHZ].channels[5], - &il->ctx); - il3945_setup_deferred_work(il); - il3945_setup_rx_handlers(il); - il_power_initialize(il); - - /********************************* - * 8. Setup and Register mac80211 - * *******************************/ - - il_enable_interrupts(il); - - err = il3945_setup_mac(il); - if (err) - goto out_remove_sysfs; - - err = il_dbgfs_register(il, DRV_NAME); - if (err) - IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); - - /* Start monitoring the killswitch */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - 2 * HZ); - - return 0; - - out_remove_sysfs: - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - out_release_irq: - free_irq(il->pci_dev->irq, il); - out_disable_msi: - pci_disable_msi(il->pci_dev); - il_free_geos(il); - il_free_channel_map(il); - out_unset_hw_params: - il3945_unset_hw_params(il); - out_eeprom_free: - il_eeprom_free(il); - out_iounmap: - pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: - pci_release_regions(pdev); - out_pci_disable_device: - pci_set_drvdata(pdev, NULL); - pci_disable_device(pdev); - out_ieee80211_free_hw: - il_free_traffic_mem(il); - ieee80211_free_hw(il->hw); - out: - return err; -} - -static void __devexit il3945_pci_remove(struct pci_dev *pdev) -{ - struct il_priv *il = pci_get_drvdata(pdev); - unsigned long flags; - - if (!il) - return; - - D_INFO("*** UNLOAD DRIVER ***\n"); - - il_dbgfs_unregister(il); - - set_bit(STATUS_EXIT_PENDING, &il->status); - - il_leds_exit(il); - - if (il->mac80211_registered) { - ieee80211_unregister_hw(il->hw); - il->mac80211_registered = 0; - } else { - il3945_down(il); - } - - /* - * Make sure device is reset to low power before unloading driver. - * This may be redundant with il_down(), but there are paths to - * run il_down() without calling apm_ops.stop(), and there are - * paths to avoid running il_down() at all before leaving driver. - * This (inexpensive) call *makes sure* device is reset. - */ - il_apm_stop(il); - - /* make sure we flush any pending irq or - * tasklet for the driver - */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - il3945_synchronize_irq(il); - - sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - - cancel_delayed_work_sync(&il->_3945.rfkill_poll); - - il3945_dealloc_ucode_pci(il); - - if (il->rxq.bd) - il3945_rx_queue_free(il, &il->rxq); - il3945_hw_txq_ctx_free(il); - - il3945_unset_hw_params(il); - - /*netif_stop_queue(dev); */ - flush_workqueue(il->workqueue); - - /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes - * il->workqueue... so we can't take down the workqueue - * until now... */ - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - il_free_traffic_mem(il); - - free_irq(pdev->irq, il); - pci_disable_msi(pdev); - - pci_iounmap(pdev, il->hw_base); - pci_release_regions(pdev); - pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); - - il_free_channel_map(il); - il_free_geos(il); - kfree(il->scan_cmd); - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - - ieee80211_free_hw(il->hw); -} - - -/***************************************************************************** - * - * driver and module entry point - * - *****************************************************************************/ - -static struct pci_driver il3945_driver = { - .name = DRV_NAME, - .id_table = il3945_hw_card_ids, - .probe = il3945_pci_probe, - .remove = __devexit_p(il3945_pci_remove), - .driver.pm = IL_LEGACY_PM_OPS, -}; - -static int __init il3945_init(void) -{ - - int ret; - pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); - pr_info(DRV_COPYRIGHT "\n"); - - ret = il3945_rate_control_register(); - if (ret) { - pr_err("Unable to register rate control algorithm: %d\n", ret); - return ret; - } - - ret = pci_register_driver(&il3945_driver); - if (ret) { - pr_err("Unable to initialize PCI module\n"); - goto error_register; - } - - return ret; - -error_register: - il3945_rate_control_unregister(); - return ret; -} - -static void __exit il3945_exit(void) -{ - pci_unregister_driver(&il3945_driver); - il3945_rate_control_unregister(); -} - -MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); - -module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); -MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); -module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); -MODULE_PARM_DESC(swcrypto, - "using software crypto (default 1 [software])"); -module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, - int, S_IRUGO); -MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); -#ifdef CONFIG_IWLEGACY_DEBUG -module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "debug output mask"); -#endif -module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); -MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); - -module_exit(il3945_exit); -module_init(il3945_init); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c deleted file mode 100644 index df86431..0000000 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ /dev/null @@ -1,3245 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#define DRV_NAME "iwl4965" - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-sta.h" -#include "iwl-4965-calib.h" -#include "iwl-4965.h" -#include "iwl-4965-led.h" - - -/****************************************************************************** - * - * module boiler plate - * - ******************************************************************************/ - -/* - * module name, copyright, version, etc. - */ -#define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux" - -#ifdef CONFIG_IWLEGACY_DEBUG -#define VD "d" -#else -#define VD -#endif - -#define DRV_VERSION IWLWIFI_VERSION VD - - -MODULE_DESCRIPTION(DRV_DESCRIPTION); -MODULE_VERSION(DRV_VERSION); -MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("iwl4965"); - -void il4965_update_chain_flags(struct il_priv *il) -{ - if (il->cfg->ops->hcmd->set_rxon_chain) { - il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); - if (il->ctx.active.rx_chain != il->ctx.staging.rx_chain) - il_commit_rxon(il, &il->ctx); - } -} - -static void il4965_clear_free_frames(struct il_priv *il) -{ - struct list_head *element; - - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); - - while (!list_empty(&il->free_frames)) { - element = il->free_frames.next; - list_del(element); - kfree(list_entry(element, struct il_frame, list)); - il->frames_count--; - } - - if (il->frames_count) { - IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); - il->frames_count = 0; - } -} - -static struct il_frame *il4965_get_free_frame(struct il_priv *il) -{ - struct il_frame *frame; - struct list_head *element; - if (list_empty(&il->free_frames)) { - frame = kzalloc(sizeof(*frame), GFP_KERNEL); - if (!frame) { - IL_ERR("Could not allocate frame!\n"); - return NULL; - } - - il->frames_count++; - return frame; - } - - element = il->free_frames.next; - list_del(element); - return list_entry(element, struct il_frame, list); -} - -static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) -{ - memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &il->free_frames); -} - -static u32 il4965_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) -{ - lockdep_assert_held(&il->mutex); - - if (!il->beacon_skb) - return 0; - - if (il->beacon_skb->len > left) - return 0; - - memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - - return il->beacon_skb->len; -} - -/* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void il4965_set_beacon_tim(struct il_priv *il, - struct il_tx_beacon_cmd *tx_beacon_cmd, - u8 *beacon, u32 frame_size) -{ - u16 tim_idx; - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; - - /* - * The idx is relative to frame start but we start looking at the - * variable-length part of the beacon. - */ - tim_idx = mgmt->u.beacon.variable - beacon; - - /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ - while ((tim_idx < (frame_size - 2)) && - (beacon[tim_idx] != WLAN_EID_TIM)) - tim_idx += beacon[tim_idx+1] + 2; - - /* If TIM field was found, set variables */ - if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { - tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); - tx_beacon_cmd->tim_size = beacon[tim_idx+1]; - } else - IL_WARN("Unable to find TIM Element in beacon\n"); -} - -static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, - struct il_frame *frame) -{ - struct il_tx_beacon_cmd *tx_beacon_cmd; - u32 frame_size; - u32 rate_flags; - u32 rate; - /* - * We have to set up the TX command, the TX Beacon command, and the - * beacon contents. - */ - - lockdep_assert_held(&il->mutex); - - if (!il->beacon_ctx) { - IL_ERR("trying to build beacon w/o beacon context!\n"); - return 0; - } - - /* Initialize memory */ - tx_beacon_cmd = &frame->u.beacon; - memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); - - /* Set up TX beacon contents */ - frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); - if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) - return 0; - if (!frame_size) - return 0; - - /* Set up TX command fields */ - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); - tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; - tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; - - /* Set up TX beacon command fields */ - il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, - frame_size); - - /* Set up packet rate and flags */ - rate = il_get_lowest_plcp(il, il->beacon_ctx); - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); - rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); - if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) - rate_flags |= RATE_MCS_CCK_MSK; - tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, - rate_flags); - - return sizeof(*tx_beacon_cmd) + frame_size; -} - -int il4965_send_beacon_cmd(struct il_priv *il) -{ - struct il_frame *frame; - unsigned int frame_size; - int rc; - - frame = il4965_get_free_frame(il); - if (!frame) { - IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); - return -ENOMEM; - } - - frame_size = il4965_hw_get_beacon_cmd(il, frame); - if (!frame_size) { - IL_ERR("Error configuring the beacon command\n"); - il4965_free_frame(il, frame); - return -EINVAL; - } - - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, - &frame->u.cmd[0]); - - il4965_free_frame(il, frame); - - return rc; -} - -static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) -{ - struct il_tfd_tb *tb = &tfd->tbs[idx]; - - dma_addr_t addr = get_unaligned_le32(&tb->lo); - if (sizeof(dma_addr_t) > sizeof(u32)) - addr |= - ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; - - return addr; -} - -static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) -{ - struct il_tfd_tb *tb = &tfd->tbs[idx]; - - return le16_to_cpu(tb->hi_n_len) >> 4; -} - -static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, - dma_addr_t addr, u16 len) -{ - struct il_tfd_tb *tb = &tfd->tbs[idx]; - u16 hi_n_len = len << 4; - - put_unaligned_le32(addr, &tb->lo); - if (sizeof(dma_addr_t) > sizeof(u32)) - hi_n_len |= ((addr >> 16) >> 16) & 0xF; - - tb->hi_n_len = cpu_to_le16(hi_n_len); - - tfd->num_tbs = idx + 1; -} - -static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) -{ - return tfd->num_tbs & 0x1f; -} - -/** - * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] - * @il - driver ilate data - * @txq - tx queue - * - * Does NOT advance any TFD circular buffer read/write idxes - * Does NOT free the TFD itself (which is within circular buffer) - */ -void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) -{ - struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; - struct il_tfd *tfd; - struct pci_dev *dev = il->pci_dev; - int idx = txq->q.read_ptr; - int i; - int num_tbs; - - tfd = &tfd_tmp[idx]; - - /* Sanity check on number of chunks */ - num_tbs = il4965_tfd_get_num_tbs(tfd); - - if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR("Too many chunks: %i\n", num_tbs); - /* @todo issue fatal error, it is quite serious situation */ - return; - } - - /* Unmap tx_cmd */ - if (num_tbs) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_BIDIRECTIONAL); - - /* Unmap chunks, if any. */ - for (i = 1; i < num_tbs; i++) - pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), - il4965_tfd_tb_get_len(tfd, i), - PCI_DMA_TODEVICE); - - /* free SKB */ - if (txq->txb) { - struct sk_buff *skb; - - skb = txq->txb[txq->q.read_ptr].skb; - - /* can be called from irqs-disabled context */ - if (skb) { - dev_kfree_skb_any(skb); - txq->txb[txq->q.read_ptr].skb = NULL; - } - } -} - -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad) -{ - struct il_queue *q; - struct il_tfd *tfd, *tfd_tmp; - u32 num_tbs; - - q = &txq->q; - tfd_tmp = (struct il_tfd *)txq->tfds; - tfd = &tfd_tmp[q->write_ptr]; - - if (reset) - memset(tfd, 0, sizeof(*tfd)); - - num_tbs = il4965_tfd_get_num_tbs(tfd); - - /* Each TFD can point to a maximum 20 Tx buffers */ - if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR("Error can not send more than %d chunks\n", - IL_NUM_OF_TBS); - return -EINVAL; - } - - BUG_ON(addr & ~DMA_BIT_MASK(36)); - if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR("Unaligned address = %llx\n", - (unsigned long long)addr); - - il4965_tfd_set_tb(tfd, num_tbs, addr, len); - - return 0; -} - -/* - * Tell nic where to find circular buffer of Tx Frame Descriptors for - * given Tx queue, and enable the DMA channel used for that queue. - * - * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA - * channels supported in hardware. - */ -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq) -{ - int txq_id = txq->q.id; - - /* Circular buffer (TFD queue in DRAM) physical base address */ - il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), - txq->q.dma_addr >> 8); - - return 0; -} - -/****************************************************************************** - * - * Generic RX handler implementations - * - ******************************************************************************/ -static void il4965_rx_reply_alive(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_alive_resp *palive; - struct delayed_work *pwork; - - palive = &pkt->u.alive_frame; - - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); - - if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - D_INFO("Initialization Alive received.\n"); - memcpy(&il->card_alive_init, - &pkt->u.alive_frame, - sizeof(struct il_init_alive_resp)); - pwork = &il->init_alive_start; - } else { - D_INFO("Runtime Alive received.\n"); - memcpy(&il->card_alive, &pkt->u.alive_frame, - sizeof(struct il_alive_resp)); - pwork = &il->alive_start; - } - - /* We delay the ALIVE response by 5ms to - * give the HW RF Kill time to activate... */ - if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); - else - IL_WARN("uCode did not respond OK.\n"); -} - -/** - * il4965_bg_stats_periodic - Timer callback to queue stats - * - * This callback is provided in order to send a stats request. - * - * This timer function is continually reset to execute within - * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION - * was received. We need to ensure we receive the stats in order - * to update the temperature used for calibrating the TXPOWER. - */ -static void il4965_bg_stats_periodic(unsigned long data) -{ - struct il_priv *il = (struct il_priv *)data; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - /* dont send host command if rf-kill is on */ - if (!il_is_ready_rf(il)) - return; - - il_send_stats_request(il, CMD_ASYNC, false); -} - -static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il4965_beacon_notif *beacon = - (struct il4965_beacon_notif *)pkt->u.raw; -#ifdef CONFIG_IWLEGACY_DEBUG - u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); -#endif - - il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); -} - -static void il4965_perform_ct_kill_task(struct il_priv *il) -{ - unsigned long flags; - - D_POWER("Stop all queues\n"); - - if (il->mac80211_registered) - ieee80211_stop_queues(il->hw); - - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - _il_rd(il, CSR_UCODE_DRV_GP1); - - spin_lock_irqsave(&il->reg_lock, flags); - if (!_il_grab_nic_access(il)) - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, flags); -} - -/* Handle notification from uCode that card's power state is changing - * due to software, hardware, or critical temperature RFKILL */ -static void il4965_rx_card_state_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = il->status; - - D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On", - (flags & CT_CARD_DISABLED) ? - "Reached" : "Not reached"); - - if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | - CT_CARD_DISABLED)) { - - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); - - if (!(flags & RXON_CARD_DISABLED)) { - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); - } - } - - if (flags & CT_CARD_DISABLED) - il4965_perform_ct_kill_task(il); - - if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - - if (!(flags & RXON_CARD_DISABLED)) - il_scan_cancel(il); - - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) - wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); - else - wake_up(&il->wait_command_queue); -} - -/** - * il4965_setup_rx_handlers - Initialize Rx handler callbacks - * - * Setup the RX handlers for each of the reply types sent from the uCode - * to the host. - * - * This function chains into the hardware specific files for them to setup - * any hardware specific handlers as well. - */ -static void il4965_setup_rx_handlers(struct il_priv *il) -{ - il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; - - /* - * The same handler is used for both the REPLY to a discrete - * stats request from the host as well as for the periodic - * stats notifications (after received beacons) from the uCode. - */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; - - il_setup_rx_scan_handlers(il); - - /* status change handler */ - il->rx_handlers[CARD_STATE_NOTIFICATION] = - il4965_rx_card_state_notif; - - il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = - il4965_rx_missed_beacon_notif; - /* Rx handlers */ - il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; - il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; - /* block ack */ - il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; - /* Set up hardware specific Rx handlers */ - il->cfg->ops->lib->rx_handler_setup(il); -} - -/** - * il4965_rx_handle - Main entry function for receiving responses from uCode - * - * Uses the il->rx_handlers callback function array to invoke - * the appropriate handlers, including command responses, - * frame-received notifications, and other notifications. - */ -void il4965_rx_handle(struct il_priv *il) -{ - struct il_rx_buf *rxb; - struct il_rx_pkt *pkt; - struct il_rx_queue *rxq = &il->rxq; - u32 r, i; - int reclaim; - unsigned long flags; - u8 fill_rx = 0; - u32 count = 8; - int total_empty; - - /* uCode's read idx (stored in shared DRAM) indicates the last Rx - * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; - i = rxq->read; - - /* Rx interrupt, but nothing sent from uCode */ - if (i == r) - D_RX("r = %d, i = %d\n", r, i); - - /* calculate total frames need to be restock after handling RX */ - total_empty = r - rxq->write_actual; - if (total_empty < 0) - total_empty += RX_QUEUE_SIZE; - - if (total_empty > (RX_QUEUE_SIZE / 2)) - fill_rx = 1; - - while (i != r) { - int len; - - rxb = rxq->queue[i]; - - /* If an RXB doesn't have a Rx queue slot associated with it, - * then a bug has been introduced in the queue refilling - * routines -- catch it here */ - BUG_ON(rxb == NULL); - - rxq->queue[i] = NULL; - - pci_unmap_page(il->pci_dev, rxb->page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - pkt = rxb_addr(rxb); - - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ - - /* Reclaim a command buffer only if this packet is a response - * to a (driver-originated) command. - * If the packet (e.g. Rx frame) originated from uCode, - * there is no command buffer to reclaim. - * Ucode should set SEQ_RX_FRAME bit if ucode-originated, - * but apparently a few don't get set; catch them here. */ - reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && - (pkt->hdr.cmd != REPLY_RX) && - (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && - (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && - (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && - (pkt->hdr.cmd != REPLY_TX); - - /* Based on type of command response or notification, - * handle those that need handling via function in - * rx_handlers table. See il4965_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { - D_RX("r = %d, i = %d, %s, 0x%02x\n", r, - i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); - } else { - /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); - } - - /* - * XXX: After here, we should always check rxb->page - * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have - * already taken or freed the pages. - */ - - if (reclaim) { - /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking il_send_cmd() - * as we reclaim the driver command queue */ - if (rxb->page) - il_tx_cmd_complete(il, rxb); - else - IL_WARN("Claim null rxb?\n"); - } - - /* Reuse the page if possible. For notification packets and - * SKBs that fail to Rx correctly, add them back into the - * rx_free list for reuse later. */ - spin_lock_irqsave(&rxq->lock, flags); - if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - } else - list_add_tail(&rxb->list, &rxq->rx_used); - - spin_unlock_irqrestore(&rxq->lock, flags); - - i = (i + 1) & RX_QUEUE_MASK; - /* If there are a lot of unused frames, - * restock the Rx queue so ucode wont assert. */ - if (fill_rx) { - count++; - if (count >= 8) { - rxq->read = i; - il4965_rx_replenish_now(il); - count = 0; - } - } - } - - /* Backtrack one entry */ - rxq->read = i; - if (fill_rx) - il4965_rx_replenish_now(il); - else - il4965_rx_queue_restock(il); -} - -/* call this function to flush any scheduled tasklet */ -static inline void il4965_synchronize_irq(struct il_priv *il) -{ - /* wait to make sure we flush pending tasklet*/ - synchronize_irq(il->pci_dev->irq); - tasklet_kill(&il->irq_tasklet); -} - -static void il4965_irq_tasklet(struct il_priv *il) -{ - u32 inta, handled = 0; - u32 inta_fh; - unsigned long flags; - u32 i; -#ifdef CONFIG_IWLEGACY_DEBUG - u32 inta_mask; -#endif - - spin_lock_irqsave(&il->lock, flags); - - /* Ack/clear/reset pending uCode interrupts. - * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, - * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = _il_rd(il, CSR_INT); - _il_wr(il, CSR_INT, inta); - - /* Ack/clear/reset pending flow-handler (DMA) interrupts. - * Any new interrupts that happen after this, either while we're - * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - _il_wr(il, CSR_FH_INT_STATUS, inta_fh); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & IL_DL_ISR) { - /* just for debug */ - inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); - } -#endif - - spin_unlock_irqrestore(&il->lock, flags); - - /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not - * atomic, make sure that inta covers all the interrupts that - * we've discovered, even if FH interrupt came in just after - * reading CSR_INT. */ - if (inta_fh & CSR49_FH_INT_RX_MASK) - inta |= CSR_INT_BIT_FH_RX; - if (inta_fh & CSR49_FH_INT_TX_MASK) - inta |= CSR_INT_BIT_FH_TX; - - /* Now service all interrupt bits discovered above. */ - if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR("Hardware error detected. Restarting.\n"); - - /* Tell the device to stop sending interrupts */ - il_disable_interrupts(il); - - il->isr_stats.hw++; - il_irq_handle_error(il); - - handled |= CSR_INT_BIT_HW_ERR; - - return; - } - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - /* NIC fires this, but we don't use it, redundant with WAKEUP */ - if (inta & CSR_INT_BIT_SCD) { - D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); - il->isr_stats.sch++; - } - - /* Alive notification via Rx interrupt will do the real work */ - if (inta & CSR_INT_BIT_ALIVE) { - D_ISR("Alive interrupt\n"); - il->isr_stats.alive++; - } - } -#endif - /* Safely ignore these bits for debug checks below */ - inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); - - /* HW RF KILL switch toggled */ - if (inta & CSR_INT_BIT_RF_KILL) { - int hw_rf_kill = 0; - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) - hw_rf_kill = 1; - - IL_WARN("RF_KILL bit toggled to %s.\n", - hw_rf_kill ? "disable radio" : "enable radio"); - - il->isr_stats.rfkill++; - - /* driver only loads ucode once setting the interface up. - * the driver allows loading the ucode even if the radio - * is killed. Hence update the killswitch state here. The - * rfkill handler will care about restarting if needed. - */ - if (!test_bit(STATUS_ALIVE, &il->status)) { - if (hw_rf_kill) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); - } - - handled |= CSR_INT_BIT_RF_KILL; - } - - /* Chip got too hot and stopped itself */ - if (inta & CSR_INT_BIT_CT_KILL) { - IL_ERR("Microcode CT kill error detected.\n"); - il->isr_stats.ctkill++; - handled |= CSR_INT_BIT_CT_KILL; - } - - /* Error detected by uCode */ - if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - " Restarting 0x%X.\n", inta); - il->isr_stats.sw++; - il_irq_handle_error(il); - handled |= CSR_INT_BIT_SW_ERR; - } - - /* - * uCode wakes up after power-down sleep. - * Tell device about any new tx or host commands enqueued, - * and about any Rx buffers made available while asleep. - */ - if (inta & CSR_INT_BIT_WAKEUP) { - D_ISR("Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(il, &il->rxq); - for (i = 0; i < il->hw_params.max_txq_num; i++) - il_txq_update_write_ptr(il, &il->txq[i]); - il->isr_stats.wakeup++; - handled |= CSR_INT_BIT_WAKEUP; - } - - /* All uCode command responses, including Tx command responses, - * Rx "responses" (frame-received notification), and other - * notifications from uCode come through here*/ - if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il4965_rx_handle(il); - il->isr_stats.rx++; - handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); - } - - /* This "Tx" DMA channel is used only for loading uCode */ - if (inta & CSR_INT_BIT_FH_TX) { - D_ISR("uCode load interrupt\n"); - il->isr_stats.tx++; - handled |= CSR_INT_BIT_FH_TX; - /* Wake up uCode load routine, now that load is complete */ - il->ucode_write_complete = 1; - wake_up(&il->wait_command_queue); - } - - if (inta & ~handled) { - IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); - il->isr_stats.unhandled++; - } - - if (inta & ~(il->inta_mask)) { - IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); - } - - /* Re-enable all interrupts */ - /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) - il_enable_interrupts(il); - /* Re-enable RF_KILL if it occurred */ - else if (handled & CSR_INT_BIT_RF_KILL) - il_enable_rfkill_int(il); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = _il_rd(il, CSR_INT); - inta_mask = _il_rd(il, CSR_INT_MASK); - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - D_ISR( - "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); - } -#endif -} - -/***************************************************************************** - * - * sysfs attributes - * - *****************************************************************************/ - -#ifdef CONFIG_IWLEGACY_DEBUG - -/* - * The following adds a new attribute to the sysfs representation - * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/) - * used for controlling the debug level. - * - * See the level definitions in iwl for details. - * - * The debug_level being managed using sysfs below is a per device debug - * level that is used instead of the global debug level if it (the per - * device debug level) is set. - */ -static ssize_t il4965_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); -} -static ssize_t il4965_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - unsigned long val; - int ret; - - ret = strict_strtoul(buf, 0, &val); - if (ret) - IL_ERR("%s is not in hex or decimal form.\n", buf); - else { - il->debug_level = val; - if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); - } - return strnlen(buf, count); -} - -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il4965_show_debug_level, il4965_store_debug_level); - - -#endif /* CONFIG_IWLEGACY_DEBUG */ - - -static ssize_t il4965_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_alive(il)) - return -EAGAIN; - - return sprintf(buf, "%d\n", il->temperature); -} - -static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); - -static ssize_t il4965_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_ready_rf(il)) - return sprintf(buf, "off\n"); - else - return sprintf(buf, "%d\n", il->tx_power_user_lmt); -} - -static ssize_t il4965_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - unsigned long val; - int ret; - - ret = strict_strtoul(buf, 10, &val); - if (ret) - IL_INFO("%s is not in decimal form.\n", buf); - else { - ret = il_set_tx_power(il, val, false); - if (ret) - IL_ERR("failed setting tx power (0x%d).\n", - ret); - else - ret = count; - } - return ret; -} - -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, - il4965_show_tx_power, il4965_store_tx_power); - -static struct attribute *il_sysfs_entries[] = { - &dev_attr_temperature.attr, - &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLEGACY_DEBUG - &dev_attr_debug_level.attr, -#endif - NULL -}; - -static struct attribute_group il_attribute_group = { - .name = NULL, /* put in device directory */ - .attrs = il_sysfs_entries, -}; - -/****************************************************************************** - * - * uCode download functions - * - ******************************************************************************/ - -static void il4965_dealloc_ucode_pci(struct il_priv *il) -{ - il_free_fw_desc(il->pci_dev, &il->ucode_code); - il_free_fw_desc(il->pci_dev, &il->ucode_data); - il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); - il_free_fw_desc(il->pci_dev, &il->ucode_init); - il_free_fw_desc(il->pci_dev, &il->ucode_init_data); - il_free_fw_desc(il->pci_dev, &il->ucode_boot); -} - -static void il4965_nic_start(struct il_priv *il) -{ - /* Remove all resets to allow NIC to operate */ - _il_wr(il, CSR_RESET, 0); -} - -static void il4965_ucode_callback(const struct firmware *ucode_raw, - void *context); -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length); - -static int __must_check il4965_request_firmware(struct il_priv *il, bool first) -{ - const char *name_pre = il->cfg->fw_name_pre; - char tag[8]; - - if (first) { - il->fw_idx = il->cfg->ucode_api_max; - sprintf(tag, "%d", il->fw_idx); - } else { - il->fw_idx--; - sprintf(tag, "%d", il->fw_idx); - } - - if (il->fw_idx < il->cfg->ucode_api_min) { - IL_ERR("no suitable firmware found!\n"); - return -ENOENT; - } - - sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - - D_INFO("attempting to load firmware '%s'\n", - il->firmware_name); - - return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, - &il->pci_dev->dev, GFP_KERNEL, il, - il4965_ucode_callback); -} - -struct il4965_firmware_pieces { - const void *inst, *data, *init, *init_data, *boot; - size_t inst_size, data_size, init_size, init_data_size, boot_size; -}; - -static int il4965_load_firmware(struct il_priv *il, - const struct firmware *ucode_raw, - struct il4965_firmware_pieces *pieces) -{ - struct il_ucode_header *ucode = (void *)ucode_raw->data; - u32 api_ver, hdr_size; - const u8 *src; - - il->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(il->ucode_ver); - - switch (api_ver) { - default: - case 0: - case 1: - case 2: - hdr_size = 24; - if (ucode_raw->size < hdr_size) { - IL_ERR("File size too small!\n"); - return -EINVAL; - } - pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); - pieces->data_size = le32_to_cpu(ucode->v1.data_size); - pieces->init_size = le32_to_cpu(ucode->v1.init_size); - pieces->init_data_size = - le32_to_cpu(ucode->v1.init_data_size); - pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); - src = ucode->v1.data; - break; - } - - /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != hdr_size + pieces->inst_size + - pieces->data_size + pieces->init_size + - pieces->init_data_size + pieces->boot_size) { - - IL_ERR( - "uCode file size %d does not match expected size\n", - (int)ucode_raw->size); - return -EINVAL; - } - - pieces->inst = src; - src += pieces->inst_size; - pieces->data = src; - src += pieces->data_size; - pieces->init = src; - src += pieces->init_size; - pieces->init_data = src; - src += pieces->init_data_size; - pieces->boot = src; - src += pieces->boot_size; - - return 0; -} - -/** - * il4965_ucode_callback - callback when firmware was loaded - * - * If loaded successfully, copies the firmware into buffers - * for the card to fetch (via DMA). - */ -static void -il4965_ucode_callback(const struct firmware *ucode_raw, void *context) -{ - struct il_priv *il = context; - struct il_ucode_header *ucode; - int err; - struct il4965_firmware_pieces pieces; - const unsigned int api_max = il->cfg->ucode_api_max; - const unsigned int api_min = il->cfg->ucode_api_min; - u32 api_ver; - - u32 max_probe_length = 200; - u32 standard_phy_calibration_size = - IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; - - memset(&pieces, 0, sizeof(pieces)); - - if (!ucode_raw) { - if (il->fw_idx <= il->cfg->ucode_api_max) - IL_ERR( - "request for firmware file '%s' failed.\n", - il->firmware_name); - goto try_again; - } - - D_INFO("Loaded firmware file '%s' (%zd bytes).\n", - il->firmware_name, ucode_raw->size); - - /* Make sure that we got at least the API version number */ - if (ucode_raw->size < 4) { - IL_ERR("File size way too small!\n"); - goto try_again; - } - - /* Data from ucode file: header followed by uCode images */ - ucode = (struct il_ucode_header *)ucode_raw->data; - - err = il4965_load_firmware(il, ucode_raw, &pieces); - - if (err) - goto try_again; - - api_ver = IL_UCODE_API(il->ucode_ver); - - /* - * api_ver should match the api version forming part of the - * firmware filename ... but we don't check for that and only rely - * on the API version read from firmware header from here on forward - */ - if (api_ver < api_min || api_ver > api_max) { - IL_ERR( - "Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); - goto try_again; - } - - if (api_ver != api_max) - IL_ERR( - "Firmware has old API version. Expected v%u, " - "got v%u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); - - IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - /* - * For any of the failures below (before allocating pci memory) - * we will try to load a version with a smaller API -- maybe the - * user just got a corrupted version of the latest API. - */ - - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %Zd\n", - pieces.inst_size); - D_INFO("f/w package hdr runtime data size = %Zd\n", - pieces.data_size); - D_INFO("f/w package hdr init inst size = %Zd\n", - pieces.init_size); - D_INFO("f/w package hdr init data size = %Zd\n", - pieces.init_data_size); - D_INFO("f/w package hdr boot inst size = %Zd\n", - pieces.boot_size); - - /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > il->hw_params.max_inst_size) { - IL_ERR("uCode instr len %Zd too large to fit in\n", - pieces.inst_size); - goto try_again; - } - - if (pieces.data_size > il->hw_params.max_data_size) { - IL_ERR("uCode data len %Zd too large to fit in\n", - pieces.data_size); - goto try_again; - } - - if (pieces.init_size > il->hw_params.max_inst_size) { - IL_ERR("uCode init instr len %Zd too large to fit in\n", - pieces.init_size); - goto try_again; - } - - if (pieces.init_data_size > il->hw_params.max_data_size) { - IL_ERR("uCode init data len %Zd too large to fit in\n", - pieces.init_data_size); - goto try_again; - } - - if (pieces.boot_size > il->hw_params.max_bsm_size) { - IL_ERR("uCode boot instr len %Zd too large to fit in\n", - pieces.boot_size); - goto try_again; - } - - /* Allocate ucode buffers for card's bus-master loading ... */ - - /* Runtime instructions and 2 copies of data: - * 1) unmodified from disk - * 2) backup cache for save/restore during power-downs */ - il->ucode_code.len = pieces.inst_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - - il->ucode_data.len = pieces.data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - - il->ucode_data_backup.len = pieces.data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - - if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || - !il->ucode_data_backup.v_addr) - goto err_pci_alloc; - - /* Initialization instructions and data */ - if (pieces.init_size && pieces.init_data_size) { - il->ucode_init.len = pieces.init_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - - il->ucode_init_data.len = pieces.init_data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - - if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) - goto err_pci_alloc; - } - - /* Bootstrap (instructions only, no data) */ - if (pieces.boot_size) { - il->ucode_boot.len = pieces.boot_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - - if (!il->ucode_boot.v_addr) - goto err_pci_alloc; - } - - /* Now that we can no longer fail, copy information */ - - il->sta_key_max_num = STA_KEY_MAX_NUM; - - /* Copy images into buffers for card's bus-master reads ... */ - - /* Runtime instructions (first block of data in file) */ - D_INFO("Copying (but not loading) uCode instr len %Zd\n", - pieces.inst_size); - memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); - - D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); - - /* - * Runtime data - * NOTE: Copy into backup buffer will be done in il_up() - */ - D_INFO("Copying (but not loading) uCode data len %Zd\n", - pieces.data_size); - memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); - memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); - - /* Initialization instructions */ - if (pieces.init_size) { - D_INFO( - "Copying (but not loading) init instr len %Zd\n", - pieces.init_size); - memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); - } - - /* Initialization data */ - if (pieces.init_data_size) { - D_INFO( - "Copying (but not loading) init data len %Zd\n", - pieces.init_data_size); - memcpy(il->ucode_init_data.v_addr, pieces.init_data, - pieces.init_data_size); - } - - /* Bootstrap instructions */ - D_INFO("Copying (but not loading) boot instr len %Zd\n", - pieces.boot_size); - memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); - - /* - * figure out the offset of chain noise reset and gain commands - * base on the size of standard phy calibration commands table size - */ - il->_4965.phy_calib_chain_noise_reset_cmd = - standard_phy_calibration_size; - il->_4965.phy_calib_chain_noise_gain_cmd = - standard_phy_calibration_size + 1; - - /************************************************** - * This is still part of probe() in a sense... - * - * 9. Setup and register with mac80211 and debugfs - **************************************************/ - err = il4965_mac_setup_register(il, max_probe_length); - if (err) - goto out_unbind; - - err = il_dbgfs_register(il, DRV_NAME); - if (err) - IL_ERR( - "failed to create debugfs files. Ignoring error: %d\n", err); - - err = sysfs_create_group(&il->pci_dev->dev.kobj, - &il_attribute_group); - if (err) { - IL_ERR("failed to create sysfs device attributes\n"); - goto out_unbind; - } - - /* We have our copies now, allow OS release its copies */ - release_firmware(ucode_raw); - complete(&il->_4965.firmware_loading_complete); - return; - - try_again: - /* try next, if any */ - if (il4965_request_firmware(il, false)) - goto out_unbind; - release_firmware(ucode_raw); - return; - - err_pci_alloc: - IL_ERR("failed to allocate pci memory\n"); - il4965_dealloc_ucode_pci(il); - out_unbind: - complete(&il->_4965.firmware_loading_complete); - device_release_driver(&il->pci_dev->dev); - release_firmware(ucode_raw); -} - -static const char * const desc_lookup_text[] = { - "OK", - "FAIL", - "BAD_PARAM", - "BAD_CHECKSUM", - "NMI_INTERRUPT_WDG", - "SYSASSERT", - "FATAL_ERROR", - "BAD_COMMAND", - "HW_ERROR_TUNE_LOCK", - "HW_ERROR_TEMPERATURE", - "ILLEGAL_CHAN_FREQ", - "VCC_NOT_STBL", - "FH_ERROR", - "NMI_INTERRUPT_HOST", - "NMI_INTERRUPT_ACTION_PT", - "NMI_INTERRUPT_UNKNOWN", - "UCODE_VERSION_MISMATCH", - "HW_ERROR_ABS_LOCK", - "HW_ERROR_CAL_LOCK_FAIL", - "NMI_INTERRUPT_INST_ACTION_PT", - "NMI_INTERRUPT_DATA_ACTION_PT", - "NMI_TRM_HW_ER", - "NMI_INTERRUPT_TRM", - "NMI_INTERRUPT_BREAK_POINT", - "DEBUG_0", - "DEBUG_1", - "DEBUG_2", - "DEBUG_3", -}; - -static struct { char *name; u8 num; } advanced_lookup[] = { - { "NMI_INTERRUPT_WDG", 0x34 }, - { "SYSASSERT", 0x35 }, - { "UCODE_VERSION_MISMATCH", 0x37 }, - { "BAD_COMMAND", 0x38 }, - { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, - { "FATAL_ERROR", 0x3D }, - { "NMI_TRM_HW_ERR", 0x46 }, - { "NMI_INTERRUPT_TRM", 0x4C }, - { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, - { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, - { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, - { "NMI_INTERRUPT_HOST", 0x66 }, - { "NMI_INTERRUPT_ACTION_PT", 0x7C }, - { "NMI_INTERRUPT_UNKNOWN", 0x84 }, - { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, - { "ADVANCED_SYSASSERT", 0 }, -}; - -static const char *il4965_desc_lookup(u32 num) -{ - int i; - int max = ARRAY_SIZE(desc_lookup_text); - - if (num < max) - return desc_lookup_text[num]; - - max = ARRAY_SIZE(advanced_lookup) - 1; - for (i = 0; i < max; i++) { - if (advanced_lookup[i].num == num) - break; - } - return advanced_lookup[i].name; -} - -#define ERROR_START_OFFSET (1 * sizeof(u32)) -#define ERROR_ELEM_SIZE (7 * sizeof(u32)) - -void il4965_dump_nic_error_log(struct il_priv *il) -{ - u32 data2, line; - u32 desc, time, count, base, data1; - u32 blink1, blink2, ilink1, ilink2; - u32 pc, hcmd; - - if (il->ucode_type == UCODE_INIT) { - base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); - } else { - base = le32_to_cpu(il->card_alive.error_event_table_ptr); - } - - if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR( - "Not valid error log pointer 0x%08X for %s uCode\n", - base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); - return; - } - - count = il_read_targ_mem(il, base); - - if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); - } - - desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); - il->isr_stats.err_code = desc; - pc = il_read_targ_mem(il, base + 2 * sizeof(u32)); - blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32)); - blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32)); - ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32)); - ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32)); - data1 = il_read_targ_mem(il, base + 7 * sizeof(u32)); - data2 = il_read_targ_mem(il, base + 8 * sizeof(u32)); - line = il_read_targ_mem(il, base + 9 * sizeof(u32)); - time = il_read_targ_mem(il, base + 11 * sizeof(u32)); - hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); - - IL_ERR("Desc Time " - "data1 data2 line\n"); - IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", - il4965_desc_lookup(desc), desc, time, data1, data2, line); - IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", - pc, blink1, blink2, ilink1, ilink2, hcmd); -} - -static void il4965_rf_kill_ct_config(struct il_priv *il) -{ - struct il_ct_kill_config cmd; - unsigned long flags; - int ret = 0; - - spin_lock_irqsave(&il->lock, flags); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - spin_unlock_irqrestore(&il->lock, flags); - - cmd.critical_temperature_R = - cpu_to_le32(il->hw_params.ct_kill_threshold); - - ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, - sizeof(cmd), &cmd); - if (ret) - IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); - else - D_INFO("REPLY_CT_KILL_CONFIG_CMD " - "succeeded, " - "critical temperature is %d\n", - il->hw_params.ct_kill_threshold); -} - -static const s8 default_queue_to_tx_fifo[] = { - IL_TX_FIFO_VO, - IL_TX_FIFO_VI, - IL_TX_FIFO_BE, - IL_TX_FIFO_BK, - IL49_CMD_FIFO_NUM, - IL_TX_FIFO_UNUSED, - IL_TX_FIFO_UNUSED, -}; - -static int il4965_alive_notify(struct il_priv *il) -{ - u32 a; - unsigned long flags; - int i, chan; - u32 reg_val; - - spin_lock_irqsave(&il->lock, flags); - - /* Clear 4965's internal Tx Scheduler data base */ - il->scd_base_addr = il_rd_prph(il, - IL49_SCD_SRAM_BASE_ADDR); - a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; - for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) - il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) - il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) - il_write_targ_mem(il, a, 0); - - /* Tel 4965 where to find Tx byte count tables */ - il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, - il->scd_bc_tbls.dma >> 10); - - /* Enable DMA channel */ - for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(chan), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); - - /* Update FH chicken bits */ - reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); - il_wr(il, FH_TX_CHICKEN_BITS_REG, - reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); - - /* Disable chain mode for all queues */ - il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); - - /* Initialize each Tx queue (including the command queue) */ - for (i = 0; i < il->hw_params.max_txq_num; i++) { - - /* TFD circular buffer read/write idxes */ - il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); - il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); - - /* Max Tx Window size for Scheduler-ACK mode */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i), - (SCD_WIN_SIZE << - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - - /* Frame limit */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + - sizeof(u32), - (SCD_FRAME_LIMIT << - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - - } - il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, - (1 << il->hw_params.max_txq_num) - 1); - - /* Activate all Tx DMA/FIFO channels */ - il4965_txq_set_sched(il, IL_MASK(0, 6)); - - il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0); - - /* make sure all queue are not stopped */ - memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); - for (i = 0; i < 4; i++) - atomic_set(&il->queue_stop_count[i], 0); - - /* reset to 0 to enable all the queue first */ - il->txq_ctx_active_msk = 0; - /* Map each Tx/cmd queue to its corresponding fifo */ - BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); - - for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { - int ac = default_queue_to_tx_fifo[i]; - - il_txq_ctx_activate(il, i); - - if (ac == IL_TX_FIFO_UNUSED) - continue; - - il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); - } - - spin_unlock_irqrestore(&il->lock, flags); - - return 0; -} - -/** - * il4965_alive_start - called after REPLY_ALIVE notification received - * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by il_init_alive_start()). - */ -static void il4965_alive_start(struct il_priv *il) -{ - int ret = 0; - struct il_rxon_context *ctx = &il->ctx; - - D_INFO("Runtime Alive received.\n"); - - if (il->card_alive.is_valid != UCODE_VALID_OK) { - /* We had an error bringing up the hardware, so take it - * all the way back down so we can try again */ - D_INFO("Alive failed.\n"); - goto restart; - } - - /* Initialize uCode has loaded Runtime uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "runtime" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad runtime uCode load.\n"); - goto restart; - } - - ret = il4965_alive_notify(il); - if (ret) { - IL_WARN( - "Could not complete ALIVE transition [ntf]: %d\n", ret); - goto restart; - } - - - /* After the ALIVE response, we can send host commands to the uCode */ - set_bit(STATUS_ALIVE, &il->status); - - /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(il); - - if (il_is_rfkill(il)) - return; - - ieee80211_wake_queues(il->hw); - - il->active_rate = RATES_MASK; - - if (il_is_associated_ctx(ctx)) { - struct il_rxon_cmd *active_rxon = - (struct il_rxon_cmd *)&ctx->active; - /* apply any changes in staging */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - } else { - /* Initialize our rx_config data */ - il_connection_init_rx_config(il, &il->ctx); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - } - - /* Configure bluetooth coexistence if enabled */ - il_send_bt_config(il); - - il4965_reset_run_time_calib(il); - - set_bit(STATUS_READY, &il->status); - - /* Configure the adapter for unassociated operation */ - il_commit_rxon(il, ctx); - - /* At this point, the NIC is initialized and operational */ - il4965_rf_kill_ct_config(il); - - D_INFO("ALIVE processing complete.\n"); - wake_up(&il->wait_command_queue); - - il_power_update_mode(il, true); - D_INFO("Updated power mode\n"); - - return; - - restart: - queue_work(il->workqueue, &il->restart); -} - -static void il4965_cancel_deferred_work(struct il_priv *il); - -static void __il4965_down(struct il_priv *il) -{ - unsigned long flags; - int exit_pending; - - D_INFO(DRV_NAME " is going down\n"); - - il_scan_cancel_timeout(il, 200); - - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); - - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set - * to prevent rearm timer */ - del_timer_sync(&il->watchdog); - - il_clear_ucode_stations(il, NULL); - il_dealloc_bcast_stations(il); - il_clear_driver_stations(il); - - /* Unblock any waiting calls */ - wake_up_all(&il->wait_command_queue); - - /* Wipe out the EXIT_PENDING status bit if we are not actually - * exiting the module */ - if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* stop and reset the on-board processor */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - il4965_synchronize_irq(il); - - if (il->mac80211_registered) - ieee80211_stop_queues(il->hw); - - /* If we have not previously called il_init() then - * clear all bits but the RF Kill bit and return */ - if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - goto exit; - } - - /* ...otherwise clear out all the status bits but the RF Kill - * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - - il4965_txq_ctx_stop(il); - il4965_rxq_stop(il); - - /* Power-down device's busmaster DMA clocks */ - il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); - udelay(5); - - /* Make sure (redundant) we've released our request to stay awake */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - - /* Stop the device, and put it in low power state */ - il_apm_stop(il); - - exit: - memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - - dev_kfree_skb(il->beacon_skb); - il->beacon_skb = NULL; - - /* clear out any free frames */ - il4965_clear_free_frames(il); -} - -static void il4965_down(struct il_priv *il) -{ - mutex_lock(&il->mutex); - __il4965_down(il); - mutex_unlock(&il->mutex); - - il4965_cancel_deferred_work(il); -} - -#define HW_READY_TIMEOUT (50) - -static int il4965_set_hw_ready(struct il_priv *il) -{ - int ret = 0; - - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); - - /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - HW_READY_TIMEOUT); - if (ret != -ETIMEDOUT) - il->hw_ready = true; - else - il->hw_ready = false; - - D_INFO("hardware %s\n", - (il->hw_ready == 1) ? "ready" : "not ready"); - return ret; -} - -static int il4965_prepare_card_hw(struct il_priv *il) -{ - int ret = 0; - - D_INFO("il4965_prepare_card_hw enter\n"); - - ret = il4965_set_hw_ready(il); - if (il->hw_ready) - return ret; - - /* If HW is not ready, prepare the conditions to check again */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_PREPARE); - - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, - CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); - - /* HW should be ready by now, check again. */ - if (ret != -ETIMEDOUT) - il4965_set_hw_ready(il); - - return ret; -} - -#define MAX_HW_RESTARTS 5 - -static int __il4965_up(struct il_priv *il) -{ - int i; - int ret; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN("Exit pending; will not bring the NIC up\n"); - return -EIO; - } - - if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR("ucode not available for device bringup\n"); - return -EIO; - } - - ret = il4965_alloc_bcast_station(il, &il->ctx); - if (ret) { - il_dealloc_bcast_stations(il); - return ret; - } - - il4965_prepare_card_hw(il); - - if (!il->hw_ready) { - IL_WARN("Exit HW not ready\n"); - return -EIO; - } - - /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, - CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); - else - set_bit(STATUS_RF_KILL_HW, &il->status); - - if (il_is_rfkill(il)) { - wiphy_rfkill_set_hw_state(il->hw->wiphy, true); - - il_enable_interrupts(il); - IL_WARN("Radio disabled by HW RF Kill switch\n"); - return 0; - } - - _il_wr(il, CSR_INT, 0xFFFFFFFF); - - /* must be initialised before il_hw_nic_init */ - il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; - - ret = il4965_hw_nic_init(il); - if (ret) { - IL_ERR("Unable to init nic\n"); - return ret; - } - - /* make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - /* clear (again), then enable host interrupts */ - _il_wr(il, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(il); - - /* really make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - - /* Copy original ucode data image from disk into backup cache. - * This will be used to initialize the on-board processor's - * data SRAM for a clean start when the runtime program first loads. */ - memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, - il->ucode_data.len); - - for (i = 0; i < MAX_HW_RESTARTS; i++) { - - /* load bootstrap state machine, - * load bootstrap program into processor's memory, - * prepare to load the "initialize" uCode */ - ret = il->cfg->ops->lib->load_ucode(il); - - if (ret) { - IL_ERR("Unable to set up bootstrap uCode: %d\n", - ret); - continue; - } - - /* start card; "initialize" will load runtime ucode */ - il4965_nic_start(il); - - D_INFO(DRV_NAME " is coming up\n"); - - return 0; - } - - set_bit(STATUS_EXIT_PENDING, &il->status); - __il4965_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* tried to restart and config the device for as long as our - * patience could withstand */ - IL_ERR("Unable to initialize device after %d attempts.\n", i); - return -EIO; -} - - -/***************************************************************************** - * - * Workqueue callbacks - * - *****************************************************************************/ - -static void il4965_bg_init_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, init_alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il->cfg->ops->lib->init_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -static void il4965_bg_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il4965_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -static void il4965_bg_run_time_calib_work(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, - run_time_calib_work); - - mutex_lock(&il->mutex); - - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) { - mutex_unlock(&il->mutex); - return; - } - - if (il->start_calib) { - il4965_chain_noise_calibration(il, - (void *)&il->_4965.stats); - il4965_sensitivity_calibration(il, - (void *)&il->_4965.stats); - } - - mutex_unlock(&il->mutex); -} - -static void il4965_bg_restart(struct work_struct *data) -{ - struct il_priv *il = container_of(data, struct il_priv, restart); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - mutex_lock(&il->mutex); - il->ctx.vif = NULL; - il->is_open = 0; - - __il4965_down(il); - - mutex_unlock(&il->mutex); - il4965_cancel_deferred_work(il); - ieee80211_restart_hw(il->hw); - } else { - il4965_down(il); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - mutex_unlock(&il->mutex); - return; - } - - __il4965_up(il); - mutex_unlock(&il->mutex); - } -} - -static void il4965_bg_rx_replenish(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - mutex_lock(&il->mutex); - il4965_rx_replenish(il); - mutex_unlock(&il->mutex); -} - -/***************************************************************************** - * - * mac80211 entry point functions - * - *****************************************************************************/ - -#define UCODE_READY_TIMEOUT (4 * HZ) - -/* - * Not a mac80211 entry point function, but it fits in with all the - * other mac80211 functions grouped here. - */ -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length) -{ - int ret; - struct ieee80211_hw *hw = il->hw; - - hw->rate_control_algorithm = "iwl-4965-rs"; - - /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_AMPDU_AGGREGATION | - IEEE80211_HW_NEED_DTIM_PERIOD | - IEEE80211_HW_SPECTRUM_MGMT | - IEEE80211_HW_REPORTS_TX_ACK_STATUS; - - if (il->cfg->sku & IL_SKU_N) - hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | - IEEE80211_HW_SUPPORTS_STATIC_SMPS; - - hw->sta_data_size = sizeof(struct il_station_priv); - hw->vif_data_size = sizeof(struct il_vif_priv); - - hw->wiphy->interface_modes |= il->ctx.interface_modes; - hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; - - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS; - - /* - * For now, disable PS by default because it affects - * RX performance significantly. - */ - hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; - - hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; - /* we create the 802.11 header and a zero-length SSID element */ - hw->wiphy->max_scan_ie_len = max_probe_length - 24 - 2; - - /* Default value; 4 EDCA QOS priorities */ - hw->queues = 4; - - hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; - - if (il->bands[IEEE80211_BAND_2GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; - if (il->bands[IEEE80211_BAND_5GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; - - il_leds_init(il); - - ret = ieee80211_register_hw(il->hw); - if (ret) { - IL_ERR("Failed to register hw (error %d)\n", ret); - return ret; - } - il->mac80211_registered = 1; - - return 0; -} - - -int il4965_mac_start(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - int ret; - - D_MAC80211("enter\n"); - - /* we should be verifying the device is ready to be opened */ - mutex_lock(&il->mutex); - ret = __il4965_up(il); - mutex_unlock(&il->mutex); - - if (ret) - return ret; - - if (il_is_rfkill(il)) - goto out; - - D_INFO("Start UP work done.\n"); - - /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from - * mac80211 will not be run successfully. */ - ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), - UCODE_READY_TIMEOUT); - if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR("START_ALIVE timeout after %dms.\n", - jiffies_to_msecs(UCODE_READY_TIMEOUT)); - return -ETIMEDOUT; - } - } - - il4965_led_enable(il); - -out: - il->is_open = 1; - D_MAC80211("leave\n"); - return 0; -} - -void il4965_mac_stop(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - - D_MAC80211("enter\n"); - - if (!il->is_open) - return; - - il->is_open = 0; - - il4965_down(il); - - flush_workqueue(il->workqueue); - - /* User space software may expect getting rfkill changes - * even if interface is down */ - _il_wr(il, CSR_INT, 0xFFFFFFFF); - il_enable_rfkill_int(il); - - D_MAC80211("leave\n"); -} - -void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -{ - struct il_priv *il = hw->priv; - - D_MACDUMP("enter\n"); - - D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - - if (il4965_tx_skb(il, skb)) - dev_kfree_skb_any(skb); - - D_MACDUMP("leave\n"); -} - -void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key) -{ - struct il_priv *il = hw->priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - - D_MAC80211("enter\n"); - - il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, - iv32, phase1key); - - D_MAC80211("leave\n"); -} - -int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) -{ - struct il_priv *il = hw->priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - struct il_rxon_context *ctx = vif_priv->ctx; - int ret; - u8 sta_id; - bool is_default_wep_key = false; - - D_MAC80211("enter\n"); - - if (il->cfg->mod_params->sw_crypto) { - D_MAC80211("leave - hwcrypto disabled\n"); - return -EOPNOTSUPP; - } - - sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); - if (sta_id == IL_INVALID_STATION) - return -EINVAL; - - mutex_lock(&il->mutex); - il_scan_cancel_timeout(il, 100); - - /* - * If we are getting WEP group key and we didn't receive any key mapping - * so far, we are in legacy wep mode (group key only), otherwise we are - * in 1X mode. - * In legacy wep mode, we use another host command to the uCode. - */ - if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) && - !sta) { - if (cmd == SET_KEY) - is_default_wep_key = !ctx->key_mapping_keys; - else - is_default_wep_key = - (key->hw_key_idx == HW_KEY_DEFAULT); - } - - switch (cmd) { - case SET_KEY: - if (is_default_wep_key) - ret = il4965_set_default_wep_key(il, - vif_priv->ctx, key); - else - ret = il4965_set_dynamic_key(il, vif_priv->ctx, - key, sta_id); - - D_MAC80211("enable hwcrypto key\n"); - break; - case DISABLE_KEY: - if (is_default_wep_key) - ret = il4965_remove_default_wep_key(il, ctx, key); - else - ret = il4965_remove_dynamic_key(il, ctx, - key, sta_id); - - D_MAC80211("disable hwcrypto key\n"); - break; - default: - ret = -EINVAL; - } - - mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); - - return ret; -} - -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size) -{ - struct il_priv *il = hw->priv; - int ret = -EINVAL; - - D_HT("A-MPDU action on addr %pM tid %d\n", - sta->addr, tid); - - if (!(il->cfg->sku & IL_SKU_N)) - return -EACCES; - - mutex_lock(&il->mutex); - - switch (action) { - case IEEE80211_AMPDU_RX_START: - D_HT("start Rx\n"); - ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); - break; - case IEEE80211_AMPDU_RX_STOP: - D_HT("stop Rx\n"); - ret = il4965_sta_rx_agg_stop(il, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - ret = 0; - break; - case IEEE80211_AMPDU_TX_START: - D_HT("start Tx\n"); - ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); - break; - case IEEE80211_AMPDU_TX_STOP: - D_HT("stop Tx\n"); - ret = il4965_tx_agg_stop(il, vif, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - ret = 0; - break; - case IEEE80211_AMPDU_TX_OPERATIONAL: - ret = 0; - break; - } - mutex_unlock(&il->mutex); - - return ret; -} - -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct il_priv *il = hw->priv; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - bool is_ap = vif->type == NL80211_IFTYPE_STATION; - int ret; - u8 sta_id; - - D_INFO("received request to add station %pM\n", - sta->addr); - mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); - sta_priv->common.sta_id = IL_INVALID_STATION; - - atomic_set(&sta_priv->pending_frames, 0); - - ret = il_add_station_common(il, vif_priv->ctx, sta->addr, - is_ap, sta, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); - /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&il->mutex); - return ret; - } - - sta_priv->common.sta_id = sta_id; - - /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); - il4965_rs_rate_init(il, sta, sta_id); - mutex_unlock(&il->mutex); - - return 0; -} - -void il4965_mac_channel_switch(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch) -{ - struct il_priv *il = hw->priv; - const struct il_channel_info *ch_info; - struct ieee80211_conf *conf = &hw->conf; - struct ieee80211_channel *channel = ch_switch->channel; - struct il_ht_config *ht_conf = &il->current_ht_config; - - struct il_rxon_context *ctx = &il->ctx; - u16 ch; - - D_MAC80211("enter\n"); - - mutex_lock(&il->mutex); - - if (il_is_rfkill(il)) - goto out; - - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) - goto out; - - if (!il_is_associated_ctx(ctx)) - goto out; - - if (!il->cfg->ops->lib->set_channel_switch) - goto out; - - ch = channel->hw_value; - if (le16_to_cpu(ctx->active.channel) == ch) - goto out; - - ch_info = il_get_channel_info(il, channel->band, ch); - if (!il_is_channel_valid(ch_info)) { - D_MAC80211("invalid channel\n"); - goto out; - } - - spin_lock_irq(&il->lock); - - il->current_ht_config.smps = conf->smps_mode; - - /* Configure HT40 channels */ - ctx->ht.enabled = conf_is_ht(conf); - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else - ctx->ht.is_40mhz = false; - - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; - - il_set_rxon_channel(il, channel, ctx); - il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, ctx->vif); - - spin_unlock_irq(&il->lock); - - il_set_rate(il); - /* - * at this point, staging_rxon has the - * configuration for channel switch - */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); - il->switch_channel = cpu_to_le16(ch); - if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); - il->switch_channel = 0; - ieee80211_chswitch_done(ctx->vif, false); - } - -out: - mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); -} - -void il4965_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) -{ - struct il_priv *il = hw->priv; - __le32 filter_or = 0, filter_nand = 0; - -#define CHK(test, flag) do { \ - if (*total_flags & (test)) \ - filter_or |= (flag); \ - else \ - filter_nand |= (flag); \ - } while (0) - - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); - - CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); - /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ - CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); - CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); - -#undef CHK - - mutex_lock(&il->mutex); - - il->ctx.staging.filter_flags &= ~filter_nand; - il->ctx.staging.filter_flags |= filter_or; - - /* - * Not committing directly because hardware can perform a scan, - * but we'll eventually commit the filter flags change anyway. - */ - - mutex_unlock(&il->mutex); - - /* - * Receiving all multicast frames is always enabled by the - * default flags setup in il_connection_init_rx_config() - * since we currently do not support programming multicast - * filters into the device. - */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; -} - -/***************************************************************************** - * - * driver setup and teardown - * - *****************************************************************************/ - -static void il4965_bg_txpower_work(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, - txpower_work); - - mutex_lock(&il->mutex); - - /* If a scan happened to start before we got here - * then just return; the stats notification will - * kick off another scheduled work to compensate for - * any temperature delta we missed here. */ - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) - goto out; - - /* Regardless of if we are associated, we must reconfigure the - * TX power since frames can be sent on non-radar channels while - * not associated */ - il->cfg->ops->lib->send_tx_power(il); - - /* Update last_temperature to keep is_calib_needed from running - * when it isn't needed... */ - il->last_temperature = il->temperature; -out: - mutex_unlock(&il->mutex); -} - -static void il4965_setup_deferred_work(struct il_priv *il) -{ - il->workqueue = create_singlethread_workqueue(DRV_NAME); - - init_waitqueue_head(&il->wait_command_queue); - - INIT_WORK(&il->restart, il4965_bg_restart); - INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); - INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); - INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); - INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); - - il_setup_scan_deferred_work(il); - - INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); - - init_timer(&il->stats_periodic); - il->stats_periodic.data = (unsigned long)il; - il->stats_periodic.function = il4965_bg_stats_periodic; - - init_timer(&il->watchdog); - il->watchdog.data = (unsigned long)il; - il->watchdog.function = il_bg_watchdog; - - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il4965_irq_tasklet, (unsigned long)il); -} - -static void il4965_cancel_deferred_work(struct il_priv *il) -{ - cancel_work_sync(&il->txpower_work); - cancel_delayed_work_sync(&il->init_alive_start); - cancel_delayed_work(&il->alive_start); - cancel_work_sync(&il->run_time_calib_work); - - il_cancel_scan_deferred_work(il); - - del_timer_sync(&il->stats_periodic); -} - -static void il4965_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) -{ - int i; - - for (i = 0; i < RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = il_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ - rates[i].hw_value_short = i; - rates[i].flags = 0; - if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { - /* - * If CCK != 1M then set short preamble rate flag. - */ - rates[i].flags |= - (il_rates[i].plcp == RATE_1M_PLCP) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; - } - } -} -/* - * Acquire il->lock before calling this function ! - */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) -{ - il_wr(il, HBUS_TARG_WRPTR, - (idx & 0xff) | (txq_id << 8)); - il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); -} - -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry) -{ - int txq_id = txq->q.id; - - /* Find out whether to activate Tx queue */ - int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; - - /* Set up and activate */ - il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | - (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | - IL49_SCD_QUEUE_STTS_REG_MSK); - - txq->sched_retry = scd_retry; - - D_INFO("%s %s Queue %d on AC %d\n", - active ? "Activate" : "Deactivate", - scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); -} - - -static int il4965_init_drv(struct il_priv *il) -{ - int ret; - - spin_lock_init(&il->sta_lock); - spin_lock_init(&il->hcmd_lock); - - INIT_LIST_HEAD(&il->free_frames); - - mutex_init(&il->mutex); - - il->ieee_channels = NULL; - il->ieee_rates = NULL; - il->band = IEEE80211_BAND_2GHZ; - - il->iw_mode = NL80211_IFTYPE_STATION; - il->current_ht_config.smps = IEEE80211_SMPS_STATIC; - il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; - - /* initialize force reset */ - il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; - - /* Choose which receivers/antennas to use */ - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, - &il->ctx); - - il_init_scan_params(il); - - ret = il_init_channel_map(il); - if (ret) { - IL_ERR("initializing regulatory failed: %d\n", ret); - goto err; - } - - ret = il_init_geos(il); - if (ret) { - IL_ERR("initializing geos failed: %d\n", ret); - goto err_free_channel_map; - } - il4965_init_hw_rates(il, il->ieee_rates); - - return 0; - -err_free_channel_map: - il_free_channel_map(il); -err: - return ret; -} - -static void il4965_uninit_drv(struct il_priv *il) -{ - il4965_calib_free_results(il); - il_free_geos(il); - il_free_channel_map(il); - kfree(il->scan_cmd); -} - -static void il4965_hw_detect(struct il_priv *il) -{ - il->hw_rev = _il_rd(il, CSR_HW_REV); - il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); - il->rev_id = il->pci_dev->revision; - D_INFO("HW Revision ID = 0x%X\n", il->rev_id); -} - -static int il4965_set_hw_params(struct il_priv *il) -{ - il->hw_params.max_rxq_size = RX_QUEUE_SIZE; - il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - if (il->cfg->mod_params->amsdu_size_8K) - il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); - else - il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); - - il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; - - if (il->cfg->mod_params->disable_11n) - il->cfg->sku &= ~IL_SKU_N; - - /* Device-specific setup */ - return il->cfg->ops->lib->set_hw_params(il); -} - -static const u8 il4965_bss_ac_to_fifo[] = { - IL_TX_FIFO_VO, - IL_TX_FIFO_VI, - IL_TX_FIFO_BE, - IL_TX_FIFO_BK, -}; - -static const u8 il4965_bss_ac_to_queue[] = { - 0, 1, 2, 3, -}; - -static int -il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - int err = 0; - struct il_priv *il; - struct ieee80211_hw *hw; - struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); - unsigned long flags; - u16 pci_cmd; - - /************************ - * 1. Allocating HW data - ************************/ - - hw = il_alloc_all(cfg); - if (!hw) { - err = -ENOMEM; - goto out; - } - il = hw->priv; - /* At this point both hw and il are allocated. */ - - il->ctx.ctxid = 0; - - il->ctx.always_active = true; - il->ctx.is_active = true; - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; - il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; - il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; - il->ctx.ac_to_queue = il4965_bss_ac_to_queue; - il->ctx.exclusive_interface_modes = - BIT(NL80211_IFTYPE_ADHOC); - il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION); - il->ctx.ap_devtype = RXON_DEV_TYPE_AP; - il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; - il->ctx.station_devtype = RXON_DEV_TYPE_ESS; - il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; - - SET_IEEE80211_DEV(hw, &pdev->dev); - - D_INFO("*** LOAD DRIVER ***\n"); - il->cfg = cfg; - il->pci_dev = pdev; - il->inta_mask = CSR_INI_SET_MASK; - - if (il_alloc_traffic_mem(il)) - IL_ERR("Not enough memory to generate traffic log\n"); - - /************************** - * 2. Initializing PCI bus - **************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); - - if (pci_enable_device(pdev)) { - err = -ENODEV; - goto out_ieee80211_free_hw; - } - - pci_set_master(pdev); - - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); - if (err) { - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, - DMA_BIT_MASK(32)); - /* both attempts failed: */ - if (err) { - IL_WARN("No suitable DMA available.\n"); - goto out_pci_disable_device; - } - } - - err = pci_request_regions(pdev, DRV_NAME); - if (err) - goto out_pci_disable_device; - - pci_set_drvdata(pdev, il); - - - /*********************** - * 3. Read REV register - ***********************/ - il->hw_base = pci_iomap(pdev, 0, 0); - if (!il->hw_base) { - err = -ENODEV; - goto out_pci_release_regions; - } - - D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); - D_INFO("pci_resource_base = %p\n", il->hw_base); - - /* these spin locks will be used in apm_ops.init and EEPROM access - * we should init now - */ - spin_lock_init(&il->reg_lock); - spin_lock_init(&il->lock); - - /* - * stop and reset the on-board processor just in case it is in a - * strange state ... like being left stranded by a primary kernel - * and this is now the kdump kernel trying to start up - */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - il4965_hw_detect(il); - IL_INFO("Detected %s, REV=0x%X\n", - il->cfg->name, il->hw_rev); - - /* We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state */ - pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - - il4965_prepare_card_hw(il); - if (!il->hw_ready) { - IL_WARN("Failed, HW not ready\n"); - goto out_iounmap; - } - - /***************** - * 4. Read EEPROM - *****************/ - /* Read the EEPROM */ - err = il_eeprom_init(il); - if (err) { - IL_ERR("Unable to init EEPROM\n"); - goto out_iounmap; - } - err = il4965_eeprom_check_version(il); - if (err) - goto out_free_eeprom; - - if (err) - goto out_free_eeprom; - - /* extract MAC Address */ - il4965_eeprom_get_mac(il, il->addresses[0].addr); - D_INFO("MAC address: %pM\n", il->addresses[0].addr); - il->hw->wiphy->addresses = il->addresses; - il->hw->wiphy->n_addresses = 1; - - /************************ - * 5. Setup HW constants - ************************/ - if (il4965_set_hw_params(il)) { - IL_ERR("failed to set hw parameters\n"); - goto out_free_eeprom; - } - - /******************* - * 6. Setup il - *******************/ - - err = il4965_init_drv(il); - if (err) - goto out_free_eeprom; - /* At this point both hw and il are initialized. */ - - /******************** - * 7. Setup services - ********************/ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - pci_enable_msi(il->pci_dev); - - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); - if (err) { - IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); - goto out_disable_msi; - } - - il4965_setup_deferred_work(il); - il4965_setup_rx_handlers(il); - - /********************************************* - * 8. Enable interrupts and read RFKILL state - *********************************************/ - - /* enable rfkill interrupt: hw bug w/a */ - pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); - if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { - pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); - } - - il_enable_rfkill_int(il); - - /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); - else - set_bit(STATUS_RF_KILL_HW, &il->status); - - wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); - - il_power_initialize(il); - - init_completion(&il->_4965.firmware_loading_complete); - - err = il4965_request_firmware(il, true); - if (err) - goto out_destroy_workqueue; - - return 0; - - out_destroy_workqueue: - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - free_irq(il->pci_dev->irq, il); - out_disable_msi: - pci_disable_msi(il->pci_dev); - il4965_uninit_drv(il); - out_free_eeprom: - il_eeprom_free(il); - out_iounmap: - pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: - pci_set_drvdata(pdev, NULL); - pci_release_regions(pdev); - out_pci_disable_device: - pci_disable_device(pdev); - out_ieee80211_free_hw: - il_free_traffic_mem(il); - ieee80211_free_hw(il->hw); - out: - return err; -} - -static void __devexit il4965_pci_remove(struct pci_dev *pdev) -{ - struct il_priv *il = pci_get_drvdata(pdev); - unsigned long flags; - - if (!il) - return; - - wait_for_completion(&il->_4965.firmware_loading_complete); - - D_INFO("*** UNLOAD DRIVER ***\n"); - - il_dbgfs_unregister(il); - sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); - - /* ieee80211_unregister_hw call wil cause il_mac_stop to - * to be called and il4965_down since we are removing the device - * we need to set STATUS_EXIT_PENDING bit. - */ - set_bit(STATUS_EXIT_PENDING, &il->status); - - il_leds_exit(il); - - if (il->mac80211_registered) { - ieee80211_unregister_hw(il->hw); - il->mac80211_registered = 0; - } else { - il4965_down(il); - } - - /* - * Make sure device is reset to low power before unloading driver. - * This may be redundant with il4965_down(), but there are paths to - * run il4965_down() without calling apm_ops.stop(), and there are - * paths to avoid running il4965_down() at all before leaving driver. - * This (inexpensive) call *makes sure* device is reset. - */ - il_apm_stop(il); - - /* make sure we flush any pending irq or - * tasklet for the driver - */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - il4965_synchronize_irq(il); - - il4965_dealloc_ucode_pci(il); - - if (il->rxq.bd) - il4965_rx_queue_free(il, &il->rxq); - il4965_hw_txq_ctx_free(il); - - il_eeprom_free(il); - - - /*netif_stop_queue(dev); */ - flush_workqueue(il->workqueue); - - /* ieee80211_unregister_hw calls il_mac_stop, which flushes - * il->workqueue... so we can't take down the workqueue - * until now... */ - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - il_free_traffic_mem(il); - - free_irq(il->pci_dev->irq, il); - pci_disable_msi(il->pci_dev); - pci_iounmap(pdev, il->hw_base); - pci_release_regions(pdev); - pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); - - il4965_uninit_drv(il); - - dev_kfree_skb(il->beacon_skb); - - ieee80211_free_hw(il->hw); -} - -/* - * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask - * must be called under il->lock and mac access - */ -void il4965_txq_set_sched(struct il_priv *il, u32 mask) -{ - il_wr_prph(il, IL49_SCD_TXFACT, mask); -} - -/***************************************************************************** - * - * driver and module entry point - * - *****************************************************************************/ - -/* Hardware specific file defines the PCI IDs table for that hardware module */ -static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { - {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, - {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, - {0} -}; -MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); - -static struct pci_driver il4965_driver = { - .name = DRV_NAME, - .id_table = il4965_hw_card_ids, - .probe = il4965_pci_probe, - .remove = __devexit_p(il4965_pci_remove), - .driver.pm = IL_LEGACY_PM_OPS, -}; - -static int __init il4965_init(void) -{ - - int ret; - pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); - pr_info(DRV_COPYRIGHT "\n"); - - ret = il4965_rate_control_register(); - if (ret) { - pr_err("Unable to register rate control algorithm: %d\n", ret); - return ret; - } - - ret = pci_register_driver(&il4965_driver); - if (ret) { - pr_err("Unable to initialize PCI module\n"); - goto error_register; - } - - return ret; - -error_register: - il4965_rate_control_unregister(); - return ret; -} - -static void __exit il4965_exit(void) -{ - pci_unregister_driver(&il4965_driver); - il4965_rate_control_unregister(); -} - -module_exit(il4965_exit); -module_init(il4965_init); - -#ifdef CONFIG_IWLEGACY_DEBUG -module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "debug output mask"); -#endif - -module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO); -MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); -module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); -MODULE_PARM_DESC(queues_num, "number of hw queues."); -module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); -MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); -module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, - int, S_IRUGO); -MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); -module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); -MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); -- cgit v0.10.2 From fc19cbde0c38c24f2d473f9095fbd5772883ec59 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 29 Aug 2011 16:59:15 +0200 Subject: iwlegacy: merge iwl-4965-led.c into 4965.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index df86431..4a8ad8d 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -58,7 +58,6 @@ #include "iwl-sta.h" #include "iwl-4965-calib.h" #include "iwl-4965.h" -#include "iwl-4965-led.h" /****************************************************************************** diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index bdfb3a6..8f68b94 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -44,10 +44,39 @@ #include "iwl-helpers.h" #include "iwl-4965-calib.h" #include "iwl-sta.h" -#include "iwl-4965-led.h" #include "iwl-4965.h" #include "iwl-4965-debugfs.h" +/* Send led command */ +static int +il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) +{ + struct il_host_cmd cmd = { + .id = REPLY_LEDS_CMD, + .len = sizeof(struct il_led_cmd), + .data = led_cmd, + .flags = CMD_ASYNC, + .callback = NULL, + }; + u32 reg; + + reg = _il_rd(il, CSR_LED_REG); + if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) + _il_wr(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + + return il_send_cmd(il, &cmd); +} + +/* Set led register off */ +void il4965_led_enable(struct il_priv *il) +{ + _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); +} + +const struct il_led_ops il4965_led_ops = { + .cmd = il4965_send_led_cmd, +}; + static int il4965_send_tx_power(struct il_priv *il); static int il4965_hw_get_temperature(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index cd8ac73..b909352 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -8,7 +8,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl-4965-led.o +iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c deleted file mode 100644 index 4854157..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ /dev/null @@ -1,73 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-commands.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-4965-led.h" - -/* Send led command */ -static int -il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) -{ - struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, - .len = sizeof(struct il_led_cmd), - .data = led_cmd, - .flags = CMD_ASYNC, - .callback = NULL, - }; - u32 reg; - - reg = _il_rd(il, CSR_LED_REG); - if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - _il_wr(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); - - return il_send_cmd(il, &cmd); -} - -/* Set led register off */ -void il4965_led_enable(struct il_priv *il) -{ - _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); -} - -const struct il_led_ops il4965_led_ops = { - .cmd = il4965_send_led_cmd, -}; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.h b/drivers/net/wireless/iwlegacy/iwl-4965-led.h deleted file mode 100644 index e804fe1..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.h +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_4965_led_h__ -#define __il_4965_led_h__ - -extern const struct il_led_ops il4965_led_ops; -void il4965_led_enable(struct il_priv *il); - -#endif /* __il_4965_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 8076bbe..c0bb45b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -279,4 +279,6 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch); +void il4965_led_enable(struct il_priv *il); + #endif /* __il_4965_h__ */ -- cgit v0.10.2 From ecce1f09e847351d18e503e533000f781cac1d41 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 29 Aug 2011 17:05:28 +0200 Subject: iwlegacy: merge iwl-3945-led.c into 3945.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b6abf34..b41e60b 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -48,9 +48,27 @@ #include "iwl-core.h" #include "iwl-helpers.h" #include "iwl-led.h" -#include "iwl-3945-led.h" #include "iwl-3945-debugfs.h" +/* Send led command */ +static int il3945_send_led_cmd(struct il_priv *il, + struct il_led_cmd *led_cmd) +{ + struct il_host_cmd cmd = { + .id = REPLY_LEDS_CMD, + .len = sizeof(struct il_led_cmd), + .data = led_cmd, + .flags = CMD_ASYNC, + .callback = NULL, + }; + + return il_send_cmd(il, &cmd); +} + +const struct il_led_ops il3945_led_ops = { + .cmd = il3945_send_led_cmd, +}; + #define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ RATE_##r##M_IEEE, \ diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index b909352..da83c69 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -16,7 +16,7 @@ iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o -iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o iwl-3945-led.o +iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.c b/drivers/net/wireless/iwlegacy/iwl-3945-led.c deleted file mode 100644 index 53ec463..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.c +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-commands.h" -#include "iwl-3945.h" -#include "iwl-core.h" -#include "iwl-dev.h" -#include "iwl-3945-led.h" - - -/* Send led command */ -static int il3945_send_led_cmd(struct il_priv *il, - struct il_led_cmd *led_cmd) -{ - struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, - .len = sizeof(struct il_led_cmd), - .data = led_cmd, - .flags = CMD_ASYNC, - .callback = NULL, - }; - - return il_send_cmd(il, &cmd); -} - -const struct il_led_ops il3945_led_ops = { - .cmd = il3945_send_led_cmd, -}; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.h b/drivers/net/wireless/iwlegacy/iwl-3945-led.h deleted file mode 100644 index 369c72d..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.h +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_3945_led_h__ -#define __il_3945_led_h__ - -extern const struct il_led_ops il3945_led_ops; - -#endif /* __il_3945_led_h__ */ -- cgit v0.10.2 From 56e7a8cca0fd9e096acd2233f0e9f95df6423071 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 12:45:25 +0200 Subject: iwlegacy: merge iwl-4965-eeprom.c into 4965.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 8f68b94..a4b42cc 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -47,6 +47,80 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" +/****************************************************************************** + * + * EEPROM related functions + * +******************************************************************************/ + +/* + * The device's EEPROM semaphore prevents conflicts between driver and uCode + * when accessing the EEPROM; each access is a series of pulses to/from the + * EEPROM chip, not a single event, so even reads could conflict if they + * weren't arbitrated by the semaphore. + */ +int il4965_eeprom_acquire_semaphore(struct il_priv *il) +{ + u16 count; + int ret; + + for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { + /* Request semaphore */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + + /* See if we got it */ + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + EEPROM_SEM_TIMEOUT); + if (ret >= 0) + return ret; + } + + return ret; +} + +void il4965_eeprom_release_semaphore(struct il_priv *il) +{ + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + +} + +int il4965_eeprom_check_version(struct il_priv *il) +{ + u16 eeprom_ver; + u16 calib_ver; + + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); + calib_ver = il_eeprom_query16(il, + EEPROM_4965_CALIB_VERSION_OFFSET); + + if (eeprom_ver < il->cfg->eeprom_ver || + calib_ver < il->cfg->eeprom_calib_ver) + goto err; + + IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", + eeprom_ver, calib_ver); + + return 0; +err: + IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " + "CALIB=0x%x < 0x%x\n", + eeprom_ver, il->cfg->eeprom_ver, + calib_ver, il->cfg->eeprom_calib_ver); + return -EINVAL; + +} + +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) +{ + const u8 *addr = il_eeprom_query_addr(il, + EEPROM_MAC_ADDRESS); + memcpy(mac, addr, ETH_ALEN); +} + /* Send led command */ static int il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index da83c69..2776845b 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -11,7 +11,7 @@ obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o -iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o +iwl4965-objs += iwl-4965-sta.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c deleted file mode 100644 index a519257..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ /dev/null @@ -1,150 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include "iwl-commands.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" -#include "iwl-4965.h" -#include "iwl-io.h" - -/****************************************************************************** - * - * EEPROM related functions - * -******************************************************************************/ - -/* - * The device's EEPROM semaphore prevents conflicts between driver and uCode - * when accessing the EEPROM; each access is a series of pulses to/from the - * EEPROM chip, not a single event, so even reads could conflict if they - * weren't arbitrated by the semaphore. - */ -int il4965_eeprom_acquire_semaphore(struct il_priv *il) -{ - u16 count; - int ret; - - for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { - /* Request semaphore */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); - - /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - EEPROM_SEM_TIMEOUT); - if (ret >= 0) - return ret; - } - - return ret; -} - -void il4965_eeprom_release_semaphore(struct il_priv *il) -{ - il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); - -} - -int il4965_eeprom_check_version(struct il_priv *il) -{ - u16 eeprom_ver; - u16 calib_ver; - - eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - calib_ver = il_eeprom_query16(il, - EEPROM_4965_CALIB_VERSION_OFFSET); - - if (eeprom_ver < il->cfg->eeprom_ver || - calib_ver < il->cfg->eeprom_calib_ver) - goto err; - - IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", - eeprom_ver, calib_ver); - - return 0; -err: - IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " - "CALIB=0x%x < 0x%x\n", - eeprom_ver, il->cfg->eeprom_ver, - calib_ver, il->cfg->eeprom_calib_ver); - return -EINVAL; - -} - -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) -{ - const u8 *addr = il_eeprom_query_addr(il, - EEPROM_MAC_ADDRESS); - memcpy(mac, addr, ETH_ALEN); -} -- cgit v0.10.2 From 862d32e6db6183e5cb67fe465818578556196a94 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 12:50:25 +0200 Subject: iwlegacy: merge iwl-4965-ucode.c into 4965.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index a4b42cc..752564d 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -47,6 +47,131 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" +#define IL_AC_UNSET -1 + +/** + * il_verify_inst_sparse - verify runtime uCode image in card vs. host, + * using sample data 100 bytes apart. If these sample points are good, + * it's a pretty good bet that everything between them is good, too. + */ +static int +il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +{ + u32 val; + int ret = 0; + u32 errcnt = 0; + u32 i; + + D_INFO("ucode inst image size is %u\n", len); + + for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + il_wr(il, HBUS_TARG_MEM_RADDR, + i + IL4965_RTC_INST_LOWER_BOUND); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + ret = -EIO; + errcnt++; + if (errcnt >= 3) + break; + } + } + + return ret; +} + +/** + * il4965_verify_inst_full - verify runtime uCode image in card vs. host, + * looking at all data. + */ +static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, + u32 len) +{ + u32 val; + u32 save_len = len; + int ret = 0; + u32 errcnt; + + D_INFO("ucode inst image size is %u\n", len); + + il_wr(il, HBUS_TARG_MEM_RADDR, + IL4965_RTC_INST_LOWER_BOUND); + + errcnt = 0; + for (; len > 0; len -= sizeof(u32), image++) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + IL_ERR("uCode INST section is invalid at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); + ret = -EIO; + errcnt++; + if (errcnt >= 20) + break; + } + } + + if (!errcnt) + D_INFO( + "ucode image in INSTRUCTION memory is good\n"); + + return ret; +} + +/** + * il4965_verify_ucode - determine which instruction image is in SRAM, + * and verify its contents + */ +int il4965_verify_ucode(struct il_priv *il) +{ + __le32 *image; + u32 len; + int ret; + + /* Try bootstrap */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_sparse(il, image, len); + if (!ret) { + D_INFO("Bootstrap uCode is good in inst SRAM\n"); + return 0; + } + + /* Try initialize */ + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + ret = il4965_verify_inst_sparse(il, image, len); + if (!ret) { + D_INFO("Initialize uCode is good in inst SRAM\n"); + return 0; + } + + /* Try runtime/protocol */ + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + ret = il4965_verify_inst_sparse(il, image, len); + if (!ret) { + D_INFO("Runtime uCode is good in inst SRAM\n"); + return 0; + } + + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + + /* Since nothing seems to match, show first several data entries in + * instruction SRAM, so maybe visual inspection will give a clue. + * Selection of bootstrap image (vs. other images) is arbitrary. */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_full(il, image, len); + + return ret; +} + /****************************************************************************** * * EEPROM related functions diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 2776845b..43daa07 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -9,7 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o +iwl4965-objs += iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c deleted file mode 100644 index 633caf5..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ /dev/null @@ -1,166 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" -#include "iwl-4965-calib.h" - -#define IL_AC_UNSET -1 - -/** - * il_verify_inst_sparse - verify runtime uCode image in card vs. host, - * using sample data 100 bytes apart. If these sample points are good, - * it's a pretty good bet that everything between them is good, too. - */ -static int -il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) -{ - u32 val; - int ret = 0; - u32 errcnt = 0; - u32 i; - - D_INFO("ucode inst image size is %u\n", len); - - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL4965_RTC_INST_LOWER_BOUND); - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - ret = -EIO; - errcnt++; - if (errcnt >= 3) - break; - } - } - - return ret; -} - -/** - * il4965_verify_inst_full - verify runtime uCode image in card vs. host, - * looking at all data. - */ -static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, - u32 len) -{ - u32 val; - u32 save_len = len; - int ret = 0; - u32 errcnt; - - D_INFO("ucode inst image size is %u\n", len); - - il_wr(il, HBUS_TARG_MEM_RADDR, - IL4965_RTC_INST_LOWER_BOUND); - - errcnt = 0; - for (; len > 0; len -= sizeof(u32), image++) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); - ret = -EIO; - errcnt++; - if (errcnt >= 20) - break; - } - } - - if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); - - return ret; -} - -/** - * il4965_verify_ucode - determine which instruction image is in SRAM, - * and verify its contents - */ -int il4965_verify_ucode(struct il_priv *il) -{ - __le32 *image; - u32 len; - int ret; - - /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - ret = il4965_verify_inst_sparse(il, image, len); - if (!ret) { - D_INFO("Bootstrap uCode is good in inst SRAM\n"); - return 0; - } - - /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; - len = il->ucode_init.len; - ret = il4965_verify_inst_sparse(il, image, len); - if (!ret) { - D_INFO("Initialize uCode is good in inst SRAM\n"); - return 0; - } - - /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; - len = il->ucode_code.len; - ret = il4965_verify_inst_sparse(il, image, len); - if (!ret) { - D_INFO("Runtime uCode is good in inst SRAM\n"); - return 0; - } - - IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); - - /* Since nothing seems to match, show first several data entries in - * instruction SRAM, so maybe visual inspection will give a clue. - * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - ret = il4965_verify_inst_full(il, image, len); - - return ret; -} -- cgit v0.10.2 From eb3cdfb72d1cc73d8f78f01bc107064d77727d30 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 12:58:35 +0200 Subject: iwlegacy: merge iwl-4965-sta.c into 4965-mac.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 4a8ad8d..142d39f 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -86,6 +86,683 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); +static struct il_link_quality_cmd * +il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) +{ + int i, r; + struct il_link_quality_cmd *link_cmd; + u32 rate_flags = 0; + __le32 rate_n_flags; + + link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); + if (!link_cmd) { + IL_ERR("Unable to allocate memory for LQ cmd.\n"); + return NULL; + } + /* Set up the rate scaling to start at selected rate, fall back + * all the way down to 1M in IEEE order, and then spin on 1M */ + if (il->band == IEEE80211_BAND_5GHZ) + r = RATE_6M_IDX; + else + r = RATE_1M_IDX; + + if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) + rate_flags |= RATE_MCS_CCK_MSK; + + rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << + RATE_MCS_ANT_POS; + rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, + rate_flags); + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) + link_cmd->rs_table[i].rate_n_flags = rate_n_flags; + + link_cmd->general_params.single_stream_ant_msk = + il4965_first_antenna(il->hw_params.valid_tx_ant); + + link_cmd->general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); + if (!link_cmd->general_params.dual_stream_ant_msk) { + link_cmd->general_params.dual_stream_ant_msk = ANT_AB; + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { + link_cmd->general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant; + } + + link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; + link_cmd->agg_params.agg_time_limit = + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); + + link_cmd->sta_id = sta_id; + + return link_cmd; +} + +/* + * il4965_add_bssid_station - Add the special IBSS BSSID station + * + * Function sleeps. + */ +int +il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 *addr, u8 *sta_id_r) +{ + int ret; + u8 sta_id; + struct il_link_quality_cmd *link_cmd; + unsigned long flags; + + if (sta_id_r) + *sta_id_r = IL_INVALID_STATION; + + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM\n", addr); + return ret; + } + + if (sta_id_r) + *sta_id_r = sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); + + /* Set up default rate scaling table in device's station table */ + link_cmd = il4965_sta_alloc_lq(il, sta_id); + if (!link_cmd) { + IL_ERR( + "Unable to initialize rate scaling for station %pM.\n", + addr); + return -ENOMEM; + } + + ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); + if (ret) + IL_ERR("Link quality command failed (%d)\n", ret); + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +static int il4965_static_wepkey_cmd(struct il_priv *il, + struct il_rxon_context *ctx, + bool send_if_empty) +{ + int i, not_empty = 0; + u8 buff[sizeof(struct il_wep_cmd) + + sizeof(struct il_wep_key) * WEP_KEYS_MAX]; + struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; + size_t cmd_size = sizeof(struct il_wep_cmd); + struct il_host_cmd cmd = { + .id = ctx->wep_key_cmd, + .data = wep_cmd, + .flags = CMD_SYNC, + }; + + might_sleep(); + + memset(wep_cmd, 0, cmd_size + + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); + + for (i = 0; i < WEP_KEYS_MAX ; i++) { + wep_cmd->key[i].key_idx = i; + if (ctx->wep_keys[i].key_size) { + wep_cmd->key[i].key_offset = i; + not_empty = 1; + } else { + wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; + } + + wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; + memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, + ctx->wep_keys[i].key_size); + } + + wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; + wep_cmd->num_keys = WEP_KEYS_MAX; + + cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; + + cmd.len = cmd_size; + + if (not_empty || send_if_empty) + return il_send_cmd(il, &cmd); + else + return 0; +} + +int il4965_restore_default_wep_keys(struct il_priv *il, + struct il_rxon_context *ctx) +{ + lockdep_assert_held(&il->mutex); + + return il4965_static_wepkey_cmd(il, ctx, false); +} + +int il4965_remove_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + D_WEP("Removing default WEP key: idx=%d\n", + keyconf->keyidx); + + memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); + if (il_is_rfkill(il)) { + D_WEP( + "Not sending REPLY_WEPKEY command due to RFKILL.\n"); + /* but keys in device are clear anyway so return success */ + return 0; + } + ret = il4965_static_wepkey_cmd(il, ctx, 1); + D_WEP("Remove default WEP key: idx=%d ret=%d\n", + keyconf->keyidx, ret); + + return ret; +} + +int il4965_set_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + if (keyconf->keylen != WEP_KEY_LEN_128 && + keyconf->keylen != WEP_KEY_LEN_64) { + D_WEP("Bad WEP key length %d\n", keyconf->keylen); + return -EINVAL; + } + + keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; + keyconf->hw_key_idx = HW_KEY_DEFAULT; + il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; + + ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; + memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, + keyconf->keylen); + + ret = il4965_static_wepkey_cmd(il, ctx, false); + D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", + keyconf->keylen, keyconf->keyidx, ret); + + return ret; +} + +static int il4965_set_wep_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + __le16 key_flags = 0; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; + + key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + key_flags &= ~STA_KEY_FLG_INVALID; + + if (keyconf->keylen == WEP_KEY_LEN_128) + key_flags |= STA_KEY_FLG_KEY_SIZE_MSK; + + if (sta_id == ctx->bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + spin_lock_irqsave(&il->sta_lock, flags); + + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; + + memcpy(il->stations[sta_id].keyinfo.key, + keyconf->key, keyconf->keylen); + + memcpy(&il->stations[sta_id].sta.key.key[3], + keyconf->key, keyconf->keylen); + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + __le16 key_flags = 0; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + key_flags &= ~STA_KEY_FLG_INVALID; + + if (sta_id == ctx->bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, + keyconf->keylen); + + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, + keyconf->keylen); + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + int ret = 0; + __le16 key_flags = 0; + + key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + key_flags &= ~STA_KEY_FLG_INVALID; + + if (sta_id == ctx->bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; + + spin_lock_irqsave(&il->sta_lock, flags); + + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = 16; + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + + + /* This copy is acutally not needed: we get the key with each TX */ + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); + + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); + + spin_unlock_irqrestore(&il->sta_lock, flags); + + return ret; +} + +void il4965_update_tkip_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) +{ + u8 sta_id; + unsigned long flags; + int i; + + if (il_scan_cancel(il)) { + /* cancel scan failed, just live w/ bad key and rely + briefly on SW decryption */ + return; + } + + sta_id = il_sta_id_or_broadcast(il, ctx, sta); + if (sta_id == IL_INVALID_STATION) + return; + + spin_lock_irqsave(&il->sta_lock, flags); + + il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; + + for (i = 0; i < 5; i++) + il->stations[sta_id].sta.key.tkip_rx_ttak[i] = + cpu_to_le16(phase1key[i]); + + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); + + spin_unlock_irqrestore(&il->sta_lock, flags); + +} + +int il4965_remove_dynamic_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + u16 key_flags; + u8 keyidx; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + ctx->key_mapping_keys--; + + spin_lock_irqsave(&il->sta_lock, flags); + key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); + keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; + + D_WEP("Remove dynamic key: idx=%d sta=%d\n", + keyconf->keyidx, sta_id); + + if (keyconf->keyidx != keyidx) { + /* We need to remove a key with idx different that the one + * in the uCode. This means that the key we need to remove has + * been replaced by another one with different idx. + * Don't do anything and return ok + */ + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + + if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { + IL_WARN("Removing wrong key %d 0x%x\n", + keyconf->keyidx, key_flags); + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + + if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, + &il->ucode_key_table)) + IL_ERR("idx %d not used in uCode key table.\n", + il->stations[sta_id].sta.key.key_offset); + memset(&il->stations[sta_id].keyinfo, 0, + sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, + sizeof(struct il4965_keyinfo)); + il->stations[sta_id].sta.key.key_flags = + STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; + il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + if (il_is_rfkill(il)) { + D_WEP( + "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + ctx->key_mapping_keys++; + keyconf->hw_key_idx = HW_KEY_DYNAMIC; + + switch (keyconf->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + ret = il4965_set_ccmp_dynamic_key_info(il, ctx, + keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_TKIP: + ret = il4965_set_tkip_dynamic_key_info(il, ctx, + keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + ret = il4965_set_wep_dynamic_key_info(il, ctx, + keyconf, sta_id); + break; + default: + IL_ERR( + "Unknown alg: %s cipher = %x\n", __func__, + keyconf->cipher); + ret = -EINVAL; + } + + D_WEP( + "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", + keyconf->cipher, keyconf->keylen, keyconf->keyidx, + sta_id, ret); + + return ret; +} + +/** + * il4965_alloc_bcast_station - add broadcast station into driver's station table. + * + * This adds the broadcast station into the driver's station table + * and marks it driver active, so that it will be restored to the + * device at the next best time. + */ +int il4965_alloc_bcast_station(struct il_priv *il, + struct il_rxon_context *ctx) +{ + struct il_link_quality_cmd *link_cmd; + unsigned long flags; + u8 sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, il_bcast_addr, + false, NULL); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return -EINVAL; + } + + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); + + link_cmd = il4965_sta_alloc_lq(il, sta_id); + if (!link_cmd) { + IL_ERR( + "Unable to initialize rate scaling for bcast station.\n"); + return -ENOMEM; + } + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +/** + * il4965_update_bcast_station - update broadcast station's LQ command + * + * Only used by iwl4965. Placed here to have all bcast station management + * code together. + */ +static int il4965_update_bcast_station(struct il_priv *il, + struct il_rxon_context *ctx) +{ + unsigned long flags; + struct il_link_quality_cmd *link_cmd; + u8 sta_id = ctx->bcast_sta_id; + + link_cmd = il4965_sta_alloc_lq(il, sta_id); + if (!link_cmd) { + IL_ERR( + "Unable to initialize rate scaling for bcast station.\n"); + return -ENOMEM; + } + + spin_lock_irqsave(&il->sta_lock, flags); + if (il->stations[sta_id].lq) + kfree(il->stations[sta_id].lq); + else + D_INFO( + "Bcast station rate scaling has not been initialized yet.\n"); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +int il4965_update_bcast_stations(struct il_priv *il) +{ + return il4965_update_bcast_station(il, &il->ctx); +} + +/** + * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table + */ +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) +{ + unsigned long flags; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + /* Remove "disable" flag, to enable Tx for this TID */ + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; + il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, + int tid, u16 ssn) +{ + unsigned long flags; + int sta_id; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) + return -ENXIO; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; + il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, + int tid) +{ + unsigned long flags; + int sta_id; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Invalid station for AGG tid %d\n", tid); + return -ENXIO; + } + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; + il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +void +il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) +{ + unsigned long flags; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.sta.modify_mask = + STA_MODIFY_SLEEP_TX_COUNT_MSK; + il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags); + +} + void il4965_update_chain_flags(struct il_priv *il) { if (il->cfg->ops->hcmd->set_rxon_chain) { diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 43daa07..0643fda0 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -11,7 +11,6 @@ obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl4965-objs += iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o -iwl4965-objs += iwl-4965-sta.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c deleted file mode 100644 index 337bf0c..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ /dev/null @@ -1,712 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-4965.h" - -static struct il_link_quality_cmd * -il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) -{ - int i, r; - struct il_link_quality_cmd *link_cmd; - u32 rate_flags = 0; - __le32 rate_n_flags; - - link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); - if (!link_cmd) { - IL_ERR("Unable to allocate memory for LQ cmd.\n"); - return NULL; - } - /* Set up the rate scaling to start at selected rate, fall back - * all the way down to 1M in IEEE order, and then spin on 1M */ - if (il->band == IEEE80211_BAND_5GHZ) - r = RATE_6M_IDX; - else - r = RATE_1M_IDX; - - if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) - rate_flags |= RATE_MCS_CCK_MSK; - - rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << - RATE_MCS_ANT_POS; - rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, - rate_flags); - for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - link_cmd->rs_table[i].rate_n_flags = rate_n_flags; - - link_cmd->general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); - - link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); - if (!link_cmd->general_params.dual_stream_ant_msk) { - link_cmd->general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { - link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; - } - - link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; - link_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); - - link_cmd->sta_id = sta_id; - - return link_cmd; -} - -/* - * il4965_add_bssid_station - Add the special IBSS BSSID station - * - * Function sleeps. - */ -int -il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r) -{ - int ret; - u8 sta_id; - struct il_link_quality_cmd *link_cmd; - unsigned long flags; - - if (sta_id_r) - *sta_id_r = IL_INVALID_STATION; - - ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM\n", addr); - return ret; - } - - if (sta_id_r) - *sta_id_r = sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&il->sta_lock, flags); - - /* Set up default rate scaling table in device's station table */ - link_cmd = il4965_sta_alloc_lq(il, sta_id); - if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for station %pM.\n", - addr); - return -ENOMEM; - } - - ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); - if (ret) - IL_ERR("Link quality command failed (%d)\n", ret); - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -static int il4965_static_wepkey_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - bool send_if_empty) -{ - int i, not_empty = 0; - u8 buff[sizeof(struct il_wep_cmd) + - sizeof(struct il_wep_key) * WEP_KEYS_MAX]; - struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; - size_t cmd_size = sizeof(struct il_wep_cmd); - struct il_host_cmd cmd = { - .id = ctx->wep_key_cmd, - .data = wep_cmd, - .flags = CMD_SYNC, - }; - - might_sleep(); - - memset(wep_cmd, 0, cmd_size + - (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); - - for (i = 0; i < WEP_KEYS_MAX ; i++) { - wep_cmd->key[i].key_idx = i; - if (ctx->wep_keys[i].key_size) { - wep_cmd->key[i].key_offset = i; - not_empty = 1; - } else { - wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; - } - - wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; - memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, - ctx->wep_keys[i].key_size); - } - - wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; - wep_cmd->num_keys = WEP_KEYS_MAX; - - cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; - - cmd.len = cmd_size; - - if (not_empty || send_if_empty) - return il_send_cmd(il, &cmd); - else - return 0; -} - -int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx) -{ - lockdep_assert_held(&il->mutex); - - return il4965_static_wepkey_cmd(il, ctx, false); -} - -int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - D_WEP("Removing default WEP key: idx=%d\n", - keyconf->keyidx); - - memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); - if (il_is_rfkill(il)) { - D_WEP( - "Not sending REPLY_WEPKEY command due to RFKILL.\n"); - /* but keys in device are clear anyway so return success */ - return 0; - } - ret = il4965_static_wepkey_cmd(il, ctx, 1); - D_WEP("Remove default WEP key: idx=%d ret=%d\n", - keyconf->keyidx, ret); - - return ret; -} - -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - if (keyconf->keylen != WEP_KEY_LEN_128 && - keyconf->keylen != WEP_KEY_LEN_64) { - D_WEP("Bad WEP key length %d\n", keyconf->keylen); - return -EINVAL; - } - - keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; - keyconf->hw_key_idx = HW_KEY_DEFAULT; - il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; - - ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; - memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, - keyconf->keylen); - - ret = il4965_static_wepkey_cmd(il, ctx, false); - D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", - keyconf->keylen, keyconf->keyidx, ret); - - return ret; -} - -static int il4965_set_wep_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - __le16 key_flags = 0; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; - - key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - key_flags &= ~STA_KEY_FLG_INVALID; - - if (keyconf->keylen == WEP_KEY_LEN_128) - key_flags |= STA_KEY_FLG_KEY_SIZE_MSK; - - if (sta_id == ctx->bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - spin_lock_irqsave(&il->sta_lock, flags); - - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; - - memcpy(il->stations[sta_id].keyinfo.key, - keyconf->key, keyconf->keylen); - - memcpy(&il->stations[sta_id].sta.key.key[3], - keyconf->key, keyconf->keylen); - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - __le16 key_flags = 0; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - key_flags &= ~STA_KEY_FLG_INVALID; - - if (sta_id == ctx->bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); - - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - int ret = 0; - __le16 key_flags = 0; - - key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - key_flags &= ~STA_KEY_FLG_INVALID; - - if (sta_id == ctx->bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; - - spin_lock_irqsave(&il->sta_lock, flags); - - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = 16; - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - - - /* This copy is acutally not needed: we get the key with each TX */ - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); - - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); - - spin_unlock_irqrestore(&il->sta_lock, flags); - - return ret; -} - -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) -{ - u8 sta_id; - unsigned long flags; - int i; - - if (il_scan_cancel(il)) { - /* cancel scan failed, just live w/ bad key and rely - briefly on SW decryption */ - return; - } - - sta_id = il_sta_id_or_broadcast(il, ctx, sta); - if (sta_id == IL_INVALID_STATION) - return; - - spin_lock_irqsave(&il->sta_lock, flags); - - il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; - - for (i = 0; i < 5; i++) - il->stations[sta_id].sta.key.tkip_rx_ttak[i] = - cpu_to_le16(phase1key[i]); - - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); - - spin_unlock_irqrestore(&il->sta_lock, flags); - -} - -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - u16 key_flags; - u8 keyidx; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - ctx->key_mapping_keys--; - - spin_lock_irqsave(&il->sta_lock, flags); - key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); - keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - - D_WEP("Remove dynamic key: idx=%d sta=%d\n", - keyconf->keyidx, sta_id); - - if (keyconf->keyidx != keyidx) { - /* We need to remove a key with idx different that the one - * in the uCode. This means that the key we need to remove has - * been replaced by another one with different idx. - * Don't do anything and return ok - */ - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - - if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN("Removing wrong key %d 0x%x\n", - keyconf->keyidx, key_flags); - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - - if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, - &il->ucode_key_table)) - IL_ERR("idx %d not used in uCode key table.\n", - il->stations[sta_id].sta.key.key_offset); - memset(&il->stations[sta_id].keyinfo, 0, - sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); - il->stations[sta_id].sta.key.key_flags = - STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; - il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - if (il_is_rfkill(il)) { - D_WEP( - "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, u8 sta_id) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - ctx->key_mapping_keys++; - keyconf->hw_key_idx = HW_KEY_DYNAMIC; - - switch (keyconf->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - ret = il4965_set_ccmp_dynamic_key_info(il, ctx, - keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_TKIP: - ret = il4965_set_tkip_dynamic_key_info(il, ctx, - keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - ret = il4965_set_wep_dynamic_key_info(il, ctx, - keyconf, sta_id); - break; - default: - IL_ERR( - "Unknown alg: %s cipher = %x\n", __func__, - keyconf->cipher); - ret = -EINVAL; - } - - D_WEP( - "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); - - return ret; -} - -/** - * il4965_alloc_bcast_station - add broadcast station into driver's station table. - * - * This adds the broadcast station into the driver's station table - * and marks it driver active, so that it will be restored to the - * device at the next best time. - */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) -{ - struct il_link_quality_cmd *link_cmd; - unsigned long flags; - u8 sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, il_bcast_addr, - false, NULL); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return -EINVAL; - } - - il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - il->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&il->sta_lock, flags); - - link_cmd = il4965_sta_alloc_lq(il, sta_id); - if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); - return -ENOMEM; - } - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -/** - * il4965_update_bcast_station - update broadcast station's LQ command - * - * Only used by iwl4965. Placed here to have all bcast station management - * code together. - */ -static int il4965_update_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) -{ - unsigned long flags; - struct il_link_quality_cmd *link_cmd; - u8 sta_id = ctx->bcast_sta_id; - - link_cmd = il4965_sta_alloc_lq(il, sta_id); - if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); - return -ENOMEM; - } - - spin_lock_irqsave(&il->sta_lock, flags); - if (il->stations[sta_id].lq) - kfree(il->stations[sta_id].lq); - else - D_INFO( - "Bcast station rate scaling has not been initialized yet.\n"); - il->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -int il4965_update_bcast_stations(struct il_priv *il) -{ - return il4965_update_bcast_station(il, &il->ctx); -} - -/** - * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table - */ -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) -{ - unsigned long flags; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - /* Remove "disable" flag, to enable Tx for this TID */ - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; - il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn) -{ - unsigned long flags; - int sta_id; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - sta_id = il_sta_id(sta); - if (sta_id == IL_INVALID_STATION) - return -ENXIO; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.station_flags_msk = 0; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; - il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; - il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid) -{ - unsigned long flags; - int sta_id; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - sta_id = il_sta_id(sta); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Invalid station for AGG tid %d\n", tid); - return -ENXIO; - } - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.station_flags_msk = 0; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; - il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -void -il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) -{ - unsigned long flags; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; - il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; - il->stations[sta_id].sta.sta.modify_mask = - STA_MODIFY_SLEEP_TX_COUNT_MSK; - il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&il->sta_lock, flags); - -} -- cgit v0.10.2 From a1751b22a82e6cd2da6c9e79611cfd6d6aba1d39 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:50:37 +0100 Subject: iwlegacy: merge iwl-4965-{tx,rx}.c into 4965-mac.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 142d39f..b6f96b4 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -86,6 +86,1483 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); +void il4965_rx_missed_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) + +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_missed_beacon_notif *missed_beacon; + + missed_beacon = &pkt->u.missed_beacon; + if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > + il->missed_beacon_threshold) { + D_CALIB( + "missed bcn cnsq %d totl %d rcd %d expctd %d\n", + le32_to_cpu(missed_beacon->consecutive_missed_beacons), + le32_to_cpu(missed_beacon->total_missed_becons), + le32_to_cpu(missed_beacon->num_recvd_beacons), + le32_to_cpu(missed_beacon->num_expected_beacons)); + if (!test_bit(STATUS_SCANNING, &il->status)) + il4965_init_sensitivity(il); + } +} + +/* Calculate noise level, based on measurements during network silence just + * before arriving beacon. This measurement can be done only if we know + * exactly when to expect beacons, therefore only when we're associated. */ +static void il4965_rx_calc_noise(struct il_priv *il) +{ + struct stats_rx_non_phy *rx_info; + int num_active_rx = 0; + int total_silence = 0; + int bcn_silence_a, bcn_silence_b, bcn_silence_c; + int last_rx_noise; + + rx_info = &(il->_4965.stats.rx.general); + bcn_silence_a = + le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; + bcn_silence_b = + le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; + bcn_silence_c = + le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; + + if (bcn_silence_a) { + total_silence += bcn_silence_a; + num_active_rx++; + } + if (bcn_silence_b) { + total_silence += bcn_silence_b; + num_active_rx++; + } + if (bcn_silence_c) { + total_silence += bcn_silence_c; + num_active_rx++; + } + + /* Average among active antennas */ + if (num_active_rx) + last_rx_noise = (total_silence / num_active_rx) - 107; + else + last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; + + D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", + bcn_silence_a, bcn_silence_b, bcn_silence_c, + last_rx_noise); +} + +#ifdef CONFIG_IWLEGACY_DEBUGFS +/* + * based on the assumption of all stats counter are in DWORD + * FIXME: This function is for debugging, do not deal with + * the case of counters roll-over. + */ +static void il4965_accumulative_stats(struct il_priv *il, + __le32 *stats) +{ + int i, size; + __le32 *prev_stats; + u32 *accum_stats; + u32 *delta, *max_delta; + struct stats_general_common *general, *accum_general; + struct stats_tx *tx, *accum_tx; + + prev_stats = (__le32 *)&il->_4965.stats; + accum_stats = (u32 *)&il->_4965.accum_stats; + size = sizeof(struct il_notif_stats); + general = &il->_4965.stats.general.common; + accum_general = &il->_4965.accum_stats.general.common; + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta = (u32 *)&il->_4965.delta_stats; + max_delta = (u32 *)&il->_4965.max_delta; + + for (i = sizeof(__le32); i < size; + i += sizeof(__le32), stats++, prev_stats++, delta++, + max_delta++, accum_stats++) { + if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { + *delta = (le32_to_cpu(*stats) - + le32_to_cpu(*prev_stats)); + *accum_stats += *delta; + if (*delta > *max_delta) + *max_delta = *delta; + } + } + + /* reset accumulative stats for "no-counter" type stats */ + accum_general->temperature = general->temperature; + accum_general->ttl_timestamp = general->ttl_timestamp; +} +#endif + +#define REG_RECALIB_PERIOD (60) + +void il4965_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + int change; + struct il_rx_pkt *pkt = rxb_addr(rxb); + + D_RX( + "Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il_notif_stats), + le32_to_cpu(pkt->len_n_flags) & + FH_RSCSR_FRAME_SIZE_MSK); + + change = ((il->_4965.stats.general.common.temperature != + pkt->u.stats.general.common.temperature) || + ((il->_4965.stats.flag & + STATISTICS_REPLY_FLG_HT40_MODE_MSK) != + (pkt->u.stats.flag & + STATISTICS_REPLY_FLG_HT40_MODE_MSK))); +#ifdef CONFIG_IWLEGACY_DEBUGFS + il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); +#endif + + /* TODO: reading some of stats is unneeded */ + memcpy(&il->_4965.stats, &pkt->u.stats, + sizeof(il->_4965.stats)); + + set_bit(STATUS_STATISTICS, &il->status); + + /* Reschedule the stats timer to occur in + * REG_RECALIB_PERIOD seconds to ensure we get a + * thermal update even if the uCode doesn't give + * us one */ + mod_timer(&il->stats_periodic, jiffies + + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); + + if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { + il4965_rx_calc_noise(il); + queue_work(il->workqueue, &il->run_time_calib_work); + } + if (il->cfg->ops->lib->temp_ops.temperature && change) + il->cfg->ops->lib->temp_ops.temperature(il); +} + +void il4965_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + + if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { +#ifdef CONFIG_IWLEGACY_DEBUGFS + memset(&il->_4965.accum_stats, 0, + sizeof(struct il_notif_stats)); + memset(&il->_4965.delta_stats, 0, + sizeof(struct il_notif_stats)); + memset(&il->_4965.max_delta, 0, + sizeof(struct il_notif_stats)); +#endif + D_RX("Statistics have been cleared\n"); + } + il4965_rx_stats(il, rxb); +} + +static const u8 tid_to_ac[] = { + IEEE80211_AC_BE, + IEEE80211_AC_BK, + IEEE80211_AC_BK, + IEEE80211_AC_BE, + IEEE80211_AC_VI, + IEEE80211_AC_VI, + IEEE80211_AC_VO, + IEEE80211_AC_VO +}; + +static inline int il4965_get_ac_from_tid(u16 tid) +{ + if (likely(tid < ARRAY_SIZE(tid_to_ac))) + return tid_to_ac[tid]; + + /* no support for TIDs 8-15 yet */ + return -EINVAL; +} + +static inline int +il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) +{ + if (likely(tid < ARRAY_SIZE(tid_to_ac))) + return ctx->ac_to_fifo[tid_to_ac[tid]]; + + /* no support for TIDs 8-15 yet */ + return -EINVAL; +} + +/* + * handle build REPLY_TX command notification. + */ +static void il4965_tx_cmd_build_basic(struct il_priv *il, + struct sk_buff *skb, + struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, + u8 std_id) +{ + __le16 fc = hdr->frame_control; + __le32 tx_flags = tx_cmd->tx_flags; + + tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { + tx_flags |= TX_CMD_FLG_ACK_MSK; + if (ieee80211_is_mgmt(fc)) + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + if (ieee80211_is_probe_resp(fc) && + !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) + tx_flags |= TX_CMD_FLG_TSF_MSK; + } else { + tx_flags &= (~TX_CMD_FLG_ACK_MSK); + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + if (ieee80211_is_back_req(fc)) + tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; + + tx_cmd->sta_id = std_id; + if (ieee80211_has_morefrags(fc)) + tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; + + if (ieee80211_is_data_qos(fc)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tx_cmd->tid_tspec = qc[0] & 0xf; + tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; + } else { + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + il_tx_cmd_protection(il, info, fc, &tx_flags); + + tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); + if (ieee80211_is_mgmt(fc)) { + if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); + else + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); + } else { + tx_cmd->timeout.pm_frame_timeout = 0; + } + + tx_cmd->driver_txop = 0; + tx_cmd->tx_flags = tx_flags; + tx_cmd->next_frame_len = 0; +} + +#define RTS_DFAULT_RETRY_LIMIT 60 + +static void il4965_tx_cmd_build_rate(struct il_priv *il, + struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, + __le16 fc) +{ + u32 rate_flags; + int rate_idx; + u8 rts_retry_limit; + u8 data_retry_limit; + u8 rate_plcp; + + /* Set retry limit on DATA packets and Probe Responses*/ + if (ieee80211_is_probe_resp(fc)) + data_retry_limit = 3; + else + data_retry_limit = IL4965_DEFAULT_TX_RETRY; + tx_cmd->data_retry_limit = data_retry_limit; + + /* Set retry limit on RTS packets */ + rts_retry_limit = RTS_DFAULT_RETRY_LIMIT; + if (data_retry_limit < rts_retry_limit) + rts_retry_limit = data_retry_limit; + tx_cmd->rts_retry_limit = rts_retry_limit; + + /* DATA packets will use the uCode station table for rate/antenna + * selection */ + if (ieee80211_is_data(fc)) { + tx_cmd->initial_rate_idx = 0; + tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; + return; + } + + /** + * If the current TX rate stored in mac80211 has the MCS bit set, it's + * not really a TX rate. Thus, we use the lowest supported rate for + * this band. Also use the lowest supported rate if the stored rate + * idx is invalid. + */ + rate_idx = info->control.rates[0].idx; + if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || + rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) + rate_idx = rate_lowest_index(&il->bands[info->band], + info->control.sta); + /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ + if (info->band == IEEE80211_BAND_5GHZ) + rate_idx += IL_FIRST_OFDM_RATE; + /* Get PLCP rate for tx_cmd->rate_n_flags */ + rate_plcp = il_rates[rate_idx].plcp; + /* Zero out flags for this packet */ + rate_flags = 0; + + /* Set CCK flag as needed */ + if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE) + rate_flags |= RATE_MCS_CCK_MSK; + + /* Set up antennas */ + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); + + rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); + + /* Set the rate in the TX cmd */ + tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); +} + +static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, + struct ieee80211_tx_info *info, + struct il_tx_cmd *tx_cmd, + struct sk_buff *skb_frag, + int sta_id) +{ + struct ieee80211_key_conf *keyconf = info->control.hw_key; + + switch (keyconf->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + tx_cmd->sec_ctl = TX_CMD_SEC_CCM; + memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); + if (info->flags & IEEE80211_TX_CTL_AMPDU) + tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; + D_TX("tx_cmd with AES hwcrypto\n"); + break; + + case WLAN_CIPHER_SUITE_TKIP: + tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; + ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); + D_TX("tx_cmd with tkip hwcrypto\n"); + break; + + case WLAN_CIPHER_SUITE_WEP104: + tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; + /* fall through */ + case WLAN_CIPHER_SUITE_WEP40: + tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | + (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); + + memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); + + D_TX("Configuring packet for WEP encryption " + "with key %d\n", keyconf->keyidx); + break; + + default: + IL_ERR("Unknown encode cipher %x\n", keyconf->cipher); + break; + } +} + +/* + * start REPLY_TX command process + */ +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_sta *sta = info->control.sta; + struct il_station_priv *sta_priv = NULL; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + struct il_tx_cmd *tx_cmd; + struct il_rxon_context *ctx = &il->ctx; + int txq_id; + dma_addr_t phys_addr; + dma_addr_t txcmd_phys; + dma_addr_t scratch_phys; + u16 len, firstlen, secondlen; + u16 seq_number = 0; + __le16 fc; + u8 hdr_len; + u8 sta_id; + u8 wait_write_ptr = 0; + u8 tid = 0; + u8 *qc = NULL; + unsigned long flags; + bool is_agg = false; + + if (info->control.vif) + ctx = il_rxon_ctx_from_vif(info->control.vif); + + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + D_DROP("Dropping - RF KILL\n"); + goto drop_unlock; + } + + fc = hdr->frame_control; + +#ifdef CONFIG_IWLEGACY_DEBUG + if (ieee80211_is_auth(fc)) + D_TX("Sending AUTH frame\n"); + else if (ieee80211_is_assoc_req(fc)) + D_TX("Sending ASSOC frame\n"); + else if (ieee80211_is_reassoc_req(fc)) + D_TX("Sending REASSOC frame\n"); +#endif + + hdr_len = ieee80211_hdrlen(fc); + + /* For management frames use broadcast id to do not break aggregation */ + if (!ieee80211_is_data(fc)) + sta_id = ctx->bcast_sta_id; + else { + /* Find idx into station table for destination station */ + sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); + + if (sta_id == IL_INVALID_STATION) { + D_DROP("Dropping - INVALID STATION: %pM\n", + hdr->addr1); + goto drop_unlock; + } + } + + D_TX("station Id %d\n", sta_id); + + if (sta) + sta_priv = (void *)sta->drv_priv; + + if (sta_priv && sta_priv->asleep && + (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) { + /* + * This sends an asynchronous command to the device, + * but we can rely on it being processed before the + * next frame is processed -- and the next frame to + * this station is the one that will consume this + * counter. + * For now set the counter to just 1 since we do not + * support uAPSD yet. + */ + il4965_sta_modify_sleep_tx_count(il, sta_id, 1); + } + + /* + * Send this frame after DTIM -- there's a special queue + * reserved for this for contexts that support AP mode. + */ + if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { + txq_id = ctx->mcast_queue; + /* + * The microcode will clear the more data + * bit in the last frame it transmits. + */ + hdr->frame_control |= + cpu_to_le16(IEEE80211_FCTL_MOREDATA); + } else + txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; + + /* irqs already disabled/saved above when locking il->lock */ + spin_lock(&il->sta_lock); + + if (ieee80211_is_data_qos(fc)) { + qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; + if (WARN_ON_ONCE(tid >= MAX_TID_COUNT)) { + spin_unlock(&il->sta_lock); + goto drop_unlock; + } + seq_number = il->stations[sta_id].tid[tid].seq_number; + seq_number &= IEEE80211_SCTL_SEQ; + hdr->seq_ctrl = hdr->seq_ctrl & + cpu_to_le16(IEEE80211_SCTL_FRAG); + hdr->seq_ctrl |= cpu_to_le16(seq_number); + seq_number += 0x10; + /* aggregation is on for this */ + if (info->flags & IEEE80211_TX_CTL_AMPDU && + il->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { + txq_id = il->stations[sta_id].tid[tid].agg.txq_id; + is_agg = true; + } + } + + txq = &il->txq[txq_id]; + q = &txq->q; + + if (unlikely(il_queue_space(q) < q->high_mark)) { + spin_unlock(&il->sta_lock); + goto drop_unlock; + } + + if (ieee80211_is_data_qos(fc)) { + il->stations[sta_id].tid[tid].tfds_in_queue++; + if (!ieee80211_has_morefrags(fc)) + il->stations[sta_id].tid[tid].seq_number = seq_number; + } + + spin_unlock(&il->sta_lock); + + /* Set up driver data for this TFD */ + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); + txq->txb[q->write_ptr].skb = skb; + txq->txb[q->write_ptr].ctx = ctx; + + /* Set up first empty entry in queue's array of Tx/cmd buffers */ + out_cmd = txq->cmd[q->write_ptr]; + out_meta = &txq->meta[q->write_ptr]; + tx_cmd = &out_cmd->cmd.tx; + memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); + memset(tx_cmd, 0, sizeof(struct il_tx_cmd)); + + /* + * Set up the Tx-command (not MAC!) header. + * Store the chosen Tx queue and TFD idx within the sequence field; + * after Tx, uCode's Tx response will return this value so driver can + * locate the frame within the tx queue and do post-tx processing. + */ + out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | + IDX_TO_SEQ(q->write_ptr))); + + /* Copy MAC header from skb into command buffer */ + memcpy(tx_cmd->hdr, hdr, hdr_len); + + + /* Total # bytes to be transmitted */ + len = (u16)skb->len; + tx_cmd->len = cpu_to_le16(len); + + if (info->control.hw_key) + il4965_tx_cmd_build_hwcrypto(il, info, tx_cmd, skb, sta_id); + + /* TODO need this for burst mode later on */ + il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id); + il_dbg_log_tx_data_frame(il, len, hdr); + + il4965_tx_cmd_build_rate(il, tx_cmd, info, fc); + + il_update_stats(il, true, fc, len); + /* + * Use the first empty entry in this queue's command buffer array + * to contain the Tx command and MAC header concatenated together + * (payload data will be in another buffer). + * Size of this varies, due to varying MAC header length. + * If end is not dword aligned, we'll have 2 extra bytes at the end + * of the MAC header (device reads on dword boundaries). + * We'll tell device about this padding later. + */ + len = sizeof(struct il_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; + firstlen = (len + 3) & ~3; + + /* Tell NIC about any 2-byte padding after MAC header */ + if (firstlen != len) + tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK; + + /* Physical address of this Tx command's header (not MAC header!), + * within command buffer array. */ + txcmd_phys = pci_map_single(il->pci_dev, + &out_cmd->hdr, firstlen, + PCI_DMA_BIDIRECTIONAL); + dma_unmap_addr_set(out_meta, mapping, txcmd_phys); + dma_unmap_len_set(out_meta, len, firstlen); + /* Add buffer containing Tx command and MAC(!) header to TFD's + * first entry */ + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + txcmd_phys, firstlen, 1, 0); + + if (!ieee80211_has_morefrags(hdr->frame_control)) { + txq->need_update = 1; + } else { + wait_write_ptr = 1; + txq->need_update = 0; + } + + /* Set up TFD's 2nd entry to point directly to remainder of skb, + * if any (802.11 null frames have no payload). */ + secondlen = skb->len - hdr_len; + if (secondlen > 0) { + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, + secondlen, PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + phys_addr, secondlen, + 0, 0); + } + + scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + + offsetof(struct il_tx_cmd, scratch); + + /* take back ownership of DMA buffer to enable update */ + pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, + firstlen, PCI_DMA_BIDIRECTIONAL); + tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); + tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); + + D_TX("sequence nr = 0X%x\n", + le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + + /* Set up entry for this TFD in Tx byte-count array */ + if (info->flags & IEEE80211_TX_CTL_AMPDU) + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, + le16_to_cpu(tx_cmd->len)); + + pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, + firstlen, PCI_DMA_BIDIRECTIONAL); + + /* Tell device the write idx *just past* this latest filled TFD */ + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + + /* + * At this point the frame is "transmitted" successfully + * and we will get a TX status notification eventually, + * regardless of the value of ret. "ret" only indicates + * whether or not we should update the write pointer. + */ + + /* + * Avoid atomic ops if it isn't an associated client. + * Also, if this is a packet for aggregation, don't + * increase the counter because the ucode will stop + * aggregation queues when their respective station + * goes to sleep. + */ + if (sta_priv && sta_priv->client && !is_agg) + atomic_inc(&sta_priv->pending_frames); + + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { + if (wait_write_ptr) { + spin_lock_irqsave(&il->lock, flags); + txq->need_update = 1; + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + } else { + il_stop_queue(il, txq); + } + } + + return 0; + +drop_unlock: + spin_unlock_irqrestore(&il->lock, flags); + return -1; +} + +static inline int il4965_alloc_dma_ptr(struct il_priv *il, + struct il_dma_ptr *ptr, size_t size) +{ + ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, + GFP_KERNEL); + if (!ptr->addr) + return -ENOMEM; + ptr->size = size; + return 0; +} + +static inline void il4965_free_dma_ptr(struct il_priv *il, + struct il_dma_ptr *ptr) +{ + if (unlikely(!ptr->addr)) + return; + + dma_free_coherent(&il->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); + memset(ptr, 0, sizeof(*ptr)); +} + +/** + * il4965_hw_txq_ctx_free - Free TXQ Context + * + * Destroy all TX DMA queues and structures + */ +void il4965_hw_txq_ctx_free(struct il_priv *il) +{ + int txq_id; + + /* Tx queues */ + if (il->txq) { + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_free(il); + else + il_tx_queue_free(il, txq_id); + } + il4965_free_dma_ptr(il, &il->kw); + + il4965_free_dma_ptr(il, &il->scd_bc_tbls); + + /* free tx queue structure */ + il_txq_mem(il); +} + +/** + * il4965_txq_ctx_alloc - allocate TX queue context + * Allocate all Tx DMA structures and initialize them + * + * @param il + * @return error code + */ +int il4965_txq_ctx_alloc(struct il_priv *il) +{ + int ret; + int txq_id, slots_num; + unsigned long flags; + + /* Free all tx/cmd queues and keep-warm buffer */ + il4965_hw_txq_ctx_free(il); + + ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, + il->hw_params.scd_bc_tbls_size); + if (ret) { + IL_ERR("Scheduler BC Table allocation failed\n"); + goto error_bc_tbls; + } + /* Alloc keep-warm buffer */ + ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); + if (ret) { + IL_ERR("Keep Warm allocation failed\n"); + goto error_kw; + } + + /* allocate tx queue structure */ + ret = il_alloc_txq_mem(il); + if (ret) + goto error; + + spin_lock_irqsave(&il->lock, flags); + + /* Turn off all Tx DMA fifos */ + il4965_txq_set_sched(il, 0); + + /* Tell NIC where to find the "keep warm" buffer */ + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + + spin_unlock_irqrestore(&il->lock, flags); + + /* Alloc and init all Tx queues, including the command queue (#4/#9) */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = (txq_id == il->cmd_queue) ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + ret = il_tx_queue_init(il, + &il->txq[txq_id], slots_num, + txq_id); + if (ret) { + IL_ERR("Tx %d queue init failed\n", txq_id); + goto error; + } + } + + return ret; + + error: + il4965_hw_txq_ctx_free(il); + il4965_free_dma_ptr(il, &il->kw); + error_kw: + il4965_free_dma_ptr(il, &il->scd_bc_tbls); + error_bc_tbls: + return ret; +} + +void il4965_txq_ctx_reset(struct il_priv *il) +{ + int txq_id, slots_num; + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + + /* Turn off all Tx DMA fifos */ + il4965_txq_set_sched(il, 0); + + /* Tell NIC where to find the "keep warm" buffer */ + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + + spin_unlock_irqrestore(&il->lock, flags); + + /* Alloc and init all Tx queues, including the command queue (#4) */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = txq_id == il->cmd_queue ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + il_tx_queue_reset(il, &il->txq[txq_id], + slots_num, txq_id); + } +} + +/** + * il4965_txq_ctx_stop - Stop all Tx DMA channels + */ +void il4965_txq_ctx_stop(struct il_priv *il) +{ + int ch, txq_id; + unsigned long flags; + + /* Turn off all Tx DMA fifos */ + spin_lock_irqsave(&il->lock, flags); + + il4965_txq_set_sched(il, 0); + + /* Stop each Tx DMA channel, and wait for it to be idle */ + for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { + il_wr(il, + FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); + if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, + FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), + 1000)) + IL_ERR("Failing on timeout while stopping" + " DMA channel %d [0x%08x]", ch, + il_rd(il, + FH_TSSR_TX_STATUS_REG)); + } + spin_unlock_irqrestore(&il->lock, flags); + + if (!il->txq) + return; + + /* Unmap DMA from host system and free skb's */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_unmap(il); + else + il_tx_queue_unmap(il, txq_id); +} + +/* + * Find first available (lowest unused) Tx Queue, mark it "active". + * Called only when finding queue for aggregation. + * Should never return anything < 7, because they should already + * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) + */ +static int il4965_txq_ctx_activate_free(struct il_priv *il) +{ + int txq_id; + + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) + return txq_id; + return -1; +} + +/** + * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration + */ +static void il4965_tx_queue_stop_scheduler(struct il_priv *il, + u16 txq_id) +{ + /* Simply stop the queue, but don't change any configuration; + * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ + il_wr_prph(il, + IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| + (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); +} + +/** + * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue + */ +static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, + u16 txq_id) +{ + u32 tbl_dw_addr; + u32 tbl_dw; + u16 scd_q2ratid; + + scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; + + tbl_dw_addr = il->scd_base_addr + + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); + + tbl_dw = il_read_targ_mem(il, tbl_dw_addr); + + if (txq_id & 0x1) + tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); + else + tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); + + il_write_targ_mem(il, tbl_dw_addr, tbl_dw); + + return 0; +} + +/** + * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue + * + * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, + * i.e. it must be one of the higher queues used for aggregation + */ +static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, + int tx_fifo, int sta_id, int tid, u16 ssn_idx) +{ + unsigned long flags; + u16 ra_tid; + int ret; + + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN( + "queue number out of range: %d, must be %d to %d\n", + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues - 1); + return -EINVAL; + } + + ra_tid = BUILD_RAxTID(sta_id, tid); + + /* Modify device's station table to Tx this TID */ + ret = il4965_sta_tx_modify_enable_tid(il, sta_id, tid); + if (ret) + return ret; + + spin_lock_irqsave(&il->lock, flags); + + /* Stop this Tx queue before configuring it */ + il4965_tx_queue_stop_scheduler(il, txq_id); + + /* Map receiver-address / traffic-ID to this queue */ + il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); + + /* Set this queue as a chain-building queue */ + il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + + /* Place first TFD at idx corresponding to start sequence number. + * Assumes that ssn_idx is valid (!= 0xFFF) */ + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + il4965_set_wr_ptrs(il, txq_id, ssn_idx); + + /* Set up Tx win size and frame limit for this queue */ + il_write_targ_mem(il, + il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + + il_write_targ_mem(il, il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), + (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) + & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + + il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + + /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); + + spin_unlock_irqrestore(&il->lock, flags); + + return 0; +} + + +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 *ssn) +{ + int sta_id; + int tx_fifo; + int txq_id; + int ret; + unsigned long flags; + struct il_tid_data *tid_data; + + tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); + if (unlikely(tx_fifo < 0)) + return tx_fifo; + + IL_WARN("%s on ra = %pM tid = %d\n", + __func__, sta->addr, tid); + + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Start AGG on invalid station\n"); + return -ENXIO; + } + if (unlikely(tid >= MAX_TID_COUNT)) + return -EINVAL; + + if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { + IL_ERR("Start AGG when state is not IL_AGG_OFF !\n"); + return -ENXIO; + } + + txq_id = il4965_txq_ctx_activate_free(il); + if (txq_id == -1) { + IL_ERR("No free aggregation queue available\n"); + return -ENXIO; + } + + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; + *ssn = SEQ_TO_SN(tid_data->seq_number); + tid_data->agg.txq_id = txq_id; + il_set_swq_id(&il->txq[txq_id], + il4965_get_ac_from_tid(tid), txq_id); + spin_unlock_irqrestore(&il->sta_lock, flags); + + ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, + sta_id, tid, *ssn); + if (ret) + return ret; + + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; + if (tid_data->tfds_in_queue == 0) { + D_HT("HW queue is empty\n"); + tid_data->agg.state = IL_AGG_ON; + ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); + } else { + D_HT( + "HW queue is NOT empty: %d packets in HW queue\n", + tid_data->tfds_in_queue); + tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; + } + spin_unlock_irqrestore(&il->sta_lock, flags); + return ret; +} + +/** + * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE + * il->lock must be held by the caller + */ +static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, + u16 ssn_idx, u8 tx_fifo) +{ + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN( + "queue number out of range: %d, must be %d to %d\n", + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues - 1); + return -EINVAL; + } + + il4965_tx_queue_stop_scheduler(il, txq_id); + + il_clear_bits_prph(il, + IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + /* supposes that ssn_idx is valid (!= 0xFFF) */ + il4965_set_wr_ptrs(il, txq_id, ssn_idx); + + il_clear_bits_prph(il, + IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_txq_ctx_deactivate(il, txq_id); + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); + + return 0; +} + +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid) +{ + int tx_fifo_id, txq_id, sta_id, ssn; + struct il_tid_data *tid_data; + int write_ptr, read_ptr; + unsigned long flags; + + tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); + if (unlikely(tx_fifo_id < 0)) + return tx_fifo_id; + + sta_id = il_sta_id(sta); + + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Invalid station for AGG tid %d\n", tid); + return -ENXIO; + } + + spin_lock_irqsave(&il->sta_lock, flags); + + tid_data = &il->stations[sta_id].tid[tid]; + ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; + txq_id = tid_data->agg.txq_id; + + switch (il->stations[sta_id].tid[tid].agg.state) { + case IL_EMPTYING_HW_QUEUE_ADDBA: + /* + * This can happen if the peer stops aggregation + * again before we've had a chance to drain the + * queue we selected previously, i.e. before the + * session was really started completely. + */ + D_HT("AGG stop before setup done\n"); + goto turn_off; + case IL_AGG_ON: + break; + default: + IL_WARN("Stopping AGG while state not ON or starting\n"); + } + + write_ptr = il->txq[txq_id].q.write_ptr; + read_ptr = il->txq[txq_id].q.read_ptr; + + /* The queue is not empty */ + if (write_ptr != read_ptr) { + D_HT("Stopping a non empty AGG HW QUEUE\n"); + il->stations[sta_id].tid[tid].agg.state = + IL_EMPTYING_HW_QUEUE_DELBA; + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + + D_HT("HW queue is empty\n"); + turn_off: + il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; + + /* do not restore/save irqs */ + spin_unlock(&il->sta_lock); + spin_lock(&il->lock); + + /* + * the only reason this call can fail is queue number out of range, + * which can happen if uCode is reloaded and all the station + * information are lost. if it is outside the range, there is no need + * to deactivate the uCode queue, just return "success" to allow + * mac80211 to clean up it own data. + */ + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo_id); + spin_unlock_irqrestore(&il->lock, flags); + + ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); + + return 0; +} + +int il4965_txq_check_empty(struct il_priv *il, + int sta_id, u8 tid, int txq_id) +{ + struct il_queue *q = &il->txq[txq_id].q; + u8 *addr = il->stations[sta_id].sta.sta.addr; + struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; + struct il_rxon_context *ctx; + + ctx = &il->ctx; + + lockdep_assert_held(&il->sta_lock); + + switch (il->stations[sta_id].tid[tid].agg.state) { + case IL_EMPTYING_HW_QUEUE_DELBA: + /* We are reclaiming the last packet of the */ + /* aggregated HW queue */ + if (txq_id == tid_data->agg.txq_id && + q->read_ptr == q->write_ptr) { + u16 ssn = SEQ_TO_SN(tid_data->seq_number); + int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); + D_HT( + "HW queue empty: continue DELBA flow\n"); + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); + tid_data->agg.state = IL_AGG_OFF; + ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); + } + break; + case IL_EMPTYING_HW_QUEUE_ADDBA: + /* We are reclaiming the last packet of the queue */ + if (tid_data->tfds_in_queue == 0) { + D_HT( + "HW queue empty: continue ADDBA flow\n"); + tid_data->agg.state = IL_AGG_ON; + ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); + } + break; + } + + return 0; +} + +static void il4965_non_agg_tx_status(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr1) +{ + struct ieee80211_sta *sta; + struct il_station_priv *sta_priv; + + rcu_read_lock(); + sta = ieee80211_find_sta(ctx->vif, addr1); + if (sta) { + sta_priv = (void *)sta->drv_priv; + /* avoid atomic ops if this isn't a client */ + if (sta_priv->client && + atomic_dec_return(&sta_priv->pending_frames) == 0) + ieee80211_sta_block_awake(il->hw, sta, false); + } + rcu_read_unlock(); +} + +static void +il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, + bool is_agg) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; + + if (!is_agg) + il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); + + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); +} + +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; + int nfreed = 0; + struct ieee80211_hdr *hdr; + + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " + "is out of range [0-%d] %d %d.\n", txq_id, + idx, q->n_bd, q->write_ptr, q->read_ptr); + return 0; + } + + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + + tx_info = &txq->txb[txq->q.read_ptr]; + + if (WARN_ON_ONCE(tx_info->skb == NULL)) + continue; + + hdr = (struct ieee80211_hdr *)tx_info->skb->data; + if (ieee80211_is_data_qos(hdr->frame_control)) + nfreed++; + + il4965_tx_status(il, tx_info, + txq_id >= IL4965_FIRST_AMPDU_QUEUE); + tx_info->skb = NULL; + + il->cfg->ops->lib->txq_free_tfd(il, txq); + } + return nfreed; +} + +/** + * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack + * + * Go through block-ack's bitmap of ACK'd frames, update driver's record of + * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. + */ +static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, + struct il_ht_agg *agg, + struct il_compressed_ba_resp *ba_resp) + +{ + int i, sh, ack; + u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl); + u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); + int successes = 0; + struct ieee80211_tx_info *info; + u64 bitmap, sent_bitmap; + + if (unlikely(!agg->wait_for_ba)) { + if (unlikely(ba_resp->bitmap)) + IL_ERR("Received BA when not expected\n"); + return -EINVAL; + } + + /* Mark that the expected block-ack response arrived */ + agg->wait_for_ba = 0; + D_TX_REPLY("BA %d %d\n", agg->start_idx, + ba_resp->seq_ctl); + + /* Calculate shift to align block-ack bits with our Tx win bits */ + sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); + if (sh < 0) /* tbw something is wrong with indices */ + sh += 0x100; + + if (agg->frame_count > (64 - sh)) { + D_TX_REPLY("more frames than bitmap size"); + return -1; + } + + /* don't use 64-bit values for now */ + bitmap = le64_to_cpu(ba_resp->bitmap) >> sh; + + /* check for success or failure according to the + * transmitted bitmap and block-ack bitmap */ + sent_bitmap = bitmap & agg->bitmap; + + /* For each frame attempted in aggregation, + * update driver's record of tx frame's status. */ + i = 0; + while (sent_bitmap) { + ack = sent_bitmap & 1ULL; + successes += ack; + D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", + ack ? "ACK" : "NACK", i, + (agg->start_idx + i) & 0xff, + agg->start_idx + i); + sent_bitmap >>= 1; + ++i; + } + + D_TX_REPLY("Bitmap %llx\n", + (unsigned long long)bitmap); + + info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); + memset(&info->status, 0, sizeof(info->status)); + info->flags |= IEEE80211_TX_STAT_ACK; + info->flags |= IEEE80211_TX_STAT_AMPDU; + info->status.ampdu_ack_len = successes; + info->status.ampdu_len = agg->frame_count; + il4965_hwrate_to_tx_control(il, agg->rate_n_flags, info); + + return 0; +} + +/** + * translate ucode response to mac80211 tx status control values + */ +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, + struct ieee80211_tx_info *info) +{ + struct ieee80211_tx_rate *r = &info->control.rates[0]; + + info->antenna_sel_tx = + ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); + if (rate_n_flags & RATE_MCS_HT_MSK) + r->flags |= IEEE80211_TX_RC_MCS; + if (rate_n_flags & RATE_MCS_GF_MSK) + r->flags |= IEEE80211_TX_RC_GREEN_FIELD; + if (rate_n_flags & RATE_MCS_HT40_MSK) + r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; + if (rate_n_flags & RATE_MCS_DUP_MSK) + r->flags |= IEEE80211_TX_RC_DUP_DATA; + if (rate_n_flags & RATE_MCS_SGI_MSK) + r->flags |= IEEE80211_TX_RC_SHORT_GI; + r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); +} + +/** + * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA + * + * Handles block-acknowledge notification from device, which reports success + * of frames sent via aggregation. + */ +void il4965_rx_reply_compressed_ba(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; + struct il_tx_queue *txq = NULL; + struct il_ht_agg *agg; + int idx; + int sta_id; + int tid; + unsigned long flags; + + /* "flow" corresponds to Tx queue */ + u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); + + /* "ssn" is start of block-ack Tx win, corresponds to idx + * (in Tx queue's circular buffer) of first TFD/frame in win */ + u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); + + if (scd_flow >= il->hw_params.max_txq_num) { + IL_ERR( + "BUG_ON scd_flow is bigger than number of queues\n"); + return; + } + + txq = &il->txq[scd_flow]; + sta_id = ba_resp->sta_id; + tid = ba_resp->tid; + agg = &il->stations[sta_id].tid[tid].agg; + if (unlikely(agg->txq_id != scd_flow)) { + /* + * FIXME: this is a uCode bug which need to be addressed, + * log the information and return for now! + * since it is possible happen very often and in order + * not to fill the syslog, don't enable the logging by default + */ + D_TX_REPLY( + "BA scd_flow %d does not match txq_id %d\n", + scd_flow, agg->txq_id); + return; + } + + /* Find idx just before block-ack win */ + idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); + + spin_lock_irqsave(&il->sta_lock, flags); + + D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " + "sta_id = %d\n", + agg->wait_for_ba, + (u8 *) &ba_resp->sta_addr_lo32, + ba_resp->sta_id); + D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," + "scd_flow = " + "%d, scd_ssn = %d\n", + ba_resp->tid, + ba_resp->seq_ctl, + (unsigned long long)le64_to_cpu(ba_resp->bitmap), + ba_resp->scd_flow, + ba_resp->scd_ssn); + D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", + agg->start_idx, + (unsigned long long)agg->bitmap); + + /* Update driver's record of ACK vs. not for each frame in win */ + il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); + + /* Release all TFDs before the SSN, i.e. all TFDs in front of + * block-ack win (we assume that they've been successfully + * transmitted ... if not, it's too late anyway). */ + if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { + /* calculate mac80211 ampdu sw queue to wake */ + int freed = il4965_tx_queue_reclaim(il, scd_flow, idx); + il4965_free_tfds_in_queue(il, sta_id, tid, freed); + + if (il_queue_space(&txq->q) > txq->q.low_mark && + il->mac80211_registered && + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) + il_wake_queue(il, txq); + + il4965_txq_check_empty(il, sta_id, tid, scd_flow); + } + + spin_unlock_irqrestore(&il->sta_lock, flags); +} + +#ifdef CONFIG_IWLEGACY_DEBUG +const char *il4965_get_tx_fail_reason(u32 status) +{ +#define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x +#define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x + + switch (status & TX_STATUS_MSK) { + case TX_STATUS_SUCCESS: + return "SUCCESS"; + TX_STATUS_POSTPONE(DELAY); + TX_STATUS_POSTPONE(FEW_BYTES); + TX_STATUS_POSTPONE(QUIET_PERIOD); + TX_STATUS_POSTPONE(CALC_TTAK); + TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); + TX_STATUS_FAIL(SHORT_LIMIT); + TX_STATUS_FAIL(LONG_LIMIT); + TX_STATUS_FAIL(FIFO_UNDERRUN); + TX_STATUS_FAIL(DRAIN_FLOW); + TX_STATUS_FAIL(RFKILL_FLUSH); + TX_STATUS_FAIL(LIFE_EXPIRE); + TX_STATUS_FAIL(DEST_PS); + TX_STATUS_FAIL(HOST_ABORTED); + TX_STATUS_FAIL(BT_RETRY); + TX_STATUS_FAIL(STA_INVALID); + TX_STATUS_FAIL(FRAG_DROPPED); + TX_STATUS_FAIL(TID_DISABLE); + TX_STATUS_FAIL(FIFO_FLUSHED); + TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); + TX_STATUS_FAIL(PASSIVE_NO_RX); + TX_STATUS_FAIL(NO_BEACON_ON_RADAR); + } + + return "UNKNOWN"; + +#undef TX_STATUS_FAIL +#undef TX_STATUS_POSTPONE +} +#endif /* CONFIG_IWLEGACY_DEBUG */ + static struct il_link_quality_cmd * il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) { diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 0643fda0..8844704 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -9,8 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-tx.o -iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o +iwl4965-objs += iwl-4965-lib.o iwl-4965-calib.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c deleted file mode 100644 index b322957..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ /dev/null @@ -1,215 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-4965-calib.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" - -void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) - -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_missed_beacon_notif *missed_beacon; - - missed_beacon = &pkt->u.missed_beacon; - if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > - il->missed_beacon_threshold) { - D_CALIB( - "missed bcn cnsq %d totl %d rcd %d expctd %d\n", - le32_to_cpu(missed_beacon->consecutive_missed_beacons), - le32_to_cpu(missed_beacon->total_missed_becons), - le32_to_cpu(missed_beacon->num_recvd_beacons), - le32_to_cpu(missed_beacon->num_expected_beacons)); - if (!test_bit(STATUS_SCANNING, &il->status)) - il4965_init_sensitivity(il); - } -} - -/* Calculate noise level, based on measurements during network silence just - * before arriving beacon. This measurement can be done only if we know - * exactly when to expect beacons, therefore only when we're associated. */ -static void il4965_rx_calc_noise(struct il_priv *il) -{ - struct stats_rx_non_phy *rx_info; - int num_active_rx = 0; - int total_silence = 0; - int bcn_silence_a, bcn_silence_b, bcn_silence_c; - int last_rx_noise; - - rx_info = &(il->_4965.stats.rx.general); - bcn_silence_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; - bcn_silence_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; - bcn_silence_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; - - if (bcn_silence_a) { - total_silence += bcn_silence_a; - num_active_rx++; - } - if (bcn_silence_b) { - total_silence += bcn_silence_b; - num_active_rx++; - } - if (bcn_silence_c) { - total_silence += bcn_silence_c; - num_active_rx++; - } - - /* Average among active antennas */ - if (num_active_rx) - last_rx_noise = (total_silence / num_active_rx) - 107; - else - last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - - D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", - bcn_silence_a, bcn_silence_b, bcn_silence_c, - last_rx_noise); -} - -#ifdef CONFIG_IWLEGACY_DEBUGFS -/* - * based on the assumption of all stats counter are in DWORD - * FIXME: This function is for debugging, do not deal with - * the case of counters roll-over. - */ -static void il4965_accumulative_stats(struct il_priv *il, - __le32 *stats) -{ - int i, size; - __le32 *prev_stats; - u32 *accum_stats; - u32 *delta, *max_delta; - struct stats_general_common *general, *accum_general; - struct stats_tx *tx, *accum_tx; - - prev_stats = (__le32 *)&il->_4965.stats; - accum_stats = (u32 *)&il->_4965.accum_stats; - size = sizeof(struct il_notif_stats); - general = &il->_4965.stats.general.common; - accum_general = &il->_4965.accum_stats.general.common; - tx = &il->_4965.stats.tx; - accum_tx = &il->_4965.accum_stats.tx; - delta = (u32 *)&il->_4965.delta_stats; - max_delta = (u32 *)&il->_4965.max_delta; - - for (i = sizeof(__le32); i < size; - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { - if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); - *accum_stats += *delta; - if (*delta > *max_delta) - *max_delta = *delta; - } - } - - /* reset accumulative stats for "no-counter" type stats */ - accum_general->temperature = general->temperature; - accum_general->ttl_timestamp = general->ttl_timestamp; -} -#endif - -#define REG_RECALIB_PERIOD (60) - -void il4965_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - int change; - struct il_rx_pkt *pkt = rxb_addr(rxb); - - D_RX( - "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il_notif_stats), - le32_to_cpu(pkt->len_n_flags) & - FH_RSCSR_FRAME_SIZE_MSK); - - change = ((il->_4965.stats.general.common.temperature != - pkt->u.stats.general.common.temperature) || - ((il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK) != - (pkt->u.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK))); -#ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); -#endif - - /* TODO: reading some of stats is unneeded */ - memcpy(&il->_4965.stats, &pkt->u.stats, - sizeof(il->_4965.stats)); - - set_bit(STATUS_STATISTICS, &il->status); - - /* Reschedule the stats timer to occur in - * REG_RECALIB_PERIOD seconds to ensure we get a - * thermal update even if the uCode doesn't give - * us one */ - mod_timer(&il->stats_periodic, jiffies + - msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); - - if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && - (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { - il4965_rx_calc_noise(il); - queue_work(il->workqueue, &il->run_time_calib_work); - } - if (il->cfg->ops->lib->temp_ops.temperature && change) - il->cfg->ops->lib->temp_ops.temperature(il); -} - -void il4965_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - - if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_4965.accum_stats, 0, - sizeof(struct il_notif_stats)); - memset(&il->_4965.delta_stats, 0, - sizeof(struct il_notif_stats)); - memset(&il->_4965.max_delta, 0, - sizeof(struct il_notif_stats)); -#endif - D_RX("Statistics have been cleared\n"); - } - il4965_rx_stats(il, rxb); -} diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c deleted file mode 100644 index a6fa1c2..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ /dev/null @@ -1,1371 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" - -/* - * mac80211 queues, ACs, hardware queues, FIFOs. - * - * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues - * - * Mac80211 uses the following numbers, which we get as from it - * by way of skb_get_queue_mapping(skb): - * - * VO 0 - * VI 1 - * BE 2 - * BK 3 - * - * - * Regular (not A-MPDU) frames are put into hardware queues corresponding - * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their - * own queue per aggregation session (RA/TID combination), such queues are - * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In - * order to map frames to the right queue, we also need an AC->hw queue - * mapping. This is implemented here. - * - * Due to the way hw queues are set up (by the hw specific modules like - * iwl-4965.c), the AC->hw queue mapping is the identity - * mapping. - */ - -static const u8 tid_to_ac[] = { - IEEE80211_AC_BE, - IEEE80211_AC_BK, - IEEE80211_AC_BK, - IEEE80211_AC_BE, - IEEE80211_AC_VI, - IEEE80211_AC_VI, - IEEE80211_AC_VO, - IEEE80211_AC_VO -}; - -static inline int il4965_get_ac_from_tid(u16 tid) -{ - if (likely(tid < ARRAY_SIZE(tid_to_ac))) - return tid_to_ac[tid]; - - /* no support for TIDs 8-15 yet */ - return -EINVAL; -} - -static inline int -il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) -{ - if (likely(tid < ARRAY_SIZE(tid_to_ac))) - return ctx->ac_to_fifo[tid_to_ac[tid]]; - - /* no support for TIDs 8-15 yet */ - return -EINVAL; -} - -/* - * handle build REPLY_TX command notification. - */ -static void il4965_tx_cmd_build_basic(struct il_priv *il, - struct sk_buff *skb, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - u8 std_id) -{ - __le16 fc = hdr->frame_control; - __le32 tx_flags = tx_cmd->tx_flags; - - tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { - tx_flags |= TX_CMD_FLG_ACK_MSK; - if (ieee80211_is_mgmt(fc)) - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - if (ieee80211_is_probe_resp(fc) && - !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) - tx_flags |= TX_CMD_FLG_TSF_MSK; - } else { - tx_flags &= (~TX_CMD_FLG_ACK_MSK); - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - if (ieee80211_is_back_req(fc)) - tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; - - tx_cmd->sta_id = std_id; - if (ieee80211_has_morefrags(fc)) - tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; - - if (ieee80211_is_data_qos(fc)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tx_cmd->tid_tspec = qc[0] & 0xf; - tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; - } else { - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - il_tx_cmd_protection(il, info, fc, &tx_flags); - - tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); - if (ieee80211_is_mgmt(fc)) { - if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); - else - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); - } else { - tx_cmd->timeout.pm_frame_timeout = 0; - } - - tx_cmd->driver_txop = 0; - tx_cmd->tx_flags = tx_flags; - tx_cmd->next_frame_len = 0; -} - -#define RTS_DFAULT_RETRY_LIMIT 60 - -static void il4965_tx_cmd_build_rate(struct il_priv *il, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - __le16 fc) -{ - u32 rate_flags; - int rate_idx; - u8 rts_retry_limit; - u8 data_retry_limit; - u8 rate_plcp; - - /* Set retry limit on DATA packets and Probe Responses*/ - if (ieee80211_is_probe_resp(fc)) - data_retry_limit = 3; - else - data_retry_limit = IL4965_DEFAULT_TX_RETRY; - tx_cmd->data_retry_limit = data_retry_limit; - - /* Set retry limit on RTS packets */ - rts_retry_limit = RTS_DFAULT_RETRY_LIMIT; - if (data_retry_limit < rts_retry_limit) - rts_retry_limit = data_retry_limit; - tx_cmd->rts_retry_limit = rts_retry_limit; - - /* DATA packets will use the uCode station table for rate/antenna - * selection */ - if (ieee80211_is_data(fc)) { - tx_cmd->initial_rate_idx = 0; - tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; - return; - } - - /** - * If the current TX rate stored in mac80211 has the MCS bit set, it's - * not really a TX rate. Thus, we use the lowest supported rate for - * this band. Also use the lowest supported rate if the stored rate - * idx is invalid. - */ - rate_idx = info->control.rates[0].idx; - if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || - rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) - rate_idx = rate_lowest_index(&il->bands[info->band], - info->control.sta); - /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ - if (info->band == IEEE80211_BAND_5GHZ) - rate_idx += IL_FIRST_OFDM_RATE; - /* Get PLCP rate for tx_cmd->rate_n_flags */ - rate_plcp = il_rates[rate_idx].plcp; - /* Zero out flags for this packet */ - rate_flags = 0; - - /* Set CCK flag as needed */ - if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE) - rate_flags |= RATE_MCS_CCK_MSK; - - /* Set up antennas */ - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); - - rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); - - /* Set the rate in the TX cmd */ - tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); -} - -static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_tx_cmd *tx_cmd, - struct sk_buff *skb_frag, - int sta_id) -{ - struct ieee80211_key_conf *keyconf = info->control.hw_key; - - switch (keyconf->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - tx_cmd->sec_ctl = TX_CMD_SEC_CCM; - memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); - if (info->flags & IEEE80211_TX_CTL_AMPDU) - tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - D_TX("tx_cmd with AES hwcrypto\n"); - break; - - case WLAN_CIPHER_SUITE_TKIP: - tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; - ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - D_TX("tx_cmd with tkip hwcrypto\n"); - break; - - case WLAN_CIPHER_SUITE_WEP104: - tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; - /* fall through */ - case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | - (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); - - memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - - D_TX("Configuring packet for WEP encryption " - "with key %d\n", keyconf->keyidx); - break; - - default: - IL_ERR("Unknown encode cipher %x\n", keyconf->cipher); - break; - } -} - -/* - * start REPLY_TX command process - */ -int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_sta *sta = info->control.sta; - struct il_station_priv *sta_priv = NULL; - struct il_tx_queue *txq; - struct il_queue *q; - struct il_device_cmd *out_cmd; - struct il_cmd_meta *out_meta; - struct il_tx_cmd *tx_cmd; - struct il_rxon_context *ctx = &il->ctx; - int txq_id; - dma_addr_t phys_addr; - dma_addr_t txcmd_phys; - dma_addr_t scratch_phys; - u16 len, firstlen, secondlen; - u16 seq_number = 0; - __le16 fc; - u8 hdr_len; - u8 sta_id; - u8 wait_write_ptr = 0; - u8 tid = 0; - u8 *qc = NULL; - unsigned long flags; - bool is_agg = false; - - if (info->control.vif) - ctx = il_rxon_ctx_from_vif(info->control.vif); - - spin_lock_irqsave(&il->lock, flags); - if (il_is_rfkill(il)) { - D_DROP("Dropping - RF KILL\n"); - goto drop_unlock; - } - - fc = hdr->frame_control; - -#ifdef CONFIG_IWLEGACY_DEBUG - if (ieee80211_is_auth(fc)) - D_TX("Sending AUTH frame\n"); - else if (ieee80211_is_assoc_req(fc)) - D_TX("Sending ASSOC frame\n"); - else if (ieee80211_is_reassoc_req(fc)) - D_TX("Sending REASSOC frame\n"); -#endif - - hdr_len = ieee80211_hdrlen(fc); - - /* For management frames use broadcast id to do not break aggregation */ - if (!ieee80211_is_data(fc)) - sta_id = ctx->bcast_sta_id; - else { - /* Find idx into station table for destination station */ - sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); - - if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); - goto drop_unlock; - } - } - - D_TX("station Id %d\n", sta_id); - - if (sta) - sta_priv = (void *)sta->drv_priv; - - if (sta_priv && sta_priv->asleep && - (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) { - /* - * This sends an asynchronous command to the device, - * but we can rely on it being processed before the - * next frame is processed -- and the next frame to - * this station is the one that will consume this - * counter. - * For now set the counter to just 1 since we do not - * support uAPSD yet. - */ - il4965_sta_modify_sleep_tx_count(il, sta_id, 1); - } - - /* - * Send this frame after DTIM -- there's a special queue - * reserved for this for contexts that support AP mode. - */ - if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { - txq_id = ctx->mcast_queue; - /* - * The microcode will clear the more data - * bit in the last frame it transmits. - */ - hdr->frame_control |= - cpu_to_le16(IEEE80211_FCTL_MOREDATA); - } else - txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; - - /* irqs already disabled/saved above when locking il->lock */ - spin_lock(&il->sta_lock); - - if (ieee80211_is_data_qos(fc)) { - qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; - if (WARN_ON_ONCE(tid >= MAX_TID_COUNT)) { - spin_unlock(&il->sta_lock); - goto drop_unlock; - } - seq_number = il->stations[sta_id].tid[tid].seq_number; - seq_number &= IEEE80211_SCTL_SEQ; - hdr->seq_ctrl = hdr->seq_ctrl & - cpu_to_le16(IEEE80211_SCTL_FRAG); - hdr->seq_ctrl |= cpu_to_le16(seq_number); - seq_number += 0x10; - /* aggregation is on for this */ - if (info->flags & IEEE80211_TX_CTL_AMPDU && - il->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { - txq_id = il->stations[sta_id].tid[tid].agg.txq_id; - is_agg = true; - } - } - - txq = &il->txq[txq_id]; - q = &txq->q; - - if (unlikely(il_queue_space(q) < q->high_mark)) { - spin_unlock(&il->sta_lock); - goto drop_unlock; - } - - if (ieee80211_is_data_qos(fc)) { - il->stations[sta_id].tid[tid].tfds_in_queue++; - if (!ieee80211_has_morefrags(fc)) - il->stations[sta_id].tid[tid].seq_number = seq_number; - } - - spin_unlock(&il->sta_lock); - - /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); - txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = ctx; - - /* Set up first empty entry in queue's array of Tx/cmd buffers */ - out_cmd = txq->cmd[q->write_ptr]; - out_meta = &txq->meta[q->write_ptr]; - tx_cmd = &out_cmd->cmd.tx; - memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); - memset(tx_cmd, 0, sizeof(struct il_tx_cmd)); - - /* - * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD idx within the sequence field; - * after Tx, uCode's Tx response will return this value so driver can - * locate the frame within the tx queue and do post-tx processing. - */ - out_cmd->hdr.cmd = REPLY_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); - - /* Copy MAC header from skb into command buffer */ - memcpy(tx_cmd->hdr, hdr, hdr_len); - - - /* Total # bytes to be transmitted */ - len = (u16)skb->len; - tx_cmd->len = cpu_to_le16(len); - - if (info->control.hw_key) - il4965_tx_cmd_build_hwcrypto(il, info, tx_cmd, skb, sta_id); - - /* TODO need this for burst mode later on */ - il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id); - il_dbg_log_tx_data_frame(il, len, hdr); - - il4965_tx_cmd_build_rate(il, tx_cmd, info, fc); - - il_update_stats(il, true, fc, len); - /* - * Use the first empty entry in this queue's command buffer array - * to contain the Tx command and MAC header concatenated together - * (payload data will be in another buffer). - * Size of this varies, due to varying MAC header length. - * If end is not dword aligned, we'll have 2 extra bytes at the end - * of the MAC header (device reads on dword boundaries). - * We'll tell device about this padding later. - */ - len = sizeof(struct il_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; - firstlen = (len + 3) & ~3; - - /* Tell NIC about any 2-byte padding after MAC header */ - if (firstlen != len) - tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK; - - /* Physical address of this Tx command's header (not MAC header!), - * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, - &out_cmd->hdr, firstlen, - PCI_DMA_BIDIRECTIONAL); - dma_unmap_addr_set(out_meta, mapping, txcmd_phys); - dma_unmap_len_set(out_meta, len, firstlen); - /* Add buffer containing Tx command and MAC(!) header to TFD's - * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, firstlen, 1, 0); - - if (!ieee80211_has_morefrags(hdr->frame_control)) { - txq->need_update = 1; - } else { - wait_write_ptr = 1; - txq->need_update = 0; - } - - /* Set up TFD's 2nd entry to point directly to remainder of skb, - * if any (802.11 null frames have no payload). */ - secondlen = skb->len - hdr_len; - if (secondlen > 0) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - secondlen, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, secondlen, - 0, 0); - } - - scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + - offsetof(struct il_tx_cmd, scratch); - - /* take back ownership of DMA buffer to enable update */ - pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); - tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); - tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); - D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); - - /* Set up entry for this TFD in Tx byte-count array */ - if (info->flags & IEEE80211_TX_CTL_AMPDU) - il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, - le16_to_cpu(tx_cmd->len)); - - pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); - - /* Tell device the write idx *just past* this latest filled TFD */ - q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - - /* - * At this point the frame is "transmitted" successfully - * and we will get a TX status notification eventually, - * regardless of the value of ret. "ret" only indicates - * whether or not we should update the write pointer. - */ - - /* - * Avoid atomic ops if it isn't an associated client. - * Also, if this is a packet for aggregation, don't - * increase the counter because the ucode will stop - * aggregation queues when their respective station - * goes to sleep. - */ - if (sta_priv && sta_priv->client && !is_agg) - atomic_inc(&sta_priv->pending_frames); - - if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { - if (wait_write_ptr) { - spin_lock_irqsave(&il->lock, flags); - txq->need_update = 1; - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - } else { - il_stop_queue(il, txq); - } - } - - return 0; - -drop_unlock: - spin_unlock_irqrestore(&il->lock, flags); - return -1; -} - -static inline int il4965_alloc_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr, size_t size) -{ - ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, - GFP_KERNEL); - if (!ptr->addr) - return -ENOMEM; - ptr->size = size; - return 0; -} - -static inline void il4965_free_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr) -{ - if (unlikely(!ptr->addr)) - return; - - dma_free_coherent(&il->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); - memset(ptr, 0, sizeof(*ptr)); -} - -/** - * il4965_hw_txq_ctx_free - Free TXQ Context - * - * Destroy all TX DMA queues and structures - */ -void il4965_hw_txq_ctx_free(struct il_priv *il) -{ - int txq_id; - - /* Tx queues */ - if (il->txq) { - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (txq_id == il->cmd_queue) - il_cmd_queue_free(il); - else - il_tx_queue_free(il, txq_id); - } - il4965_free_dma_ptr(il, &il->kw); - - il4965_free_dma_ptr(il, &il->scd_bc_tbls); - - /* free tx queue structure */ - il_txq_mem(il); -} - -/** - * il4965_txq_ctx_alloc - allocate TX queue context - * Allocate all Tx DMA structures and initialize them - * - * @param il - * @return error code - */ -int il4965_txq_ctx_alloc(struct il_priv *il) -{ - int ret; - int txq_id, slots_num; - unsigned long flags; - - /* Free all tx/cmd queues and keep-warm buffer */ - il4965_hw_txq_ctx_free(il); - - ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, - il->hw_params.scd_bc_tbls_size); - if (ret) { - IL_ERR("Scheduler BC Table allocation failed\n"); - goto error_bc_tbls; - } - /* Alloc keep-warm buffer */ - ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); - if (ret) { - IL_ERR("Keep Warm allocation failed\n"); - goto error_kw; - } - - /* allocate tx queue structure */ - ret = il_alloc_txq_mem(il); - if (ret) - goto error; - - spin_lock_irqsave(&il->lock, flags); - - /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(il, 0); - - /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - - spin_unlock_irqrestore(&il->lock, flags); - - /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == il->cmd_queue) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = il_tx_queue_init(il, - &il->txq[txq_id], slots_num, - txq_id); - if (ret) { - IL_ERR("Tx %d queue init failed\n", txq_id); - goto error; - } - } - - return ret; - - error: - il4965_hw_txq_ctx_free(il); - il4965_free_dma_ptr(il, &il->kw); - error_kw: - il4965_free_dma_ptr(il, &il->scd_bc_tbls); - error_bc_tbls: - return ret; -} - -void il4965_txq_ctx_reset(struct il_priv *il) -{ - int txq_id, slots_num; - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - - /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(il, 0); - - /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - - spin_unlock_irqrestore(&il->lock, flags); - - /* Alloc and init all Tx queues, including the command queue (#4) */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = txq_id == il->cmd_queue ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - il_tx_queue_reset(il, &il->txq[txq_id], - slots_num, txq_id); - } -} - -/** - * il4965_txq_ctx_stop - Stop all Tx DMA channels - */ -void il4965_txq_ctx_stop(struct il_priv *il) -{ - int ch, txq_id; - unsigned long flags; - - /* Turn off all Tx DMA fifos */ - spin_lock_irqsave(&il->lock, flags); - - il4965_txq_set_sched(il, 0); - - /* Stop each Tx DMA channel, and wait for it to be idle */ - for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { - il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), - 1000)) - IL_ERR("Failing on timeout while stopping" - " DMA channel %d [0x%08x]", ch, - il_rd(il, - FH_TSSR_TX_STATUS_REG)); - } - spin_unlock_irqrestore(&il->lock, flags); - - if (!il->txq) - return; - - /* Unmap DMA from host system and free skb's */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (txq_id == il->cmd_queue) - il_cmd_queue_unmap(il); - else - il_tx_queue_unmap(il, txq_id); -} - -/* - * Find first available (lowest unused) Tx Queue, mark it "active". - * Called only when finding queue for aggregation. - * Should never return anything < 7, because they should already - * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) - */ -static int il4965_txq_ctx_activate_free(struct il_priv *il) -{ - int txq_id; - - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) - return txq_id; - return -1; -} - -/** - * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration - */ -static void il4965_tx_queue_stop_scheduler(struct il_priv *il, - u16 txq_id) -{ - /* Simply stop the queue, but don't change any configuration; - * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_wr_prph(il, - IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| - (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); -} - -/** - * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue - */ -static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, - u16 txq_id) -{ - u32 tbl_dw_addr; - u32 tbl_dw; - u16 scd_q2ratid; - - scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; - - tbl_dw_addr = il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); - - tbl_dw = il_read_targ_mem(il, tbl_dw_addr); - - if (txq_id & 0x1) - tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); - else - tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); - - il_write_targ_mem(il, tbl_dw_addr, tbl_dw); - - return 0; -} - -/** - * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue - * - * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, - * i.e. it must be one of the higher queues used for aggregation - */ -static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, - int tx_fifo, int sta_id, int tid, u16 ssn_idx) -{ - unsigned long flags; - u16 ra_tid; - int ret; - - if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || - (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", - txq_id, IL49_FIRST_AMPDU_QUEUE, - IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues - 1); - return -EINVAL; - } - - ra_tid = BUILD_RAxTID(sta_id, tid); - - /* Modify device's station table to Tx this TID */ - ret = il4965_sta_tx_modify_enable_tid(il, sta_id, tid); - if (ret) - return ret; - - spin_lock_irqsave(&il->lock, flags); - - /* Stop this Tx queue before configuring it */ - il4965_tx_queue_stop_scheduler(il, txq_id); - - /* Map receiver-address / traffic-ID to this queue */ - il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); - - /* Set this queue as a chain-building queue */ - il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - - /* Place first TFD at idx corresponding to start sequence number. - * Assumes that ssn_idx is valid (!= 0xFFF) */ - il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - il4965_set_wr_ptrs(il, txq_id, ssn_idx); - - /* Set up Tx win size and frame limit for this queue */ - il_write_targ_mem(il, - il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), - (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), - (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) - & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - - il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - - /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ - il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); - - spin_unlock_irqrestore(&il->lock, flags); - - return 0; -} - - -int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn) -{ - int sta_id; - int tx_fifo; - int txq_id; - int ret; - unsigned long flags; - struct il_tid_data *tid_data; - - tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); - if (unlikely(tx_fifo < 0)) - return tx_fifo; - - IL_WARN("%s on ra = %pM tid = %d\n", - __func__, sta->addr, tid); - - sta_id = il_sta_id(sta); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Start AGG on invalid station\n"); - return -ENXIO; - } - if (unlikely(tid >= MAX_TID_COUNT)) - return -EINVAL; - - if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { - IL_ERR("Start AGG when state is not IL_AGG_OFF !\n"); - return -ENXIO; - } - - txq_id = il4965_txq_ctx_activate_free(il); - if (txq_id == -1) { - IL_ERR("No free aggregation queue available\n"); - return -ENXIO; - } - - spin_lock_irqsave(&il->sta_lock, flags); - tid_data = &il->stations[sta_id].tid[tid]; - *ssn = SEQ_TO_SN(tid_data->seq_number); - tid_data->agg.txq_id = txq_id; - il_set_swq_id(&il->txq[txq_id], - il4965_get_ac_from_tid(tid), txq_id); - spin_unlock_irqrestore(&il->sta_lock, flags); - - ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, - sta_id, tid, *ssn); - if (ret) - return ret; - - spin_lock_irqsave(&il->sta_lock, flags); - tid_data = &il->stations[sta_id].tid[tid]; - if (tid_data->tfds_in_queue == 0) { - D_HT("HW queue is empty\n"); - tid_data->agg.state = IL_AGG_ON; - ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); - } else { - D_HT( - "HW queue is NOT empty: %d packets in HW queue\n", - tid_data->tfds_in_queue); - tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; - } - spin_unlock_irqrestore(&il->sta_lock, flags); - return ret; -} - -/** - * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE - * il->lock must be held by the caller - */ -static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, - u16 ssn_idx, u8 tx_fifo) -{ - if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || - (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", - txq_id, IL49_FIRST_AMPDU_QUEUE, - IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues - 1); - return -EINVAL; - } - - il4965_tx_queue_stop_scheduler(il, txq_id); - - il_clear_bits_prph(il, - IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - - il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - /* supposes that ssn_idx is valid (!= 0xFFF) */ - il4965_set_wr_ptrs(il, txq_id, ssn_idx); - - il_clear_bits_prph(il, - IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - il_txq_ctx_deactivate(il, txq_id); - il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); - - return 0; -} - -int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid) -{ - int tx_fifo_id, txq_id, sta_id, ssn; - struct il_tid_data *tid_data; - int write_ptr, read_ptr; - unsigned long flags; - - tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); - if (unlikely(tx_fifo_id < 0)) - return tx_fifo_id; - - sta_id = il_sta_id(sta); - - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Invalid station for AGG tid %d\n", tid); - return -ENXIO; - } - - spin_lock_irqsave(&il->sta_lock, flags); - - tid_data = &il->stations[sta_id].tid[tid]; - ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; - txq_id = tid_data->agg.txq_id; - - switch (il->stations[sta_id].tid[tid].agg.state) { - case IL_EMPTYING_HW_QUEUE_ADDBA: - /* - * This can happen if the peer stops aggregation - * again before we've had a chance to drain the - * queue we selected previously, i.e. before the - * session was really started completely. - */ - D_HT("AGG stop before setup done\n"); - goto turn_off; - case IL_AGG_ON: - break; - default: - IL_WARN("Stopping AGG while state not ON or starting\n"); - } - - write_ptr = il->txq[txq_id].q.write_ptr; - read_ptr = il->txq[txq_id].q.read_ptr; - - /* The queue is not empty */ - if (write_ptr != read_ptr) { - D_HT("Stopping a non empty AGG HW QUEUE\n"); - il->stations[sta_id].tid[tid].agg.state = - IL_EMPTYING_HW_QUEUE_DELBA; - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - - D_HT("HW queue is empty\n"); - turn_off: - il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; - - /* do not restore/save irqs */ - spin_unlock(&il->sta_lock); - spin_lock(&il->lock); - - /* - * the only reason this call can fail is queue number out of range, - * which can happen if uCode is reloaded and all the station - * information are lost. if it is outside the range, there is no need - * to deactivate the uCode queue, just return "success" to allow - * mac80211 to clean up it own data. - */ - il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo_id); - spin_unlock_irqrestore(&il->lock, flags); - - ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); - - return 0; -} - -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id) -{ - struct il_queue *q = &il->txq[txq_id].q; - u8 *addr = il->stations[sta_id].sta.sta.addr; - struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; - struct il_rxon_context *ctx; - - ctx = &il->ctx; - - lockdep_assert_held(&il->sta_lock); - - switch (il->stations[sta_id].tid[tid].agg.state) { - case IL_EMPTYING_HW_QUEUE_DELBA: - /* We are reclaiming the last packet of the */ - /* aggregated HW queue */ - if (txq_id == tid_data->agg.txq_id && - q->read_ptr == q->write_ptr) { - u16 ssn = SEQ_TO_SN(tid_data->seq_number); - int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - D_HT( - "HW queue empty: continue DELBA flow\n"); - il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); - tid_data->agg.state = IL_AGG_OFF; - ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); - } - break; - case IL_EMPTYING_HW_QUEUE_ADDBA: - /* We are reclaiming the last packet of the queue */ - if (tid_data->tfds_in_queue == 0) { - D_HT( - "HW queue empty: continue ADDBA flow\n"); - tid_data->agg.state = IL_AGG_ON; - ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); - } - break; - } - - return 0; -} - -static void il4965_non_agg_tx_status(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr1) -{ - struct ieee80211_sta *sta; - struct il_station_priv *sta_priv; - - rcu_read_lock(); - sta = ieee80211_find_sta(ctx->vif, addr1); - if (sta) { - sta_priv = (void *)sta->drv_priv; - /* avoid atomic ops if this isn't a client */ - if (sta_priv->client && - atomic_dec_return(&sta_priv->pending_frames) == 0) - ieee80211_sta_block_awake(il->hw, sta, false); - } - rcu_read_unlock(); -} - -static void -il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, - bool is_agg) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; - - if (!is_agg) - il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); - - ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); -} - -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - struct il_tx_info *tx_info; - int nfreed = 0; - struct ieee80211_hdr *hdr; - - if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); - return 0; - } - - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { - - tx_info = &txq->txb[txq->q.read_ptr]; - - if (WARN_ON_ONCE(tx_info->skb == NULL)) - continue; - - hdr = (struct ieee80211_hdr *)tx_info->skb->data; - if (ieee80211_is_data_qos(hdr->frame_control)) - nfreed++; - - il4965_tx_status(il, tx_info, - txq_id >= IL4965_FIRST_AMPDU_QUEUE); - tx_info->skb = NULL; - - il->cfg->ops->lib->txq_free_tfd(il, txq); - } - return nfreed; -} - -/** - * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack - * - * Go through block-ack's bitmap of ACK'd frames, update driver's record of - * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. - */ -static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, - struct il_ht_agg *agg, - struct il_compressed_ba_resp *ba_resp) - -{ - int i, sh, ack; - u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl); - u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - int successes = 0; - struct ieee80211_tx_info *info; - u64 bitmap, sent_bitmap; - - if (unlikely(!agg->wait_for_ba)) { - if (unlikely(ba_resp->bitmap)) - IL_ERR("Received BA when not expected\n"); - return -EINVAL; - } - - /* Mark that the expected block-ack response arrived */ - agg->wait_for_ba = 0; - D_TX_REPLY("BA %d %d\n", agg->start_idx, - ba_resp->seq_ctl); - - /* Calculate shift to align block-ack bits with our Tx win bits */ - sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); - if (sh < 0) /* tbw something is wrong with indices */ - sh += 0x100; - - if (agg->frame_count > (64 - sh)) { - D_TX_REPLY("more frames than bitmap size"); - return -1; - } - - /* don't use 64-bit values for now */ - bitmap = le64_to_cpu(ba_resp->bitmap) >> sh; - - /* check for success or failure according to the - * transmitted bitmap and block-ack bitmap */ - sent_bitmap = bitmap & agg->bitmap; - - /* For each frame attempted in aggregation, - * update driver's record of tx frame's status. */ - i = 0; - while (sent_bitmap) { - ack = sent_bitmap & 1ULL; - successes += ack; - D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", - ack ? "ACK" : "NACK", i, - (agg->start_idx + i) & 0xff, - agg->start_idx + i); - sent_bitmap >>= 1; - ++i; - } - - D_TX_REPLY("Bitmap %llx\n", - (unsigned long long)bitmap); - - info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); - memset(&info->status, 0, sizeof(info->status)); - info->flags |= IEEE80211_TX_STAT_ACK; - info->flags |= IEEE80211_TX_STAT_AMPDU; - info->status.ampdu_ack_len = successes; - info->status.ampdu_len = agg->frame_count; - il4965_hwrate_to_tx_control(il, agg->rate_n_flags, info); - - return 0; -} - -/** - * translate ucode response to mac80211 tx status control values - */ -void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info) -{ - struct ieee80211_tx_rate *r = &info->control.rates[0]; - - info->antenna_sel_tx = - ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); - if (rate_n_flags & RATE_MCS_HT_MSK) - r->flags |= IEEE80211_TX_RC_MCS; - if (rate_n_flags & RATE_MCS_GF_MSK) - r->flags |= IEEE80211_TX_RC_GREEN_FIELD; - if (rate_n_flags & RATE_MCS_HT40_MSK) - r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; - if (rate_n_flags & RATE_MCS_DUP_MSK) - r->flags |= IEEE80211_TX_RC_DUP_DATA; - if (rate_n_flags & RATE_MCS_SGI_MSK) - r->flags |= IEEE80211_TX_RC_SHORT_GI; - r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); -} - -/** - * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA - * - * Handles block-acknowledge notification from device, which reports success - * of frames sent via aggregation. - */ -void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; - struct il_tx_queue *txq = NULL; - struct il_ht_agg *agg; - int idx; - int sta_id; - int tid; - unsigned long flags; - - /* "flow" corresponds to Tx queue */ - u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - - /* "ssn" is start of block-ack Tx win, corresponds to idx - * (in Tx queue's circular buffer) of first TFD/frame in win */ - u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); - - if (scd_flow >= il->hw_params.max_txq_num) { - IL_ERR( - "BUG_ON scd_flow is bigger than number of queues\n"); - return; - } - - txq = &il->txq[scd_flow]; - sta_id = ba_resp->sta_id; - tid = ba_resp->tid; - agg = &il->stations[sta_id].tid[tid].agg; - if (unlikely(agg->txq_id != scd_flow)) { - /* - * FIXME: this is a uCode bug which need to be addressed, - * log the information and return for now! - * since it is possible happen very often and in order - * not to fill the syslog, don't enable the logging by default - */ - D_TX_REPLY( - "BA scd_flow %d does not match txq_id %d\n", - scd_flow, agg->txq_id); - return; - } - - /* Find idx just before block-ack win */ - idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); - - spin_lock_irqsave(&il->sta_lock, flags); - - D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " - "sta_id = %d\n", - agg->wait_for_ba, - (u8 *) &ba_resp->sta_addr_lo32, - ba_resp->sta_id); - D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," - "scd_flow = " - "%d, scd_ssn = %d\n", - ba_resp->tid, - ba_resp->seq_ctl, - (unsigned long long)le64_to_cpu(ba_resp->bitmap), - ba_resp->scd_flow, - ba_resp->scd_ssn); - D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", - agg->start_idx, - (unsigned long long)agg->bitmap); - - /* Update driver's record of ACK vs. not for each frame in win */ - il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); - - /* Release all TFDs before the SSN, i.e. all TFDs in front of - * block-ack win (we assume that they've been successfully - * transmitted ... if not, it's too late anyway). */ - if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { - /* calculate mac80211 ampdu sw queue to wake */ - int freed = il4965_tx_queue_reclaim(il, scd_flow, idx); - il4965_free_tfds_in_queue(il, sta_id, tid, freed); - - if (il_queue_space(&txq->q) > txq->q.low_mark && - il->mac80211_registered && - agg->state != IL_EMPTYING_HW_QUEUE_DELBA) - il_wake_queue(il, txq); - - il4965_txq_check_empty(il, sta_id, tid, scd_flow); - } - - spin_unlock_irqrestore(&il->sta_lock, flags); -} - -#ifdef CONFIG_IWLEGACY_DEBUG -const char *il4965_get_tx_fail_reason(u32 status) -{ -#define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x -#define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x - - switch (status & TX_STATUS_MSK) { - case TX_STATUS_SUCCESS: - return "SUCCESS"; - TX_STATUS_POSTPONE(DELAY); - TX_STATUS_POSTPONE(FEW_BYTES); - TX_STATUS_POSTPONE(QUIET_PERIOD); - TX_STATUS_POSTPONE(CALC_TTAK); - TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); - TX_STATUS_FAIL(SHORT_LIMIT); - TX_STATUS_FAIL(LONG_LIMIT); - TX_STATUS_FAIL(FIFO_UNDERRUN); - TX_STATUS_FAIL(DRAIN_FLOW); - TX_STATUS_FAIL(RFKILL_FLUSH); - TX_STATUS_FAIL(LIFE_EXPIRE); - TX_STATUS_FAIL(DEST_PS); - TX_STATUS_FAIL(HOST_ABORTED); - TX_STATUS_FAIL(BT_RETRY); - TX_STATUS_FAIL(STA_INVALID); - TX_STATUS_FAIL(FRAG_DROPPED); - TX_STATUS_FAIL(TID_DISABLE); - TX_STATUS_FAIL(FIFO_FLUSHED); - TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); - TX_STATUS_FAIL(PASSIVE_NO_RX); - TX_STATUS_FAIL(NO_BEACON_ON_RADAR); - } - - return "UNKNOWN"; - -#undef TX_STATUS_FAIL -#undef TX_STATUS_POSTPONE -} -#endif /* CONFIG_IWLEGACY_DEBUG */ -- cgit v0.10.2 From fcb74588dccb06d8e3e13afb36c5401cae470518 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 13:06:03 +0200 Subject: iwlegacy: merge iwl-4965-lib.c into 4965-mac.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index b6f96b4..d817d8d 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -86,6 +86,1158 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); +void il4965_check_abort_status(struct il_priv *il, + u8 frame_count, u32 status) +{ + if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { + IL_ERR("Tx flush command to flush out all frames\n"); + if (!test_bit(STATUS_EXIT_PENDING, &il->status)) + queue_work(il->workqueue, &il->tx_flush); + } +} + +/* + * EEPROM + */ +struct il_mod_params il4965_mod_params = { + .amsdu_size_8K = 1, + .restart_fw = 1, + /* the rest are 0 by default */ +}; + +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +{ + unsigned long flags; + int i; + spin_lock_irqsave(&rxq->lock, flags); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { + /* In the reset function, these buffers may have been allocated + * to an SKB, so we need to unmap and free potential storage */ + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + } + + for (i = 0; i < RX_QUEUE_SIZE; i++) + rxq->queue[i] = NULL; + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + spin_unlock_irqrestore(&rxq->lock, flags); +} + +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +{ + u32 rb_size; + const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ + u32 rb_timeout = 0; + + if (il->cfg->mod_params->amsdu_size_8K) + rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; + else + rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; + + /* Stop Rx DMA */ + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + + /* Reset driver's Rx queue write idx */ + il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + + /* Tell device where to find RBD circular buffer in DRAM */ + il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + (u32)(rxq->bd_dma >> 8)); + + /* Tell device where in DRAM to update its Rx status */ + il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, + rxq->rb_stts_dma >> 4); + + /* Enable Rx DMA + * Direct rx interrupts to hosts + * Rx buffer size 4 or 8k + * RB timeout 0x10 + * 256 RBDs + */ + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, + FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | + FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | + FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | + rb_size| + (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| + (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + + /* Set interrupt coalescing timer to default (2048 usecs) */ + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); + + return 0; +} + +static void il4965_set_pwr_vmain(struct il_priv *il) +{ +/* + * (for documentation purposes) + * to set power to V_AUX, do: + + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VAUX, + ~APMG_PS_CTRL_MSK_PWR_SRC); + */ + + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); +} + +int il4965_hw_nic_init(struct il_priv *il) +{ + unsigned long flags; + struct il_rx_queue *rxq = &il->rxq; + int ret; + + /* nic_init */ + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); + + /* Set interrupt coalescing calibration timer to default (512 usecs) */ + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); + + spin_unlock_irqrestore(&il->lock, flags); + + il4965_set_pwr_vmain(il); + + il->cfg->ops->lib->apm_ops.config(il); + + /* Allocate the RX queue, or reset if it is already allocated */ + if (!rxq->bd) { + ret = il_rx_queue_alloc(il); + if (ret) { + IL_ERR("Unable to initialize Rx queue\n"); + return -ENOMEM; + } + } else + il4965_rx_queue_reset(il, rxq); + + il4965_rx_replenish(il); + + il4965_rx_init(il, rxq); + + spin_lock_irqsave(&il->lock, flags); + + rxq->need_update = 1; + il_rx_queue_update_write_ptr(il, rxq); + + spin_unlock_irqrestore(&il->lock, flags); + + /* Allocate or reset and init all Tx and Command queues */ + if (!il->txq) { + ret = il4965_txq_ctx_alloc(il); + if (ret) + return ret; + } else + il4965_txq_ctx_reset(il); + + set_bit(STATUS_INIT, &il->status); + + return 0; +} + +/** + * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + */ +static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, + dma_addr_t dma_addr) +{ + return cpu_to_le32((u32)(dma_addr >> 8)); +} + +/** + * il4965_rx_queue_restock - refill RX queue from pre-allocated pool + * + * If there are slots in the RX queue that need to be restocked, + * and we have free pre-allocated buffers, fill the ranks as much + * as we can, pulling from rx_free. + * + * This moves the 'write' idx forward to catch up with 'processed', and + * also updates the memory address in the firmware to reference the new + * target buffer. + */ +void il4965_rx_queue_restock(struct il_priv *il) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + unsigned long flags; + + spin_lock_irqsave(&rxq->lock, flags); + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { + /* The overwritten rxb must be a used one */ + rxb = rxq->queue[rxq->write]; + BUG_ON(rxb && rxb->page); + + /* Get next free Rx buffer, remove from free list */ + element = rxq->rx_free.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + + /* Point to Rx buffer via next RBD in circular buffer */ + rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, + rxb->page_dma); + rxq->queue[rxq->write] = rxb; + rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; + rxq->free_count--; + } + spin_unlock_irqrestore(&rxq->lock, flags); + /* If the pre-allocated buffer pool is dropping low, schedule to + * refill it */ + if (rxq->free_count <= RX_LOW_WATERMARK) + queue_work(il->workqueue, &il->rx_replenish); + + + /* If we've added more space for the firmware to place data, tell it. + * Increment device's write pointer in multiples of 8. */ + if (rxq->write_actual != (rxq->write & ~0x7)) { + spin_lock_irqsave(&rxq->lock, flags); + rxq->need_update = 1; + spin_unlock_irqrestore(&rxq->lock, flags); + il_rx_queue_update_write_ptr(il, rxq); + } +} + +/** + * il4965_rx_replenish - Move all used packet from rx_used to rx_free + * + * When moving to rx_free an SKB is allocated for the slot. + * + * Also restock the Rx queue via il_rx_queue_restock. + * This is called as a scheduled work item (except for during initialization) + */ +static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + struct page *page; + unsigned long flags; + gfp_t gfp_mask = priority; + + while (1) { + spin_lock_irqsave(&rxq->lock, flags); + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + return; + } + spin_unlock_irqrestore(&rxq->lock, flags); + + if (rxq->free_count > RX_LOW_WATERMARK) + gfp_mask |= __GFP_NOWARN; + + if (il->hw_params.rx_page_order > 0) + gfp_mask |= __GFP_COMP; + + /* Alloc a new receive buffer */ + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); + if (!page) { + if (net_ratelimit()) + D_INFO("alloc_pages failed, " + "order: %d\n", + il->hw_params.rx_page_order); + + if (rxq->free_count <= RX_LOW_WATERMARK && + net_ratelimit()) + IL_ERR( + "Failed to alloc_pages with %s. " + "Only %u free buffers remaining.\n", + priority == GFP_ATOMIC ? + "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); + /* We don't reschedule replenish work here -- we will + * call the restock method and if it still needs + * more buffers it will schedule replenish */ + return; + } + + spin_lock_irqsave(&rxq->lock, flags); + + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + __free_pages(page, il->hw_params.rx_page_order); + return; + } + element = rxq->rx_used.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + + spin_unlock_irqrestore(&rxq->lock, flags); + + BUG_ON(rxb->page); + rxb->page = page; + /* Get physical address of the RB */ + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + /* dma address must be no more than 36 bits */ + BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); + /* and also 256 byte aligned! */ + BUG_ON(rxb->page_dma & DMA_BIT_MASK(8)); + + spin_lock_irqsave(&rxq->lock, flags); + + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + il->alloc_rxb_page++; + + spin_unlock_irqrestore(&rxq->lock, flags); + } +} + +void il4965_rx_replenish(struct il_priv *il) +{ + unsigned long flags; + + il4965_rx_allocate(il, GFP_KERNEL); + + spin_lock_irqsave(&il->lock, flags); + il4965_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); +} + +void il4965_rx_replenish_now(struct il_priv *il) +{ + il4965_rx_allocate(il, GFP_ATOMIC); + + il4965_rx_queue_restock(il); +} + +/* Assumes that the skb field of the buffers in 'pool' is kept accurate. + * If an SKB has been detached, the POOL needs to have its SKB set to NULL + * This free routine walks the list of POOL entries and if SKB is set to + * non NULL it is unmapped and freed + */ +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +{ + int i; + for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + } + + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), + rxq->rb_stts, rxq->rb_stts_dma); + rxq->bd = NULL; + rxq->rb_stts = NULL; +} + +int il4965_rxq_stop(struct il_priv *il) +{ + + /* stop Rx DMA */ + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, + FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + + return 0; +} + +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) +{ + int idx = 0; + int band_offset = 0; + + /* HT rate format: mac80211 wants an MCS number, which is just LSB */ + if (rate_n_flags & RATE_MCS_HT_MSK) { + idx = (rate_n_flags & 0xff); + return idx; + /* Legacy rate format, search for match in table */ + } else { + if (band == IEEE80211_BAND_5GHZ) + band_offset = IL_FIRST_OFDM_RATE; + for (idx = band_offset; idx < RATE_COUNT_LEGACY; idx++) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) + return idx - band_offset; + } + + return -1; +} + +static int il4965_calc_rssi(struct il_priv *il, + struct il_rx_phy_res *rx_resp) +{ + /* data from PHY/DSP regarding signal strength, etc., + * contents are always there, not configurable by host. */ + struct il4965_rx_non_cfg_phy *ncphy = + (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; + u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) + >> IL49_AGC_DB_POS; + + u32 valid_antennae = + (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) + >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; + u8 max_rssi = 0; + u32 i; + + /* Find max rssi among 3 possible receivers. + * These values are measured by the digital signal processor (DSP). + * They should stay fairly constant even as the signal strength varies, + * if the radio's automatic gain control (AGC) is working right. + * AGC value (see below) will provide the "interesting" info. */ + for (i = 0; i < 3; i++) + if (valid_antennae & (1 << i)) + max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); + + D_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", + ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], + max_rssi, agc); + + /* dBm = max_rssi dB - agc dB - constant. + * Higher AGC (higher radio gain) means lower signal. */ + return max_rssi - agc - IL4965_RSSI_OFFSET; +} + + +static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) +{ + u32 decrypt_out = 0; + + if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) == + RX_RES_STATUS_STATION_FOUND) + decrypt_out |= (RX_RES_STATUS_STATION_FOUND | + RX_RES_STATUS_NO_STATION_INFO_MISMATCH); + + decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK); + + /* packet was not encrypted */ + if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == + RX_RES_STATUS_SEC_TYPE_NONE) + return decrypt_out; + + /* packet was encrypted with unknown alg */ + if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == + RX_RES_STATUS_SEC_TYPE_ERR) + return decrypt_out; + + /* decryption was not done in HW */ + if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) != + RX_MPDU_RES_STATUS_DEC_DONE_MSK) + return decrypt_out; + + switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) { + + case RX_RES_STATUS_SEC_TYPE_CCMP: + /* alg is CCM: check MIC only */ + if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK)) + /* Bad MIC */ + decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; + else + decrypt_out |= RX_RES_STATUS_DECRYPT_OK; + + break; + + case RX_RES_STATUS_SEC_TYPE_TKIP: + if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) { + /* Bad TTAK */ + decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK; + break; + } + /* fall through if TTAK OK */ + default: + if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK)) + decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; + else + decrypt_out |= RX_RES_STATUS_DECRYPT_OK; + break; + } + + D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", + decrypt_in, decrypt_out); + + return decrypt_out; +} + +static void il4965_pass_packet_to_mac80211(struct il_priv *il, + struct ieee80211_hdr *hdr, + u16 len, + u32 ampdu_status, + struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) +{ + struct sk_buff *skb; + __le16 fc = hdr->frame_control; + + /* We only process data packets if the interface is open */ + if (unlikely(!il->is_open)) { + D_DROP( + "Dropping packet while interface is not open.\n"); + return; + } + + /* In case of HW accelerated crypto and bad decryption, drop */ + if (!il->cfg->mod_params->sw_crypto && + il_set_decrypted_flag(il, hdr, ampdu_status, stats)) + return; + + skb = dev_alloc_skb(128); + if (!skb) { + IL_ERR("dev_alloc_skb failed\n"); + return; + } + + skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); + + il_update_stats(il, false, fc, len); + memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); + + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; + rxb->page = NULL; +} + +/* Called for REPLY_RX (legacy ABG frames), or + * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ +void il4965_rx_reply_rx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct ieee80211_hdr *header; + struct ieee80211_rx_status rx_status; + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_rx_phy_res *phy_res; + __le32 rx_pkt_status; + struct il_rx_mpdu_res_start *amsdu; + u32 len; + u32 ampdu_status; + u32 rate_n_flags; + + /** + * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. + * REPLY_RX: physical layer info is in this buffer + * REPLY_RX_MPDU_CMD: physical layer info was sent in separate + * command and cached in il->last_phy_res + * + * Here we set up local variables depending on which command is + * received. + */ + if (pkt->hdr.cmd == REPLY_RX) { + phy_res = (struct il_rx_phy_res *)pkt->u.raw; + header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt); + + len = le16_to_cpu(phy_res->byte_count); + rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt + len); + ampdu_status = le32_to_cpu(rx_pkt_status); + } else { + if (!il->_4965.last_phy_res_valid) { + IL_ERR("MPDU frame without cached PHY data\n"); + return; + } + phy_res = &il->_4965.last_phy_res; + amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; + header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); + len = le16_to_cpu(amsdu->byte_count); + rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); + ampdu_status = il4965_translate_rx_status(il, + le32_to_cpu(rx_pkt_status)); + } + + if ((unlikely(phy_res->cfg_phy_cnt > 20))) { + D_DROP("dsp size out of range [0,20]: %d/n", + phy_res->cfg_phy_cnt); + return; + } + + if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || + !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { + D_RX("Bad CRC or FIFO: 0x%08X.\n", + le32_to_cpu(rx_pkt_status)); + return; + } + + /* This will be used in several places later */ + rate_n_flags = le32_to_cpu(phy_res->rate_n_flags); + + /* rx_status carries information about the packet to mac80211 */ + rx_status.mactime = le64_to_cpu(phy_res->timestamp); + rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? + IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.freq = + ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), + rx_status.band); + rx_status.rate_idx = + il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); + rx_status.flag = 0; + + /* TSF isn't reliable. In order to allow smooth user experience, + * this W/A doesn't propagate it to the mac80211 */ + /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ + + il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); + + /* Find max signal strength (dBm) among 3 antenna/receiver chains */ + rx_status.signal = il4965_calc_rssi(il, phy_res); + + il_dbg_log_rx_data_frame(il, len, header); + D_STATS("Rssi %d, TSF %llu\n", + rx_status.signal, (unsigned long long)rx_status.mactime); + + /* + * "antenna number" + * + * It seems that the antenna field in the phy flags value + * is actually a bit field. This is undefined by radiotap, + * it wants an actual antenna number but I always get "7" + * for most legacy frames I receive indicating that the + * same frame was received on all three RX chains. + * + * I think this field should be removed in favor of a + * new 802.11n radiotap field "RX chains" that is defined + * as a bitmask. + */ + rx_status.antenna = + (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) + >> RX_RES_PHY_FLAGS_ANTENNA_POS; + + /* set the preamble flag if appropriate */ + if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) + rx_status.flag |= RX_FLAG_SHORTPRE; + + /* Set up the HT phy flags */ + if (rate_n_flags & RATE_MCS_HT_MSK) + rx_status.flag |= RX_FLAG_HT; + if (rate_n_flags & RATE_MCS_HT40_MSK) + rx_status.flag |= RX_FLAG_40MHZ; + if (rate_n_flags & RATE_MCS_SGI_MSK) + rx_status.flag |= RX_FLAG_SHORT_GI; + + il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, + rxb, &rx_status); +} + +/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). + * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ +void il4965_rx_reply_rx_phy(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + il->_4965.last_phy_res_valid = true; + memcpy(&il->_4965.last_phy_res, pkt->u.raw, + sizeof(struct il_rx_phy_res)); +} + +static int il4965_get_channels_for_scan(struct il_priv *il, + struct ieee80211_vif *vif, + enum ieee80211_band band, + u8 is_active, u8 n_probes, + struct il_scan_channel *scan_ch) +{ + struct ieee80211_channel *chan; + const struct ieee80211_supported_band *sband; + const struct il_channel_info *ch_info; + u16 passive_dwell = 0; + u16 active_dwell = 0; + int added, i; + u16 channel; + + sband = il_get_hw_mode(il, band); + if (!sband) + return 0; + + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); + + if (passive_dwell <= active_dwell) + passive_dwell = active_dwell + 1; + + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; + + if (chan->band != band) + continue; + + channel = chan->hw_value; + scan_ch->channel = cpu_to_le16(channel); + + ch_info = il_get_channel_info(il, band, channel); + if (!il_is_channel_valid(ch_info)) { + D_SCAN( + "Channel %d is INVALID for this band.\n", + channel); + continue; + } + + if (!is_active || il_is_channel_passive(ch_info) || + (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) + scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; + else + scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; + + if (n_probes) + scan_ch->type |= IL_SCAN_PROBE_MASK(n_probes); + + scan_ch->active_dwell = cpu_to_le16(active_dwell); + scan_ch->passive_dwell = cpu_to_le16(passive_dwell); + + /* Set txpower levels to defaults */ + scan_ch->dsp_atten = 110; + + /* NOTE: if we were doing 6Mb OFDM for scans we'd use + * power level: + * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; + */ + if (band == IEEE80211_BAND_5GHZ) + scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; + else + scan_ch->tx_gain = ((1 << 5) | (5 << 3)); + + D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", + channel, le32_to_cpu(scan_ch->type), + (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? + "ACTIVE" : "PASSIVE", + (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? + active_dwell : passive_dwell); + + scan_ch++; + added++; + } + + D_SCAN("total channels to scan %d\n", added); + return added; +} + +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +{ + struct il_host_cmd cmd = { + .id = REPLY_SCAN_CMD, + .len = sizeof(struct il_scan_cmd), + .flags = CMD_SIZE_HUGE, + }; + struct il_scan_cmd *scan; + struct il_rxon_context *ctx = &il->ctx; + u32 rate_flags = 0; + u16 cmd_len; + u16 rx_chain = 0; + enum ieee80211_band band; + u8 n_probes = 0; + u8 rx_ant = il->hw_params.valid_rx_ant; + u8 rate; + bool is_active = false; + int chan_mod; + u8 active_chains; + u8 scan_tx_antennas = il->hw_params.valid_tx_ant; + int ret; + + lockdep_assert_held(&il->mutex); + + if (vif) + ctx = il_rxon_ctx_from_vif(vif); + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); + if (!il->scan_cmd) { + D_SCAN( + "fail to allocate memory for scan\n"); + return -ENOMEM; + } + } + scan = il->scan_cmd; + memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); + + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; + + if (il_is_any_associated(il)) { + u16 interval; + u32 extra; + u32 suspend_time = 100; + u32 scan_suspend_time = 100; + + D_INFO("Scanning while associated...\n"); + interval = vif->bss_conf.beacon_int; + + scan->suspend_time = 0; + scan->max_out_time = cpu_to_le32(200 * 1024); + if (!interval) + interval = suspend_time; + + extra = (suspend_time / interval) << 22; + scan_suspend_time = (extra | + ((suspend_time % interval) * 1024)); + scan->suspend_time = cpu_to_le32(scan_suspend_time); + D_SCAN("suspend_time 0x%X beacon interval %d\n", + scan_suspend_time, interval); + } + + if (il->scan_request->n_ssids) { + int i, p = 0; + D_SCAN("Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { + /* always does wildcard anyway */ + if (!il->scan_request->ssids[i].ssid_len) + continue; + scan->direct_scan[p].id = WLAN_EID_SSID; + scan->direct_scan[p].len = + il->scan_request->ssids[i].ssid_len; + memcpy(scan->direct_scan[p].ssid, + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); + n_probes++; + p++; + } + is_active = true; + } else + D_SCAN("Start passive scan.\n"); + + scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; + scan->tx_cmd.sta_id = ctx->bcast_sta_id; + scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + + switch (il->scan_band) { + case IEEE80211_BAND_2GHZ: + scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; + chan_mod = le32_to_cpu( + il->ctx.active.flags & + RXON_FLG_CHANNEL_MODE_MSK) + >> RXON_FLG_CHANNEL_MODE_POS; + if (chan_mod == CHANNEL_MODE_PURE_40) { + rate = RATE_6M_PLCP; + } else { + rate = RATE_1M_PLCP; + rate_flags = RATE_MCS_CCK_MSK; + } + break; + case IEEE80211_BAND_5GHZ: + rate = RATE_6M_PLCP; + break; + default: + IL_WARN("Invalid scan band\n"); + return -EIO; + } + + /* + * If active scanning is requested but a certain channel is + * marked passive, we can do active scanning if we detect + * transmissions. + * + * There is an issue with some firmware versions that triggers + * a sysassert on a "good CRC threshold" of zero (== disabled), + * on a radar channel even though this means that we should NOT + * send probes. + * + * The "good CRC threshold" is the number of frames that we + * need to receive during our dwell time on a channel before + * sending out probes -- setting this to a huge value will + * mean we never reach it, but at the same time work around + * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER + * here instead of IL_GOOD_CRC_TH_DISABLED. + */ + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_NEVER; + + band = il->scan_band; + + if (il->cfg->scan_rx_antennas[band]) + rx_ant = il->cfg->scan_rx_antennas[band]; + + il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, + il->scan_tx_ant[band], + scan_tx_antennas); + rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); + scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); + + /* In power save mode use one chain, otherwise use all chains */ + if (test_bit(STATUS_POWER_PMI, &il->status)) { + /* rx_ant has been set to all valid chains previously */ + active_chains = rx_ant & + ((u8)(il->chain_noise_data.active_chains)); + if (!active_chains) + active_chains = rx_ant; + + D_SCAN("chain_noise_data.active_chains: %u\n", + il->chain_noise_data.active_chains); + + rx_ant = il4965_first_antenna(active_chains); + } + + /* MIMO is not used here, but value is required */ + rx_chain |= il->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; + rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; + rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; + rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; + scan->rx_chain = cpu_to_le16(rx_chain); + + cmd_len = il_fill_probe_req(il, + (struct ieee80211_mgmt *)scan->data, + vif->addr, + il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); + scan->tx_cmd.len = cpu_to_le16(cmd_len); + + scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | + RXON_FILTER_BCON_AWARE_MSK); + + scan->channel_count = il4965_get_channels_for_scan(il, vif, band, + is_active, n_probes, + (void *)&scan->data[cmd_len]); + if (scan->channel_count == 0) { + D_SCAN("channel count %d\n", scan->channel_count); + return -EIO; + } + + cmd.len += le16_to_cpu(scan->tx_cmd.len) + + scan->channel_count * sizeof(struct il_scan_channel); + cmd.data = scan; + scan->len = cpu_to_le16(cmd.len); + + set_bit(STATUS_SCAN_HW, &il->status); + + ret = il_send_cmd_sync(il, &cmd); + if (ret) + clear_bit(STATUS_SCAN_HW, &il->status); + + return ret; +} + +int il4965_manage_ibss_station(struct il_priv *il, + struct ieee80211_vif *vif, bool add) +{ + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + + if (add) + return il4965_add_bssid_station(il, vif_priv->ctx, + vif->bss_conf.bssid, + &vif_priv->ibss_bssid_sta_id); + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, + vif->bss_conf.bssid); +} + +void il4965_free_tfds_in_queue(struct il_priv *il, + int sta_id, int tid, int freed) +{ + lockdep_assert_held(&il->sta_lock); + + if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) + il->stations[sta_id].tid[tid].tfds_in_queue -= freed; + else { + D_TX("free more than tfds_in_queue (%u:%d)\n", + il->stations[sta_id].tid[tid].tfds_in_queue, + freed); + il->stations[sta_id].tid[tid].tfds_in_queue = 0; + } +} + +#define IL_TX_QUEUE_MSK 0xfffff + +static bool il4965_is_single_rx_stream(struct il_priv *il) +{ + return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || + il->current_ht_config.single_chain_sufficient; +} + +#define IL_NUM_RX_CHAINS_MULTIPLE 3 +#define IL_NUM_RX_CHAINS_SINGLE 2 +#define IL_NUM_IDLE_CHAINS_DUAL 2 +#define IL_NUM_IDLE_CHAINS_SINGLE 1 + +/* + * Determine how many receiver/antenna chains to use. + * + * More provides better reception via diversity. Fewer saves power + * at the expense of throughput, but only when not in powersave to + * start with. + * + * MIMO (dual stream) requires at least 2, but works better with 3. + * This does not determine *which* chains to use, just how many. + */ +static int il4965_get_active_rx_chain_count(struct il_priv *il) +{ + /* # of Rx chains to use when expecting MIMO. */ + if (il4965_is_single_rx_stream(il)) + return IL_NUM_RX_CHAINS_SINGLE; + else + return IL_NUM_RX_CHAINS_MULTIPLE; +} + +/* + * When we are in power saving mode, unless device support spatial + * multiplexing power save, use the active count for rx chain count. + */ +static int +il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) +{ + /* # Rx chains when idling, depending on SMPS mode */ + switch (il->current_ht_config.smps) { + case IEEE80211_SMPS_STATIC: + case IEEE80211_SMPS_DYNAMIC: + return IL_NUM_IDLE_CHAINS_SINGLE; + case IEEE80211_SMPS_OFF: + return active_cnt; + default: + WARN(1, "invalid SMPS mode %d", + il->current_ht_config.smps); + return active_cnt; + } +} + +/* up to 4 chains */ +static u8 il4965_count_chain_bitmap(u32 chain_bitmap) +{ + u8 res; + res = (chain_bitmap & BIT(0)) >> 0; + res += (chain_bitmap & BIT(1)) >> 1; + res += (chain_bitmap & BIT(2)) >> 2; + res += (chain_bitmap & BIT(3)) >> 3; + return res; +} + +/** + * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image + * + * Selects how many and which Rx receivers/antennas/chains to use. + * This should not be used for scan command ... it puts data in wrong place. + */ +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) +{ + bool is_single = il4965_is_single_rx_stream(il); + bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); + u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; + u32 active_chains; + u16 rx_chain; + + /* Tell uCode which antennas are actually connected. + * Before first association, we assume all antennas are connected. + * Just after first association, il4965_chain_noise_calibration() + * checks which antennas actually *are* connected. */ + if (il->chain_noise_data.active_chains) + active_chains = il->chain_noise_data.active_chains; + else + active_chains = il->hw_params.valid_rx_ant; + + rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; + + /* How many receivers should we use? */ + active_rx_cnt = il4965_get_active_rx_chain_count(il); + idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); + + + /* correct rx chain count according hw settings + * and chain noise calibration + */ + valid_rx_cnt = il4965_count_chain_bitmap(active_chains); + if (valid_rx_cnt < active_rx_cnt) + active_rx_cnt = valid_rx_cnt; + + if (valid_rx_cnt < idle_rx_cnt) + idle_rx_cnt = valid_rx_cnt; + + rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; + rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; + + ctx->staging.rx_chain = cpu_to_le16(rx_chain); + + if (!is_single && active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE && is_cam) + ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; + else + ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; + + D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", + ctx->staging.rx_chain, + active_rx_cnt, idle_rx_cnt); + + WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || + active_rx_cnt < idle_rx_cnt); +} + +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) +{ + int i; + u8 ind = ant; + + for (i = 0; i < RATE_ANT_NUM - 1; i++) { + ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; + if (valid & BIT(ind)) + return ind; + } + return ant; +} + +static const char *il4965_get_fh_string(int cmd) +{ + switch (cmd) { + IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH_RSCSR_CHNL0_WPTR); + IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH_TSSR_TX_STATUS_REG); + IL_CMD(FH_TSSR_TX_ERROR_REG); + default: + return "UNKNOWN"; + } +} + +int il4965_dump_fh(struct il_priv *il, char **buf, bool display) +{ + int i; +#ifdef CONFIG_IWLEGACY_DEBUG + int pos = 0; + size_t bufsz = 0; +#endif + static const u32 fh_tbl[] = { + FH_RSCSR_CHNL0_STTS_WPTR_REG, + FH_RSCSR_CHNL0_RBDCB_BASE_REG, + FH_RSCSR_CHNL0_WPTR, + FH_MEM_RCSR_CHNL0_CONFIG_REG, + FH_MEM_RSSR_SHARED_CTRL_REG, + FH_MEM_RSSR_RX_STATUS_REG, + FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, + FH_TSSR_TX_STATUS_REG, + FH_TSSR_TX_ERROR_REG + }; +#ifdef CONFIG_IWLEGACY_DEBUG + if (display) { + bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; + *buf = kmalloc(bufsz, GFP_KERNEL); + if (!*buf) + return -ENOMEM; + pos += scnprintf(*buf + pos, bufsz - pos, + "FH register values:\n"); + for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { + pos += scnprintf(*buf + pos, bufsz - pos, + " %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); + } + return pos; + } +#endif + IL_ERR("FH register values:\n"); + for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { + IL_ERR(" %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); + } + return 0; +} void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_buf *rxb) diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 8844704..d0f9f23 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -9,7 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-lib.o iwl-4965-calib.o +iwl4965-objs += iwl-4965-calib.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c deleted file mode 100644 index bbec6bd..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ /dev/null @@ -1,1194 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" -#include "iwl-sta.h" - -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status) -{ - if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IL_ERR("Tx flush command to flush out all frames\n"); - if (!test_bit(STATUS_EXIT_PENDING, &il->status)) - queue_work(il->workqueue, &il->tx_flush); - } -} - -/* - * EEPROM - */ -struct il_mod_params il4965_mod_params = { - .amsdu_size_8K = 1, - .restart_fw = 1, - /* the rest are 0 by default */ -}; - -void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) -{ - unsigned long flags; - int i; - spin_lock_irqsave(&rxq->lock, flags); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - /* Fill the rx_used queue with _all_ of the Rx buffers */ - for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { - /* In the reset function, these buffers may have been allocated - * to an SKB, so we need to unmap and free potential storage */ - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - list_add_tail(&rxq->pool[i].list, &rxq->rx_used); - } - - for (i = 0; i < RX_QUEUE_SIZE; i++) - rxq->queue[i] = NULL; - - /* Set us so that we have processed and used all buffers, but have - * not restocked the Rx queue with fresh buffers */ - rxq->read = rxq->write = 0; - rxq->write_actual = 0; - rxq->free_count = 0; - spin_unlock_irqrestore(&rxq->lock, flags); -} - -int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) -{ - u32 rb_size; - const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ - u32 rb_timeout = 0; - - if (il->cfg->mod_params->amsdu_size_8K) - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; - else - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; - - /* Stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - - /* Reset driver's Rx queue write idx */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); - - /* Tell device where to find RBD circular buffer in DRAM */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, - (u32)(rxq->bd_dma >> 8)); - - /* Tell device where in DRAM to update its Rx status */ - il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, - rxq->rb_stts_dma >> 4); - - /* Enable Rx DMA - * Direct rx interrupts to hosts - * Rx buffer size 4 or 8k - * RB timeout 0x10 - * 256 RBDs - */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | - FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | - rb_size| - (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| - (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); - - /* Set interrupt coalescing timer to default (2048 usecs) */ - il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); - - return 0; -} - -static void il4965_set_pwr_vmain(struct il_priv *il) -{ -/* - * (for documentation purposes) - * to set power to V_AUX, do: - - if (pci_pme_capable(il->pci_dev, PCI_D3cold)) - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VAUX, - ~APMG_PS_CTRL_MSK_PWR_SRC); - */ - - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); -} - -int il4965_hw_nic_init(struct il_priv *il) -{ - unsigned long flags; - struct il_rx_queue *rxq = &il->rxq; - int ret; - - /* nic_init */ - spin_lock_irqsave(&il->lock, flags); - il->cfg->ops->lib->apm_ops.init(il); - - /* Set interrupt coalescing calibration timer to default (512 usecs) */ - il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); - - spin_unlock_irqrestore(&il->lock, flags); - - il4965_set_pwr_vmain(il); - - il->cfg->ops->lib->apm_ops.config(il); - - /* Allocate the RX queue, or reset if it is already allocated */ - if (!rxq->bd) { - ret = il_rx_queue_alloc(il); - if (ret) { - IL_ERR("Unable to initialize Rx queue\n"); - return -ENOMEM; - } - } else - il4965_rx_queue_reset(il, rxq); - - il4965_rx_replenish(il); - - il4965_rx_init(il, rxq); - - spin_lock_irqsave(&il->lock, flags); - - rxq->need_update = 1; - il_rx_queue_update_write_ptr(il, rxq); - - spin_unlock_irqrestore(&il->lock, flags); - - /* Allocate or reset and init all Tx and Command queues */ - if (!il->txq) { - ret = il4965_txq_ctx_alloc(il); - if (ret) - return ret; - } else - il4965_txq_ctx_reset(il); - - set_bit(STATUS_INIT, &il->status); - - return 0; -} - -/** - * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr - */ -static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) -{ - return cpu_to_le32((u32)(dma_addr >> 8)); -} - -/** - * il4965_rx_queue_restock - refill RX queue from pre-allocated pool - * - * If there are slots in the RX queue that need to be restocked, - * and we have free pre-allocated buffers, fill the ranks as much - * as we can, pulling from rx_free. - * - * This moves the 'write' idx forward to catch up with 'processed', and - * also updates the memory address in the firmware to reference the new - * target buffer. - */ -void il4965_rx_queue_restock(struct il_priv *il) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - unsigned long flags; - - spin_lock_irqsave(&rxq->lock, flags); - while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { - /* The overwritten rxb must be a used one */ - rxb = rxq->queue[rxq->write]; - BUG_ON(rxb && rxb->page); - - /* Get next free Rx buffer, remove from free list */ - element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - - /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, - rxb->page_dma); - rxq->queue[rxq->write] = rxb; - rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; - rxq->free_count--; - } - spin_unlock_irqrestore(&rxq->lock, flags); - /* If the pre-allocated buffer pool is dropping low, schedule to - * refill it */ - if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(il->workqueue, &il->rx_replenish); - - - /* If we've added more space for the firmware to place data, tell it. - * Increment device's write pointer in multiples of 8. */ - if (rxq->write_actual != (rxq->write & ~0x7)) { - spin_lock_irqsave(&rxq->lock, flags); - rxq->need_update = 1; - spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(il, rxq); - } -} - -/** - * il4965_rx_replenish - Move all used packet from rx_used to rx_free - * - * When moving to rx_free an SKB is allocated for the slot. - * - * Also restock the Rx queue via il_rx_queue_restock. - * This is called as a scheduled work item (except for during initialization) - */ -static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - struct page *page; - unsigned long flags; - gfp_t gfp_mask = priority; - - while (1) { - spin_lock_irqsave(&rxq->lock, flags); - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - return; - } - spin_unlock_irqrestore(&rxq->lock, flags); - - if (rxq->free_count > RX_LOW_WATERMARK) - gfp_mask |= __GFP_NOWARN; - - if (il->hw_params.rx_page_order > 0) - gfp_mask |= __GFP_COMP; - - /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); - if (!page) { - if (net_ratelimit()) - D_INFO("alloc_pages failed, " - "order: %d\n", - il->hw_params.rx_page_order); - - if (rxq->free_count <= RX_LOW_WATERMARK && - net_ratelimit()) - IL_ERR( - "Failed to alloc_pages with %s. " - "Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? - "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); - /* We don't reschedule replenish work here -- we will - * call the restock method and if it still needs - * more buffers it will schedule replenish */ - return; - } - - spin_lock_irqsave(&rxq->lock, flags); - - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, il->hw_params.rx_page_order); - return; - } - element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - - spin_unlock_irqrestore(&rxq->lock, flags); - - BUG_ON(rxb->page); - rxb->page = page; - /* Get physical address of the RB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - /* dma address must be no more than 36 bits */ - BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); - /* and also 256 byte aligned! */ - BUG_ON(rxb->page_dma & DMA_BIT_MASK(8)); - - spin_lock_irqsave(&rxq->lock, flags); - - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - il->alloc_rxb_page++; - - spin_unlock_irqrestore(&rxq->lock, flags); - } -} - -void il4965_rx_replenish(struct il_priv *il) -{ - unsigned long flags; - - il4965_rx_allocate(il, GFP_KERNEL); - - spin_lock_irqsave(&il->lock, flags); - il4965_rx_queue_restock(il); - spin_unlock_irqrestore(&il->lock, flags); -} - -void il4965_rx_replenish_now(struct il_priv *il) -{ - il4965_rx_allocate(il, GFP_ATOMIC); - - il4965_rx_queue_restock(il); -} - -/* Assumes that the skb field of the buffers in 'pool' is kept accurate. - * If an SKB has been detached, the POOL needs to have its SKB set to NULL - * This free routine walks the list of POOL entries and if SKB is set to - * non NULL it is unmapped and freed - */ -void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) -{ - int i; - for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - } - - dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, - rxq->bd_dma); - dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), - rxq->rb_stts, rxq->rb_stts_dma); - rxq->bd = NULL; - rxq->rb_stts = NULL; -} - -int il4965_rxq_stop(struct il_priv *il) -{ - - /* stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, - FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); - - return 0; -} - -int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) -{ - int idx = 0; - int band_offset = 0; - - /* HT rate format: mac80211 wants an MCS number, which is just LSB */ - if (rate_n_flags & RATE_MCS_HT_MSK) { - idx = (rate_n_flags & 0xff); - return idx; - /* Legacy rate format, search for match in table */ - } else { - if (band == IEEE80211_BAND_5GHZ) - band_offset = IL_FIRST_OFDM_RATE; - for (idx = band_offset; idx < RATE_COUNT_LEGACY; idx++) - if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) - return idx - band_offset; - } - - return -1; -} - -static int il4965_calc_rssi(struct il_priv *il, - struct il_rx_phy_res *rx_resp) -{ - /* data from PHY/DSP regarding signal strength, etc., - * contents are always there, not configurable by host. */ - struct il4965_rx_non_cfg_phy *ncphy = - (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; - u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) - >> IL49_AGC_DB_POS; - - u32 valid_antennae = - (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) - >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; - u8 max_rssi = 0; - u32 i; - - /* Find max rssi among 3 possible receivers. - * These values are measured by the digital signal processor (DSP). - * They should stay fairly constant even as the signal strength varies, - * if the radio's automatic gain control (AGC) is working right. - * AGC value (see below) will provide the "interesting" info. */ - for (i = 0; i < 3; i++) - if (valid_antennae & (1 << i)) - max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - - D_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", - ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], - max_rssi, agc); - - /* dBm = max_rssi dB - agc dB - constant. - * Higher AGC (higher radio gain) means lower signal. */ - return max_rssi - agc - IL4965_RSSI_OFFSET; -} - - -static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) -{ - u32 decrypt_out = 0; - - if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) == - RX_RES_STATUS_STATION_FOUND) - decrypt_out |= (RX_RES_STATUS_STATION_FOUND | - RX_RES_STATUS_NO_STATION_INFO_MISMATCH); - - decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK); - - /* packet was not encrypted */ - if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_NONE) - return decrypt_out; - - /* packet was encrypted with unknown alg */ - if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_ERR) - return decrypt_out; - - /* decryption was not done in HW */ - if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) != - RX_MPDU_RES_STATUS_DEC_DONE_MSK) - return decrypt_out; - - switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) { - - case RX_RES_STATUS_SEC_TYPE_CCMP: - /* alg is CCM: check MIC only */ - if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK)) - /* Bad MIC */ - decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; - else - decrypt_out |= RX_RES_STATUS_DECRYPT_OK; - - break; - - case RX_RES_STATUS_SEC_TYPE_TKIP: - if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) { - /* Bad TTAK */ - decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK; - break; - } - /* fall through if TTAK OK */ - default: - if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK)) - decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; - else - decrypt_out |= RX_RES_STATUS_DECRYPT_OK; - break; - } - - D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", - decrypt_in, decrypt_out); - - return decrypt_out; -} - -static void il4965_pass_packet_to_mac80211(struct il_priv *il, - struct ieee80211_hdr *hdr, - u16 len, - u32 ampdu_status, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) -{ - struct sk_buff *skb; - __le16 fc = hdr->frame_control; - - /* We only process data packets if the interface is open */ - if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); - return; - } - - /* In case of HW accelerated crypto and bad decryption, drop */ - if (!il->cfg->mod_params->sw_crypto && - il_set_decrypted_flag(il, hdr, ampdu_status, stats)) - return; - - skb = dev_alloc_skb(128); - if (!skb) { - IL_ERR("dev_alloc_skb failed\n"); - return; - } - - skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); - - il_update_stats(il, false, fc, len); - memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - - ieee80211_rx(il->hw, skb); - il->alloc_rxb_page--; - rxb->page = NULL; -} - -/* Called for REPLY_RX (legacy ABG frames), or - * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ -void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct ieee80211_hdr *header; - struct ieee80211_rx_status rx_status; - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_rx_phy_res *phy_res; - __le32 rx_pkt_status; - struct il_rx_mpdu_res_start *amsdu; - u32 len; - u32 ampdu_status; - u32 rate_n_flags; - - /** - * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. - * REPLY_RX: physical layer info is in this buffer - * REPLY_RX_MPDU_CMD: physical layer info was sent in separate - * command and cached in il->last_phy_res - * - * Here we set up local variables depending on which command is - * received. - */ - if (pkt->hdr.cmd == REPLY_RX) { - phy_res = (struct il_rx_phy_res *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) - + phy_res->cfg_phy_cnt); - - len = le16_to_cpu(phy_res->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) + - phy_res->cfg_phy_cnt + len); - ampdu_status = le32_to_cpu(rx_pkt_status); - } else { - if (!il->_4965.last_phy_res_valid) { - IL_ERR("MPDU frame without cached PHY data\n"); - return; - } - phy_res = &il->_4965.last_phy_res; - amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); - len = le16_to_cpu(amsdu->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = il4965_translate_rx_status(il, - le32_to_cpu(rx_pkt_status)); - } - - if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - D_DROP("dsp size out of range [0,20]: %d/n", - phy_res->cfg_phy_cnt); - return; - } - - if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || - !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - D_RX("Bad CRC or FIFO: 0x%08X.\n", - le32_to_cpu(rx_pkt_status)); - return; - } - - /* This will be used in several places later */ - rate_n_flags = le32_to_cpu(phy_res->rate_n_flags); - - /* rx_status carries information about the packet to mac80211 */ - rx_status.mactime = le64_to_cpu(phy_res->timestamp); - rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; - rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), - rx_status.band); - rx_status.rate_idx = - il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); - rx_status.flag = 0; - - /* TSF isn't reliable. In order to allow smooth user experience, - * this W/A doesn't propagate it to the mac80211 */ - /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ - - il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); - - /* Find max signal strength (dBm) among 3 antenna/receiver chains */ - rx_status.signal = il4965_calc_rssi(il, phy_res); - - il_dbg_log_rx_data_frame(il, len, header); - D_STATS("Rssi %d, TSF %llu\n", - rx_status.signal, (unsigned long long)rx_status.mactime); - - /* - * "antenna number" - * - * It seems that the antenna field in the phy flags value - * is actually a bit field. This is undefined by radiotap, - * it wants an actual antenna number but I always get "7" - * for most legacy frames I receive indicating that the - * same frame was received on all three RX chains. - * - * I think this field should be removed in favor of a - * new 802.11n radiotap field "RX chains" that is defined - * as a bitmask. - */ - rx_status.antenna = - (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) - >> RX_RES_PHY_FLAGS_ANTENNA_POS; - - /* set the preamble flag if appropriate */ - if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) - rx_status.flag |= RX_FLAG_SHORTPRE; - - /* Set up the HT phy flags */ - if (rate_n_flags & RATE_MCS_HT_MSK) - rx_status.flag |= RX_FLAG_HT; - if (rate_n_flags & RATE_MCS_HT40_MSK) - rx_status.flag |= RX_FLAG_40MHZ; - if (rate_n_flags & RATE_MCS_SGI_MSK) - rx_status.flag |= RX_FLAG_SHORT_GI; - - il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, - rxb, &rx_status); -} - -/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). - * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ -void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - il->_4965.last_phy_res_valid = true; - memcpy(&il->_4965.last_phy_res, pkt->u.raw, - sizeof(struct il_rx_phy_res)); -} - -static int il4965_get_channels_for_scan(struct il_priv *il, - struct ieee80211_vif *vif, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il_scan_channel *scan_ch) -{ - struct ieee80211_channel *chan; - const struct ieee80211_supported_band *sband; - const struct il_channel_info *ch_info; - u16 passive_dwell = 0; - u16 active_dwell = 0; - int added, i; - u16 channel; - - sband = il_get_hw_mode(il, band); - if (!sband) - return 0; - - active_dwell = il_get_active_dwell_time(il, band, n_probes); - passive_dwell = il_get_passive_dwell_time(il, band, vif); - - if (passive_dwell <= active_dwell) - passive_dwell = active_dwell + 1; - - for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { - chan = il->scan_request->channels[i]; - - if (chan->band != band) - continue; - - channel = chan->hw_value; - scan_ch->channel = cpu_to_le16(channel); - - ch_info = il_get_channel_info(il, band, channel); - if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", - channel); - continue; - } - - if (!is_active || il_is_channel_passive(ch_info) || - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) - scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; - else - scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; - - if (n_probes) - scan_ch->type |= IL_SCAN_PROBE_MASK(n_probes); - - scan_ch->active_dwell = cpu_to_le16(active_dwell); - scan_ch->passive_dwell = cpu_to_le16(passive_dwell); - - /* Set txpower levels to defaults */ - scan_ch->dsp_atten = 110; - - /* NOTE: if we were doing 6Mb OFDM for scans we'd use - * power level: - * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; - */ - if (band == IEEE80211_BAND_5GHZ) - scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; - else - scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - - D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", - channel, le32_to_cpu(scan_ch->type), - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - "ACTIVE" : "PASSIVE", - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - active_dwell : passive_dwell); - - scan_ch++; - added++; - } - - D_SCAN("total channels to scan %d\n", added); - return added; -} - -int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) -{ - struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, - .len = sizeof(struct il_scan_cmd), - .flags = CMD_SIZE_HUGE, - }; - struct il_scan_cmd *scan; - struct il_rxon_context *ctx = &il->ctx; - u32 rate_flags = 0; - u16 cmd_len; - u16 rx_chain = 0; - enum ieee80211_band band; - u8 n_probes = 0; - u8 rx_ant = il->hw_params.valid_rx_ant; - u8 rate; - bool is_active = false; - int chan_mod; - u8 active_chains; - u8 scan_tx_antennas = il->hw_params.valid_tx_ant; - int ret; - - lockdep_assert_held(&il->mutex); - - if (vif) - ctx = il_rxon_ctx_from_vif(vif); - - if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!il->scan_cmd) { - D_SCAN( - "fail to allocate memory for scan\n"); - return -ENOMEM; - } - } - scan = il->scan_cmd; - memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); - - scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; - scan->quiet_time = IL_ACTIVE_QUIET_TIME; - - if (il_is_any_associated(il)) { - u16 interval; - u32 extra; - u32 suspend_time = 100; - u32 scan_suspend_time = 100; - - D_INFO("Scanning while associated...\n"); - interval = vif->bss_conf.beacon_int; - - scan->suspend_time = 0; - scan->max_out_time = cpu_to_le32(200 * 1024); - if (!interval) - interval = suspend_time; - - extra = (suspend_time / interval) << 22; - scan_suspend_time = (extra | - ((suspend_time % interval) * 1024)); - scan->suspend_time = cpu_to_le32(scan_suspend_time); - D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); - } - - if (il->scan_request->n_ssids) { - int i, p = 0; - D_SCAN("Kicking off active scan\n"); - for (i = 0; i < il->scan_request->n_ssids; i++) { - /* always does wildcard anyway */ - if (!il->scan_request->ssids[i].ssid_len) - continue; - scan->direct_scan[p].id = WLAN_EID_SSID; - scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; - memcpy(scan->direct_scan[p].ssid, - il->scan_request->ssids[i].ssid, - il->scan_request->ssids[i].ssid_len); - n_probes++; - p++; - } - is_active = true; - } else - D_SCAN("Start passive scan.\n"); - - scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = ctx->bcast_sta_id; - scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - - switch (il->scan_band) { - case IEEE80211_BAND_2GHZ: - scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - chan_mod = le32_to_cpu( - il->ctx.active.flags & - RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; - if (chan_mod == CHANNEL_MODE_PURE_40) { - rate = RATE_6M_PLCP; - } else { - rate = RATE_1M_PLCP; - rate_flags = RATE_MCS_CCK_MSK; - } - break; - case IEEE80211_BAND_5GHZ: - rate = RATE_6M_PLCP; - break; - default: - IL_WARN("Invalid scan band\n"); - return -EIO; - } - - /* - * If active scanning is requested but a certain channel is - * marked passive, we can do active scanning if we detect - * transmissions. - * - * There is an issue with some firmware versions that triggers - * a sysassert on a "good CRC threshold" of zero (== disabled), - * on a radar channel even though this means that we should NOT - * send probes. - * - * The "good CRC threshold" is the number of frames that we - * need to receive during our dwell time on a channel before - * sending out probes -- setting this to a huge value will - * mean we never reach it, but at the same time work around - * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER - * here instead of IL_GOOD_CRC_TH_DISABLED. - */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_NEVER; - - band = il->scan_band; - - if (il->cfg->scan_rx_antennas[band]) - rx_ant = il->cfg->scan_rx_antennas[band]; - - il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, - il->scan_tx_ant[band], - scan_tx_antennas); - rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); - scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); - - /* In power save mode use one chain, otherwise use all chains */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { - /* rx_ant has been set to all valid chains previously */ - active_chains = rx_ant & - ((u8)(il->chain_noise_data.active_chains)); - if (!active_chains) - active_chains = rx_ant; - - D_SCAN("chain_noise_data.active_chains: %u\n", - il->chain_noise_data.active_chains); - - rx_ant = il4965_first_antenna(active_chains); - } - - /* MIMO is not used here, but value is required */ - rx_chain |= il->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; - rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; - rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; - rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; - scan->rx_chain = cpu_to_le16(rx_chain); - - cmd_len = il_fill_probe_req(il, - (struct ieee80211_mgmt *)scan->data, - vif->addr, - il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); - scan->tx_cmd.len = cpu_to_le16(cmd_len); - - scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | - RXON_FILTER_BCON_AWARE_MSK); - - scan->channel_count = il4965_get_channels_for_scan(il, vif, band, - is_active, n_probes, - (void *)&scan->data[cmd_len]); - if (scan->channel_count == 0) { - D_SCAN("channel count %d\n", scan->channel_count); - return -EIO; - } - - cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct il_scan_channel); - cmd.data = scan; - scan->len = cpu_to_le16(cmd.len); - - set_bit(STATUS_SCAN_HW, &il->status); - - ret = il_send_cmd_sync(il, &cmd); - if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); - - return ret; -} - -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) -{ - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - - if (add) - return il4965_add_bssid_station(il, vif_priv->ctx, - vif->bss_conf.bssid, - &vif_priv->ibss_bssid_sta_id); - return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); -} - -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed) -{ - lockdep_assert_held(&il->sta_lock); - - if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) - il->stations[sta_id].tid[tid].tfds_in_queue -= freed; - else { - D_TX("free more than tfds_in_queue (%u:%d)\n", - il->stations[sta_id].tid[tid].tfds_in_queue, - freed); - il->stations[sta_id].tid[tid].tfds_in_queue = 0; - } -} - -#define IL_TX_QUEUE_MSK 0xfffff - -static bool il4965_is_single_rx_stream(struct il_priv *il) -{ - return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || - il->current_ht_config.single_chain_sufficient; -} - -#define IL_NUM_RX_CHAINS_MULTIPLE 3 -#define IL_NUM_RX_CHAINS_SINGLE 2 -#define IL_NUM_IDLE_CHAINS_DUAL 2 -#define IL_NUM_IDLE_CHAINS_SINGLE 1 - -/* - * Determine how many receiver/antenna chains to use. - * - * More provides better reception via diversity. Fewer saves power - * at the expense of throughput, but only when not in powersave to - * start with. - * - * MIMO (dual stream) requires at least 2, but works better with 3. - * This does not determine *which* chains to use, just how many. - */ -static int il4965_get_active_rx_chain_count(struct il_priv *il) -{ - /* # of Rx chains to use when expecting MIMO. */ - if (il4965_is_single_rx_stream(il)) - return IL_NUM_RX_CHAINS_SINGLE; - else - return IL_NUM_RX_CHAINS_MULTIPLE; -} - -/* - * When we are in power saving mode, unless device support spatial - * multiplexing power save, use the active count for rx chain count. - */ -static int -il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) -{ - /* # Rx chains when idling, depending on SMPS mode */ - switch (il->current_ht_config.smps) { - case IEEE80211_SMPS_STATIC: - case IEEE80211_SMPS_DYNAMIC: - return IL_NUM_IDLE_CHAINS_SINGLE; - case IEEE80211_SMPS_OFF: - return active_cnt; - default: - WARN(1, "invalid SMPS mode %d", - il->current_ht_config.smps); - return active_cnt; - } -} - -/* up to 4 chains */ -static u8 il4965_count_chain_bitmap(u32 chain_bitmap) -{ - u8 res; - res = (chain_bitmap & BIT(0)) >> 0; - res += (chain_bitmap & BIT(1)) >> 1; - res += (chain_bitmap & BIT(2)) >> 2; - res += (chain_bitmap & BIT(3)) >> 3; - return res; -} - -/** - * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image - * - * Selects how many and which Rx receivers/antennas/chains to use. - * This should not be used for scan command ... it puts data in wrong place. - */ -void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) -{ - bool is_single = il4965_is_single_rx_stream(il); - bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); - u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; - u32 active_chains; - u16 rx_chain; - - /* Tell uCode which antennas are actually connected. - * Before first association, we assume all antennas are connected. - * Just after first association, il4965_chain_noise_calibration() - * checks which antennas actually *are* connected. */ - if (il->chain_noise_data.active_chains) - active_chains = il->chain_noise_data.active_chains; - else - active_chains = il->hw_params.valid_rx_ant; - - rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; - - /* How many receivers should we use? */ - active_rx_cnt = il4965_get_active_rx_chain_count(il); - idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); - - - /* correct rx chain count according hw settings - * and chain noise calibration - */ - valid_rx_cnt = il4965_count_chain_bitmap(active_chains); - if (valid_rx_cnt < active_rx_cnt) - active_rx_cnt = valid_rx_cnt; - - if (valid_rx_cnt < idle_rx_cnt) - idle_rx_cnt = valid_rx_cnt; - - rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; - rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; - - ctx->staging.rx_chain = cpu_to_le16(rx_chain); - - if (!is_single && active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE && is_cam) - ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; - else - ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - - D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", - ctx->staging.rx_chain, - active_rx_cnt, idle_rx_cnt); - - WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || - active_rx_cnt < idle_rx_cnt); -} - -u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) -{ - int i; - u8 ind = ant; - - for (i = 0; i < RATE_ANT_NUM - 1; i++) { - ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; - if (valid & BIT(ind)) - return ind; - } - return ant; -} - -static const char *il4965_get_fh_string(int cmd) -{ - switch (cmd) { - IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); - IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); - IL_CMD(FH_RSCSR_CHNL0_WPTR); - IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); - IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); - IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); - IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IL_CMD(FH_TSSR_TX_STATUS_REG); - IL_CMD(FH_TSSR_TX_ERROR_REG); - default: - return "UNKNOWN"; - } -} - -int il4965_dump_fh(struct il_priv *il, char **buf, bool display) -{ - int i; -#ifdef CONFIG_IWLEGACY_DEBUG - int pos = 0; - size_t bufsz = 0; -#endif - static const u32 fh_tbl[] = { - FH_RSCSR_CHNL0_STTS_WPTR_REG, - FH_RSCSR_CHNL0_RBDCB_BASE_REG, - FH_RSCSR_CHNL0_WPTR, - FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_MEM_RSSR_SHARED_CTRL_REG, - FH_MEM_RSSR_RX_STATUS_REG, - FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, - FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_ERROR_REG - }; -#ifdef CONFIG_IWLEGACY_DEBUG - if (display) { - bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; - *buf = kmalloc(bufsz, GFP_KERNEL); - if (!*buf) - return -ENOMEM; - pos += scnprintf(*buf + pos, bufsz - pos, - "FH register values:\n"); - for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - pos += scnprintf(*buf + pos, bufsz - pos, - " %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); - } - return pos; - } -#endif - IL_ERR("FH register values:\n"); - for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(" %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); - } - return 0; -} -- cgit v0.10.2 From f3a1b49d669472159e05327fff64ec55315a0f54 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 13:14:41 +0200 Subject: iwlegacy: rename iwl-4965-{rs,calib,debugfs}.c to 4965-{rs,calib,debug}.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c new file mode 100644 index 0000000..1d873a6 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -0,0 +1,966 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#include +#include + +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-4965-calib.h" + +/***************************************************************************** + * INIT calibrations framework + *****************************************************************************/ + +struct stats_general_data { + u32 beacon_silence_rssi_a; + u32 beacon_silence_rssi_b; + u32 beacon_silence_rssi_c; + u32 beacon_energy_a; + u32 beacon_energy_b; + u32 beacon_energy_c; +}; + +void il4965_calib_free_results(struct il_priv *il) +{ + int i; + + for (i = 0; i < IL_CALIB_MAX; i++) { + kfree(il->calib_results[i].buf); + il->calib_results[i].buf = NULL; + il->calib_results[i].buf_len = 0; + } +} + +/***************************************************************************** + * RUNTIME calibrations framework + *****************************************************************************/ + +/* "false alarms" are signals that our DSP tries to lock onto, + * but then determines that they are either noise, or transmissions + * from a distant wireless network (also "noise", really) that get + * "stepped on" by stronger transmissions within our own network. + * This algorithm attempts to set a sensitivity level that is high + * enough to receive all of our own network traffic, but not so + * high that our DSP gets too busy trying to lock onto non-network + * activity/noise. */ +static int il4965_sens_energy_cck(struct il_priv *il, + u32 norm_fa, + u32 rx_enable_time, + struct stats_general_data *rx_info) +{ + u32 max_nrg_cck = 0; + int i = 0; + u8 max_silence_rssi = 0; + u32 silence_ref = 0; + u8 silence_rssi_a = 0; + u8 silence_rssi_b = 0; + u8 silence_rssi_c = 0; + u32 val; + + /* "false_alarms" values below are cross-multiplications to assess the + * numbers of false alarms within the measured period of actual Rx + * (Rx is off when we're txing), vs the min/max expected false alarms + * (some should be expected if rx is sensitive enough) in a + * hypothetical listening period of 200 time units (TU), 204.8 msec: + * + * MIN_FA/fixed-time < false_alarms/actual-rx-time < MAX_FA/beacon-time + * + * */ + u32 false_alarms = norm_fa * 200 * 1024; + u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; + u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; + + data = &(il->sensitivity_data); + + data->nrg_auto_corr_silence_diff = 0; + + /* Find max silence rssi among all 3 receivers. + * This is background noise, which may include transmissions from other + * networks, measured during silence before our network's beacon */ + silence_rssi_a = (u8)((rx_info->beacon_silence_rssi_a & + ALL_BAND_FILTER) >> 8); + silence_rssi_b = (u8)((rx_info->beacon_silence_rssi_b & + ALL_BAND_FILTER) >> 8); + silence_rssi_c = (u8)((rx_info->beacon_silence_rssi_c & + ALL_BAND_FILTER) >> 8); + + val = max(silence_rssi_b, silence_rssi_c); + max_silence_rssi = max(silence_rssi_a, (u8) val); + + /* Store silence rssi in 20-beacon history table */ + data->nrg_silence_rssi[data->nrg_silence_idx] = max_silence_rssi; + data->nrg_silence_idx++; + if (data->nrg_silence_idx >= NRG_NUM_PREV_STAT_L) + data->nrg_silence_idx = 0; + + /* Find max silence rssi across 20 beacon history */ + for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) { + val = data->nrg_silence_rssi[i]; + silence_ref = max(silence_ref, val); + } + D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", + silence_rssi_a, silence_rssi_b, silence_rssi_c, + silence_ref); + + /* Find max rx energy (min value!) among all 3 receivers, + * measured during beacon frame. + * Save it in 10-beacon history table. */ + i = data->nrg_energy_idx; + val = min(rx_info->beacon_energy_b, rx_info->beacon_energy_c); + data->nrg_value[i] = min(rx_info->beacon_energy_a, val); + + data->nrg_energy_idx++; + if (data->nrg_energy_idx >= 10) + data->nrg_energy_idx = 0; + + /* Find min rx energy (max value) across 10 beacon history. + * This is the minimum signal level that we want to receive well. + * Add backoff (margin so we don't miss slightly lower energy frames). + * This establishes an upper bound (min value) for energy threshold. */ + max_nrg_cck = data->nrg_value[0]; + for (i = 1; i < 10; i++) + max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); + max_nrg_cck += 6; + + D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + rx_info->beacon_energy_a, rx_info->beacon_energy_b, + rx_info->beacon_energy_c, max_nrg_cck - 6); + + /* Count number of consecutive beacons with fewer-than-desired + * false alarms. */ + if (false_alarms < min_false_alarms) + data->num_in_cck_no_fa++; + else + data->num_in_cck_no_fa = 0; + D_CALIB("consecutive bcns with few false alarms = %u\n", + data->num_in_cck_no_fa); + + /* If we got too many false alarms this time, reduce sensitivity */ + if (false_alarms > max_false_alarms && + data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { + D_CALIB("norm FA %u > max FA %u\n", + false_alarms, max_false_alarms); + D_CALIB("... reducing sensitivity\n"); + data->nrg_curr_state = IL_FA_TOO_MANY; + /* Store for "fewer than desired" on later beacon */ + data->nrg_silence_ref = silence_ref; + + /* increase energy threshold (reduce nrg value) + * to decrease sensitivity */ + data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; + /* Else if we got fewer than desired, increase sensitivity */ + } else if (false_alarms < min_false_alarms) { + data->nrg_curr_state = IL_FA_TOO_FEW; + + /* Compare silence level with silence level for most recent + * healthy number or too many false alarms */ + data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - + (s32)silence_ref; + + D_CALIB( + "norm FA %u < min FA %u, silence diff %d\n", + false_alarms, min_false_alarms, + data->nrg_auto_corr_silence_diff); + + /* Increase value to increase sensitivity, but only if: + * 1a) previous beacon did *not* have *too many* false alarms + * 1b) AND there's a significant difference in Rx levels + * from a previous beacon with too many, or healthy # FAs + * OR 2) We've seen a lot of beacons (100) with too few + * false alarms */ + if (data->nrg_prev_state != IL_FA_TOO_MANY && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { + + D_CALIB("... increasing sensitivity\n"); + /* Increase nrg value to increase sensitivity */ + val = data->nrg_th_cck + NRG_STEP_CCK; + data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); + } else { + D_CALIB( + "... but not changing sensitivity\n"); + } + + /* Else we got a healthy number of false alarms, keep status quo */ + } else { + D_CALIB(" FA in safe zone\n"); + data->nrg_curr_state = IL_FA_GOOD_RANGE; + + /* Store for use in "fewer than desired" with later beacon */ + data->nrg_silence_ref = silence_ref; + + /* If previous beacon had too many false alarms, + * give it some extra margin by reducing sensitivity again + * (but don't go below measured energy of desired Rx) */ + if (IL_FA_TOO_MANY == data->nrg_prev_state) { + D_CALIB("... increasing margin\n"); + if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) + data->nrg_th_cck -= NRG_MARGIN; + else + data->nrg_th_cck = max_nrg_cck; + } + } + + /* Make sure the energy threshold does not go above the measured + * energy of the desired Rx signals (reduced by backoff margin), + * or else we might start missing Rx frames. + * Lower value is higher energy, so we use max()! + */ + data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); + D_CALIB("new nrg_th_cck %u\n", data->nrg_th_cck); + + data->nrg_prev_state = data->nrg_curr_state; + + /* Auto-correlation CCK algorithm */ + if (false_alarms > min_false_alarms) { + + /* increase auto_corr values to decrease sensitivity + * so the DSP won't be disturbed by the noise + */ + if (data->auto_corr_cck < AUTO_CORR_MAX_TH_CCK) + data->auto_corr_cck = AUTO_CORR_MAX_TH_CCK + 1; + else { + val = data->auto_corr_cck + AUTO_CORR_STEP_CCK; + data->auto_corr_cck = + min((u32)ranges->auto_corr_max_cck, val); + } + val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; + data->auto_corr_cck_mrc = + min((u32)ranges->auto_corr_max_cck_mrc, val); + } else if (false_alarms < min_false_alarms && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { + + /* Decrease auto_corr values to increase sensitivity */ + val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; + data->auto_corr_cck = + max((u32)ranges->auto_corr_min_cck, val); + val = data->auto_corr_cck_mrc - AUTO_CORR_STEP_CCK; + data->auto_corr_cck_mrc = + max((u32)ranges->auto_corr_min_cck_mrc, val); + } + + return 0; +} + + +static int il4965_sens_auto_corr_ofdm(struct il_priv *il, + u32 norm_fa, + u32 rx_enable_time) +{ + u32 val; + u32 false_alarms = norm_fa * 200 * 1024; + u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; + u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; + + data = &(il->sensitivity_data); + + /* If we got too many false alarms this time, reduce sensitivity */ + if (false_alarms > max_false_alarms) { + + D_CALIB("norm FA %u > max FA %u)\n", + false_alarms, max_false_alarms); + + val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm = + min((u32)ranges->auto_corr_max_ofdm, val); + + val = data->auto_corr_ofdm_mrc + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc = + min((u32)ranges->auto_corr_max_ofdm_mrc, val); + + val = data->auto_corr_ofdm_x1 + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_x1 = + min((u32)ranges->auto_corr_max_ofdm_x1, val); + + val = data->auto_corr_ofdm_mrc_x1 + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc_x1 = + min((u32)ranges->auto_corr_max_ofdm_mrc_x1, val); + } + + /* Else if we got fewer than desired, increase sensitivity */ + else if (false_alarms < min_false_alarms) { + + D_CALIB("norm FA %u < min FA %u\n", + false_alarms, min_false_alarms); + + val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm = + max((u32)ranges->auto_corr_min_ofdm, val); + + val = data->auto_corr_ofdm_mrc - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc = + max((u32)ranges->auto_corr_min_ofdm_mrc, val); + + val = data->auto_corr_ofdm_x1 - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_x1 = + max((u32)ranges->auto_corr_min_ofdm_x1, val); + + val = data->auto_corr_ofdm_mrc_x1 - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc_x1 = + max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); + } else { + D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", + min_false_alarms, false_alarms, max_false_alarms); + } + return 0; +} + +static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, + struct il_sensitivity_data *data, + __le16 *tbl) +{ + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm); + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm_mrc); + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm_x1); + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); + + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = + cpu_to_le16((u16)data->auto_corr_cck); + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16((u16)data->auto_corr_cck_mrc); + + tbl[HD_MIN_ENERGY_CCK_DET_IDX] = + cpu_to_le16((u16)data->nrg_th_cck); + tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = + cpu_to_le16((u16)data->nrg_th_ofdm); + + tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = + cpu_to_le16(data->barker_corr_th_min); + tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16(data->barker_corr_th_min_mrc); + tbl[HD_OFDM_ENERGY_TH_IN_IDX] = + cpu_to_le16(data->nrg_th_cca); + + D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, + data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, + data->nrg_th_ofdm); + + D_CALIB("cck: ac %u mrc %u thresh %u\n", + data->auto_corr_cck, data->auto_corr_cck_mrc, + data->nrg_th_cck); +} + +/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ +static int il4965_sensitivity_write(struct il_priv *il) +{ + struct il_sensitivity_cmd cmd; + struct il_sensitivity_data *data = NULL; + struct il_host_cmd cmd_out = { + .id = SENSITIVITY_CMD, + .len = sizeof(struct il_sensitivity_cmd), + .flags = CMD_ASYNC, + .data = &cmd, + }; + + data = &(il->sensitivity_data); + + memset(&cmd, 0, sizeof(cmd)); + + il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); + + /* Update uCode's "work" table, and copy it to DSP */ + cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; + + /* Don't send command to uCode if nothing has changed */ + if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), + sizeof(u16)*HD_TBL_SIZE)) { + D_CALIB("No change in SENSITIVITY_CMD\n"); + return 0; + } + + /* Copy table for comparison next time */ + memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), + sizeof(u16)*HD_TBL_SIZE); + + return il_send_cmd(il, &cmd_out); +} + +void il4965_init_sensitivity(struct il_priv *il) +{ + int ret = 0; + int i; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; + + if (il->disable_sens_cal) + return; + + D_CALIB("Start il4965_init_sensitivity\n"); + + /* Clear driver's sensitivity algo data */ + data = &(il->sensitivity_data); + + if (ranges == NULL) + return; + + memset(data, 0, sizeof(struct il_sensitivity_data)); + + data->num_in_cck_no_fa = 0; + data->nrg_curr_state = IL_FA_TOO_MANY; + data->nrg_prev_state = IL_FA_TOO_MANY; + data->nrg_silence_ref = 0; + data->nrg_silence_idx = 0; + data->nrg_energy_idx = 0; + + for (i = 0; i < 10; i++) + data->nrg_value[i] = 0; + + for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) + data->nrg_silence_rssi[i] = 0; + + data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; + data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; + data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; + data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; + data->auto_corr_cck = AUTO_CORR_CCK_MIN_VAL_DEF; + data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; + data->nrg_th_cck = ranges->nrg_th_cck; + data->nrg_th_ofdm = ranges->nrg_th_ofdm; + data->barker_corr_th_min = ranges->barker_corr_th_min; + data->barker_corr_th_min_mrc = ranges->barker_corr_th_min_mrc; + data->nrg_th_cca = ranges->nrg_th_cca; + + data->last_bad_plcp_cnt_ofdm = 0; + data->last_fa_cnt_ofdm = 0; + data->last_bad_plcp_cnt_cck = 0; + data->last_fa_cnt_cck = 0; + + ret |= il4965_sensitivity_write(il); + D_CALIB("<disable_sens_cal) + return; + + data = &(il->sensitivity_data); + + if (!il_is_any_associated(il)) { + D_CALIB("<< - not associated\n"); + return; + } + + spin_lock_irqsave(&il->lock, flags); + + rx_info = &(((struct il_notif_stats *)resp)->rx.general); + ofdm = &(((struct il_notif_stats *)resp)->rx.ofdm); + cck = &(((struct il_notif_stats *)resp)->rx.cck); + + if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { + D_CALIB("<< invalid data.\n"); + spin_unlock_irqrestore(&il->lock, flags); + return; + } + + /* Extract Statistics: */ + rx_enable_time = le32_to_cpu(rx_info->channel_load); + fa_cck = le32_to_cpu(cck->false_alarm_cnt); + fa_ofdm = le32_to_cpu(ofdm->false_alarm_cnt); + bad_plcp_cck = le32_to_cpu(cck->plcp_err); + bad_plcp_ofdm = le32_to_cpu(ofdm->plcp_err); + + statis.beacon_silence_rssi_a = + le32_to_cpu(rx_info->beacon_silence_rssi_a); + statis.beacon_silence_rssi_b = + le32_to_cpu(rx_info->beacon_silence_rssi_b); + statis.beacon_silence_rssi_c = + le32_to_cpu(rx_info->beacon_silence_rssi_c); + statis.beacon_energy_a = + le32_to_cpu(rx_info->beacon_energy_a); + statis.beacon_energy_b = + le32_to_cpu(rx_info->beacon_energy_b); + statis.beacon_energy_c = + le32_to_cpu(rx_info->beacon_energy_c); + + spin_unlock_irqrestore(&il->lock, flags); + + D_CALIB("rx_enable_time = %u usecs\n", rx_enable_time); + + if (!rx_enable_time) { + D_CALIB("<< RX Enable Time == 0!\n"); + return; + } + + /* These stats increase monotonically, and do not reset + * at each beacon. Calculate difference from last value, or just + * use the new stats value if it has reset or wrapped around. */ + if (data->last_bad_plcp_cnt_cck > bad_plcp_cck) + data->last_bad_plcp_cnt_cck = bad_plcp_cck; + else { + bad_plcp_cck -= data->last_bad_plcp_cnt_cck; + data->last_bad_plcp_cnt_cck += bad_plcp_cck; + } + + if (data->last_bad_plcp_cnt_ofdm > bad_plcp_ofdm) + data->last_bad_plcp_cnt_ofdm = bad_plcp_ofdm; + else { + bad_plcp_ofdm -= data->last_bad_plcp_cnt_ofdm; + data->last_bad_plcp_cnt_ofdm += bad_plcp_ofdm; + } + + if (data->last_fa_cnt_ofdm > fa_ofdm) + data->last_fa_cnt_ofdm = fa_ofdm; + else { + fa_ofdm -= data->last_fa_cnt_ofdm; + data->last_fa_cnt_ofdm += fa_ofdm; + } + + if (data->last_fa_cnt_cck > fa_cck) + data->last_fa_cnt_cck = fa_cck; + else { + fa_cck -= data->last_fa_cnt_cck; + data->last_fa_cnt_cck += fa_cck; + } + + /* Total aborted signal locks */ + norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; + norm_fa_cck = fa_cck + bad_plcp_cck; + + D_CALIB( + "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, + bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); + + il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); + il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); + + il4965_sensitivity_write(il); +} + +static inline u8 il4965_find_first_chain(u8 mask) +{ + if (mask & ANT_A) + return CHAIN_A; + if (mask & ANT_B) + return CHAIN_B; + return CHAIN_C; +} + +/** + * Run disconnected antenna algorithm to find out which antennas are + * disconnected. + */ +static void +il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, + struct il_chain_noise_data *data) +{ + u32 active_chains = 0; + u32 max_average_sig; + u16 max_average_sig_antenna_i; + u8 num_tx_chains; + u8 first_chain; + u16 i = 0; + + average_sig[0] = data->chain_signal_a / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[1] = data->chain_signal_b / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[2] = data->chain_signal_c / + il->cfg->base_params->chain_noise_num_beacons; + + if (average_sig[0] >= average_sig[1]) { + max_average_sig = average_sig[0]; + max_average_sig_antenna_i = 0; + active_chains = (1 << max_average_sig_antenna_i); + } else { + max_average_sig = average_sig[1]; + max_average_sig_antenna_i = 1; + active_chains = (1 << max_average_sig_antenna_i); + } + + if (average_sig[2] >= max_average_sig) { + max_average_sig = average_sig[2]; + max_average_sig_antenna_i = 2; + active_chains = (1 << max_average_sig_antenna_i); + } + + D_CALIB("average_sig: a %d b %d c %d\n", + average_sig[0], average_sig[1], average_sig[2]); + D_CALIB("max_average_sig = %d, antenna %d\n", + max_average_sig, max_average_sig_antenna_i); + + /* Compare signal strengths for all 3 receivers. */ + for (i = 0; i < NUM_RX_CHAINS; i++) { + if (i != max_average_sig_antenna_i) { + s32 rssi_delta = (max_average_sig - average_sig[i]); + + /* If signal is very weak, compared with + * strongest, mark it as disconnected. */ + if (rssi_delta > MAXIMUM_ALLOWED_PATHLOSS) + data->disconn_array[i] = 1; + else + active_chains |= (1 << i); + D_CALIB("i = %d rssiDelta = %d " + "disconn_array[i] = %d\n", + i, rssi_delta, data->disconn_array[i]); + } + } + + /* + * The above algorithm sometimes fails when the ucode + * reports 0 for all chains. It's not clear why that + * happens to start with, but it is then causing trouble + * because this can make us enable more chains than the + * hardware really has. + * + * To be safe, simply mask out any chains that we know + * are not on the device. + */ + active_chains &= il->hw_params.valid_rx_ant; + + num_tx_chains = 0; + for (i = 0; i < NUM_RX_CHAINS; i++) { + /* loops on all the bits of + * il->hw_setting.valid_tx_ant */ + u8 ant_msk = (1 << i); + if (!(il->hw_params.valid_tx_ant & ant_msk)) + continue; + + num_tx_chains++; + if (data->disconn_array[i] == 0) + /* there is a Tx antenna connected */ + break; + if (num_tx_chains == il->hw_params.tx_chains_num && + data->disconn_array[i]) { + /* + * If all chains are disconnected + * connect the first valid tx chain + */ + first_chain = + il4965_find_first_chain(il->cfg->valid_tx_ant); + data->disconn_array[first_chain] = 0; + active_chains |= BIT(first_chain); + D_CALIB( + "All Tx chains are disconnected W/A - declare %d as connected\n", + first_chain); + break; + } + } + + if (active_chains != il->hw_params.valid_rx_ant && + active_chains != il->chain_noise_data.active_chains) + D_CALIB( + "Detected that not all antennas are connected! " + "Connected: %#x, valid: %#x.\n", + active_chains, il->hw_params.valid_rx_ant); + + /* Save for use within RXON, TX, SCAN commands, etc. */ + data->active_chains = active_chains; + D_CALIB("active_chains (bitwise) = 0x%x\n", + active_chains); +} + +static void il4965_gain_computation(struct il_priv *il, + u32 *average_noise, + u16 min_average_noise_antenna_i, + u32 min_average_noise, + u8 default_chain) +{ + int i, ret; + struct il_chain_noise_data *data = &il->chain_noise_data; + + data->delta_gain_code[min_average_noise_antenna_i] = 0; + + for (i = default_chain; i < NUM_RX_CHAINS; i++) { + s32 delta_g = 0; + + if (!data->disconn_array[i] && + data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { + delta_g = average_noise[i] - min_average_noise; + data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); + data->delta_gain_code[i] = + min(data->delta_gain_code[i], + (u8) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); + + data->delta_gain_code[i] = + (data->delta_gain_code[i] | (1 << 2)); + } else { + data->delta_gain_code[i] = 0; + } + } + D_CALIB("delta_gain_codes: a %d b %d c %d\n", + data->delta_gain_code[0], + data->delta_gain_code[1], + data->delta_gain_code[2]); + + /* Differential gain gets sent to uCode only once */ + if (!data->radio_write) { + struct il_calib_diff_gain_cmd cmd; + data->radio_write = 1; + + memset(&cmd, 0, sizeof(cmd)); + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.diff_gain_a = data->delta_gain_code[0]; + cmd.diff_gain_b = data->delta_gain_code[1]; + cmd.diff_gain_c = data->delta_gain_code[2]; + ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + sizeof(cmd), &cmd); + if (ret) + D_CALIB("fail sending cmd " + "REPLY_PHY_CALIBRATION_CMD\n"); + + /* TODO we might want recalculate + * rx_chain in rxon cmd */ + + /* Mark so we run this algo only once! */ + data->state = IL_CHAIN_NOISE_CALIBRATED; + } +} + + + +/* + * Accumulate 16 beacons of signal and noise stats for each of + * 3 receivers/antennas/rx-chains, then figure out: + * 1) Which antennas are connected. + * 2) Differential rx gain settings to balance the 3 receivers. + */ +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) +{ + struct il_chain_noise_data *data = NULL; + + u32 chain_noise_a; + u32 chain_noise_b; + u32 chain_noise_c; + u32 chain_sig_a; + u32 chain_sig_b; + u32 chain_sig_c; + u32 average_sig[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; + u32 average_noise[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; + u32 min_average_noise = MIN_AVERAGE_NOISE_MAX_VALUE; + u16 min_average_noise_antenna_i = INITIALIZATION_VALUE; + u16 i = 0; + u16 rxon_chnum = INITIALIZATION_VALUE; + u16 stat_chnum = INITIALIZATION_VALUE; + u8 rxon_band24; + u8 stat_band24; + unsigned long flags; + struct stats_rx_non_phy *rx_info; + + struct il_rxon_context *ctx = &il->ctx; + + if (il->disable_chain_noise_cal) + return; + + data = &(il->chain_noise_data); + + /* + * Accumulate just the first "chain_noise_num_beacons" after + * the first association, then we're done forever. + */ + if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { + if (data->state == IL_CHAIN_NOISE_ALIVE) + D_CALIB("Wait for noise calib reset\n"); + return; + } + + spin_lock_irqsave(&il->lock, flags); + + rx_info = &(((struct il_notif_stats *)stat_resp)-> + rx.general); + + if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { + D_CALIB(" << Interference data unavailable\n"); + spin_unlock_irqrestore(&il->lock, flags); + return; + } + + rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); + rxon_chnum = le16_to_cpu(ctx->staging.channel); + + stat_band24 = !!(((struct il_notif_stats *) + stat_resp)->flag & + STATISTICS_REPLY_FLG_BAND_24G_MSK); + stat_chnum = le32_to_cpu(((struct il_notif_stats *) + stat_resp)->flag) >> 16; + + /* Make sure we accumulate data for just the associated channel + * (even if scanning). */ + if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { + D_CALIB("Stats not from chan=%d, band24=%d\n", + rxon_chnum, rxon_band24); + spin_unlock_irqrestore(&il->lock, flags); + return; + } + + /* + * Accumulate beacon stats values across + * "chain_noise_num_beacons" + */ + chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & + IN_BAND_FILTER; + chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & + IN_BAND_FILTER; + chain_noise_c = le32_to_cpu(rx_info->beacon_silence_rssi_c) & + IN_BAND_FILTER; + + chain_sig_a = le32_to_cpu(rx_info->beacon_rssi_a) & IN_BAND_FILTER; + chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; + chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; + + spin_unlock_irqrestore(&il->lock, flags); + + data->beacon_count++; + + data->chain_noise_a = (chain_noise_a + data->chain_noise_a); + data->chain_noise_b = (chain_noise_b + data->chain_noise_b); + data->chain_noise_c = (chain_noise_c + data->chain_noise_c); + + data->chain_signal_a = (chain_sig_a + data->chain_signal_a); + data->chain_signal_b = (chain_sig_b + data->chain_signal_b); + data->chain_signal_c = (chain_sig_c + data->chain_signal_c); + + D_CALIB("chan=%d, band24=%d, beacon=%d\n", + rxon_chnum, rxon_band24, data->beacon_count); + D_CALIB("chain_sig: a %d b %d c %d\n", + chain_sig_a, chain_sig_b, chain_sig_c); + D_CALIB("chain_noise: a %d b %d c %d\n", + chain_noise_a, chain_noise_b, chain_noise_c); + + /* If this is the "chain_noise_num_beacons", determine: + * 1) Disconnected antennas (using signal strengths) + * 2) Differential gain (using silence noise) to balance receivers */ + if (data->beacon_count != + il->cfg->base_params->chain_noise_num_beacons) + return; + + /* Analyze signal for disconnected antenna */ + il4965_find_disconn_antenna(il, average_sig, data); + + /* Analyze noise for rx balance */ + average_noise[0] = data->chain_noise_a / + il->cfg->base_params->chain_noise_num_beacons; + average_noise[1] = data->chain_noise_b / + il->cfg->base_params->chain_noise_num_beacons; + average_noise[2] = data->chain_noise_c / + il->cfg->base_params->chain_noise_num_beacons; + + for (i = 0; i < NUM_RX_CHAINS; i++) { + if (!data->disconn_array[i] && + average_noise[i] <= min_average_noise) { + /* This means that chain i is active and has + * lower noise values so far: */ + min_average_noise = average_noise[i]; + min_average_noise_antenna_i = i; + } + } + + D_CALIB("average_noise: a %d b %d c %d\n", + average_noise[0], average_noise[1], + average_noise[2]); + + D_CALIB("min_average_noise = %d, antenna %d\n", + min_average_noise, min_average_noise_antenna_i); + + il4965_gain_computation(il, average_noise, + min_average_noise_antenna_i, min_average_noise, + il4965_find_first_chain(il->cfg->valid_rx_ant)); + + /* Some power changes may have been made during the calibration. + * Update and commit the RXON + */ + if (il->cfg->ops->lib->update_chain_flags) + il->cfg->ops->lib->update_chain_flags(il); + + data->state = IL_CHAIN_NOISE_DONE; + il_power_update_mode(il, false); +} + +void il4965_reset_run_time_calib(struct il_priv *il) +{ + int i; + memset(&(il->sensitivity_data), 0, + sizeof(struct il_sensitivity_data)); + memset(&(il->chain_noise_data), 0, + sizeof(struct il_chain_noise_data)); + for (i = 0; i < NUM_RX_CHAINS; i++) + il->chain_noise_data.delta_gain_code[i] = + CHAIN_NOISE_DELTA_GAIN_INIT_VAL; + + /* Ask for stats now, the uCode will send notification + * periodically after association */ + il_send_stats_request(il, CMD_ASYNC, true); +} diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c new file mode 100644 index 0000000..89e5828 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -0,0 +1,774 @@ +/****************************************************************************** +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, +* USA +* +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* Contact Information: +* Intel Linux Wireless +* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 +*****************************************************************************/ +#include "iwl-4965.h" +#include "iwl-4965-debugfs.h" + +static const char *fmt_value = " %-30s %10u\n"; +static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; +static const char *fmt_header = + "%-32s current cumulative delta max\n"; + +static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) +{ + int p = 0; + u32 flag; + + flag = le32_to_cpu(il->_4965.stats.flag); + + p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); + if (flag & UCODE_STATISTICS_CLEAR_MSK) + p += scnprintf(buf + p, bufsz - p, + "\tStatistics have been cleared\n"); + p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", + (flag & UCODE_STATISTICS_FREQUENCY_MSK) + ? "2.4 GHz" : "5.2 GHz"); + p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", + (flag & UCODE_STATISTICS_NARROW_BAND_MSK) + ? "enabled" : "disabled"); + + return p; +} + +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct stats_rx_phy) * 40 + + sizeof(struct stats_rx_non_phy) * 40 + + sizeof(struct stats_rx_ht_phy) * 40 + 400; + ssize_t ret; + struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; + struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct stats_rx_non_phy *general, *accum_general; + struct stats_rx_non_phy *delta_general, *max_general; + struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * the statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + ofdm = &il->_4965.stats.rx.ofdm; + cck = &il->_4965.stats.rx.cck; + general = &il->_4965.stats.rx.general; + ht = &il->_4965.stats.rx.ofdm_ht; + accum_ofdm = &il->_4965.accum_stats.rx.ofdm; + accum_cck = &il->_4965.accum_stats.rx.cck; + accum_general = &il->_4965.accum_stats.rx.general; + accum_ht = &il->_4965.accum_stats.rx.ofdm_ht; + delta_ofdm = &il->_4965.delta_stats.rx.ofdm; + delta_cck = &il->_4965.delta_stats.rx.cck; + delta_general = &il->_4965.delta_stats.rx.general; + delta_ht = &il->_4965.delta_stats.rx.ofdm_ht; + max_ofdm = &il->_4965.max_delta.rx.ofdm; + max_cck = &il->_4965.max_delta.rx.cck; + max_general = &il->_4965.max_delta.rx.general; + max_ht = &il->_4965.max_delta.rx.ofdm_ht; + + pos += il4965_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - OFDM:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ina_cnt:", + le32_to_cpu(ofdm->ina_cnt), + accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "overrun_err:", + le32_to_cpu(ofdm->overrun_err), + accum_ofdm->overrun_err, delta_ofdm->overrun_err, + max_ofdm->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_good:", + le32_to_cpu(ofdm->crc32_good), + accum_ofdm->crc32_good, delta_ofdm->crc32_good, + max_ofdm->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, + delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), + accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, + max_ofdm->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), + accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, + max_ofdm->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, + delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), + accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, + max_ofdm->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), + accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, + max_ofdm->sent_cts_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(ofdm->sent_ba_rsp_cnt), + accum_ofdm->sent_ba_rsp_cnt, + delta_ofdm->sent_ba_rsp_cnt, + max_ofdm->sent_ba_rsp_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dsp_self_kill:", + le32_to_cpu(ofdm->dsp_self_kill), + accum_ofdm->dsp_self_kill, + delta_ofdm->dsp_self_kill, + max_ofdm->dsp_self_kill); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "mh_format_err:", + le32_to_cpu(ofdm->mh_format_err), + accum_ofdm->mh_format_err, + delta_ofdm->mh_format_err, + max_ofdm->mh_format_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "re_acq_main_rssi_sum:", + le32_to_cpu(ofdm->re_acq_main_rssi_sum), + accum_ofdm->re_acq_main_rssi_sum, + delta_ofdm->re_acq_main_rssi_sum, + max_ofdm->re_acq_main_rssi_sum); + + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - CCK:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "overrun_err:", + le32_to_cpu(cck->overrun_err), + accum_cck->overrun_err, delta_cck->overrun_err, + max_cck->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, + max_cck->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, max_cck->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, + delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, + max_cck->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), + accum_cck->sfd_timeout, delta_cck->sfd_timeout, + max_cck->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_timeout:", + le32_to_cpu(cck->fina_timeout), + accum_cck->fina_timeout, delta_cck->fina_timeout, + max_cck->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), + accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, + max_cck->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), + accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, + max_cck->sent_cts_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(cck->sent_ba_rsp_cnt), + accum_cck->sent_ba_rsp_cnt, + delta_cck->sent_ba_rsp_cnt, + max_cck->sent_ba_rsp_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dsp_self_kill:", + le32_to_cpu(cck->dsp_self_kill), + accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, + max_cck->dsp_self_kill); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "mh_format_err:", + le32_to_cpu(cck->mh_format_err), + accum_cck->mh_format_err, delta_cck->mh_format_err, + max_cck->mh_format_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "re_acq_main_rssi_sum:", + le32_to_cpu(cck->re_acq_main_rssi_sum), + accum_cck->re_acq_main_rssi_sum, + delta_cck->re_acq_main_rssi_sum, + max_cck->re_acq_main_rssi_sum); + + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - GENERAL:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bogus_cts:", + le32_to_cpu(general->bogus_cts), + accum_general->bogus_cts, delta_general->bogus_cts, + max_general->bogus_cts); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bogus_ack:", + le32_to_cpu(general->bogus_ack), + accum_general->bogus_ack, delta_general->bogus_ack, + max_general->bogus_ack); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "channel_beacons:", + le32_to_cpu(general->channel_beacons), + accum_general->channel_beacons, + delta_general->channel_beacons, + max_general->channel_beacons); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "num_missed_bcon:", + le32_to_cpu(general->num_missed_bcon), + accum_general->num_missed_bcon, + delta_general->num_missed_bcon, + max_general->num_missed_bcon); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "adc_rx_saturation_time:", + le32_to_cpu(general->adc_rx_saturation_time), + accum_general->adc_rx_saturation_time, + delta_general->adc_rx_saturation_time, + max_general->adc_rx_saturation_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ina_detect_search_tm:", + le32_to_cpu(general->ina_detection_search_time), + accum_general->ina_detection_search_time, + delta_general->ina_detection_search_time, + max_general->ina_detection_search_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_silence_rssi_a:", + le32_to_cpu(general->beacon_silence_rssi_a), + accum_general->beacon_silence_rssi_a, + delta_general->beacon_silence_rssi_a, + max_general->beacon_silence_rssi_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_silence_rssi_b:", + le32_to_cpu(general->beacon_silence_rssi_b), + accum_general->beacon_silence_rssi_b, + delta_general->beacon_silence_rssi_b, + max_general->beacon_silence_rssi_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_silence_rssi_c:", + le32_to_cpu(general->beacon_silence_rssi_c), + accum_general->beacon_silence_rssi_c, + delta_general->beacon_silence_rssi_c, + max_general->beacon_silence_rssi_c); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "interference_data_flag:", + le32_to_cpu(general->interference_data_flag), + accum_general->interference_data_flag, + delta_general->interference_data_flag, + max_general->interference_data_flag); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "channel_load:", + le32_to_cpu(general->channel_load), + accum_general->channel_load, + delta_general->channel_load, + max_general->channel_load); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dsp_false_alarms:", + le32_to_cpu(general->dsp_false_alarms), + accum_general->dsp_false_alarms, + delta_general->dsp_false_alarms, + max_general->dsp_false_alarms); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_rssi_a:", + le32_to_cpu(general->beacon_rssi_a), + accum_general->beacon_rssi_a, + delta_general->beacon_rssi_a, + max_general->beacon_rssi_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_rssi_b:", + le32_to_cpu(general->beacon_rssi_b), + accum_general->beacon_rssi_b, + delta_general->beacon_rssi_b, + max_general->beacon_rssi_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_rssi_c:", + le32_to_cpu(general->beacon_rssi_c), + accum_general->beacon_rssi_c, + delta_general->beacon_rssi_c, + max_general->beacon_rssi_c); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_energy_a:", + le32_to_cpu(general->beacon_energy_a), + accum_general->beacon_energy_a, + delta_general->beacon_energy_a, + max_general->beacon_energy_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_energy_b:", + le32_to_cpu(general->beacon_energy_b), + accum_general->beacon_energy_b, + delta_general->beacon_energy_b, + max_general->beacon_energy_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_energy_c:", + le32_to_cpu(general->beacon_energy_c), + accum_general->beacon_energy_c, + delta_general->beacon_energy_c, + max_general->beacon_energy_c); + + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - OFDM_HT:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "plcp_err:", + le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, + delta_ht->plcp_err, max_ht->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "overrun_err:", + le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, + delta_ht->overrun_err, max_ht->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "early_overrun_err:", + le32_to_cpu(ht->early_overrun_err), + accum_ht->early_overrun_err, + delta_ht->early_overrun_err, + max_ht->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_good:", + le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, + delta_ht->crc32_good, max_ht->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_err:", + le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, + delta_ht->crc32_err, max_ht->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "mh_format_err:", + le32_to_cpu(ht->mh_format_err), + accum_ht->mh_format_err, + delta_ht->mh_format_err, max_ht->mh_format_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg_crc32_good:", + le32_to_cpu(ht->agg_crc32_good), + accum_ht->agg_crc32_good, + delta_ht->agg_crc32_good, max_ht->agg_crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg_mpdu_cnt:", + le32_to_cpu(ht->agg_mpdu_cnt), + accum_ht->agg_mpdu_cnt, + delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg_cnt:", + le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, + delta_ht->agg_cnt, max_ht->agg_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "unsupport_mcs:", + le32_to_cpu(ht->unsupport_mcs), + accum_ht->unsupport_mcs, + delta_ht->unsupport_mcs, max_ht->unsupport_mcs); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t il4965_ucode_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = (sizeof(struct stats_tx) * 48) + 250; + ssize_t ret; + struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* the statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta_tx = &il->_4965.delta_stats.tx; + max_tx = &il->_4965.max_delta.tx; + + pos += il4965_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Tx:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "preamble:", + le32_to_cpu(tx->preamble_cnt), + accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, + delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, + delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, + delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), + accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ack_timeout:", + le32_to_cpu(tx->ack_timeout), + accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, + delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), + accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, + max_tx->actual_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dump_msdu_cnt:", + le32_to_cpu(tx->dump_msdu_cnt), + accum_tx->dump_msdu_cnt, + delta_tx->dump_msdu_cnt, + max_tx->dump_msdu_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "abort_nxt_frame_mismatch:", + le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), + accum_tx->burst_abort_next_frame_mismatch_cnt, + delta_tx->burst_abort_next_frame_mismatch_cnt, + max_tx->burst_abort_next_frame_mismatch_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "abort_missing_nxt_frame:", + le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), + accum_tx->burst_abort_missing_next_frame_cnt, + delta_tx->burst_abort_missing_next_frame_cnt, + max_tx->burst_abort_missing_next_frame_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "cts_timeout_collision:", + le32_to_cpu(tx->cts_timeout_collision), + accum_tx->cts_timeout_collision, + delta_tx->cts_timeout_collision, + max_tx->cts_timeout_collision); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ack_ba_timeout_collision:", + le32_to_cpu(tx->ack_or_ba_timeout_collision), + accum_tx->ack_or_ba_timeout_collision, + delta_tx->ack_or_ba_timeout_collision, + max_tx->ack_or_ba_timeout_collision); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg ba_timeout:", + le32_to_cpu(tx->agg.ba_timeout), + accum_tx->agg.ba_timeout, + delta_tx->agg.ba_timeout, + max_tx->agg.ba_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg ba_resched_frames:", + le32_to_cpu(tx->agg.ba_reschedule_frames), + accum_tx->agg.ba_reschedule_frames, + delta_tx->agg.ba_reschedule_frames, + max_tx->agg.ba_reschedule_frames); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_agg_frame:", + le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), + accum_tx->agg.scd_query_agg_frame_cnt, + delta_tx->agg.scd_query_agg_frame_cnt, + max_tx->agg.scd_query_agg_frame_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_no_agg:", + le32_to_cpu(tx->agg.scd_query_no_agg), + accum_tx->agg.scd_query_no_agg, + delta_tx->agg.scd_query_no_agg, + max_tx->agg.scd_query_no_agg); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_agg:", + le32_to_cpu(tx->agg.scd_query_agg), + accum_tx->agg.scd_query_agg, + delta_tx->agg.scd_query_agg, + max_tx->agg.scd_query_agg); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_mismatch:", + le32_to_cpu(tx->agg.scd_query_mismatch), + accum_tx->agg.scd_query_mismatch, + delta_tx->agg.scd_query_mismatch, + max_tx->agg.scd_query_mismatch); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg frame_not_ready:", + le32_to_cpu(tx->agg.frame_not_ready), + accum_tx->agg.frame_not_ready, + delta_tx->agg.frame_not_ready, + max_tx->agg.frame_not_ready); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg underrun:", + le32_to_cpu(tx->agg.underrun), + accum_tx->agg.underrun, + delta_tx->agg.underrun, max_tx->agg.underrun); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg bt_prio_kill:", + le32_to_cpu(tx->agg.bt_prio_kill), + accum_tx->agg.bt_prio_kill, + delta_tx->agg.bt_prio_kill, + max_tx->agg.bt_prio_kill); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg rx_ba_rsp_cnt:", + le32_to_cpu(tx->agg.rx_ba_rsp_cnt), + accum_tx->agg.rx_ba_rsp_cnt, + delta_tx->agg.rx_ba_rsp_cnt, + max_tx->agg.rx_ba_rsp_cnt); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct stats_general) * 10 + 300; + ssize_t ret; + struct stats_general_common *general, *accum_general; + struct stats_general_common *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct stats_div *div, *accum_div, *delta_div, *max_div; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* the statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + general = &il->_4965.stats.general.common; + dbg = &il->_4965.stats.general.common.dbg; + div = &il->_4965.stats.general.common.div; + accum_general = &il->_4965.accum_stats.general.common; + accum_dbg = &il->_4965.accum_stats.general.common.dbg; + accum_div = &il->_4965.accum_stats.general.common.div; + delta_general = &il->_4965.delta_stats.general.common; + max_general = &il->_4965.max_delta.general.common; + delta_dbg = &il->_4965.delta_stats.general.common.dbg; + max_dbg = &il->_4965.max_delta.general.common.dbg; + delta_div = &il->_4965.delta_stats.general.common.div; + max_div = &il->_4965.max_delta.general.common.div; + + pos += il4965_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_General:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_value, "temperature:", + le32_to_cpu(general->temperature)); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_value, "ttl_timestamp:", + le32_to_cpu(general->ttl_timestamp)); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "burst_check:", + le32_to_cpu(dbg->burst_check), + accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "burst_count:", + le32_to_cpu(dbg->burst_count), + accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "wait_for_silence_timeout_count:", + le32_to_cpu(dbg->wait_for_silence_timeout_cnt), + accum_dbg->wait_for_silence_timeout_cnt, + delta_dbg->wait_for_silence_timeout_cnt, + max_dbg->wait_for_silence_timeout_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, + delta_general->sleep_time, max_general->sleep_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "slots_out:", + le32_to_cpu(general->slots_out), + accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, + delta_general->slots_idle, max_general->slots_idle); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rx_enable_counter:", + le32_to_cpu(general->rx_enable_counter), + accum_general->rx_enable_counter, + delta_general->rx_enable_counter, + max_general->rx_enable_counter); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "num_of_sos_states:", + le32_to_cpu(general->num_of_sos_states), + accum_general->num_of_sos_states, + delta_general->num_of_sos_states, + max_general->num_of_sos_states); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c new file mode 100644 index 0000000..4a54311 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -0,0 +1,2862 @@ +/****************************************************************************** + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "iwl-dev.h" +#include "iwl-sta.h" +#include "iwl-core.h" +#include "iwl-4965.h" + +#define IL4965_RS_NAME "iwl-4965-rs" + +#define NUM_TRY_BEFORE_ANT_TOGGLE 1 +#define IL_NUMBER_TRY 1 +#define IL_HT_NUMBER_TRY 3 + +#define RATE_MAX_WINDOW 62 /* # tx in history win */ +#define RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ +#define RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ + +/* max allowed rate miss before sync LQ cmd */ +#define IL_MISSED_RATE_MAX 15 +/* max time to accum history 2 seconds */ +#define RATE_SCALE_FLUSH_INTVL (3*HZ) + +static u8 rs_ht_to_legacy[] = { + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, + RATE_6M_IDX, RATE_9M_IDX, + RATE_12M_IDX, RATE_18M_IDX, + RATE_24M_IDX, RATE_36M_IDX, + RATE_48M_IDX, RATE_54M_IDX +}; + +static const u8 ant_toggle_lookup[] = { + /*ANT_NONE -> */ ANT_NONE, + /*ANT_A -> */ ANT_B, + /*ANT_B -> */ ANT_C, + /*ANT_AB -> */ ANT_BC, + /*ANT_C -> */ ANT_A, + /*ANT_AC -> */ ANT_AB, + /*ANT_BC -> */ ANT_AC, + /*ANT_ABC -> */ ANT_ABC, +}; + +#define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ + RATE_SISO_##s##M_PLCP, \ + RATE_MIMO2_##s##M_PLCP,\ + RATE_##r##M_IEEE, \ + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX } + +/* + * Parameter order: + * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate + * + * If there isn't a valid next or previous rate then INV is used which + * maps to RATE_INVALID + * + */ +const struct il_rate_info il_rates[RATE_COUNT] = { + IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ +}; + +static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) +{ + int idx = 0; + + /* HT rate format */ + if (rate_n_flags & RATE_MCS_HT_MSK) { + idx = (rate_n_flags & 0xff); + + if (idx >= RATE_MIMO2_6M_PLCP) + idx = idx - RATE_MIMO2_6M_PLCP; + + idx += IL_FIRST_OFDM_RATE; + /* skip 9M not supported in ht*/ + if (idx >= RATE_9M_IDX) + idx += 1; + if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) + return idx; + + /* legacy rate format, search for match in table */ + } else { + for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) + return idx; + } + + return -1; +} + +static void il4965_rs_rate_scale_perform(struct il_priv *il, + struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta); +static void il4965_rs_fill_link_cmd(struct il_priv *il, + struct il_lq_sta *lq_sta, u32 rate_n_flags); +static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, + bool force_search); + +#ifdef CONFIG_MAC80211_DEBUGFS +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, + u32 *rate_n_flags, int idx); +#else +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, + u32 *rate_n_flags, int idx) +{} +#endif + +/** + * The following tables contain the expected throughput metrics for all rates + * + * 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits + * + * where invalid entries are zeros. + * + * CCK rates are only valid in legacy table and will only be used in G + * (2.4 GHz) band. + */ + +static s32 expected_tpt_legacy[RATE_COUNT] = { + 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 +}; + +static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ + {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ + {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ + {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ +}; + +static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ + {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ + {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ + {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ +}; + +static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ + {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ + {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ + {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ +}; + +static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ + {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ + {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ + {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ +}; + +/* mbps, mcs */ +static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { + { "1", "BPSK DSSS"}, + { "2", "QPSK DSSS"}, + {"5.5", "BPSK CCK"}, + { "11", "QPSK CCK"}, + { "6", "BPSK 1/2"}, + { "9", "BPSK 1/2"}, + { "12", "QPSK 1/2"}, + { "18", "QPSK 3/4"}, + { "24", "16QAM 1/2"}, + { "36", "16QAM 3/4"}, + { "48", "64QAM 2/3"}, + { "54", "64QAM 3/4"}, + { "60", "64QAM 5/6"}, +}; + +#define MCS_IDX_PER_STREAM (8) + +static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) +{ + return (u8)(rate_n_flags & 0xFF); +} + +static void +il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) +{ + win->data = 0; + win->success_counter = 0; + win->success_ratio = IL_INVALID_VALUE; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; +} + +static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) +{ + return (ant_type & valid_antenna) == ant_type; +} + +/* + * removes the old data from the stats. All data that is older than + * TID_MAX_TIME_DIFF, will be deleted. + */ +static void +il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) +{ + /* The oldest age we want to keep */ + u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; + + while (tl->queue_count && tl->time_stamp < oldest_time) { + tl->total -= tl->packet_count[tl->head]; + tl->packet_count[tl->head] = 0; + tl->time_stamp += TID_QUEUE_CELL_SPACING; + tl->queue_count--; + tl->head++; + if (tl->head >= TID_QUEUE_MAX_SIZE) + tl->head = 0; + } +} + +/* + * increment traffic load value for tid and also remove + * any old values if passed the certain time period + */ +static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, + struct ieee80211_hdr *hdr) +{ + u32 curr_time = jiffies_to_msecs(jiffies); + u32 time_diff; + s32 idx; + struct il_traffic_load *tl = NULL; + u8 tid; + + if (ieee80211_is_data_qos(hdr->frame_control)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & 0xf; + } else + return MAX_TID_COUNT; + + if (unlikely(tid >= TID_MAX_LOAD_COUNT)) + return MAX_TID_COUNT; + + tl = &lq_data->load[tid]; + + curr_time -= curr_time % TID_ROUND_VALUE; + + /* Happens only for the first packet. Initialize the data */ + if (!(tl->queue_count)) { + tl->total = 1; + tl->time_stamp = curr_time; + tl->queue_count = 1; + tl->head = 0; + tl->packet_count[0] = 1; + return MAX_TID_COUNT; + } + + time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); + idx = time_diff / TID_QUEUE_CELL_SPACING; + + /* The history is too long: remove data that is older than */ + /* TID_MAX_TIME_DIFF */ + if (idx >= TID_QUEUE_MAX_SIZE) + il4965_rs_tl_rm_old_stats(tl, curr_time); + + idx = (tl->head + idx) % TID_QUEUE_MAX_SIZE; + tl->packet_count[idx] = tl->packet_count[idx] + 1; + tl->total = tl->total + 1; + + if ((idx + 1) > tl->queue_count) + tl->queue_count = idx + 1; + + return tid; +} + +/* + get the traffic load value for tid +*/ +static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) +{ + u32 curr_time = jiffies_to_msecs(jiffies); + u32 time_diff; + s32 idx; + struct il_traffic_load *tl = NULL; + + if (tid >= TID_MAX_LOAD_COUNT) + return 0; + + tl = &(lq_data->load[tid]); + + curr_time -= curr_time % TID_ROUND_VALUE; + + if (!(tl->queue_count)) + return 0; + + time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); + idx = time_diff / TID_QUEUE_CELL_SPACING; + + /* The history is too long: remove data that is older than */ + /* TID_MAX_TIME_DIFF */ + if (idx >= TID_QUEUE_MAX_SIZE) + il4965_rs_tl_rm_old_stats(tl, curr_time); + + return tl->total; +} + +static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, + struct il_lq_sta *lq_data, u8 tid, + struct ieee80211_sta *sta) +{ + int ret = -EAGAIN; + u32 load; + + load = il4965_rs_tl_get_load(lq_data, tid); + + if (load > IL_AGG_LOAD_THRESHOLD) { + D_HT("Starting Tx agg: STA: %pM tid: %d\n", + sta->addr, tid); + ret = ieee80211_start_tx_ba_session(sta, tid, 5000); + if (ret == -EAGAIN) { + /* + * driver and mac80211 is out of sync + * this might be cause by reloading firmware + * stop the tx ba session here + */ + IL_ERR("Fail start Tx agg on tid: %d\n", + tid); + ieee80211_stop_tx_ba_session(sta, tid); + } + } else { + IL_ERR("Aggregation not enabled for tid %d " + "because load = %u\n", tid, load); + } + return ret; +} + +static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, + struct il_lq_sta *lq_data, + struct ieee80211_sta *sta) +{ + if (tid < TID_MAX_LOAD_COUNT) + il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); + else + IL_ERR("tid exceeds max load count: %d/%d\n", + tid, TID_MAX_LOAD_COUNT); +} + +static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) +{ + return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + + !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + + !!(rate_n_flags & RATE_MCS_ANT_C_MSK); +} + +/* + * Static function to get the expected throughput from an il_scale_tbl_info + * that wraps a NULL pointer check + */ +static s32 +il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) +{ + if (tbl->expected_tpt) + return tbl->expected_tpt[rs_idx]; + return 0; +} + +/** + * il4965_rs_collect_tx_data - Update the success/failure sliding win + * + * We keep a sliding win of the last 62 packets transmitted + * at this rate. win->data contains the bitmask of successful + * packets. + */ +static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, + int scale_idx, int attempts, int successes) +{ + struct il_rate_scale_data *win = NULL; + static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); + s32 fail_count, tpt; + + if (scale_idx < 0 || scale_idx >= RATE_COUNT) + return -EINVAL; + + /* Select win for current tx bit rate */ + win = &(tbl->win[scale_idx]); + + /* Get expected throughput */ + tpt = il4965_get_expected_tpt(tbl, scale_idx); + + /* + * Keep track of only the latest 62 tx frame attempts in this rate's + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; + * if the oldest attempt (highest bit in bitmap) shows "success", + * subtract "1" from the success counter (this is the main reason + * we keep these bitmaps!). + */ + while (attempts > 0) { + if (win->counter >= RATE_MAX_WINDOW) { + + /* remove earliest */ + win->counter = RATE_MAX_WINDOW - 1; + + if (win->data & mask) { + win->data &= ~mask; + win->success_counter--; + } + } + + /* Increment frames-attempted counter */ + win->counter++; + + /* Shift bitmap by one frame to throw away oldest history */ + win->data <<= 1; + + /* Mark the most recent #successes attempts as successful */ + if (successes > 0) { + win->success_counter++; + win->data |= 0x1; + successes--; + } + + attempts--; + } + + /* Calculate current success ratio, avoid divide-by-0! */ + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; + else + win->success_ratio = IL_INVALID_VALUE; + + fail_count = win->counter - win->success_counter; + + /* Calculate average throughput, if we have enough history. */ + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) + win->average_tpt = (win->success_ratio * tpt + 64) / 128; + else + win->average_tpt = IL_INVALID_VALUE; + + /* Tag this win as having been updated */ + win->stamp = jiffies; + + return 0; +} + +/* + * Fill uCode API rate_n_flags field, based on "search" or "active" table. + */ +static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, + struct il_scale_tbl_info *tbl, + int idx, u8 use_green) +{ + u32 rate_n_flags = 0; + + if (is_legacy(tbl->lq_type)) { + rate_n_flags = il_rates[idx].plcp; + if (idx >= IL_FIRST_CCK_RATE && idx <= IL_LAST_CCK_RATE) + rate_n_flags |= RATE_MCS_CCK_MSK; + + } else if (is_Ht(tbl->lq_type)) { + if (idx > IL_LAST_OFDM_RATE) { + IL_ERR("Invalid HT rate idx %d\n", idx); + idx = IL_LAST_OFDM_RATE; + } + rate_n_flags = RATE_MCS_HT_MSK; + + if (is_siso(tbl->lq_type)) + rate_n_flags |= il_rates[idx].plcp_siso; + else + rate_n_flags |= il_rates[idx].plcp_mimo2; + } else { + IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); + } + + rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & + RATE_MCS_ANT_ABC_MSK); + + if (is_Ht(tbl->lq_type)) { + if (tbl->is_ht40) { + if (tbl->is_dup) + rate_n_flags |= RATE_MCS_DUP_MSK; + else + rate_n_flags |= RATE_MCS_HT40_MSK; + } + if (tbl->is_SGI) + rate_n_flags |= RATE_MCS_SGI_MSK; + + if (use_green) { + rate_n_flags |= RATE_MCS_GF_MSK; + if (is_siso(tbl->lq_type) && tbl->is_SGI) { + rate_n_flags &= ~RATE_MCS_SGI_MSK; + IL_ERR("GF was set with SGI:SISO\n"); + } + } + } + return rate_n_flags; +} + +/* + * Interpret uCode API's rate_n_flags format, + * fill "search" or "active" tx mode table. + */ +static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, + enum ieee80211_band band, + struct il_scale_tbl_info *tbl, + int *rate_idx) +{ + u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); + u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); + u8 mcs; + + memset(tbl, 0, sizeof(struct il_scale_tbl_info)); + *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); + + if (*rate_idx == RATE_INVALID) { + *rate_idx = -1; + return -EINVAL; + } + tbl->is_SGI = 0; /* default legacy setup */ + tbl->is_ht40 = 0; + tbl->is_dup = 0; + tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); + tbl->lq_type = LQ_NONE; + tbl->max_search = IL_MAX_SEARCH; + + /* legacy rate format */ + if (!(rate_n_flags & RATE_MCS_HT_MSK)) { + if (il4965_num_of_ant == 1) { + if (band == IEEE80211_BAND_5GHZ) + tbl->lq_type = LQ_A; + else + tbl->lq_type = LQ_G; + } + /* HT rate format */ + } else { + if (rate_n_flags & RATE_MCS_SGI_MSK) + tbl->is_SGI = 1; + + if ((rate_n_flags & RATE_MCS_HT40_MSK) || + (rate_n_flags & RATE_MCS_DUP_MSK)) + tbl->is_ht40 = 1; + + if (rate_n_flags & RATE_MCS_DUP_MSK) + tbl->is_dup = 1; + + mcs = il4965_rs_extract_rate(rate_n_flags); + + /* SISO */ + if (mcs <= RATE_SISO_60M_PLCP) { + if (il4965_num_of_ant == 1) + tbl->lq_type = LQ_SISO; /*else NONE*/ + /* MIMO2 */ + } else { + if (il4965_num_of_ant == 2) + tbl->lq_type = LQ_MIMO2; + } + } + return 0; +} + +/* switch to another antenna/antennas and return 1 */ +/* if no other valid antenna found, return 0 */ +static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, + struct il_scale_tbl_info *tbl) +{ + u8 new_ant_type; + + if (!tbl->ant_type || tbl->ant_type > ANT_ABC) + return 0; + + if (!il4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) + return 0; + + new_ant_type = ant_toggle_lookup[tbl->ant_type]; + + while (new_ant_type != tbl->ant_type && + !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) + new_ant_type = ant_toggle_lookup[new_ant_type]; + + if (new_ant_type == tbl->ant_type) + return 0; + + tbl->ant_type = new_ant_type; + *rate_n_flags &= ~RATE_MCS_ANT_ABC_MSK; + *rate_n_flags |= new_ant_type << RATE_MCS_ANT_POS; + return 1; +} + +/** + * Green-field mode is valid if the station supports it and + * there are no non-GF stations present in the BSS. + */ +static bool il4965_rs_use_green(struct ieee80211_sta *sta) +{ + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && + !(ctx->ht.non_gf_sta_present); +} + +/** + * il4965_rs_get_supported_rates - get the available rates + * + * if management frame or broadcast frame only return + * basic available rates. + * + */ +static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, + struct ieee80211_hdr *hdr, + enum il_table_type rate_type) +{ + if (is_legacy(rate_type)) { + return lq_sta->active_legacy_rate; + } else { + if (is_siso(rate_type)) + return lq_sta->active_siso_rate; + else + return lq_sta->active_mimo2_rate; + } +} + +static u16 +il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, + int rate_type) +{ + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; + + /* 802.11A or ht walks to the next literal adjacent rate in + * the rate table */ + if (is_a_band(rate_type) || !is_legacy(rate_type)) { + int i; + u32 mask; + + /* Find the previous rate that is in the rate mask */ + i = idx - 1; + for (mask = (1 << i); i >= 0; i--, mask >>= 1) { + if (rate_mask & mask) { + low = i; + break; + } + } + + /* Find the next rate that is in the rate mask */ + i = idx + 1; + for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { + if (rate_mask & mask) { + high = i; + break; + } + } + + return (high << 8) | low; + } + + low = idx; + while (low != RATE_INVALID) { + low = il_rates[low].prev_rs; + if (low == RATE_INVALID) + break; + if (rate_mask & (1 << low)) + break; + D_RATE("Skipping masked lower rate: %d\n", low); + } + + high = idx; + while (high != RATE_INVALID) { + high = il_rates[high].next_rs; + if (high == RATE_INVALID) + break; + if (rate_mask & (1 << high)) + break; + D_RATE("Skipping masked higher rate: %d\n", high); + } + + return (high << 8) | low; +} + +static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, + u8 scale_idx, u8 ht_possible) +{ + s32 low; + u16 rate_mask; + u16 high_low; + u8 switch_to_legacy = 0; + u8 is_green = lq_sta->is_green; + struct il_priv *il = lq_sta->drv; + + /* check if we need to switch from HT to legacy rates. + * assumption is that mandatory rates (1Mbps or 6Mbps) + * are always supported (spec demand) */ + if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_idx)) { + switch_to_legacy = 1; + scale_idx = rs_ht_to_legacy[scale_idx]; + if (lq_sta->band == IEEE80211_BAND_5GHZ) + tbl->lq_type = LQ_A; + else + tbl->lq_type = LQ_G; + + if (il4965_num_of_ant(tbl->ant_type) > 1) + tbl->ant_type = + il4965_first_antenna(il->hw_params.valid_tx_ant); + + tbl->is_ht40 = 0; + tbl->is_SGI = 0; + tbl->max_search = IL_MAX_SEARCH; + } + + rate_mask = il4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); + + /* Mask with station rate restriction */ + if (is_legacy(tbl->lq_type)) { + /* supp_rates has no CCK bits in A mode */ + if (lq_sta->band == IEEE80211_BAND_5GHZ) + rate_mask = (u16)(rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + else + rate_mask = (u16)(rate_mask & lq_sta->supp_rates); + } + + /* If we switched from HT to legacy, check current rate */ + if (switch_to_legacy && (rate_mask & (1 << scale_idx))) { + low = scale_idx; + goto out; + } + + high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, + scale_idx, rate_mask, + tbl->lq_type); + low = high_low & 0xff; + + if (low == RATE_INVALID) + low = scale_idx; + +out: + return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); +} + +/* + * Simple function to compare two rate scale table types + */ +static bool il4965_table_type_matches(struct il_scale_tbl_info *a, + struct il_scale_tbl_info *b) +{ + return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && + a->is_SGI == b->is_SGI); +} + +/* + * mac80211 sends us Tx status + */ +static void +il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) +{ + int legacy_success; + int retries; + int rs_idx, mac_idx, i; + struct il_lq_sta *lq_sta = il_sta; + struct il_link_quality_cmd *table; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct il_priv *il = (struct il_priv *)il_r; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + enum mac80211_rate_control_flags mac_flags; + u32 tx_rate; + struct il_scale_tbl_info tbl_type; + struct il_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + D_RATE( + "get frame ack response, update rate scale win\n"); + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (!lq_sta) { + D_RATE("Station rate scaling not created yet.\n"); + return; + } else if (!lq_sta->drv) { + D_RATE("Rate scaling not initialized yet.\n"); + return; + } + + if (!ieee80211_is_data(hdr->frame_control) || + (info->flags & IEEE80211_TX_CTL_NO_ACK)) + return; + + /* This packet was aggregated but doesn't carry status info */ + if ((info->flags & IEEE80211_TX_CTL_AMPDU) && + !(info->flags & IEEE80211_TX_STAT_AMPDU)) + return; + + /* + * Ignore this Tx frame response if its initial rate doesn't match + * that of latest Link Quality command. There may be stragglers + * from a previous Link Quality command, but we're no longer interested + * in those; they're either from the "active" mode while we're trying + * to check "search" mode, or a prior "search" mode after we've moved + * to a new "search" mode (which might become the new "active" mode). + */ + table = &lq_sta->lq; + tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); + il4965_rs_get_tbl_info_from_mcs(tx_rate, + il->band, &tbl_type, &rs_idx); + if (il->band == IEEE80211_BAND_5GHZ) + rs_idx -= IL_FIRST_OFDM_RATE; + mac_flags = info->status.rates[0].flags; + mac_idx = info->status.rates[0].idx; + /* For HT packets, map MCS to PLCP */ + if (mac_flags & IEEE80211_TX_RC_MCS) { + mac_idx &= RATE_MCS_CODE_MSK; /* Remove # of streams */ + if (mac_idx >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) + mac_idx++; + /* + * mac80211 HT idx is always zero-idxed; we need to move + * HT OFDM rates after CCK rates in 2.4 GHz band + */ + if (il->band == IEEE80211_BAND_2GHZ) + mac_idx += IL_FIRST_OFDM_RATE; + } + /* Here we actually compare this rate to the latest LQ command */ + if (mac_idx < 0 || + tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || + tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || + tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || + tbl_type.ant_type != info->antenna_sel_tx || + !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || + !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || + rs_idx != mac_idx) { + D_RATE( + "initial rate %d does not match %d (0x%x)\n", + mac_idx, rs_idx, tx_rate); + /* + * Since rates mis-match, the last LQ command may have failed. + * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with + * ... driver. + */ + lq_sta->missed_rate_counter++; + if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { + lq_sta->missed_rate_counter = 0; + il_send_lq_cmd(il, ctx, &lq_sta->lq, + CMD_ASYNC, false); + } + /* Regardless, ignore this status info for outdated rate */ + return; + } else + /* Rate did match, so reset the missed_rate_counter */ + lq_sta->missed_rate_counter = 0; + + /* Figure out if rate scale algorithm is in active or search table */ + if (il4965_table_type_matches(&tbl_type, + &(lq_sta->lq_info[lq_sta->active_tbl]))) { + curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); + } else if (il4965_table_type_matches(&tbl_type, + &lq_sta->lq_info[1 - lq_sta->active_tbl])) { + curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); + other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + } else { + D_RATE( + "Neither active nor search matches tx rate\n"); + tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + D_RATE("active- lq:%x, ant:%x, SGI:%d\n", + tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); + tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); + D_RATE("search- lq:%x, ant:%x, SGI:%d\n", + tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); + D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", + tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); + /* + * no matching table found, let's by-pass the data collection + * and continue to perform rate scale to find the rate table + */ + il4965_rs_stay_in_table(lq_sta, true); + goto done; + } + + /* + * Updating the frame history depends on whether packets were + * aggregated. + * + * For aggregation, all packets were transmitted at the same rate, the + * first idx into rate scale table. + */ + if (info->flags & IEEE80211_TX_STAT_AMPDU) { + tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, + &rs_idx); + il4965_rs_collect_tx_data(curr_tbl, rs_idx, + info->status.ampdu_len, + info->status.ampdu_ack_len); + + /* Update success/fail counts if not searching for new mode */ + if (lq_sta->stay_in_tbl) { + lq_sta->total_success += info->status.ampdu_ack_len; + lq_sta->total_failed += (info->status.ampdu_len - + info->status.ampdu_ack_len); + } + } else { + /* + * For legacy, update frame history with for each Tx retry. + */ + retries = info->status.rates[0].count - 1; + /* HW doesn't send more than 15 retries */ + retries = min(retries, 15); + + /* The last transmission may have been successful */ + legacy_success = !!(info->flags & IEEE80211_TX_STAT_ACK); + /* Collect data for each rate used during failed TX attempts */ + for (i = 0; i <= retries; ++i) { + tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, + &tbl_type, &rs_idx); + /* + * Only collect stats if retried rate is in the same RS + * table as active/search. + */ + if (il4965_table_type_matches(&tbl_type, curr_tbl)) + tmp_tbl = curr_tbl; + else if (il4965_table_type_matches(&tbl_type, + other_tbl)) + tmp_tbl = other_tbl; + else + continue; + il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, + i < retries ? 0 : legacy_success); + } + + /* Update success/fail counts if not searching for new mode */ + if (lq_sta->stay_in_tbl) { + lq_sta->total_success += legacy_success; + lq_sta->total_failed += retries + (1 - legacy_success); + } + } + /* The last TX rate is cached in lq_sta; it's set in if/else above */ + lq_sta->last_rate_n_flags = tx_rate; +done: + /* See if there's a better rate or modulation mode to try. */ + if (sta && sta->supp_rates[sband->band]) + il4965_rs_rate_scale_perform(il, skb, sta, lq_sta); +} + +/* + * Begin a period of staying with a selected modulation mode. + * Set "stay_in_tbl" flag to prevent any mode switches. + * Set frame tx success limits according to legacy vs. high-throughput, + * and reset overall (spanning all rates) tx success history stats. + * These control how long we stay using same modulation mode before + * searching for a new mode. + */ +static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, + struct il_lq_sta *lq_sta) +{ + D_RATE("we are staying in the same table\n"); + lq_sta->stay_in_tbl = 1; /* only place this gets set */ + if (is_legacy) { + lq_sta->table_count_limit = IL_LEGACY_TBL_COUNT; + lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; + } else { + lq_sta->table_count_limit = IL_NONE_LEGACY_TBL_COUNT; + lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; + } + lq_sta->table_count = 0; + lq_sta->total_failed = 0; + lq_sta->total_success = 0; + lq_sta->flush_timer = jiffies; + lq_sta->action_counter = 0; +} + +/* + * Find correct throughput table for given mode of modulation + */ +static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl) +{ + /* Used to choose among HT tables */ + s32 (*ht_tbl_pointer)[RATE_COUNT]; + + /* Check for invalid LQ type */ + if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { + tbl->expected_tpt = expected_tpt_legacy; + return; + } + + /* Legacy rates have only one table */ + if (is_legacy(tbl->lq_type)) { + tbl->expected_tpt = expected_tpt_legacy; + return; + } + + /* Choose among many HT tables depending on number of streams + * (SISO/MIMO2), channel width (20/40), SGI, and aggregation + * status */ + if (is_siso(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) + ht_tbl_pointer = expected_tpt_siso20MHz; + else if (is_siso(tbl->lq_type)) + ht_tbl_pointer = expected_tpt_siso40MHz; + else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) + ht_tbl_pointer = expected_tpt_mimo2_20MHz; + else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ + ht_tbl_pointer = expected_tpt_mimo2_40MHz; + + if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ + tbl->expected_tpt = ht_tbl_pointer[0]; + else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ + tbl->expected_tpt = ht_tbl_pointer[1]; + else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ + tbl->expected_tpt = ht_tbl_pointer[2]; + else /* AGG+SGI */ + tbl->expected_tpt = ht_tbl_pointer[3]; +} + +/* + * Find starting rate for new "search" high-throughput mode of modulation. + * Goal is to find lowest expected rate (under perfect conditions) that is + * above the current measured throughput of "active" mode, to give new mode + * a fair chance to prove itself without too many challenges. + * + * This gets called when transitioning to more aggressive modulation + * (i.e. legacy to SISO or MIMO, or SISO to MIMO), as well as less aggressive + * (i.e. MIMO to SISO). When moving to MIMO, bit rate will typically need + * to decrease to match "active" throughput. When moving from MIMO to SISO, + * bit rate will typically need to increase, but not if performance was bad. + */ +static s32 il4965_rs_get_best_rate(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, /* "search" */ + u16 rate_mask, s8 idx) +{ + /* "active" values */ + struct il_scale_tbl_info *active_tbl = + &(lq_sta->lq_info[lq_sta->active_tbl]); + s32 active_sr = active_tbl->win[idx].success_ratio; + s32 active_tpt = active_tbl->expected_tpt[idx]; + + /* expected "search" throughput */ + s32 *tpt_tbl = tbl->expected_tpt; + + s32 new_rate, high, low, start_hi; + u16 high_low; + s8 rate = idx; + + new_rate = high = low = start_hi = RATE_INVALID; + + for (; ;) { + high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, + tbl->lq_type); + + low = high_low & 0xff; + high = (high_low >> 8) & 0xff; + + /* + * Lower the "search" bit rate, to give new "search" mode + * approximately the same throughput as "active" if: + * + * 1) "Active" mode has been working modestly well (but not + * great), and expected "search" throughput (under perfect + * conditions) at candidate rate is above the actual + * measured "active" throughput (but less than expected + * "active" throughput under perfect conditions). + * OR + * 2) "Active" mode has been working perfectly or very well + * and expected "search" throughput (under perfect + * conditions) at candidate rate is above expected + * "active" throughput (under perfect conditions). + */ + if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && + (active_sr > RATE_DECREASE_TH && + active_sr <= RATE_HIGH_TH && + tpt_tbl[rate] <= active_tpt)) || + (active_sr >= RATE_SCALE_SWITCH && + tpt_tbl[rate] > active_tpt)) { + + /* (2nd or later pass) + * If we've already tried to raise the rate, and are + * now trying to lower it, use the higher rate. */ + if (start_hi != RATE_INVALID) { + new_rate = start_hi; + break; + } + + new_rate = rate; + + /* Loop again with lower rate */ + if (low != RATE_INVALID) + rate = low; + + /* Lower rate not available, use the original */ + else + break; + + /* Else try to raise the "search" rate to match "active" */ + } else { + /* (2nd or later pass) + * If we've already tried to lower the rate, and are + * now trying to raise it, use the lower rate. */ + if (new_rate != RATE_INVALID) + break; + + /* Loop again with higher rate */ + else if (high != RATE_INVALID) { + start_hi = high; + rate = high; + + /* Higher rate not available, use the original */ + } else { + new_rate = rate; + break; + } + } + } + + return new_rate; +} + +/* + * Set up search table for MIMO2 + */ +static int il4965_rs_switch_to_mimo2(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) +{ + u16 rate_mask; + s32 rate; + s8 is_green = lq_sta->is_green; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) + return -1; + + if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) + == WLAN_HT_CAP_SM_PS_STATIC) + return -1; + + /* Need both Tx chains/antennas to support MIMO */ + if (il->hw_params.tx_chains_num < 2) + return -1; + + D_RATE("LQ: try to switch to MIMO2\n"); + + tbl->lq_type = LQ_MIMO2; + tbl->is_dup = lq_sta->is_dup; + tbl->action = 0; + tbl->max_search = IL_MAX_SEARCH; + rate_mask = lq_sta->active_mimo2_rate; + + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + tbl->is_ht40 = 1; + else + tbl->is_ht40 = 0; + + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); + + D_RATE("LQ: MIMO2 best rate %d mask %X\n", + rate, rate_mask); + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { + D_RATE( + "Can't switch with idx %d rate mask %x\n", + rate, rate_mask); + return -1; + } + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, + tbl, rate, is_green); + + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", + tbl->current_rate, is_green); + return 0; +} + +/* + * Set up search table for SISO + */ +static int il4965_rs_switch_to_siso(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) +{ + u16 rate_mask; + u8 is_green = lq_sta->is_green; + s32 rate; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) + return -1; + + D_RATE("LQ: try to switch to SISO\n"); + + tbl->is_dup = lq_sta->is_dup; + tbl->lq_type = LQ_SISO; + tbl->action = 0; + tbl->max_search = IL_MAX_SEARCH; + rate_mask = lq_sta->active_siso_rate; + + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + tbl->is_ht40 = 1; + else + tbl->is_ht40 = 0; + + if (is_green) + tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ + + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); + + D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { + D_RATE( + "can not switch with idx %d rate mask %x\n", + rate, rate_mask); + return -1; + } + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, + tbl, rate, is_green); + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", + tbl->current_rate, is_green); + return 0; +} + +/* + * Try to switch to new modulation mode from legacy + */ +static int il4965_rs_move_legacy_other(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + int idx) +{ + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + struct il_rate_scale_data *win = &(tbl->win[idx]); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u8 start_action; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; + int ret = 0; + u8 update_search_tbl_counter = 0; + + tbl->action = IL_LEGACY_SWITCH_SISO; + + start_action = tbl->action; + for (; ;) { + lq_sta->action_counter++; + switch (tbl->action) { + case IL_LEGACY_SWITCH_ANTENNA1: + case IL_LEGACY_SWITCH_ANTENNA2: + D_RATE("LQ: Legacy toggle Antenna\n"); + + if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && + tx_chains_num <= 1) || + (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && + tx_chains_num <= 2)) + break; + + /* Don't change antenna if success has been great */ + if (win->success_ratio >= IL_RS_GOOD_RATIO) + break; + + /* Set up search table to try other antenna */ + memcpy(search_tbl, tbl, sz); + + if (il4965_rs_toggle_antenna(valid_tx_ant, + &search_tbl->current_rate, search_tbl)) { + update_search_tbl_counter = 1; + il4965_rs_set_expected_tpt_table(lq_sta, + search_tbl); + goto out; + } + break; + case IL_LEGACY_SWITCH_SISO: + D_RATE("LQ: Legacy switch to SISO\n"); + + /* Set up search table to try SISO */ + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = 0; + ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, + search_tbl, idx); + if (!ret) { + lq_sta->action_counter = 0; + goto out; + } + + break; + case IL_LEGACY_SWITCH_MIMO2_AB: + case IL_LEGACY_SWITCH_MIMO2_AC: + case IL_LEGACY_SWITCH_MIMO2_BC: + D_RATE("LQ: Legacy switch to MIMO2\n"); + + /* Set up search table to try MIMO */ + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = 0; + + if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AB) + search_tbl->ant_type = ANT_AB; + else if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AC) + search_tbl->ant_type = ANT_AC; + else + search_tbl->ant_type = ANT_BC; + + if (!il4965_rs_is_valid_ant(valid_tx_ant, + search_tbl->ant_type)) + break; + + ret = il4965_rs_switch_to_mimo2(il, lq_sta, + conf, sta, + search_tbl, idx); + if (!ret) { + lq_sta->action_counter = 0; + goto out; + } + break; + } + tbl->action++; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; + + if (tbl->action == start_action) + break; + + } + search_tbl->lq_type = LQ_NONE; + return 0; + +out: + lq_sta->search_better_tbl = 1; + tbl->action++; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; + if (update_search_tbl_counter) + search_tbl->action = tbl->action; + return 0; + +} + +/* + * Try to switch to new modulation mode from SISO + */ +static int il4965_rs_move_siso_to_other(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) +{ + u8 is_green = lq_sta->is_green; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + struct il_rate_scale_data *win = &(tbl->win[idx]); + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u8 start_action; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; + u8 update_search_tbl_counter = 0; + int ret; + + start_action = tbl->action; + + for (;;) { + lq_sta->action_counter++; + switch (tbl->action) { + case IL_SISO_SWITCH_ANTENNA1: + case IL_SISO_SWITCH_ANTENNA2: + D_RATE("LQ: SISO toggle Antenna\n"); + if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && + tx_chains_num <= 1) || + (tbl->action == IL_SISO_SWITCH_ANTENNA2 && + tx_chains_num <= 2)) + break; + + if (win->success_ratio >= IL_RS_GOOD_RATIO) + break; + + memcpy(search_tbl, tbl, sz); + if (il4965_rs_toggle_antenna(valid_tx_ant, + &search_tbl->current_rate, search_tbl)) { + update_search_tbl_counter = 1; + goto out; + } + break; + case IL_SISO_SWITCH_MIMO2_AB: + case IL_SISO_SWITCH_MIMO2_AC: + case IL_SISO_SWITCH_MIMO2_BC: + D_RATE("LQ: SISO switch to MIMO2\n"); + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = 0; + + if (tbl->action == IL_SISO_SWITCH_MIMO2_AB) + search_tbl->ant_type = ANT_AB; + else if (tbl->action == IL_SISO_SWITCH_MIMO2_AC) + search_tbl->ant_type = ANT_AC; + else + search_tbl->ant_type = ANT_BC; + + if (!il4965_rs_is_valid_ant(valid_tx_ant, + search_tbl->ant_type)) + break; + + ret = il4965_rs_switch_to_mimo2(il, lq_sta, + conf, sta, + search_tbl, idx); + if (!ret) + goto out; + break; + case IL_SISO_SWITCH_GI: + if (!tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_20)) + break; + if (tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_40)) + break; + + D_RATE("LQ: SISO toggle SGI/NGI\n"); + + memcpy(search_tbl, tbl, sz); + if (is_green) { + if (!tbl->is_SGI) + break; + else + IL_ERR( + "SGI was set in GF+SISO\n"); + } + search_tbl->is_SGI = !tbl->is_SGI; + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + if (tbl->is_SGI) { + s32 tpt = lq_sta->last_tpt / 100; + if (tpt >= search_tbl->expected_tpt[idx]) + break; + } + search_tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, search_tbl, + idx, is_green); + update_search_tbl_counter = 1; + goto out; + } + tbl->action++; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; + + if (tbl->action == start_action) + break; + } + search_tbl->lq_type = LQ_NONE; + return 0; + + out: + lq_sta->search_better_tbl = 1; + tbl->action++; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; + if (update_search_tbl_counter) + search_tbl->action = tbl->action; + + return 0; +} + +/* + * Try to switch to new modulation mode from MIMO2 + */ +static int il4965_rs_move_mimo2_to_other(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) +{ + s8 is_green = lq_sta->is_green; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + struct il_rate_scale_data *win = &(tbl->win[idx]); + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u8 start_action; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; + u8 update_search_tbl_counter = 0; + int ret; + + start_action = tbl->action; + for (;;) { + lq_sta->action_counter++; + switch (tbl->action) { + case IL_MIMO2_SWITCH_ANTENNA1: + case IL_MIMO2_SWITCH_ANTENNA2: + D_RATE("LQ: MIMO2 toggle Antennas\n"); + + if (tx_chains_num <= 2) + break; + + if (win->success_ratio >= IL_RS_GOOD_RATIO) + break; + + memcpy(search_tbl, tbl, sz); + if (il4965_rs_toggle_antenna(valid_tx_ant, + &search_tbl->current_rate, search_tbl)) { + update_search_tbl_counter = 1; + goto out; + } + break; + case IL_MIMO2_SWITCH_SISO_A: + case IL_MIMO2_SWITCH_SISO_B: + case IL_MIMO2_SWITCH_SISO_C: + D_RATE("LQ: MIMO2 switch to SISO\n"); + + /* Set up new search table for SISO */ + memcpy(search_tbl, tbl, sz); + + if (tbl->action == IL_MIMO2_SWITCH_SISO_A) + search_tbl->ant_type = ANT_A; + else if (tbl->action == IL_MIMO2_SWITCH_SISO_B) + search_tbl->ant_type = ANT_B; + else + search_tbl->ant_type = ANT_C; + + if (!il4965_rs_is_valid_ant(valid_tx_ant, + search_tbl->ant_type)) + break; + + ret = il4965_rs_switch_to_siso(il, lq_sta, + conf, sta, + search_tbl, idx); + if (!ret) + goto out; + + break; + + case IL_MIMO2_SWITCH_GI: + if (!tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_20)) + break; + if (tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_40)) + break; + + D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); + + /* Set up new search table for MIMO2 */ + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = !tbl->is_SGI; + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + /* + * If active table already uses the fastest possible + * modulation (dual stream with short guard interval), + * and it's working well, there's no need to look + * for a better type of modulation! + */ + if (tbl->is_SGI) { + s32 tpt = lq_sta->last_tpt / 100; + if (tpt >= search_tbl->expected_tpt[idx]) + break; + } + search_tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, search_tbl, + idx, is_green); + update_search_tbl_counter = 1; + goto out; + + } + tbl->action++; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; + + if (tbl->action == start_action) + break; + } + search_tbl->lq_type = LQ_NONE; + return 0; + out: + lq_sta->search_better_tbl = 1; + tbl->action++; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; + if (update_search_tbl_counter) + search_tbl->action = tbl->action; + + return 0; + +} + +/* + * Check whether we should continue using same modulation mode, or + * begin search for a new mode, based on: + * 1) # tx successes or failures while using this mode + * 2) # times calling this function + * 3) elapsed time in this mode (not used, for now) + */ +static void +il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) +{ + struct il_scale_tbl_info *tbl; + int i; + int active_tbl; + int flush_interval_passed = 0; + struct il_priv *il; + + il = lq_sta->drv; + active_tbl = lq_sta->active_tbl; + + tbl = &(lq_sta->lq_info[active_tbl]); + + /* If we've been disallowing search, see if we should now allow it */ + if (lq_sta->stay_in_tbl) { + + /* Elapsed time using current modulation mode */ + if (lq_sta->flush_timer) + flush_interval_passed = + time_after(jiffies, + (unsigned long)(lq_sta->flush_timer + + RATE_SCALE_FLUSH_INTVL)); + + /* + * Check if we should allow search for new modulation mode. + * If many frames have failed or succeeded, or we've used + * this same modulation for a long time, allow search, and + * reset history stats that keep track of whether we should + * allow a new search. Also (below) reset all bitmaps and + * stats in active history. + */ + if (force_search || + lq_sta->total_failed > lq_sta->max_failure_limit || + lq_sta->total_success > lq_sta->max_success_limit || + (!lq_sta->search_better_tbl && lq_sta->flush_timer && + flush_interval_passed)) { + D_RATE("LQ: stay is expired %d %d %d\n:", + lq_sta->total_failed, + lq_sta->total_success, + flush_interval_passed); + + /* Allow search for new mode */ + lq_sta->stay_in_tbl = 0; /* only place reset */ + lq_sta->total_failed = 0; + lq_sta->total_success = 0; + lq_sta->flush_timer = 0; + + /* + * Else if we've used this modulation mode enough repetitions + * (regardless of elapsed time or success/failure), reset + * history bitmaps and rate-specific stats for all rates in + * active table. + */ + } else { + lq_sta->table_count++; + if (lq_sta->table_count >= + lq_sta->table_count_limit) { + lq_sta->table_count = 0; + + D_RATE( + "LQ: stay in table clear win\n"); + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &(tbl->win[i])); + } + } + + /* If transitioning to allow "search", reset all history + * bitmaps and stats in active table (this will become the new + * "search" table). */ + if (!lq_sta->stay_in_tbl) { + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &(tbl->win[i])); + } + } +} + +/* + * setup rate table in uCode + * return rate_n_flags as used in the table + */ +static u32 il4965_rs_update_rate_tbl(struct il_priv *il, + struct il_rxon_context *ctx, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, + int idx, u8 is_green) +{ + u32 rate; + + /* Update uCode's rate table. */ + rate = il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); + il4965_rs_fill_link_cmd(il, lq_sta, rate); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); + + return rate; +} + +/* + * Do rate scaling and search for new modulation mode. + */ +static void il4965_rs_rate_scale_perform(struct il_priv *il, + struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta) +{ + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &hw->conf; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + int low = RATE_INVALID; + int high = RATE_INVALID; + int idx; + int i; + struct il_rate_scale_data *win = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; + u32 fail_count; + s8 scale_action = 0; + u16 rate_mask; + u8 update_lq = 0; + struct il_scale_tbl_info *tbl, *tbl1; + u16 rate_scale_idx_msk = 0; + u32 rate; + u8 is_green = 0; + u8 active_tbl = 0; + u8 done_search = 0; + u16 high_low; + s32 sr; + u8 tid = MAX_TID_COUNT; + struct il_tid_data *tid_data; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + D_RATE("rate scale calculate new rate for skb\n"); + + /* Send management frames and NO_ACK data using lowest rate. */ + /* TODO: this could probably be improved.. */ + if (!ieee80211_is_data(hdr->frame_control) || + (info->flags & IEEE80211_TX_CTL_NO_ACK)) + return; + + if (!sta || !lq_sta) + return; + + lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; + + tid = il4965_rs_tl_add_packet(lq_sta, hdr); + if (tid != MAX_TID_COUNT && (lq_sta->tx_agg_tid_en & (1 << tid))) { + tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; + if (tid_data->agg.state == IL_AGG_OFF) + lq_sta->is_agg = 0; + else + lq_sta->is_agg = 1; + } else + lq_sta->is_agg = 0; + + /* + * Select rate-scale / modulation-mode table to work with in + * the rest of this function: "search" if searching for better + * modulation mode, or "active" if doing rate scaling within a mode. + */ + if (!lq_sta->search_better_tbl) + active_tbl = lq_sta->active_tbl; + else + active_tbl = 1 - lq_sta->active_tbl; + + tbl = &(lq_sta->lq_info[active_tbl]); + if (is_legacy(tbl->lq_type)) + lq_sta->is_green = 0; + else + lq_sta->is_green = il4965_rs_use_green(sta); + is_green = lq_sta->is_green; + + /* current tx rate */ + idx = lq_sta->last_txrate_idx; + + D_RATE("Rate scale idx %d for type %d\n", idx, + tbl->lq_type); + + /* rates available for this association, and for modulation mode */ + rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); + + D_RATE("mask 0x%04X\n", rate_mask); + + /* mask with station rate restriction */ + if (is_legacy(tbl->lq_type)) { + if (lq_sta->band == IEEE80211_BAND_5GHZ) + /* supp_rates has no CCK bits in A mode */ + rate_scale_idx_msk = (u16) (rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + else + rate_scale_idx_msk = (u16) (rate_mask & + lq_sta->supp_rates); + + } else + rate_scale_idx_msk = rate_mask; + + if (!rate_scale_idx_msk) + rate_scale_idx_msk = rate_mask; + + if (!((1 << idx) & rate_scale_idx_msk)) { + IL_ERR("Current Rate is not valid\n"); + if (lq_sta->search_better_tbl) { + /* revert to active table if search table is not valid*/ + tbl->lq_type = LQ_NONE; + lq_sta->search_better_tbl = 0; + tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + /* get "active" rate info */ + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, + tbl, idx, is_green); + } + return; + } + + /* Get expected throughput table and history win for current rate */ + if (!tbl->expected_tpt) { + IL_ERR("tbl->expected_tpt is NULL\n"); + return; + } + + /* force user max rate if set by user */ + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < idx) { + idx = lq_sta->max_rate_idx; + update_lq = 1; + win = &(tbl->win[idx]); + goto lq_update; + } + + win = &(tbl->win[idx]); + + /* + * If there is not enough history to calculate actual average + * throughput, keep analyzing results of more tx frames, without + * changing rate or mode (bypass most of the rest of this function). + * Set up new rate table in uCode only if old rate is not supported + * in current association (use new rate found above). + */ + fail_count = win->counter - win->success_counter; + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { + D_RATE("LQ: still below TH. succ=%d total=%d " + "for idx %d\n", + win->success_counter, win->counter, idx); + + /* Can't calculate this yet; not enough history */ + win->average_tpt = IL_INVALID_VALUE; + + /* Should we stay with this modulation mode, + * or search for a new one? */ + il4965_rs_stay_in_table(lq_sta, false); + + goto out; + } + /* Else we have enough samples; calculate estimate of + * actual average throughput */ + if (win->average_tpt != ((win->success_ratio * + tbl->expected_tpt[idx] + 64) / 128)) { + IL_ERR( + "expected_tpt should have been calculated by now\n"); + win->average_tpt = ((win->success_ratio * + tbl->expected_tpt[idx] + 64) / 128); + } + + /* If we are searching for better modulation mode, check success. */ + if (lq_sta->search_better_tbl) { + /* If good success, continue using the "search" mode; + * no need to send new link quality command, since we're + * continuing to use the setup that we've been trying. */ + if (win->average_tpt > lq_sta->last_tpt) { + + D_RATE("LQ: SWITCHING TO NEW TBL " + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, + win->average_tpt, + lq_sta->last_tpt); + + if (!is_legacy(tbl->lq_type)) + lq_sta->enable_counter = 1; + + /* Swap tables; "search" becomes "active" */ + lq_sta->active_tbl = active_tbl; + current_tpt = win->average_tpt; + + /* Else poor success; go back to mode in "active" table */ + } else { + + D_RATE("LQ: GOING BACK TO THE OLD TBL " + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, + win->average_tpt, + lq_sta->last_tpt); + + /* Nullify "search" table */ + tbl->lq_type = LQ_NONE; + + /* Revert to "active" table */ + active_tbl = lq_sta->active_tbl; + tbl = &(lq_sta->lq_info[active_tbl]); + + /* Revert to "active" rate and throughput info */ + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); + current_tpt = lq_sta->last_tpt; + + /* Need to set up a new rate table in uCode */ + update_lq = 1; + } + + /* Either way, we've made a decision; modulation mode + * search is done, allow rate adjustment next time. */ + lq_sta->search_better_tbl = 0; + done_search = 1; /* Don't switch modes below! */ + goto lq_update; + } + + /* (Else) not in search of better modulation mode, try for better + * starting rate, while staying in this mode. */ + high_low = il4965_rs_get_adjacent_rate(il, idx, + rate_scale_idx_msk, + tbl->lq_type); + low = high_low & 0xff; + high = (high_low >> 8) & 0xff; + + /* If user set max rate, dont allow higher than user constrain */ + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < high) + high = RATE_INVALID; + + sr = win->success_ratio; + + /* Collect measured throughputs for current and adjacent rates */ + current_tpt = win->average_tpt; + if (low != RATE_INVALID) + low_tpt = tbl->win[low].average_tpt; + if (high != RATE_INVALID) + high_tpt = tbl->win[high].average_tpt; + + scale_action = 0; + + /* Too many failures, decrease rate */ + if (sr <= RATE_DECREASE_TH || current_tpt == 0) { + D_RATE( + "decrease rate because of low success_ratio\n"); + scale_action = -1; + + /* No throughput measured yet for adjacent rates; try increase. */ + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { + + if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) + scale_action = 1; + else if (low != RATE_INVALID) + scale_action = 0; + } + + /* Both adjacent throughputs are measured, but neither one has better + * throughput; we're using the best rate, don't change it! */ + else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) + scale_action = 0; + + /* At least one adjacent rate's throughput is measured, + * and may have better performance. */ + else { + /* Higher adjacent rate's throughput is measured */ + if (high_tpt != IL_INVALID_VALUE) { + /* Higher rate has better throughput */ + if (high_tpt > current_tpt && + sr >= RATE_INCREASE_TH) { + scale_action = 1; + } else { + scale_action = 0; + } + + /* Lower adjacent rate's throughput is measured */ + } else if (low_tpt != IL_INVALID_VALUE) { + /* Lower rate has better throughput */ + if (low_tpt > current_tpt) { + D_RATE( + "decrease rate because of low tpt\n"); + scale_action = -1; + } else if (sr >= RATE_INCREASE_TH) { + scale_action = 1; + } + } + } + + /* Sanity check; asked for decrease, but success rate or throughput + * has been good at old rate. Don't change it. */ + if (scale_action == -1 && low != RATE_INVALID && + (sr > RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) + scale_action = 0; + + switch (scale_action) { + case -1: + /* Decrease starting rate, update uCode's rate table */ + if (low != RATE_INVALID) { + update_lq = 1; + idx = low; + } + + break; + case 1: + /* Increase starting rate, update uCode's rate table */ + if (high != RATE_INVALID) { + update_lq = 1; + idx = high; + } + + break; + case 0: + /* No change */ + default: + break; + } + + D_RATE("choose rate scale idx %d action %d low %d " + "high %d type %d\n", + idx, scale_action, low, high, tbl->lq_type); + +lq_update: + /* Replace uCode's rate table for the destination station. */ + if (update_lq) + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, + tbl, idx, is_green); + + /* Should we stay with this modulation mode, + * or search for a new one? */ + il4965_rs_stay_in_table(lq_sta, false); + + /* + * Search for new modulation mode if we're: + * 1) Not changing rates right now + * 2) Not just finishing up a search + * 3) Allowing a new search + */ + if (!update_lq && !done_search && !lq_sta->stay_in_tbl && + win->counter) { + /* Save current throughput to compare with "search" throughput*/ + lq_sta->last_tpt = current_tpt; + + /* Select a new "search" modulation mode to try. + * If one is found, set up the new "search" table. */ + if (is_legacy(tbl->lq_type)) + il4965_rs_move_legacy_other(il, lq_sta, + conf, sta, idx); + else if (is_siso(tbl->lq_type)) + il4965_rs_move_siso_to_other(il, lq_sta, + conf, sta, idx); + else /* (is_mimo2(tbl->lq_type)) */ + il4965_rs_move_mimo2_to_other(il, lq_sta, + conf, sta, idx); + + /* If new "search" mode was selected, set up in uCode table */ + if (lq_sta->search_better_tbl) { + /* Access the "search" table, clear its history. */ + tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &(tbl->win[i])); + + /* Use new "search" start rate */ + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); + + D_RATE( + "Switch current mcs: %X idx: %d\n", + tbl->current_rate, idx); + il4965_rs_fill_link_cmd(il, lq_sta, + tbl->current_rate); + il_send_lq_cmd(il, ctx, + &lq_sta->lq, CMD_ASYNC, false); + } else + done_search = 1; + } + + if (done_search && !lq_sta->stay_in_tbl) { + /* If the "active" (non-search) mode was legacy, + * and we've tried switching antennas, + * but we haven't been able to try HT modes (not available), + * stay with best antenna legacy modulation for a while + * before next round of mode comparisons. */ + tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); + if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && + lq_sta->action_counter > tbl1->max_search) { + D_RATE("LQ: STAY in legacy table\n"); + il4965_rs_set_stay_in_table(il, 1, lq_sta); + } + + /* If we're in an HT mode, and all 3 mode switch actions + * have been tried and compared, stay in this best modulation + * mode for a while before next round of mode comparisons. */ + if (lq_sta->enable_counter && + lq_sta->action_counter >= tbl1->max_search) { + if (lq_sta->last_tpt > IL_AGG_TPT_THREHOLD && + (lq_sta->tx_agg_tid_en & (1 << tid)) && + tid != MAX_TID_COUNT) { + tid_data = + &il->stations[lq_sta->lq.sta_id].tid[tid]; + if (tid_data->agg.state == IL_AGG_OFF) { + D_RATE( + "try to aggregate tid %d\n", + tid); + il4965_rs_tl_turn_on_agg(il, tid, + lq_sta, sta); + } + } + il4965_rs_set_stay_in_table(il, 0, lq_sta); + } + } + +out: + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, + idx, is_green); + i = idx; + lq_sta->last_txrate_idx = i; +} + +/** + * il4965_rs_initialize_lq - Initialize a station's hardware rate table + * + * The uCode's station table contains a table of fallback rates + * for automatic fallback during transmission. + * + * NOTE: This sets up a default set of values. These will be replaced later + * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of + * rc80211_simple. + * + * NOTE: Run REPLY_ADD_STA command to set up station table entry, before + * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, + * which requires station table entry to exist). + */ +static void il4965_rs_initialize_lq(struct il_priv *il, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta) +{ + struct il_scale_tbl_info *tbl; + int rate_idx; + int i; + u32 rate; + u8 use_green = il4965_rs_use_green(sta); + u8 active_tbl = 0; + u8 valid_tx_ant; + struct il_station_priv *sta_priv; + struct il_rxon_context *ctx; + + if (!sta || !lq_sta) + return; + + sta_priv = (void *)sta->drv_priv; + ctx = sta_priv->common.ctx; + + i = lq_sta->last_txrate_idx; + + valid_tx_ant = il->hw_params.valid_tx_ant; + + if (!lq_sta->search_better_tbl) + active_tbl = lq_sta->active_tbl; + else + active_tbl = 1 - lq_sta->active_tbl; + + tbl = &(lq_sta->lq_info[active_tbl]); + + if (i < 0 || i >= RATE_COUNT) + i = 0; + + rate = il_rates[i].plcp; + tbl->ant_type = il4965_first_antenna(valid_tx_ant); + rate |= tbl->ant_type << RATE_MCS_ANT_POS; + + if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) + rate |= RATE_MCS_CCK_MSK; + + il4965_rs_get_tbl_info_from_mcs(rate, il->band, tbl, &rate_idx); + if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) + il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); + + rate = il4965_rate_n_flags_from_tbl(il, tbl, rate_idx, use_green); + tbl->current_rate = rate; + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + il4965_rs_fill_link_cmd(NULL, lq_sta, rate); + il->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_SYNC, true); +} + +static void +il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, + struct ieee80211_tx_rate_control *txrc) +{ + + struct sk_buff *skb = txrc->skb; + struct ieee80211_supported_band *sband = txrc->sband; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct il_lq_sta *lq_sta = il_sta; + int rate_idx; + + D_RATE("rate scale calculate new rate for skb\n"); + + /* Get max rate if user set max rate */ + if (lq_sta) { + lq_sta->max_rate_idx = txrc->max_rate_idx; + if (sband->band == IEEE80211_BAND_5GHZ && + lq_sta->max_rate_idx != -1) + lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; + if (lq_sta->max_rate_idx < 0 || + lq_sta->max_rate_idx >= RATE_COUNT) + lq_sta->max_rate_idx = -1; + } + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (lq_sta && !lq_sta->drv) { + D_RATE("Rate scaling not initialized yet.\n"); + il_sta = NULL; + } + + /* Send management frames and NO_ACK data using lowest rate. */ + if (rate_control_send_low(sta, il_sta, txrc)) + return; + + if (!lq_sta) + return; + + rate_idx = lq_sta->last_txrate_idx; + + if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { + rate_idx -= IL_FIRST_OFDM_RATE; + /* 6M and 9M shared same MCS idx */ + rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; + if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= + RATE_MIMO2_6M_PLCP) + rate_idx = rate_idx + MCS_IDX_PER_STREAM; + info->control.rates[0].flags = IEEE80211_TX_RC_MCS; + if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_SHORT_GI; + if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_DUP_DATA; + if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_40_MHZ_WIDTH; + if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_GREEN_FIELD; + } else { + /* Check for invalid rates */ + if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || + (sband->band == IEEE80211_BAND_5GHZ && + rate_idx < IL_FIRST_OFDM_RATE)) + rate_idx = rate_lowest_index(sband, sta); + /* On valid 5 GHz rate, adjust idx */ + else if (sband->band == IEEE80211_BAND_5GHZ) + rate_idx -= IL_FIRST_OFDM_RATE; + info->control.rates[0].flags = 0; + } + info->control.rates[0].idx = rate_idx; + +} + +static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, + gfp_t gfp) +{ + struct il_lq_sta *lq_sta; + struct il_station_priv *sta_priv = + (struct il_station_priv *) sta->drv_priv; + struct il_priv *il; + + il = (struct il_priv *)il_rate; + D_RATE("create station rate scale win\n"); + + lq_sta = &sta_priv->lq_sta; + + return lq_sta; +} + +/* + * Called after adding a new station to initialize rate scaling + */ +void +il4965_rs_rate_init(struct il_priv *il, + struct ieee80211_sta *sta, + u8 sta_id) +{ + int i, j; + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + struct il_station_priv *sta_priv; + struct il_lq_sta *lq_sta; + struct ieee80211_supported_band *sband; + + sta_priv = (struct il_station_priv *) sta->drv_priv; + lq_sta = &sta_priv->lq_sta; + sband = hw->wiphy->bands[conf->channel->band]; + + + lq_sta->lq.sta_id = sta_id; + + for (j = 0; j < LQ_SIZE; j++) + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &lq_sta->lq_info[j].win[i]); + + lq_sta->flush_timer = 0; + lq_sta->supp_rates = sta->supp_rates[sband->band]; + for (j = 0; j < LQ_SIZE; j++) + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &lq_sta->lq_info[j].win[i]); + + D_RATE("LQ:" + "*** rate scale station global init for station %d ***\n", + sta_id); + /* TODO: what is a good starting rate for STA? About middle? Maybe not + * the lowest or the highest rate.. Could consider using RSSI from + * previous packets? Need to have IEEE 802.1X auth succeed immediately + * after assoc.. */ + + lq_sta->is_dup = 0; + lq_sta->max_rate_idx = -1; + lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; + lq_sta->is_green = il4965_rs_use_green(sta); + lq_sta->active_legacy_rate = il->active_rate & ~(0x1000); + lq_sta->band = il->band; + /* + * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), + * supp_rates[] does not; shift to convert format, force 9 MBits off. + */ + lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; + lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; + lq_sta->active_siso_rate &= ~((u16)0x2); + lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; + + /* Same here */ + lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; + lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; + lq_sta->active_mimo2_rate &= ~((u16)0x2); + lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; + + /* These values will be overridden later */ + lq_sta->lq.general_params.single_stream_ant_msk = + il4965_first_antenna(il->hw_params.valid_tx_ant); + lq_sta->lq.general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); + if (!lq_sta->lq.general_params.dual_stream_ant_msk) { + lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { + lq_sta->lq.general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant; + } + + /* as default allow aggregation for all tids */ + lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; + lq_sta->drv = il; + + /* Set last_txrate_idx to lowest rate */ + lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); + if (sband->band == IEEE80211_BAND_5GHZ) + lq_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; + lq_sta->is_agg = 0; + +#ifdef CONFIG_MAC80211_DEBUGFS + lq_sta->dbg_fixed_rate = 0; +#endif + + il4965_rs_initialize_lq(il, conf, sta, lq_sta); +} + +static void il4965_rs_fill_link_cmd(struct il_priv *il, + struct il_lq_sta *lq_sta, u32 new_rate) +{ + struct il_scale_tbl_info tbl_type; + int idx = 0; + int rate_idx; + int repeat_rate = 0; + u8 ant_toggle_cnt = 0; + u8 use_ht_possible = 1; + u8 valid_tx_ant = 0; + struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; + + /* Override starting rate (idx 0) if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); + + /* Interpret new_rate (rate_n_flags) */ + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, + &tbl_type, &rate_idx); + + /* How many times should we repeat the initial rate? */ + if (is_legacy(tbl_type.lq_type)) { + ant_toggle_cnt = 1; + repeat_rate = IL_NUMBER_TRY; + } else { + repeat_rate = IL_HT_NUMBER_TRY; + } + + lq_cmd->general_params.mimo_delimiter = + is_mimo(tbl_type.lq_type) ? 1 : 0; + + /* Fill 1st table entry (idx 0) */ + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); + + if (il4965_num_of_ant(tbl_type.ant_type) == 1) { + lq_cmd->general_params.single_stream_ant_msk = + tbl_type.ant_type; + } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { + lq_cmd->general_params.dual_stream_ant_msk = + tbl_type.ant_type; + } /* otherwise we don't modify the existing value */ + + idx++; + repeat_rate--; + if (il) + valid_tx_ant = il->hw_params.valid_tx_ant; + + /* Fill rest of rate table */ + while (idx < LINK_QUAL_MAX_RETRY_NUM) { + /* Repeat initial/next rate. + * For legacy IL_NUMBER_TRY == 1, this loop will not execute. + * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ + while (repeat_rate > 0 && idx < LINK_QUAL_MAX_RETRY_NUM) { + if (is_legacy(tbl_type.lq_type)) { + if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) + ant_toggle_cnt++; + else if (il && + il4965_rs_toggle_antenna(valid_tx_ant, + &new_rate, &tbl_type)) + ant_toggle_cnt = 1; + } + + /* Override next rate if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); + + /* Fill next table entry */ + lq_cmd->rs_table[idx].rate_n_flags = + cpu_to_le32(new_rate); + repeat_rate--; + idx++; + } + + il4965_rs_get_tbl_info_from_mcs(new_rate, + lq_sta->band, &tbl_type, + &rate_idx); + + /* Indicate to uCode which entries might be MIMO. + * If initial rate was MIMO, this will finally end up + * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ + if (is_mimo(tbl_type.lq_type)) + lq_cmd->general_params.mimo_delimiter = idx; + + /* Get next rate */ + new_rate = il4965_rs_get_lower_rate(lq_sta, + &tbl_type, rate_idx, + use_ht_possible); + + /* How many times should we repeat the next rate? */ + if (is_legacy(tbl_type.lq_type)) { + if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) + ant_toggle_cnt++; + else if (il && + il4965_rs_toggle_antenna(valid_tx_ant, + &new_rate, &tbl_type)) + ant_toggle_cnt = 1; + + repeat_rate = IL_NUMBER_TRY; + } else { + repeat_rate = IL_HT_NUMBER_TRY; + } + + /* Don't allow HT rates after next pass. + * il4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ + use_ht_possible = 0; + + /* Override next rate if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); + + /* Fill next table entry */ + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); + + idx++; + repeat_rate--; + } + + lq_cmd->agg_params.agg_frame_cnt_limit = LINK_QUAL_AGG_FRAME_LIMIT_DEF; + lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; + + lq_cmd->agg_params.agg_time_limit = + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); +} + +static void +*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +{ + return hw->priv; +} +/* rate scale requires free function to be implemented */ +static void il4965_rs_free(void *il_rate) +{ + return; +} + +static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, + void *il_sta) +{ + struct il_priv *il __maybe_unused = il_r; + + D_RATE("enter\n"); + D_RATE("leave\n"); +} + + +#ifdef CONFIG_MAC80211_DEBUGFS +static int il4965_open_file_generic(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, + u32 *rate_n_flags, int idx) +{ + struct il_priv *il; + u8 valid_tx_ant; + u8 ant_sel_tx; + + il = lq_sta->drv; + valid_tx_ant = il->hw_params.valid_tx_ant; + if (lq_sta->dbg_fixed_rate) { + ant_sel_tx = + ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) + >> RATE_MCS_ANT_POS); + if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { + *rate_n_flags = lq_sta->dbg_fixed_rate; + D_RATE("Fixed rate ON\n"); + } else { + lq_sta->dbg_fixed_rate = 0; + IL_ERR( + "Invalid antenna selection 0x%X, Valid is 0x%X\n", + ant_sel_tx, valid_tx_ant); + D_RATE("Fixed rate OFF\n"); + } + } else { + D_RATE("Fixed rate OFF\n"); + } +} + +static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, + const char __user *user_buf, size_t count, loff_t *ppos) +{ + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *il; + char buf[64]; + size_t buf_size; + u32 parsed_rate; + struct il_station_priv *sta_priv = + container_of(lq_sta, struct il_station_priv, lq_sta); + struct il_rxon_context *ctx = sta_priv->common.ctx; + + il = lq_sta->drv; + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + if (sscanf(buf, "%x", &parsed_rate) == 1) + lq_sta->dbg_fixed_rate = parsed_rate; + else + lq_sta->dbg_fixed_rate = 0; + + lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ + lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + + D_RATE("sta_id %d rate 0x%X\n", + lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); + + if (lq_sta->dbg_fixed_rate) { + il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); + il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, + false); + } + + return count; +} + +static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char *buff; + int desc = 0; + int i = 0; + int idx = 0; + ssize_t ret; + + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *il; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + + il = lq_sta->drv; + buff = kmalloc(1024, GFP_KERNEL); + if (!buff) + return -ENOMEM; + + desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); + desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", + lq_sta->total_failed, lq_sta->total_success, + lq_sta->active_legacy_rate); + desc += sprintf(buff+desc, "fixed rate 0x%X\n", + lq_sta->dbg_fixed_rate); + desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", + (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", + (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", + (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); + desc += sprintf(buff+desc, "lq type %s\n", + (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); + if (is_Ht(tbl->lq_type)) { + desc += sprintf(buff+desc, " %s", + (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); + desc += sprintf(buff+desc, " %s", + (tbl->is_ht40) ? "40MHz" : "20MHz"); + desc += sprintf(buff+desc, " %s %s %s\n", + (tbl->is_SGI) ? "SGI" : "", + (lq_sta->is_green) ? "GF enabled" : "", + (lq_sta->is_agg) ? "AGG on" : ""); + } + desc += sprintf(buff+desc, "last tx rate=0x%X\n", + lq_sta->last_rate_n_flags); + desc += sprintf(buff+desc, "general:" + "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", + lq_sta->lq.general_params.flags, + lq_sta->lq.general_params.mimo_delimiter, + lq_sta->lq.general_params.single_stream_ant_msk, + lq_sta->lq.general_params.dual_stream_ant_msk); + + desc += sprintf(buff+desc, "agg:" + "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", + le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), + lq_sta->lq.agg_params.agg_dis_start_th, + lq_sta->lq.agg_params.agg_frame_cnt_limit); + + desc += sprintf(buff+desc, + "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", + lq_sta->lq.general_params.start_rate_idx[0], + lq_sta->lq.general_params.start_rate_idx[1], + lq_sta->lq.general_params.start_rate_idx[2], + lq_sta->lq.general_params.start_rate_idx[3]); + + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { + idx = il4965_hwrate_to_plcp_idx( + le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); + if (is_legacy(tbl->lq_type)) { + desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", + i, + le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), + il_rate_mcs[idx].mbps); + } else { + desc += sprintf(buff+desc, + " rate[%d] 0x%X %smbps (%s)\n", + i, + le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), + il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); + } + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + kfree(buff); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_scale_table_ops = { + .write = il4965_rs_sta_dbgfs_scale_table_write, + .read = il4965_rs_sta_dbgfs_scale_table_read, + .open = il4965_open_file_generic, + .llseek = default_llseek, +}; +static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char *buff; + int desc = 0; + int i, j; + ssize_t ret; + + struct il_lq_sta *lq_sta = file->private_data; + + buff = kmalloc(1024, GFP_KERNEL); + if (!buff) + return -ENOMEM; + + for (i = 0; i < LQ_SIZE; i++) { + desc += sprintf(buff+desc, + "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" + "rate=0x%X\n", + lq_sta->active_tbl == i ? "*" : "x", + lq_sta->lq_info[i].lq_type, + lq_sta->lq_info[i].is_SGI, + lq_sta->lq_info[i].is_ht40, + lq_sta->lq_info[i].is_dup, + lq_sta->is_green, + lq_sta->lq_info[i].current_rate); + for (j = 0; j < RATE_COUNT; j++) { + desc += sprintf(buff+desc, + "counter=%d success=%d %%=%d\n", + lq_sta->lq_info[i].win[j].counter, + lq_sta->lq_info[i].win[j].success_counter, + lq_sta->lq_info[i].win[j].success_ratio); + } + } + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + kfree(buff); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_stats_table_ops = { + .read = il4965_rs_sta_dbgfs_stats_table_read, + .open = il4965_open_file_generic, + .llseek = default_llseek, +}; + +static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char buff[120]; + int desc = 0; + ssize_t ret; + + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *il; + struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; + + il = lq_sta->drv; + + if (is_Ht(tbl->lq_type)) + desc += sprintf(buff+desc, + "Bit Rate= %d Mb/s\n", + tbl->expected_tpt[lq_sta->last_txrate_idx]); + else + desc += sprintf(buff+desc, + "Bit Rate= %d Mb/s\n", + il_rates[lq_sta->last_txrate_idx].ieee >> 1); + + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { + .read = il4965_rs_sta_dbgfs_rate_scale_data_read, + .open = il4965_open_file_generic, + .llseek = default_llseek, +}; + +static void il4965_rs_add_debugfs(void *il, void *il_sta, + struct dentry *dir) +{ + struct il_lq_sta *lq_sta = il_sta; + lq_sta->rs_sta_dbgfs_scale_table_file = + debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, + lq_sta, &rs_sta_dbgfs_scale_table_ops); + lq_sta->rs_sta_dbgfs_stats_table_file = + debugfs_create_file("rate_stats_table", S_IRUSR, dir, + lq_sta, &rs_sta_dbgfs_stats_table_ops); + lq_sta->rs_sta_dbgfs_rate_scale_data_file = + debugfs_create_file("rate_scale_data", S_IRUSR, dir, + lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); + lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = + debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, + &lq_sta->tx_agg_tid_en); + +} + +static void il4965_rs_remove_debugfs(void *il, void *il_sta) +{ + struct il_lq_sta *lq_sta = il_sta; + debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); + debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); + debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); + debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); +} +#endif + +/* + * Initialization of rate scaling information is done by driver after + * the station is added. Since mac80211 calls this function before a + * station is added we ignore it. + */ +static void +il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) +{ +} +static struct rate_control_ops rs_4965_ops = { + .module = NULL, + .name = IL4965_RS_NAME, + .tx_status = il4965_rs_tx_status, + .get_rate = il4965_rs_get_rate, + .rate_init = il4965_rs_rate_init_stub, + .alloc = il4965_rs_alloc, + .free = il4965_rs_free, + .alloc_sta = il4965_rs_alloc_sta, + .free_sta = il4965_rs_free_sta, +#ifdef CONFIG_MAC80211_DEBUGFS + .add_sta_debugfs = il4965_rs_add_debugfs, + .remove_sta_debugfs = il4965_rs_remove_debugfs, +#endif +}; + +int il4965_rate_control_register(void) +{ + return ieee80211_rate_control_register(&rs_4965_ops); +} + +void il4965_rate_control_unregister(void) +{ + ieee80211_rate_control_unregister(&rs_4965_ops); +} diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index d0f9f23..b0ffa98 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -8,9 +8,8 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-calib.o -iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o +iwl4965-objs := 4965.o 4965-mac.o 4965-rs.o 4965-calib.o +iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += 4965-debug.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c deleted file mode 100644 index 1d873a6..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ /dev/null @@ -1,966 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-4965-calib.h" - -/***************************************************************************** - * INIT calibrations framework - *****************************************************************************/ - -struct stats_general_data { - u32 beacon_silence_rssi_a; - u32 beacon_silence_rssi_b; - u32 beacon_silence_rssi_c; - u32 beacon_energy_a; - u32 beacon_energy_b; - u32 beacon_energy_c; -}; - -void il4965_calib_free_results(struct il_priv *il) -{ - int i; - - for (i = 0; i < IL_CALIB_MAX; i++) { - kfree(il->calib_results[i].buf); - il->calib_results[i].buf = NULL; - il->calib_results[i].buf_len = 0; - } -} - -/***************************************************************************** - * RUNTIME calibrations framework - *****************************************************************************/ - -/* "false alarms" are signals that our DSP tries to lock onto, - * but then determines that they are either noise, or transmissions - * from a distant wireless network (also "noise", really) that get - * "stepped on" by stronger transmissions within our own network. - * This algorithm attempts to set a sensitivity level that is high - * enough to receive all of our own network traffic, but not so - * high that our DSP gets too busy trying to lock onto non-network - * activity/noise. */ -static int il4965_sens_energy_cck(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time, - struct stats_general_data *rx_info) -{ - u32 max_nrg_cck = 0; - int i = 0; - u8 max_silence_rssi = 0; - u32 silence_ref = 0; - u8 silence_rssi_a = 0; - u8 silence_rssi_b = 0; - u8 silence_rssi_c = 0; - u32 val; - - /* "false_alarms" values below are cross-multiplications to assess the - * numbers of false alarms within the measured period of actual Rx - * (Rx is off when we're txing), vs the min/max expected false alarms - * (some should be expected if rx is sensitive enough) in a - * hypothetical listening period of 200 time units (TU), 204.8 msec: - * - * MIN_FA/fixed-time < false_alarms/actual-rx-time < MAX_FA/beacon-time - * - * */ - u32 false_alarms = norm_fa * 200 * 1024; - u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; - u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; - struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - - data = &(il->sensitivity_data); - - data->nrg_auto_corr_silence_diff = 0; - - /* Find max silence rssi among all 3 receivers. - * This is background noise, which may include transmissions from other - * networks, measured during silence before our network's beacon */ - silence_rssi_a = (u8)((rx_info->beacon_silence_rssi_a & - ALL_BAND_FILTER) >> 8); - silence_rssi_b = (u8)((rx_info->beacon_silence_rssi_b & - ALL_BAND_FILTER) >> 8); - silence_rssi_c = (u8)((rx_info->beacon_silence_rssi_c & - ALL_BAND_FILTER) >> 8); - - val = max(silence_rssi_b, silence_rssi_c); - max_silence_rssi = max(silence_rssi_a, (u8) val); - - /* Store silence rssi in 20-beacon history table */ - data->nrg_silence_rssi[data->nrg_silence_idx] = max_silence_rssi; - data->nrg_silence_idx++; - if (data->nrg_silence_idx >= NRG_NUM_PREV_STAT_L) - data->nrg_silence_idx = 0; - - /* Find max silence rssi across 20 beacon history */ - for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) { - val = data->nrg_silence_rssi[i]; - silence_ref = max(silence_ref, val); - } - D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", - silence_rssi_a, silence_rssi_b, silence_rssi_c, - silence_ref); - - /* Find max rx energy (min value!) among all 3 receivers, - * measured during beacon frame. - * Save it in 10-beacon history table. */ - i = data->nrg_energy_idx; - val = min(rx_info->beacon_energy_b, rx_info->beacon_energy_c); - data->nrg_value[i] = min(rx_info->beacon_energy_a, val); - - data->nrg_energy_idx++; - if (data->nrg_energy_idx >= 10) - data->nrg_energy_idx = 0; - - /* Find min rx energy (max value) across 10 beacon history. - * This is the minimum signal level that we want to receive well. - * Add backoff (margin so we don't miss slightly lower energy frames). - * This establishes an upper bound (min value) for energy threshold. */ - max_nrg_cck = data->nrg_value[0]; - for (i = 1; i < 10; i++) - max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); - max_nrg_cck += 6; - - D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", - rx_info->beacon_energy_a, rx_info->beacon_energy_b, - rx_info->beacon_energy_c, max_nrg_cck - 6); - - /* Count number of consecutive beacons with fewer-than-desired - * false alarms. */ - if (false_alarms < min_false_alarms) - data->num_in_cck_no_fa++; - else - data->num_in_cck_no_fa = 0; - D_CALIB("consecutive bcns with few false alarms = %u\n", - data->num_in_cck_no_fa); - - /* If we got too many false alarms this time, reduce sensitivity */ - if (false_alarms > max_false_alarms && - data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { - D_CALIB("norm FA %u > max FA %u\n", - false_alarms, max_false_alarms); - D_CALIB("... reducing sensitivity\n"); - data->nrg_curr_state = IL_FA_TOO_MANY; - /* Store for "fewer than desired" on later beacon */ - data->nrg_silence_ref = silence_ref; - - /* increase energy threshold (reduce nrg value) - * to decrease sensitivity */ - data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; - /* Else if we got fewer than desired, increase sensitivity */ - } else if (false_alarms < min_false_alarms) { - data->nrg_curr_state = IL_FA_TOO_FEW; - - /* Compare silence level with silence level for most recent - * healthy number or too many false alarms */ - data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - - (s32)silence_ref; - - D_CALIB( - "norm FA %u < min FA %u, silence diff %d\n", - false_alarms, min_false_alarms, - data->nrg_auto_corr_silence_diff); - - /* Increase value to increase sensitivity, but only if: - * 1a) previous beacon did *not* have *too many* false alarms - * 1b) AND there's a significant difference in Rx levels - * from a previous beacon with too many, or healthy # FAs - * OR 2) We've seen a lot of beacons (100) with too few - * false alarms */ - if (data->nrg_prev_state != IL_FA_TOO_MANY && - (data->nrg_auto_corr_silence_diff > NRG_DIFF || - data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { - - D_CALIB("... increasing sensitivity\n"); - /* Increase nrg value to increase sensitivity */ - val = data->nrg_th_cck + NRG_STEP_CCK; - data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); - } else { - D_CALIB( - "... but not changing sensitivity\n"); - } - - /* Else we got a healthy number of false alarms, keep status quo */ - } else { - D_CALIB(" FA in safe zone\n"); - data->nrg_curr_state = IL_FA_GOOD_RANGE; - - /* Store for use in "fewer than desired" with later beacon */ - data->nrg_silence_ref = silence_ref; - - /* If previous beacon had too many false alarms, - * give it some extra margin by reducing sensitivity again - * (but don't go below measured energy of desired Rx) */ - if (IL_FA_TOO_MANY == data->nrg_prev_state) { - D_CALIB("... increasing margin\n"); - if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) - data->nrg_th_cck -= NRG_MARGIN; - else - data->nrg_th_cck = max_nrg_cck; - } - } - - /* Make sure the energy threshold does not go above the measured - * energy of the desired Rx signals (reduced by backoff margin), - * or else we might start missing Rx frames. - * Lower value is higher energy, so we use max()! - */ - data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - D_CALIB("new nrg_th_cck %u\n", data->nrg_th_cck); - - data->nrg_prev_state = data->nrg_curr_state; - - /* Auto-correlation CCK algorithm */ - if (false_alarms > min_false_alarms) { - - /* increase auto_corr values to decrease sensitivity - * so the DSP won't be disturbed by the noise - */ - if (data->auto_corr_cck < AUTO_CORR_MAX_TH_CCK) - data->auto_corr_cck = AUTO_CORR_MAX_TH_CCK + 1; - else { - val = data->auto_corr_cck + AUTO_CORR_STEP_CCK; - data->auto_corr_cck = - min((u32)ranges->auto_corr_max_cck, val); - } - val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; - data->auto_corr_cck_mrc = - min((u32)ranges->auto_corr_max_cck_mrc, val); - } else if (false_alarms < min_false_alarms && - (data->nrg_auto_corr_silence_diff > NRG_DIFF || - data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { - - /* Decrease auto_corr values to increase sensitivity */ - val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; - data->auto_corr_cck = - max((u32)ranges->auto_corr_min_cck, val); - val = data->auto_corr_cck_mrc - AUTO_CORR_STEP_CCK; - data->auto_corr_cck_mrc = - max((u32)ranges->auto_corr_min_cck_mrc, val); - } - - return 0; -} - - -static int il4965_sens_auto_corr_ofdm(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time) -{ - u32 val; - u32 false_alarms = norm_fa * 200 * 1024; - u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; - u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; - struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - - data = &(il->sensitivity_data); - - /* If we got too many false alarms this time, reduce sensitivity */ - if (false_alarms > max_false_alarms) { - - D_CALIB("norm FA %u > max FA %u)\n", - false_alarms, max_false_alarms); - - val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm = - min((u32)ranges->auto_corr_max_ofdm, val); - - val = data->auto_corr_ofdm_mrc + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc = - min((u32)ranges->auto_corr_max_ofdm_mrc, val); - - val = data->auto_corr_ofdm_x1 + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_x1 = - min((u32)ranges->auto_corr_max_ofdm_x1, val); - - val = data->auto_corr_ofdm_mrc_x1 + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc_x1 = - min((u32)ranges->auto_corr_max_ofdm_mrc_x1, val); - } - - /* Else if we got fewer than desired, increase sensitivity */ - else if (false_alarms < min_false_alarms) { - - D_CALIB("norm FA %u < min FA %u\n", - false_alarms, min_false_alarms); - - val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm = - max((u32)ranges->auto_corr_min_ofdm, val); - - val = data->auto_corr_ofdm_mrc - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc = - max((u32)ranges->auto_corr_min_ofdm_mrc, val); - - val = data->auto_corr_ofdm_x1 - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_x1 = - max((u32)ranges->auto_corr_min_ofdm_x1, val); - - val = data->auto_corr_ofdm_mrc_x1 - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc_x1 = - max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); - } else { - D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", - min_false_alarms, false_alarms, max_false_alarms); - } - return 0; -} - -static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, - struct il_sensitivity_data *data, - __le16 *tbl) -{ - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm); - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_x1); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); - - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_cck); - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_cck_mrc); - - tbl[HD_MIN_ENERGY_CCK_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_cck); - tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_ofdm); - - tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = - cpu_to_le16(data->barker_corr_th_min); - tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16(data->barker_corr_th_min_mrc); - tbl[HD_OFDM_ENERGY_TH_IN_IDX] = - cpu_to_le16(data->nrg_th_cca); - - D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", - data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, - data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, - data->nrg_th_ofdm); - - D_CALIB("cck: ac %u mrc %u thresh %u\n", - data->auto_corr_cck, data->auto_corr_cck_mrc, - data->nrg_th_cck); -} - -/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ -static int il4965_sensitivity_write(struct il_priv *il) -{ - struct il_sensitivity_cmd cmd; - struct il_sensitivity_data *data = NULL; - struct il_host_cmd cmd_out = { - .id = SENSITIVITY_CMD, - .len = sizeof(struct il_sensitivity_cmd), - .flags = CMD_ASYNC, - .data = &cmd, - }; - - data = &(il->sensitivity_data); - - memset(&cmd, 0, sizeof(cmd)); - - il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); - - /* Update uCode's "work" table, and copy it to DSP */ - cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; - - /* Don't send command to uCode if nothing has changed */ - if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), - sizeof(u16)*HD_TBL_SIZE)) { - D_CALIB("No change in SENSITIVITY_CMD\n"); - return 0; - } - - /* Copy table for comparison next time */ - memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), - sizeof(u16)*HD_TBL_SIZE); - - return il_send_cmd(il, &cmd_out); -} - -void il4965_init_sensitivity(struct il_priv *il) -{ - int ret = 0; - int i; - struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - - if (il->disable_sens_cal) - return; - - D_CALIB("Start il4965_init_sensitivity\n"); - - /* Clear driver's sensitivity algo data */ - data = &(il->sensitivity_data); - - if (ranges == NULL) - return; - - memset(data, 0, sizeof(struct il_sensitivity_data)); - - data->num_in_cck_no_fa = 0; - data->nrg_curr_state = IL_FA_TOO_MANY; - data->nrg_prev_state = IL_FA_TOO_MANY; - data->nrg_silence_ref = 0; - data->nrg_silence_idx = 0; - data->nrg_energy_idx = 0; - - for (i = 0; i < 10; i++) - data->nrg_value[i] = 0; - - for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) - data->nrg_silence_rssi[i] = 0; - - data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; - data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; - data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; - data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; - data->auto_corr_cck = AUTO_CORR_CCK_MIN_VAL_DEF; - data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; - data->nrg_th_cck = ranges->nrg_th_cck; - data->nrg_th_ofdm = ranges->nrg_th_ofdm; - data->barker_corr_th_min = ranges->barker_corr_th_min; - data->barker_corr_th_min_mrc = ranges->barker_corr_th_min_mrc; - data->nrg_th_cca = ranges->nrg_th_cca; - - data->last_bad_plcp_cnt_ofdm = 0; - data->last_fa_cnt_ofdm = 0; - data->last_bad_plcp_cnt_cck = 0; - data->last_fa_cnt_cck = 0; - - ret |= il4965_sensitivity_write(il); - D_CALIB("<disable_sens_cal) - return; - - data = &(il->sensitivity_data); - - if (!il_is_any_associated(il)) { - D_CALIB("<< - not associated\n"); - return; - } - - spin_lock_irqsave(&il->lock, flags); - - rx_info = &(((struct il_notif_stats *)resp)->rx.general); - ofdm = &(((struct il_notif_stats *)resp)->rx.ofdm); - cck = &(((struct il_notif_stats *)resp)->rx.cck); - - if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - D_CALIB("<< invalid data.\n"); - spin_unlock_irqrestore(&il->lock, flags); - return; - } - - /* Extract Statistics: */ - rx_enable_time = le32_to_cpu(rx_info->channel_load); - fa_cck = le32_to_cpu(cck->false_alarm_cnt); - fa_ofdm = le32_to_cpu(ofdm->false_alarm_cnt); - bad_plcp_cck = le32_to_cpu(cck->plcp_err); - bad_plcp_ofdm = le32_to_cpu(ofdm->plcp_err); - - statis.beacon_silence_rssi_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a); - statis.beacon_silence_rssi_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b); - statis.beacon_silence_rssi_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c); - statis.beacon_energy_a = - le32_to_cpu(rx_info->beacon_energy_a); - statis.beacon_energy_b = - le32_to_cpu(rx_info->beacon_energy_b); - statis.beacon_energy_c = - le32_to_cpu(rx_info->beacon_energy_c); - - spin_unlock_irqrestore(&il->lock, flags); - - D_CALIB("rx_enable_time = %u usecs\n", rx_enable_time); - - if (!rx_enable_time) { - D_CALIB("<< RX Enable Time == 0!\n"); - return; - } - - /* These stats increase monotonically, and do not reset - * at each beacon. Calculate difference from last value, or just - * use the new stats value if it has reset or wrapped around. */ - if (data->last_bad_plcp_cnt_cck > bad_plcp_cck) - data->last_bad_plcp_cnt_cck = bad_plcp_cck; - else { - bad_plcp_cck -= data->last_bad_plcp_cnt_cck; - data->last_bad_plcp_cnt_cck += bad_plcp_cck; - } - - if (data->last_bad_plcp_cnt_ofdm > bad_plcp_ofdm) - data->last_bad_plcp_cnt_ofdm = bad_plcp_ofdm; - else { - bad_plcp_ofdm -= data->last_bad_plcp_cnt_ofdm; - data->last_bad_plcp_cnt_ofdm += bad_plcp_ofdm; - } - - if (data->last_fa_cnt_ofdm > fa_ofdm) - data->last_fa_cnt_ofdm = fa_ofdm; - else { - fa_ofdm -= data->last_fa_cnt_ofdm; - data->last_fa_cnt_ofdm += fa_ofdm; - } - - if (data->last_fa_cnt_cck > fa_cck) - data->last_fa_cnt_cck = fa_cck; - else { - fa_cck -= data->last_fa_cnt_cck; - data->last_fa_cnt_cck += fa_cck; - } - - /* Total aborted signal locks */ - norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; - norm_fa_cck = fa_cck + bad_plcp_cck; - - D_CALIB( - "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, - bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); - - il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); - il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); - - il4965_sensitivity_write(il); -} - -static inline u8 il4965_find_first_chain(u8 mask) -{ - if (mask & ANT_A) - return CHAIN_A; - if (mask & ANT_B) - return CHAIN_B; - return CHAIN_C; -} - -/** - * Run disconnected antenna algorithm to find out which antennas are - * disconnected. - */ -static void -il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, - struct il_chain_noise_data *data) -{ - u32 active_chains = 0; - u32 max_average_sig; - u16 max_average_sig_antenna_i; - u8 num_tx_chains; - u8 first_chain; - u16 i = 0; - - average_sig[0] = data->chain_signal_a / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[1] = data->chain_signal_b / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[2] = data->chain_signal_c / - il->cfg->base_params->chain_noise_num_beacons; - - if (average_sig[0] >= average_sig[1]) { - max_average_sig = average_sig[0]; - max_average_sig_antenna_i = 0; - active_chains = (1 << max_average_sig_antenna_i); - } else { - max_average_sig = average_sig[1]; - max_average_sig_antenna_i = 1; - active_chains = (1 << max_average_sig_antenna_i); - } - - if (average_sig[2] >= max_average_sig) { - max_average_sig = average_sig[2]; - max_average_sig_antenna_i = 2; - active_chains = (1 << max_average_sig_antenna_i); - } - - D_CALIB("average_sig: a %d b %d c %d\n", - average_sig[0], average_sig[1], average_sig[2]); - D_CALIB("max_average_sig = %d, antenna %d\n", - max_average_sig, max_average_sig_antenna_i); - - /* Compare signal strengths for all 3 receivers. */ - for (i = 0; i < NUM_RX_CHAINS; i++) { - if (i != max_average_sig_antenna_i) { - s32 rssi_delta = (max_average_sig - average_sig[i]); - - /* If signal is very weak, compared with - * strongest, mark it as disconnected. */ - if (rssi_delta > MAXIMUM_ALLOWED_PATHLOSS) - data->disconn_array[i] = 1; - else - active_chains |= (1 << i); - D_CALIB("i = %d rssiDelta = %d " - "disconn_array[i] = %d\n", - i, rssi_delta, data->disconn_array[i]); - } - } - - /* - * The above algorithm sometimes fails when the ucode - * reports 0 for all chains. It's not clear why that - * happens to start with, but it is then causing trouble - * because this can make us enable more chains than the - * hardware really has. - * - * To be safe, simply mask out any chains that we know - * are not on the device. - */ - active_chains &= il->hw_params.valid_rx_ant; - - num_tx_chains = 0; - for (i = 0; i < NUM_RX_CHAINS; i++) { - /* loops on all the bits of - * il->hw_setting.valid_tx_ant */ - u8 ant_msk = (1 << i); - if (!(il->hw_params.valid_tx_ant & ant_msk)) - continue; - - num_tx_chains++; - if (data->disconn_array[i] == 0) - /* there is a Tx antenna connected */ - break; - if (num_tx_chains == il->hw_params.tx_chains_num && - data->disconn_array[i]) { - /* - * If all chains are disconnected - * connect the first valid tx chain - */ - first_chain = - il4965_find_first_chain(il->cfg->valid_tx_ant); - data->disconn_array[first_chain] = 0; - active_chains |= BIT(first_chain); - D_CALIB( - "All Tx chains are disconnected W/A - declare %d as connected\n", - first_chain); - break; - } - } - - if (active_chains != il->hw_params.valid_rx_ant && - active_chains != il->chain_noise_data.active_chains) - D_CALIB( - "Detected that not all antennas are connected! " - "Connected: %#x, valid: %#x.\n", - active_chains, il->hw_params.valid_rx_ant); - - /* Save for use within RXON, TX, SCAN commands, etc. */ - data->active_chains = active_chains; - D_CALIB("active_chains (bitwise) = 0x%x\n", - active_chains); -} - -static void il4965_gain_computation(struct il_priv *il, - u32 *average_noise, - u16 min_average_noise_antenna_i, - u32 min_average_noise, - u8 default_chain) -{ - int i, ret; - struct il_chain_noise_data *data = &il->chain_noise_data; - - data->delta_gain_code[min_average_noise_antenna_i] = 0; - - for (i = default_chain; i < NUM_RX_CHAINS; i++) { - s32 delta_g = 0; - - if (!data->disconn_array[i] && - data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { - delta_g = average_noise[i] - min_average_noise; - data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); - data->delta_gain_code[i] = - min(data->delta_gain_code[i], - (u8) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); - - data->delta_gain_code[i] = - (data->delta_gain_code[i] | (1 << 2)); - } else { - data->delta_gain_code[i] = 0; - } - } - D_CALIB("delta_gain_codes: a %d b %d c %d\n", - data->delta_gain_code[0], - data->delta_gain_code[1], - data->delta_gain_code[2]); - - /* Differential gain gets sent to uCode only once */ - if (!data->radio_write) { - struct il_calib_diff_gain_cmd cmd; - data->radio_write = 1; - - memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; - cmd.diff_gain_a = data->delta_gain_code[0]; - cmd.diff_gain_b = data->delta_gain_code[1]; - cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, - sizeof(cmd), &cmd); - if (ret) - D_CALIB("fail sending cmd " - "REPLY_PHY_CALIBRATION_CMD\n"); - - /* TODO we might want recalculate - * rx_chain in rxon cmd */ - - /* Mark so we run this algo only once! */ - data->state = IL_CHAIN_NOISE_CALIBRATED; - } -} - - - -/* - * Accumulate 16 beacons of signal and noise stats for each of - * 3 receivers/antennas/rx-chains, then figure out: - * 1) Which antennas are connected. - * 2) Differential rx gain settings to balance the 3 receivers. - */ -void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) -{ - struct il_chain_noise_data *data = NULL; - - u32 chain_noise_a; - u32 chain_noise_b; - u32 chain_noise_c; - u32 chain_sig_a; - u32 chain_sig_b; - u32 chain_sig_c; - u32 average_sig[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; - u32 average_noise[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; - u32 min_average_noise = MIN_AVERAGE_NOISE_MAX_VALUE; - u16 min_average_noise_antenna_i = INITIALIZATION_VALUE; - u16 i = 0; - u16 rxon_chnum = INITIALIZATION_VALUE; - u16 stat_chnum = INITIALIZATION_VALUE; - u8 rxon_band24; - u8 stat_band24; - unsigned long flags; - struct stats_rx_non_phy *rx_info; - - struct il_rxon_context *ctx = &il->ctx; - - if (il->disable_chain_noise_cal) - return; - - data = &(il->chain_noise_data); - - /* - * Accumulate just the first "chain_noise_num_beacons" after - * the first association, then we're done forever. - */ - if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { - if (data->state == IL_CHAIN_NOISE_ALIVE) - D_CALIB("Wait for noise calib reset\n"); - return; - } - - spin_lock_irqsave(&il->lock, flags); - - rx_info = &(((struct il_notif_stats *)stat_resp)-> - rx.general); - - if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - D_CALIB(" << Interference data unavailable\n"); - spin_unlock_irqrestore(&il->lock, flags); - return; - } - - rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); - rxon_chnum = le16_to_cpu(ctx->staging.channel); - - stat_band24 = !!(((struct il_notif_stats *) - stat_resp)->flag & - STATISTICS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct il_notif_stats *) - stat_resp)->flag) >> 16; - - /* Make sure we accumulate data for just the associated channel - * (even if scanning). */ - if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { - D_CALIB("Stats not from chan=%d, band24=%d\n", - rxon_chnum, rxon_band24); - spin_unlock_irqrestore(&il->lock, flags); - return; - } - - /* - * Accumulate beacon stats values across - * "chain_noise_num_beacons" - */ - chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & - IN_BAND_FILTER; - chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & - IN_BAND_FILTER; - chain_noise_c = le32_to_cpu(rx_info->beacon_silence_rssi_c) & - IN_BAND_FILTER; - - chain_sig_a = le32_to_cpu(rx_info->beacon_rssi_a) & IN_BAND_FILTER; - chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; - chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; - - spin_unlock_irqrestore(&il->lock, flags); - - data->beacon_count++; - - data->chain_noise_a = (chain_noise_a + data->chain_noise_a); - data->chain_noise_b = (chain_noise_b + data->chain_noise_b); - data->chain_noise_c = (chain_noise_c + data->chain_noise_c); - - data->chain_signal_a = (chain_sig_a + data->chain_signal_a); - data->chain_signal_b = (chain_sig_b + data->chain_signal_b); - data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - - D_CALIB("chan=%d, band24=%d, beacon=%d\n", - rxon_chnum, rxon_band24, data->beacon_count); - D_CALIB("chain_sig: a %d b %d c %d\n", - chain_sig_a, chain_sig_b, chain_sig_c); - D_CALIB("chain_noise: a %d b %d c %d\n", - chain_noise_a, chain_noise_b, chain_noise_c); - - /* If this is the "chain_noise_num_beacons", determine: - * 1) Disconnected antennas (using signal strengths) - * 2) Differential gain (using silence noise) to balance receivers */ - if (data->beacon_count != - il->cfg->base_params->chain_noise_num_beacons) - return; - - /* Analyze signal for disconnected antenna */ - il4965_find_disconn_antenna(il, average_sig, data); - - /* Analyze noise for rx balance */ - average_noise[0] = data->chain_noise_a / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[1] = data->chain_noise_b / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[2] = data->chain_noise_c / - il->cfg->base_params->chain_noise_num_beacons; - - for (i = 0; i < NUM_RX_CHAINS; i++) { - if (!data->disconn_array[i] && - average_noise[i] <= min_average_noise) { - /* This means that chain i is active and has - * lower noise values so far: */ - min_average_noise = average_noise[i]; - min_average_noise_antenna_i = i; - } - } - - D_CALIB("average_noise: a %d b %d c %d\n", - average_noise[0], average_noise[1], - average_noise[2]); - - D_CALIB("min_average_noise = %d, antenna %d\n", - min_average_noise, min_average_noise_antenna_i); - - il4965_gain_computation(il, average_noise, - min_average_noise_antenna_i, min_average_noise, - il4965_find_first_chain(il->cfg->valid_rx_ant)); - - /* Some power changes may have been made during the calibration. - * Update and commit the RXON - */ - if (il->cfg->ops->lib->update_chain_flags) - il->cfg->ops->lib->update_chain_flags(il); - - data->state = IL_CHAIN_NOISE_DONE; - il_power_update_mode(il, false); -} - -void il4965_reset_run_time_calib(struct il_priv *il) -{ - int i; - memset(&(il->sensitivity_data), 0, - sizeof(struct il_sensitivity_data)); - memset(&(il->chain_noise_data), 0, - sizeof(struct il_chain_noise_data)); - for (i = 0; i < NUM_RX_CHAINS; i++) - il->chain_noise_data.delta_gain_code[i] = - CHAIN_NOISE_DELTA_GAIN_INIT_VAL; - - /* Ask for stats now, the uCode will send notification - * periodically after association */ - il_send_stats_request(il, CMD_ASYNC, true); -} diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c deleted file mode 100644 index 89e5828..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ /dev/null @@ -1,774 +0,0 @@ -/****************************************************************************** -* -* GPL LICENSE SUMMARY -* -* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, -* USA -* -* The full GNU General Public License is included in this distribution -* in the file called LICENSE.GPL. -* -* Contact Information: -* Intel Linux Wireless -* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 -*****************************************************************************/ -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" - -static const char *fmt_value = " %-30s %10u\n"; -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; -static const char *fmt_header = - "%-32s current cumulative delta max\n"; - -static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) -{ - int p = 0; - u32 flag; - - flag = le32_to_cpu(il->_4965.stats.flag); - - p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); - if (flag & UCODE_STATISTICS_CLEAR_MSK) - p += scnprintf(buf + p, bufsz - p, - "\tStatistics have been cleared\n"); - p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (flag & UCODE_STATISTICS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); - p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (flag & UCODE_STATISTICS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); - - return p; -} - -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct stats_rx_phy) * 40 + - sizeof(struct stats_rx_non_phy) * 40 + - sizeof(struct stats_rx_ht_phy) * 40 + 400; - ssize_t ret; - struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; - struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct stats_rx_non_phy *general, *accum_general; - struct stats_rx_non_phy *delta_general, *max_general; - struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - ofdm = &il->_4965.stats.rx.ofdm; - cck = &il->_4965.stats.rx.cck; - general = &il->_4965.stats.rx.general; - ht = &il->_4965.stats.rx.ofdm_ht; - accum_ofdm = &il->_4965.accum_stats.rx.ofdm; - accum_cck = &il->_4965.accum_stats.rx.cck; - accum_general = &il->_4965.accum_stats.rx.general; - accum_ht = &il->_4965.accum_stats.rx.ofdm_ht; - delta_ofdm = &il->_4965.delta_stats.rx.ofdm; - delta_cck = &il->_4965.delta_stats.rx.cck; - delta_general = &il->_4965.delta_stats.rx.general; - delta_ht = &il->_4965.delta_stats.rx.ofdm_ht; - max_ofdm = &il->_4965.max_delta.rx.ofdm; - max_cck = &il->_4965.max_delta.rx.cck; - max_general = &il->_4965.max_delta.rx.general; - max_ht = &il->_4965.max_delta.rx.ofdm_ht; - - pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, - max_ofdm->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(ofdm->sent_ba_rsp_cnt), - accum_ofdm->sent_ba_rsp_cnt, - delta_ofdm->sent_ba_rsp_cnt, - max_ofdm->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(ofdm->dsp_self_kill), - accum_ofdm->dsp_self_kill, - delta_ofdm->dsp_self_kill, - max_ofdm->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ofdm->mh_format_err), - accum_ofdm->mh_format_err, - delta_ofdm->mh_format_err, - max_ofdm->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(ofdm->re_acq_main_rssi_sum), - accum_ofdm->re_acq_main_rssi_sum, - delta_ofdm->re_acq_main_rssi_sum, - max_ofdm->re_acq_main_rssi_sum); - - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, delta_cck->overrun_err, - max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, delta_cck->sfd_timeout, - max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, delta_cck->fina_timeout, - max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(cck->sent_ba_rsp_cnt), - accum_cck->sent_ba_rsp_cnt, - delta_cck->sent_ba_rsp_cnt, - max_cck->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(cck->dsp_self_kill), - accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, - max_cck->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(cck->mh_format_err), - accum_cck->mh_format_err, delta_cck->mh_format_err, - max_cck->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(cck->re_acq_main_rssi_sum), - accum_cck->re_acq_main_rssi_sum, - delta_cck->re_acq_main_rssi_sum, - max_cck->re_acq_main_rssi_sum); - - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, delta_general->bogus_cts, - max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, delta_general->bogus_ack, - max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_beacons:", - le32_to_cpu(general->channel_beacons), - accum_general->channel_beacons, - delta_general->channel_beacons, - max_general->channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_missed_bcon:", - le32_to_cpu(general->num_missed_bcon), - accum_general->num_missed_bcon, - delta_general->num_missed_bcon, - max_general->num_missed_bcon); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "adc_rx_saturation_time:", - le32_to_cpu(general->adc_rx_saturation_time), - accum_general->adc_rx_saturation_time, - delta_general->adc_rx_saturation_time, - max_general->adc_rx_saturation_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_detect_search_tm:", - le32_to_cpu(general->ina_detection_search_time), - accum_general->ina_detection_search_time, - delta_general->ina_detection_search_time, - max_general->ina_detection_search_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_a:", - le32_to_cpu(general->beacon_silence_rssi_a), - accum_general->beacon_silence_rssi_a, - delta_general->beacon_silence_rssi_a, - max_general->beacon_silence_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_b:", - le32_to_cpu(general->beacon_silence_rssi_b), - accum_general->beacon_silence_rssi_b, - delta_general->beacon_silence_rssi_b, - max_general->beacon_silence_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_c:", - le32_to_cpu(general->beacon_silence_rssi_c), - accum_general->beacon_silence_rssi_c, - delta_general->beacon_silence_rssi_c, - max_general->beacon_silence_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "interference_data_flag:", - le32_to_cpu(general->interference_data_flag), - accum_general->interference_data_flag, - delta_general->interference_data_flag, - max_general->interference_data_flag); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_load:", - le32_to_cpu(general->channel_load), - accum_general->channel_load, - delta_general->channel_load, - max_general->channel_load); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_false_alarms:", - le32_to_cpu(general->dsp_false_alarms), - accum_general->dsp_false_alarms, - delta_general->dsp_false_alarms, - max_general->dsp_false_alarms); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_a:", - le32_to_cpu(general->beacon_rssi_a), - accum_general->beacon_rssi_a, - delta_general->beacon_rssi_a, - max_general->beacon_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_b:", - le32_to_cpu(general->beacon_rssi_b), - accum_general->beacon_rssi_b, - delta_general->beacon_rssi_b, - max_general->beacon_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_c:", - le32_to_cpu(general->beacon_rssi_c), - accum_general->beacon_rssi_c, - delta_general->beacon_rssi_c, - max_general->beacon_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_a:", - le32_to_cpu(general->beacon_energy_a), - accum_general->beacon_energy_a, - delta_general->beacon_energy_a, - max_general->beacon_energy_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_b:", - le32_to_cpu(general->beacon_energy_b), - accum_general->beacon_energy_b, - delta_general->beacon_energy_b, - max_general->beacon_energy_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_c:", - le32_to_cpu(general->beacon_energy_c), - accum_general->beacon_energy_c, - delta_general->beacon_energy_c, - max_general->beacon_energy_c); - - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM_HT:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, - delta_ht->plcp_err, max_ht->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, - delta_ht->overrun_err, max_ht->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ht->early_overrun_err), - accum_ht->early_overrun_err, - delta_ht->early_overrun_err, - max_ht->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, - delta_ht->crc32_good, max_ht->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, - delta_ht->crc32_err, max_ht->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ht->mh_format_err), - accum_ht->mh_format_err, - delta_ht->mh_format_err, max_ht->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_crc32_good:", - le32_to_cpu(ht->agg_crc32_good), - accum_ht->agg_crc32_good, - delta_ht->agg_crc32_good, max_ht->agg_crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_mpdu_cnt:", - le32_to_cpu(ht->agg_mpdu_cnt), - accum_ht->agg_mpdu_cnt, - delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_cnt:", - le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, - delta_ht->agg_cnt, max_ht->agg_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unsupport_mcs:", - le32_to_cpu(ht->unsupport_mcs), - accum_ht->unsupport_mcs, - delta_ht->unsupport_mcs, max_ht->unsupport_mcs); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t il4965_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = (sizeof(struct stats_tx) * 48) + 250; - ssize_t ret; - struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - tx = &il->_4965.stats.tx; - accum_tx = &il->_4965.accum_stats.tx; - delta_tx = &il->_4965.delta_stats.tx; - max_tx = &il->_4965.max_delta.tx; - - pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dump_msdu_cnt:", - le32_to_cpu(tx->dump_msdu_cnt), - accum_tx->dump_msdu_cnt, - delta_tx->dump_msdu_cnt, - max_tx->dump_msdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_nxt_frame_mismatch:", - le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), - accum_tx->burst_abort_next_frame_mismatch_cnt, - delta_tx->burst_abort_next_frame_mismatch_cnt, - max_tx->burst_abort_next_frame_mismatch_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_missing_nxt_frame:", - le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), - accum_tx->burst_abort_missing_next_frame_cnt, - delta_tx->burst_abort_missing_next_frame_cnt, - max_tx->burst_abort_missing_next_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout_collision:", - le32_to_cpu(tx->cts_timeout_collision), - accum_tx->cts_timeout_collision, - delta_tx->cts_timeout_collision, - max_tx->cts_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_ba_timeout_collision:", - le32_to_cpu(tx->ack_or_ba_timeout_collision), - accum_tx->ack_or_ba_timeout_collision, - delta_tx->ack_or_ba_timeout_collision, - max_tx->ack_or_ba_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_timeout:", - le32_to_cpu(tx->agg.ba_timeout), - accum_tx->agg.ba_timeout, - delta_tx->agg.ba_timeout, - max_tx->agg.ba_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_resched_frames:", - le32_to_cpu(tx->agg.ba_reschedule_frames), - accum_tx->agg.ba_reschedule_frames, - delta_tx->agg.ba_reschedule_frames, - max_tx->agg.ba_reschedule_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg_frame:", - le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), - accum_tx->agg.scd_query_agg_frame_cnt, - delta_tx->agg.scd_query_agg_frame_cnt, - max_tx->agg.scd_query_agg_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_no_agg:", - le32_to_cpu(tx->agg.scd_query_no_agg), - accum_tx->agg.scd_query_no_agg, - delta_tx->agg.scd_query_no_agg, - max_tx->agg.scd_query_no_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg:", - le32_to_cpu(tx->agg.scd_query_agg), - accum_tx->agg.scd_query_agg, - delta_tx->agg.scd_query_agg, - max_tx->agg.scd_query_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_mismatch:", - le32_to_cpu(tx->agg.scd_query_mismatch), - accum_tx->agg.scd_query_mismatch, - delta_tx->agg.scd_query_mismatch, - max_tx->agg.scd_query_mismatch); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg frame_not_ready:", - le32_to_cpu(tx->agg.frame_not_ready), - accum_tx->agg.frame_not_ready, - delta_tx->agg.frame_not_ready, - max_tx->agg.frame_not_ready); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg underrun:", - le32_to_cpu(tx->agg.underrun), - accum_tx->agg.underrun, - delta_tx->agg.underrun, max_tx->agg.underrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg bt_prio_kill:", - le32_to_cpu(tx->agg.bt_prio_kill), - accum_tx->agg.bt_prio_kill, - delta_tx->agg.bt_prio_kill, - max_tx->agg.bt_prio_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg rx_ba_rsp_cnt:", - le32_to_cpu(tx->agg.rx_ba_rsp_cnt), - accum_tx->agg.rx_ba_rsp_cnt, - delta_tx->agg.rx_ba_rsp_cnt, - max_tx->agg.rx_ba_rsp_cnt); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct stats_general) * 10 + 300; - ssize_t ret; - struct stats_general_common *general, *accum_general; - struct stats_general_common *delta_general, *max_general; - struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct stats_div *div, *accum_div, *delta_div, *max_div; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - general = &il->_4965.stats.general.common; - dbg = &il->_4965.stats.general.common.dbg; - div = &il->_4965.stats.general.common.div; - accum_general = &il->_4965.accum_stats.general.common; - accum_dbg = &il->_4965.accum_stats.general.common.dbg; - accum_div = &il->_4965.accum_stats.general.common.div; - delta_general = &il->_4965.delta_stats.general.common; - max_general = &il->_4965.max_delta.general.common; - delta_dbg = &il->_4965.delta_stats.general.common.dbg; - max_dbg = &il->_4965.max_delta.general.common.dbg; - delta_div = &il->_4965.delta_stats.general.common.div; - max_div = &il->_4965.max_delta.general.common.div; - - pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "temperature:", - le32_to_cpu(general->temperature)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "ttl_timestamp:", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "wait_for_silence_timeout_count:", - le32_to_cpu(dbg->wait_for_silence_timeout_cnt), - accum_dbg->wait_for_silence_timeout_cnt, - delta_dbg->wait_for_silence_timeout_cnt, - max_dbg->wait_for_silence_timeout_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_enable_counter:", - le32_to_cpu(general->rx_enable_counter), - accum_general->rx_enable_counter, - delta_general->rx_enable_counter, - max_general->rx_enable_counter); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_of_sos_states:", - le32_to_cpu(general->num_of_sos_states), - accum_general->num_of_sos_states, - delta_general->num_of_sos_states, - max_general->num_of_sos_states); - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c deleted file mode 100644 index 4a54311..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ /dev/null @@ -1,2862 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "iwl-dev.h" -#include "iwl-sta.h" -#include "iwl-core.h" -#include "iwl-4965.h" - -#define IL4965_RS_NAME "iwl-4965-rs" - -#define NUM_TRY_BEFORE_ANT_TOGGLE 1 -#define IL_NUMBER_TRY 1 -#define IL_HT_NUMBER_TRY 3 - -#define RATE_MAX_WINDOW 62 /* # tx in history win */ -#define RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ -#define RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ - -/* max allowed rate miss before sync LQ cmd */ -#define IL_MISSED_RATE_MAX 15 -/* max time to accum history 2 seconds */ -#define RATE_SCALE_FLUSH_INTVL (3*HZ) - -static u8 rs_ht_to_legacy[] = { - RATE_6M_IDX, RATE_6M_IDX, - RATE_6M_IDX, RATE_6M_IDX, - RATE_6M_IDX, - RATE_6M_IDX, RATE_9M_IDX, - RATE_12M_IDX, RATE_18M_IDX, - RATE_24M_IDX, RATE_36M_IDX, - RATE_48M_IDX, RATE_54M_IDX -}; - -static const u8 ant_toggle_lookup[] = { - /*ANT_NONE -> */ ANT_NONE, - /*ANT_A -> */ ANT_B, - /*ANT_B -> */ ANT_C, - /*ANT_AB -> */ ANT_BC, - /*ANT_C -> */ ANT_A, - /*ANT_AC -> */ ANT_AB, - /*ANT_BC -> */ ANT_AC, - /*ANT_ABC -> */ ANT_ABC, -}; - -#define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ - RATE_SISO_##s##M_PLCP, \ - RATE_MIMO2_##s##M_PLCP,\ - RATE_##r##M_IEEE, \ - RATE_##ip##M_IDX, \ - RATE_##in##M_IDX, \ - RATE_##rp##M_IDX, \ - RATE_##rn##M_IDX, \ - RATE_##pp##M_IDX, \ - RATE_##np##M_IDX } - -/* - * Parameter order: - * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate - * - * If there isn't a valid next or previous rate then INV is used which - * maps to RATE_INVALID - * - */ -const struct il_rate_info il_rates[RATE_COUNT] = { - IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ - IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ -}; - -static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) -{ - int idx = 0; - - /* HT rate format */ - if (rate_n_flags & RATE_MCS_HT_MSK) { - idx = (rate_n_flags & 0xff); - - if (idx >= RATE_MIMO2_6M_PLCP) - idx = idx - RATE_MIMO2_6M_PLCP; - - idx += IL_FIRST_OFDM_RATE; - /* skip 9M not supported in ht*/ - if (idx >= RATE_9M_IDX) - idx += 1; - if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) - return idx; - - /* legacy rate format, search for match in table */ - } else { - for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) - if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) - return idx; - } - - return -1; -} - -static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta); -static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 rate_n_flags); -static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, - bool force_search); - -#ifdef CONFIG_MAC80211_DEBUGFS -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx); -#else -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) -{} -#endif - -/** - * The following tables contain the expected throughput metrics for all rates - * - * 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits - * - * where invalid entries are zeros. - * - * CCK rates are only valid in legacy table and will only be used in G - * (2.4 GHz) band. - */ - -static s32 expected_tpt_legacy[RATE_COUNT] = { - 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 -}; - -static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ - {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ - {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ - {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ -}; - -static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ - {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ - {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ - {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ -}; - -static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ - {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ - {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ - {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ -}; - -static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ - {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ - {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ - {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ -}; - -/* mbps, mcs */ -static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { - { "1", "BPSK DSSS"}, - { "2", "QPSK DSSS"}, - {"5.5", "BPSK CCK"}, - { "11", "QPSK CCK"}, - { "6", "BPSK 1/2"}, - { "9", "BPSK 1/2"}, - { "12", "QPSK 1/2"}, - { "18", "QPSK 3/4"}, - { "24", "16QAM 1/2"}, - { "36", "16QAM 3/4"}, - { "48", "64QAM 2/3"}, - { "54", "64QAM 3/4"}, - { "60", "64QAM 5/6"}, -}; - -#define MCS_IDX_PER_STREAM (8) - -static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) -{ - return (u8)(rate_n_flags & 0xFF); -} - -static void -il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) -{ - win->data = 0; - win->success_counter = 0; - win->success_ratio = IL_INVALID_VALUE; - win->counter = 0; - win->average_tpt = IL_INVALID_VALUE; - win->stamp = 0; -} - -static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) -{ - return (ant_type & valid_antenna) == ant_type; -} - -/* - * removes the old data from the stats. All data that is older than - * TID_MAX_TIME_DIFF, will be deleted. - */ -static void -il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) -{ - /* The oldest age we want to keep */ - u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; - - while (tl->queue_count && tl->time_stamp < oldest_time) { - tl->total -= tl->packet_count[tl->head]; - tl->packet_count[tl->head] = 0; - tl->time_stamp += TID_QUEUE_CELL_SPACING; - tl->queue_count--; - tl->head++; - if (tl->head >= TID_QUEUE_MAX_SIZE) - tl->head = 0; - } -} - -/* - * increment traffic load value for tid and also remove - * any old values if passed the certain time period - */ -static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, - struct ieee80211_hdr *hdr) -{ - u32 curr_time = jiffies_to_msecs(jiffies); - u32 time_diff; - s32 idx; - struct il_traffic_load *tl = NULL; - u8 tid; - - if (ieee80211_is_data_qos(hdr->frame_control)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & 0xf; - } else - return MAX_TID_COUNT; - - if (unlikely(tid >= TID_MAX_LOAD_COUNT)) - return MAX_TID_COUNT; - - tl = &lq_data->load[tid]; - - curr_time -= curr_time % TID_ROUND_VALUE; - - /* Happens only for the first packet. Initialize the data */ - if (!(tl->queue_count)) { - tl->total = 1; - tl->time_stamp = curr_time; - tl->queue_count = 1; - tl->head = 0; - tl->packet_count[0] = 1; - return MAX_TID_COUNT; - } - - time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - idx = time_diff / TID_QUEUE_CELL_SPACING; - - /* The history is too long: remove data that is older than */ - /* TID_MAX_TIME_DIFF */ - if (idx >= TID_QUEUE_MAX_SIZE) - il4965_rs_tl_rm_old_stats(tl, curr_time); - - idx = (tl->head + idx) % TID_QUEUE_MAX_SIZE; - tl->packet_count[idx] = tl->packet_count[idx] + 1; - tl->total = tl->total + 1; - - if ((idx + 1) > tl->queue_count) - tl->queue_count = idx + 1; - - return tid; -} - -/* - get the traffic load value for tid -*/ -static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) -{ - u32 curr_time = jiffies_to_msecs(jiffies); - u32 time_diff; - s32 idx; - struct il_traffic_load *tl = NULL; - - if (tid >= TID_MAX_LOAD_COUNT) - return 0; - - tl = &(lq_data->load[tid]); - - curr_time -= curr_time % TID_ROUND_VALUE; - - if (!(tl->queue_count)) - return 0; - - time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - idx = time_diff / TID_QUEUE_CELL_SPACING; - - /* The history is too long: remove data that is older than */ - /* TID_MAX_TIME_DIFF */ - if (idx >= TID_QUEUE_MAX_SIZE) - il4965_rs_tl_rm_old_stats(tl, curr_time); - - return tl->total; -} - -static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, - struct il_lq_sta *lq_data, u8 tid, - struct ieee80211_sta *sta) -{ - int ret = -EAGAIN; - u32 load; - - load = il4965_rs_tl_get_load(lq_data, tid); - - if (load > IL_AGG_LOAD_THRESHOLD) { - D_HT("Starting Tx agg: STA: %pM tid: %d\n", - sta->addr, tid); - ret = ieee80211_start_tx_ba_session(sta, tid, 5000); - if (ret == -EAGAIN) { - /* - * driver and mac80211 is out of sync - * this might be cause by reloading firmware - * stop the tx ba session here - */ - IL_ERR("Fail start Tx agg on tid: %d\n", - tid); - ieee80211_stop_tx_ba_session(sta, tid); - } - } else { - IL_ERR("Aggregation not enabled for tid %d " - "because load = %u\n", tid, load); - } - return ret; -} - -static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, - struct il_lq_sta *lq_data, - struct ieee80211_sta *sta) -{ - if (tid < TID_MAX_LOAD_COUNT) - il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); - else - IL_ERR("tid exceeds max load count: %d/%d\n", - tid, TID_MAX_LOAD_COUNT); -} - -static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) -{ - return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_C_MSK); -} - -/* - * Static function to get the expected throughput from an il_scale_tbl_info - * that wraps a NULL pointer check - */ -static s32 -il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) -{ - if (tbl->expected_tpt) - return tbl->expected_tpt[rs_idx]; - return 0; -} - -/** - * il4965_rs_collect_tx_data - Update the success/failure sliding win - * - * We keep a sliding win of the last 62 packets transmitted - * at this rate. win->data contains the bitmask of successful - * packets. - */ -static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, - int scale_idx, int attempts, int successes) -{ - struct il_rate_scale_data *win = NULL; - static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); - s32 fail_count, tpt; - - if (scale_idx < 0 || scale_idx >= RATE_COUNT) - return -EINVAL; - - /* Select win for current tx bit rate */ - win = &(tbl->win[scale_idx]); - - /* Get expected throughput */ - tpt = il4965_get_expected_tpt(tbl, scale_idx); - - /* - * Keep track of only the latest 62 tx frame attempts in this rate's - * history win; anything older isn't really relevant any more. - * If we have filled up the sliding win, drop the oldest attempt; - * if the oldest attempt (highest bit in bitmap) shows "success", - * subtract "1" from the success counter (this is the main reason - * we keep these bitmaps!). - */ - while (attempts > 0) { - if (win->counter >= RATE_MAX_WINDOW) { - - /* remove earliest */ - win->counter = RATE_MAX_WINDOW - 1; - - if (win->data & mask) { - win->data &= ~mask; - win->success_counter--; - } - } - - /* Increment frames-attempted counter */ - win->counter++; - - /* Shift bitmap by one frame to throw away oldest history */ - win->data <<= 1; - - /* Mark the most recent #successes attempts as successful */ - if (successes > 0) { - win->success_counter++; - win->data |= 0x1; - successes--; - } - - attempts--; - } - - /* Calculate current success ratio, avoid divide-by-0! */ - if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; - else - win->success_ratio = IL_INVALID_VALUE; - - fail_count = win->counter - win->success_counter; - - /* Calculate average throughput, if we have enough history. */ - if (fail_count >= RATE_MIN_FAILURE_TH || - win->success_counter >= RATE_MIN_SUCCESS_TH) - win->average_tpt = (win->success_ratio * tpt + 64) / 128; - else - win->average_tpt = IL_INVALID_VALUE; - - /* Tag this win as having been updated */ - win->stamp = jiffies; - - return 0; -} - -/* - * Fill uCode API rate_n_flags field, based on "search" or "active" table. - */ -static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, - struct il_scale_tbl_info *tbl, - int idx, u8 use_green) -{ - u32 rate_n_flags = 0; - - if (is_legacy(tbl->lq_type)) { - rate_n_flags = il_rates[idx].plcp; - if (idx >= IL_FIRST_CCK_RATE && idx <= IL_LAST_CCK_RATE) - rate_n_flags |= RATE_MCS_CCK_MSK; - - } else if (is_Ht(tbl->lq_type)) { - if (idx > IL_LAST_OFDM_RATE) { - IL_ERR("Invalid HT rate idx %d\n", idx); - idx = IL_LAST_OFDM_RATE; - } - rate_n_flags = RATE_MCS_HT_MSK; - - if (is_siso(tbl->lq_type)) - rate_n_flags |= il_rates[idx].plcp_siso; - else - rate_n_flags |= il_rates[idx].plcp_mimo2; - } else { - IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); - } - - rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & - RATE_MCS_ANT_ABC_MSK); - - if (is_Ht(tbl->lq_type)) { - if (tbl->is_ht40) { - if (tbl->is_dup) - rate_n_flags |= RATE_MCS_DUP_MSK; - else - rate_n_flags |= RATE_MCS_HT40_MSK; - } - if (tbl->is_SGI) - rate_n_flags |= RATE_MCS_SGI_MSK; - - if (use_green) { - rate_n_flags |= RATE_MCS_GF_MSK; - if (is_siso(tbl->lq_type) && tbl->is_SGI) { - rate_n_flags &= ~RATE_MCS_SGI_MSK; - IL_ERR("GF was set with SGI:SISO\n"); - } - } - } - return rate_n_flags; -} - -/* - * Interpret uCode API's rate_n_flags format, - * fill "search" or "active" tx mode table. - */ -static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, - enum ieee80211_band band, - struct il_scale_tbl_info *tbl, - int *rate_idx) -{ - u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); - u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); - u8 mcs; - - memset(tbl, 0, sizeof(struct il_scale_tbl_info)); - *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - - if (*rate_idx == RATE_INVALID) { - *rate_idx = -1; - return -EINVAL; - } - tbl->is_SGI = 0; /* default legacy setup */ - tbl->is_ht40 = 0; - tbl->is_dup = 0; - tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); - tbl->lq_type = LQ_NONE; - tbl->max_search = IL_MAX_SEARCH; - - /* legacy rate format */ - if (!(rate_n_flags & RATE_MCS_HT_MSK)) { - if (il4965_num_of_ant == 1) { - if (band == IEEE80211_BAND_5GHZ) - tbl->lq_type = LQ_A; - else - tbl->lq_type = LQ_G; - } - /* HT rate format */ - } else { - if (rate_n_flags & RATE_MCS_SGI_MSK) - tbl->is_SGI = 1; - - if ((rate_n_flags & RATE_MCS_HT40_MSK) || - (rate_n_flags & RATE_MCS_DUP_MSK)) - tbl->is_ht40 = 1; - - if (rate_n_flags & RATE_MCS_DUP_MSK) - tbl->is_dup = 1; - - mcs = il4965_rs_extract_rate(rate_n_flags); - - /* SISO */ - if (mcs <= RATE_SISO_60M_PLCP) { - if (il4965_num_of_ant == 1) - tbl->lq_type = LQ_SISO; /*else NONE*/ - /* MIMO2 */ - } else { - if (il4965_num_of_ant == 2) - tbl->lq_type = LQ_MIMO2; - } - } - return 0; -} - -/* switch to another antenna/antennas and return 1 */ -/* if no other valid antenna found, return 0 */ -static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, - struct il_scale_tbl_info *tbl) -{ - u8 new_ant_type; - - if (!tbl->ant_type || tbl->ant_type > ANT_ABC) - return 0; - - if (!il4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) - return 0; - - new_ant_type = ant_toggle_lookup[tbl->ant_type]; - - while (new_ant_type != tbl->ant_type && - !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) - new_ant_type = ant_toggle_lookup[new_ant_type]; - - if (new_ant_type == tbl->ant_type) - return 0; - - tbl->ant_type = new_ant_type; - *rate_n_flags &= ~RATE_MCS_ANT_ABC_MSK; - *rate_n_flags |= new_ant_type << RATE_MCS_ANT_POS; - return 1; -} - -/** - * Green-field mode is valid if the station supports it and - * there are no non-GF stations present in the BSS. - */ -static bool il4965_rs_use_green(struct ieee80211_sta *sta) -{ - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && - !(ctx->ht.non_gf_sta_present); -} - -/** - * il4965_rs_get_supported_rates - get the available rates - * - * if management frame or broadcast frame only return - * basic available rates. - * - */ -static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, - struct ieee80211_hdr *hdr, - enum il_table_type rate_type) -{ - if (is_legacy(rate_type)) { - return lq_sta->active_legacy_rate; - } else { - if (is_siso(rate_type)) - return lq_sta->active_siso_rate; - else - return lq_sta->active_mimo2_rate; - } -} - -static u16 -il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, - int rate_type) -{ - u8 high = RATE_INVALID; - u8 low = RATE_INVALID; - - /* 802.11A or ht walks to the next literal adjacent rate in - * the rate table */ - if (is_a_band(rate_type) || !is_legacy(rate_type)) { - int i; - u32 mask; - - /* Find the previous rate that is in the rate mask */ - i = idx - 1; - for (mask = (1 << i); i >= 0; i--, mask >>= 1) { - if (rate_mask & mask) { - low = i; - break; - } - } - - /* Find the next rate that is in the rate mask */ - i = idx + 1; - for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { - if (rate_mask & mask) { - high = i; - break; - } - } - - return (high << 8) | low; - } - - low = idx; - while (low != RATE_INVALID) { - low = il_rates[low].prev_rs; - if (low == RATE_INVALID) - break; - if (rate_mask & (1 << low)) - break; - D_RATE("Skipping masked lower rate: %d\n", low); - } - - high = idx; - while (high != RATE_INVALID) { - high = il_rates[high].next_rs; - if (high == RATE_INVALID) - break; - if (rate_mask & (1 << high)) - break; - D_RATE("Skipping masked higher rate: %d\n", high); - } - - return (high << 8) | low; -} - -static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - u8 scale_idx, u8 ht_possible) -{ - s32 low; - u16 rate_mask; - u16 high_low; - u8 switch_to_legacy = 0; - u8 is_green = lq_sta->is_green; - struct il_priv *il = lq_sta->drv; - - /* check if we need to switch from HT to legacy rates. - * assumption is that mandatory rates (1Mbps or 6Mbps) - * are always supported (spec demand) */ - if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_idx)) { - switch_to_legacy = 1; - scale_idx = rs_ht_to_legacy[scale_idx]; - if (lq_sta->band == IEEE80211_BAND_5GHZ) - tbl->lq_type = LQ_A; - else - tbl->lq_type = LQ_G; - - if (il4965_num_of_ant(tbl->ant_type) > 1) - tbl->ant_type = - il4965_first_antenna(il->hw_params.valid_tx_ant); - - tbl->is_ht40 = 0; - tbl->is_SGI = 0; - tbl->max_search = IL_MAX_SEARCH; - } - - rate_mask = il4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); - - /* Mask with station rate restriction */ - if (is_legacy(tbl->lq_type)) { - /* supp_rates has no CCK bits in A mode */ - if (lq_sta->band == IEEE80211_BAND_5GHZ) - rate_mask = (u16)(rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); - else - rate_mask = (u16)(rate_mask & lq_sta->supp_rates); - } - - /* If we switched from HT to legacy, check current rate */ - if (switch_to_legacy && (rate_mask & (1 << scale_idx))) { - low = scale_idx; - goto out; - } - - high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, - scale_idx, rate_mask, - tbl->lq_type); - low = high_low & 0xff; - - if (low == RATE_INVALID) - low = scale_idx; - -out: - return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); -} - -/* - * Simple function to compare two rate scale table types - */ -static bool il4965_table_type_matches(struct il_scale_tbl_info *a, - struct il_scale_tbl_info *b) -{ - return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && - a->is_SGI == b->is_SGI); -} - -/* - * mac80211 sends us Tx status - */ -static void -il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) -{ - int legacy_success; - int retries; - int rs_idx, mac_idx, i; - struct il_lq_sta *lq_sta = il_sta; - struct il_link_quality_cmd *table; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct il_priv *il = (struct il_priv *)il_r; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - enum mac80211_rate_control_flags mac_flags; - u32 tx_rate; - struct il_scale_tbl_info tbl_type; - struct il_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - D_RATE( - "get frame ack response, update rate scale win\n"); - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (!lq_sta) { - D_RATE("Station rate scaling not created yet.\n"); - return; - } else if (!lq_sta->drv) { - D_RATE("Rate scaling not initialized yet.\n"); - return; - } - - if (!ieee80211_is_data(hdr->frame_control) || - (info->flags & IEEE80211_TX_CTL_NO_ACK)) - return; - - /* This packet was aggregated but doesn't carry status info */ - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && - !(info->flags & IEEE80211_TX_STAT_AMPDU)) - return; - - /* - * Ignore this Tx frame response if its initial rate doesn't match - * that of latest Link Quality command. There may be stragglers - * from a previous Link Quality command, but we're no longer interested - * in those; they're either from the "active" mode while we're trying - * to check "search" mode, or a prior "search" mode after we've moved - * to a new "search" mode (which might become the new "active" mode). - */ - table = &lq_sta->lq; - tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, - il->band, &tbl_type, &rs_idx); - if (il->band == IEEE80211_BAND_5GHZ) - rs_idx -= IL_FIRST_OFDM_RATE; - mac_flags = info->status.rates[0].flags; - mac_idx = info->status.rates[0].idx; - /* For HT packets, map MCS to PLCP */ - if (mac_flags & IEEE80211_TX_RC_MCS) { - mac_idx &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_idx >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) - mac_idx++; - /* - * mac80211 HT idx is always zero-idxed; we need to move - * HT OFDM rates after CCK rates in 2.4 GHz band - */ - if (il->band == IEEE80211_BAND_2GHZ) - mac_idx += IL_FIRST_OFDM_RATE; - } - /* Here we actually compare this rate to the latest LQ command */ - if (mac_idx < 0 || - tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || - tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || - tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || - tbl_type.ant_type != info->antenna_sel_tx || - !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || - !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || - rs_idx != mac_idx) { - D_RATE( - "initial rate %d does not match %d (0x%x)\n", - mac_idx, rs_idx, tx_rate); - /* - * Since rates mis-match, the last LQ command may have failed. - * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with - * ... driver. - */ - lq_sta->missed_rate_counter++; - if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { - lq_sta->missed_rate_counter = 0; - il_send_lq_cmd(il, ctx, &lq_sta->lq, - CMD_ASYNC, false); - } - /* Regardless, ignore this status info for outdated rate */ - return; - } else - /* Rate did match, so reset the missed_rate_counter */ - lq_sta->missed_rate_counter = 0; - - /* Figure out if rate scale algorithm is in active or search table */ - if (il4965_table_type_matches(&tbl_type, - &(lq_sta->lq_info[lq_sta->active_tbl]))) { - curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - } else if (il4965_table_type_matches(&tbl_type, - &lq_sta->lq_info[1 - lq_sta->active_tbl])) { - curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - } else { - D_RATE( - "Neither active nor search matches tx rate\n"); - tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - D_RATE("active- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - D_RATE("search- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", - tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); - /* - * no matching table found, let's by-pass the data collection - * and continue to perform rate scale to find the rate table - */ - il4965_rs_stay_in_table(lq_sta, true); - goto done; - } - - /* - * Updating the frame history depends on whether packets were - * aggregated. - * - * For aggregation, all packets were transmitted at the same rate, the - * first idx into rate scale table. - */ - if (info->flags & IEEE80211_TX_STAT_AMPDU) { - tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, - &rs_idx); - il4965_rs_collect_tx_data(curr_tbl, rs_idx, - info->status.ampdu_len, - info->status.ampdu_ack_len); - - /* Update success/fail counts if not searching for new mode */ - if (lq_sta->stay_in_tbl) { - lq_sta->total_success += info->status.ampdu_ack_len; - lq_sta->total_failed += (info->status.ampdu_len - - info->status.ampdu_ack_len); - } - } else { - /* - * For legacy, update frame history with for each Tx retry. - */ - retries = info->status.rates[0].count - 1; - /* HW doesn't send more than 15 retries */ - retries = min(retries, 15); - - /* The last transmission may have been successful */ - legacy_success = !!(info->flags & IEEE80211_TX_STAT_ACK); - /* Collect data for each rate used during failed TX attempts */ - for (i = 0; i <= retries; ++i) { - tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, - &tbl_type, &rs_idx); - /* - * Only collect stats if retried rate is in the same RS - * table as active/search. - */ - if (il4965_table_type_matches(&tbl_type, curr_tbl)) - tmp_tbl = curr_tbl; - else if (il4965_table_type_matches(&tbl_type, - other_tbl)) - tmp_tbl = other_tbl; - else - continue; - il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, - i < retries ? 0 : legacy_success); - } - - /* Update success/fail counts if not searching for new mode */ - if (lq_sta->stay_in_tbl) { - lq_sta->total_success += legacy_success; - lq_sta->total_failed += retries + (1 - legacy_success); - } - } - /* The last TX rate is cached in lq_sta; it's set in if/else above */ - lq_sta->last_rate_n_flags = tx_rate; -done: - /* See if there's a better rate or modulation mode to try. */ - if (sta && sta->supp_rates[sband->band]) - il4965_rs_rate_scale_perform(il, skb, sta, lq_sta); -} - -/* - * Begin a period of staying with a selected modulation mode. - * Set "stay_in_tbl" flag to prevent any mode switches. - * Set frame tx success limits according to legacy vs. high-throughput, - * and reset overall (spanning all rates) tx success history stats. - * These control how long we stay using same modulation mode before - * searching for a new mode. - */ -static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, - struct il_lq_sta *lq_sta) -{ - D_RATE("we are staying in the same table\n"); - lq_sta->stay_in_tbl = 1; /* only place this gets set */ - if (is_legacy) { - lq_sta->table_count_limit = IL_LEGACY_TBL_COUNT; - lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; - } else { - lq_sta->table_count_limit = IL_NONE_LEGACY_TBL_COUNT; - lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; - } - lq_sta->table_count = 0; - lq_sta->total_failed = 0; - lq_sta->total_success = 0; - lq_sta->flush_timer = jiffies; - lq_sta->action_counter = 0; -} - -/* - * Find correct throughput table for given mode of modulation - */ -static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl) -{ - /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[RATE_COUNT]; - - /* Check for invalid LQ type */ - if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { - tbl->expected_tpt = expected_tpt_legacy; - return; - } - - /* Legacy rates have only one table */ - if (is_legacy(tbl->lq_type)) { - tbl->expected_tpt = expected_tpt_legacy; - return; - } - - /* Choose among many HT tables depending on number of streams - * (SISO/MIMO2), channel width (20/40), SGI, and aggregation - * status */ - if (is_siso(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) - ht_tbl_pointer = expected_tpt_siso20MHz; - else if (is_siso(tbl->lq_type)) - ht_tbl_pointer = expected_tpt_siso40MHz; - else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) - ht_tbl_pointer = expected_tpt_mimo2_20MHz; - else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ - ht_tbl_pointer = expected_tpt_mimo2_40MHz; - - if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ - tbl->expected_tpt = ht_tbl_pointer[0]; - else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ - tbl->expected_tpt = ht_tbl_pointer[1]; - else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ - tbl->expected_tpt = ht_tbl_pointer[2]; - else /* AGG+SGI */ - tbl->expected_tpt = ht_tbl_pointer[3]; -} - -/* - * Find starting rate for new "search" high-throughput mode of modulation. - * Goal is to find lowest expected rate (under perfect conditions) that is - * above the current measured throughput of "active" mode, to give new mode - * a fair chance to prove itself without too many challenges. - * - * This gets called when transitioning to more aggressive modulation - * (i.e. legacy to SISO or MIMO, or SISO to MIMO), as well as less aggressive - * (i.e. MIMO to SISO). When moving to MIMO, bit rate will typically need - * to decrease to match "active" throughput. When moving from MIMO to SISO, - * bit rate will typically need to increase, but not if performance was bad. - */ -static s32 il4965_rs_get_best_rate(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, /* "search" */ - u16 rate_mask, s8 idx) -{ - /* "active" values */ - struct il_scale_tbl_info *active_tbl = - &(lq_sta->lq_info[lq_sta->active_tbl]); - s32 active_sr = active_tbl->win[idx].success_ratio; - s32 active_tpt = active_tbl->expected_tpt[idx]; - - /* expected "search" throughput */ - s32 *tpt_tbl = tbl->expected_tpt; - - s32 new_rate, high, low, start_hi; - u16 high_low; - s8 rate = idx; - - new_rate = high = low = start_hi = RATE_INVALID; - - for (; ;) { - high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, - tbl->lq_type); - - low = high_low & 0xff; - high = (high_low >> 8) & 0xff; - - /* - * Lower the "search" bit rate, to give new "search" mode - * approximately the same throughput as "active" if: - * - * 1) "Active" mode has been working modestly well (but not - * great), and expected "search" throughput (under perfect - * conditions) at candidate rate is above the actual - * measured "active" throughput (but less than expected - * "active" throughput under perfect conditions). - * OR - * 2) "Active" mode has been working perfectly or very well - * and expected "search" throughput (under perfect - * conditions) at candidate rate is above expected - * "active" throughput (under perfect conditions). - */ - if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && - (active_sr > RATE_DECREASE_TH && - active_sr <= RATE_HIGH_TH && - tpt_tbl[rate] <= active_tpt)) || - (active_sr >= RATE_SCALE_SWITCH && - tpt_tbl[rate] > active_tpt)) { - - /* (2nd or later pass) - * If we've already tried to raise the rate, and are - * now trying to lower it, use the higher rate. */ - if (start_hi != RATE_INVALID) { - new_rate = start_hi; - break; - } - - new_rate = rate; - - /* Loop again with lower rate */ - if (low != RATE_INVALID) - rate = low; - - /* Lower rate not available, use the original */ - else - break; - - /* Else try to raise the "search" rate to match "active" */ - } else { - /* (2nd or later pass) - * If we've already tried to lower the rate, and are - * now trying to raise it, use the lower rate. */ - if (new_rate != RATE_INVALID) - break; - - /* Loop again with higher rate */ - else if (high != RATE_INVALID) { - start_hi = high; - rate = high; - - /* Higher rate not available, use the original */ - } else { - new_rate = rate; - break; - } - } - } - - return new_rate; -} - -/* - * Set up search table for MIMO2 - */ -static int il4965_rs_switch_to_mimo2(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) -{ - u16 rate_mask; - s32 rate; - s8 is_green = lq_sta->is_green; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) - return -1; - - if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) - == WLAN_HT_CAP_SM_PS_STATIC) - return -1; - - /* Need both Tx chains/antennas to support MIMO */ - if (il->hw_params.tx_chains_num < 2) - return -1; - - D_RATE("LQ: try to switch to MIMO2\n"); - - tbl->lq_type = LQ_MIMO2; - tbl->is_dup = lq_sta->is_dup; - tbl->action = 0; - tbl->max_search = IL_MAX_SEARCH; - rate_mask = lq_sta->active_mimo2_rate; - - if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) - tbl->is_ht40 = 1; - else - tbl->is_ht40 = 0; - - il4965_rs_set_expected_tpt_table(lq_sta, tbl); - - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); - - D_RATE("LQ: MIMO2 best rate %d mask %X\n", - rate, rate_mask); - if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "Can't switch with idx %d rate mask %x\n", - rate, rate_mask); - return -1; - } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); - - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); - return 0; -} - -/* - * Set up search table for SISO - */ -static int il4965_rs_switch_to_siso(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) -{ - u16 rate_mask; - u8 is_green = lq_sta->is_green; - s32 rate; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) - return -1; - - D_RATE("LQ: try to switch to SISO\n"); - - tbl->is_dup = lq_sta->is_dup; - tbl->lq_type = LQ_SISO; - tbl->action = 0; - tbl->max_search = IL_MAX_SEARCH; - rate_mask = lq_sta->active_siso_rate; - - if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) - tbl->is_ht40 = 1; - else - tbl->is_ht40 = 0; - - if (is_green) - tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ - - il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); - - D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); - if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "can not switch with idx %d rate mask %x\n", - rate, rate_mask); - return -1; - } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); - return 0; -} - -/* - * Try to switch to new modulation mode from legacy - */ -static int il4965_rs_move_legacy_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - int idx) -{ - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[idx]); - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); - u8 start_action; - u8 valid_tx_ant = il->hw_params.valid_tx_ant; - u8 tx_chains_num = il->hw_params.tx_chains_num; - int ret = 0; - u8 update_search_tbl_counter = 0; - - tbl->action = IL_LEGACY_SWITCH_SISO; - - start_action = tbl->action; - for (; ;) { - lq_sta->action_counter++; - switch (tbl->action) { - case IL_LEGACY_SWITCH_ANTENNA1: - case IL_LEGACY_SWITCH_ANTENNA2: - D_RATE("LQ: Legacy toggle Antenna\n"); - - if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || - (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) - break; - - /* Don't change antenna if success has been great */ - if (win->success_ratio >= IL_RS_GOOD_RATIO) - break; - - /* Set up search table to try other antenna */ - memcpy(search_tbl, tbl, sz); - - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { - update_search_tbl_counter = 1; - il4965_rs_set_expected_tpt_table(lq_sta, - search_tbl); - goto out; - } - break; - case IL_LEGACY_SWITCH_SISO: - D_RATE("LQ: Legacy switch to SISO\n"); - - /* Set up search table to try SISO */ - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = 0; - ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, idx); - if (!ret) { - lq_sta->action_counter = 0; - goto out; - } - - break; - case IL_LEGACY_SWITCH_MIMO2_AB: - case IL_LEGACY_SWITCH_MIMO2_AC: - case IL_LEGACY_SWITCH_MIMO2_BC: - D_RATE("LQ: Legacy switch to MIMO2\n"); - - /* Set up search table to try MIMO */ - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = 0; - - if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AB) - search_tbl->ant_type = ANT_AB; - else if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AC) - search_tbl->ant_type = ANT_AC; - else - search_tbl->ant_type = ANT_BC; - - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) - break; - - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); - if (!ret) { - lq_sta->action_counter = 0; - goto out; - } - break; - } - tbl->action++; - if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IL_LEGACY_SWITCH_ANTENNA1; - - if (tbl->action == start_action) - break; - - } - search_tbl->lq_type = LQ_NONE; - return 0; - -out: - lq_sta->search_better_tbl = 1; - tbl->action++; - if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IL_LEGACY_SWITCH_ANTENNA1; - if (update_search_tbl_counter) - search_tbl->action = tbl->action; - return 0; - -} - -/* - * Try to switch to new modulation mode from SISO - */ -static int il4965_rs_move_siso_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) -{ - u8 is_green = lq_sta->is_green; - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[idx]); - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); - u8 start_action; - u8 valid_tx_ant = il->hw_params.valid_tx_ant; - u8 tx_chains_num = il->hw_params.tx_chains_num; - u8 update_search_tbl_counter = 0; - int ret; - - start_action = tbl->action; - - for (;;) { - lq_sta->action_counter++; - switch (tbl->action) { - case IL_SISO_SWITCH_ANTENNA1: - case IL_SISO_SWITCH_ANTENNA2: - D_RATE("LQ: SISO toggle Antenna\n"); - if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || - (tbl->action == IL_SISO_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) - break; - - if (win->success_ratio >= IL_RS_GOOD_RATIO) - break; - - memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { - update_search_tbl_counter = 1; - goto out; - } - break; - case IL_SISO_SWITCH_MIMO2_AB: - case IL_SISO_SWITCH_MIMO2_AC: - case IL_SISO_SWITCH_MIMO2_BC: - D_RATE("LQ: SISO switch to MIMO2\n"); - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = 0; - - if (tbl->action == IL_SISO_SWITCH_MIMO2_AB) - search_tbl->ant_type = ANT_AB; - else if (tbl->action == IL_SISO_SWITCH_MIMO2_AC) - search_tbl->ant_type = ANT_AC; - else - search_tbl->ant_type = ANT_BC; - - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) - break; - - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); - if (!ret) - goto out; - break; - case IL_SISO_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) - break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) - break; - - D_RATE("LQ: SISO toggle SGI/NGI\n"); - - memcpy(search_tbl, tbl, sz); - if (is_green) { - if (!tbl->is_SGI) - break; - else - IL_ERR( - "SGI was set in GF+SISO\n"); - } - search_tbl->is_SGI = !tbl->is_SGI; - il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); - if (tbl->is_SGI) { - s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[idx]) - break; - } - search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); - update_search_tbl_counter = 1; - goto out; - } - tbl->action++; - if (tbl->action > IL_SISO_SWITCH_GI) - tbl->action = IL_SISO_SWITCH_ANTENNA1; - - if (tbl->action == start_action) - break; - } - search_tbl->lq_type = LQ_NONE; - return 0; - - out: - lq_sta->search_better_tbl = 1; - tbl->action++; - if (tbl->action > IL_SISO_SWITCH_GI) - tbl->action = IL_SISO_SWITCH_ANTENNA1; - if (update_search_tbl_counter) - search_tbl->action = tbl->action; - - return 0; -} - -/* - * Try to switch to new modulation mode from MIMO2 - */ -static int il4965_rs_move_mimo2_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) -{ - s8 is_green = lq_sta->is_green; - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[idx]); - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); - u8 start_action; - u8 valid_tx_ant = il->hw_params.valid_tx_ant; - u8 tx_chains_num = il->hw_params.tx_chains_num; - u8 update_search_tbl_counter = 0; - int ret; - - start_action = tbl->action; - for (;;) { - lq_sta->action_counter++; - switch (tbl->action) { - case IL_MIMO2_SWITCH_ANTENNA1: - case IL_MIMO2_SWITCH_ANTENNA2: - D_RATE("LQ: MIMO2 toggle Antennas\n"); - - if (tx_chains_num <= 2) - break; - - if (win->success_ratio >= IL_RS_GOOD_RATIO) - break; - - memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { - update_search_tbl_counter = 1; - goto out; - } - break; - case IL_MIMO2_SWITCH_SISO_A: - case IL_MIMO2_SWITCH_SISO_B: - case IL_MIMO2_SWITCH_SISO_C: - D_RATE("LQ: MIMO2 switch to SISO\n"); - - /* Set up new search table for SISO */ - memcpy(search_tbl, tbl, sz); - - if (tbl->action == IL_MIMO2_SWITCH_SISO_A) - search_tbl->ant_type = ANT_A; - else if (tbl->action == IL_MIMO2_SWITCH_SISO_B) - search_tbl->ant_type = ANT_B; - else - search_tbl->ant_type = ANT_C; - - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) - break; - - ret = il4965_rs_switch_to_siso(il, lq_sta, - conf, sta, - search_tbl, idx); - if (!ret) - goto out; - - break; - - case IL_MIMO2_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) - break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) - break; - - D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); - - /* Set up new search table for MIMO2 */ - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = !tbl->is_SGI; - il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); - /* - * If active table already uses the fastest possible - * modulation (dual stream with short guard interval), - * and it's working well, there's no need to look - * for a better type of modulation! - */ - if (tbl->is_SGI) { - s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[idx]) - break; - } - search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); - update_search_tbl_counter = 1; - goto out; - - } - tbl->action++; - if (tbl->action > IL_MIMO2_SWITCH_GI) - tbl->action = IL_MIMO2_SWITCH_ANTENNA1; - - if (tbl->action == start_action) - break; - } - search_tbl->lq_type = LQ_NONE; - return 0; - out: - lq_sta->search_better_tbl = 1; - tbl->action++; - if (tbl->action > IL_MIMO2_SWITCH_GI) - tbl->action = IL_MIMO2_SWITCH_ANTENNA1; - if (update_search_tbl_counter) - search_tbl->action = tbl->action; - - return 0; - -} - -/* - * Check whether we should continue using same modulation mode, or - * begin search for a new mode, based on: - * 1) # tx successes or failures while using this mode - * 2) # times calling this function - * 3) elapsed time in this mode (not used, for now) - */ -static void -il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) -{ - struct il_scale_tbl_info *tbl; - int i; - int active_tbl; - int flush_interval_passed = 0; - struct il_priv *il; - - il = lq_sta->drv; - active_tbl = lq_sta->active_tbl; - - tbl = &(lq_sta->lq_info[active_tbl]); - - /* If we've been disallowing search, see if we should now allow it */ - if (lq_sta->stay_in_tbl) { - - /* Elapsed time using current modulation mode */ - if (lq_sta->flush_timer) - flush_interval_passed = - time_after(jiffies, - (unsigned long)(lq_sta->flush_timer + - RATE_SCALE_FLUSH_INTVL)); - - /* - * Check if we should allow search for new modulation mode. - * If many frames have failed or succeeded, or we've used - * this same modulation for a long time, allow search, and - * reset history stats that keep track of whether we should - * allow a new search. Also (below) reset all bitmaps and - * stats in active history. - */ - if (force_search || - lq_sta->total_failed > lq_sta->max_failure_limit || - lq_sta->total_success > lq_sta->max_success_limit || - (!lq_sta->search_better_tbl && lq_sta->flush_timer && - flush_interval_passed)) { - D_RATE("LQ: stay is expired %d %d %d\n:", - lq_sta->total_failed, - lq_sta->total_success, - flush_interval_passed); - - /* Allow search for new mode */ - lq_sta->stay_in_tbl = 0; /* only place reset */ - lq_sta->total_failed = 0; - lq_sta->total_success = 0; - lq_sta->flush_timer = 0; - - /* - * Else if we've used this modulation mode enough repetitions - * (regardless of elapsed time or success/failure), reset - * history bitmaps and rate-specific stats for all rates in - * active table. - */ - } else { - lq_sta->table_count++; - if (lq_sta->table_count >= - lq_sta->table_count_limit) { - lq_sta->table_count = 0; - - D_RATE( - "LQ: stay in table clear win\n"); - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); - } - } - - /* If transitioning to allow "search", reset all history - * bitmaps and stats in active table (this will become the new - * "search" table). */ - if (!lq_sta->stay_in_tbl) { - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); - } - } -} - -/* - * setup rate table in uCode - * return rate_n_flags as used in the table - */ -static u32 il4965_rs_update_rate_tbl(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - int idx, u8 is_green) -{ - u32 rate; - - /* Update uCode's rate table. */ - rate = il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); - il4965_rs_fill_link_cmd(il, lq_sta, rate); - il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); - - return rate; -} - -/* - * Do rate scaling and search for new modulation mode. - */ -static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) -{ - struct ieee80211_hw *hw = il->hw; - struct ieee80211_conf *conf = &hw->conf; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - int low = RATE_INVALID; - int high = RATE_INVALID; - int idx; - int i; - struct il_rate_scale_data *win = NULL; - int current_tpt = IL_INVALID_VALUE; - int low_tpt = IL_INVALID_VALUE; - int high_tpt = IL_INVALID_VALUE; - u32 fail_count; - s8 scale_action = 0; - u16 rate_mask; - u8 update_lq = 0; - struct il_scale_tbl_info *tbl, *tbl1; - u16 rate_scale_idx_msk = 0; - u32 rate; - u8 is_green = 0; - u8 active_tbl = 0; - u8 done_search = 0; - u16 high_low; - s32 sr; - u8 tid = MAX_TID_COUNT; - struct il_tid_data *tid_data; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - D_RATE("rate scale calculate new rate for skb\n"); - - /* Send management frames and NO_ACK data using lowest rate. */ - /* TODO: this could probably be improved.. */ - if (!ieee80211_is_data(hdr->frame_control) || - (info->flags & IEEE80211_TX_CTL_NO_ACK)) - return; - - if (!sta || !lq_sta) - return; - - lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; - - tid = il4965_rs_tl_add_packet(lq_sta, hdr); - if (tid != MAX_TID_COUNT && (lq_sta->tx_agg_tid_en & (1 << tid))) { - tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IL_AGG_OFF) - lq_sta->is_agg = 0; - else - lq_sta->is_agg = 1; - } else - lq_sta->is_agg = 0; - - /* - * Select rate-scale / modulation-mode table to work with in - * the rest of this function: "search" if searching for better - * modulation mode, or "active" if doing rate scaling within a mode. - */ - if (!lq_sta->search_better_tbl) - active_tbl = lq_sta->active_tbl; - else - active_tbl = 1 - lq_sta->active_tbl; - - tbl = &(lq_sta->lq_info[active_tbl]); - if (is_legacy(tbl->lq_type)) - lq_sta->is_green = 0; - else - lq_sta->is_green = il4965_rs_use_green(sta); - is_green = lq_sta->is_green; - - /* current tx rate */ - idx = lq_sta->last_txrate_idx; - - D_RATE("Rate scale idx %d for type %d\n", idx, - tbl->lq_type); - - /* rates available for this association, and for modulation mode */ - rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - - D_RATE("mask 0x%04X\n", rate_mask); - - /* mask with station rate restriction */ - if (is_legacy(tbl->lq_type)) { - if (lq_sta->band == IEEE80211_BAND_5GHZ) - /* supp_rates has no CCK bits in A mode */ - rate_scale_idx_msk = (u16) (rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); - else - rate_scale_idx_msk = (u16) (rate_mask & - lq_sta->supp_rates); - - } else - rate_scale_idx_msk = rate_mask; - - if (!rate_scale_idx_msk) - rate_scale_idx_msk = rate_mask; - - if (!((1 << idx) & rate_scale_idx_msk)) { - IL_ERR("Current Rate is not valid\n"); - if (lq_sta->search_better_tbl) { - /* revert to active table if search table is not valid*/ - tbl->lq_type = LQ_NONE; - lq_sta->search_better_tbl = 0; - tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - /* get "active" rate info */ - idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); - } - return; - } - - /* Get expected throughput table and history win for current rate */ - if (!tbl->expected_tpt) { - IL_ERR("tbl->expected_tpt is NULL\n"); - return; - } - - /* force user max rate if set by user */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < idx) { - idx = lq_sta->max_rate_idx; - update_lq = 1; - win = &(tbl->win[idx]); - goto lq_update; - } - - win = &(tbl->win[idx]); - - /* - * If there is not enough history to calculate actual average - * throughput, keep analyzing results of more tx frames, without - * changing rate or mode (bypass most of the rest of this function). - * Set up new rate table in uCode only if old rate is not supported - * in current association (use new rate found above). - */ - fail_count = win->counter - win->success_counter; - if (fail_count < RATE_MIN_FAILURE_TH && - win->success_counter < RATE_MIN_SUCCESS_TH) { - D_RATE("LQ: still below TH. succ=%d total=%d " - "for idx %d\n", - win->success_counter, win->counter, idx); - - /* Can't calculate this yet; not enough history */ - win->average_tpt = IL_INVALID_VALUE; - - /* Should we stay with this modulation mode, - * or search for a new one? */ - il4965_rs_stay_in_table(lq_sta, false); - - goto out; - } - /* Else we have enough samples; calculate estimate of - * actual average throughput */ - if (win->average_tpt != ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128)) { - IL_ERR( - "expected_tpt should have been calculated by now\n"); - win->average_tpt = ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128); - } - - /* If we are searching for better modulation mode, check success. */ - if (lq_sta->search_better_tbl) { - /* If good success, continue using the "search" mode; - * no need to send new link quality command, since we're - * continuing to use the setup that we've been trying. */ - if (win->average_tpt > lq_sta->last_tpt) { - - D_RATE("LQ: SWITCHING TO NEW TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); - - if (!is_legacy(tbl->lq_type)) - lq_sta->enable_counter = 1; - - /* Swap tables; "search" becomes "active" */ - lq_sta->active_tbl = active_tbl; - current_tpt = win->average_tpt; - - /* Else poor success; go back to mode in "active" table */ - } else { - - D_RATE("LQ: GOING BACK TO THE OLD TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); - - /* Nullify "search" table */ - tbl->lq_type = LQ_NONE; - - /* Revert to "active" table */ - active_tbl = lq_sta->active_tbl; - tbl = &(lq_sta->lq_info[active_tbl]); - - /* Revert to "active" rate and throughput info */ - idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - current_tpt = lq_sta->last_tpt; - - /* Need to set up a new rate table in uCode */ - update_lq = 1; - } - - /* Either way, we've made a decision; modulation mode - * search is done, allow rate adjustment next time. */ - lq_sta->search_better_tbl = 0; - done_search = 1; /* Don't switch modes below! */ - goto lq_update; - } - - /* (Else) not in search of better modulation mode, try for better - * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(il, idx, - rate_scale_idx_msk, - tbl->lq_type); - low = high_low & 0xff; - high = (high_low >> 8) & 0xff; - - /* If user set max rate, dont allow higher than user constrain */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < high) - high = RATE_INVALID; - - sr = win->success_ratio; - - /* Collect measured throughputs for current and adjacent rates */ - current_tpt = win->average_tpt; - if (low != RATE_INVALID) - low_tpt = tbl->win[low].average_tpt; - if (high != RATE_INVALID) - high_tpt = tbl->win[high].average_tpt; - - scale_action = 0; - - /* Too many failures, decrease rate */ - if (sr <= RATE_DECREASE_TH || current_tpt == 0) { - D_RATE( - "decrease rate because of low success_ratio\n"); - scale_action = -1; - - /* No throughput measured yet for adjacent rates; try increase. */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { - - if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) - scale_action = 1; - else if (low != RATE_INVALID) - scale_action = 0; - } - - /* Both adjacent throughputs are measured, but neither one has better - * throughput; we're using the best rate, don't change it! */ - else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE && - low_tpt < current_tpt && high_tpt < current_tpt) - scale_action = 0; - - /* At least one adjacent rate's throughput is measured, - * and may have better performance. */ - else { - /* Higher adjacent rate's throughput is measured */ - if (high_tpt != IL_INVALID_VALUE) { - /* Higher rate has better throughput */ - if (high_tpt > current_tpt && - sr >= RATE_INCREASE_TH) { - scale_action = 1; - } else { - scale_action = 0; - } - - /* Lower adjacent rate's throughput is measured */ - } else if (low_tpt != IL_INVALID_VALUE) { - /* Lower rate has better throughput */ - if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); - scale_action = -1; - } else if (sr >= RATE_INCREASE_TH) { - scale_action = 1; - } - } - } - - /* Sanity check; asked for decrease, but success rate or throughput - * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != RATE_INVALID && - (sr > RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) - scale_action = 0; - - switch (scale_action) { - case -1: - /* Decrease starting rate, update uCode's rate table */ - if (low != RATE_INVALID) { - update_lq = 1; - idx = low; - } - - break; - case 1: - /* Increase starting rate, update uCode's rate table */ - if (high != RATE_INVALID) { - update_lq = 1; - idx = high; - } - - break; - case 0: - /* No change */ - default: - break; - } - - D_RATE("choose rate scale idx %d action %d low %d " - "high %d type %d\n", - idx, scale_action, low, high, tbl->lq_type); - -lq_update: - /* Replace uCode's rate table for the destination station. */ - if (update_lq) - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); - - /* Should we stay with this modulation mode, - * or search for a new one? */ - il4965_rs_stay_in_table(lq_sta, false); - - /* - * Search for new modulation mode if we're: - * 1) Not changing rates right now - * 2) Not just finishing up a search - * 3) Allowing a new search - */ - if (!update_lq && !done_search && !lq_sta->stay_in_tbl && - win->counter) { - /* Save current throughput to compare with "search" throughput*/ - lq_sta->last_tpt = current_tpt; - - /* Select a new "search" modulation mode to try. - * If one is found, set up the new "search" table. */ - if (is_legacy(tbl->lq_type)) - il4965_rs_move_legacy_other(il, lq_sta, - conf, sta, idx); - else if (is_siso(tbl->lq_type)) - il4965_rs_move_siso_to_other(il, lq_sta, - conf, sta, idx); - else /* (is_mimo2(tbl->lq_type)) */ - il4965_rs_move_mimo2_to_other(il, lq_sta, - conf, sta, idx); - - /* If new "search" mode was selected, set up in uCode table */ - if (lq_sta->search_better_tbl) { - /* Access the "search" table, clear its history. */ - tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); - - /* Use new "search" start rate */ - idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - - D_RATE( - "Switch current mcs: %X idx: %d\n", - tbl->current_rate, idx); - il4965_rs_fill_link_cmd(il, lq_sta, - tbl->current_rate); - il_send_lq_cmd(il, ctx, - &lq_sta->lq, CMD_ASYNC, false); - } else - done_search = 1; - } - - if (done_search && !lq_sta->stay_in_tbl) { - /* If the "active" (non-search) mode was legacy, - * and we've tried switching antennas, - * but we haven't been able to try HT modes (not available), - * stay with best antenna legacy modulation for a while - * before next round of mode comparisons. */ - tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); - if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && - lq_sta->action_counter > tbl1->max_search) { - D_RATE("LQ: STAY in legacy table\n"); - il4965_rs_set_stay_in_table(il, 1, lq_sta); - } - - /* If we're in an HT mode, and all 3 mode switch actions - * have been tried and compared, stay in this best modulation - * mode for a while before next round of mode comparisons. */ - if (lq_sta->enable_counter && - lq_sta->action_counter >= tbl1->max_search) { - if (lq_sta->last_tpt > IL_AGG_TPT_THREHOLD && - (lq_sta->tx_agg_tid_en & (1 << tid)) && - tid != MAX_TID_COUNT) { - tid_data = - &il->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IL_AGG_OFF) { - D_RATE( - "try to aggregate tid %d\n", - tid); - il4965_rs_tl_turn_on_agg(il, tid, - lq_sta, sta); - } - } - il4965_rs_set_stay_in_table(il, 0, lq_sta); - } - } - -out: - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, - idx, is_green); - i = idx; - lq_sta->last_txrate_idx = i; -} - -/** - * il4965_rs_initialize_lq - Initialize a station's hardware rate table - * - * The uCode's station table contains a table of fallback rates - * for automatic fallback during transmission. - * - * NOTE: This sets up a default set of values. These will be replaced later - * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of - * rc80211_simple. - * - * NOTE: Run REPLY_ADD_STA command to set up station table entry, before - * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, - * which requires station table entry to exist). - */ -static void il4965_rs_initialize_lq(struct il_priv *il, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) -{ - struct il_scale_tbl_info *tbl; - int rate_idx; - int i; - u32 rate; - u8 use_green = il4965_rs_use_green(sta); - u8 active_tbl = 0; - u8 valid_tx_ant; - struct il_station_priv *sta_priv; - struct il_rxon_context *ctx; - - if (!sta || !lq_sta) - return; - - sta_priv = (void *)sta->drv_priv; - ctx = sta_priv->common.ctx; - - i = lq_sta->last_txrate_idx; - - valid_tx_ant = il->hw_params.valid_tx_ant; - - if (!lq_sta->search_better_tbl) - active_tbl = lq_sta->active_tbl; - else - active_tbl = 1 - lq_sta->active_tbl; - - tbl = &(lq_sta->lq_info[active_tbl]); - - if (i < 0 || i >= RATE_COUNT) - i = 0; - - rate = il_rates[i].plcp; - tbl->ant_type = il4965_first_antenna(valid_tx_ant); - rate |= tbl->ant_type << RATE_MCS_ANT_POS; - - if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) - rate |= RATE_MCS_CCK_MSK; - - il4965_rs_get_tbl_info_from_mcs(rate, il->band, tbl, &rate_idx); - if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) - il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); - - rate = il4965_rate_n_flags_from_tbl(il, tbl, rate_idx, use_green); - tbl->current_rate = rate; - il4965_rs_set_expected_tpt_table(lq_sta, tbl); - il4965_rs_fill_link_cmd(NULL, lq_sta, rate); - il->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; - il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_SYNC, true); -} - -static void -il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, - struct ieee80211_tx_rate_control *txrc) -{ - - struct sk_buff *skb = txrc->skb; - struct ieee80211_supported_band *sband = txrc->sband; - struct il_priv *il __maybe_unused = (struct il_priv *)il_r; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct il_lq_sta *lq_sta = il_sta; - int rate_idx; - - D_RATE("rate scale calculate new rate for skb\n"); - - /* Get max rate if user set max rate */ - if (lq_sta) { - lq_sta->max_rate_idx = txrc->max_rate_idx; - if (sband->band == IEEE80211_BAND_5GHZ && - lq_sta->max_rate_idx != -1) - lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; - if (lq_sta->max_rate_idx < 0 || - lq_sta->max_rate_idx >= RATE_COUNT) - lq_sta->max_rate_idx = -1; - } - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (lq_sta && !lq_sta->drv) { - D_RATE("Rate scaling not initialized yet.\n"); - il_sta = NULL; - } - - /* Send management frames and NO_ACK data using lowest rate. */ - if (rate_control_send_low(sta, il_sta, txrc)) - return; - - if (!lq_sta) - return; - - rate_idx = lq_sta->last_txrate_idx; - - if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { - rate_idx -= IL_FIRST_OFDM_RATE; - /* 6M and 9M shared same MCS idx */ - rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; - if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - RATE_MIMO2_6M_PLCP) - rate_idx = rate_idx + MCS_IDX_PER_STREAM; - info->control.rates[0].flags = IEEE80211_TX_RC_MCS; - if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_SHORT_GI; - if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_DUP_DATA; - if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_40_MHZ_WIDTH; - if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_GREEN_FIELD; - } else { - /* Check for invalid rates */ - if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || - (sband->band == IEEE80211_BAND_5GHZ && - rate_idx < IL_FIRST_OFDM_RATE)) - rate_idx = rate_lowest_index(sband, sta); - /* On valid 5 GHz rate, adjust idx */ - else if (sband->band == IEEE80211_BAND_5GHZ) - rate_idx -= IL_FIRST_OFDM_RATE; - info->control.rates[0].flags = 0; - } - info->control.rates[0].idx = rate_idx; - -} - -static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, - gfp_t gfp) -{ - struct il_lq_sta *lq_sta; - struct il_station_priv *sta_priv = - (struct il_station_priv *) sta->drv_priv; - struct il_priv *il; - - il = (struct il_priv *)il_rate; - D_RATE("create station rate scale win\n"); - - lq_sta = &sta_priv->lq_sta; - - return lq_sta; -} - -/* - * Called after adding a new station to initialize rate scaling - */ -void -il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, - u8 sta_id) -{ - int i, j; - struct ieee80211_hw *hw = il->hw; - struct ieee80211_conf *conf = &il->hw->conf; - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - struct il_station_priv *sta_priv; - struct il_lq_sta *lq_sta; - struct ieee80211_supported_band *sband; - - sta_priv = (struct il_station_priv *) sta->drv_priv; - lq_sta = &sta_priv->lq_sta; - sband = hw->wiphy->bands[conf->channel->band]; - - - lq_sta->lq.sta_id = sta_id; - - for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); - - lq_sta->flush_timer = 0; - lq_sta->supp_rates = sta->supp_rates[sband->band]; - for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); - - D_RATE("LQ:" - "*** rate scale station global init for station %d ***\n", - sta_id); - /* TODO: what is a good starting rate for STA? About middle? Maybe not - * the lowest or the highest rate.. Could consider using RSSI from - * previous packets? Need to have IEEE 802.1X auth succeed immediately - * after assoc.. */ - - lq_sta->is_dup = 0; - lq_sta->max_rate_idx = -1; - lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; - lq_sta->is_green = il4965_rs_use_green(sta); - lq_sta->active_legacy_rate = il->active_rate & ~(0x1000); - lq_sta->band = il->band; - /* - * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), - * supp_rates[] does not; shift to convert format, force 9 MBits off. - */ - lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; - lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; - lq_sta->active_siso_rate &= ~((u16)0x2); - lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; - - /* Same here */ - lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; - lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; - lq_sta->active_mimo2_rate &= ~((u16)0x2); - lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; - - /* These values will be overridden later */ - lq_sta->lq.general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); - lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); - if (!lq_sta->lq.general_params.dual_stream_ant_msk) { - lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { - lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; - } - - /* as default allow aggregation for all tids */ - lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; - lq_sta->drv = il; - - /* Set last_txrate_idx to lowest rate */ - lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); - if (sband->band == IEEE80211_BAND_5GHZ) - lq_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - lq_sta->is_agg = 0; - -#ifdef CONFIG_MAC80211_DEBUGFS - lq_sta->dbg_fixed_rate = 0; -#endif - - il4965_rs_initialize_lq(il, conf, sta, lq_sta); -} - -static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 new_rate) -{ - struct il_scale_tbl_info tbl_type; - int idx = 0; - int rate_idx; - int repeat_rate = 0; - u8 ant_toggle_cnt = 0; - u8 use_ht_possible = 1; - u8 valid_tx_ant = 0; - struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; - - /* Override starting rate (idx 0) if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); - - /* Interpret new_rate (rate_n_flags) */ - il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, - &tbl_type, &rate_idx); - - /* How many times should we repeat the initial rate? */ - if (is_legacy(tbl_type.lq_type)) { - ant_toggle_cnt = 1; - repeat_rate = IL_NUMBER_TRY; - } else { - repeat_rate = IL_HT_NUMBER_TRY; - } - - lq_cmd->general_params.mimo_delimiter = - is_mimo(tbl_type.lq_type) ? 1 : 0; - - /* Fill 1st table entry (idx 0) */ - lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); - - if (il4965_num_of_ant(tbl_type.ant_type) == 1) { - lq_cmd->general_params.single_stream_ant_msk = - tbl_type.ant_type; - } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { - lq_cmd->general_params.dual_stream_ant_msk = - tbl_type.ant_type; - } /* otherwise we don't modify the existing value */ - - idx++; - repeat_rate--; - if (il) - valid_tx_ant = il->hw_params.valid_tx_ant; - - /* Fill rest of rate table */ - while (idx < LINK_QUAL_MAX_RETRY_NUM) { - /* Repeat initial/next rate. - * For legacy IL_NUMBER_TRY == 1, this loop will not execute. - * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ - while (repeat_rate > 0 && idx < LINK_QUAL_MAX_RETRY_NUM) { - if (is_legacy(tbl_type.lq_type)) { - if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) - ant_toggle_cnt++; - else if (il && - il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) - ant_toggle_cnt = 1; - } - - /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); - - /* Fill next table entry */ - lq_cmd->rs_table[idx].rate_n_flags = - cpu_to_le32(new_rate); - repeat_rate--; - idx++; - } - - il4965_rs_get_tbl_info_from_mcs(new_rate, - lq_sta->band, &tbl_type, - &rate_idx); - - /* Indicate to uCode which entries might be MIMO. - * If initial rate was MIMO, this will finally end up - * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ - if (is_mimo(tbl_type.lq_type)) - lq_cmd->general_params.mimo_delimiter = idx; - - /* Get next rate */ - new_rate = il4965_rs_get_lower_rate(lq_sta, - &tbl_type, rate_idx, - use_ht_possible); - - /* How many times should we repeat the next rate? */ - if (is_legacy(tbl_type.lq_type)) { - if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) - ant_toggle_cnt++; - else if (il && - il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) - ant_toggle_cnt = 1; - - repeat_rate = IL_NUMBER_TRY; - } else { - repeat_rate = IL_HT_NUMBER_TRY; - } - - /* Don't allow HT rates after next pass. - * il4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ - use_ht_possible = 0; - - /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); - - /* Fill next table entry */ - lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); - - idx++; - repeat_rate--; - } - - lq_cmd->agg_params.agg_frame_cnt_limit = LINK_QUAL_AGG_FRAME_LIMIT_DEF; - lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; - - lq_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); -} - -static void -*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) -{ - return hw->priv; -} -/* rate scale requires free function to be implemented */ -static void il4965_rs_free(void *il_rate) -{ - return; -} - -static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, - void *il_sta) -{ - struct il_priv *il __maybe_unused = il_r; - - D_RATE("enter\n"); - D_RATE("leave\n"); -} - - -#ifdef CONFIG_MAC80211_DEBUGFS -static int il4965_open_file_generic(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) -{ - struct il_priv *il; - u8 valid_tx_ant; - u8 ant_sel_tx; - - il = lq_sta->drv; - valid_tx_ant = il->hw_params.valid_tx_ant; - if (lq_sta->dbg_fixed_rate) { - ant_sel_tx = - ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) - >> RATE_MCS_ANT_POS); - if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { - *rate_n_flags = lq_sta->dbg_fixed_rate; - D_RATE("Fixed rate ON\n"); - } else { - lq_sta->dbg_fixed_rate = 0; - IL_ERR( - "Invalid antenna selection 0x%X, Valid is 0x%X\n", - ant_sel_tx, valid_tx_ant); - D_RATE("Fixed rate OFF\n"); - } - } else { - D_RATE("Fixed rate OFF\n"); - } -} - -static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, - const char __user *user_buf, size_t count, loff_t *ppos) -{ - struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *il; - char buf[64]; - size_t buf_size; - u32 parsed_rate; - struct il_station_priv *sta_priv = - container_of(lq_sta, struct il_station_priv, lq_sta); - struct il_rxon_context *ctx = sta_priv->common.ctx; - - il = lq_sta->drv; - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - - if (sscanf(buf, "%x", &parsed_rate) == 1) - lq_sta->dbg_fixed_rate = parsed_rate; - else - lq_sta->dbg_fixed_rate = 0; - - lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ - lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - - D_RATE("sta_id %d rate 0x%X\n", - lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); - - if (lq_sta->dbg_fixed_rate) { - il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); - il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, - false); - } - - return count; -} - -static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) -{ - char *buff; - int desc = 0; - int i = 0; - int idx = 0; - ssize_t ret; - - struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *il; - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - - il = lq_sta->drv; - buff = kmalloc(1024, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); - desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", - lq_sta->total_failed, lq_sta->total_success, - lq_sta->active_legacy_rate); - desc += sprintf(buff+desc, "fixed rate 0x%X\n", - lq_sta->dbg_fixed_rate); - desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", - (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", - (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", - (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); - desc += sprintf(buff+desc, "lq type %s\n", - (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); - if (is_Ht(tbl->lq_type)) { - desc += sprintf(buff+desc, " %s", - (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); - desc += sprintf(buff+desc, " %s", - (tbl->is_ht40) ? "40MHz" : "20MHz"); - desc += sprintf(buff+desc, " %s %s %s\n", - (tbl->is_SGI) ? "SGI" : "", - (lq_sta->is_green) ? "GF enabled" : "", - (lq_sta->is_agg) ? "AGG on" : ""); - } - desc += sprintf(buff+desc, "last tx rate=0x%X\n", - lq_sta->last_rate_n_flags); - desc += sprintf(buff+desc, "general:" - "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", - lq_sta->lq.general_params.flags, - lq_sta->lq.general_params.mimo_delimiter, - lq_sta->lq.general_params.single_stream_ant_msk, - lq_sta->lq.general_params.dual_stream_ant_msk); - - desc += sprintf(buff+desc, "agg:" - "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", - le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), - lq_sta->lq.agg_params.agg_dis_start_th, - lq_sta->lq.agg_params.agg_frame_cnt_limit); - - desc += sprintf(buff+desc, - "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", - lq_sta->lq.general_params.start_rate_idx[0], - lq_sta->lq.general_params.start_rate_idx[1], - lq_sta->lq.general_params.start_rate_idx[2], - lq_sta->lq.general_params.start_rate_idx[3]); - - for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - idx = il4965_hwrate_to_plcp_idx( - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); - if (is_legacy(tbl->lq_type)) { - desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps); - } else { - desc += sprintf(buff+desc, - " rate[%d] 0x%X %smbps (%s)\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); - } - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - kfree(buff); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_scale_table_ops = { - .write = il4965_rs_sta_dbgfs_scale_table_write, - .read = il4965_rs_sta_dbgfs_scale_table_read, - .open = il4965_open_file_generic, - .llseek = default_llseek, -}; -static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) -{ - char *buff; - int desc = 0; - int i, j; - ssize_t ret; - - struct il_lq_sta *lq_sta = file->private_data; - - buff = kmalloc(1024, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - for (i = 0; i < LQ_SIZE; i++) { - desc += sprintf(buff+desc, - "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" - "rate=0x%X\n", - lq_sta->active_tbl == i ? "*" : "x", - lq_sta->lq_info[i].lq_type, - lq_sta->lq_info[i].is_SGI, - lq_sta->lq_info[i].is_ht40, - lq_sta->lq_info[i].is_dup, - lq_sta->is_green, - lq_sta->lq_info[i].current_rate); - for (j = 0; j < RATE_COUNT; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->lq_info[i].win[j].counter, - lq_sta->lq_info[i].win[j].success_counter, - lq_sta->lq_info[i].win[j].success_ratio); - } - } - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - kfree(buff); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = il4965_rs_sta_dbgfs_stats_table_read, - .open = il4965_open_file_generic, - .llseek = default_llseek, -}; - -static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) -{ - char buff[120]; - int desc = 0; - ssize_t ret; - - struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *il; - struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; - - il = lq_sta->drv; - - if (is_Ht(tbl->lq_type)) - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - tbl->expected_tpt[lq_sta->last_txrate_idx]); - else - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - il_rates[lq_sta->last_txrate_idx].ieee >> 1); - - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { - .read = il4965_rs_sta_dbgfs_rate_scale_data_read, - .open = il4965_open_file_generic, - .llseek = default_llseek, -}; - -static void il4965_rs_add_debugfs(void *il, void *il_sta, - struct dentry *dir) -{ - struct il_lq_sta *lq_sta = il_sta; - lq_sta->rs_sta_dbgfs_scale_table_file = - debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, - lq_sta, &rs_sta_dbgfs_scale_table_ops); - lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); - lq_sta->rs_sta_dbgfs_rate_scale_data_file = - debugfs_create_file("rate_scale_data", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); - lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = - debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, - &lq_sta->tx_agg_tid_en); - -} - -static void il4965_rs_remove_debugfs(void *il, void *il_sta) -{ - struct il_lq_sta *lq_sta = il_sta; - debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); - debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); - debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); - debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); -} -#endif - -/* - * Initialization of rate scaling information is done by driver after - * the station is added. Since mac80211 calls this function before a - * station is added we ignore it. - */ -static void -il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta) -{ -} -static struct rate_control_ops rs_4965_ops = { - .module = NULL, - .name = IL4965_RS_NAME, - .tx_status = il4965_rs_tx_status, - .get_rate = il4965_rs_get_rate, - .rate_init = il4965_rs_rate_init_stub, - .alloc = il4965_rs_alloc, - .free = il4965_rs_free, - .alloc_sta = il4965_rs_alloc_sta, - .free_sta = il4965_rs_free_sta, -#ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = il4965_rs_add_debugfs, - .remove_sta_debugfs = il4965_rs_remove_debugfs, -#endif -}; - -int il4965_rate_control_register(void) -{ - return ieee80211_rate_control_register(&rs_4965_ops); -} - -void il4965_rate_control_unregister(void) -{ - ieee80211_rate_control_unregister(&rs_4965_ops); -} -- cgit v0.10.2 From ccf5533ec4cdf792ec17c375b1186cfed4086f2a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 6 Sep 2011 12:28:10 +0200 Subject: iwlegacy: rename iwl-3945-{rs,debugfs}.c to 3945-{rs,debug}.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c new file mode 100644 index 0000000..88b3d8f --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -0,0 +1,523 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + *****************************************************************************/ + +#include "iwl-3945-debugfs.h" + + +static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) +{ + int p = 0; + + p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", + le32_to_cpu(il->_3945.stats.flag)); + if (le32_to_cpu(il->_3945.stats.flag) & + UCODE_STATISTICS_CLEAR_MSK) + p += scnprintf(buf + p, bufsz - p, + "\tStatistics have been cleared\n"); + p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", + (le32_to_cpu(il->_3945.stats.flag) & + UCODE_STATISTICS_FREQUENCY_MSK) + ? "2.4 GHz" : "5.2 GHz"); + p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", + (le32_to_cpu(il->_3945.stats.flag) & + UCODE_STATISTICS_NARROW_BAND_MSK) + ? "enabled" : "disabled"); + return p; +} + +ssize_t il3945_ucode_rx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + + sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; + ssize_t ret; + struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, + *max_ofdm; + struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct iwl39_stats_rx_non_phy *general, *accum_general; + struct iwl39_stats_rx_non_phy *delta_general, *max_general; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * The statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + ofdm = &il->_3945.stats.rx.ofdm; + cck = &il->_3945.stats.rx.cck; + general = &il->_3945.stats.rx.general; + accum_ofdm = &il->_3945.accum_stats.rx.ofdm; + accum_cck = &il->_3945.accum_stats.rx.cck; + accum_general = &il->_3945.accum_stats.rx.general; + delta_ofdm = &il->_3945.delta_stats.rx.ofdm; + delta_cck = &il->_3945.delta_stats.rx.cck; + delta_general = &il->_3945.delta_stats.rx.general; + max_ofdm = &il->_3945.max_delta.rx.ofdm; + max_cck = &il->_3945.max_delta.rx.cck; + max_general = &il->_3945.max_delta.rx.general; + + pos += il3945_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - OFDM:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "ina_cnt:", le32_to_cpu(ofdm->ina_cnt), + accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "overrun_err:", + le32_to_cpu(ofdm->overrun_err), + accum_ofdm->overrun_err, delta_ofdm->overrun_err, + max_ofdm->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "crc32_good:", le32_to_cpu(ofdm->crc32_good), + accum_ofdm->crc32_good, delta_ofdm->crc32_good, + max_ofdm->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, + delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), + accum_ofdm->sfd_timeout, + delta_ofdm->sfd_timeout, + max_ofdm->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), + accum_ofdm->fina_timeout, + delta_ofdm->fina_timeout, + max_ofdm->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, + delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), + accum_ofdm->sent_ack_cnt, + delta_ofdm->sent_ack_cnt, + max_ofdm->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), + accum_ofdm->sent_cts_cnt, + delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); + + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - CCK:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "overrun_err:", + le32_to_cpu(cck->overrun_err), + accum_cck->overrun_err, + delta_cck->overrun_err, max_cck->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, + max_cck->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, + max_cck->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, + delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, + max_cck->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), + accum_cck->sfd_timeout, + delta_cck->sfd_timeout, max_cck->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_timeout:", + le32_to_cpu(cck->fina_timeout), + accum_cck->fina_timeout, + delta_cck->fina_timeout, max_cck->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, + delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), + accum_cck->sent_ack_cnt, + delta_cck->sent_ack_cnt, + max_cck->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), + accum_cck->sent_cts_cnt, + delta_cck->sent_cts_cnt, + max_cck->sent_cts_cnt); + + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - GENERAL:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bogus_cts:", + le32_to_cpu(general->bogus_cts), + accum_general->bogus_cts, + delta_general->bogus_cts, max_general->bogus_cts); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bogus_ack:", + le32_to_cpu(general->bogus_ack), + accum_general->bogus_ack, + delta_general->bogus_ack, max_general->bogus_ack); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t il3945_ucode_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250; + ssize_t ret; + struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * The statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + tx = &il->_3945.stats.tx; + accum_tx = &il->_3945.accum_stats.tx; + delta_tx = &il->_3945.delta_stats.tx; + max_tx = &il->_3945.max_delta.tx; + pos += il3945_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Tx:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "preamble:", + le32_to_cpu(tx->preamble_cnt), + accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, + delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, + delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, + delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), + accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "ack_timeout:", + le32_to_cpu(tx->ack_timeout), + accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, + delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), + accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, + max_tx->actual_ack_cnt); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t il3945_ucode_general_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300; + ssize_t ret; + struct iwl39_stats_general *general, *accum_general; + struct iwl39_stats_general *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * The statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + general = &il->_3945.stats.general; + dbg = &il->_3945.stats.general.dbg; + div = &il->_3945.stats.general.div; + accum_general = &il->_3945.accum_stats.general; + delta_general = &il->_3945.delta_stats.general; + max_general = &il->_3945.max_delta.general; + accum_dbg = &il->_3945.accum_stats.general.dbg; + delta_dbg = &il->_3945.delta_stats.general.dbg; + max_dbg = &il->_3945.max_delta.general.dbg; + accum_div = &il->_3945.accum_stats.general.div; + delta_div = &il->_3945.delta_stats.general.div; + max_div = &il->_3945.max_delta.general.div; + pos += il3945_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_General:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "burst_check:", + le32_to_cpu(dbg->burst_check), + accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "burst_count:", + le32_to_cpu(dbg->burst_count), + accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, + delta_general->sleep_time, max_general->sleep_time); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "slots_out:", + le32_to_cpu(general->slots_out), + accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, + delta_general->slots_idle, max_general->slots_idle); + pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", + le32_to_cpu(general->ttl_timestamp)); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c new file mode 100644 index 0000000..f84ed5e --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -0,0 +1,996 @@ +/****************************************************************************** + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "iwl-commands.h" +#include "iwl-3945.h" +#include "iwl-sta.h" + +#define RS_NAME "iwl-3945-rs" + +static s32 il3945_expected_tpt_g[RATE_COUNT_3945] = { + 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 +}; + +static s32 il3945_expected_tpt_g_prot[RATE_COUNT_3945] = { + 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 +}; + +static s32 il3945_expected_tpt_a[RATE_COUNT_3945] = { + 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 +}; + +static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { + 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +struct il3945_tpt_entry { + s8 min_rssi; + u8 idx; +}; + +static struct il3945_tpt_entry il3945_tpt_table_a[] = { + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-72, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-87, RATE_9M_IDX}, + {-89, RATE_6M_IDX} +}; + +static struct il3945_tpt_entry il3945_tpt_table_g[] = { + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-68, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-86, RATE_11M_IDX}, + {-88, RATE_5M_IDX}, + {-90, RATE_2M_IDX}, + {-92, RATE_1M_IDX} +}; + +#define RATE_MAX_WINDOW 62 +#define RATE_FLUSH (3*HZ) +#define RATE_WIN_FLUSH (HZ/2) +#define IL39_RATE_HIGH_TH 11520 +#define IL_SUCCESS_UP_TH 8960 +#define IL_SUCCESS_DOWN_TH 10880 +#define RATE_MIN_FAILURE_TH 6 +#define RATE_MIN_SUCCESS_TH 8 +#define RATE_DECREASE_TH 1920 +#define RATE_RETRY_TH 15 + +static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) +{ + u32 idx = 0; + u32 table_size = 0; + struct il3945_tpt_entry *tpt_table = NULL; + + if (rssi < IL_MIN_RSSI_VAL || rssi > IL_MAX_RSSI_VAL) + rssi = IL_MIN_RSSI_VAL; + + switch (band) { + case IEEE80211_BAND_2GHZ: + tpt_table = il3945_tpt_table_g; + table_size = ARRAY_SIZE(il3945_tpt_table_g); + break; + + case IEEE80211_BAND_5GHZ: + tpt_table = il3945_tpt_table_a; + table_size = ARRAY_SIZE(il3945_tpt_table_a); + break; + + default: + BUG(); + break; + } + + while (idx < table_size && rssi < tpt_table[idx].min_rssi) + idx++; + + idx = min(idx, (table_size - 1)); + + return tpt_table[idx].idx; +} + +static void il3945_clear_win(struct il3945_rate_scale_data *win) +{ + win->data = 0; + win->success_counter = 0; + win->success_ratio = -1; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; +} + +/** + * il3945_rate_scale_flush_wins - flush out the rate scale wins + * + * Returns the number of wins that have gathered data but were + * not flushed. If there were any that were not flushed, then + * reschedule the rate flushing routine. + */ +static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) +{ + int unflushed = 0; + int i; + unsigned long flags; + struct il_priv *il __maybe_unused = rs_sta->il; + + /* + * For each rate, if we have collected data on that rate + * and it has been more than RATE_WIN_FLUSH + * since we flushed, clear out the gathered stats + */ + for (i = 0; i < RATE_COUNT_3945; i++) { + if (!rs_sta->win[i].counter) + continue; + + spin_lock_irqsave(&rs_sta->lock, flags); + if (time_after(jiffies, rs_sta->win[i].stamp + + RATE_WIN_FLUSH)) { + D_RATE("flushing %d samples of rate " + "idx %d\n", + rs_sta->win[i].counter, i); + il3945_clear_win(&rs_sta->win[i]); + } else + unflushed++; + spin_unlock_irqrestore(&rs_sta->lock, flags); + } + + return unflushed; +} + +#define RATE_FLUSH_MAX 5000 /* msec */ +#define RATE_FLUSH_MIN 50 /* msec */ +#define IL_AVERAGE_PACKETS 1500 + +static void il3945_bg_rate_scale_flush(unsigned long data) +{ + struct il3945_rs_sta *rs_sta = (void *)data; + struct il_priv *il __maybe_unused = rs_sta->il; + int unflushed = 0; + unsigned long flags; + u32 packet_count, duration, pps; + + D_RATE("enter\n"); + + unflushed = il3945_rate_scale_flush_wins(rs_sta); + + spin_lock_irqsave(&rs_sta->lock, flags); + + /* Number of packets Rx'd since last time this timer ran */ + packet_count = (rs_sta->tx_packets - rs_sta->last_tx_packets) + 1; + + rs_sta->last_tx_packets = rs_sta->tx_packets + 1; + + if (unflushed) { + duration = + jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); + + D_RATE("Tx'd %d packets in %dms\n", + packet_count, duration); + + /* Determine packets per second */ + if (duration) + pps = (packet_count * 1000) / duration; + else + pps = 0; + + if (pps) { + duration = (IL_AVERAGE_PACKETS * 1000) / pps; + if (duration < RATE_FLUSH_MIN) + duration = RATE_FLUSH_MIN; + else if (duration > RATE_FLUSH_MAX) + duration = RATE_FLUSH_MAX; + } else + duration = RATE_FLUSH_MAX; + + rs_sta->flush_time = msecs_to_jiffies(duration); + + D_RATE("new flush period: %d msec ave %d\n", + duration, packet_count); + + mod_timer(&rs_sta->rate_scale_flush, jiffies + + rs_sta->flush_time); + + rs_sta->last_partial_flush = jiffies; + } else { + rs_sta->flush_time = RATE_FLUSH; + rs_sta->flush_pending = 0; + } + /* If there weren't any unflushed entries, we don't schedule the timer + * to run again */ + + rs_sta->last_flush = jiffies; + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + D_RATE("leave\n"); +} + +/** + * il3945_collect_tx_data - Update the success/failure sliding win + * + * We keep a sliding win of the last 64 packets transmitted + * at this rate. win->data contains the bitmask of successful + * packets. + */ +static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, + struct il3945_rate_scale_data *win, + int success, int retries, int idx) +{ + unsigned long flags; + s32 fail_count; + struct il_priv *il __maybe_unused = rs_sta->il; + + if (!retries) { + D_RATE("leave: retries == 0 -- should be at least 1\n"); + return; + } + + spin_lock_irqsave(&rs_sta->lock, flags); + + /* + * Keep track of only the latest 62 tx frame attempts in this rate's + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; + * if the oldest attempt (highest bit in bitmap) shows "success", + * subtract "1" from the success counter (this is the main reason + * we keep these bitmaps!). + * */ + while (retries > 0) { + if (win->counter >= RATE_MAX_WINDOW) { + + /* remove earliest */ + win->counter = RATE_MAX_WINDOW - 1; + + if (win->data & (1ULL << (RATE_MAX_WINDOW - 1))) { + win->data &= ~(1ULL << (RATE_MAX_WINDOW - 1)); + win->success_counter--; + } + } + + /* Increment frames-attempted counter */ + win->counter++; + + /* Shift bitmap by one frame (throw away oldest history), + * OR in "1", and increment "success" if this + * frame was successful. */ + win->data <<= 1; + if (success > 0) { + win->success_counter++; + win->data |= 0x1; + success--; + } + + retries--; + } + + /* Calculate current success ratio, avoid divide-by-0! */ + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; + else + win->success_ratio = IL_INVALID_VALUE; + + fail_count = win->counter - win->success_counter; + + /* Calculate average throughput, if we have enough history. */ + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) + win->average_tpt = ((win->success_ratio * + rs_sta->expected_tpt[idx] + 64) / 128); + else + win->average_tpt = IL_INVALID_VALUE; + + /* Tag this win as having been updated */ + win->stamp = jiffies; + + spin_unlock_irqrestore(&rs_sta->lock, flags); + +} + +/* + * Called after adding a new station to initialize rate scaling + */ +void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) +{ + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; + struct il3945_sta_priv *psta; + struct il3945_rs_sta *rs_sta; + struct ieee80211_supported_band *sband; + int i; + + D_INFO("enter\n"); + if (sta_id == il->ctx.bcast_sta_id) + goto out; + + psta = (struct il3945_sta_priv *) sta->drv_priv; + rs_sta = &psta->rs_sta; + sband = hw->wiphy->bands[conf->channel->band]; + + rs_sta->il = il; + + rs_sta->start_rate = RATE_INVALID; + + /* default to just 802.11b */ + rs_sta->expected_tpt = il3945_expected_tpt_b; + + rs_sta->last_partial_flush = jiffies; + rs_sta->last_flush = jiffies; + rs_sta->flush_time = RATE_FLUSH; + rs_sta->last_tx_packets = 0; + + rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; + rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; + + for (i = 0; i < RATE_COUNT_3945; i++) + il3945_clear_win(&rs_sta->win[i]); + + /* TODO: what is a good starting rate for STA? About middle? Maybe not + * the lowest or the highest rate.. Could consider using RSSI from + * previous packets? Need to have IEEE 802.1X auth succeed immediately + * after assoc.. */ + + for (i = sband->n_bitrates - 1; i >= 0; i--) { + if (sta->supp_rates[sband->band] & (1 << i)) { + rs_sta->last_txrate_idx = i; + break; + } + } + + il->_3945.sta_supp_rates = sta->supp_rates[sband->band]; + /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ + if (sband->band == IEEE80211_BAND_5GHZ) { + rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; + il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << + IL_FIRST_OFDM_RATE; + } + +out: + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + + D_INFO("leave\n"); +} + +static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +{ + return hw->priv; +} + +/* rate scale requires free function to be implemented */ +static void il3945_rs_free(void *il) +{ + return; +} + +static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) +{ + struct il3945_rs_sta *rs_sta; + struct il3945_sta_priv *psta = (void *) sta->drv_priv; + struct il_priv *il __maybe_unused = il_priv; + + D_RATE("enter\n"); + + rs_sta = &psta->rs_sta; + + spin_lock_init(&rs_sta->lock); + init_timer(&rs_sta->rate_scale_flush); + + D_RATE("leave\n"); + + return rs_sta; +} + +static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, + void *il_sta) +{ + struct il3945_rs_sta *rs_sta = il_sta; + + /* + * Be careful not to use any members of il3945_rs_sta (like trying + * to use il_priv to print out debugging) since it may not be fully + * initialized at this point. + */ + del_timer_sync(&rs_sta->rate_scale_flush); +} + + +/** + * il3945_rs_tx_status - Update rate control values based on Tx results + * + * NOTE: Uses il_priv->retry_rate for the # of retries attempted by + * the hardware for each rate. + */ +static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) +{ + s8 retries = 0, current_count; + int scale_rate_idx, first_idx, last_idx; + unsigned long flags; + struct il_priv *il = (struct il_priv *)il_rate; + struct il3945_rs_sta *rs_sta = il_sta; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + + D_RATE("enter\n"); + + retries = info->status.rates[0].count; + /* Sanity Check for retries */ + if (retries > RATE_RETRY_TH) + retries = RATE_RETRY_TH; + + first_idx = sband->bitrates[info->status.rates[0].idx].hw_value; + if (first_idx < 0 || first_idx >= RATE_COUNT_3945) { + D_RATE("leave: Rate out of bounds: %d\n", first_idx); + return; + } + + if (!il_sta) { + D_RATE("leave: No STA il data to update!\n"); + return; + } + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (!rs_sta->il) { + D_RATE("leave: STA il data uninitialized!\n"); + return; + } + + + rs_sta->tx_packets++; + + scale_rate_idx = first_idx; + last_idx = first_idx; + + /* + * Update the win for each rate. We determine which rates + * were Tx'd based on the total number of retries vs. the number + * of retries configured for each rate -- currently set to the + * il value 'retry_rate' vs. rate specific + * + * On exit from this while loop last_idx indicates the rate + * at which the frame was finally transmitted (or failed if no + * ACK) + */ + while (retries > 1) { + if ((retries - 1) < il->retry_rate) { + current_count = (retries - 1); + last_idx = scale_rate_idx; + } else { + current_count = il->retry_rate; + last_idx = il3945_rs_next_rate(il, + scale_rate_idx); + } + + /* Update this rate accounting for as many retries + * as was used for it (per current_count) */ + il3945_collect_tx_data(rs_sta, + &rs_sta->win[scale_rate_idx], + 0, current_count, scale_rate_idx); + D_RATE("Update rate %d for %d retries.\n", + scale_rate_idx, current_count); + + retries -= current_count; + + scale_rate_idx = last_idx; + } + + + /* Update the last idx win with success/failure based on ACK */ + D_RATE("Update rate %d with %s.\n", + last_idx, + (info->flags & IEEE80211_TX_STAT_ACK) ? + "success" : "failure"); + il3945_collect_tx_data(rs_sta, + &rs_sta->win[last_idx], + info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); + + /* We updated the rate scale win -- if its been more than + * flush_time since the last run, schedule the flush + * again */ + spin_lock_irqsave(&rs_sta->lock, flags); + + if (!rs_sta->flush_pending && + time_after(jiffies, rs_sta->last_flush + + rs_sta->flush_time)) { + + rs_sta->last_partial_flush = jiffies; + rs_sta->flush_pending = 1; + mod_timer(&rs_sta->rate_scale_flush, + jiffies + rs_sta->flush_time); + } + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + D_RATE("leave\n"); +} + +static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, + u8 idx, u16 rate_mask, enum ieee80211_band band) +{ + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; + struct il_priv *il __maybe_unused = rs_sta->il; + + /* 802.11A walks to the next literal adjacent rate in + * the rate table */ + if (unlikely(band == IEEE80211_BAND_5GHZ)) { + int i; + u32 mask; + + /* Find the previous rate that is in the rate mask */ + i = idx - 1; + for (mask = (1 << i); i >= 0; i--, mask >>= 1) { + if (rate_mask & mask) { + low = i; + break; + } + } + + /* Find the next rate that is in the rate mask */ + i = idx + 1; + for (mask = (1 << i); i < RATE_COUNT_3945; + i++, mask <<= 1) { + if (rate_mask & mask) { + high = i; + break; + } + } + + return (high << 8) | low; + } + + low = idx; + while (low != RATE_INVALID) { + if (rs_sta->tgg) + low = il3945_rates[low].prev_rs_tgg; + else + low = il3945_rates[low].prev_rs; + if (low == RATE_INVALID) + break; + if (rate_mask & (1 << low)) + break; + D_RATE("Skipping masked lower rate: %d\n", low); + } + + high = idx; + while (high != RATE_INVALID) { + if (rs_sta->tgg) + high = il3945_rates[high].next_rs_tgg; + else + high = il3945_rates[high].next_rs; + if (high == RATE_INVALID) + break; + if (rate_mask & (1 << high)) + break; + D_RATE("Skipping masked higher rate: %d\n", high); + } + + return (high << 8) | low; +} + +/** + * il3945_rs_get_rate - find the rate for the requested packet + * + * Returns the ieee80211_rate structure allocated by the driver. + * + * The rate control algorithm has no internal mapping between hw_mode's + * rate ordering and the rate ordering used by the rate control algorithm. + * + * The rate control algorithm uses a single table of rates that goes across + * the entire A/B/G spectrum vs. being limited to just one particular + * hw_mode. + * + * As such, we can't convert the idx obtained below into the hw_mode's + * rate table and must reference the driver allocated rate table + * + */ +static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, + void *il_sta, struct ieee80211_tx_rate_control *txrc) +{ + struct ieee80211_supported_band *sband = txrc->sband; + struct sk_buff *skb = txrc->skb; + u8 low = RATE_INVALID; + u8 high = RATE_INVALID; + u16 high_low; + int idx; + struct il3945_rs_sta *rs_sta = il_sta; + struct il3945_rate_scale_data *win = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; + u32 fail_count; + s8 scale_action = 0; + unsigned long flags; + u16 rate_mask; + s8 max_rate_idx = -1; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + + D_RATE("enter\n"); + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (rs_sta && !rs_sta->il) { + D_RATE("Rate scaling information not initialized yet.\n"); + il_sta = NULL; + } + + if (rate_control_send_low(sta, il_sta, txrc)) + return; + + rate_mask = sta->supp_rates[sband->band]; + + /* get user max rate if set */ + max_rate_idx = txrc->max_rate_idx; + if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) + max_rate_idx += IL_FIRST_OFDM_RATE; + if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) + max_rate_idx = -1; + + idx = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); + + if (sband->band == IEEE80211_BAND_5GHZ) + rate_mask = rate_mask << IL_FIRST_OFDM_RATE; + + spin_lock_irqsave(&rs_sta->lock, flags); + + /* for recent assoc, choose best rate regarding + * to rssi value + */ + if (rs_sta->start_rate != RATE_INVALID) { + if (rs_sta->start_rate < idx && + (rate_mask & (1 << rs_sta->start_rate))) + idx = rs_sta->start_rate; + rs_sta->start_rate = RATE_INVALID; + } + + /* force user max rate if set by user */ + if (max_rate_idx != -1 && max_rate_idx < idx) { + if (rate_mask & (1 << max_rate_idx)) + idx = max_rate_idx; + } + + win = &(rs_sta->win[idx]); + + fail_count = win->counter - win->success_counter; + + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { + spin_unlock_irqrestore(&rs_sta->lock, flags); + + D_RATE("Invalid average_tpt on rate %d: " + "counter: %d, success_counter: %d, " + "expected_tpt is %sNULL\n", + idx, + win->counter, + win->success_counter, + rs_sta->expected_tpt ? "not " : ""); + + /* Can't calculate this yet; not enough history */ + win->average_tpt = IL_INVALID_VALUE; + goto out; + + } + + current_tpt = win->average_tpt; + + high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, + sband->band); + low = high_low & 0xff; + high = (high_low >> 8) & 0xff; + + /* If user set max rate, dont allow higher than user constrain */ + if (max_rate_idx != -1 && max_rate_idx < high) + high = RATE_INVALID; + + /* Collect Measured throughputs of adjacent rates */ + if (low != RATE_INVALID) + low_tpt = rs_sta->win[low].average_tpt; + + if (high != RATE_INVALID) + high_tpt = rs_sta->win[high].average_tpt; + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + scale_action = 0; + + /* Low success ratio , need to drop the rate */ + if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { + D_RATE("decrease rate because of low success_ratio\n"); + scale_action = -1; + /* No throughput measured yet for adjacent rates, + * try increase */ + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { + + if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) + scale_action = 1; + else if (low != RATE_INVALID) + scale_action = 0; + + /* Both adjacent throughputs are measured, but neither one has + * better throughput; we're using the best rate, don't change + * it! */ + } else if (low_tpt != IL_INVALID_VALUE && + high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) { + + D_RATE("No action -- low [%d] & high [%d] < " + "current_tpt [%d]\n", + low_tpt, high_tpt, current_tpt); + scale_action = 0; + + /* At least one of the rates has better throughput */ + } else { + if (high_tpt != IL_INVALID_VALUE) { + + /* High rate has better throughput, Increase + * rate */ + if (high_tpt > current_tpt && + win->success_ratio >= RATE_INCREASE_TH) + scale_action = 1; + else { + D_RATE( + "decrease rate because of high tpt\n"); + scale_action = 0; + } + } else if (low_tpt != IL_INVALID_VALUE) { + if (low_tpt > current_tpt) { + D_RATE( + "decrease rate because of low tpt\n"); + scale_action = -1; + } else if (win->success_ratio >= RATE_INCREASE_TH) { + /* Lower rate has better + * throughput,decrease rate */ + scale_action = 1; + } + } + } + + /* Sanity check; asked for decrease, but success rate or throughput + * has been good at old rate. Don't change it. */ + if (scale_action == -1 && low != RATE_INVALID && + (win->success_ratio > RATE_HIGH_TH || + current_tpt > 100 * rs_sta->expected_tpt[low])) + scale_action = 0; + + switch (scale_action) { + case -1: + + /* Decrese rate */ + if (low != RATE_INVALID) + idx = low; + break; + + case 1: + /* Increase rate */ + if (high != RATE_INVALID) + idx = high; + + break; + + case 0: + default: + /* No change */ + break; + } + + D_RATE("Selected %d (action %d) - low %d high %d\n", + idx, scale_action, low, high); + + out: + + if (sband->band == IEEE80211_BAND_5GHZ) { + if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) + idx = IL_FIRST_OFDM_RATE; + rs_sta->last_txrate_idx = idx; + info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE; + } else { + rs_sta->last_txrate_idx = idx; + info->control.rates[0].idx = rs_sta->last_txrate_idx; + } + + D_RATE("leave: %d\n", idx); +} + +#ifdef CONFIG_MAC80211_DEBUGFS +static int il3945_open_file_generic(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + char *buff; + int desc = 0; + int j; + ssize_t ret; + struct il3945_rs_sta *lq_sta = file->private_data; + + buff = kmalloc(1024, GFP_KERNEL); + if (!buff) + return -ENOMEM; + + desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" + "rate=0x%X flush time %d\n", + lq_sta->tx_packets, + lq_sta->last_txrate_idx, + lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); + for (j = 0; j < RATE_COUNT_3945; j++) { + desc += sprintf(buff+desc, + "counter=%d success=%d %%=%d\n", + lq_sta->win[j].counter, + lq_sta->win[j].success_counter, + lq_sta->win[j].success_ratio); + } + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + kfree(buff); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_stats_table_ops = { + .read = il3945_sta_dbgfs_stats_table_read, + .open = il3945_open_file_generic, + .llseek = default_llseek, +}; + +static void il3945_add_debugfs(void *il, void *il_sta, + struct dentry *dir) +{ + struct il3945_rs_sta *lq_sta = il_sta; + + lq_sta->rs_sta_dbgfs_stats_table_file = + debugfs_create_file("rate_stats_table", 0600, dir, + lq_sta, &rs_sta_dbgfs_stats_table_ops); + +} + +static void il3945_remove_debugfs(void *il, void *il_sta) +{ + struct il3945_rs_sta *lq_sta = il_sta; + debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); +} +#endif + +/* + * Initialization of rate scaling information is done by driver after + * the station is added. Since mac80211 calls this function before a + * station is added we ignore it. + */ +static void il3945_rs_rate_init_stub(void *il_r, + struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) +{ +} + +static struct rate_control_ops rs_ops = { + .module = NULL, + .name = RS_NAME, + .tx_status = il3945_rs_tx_status, + .get_rate = il3945_rs_get_rate, + .rate_init = il3945_rs_rate_init_stub, + .alloc = il3945_rs_alloc, + .free = il3945_rs_free, + .alloc_sta = il3945_rs_alloc_sta, + .free_sta = il3945_rs_free_sta, +#ifdef CONFIG_MAC80211_DEBUGFS + .add_sta_debugfs = il3945_add_debugfs, + .remove_sta_debugfs = il3945_remove_debugfs, +#endif + +}; +void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) +{ + struct il_priv *il = hw->priv; + s32 rssi = 0; + unsigned long flags; + struct il3945_rs_sta *rs_sta; + struct ieee80211_sta *sta; + struct il3945_sta_priv *psta; + + D_RATE("enter\n"); + + rcu_read_lock(); + + sta = ieee80211_find_sta(il->ctx.vif, + il->stations[sta_id].sta.sta.addr); + if (!sta) { + D_RATE("Unable to find station to initialize rate scaling.\n"); + rcu_read_unlock(); + return; + } + + psta = (void *) sta->drv_priv; + rs_sta = &psta->rs_sta; + + spin_lock_irqsave(&rs_sta->lock, flags); + + rs_sta->tgg = 0; + switch (il->band) { + case IEEE80211_BAND_2GHZ: + /* TODO: this always does G, not a regression */ + if (il->ctx.active.flags & + RXON_FLG_TGG_PROTECT_MSK) { + rs_sta->tgg = 1; + rs_sta->expected_tpt = il3945_expected_tpt_g_prot; + } else + rs_sta->expected_tpt = il3945_expected_tpt_g; + break; + + case IEEE80211_BAND_5GHZ: + rs_sta->expected_tpt = il3945_expected_tpt_a; + break; + case IEEE80211_NUM_BANDS: + BUG(); + break; + } + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + rssi = il->_3945.last_rx_rssi; + if (rssi == 0) + rssi = IL_MIN_RSSI_VAL; + + D_RATE("Network RSSI: %d\n", rssi); + + rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); + + D_RATE("leave: rssi %d assign rate idx: " + "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, + il3945_rates[rs_sta->start_rate].plcp); + rcu_read_unlock(); +} + +int il3945_rate_control_register(void) +{ + return ieee80211_rate_control_register(&rs_ops); +} + +void il3945_rate_control_unregister(void) +{ + ieee80211_rate_control_unregister(&rs_ops); +} diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index b0ffa98..d402496 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -13,7 +13,7 @@ iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += 4965-debug.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o -iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o -iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o +iwl3945-objs := 3945-mac.o 3945.o 3945-rs.o +iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += 3945-debug.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c deleted file mode 100644 index 88b3d8f..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ /dev/null @@ -1,523 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include "iwl-3945-debugfs.h" - - -static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) -{ - int p = 0; - - p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", - le32_to_cpu(il->_3945.stats.flag)); - if (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_CLEAR_MSK) - p += scnprintf(buf + p, bufsz - p, - "\tStatistics have been cleared\n"); - p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); - p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); - return p; -} - -ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + - sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; - ssize_t ret; - struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, - *max_ofdm; - struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct iwl39_stats_rx_non_phy *general, *accum_general; - struct iwl39_stats_rx_non_phy *delta_general, *max_general; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * The statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - ofdm = &il->_3945.stats.rx.ofdm; - cck = &il->_3945.stats.rx.cck; - general = &il->_3945.stats.rx.general; - accum_ofdm = &il->_3945.accum_stats.rx.ofdm; - accum_cck = &il->_3945.accum_stats.rx.cck; - accum_general = &il->_3945.accum_stats.rx.general; - delta_ofdm = &il->_3945.delta_stats.rx.ofdm; - delta_cck = &il->_3945.delta_stats.rx.cck; - delta_general = &il->_3945.delta_stats.rx.general; - max_ofdm = &il->_3945.max_delta.rx.ofdm; - max_cck = &il->_3945.max_delta.rx.cck; - max_general = &il->_3945.max_delta.rx.general; - - pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, - delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, - delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, - delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, - delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); - - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, - delta_cck->overrun_err, max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, - max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, - delta_cck->sfd_timeout, max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, - delta_cck->fina_timeout, max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, - delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, - delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, - delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); - - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, - delta_general->bogus_cts, max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, - delta_general->bogus_ack, max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250; - ssize_t ret; - struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * The statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - tx = &il->_3945.stats.tx; - accum_tx = &il->_3945.accum_stats.tx; - delta_tx = &il->_3945.delta_stats.tx; - max_tx = &il->_3945.max_delta.tx; - pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300; - ssize_t ret; - struct iwl39_stats_general *general, *accum_general; - struct iwl39_stats_general *delta_general, *max_general; - struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * The statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - general = &il->_3945.stats.general; - dbg = &il->_3945.stats.general.dbg; - div = &il->_3945.stats.general.div; - accum_general = &il->_3945.accum_stats.general; - delta_general = &il->_3945.delta_stats.general; - max_general = &il->_3945.max_delta.general; - accum_dbg = &il->_3945.accum_stats.general.dbg; - delta_dbg = &il->_3945.delta_stats.general.dbg; - max_dbg = &il->_3945.max_delta.general.dbg; - accum_div = &il->_3945.accum_stats.general.div; - delta_div = &il->_3945.delta_stats.general.div; - max_div = &il->_3945.max_delta.general.div; - pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c deleted file mode 100644 index f84ed5e..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ /dev/null @@ -1,996 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "iwl-commands.h" -#include "iwl-3945.h" -#include "iwl-sta.h" - -#define RS_NAME "iwl-3945-rs" - -static s32 il3945_expected_tpt_g[RATE_COUNT_3945] = { - 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 -}; - -static s32 il3945_expected_tpt_g_prot[RATE_COUNT_3945] = { - 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 -}; - -static s32 il3945_expected_tpt_a[RATE_COUNT_3945] = { - 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 -}; - -static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { - 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -struct il3945_tpt_entry { - s8 min_rssi; - u8 idx; -}; - -static struct il3945_tpt_entry il3945_tpt_table_a[] = { - {-60, RATE_54M_IDX}, - {-64, RATE_48M_IDX}, - {-72, RATE_36M_IDX}, - {-80, RATE_24M_IDX}, - {-84, RATE_18M_IDX}, - {-85, RATE_12M_IDX}, - {-87, RATE_9M_IDX}, - {-89, RATE_6M_IDX} -}; - -static struct il3945_tpt_entry il3945_tpt_table_g[] = { - {-60, RATE_54M_IDX}, - {-64, RATE_48M_IDX}, - {-68, RATE_36M_IDX}, - {-80, RATE_24M_IDX}, - {-84, RATE_18M_IDX}, - {-85, RATE_12M_IDX}, - {-86, RATE_11M_IDX}, - {-88, RATE_5M_IDX}, - {-90, RATE_2M_IDX}, - {-92, RATE_1M_IDX} -}; - -#define RATE_MAX_WINDOW 62 -#define RATE_FLUSH (3*HZ) -#define RATE_WIN_FLUSH (HZ/2) -#define IL39_RATE_HIGH_TH 11520 -#define IL_SUCCESS_UP_TH 8960 -#define IL_SUCCESS_DOWN_TH 10880 -#define RATE_MIN_FAILURE_TH 6 -#define RATE_MIN_SUCCESS_TH 8 -#define RATE_DECREASE_TH 1920 -#define RATE_RETRY_TH 15 - -static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) -{ - u32 idx = 0; - u32 table_size = 0; - struct il3945_tpt_entry *tpt_table = NULL; - - if (rssi < IL_MIN_RSSI_VAL || rssi > IL_MAX_RSSI_VAL) - rssi = IL_MIN_RSSI_VAL; - - switch (band) { - case IEEE80211_BAND_2GHZ: - tpt_table = il3945_tpt_table_g; - table_size = ARRAY_SIZE(il3945_tpt_table_g); - break; - - case IEEE80211_BAND_5GHZ: - tpt_table = il3945_tpt_table_a; - table_size = ARRAY_SIZE(il3945_tpt_table_a); - break; - - default: - BUG(); - break; - } - - while (idx < table_size && rssi < tpt_table[idx].min_rssi) - idx++; - - idx = min(idx, (table_size - 1)); - - return tpt_table[idx].idx; -} - -static void il3945_clear_win(struct il3945_rate_scale_data *win) -{ - win->data = 0; - win->success_counter = 0; - win->success_ratio = -1; - win->counter = 0; - win->average_tpt = IL_INVALID_VALUE; - win->stamp = 0; -} - -/** - * il3945_rate_scale_flush_wins - flush out the rate scale wins - * - * Returns the number of wins that have gathered data but were - * not flushed. If there were any that were not flushed, then - * reschedule the rate flushing routine. - */ -static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) -{ - int unflushed = 0; - int i; - unsigned long flags; - struct il_priv *il __maybe_unused = rs_sta->il; - - /* - * For each rate, if we have collected data on that rate - * and it has been more than RATE_WIN_FLUSH - * since we flushed, clear out the gathered stats - */ - for (i = 0; i < RATE_COUNT_3945; i++) { - if (!rs_sta->win[i].counter) - continue; - - spin_lock_irqsave(&rs_sta->lock, flags); - if (time_after(jiffies, rs_sta->win[i].stamp + - RATE_WIN_FLUSH)) { - D_RATE("flushing %d samples of rate " - "idx %d\n", - rs_sta->win[i].counter, i); - il3945_clear_win(&rs_sta->win[i]); - } else - unflushed++; - spin_unlock_irqrestore(&rs_sta->lock, flags); - } - - return unflushed; -} - -#define RATE_FLUSH_MAX 5000 /* msec */ -#define RATE_FLUSH_MIN 50 /* msec */ -#define IL_AVERAGE_PACKETS 1500 - -static void il3945_bg_rate_scale_flush(unsigned long data) -{ - struct il3945_rs_sta *rs_sta = (void *)data; - struct il_priv *il __maybe_unused = rs_sta->il; - int unflushed = 0; - unsigned long flags; - u32 packet_count, duration, pps; - - D_RATE("enter\n"); - - unflushed = il3945_rate_scale_flush_wins(rs_sta); - - spin_lock_irqsave(&rs_sta->lock, flags); - - /* Number of packets Rx'd since last time this timer ran */ - packet_count = (rs_sta->tx_packets - rs_sta->last_tx_packets) + 1; - - rs_sta->last_tx_packets = rs_sta->tx_packets + 1; - - if (unflushed) { - duration = - jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - - D_RATE("Tx'd %d packets in %dms\n", - packet_count, duration); - - /* Determine packets per second */ - if (duration) - pps = (packet_count * 1000) / duration; - else - pps = 0; - - if (pps) { - duration = (IL_AVERAGE_PACKETS * 1000) / pps; - if (duration < RATE_FLUSH_MIN) - duration = RATE_FLUSH_MIN; - else if (duration > RATE_FLUSH_MAX) - duration = RATE_FLUSH_MAX; - } else - duration = RATE_FLUSH_MAX; - - rs_sta->flush_time = msecs_to_jiffies(duration); - - D_RATE("new flush period: %d msec ave %d\n", - duration, packet_count); - - mod_timer(&rs_sta->rate_scale_flush, jiffies + - rs_sta->flush_time); - - rs_sta->last_partial_flush = jiffies; - } else { - rs_sta->flush_time = RATE_FLUSH; - rs_sta->flush_pending = 0; - } - /* If there weren't any unflushed entries, we don't schedule the timer - * to run again */ - - rs_sta->last_flush = jiffies; - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - D_RATE("leave\n"); -} - -/** - * il3945_collect_tx_data - Update the success/failure sliding win - * - * We keep a sliding win of the last 64 packets transmitted - * at this rate. win->data contains the bitmask of successful - * packets. - */ -static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, - struct il3945_rate_scale_data *win, - int success, int retries, int idx) -{ - unsigned long flags; - s32 fail_count; - struct il_priv *il __maybe_unused = rs_sta->il; - - if (!retries) { - D_RATE("leave: retries == 0 -- should be at least 1\n"); - return; - } - - spin_lock_irqsave(&rs_sta->lock, flags); - - /* - * Keep track of only the latest 62 tx frame attempts in this rate's - * history win; anything older isn't really relevant any more. - * If we have filled up the sliding win, drop the oldest attempt; - * if the oldest attempt (highest bit in bitmap) shows "success", - * subtract "1" from the success counter (this is the main reason - * we keep these bitmaps!). - * */ - while (retries > 0) { - if (win->counter >= RATE_MAX_WINDOW) { - - /* remove earliest */ - win->counter = RATE_MAX_WINDOW - 1; - - if (win->data & (1ULL << (RATE_MAX_WINDOW - 1))) { - win->data &= ~(1ULL << (RATE_MAX_WINDOW - 1)); - win->success_counter--; - } - } - - /* Increment frames-attempted counter */ - win->counter++; - - /* Shift bitmap by one frame (throw away oldest history), - * OR in "1", and increment "success" if this - * frame was successful. */ - win->data <<= 1; - if (success > 0) { - win->success_counter++; - win->data |= 0x1; - success--; - } - - retries--; - } - - /* Calculate current success ratio, avoid divide-by-0! */ - if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; - else - win->success_ratio = IL_INVALID_VALUE; - - fail_count = win->counter - win->success_counter; - - /* Calculate average throughput, if we have enough history. */ - if (fail_count >= RATE_MIN_FAILURE_TH || - win->success_counter >= RATE_MIN_SUCCESS_TH) - win->average_tpt = ((win->success_ratio * - rs_sta->expected_tpt[idx] + 64) / 128); - else - win->average_tpt = IL_INVALID_VALUE; - - /* Tag this win as having been updated */ - win->stamp = jiffies; - - spin_unlock_irqrestore(&rs_sta->lock, flags); - -} - -/* - * Called after adding a new station to initialize rate scaling - */ -void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) -{ - struct ieee80211_hw *hw = il->hw; - struct ieee80211_conf *conf = &il->hw->conf; - struct il3945_sta_priv *psta; - struct il3945_rs_sta *rs_sta; - struct ieee80211_supported_band *sband; - int i; - - D_INFO("enter\n"); - if (sta_id == il->ctx.bcast_sta_id) - goto out; - - psta = (struct il3945_sta_priv *) sta->drv_priv; - rs_sta = &psta->rs_sta; - sband = hw->wiphy->bands[conf->channel->band]; - - rs_sta->il = il; - - rs_sta->start_rate = RATE_INVALID; - - /* default to just 802.11b */ - rs_sta->expected_tpt = il3945_expected_tpt_b; - - rs_sta->last_partial_flush = jiffies; - rs_sta->last_flush = jiffies; - rs_sta->flush_time = RATE_FLUSH; - rs_sta->last_tx_packets = 0; - - rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; - rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; - - for (i = 0; i < RATE_COUNT_3945; i++) - il3945_clear_win(&rs_sta->win[i]); - - /* TODO: what is a good starting rate for STA? About middle? Maybe not - * the lowest or the highest rate.. Could consider using RSSI from - * previous packets? Need to have IEEE 802.1X auth succeed immediately - * after assoc.. */ - - for (i = sband->n_bitrates - 1; i >= 0; i--) { - if (sta->supp_rates[sband->band] & (1 << i)) { - rs_sta->last_txrate_idx = i; - break; - } - } - - il->_3945.sta_supp_rates = sta->supp_rates[sband->band]; - /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ - if (sband->band == IEEE80211_BAND_5GHZ) { - rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << - IL_FIRST_OFDM_RATE; - } - -out: - il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - - D_INFO("leave\n"); -} - -static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) -{ - return hw->priv; -} - -/* rate scale requires free function to be implemented */ -static void il3945_rs_free(void *il) -{ - return; -} - -static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) -{ - struct il3945_rs_sta *rs_sta; - struct il3945_sta_priv *psta = (void *) sta->drv_priv; - struct il_priv *il __maybe_unused = il_priv; - - D_RATE("enter\n"); - - rs_sta = &psta->rs_sta; - - spin_lock_init(&rs_sta->lock); - init_timer(&rs_sta->rate_scale_flush); - - D_RATE("leave\n"); - - return rs_sta; -} - -static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, - void *il_sta) -{ - struct il3945_rs_sta *rs_sta = il_sta; - - /* - * Be careful not to use any members of il3945_rs_sta (like trying - * to use il_priv to print out debugging) since it may not be fully - * initialized at this point. - */ - del_timer_sync(&rs_sta->rate_scale_flush); -} - - -/** - * il3945_rs_tx_status - Update rate control values based on Tx results - * - * NOTE: Uses il_priv->retry_rate for the # of retries attempted by - * the hardware for each rate. - */ -static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) -{ - s8 retries = 0, current_count; - int scale_rate_idx, first_idx, last_idx; - unsigned long flags; - struct il_priv *il = (struct il_priv *)il_rate; - struct il3945_rs_sta *rs_sta = il_sta; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - - D_RATE("enter\n"); - - retries = info->status.rates[0].count; - /* Sanity Check for retries */ - if (retries > RATE_RETRY_TH) - retries = RATE_RETRY_TH; - - first_idx = sband->bitrates[info->status.rates[0].idx].hw_value; - if (first_idx < 0 || first_idx >= RATE_COUNT_3945) { - D_RATE("leave: Rate out of bounds: %d\n", first_idx); - return; - } - - if (!il_sta) { - D_RATE("leave: No STA il data to update!\n"); - return; - } - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (!rs_sta->il) { - D_RATE("leave: STA il data uninitialized!\n"); - return; - } - - - rs_sta->tx_packets++; - - scale_rate_idx = first_idx; - last_idx = first_idx; - - /* - * Update the win for each rate. We determine which rates - * were Tx'd based on the total number of retries vs. the number - * of retries configured for each rate -- currently set to the - * il value 'retry_rate' vs. rate specific - * - * On exit from this while loop last_idx indicates the rate - * at which the frame was finally transmitted (or failed if no - * ACK) - */ - while (retries > 1) { - if ((retries - 1) < il->retry_rate) { - current_count = (retries - 1); - last_idx = scale_rate_idx; - } else { - current_count = il->retry_rate; - last_idx = il3945_rs_next_rate(il, - scale_rate_idx); - } - - /* Update this rate accounting for as many retries - * as was used for it (per current_count) */ - il3945_collect_tx_data(rs_sta, - &rs_sta->win[scale_rate_idx], - 0, current_count, scale_rate_idx); - D_RATE("Update rate %d for %d retries.\n", - scale_rate_idx, current_count); - - retries -= current_count; - - scale_rate_idx = last_idx; - } - - - /* Update the last idx win with success/failure based on ACK */ - D_RATE("Update rate %d with %s.\n", - last_idx, - (info->flags & IEEE80211_TX_STAT_ACK) ? - "success" : "failure"); - il3945_collect_tx_data(rs_sta, - &rs_sta->win[last_idx], - info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); - - /* We updated the rate scale win -- if its been more than - * flush_time since the last run, schedule the flush - * again */ - spin_lock_irqsave(&rs_sta->lock, flags); - - if (!rs_sta->flush_pending && - time_after(jiffies, rs_sta->last_flush + - rs_sta->flush_time)) { - - rs_sta->last_partial_flush = jiffies; - rs_sta->flush_pending = 1; - mod_timer(&rs_sta->rate_scale_flush, - jiffies + rs_sta->flush_time); - } - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - D_RATE("leave\n"); -} - -static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, - u8 idx, u16 rate_mask, enum ieee80211_band band) -{ - u8 high = RATE_INVALID; - u8 low = RATE_INVALID; - struct il_priv *il __maybe_unused = rs_sta->il; - - /* 802.11A walks to the next literal adjacent rate in - * the rate table */ - if (unlikely(band == IEEE80211_BAND_5GHZ)) { - int i; - u32 mask; - - /* Find the previous rate that is in the rate mask */ - i = idx - 1; - for (mask = (1 << i); i >= 0; i--, mask >>= 1) { - if (rate_mask & mask) { - low = i; - break; - } - } - - /* Find the next rate that is in the rate mask */ - i = idx + 1; - for (mask = (1 << i); i < RATE_COUNT_3945; - i++, mask <<= 1) { - if (rate_mask & mask) { - high = i; - break; - } - } - - return (high << 8) | low; - } - - low = idx; - while (low != RATE_INVALID) { - if (rs_sta->tgg) - low = il3945_rates[low].prev_rs_tgg; - else - low = il3945_rates[low].prev_rs; - if (low == RATE_INVALID) - break; - if (rate_mask & (1 << low)) - break; - D_RATE("Skipping masked lower rate: %d\n", low); - } - - high = idx; - while (high != RATE_INVALID) { - if (rs_sta->tgg) - high = il3945_rates[high].next_rs_tgg; - else - high = il3945_rates[high].next_rs; - if (high == RATE_INVALID) - break; - if (rate_mask & (1 << high)) - break; - D_RATE("Skipping masked higher rate: %d\n", high); - } - - return (high << 8) | low; -} - -/** - * il3945_rs_get_rate - find the rate for the requested packet - * - * Returns the ieee80211_rate structure allocated by the driver. - * - * The rate control algorithm has no internal mapping between hw_mode's - * rate ordering and the rate ordering used by the rate control algorithm. - * - * The rate control algorithm uses a single table of rates that goes across - * the entire A/B/G spectrum vs. being limited to just one particular - * hw_mode. - * - * As such, we can't convert the idx obtained below into the hw_mode's - * rate table and must reference the driver allocated rate table - * - */ -static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, - void *il_sta, struct ieee80211_tx_rate_control *txrc) -{ - struct ieee80211_supported_band *sband = txrc->sband; - struct sk_buff *skb = txrc->skb; - u8 low = RATE_INVALID; - u8 high = RATE_INVALID; - u16 high_low; - int idx; - struct il3945_rs_sta *rs_sta = il_sta; - struct il3945_rate_scale_data *win = NULL; - int current_tpt = IL_INVALID_VALUE; - int low_tpt = IL_INVALID_VALUE; - int high_tpt = IL_INVALID_VALUE; - u32 fail_count; - s8 scale_action = 0; - unsigned long flags; - u16 rate_mask; - s8 max_rate_idx = -1; - struct il_priv *il __maybe_unused = (struct il_priv *)il_r; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - - D_RATE("enter\n"); - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (rs_sta && !rs_sta->il) { - D_RATE("Rate scaling information not initialized yet.\n"); - il_sta = NULL; - } - - if (rate_control_send_low(sta, il_sta, txrc)) - return; - - rate_mask = sta->supp_rates[sband->band]; - - /* get user max rate if set */ - max_rate_idx = txrc->max_rate_idx; - if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) - max_rate_idx += IL_FIRST_OFDM_RATE; - if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) - max_rate_idx = -1; - - idx = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); - - if (sband->band == IEEE80211_BAND_5GHZ) - rate_mask = rate_mask << IL_FIRST_OFDM_RATE; - - spin_lock_irqsave(&rs_sta->lock, flags); - - /* for recent assoc, choose best rate regarding - * to rssi value - */ - if (rs_sta->start_rate != RATE_INVALID) { - if (rs_sta->start_rate < idx && - (rate_mask & (1 << rs_sta->start_rate))) - idx = rs_sta->start_rate; - rs_sta->start_rate = RATE_INVALID; - } - - /* force user max rate if set by user */ - if (max_rate_idx != -1 && max_rate_idx < idx) { - if (rate_mask & (1 << max_rate_idx)) - idx = max_rate_idx; - } - - win = &(rs_sta->win[idx]); - - fail_count = win->counter - win->success_counter; - - if (fail_count < RATE_MIN_FAILURE_TH && - win->success_counter < RATE_MIN_SUCCESS_TH) { - spin_unlock_irqrestore(&rs_sta->lock, flags); - - D_RATE("Invalid average_tpt on rate %d: " - "counter: %d, success_counter: %d, " - "expected_tpt is %sNULL\n", - idx, - win->counter, - win->success_counter, - rs_sta->expected_tpt ? "not " : ""); - - /* Can't calculate this yet; not enough history */ - win->average_tpt = IL_INVALID_VALUE; - goto out; - - } - - current_tpt = win->average_tpt; - - high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, - sband->band); - low = high_low & 0xff; - high = (high_low >> 8) & 0xff; - - /* If user set max rate, dont allow higher than user constrain */ - if (max_rate_idx != -1 && max_rate_idx < high) - high = RATE_INVALID; - - /* Collect Measured throughputs of adjacent rates */ - if (low != RATE_INVALID) - low_tpt = rs_sta->win[low].average_tpt; - - if (high != RATE_INVALID) - high_tpt = rs_sta->win[high].average_tpt; - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - scale_action = 0; - - /* Low success ratio , need to drop the rate */ - if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { - D_RATE("decrease rate because of low success_ratio\n"); - scale_action = -1; - /* No throughput measured yet for adjacent rates, - * try increase */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { - - if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) - scale_action = 1; - else if (low != RATE_INVALID) - scale_action = 0; - - /* Both adjacent throughputs are measured, but neither one has - * better throughput; we're using the best rate, don't change - * it! */ - } else if (low_tpt != IL_INVALID_VALUE && - high_tpt != IL_INVALID_VALUE && - low_tpt < current_tpt && high_tpt < current_tpt) { - - D_RATE("No action -- low [%d] & high [%d] < " - "current_tpt [%d]\n", - low_tpt, high_tpt, current_tpt); - scale_action = 0; - - /* At least one of the rates has better throughput */ - } else { - if (high_tpt != IL_INVALID_VALUE) { - - /* High rate has better throughput, Increase - * rate */ - if (high_tpt > current_tpt && - win->success_ratio >= RATE_INCREASE_TH) - scale_action = 1; - else { - D_RATE( - "decrease rate because of high tpt\n"); - scale_action = 0; - } - } else if (low_tpt != IL_INVALID_VALUE) { - if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); - scale_action = -1; - } else if (win->success_ratio >= RATE_INCREASE_TH) { - /* Lower rate has better - * throughput,decrease rate */ - scale_action = 1; - } - } - } - - /* Sanity check; asked for decrease, but success rate or throughput - * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != RATE_INVALID && - (win->success_ratio > RATE_HIGH_TH || - current_tpt > 100 * rs_sta->expected_tpt[low])) - scale_action = 0; - - switch (scale_action) { - case -1: - - /* Decrese rate */ - if (low != RATE_INVALID) - idx = low; - break; - - case 1: - /* Increase rate */ - if (high != RATE_INVALID) - idx = high; - - break; - - case 0: - default: - /* No change */ - break; - } - - D_RATE("Selected %d (action %d) - low %d high %d\n", - idx, scale_action, low, high); - - out: - - if (sband->band == IEEE80211_BAND_5GHZ) { - if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) - idx = IL_FIRST_OFDM_RATE; - rs_sta->last_txrate_idx = idx; - info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE; - } else { - rs_sta->last_txrate_idx = idx; - info->control.rates[0].idx = rs_sta->last_txrate_idx; - } - - D_RATE("leave: %d\n", idx); -} - -#ifdef CONFIG_MAC80211_DEBUGFS -static int il3945_open_file_generic(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - char *buff; - int desc = 0; - int j; - ssize_t ret; - struct il3945_rs_sta *lq_sta = file->private_data; - - buff = kmalloc(1024, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" - "rate=0x%X flush time %d\n", - lq_sta->tx_packets, - lq_sta->last_txrate_idx, - lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); - for (j = 0; j < RATE_COUNT_3945; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->win[j].counter, - lq_sta->win[j].success_counter, - lq_sta->win[j].success_ratio); - } - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - kfree(buff); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = il3945_sta_dbgfs_stats_table_read, - .open = il3945_open_file_generic, - .llseek = default_llseek, -}; - -static void il3945_add_debugfs(void *il, void *il_sta, - struct dentry *dir) -{ - struct il3945_rs_sta *lq_sta = il_sta; - - lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", 0600, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); - -} - -static void il3945_remove_debugfs(void *il, void *il_sta) -{ - struct il3945_rs_sta *lq_sta = il_sta; - debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); -} -#endif - -/* - * Initialization of rate scaling information is done by driver after - * the station is added. Since mac80211 calls this function before a - * station is added we ignore it. - */ -static void il3945_rs_rate_init_stub(void *il_r, - struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta) -{ -} - -static struct rate_control_ops rs_ops = { - .module = NULL, - .name = RS_NAME, - .tx_status = il3945_rs_tx_status, - .get_rate = il3945_rs_get_rate, - .rate_init = il3945_rs_rate_init_stub, - .alloc = il3945_rs_alloc, - .free = il3945_rs_free, - .alloc_sta = il3945_rs_alloc_sta, - .free_sta = il3945_rs_free_sta, -#ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = il3945_add_debugfs, - .remove_sta_debugfs = il3945_remove_debugfs, -#endif - -}; -void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) -{ - struct il_priv *il = hw->priv; - s32 rssi = 0; - unsigned long flags; - struct il3945_rs_sta *rs_sta; - struct ieee80211_sta *sta; - struct il3945_sta_priv *psta; - - D_RATE("enter\n"); - - rcu_read_lock(); - - sta = ieee80211_find_sta(il->ctx.vif, - il->stations[sta_id].sta.sta.addr); - if (!sta) { - D_RATE("Unable to find station to initialize rate scaling.\n"); - rcu_read_unlock(); - return; - } - - psta = (void *) sta->drv_priv; - rs_sta = &psta->rs_sta; - - spin_lock_irqsave(&rs_sta->lock, flags); - - rs_sta->tgg = 0; - switch (il->band) { - case IEEE80211_BAND_2GHZ: - /* TODO: this always does G, not a regression */ - if (il->ctx.active.flags & - RXON_FLG_TGG_PROTECT_MSK) { - rs_sta->tgg = 1; - rs_sta->expected_tpt = il3945_expected_tpt_g_prot; - } else - rs_sta->expected_tpt = il3945_expected_tpt_g; - break; - - case IEEE80211_BAND_5GHZ: - rs_sta->expected_tpt = il3945_expected_tpt_a; - break; - case IEEE80211_NUM_BANDS: - BUG(); - break; - } - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - rssi = il->_3945.last_rx_rssi; - if (rssi == 0) - rssi = IL_MIN_RSSI_VAL; - - D_RATE("Network RSSI: %d\n", rssi); - - rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); - - D_RATE("leave: rssi %d assign rate idx: " - "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, - il3945_rates[rs_sta->start_rate].plcp); - rcu_read_unlock(); -} - -int il3945_rate_control_register(void) -{ - return ieee80211_rate_control_register(&rs_ops); -} - -void il3945_rate_control_unregister(void) -{ - ieee80211_rate_control_unregister(&rs_ops); -} -- cgit v0.10.2 From 8f29b456f8b2c560819f698b82ef2efc09ac47c5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:57:25 +0100 Subject: iwlegacy: add accidentally removed comments Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index d817d8d..a8a6461 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1411,6 +1411,33 @@ void il4965_reply_stats(struct il_priv *il, il4965_rx_stats(il, rxb); } + +/* + * mac80211 queues, ACs, hardware queues, FIFOs. + * + * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues + * + * Mac80211 uses the following numbers, which we get as from it + * by way of skb_get_queue_mapping(skb): + * + * VO 0 + * VI 1 + * BE 2 + * BK 3 + * + * + * Regular (not A-MPDU) frames are put into hardware queues corresponding + * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their + * own queue per aggregation session (RA/TID combination), such queues are + * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In + * order to map frames to the right queue, we also need an AC->hw queue + * mapping. This is implemented here. + * + * Due to the way hw queues are set up (by the hw specific modules like + * iwl-4965.c), the AC->hw queue mapping is the identity + * mapping. + */ + static const u8 tid_to_ac[] = { IEEE80211_AC_BE, IEEE80211_AC_BK, -- cgit v0.10.2 From af038f404ffb851dcefa0c56c5c81cacd06f0903 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 13:58:27 +0200 Subject: iwlegacy: move iwl-4965-{,hw,debugfs,calib}.h to 4965.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 1d873a6..1d0502e 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -65,7 +65,7 @@ #include "iwl-dev.h" #include "iwl-core.h" -#include "iwl-4965-calib.h" +#include "4965.h" /***************************************************************************** * INIT calibrations framework diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 89e5828..825d0aa 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -25,8 +25,9 @@ * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" +#include "iwl-dev.h" +#include "iwl-core.h" +#include "4965.h" static const char *fmt_value = " %-30s %10u\n"; static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index a8a6461..ee084a8 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -56,8 +56,7 @@ #include "iwl-io.h" #include "iwl-helpers.h" #include "iwl-sta.h" -#include "iwl-4965-calib.h" -#include "iwl-4965.h" +#include "4965.h" /****************************************************************************** @@ -820,6 +819,11 @@ static int il4965_get_channels_for_scan(struct il_priv *il, return added; } +static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) +{ + return BIT(ant_idx) << RATE_MCS_ANT_POS; +} + int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { @@ -1434,7 +1438,7 @@ void il4965_reply_stats(struct il_priv *il, * mapping. This is implemented here. * * Due to the way hw queues are set up (by the hw specific modules like - * iwl-4965.c), the AC->hw queue mapping is the identity + * 4965.c), the AC->hw queue mapping is the identity * mapping. */ diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 4a54311..c4bf4aa 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -38,7 +38,7 @@ #include "iwl-dev.h" #include "iwl-sta.h" #include "iwl-core.h" -#include "iwl-4965.h" +#include "4965.h" #define IL4965_RS_NAME "iwl-4965-rs" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 752564d..8199e63 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -42,10 +42,8 @@ #include "iwl-core.h" #include "iwl-io.h" #include "iwl-helpers.h" -#include "iwl-4965-calib.h" #include "iwl-sta.h" -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" +#include "4965.h" #define IL_AC_UNSET -1 @@ -1829,6 +1827,28 @@ static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; } +static inline u32 il4965_tx_status_to_mac80211(u32 status) +{ + status &= TX_STATUS_MSK; + + switch (status) { + case TX_STATUS_SUCCESS: + case TX_STATUS_DIRECT_DONE: + return IEEE80211_TX_STAT_ACK; + case TX_STATUS_FAIL_DEST_PS: + return IEEE80211_TX_STAT_TX_FILTERED; + default: + return 0; + } +} + +static inline bool il4965_is_tx_success(u32 status) +{ + status &= TX_STATUS_MSK; + return (status == TX_STATUS_SUCCESS || + status == TX_STATUS_DIRECT_DONE); +} + /** * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h new file mode 100644 index 0000000..b1a01c9 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -0,0 +1,1004 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#ifndef __il_4965_h__ +#define __il_4965_h__ + +#include "iwl-fh.h" +#include "iwl-debug.h" + +struct il_rx_queue; +struct il_rx_buf; +struct il_rx_pkt; +struct il_tx_queue; +struct il_rxon_context; + +/* configuration for the _4965 devices */ +extern struct il_cfg il4965_cfg; + +extern struct il_mod_params il4965_mod_params; + +extern struct ieee80211_ops il4965_hw_ops; + +/* tx queue */ +void il4965_free_tfds_in_queue(struct il_priv *il, + int sta_id, int tid, int freed); + +/* RXON */ +void il4965_set_rxon_chain(struct il_priv *il, + struct il_rxon_context *ctx); + +/* uCode */ +int il4965_verify_ucode(struct il_priv *il); + +/* lib */ +void il4965_check_abort_status(struct il_priv *il, + u8 frame_count, u32 status); + +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_hw_nic_init(struct il_priv *il); +int il4965_dump_fh(struct il_priv *il, char **buf, bool display); + +/* rx */ +void il4965_rx_queue_restock(struct il_priv *il); +void il4965_rx_replenish(struct il_priv *il); +void il4965_rx_replenish_now(struct il_priv *il); +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rxq_stop(struct il_priv *il); +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); +void il4965_rx_reply_rx(struct il_priv *il, + struct il_rx_buf *rxb); +void il4965_rx_reply_rx_phy(struct il_priv *il, + struct il_rx_buf *rxb); +void il4965_rx_handle(struct il_priv *il); + +/* tx */ +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad); +int il4965_hw_tx_queue_init(struct il_priv *il, + struct il_tx_queue *txq); +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, + struct ieee80211_tx_info *info); +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 *ssn); +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid); +int il4965_txq_check_empty(struct il_priv *il, + int sta_id, u8 tid, int txq_id); +void il4965_rx_reply_compressed_ba(struct il_priv *il, + struct il_rx_buf *rxb); +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); +void il4965_hw_txq_ctx_free(struct il_priv *il); +int il4965_txq_ctx_alloc(struct il_priv *il); +void il4965_txq_ctx_reset(struct il_priv *il); +void il4965_txq_ctx_stop(struct il_priv *il); +void il4965_txq_set_sched(struct il_priv *il, u32 mask); + +/* + * Acquire il->lock before calling this function ! + */ +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); +/** + * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue + * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed + * @scd_retry: (1) Indicates queue will be used in aggregation mode + * + * NOTE: Acquire il->lock before calling this function ! + */ +void il4965_tx_queue_set_status(struct il_priv *il, + struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry); + +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); + +/* rx */ +void il4965_rx_missed_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb); +bool il4965_good_plcp_health(struct il_priv *il, + struct il_rx_pkt *pkt); +void il4965_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb); +void il4965_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb); + +/* scan */ +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); + +/* station mgmt */ +int il4965_manage_ibss_station(struct il_priv *il, + struct ieee80211_vif *vif, bool add); + +/* hcmd */ +int il4965_send_beacon_cmd(struct il_priv *il); + +#ifdef CONFIG_IWLEGACY_DEBUG +const char *il4965_get_tx_fail_reason(u32 status); +#else +static inline const char * +il4965_get_tx_fail_reason(u32 status) { return ""; } +#endif + +/* station management */ +int il4965_alloc_bcast_station(struct il_priv *il, + struct il_rxon_context *ctx); +int il4965_add_bssid_station(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, u8 *sta_id_r); +int il4965_remove_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key); +int il4965_set_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key); +int il4965_restore_default_wep_keys(struct il_priv *il, + struct il_rxon_context *ctx); +int il4965_set_dynamic_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +int il4965_remove_dynamic_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +void il4965_update_tkip_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, + int sta_id, int tid); +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, + int tid, u16 ssn); +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, + int tid); +void il4965_sta_modify_sleep_tx_count(struct il_priv *il, + int sta_id, int cnt); +int il4965_update_bcast_stations(struct il_priv *il); + +/* rate */ +static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) +{ + return le32_to_cpu(rate_n_flags) & 0xFF; +} + +static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) +{ + return cpu_to_le32(flags|(u32)rate); +} + +/* eeprom */ +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); +int il4965_eeprom_acquire_semaphore(struct il_priv *il); +void il4965_eeprom_release_semaphore(struct il_priv *il); +int il4965_eeprom_check_version(struct il_priv *il); + +/* mac80211 handlers (for 4965) */ +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); +int il4965_mac_start(struct ieee80211_hw *hw); +void il4965_mac_stop(struct ieee80211_hw *hw); +void il4965_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 multicast); +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key); +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, + u32 iv32, u16 *phase1key); +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size); +int il4965_mac_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta); +void il4965_mac_channel_switch(struct ieee80211_hw *hw, + struct ieee80211_channel_switch *ch_switch); + +void il4965_led_enable(struct il_priv *il); + + +/* EEPROM */ +#define IL4965_EEPROM_IMG_SIZE 1024 + +/* + * uCode queue management definitions ... + * The first queue used for block-ack aggregation is #7 (4965 only). + * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. + */ +#define IL49_FIRST_AMPDU_QUEUE 7 + +/* Sizes and addresses for instruction and data memory (SRAM) in + * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ +#define IL49_RTC_INST_LOWER_BOUND (0x000000) +#define IL49_RTC_INST_UPPER_BOUND (0x018000) + +#define IL49_RTC_DATA_LOWER_BOUND (0x800000) +#define IL49_RTC_DATA_UPPER_BOUND (0x80A000) + +#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \ + IL49_RTC_INST_LOWER_BOUND) +#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \ + IL49_RTC_DATA_LOWER_BOUND) + +#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE +#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE + +/* Size of uCode instruction memory in bootstrap state machine */ +#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE + +static inline int il4965_hw_valid_rtc_data_addr(u32 addr) +{ + return (addr >= IL49_RTC_DATA_LOWER_BOUND && + addr < IL49_RTC_DATA_UPPER_BOUND); +} + +/********************* START TEMPERATURE *************************************/ + +/** + * 4965 temperature calculation. + * + * The driver must calculate the device temperature before calculating + * a txpower setting (amplifier gain is temperature dependent). The + * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration + * values used for the life of the driver, and one of which (R4) is the + * real-time temperature indicator. + * + * uCode provides all 4 values to the driver via the "initialize alive" + * notification (see struct il4965_init_alive_resp). After the runtime uCode + * image loads, uCode updates the R4 value via stats notifications + * (see STATISTICS_NOTIFICATION), which occur after each received beacon + * when associated, or can be requested via REPLY_STATISTICS_CMD. + * + * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver + * must sign-extend to 32 bits before applying formula below. + * + * Formula: + * + * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 + * + * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is + * an additional correction, which should be centered around 0 degrees + * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for + * centering the 97/100 correction around 0 degrees K. + * + * Add 273 to Kelvin value to find degrees Celsius, for comparing current + * temperature with factory-measured temperatures when calculating txpower + * settings. + */ +#define TEMPERATURE_CALIB_KELVIN_OFFSET 8 +#define TEMPERATURE_CALIB_A_VAL 259 + +/* Limit range of calculated temperature to be between these Kelvin values */ +#define IL_TX_POWER_TEMPERATURE_MIN (263) +#define IL_TX_POWER_TEMPERATURE_MAX (410) + +#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ + ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ + (t) > IL_TX_POWER_TEMPERATURE_MAX) + +/********************* END TEMPERATURE ***************************************/ + +/********************* START TXPOWER *****************************************/ + +/** + * 4965 txpower calculations rely on information from three sources: + * + * 1) EEPROM + * 2) "initialize" alive notification + * 3) stats notifications + * + * EEPROM data consists of: + * + * 1) Regulatory information (max txpower and channel usage flags) is provided + * separately for each channel that can possibly supported by 4965. + * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz + * (legacy) channels. + * + * See struct il4965_eeprom_channel for format, and struct il4965_eeprom + * for locations in EEPROM. + * + * 2) Factory txpower calibration information is provided separately for + * sub-bands of contiguous channels. 2.4GHz has just one sub-band, + * but 5 GHz has several sub-bands. + * + * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. + * + * See struct il4965_eeprom_calib_info (and the tree of structures + * contained within it) for format, and struct il4965_eeprom for + * locations in EEPROM. + * + * "Initialization alive" notification (see struct il4965_init_alive_resp) + * consists of: + * + * 1) Temperature calculation parameters. + * + * 2) Power supply voltage measurement. + * + * 3) Tx gain compensation to balance 2 transmitters for MIMO use. + * + * Statistics notifications deliver: + * + * 1) Current values for temperature param R4. + */ + +/** + * To calculate a txpower setting for a given desired target txpower, channel, + * modulation bit rate, and transmitter chain (4965 has 2 transmitters to + * support MIMO and transmit diversity), driver must do the following: + * + * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. + * Do not exceed regulatory limit; reduce target txpower if necessary. + * + * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), + * 2 transmitters will be used simultaneously; driver must reduce the + * regulatory limit by 3 dB (half-power) for each transmitter, so the + * combined total output of the 2 transmitters is within regulatory limits. + * + * + * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by + * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); + * reduce target txpower if necessary. + * + * Backoff values below are in 1/2 dB units (equivalent to steps in + * txpower gain tables): + * + * OFDM 6 - 36 MBit: 10 steps (5 dB) + * OFDM 48 MBit: 15 steps (7.5 dB) + * OFDM 54 MBit: 17 steps (8.5 dB) + * OFDM 60 MBit: 20 steps (10 dB) + * CCK all rates: 10 steps (5 dB) + * + * Backoff values apply to saturation txpower on a per-transmitter basis; + * when using MIMO (2 transmitters), each transmitter uses the same + * saturation level provided in EEPROM, and the same backoff values; + * no reduction (such as with regulatory txpower limits) is required. + * + * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel + * widths and 40 Mhz (.11n HT40) channel widths; there is no separate + * factory measurement for ht40 channels. + * + * The result of this step is the final target txpower. The rest of + * the steps figure out the proper settings for the device to achieve + * that target txpower. + * + * + * 3) Determine (EEPROM) calibration sub band for the target channel, by + * comparing against first and last channels in each sub band + * (see struct il4965_eeprom_calib_subband_info). + * + * + * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, + * referencing the 2 factory-measured (sample) channels within the sub band. + * + * Interpolation is based on difference between target channel's frequency + * and the sample channels' frequencies. Since channel numbers are based + * on frequency (5 MHz between each channel number), this is equivalent + * to interpolating based on channel number differences. + * + * Note that the sample channels may or may not be the channels at the + * edges of the sub band. The target channel may be "outside" of the + * span of the sampled channels. + * + * Driver may choose the pair (for 2 Tx chains) of measurements (see + * struct il4965_eeprom_calib_ch_info) for which the actual measured + * txpower comes closest to the desired txpower. Usually, though, + * the middle set of measurements is closest to the regulatory limits, + * and is therefore a good choice for all txpower calculations (this + * assumes that high accuracy is needed for maximizing legal txpower, + * while lower txpower configurations do not need as much accuracy). + * + * Driver should interpolate both members of the chosen measurement pair, + * i.e. for both Tx chains (radio transmitters), unless the driver knows + * that only one of the chains will be used (e.g. only one tx antenna + * connected, but this should be unusual). The rate scaling algorithm + * switches antennas to find best performance, so both Tx chains will + * be used (although only one at a time) even for non-MIMO transmissions. + * + * Driver should interpolate factory values for temperature, gain table + * idx, and actual power. The power amplifier detector values are + * not used by the driver. + * + * Sanity check: If the target channel happens to be one of the sample + * channels, the results should agree with the sample channel's + * measurements! + * + * + * 5) Find difference between desired txpower and (interpolated) + * factory-measured txpower. Using (interpolated) factory gain table idx + * (shown elsewhere) as a starting point, adjust this idx lower to + * increase txpower, or higher to decrease txpower, until the target + * txpower is reached. Each step in the gain table is 1/2 dB. + * + * For example, if factory measured txpower is 16 dBm, and target txpower + * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower + * by 3 dB. + * + * + * 6) Find difference between current device temperature and (interpolated) + * factory-measured temperature for sub-band. Factory values are in + * degrees Celsius. To calculate current temperature, see comments for + * "4965 temperature calculation". + * + * If current temperature is higher than factory temperature, driver must + * increase gain (lower gain table idx), and vice verse. + * + * Temperature affects gain differently for different channels: + * + * 2.4 GHz all channels: 3.5 degrees per half-dB step + * 5 GHz channels 34-43: 4.5 degrees per half-dB step + * 5 GHz channels >= 44: 4.0 degrees per half-dB step + * + * NOTE: Temperature can increase rapidly when transmitting, especially + * with heavy traffic at high txpowers. Driver should update + * temperature calculations often under these conditions to + * maintain strong txpower in the face of rising temperature. + * + * + * 7) Find difference between current power supply voltage indicator + * (from "initialize alive") and factory-measured power supply voltage + * indicator (EEPROM). + * + * If the current voltage is higher (indicator is lower) than factory + * voltage, gain should be reduced (gain table idx increased) by: + * + * (eeprom - current) / 7 + * + * If the current voltage is lower (indicator is higher) than factory + * voltage, gain should be increased (gain table idx decreased) by: + * + * 2 * (current - eeprom) / 7 + * + * If number of idx steps in either direction turns out to be > 2, + * something is wrong ... just use 0. + * + * NOTE: Voltage compensation is independent of band/channel. + * + * NOTE: "Initialize" uCode measures current voltage, which is assumed + * to be constant after this initial measurement. Voltage + * compensation for txpower (number of steps in gain table) + * may be calculated once and used until the next uCode bootload. + * + * + * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), + * adjust txpower for each transmitter chain, so txpower is balanced + * between the two chains. There are 5 pairs of tx_atten[group][chain] + * values in "initialize alive", one pair for each of 5 channel ranges: + * + * Group 0: 5 GHz channel 34-43 + * Group 1: 5 GHz channel 44-70 + * Group 2: 5 GHz channel 71-124 + * Group 3: 5 GHz channel 125-200 + * Group 4: 2.4 GHz all channels + * + * Add the tx_atten[group][chain] value to the idx for the target chain. + * The values are signed, but are in pairs of 0 and a non-negative number, + * so as to reduce gain (if necessary) of the "hotter" channel. This + * avoids any need to double-check for regulatory compliance after + * this step. + * + * + * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation + * value to the idx: + * + * Hardware rev B: 9 steps (4.5 dB) + * Hardware rev C: 5 steps (2.5 dB) + * + * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, + * bits [3:2], 1 = B, 2 = C. + * + * NOTE: This compensation is in addition to any saturation backoff that + * might have been applied in an earlier step. + * + * + * 10) Select the gain table, based on band (2.4 vs 5 GHz). + * + * Limit the adjusted idx to stay within the table! + * + * + * 11) Read gain table entries for DSP and radio gain, place into appropriate + * location(s) in command (struct il4965_txpowertable_cmd). + */ + +/** + * When MIMO is used (2 transmitters operating simultaneously), driver should + * limit each transmitter to deliver a max of 3 dB below the regulatory limit + * for the device. That is, use half power for each transmitter, so total + * txpower is within regulatory limits. + * + * The value "6" represents number of steps in gain table to reduce power 3 dB. + * Each step is 1/2 dB. + */ +#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) + +/** + * CCK gain compensation. + * + * When calculating txpowers for CCK, after making sure that the target power + * is within regulatory and saturation limits, driver must additionally + * back off gain by adding these values to the gain table idx. + * + * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, + * bits [3:2], 1 = B, 2 = C. + */ +#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9) +#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5) + +/* + * 4965 power supply voltage compensation for txpower + */ +#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7) + +/** + * Gain tables. + * + * The following tables contain pair of values for setting txpower, i.e. + * gain settings for the output of the device's digital signal processor (DSP), + * and for the analog gain structure of the transmitter. + * + * Each entry in the gain tables represents a step of 1/2 dB. Note that these + * are *relative* steps, not indications of absolute output power. Output + * power varies with temperature, voltage, and channel frequency, and also + * requires consideration of average power (to satisfy regulatory constraints), + * and peak power (to avoid distortion of the output signal). + * + * Each entry contains two values: + * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained + * linear value that multiplies the output of the digital signal processor, + * before being sent to the analog radio. + * 2) Radio gain. This sets the analog gain of the radio Tx path. + * It is a coarser setting, and behaves in a logarithmic (dB) fashion. + * + * EEPROM contains factory calibration data for txpower. This maps actual + * measured txpower levels to gain settings in the "well known" tables + * below ("well-known" means here that both factory calibration *and* the + * driver work with the same table). + * + * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table + * has an extension (into negative idxes), in case the driver needs to + * boost power setting for high device temperatures (higher than would be + * present during factory calibration). A 5 Ghz EEPROM idx of "40" + * corresponds to the 49th entry in the table used by the driver. + */ +#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ +#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ + +/** + * 2.4 GHz gain table + * + * Index Dsp gain Radio gain + * 0 110 0x3f (highest gain) + * 1 104 0x3f + * 2 98 0x3f + * 3 110 0x3e + * 4 104 0x3e + * 5 98 0x3e + * 6 110 0x3d + * 7 104 0x3d + * 8 98 0x3d + * 9 110 0x3c + * 10 104 0x3c + * 11 98 0x3c + * 12 110 0x3b + * 13 104 0x3b + * 14 98 0x3b + * 15 110 0x3a + * 16 104 0x3a + * 17 98 0x3a + * 18 110 0x39 + * 19 104 0x39 + * 20 98 0x39 + * 21 110 0x38 + * 22 104 0x38 + * 23 98 0x38 + * 24 110 0x37 + * 25 104 0x37 + * 26 98 0x37 + * 27 110 0x36 + * 28 104 0x36 + * 29 98 0x36 + * 30 110 0x35 + * 31 104 0x35 + * 32 98 0x35 + * 33 110 0x34 + * 34 104 0x34 + * 35 98 0x34 + * 36 110 0x33 + * 37 104 0x33 + * 38 98 0x33 + * 39 110 0x32 + * 40 104 0x32 + * 41 98 0x32 + * 42 110 0x31 + * 43 104 0x31 + * 44 98 0x31 + * 45 110 0x30 + * 46 104 0x30 + * 47 98 0x30 + * 48 110 0x6 + * 49 104 0x6 + * 50 98 0x6 + * 51 110 0x5 + * 52 104 0x5 + * 53 98 0x5 + * 54 110 0x4 + * 55 104 0x4 + * 56 98 0x4 + * 57 110 0x3 + * 58 104 0x3 + * 59 98 0x3 + * 60 110 0x2 + * 61 104 0x2 + * 62 98 0x2 + * 63 110 0x1 + * 64 104 0x1 + * 65 98 0x1 + * 66 110 0x0 + * 67 104 0x0 + * 68 98 0x0 + * 69 97 0 + * 70 96 0 + * 71 95 0 + * 72 94 0 + * 73 93 0 + * 74 92 0 + * 75 91 0 + * 76 90 0 + * 77 89 0 + * 78 88 0 + * 79 87 0 + * 80 86 0 + * 81 85 0 + * 82 84 0 + * 83 83 0 + * 84 82 0 + * 85 81 0 + * 86 80 0 + * 87 79 0 + * 88 78 0 + * 89 77 0 + * 90 76 0 + * 91 75 0 + * 92 74 0 + * 93 73 0 + * 94 72 0 + * 95 71 0 + * 96 70 0 + * 97 69 0 + * 98 68 0 + */ + +/** + * 5 GHz gain table + * + * Index Dsp gain Radio gain + * -9 123 0x3F (highest gain) + * -8 117 0x3F + * -7 110 0x3F + * -6 104 0x3F + * -5 98 0x3F + * -4 110 0x3E + * -3 104 0x3E + * -2 98 0x3E + * -1 110 0x3D + * 0 104 0x3D + * 1 98 0x3D + * 2 110 0x3C + * 3 104 0x3C + * 4 98 0x3C + * 5 110 0x3B + * 6 104 0x3B + * 7 98 0x3B + * 8 110 0x3A + * 9 104 0x3A + * 10 98 0x3A + * 11 110 0x39 + * 12 104 0x39 + * 13 98 0x39 + * 14 110 0x38 + * 15 104 0x38 + * 16 98 0x38 + * 17 110 0x37 + * 18 104 0x37 + * 19 98 0x37 + * 20 110 0x36 + * 21 104 0x36 + * 22 98 0x36 + * 23 110 0x35 + * 24 104 0x35 + * 25 98 0x35 + * 26 110 0x34 + * 27 104 0x34 + * 28 98 0x34 + * 29 110 0x33 + * 30 104 0x33 + * 31 98 0x33 + * 32 110 0x32 + * 33 104 0x32 + * 34 98 0x32 + * 35 110 0x31 + * 36 104 0x31 + * 37 98 0x31 + * 38 110 0x30 + * 39 104 0x30 + * 40 98 0x30 + * 41 110 0x25 + * 42 104 0x25 + * 43 98 0x25 + * 44 110 0x24 + * 45 104 0x24 + * 46 98 0x24 + * 47 110 0x23 + * 48 104 0x23 + * 49 98 0x23 + * 50 110 0x22 + * 51 104 0x18 + * 52 98 0x18 + * 53 110 0x17 + * 54 104 0x17 + * 55 98 0x17 + * 56 110 0x16 + * 57 104 0x16 + * 58 98 0x16 + * 59 110 0x15 + * 60 104 0x15 + * 61 98 0x15 + * 62 110 0x14 + * 63 104 0x14 + * 64 98 0x14 + * 65 110 0x13 + * 66 104 0x13 + * 67 98 0x13 + * 68 110 0x12 + * 69 104 0x08 + * 70 98 0x08 + * 71 110 0x07 + * 72 104 0x07 + * 73 98 0x07 + * 74 110 0x06 + * 75 104 0x06 + * 76 98 0x06 + * 77 110 0x05 + * 78 104 0x05 + * 79 98 0x05 + * 80 110 0x04 + * 81 104 0x04 + * 82 98 0x04 + * 83 110 0x03 + * 84 104 0x03 + * 85 98 0x03 + * 86 110 0x02 + * 87 104 0x02 + * 88 98 0x02 + * 89 110 0x01 + * 90 104 0x01 + * 91 98 0x01 + * 92 110 0x00 + * 93 104 0x00 + * 94 98 0x00 + * 95 93 0x00 + * 96 88 0x00 + * 97 83 0x00 + * 98 78 0x00 + */ + + +/** + * Sanity checks and default values for EEPROM regulatory levels. + * If EEPROM values fall outside MIN/MAX range, use default values. + * + * Regulatory limits refer to the maximum average txpower allowed by + * regulatory agencies in the geographies in which the device is meant + * to be operated. These limits are SKU-specific (i.e. geography-specific), + * and channel-specific; each channel has an individual regulatory limit + * listed in the EEPROM. + * + * Units are in half-dBm (i.e. "34" means 17 dBm). + */ +#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34) +#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34) +#define IL_TX_POWER_REGULATORY_MIN (0) +#define IL_TX_POWER_REGULATORY_MAX (34) + +/** + * Sanity checks and default values for EEPROM saturation levels. + * If EEPROM values fall outside MIN/MAX range, use default values. + * + * Saturation is the highest level that the output power amplifier can produce + * without significant clipping distortion. This is a "peak" power level. + * Different types of modulation (i.e. various "rates", and OFDM vs. CCK) + * require differing amounts of backoff, relative to their average power output, + * in order to avoid clipping distortion. + * + * Driver must make sure that it is violating neither the saturation limit, + * nor the regulatory limit, when calculating Tx power settings for various + * rates. + * + * Units are in half-dBm (i.e. "38" means 19 dBm). + */ +#define IL_TX_POWER_DEFAULT_SATURATION_24 (38) +#define IL_TX_POWER_DEFAULT_SATURATION_52 (38) +#define IL_TX_POWER_SATURATION_MIN (20) +#define IL_TX_POWER_SATURATION_MAX (50) + +/** + * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) + * and thermal Txpower calibration. + * + * When calculating txpower, driver must compensate for current device + * temperature; higher temperature requires higher gain. Driver must calculate + * current temperature (see "4965 temperature calculation"), then compare vs. + * factory calibration temperature in EEPROM; if current temperature is higher + * than factory temperature, driver must *increase* gain by proportions shown + * in table below. If current temperature is lower than factory, driver must + * *decrease* gain. + * + * Different frequency ranges require different compensation, as shown below. + */ +/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR1_FCH 34 +#define CALIB_IL_TX_ATTEN_GR1_LCH 43 + +/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR2_FCH 44 +#define CALIB_IL_TX_ATTEN_GR2_LCH 70 + +/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR3_FCH 71 +#define CALIB_IL_TX_ATTEN_GR3_LCH 124 + +/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR4_FCH 125 +#define CALIB_IL_TX_ATTEN_GR4_LCH 200 + +/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR5_FCH 1 +#define CALIB_IL_TX_ATTEN_GR5_LCH 20 + +enum { + CALIB_CH_GROUP_1 = 0, + CALIB_CH_GROUP_2 = 1, + CALIB_CH_GROUP_3 = 2, + CALIB_CH_GROUP_4 = 3, + CALIB_CH_GROUP_5 = 4, + CALIB_CH_GROUP_MAX +}; + +/********************* END TXPOWER *****************************************/ + + +/** + * Tx/Rx Queues + * + * Most communication between driver and 4965 is via queues of data buffers. + * For example, all commands that the driver issues to device's embedded + * controller (uCode) are via the command queue (one of the Tx queues). All + * uCode command responses/replies/notifications, including Rx frames, are + * conveyed from uCode to driver via the Rx queue. + * + * Most support for these queues, including handshake support, resides in + * structures in host DRAM, shared between the driver and the device. When + * allocating this memory, the driver must make sure that data written by + * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's + * cache memory), so DRAM and cache are consistent, and the device can + * immediately see changes made by the driver. + * + * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via + * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array + * in DRAM containing 256 Transmit Frame Descriptors (TFDs). + */ +#define IL49_NUM_FIFOS 7 +#define IL49_CMD_FIFO_NUM 4 +#define IL49_NUM_QUEUES 16 +#define IL49_NUM_AMPDU_QUEUES 8 + + +/** + * struct il4965_schedq_bc_tbl + * + * Byte Count table + * + * Each Tx queue uses a byte-count table containing 320 entries: + * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that + * duplicate the first 64 entries (to avoid wrap-around within a Tx win; + * max Tx win is 64 TFDs). + * + * When driver sets up a new TFD, it must also enter the total byte count + * of the frame to be transmitted into the corresponding entry in the byte + * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver + * must duplicate the byte count entry in corresponding idx 256-319. + * + * padding puts each byte count table on a 1024-byte boundary; + * 4965 assumes tables are separated by 1024 bytes. + */ +struct il4965_scd_bc_tbl { + __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; + u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; +} __packed; + + +#define IL4965_RTC_INST_LOWER_BOUND (0x000000) + +/* RSSI to dBm */ +#define IL4965_RSSI_OFFSET 44 + +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 + +/* PCI register values */ +#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 +#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 + +#define IL4965_DEFAULT_TX_RETRY 15 + +/* EEPROM */ +#define IL4965_FIRST_AMPDU_QUEUE 10 + +/* Calibration */ +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp); +void il4965_sensitivity_calibration(struct il_priv *il, void *resp); +void il4965_init_sensitivity(struct il_priv *il); +void il4965_reset_run_time_calib(struct il_priv *il); +void il4965_calib_free_results(struct il_priv *il); + +/* Debug */ +#ifdef CONFIG_IWLEGACY_DEBUGFS +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il4965_ucode_general_stats_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos); +#else +static ssize_t +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +static ssize_t +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +static ssize_t +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +#endif + +#endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h deleted file mode 100644 index 0e30ea7..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ -#ifndef __il_4965_calib_h__ -#define __il_4965_calib_h__ - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-commands.h" - -void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp); -void il4965_sensitivity_calibration(struct il_priv *il, void *resp); -void il4965_init_sensitivity(struct il_priv *il); -void il4965_reset_run_time_calib(struct il_priv *il); -void il4965_calib_free_results(struct il_priv *il); - -#endif /* __il_4965_calib_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h deleted file mode 100644 index 284604c..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" - -#ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il4965_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos); -#else -static ssize_t -il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -static ssize_t -il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -static ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h deleted file mode 100644 index 5c8b8ba..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ /dev/null @@ -1,811 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Please use this file (iwl-4965-hw.h) only for hardware-related definitions. - * Use iwl-commands.h for uCode API definitions. - * Use iwl-dev.h for driver implementation definitions. - */ - -#ifndef __il_4965_hw_h__ -#define __il_4965_hw_h__ - -#include "iwl-fh.h" - -/* EEPROM */ -#define IL4965_EEPROM_IMG_SIZE 1024 - -/* - * uCode queue management definitions ... - * The first queue used for block-ack aggregation is #7 (4965 only). - * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. - */ -#define IL49_FIRST_AMPDU_QUEUE 7 - -/* Sizes and addresses for instruction and data memory (SRAM) in - * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IL49_RTC_INST_LOWER_BOUND (0x000000) -#define IL49_RTC_INST_UPPER_BOUND (0x018000) - -#define IL49_RTC_DATA_LOWER_BOUND (0x800000) -#define IL49_RTC_DATA_UPPER_BOUND (0x80A000) - -#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \ - IL49_RTC_INST_LOWER_BOUND) -#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \ - IL49_RTC_DATA_LOWER_BOUND) - -#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE -#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE - -/* Size of uCode instruction memory in bootstrap state machine */ -#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE - -static inline int il4965_hw_valid_rtc_data_addr(u32 addr) -{ - return (addr >= IL49_RTC_DATA_LOWER_BOUND && - addr < IL49_RTC_DATA_UPPER_BOUND); -} - -/********************* START TEMPERATURE *************************************/ - -/** - * 4965 temperature calculation. - * - * The driver must calculate the device temperature before calculating - * a txpower setting (amplifier gain is temperature dependent). The - * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration - * values used for the life of the driver, and one of which (R4) is the - * real-time temperature indicator. - * - * uCode provides all 4 values to the driver via the "initialize alive" - * notification (see struct il4965_init_alive_resp). After the runtime uCode - * image loads, uCode updates the R4 value via stats notifications - * (see STATISTICS_NOTIFICATION), which occur after each received beacon - * when associated, or can be requested via REPLY_STATISTICS_CMD. - * - * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver - * must sign-extend to 32 bits before applying formula below. - * - * Formula: - * - * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 - * - * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is - * an additional correction, which should be centered around 0 degrees - * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for - * centering the 97/100 correction around 0 degrees K. - * - * Add 273 to Kelvin value to find degrees Celsius, for comparing current - * temperature with factory-measured temperatures when calculating txpower - * settings. - */ -#define TEMPERATURE_CALIB_KELVIN_OFFSET 8 -#define TEMPERATURE_CALIB_A_VAL 259 - -/* Limit range of calculated temperature to be between these Kelvin values */ -#define IL_TX_POWER_TEMPERATURE_MIN (263) -#define IL_TX_POWER_TEMPERATURE_MAX (410) - -#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ - ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ - (t) > IL_TX_POWER_TEMPERATURE_MAX) - -/********************* END TEMPERATURE ***************************************/ - -/********************* START TXPOWER *****************************************/ - -/** - * 4965 txpower calculations rely on information from three sources: - * - * 1) EEPROM - * 2) "initialize" alive notification - * 3) stats notifications - * - * EEPROM data consists of: - * - * 1) Regulatory information (max txpower and channel usage flags) is provided - * separately for each channel that can possibly supported by 4965. - * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz - * (legacy) channels. - * - * See struct il4965_eeprom_channel for format, and struct il4965_eeprom - * for locations in EEPROM. - * - * 2) Factory txpower calibration information is provided separately for - * sub-bands of contiguous channels. 2.4GHz has just one sub-band, - * but 5 GHz has several sub-bands. - * - * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. - * - * See struct il4965_eeprom_calib_info (and the tree of structures - * contained within it) for format, and struct il4965_eeprom for - * locations in EEPROM. - * - * "Initialization alive" notification (see struct il4965_init_alive_resp) - * consists of: - * - * 1) Temperature calculation parameters. - * - * 2) Power supply voltage measurement. - * - * 3) Tx gain compensation to balance 2 transmitters for MIMO use. - * - * Statistics notifications deliver: - * - * 1) Current values for temperature param R4. - */ - -/** - * To calculate a txpower setting for a given desired target txpower, channel, - * modulation bit rate, and transmitter chain (4965 has 2 transmitters to - * support MIMO and transmit diversity), driver must do the following: - * - * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. - * Do not exceed regulatory limit; reduce target txpower if necessary. - * - * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), - * 2 transmitters will be used simultaneously; driver must reduce the - * regulatory limit by 3 dB (half-power) for each transmitter, so the - * combined total output of the 2 transmitters is within regulatory limits. - * - * - * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by - * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); - * reduce target txpower if necessary. - * - * Backoff values below are in 1/2 dB units (equivalent to steps in - * txpower gain tables): - * - * OFDM 6 - 36 MBit: 10 steps (5 dB) - * OFDM 48 MBit: 15 steps (7.5 dB) - * OFDM 54 MBit: 17 steps (8.5 dB) - * OFDM 60 MBit: 20 steps (10 dB) - * CCK all rates: 10 steps (5 dB) - * - * Backoff values apply to saturation txpower on a per-transmitter basis; - * when using MIMO (2 transmitters), each transmitter uses the same - * saturation level provided in EEPROM, and the same backoff values; - * no reduction (such as with regulatory txpower limits) is required. - * - * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel - * widths and 40 Mhz (.11n HT40) channel widths; there is no separate - * factory measurement for ht40 channels. - * - * The result of this step is the final target txpower. The rest of - * the steps figure out the proper settings for the device to achieve - * that target txpower. - * - * - * 3) Determine (EEPROM) calibration sub band for the target channel, by - * comparing against first and last channels in each sub band - * (see struct il4965_eeprom_calib_subband_info). - * - * - * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, - * referencing the 2 factory-measured (sample) channels within the sub band. - * - * Interpolation is based on difference between target channel's frequency - * and the sample channels' frequencies. Since channel numbers are based - * on frequency (5 MHz between each channel number), this is equivalent - * to interpolating based on channel number differences. - * - * Note that the sample channels may or may not be the channels at the - * edges of the sub band. The target channel may be "outside" of the - * span of the sampled channels. - * - * Driver may choose the pair (for 2 Tx chains) of measurements (see - * struct il4965_eeprom_calib_ch_info) for which the actual measured - * txpower comes closest to the desired txpower. Usually, though, - * the middle set of measurements is closest to the regulatory limits, - * and is therefore a good choice for all txpower calculations (this - * assumes that high accuracy is needed for maximizing legal txpower, - * while lower txpower configurations do not need as much accuracy). - * - * Driver should interpolate both members of the chosen measurement pair, - * i.e. for both Tx chains (radio transmitters), unless the driver knows - * that only one of the chains will be used (e.g. only one tx antenna - * connected, but this should be unusual). The rate scaling algorithm - * switches antennas to find best performance, so both Tx chains will - * be used (although only one at a time) even for non-MIMO transmissions. - * - * Driver should interpolate factory values for temperature, gain table - * idx, and actual power. The power amplifier detector values are - * not used by the driver. - * - * Sanity check: If the target channel happens to be one of the sample - * channels, the results should agree with the sample channel's - * measurements! - * - * - * 5) Find difference between desired txpower and (interpolated) - * factory-measured txpower. Using (interpolated) factory gain table idx - * (shown elsewhere) as a starting point, adjust this idx lower to - * increase txpower, or higher to decrease txpower, until the target - * txpower is reached. Each step in the gain table is 1/2 dB. - * - * For example, if factory measured txpower is 16 dBm, and target txpower - * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower - * by 3 dB. - * - * - * 6) Find difference between current device temperature and (interpolated) - * factory-measured temperature for sub-band. Factory values are in - * degrees Celsius. To calculate current temperature, see comments for - * "4965 temperature calculation". - * - * If current temperature is higher than factory temperature, driver must - * increase gain (lower gain table idx), and vice verse. - * - * Temperature affects gain differently for different channels: - * - * 2.4 GHz all channels: 3.5 degrees per half-dB step - * 5 GHz channels 34-43: 4.5 degrees per half-dB step - * 5 GHz channels >= 44: 4.0 degrees per half-dB step - * - * NOTE: Temperature can increase rapidly when transmitting, especially - * with heavy traffic at high txpowers. Driver should update - * temperature calculations often under these conditions to - * maintain strong txpower in the face of rising temperature. - * - * - * 7) Find difference between current power supply voltage indicator - * (from "initialize alive") and factory-measured power supply voltage - * indicator (EEPROM). - * - * If the current voltage is higher (indicator is lower) than factory - * voltage, gain should be reduced (gain table idx increased) by: - * - * (eeprom - current) / 7 - * - * If the current voltage is lower (indicator is higher) than factory - * voltage, gain should be increased (gain table idx decreased) by: - * - * 2 * (current - eeprom) / 7 - * - * If number of idx steps in either direction turns out to be > 2, - * something is wrong ... just use 0. - * - * NOTE: Voltage compensation is independent of band/channel. - * - * NOTE: "Initialize" uCode measures current voltage, which is assumed - * to be constant after this initial measurement. Voltage - * compensation for txpower (number of steps in gain table) - * may be calculated once and used until the next uCode bootload. - * - * - * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), - * adjust txpower for each transmitter chain, so txpower is balanced - * between the two chains. There are 5 pairs of tx_atten[group][chain] - * values in "initialize alive", one pair for each of 5 channel ranges: - * - * Group 0: 5 GHz channel 34-43 - * Group 1: 5 GHz channel 44-70 - * Group 2: 5 GHz channel 71-124 - * Group 3: 5 GHz channel 125-200 - * Group 4: 2.4 GHz all channels - * - * Add the tx_atten[group][chain] value to the idx for the target chain. - * The values are signed, but are in pairs of 0 and a non-negative number, - * so as to reduce gain (if necessary) of the "hotter" channel. This - * avoids any need to double-check for regulatory compliance after - * this step. - * - * - * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation - * value to the idx: - * - * Hardware rev B: 9 steps (4.5 dB) - * Hardware rev C: 5 steps (2.5 dB) - * - * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, - * bits [3:2], 1 = B, 2 = C. - * - * NOTE: This compensation is in addition to any saturation backoff that - * might have been applied in an earlier step. - * - * - * 10) Select the gain table, based on band (2.4 vs 5 GHz). - * - * Limit the adjusted idx to stay within the table! - * - * - * 11) Read gain table entries for DSP and radio gain, place into appropriate - * location(s) in command (struct il4965_txpowertable_cmd). - */ - -/** - * When MIMO is used (2 transmitters operating simultaneously), driver should - * limit each transmitter to deliver a max of 3 dB below the regulatory limit - * for the device. That is, use half power for each transmitter, so total - * txpower is within regulatory limits. - * - * The value "6" represents number of steps in gain table to reduce power 3 dB. - * Each step is 1/2 dB. - */ -#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) - -/** - * CCK gain compensation. - * - * When calculating txpowers for CCK, after making sure that the target power - * is within regulatory and saturation limits, driver must additionally - * back off gain by adding these values to the gain table idx. - * - * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, - * bits [3:2], 1 = B, 2 = C. - */ -#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9) -#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5) - -/* - * 4965 power supply voltage compensation for txpower - */ -#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7) - -/** - * Gain tables. - * - * The following tables contain pair of values for setting txpower, i.e. - * gain settings for the output of the device's digital signal processor (DSP), - * and for the analog gain structure of the transmitter. - * - * Each entry in the gain tables represents a step of 1/2 dB. Note that these - * are *relative* steps, not indications of absolute output power. Output - * power varies with temperature, voltage, and channel frequency, and also - * requires consideration of average power (to satisfy regulatory constraints), - * and peak power (to avoid distortion of the output signal). - * - * Each entry contains two values: - * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained - * linear value that multiplies the output of the digital signal processor, - * before being sent to the analog radio. - * 2) Radio gain. This sets the analog gain of the radio Tx path. - * It is a coarser setting, and behaves in a logarithmic (dB) fashion. - * - * EEPROM contains factory calibration data for txpower. This maps actual - * measured txpower levels to gain settings in the "well known" tables - * below ("well-known" means here that both factory calibration *and* the - * driver work with the same table). - * - * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table - * has an extension (into negative idxes), in case the driver needs to - * boost power setting for high device temperatures (higher than would be - * present during factory calibration). A 5 Ghz EEPROM idx of "40" - * corresponds to the 49th entry in the table used by the driver. - */ -#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ -#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ - -/** - * 2.4 GHz gain table - * - * Index Dsp gain Radio gain - * 0 110 0x3f (highest gain) - * 1 104 0x3f - * 2 98 0x3f - * 3 110 0x3e - * 4 104 0x3e - * 5 98 0x3e - * 6 110 0x3d - * 7 104 0x3d - * 8 98 0x3d - * 9 110 0x3c - * 10 104 0x3c - * 11 98 0x3c - * 12 110 0x3b - * 13 104 0x3b - * 14 98 0x3b - * 15 110 0x3a - * 16 104 0x3a - * 17 98 0x3a - * 18 110 0x39 - * 19 104 0x39 - * 20 98 0x39 - * 21 110 0x38 - * 22 104 0x38 - * 23 98 0x38 - * 24 110 0x37 - * 25 104 0x37 - * 26 98 0x37 - * 27 110 0x36 - * 28 104 0x36 - * 29 98 0x36 - * 30 110 0x35 - * 31 104 0x35 - * 32 98 0x35 - * 33 110 0x34 - * 34 104 0x34 - * 35 98 0x34 - * 36 110 0x33 - * 37 104 0x33 - * 38 98 0x33 - * 39 110 0x32 - * 40 104 0x32 - * 41 98 0x32 - * 42 110 0x31 - * 43 104 0x31 - * 44 98 0x31 - * 45 110 0x30 - * 46 104 0x30 - * 47 98 0x30 - * 48 110 0x6 - * 49 104 0x6 - * 50 98 0x6 - * 51 110 0x5 - * 52 104 0x5 - * 53 98 0x5 - * 54 110 0x4 - * 55 104 0x4 - * 56 98 0x4 - * 57 110 0x3 - * 58 104 0x3 - * 59 98 0x3 - * 60 110 0x2 - * 61 104 0x2 - * 62 98 0x2 - * 63 110 0x1 - * 64 104 0x1 - * 65 98 0x1 - * 66 110 0x0 - * 67 104 0x0 - * 68 98 0x0 - * 69 97 0 - * 70 96 0 - * 71 95 0 - * 72 94 0 - * 73 93 0 - * 74 92 0 - * 75 91 0 - * 76 90 0 - * 77 89 0 - * 78 88 0 - * 79 87 0 - * 80 86 0 - * 81 85 0 - * 82 84 0 - * 83 83 0 - * 84 82 0 - * 85 81 0 - * 86 80 0 - * 87 79 0 - * 88 78 0 - * 89 77 0 - * 90 76 0 - * 91 75 0 - * 92 74 0 - * 93 73 0 - * 94 72 0 - * 95 71 0 - * 96 70 0 - * 97 69 0 - * 98 68 0 - */ - -/** - * 5 GHz gain table - * - * Index Dsp gain Radio gain - * -9 123 0x3F (highest gain) - * -8 117 0x3F - * -7 110 0x3F - * -6 104 0x3F - * -5 98 0x3F - * -4 110 0x3E - * -3 104 0x3E - * -2 98 0x3E - * -1 110 0x3D - * 0 104 0x3D - * 1 98 0x3D - * 2 110 0x3C - * 3 104 0x3C - * 4 98 0x3C - * 5 110 0x3B - * 6 104 0x3B - * 7 98 0x3B - * 8 110 0x3A - * 9 104 0x3A - * 10 98 0x3A - * 11 110 0x39 - * 12 104 0x39 - * 13 98 0x39 - * 14 110 0x38 - * 15 104 0x38 - * 16 98 0x38 - * 17 110 0x37 - * 18 104 0x37 - * 19 98 0x37 - * 20 110 0x36 - * 21 104 0x36 - * 22 98 0x36 - * 23 110 0x35 - * 24 104 0x35 - * 25 98 0x35 - * 26 110 0x34 - * 27 104 0x34 - * 28 98 0x34 - * 29 110 0x33 - * 30 104 0x33 - * 31 98 0x33 - * 32 110 0x32 - * 33 104 0x32 - * 34 98 0x32 - * 35 110 0x31 - * 36 104 0x31 - * 37 98 0x31 - * 38 110 0x30 - * 39 104 0x30 - * 40 98 0x30 - * 41 110 0x25 - * 42 104 0x25 - * 43 98 0x25 - * 44 110 0x24 - * 45 104 0x24 - * 46 98 0x24 - * 47 110 0x23 - * 48 104 0x23 - * 49 98 0x23 - * 50 110 0x22 - * 51 104 0x18 - * 52 98 0x18 - * 53 110 0x17 - * 54 104 0x17 - * 55 98 0x17 - * 56 110 0x16 - * 57 104 0x16 - * 58 98 0x16 - * 59 110 0x15 - * 60 104 0x15 - * 61 98 0x15 - * 62 110 0x14 - * 63 104 0x14 - * 64 98 0x14 - * 65 110 0x13 - * 66 104 0x13 - * 67 98 0x13 - * 68 110 0x12 - * 69 104 0x08 - * 70 98 0x08 - * 71 110 0x07 - * 72 104 0x07 - * 73 98 0x07 - * 74 110 0x06 - * 75 104 0x06 - * 76 98 0x06 - * 77 110 0x05 - * 78 104 0x05 - * 79 98 0x05 - * 80 110 0x04 - * 81 104 0x04 - * 82 98 0x04 - * 83 110 0x03 - * 84 104 0x03 - * 85 98 0x03 - * 86 110 0x02 - * 87 104 0x02 - * 88 98 0x02 - * 89 110 0x01 - * 90 104 0x01 - * 91 98 0x01 - * 92 110 0x00 - * 93 104 0x00 - * 94 98 0x00 - * 95 93 0x00 - * 96 88 0x00 - * 97 83 0x00 - * 98 78 0x00 - */ - - -/** - * Sanity checks and default values for EEPROM regulatory levels. - * If EEPROM values fall outside MIN/MAX range, use default values. - * - * Regulatory limits refer to the maximum average txpower allowed by - * regulatory agencies in the geographies in which the device is meant - * to be operated. These limits are SKU-specific (i.e. geography-specific), - * and channel-specific; each channel has an individual regulatory limit - * listed in the EEPROM. - * - * Units are in half-dBm (i.e. "34" means 17 dBm). - */ -#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34) -#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34) -#define IL_TX_POWER_REGULATORY_MIN (0) -#define IL_TX_POWER_REGULATORY_MAX (34) - -/** - * Sanity checks and default values for EEPROM saturation levels. - * If EEPROM values fall outside MIN/MAX range, use default values. - * - * Saturation is the highest level that the output power amplifier can produce - * without significant clipping distortion. This is a "peak" power level. - * Different types of modulation (i.e. various "rates", and OFDM vs. CCK) - * require differing amounts of backoff, relative to their average power output, - * in order to avoid clipping distortion. - * - * Driver must make sure that it is violating neither the saturation limit, - * nor the regulatory limit, when calculating Tx power settings for various - * rates. - * - * Units are in half-dBm (i.e. "38" means 19 dBm). - */ -#define IL_TX_POWER_DEFAULT_SATURATION_24 (38) -#define IL_TX_POWER_DEFAULT_SATURATION_52 (38) -#define IL_TX_POWER_SATURATION_MIN (20) -#define IL_TX_POWER_SATURATION_MAX (50) - -/** - * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) - * and thermal Txpower calibration. - * - * When calculating txpower, driver must compensate for current device - * temperature; higher temperature requires higher gain. Driver must calculate - * current temperature (see "4965 temperature calculation"), then compare vs. - * factory calibration temperature in EEPROM; if current temperature is higher - * than factory temperature, driver must *increase* gain by proportions shown - * in table below. If current temperature is lower than factory, driver must - * *decrease* gain. - * - * Different frequency ranges require different compensation, as shown below. - */ -/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR1_FCH 34 -#define CALIB_IL_TX_ATTEN_GR1_LCH 43 - -/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR2_FCH 44 -#define CALIB_IL_TX_ATTEN_GR2_LCH 70 - -/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR3_FCH 71 -#define CALIB_IL_TX_ATTEN_GR3_LCH 124 - -/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR4_FCH 125 -#define CALIB_IL_TX_ATTEN_GR4_LCH 200 - -/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR5_FCH 1 -#define CALIB_IL_TX_ATTEN_GR5_LCH 20 - -enum { - CALIB_CH_GROUP_1 = 0, - CALIB_CH_GROUP_2 = 1, - CALIB_CH_GROUP_3 = 2, - CALIB_CH_GROUP_4 = 3, - CALIB_CH_GROUP_5 = 4, - CALIB_CH_GROUP_MAX -}; - -/********************* END TXPOWER *****************************************/ - - -/** - * Tx/Rx Queues - * - * Most communication between driver and 4965 is via queues of data buffers. - * For example, all commands that the driver issues to device's embedded - * controller (uCode) are via the command queue (one of the Tx queues). All - * uCode command responses/replies/notifications, including Rx frames, are - * conveyed from uCode to driver via the Rx queue. - * - * Most support for these queues, including handshake support, resides in - * structures in host DRAM, shared between the driver and the device. When - * allocating this memory, the driver must make sure that data written by - * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's - * cache memory), so DRAM and cache are consistent, and the device can - * immediately see changes made by the driver. - * - * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via - * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array - * in DRAM containing 256 Transmit Frame Descriptors (TFDs). - */ -#define IL49_NUM_FIFOS 7 -#define IL49_CMD_FIFO_NUM 4 -#define IL49_NUM_QUEUES 16 -#define IL49_NUM_AMPDU_QUEUES 8 - - -/** - * struct il4965_schedq_bc_tbl - * - * Byte Count table - * - * Each Tx queue uses a byte-count table containing 320 entries: - * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that - * duplicate the first 64 entries (to avoid wrap-around within a Tx win; - * max Tx win is 64 TFDs). - * - * When driver sets up a new TFD, it must also enter the total byte count - * of the frame to be transmitted into the corresponding entry in the byte - * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver - * must duplicate the byte count entry in corresponding idx 256-319. - * - * padding puts each byte count table on a 1024-byte boundary; - * 4965 assumes tables are separated by 1024 bytes. - */ -struct il4965_scd_bc_tbl { - __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; - u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; -} __packed; - - -#define IL4965_RTC_INST_LOWER_BOUND (0x000000) - -/* RSSI to dBm */ -#define IL4965_RSSI_OFFSET 44 - -/* PCI registers */ -#define PCI_CFG_RETRY_TIMEOUT 0x041 - -/* PCI register values */ -#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 -#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 - -#define IL4965_DEFAULT_TX_RETRY 15 - -/* EEPROM */ -#define IL4965_FIRST_AMPDU_QUEUE 10 - - -#endif /* !__il_4965_hw_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h deleted file mode 100644 index c0bb45b..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ /dev/null @@ -1,284 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_4965_h__ -#define __il_4965_h__ - -#include "iwl-dev.h" - -/* configuration for the _4965 devices */ -extern struct il_cfg il4965_cfg; - -extern struct il_mod_params il4965_mod_params; - -extern struct ieee80211_ops il4965_hw_ops; - -/* tx queue */ -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed); - -/* RXON */ -void il4965_set_rxon_chain(struct il_priv *il, - struct il_rxon_context *ctx); - -/* uCode */ -int il4965_verify_ucode(struct il_priv *il); - -/* lib */ -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status); - -void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); -int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); -int il4965_hw_nic_init(struct il_priv *il); -int il4965_dump_fh(struct il_priv *il, char **buf, bool display); - -/* rx */ -void il4965_rx_queue_restock(struct il_priv *il); -void il4965_rx_replenish(struct il_priv *il); -void il4965_rx_replenish_now(struct il_priv *il); -void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); -int il4965_rxq_stop(struct il_priv *il); -int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_rx_handle(struct il_priv *il); - -/* tx */ -void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad); -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); -void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info); -int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); -int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn); -int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid); -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id); -void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb); -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); -void il4965_hw_txq_ctx_free(struct il_priv *il); -int il4965_txq_ctx_alloc(struct il_priv *il); -void il4965_txq_ctx_reset(struct il_priv *il); -void il4965_txq_ctx_stop(struct il_priv *il); -void il4965_txq_set_sched(struct il_priv *il, u32 mask); - -/* - * Acquire il->lock before calling this function ! - */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); -/** - * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue - * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed - * @scd_retry: (1) Indicates queue will be used in aggregation mode - * - * NOTE: Acquire il->lock before calling this function ! - */ -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry); - -static inline u32 il4965_tx_status_to_mac80211(u32 status) -{ - status &= TX_STATUS_MSK; - - switch (status) { - case TX_STATUS_SUCCESS: - case TX_STATUS_DIRECT_DONE: - return IEEE80211_TX_STAT_ACK; - case TX_STATUS_FAIL_DEST_PS: - return IEEE80211_TX_STAT_TX_FILTERED; - default: - return 0; - } -} - -static inline bool il4965_is_tx_success(u32 status) -{ - status &= TX_STATUS_MSK; - return (status == TX_STATUS_SUCCESS || - status == TX_STATUS_DIRECT_DONE); -} - -u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); - -/* rx */ -void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb); -bool il4965_good_plcp_health(struct il_priv *il, - struct il_rx_pkt *pkt); -void il4965_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb); - -/* scan */ -int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); - -/* station mgmt */ -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add); - -/* hcmd */ -int il4965_send_beacon_cmd(struct il_priv *il); - -#ifdef CONFIG_IWLEGACY_DEBUG -const char *il4965_get_tx_fail_reason(u32 status); -#else -static inline const char * -il4965_get_tx_fail_reason(u32 status) { return ""; } -#endif - -/* station management */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_add_bssid_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r); -int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key); -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key); -int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_set_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, - int sta_id, int tid); -int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn); -int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid); -void il4965_sta_modify_sleep_tx_count(struct il_priv *il, - int sta_id, int cnt); -int il4965_update_bcast_stations(struct il_priv *il); - -/* rate */ -static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) -{ - return BIT(ant_idx) << RATE_MCS_ANT_POS; -} - -static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) -{ - return le32_to_cpu(rate_n_flags) & 0xFF; -} - -static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) -{ - return cpu_to_le32(flags|(u32)rate); -} - -/* eeprom */ -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); -int il4965_eeprom_acquire_semaphore(struct il_priv *il); -void il4965_eeprom_release_semaphore(struct il_priv *il); -int il4965_eeprom_check_version(struct il_priv *il); - -/* mac80211 handlers (for 4965) */ -void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); -int il4965_mac_start(struct ieee80211_hw *hw); -void il4965_mac_stop(struct ieee80211_hw *hw); -void il4965_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast); -int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, struct ieee80211_sta *sta, - struct ieee80211_key_conf *key); -void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key); -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size); -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta); -void il4965_mac_channel_switch(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch); - -void il4965_led_enable(struct il_priv *il); - -#endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index e6688b1..55822da 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -347,7 +347,7 @@ struct il3945_power_per_rate { * For MIMO rates, one value may be different from the other, * in order to balance the Tx output between the two transmitters. * - * See more details in doc for TXPOWER in iwl-4965-hw.h. + * See more details in doc for TXPOWER in 4965.h. */ union il4965_tx_power_dual_stream { struct { @@ -1756,7 +1756,7 @@ struct il_compressed_ba_resp { /* * REPLY_TX_PWR_TBL_CMD = 0x97 (command, has simple generic response) * - * See details under "TXPOWER" in iwl-4965-hw.h. + * See details under "TXPOWER" in 4965.h. */ struct il3945_txpowertable_cmd { diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 7c86d19..97b2573 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -26,7 +26,7 @@ /* * Please use this file (iwl-dev.h) for driver implementation definitions. * Please use iwl-commands.h for uCode API definitions. - * Please use iwl-4965-hw.h for hardware-related definitions. + * Please use 4965.h for hardware-related definitions. */ #ifndef __il_dev_h__ @@ -44,7 +44,7 @@ #include "iwl-prph.h" #include "iwl-fh.h" #include "iwl-debug.h" -#include "iwl-4965-hw.h" +#include "4965.h" #include "iwl-3945-hw.h" #include "iwl-led.h" #include "iwl-power.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index eb868c0..61435a5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -154,7 +154,7 @@ extern const u8 il_eeprom_band_1[14]; * 1) Temperature (degrees Celsius) of device when measurement was made. * * 2) Gain table idx used to achieve the target measurement power. - * This refers to the "well-known" gain tables (see iwl-4965-hw.h). + * This refers to the "well-known" gain tables (see 4965.h). * * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). * diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index e34d907..b0bf684 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -255,7 +255,7 @@ * but one DMA channel may take input from several queues. * * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows - * (cf. default_queue_to_tx_fifo in iwl-4965.c): + * (cf. default_queue_to_tx_fifo in 4965.c): * * 0 -- EDCA BK (background) frames, lowest priority * 1 -- EDCA BE (best effort) frames, normal priority diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 10a0914..e46e588 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -232,7 +232,7 @@ EXPORT_SYMBOL(il_cmd_queue_free); * reclaiming packets (on 'tx done IRQ), if free space become > high mark, * Tx queue resumed. * - * See more detailed info in iwl-4965-hw.h. + * See more detailed info in 4965.h. ***************************************************/ int il_queue_space(const struct il_queue *q) -- cgit v0.10.2 From 6bbb1370c3083190cae8487c2c61c0d24f869e68 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 14:12:12 +0200 Subject: iwlegacy: move iwl-3945-{,hw,fh,debugfs}.h to 3945.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 88b3d8f..9c837c3 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -26,8 +26,9 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-3945-debugfs.h" - +#include "iwl-dev.h" +#include "iwl-core.h" +#include "3945.h" static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) { diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 151c8fa..17edbdf 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -52,10 +52,9 @@ #define DRV_NAME "iwl3945" #include "iwl-fh.h" -#include "iwl-3945-fh.h" #include "iwl-commands.h" #include "iwl-sta.h" -#include "iwl-3945.h" +#include "3945.h" #include "iwl-core.h" #include "iwl-helpers.h" #include "iwl-dev.h" diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index f84ed5e..0d2beba 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -37,7 +37,7 @@ #include #include "iwl-commands.h" -#include "iwl-3945.h" +#include "3945.h" #include "iwl-sta.h" #define RS_NAME "iwl-3945-rs" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b41e60b..17615c3 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -40,15 +40,13 @@ #include #include "iwl-fh.h" -#include "iwl-3945-fh.h" #include "iwl-commands.h" #include "iwl-sta.h" -#include "iwl-3945.h" #include "iwl-eeprom.h" #include "iwl-core.h" #include "iwl-helpers.h" #include "iwl-led.h" -#include "iwl-3945-debugfs.h" +#include "3945.h" /* Send led command */ static int il3945_send_led_cmd(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h new file mode 100644 index 0000000..d65565f --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -0,0 +1,667 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#ifndef __il_3945_h__ +#define __il_3945_h__ + +#include /* for struct pci_device_id */ +#include +#include + +/* Hardware specific file defines the PCI IDs table for that hardware module */ +extern const struct pci_device_id il3945_hw_card_ids[]; + +#include "iwl-csr.h" +#include "iwl-prph.h" +#include "iwl-fh.h" +#include "iwl-debug.h" +#include "iwl-power.h" +#include "iwl-dev.h" +#include "iwl-led.h" +#include "iwl-eeprom.h" + +/* Highest firmware API version supported */ +#define IL3945_UCODE_API_MAX 2 + +/* Lowest firmware API version supported */ +#define IL3945_UCODE_API_MIN 1 + +#define IL3945_FW_PRE "iwlwifi-3945-" +#define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode" +#define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api) + +/* Default noise level to report when noise measurement is not available. + * This may be because we're: + * 1) Not associated (4965, no beacon stats being sent to driver) + * 2) Scanning (noise measurement does not apply to associated channel) + * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) + * Use default noise value of -127 ... this is below the range of measurable + * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. + * Also, -127 works better than 0 when averaging frames with/without + * noise info (e.g. averaging might be done in app); measured dBm values are + * always negative ... using a negative value as the default keeps all + * averages within an s8's (used in some apps) range of negative values. */ +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) + +/* Module parameters accessible from iwl-*.c */ +extern struct il_mod_params il3945_mod_params; + +struct il3945_rate_scale_data { + u64 data; + s32 success_counter; + s32 success_ratio; + s32 counter; + s32 average_tpt; + unsigned long stamp; +}; + +struct il3945_rs_sta { + spinlock_t lock; + struct il_priv *il; + s32 *expected_tpt; + unsigned long last_partial_flush; + unsigned long last_flush; + u32 flush_time; + u32 last_tx_packets; + u32 tx_packets; + u8 tgg; + u8 flush_pending; + u8 start_rate; + struct timer_list rate_scale_flush; + struct il3945_rate_scale_data win[RATE_COUNT_3945]; +#ifdef CONFIG_MAC80211_DEBUGFS + struct dentry *rs_sta_dbgfs_stats_table_file; +#endif + + /* used to be in sta_info */ + int last_txrate_idx; +}; + + +/* + * The common struct MUST be first because it is shared between + * 3945 and 4965! + */ +struct il3945_sta_priv { + struct il_station_priv_common common; + struct il3945_rs_sta rs_sta; +}; + +enum il3945_antenna { + IL_ANTENNA_DIVERSITY, + IL_ANTENNA_MAIN, + IL_ANTENNA_AUX +}; + +/* + * RTS threshold here is total size [2347] minus 4 FCS bytes + * Per spec: + * a value of 0 means RTS on all data/management packets + * a value > max MSDU size means no RTS + * else RTS for data/management frames where MPDU is larger + * than RTS value. + */ +#define DEFAULT_RTS_THRESHOLD 2347U +#define MIN_RTS_THRESHOLD 0U +#define MAX_RTS_THRESHOLD 2347U +#define MAX_MSDU_SIZE 2304U +#define MAX_MPDU_SIZE 2346U +#define DEFAULT_BEACON_INTERVAL 100U +#define DEFAULT_SHORT_RETRY_LIMIT 7U +#define DEFAULT_LONG_RETRY_LIMIT 4U + +#define IL_TX_FIFO_AC0 0 +#define IL_TX_FIFO_AC1 1 +#define IL_TX_FIFO_AC2 2 +#define IL_TX_FIFO_AC3 3 +#define IL_TX_FIFO_HCCA_1 5 +#define IL_TX_FIFO_HCCA_2 6 +#define IL_TX_FIFO_NONE 7 + +#define IEEE80211_DATA_LEN 2304 +#define IEEE80211_4ADDR_LEN 30 +#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) +#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) + +struct il3945_frame { + union { + struct ieee80211_hdr frame; + struct il3945_tx_beacon_cmd beacon; + u8 raw[IEEE80211_FRAME_LEN]; + u8 cmd[360]; + } u; + struct list_head list; +}; + +#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) +#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) +#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) + +#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 +#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 +#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 + +#define IL_SUPPORTED_RATES_IE_LEN 8 + +#define SCAN_INTERVAL 100 + +#define MAX_TID_COUNT 9 + +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 + +#define STA_PS_STATUS_WAKE 0 +#define STA_PS_STATUS_SLEEP 1 + +struct il3945_ibss_seq { + u8 mac[ETH_ALEN]; + u16 seq_num; + u16 frag_num; + unsigned long packet_time; + struct list_head list; +}; + +#define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\ + x->u.rx_frame.stats.payload + \ + x->u.rx_frame.stats.phy_count)) +#define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\ + IL_RX_HDR(x)->payload + \ + le16_to_cpu(IL_RX_HDR(x)->len))) +#define IL_RX_STATS(x) (&x->u.rx_frame.stats) +#define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) + + +/****************************************************************************** + * + * Functions implemented in iwl3945-base.c which are forward declared here + * for use by iwl-*.c + * + *****************************************************************************/ +extern int il3945_calc_db_from_ratio(int sig_ratio); +extern void il3945_rx_replenish(void *data); +extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, + struct ieee80211_hdr *hdr, int left); +extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, + char **buf, bool display); +extern void il3945_dump_nic_error_log(struct il_priv *il); + +/****************************************************************************** + * + * Functions implemented in iwl-[34]*.c which are forward declared here + * for use by iwl3945-base.c + * + * NOTE: The implementation of these functions are hardware specific + * which is why they are in the hardware specific files (vs. iwl-base.c) + * + * Naming convention -- + * il3945_ <-- Its part of iwlwifi (should be changed to il3945_) + * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) + * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) + * il3945_bg_ <-- Called from work queue context + * il3945_mac_ <-- mac80211 callback + * + ****************************************************************************/ +extern void il3945_hw_rx_handler_setup(struct il_priv *il); +extern void il3945_hw_setup_deferred_work(struct il_priv *il); +extern void il3945_hw_cancel_deferred_work(struct il_priv *il); +extern int il3945_hw_rxq_stop(struct il_priv *il); +extern int il3945_hw_set_hw_params(struct il_priv *il); +extern int il3945_hw_nic_init(struct il_priv *il); +extern int il3945_hw_nic_stop_master(struct il_priv *il); +extern void il3945_hw_txq_ctx_free(struct il_priv *il); +extern void il3945_hw_txq_ctx_stop(struct il_priv *il); +extern int il3945_hw_nic_reset(struct il_priv *il); +extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, + u8 reset, u8 pad); +extern void il3945_hw_txq_free_tfd(struct il_priv *il, + struct il_tx_queue *txq); +extern int il3945_hw_get_temperature(struct il_priv *il); +extern int il3945_hw_tx_queue_init(struct il_priv *il, + struct il_tx_queue *txq); +extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, + struct il3945_frame *frame, u8 rate); +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, + struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, + int sta_id, int tx_id); +extern int il3945_hw_reg_send_txpower(struct il_priv *il); +extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); +extern void il3945_hw_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb); +void il3945_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb); +extern void il3945_disable_events(struct il_priv *il); +extern int il4965_get_temperature(const struct il_priv *il); +extern void il3945_post_associate(struct il_priv *il); +extern void il3945_config_ap(struct il_priv *il); + +extern int il3945_commit_rxon(struct il_priv *il, + struct il_rxon_context *ctx); + +/** + * il3945_hw_find_station - Find station id for a given BSSID + * @bssid: MAC address of station ID to find + * + * NOTE: This should not be hardware specific but the code has + * not yet been merged into a single common layer for managing the + * station tables. + */ +extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); + +extern struct ieee80211_ops il3945_hw_ops; + +extern __le32 il3945_get_antenna_flags(const struct il_priv *il); +extern int il3945_init_hw_rate_table(struct il_priv *il); +extern void il3945_reg_txpower_periodic(struct il_priv *il); +extern int il3945_txpower_set_from_eeprom(struct il_priv *il); + +extern const struct il_channel_info *il3945_get_channel_info( + const struct il_priv *il, enum ieee80211_band band, u16 channel); + +extern int il3945_rs_next_rate(struct il_priv *il, int rate); + +/* scanning */ +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); +void il3945_post_scan(struct il_priv *il); + +/* rates */ +extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; + + + +/* RSSI to dBm */ +#define IL39_RSSI_OFFSET 95 + +/* + * EEPROM related constants, enums, and structures. + */ +#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7) + +/* + * Mapping of a Tx power level, at factory calibration temperature, + * to a radio/DSP gain table idx. + * One for each of 5 "sample" power levels in each band. + * v_det is measured at the factory, using the 3945's built-in power amplifier + * (PA) output voltage detector. This same detector is used during Tx of + * long packets in normal operation to provide feedback as to proper output + * level. + * Data copied from EEPROM. + * DO NOT ALTER THIS STRUCTURE!!! + */ +struct il3945_eeprom_txpower_sample { + u8 gain_idx; /* idx into power (gain) setup table ... */ + s8 power; /* ... for this pwr level for this chnl group */ + u16 v_det; /* PA output voltage */ +} __packed; + +/* + * Mappings of Tx power levels -> nominal radio/DSP gain table idxes. + * One for each channel group (a.k.a. "band") (1 for BG, 4 for A). + * Tx power setup code interpolates between the 5 "sample" power levels + * to determine the nominal setup for a requested power level. + * Data copied from EEPROM. + * DO NOT ALTER THIS STRUCTURE!!! + */ +struct il3945_eeprom_txpower_group { + struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ + s32 a, b, c, d, e; /* coefficients for voltage->power + * formula (signed) */ + s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on + * frequency (signed) */ + s8 saturation_power; /* highest power possible by h/w in this + * band */ + u8 group_channel; /* "representative" channel # in this band */ + s16 temperature; /* h/w temperature at factory calib this band + * (signed) */ +} __packed; + +/* + * Temperature-based Tx-power compensation data, not band-specific. + * These coefficients are use to modify a/b/c/d/e coeffs based on + * difference between current temperature and factory calib temperature. + * Data copied from EEPROM. + */ +struct il3945_eeprom_temperature_corr { + u32 Ta; + u32 Tb; + u32 Tc; + u32 Td; + u32 Te; +} __packed; + +/* + * EEPROM map + */ +struct il3945_eeprom { + u8 reserved0[16]; + u16 device_id; /* abs.ofs: 16 */ + u8 reserved1[2]; + u16 pmc; /* abs.ofs: 20 */ + u8 reserved2[20]; + u8 mac_address[6]; /* abs.ofs: 42 */ + u8 reserved3[58]; + u16 board_revision; /* abs.ofs: 106 */ + u8 reserved4[11]; + u8 board_pba_number[9]; /* abs.ofs: 119 */ + u8 reserved5[8]; + u16 version; /* abs.ofs: 136 */ + u8 sku_cap; /* abs.ofs: 138 */ + u8 leds_mode; /* abs.ofs: 139 */ + u16 oem_mode; + u16 wowlan_mode; /* abs.ofs: 142 */ + u16 leds_time_interval; /* abs.ofs: 144 */ + u8 leds_off_time; /* abs.ofs: 146 */ + u8 leds_on_time; /* abs.ofs: 147 */ + u8 almgor_m_version; /* abs.ofs: 148 */ + u8 antenna_switch_type; /* abs.ofs: 149 */ + u8 reserved6[42]; + u8 sku_id[4]; /* abs.ofs: 192 */ + +/* + * Per-channel regulatory data. + * + * Each channel that *might* be supported by 3945 has a fixed location + * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory + * txpower (MSB). + * + * Entries immediately below are for 20 MHz channel width. + * + * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 + */ + u16 band_1_count; /* abs.ofs: 196 */ + struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ + +/* + * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, + * 5.0 GHz channels 7, 8, 11, 12, 16 + * (4915-5080MHz) (none of these is ever supported) + */ + u16 band_2_count; /* abs.ofs: 226 */ + struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ + +/* + * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 + * (5170-5320MHz) + */ + u16 band_3_count; /* abs.ofs: 254 */ + struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ + +/* + * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 + * (5500-5700MHz) + */ + u16 band_4_count; /* abs.ofs: 280 */ + struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ + +/* + * 5.7 GHz channels 145, 149, 153, 157, 161, 165 + * (5725-5825MHz) + */ + u16 band_5_count; /* abs.ofs: 304 */ + struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ + + u8 reserved9[194]; + +/* + * 3945 Txpower calibration data. + */ +#define IL_NUM_TX_CALIB_GROUPS 5 + struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; +/* abs.ofs: 512 */ + struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ + u8 reserved16[172]; /* fill out to full 1024 byte block */ +} __packed; + +#define IL3945_EEPROM_IMG_SIZE 1024 + +/* End of EEPROM */ + +#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */ +#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */ + +/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */ +#define IL39_NUM_QUEUES 5 +#define IL39_CMD_QUEUE_NUM 4 + +#define IL_DEFAULT_TX_RETRY 15 + +/*********************************************/ + +#define RFD_SIZE 4 +#define NUM_TFD_CHUNKS 4 + +#define RX_QUEUE_SIZE 256 +#define RX_QUEUE_MASK 255 +#define RX_QUEUE_SIZE_LOG 8 + +#define TFD_CTL_COUNT_SET(n) (n << 24) +#define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7) +#define TFD_CTL_PAD_SET(n) (n << 28) +#define TFD_CTL_PAD_GET(ctl) (ctl >> 28) + +/* Sizes and addresses for instruction and data memory (SRAM) in + * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ +#define IL39_RTC_INST_LOWER_BOUND (0x000000) +#define IL39_RTC_INST_UPPER_BOUND (0x014000) + +#define IL39_RTC_DATA_LOWER_BOUND (0x800000) +#define IL39_RTC_DATA_UPPER_BOUND (0x808000) + +#define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \ + IL39_RTC_INST_LOWER_BOUND) +#define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \ + IL39_RTC_DATA_LOWER_BOUND) + +#define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE +#define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE + +/* Size of uCode instruction memory in bootstrap state machine */ +#define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE + +static inline int il3945_hw_valid_rtc_data_addr(u32 addr) +{ + return (addr >= IL39_RTC_DATA_LOWER_BOUND && + addr < IL39_RTC_DATA_UPPER_BOUND); +} + +/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE + * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ +struct il3945_shared { + __le32 tx_base_ptr[8]; +} __packed; + +static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) +{ + return le16_to_cpu(rate_n_flags) & 0xFF; +} + +static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) +{ + return le16_to_cpu(rate_n_flags); +} + +static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) +{ + return cpu_to_le16((u16)rate|flags); +} + +/************************************/ +/* iwl3945 Flow Handler Definitions */ +/************************************/ + +/** + * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) + * Addresses are offsets from device's PCI hardware base address. + */ +#define FH39_MEM_LOWER_BOUND (0x0800) +#define FH39_MEM_UPPER_BOUND (0x1000) + +#define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140) +#define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180) +#define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400) +#define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0) +#define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500) +#define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680) + +/* TFDB (Transmit Frame Buffer Descriptor) */ +#define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \ + ((_ch) * 2 + (buf)) * 0x28) +#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch)) + +/* CBCC channel is [0,2] */ +#define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8) +#define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00) +#define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04) + +/* RCSR channel is [0,2] */ +#define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40) +#define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00) +#define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04) +#define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20) +#define FH39_RCSR_RPTR_ADDR(_ch) (FH39_RCSR(_ch) + 0x24) + +#define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0)) + +/* RSSR */ +#define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000) +#define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004) + +/* TCSR */ +#define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20) +#define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00) +#define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04) +#define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08) + +/* TSSR */ +#define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000) +#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) +#define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) + + +/* DBM */ + +#define FH39_SRVC_CHNL (6) + +#define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20) +#define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4) + +#define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) +#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000) +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) + +#define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000) + +#define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000) +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100) +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020) +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005) + +#define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) (BIT(_ch) << 24) +#define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch) (BIT(_ch) << 16) + +#define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \ + (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \ + FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch)) + +#define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) + +struct il3945_tfd_tb { + __le32 addr; + __le32 len; +} __packed; + +struct il3945_tfd { + __le32 control_flags; + struct il3945_tfd_tb tbs[4]; + u8 __pad[28]; +} __packed; + +#ifdef CONFIG_IWLEGACY_DEBUGFS +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il3945_ucode_general_stats_read(struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos); +#else +static ssize_t il3945_ucode_rx_stats_read(struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos) +{ + return 0; +} +static ssize_t il3945_ucode_tx_stats_read(struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos) +{ + return 0; +} +static ssize_t il3945_ucode_general_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +#endif + +/* Requires full declaration of il_priv before including */ +#include "iwl-io.h" + +#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h deleted file mode 100644 index 9d1a4a0..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" - -#ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos); -#else -static ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) -{ - return 0; -} -static ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) -{ - return 0; -} -static ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h deleted file mode 100644 index aa44a90..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h +++ /dev/null @@ -1,187 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#ifndef __il_3945_fh_h__ -#define __il_3945_fh_h__ - -/************************************/ -/* iwl3945 Flow Handler Definitions */ -/************************************/ - -/** - * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) - * Addresses are offsets from device's PCI hardware base address. - */ -#define FH39_MEM_LOWER_BOUND (0x0800) -#define FH39_MEM_UPPER_BOUND (0x1000) - -#define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140) -#define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180) -#define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400) -#define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0) -#define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500) -#define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680) - -/* TFDB (Transmit Frame Buffer Descriptor) */ -#define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \ - ((_ch) * 2 + (buf)) * 0x28) -#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch)) - -/* CBCC channel is [0,2] */ -#define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8) -#define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00) -#define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04) - -/* RCSR channel is [0,2] */ -#define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40) -#define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00) -#define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04) -#define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20) -#define FH39_RCSR_RPTR_ADDR(_ch) (FH39_RCSR(_ch) + 0x24) - -#define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0)) - -/* RSSR */ -#define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000) -#define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004) - -/* TCSR */ -#define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20) -#define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00) -#define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04) -#define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08) - -/* TSSR */ -#define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000) -#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) -#define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) - - -/* DBM */ - -#define FH39_SRVC_CHNL (6) - -#define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20) -#define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4) - -#define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) -#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000) -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) - -#define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000) - -#define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000) -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100) -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020) -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005) - -#define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) (BIT(_ch) << 24) -#define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch) (BIT(_ch) << 16) - -#define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \ - (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \ - FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch)) - -#define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) - -struct il3945_tfd_tb { - __le32 addr; - __le32 len; -} __packed; - -struct il3945_tfd { - __le32 control_flags; - struct il3945_tfd_tb tbs[4]; - u8 __pad[28]; -} __packed; - - -#endif /* __il_3945_fh_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h deleted file mode 100644 index 53e5fb4..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ /dev/null @@ -1,291 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Please use this file (iwl-3945-hw.h) only for hardware-related definitions. - * Please use iwl-commands.h for uCode API definitions. - * Please use iwl-3945.h for driver implementation definitions. - */ - -#ifndef __il_3945_hw__ -#define __il_3945_hw__ - -#include "iwl-eeprom.h" - -/* RSSI to dBm */ -#define IL39_RSSI_OFFSET 95 - -/* - * EEPROM related constants, enums, and structures. - */ -#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7) - -/* - * Mapping of a Tx power level, at factory calibration temperature, - * to a radio/DSP gain table idx. - * One for each of 5 "sample" power levels in each band. - * v_det is measured at the factory, using the 3945's built-in power amplifier - * (PA) output voltage detector. This same detector is used during Tx of - * long packets in normal operation to provide feedback as to proper output - * level. - * Data copied from EEPROM. - * DO NOT ALTER THIS STRUCTURE!!! - */ -struct il3945_eeprom_txpower_sample { - u8 gain_idx; /* idx into power (gain) setup table ... */ - s8 power; /* ... for this pwr level for this chnl group */ - u16 v_det; /* PA output voltage */ -} __packed; - -/* - * Mappings of Tx power levels -> nominal radio/DSP gain table idxes. - * One for each channel group (a.k.a. "band") (1 for BG, 4 for A). - * Tx power setup code interpolates between the 5 "sample" power levels - * to determine the nominal setup for a requested power level. - * Data copied from EEPROM. - * DO NOT ALTER THIS STRUCTURE!!! - */ -struct il3945_eeprom_txpower_group { - struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ - s32 a, b, c, d, e; /* coefficients for voltage->power - * formula (signed) */ - s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on - * frequency (signed) */ - s8 saturation_power; /* highest power possible by h/w in this - * band */ - u8 group_channel; /* "representative" channel # in this band */ - s16 temperature; /* h/w temperature at factory calib this band - * (signed) */ -} __packed; - -/* - * Temperature-based Tx-power compensation data, not band-specific. - * These coefficients are use to modify a/b/c/d/e coeffs based on - * difference between current temperature and factory calib temperature. - * Data copied from EEPROM. - */ -struct il3945_eeprom_temperature_corr { - u32 Ta; - u32 Tb; - u32 Tc; - u32 Td; - u32 Te; -} __packed; - -/* - * EEPROM map - */ -struct il3945_eeprom { - u8 reserved0[16]; - u16 device_id; /* abs.ofs: 16 */ - u8 reserved1[2]; - u16 pmc; /* abs.ofs: 20 */ - u8 reserved2[20]; - u8 mac_address[6]; /* abs.ofs: 42 */ - u8 reserved3[58]; - u16 board_revision; /* abs.ofs: 106 */ - u8 reserved4[11]; - u8 board_pba_number[9]; /* abs.ofs: 119 */ - u8 reserved5[8]; - u16 version; /* abs.ofs: 136 */ - u8 sku_cap; /* abs.ofs: 138 */ - u8 leds_mode; /* abs.ofs: 139 */ - u16 oem_mode; - u16 wowlan_mode; /* abs.ofs: 142 */ - u16 leds_time_interval; /* abs.ofs: 144 */ - u8 leds_off_time; /* abs.ofs: 146 */ - u8 leds_on_time; /* abs.ofs: 147 */ - u8 almgor_m_version; /* abs.ofs: 148 */ - u8 antenna_switch_type; /* abs.ofs: 149 */ - u8 reserved6[42]; - u8 sku_id[4]; /* abs.ofs: 192 */ - -/* - * Per-channel regulatory data. - * - * Each channel that *might* be supported by 3945 has a fixed location - * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory - * txpower (MSB). - * - * Entries immediately below are for 20 MHz channel width. - * - * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 - */ - u16 band_1_count; /* abs.ofs: 196 */ - struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ - -/* - * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, - * 5.0 GHz channels 7, 8, 11, 12, 16 - * (4915-5080MHz) (none of these is ever supported) - */ - u16 band_2_count; /* abs.ofs: 226 */ - struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ - -/* - * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 - * (5170-5320MHz) - */ - u16 band_3_count; /* abs.ofs: 254 */ - struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ - -/* - * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 - * (5500-5700MHz) - */ - u16 band_4_count; /* abs.ofs: 280 */ - struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ - -/* - * 5.7 GHz channels 145, 149, 153, 157, 161, 165 - * (5725-5825MHz) - */ - u16 band_5_count; /* abs.ofs: 304 */ - struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ - - u8 reserved9[194]; - -/* - * 3945 Txpower calibration data. - */ -#define IL_NUM_TX_CALIB_GROUPS 5 - struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; -/* abs.ofs: 512 */ - struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ - u8 reserved16[172]; /* fill out to full 1024 byte block */ -} __packed; - -#define IL3945_EEPROM_IMG_SIZE 1024 - -/* End of EEPROM */ - -#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */ -#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */ - -/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */ -#define IL39_NUM_QUEUES 5 -#define IL39_CMD_QUEUE_NUM 4 - -#define IL_DEFAULT_TX_RETRY 15 - -/*********************************************/ - -#define RFD_SIZE 4 -#define NUM_TFD_CHUNKS 4 - -#define RX_QUEUE_SIZE 256 -#define RX_QUEUE_MASK 255 -#define RX_QUEUE_SIZE_LOG 8 - -#define U32_PAD(n) ((4-(n))&0x3) - -#define TFD_CTL_COUNT_SET(n) (n << 24) -#define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7) -#define TFD_CTL_PAD_SET(n) (n << 28) -#define TFD_CTL_PAD_GET(ctl) (ctl >> 28) - -/* Sizes and addresses for instruction and data memory (SRAM) in - * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IL39_RTC_INST_LOWER_BOUND (0x000000) -#define IL39_RTC_INST_UPPER_BOUND (0x014000) - -#define IL39_RTC_DATA_LOWER_BOUND (0x800000) -#define IL39_RTC_DATA_UPPER_BOUND (0x808000) - -#define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \ - IL39_RTC_INST_LOWER_BOUND) -#define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \ - IL39_RTC_DATA_LOWER_BOUND) - -#define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE -#define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE - -/* Size of uCode instruction memory in bootstrap state machine */ -#define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE - -static inline int il3945_hw_valid_rtc_data_addr(u32 addr) -{ - return (addr >= IL39_RTC_DATA_LOWER_BOUND && - addr < IL39_RTC_DATA_UPPER_BOUND); -} - -/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE - * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ -struct il3945_shared { - __le32 tx_base_ptr[8]; -} __packed; - -static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) -{ - return le16_to_cpu(rate_n_flags) & 0xFF; -} - -static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) -{ - return le16_to_cpu(rate_n_flags); -} - -static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) -{ - return cpu_to_le16((u16)rate|flags); -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h deleted file mode 100644 index 80fcbf8..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ /dev/null @@ -1,308 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -/* - * Please use this file (iwl-3945.h) for driver implementation definitions. - * Please use iwl-3945-commands.h for uCode API definitions. - * Please use iwl-3945-hw.h for hardware-related definitions. - */ - -#ifndef __il_3945_h__ -#define __il_3945_h__ - -#include /* for struct pci_device_id */ -#include -#include - -/* Hardware specific file defines the PCI IDs table for that hardware module */ -extern const struct pci_device_id il3945_hw_card_ids[]; - -#include "iwl-csr.h" -#include "iwl-prph.h" -#include "iwl-fh.h" -#include "iwl-3945-hw.h" -#include "iwl-debug.h" -#include "iwl-power.h" -#include "iwl-dev.h" -#include "iwl-led.h" - -/* Highest firmware API version supported */ -#define IL3945_UCODE_API_MAX 2 - -/* Lowest firmware API version supported */ -#define IL3945_UCODE_API_MIN 1 - -#define IL3945_FW_PRE "iwlwifi-3945-" -#define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode" -#define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api) - -/* Default noise level to report when noise measurement is not available. - * This may be because we're: - * 1) Not associated (4965, no beacon stats being sent to driver) - * 2) Scanning (noise measurement does not apply to associated channel) - * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) - * Use default noise value of -127 ... this is below the range of measurable - * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. - * Also, -127 works better than 0 when averaging frames with/without - * noise info (e.g. averaging might be done in app); measured dBm values are - * always negative ... using a negative value as the default keeps all - * averages within an s8's (used in some apps) range of negative values. */ -#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) - -/* Module parameters accessible from iwl-*.c */ -extern struct il_mod_params il3945_mod_params; - -struct il3945_rate_scale_data { - u64 data; - s32 success_counter; - s32 success_ratio; - s32 counter; - s32 average_tpt; - unsigned long stamp; -}; - -struct il3945_rs_sta { - spinlock_t lock; - struct il_priv *il; - s32 *expected_tpt; - unsigned long last_partial_flush; - unsigned long last_flush; - u32 flush_time; - u32 last_tx_packets; - u32 tx_packets; - u8 tgg; - u8 flush_pending; - u8 start_rate; - struct timer_list rate_scale_flush; - struct il3945_rate_scale_data win[RATE_COUNT_3945]; -#ifdef CONFIG_MAC80211_DEBUGFS - struct dentry *rs_sta_dbgfs_stats_table_file; -#endif - - /* used to be in sta_info */ - int last_txrate_idx; -}; - - -/* - * The common struct MUST be first because it is shared between - * 3945 and 4965! - */ -struct il3945_sta_priv { - struct il_station_priv_common common; - struct il3945_rs_sta rs_sta; -}; - -enum il3945_antenna { - IL_ANTENNA_DIVERSITY, - IL_ANTENNA_MAIN, - IL_ANTENNA_AUX -}; - -/* - * RTS threshold here is total size [2347] minus 4 FCS bytes - * Per spec: - * a value of 0 means RTS on all data/management packets - * a value > max MSDU size means no RTS - * else RTS for data/management frames where MPDU is larger - * than RTS value. - */ -#define DEFAULT_RTS_THRESHOLD 2347U -#define MIN_RTS_THRESHOLD 0U -#define MAX_RTS_THRESHOLD 2347U -#define MAX_MSDU_SIZE 2304U -#define MAX_MPDU_SIZE 2346U -#define DEFAULT_BEACON_INTERVAL 100U -#define DEFAULT_SHORT_RETRY_LIMIT 7U -#define DEFAULT_LONG_RETRY_LIMIT 4U - -#define IL_TX_FIFO_AC0 0 -#define IL_TX_FIFO_AC1 1 -#define IL_TX_FIFO_AC2 2 -#define IL_TX_FIFO_AC3 3 -#define IL_TX_FIFO_HCCA_1 5 -#define IL_TX_FIFO_HCCA_2 6 -#define IL_TX_FIFO_NONE 7 - -#define IEEE80211_DATA_LEN 2304 -#define IEEE80211_4ADDR_LEN 30 -#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) -#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) - -struct il3945_frame { - union { - struct ieee80211_hdr frame; - struct il3945_tx_beacon_cmd beacon; - u8 raw[IEEE80211_FRAME_LEN]; - u8 cmd[360]; - } u; - struct list_head list; -}; - -#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) -#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) -#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) - -#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 -#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 -#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 - -#define IL_SUPPORTED_RATES_IE_LEN 8 - -#define SCAN_INTERVAL 100 - -#define MAX_TID_COUNT 9 - -#define IL_INVALID_RATE 0xFF -#define IL_INVALID_VALUE -1 - -#define STA_PS_STATUS_WAKE 0 -#define STA_PS_STATUS_SLEEP 1 - -struct il3945_ibss_seq { - u8 mac[ETH_ALEN]; - u16 seq_num; - u16 frag_num; - unsigned long packet_time; - struct list_head list; -}; - -#define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\ - x->u.rx_frame.stats.payload + \ - x->u.rx_frame.stats.phy_count)) -#define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\ - IL_RX_HDR(x)->payload + \ - le16_to_cpu(IL_RX_HDR(x)->len))) -#define IL_RX_STATS(x) (&x->u.rx_frame.stats) -#define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) - - -/****************************************************************************** - * - * Functions implemented in iwl3945-base.c which are forward declared here - * for use by iwl-*.c - * - *****************************************************************************/ -extern int il3945_calc_db_from_ratio(int sig_ratio); -extern void il3945_rx_replenish(void *data); -extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); -extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, int left); -extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, - char **buf, bool display); -extern void il3945_dump_nic_error_log(struct il_priv *il); - -/****************************************************************************** - * - * Functions implemented in iwl-[34]*.c which are forward declared here - * for use by iwl3945-base.c - * - * NOTE: The implementation of these functions are hardware specific - * which is why they are in the hardware specific files (vs. iwl-base.c) - * - * Naming convention -- - * il3945_ <-- Its part of iwlwifi (should be changed to il3945_) - * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) - * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * il3945_bg_ <-- Called from work queue context - * il3945_mac_ <-- mac80211 callback - * - ****************************************************************************/ -extern void il3945_hw_rx_handler_setup(struct il_priv *il); -extern void il3945_hw_setup_deferred_work(struct il_priv *il); -extern void il3945_hw_cancel_deferred_work(struct il_priv *il); -extern int il3945_hw_rxq_stop(struct il_priv *il); -extern int il3945_hw_set_hw_params(struct il_priv *il); -extern int il3945_hw_nic_init(struct il_priv *il); -extern int il3945_hw_nic_stop_master(struct il_priv *il); -extern void il3945_hw_txq_ctx_free(struct il_priv *il); -extern void il3945_hw_txq_ctx_stop(struct il_priv *il); -extern int il3945_hw_nic_reset(struct il_priv *il); -extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad); -extern void il3945_hw_txq_free_tfd(struct il_priv *il, - struct il_tx_queue *txq); -extern int il3945_hw_get_temperature(struct il_priv *il); -extern int il3945_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); -extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate); -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id); -extern int il3945_hw_reg_send_txpower(struct il_priv *il); -extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hw_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il3945_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb); -extern void il3945_disable_events(struct il_priv *il); -extern int il4965_get_temperature(const struct il_priv *il); -extern void il3945_post_associate(struct il_priv *il); -extern void il3945_config_ap(struct il_priv *il); - -extern int il3945_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx); - -/** - * il3945_hw_find_station - Find station id for a given BSSID - * @bssid: MAC address of station ID to find - * - * NOTE: This should not be hardware specific but the code has - * not yet been merged into a single common layer for managing the - * station tables. - */ -extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); - -extern struct ieee80211_ops il3945_hw_ops; - -/* - * Forward declare iwl-3945.c functions for iwl3945-base.c - */ -extern __le32 il3945_get_antenna_flags(const struct il_priv *il); -extern int il3945_init_hw_rate_table(struct il_priv *il); -extern void il3945_reg_txpower_periodic(struct il_priv *il); -extern int il3945_txpower_set_from_eeprom(struct il_priv *il); - -extern const struct il_channel_info *il3945_get_channel_info( - const struct il_priv *il, enum ieee80211_band band, u16 channel); - -extern int il3945_rs_next_rate(struct il_priv *il, int rate); - -/* scanning */ -int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); -void il3945_post_scan(struct il_priv *il); - -/* rates */ -extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; - -/* Requires full declaration of il_priv before including */ -#include "iwl-io.h" - -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 97b2573..f7c3b43 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -45,11 +45,12 @@ #include "iwl-fh.h" #include "iwl-debug.h" #include "4965.h" -#include "iwl-3945-hw.h" #include "iwl-led.h" #include "iwl-power.h" #include "iwl-legacy-rs.h" +#define U32_PAD(n) ((4-(n))&0x3) + struct il_tx_queue; /* CT-KILL constants */ -- cgit v0.10.2 From a6766ccdaf9cc80d565672516d429a562d1a732d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:09:01 +0100 Subject: iwlegacy: s/STATUS_/S_/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 17edbdf..f69211e 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -827,17 +827,17 @@ static void il3945_rx_card_state_notif(struct il_priv *il, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); il_scan_cancel(il); - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) + if ((test_bit(S_RF_KILL_HW, &status) != + test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -1537,7 +1537,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) + if (test_bit(S_INT_ENABLED, &il->status)) il_enable_interrupts(il); #ifdef CONFIG_IWLEGACY_DEBUG @@ -2213,7 +2213,7 @@ static void il3945_alive_start(struct il_priv *il) D_INFO("RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); /* if RFKILL is not on, then wait for thermal * sensor in adapter to kick in */ while (il3945_hw_get_temperature(il) == 0) { @@ -2225,10 +2225,10 @@ static void il3945_alive_start(struct il_priv *il) D_INFO("Thermal calibration took %dus\n", thermal_spin * 10); } else - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); /* After the ALIVE response, we can send commands to 3945 uCode */ - set_bit(STATUS_ALIVE, &il->status); + set_bit(S_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ il_setup_watchdog(il); @@ -2256,7 +2256,7 @@ static void il3945_alive_start(struct il_priv *il) /* Configure Bluetooth device coexistence support */ il_send_bt_config(il); - set_bit(STATUS_READY, &il->status); + set_bit(S_READY, &il->status); /* Configure the adapter for unassociated operation */ il3945_commit_rxon(il, ctx); @@ -2283,9 +2283,9 @@ static void __il3945_down(struct il_priv *il) il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + exit_pending = test_and_set_bit(S_EXIT_PENDING, &il->status); - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + /* Stop TX queues watchdog. We need to have S_EXIT_PENDING bit set * to prevent rearm timer */ del_timer_sync(&il->watchdog); @@ -2300,7 +2300,7 @@ static void __il3945_down(struct il_priv *il) /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); @@ -2317,25 +2317,25 @@ static void __il3945_down(struct il_priv *il) /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status = test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status &= test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_FW_ERROR, &il->status) << + S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; il3945_hw_txq_ctx_stop(il); il3945_hw_rxq_stop(il); @@ -2400,7 +2400,7 @@ static int __il3945_up(struct il_priv *il) if (rc) return rc; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } @@ -2413,9 +2413,9 @@ static int __il3945_up(struct il_priv *il) /* If platform's RF_KILL switch is NOT set to KILL */ if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); else { - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); IL_WARN("Radio disabled by HW RF Kill switch\n"); return -ENODEV; } @@ -2448,7 +2448,7 @@ static int __il3945_up(struct il_priv *il) il->ucode_data.len); /* We return success when we resume from suspend and rf_kill is on. */ - if (test_bit(STATUS_RF_KILL_HW, &il->status)) + if (test_bit(S_RF_KILL_HW, &il->status)) return 0; for (i = 0; i < MAX_HW_RESTARTS; i++) { @@ -2472,9 +2472,9 @@ static int __il3945_up(struct il_priv *il) return 0; } - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); __il3945_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ @@ -2495,7 +2495,7 @@ static void il3945_bg_init_alive_start(struct work_struct *data) container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il3945_init_alive_start(il); @@ -2509,7 +2509,7 @@ static void il3945_bg_alive_start(struct work_struct *data) container_of(data, struct il_priv, alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il3945_alive_start(il); @@ -2527,15 +2527,15 @@ static void il3945_rfkill_poll(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); - bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); + bool old_rfkill = test_bit(S_RF_KILL_HW, &il->status); bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { if (new_rfkill) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); @@ -2682,10 +2682,10 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &il->status); + set_bit(S_SCAN_HW, &il->status); ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(S_SCAN_HW, &il->status); return ret; } @@ -2705,10 +2705,10 @@ static void il3945_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); il->ctx.vif = NULL; il->is_open = 0; @@ -2719,7 +2719,7 @@ static void il3945_bg_restart(struct work_struct *data) il3945_down(il); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { mutex_unlock(&il->mutex); return; } @@ -2735,7 +2735,7 @@ static void il3945_bg_rx_replenish(struct work_struct *data) container_of(data, struct il_priv, rx_replenish); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il3945_rx_replenish(il); @@ -2755,7 +2755,7 @@ void il3945_post_associate(struct il_priv *il) D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; il_scan_cancel_timeout(il, 200); @@ -2847,10 +2847,10 @@ static int il3945_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), + test_bit(S_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { + if (!test_bit(S_READY, &il->status)) { IL_ERR( "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); @@ -2918,7 +2918,7 @@ void il3945_config_ap(struct il_priv *il) struct ieee80211_vif *vif = ctx->vif; int rc = 0; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ @@ -3870,7 +3870,7 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) il_dbgfs_unregister(il); - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); il_leds_exit(il); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 17615c3..8ebd576 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -1008,7 +1008,7 @@ int il3945_hw_nic_init(struct il_priv *il) if (rc) return rc; - set_bit(STATUS_INIT, &il->status); + set_bit(S_INIT, &il->status); return 0; } @@ -1394,7 +1394,7 @@ static int il3945_send_tx_power(struct il_priv *il) }; u16 chan; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; @@ -1571,7 +1571,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) int temperature = il->temperature; if (il->disable_tx_power_cal || - test_bit(STATUS_SCANNING, &il->status)) { + test_bit(S_SCANNING, &il->status)) { /* do not perform tx power calibration */ return 0; } @@ -1726,7 +1726,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) int rc = 0; bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return -EINVAL; if (!il_is_alive(il)) @@ -1885,7 +1885,7 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) struct il_priv *il = container_of(work, struct il_priv, _3945.thermal_periodic.work); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; mutex_lock(&il->mutex); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index ee084a8..c4198bd 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -90,7 +90,7 @@ void il4965_check_abort_status(struct il_priv *il, { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { IL_ERR("Tx flush command to flush out all frames\n"); - if (!test_bit(STATUS_EXIT_PENDING, &il->status)) + if (!test_bit(S_EXIT_PENDING, &il->status)) queue_work(il->workqueue, &il->tx_flush); } } @@ -246,7 +246,7 @@ int il4965_hw_nic_init(struct il_priv *il) } else il4965_txq_ctx_reset(il); - set_bit(STATUS_INIT, &il->status); + set_bit(S_INIT, &il->status); return 0; } @@ -966,7 +966,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { + if (test_bit(S_POWER_PMI, &il->status)) { /* rx_ant has been set to all valid chains previously */ active_chains = rx_ant & ((u8)(il->chain_noise_data.active_chains)); @@ -1010,11 +1010,11 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &il->status); + set_bit(S_SCAN_HW, &il->status); ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(S_SCAN_HW, &il->status); return ret; } @@ -1120,7 +1120,7 @@ static u8 il4965_count_chain_bitmap(u32 chain_bitmap) void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) { bool is_single = il4965_is_single_rx_stream(il); - bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); + bool is_cam = !test_bit(S_POWER_PMI, &il->status); u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; u32 active_chains; u16 rx_chain; @@ -1258,7 +1258,7 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, le32_to_cpu(missed_beacon->total_missed_becons), le32_to_cpu(missed_beacon->num_recvd_beacons), le32_to_cpu(missed_beacon->num_expected_beacons)); - if (!test_bit(STATUS_SCANNING, &il->status)) + if (!test_bit(S_SCANNING, &il->status)) il4965_init_sensitivity(il); } } @@ -1378,7 +1378,7 @@ void il4965_rx_stats(struct il_priv *il, memcpy(&il->_4965.stats, &pkt->u.stats, sizeof(il->_4965.stats)); - set_bit(STATUS_STATISTICS, &il->status); + set_bit(S_STATISTICS, &il->status); /* Reschedule the stats timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a @@ -1387,7 +1387,7 @@ void il4965_rx_stats(struct il_priv *il, mod_timer(&il->stats_periodic, jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); - if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + if (unlikely(!test_bit(S_SCANNING, &il->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { il4965_rx_calc_noise(il); queue_work(il->workqueue, &il->run_time_calib_work); @@ -3809,7 +3809,7 @@ static void il4965_bg_stats_periodic(unsigned long data) { struct il_priv *il = (struct il_priv *)data; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; /* dont send host command if rf-kill is on */ @@ -3895,17 +3895,17 @@ static void il4965_rx_card_state_notif(struct il_priv *il, il4965_perform_ct_kill_task(il); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); if (!(flags & RXON_CARD_DISABLED)) il_scan_cancel(il); - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) + if ((test_bit(S_RF_KILL_HW, &status) != + test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -4199,11 +4199,11 @@ static void il4965_irq_tasklet(struct il_priv *il) * is killed. Hence update the killswitch state here. The * rfkill handler will care about restarting if needed. */ - if (!test_bit(STATUS_ALIVE, &il->status)) { + if (!test_bit(S_ALIVE, &il->status)) { if (hw_rf_kill) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); } @@ -4272,7 +4272,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) + if (test_bit(S_INT_ENABLED, &il->status)) il_enable_interrupts(il); /* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) @@ -5079,7 +5079,7 @@ static void il4965_alive_start(struct il_priv *il) /* After the ALIVE response, we can send host commands to the uCode */ - set_bit(STATUS_ALIVE, &il->status); + set_bit(S_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ il_setup_watchdog(il); @@ -5110,7 +5110,7 @@ static void il4965_alive_start(struct il_priv *il) il4965_reset_run_time_calib(il); - set_bit(STATUS_READY, &il->status); + set_bit(S_READY, &il->status); /* Configure the adapter for unassociated operation */ il_commit_rxon(il, ctx); @@ -5141,9 +5141,9 @@ static void __il4965_down(struct il_priv *il) il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + exit_pending = test_and_set_bit(S_EXIT_PENDING, &il->status); - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + /* Stop TX queues watchdog. We need to have S_EXIT_PENDING bit set * to prevent rearm timer */ del_timer_sync(&il->watchdog); @@ -5157,7 +5157,7 @@ static void __il4965_down(struct il_priv *il) /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); @@ -5174,25 +5174,25 @@ static void __il4965_down(struct il_priv *il) /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status = test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status &= test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_FW_ERROR, &il->status) << + S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; il4965_txq_ctx_stop(il); il4965_rxq_stop(il); @@ -5283,7 +5283,7 @@ static int __il4965_up(struct il_priv *il) int i; int ret; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } @@ -5309,9 +5309,9 @@ static int __il4965_up(struct il_priv *il) /* If platform's RF_KILL switch is NOT set to KILL */ if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); if (il_is_rfkill(il)) { wiphy_rfkill_set_hw_state(il->hw->wiphy, true); @@ -5372,9 +5372,9 @@ static int __il4965_up(struct il_priv *il) return 0; } - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); __il4965_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ @@ -5395,7 +5395,7 @@ static void il4965_bg_init_alive_start(struct work_struct *data) container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il->cfg->ops->lib->init_alive_start(il); @@ -5409,7 +5409,7 @@ static void il4965_bg_alive_start(struct work_struct *data) container_of(data, struct il_priv, alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il4965_alive_start(il); @@ -5424,8 +5424,8 @@ static void il4965_bg_run_time_calib_work(struct work_struct *work) mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status) || + test_bit(S_SCANNING, &il->status)) { mutex_unlock(&il->mutex); return; } @@ -5444,10 +5444,10 @@ static void il4965_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); il->ctx.vif = NULL; il->is_open = 0; @@ -5461,7 +5461,7 @@ static void il4965_bg_restart(struct work_struct *data) il4965_down(il); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { mutex_unlock(&il->mutex); return; } @@ -5476,7 +5476,7 @@ static void il4965_bg_rx_replenish(struct work_struct *data) struct il_priv *il = container_of(data, struct il_priv, rx_replenish); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; mutex_lock(&il->mutex); @@ -5582,10 +5582,10 @@ int il4965_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), + test_bit(S_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { + if (!test_bit(S_READY, &il->status)) { IL_ERR("START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; @@ -5751,7 +5751,7 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_RX_STOP: D_HT("stop Rx\n"); ret = il4965_sta_rx_agg_stop(il, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: @@ -5761,7 +5761,7 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_TX_STOP: D_HT("stop Tx\n"); ret = il4965_tx_agg_stop(il, vif, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_OPERATIONAL: @@ -5833,9 +5833,9 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, if (il_is_rfkill(il)) goto out; - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status) || + test_bit(S_SCANNING, &il->status) || + test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) goto out; if (!il_is_associated_ctx(ctx)) @@ -5891,10 +5891,10 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, * at this point, staging_rxon has the * configuration for channel switch */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + set_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = cpu_to_le16(ch); if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = 0; ieee80211_chswitch_done(ctx->vif, false); } @@ -5968,8 +5968,8 @@ static void il4965_bg_txpower_work(struct work_struct *work) * then just return; the stats notification will * kick off another scheduled work to compensate for * any temperature delta we missed here. */ - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status) || + test_bit(S_SCANNING, &il->status)) goto out; /* Regardless of if we are associated, we must reconfigure the @@ -6376,12 +6376,12 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* If platform's RF_KILL switch is NOT set to KILL */ if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); il_power_initialize(il); @@ -6433,9 +6433,9 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) /* ieee80211_unregister_hw call wil cause il_mac_stop to * to be called and il4965_down since we are removing the device - * we need to set STATUS_EXIT_PENDING bit. + * we need to set S_EXIT_PENDING bit. */ - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); il_leds_exit(il); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 8199e63..1efe824 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1349,7 +1349,7 @@ static int il4965_send_tx_power(struct il_priv *il) u8 ctrl_chan_high = 0; struct il_rxon_context *ctx = &il->ctx; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; @@ -1441,7 +1441,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * receive commit_rxon request * abort any previous channel switch if still in process */ - if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && + if (test_bit(S_CHANNEL_SWITCH_PENDING, &il->status) && il->switch_channel != ctx->staging.channel) { D_11H("abort channel switch on %d\n", le16_to_cpu(il->switch_channel)); @@ -1673,7 +1673,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) s32 R1, R2, R3; u32 R4; - if (test_bit(STATUS_TEMPERATURE, &il->status) && + if (test_bit(S_TEMPERATURE, &il->status) && (il->_4965.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); @@ -1696,7 +1696,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) * with an updated temperature, use R4 provided to us in the * "initialize" ALIVE response. */ - if (!test_bit(STATUS_TEMPERATURE, &il->status)) + if (!test_bit(S_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else vt = sign_extend32(le32_to_cpu(il->_4965.stats. @@ -1737,7 +1737,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - if (!test_bit(STATUS_STATISTICS, &il->status)) { + if (!test_bit(S_STATISTICS, &il->status)) { D_TEMP("Temperature not updated -- no stats.\n"); return 0; } @@ -1784,10 +1784,10 @@ static void il4965_temperature_calib(struct il_priv *il) } il->temperature = temp; - set_bit(STATUS_TEMPERATURE, &il->status); + set_bit(S_TEMPERATURE, &il->status); if (!il->disable_tx_power_cal && - unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + unlikely(!test_bit(S_SCANNING, &il->status)) && il4965_is_temp_calib_needed(il)) queue_work(il->workqueue, &il->txpower_work); } @@ -2179,7 +2179,7 @@ static void il4965_post_associate(struct il_priv *il) if (!vif || !il->is_open) return; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; il_scan_cancel_timeout(il, 200); @@ -2254,7 +2254,7 @@ static void il4965_config_ap(struct il_priv *il) lockdep_assert_held(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index bd222f5..ba7ee4b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -165,7 +165,7 @@ int il_init_geos(struct il_priv *il) if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { D_INFO("Geography modes already initialized.\n"); - set_bit(STATUS_GEO_CONFIGURED, &il->status); + set_bit(S_GEO_CONFIGURED, &il->status); return 0; } @@ -264,7 +264,7 @@ int il_init_geos(struct il_priv *il) il->bands[IEEE80211_BAND_2GHZ].n_channels, il->bands[IEEE80211_BAND_5GHZ].n_channels); - set_bit(STATUS_GEO_CONFIGURED, &il->status); + set_bit(S_GEO_CONFIGURED, &il->status); return 0; } @@ -277,7 +277,7 @@ void il_free_geos(struct il_priv *il) { kfree(il->ieee_channels); kfree(il->ieee_rates); - clear_bit(STATUS_GEO_CONFIGURED, &il->status); + clear_bit(S_GEO_CONFIGURED, &il->status); } EXPORT_SYMBOL(il_free_geos); @@ -839,10 +839,10 @@ void il_chswitch_done(struct il_priv *il, bool is_success) { struct il_rxon_context *ctx = &il->ctx; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } EXPORT_SYMBOL(il_chswitch_done); @@ -855,7 +855,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) struct il_rxon_context *ctx = &il->ctx; struct il_rxon_cmd *rxon = (void *)&ctx->active; - if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) return; if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { @@ -903,10 +903,10 @@ EXPORT_SYMBOL(il_print_rx_config_cmd); void il_irq_handle_error(struct il_priv *il) { /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &il->status); + set_bit(S_FW_ERROR, &il->status); /* Cancel currently queued command. */ - clear_bit(STATUS_HCMD_ACTIVE, &il->status); + clear_bit(S_HCMD_ACTIVE, &il->status); IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); @@ -924,9 +924,9 @@ void il_irq_handle_error(struct il_priv *il) /* Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &il->status); + clear_bit(S_READY, &il->status); - if (!test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (!test_bit(S_EXIT_PENDING, &il->status)) { IL_DBG(IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); @@ -1127,7 +1127,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) il->tx_power_next = tx_power; /* do not set tx power when scanning or channel changing */ - defer = test_bit(STATUS_SCANNING, &il->status) || + defer = test_bit(S_SCANNING, &il->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { D_INFO("Deferring tx power set\n"); @@ -1678,7 +1678,7 @@ int il_force_reset(struct il_priv *il, bool external) { struct il_force_reset *force_reset; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return -EINVAL; force_reset = &il->force_reset; @@ -1713,13 +1713,13 @@ int il_force_reset(struct il_priv *il, bool external) IL_ERR("On demand firmware reload\n"); /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &il->status); + set_bit(S_FW_ERROR, &il->status); wake_up(&il->wait_command_queue); /* * Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &il->status); + clear_bit(S_READY, &il->status); queue_work(il->workqueue, &il->restart); return 0; @@ -1826,7 +1826,7 @@ void il_bg_watchdog(unsigned long data) int cnt; unsigned long timeout; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; timeout = il->cfg->base_params->wd_timeout; @@ -1960,9 +1960,9 @@ int il_pci_resume(struct device *device) hw_rfkill = true; if (hw_rfkill) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); @@ -1985,7 +1985,7 @@ EXPORT_SYMBOL(il_pm_ops); static void il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) { - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; if (!ctx->is_active) @@ -2034,7 +2034,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, changed); - if (unlikely(test_bit(STATUS_SCANNING, &il->status))) { + if (unlikely(test_bit(S_SCANNING, &il->status))) { scan_active = 1; D_MAC80211("scan active\n"); } @@ -2566,7 +2566,7 @@ unplugged: none: /* re-enable interrupts here since we don't have anything to service. */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) + if (test_bit(S_INT_ENABLED, &il->status)) il_enable_interrupts(il); spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 8333761..5b2883f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -533,47 +533,47 @@ void il_free_geos(struct il_priv *il); /*************** DRIVER STATUS FUNCTIONS *****/ -#define STATUS_HCMD_ACTIVE 0 /* host command in progress */ -/* 1 is unused (used to be STATUS_HCMD_SYNC_ACTIVE) */ -#define STATUS_INT_ENABLED 2 -#define STATUS_RF_KILL_HW 3 -#define STATUS_CT_KILL 4 -#define STATUS_INIT 5 -#define STATUS_ALIVE 6 -#define STATUS_READY 7 -#define STATUS_TEMPERATURE 8 -#define STATUS_GEO_CONFIGURED 9 -#define STATUS_EXIT_PENDING 10 -#define STATUS_STATISTICS 12 -#define STATUS_SCANNING 13 -#define STATUS_SCAN_ABORTING 14 -#define STATUS_SCAN_HW 15 -#define STATUS_POWER_PMI 16 -#define STATUS_FW_ERROR 17 -#define STATUS_CHANNEL_SWITCH_PENDING 18 +#define S_HCMD_ACTIVE 0 /* host command in progress */ +/* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */ +#define S_INT_ENABLED 2 +#define S_RF_KILL_HW 3 +#define S_CT_KILL 4 +#define S_INIT 5 +#define S_ALIVE 6 +#define S_READY 7 +#define S_TEMPERATURE 8 +#define S_GEO_CONFIGURED 9 +#define S_EXIT_PENDING 10 +#define S_STATISTICS 12 +#define S_SCANNING 13 +#define S_SCAN_ABORTING 14 +#define S_SCAN_HW 15 +#define S_POWER_PMI 16 +#define S_FW_ERROR 17 +#define S_CHANNEL_SWITCH_PENDING 18 static inline int il_is_ready(struct il_priv *il) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ - return test_bit(STATUS_READY, &il->status) && - test_bit(STATUS_GEO_CONFIGURED, &il->status) && - !test_bit(STATUS_EXIT_PENDING, &il->status); + return test_bit(S_READY, &il->status) && + test_bit(S_GEO_CONFIGURED, &il->status) && + !test_bit(S_EXIT_PENDING, &il->status); } static inline int il_is_alive(struct il_priv *il) { - return test_bit(STATUS_ALIVE, &il->status); + return test_bit(S_ALIVE, &il->status); } static inline int il_is_init(struct il_priv *il) { - return test_bit(STATUS_INIT, &il->status); + return test_bit(S_INIT, &il->status); } static inline int il_is_rfkill_hw(struct il_priv *il) { - return test_bit(STATUS_RF_KILL_HW, &il->status); + return test_bit(S_RF_KILL_HW, &il->status); } static inline int il_is_rfkill(struct il_priv *il) @@ -583,7 +583,7 @@ static inline int il_is_rfkill(struct il_priv *il) static inline int il_is_ctkill(struct il_priv *il) { - return test_bit(STATUS_CT_KILL, &il->status); + return test_bit(S_CT_KILL, &il->status); } static inline int il_is_ready_rf(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 8448db7..114922b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -402,7 +402,7 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, char *buf; ssize_t ret; - if (!test_bit(STATUS_GEO_CONFIGURED, &il->status)) + if (!test_bit(S_GEO_CONFIGURED, &il->status)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); @@ -471,38 +471,38 @@ static ssize_t il_dbgfs_status_read(struct file *file, int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", - test_bit(STATUS_HCMD_ACTIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", - test_bit(STATUS_INT_ENABLED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", - test_bit(STATUS_RF_KILL_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", - test_bit(STATUS_CT_KILL, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", - test_bit(STATUS_INIT, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", - test_bit(STATUS_ALIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", - test_bit(STATUS_READY, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", - test_bit(STATUS_TEMPERATURE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", - test_bit(STATUS_GEO_CONFIGURED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", - test_bit(STATUS_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", - test_bit(STATUS_STATISTICS, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", - test_bit(STATUS_SCANNING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", - test_bit(STATUS_SCAN_ABORTING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", - test_bit(STATUS_SCAN_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", - test_bit(STATUS_POWER_PMI, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", - test_bit(STATUS_FW_ERROR, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", + test_bit(S_HCMD_ACTIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", + test_bit(S_INT_ENABLED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", + test_bit(S_RF_KILL_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", + test_bit(S_CT_KILL, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", + test_bit(S_INIT, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", + test_bit(S_ALIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", + test_bit(S_READY, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", + test_bit(S_TEMPERATURE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", + test_bit(S_GEO_CONFIGURED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", + test_bit(S_EXIT_PENDING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_STATISTICS:\t %d\n", + test_bit(S_STATISTICS, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", + test_bit(S_SCANNING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", + test_bit(S_SCAN_ABORTING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", + test_bit(S_SCAN_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", + test_bit(S_POWER_PMI, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", + test_bit(S_FW_ERROR, &il->status)); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 0b11f2f..4762a0e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -128,7 +128,7 @@ il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) if (!cmd->callback) cmd->callback = il_generic_cmd_callback; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return -EBUSY; ret = il_enqueue_hcmd(il, cmd); @@ -155,7 +155,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) D_INFO("Attempting to send sync command %s\n", il_get_cmd_string(cmd->id)); - set_bit(STATUS_HCMD_ACTIVE, &il->status); + set_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Setting HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); @@ -168,16 +168,16 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) } ret = wait_event_timeout(il->wait_command_queue, - !test_bit(STATUS_HCMD_ACTIVE, &il->status), + !test_bit(S_HCMD_ACTIVE, &il->status), HOST_COMPLETE_TIMEOUT); if (!ret) { - if (test_bit(STATUS_HCMD_ACTIVE, &il->status)) { + if (test_bit(S_HCMD_ACTIVE, &il->status)) { IL_ERR( "Error sending %s: time out after %dms.\n", il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - clear_bit(STATUS_HCMD_ACTIVE, &il->status); + clear_bit(S_HCMD_ACTIVE, &il->status); D_INFO( "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); @@ -186,13 +186,13 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) } } - if (test_bit(STATUS_RF_KILL_HW, &il->status)) { + if (test_bit(S_RF_KILL_HW, &il->status)) { IL_ERR("Command %s aborted: RF KILL Switch\n", il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } - if (test_bit(STATUS_FW_ERROR, &il->status)) { + if (test_bit(S_FW_ERROR, &il->status)) { IL_ERR("Command %s failed: FW Error\n", il_get_cmd_string(cmd->id)); ret = -EIO; diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index 5fcb23e..0e64003 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -146,7 +146,7 @@ static inline void il_stop_queue(struct il_priv *il, static inline void il_disable_interrupts(struct il_priv *il) { - clear_bit(STATUS_INT_ENABLED, &il->status); + clear_bit(S_INT_ENABLED, &il->status); /* disable interrupts from uCode/NIC to host */ _il_wr(il, CSR_INT_MASK, 0x00000000); @@ -167,7 +167,7 @@ static inline void il_enable_rfkill_int(struct il_priv *il) static inline void il_enable_interrupts(struct il_priv *il) { D_ISR("Enabling interrupts\n"); - set_bit(STATUS_INT_ENABLED, &il->status); + set_bit(S_INT_ENABLED, &il->status); _il_wr(il, CSR_INT_MASK, il->inta_mask); } diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 3652cdc..a840c2e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -107,7 +107,7 @@ static int il_led_cmd(struct il_priv *il, }; int ret; - if (!test_bit(STATUS_READY, &il->status)) + if (!test_bit(S_READY, &il->status)) return -EBUSY; if (il->blink_on == on && il->blink_off == off) diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 051623a..c66a0f7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -113,18 +113,18 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, /* scan complete use sleep_power_next, need to be updated */ memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); - if (test_bit(STATUS_SCANNING, &il->status) && !force) { + if (test_bit(S_SCANNING, &il->status) && !force) { D_INFO("Defer power set mode while scanning\n"); return 0; } if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) - set_bit(STATUS_POWER_PMI, &il->status); + set_bit(S_POWER_PMI, &il->status); ret = il_set_power(il, cmd); if (!ret) { if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) - clear_bit(STATUS_POWER_PMI, &il->status); + clear_bit(S_POWER_PMI, &il->status); if (il->cfg->ops->lib->update_chain_flags && update_chains) il->cfg->ops->lib->update_chain_flags(il); diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 58d19c1..76f2361 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -137,7 +137,7 @@ il_rx_queue_update_write_ptr(struct il_priv *il, goto exit_unlock; /* If power-saving is in use, make sure device is awake */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { + if (test_bit(S_POWER_PMI, &il->status)) { reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 18226d1..6d20f2b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -66,11 +66,11 @@ static int il_send_scan_abort(struct il_priv *il) /* Exit instantly with error when device is not ready * to receive scan abort command or it does not perform * hardware scan currently */ - if (!test_bit(STATUS_READY, &il->status) || - !test_bit(STATUS_GEO_CONFIGURED, &il->status) || - !test_bit(STATUS_SCAN_HW, &il->status) || - test_bit(STATUS_FW_ERROR, &il->status) || - test_bit(STATUS_EXIT_PENDING, &il->status)) + if (!test_bit(S_READY, &il->status) || + !test_bit(S_GEO_CONFIGURED, &il->status) || + !test_bit(S_SCAN_HW, &il->status) || + test_bit(S_FW_ERROR, &il->status) || + test_bit(S_EXIT_PENDING, &il->status)) return -EIO; ret = il_send_cmd_sync(il, &cmd); @@ -109,15 +109,15 @@ void il_force_scan_end(struct il_priv *il) { lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &il->status)) { + if (!test_bit(S_SCANNING, &il->status)) { D_SCAN("Forcing scan end while not scanning\n"); return; } D_SCAN("Forcing scan end\n"); - clear_bit(STATUS_SCANNING, &il->status); - clear_bit(STATUS_SCAN_HW, &il->status); - clear_bit(STATUS_SCAN_ABORTING, &il->status); + clear_bit(S_SCANNING, &il->status); + clear_bit(S_SCAN_HW, &il->status); + clear_bit(S_SCAN_ABORTING, &il->status); il_complete_scan(il, true); } @@ -127,12 +127,12 @@ static void il_do_scan_abort(struct il_priv *il) lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &il->status)) { + if (!test_bit(S_SCANNING, &il->status)) { D_SCAN("Not performing scan to abort\n"); return; } - if (test_and_set_bit(STATUS_SCAN_ABORTING, &il->status)) { + if (test_and_set_bit(S_SCAN_ABORTING, &il->status)) { D_SCAN("Scan abort in progress\n"); return; } @@ -172,12 +172,12 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) il_do_scan_abort(il); while (time_before_eq(jiffies, timeout)) { - if (!test_bit(STATUS_SCAN_HW, &il->status)) + if (!test_bit(S_SCAN_HW, &il->status)) break; msleep(20); } - return test_bit(STATUS_SCAN_HW, &il->status); + return test_bit(S_SCAN_HW, &il->status); } EXPORT_SYMBOL(il_scan_cancel_timeout); @@ -251,7 +251,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, scan_notif->tsf_high, scan_notif->status); /* The HW is no longer scanning */ - clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(S_SCAN_HW, &il->status); D_SCAN("Scan on %sGHz took %dms\n", (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", @@ -341,25 +341,25 @@ static int il_scan_initiate(struct il_priv *il, return -EIO; } - if (test_bit(STATUS_SCAN_HW, &il->status)) { + if (test_bit(S_SCAN_HW, &il->status)) { D_SCAN( "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } - if (test_bit(STATUS_SCAN_ABORTING, &il->status)) { + if (test_bit(S_SCAN_ABORTING, &il->status)) { D_SCAN("Scan request while abort pending.\n"); return -EBUSY; } D_SCAN("Starting scan...\n"); - set_bit(STATUS_SCANNING, &il->status); + set_bit(S_SCANNING, &il->status); il->scan_start = jiffies; ret = il->cfg->ops->utils->request_scan(il, vif); if (ret) { - clear_bit(STATUS_SCANNING, &il->status); + clear_bit(S_SCANNING, &il->status); return ret; } @@ -383,7 +383,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, mutex_lock(&il->mutex); - if (test_bit(STATUS_SCANNING, &il->status)) { + if (test_bit(S_SCANNING, &il->status)) { D_SCAN("Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; @@ -494,11 +494,11 @@ static void il_bg_scan_completed(struct work_struct *work) mutex_lock(&il->mutex); - aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &il->status); + aborted = test_and_clear_bit(S_SCAN_ABORTING, &il->status); if (aborted) D_SCAN("Aborted scan completed.\n"); - if (!test_and_clear_bit(STATUS_SCANNING, &il->status)) { + if (!test_and_clear_bit(S_SCANNING, &il->status)) { D_SCAN("Scan already completed.\n"); goto out_settings; } diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index e46e588..3f97d09 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -51,7 +51,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) return; /* if we're trying to save power */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { + if (test_bit(S_POWER_PMI, &il->status)) { /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ @@ -641,7 +641,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); if (!(meta->flags & CMD_ASYNC)) { - clear_bit(STATUS_HCMD_ACTIVE, &il->status); + clear_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->hdr.cmd)); wake_up(&il->wait_command_queue); -- cgit v0.10.2 From db7746f78cab25ee39dd20f61d9b2e6b5993d8fa Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:11:50 +0100 Subject: iwlegacy: s/STATISTICS/STATS/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 9c837c3..fc2d651 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -37,16 +37,16 @@ static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", le32_to_cpu(il->_3945.stats.flag)); if (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_CLEAR_MSK) + UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_FREQUENCY_MSK) + UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_NARROW_BAND_MSK) + UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; } diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index f69211e..2ff8075 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -869,8 +869,8 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; + il->rx_handlers[REPLY_STATS_CMD] = il3945_reply_stats; + il->rx_handlers[STATS_NOTIFICATION] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; @@ -1253,7 +1253,7 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != STATISTICS_NOTIFICATION && + pkt->hdr.cmd != STATS_NOTIFICATION && pkt->hdr.cmd != REPLY_TX; /* Based on type of command response or notification, diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 8ebd576..82534a2 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -432,7 +432,7 @@ void il3945_reply_stats(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; - if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { + if (le32_to_cpu(*flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_3945.accum_stats, 0, sizeof(struct il3945_notif_stats)); diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 1d0502e..cd61050 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -853,7 +853,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) stat_band24 = !!(((struct il_notif_stats *) stat_resp)->flag & - STATISTICS_REPLY_FLG_BAND_24G_MSK); + STATS_REPLY_FLG_BAND_24G_MSK); stat_chnum = le32_to_cpu(((struct il_notif_stats *) stat_resp)->flag) >> 16; diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 825d0aa..ad9c6d0 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -42,14 +42,14 @@ static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) flag = le32_to_cpu(il->_4965.stats.flag); p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); - if (flag & UCODE_STATISTICS_CLEAR_MSK) + if (flag & UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (flag & UCODE_STATISTICS_FREQUENCY_MSK) + (flag & UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (flag & UCODE_STATISTICS_NARROW_BAND_MSK) + (flag & UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index c4198bd..c3f8137 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1367,9 +1367,9 @@ void il4965_rx_stats(struct il_priv *il, change = ((il->_4965.stats.general.common.temperature != pkt->u.stats.general.common.temperature) || ((il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK) != + STATS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK))); + STATS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); #endif @@ -1378,7 +1378,7 @@ void il4965_rx_stats(struct il_priv *il, memcpy(&il->_4965.stats, &pkt->u.stats, sizeof(il->_4965.stats)); - set_bit(S_STATISTICS, &il->status); + set_bit(S_STATS, &il->status); /* Reschedule the stats timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a @@ -1388,7 +1388,7 @@ void il4965_rx_stats(struct il_priv *il, msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(S_SCANNING, &il->status)) && - (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { + (pkt->hdr.cmd == STATS_NOTIFICATION)) { il4965_rx_calc_noise(il); queue_work(il->workqueue, &il->run_time_calib_work); } @@ -1401,7 +1401,7 @@ void il4965_reply_stats(struct il_priv *il, { struct il_rx_pkt *pkt = rxb_addr(rxb); - if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { + if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_4965.accum_stats, 0, sizeof(struct il_notif_stats)); @@ -3801,7 +3801,7 @@ static void il4965_rx_reply_alive(struct il_priv *il, * This callback is provided in order to send a stats request. * * This timer function is continually reset to execute within - * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION + * REG_RECALIB_PERIOD seconds since the last STATS_NOTIFICATION * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ @@ -3936,8 +3936,8 @@ static void il4965_setup_rx_handlers(struct il_priv *il) * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; + il->rx_handlers[REPLY_STATS_CMD] = il4965_reply_stats; + il->rx_handlers[STATS_NOTIFICATION] = il4965_rx_stats; il_setup_rx_scan_handlers(il); @@ -4023,7 +4023,7 @@ void il4965_rx_handle(struct il_priv *il) (pkt->hdr.cmd != REPLY_RX) && (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && - (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && + (pkt->hdr.cmd != STATS_NOTIFICATION) && (pkt->hdr.cmd != REPLY_TX); /* Based on type of command response or notification, diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 1efe824..361a1ca 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1675,7 +1675,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) if (test_bit(S_TEMPERATURE, &il->status) && (il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { + STATS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); @@ -1737,7 +1737,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - if (!test_bit(S_STATISTICS, &il->status)) { + if (!test_bit(S_STATS, &il->status)) { D_TEMP("Temperature not updated -- no stats.\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index b1a01c9..85c3a49 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -278,8 +278,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * uCode provides all 4 values to the driver via the "initialize alive" * notification (see struct il4965_init_alive_resp). After the runtime uCode * image loads, uCode updates the R4 value via stats notifications - * (see STATISTICS_NOTIFICATION), which occur after each received beacon - * when associated, or can be requested via REPLY_STATISTICS_CMD. + * (see STATS_NOTIFICATION), which occur after each received beacon + * when associated, or can be requested via REPLY_STATS_CMD. * * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver * must sign-extend to 32 bits before applying formula below. diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 55822da..1a6ca36 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -136,8 +136,8 @@ enum { REPLY_BT_CONFIG = 0x9b, /* Statistics */ - REPLY_STATISTICS_CMD = 0x9c, - STATISTICS_NOTIFICATION = 0x9d, + REPLY_STATS_CMD = 0x9c, + STATS_NOTIFICATION = 0x9d, /* RF-KILL commands and notifications */ CARD_STATE_NOTIFICATION = 0xa1, @@ -2626,7 +2626,7 @@ struct il_scanstart_notification { #define IL_PROBE_STATUS_FAIL_TTL BIT(1) #define IL_PROBE_STATUS_FAIL_BT BIT(2) -#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */ +#define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ /* * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) */ @@ -2637,7 +2637,7 @@ struct il_scanresults_notification { u8 num_probe_not_sent; /* not enough time to send */ __le32 tsf_low; __le32 tsf_high; - __le32 stats[NUMBER_OF_STATISTICS]; + __le32 stats[NUMBER_OF_STATS]; } __packed; /* @@ -2958,24 +2958,24 @@ struct stats_general { __le32 reserved3; } __packed; -#define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0) -#define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1) -#define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2) +#define UCODE_STATS_CLEAR_MSK (0x1 << 0) +#define UCODE_STATS_FREQUENCY_MSK (0x1 << 1) +#define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) /* - * REPLY_STATISTICS_CMD = 0x9c, + * REPLY_STATS_CMD = 0x9c, * all devices identical. * * This command triggers an immediate response containing uCode stats. - * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below. + * The response is in the same format as STATS_NOTIFICATION 0x9d, below. * * If the CLEAR_STATS configuration flag is set, uCode will clear its * internal copy of the stats (counters) after issuing the response. - * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below). + * This flag does not affect STATS_NOTIFICATIONs after beacons (see below). * * If the DISABLE_NOTIF configuration flag is set, uCode will not issue - * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag - * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself. + * STATS_NOTIFICATIONs after received beacons (see below). This flag + * does not affect the response to the REPLY_STATS_CMD 0x9c itself. */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ #define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ @@ -2984,22 +2984,22 @@ struct il_stats_cmd { } __packed; /* - * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command) + * STATS_NOTIFICATION = 0x9d (notification only, not a command) * * By default, uCode issues this notification after receiving a beacon * while associated. To disable this behavior, set DISABLE_NOTIF flag in the - * REPLY_STATISTICS_CMD 0x9c, above. + * REPLY_STATS_CMD 0x9c, above. * * Statistics counters continue to increment beacon after beacon, but are - * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD + * cleared when changing channels or when driver issues REPLY_STATS_CMD * 0x9c with CLEAR_STATS bit set (see above). * * uCode also issues this notification during scans. uCode clears stats * appropriately so that each notification contains stats for only the * one channel that has just been scanned. */ -#define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) -#define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) +#define STATS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) +#define STATS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) struct il3945_notif_stats { __le32 flag; @@ -3076,7 +3076,7 @@ struct il_missed_beacon_notif { * time listening, not transmitting). Driver must adjust sensitivity so that * the ratio of actual false alarms to actual Rx time falls within this range. * - * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each + * While associated, uCode delivers STATS_NOTIFICATIONs after each * received beacon. These provide information to the driver to analyze the * sensitivity. Don't analyze stats that come in from scanning, or any * other non-associated-network source. Pertinent stats include: @@ -3255,7 +3255,7 @@ struct il_sensitivity_cmd { * This command sets the relative gains of 4965 device's 3 radio receiver chains. * * After the first association, driver should accumulate signal and noise - * stats from the STATISTICS_NOTIFICATIONs that follow the first 20 + * stats from the STATS_NOTIFICATIONs that follow the first 20 * beacons from the associated network (don't collect stats that come * in from scanning, or any other non-network source). * diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index ba7ee4b..e6c7d5f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1179,11 +1179,11 @@ int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu_async(il, REPLY_STATS_CMD, sizeof(struct il_stats_cmd), &stats_cmd, NULL); else - return il_send_cmd_pdu(il, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu(il, REPLY_STATS_CMD, sizeof(struct il_stats_cmd), &stats_cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 5b2883f..e275ffc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -544,7 +544,7 @@ void il_free_geos(struct il_priv *il); #define S_TEMPERATURE 8 #define S_GEO_CONFIGURED 9 #define S_EXIT_PENDING 10 -#define S_STATISTICS 12 +#define S_STATS 12 #define S_SCANNING 13 #define S_SCAN_ABORTING 14 #define S_SCAN_HW 15 diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 114922b..b9888ac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -491,8 +491,8 @@ static ssize_t il_dbgfs_status_read(struct file *file, test_bit(S_GEO_CONFIGURED, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", test_bit(S_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_STATISTICS:\t %d\n", - test_bit(S_STATISTICS, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", + test_bit(S_STATS, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", test_bit(S_SCANNING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 4762a0e..19a5955 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -70,8 +70,8 @@ const char *il_get_cmd_string(u8 cmd) IL_CMD(REPLY_TX_BEACON); IL_CMD(REPLY_TX_PWR_TBL_CMD); IL_CMD(REPLY_BT_CONFIG); - IL_CMD(REPLY_STATISTICS_CMD); - IL_CMD(STATISTICS_NOTIFICATION); + IL_CMD(REPLY_STATS_CMD); + IL_CMD(STATS_NOTIFICATION); IL_CMD(CARD_STATE_NOTIFICATION); IL_CMD(MISSED_BEACONS_NOTIFICATION); IL_CMD(REPLY_CT_KILL_CONFIG_CMD); -- cgit v0.10.2 From 4d69c7521a90cba945b4720672b4511b1e541189 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 15:26:35 +0200 Subject: iwlegacy: rename REPLY_ to N_ or C_ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 2ff8075..65cab846 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -348,7 +348,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il) frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il3945_free_frame(il, frame); @@ -406,7 +406,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, } /* - * handle build REPLY_TX command notification. + * handle build C_TX command notification. */ static void il3945_build_tx_cmd_basic(struct il_priv *il, struct il_device_cmd *cmd, @@ -460,7 +460,7 @@ static void il3945_build_tx_cmd_basic(struct il_priv *il, } /* - * start REPLY_TX command process + * start C_TX command process */ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) { @@ -560,7 +560,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ - out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.cmd = C_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); @@ -672,7 +672,7 @@ static int il3945_get_measurement(struct il_priv *il, struct il_spectrum_cmd spectrum; struct il_rx_pkt *pkt; struct il_host_cmd cmd = { - .id = REPLY_SPECTRUM_MEASUREMENT_CMD, + .id = C_SPECTRUM_MEASUREMENT, .data = (void *)&spectrum, .flags = CMD_WANT_SKB, }; @@ -717,7 +717,7 @@ static int il3945_get_measurement(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); + IL_ERR("Bad return from N_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -786,7 +786,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); #endif - D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + D_RX("Received C_ADD_STA: 0x%02X\n", pkt->u.status); } static void il3945_rx_beacon_notif(struct il_priv *il, @@ -853,27 +853,27 @@ static void il3945_rx_card_state_notif(struct il_priv *il, */ static void il3945_setup_rx_handlers(struct il_priv *il) { - il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; - il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[N_ALIVE] = il3945_rx_reply_alive; + il->rx_handlers[C_ADD_STA] = il3945_rx_reply_add_sta; + il->rx_handlers[N_ERROR] = il_rx_reply_error; + il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->rx_handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->rx_handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; + il->rx_handlers[N_BEACON] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATS_CMD] = il3945_reply_stats; - il->rx_handlers[STATS_NOTIFICATION] = il3945_hw_rx_stats; + il->rx_handlers[C_STATS] = il3945_reply_stats; + il->rx_handlers[N_STATS] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); - il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; + il->rx_handlers[N_CARD_STATE] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ il3945_hw_rx_handler_setup(il); @@ -1253,8 +1253,8 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != STATS_NOTIFICATION && - pkt->hdr.cmd != REPLY_TX; + pkt->hdr.cmd != N_STATS && + pkt->hdr.cmd != C_TX; /* Based on type of command response or notification, * handle those that need handling via function in @@ -2137,9 +2137,9 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) } /** - * il3945_init_alive_start - Called after REPLY_ALIVE notification received + * il3945_init_alive_start - Called after N_ALIVE notification received * - * Called after REPLY_ALIVE notification received from "initialize" uCode. + * Called after N_ALIVE notification received from "initialize" uCode. * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ @@ -2180,7 +2180,7 @@ static void il3945_init_alive_start(struct il_priv *il) } /** - * il3945_alive_start - called after REPLY_ALIVE notification received + * il3945_alive_start - called after N_ALIVE notification received * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il3945_init_alive_start()). */ @@ -2553,7 +2553,7 @@ static void il3945_rfkill_poll(struct work_struct *data) int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, + .id = C_SCAN, .len = sizeof(struct il3945_scan_cmd), .flags = CMD_SIZE_HUGE, }; @@ -2767,7 +2767,7 @@ void il3945_post_associate(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " + IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2931,7 +2931,7 @@ void il3945_config_ap(struct il_priv *il) /* RXON Timing */ rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " + IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -3657,12 +3657,12 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->ctx.ctxid = 0; - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.rxon_cmd = C_RXON; + il->ctx.rxon_timing_cmd = C_RXON_TIMING; + il->ctx.rxon_assoc_cmd = C_RXON_ASSOC; + il->ctx.qos_cmd = C_QOS_PARAM; il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 82534a2..ba250f7 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -53,7 +53,7 @@ static int il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, + .id = C_LEDS, .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, @@ -1444,7 +1444,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].rate); } - return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, + return il_send_cmd_pdu(il, C_TX_PWR_TBL, sizeof(struct il3945_txpowertable_cmd), &txpower); @@ -1673,7 +1673,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, struct il_rx_pkt *pkt; struct il3945_rxon_assoc_cmd rxon_assoc; struct il_host_cmd cmd = { - .id = REPLY_RXON_ASSOC, + .id = C_RXON_ASSOC, .len = sizeof(rxon_assoc), .flags = CMD_WANT_SKB, .data = &rxon_assoc, @@ -1701,7 +1701,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); + IL_ERR("Bad return from C_RXON_ASSOC command\n"); rc = -EIO; } @@ -1782,7 +1782,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(il, REPLY_RXON, + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), &il->ctx.active); @@ -1818,7 +1818,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = il_send_cmd_pdu(il, REPLY_RXON, + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { @@ -2237,9 +2237,9 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { - case REPLY_RXON: + case C_RXON: return sizeof(struct il3945_rxon_cmd); - case POWER_TBL_CMD: + case C_POWER_TBL: return sizeof(struct il3945_powertable_cmd); default: return len; @@ -2383,14 +2383,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + rc = il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + return il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } @@ -2464,8 +2464,8 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, void il3945_hw_rx_handler_setup(struct il_priv *il) { - il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; - il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; + il->rx_handlers[C_TX] = il3945_rx_reply_tx; + il->rx_handlers[N_3945_RX] = il3945_rx_reply_rx; } void il3945_hw_setup_deferred_work(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index cd61050..c5dcc52 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -410,13 +410,13 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, data->nrg_th_cck); } -/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ +/* Prepare a C_SENSITIVITY, send to uCode if values have changed */ static int il4965_sensitivity_write(struct il_priv *il) { struct il_sensitivity_cmd cmd; struct il_sensitivity_data *data = NULL; struct il_host_cmd cmd_out = { - .id = SENSITIVITY_CMD, + .id = C_SENSITIVITY, .len = sizeof(struct il_sensitivity_cmd), .flags = CMD_ASYNC, .data = &cmd, @@ -429,12 +429,12 @@ static int il4965_sensitivity_write(struct il_priv *il) il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ - cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; + cmd.control = C_SENSITIVITY_CONTROL_WORK_TBL; /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), sizeof(u16)*HD_TBL_SIZE)) { - D_CALIB("No change in SENSITIVITY_CMD\n"); + D_CALIB("No change in C_SENSITIVITY\n"); return 0; } @@ -776,11 +776,11 @@ static void il4965_gain_computation(struct il_priv *il, cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + ret = il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd); if (ret) D_CALIB("fail sending cmd " - "REPLY_PHY_CALIBRATION_CMD\n"); + "C_PHY_CALIBRATION\n"); /* TODO we might want recalculate * rx_chain in rxon cmd */ diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index c3f8137..098d863 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -608,8 +608,8 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, rxb->page = NULL; } -/* Called for REPLY_RX (legacy ABG frames), or - * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ +/* Called for N_RX (legacy ABG frames), or + * N_RX_MPDU (HT high-throughput N frames). */ void il4965_rx_reply_rx(struct il_priv *il, struct il_rx_buf *rxb) { @@ -624,15 +624,15 @@ void il4965_rx_reply_rx(struct il_priv *il, u32 rate_n_flags; /** - * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. - * REPLY_RX: physical layer info is in this buffer - * REPLY_RX_MPDU_CMD: physical layer info was sent in separate + * N_RX and N_RX_MPDU are handled differently. + * N_RX: physical layer info is in this buffer + * N_RX_MPDU: physical layer info was sent in separate * command and cached in il->last_phy_res * * Here we set up local variables depending on which command is * received. */ - if (pkt->hdr.cmd == REPLY_RX) { + if (pkt->hdr.cmd == N_RX) { phy_res = (struct il_rx_phy_res *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + phy_res->cfg_phy_cnt); @@ -728,8 +728,8 @@ void il4965_rx_reply_rx(struct il_priv *il, rxb, &rx_status); } -/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). - * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ +/* Cache phy data (Rx signal strength, etc) for HT frame (N_RX_PHY). + * This will be used later in il_rx_reply_rx() for N_RX_MPDU. */ void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_buf *rxb) { @@ -827,7 +827,7 @@ static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, + .id = C_SCAN, .len = sizeof(struct il_scan_cmd), .flags = CMD_SIZE_HUGE, }; @@ -1388,7 +1388,7 @@ void il4965_rx_stats(struct il_priv *il, msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(S_SCANNING, &il->status)) && - (pkt->hdr.cmd == STATS_NOTIFICATION)) { + (pkt->hdr.cmd == N_STATS)) { il4965_rx_calc_noise(il); queue_work(il->workqueue, &il->run_time_calib_work); } @@ -1473,7 +1473,7 @@ il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) } /* - * handle build REPLY_TX command notification. + * handle build C_TX command notification. */ static void il4965_tx_cmd_build_basic(struct il_priv *il, struct sk_buff *skb, @@ -1640,7 +1640,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, } /* - * start REPLY_TX command process + * start C_TX command process */ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) { @@ -1797,7 +1797,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ - out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.cmd = C_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); @@ -2616,7 +2616,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, } /** - * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA + * il4965_rx_reply_compressed_ba - Handler for N_COMPRESSED_BA * * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. @@ -2668,7 +2668,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); - D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " + D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, @@ -2917,7 +2917,7 @@ int il4965_remove_default_wep_key(struct il_priv *il, memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); if (il_is_rfkill(il)) { D_WEP( - "Not sending REPLY_WEPKEY command due to RFKILL.\n"); + "Not sending C_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } @@ -3201,7 +3201,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, if (il_is_rfkill(il)) { D_WEP( - "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); + "Not sending C_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } @@ -3598,7 +3598,7 @@ int il4965_send_beacon_cmd(struct il_priv *il) return -EINVAL; } - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il4965_free_frame(il, frame); @@ -3801,7 +3801,7 @@ static void il4965_rx_reply_alive(struct il_priv *il, * This callback is provided in order to send a stats request. * * This timer function is continually reset to execute within - * REG_RECALIB_PERIOD seconds since the last STATS_NOTIFICATION + * REG_RECALIB_PERIOD seconds since the last N_STATS * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ @@ -3921,37 +3921,37 @@ static void il4965_rx_card_state_notif(struct il_priv *il, */ static void il4965_setup_rx_handlers(struct il_priv *il) { - il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[N_ALIVE] = il4965_rx_reply_alive; + il->rx_handlers[N_ERROR] = il_rx_reply_error; + il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->rx_handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->rx_handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATS_CMD] = il4965_reply_stats; - il->rx_handlers[STATS_NOTIFICATION] = il4965_rx_stats; + il->rx_handlers[C_STATS] = il4965_reply_stats; + il->rx_handlers[N_STATS] = il4965_rx_stats; il_setup_rx_scan_handlers(il); /* status change handler */ - il->rx_handlers[CARD_STATE_NOTIFICATION] = + il->rx_handlers[N_CARD_STATE] = il4965_rx_card_state_notif; - il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = + il->rx_handlers[N_MISSED_BEACONS] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; - il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; + il->rx_handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; + il->rx_handlers[N_RX_MPDU] = il4965_rx_reply_rx; /* block ack */ - il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->rx_handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ il->cfg->ops->lib->rx_handler_setup(il); } @@ -4019,12 +4019,12 @@ void il4965_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && - (pkt->hdr.cmd != REPLY_RX) && - (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && - (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && - (pkt->hdr.cmd != STATS_NOTIFICATION) && - (pkt->hdr.cmd != REPLY_TX); + (pkt->hdr.cmd != N_RX_PHY) && + (pkt->hdr.cmd != N_RX) && + (pkt->hdr.cmd != N_RX_MPDU) && + (pkt->hdr.cmd != N_COMPRESSED_BA) && + (pkt->hdr.cmd != N_STATS) && + (pkt->hdr.cmd != C_TX); /* Based on type of command response or notification, * handle those that need handling via function in @@ -4923,12 +4923,12 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) cmd.critical_temperature_R = cpu_to_le32(il->hw_params.ct_kill_threshold); - ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, + ret = il_send_cmd_pdu(il, C_CT_KILL_CONFIG, sizeof(cmd), &cmd); if (ret) - IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR("C_CT_KILL_CONFIG failed\n"); else - D_INFO("REPLY_CT_KILL_CONFIG_CMD " + D_INFO("C_CT_KILL_CONFIG " "succeeded, " "critical temperature is %d\n", il->hw_params.ct_kill_threshold); @@ -5042,7 +5042,7 @@ static int il4965_alive_notify(struct il_priv *il) } /** - * il4965_alive_start - called after REPLY_ALIVE notification received + * il4965_alive_start - called after N_ALIVE notification received * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il_init_alive_start()). */ @@ -6200,12 +6200,12 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.always_active = true; il->ctx.is_active = true; - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.rxon_cmd = C_RXON; + il->ctx.rxon_timing_cmd = C_RXON_TIMING; + il->ctx.rxon_assoc_cmd = C_RXON_ASSOC; + il->ctx.qos_cmd = C_QOS_PARAM; il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; il->ctx.ac_to_queue = il4965_bss_ac_to_queue; il->ctx.exclusive_interface_modes = diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index c4bf4aa..4809a9d 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -2172,8 +2172,8 @@ out: * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of * rc80211_simple. * - * NOTE: Run REPLY_ADD_STA command to set up station table entry, before - * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, + * NOTE: Run C_ADD_STA command to set up station table entry, before + * calling this function (which runs C_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ static void il4965_rs_initialize_lq(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 361a1ca..3b101c1 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -249,7 +249,7 @@ static int il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, + .id = C_LEDS, .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, @@ -465,9 +465,9 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) } /** - * il4965_init_alive_start - Called after REPLY_ALIVE notification received + * il4965_init_alive_start - Called after N_ALIVE notification received * - * Called after REPLY_ALIVE notification received from "initialize" uCode. + * Called after N_ALIVE notification received from "initialize" uCode. * * The 4965 "initialize" ALIVE reply contains calibration data for: * Voltage, temperature, and MIMO tx gain correction, now stored in il @@ -567,10 +567,10 @@ static void il4965_chain_noise_reset(struct il_priv *il) cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + if (il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd)) IL_ERR( - "Could not send REPLY_PHY_CALIBRATION_CMD\n"); + "Could not send C_PHY_CALIBRATION\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; D_CALIB("Run chain_noise_calibrate\n"); } @@ -1370,7 +1370,7 @@ static int il4965_send_tx_power(struct il_priv *il) goto out; ret = il_send_cmd_pdu(il, - REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); + C_TX_PWR_TBL, sizeof(cmd), &cmd); out: return ret; @@ -1408,7 +1408,7 @@ static int il4965_send_rxon_assoc(struct il_priv *il, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, + ret = il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc), &rxon_assoc, NULL); return ret; @@ -1632,7 +1632,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, } return il_send_cmd_pdu(il, - REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); + C_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** @@ -1795,7 +1795,7 @@ static void il4965_temperature_calib(struct il_priv *il) static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { - case REPLY_RXON: + case C_RXON: return (u16) sizeof(struct il4965_rxon_cmd); default: return len; @@ -2145,10 +2145,10 @@ static void il4965_rx_beacon_notif(struct il_priv *il, static void il4965_rx_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; + il->rx_handlers[N_RX] = il4965_rx_reply_rx; /* Tx response */ - il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[C_TX] = il4965_rx_reply_tx; + il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; } static struct il_hcmd_ops il4965_hcmd = { diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 85c3a49..94cf7e7 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -278,8 +278,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * uCode provides all 4 values to the driver via the "initialize alive" * notification (see struct il4965_init_alive_resp). After the runtime uCode * image loads, uCode updates the R4 value via stats notifications - * (see STATS_NOTIFICATION), which occur after each received beacon - * when associated, or can be requested via REPLY_STATS_CMD. + * (see N_STATS), which occur after each received beacon + * when associated, or can be requested via C_STATS. * * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver * must sign-extend to 32 bits before applying formula below. diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 1a6ca36..8df4d25 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -84,76 +84,76 @@ struct il_priv; #define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) enum { - REPLY_ALIVE = 0x1, - REPLY_ERROR = 0x2, + N_ALIVE = 0x1, + N_ERROR = 0x2, /* RXON and QOS commands */ - REPLY_RXON = 0x10, - REPLY_RXON_ASSOC = 0x11, - REPLY_QOS_PARAM = 0x13, - REPLY_RXON_TIMING = 0x14, + C_RXON = 0x10, + C_RXON_ASSOC = 0x11, + C_QOS_PARAM = 0x13, + C_RXON_TIMING = 0x14, /* Multi-Station support */ - REPLY_ADD_STA = 0x18, - REPLY_REMOVE_STA = 0x19, + C_ADD_STA = 0x18, + C_REM_STA = 0x19, /* Security */ - REPLY_WEPKEY = 0x20, + C_WEPKEY = 0x20, /* RX, TX, LEDs */ - REPLY_3945_RX = 0x1b, /* 3945 only */ - REPLY_TX = 0x1c, - REPLY_RATE_SCALE = 0x47, /* 3945 only */ - REPLY_LEDS_CMD = 0x48, - REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 and up */ + N_3945_RX = 0x1b, /* 3945 only */ + C_TX = 0x1c, + C_RATE_SCALE = 0x47, /* 3945 only */ + C_LEDS = 0x48, + C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ /* 802.11h related */ - REPLY_CHANNEL_SWITCH = 0x72, - CHANNEL_SWITCH_NOTIFICATION = 0x73, - REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74, - SPECTRUM_MEASURE_NOTIFICATION = 0x75, + C_CHANNEL_SWITCH = 0x72, + N_CHANNEL_SWITCH = 0x73, + C_SPECTRUM_MEASUREMENT = 0x74, + N_SPECTRUM_MEASUREMENT = 0x75, /* Power Management */ - POWER_TBL_CMD = 0x77, - PM_SLEEP_NOTIFICATION = 0x7A, - PM_DEBUG_STATISTIC_NOTIFIC = 0x7B, + C_POWER_TBL = 0x77, + N_PM_SLEEP = 0x7A, + N_PM_DEBUG_STATS = 0x7B, /* Scan commands and notifications */ - REPLY_SCAN_CMD = 0x80, - REPLY_SCAN_ABORT_CMD = 0x81, - SCAN_START_NOTIFICATION = 0x82, - SCAN_RESULTS_NOTIFICATION = 0x83, - SCAN_COMPLETE_NOTIFICATION = 0x84, + C_SCAN = 0x80, + C_SCAN_ABORT = 0x81, + N_SCAN_START = 0x82, + N_SCAN_RESULTS = 0x83, + N_SCAN_COMPLETE = 0x84, /* IBSS/AP commands */ - BEACON_NOTIFICATION = 0x90, - REPLY_TX_BEACON = 0x91, + N_BEACON = 0x90, + C_TX_BEACON= 0x91, /* Miscellaneous commands */ - REPLY_TX_PWR_TBL_CMD = 0x97, + C_TX_PWR_TBL = 0x97, /* Bluetooth device coexistence config command */ - REPLY_BT_CONFIG = 0x9b, + C_BT_CONFIG = 0x9b, /* Statistics */ - REPLY_STATS_CMD = 0x9c, - STATS_NOTIFICATION = 0x9d, + C_STATS = 0x9c, + N_STATS = 0x9d, /* RF-KILL commands and notifications */ - CARD_STATE_NOTIFICATION = 0xa1, + N_CARD_STATE = 0xa1, /* Missed beacons notification */ - MISSED_BEACONS_NOTIFICATION = 0xa2, + N_MISSED_BEACONS = 0xa2, - REPLY_CT_KILL_CONFIG_CMD = 0xa4, - SENSITIVITY_CMD = 0xa8, - REPLY_PHY_CALIBRATION_CMD = 0xb0, - REPLY_RX_PHY_CMD = 0xc0, - REPLY_RX_MPDU_CMD = 0xc1, - REPLY_RX = 0xc3, - REPLY_COMPRESSED_BA = 0xc5, + C_CT_KILL_CONFIG = 0xa4, + C_SENSITIVITY = 0xa8, + C_PHY_CALIBRATION = 0xb0, + N_RX_PHY = 0xc0, + N_RX_MPDU = 0xc1, + N_RX = 0xc3, + N_COMPRESSED_BA = 0xc5, - REPLY_MAX = 0xff + IL_CN_MAX = 0xff }; /****************************************************************************** @@ -180,7 +180,7 @@ enum { * driver, and each response/notification received from uCode. */ struct il_cmd_header { - u8 cmd; /* Command ID: REPLY_RXON, etc. */ + u8 cmd; /* Command ID: C_RXON, etc. */ u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ /* * The driver sets up the sequence number to values of its choosing. @@ -192,7 +192,7 @@ struct il_cmd_header { * There is one exception: uCode sets bit 15 when it originates * the response/notification, i.e. when the response/notification * is not a direct response to a command sent by the driver. For - * example, uCode issues REPLY_3945_RX when it sends a received frame + * example, uCode issues N_3945_RX when it sends a received frame * to the driver; it is not a direct response to any driver command. * * The Linux driver uses the following format: @@ -214,7 +214,7 @@ struct il_cmd_header { /** * struct il3945_tx_power * - * Used in REPLY_TX_PWR_TBL_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH + * Used in C_TX_PWR_TBL, C_SCAN, C_CHANNEL_SWITCH * * Each entry contains two values: * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained @@ -233,7 +233,7 @@ struct il3945_tx_power { /** * struct il3945_power_per_rate * - * Used in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Used in C_TX_PWR_TBL, C_CHANNEL_SWITCH */ struct il3945_power_per_rate { u8 rate; /* plcp */ @@ -245,10 +245,10 @@ struct il3945_power_per_rate { * iwl4965 rate_n_flags bit fields * * rate_n_flags format is used in following iwl4965 commands: - * REPLY_RX (response only) - * REPLY_RX_MPDU (response only) - * REPLY_TX (both command and response) - * REPLY_TX_LINK_QUALITY_CMD + * N_RX (response only) + * N_RX_MPDU (response only) + * C_TX (both command and response) + * C_TX_LINK_QUALITY_CMD * * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"): * 2-0: 0) 6 Mbps @@ -336,7 +336,7 @@ struct il3945_power_per_rate { /** * union il4965_tx_power_dual_stream * - * Host format used for REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Host format used for C_TX_PWR_TBL, C_CHANNEL_SWITCH * Use __le32 version (struct tx_power_dual_stream) when building command. * * Driver provides radio gain and DSP attenuation settings to device in pairs, @@ -360,7 +360,7 @@ union il4965_tx_power_dual_stream { /** * struct tx_power_dual_stream * - * Table entries in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Table entries in C_TX_PWR_TBL, C_CHANNEL_SWITCH * * Same format as il_tx_power_dual_stream, but __le32 */ @@ -371,7 +371,7 @@ struct tx_power_dual_stream { /** * struct il4965_tx_power_db * - * Entire table within REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Entire table within C_TX_PWR_TBL, C_CHANNEL_SWITCH */ struct il4965_tx_power_db { struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; @@ -387,7 +387,7 @@ struct il4965_tx_power_db { #define INITIALIZE_SUBTYPE (9) /* - * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command) + * ("Initialize") N_ALIVE = 0x1 (response only, not a command) * * uCode issues this "initialize alive" notification once the initialization * uCode image has completed its work, and is ready to load the runtime image. @@ -435,7 +435,7 @@ struct il_init_alive_resp { /** - * REPLY_ALIVE = 0x1 (response only, not a command) + * N_ALIVE = 0x1 (response only, not a command) * * uCode issues this "alive" notification once the runtime image is ready * to receive commands from the driver. This is the *second* "alive" @@ -526,7 +526,7 @@ struct il_alive_resp { } __packed; /* - * REPLY_ERROR = 0x2 (response only, not a command) + * N_ERROR = 0x2 (response only, not a command) */ struct il_error_resp { __le32 error_type; @@ -640,7 +640,7 @@ enum { #define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6) /** - * REPLY_RXON = 0x10 (command, has simple generic response) + * C_RXON = 0x10 (command, has simple generic response) * * RXON tunes the radio tuner to a service channel, and sets up a number * of parameters that are used primarily for Rx, but also for Tx operations. @@ -653,7 +653,7 @@ enum { * channel. * * NOTE: All RXONs wipe clean the internal txpower table. Driver must - * issue a new REPLY_TX_PWR_TBL_CMD after each REPLY_RXON (0x10), + * issue a new C_TX_PWR_TBL after each C_RXON (0x10), * regardless of whether RXON_FILTER_ASSOC_MSK is set. */ @@ -723,7 +723,7 @@ struct il_rxon_cmd { /* - * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response) + * C_RXON_ASSOC = 0x11 (command, has simple generic response) */ struct il3945_rxon_assoc_cmd { __le32 flags; @@ -749,7 +749,7 @@ struct il4965_rxon_assoc_cmd { #define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* - * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) + * C_RXON_TIMING = 0x14 (command, has simple generic response) */ struct il_rxon_time_cmd { __le64 timestamp; @@ -762,7 +762,7 @@ struct il_rxon_time_cmd { } __packed; /* - * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response) + * C_CHANNEL_SWITCH = 0x72 (command, has simple generic response) */ struct il3945_channel_switch_cmd { u8 band; @@ -785,7 +785,7 @@ struct il4965_channel_switch_cmd { } __packed; /* - * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command) + * N_CHANNEL_SWITCH = 0x73 (notification only, not a command) */ struct il_csa_notification { __le16 band; @@ -800,7 +800,7 @@ struct il_csa_notification { *****************************************************************************/ /** - * struct il_ac_qos -- QOS timing params for REPLY_QOS_PARAM + * struct il_ac_qos -- QOS timing params for C_QOS_PARAM * One for each of 4 EDCA access categories in struct il_qosparam_cmd * * @cw_min: Contention win, start value in numbers of slots. @@ -832,7 +832,7 @@ struct il_ac_qos { #define AC_NUM 4 /* - * REPLY_QOS_PARAM = 0x13 (command, has simple generic response) + * C_QOS_PARAM = 0x13 (command, has simple generic response) * * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs * 0: Background, 1: Best Effort, 2: Video, 3: Voice. @@ -936,15 +936,15 @@ struct sta_id_modify { } __packed; /* - * REPLY_ADD_STA = 0x18 (command) + * C_ADD_STA = 0x18 (command) * * The device contains an internal table of per-station information, * with info on security keys, aggregation parameters, and Tx rates for * initial Tx attempt and any retries (4965 devices uses - * REPLY_TX_LINK_QUALITY_CMD, - * 3945 uses REPLY_RATE_SCALE to set up rate tables). + * C_TX_LINK_QUALITY_CMD, + * 3945 uses C_RATE_SCALE to set up rate tables). * - * REPLY_ADD_STA sets up the table entry for one station, either creating + * C_ADD_STA sets up the table entry for one station, either creating * a new entry, or modifying a pre-existing one. * * NOTE: RXON command (without "associated" bit set) wipes the station table @@ -1071,7 +1071,7 @@ struct il_addsta_cmd { #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 #define ADD_STA_MODIFY_NON_EXIST_STA 0x8 /* - * REPLY_ADD_STA = 0x18 (response) + * C_ADD_STA = 0x18 (response) */ struct il_add_sta_resp { u8 status; /* ADD_STA_* */ @@ -1079,14 +1079,14 @@ struct il_add_sta_resp { #define REM_STA_SUCCESS_MSK 0x1 /* - * REPLY_REM_STA = 0x19 (response) + * C_REM_STA = 0x19 (response) */ struct il_rem_sta_resp { u8 status; } __packed; /* - * REPLY_REM_STA = 0x19 (command) + * C_REM_STA = 0x19 (command) */ struct il_rem_sta_cmd { u8 num_sta; /* number of removed stations */ @@ -1195,7 +1195,7 @@ struct il3945_rx_frame_end { } __packed; /* - * REPLY_3945_RX = 0x1b (response only, not a command) + * N_3945_RX = 0x1b (response only, not a command) * * NOTE: DO NOT dereference from casts to this structure * It is provided only for calculating minimum data set size. @@ -1226,7 +1226,7 @@ struct il4965_rx_non_cfg_phy { /* - * REPLY_RX = 0xc3 (response only, not a command) + * N_RX = 0xc3 (response only, not a command) * Used only for legacy (non 11n) frames. */ struct il_rx_phy_res { @@ -1254,7 +1254,7 @@ struct il_rx_mpdu_res_start { * (5) * Tx Commands & Responses: * - * Driver must place each REPLY_TX command into one of the prioritized Tx + * Driver must place each C_TX command into one of the prioritized Tx * queues in host DRAM, shared between driver and device (see comments for * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode * are preparing to transmit, the device pulls the Tx command over the PCI @@ -1264,18 +1264,18 @@ struct il_rx_mpdu_res_start { * uCode handles all timing and protocol related to control frames * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler * handle reception of block-acks; uCode updates the host driver via - * REPLY_COMPRESSED_BA. + * N_COMPRESSED_BA. * * uCode handles retrying Tx when an ACK is expected but not received. * This includes trying lower data rates than the one requested in the Tx - * command, as set up by the REPLY_RATE_SCALE (for 3945) or - * REPLY_TX_LINK_QUALITY_CMD (4965). + * command, as set up by the C_RATE_SCALE (for 3945) or + * C_TX_LINK_QUALITY_CMD (4965). * - * Driver sets up transmit power for various rates via REPLY_TX_PWR_TBL_CMD. + * Driver sets up transmit power for various rates via C_TX_PWR_TBL. * This command must be executed after every RXON command, before Tx can occur. *****************************************************************************/ -/* REPLY_TX Tx flags field */ +/* C_TX Tx flags field */ /* * 1: Use Request-To-Send protocol before this frame. @@ -1296,7 +1296,7 @@ struct il_rx_mpdu_res_start { #define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3) /* For 4965 devices: - * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD). + * 1: Use rate scale table (see C_TX_LINK_QUALITY_CMD). * Tx command's initial_rate_idx indicates first rate to try; * uCode walks through table for additional Tx attempts. * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. @@ -1322,7 +1322,7 @@ struct il_rx_mpdu_res_start { /* 1: uCode overrides sequence control field in MAC header. * 0: Driver provides sequence control field in MAC header. * Set this for management frames, non-QOS data frames, non-unicast frames, - * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */ + * and also in Tx command embedded in C_SCAN for active scans. */ #define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13) /* 1: This frame is non-last MPDU; more fragments are coming. @@ -1369,7 +1369,7 @@ struct il_rx_mpdu_res_start { #define TKIP_ICV_LEN 4 /* - * REPLY_TX = 0x1c (command) + * C_TX = 0x1c (command) */ struct il3945_tx_cmd { @@ -1434,7 +1434,7 @@ struct il3945_tx_cmd { } __packed; /* - * REPLY_TX = 0x1c (response) + * C_TX = 0x1c (response) */ struct il3945_tx_resp { u8 failure_rts; @@ -1493,7 +1493,7 @@ struct il_tx_cmd { u8 sec_ctl; /* TX_CMD_SEC_* */ /* - * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial + * Index into rate table (see C_TX_LINK_QUALITY_CMD) for initial * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for * data frames, this field may be used to selectively reduce initial * rate (via non-0 value) for special frames (e.g. management), while @@ -1671,7 +1671,7 @@ enum { #define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 /* - * REPLY_TX = 0x1c (response) + * C_TX = 0x1c (response) * * This response may be in one of two slightly different formats, indicated * by the frame_count field: @@ -1735,7 +1735,7 @@ struct il4965_tx_resp { } __packed; /* - * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command) + * N_COMPRESSED_BA = 0xc5 (response only, not a command) * * Reports Block-Acknowledge from recipient station */ @@ -1754,7 +1754,7 @@ struct il_compressed_ba_resp { } __packed; /* - * REPLY_TX_PWR_TBL_CMD = 0x97 (command, has simple generic response) + * C_TX_PWR_TBL = 0x97 (command, has simple generic response) * * See details under "TXPOWER" in 4965.h. */ @@ -1777,7 +1777,7 @@ struct il4965_txpowertable_cmd { /** * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response * - * REPLY_RATE_SCALE = 0x47 (command, has simple generic response) + * C_RATE_SCALE = 0x47 (command, has simple generic response) * * NOTE: The table of rates passed to the uCode via the * RATE_SCALE command sets up the corresponding order of @@ -1786,7 +1786,7 @@ struct il4965_txpowertable_cmd { * * For example, if you set 9MB (PLCP 0x0f) as the first * rate in the rate table, the bit mask for that rate - * when passed through ofdm_basic_rates on the REPLY_RXON + * when passed through ofdm_basic_rates on the C_RXON * command would be bit 0 (1 << 0) */ struct il3945_rate_scaling_info { @@ -1820,7 +1820,7 @@ struct il3945_rate_scaling_cmd { /** * struct il_link_qual_general_params * - * Used in REPLY_TX_LINK_QUALITY_CMD + * Used in C_TX_LINK_QUALITY_CMD */ struct il_link_qual_general_params { u8 flags; @@ -1863,7 +1863,7 @@ struct il_link_qual_general_params { /** * struct il_link_qual_agg_params * - * Used in REPLY_TX_LINK_QUALITY_CMD + * Used in C_TX_LINK_QUALITY_CMD */ struct il_link_qual_agg_params { @@ -1892,9 +1892,9 @@ struct il_link_qual_agg_params { } __packed; /* - * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) + * C_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) * - * For 4965 devices only; 3945 uses REPLY_RATE_SCALE. + * For 4965 devices only; 3945 uses C_RATE_SCALE. * * Each station in the 4965 device's internal station table has its own table * of 16 @@ -1903,7 +1903,7 @@ struct il_link_qual_agg_params { * one station. * * NOTE: Station must already be in 4965 device's station table. - * Use REPLY_ADD_STA. + * Use C_ADD_STA. * * The rate scaling procedures described below work well. Of course, other * procedures are possible, and may work better for particular environments. @@ -2117,7 +2117,7 @@ struct il_link_quality_cmd { #define BT_MAX_KILL_DEF (0x5) /* - * REPLY_BT_CONFIG = 0x9b (command, has simple generic response) + * C_BT_CONFIG = 0x9b (command, has simple generic response) * * 3945 and 4965 devices support hardware handshake with Bluetooth device on * same platform. Bluetooth device alerts wireless device when it will Tx; @@ -2159,7 +2159,7 @@ struct il_measure_channel { } __packed; /* - * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command) + * C_SPECTRUM_MEASUREMENT = 0x74 (command) */ struct il_spectrum_cmd { __le16 len; /* number of bytes starting from token */ @@ -2178,7 +2178,7 @@ struct il_spectrum_cmd { } __packed; /* - * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response) + * C_SPECTRUM_MEASUREMENT = 0x74 (response) */ struct il_spectrum_resp { u8 token; @@ -2228,7 +2228,7 @@ enum il_measure_type { }; /* - * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command) + * N_SPECTRUM_MEASUREMENT = 0x75 (notification only, not a command) */ struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ @@ -2263,7 +2263,7 @@ struct il_spectrum_notification { * struct il_powertable_cmd - Power Table Command * @flags: See below: * - * POWER_TBL_CMD = 0x77 (command, has simple generic response) + * C_POWER_TBL = 0x77 (command, has simple generic response) * * PM allow: * bit 0 - '0' Driver not allow power management @@ -2318,7 +2318,7 @@ struct il_powertable_cmd { } __packed; /* - * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command) + * N_PM_SLEEP = 0x7A (notification only, not a command) * all devices identical. */ struct il_sleep_notification { @@ -2346,7 +2346,7 @@ enum { }; /* - * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command) + * N_CARD_STATE = 0xa1 (notification only, not a command) */ struct il_card_state_notif { __le32 flags; @@ -2373,7 +2373,7 @@ struct il_ct_kill_config { #define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) /** - * struct il_scan_channel - entry in REPLY_SCAN_CMD channel table + * struct il_scan_channel - entry in C_SCAN channel table * * One for each channel in the scan list. * Each channel can independently select: @@ -2431,7 +2431,7 @@ struct il_scan_channel { /** * struct il_ssid_ie - directed scan network information element * - * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in + * Up to 20 of these may appear in C_SCAN (Note: Only 4 are in * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; * each channel may select different ssids from among the 20 (4) entries. * SSID IEs get transmitted in reverse order of entry. @@ -2452,7 +2452,7 @@ struct il_ssid_ie { #define IL_MAX_CMD_SIZE 4096 /* - * REPLY_SCAN_CMD = 0x80 (command) + * C_SCAN = 0x80 (command) * * The hardware scan command is very powerful; the driver can set it up to * maintain (relatively) normal network traffic while doing a scan in the @@ -2542,7 +2542,7 @@ struct il3945_scan_cmd { * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION) + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) * before requesting another scan. */ u8 data[0]; @@ -2586,7 +2586,7 @@ struct il_scan_cmd { * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION) + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) * before requesting another scan. */ u8 data[0]; @@ -2598,14 +2598,14 @@ struct il_scan_cmd { #define ABORT_STATUS 0x2 /* - * REPLY_SCAN_CMD = 0x80 (response) + * C_SCAN = 0x80 (response) */ struct il_scanreq_notification { __le32 status; /* 1: okay, 2: cannot fulfill request */ } __packed; /* - * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command) + * N_SCAN_START = 0x82 (notification only, not a command) */ struct il_scanstart_notification { __le32 tsf_low; @@ -2628,7 +2628,7 @@ struct il_scanstart_notification { #define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ /* - * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) + * N_SCAN_RESULTS = 0x83 (notification only, not a command) */ struct il_scanresults_notification { u8 channel; @@ -2641,7 +2641,7 @@ struct il_scanresults_notification { } __packed; /* - * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command) + * N_SCAN_COMPLETE = 0x84 (notification only, not a command) */ struct il_scancomplete_notification { u8 scanned_channels; @@ -2664,7 +2664,7 @@ enum il_ibss_manager { }; /* - * BEACON_NOTIFICATION = 0x90 (notification only, not a command) + * N_BEACON = 0x90 (notification only, not a command) */ struct il3945_beacon_notif { @@ -2682,7 +2682,7 @@ struct il4965_beacon_notif { } __packed; /* - * REPLY_TX_BEACON = 0x91 (command, has simple generic response) + * C_TX_BEACON= 0x91 (command, has simple generic response) */ struct il3945_tx_beacon_cmd { @@ -2963,19 +2963,19 @@ struct stats_general { #define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) /* - * REPLY_STATS_CMD = 0x9c, + * C_STATS = 0x9c, * all devices identical. * * This command triggers an immediate response containing uCode stats. - * The response is in the same format as STATS_NOTIFICATION 0x9d, below. + * The response is in the same format as N_STATS 0x9d, below. * * If the CLEAR_STATS configuration flag is set, uCode will clear its * internal copy of the stats (counters) after issuing the response. - * This flag does not affect STATS_NOTIFICATIONs after beacons (see below). + * This flag does not affect N_STATSs after beacons (see below). * * If the DISABLE_NOTIF configuration flag is set, uCode will not issue - * STATS_NOTIFICATIONs after received beacons (see below). This flag - * does not affect the response to the REPLY_STATS_CMD 0x9c itself. + * N_STATSs after received beacons (see below). This flag + * does not affect the response to the C_STATS 0x9c itself. */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ #define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ @@ -2984,14 +2984,14 @@ struct il_stats_cmd { } __packed; /* - * STATS_NOTIFICATION = 0x9d (notification only, not a command) + * N_STATS = 0x9d (notification only, not a command) * * By default, uCode issues this notification after receiving a beacon * while associated. To disable this behavior, set DISABLE_NOTIF flag in the - * REPLY_STATS_CMD 0x9c, above. + * C_STATS 0x9c, above. * * Statistics counters continue to increment beacon after beacon, but are - * cleared when changing channels or when driver issues REPLY_STATS_CMD + * cleared when changing channels or when driver issues C_STATS * 0x9c with CLEAR_STATS bit set (see above). * * uCode also issues this notification during scans. uCode clears stats @@ -3016,9 +3016,9 @@ struct il_notif_stats { } __packed; /* - * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command) + * N_MISSED_BEACONS = 0xa2 (notification only, not a command) * - * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed + * uCode send N_MISSED_BEACONS to driver when detect beacon missed * in regardless of how many missed beacons, which mean when driver receive the * notification, inside the command, it can find all the beacons information * which include number of total missed beacons, number of consecutive missed @@ -3062,7 +3062,7 @@ struct il_missed_beacon_notif { *****************************************************************************/ /** - * SENSITIVITY_CMD = 0xa8 (command, has simple generic response) + * C_SENSITIVITY = 0xa8 (command, has simple generic response) * * This command sets up the Rx signal detector for a sensitivity level that * is high enough to lock onto all signals within the associated network, @@ -3076,7 +3076,7 @@ struct il_missed_beacon_notif { * time listening, not transmitting). Driver must adjust sensitivity so that * the ratio of actual false alarms to actual Rx time falls within this range. * - * While associated, uCode delivers STATS_NOTIFICATIONs after each + * While associated, uCode delivers N_STATSs after each * received beacon. These provide information to the driver to analyze the * sensitivity. Don't analyze stats that come in from scanning, or any * other non-associated-network source. Pertinent stats include: @@ -3217,7 +3217,7 @@ struct il_missed_beacon_notif { */ /* - * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) + * Table entries in C_SENSITIVITY (struct il_sensitivity_cmd) */ #define HD_TBL_SIZE (11) /* number of entries */ #define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ @@ -3233,8 +3233,8 @@ struct il_missed_beacon_notif { #define HD_OFDM_ENERGY_TH_IN_IDX (10) /* Control field in struct il_sensitivity_cmd */ -#define SENSITIVITY_CMD_CONTROL_DEFAULT_TBL cpu_to_le16(0) -#define SENSITIVITY_CMD_CONTROL_WORK_TBL cpu_to_le16(1) +#define C_SENSITIVITY_CONTROL_DEFAULT_TBL cpu_to_le16(0) +#define C_SENSITIVITY_CONTROL_WORK_TBL cpu_to_le16(1) /** * struct il_sensitivity_cmd @@ -3250,12 +3250,12 @@ struct il_sensitivity_cmd { /** - * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response) + * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) * * This command sets the relative gains of 4965 device's 3 radio receiver chains. * * After the first association, driver should accumulate signal and noise - * stats from the STATS_NOTIFICATIONs that follow the first 20 + * stats from the N_STATSs that follow the first 20 * beacons from the associated network (don't collect stats that come * in from scanning, or any other non-network source). * @@ -3338,7 +3338,7 @@ struct il_calib_diff_gain_cmd { /* * LEDs Command & Response - * REPLY_LEDS_CMD = 0x48 (command, has simple generic response) + * C_LEDS = 0x48 (command, has simple generic response) * * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), * this command turns it on or off, or sets up a periodic blinking cycle. diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index e6c7d5f..baed3dc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1165,7 +1165,7 @@ void il_send_bt_config(struct il_priv *il) D_INFO("BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, + if (il_send_cmd_pdu(il, C_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) IL_ERR("failed to send BT Coex Config\n"); } @@ -1179,11 +1179,11 @@ int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, REPLY_STATS_CMD, + return il_send_cmd_pdu_async(il, C_STATS, sizeof(struct il_stats_cmd), &stats_cmd, NULL); else - return il_send_cmd_pdu(il, REPLY_STATS_CMD, + return il_send_cmd_pdu(il, C_STATS, sizeof(struct il_stats_cmd), &stats_cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index b9888ac..4076b79 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -554,7 +554,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n", il->isr_stats.rx); - for (cnt = 0; cnt < REPLY_MAX; cnt++) { + for (cnt = 0; cnt < IL_CN_MAX; cnt++) { if (il->isr_stats.rx_handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index f7c3b43..1bc4a71 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -383,8 +383,8 @@ struct il_rx_queue { * @bitmap1: High order, one bit for each frame pending ACK in Tx win * @rate_n_flags: Rate at which Tx was attempted * - * If REPLY_TX indicates that aggregation was attempted, driver must wait - * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info + * If C_TX indicates that aggregation was attempted, driver must wait + * for block ack (N_COMPRESSED_BA). This struct stores tx reply info * until block ack arrives. */ struct il_ht_agg { @@ -813,7 +813,7 @@ struct isr_stats { u32 ctkill; u32 wakeup; u32 rx; - u32 rx_handlers[REPLY_MAX]; + u32 rx_handlers[IL_CN_MAX]; u32 tx; u32 unhandled; }; @@ -968,7 +968,7 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[REPLY_MAX])(struct il_priv *il, + void (*rx_handlers[IL_CN_MAX])(struct il_priv *il, struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 19a5955..670a398 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -40,47 +40,47 @@ const char *il_get_cmd_string(u8 cmd) { switch (cmd) { - IL_CMD(REPLY_ALIVE); - IL_CMD(REPLY_ERROR); - IL_CMD(REPLY_RXON); - IL_CMD(REPLY_RXON_ASSOC); - IL_CMD(REPLY_QOS_PARAM); - IL_CMD(REPLY_RXON_TIMING); - IL_CMD(REPLY_ADD_STA); - IL_CMD(REPLY_REMOVE_STA); - IL_CMD(REPLY_WEPKEY); - IL_CMD(REPLY_3945_RX); - IL_CMD(REPLY_TX); - IL_CMD(REPLY_RATE_SCALE); - IL_CMD(REPLY_LEDS_CMD); - IL_CMD(REPLY_TX_LINK_QUALITY_CMD); - IL_CMD(REPLY_CHANNEL_SWITCH); - IL_CMD(CHANNEL_SWITCH_NOTIFICATION); - IL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); - IL_CMD(SPECTRUM_MEASURE_NOTIFICATION); - IL_CMD(POWER_TBL_CMD); - IL_CMD(PM_SLEEP_NOTIFICATION); - IL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); - IL_CMD(REPLY_SCAN_CMD); - IL_CMD(REPLY_SCAN_ABORT_CMD); - IL_CMD(SCAN_START_NOTIFICATION); - IL_CMD(SCAN_RESULTS_NOTIFICATION); - IL_CMD(SCAN_COMPLETE_NOTIFICATION); - IL_CMD(BEACON_NOTIFICATION); - IL_CMD(REPLY_TX_BEACON); - IL_CMD(REPLY_TX_PWR_TBL_CMD); - IL_CMD(REPLY_BT_CONFIG); - IL_CMD(REPLY_STATS_CMD); - IL_CMD(STATS_NOTIFICATION); - IL_CMD(CARD_STATE_NOTIFICATION); - IL_CMD(MISSED_BEACONS_NOTIFICATION); - IL_CMD(REPLY_CT_KILL_CONFIG_CMD); - IL_CMD(SENSITIVITY_CMD); - IL_CMD(REPLY_PHY_CALIBRATION_CMD); - IL_CMD(REPLY_RX_PHY_CMD); - IL_CMD(REPLY_RX_MPDU_CMD); - IL_CMD(REPLY_RX); - IL_CMD(REPLY_COMPRESSED_BA); + IL_CMD(N_ALIVE); + IL_CMD(N_ERROR); + IL_CMD(C_RXON); + IL_CMD(C_RXON_ASSOC); + IL_CMD(C_QOS_PARAM); + IL_CMD(C_RXON_TIMING); + IL_CMD(C_ADD_STA); + IL_CMD(C_REM_STA); + IL_CMD(C_WEPKEY); + IL_CMD(N_3945_RX); + IL_CMD(C_TX); + IL_CMD(C_RATE_SCALE); + IL_CMD(C_LEDS); + IL_CMD(C_TX_LINK_QUALITY_CMD); + IL_CMD(C_CHANNEL_SWITCH); + IL_CMD(N_CHANNEL_SWITCH); + IL_CMD(C_SPECTRUM_MEASUREMENT); + IL_CMD(N_SPECTRUM_MEASUREMENT); + IL_CMD(C_POWER_TBL); + IL_CMD(N_PM_SLEEP); + IL_CMD(N_PM_DEBUG_STATS); + IL_CMD(C_SCAN); + IL_CMD(C_SCAN_ABORT); + IL_CMD(N_SCAN_START); + IL_CMD(N_SCAN_RESULTS); + IL_CMD(N_SCAN_COMPLETE); + IL_CMD(N_BEACON); + IL_CMD(C_TX_BEACON); + IL_CMD(C_TX_PWR_TBL); + IL_CMD(C_BT_CONFIG); + IL_CMD(C_STATS); + IL_CMD(N_STATS); + IL_CMD(N_CARD_STATE); + IL_CMD(N_MISSED_BEACONS); + IL_CMD(C_CT_KILL_CONFIG); + IL_CMD(C_SENSITIVITY); + IL_CMD(C_PHY_CALIBRATION); + IL_CMD(N_RX_PHY); + IL_CMD(N_RX_MPDU); + IL_CMD(N_RX); + IL_CMD(N_COMPRESSED_BA); default: return "UNKNOWN"; @@ -102,8 +102,8 @@ static void il_generic_cmd_callback(struct il_priv *il, #ifdef CONFIG_IWLEGACY_DEBUG switch (cmd->hdr.cmd) { - case REPLY_TX_LINK_QUALITY_CMD: - case SENSITIVITY_CMD: + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: D_HC_DUMP("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index c66a0f7..2b06a95 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -88,7 +88,7 @@ il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return il_send_cmd_pdu(il, POWER_TBL_CMD, + return il_send_cmd_pdu(il, C_POWER_TBL, sizeof(struct il_powertable_cmd), cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index b0bf684..029ea8a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -189,7 +189,7 @@ * procedure. * * This save/restore method is mostly for autonomous power management during - * normal operation (result of POWER_TBL_CMD). Platform suspend/resume and + * normal operation (result of C_POWER_TBL). Platform suspend/resume and * RFKILL should use complete restarts (with total re-initialization) of uCode, * allowing total shutdown (including BSM memory). * diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 6d20f2b..1f81d56 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -59,7 +59,7 @@ static int il_send_scan_abort(struct il_priv *il) int ret; struct il_rx_pkt *pkt; struct il_host_cmd cmd = { - .id = REPLY_SCAN_ABORT_CMD, + .id = C_SCAN_ABORT, .flags = CMD_WANT_SKB, }; @@ -181,7 +181,7 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) } EXPORT_SYMBOL(il_scan_cancel_timeout); -/* Service response to REPLY_SCAN_CMD (0x80) */ +/* Service response to C_SCAN (0x80) */ static void il_rx_reply_scan(struct il_priv *il, struct il_rx_buf *rxb) { @@ -194,7 +194,7 @@ static void il_rx_reply_scan(struct il_priv *il, #endif } -/* Service SCAN_START_NOTIFICATION (0x82) */ +/* Service N_SCAN_START (0x82) */ static void il_rx_scan_start_notif(struct il_priv *il, struct il_rx_buf *rxb) { @@ -212,7 +212,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, notif->status, notif->beacon_timer); } -/* Service SCAN_RESULTS_NOTIFICATION (0x83) */ +/* Service N_SCAN_RESULTS (0x83) */ static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_buf *rxb) { @@ -234,7 +234,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, #endif } -/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ +/* Service N_SCAN_COMPLETE (0x84) */ static void il_rx_scan_complete_notif(struct il_priv *il, struct il_rx_buf *rxb) { @@ -263,12 +263,12 @@ static void il_rx_scan_complete_notif(struct il_priv *il, void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - il->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; - il->rx_handlers[SCAN_START_NOTIFICATION] = + il->rx_handlers[C_SCAN] = il_rx_reply_scan; + il->rx_handlers[N_SCAN_START] = il_rx_scan_start_notif; - il->rx_handlers[SCAN_RESULTS_NOTIFICATION] = + il->rx_handlers[N_SCAN_RESULTS] = il_rx_scan_results_notif; - il->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = + il->rx_handlers[N_SCAN_COMPLETE] = il_rx_scan_complete_notif; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index ffb966b..58762e79 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -67,7 +67,7 @@ static int il_process_add_sta_resp(struct il_priv *il, int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_ADD_STA (0x%08X)\n", + IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } @@ -79,7 +79,7 @@ static int il_process_add_sta_resp(struct il_priv *il, switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - D_INFO("REPLY_ADD_STA PASSED\n"); + D_INFO("C_ADD_STA PASSED\n"); il_sta_ucode_activate(il, sta_id); ret = 0; break; @@ -97,7 +97,7 @@ static int il_process_add_sta_resp(struct il_priv *il, sta_id); break; default: - D_ASSOC("Received REPLY_ADD_STA:(0x%08X)\n", + D_ASSOC("Received C_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } @@ -142,7 +142,7 @@ int il_send_add_sta(struct il_priv *il, int ret = 0; u8 data[sizeof(*sta)]; struct il_host_cmd cmd = { - .id = REPLY_ADD_STA, + .id = C_ADD_STA, .flags = flags, .data = data, }; @@ -290,7 +290,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, sta_id, addr); il->num_stations++; - /* Set up the REPLY_ADD_STA command to send to device */ + /* Set up the C_ADD_STA command to send to device */ memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); memcpy(station->sta.sta.addr, addr, ETH_ALEN); station->sta.mode = 0; @@ -421,7 +421,7 @@ static int il_send_remove_station(struct il_priv *il, struct il_rem_sta_cmd rm_sta_cmd; struct il_host_cmd cmd = { - .id = REPLY_REMOVE_STA, + .id = C_REM_STA, .len = sizeof(struct il_rem_sta_cmd), .flags = CMD_SYNC, .data = &rm_sta_cmd, @@ -440,7 +440,7 @@ static int il_send_remove_station(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", + IL_ERR("Bad return from C_REM_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -454,11 +454,11 @@ static int il_send_remove_station(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); } - D_ASSOC("REPLY_REMOVE_STA PASSED\n"); + D_ASSOC("C_REM_STA PASSED\n"); break; default: ret = -EIO; - IL_ERR("REPLY_REMOVE_STA failed\n"); + IL_ERR("C_REM_STA failed\n"); break; } } @@ -753,7 +753,7 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, unsigned long flags_spin; struct il_host_cmd cmd = { - .id = REPLY_TX_LINK_QUALITY_CMD, + .id = C_TX_LINK_QUALITY_CMD, .len = sizeof(struct il_link_quality_cmd), .flags = flags, .data = lq, diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 3f97d09..3b588b3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -509,8 +509,8 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) #ifdef CONFIG_IWLEGACY_DEBUG switch (out_cmd->hdr.cmd) { - case REPLY_TX_LINK_QUALITY_CMD: - case SENSITIVITY_CMD: + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: D_HC_DUMP( "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", -- cgit v0.10.2 From d0c72347bece3299a90351151c69c0f721f964ff Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 15:39:42 +0200 Subject: iwlegacy: s/rx_handler/handler/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 65cab846..fa5e038 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -843,7 +843,7 @@ static void il3945_rx_card_state_notif(struct il_priv *il, } /** - * il3945_setup_rx_handlers - Initialize Rx handler callbacks + * il3945_setup_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -851,32 +851,32 @@ static void il3945_rx_card_state_notif(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il3945_setup_rx_handlers(struct il_priv *il) +static void il3945_setup_handlers(struct il_priv *il) { - il->rx_handlers[N_ALIVE] = il3945_rx_reply_alive; - il->rx_handlers[C_ADD_STA] = il3945_rx_reply_add_sta; - il->rx_handlers[N_ERROR] = il_rx_reply_error; - il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; - il->rx_handlers[N_SPECTRUM_MEASUREMENT] = + il->handlers[N_ALIVE] = il3945_rx_reply_alive; + il->handlers[C_ADD_STA] = il3945_rx_reply_add_sta; + il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; - il->rx_handlers[N_PM_DEBUG_STATS] = + il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[N_BEACON] = il3945_rx_beacon_notif; + il->handlers[N_BEACON] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[C_STATS] = il3945_reply_stats; - il->rx_handlers[N_STATS] = il3945_hw_rx_stats; + il->handlers[C_STATS] = il3945_reply_stats; + il->handlers[N_STATS] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); - il->rx_handlers[N_CARD_STATE] = il3945_rx_card_state_notif; + il->handlers[N_CARD_STATE] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ - il3945_hw_rx_handler_setup(il); + il3945_hw_handler_setup(il); } /************************** RX-FUNCTIONS ****************************/ @@ -1194,7 +1194,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) /** * il3945_rx_handle - Main entry function for receiving responses from uCode * - * Uses the il->rx_handlers callback function array to invoke + * Uses the il->handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ @@ -1258,12 +1258,12 @@ static void il3945_rx_handle(struct il_priv *il) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See il3945_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { + * handlers table. See il3945_setup_handlers() */ + if (il->handlers[pkt->hdr.cmd]) { D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); + il->isr_stats.handlers[pkt->hdr.cmd]++; + il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ D_RX( @@ -1275,7 +1275,7 @@ static void il3945_rx_handle(struct il_priv *il) /* * XXX: After here, we should always check rxb->page * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have + * memory (pkt). Because some handler might have * already taken or freed the pages. */ @@ -3807,7 +3807,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en &il->bands[IEEE80211_BAND_2GHZ].channels[5], &il->ctx); il3945_setup_deferred_work(il); - il3945_setup_rx_handlers(il); + il3945_setup_handlers(il); il_power_initialize(il); /********************************* diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index ba250f7..94d540c 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2462,10 +2462,10 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void il3945_hw_rx_handler_setup(struct il_priv *il) +void il3945_hw_handler_setup(struct il_priv *il) { - il->rx_handlers[C_TX] = il3945_rx_reply_tx; - il->rx_handlers[N_3945_RX] = il3945_rx_reply_rx; + il->handlers[C_TX] = il3945_rx_reply_tx; + il->handlers[N_3945_RX] = il3945_rx_reply_rx; } void il3945_hw_setup_deferred_work(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index d65565f..6000aff 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -225,7 +225,7 @@ extern void il3945_dump_nic_error_log(struct il_priv *il); * il3945_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void il3945_hw_rx_handler_setup(struct il_priv *il); +extern void il3945_hw_handler_setup(struct il_priv *il); extern void il3945_hw_setup_deferred_work(struct il_priv *il); extern void il3945_hw_cancel_deferred_work(struct il_priv *il); extern int il3945_hw_rxq_stop(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 098d863..d82d05f 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -3911,7 +3911,7 @@ static void il4965_rx_card_state_notif(struct il_priv *il, } /** - * il4965_setup_rx_handlers - Initialize Rx handler callbacks + * il4965_setup_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -3919,47 +3919,47 @@ static void il4965_rx_card_state_notif(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il4965_setup_rx_handlers(struct il_priv *il) +static void il4965_setup_handlers(struct il_priv *il) { - il->rx_handlers[N_ALIVE] = il4965_rx_reply_alive; - il->rx_handlers[N_ERROR] = il_rx_reply_error; - il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; - il->rx_handlers[N_SPECTRUM_MEASUREMENT] = + il->handlers[N_ALIVE] = il4965_rx_reply_alive; + il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; - il->rx_handlers[N_PM_DEBUG_STATS] = + il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; + il->handlers[N_BEACON] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[C_STATS] = il4965_reply_stats; - il->rx_handlers[N_STATS] = il4965_rx_stats; + il->handlers[C_STATS] = il4965_reply_stats; + il->handlers[N_STATS] = il4965_rx_stats; il_setup_rx_scan_handlers(il); /* status change handler */ - il->rx_handlers[N_CARD_STATE] = + il->handlers[N_CARD_STATE] = il4965_rx_card_state_notif; - il->rx_handlers[N_MISSED_BEACONS] = + il->handlers[N_MISSED_BEACONS] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - il->rx_handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; - il->rx_handlers[N_RX_MPDU] = il4965_rx_reply_rx; + il->handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; + il->handlers[N_RX_MPDU] = il4965_rx_reply_rx; /* block ack */ - il->rx_handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ - il->cfg->ops->lib->rx_handler_setup(il); + il->cfg->ops->lib->handler_setup(il); } /** * il4965_rx_handle - Main entry function for receiving responses from uCode * - * Uses the il->rx_handlers callback function array to invoke + * Uses the il->handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ @@ -4028,13 +4028,13 @@ void il4965_rx_handle(struct il_priv *il) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See il4965_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { + * handlers table. See il4965_setup_handlers() */ + if (il->handlers[pkt->hdr.cmd]) { D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); + il->isr_stats.handlers[pkt->hdr.cmd]++; + il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ D_RX( @@ -4046,7 +4046,7 @@ void il4965_rx_handle(struct il_priv *il) /* * XXX: After here, we should always check rxb->page * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have + * memory (pkt). Because some handler might have * already taken or freed the pages. */ @@ -6358,7 +6358,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } il4965_setup_deferred_work(il); - il4965_setup_rx_handlers(il); + il4965_setup_handlers(il); /********************************************* * 8. Enable interrupts and read RFKILL state diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 3b101c1..f48cb89 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2142,13 +2142,13 @@ static void il4965_rx_beacon_notif(struct il_priv *il, } /* Set up 4965-specific Rx frame reply handlers */ -static void il4965_rx_handler_setup(struct il_priv *il) +static void il4965_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - il->rx_handlers[N_RX] = il4965_rx_reply_rx; + il->handlers[N_RX] = il4965_rx_reply_rx; /* Tx response */ - il->rx_handlers[C_TX] = il4965_rx_reply_tx; - il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; + il->handlers[C_TX] = il4965_rx_reply_tx; + il->handlers[N_BEACON] = il4965_rx_beacon_notif; } static struct il_hcmd_ops il4965_hcmd = { @@ -2316,7 +2316,7 @@ static struct il_lib_ops il4965_lib = { .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, .txq_free_tfd = il4965_hw_txq_free_tfd, .txq_init = il4965_hw_tx_queue_init, - .rx_handler_setup = il4965_rx_handler_setup, + .handler_setup = il4965_handler_setup, .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, .init_alive_start = il4965_init_alive_start, .load_ucode = il4965_load_bsm, diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index e275ffc..a3701a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -136,7 +136,7 @@ struct il_lib_ops { int (*txq_init)(struct il_priv *il, struct il_tx_queue *txq); /* setup Rx handler */ - void (*rx_handler_setup)(struct il_priv *il); + void (*handler_setup)(struct il_priv *il); /* alive notification after init uCode load */ void (*init_alive_start)(struct il_priv *il); /* check validity of rtc data address */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 4076b79..3f6b06e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -555,11 +555,11 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, "Rx command responses:\t\t %u\n", il->isr_stats.rx); for (cnt = 0; cnt < IL_CN_MAX; cnt++) { - if (il->isr_stats.rx_handlers[cnt] > 0) + if (il->isr_stats.handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", il_get_cmd_string(cnt), - il->isr_stats.rx_handlers[cnt]); + il->isr_stats.handlers[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 1bc4a71..2ebd807 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -813,7 +813,7 @@ struct isr_stats { u32 ctkill; u32 wakeup; u32 rx; - u32 rx_handlers[IL_CN_MAX]; + u32 handlers[IL_CN_MAX]; u32 tx; u32 unhandled; }; @@ -968,7 +968,7 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[IL_CN_MAX])(struct il_priv *il, + void (*handlers[IL_CN_MAX])(struct il_priv *il, struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 1f81d56..2bed3ae 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -263,12 +263,12 @@ static void il_rx_scan_complete_notif(struct il_priv *il, void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - il->rx_handlers[C_SCAN] = il_rx_reply_scan; - il->rx_handlers[N_SCAN_START] = + il->handlers[C_SCAN] = il_rx_reply_scan; + il->handlers[N_SCAN_START] = il_rx_scan_start_notif; - il->rx_handlers[N_SCAN_RESULTS] = + il->handlers[N_SCAN_RESULTS] = il_rx_scan_results_notif; - il->rx_handlers[N_SCAN_COMPLETE] = + il->handlers[N_SCAN_COMPLETE] = il_rx_scan_complete_notif; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); -- cgit v0.10.2 From 6e9848b496cf256ba820094e88e78cc4f8304008 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 15:45:31 +0200 Subject: iwlegacy: s/rx_reply/hdl/ Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index fa5e038..e9a1e64 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -743,7 +743,7 @@ static int il3945_get_measurement(struct il_priv *il, return rc; } -static void il3945_rx_reply_alive(struct il_priv *il, +static void il3945_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -779,7 +779,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, IL_WARN("uCode did not respond OK.\n"); } -static void il3945_rx_reply_add_sta(struct il_priv *il, +static void il3945_hdl_add_sta(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -853,9 +853,9 @@ static void il3945_rx_card_state_notif(struct il_priv *il, */ static void il3945_setup_handlers(struct il_priv *il) { - il->handlers[N_ALIVE] = il3945_rx_reply_alive; - il->handlers[C_ADD_STA] = il3945_rx_reply_add_sta; - il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_ALIVE] = il3945_hdl_alive; + il->handlers[C_ADD_STA] = il3945_hdl_add_sta; + il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 94d540c..b45905f 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -315,9 +315,9 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, } /** - * il3945_rx_reply_tx - Handle Tx response + * il3945_hdl_tx - Handle Tx response */ -static void il3945_rx_reply_tx(struct il_priv *il, +static void il3945_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -521,7 +521,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void il3945_rx_reply_rx(struct il_priv *il, +static void il3945_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; @@ -2464,8 +2464,8 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, void il3945_hw_handler_setup(struct il_priv *il) { - il->handlers[C_TX] = il3945_rx_reply_tx; - il->handlers[N_3945_RX] = il3945_rx_reply_rx; + il->handlers[C_TX] = il3945_hdl_tx; + il->handlers[N_3945_RX] = il3945_hdl_rx; } void il3945_hw_setup_deferred_work(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index d82d05f..0797c11 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -610,7 +610,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* Called for N_RX (legacy ABG frames), or * N_RX_MPDU (HT high-throughput N frames). */ -void il4965_rx_reply_rx(struct il_priv *il, +void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; @@ -729,8 +729,8 @@ void il4965_rx_reply_rx(struct il_priv *il, } /* Cache phy data (Rx signal strength, etc) for HT frame (N_RX_PHY). - * This will be used later in il_rx_reply_rx() for N_RX_MPDU. */ -void il4965_rx_reply_rx_phy(struct il_priv *il, + * This will be used later in il_hdl_rx() for N_RX_MPDU. */ +void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -2616,12 +2616,12 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, } /** - * il4965_rx_reply_compressed_ba - Handler for N_COMPRESSED_BA + * il4965_hdl_compressed_ba - Handler for N_COMPRESSED_BA * * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void il4965_rx_reply_compressed_ba(struct il_priv *il, +void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3759,7 +3759,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, * Generic RX handler implementations * ******************************************************************************/ -static void il4965_rx_reply_alive(struct il_priv *il, +static void il4965_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3921,8 +3921,8 @@ static void il4965_rx_card_state_notif(struct il_priv *il, */ static void il4965_setup_handlers(struct il_priv *il) { - il->handlers[N_ALIVE] = il4965_rx_reply_alive; - il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_ALIVE] = il4965_hdl_alive; + il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; @@ -3948,10 +3948,10 @@ static void il4965_setup_handlers(struct il_priv *il) il->handlers[N_MISSED_BEACONS] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - il->handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; - il->handlers[N_RX_MPDU] = il4965_rx_reply_rx; + il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; + il->handlers[N_RX_MPDU] = il4965_hdl_rx; /* block ack */ - il->handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; /* Set up hardware specific Rx handlers */ il->cfg->ops->lib->handler_setup(il); } diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index f48cb89..726fc80 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2017,9 +2017,9 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) } /** - * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response + * il4965_hdl_tx - Handle standard (non-aggregation) Tx response */ -static void il4965_rx_reply_tx(struct il_priv *il, +static void il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -2145,9 +2145,9 @@ static void il4965_rx_beacon_notif(struct il_priv *il, static void il4965_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - il->handlers[N_RX] = il4965_rx_reply_rx; + il->handlers[N_RX] = il4965_hdl_rx; /* Tx response */ - il->handlers[C_TX] = il4965_rx_reply_tx; + il->handlers[C_TX] = il4965_hdl_tx; il->handlers[N_BEACON] = il4965_rx_beacon_notif; } diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 94cf7e7..a8acbbb 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -73,9 +73,9 @@ void il4965_rx_replenish_now(struct il_priv *il); void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_rx_reply_rx(struct il_priv *il, +void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb); -void il4965_rx_reply_rx_phy(struct il_priv *il, +void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb); void il4965_rx_handle(struct il_priv *il); @@ -95,7 +95,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); -void il4965_rx_reply_compressed_ba(struct il_priv *il, +void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb); int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); void il4965_hw_txq_ctx_free(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index baed3dc..abb8d86 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1213,7 +1213,7 @@ void il_rx_pm_debug_stats_notif(struct il_priv *il, } EXPORT_SYMBOL(il_rx_pm_debug_stats_notif); -void il_rx_reply_error(struct il_priv *il, +void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1226,7 +1226,7 @@ void il_rx_reply_error(struct il_priv *il, le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), le32_to_cpu(pkt->u.err_resp.error_info)); } -EXPORT_SYMBOL(il_rx_reply_error); +EXPORT_SYMBOL(il_hdl_error); void il_clear_isr_stats(struct il_priv *il) { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index a3701a6..9897dac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -373,7 +373,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_buf *rxb); void il_rx_pm_debug_stats_notif(struct il_priv *il, struct il_rx_buf *rxb); -void il_rx_reply_error(struct il_priv *il, +void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb); /***************************************************** diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 2bed3ae..f81db76 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -182,7 +182,7 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to C_SCAN (0x80) */ -static void il_rx_reply_scan(struct il_priv *il, +static void il_hdl_scan(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -263,7 +263,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - il->handlers[C_SCAN] = il_rx_reply_scan; + il->handlers[C_SCAN] = il_hdl_scan; il->handlers[N_SCAN_START] = il_rx_scan_start_notif; il->handlers[N_SCAN_RESULTS] = -- cgit v0.10.2 From d2dfb33ec9a8da257bb0e6ed2872af2fdf85260c Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:16:38 +0100 Subject: iwlegacy: rename other handlers Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index e9a1e64..e33ebca 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -789,7 +789,7 @@ static void il3945_hdl_add_sta(struct il_priv *il, D_RX("Received C_ADD_STA: 0x%02X\n", pkt->u.status); } -static void il3945_rx_beacon_notif(struct il_priv *il, +static void il3945_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -812,7 +812,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il3945_rx_card_state_notif(struct il_priv *il, +static void il3945_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -856,24 +856,24 @@ static void il3945_setup_handlers(struct il_priv *il) il->handlers[N_ALIVE] = il3945_hdl_alive; il->handlers[C_ADD_STA] = il3945_hdl_add_sta; il->handlers[N_ERROR] = il_hdl_error; - il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = - il_rx_spectrum_measure_notif; - il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il_hdl_spectrum_measurement; + il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; il->handlers[N_PM_DEBUG_STATS] = - il_rx_pm_debug_stats_notif; - il->handlers[N_BEACON] = il3945_rx_beacon_notif; + il_hdl_pm_debug_stats; + il->handlers[N_BEACON] = il3945_hdl_beacon; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->handlers[C_STATS] = il3945_reply_stats; - il->handlers[N_STATS] = il3945_hw_rx_stats; + il->handlers[C_STATS] = il3945_hdl_c_stats; + il->handlers[N_STATS] = il3945_hdl_stats; il_setup_rx_scan_handlers(il); - il->handlers[N_CARD_STATE] = il3945_rx_card_state_notif; + il->handlers[N_CARD_STATE] = il3945_hdl_card_state; /* Set up hardware specific Rx handlers */ il3945_hw_handler_setup(il); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b45905f..83fe531 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -411,7 +411,7 @@ static void il3945_accumulative_stats(struct il_priv *il, } #endif -void il3945_hw_rx_stats(struct il_priv *il, +void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -426,7 +426,7 @@ void il3945_hw_rx_stats(struct il_priv *il, memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); } -void il3945_reply_stats(struct il_priv *il, +void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -443,7 +443,7 @@ void il3945_reply_stats(struct il_priv *il, #endif D_RX("Statistics have been cleared\n"); } - il3945_hw_rx_stats(il, rxb); + il3945_hdl_stats(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 6000aff..9854cf1 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -253,9 +253,9 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id); extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hw_rx_stats(struct il_priv *il, +extern void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il3945_reply_stats(struct il_priv *il, +void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 0797c11..2bab0fc 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1242,7 +1242,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) } return 0; } -void il4965_rx_missed_beacon_notif(struct il_priv *il, +void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb) { @@ -1352,7 +1352,7 @@ static void il4965_accumulative_stats(struct il_priv *il, #define REG_RECALIB_PERIOD (60) -void il4965_rx_stats(struct il_priv *il, +void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { int change; @@ -1396,7 +1396,7 @@ void il4965_rx_stats(struct il_priv *il, il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_reply_stats(struct il_priv *il, +void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1412,7 +1412,7 @@ void il4965_reply_stats(struct il_priv *il, #endif D_RX("Statistics have been cleared\n"); } - il4965_rx_stats(il, rxb); + il4965_hdl_stats(il, rxb); } @@ -3819,7 +3819,7 @@ static void il4965_bg_stats_periodic(unsigned long data) il_send_stats_request(il, CMD_ASYNC, false); } -static void il4965_rx_beacon_notif(struct il_priv *il, +static void il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3861,7 +3861,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il4965_rx_card_state_notif(struct il_priv *il, +static void il4965_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3923,30 +3923,30 @@ static void il4965_setup_handlers(struct il_priv *il) { il->handlers[N_ALIVE] = il4965_hdl_alive; il->handlers[N_ERROR] = il_hdl_error; - il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = - il_rx_spectrum_measure_notif; - il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il_hdl_spectrum_measurement; + il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; il->handlers[N_PM_DEBUG_STATS] = - il_rx_pm_debug_stats_notif; - il->handlers[N_BEACON] = il4965_rx_beacon_notif; + il_hdl_pm_debug_stats; + il->handlers[N_BEACON] = il4965_hdl_beacon; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->handlers[C_STATS] = il4965_reply_stats; - il->handlers[N_STATS] = il4965_rx_stats; + il->handlers[C_STATS] = il4965_hdl_c_stats; + il->handlers[N_STATS] = il4965_hdl_stats; il_setup_rx_scan_handlers(il); /* status change handler */ il->handlers[N_CARD_STATE] = - il4965_rx_card_state_notif; + il4965_hdl_card_state; il->handlers[N_MISSED_BEACONS] = - il4965_rx_missed_beacon_notif; + il4965_hdl_missed_beacon; /* Rx handlers */ il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; il->handlers[N_RX_MPDU] = il4965_hdl_rx; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 726fc80..ed2c617 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2122,7 +2122,7 @@ static void il4965_hdl_tx(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags); } -static void il4965_rx_beacon_notif(struct il_priv *il, +static void il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -2148,7 +2148,7 @@ static void il4965_handler_setup(struct il_priv *il) il->handlers[N_RX] = il4965_hdl_rx; /* Tx response */ il->handlers[C_TX] = il4965_hdl_tx; - il->handlers[N_BEACON] = il4965_rx_beacon_notif; + il->handlers[N_BEACON] = il4965_hdl_beacon; } static struct il_hcmd_ops il4965_hcmd = { diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index a8acbbb..5234de7 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -122,13 +122,13 @@ void il4965_tx_queue_set_status(struct il_priv *il, u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ -void il4965_rx_missed_beacon_notif(struct il_priv *il, +void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb); bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); -void il4965_rx_stats(struct il_priv *il, +void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il4965_reply_stats(struct il_priv *il, +void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); /* scan */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index abb8d86..856a321 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -847,7 +847,7 @@ void il_chswitch_done(struct il_priv *il, bool is_success) } EXPORT_SYMBOL(il_chswitch_done); -void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); @@ -870,7 +870,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) il_chswitch_done(il, false); } } -EXPORT_SYMBOL(il_rx_csa); +EXPORT_SYMBOL(il_hdl_csa); #ifdef CONFIG_IWLEGACY_DEBUG void il_print_rx_config_cmd(struct il_priv *il, @@ -1189,7 +1189,7 @@ int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) } EXPORT_SYMBOL(il_send_stats_request); -void il_rx_pm_sleep_notif(struct il_priv *il, +void il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -1199,9 +1199,9 @@ void il_rx_pm_sleep_notif(struct il_priv *il, sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } -EXPORT_SYMBOL(il_rx_pm_sleep_notif); +EXPORT_SYMBOL(il_hdl_pm_sleep); -void il_rx_pm_debug_stats_notif(struct il_priv *il, +void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1211,7 +1211,7 @@ void il_rx_pm_debug_stats_notif(struct il_priv *il, il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } -EXPORT_SYMBOL(il_rx_pm_debug_stats_notif); +EXPORT_SYMBOL(il_hdl_pm_debug_stats); void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb) diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 9897dac..5de742c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -369,9 +369,9 @@ static inline void il_update_stats(struct il_priv *il, bool is_tx, /***************************************************** * RX handlers. * **************************************************/ -void il_rx_pm_sleep_notif(struct il_priv *il, +void il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb); -void il_rx_pm_debug_stats_notif(struct il_priv *il, +void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb); void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb); @@ -388,12 +388,12 @@ int il_rx_queue_space(const struct il_rx_queue *q); void il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb); /* Handlers */ -void il_rx_spectrum_measure_notif(struct il_priv *il, +void il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb); void il_recover_from_stats(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); -void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb); +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); /* TX helpers */ diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 76f2361..7a8ae55 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -210,7 +210,7 @@ err_bd: EXPORT_SYMBOL(il_rx_queue_alloc); -void il_rx_spectrum_measure_notif(struct il_priv *il, +void il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -225,7 +225,7 @@ void il_rx_spectrum_measure_notif(struct il_priv *il, memcpy(&il->measure_report, report, sizeof(*report)); il->measurement_status |= MEASUREMENT_READY; } -EXPORT_SYMBOL(il_rx_spectrum_measure_notif); +EXPORT_SYMBOL(il_hdl_spectrum_measurement); /* * returns non-zero if packet should be dropped diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index f81db76..aaa589a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -195,7 +195,7 @@ static void il_hdl_scan(struct il_priv *il, } /* Service N_SCAN_START (0x82) */ -static void il_rx_scan_start_notif(struct il_priv *il, +static void il_hdl_scan_start(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -213,7 +213,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, } /* Service N_SCAN_RESULTS (0x83) */ -static void il_rx_scan_results_notif(struct il_priv *il, +static void il_hdl_scan_results(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -235,7 +235,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, } /* Service N_SCAN_COMPLETE (0x84) */ -static void il_rx_scan_complete_notif(struct il_priv *il, +static void il_hdl_scan_complete(struct il_priv *il, struct il_rx_buf *rxb) { @@ -265,11 +265,11 @@ void il_setup_rx_scan_handlers(struct il_priv *il) /* scan handlers */ il->handlers[C_SCAN] = il_hdl_scan; il->handlers[N_SCAN_START] = - il_rx_scan_start_notif; + il_hdl_scan_start; il->handlers[N_SCAN_RESULTS] = - il_rx_scan_results_notif; + il_hdl_scan_results; il->handlers[N_SCAN_COMPLETE] = - il_rx_scan_complete_notif; + il_hdl_scan_complete; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); -- cgit v0.10.2 From 4ed47911a2e0f9a425d22253433452ffa59d533e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:18:51 +0100 Subject: iwlegacy: rename iwl-core.c to common.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index d402496..0f51f9d 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_IWLEGACY) += iwl-legacy.o -iwl-legacy-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o +iwl-legacy-objs := common.o iwl-eeprom.o iwl-hcmd.o iwl-power.o iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-legacy-objs += iwl-scan.o iwl-led.o iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c new file mode 100644 index 0000000..856a321 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/common.c @@ -0,0 +1,2608 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "iwl-eeprom.h" +#include "iwl-dev.h" +#include "iwl-debug.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-power.h" +#include "iwl-sta.h" +#include "iwl-helpers.h" + + +MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965"); +MODULE_VERSION(IWLWIFI_VERSION); +MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); +MODULE_LICENSE("GPL"); + +/* + * set bt_coex_active to true, uCode will do kill/defer + * every time the priority line is asserted (BT is sending signals on the + * priority line in the PCIx). + * set bt_coex_active to false, uCode will ignore the BT activity and + * perform the normal operation + * + * User might experience transmit issue on some platform due to WiFi/BT + * co-exist problem. The possible behaviors are: + * Able to scan and finding all the available AP + * Not able to associate with any AP + * On those platforms, WiFi communication can be restored by set + * "bt_coex_active" module parameter to "false" + * + * default: bt_coex_active = true (BT_COEX_ENABLE) + */ +static bool bt_coex_active = true; +module_param(bt_coex_active, bool, S_IRUGO); +MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); + +u32 il_debug_level; +EXPORT_SYMBOL(il_debug_level); + +const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +EXPORT_SYMBOL(il_bcast_addr); + + +/* This function both allocates and initializes hw and il. */ +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) +{ + struct il_priv *il; + /* mac80211 allocates memory for this device instance, including + * space for this driver's ilate structure */ + struct ieee80211_hw *hw; + + hw = ieee80211_alloc_hw(sizeof(struct il_priv), + cfg->ops->ieee80211_ops); + if (hw == NULL) { + pr_err("%s: Can not allocate network device\n", + cfg->name); + goto out; + } + + il = hw->priv; + il->hw = hw; + +out: + return hw; +} +EXPORT_SYMBOL(il_alloc_all); + +#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ +#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ +static void il_init_ht_hw_capab(const struct il_priv *il, + struct ieee80211_sta_ht_cap *ht_info, + enum ieee80211_band band) +{ + u16 max_bit_rate = 0; + u8 rx_chains_num = il->hw_params.rx_chains_num; + u8 tx_chains_num = il->hw_params.tx_chains_num; + + ht_info->cap = 0; + memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); + + ht_info->ht_supported = true; + + ht_info->cap |= IEEE80211_HT_CAP_SGI_20; + max_bit_rate = MAX_BIT_RATE_20_MHZ; + if (il->hw_params.ht40_channel & BIT(band)) { + ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; + ht_info->cap |= IEEE80211_HT_CAP_SGI_40; + ht_info->mcs.rx_mask[4] = 0x01; + max_bit_rate = MAX_BIT_RATE_40_MHZ; + } + + if (il->cfg->mod_params->amsdu_size_8K) + ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; + + ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; + ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; + + ht_info->mcs.rx_mask[0] = 0xFF; + if (rx_chains_num >= 2) + ht_info->mcs.rx_mask[1] = 0xFF; + if (rx_chains_num >= 3) + ht_info->mcs.rx_mask[2] = 0xFF; + + /* Highest supported Rx data rate */ + max_bit_rate *= rx_chains_num; + WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK); + ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); + + /* Tx MCS capabilities */ + ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; + if (tx_chains_num != rx_chains_num) { + ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; + ht_info->mcs.tx_params |= ((tx_chains_num - 1) << + IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); + } +} + +/** + * il_init_geos - Initialize mac80211's geo/channel info based from eeprom + */ +int il_init_geos(struct il_priv *il) +{ + struct il_channel_info *ch; + struct ieee80211_supported_band *sband; + struct ieee80211_channel *channels; + struct ieee80211_channel *geo_ch; + struct ieee80211_rate *rates; + int i = 0; + s8 max_tx_power = 0; + + if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || + il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { + D_INFO("Geography modes already initialized.\n"); + set_bit(S_GEO_CONFIGURED, &il->status); + return 0; + } + + channels = kzalloc(sizeof(struct ieee80211_channel) * + il->channel_count, GFP_KERNEL); + if (!channels) + return -ENOMEM; + + rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), + GFP_KERNEL); + if (!rates) { + kfree(channels); + return -ENOMEM; + } + + /* 5.2GHz channels start after the 2.4GHz channels */ + sband = &il->bands[IEEE80211_BAND_5GHZ]; + sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; + /* just OFDM */ + sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; + sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; + + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, + IEEE80211_BAND_5GHZ); + + sband = &il->bands[IEEE80211_BAND_2GHZ]; + sband->channels = channels; + /* OFDM & CCK */ + sband->bitrates = rates; + sband->n_bitrates = RATE_COUNT_LEGACY; + + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, + IEEE80211_BAND_2GHZ); + + il->ieee_channels = channels; + il->ieee_rates = rates; + + for (i = 0; i < il->channel_count; i++) { + ch = &il->channel_info[i]; + + if (!il_is_channel_valid(ch)) + continue; + + sband = &il->bands[ch->band]; + + geo_ch = &sband->channels[sband->n_channels++]; + + geo_ch->center_freq = + ieee80211_channel_to_frequency(ch->channel, ch->band); + geo_ch->max_power = ch->max_power_avg; + geo_ch->max_antenna_gain = 0xff; + geo_ch->hw_value = ch->channel; + + if (il_is_channel_valid(ch)) { + if (!(ch->flags & EEPROM_CHANNEL_IBSS)) + geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; + + if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) + geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; + + if (ch->flags & EEPROM_CHANNEL_RADAR) + geo_ch->flags |= IEEE80211_CHAN_RADAR; + + geo_ch->flags |= ch->ht40_extension_channel; + + if (ch->max_power_avg > max_tx_power) + max_tx_power = ch->max_power_avg; + } else { + geo_ch->flags |= IEEE80211_CHAN_DISABLED; + } + + D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + ch->channel, geo_ch->center_freq, + il_is_channel_a_band(ch) ? "5.2" : "2.4", + geo_ch->flags & IEEE80211_CHAN_DISABLED ? + "restricted" : "valid", + geo_ch->flags); + } + + il->tx_power_device_lmt = max_tx_power; + il->tx_power_user_lmt = max_tx_power; + il->tx_power_next = max_tx_power; + + if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 && + (il->cfg->sku & IL_SKU_A)) { + IL_INFO("Incorrectly detected BG card as ABG. " + "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", + il->pci_dev->device, + il->pci_dev->subsystem_device); + il->cfg->sku &= ~IL_SKU_A; + } + + IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", + il->bands[IEEE80211_BAND_2GHZ].n_channels, + il->bands[IEEE80211_BAND_5GHZ].n_channels); + + set_bit(S_GEO_CONFIGURED, &il->status); + + return 0; +} +EXPORT_SYMBOL(il_init_geos); + +/* + * il_free_geos - undo allocations in il_init_geos + */ +void il_free_geos(struct il_priv *il) +{ + kfree(il->ieee_channels); + kfree(il->ieee_rates); + clear_bit(S_GEO_CONFIGURED, &il->status); +} +EXPORT_SYMBOL(il_free_geos); + +static bool il_is_channel_extension(struct il_priv *il, + enum ieee80211_band band, + u16 channel, u8 extension_chan_offset) +{ + const struct il_channel_info *ch_info; + + ch_info = il_get_channel_info(il, band, channel); + if (!il_is_channel_valid(ch_info)) + return false; + + if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) + return !(ch_info->ht40_extension_channel & + IEEE80211_CHAN_NO_HT40PLUS); + else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) + return !(ch_info->ht40_extension_channel & + IEEE80211_CHAN_NO_HT40MINUS); + + return false; +} + +bool il_is_ht40_tx_allowed(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap) +{ + if (!ctx->ht.enabled || !ctx->ht.is_40mhz) + return false; + + /* + * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40 + * the bit will not set if it is pure 40MHz case + */ + if (ht_cap && !ht_cap->ht_supported) + return false; + +#ifdef CONFIG_IWLEGACY_DEBUGFS + if (il->disable_ht40) + return false; +#endif + + return il_is_channel_extension(il, il->band, + le16_to_cpu(ctx->staging.channel), + ctx->ht.extension_chan_offset); +} +EXPORT_SYMBOL(il_is_ht40_tx_allowed); + +static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) +{ + u16 new_val; + u16 beacon_factor; + + /* + * If mac80211 hasn't given us a beacon interval, program + * the default into the device. + */ + if (!beacon_val) + return DEFAULT_BEACON_INTERVAL; + + /* + * If the beacon interval we obtained from the peer + * is too large, we'll have to wake up more often + * (and in IBSS case, we'll beacon too much) + * + * For example, if max_beacon_val is 4096, and the + * requested beacon interval is 7000, we'll have to + * use 3500 to be able to wake up on the beacons. + * + * This could badly influence beacon detection stats. + */ + + beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; + new_val = beacon_val / beacon_factor; + + if (!new_val) + new_val = max_beacon_val; + + return new_val; +} + +int +il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) +{ + u64 tsf; + s32 interval_tm, rem; + struct ieee80211_conf *conf = NULL; + u16 beacon_int; + struct ieee80211_vif *vif = ctx->vif; + + conf = il_ieee80211_get_hw_conf(il->hw); + + lockdep_assert_held(&il->mutex); + + memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); + + ctx->timing.timestamp = cpu_to_le64(il->timestamp); + ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); + + beacon_int = vif ? vif->bss_conf.beacon_int : 0; + + /* + * TODO: For IBSS we need to get atim_win from mac80211, + * for now just always use 0 + */ + ctx->timing.atim_win = 0; + + beacon_int = il_adjust_beacon_interval(beacon_int, + il->hw_params.max_beacon_itrvl * TIME_UNIT); + ctx->timing.beacon_interval = cpu_to_le16(beacon_int); + + tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ + interval_tm = beacon_int * TIME_UNIT; + rem = do_div(tsf, interval_tm); + ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); + + ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; + + D_ASSOC( + "beacon interval %d beacon timer %d beacon tim %d\n", + le16_to_cpu(ctx->timing.beacon_interval), + le32_to_cpu(ctx->timing.beacon_init_val), + le16_to_cpu(ctx->timing.atim_win)); + + return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, + sizeof(ctx->timing), &ctx->timing); +} +EXPORT_SYMBOL(il_send_rxon_timing); + +void +il_set_rxon_hwcrypto(struct il_priv *il, + struct il_rxon_context *ctx, + int hw_decrypt) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + + if (hw_decrypt) + rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; + else + rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; + +} +EXPORT_SYMBOL(il_set_rxon_hwcrypto); + +/* validate RXON structure is valid */ +int +il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + bool error = false; + + if (rxon->flags & RXON_FLG_BAND_24G_MSK) { + if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { + IL_WARN("check 2.4G: wrong narrow\n"); + error = true; + } + if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { + IL_WARN("check 2.4G: wrong radar\n"); + error = true; + } + } else { + if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { + IL_WARN("check 5.2G: not short slot!\n"); + error = true; + } + if (rxon->flags & RXON_FLG_CCK_MSK) { + IL_WARN("check 5.2G: CCK!\n"); + error = true; + } + } + if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { + IL_WARN("mac/bssid mcast!\n"); + error = true; + } + + /* make sure basic rates 6Mbps and 1Mbps are supported */ + if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && + (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { + IL_WARN("neither 1 nor 6 are basic\n"); + error = true; + } + + if (le16_to_cpu(rxon->assoc_id) > 2007) { + IL_WARN("aid > 2007\n"); + error = true; + } + + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) + == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { + IL_WARN("CCK and short slot\n"); + error = true; + } + + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) + == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { + IL_WARN("CCK and auto detect"); + error = true; + } + + if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | + RXON_FLG_TGG_PROTECT_MSK)) == + RXON_FLG_TGG_PROTECT_MSK) { + IL_WARN("TGg but no auto-detect\n"); + error = true; + } + + if (error) + IL_WARN("Tuning to channel %d\n", + le16_to_cpu(rxon->channel)); + + if (error) { + IL_ERR("Invalid RXON\n"); + return -EINVAL; + } + return 0; +} +EXPORT_SYMBOL(il_check_rxon_cmd); + +/** + * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed + * @il: staging_rxon is compared to active_rxon + * + * If the RXON structure is changing enough to require a new tune, + * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that + * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. + */ +int il_full_rxon_required(struct il_priv *il, + struct il_rxon_context *ctx) +{ + const struct il_rxon_cmd *staging = &ctx->staging; + const struct il_rxon_cmd *active = &ctx->active; + +#define CHK(cond) \ + if ((cond)) { \ + D_INFO("need full RXON - " #cond "\n"); \ + return 1; \ + } + +#define CHK_NEQ(c1, c2) \ + if ((c1) != (c2)) { \ + D_INFO("need full RXON - " \ + #c1 " != " #c2 " - %d != %d\n", \ + (c1), (c2)); \ + return 1; \ + } + + /* These items are only settable from the full RXON command */ + CHK(!il_is_associated_ctx(ctx)); + CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); + CHK(compare_ether_addr(staging->node_addr, active->node_addr)); + CHK(compare_ether_addr(staging->wlap_bssid_addr, + active->wlap_bssid_addr)); + CHK_NEQ(staging->dev_type, active->dev_type); + CHK_NEQ(staging->channel, active->channel); + CHK_NEQ(staging->air_propagation, active->air_propagation); + CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, + active->ofdm_ht_single_stream_basic_rates); + CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, + active->ofdm_ht_dual_stream_basic_rates); + CHK_NEQ(staging->assoc_id, active->assoc_id); + + /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can + * be updated with the RXON_ASSOC command -- however only some + * flag transitions are allowed using RXON_ASSOC */ + + /* Check if we are not switching bands */ + CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, + active->flags & RXON_FLG_BAND_24G_MSK); + + /* Check if we are switching association toggle */ + CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, + active->filter_flags & RXON_FILTER_ASSOC_MSK); + +#undef CHK +#undef CHK_NEQ + + return 0; +} +EXPORT_SYMBOL(il_full_rxon_required); + +u8 il_get_lowest_plcp(struct il_priv *il, + struct il_rxon_context *ctx) +{ + /* + * Assign the lowest rate -- should really get this from + * the beacon skb from mac80211. + */ + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) + return RATE_1M_PLCP; + else + return RATE_6M_PLCP; +} +EXPORT_SYMBOL(il_get_lowest_plcp); + +static void _il_set_rxon_ht(struct il_priv *il, + struct il_ht_config *ht_conf, + struct il_rxon_context *ctx) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + + if (!ctx->ht.enabled) { + rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | + RXON_FLG_HT40_PROT_MSK | + RXON_FLG_HT_PROT_MSK); + return; + } + + rxon->flags |= cpu_to_le32(ctx->ht.protection << + RXON_FLG_HT_OPERATING_MODE_POS); + + /* Set up channel bandwidth: + * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ + /* clear the HT channel mode before set the mode */ + rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + if (il_is_ht40_tx_allowed(il, ctx, NULL)) { + /* pure ht40 */ + if (ctx->ht.protection == + IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { + rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; + /* Note: control channel is opposite of extension channel */ + switch (ctx->ht.extension_chan_offset) { + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: + rxon->flags &= + ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + break; + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: + rxon->flags |= + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + break; + } + } else { + /* Note: control channel is opposite of extension channel */ + switch (ctx->ht.extension_chan_offset) { + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: + rxon->flags &= + ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; + break; + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: + rxon->flags |= + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; + break; + case IEEE80211_HT_PARAM_CHA_SEC_NONE: + default: + /* channel location only valid if in Mixed mode */ + IL_ERR( + "invalid extension channel offset\n"); + break; + } + } + } else { + rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; + } + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + D_ASSOC("rxon flags 0x%X operation mode :0x%X " + "extension channel offset 0x%x\n", + le32_to_cpu(rxon->flags), ctx->ht.protection, + ctx->ht.extension_chan_offset); +} + +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) +{ + _il_set_rxon_ht(il, ht_conf, &il->ctx); +} +EXPORT_SYMBOL(il_set_rxon_ht); + +/* Return valid, unused, channel for a passive scan to reset the RF */ +u8 il_get_single_channel_number(struct il_priv *il, + enum ieee80211_band band) +{ + const struct il_channel_info *ch_info; + int i; + u8 channel = 0; + u8 min, max; + + if (band == IEEE80211_BAND_5GHZ) { + min = 14; + max = il->channel_count; + } else { + min = 0; + max = 14; + } + + for (i = min; i < max; i++) { + channel = il->channel_info[i].channel; + if (channel == le16_to_cpu(il->ctx.staging.channel)) + continue; + + ch_info = il_get_channel_info(il, band, channel); + if (il_is_channel_valid(ch_info)) + break; + } + + return channel; +} +EXPORT_SYMBOL(il_get_single_channel_number); + +/** + * il_set_rxon_channel - Set the band and channel values in staging RXON + * @ch: requested channel as a pointer to struct ieee80211_channel + + * NOTE: Does not commit to the hardware; it sets appropriate bit fields + * in the staging RXON flag structure based on the ch->band + */ +int +il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, + struct il_rxon_context *ctx) +{ + enum ieee80211_band band = ch->band; + u16 channel = ch->hw_value; + + if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) + return 0; + + ctx->staging.channel = cpu_to_le16(channel); + if (band == IEEE80211_BAND_5GHZ) + ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; + else + ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; + + il->band = band; + + D_INFO("Staging channel set to %d [%d]\n", channel, band); + + return 0; +} +EXPORT_SYMBOL(il_set_rxon_channel); + +void il_set_flags_for_band(struct il_priv *il, + struct il_rxon_context *ctx, + enum ieee80211_band band, + struct ieee80211_vif *vif) +{ + if (band == IEEE80211_BAND_5GHZ) { + ctx->staging.flags &= + ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK + | RXON_FLG_CCK_MSK); + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + } else { + /* Copied from il_post_associate() */ + if (vif && vif->bss_conf.use_short_slot) + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + + ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; + ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; + ctx->staging.flags &= ~RXON_FLG_CCK_MSK; + } +} +EXPORT_SYMBOL(il_set_flags_for_band); + +/* + * initialize rxon structure with default values from eeprom + */ +void il_connection_init_rx_config(struct il_priv *il, + struct il_rxon_context *ctx) +{ + const struct il_channel_info *ch_info; + + memset(&ctx->staging, 0, sizeof(ctx->staging)); + + if (!ctx->vif) { + ctx->staging.dev_type = ctx->unused_devtype; + } else + switch (ctx->vif->type) { + + case NL80211_IFTYPE_STATION: + ctx->staging.dev_type = ctx->station_devtype; + ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; + break; + + case NL80211_IFTYPE_ADHOC: + ctx->staging.dev_type = ctx->ibss_devtype; + ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | + RXON_FILTER_ACCEPT_GRP_MSK; + break; + + default: + IL_ERR("Unsupported interface type %d\n", + ctx->vif->type); + break; + } + +#if 0 + /* TODO: Figure out when short_preamble would be set and cache from + * that */ + if (!hw_to_local(il->hw)->short_preamble) + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; +#endif + + ch_info = il_get_channel_info(il, il->band, + le16_to_cpu(ctx->active.channel)); + + if (!ch_info) + ch_info = &il->channel_info[0]; + + ctx->staging.channel = cpu_to_le16(ch_info->channel); + il->band = ch_info->band; + + il_set_flags_for_band(il, ctx, il->band, ctx->vif); + + ctx->staging.ofdm_basic_rates = + (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + ctx->staging.cck_basic_rates = + (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; + + /* clear both MIX and PURE40 mode flag */ + ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | + RXON_FLG_CHANNEL_MODE_PURE_40); + if (ctx->vif) + memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); + + ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; + ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; +} +EXPORT_SYMBOL(il_connection_init_rx_config); + +void il_set_rate(struct il_priv *il) +{ + const struct ieee80211_supported_band *hw = NULL; + struct ieee80211_rate *rate; + int i; + + hw = il_get_hw_mode(il, il->band); + if (!hw) { + IL_ERR("Failed to set rate: unable to get hw mode\n"); + return; + } + + il->active_rate = 0; + + for (i = 0; i < hw->n_bitrates; i++) { + rate = &(hw->bitrates[i]); + if (rate->hw_value < RATE_COUNT_LEGACY) + il->active_rate |= (1 << rate->hw_value); + } + + D_RATE("Set active_rate = %0x\n", il->active_rate); + + il->ctx.staging.cck_basic_rates = + (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; + + il->ctx.staging.ofdm_basic_rates = + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; +} +EXPORT_SYMBOL(il_set_rate); + +void il_chswitch_done(struct il_priv *il, bool is_success) +{ + struct il_rxon_context *ctx = &il->ctx; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return; + + if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) + ieee80211_chswitch_done(ctx->vif, is_success); +} +EXPORT_SYMBOL(il_chswitch_done); + +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_csa_notification *csa = &(pkt->u.csa_notif); + + struct il_rxon_context *ctx = &il->ctx; + struct il_rxon_cmd *rxon = (void *)&ctx->active; + + if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) + return; + + if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { + rxon->channel = csa->channel; + ctx->staging.channel = csa->channel; + D_11H("CSA notif: channel %d\n", + le16_to_cpu(csa->channel)); + il_chswitch_done(il, true); + } else { + IL_ERR("CSA notif (fail) : channel %d\n", + le16_to_cpu(csa->channel)); + il_chswitch_done(il, false); + } +} +EXPORT_SYMBOL(il_hdl_csa); + +#ifdef CONFIG_IWLEGACY_DEBUG +void il_print_rx_config_cmd(struct il_priv *il, + struct il_rxon_context *ctx) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + + D_RADIO("RX CONFIG:\n"); + il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); + D_RADIO("u16 channel: 0x%x\n", + le16_to_cpu(rxon->channel)); + D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + D_RADIO("u32 filter_flags: 0x%08x\n", + le32_to_cpu(rxon->filter_flags)); + D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); + D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", + rxon->ofdm_basic_rates); + D_RADIO("u8 cck_basic_rates: 0x%02x\n", + rxon->cck_basic_rates); + D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); + D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + D_RADIO("u16 assoc_id: 0x%x\n", + le16_to_cpu(rxon->assoc_id)); +} +EXPORT_SYMBOL(il_print_rx_config_cmd); +#endif +/** + * il_irq_handle_error - called for HW or SW error interrupt from card + */ +void il_irq_handle_error(struct il_priv *il) +{ + /* Set the FW error flag -- cleared on il_down */ + set_bit(S_FW_ERROR, &il->status); + + /* Cancel currently queued command. */ + clear_bit(S_HCMD_ACTIVE, &il->status); + + IL_ERR("Loaded firmware version: %s\n", + il->hw->wiphy->fw_version); + + il->cfg->ops->lib->dump_nic_error_log(il); + if (il->cfg->ops->lib->dump_fh) + il->cfg->ops->lib->dump_fh(il, NULL, false); +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & IL_DL_FW_ERRORS) + il_print_rx_config_cmd(il, + &il->ctx); +#endif + + wake_up(&il->wait_command_queue); + + /* Keep the restart process from trying to send host + * commands by clearing the INIT status bit */ + clear_bit(S_READY, &il->status); + + if (!test_bit(S_EXIT_PENDING, &il->status)) { + IL_DBG(IL_DL_FW_ERRORS, + "Restarting adapter due to uCode error.\n"); + + if (il->cfg->mod_params->restart_fw) + queue_work(il->workqueue, &il->restart); + } +} +EXPORT_SYMBOL(il_irq_handle_error); + +static int il_apm_stop_master(struct il_priv *il) +{ + int ret = 0; + + /* stop device's busmaster DMA activity */ + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + + ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); + if (ret) + IL_WARN("Master Disable Timed Out, 100 usec\n"); + + D_INFO("stop master\n"); + + return ret; +} + +void il_apm_stop(struct il_priv *il) +{ + D_INFO("Stop card, put in low power state\n"); + + /* Stop device's DMA activity */ + il_apm_stop_master(il); + + /* Reset the entire device */ + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + + udelay(10); + + /* + * Clear "initialization complete" bit to move adapter from + * D0A* (powered-up Active) --> D0U* (Uninitialized) state. + */ + il_clear_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_INIT_DONE); +} +EXPORT_SYMBOL(il_apm_stop); + + +/* + * Start up NIC's basic functionality after it has been reset + * (e.g. after platform boot, or shutdown via il_apm_stop()) + * NOTE: This does not load uCode nor start the embedded processor + */ +int il_apm_init(struct il_priv *il) +{ + int ret = 0; + u16 lctl; + + D_INFO("Init card's basic functions\n"); + + /* + * Use "set_bit" below rather than "write", to preserve any hardware + * bits already set by default after reset. + */ + + /* Disable L0S exit timer (platform NMI Work/Around) */ + il_set_bit(il, CSR_GIO_CHICKEN_BITS, + CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); + + /* + * Disable L0s without affecting L1; + * don't wait for ICH L0s (ICH bug W/A) + */ + il_set_bit(il, CSR_GIO_CHICKEN_BITS, + CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); + + /* Set FH wait threshold to maximum (HW error during stress W/A) */ + il_set_bit(il, CSR_DBG_HPET_MEM_REG, + CSR_DBG_HPET_MEM_REG_VAL); + + /* + * Enable HAP INTA (interrupt from management bus) to + * wake device's PCI Express link L1a -> L0s + * NOTE: This is no-op for 3945 (non-existent bit) + */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); + + /* + * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. + * Check if BIOS (or OS) enabled L1-ASPM on this device. + * If so (likely), disable L0S, so device moves directly L0->L1; + * costs negligible amount of power savings. + * If not (unlikely), enable L0S, so there is at least some + * power savings, even without L1. + */ + if (il->cfg->base_params->set_l0s) { + lctl = il_pcie_link_ctl(il); + if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == + PCI_CFG_LINK_CTRL_VAL_L1_EN) { + /* L1-ASPM enabled; disable(!) L0S */ + il_set_bit(il, CSR_GIO_REG, + CSR_GIO_REG_VAL_L0S_ENABLED); + D_POWER("L1 Enabled; Disabling L0S\n"); + } else { + /* L1-ASPM disabled; enable(!) L0S */ + il_clear_bit(il, CSR_GIO_REG, + CSR_GIO_REG_VAL_L0S_ENABLED); + D_POWER("L1 Disabled; Enabling L0S\n"); + } + } + + /* Configure analog phase-lock-loop before activating to D0A */ + if (il->cfg->base_params->pll_cfg_val) + il_set_bit(il, CSR_ANA_PLL_CFG, + il->cfg->base_params->pll_cfg_val); + + /* + * Set "initialization complete" bit to move adapter from + * D0U* --> D0A* (powered-up active) state. + */ + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + + /* + * Wait for clock stabilization; once stabilized, access to + * device-internal resources is supported, e.g. il_wr_prph() + * and accesses to uCode SRAM. + */ + ret = _il_poll_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); + if (ret < 0) { + D_INFO("Failed to init the card\n"); + goto out; + } + + /* + * Enable DMA and BSM (if used) clocks, wait for them to stabilize. + * BSM (Boostrap State Machine) is only in 3945 and 4965. + * + * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits + * do not disable clocks. This preserves any hardware bits already + * set by default in "CLK_CTRL_REG" after reset. + */ + if (il->cfg->base_params->use_bsm) + il_wr_prph(il, APMG_CLK_EN_REG, + APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); + else + il_wr_prph(il, APMG_CLK_EN_REG, + APMG_CLK_VAL_DMA_CLK_RQT); + udelay(20); + + /* Disable L1-Active */ + il_set_bits_prph(il, APMG_PCIDEV_STT_REG, + APMG_PCIDEV_STT_VAL_L1_ACT_DIS); + +out: + return ret; +} +EXPORT_SYMBOL(il_apm_init); + + +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) +{ + int ret; + s8 prev_tx_power; + bool defer; + struct il_rxon_context *ctx = &il->ctx; + + lockdep_assert_held(&il->mutex); + + if (il->tx_power_user_lmt == tx_power && !force) + return 0; + + if (!il->cfg->ops->lib->send_tx_power) + return -EOPNOTSUPP; + + /* 0 dBm mean 1 milliwatt */ + if (tx_power < 0) { + IL_WARN( + "Requested user TXPOWER %d below 1 mW.\n", + tx_power); + return -EINVAL; + } + + if (tx_power > il->tx_power_device_lmt) { + IL_WARN( + "Requested user TXPOWER %d above upper limit %d.\n", + tx_power, il->tx_power_device_lmt); + return -EINVAL; + } + + if (!il_is_ready_rf(il)) + return -EIO; + + /* scan complete and commit_rxon use tx_power_next value, + * it always need to be updated for newest request */ + il->tx_power_next = tx_power; + + /* do not set tx power when scanning or channel changing */ + defer = test_bit(S_SCANNING, &il->status) || + memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); + if (defer && !force) { + D_INFO("Deferring tx power set\n"); + return 0; + } + + prev_tx_power = il->tx_power_user_lmt; + il->tx_power_user_lmt = tx_power; + + ret = il->cfg->ops->lib->send_tx_power(il); + + /* if fail to set tx_power, restore the orig. tx power */ + if (ret) { + il->tx_power_user_lmt = prev_tx_power; + il->tx_power_next = prev_tx_power; + } + return ret; +} +EXPORT_SYMBOL(il_set_tx_power); + +void il_send_bt_config(struct il_priv *il) +{ + struct il_bt_cmd bt_cmd = { + .lead_time = BT_LEAD_TIME_DEF, + .max_kill = BT_MAX_KILL_DEF, + .kill_ack_mask = 0, + .kill_cts_mask = 0, + }; + + if (!bt_coex_active) + bt_cmd.flags = BT_COEX_DISABLE; + else + bt_cmd.flags = BT_COEX_ENABLE; + + D_INFO("BT coex %s\n", + (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); + + if (il_send_cmd_pdu(il, C_BT_CONFIG, + sizeof(struct il_bt_cmd), &bt_cmd)) + IL_ERR("failed to send BT Coex Config\n"); +} +EXPORT_SYMBOL(il_send_bt_config); + +int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) +{ + struct il_stats_cmd stats_cmd = { + .configuration_flags = + clear ? IL_STATS_CONF_CLEAR_STATS : 0, + }; + + if (flags & CMD_ASYNC) + return il_send_cmd_pdu_async(il, C_STATS, + sizeof(struct il_stats_cmd), + &stats_cmd, NULL); + else + return il_send_cmd_pdu(il, C_STATS, + sizeof(struct il_stats_cmd), + &stats_cmd); +} +EXPORT_SYMBOL(il_send_stats_request); + +void il_hdl_pm_sleep(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); + D_RX("sleep mode: %d, src: %d\n", + sleep->pm_sleep_mode, sleep->pm_wakeup_src); +#endif +} +EXPORT_SYMBOL(il_hdl_pm_sleep); + +void il_hdl_pm_debug_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + D_RADIO("Dumping %d bytes of unhandled " + "notification for %s:\n", len, + il_get_cmd_string(pkt->hdr.cmd)); + il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); +} +EXPORT_SYMBOL(il_hdl_pm_debug_stats); + +void il_hdl_error(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + + IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " + "seq 0x%04X ser 0x%08X\n", + le32_to_cpu(pkt->u.err_resp.error_type), + il_get_cmd_string(pkt->u.err_resp.cmd_id), + pkt->u.err_resp.cmd_id, + le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), + le32_to_cpu(pkt->u.err_resp.error_info)); +} +EXPORT_SYMBOL(il_hdl_error); + +void il_clear_isr_stats(struct il_priv *il) +{ + memset(&il->isr_stats, 0, sizeof(il->isr_stats)); +} + +int il_mac_conf_tx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *params) +{ + struct il_priv *il = hw->priv; + unsigned long flags; + int q; + + D_MAC80211("enter\n"); + + if (!il_is_ready_rf(il)) { + D_MAC80211("leave - RF not ready\n"); + return -EIO; + } + + if (queue >= AC_NUM) { + D_MAC80211("leave - queue >= AC_NUM %d\n", queue); + return 0; + } + + q = AC_NUM - 1 - queue; + + spin_lock_irqsave(&il->lock, flags); + + il->ctx.qos_data.def_qos_parm.ac[q].cw_min = + cpu_to_le16(params->cw_min); + il->ctx.qos_data.def_qos_parm.ac[q].cw_max = + cpu_to_le16(params->cw_max); + il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; + il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = + cpu_to_le16((params->txop * 32)); + + il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; + + spin_unlock_irqrestore(&il->lock, flags); + + D_MAC80211("leave\n"); + return 0; +} +EXPORT_SYMBOL(il_mac_conf_tx); + +int il_mac_tx_last_beacon(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + + return il->ibss_manager == IL_IBSS_MANAGER; +} +EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); + +static int +il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) +{ + il_connection_init_rx_config(il, ctx); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + return il_commit_rxon(il, ctx); +} + +static int il_setup_interface(struct il_priv *il, + struct il_rxon_context *ctx) +{ + struct ieee80211_vif *vif = ctx->vif; + int err; + + lockdep_assert_held(&il->mutex); + + /* + * This variable will be correct only when there's just + * a single context, but all code using it is for hardware + * that supports only one context. + */ + il->iw_mode = vif->type; + + ctx->is_active = true; + + err = il_set_mode(il, ctx); + if (err) { + if (!ctx->always_active) + ctx->is_active = false; + return err; + } + + return 0; +} + +int +il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + int err; + u32 modes; + + D_MAC80211("enter: type %d, addr %pM\n", + vif->type, vif->addr); + + mutex_lock(&il->mutex); + + if (!il_is_ready_rf(il)) { + IL_WARN("Try to add interface when device not ready\n"); + err = -EINVAL; + goto out; + } + + + /* check if busy context is exclusive */ + if (il->ctx.vif && + (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { + err = -EINVAL; + goto out; + } + + modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; + if (!(modes & BIT(vif->type))) { + err = -EOPNOTSUPP; + goto out; + } + + vif_priv->ctx = &il->ctx; + il->ctx.vif = vif; + + err = il_setup_interface(il, &il->ctx); + if (err) { + il->ctx.vif = NULL; + il->iw_mode = NL80211_IFTYPE_STATION; + } + + out: + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); + return err; +} +EXPORT_SYMBOL(il_mac_add_interface); + +static void il_teardown_interface(struct il_priv *il, + struct ieee80211_vif *vif, + bool mode_change) +{ + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + lockdep_assert_held(&il->mutex); + + if (il->scan_vif == vif) { + il_scan_cancel_timeout(il, 200); + il_force_scan_end(il); + } + + if (!mode_change) { + il_set_mode(il, ctx); + if (!ctx->always_active) + ctx->is_active = false; + } +} + +void il_mac_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + D_MAC80211("enter\n"); + + mutex_lock(&il->mutex); + + WARN_ON(ctx->vif != vif); + ctx->vif = NULL; + + il_teardown_interface(il, vif, false); + + memset(il->bssid, 0, ETH_ALEN); + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); + +} +EXPORT_SYMBOL(il_mac_remove_interface); + +int il_alloc_txq_mem(struct il_priv *il) +{ + if (!il->txq) + il->txq = kzalloc( + sizeof(struct il_tx_queue) * + il->cfg->base_params->num_of_queues, + GFP_KERNEL); + if (!il->txq) { + IL_ERR("Not enough memory for txq\n"); + return -ENOMEM; + } + return 0; +} +EXPORT_SYMBOL(il_alloc_txq_mem); + +void il_txq_mem(struct il_priv *il) +{ + kfree(il->txq); + il->txq = NULL; +} +EXPORT_SYMBOL(il_txq_mem); + +#ifdef CONFIG_IWLEGACY_DEBUGFS + +#define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) + +void il_reset_traffic_log(struct il_priv *il) +{ + il->tx_traffic_idx = 0; + il->rx_traffic_idx = 0; + if (il->tx_traffic) + memset(il->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); + if (il->rx_traffic) + memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); +} + +int il_alloc_traffic_mem(struct il_priv *il) +{ + u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; + + if (il_debug_level & IL_DL_TX) { + if (!il->tx_traffic) { + il->tx_traffic = + kzalloc(traffic_size, GFP_KERNEL); + if (!il->tx_traffic) + return -ENOMEM; + } + } + if (il_debug_level & IL_DL_RX) { + if (!il->rx_traffic) { + il->rx_traffic = + kzalloc(traffic_size, GFP_KERNEL); + if (!il->rx_traffic) + return -ENOMEM; + } + } + il_reset_traffic_log(il); + return 0; +} +EXPORT_SYMBOL(il_alloc_traffic_mem); + +void il_free_traffic_mem(struct il_priv *il) +{ + kfree(il->tx_traffic); + il->tx_traffic = NULL; + + kfree(il->rx_traffic); + il->rx_traffic = NULL; +} +EXPORT_SYMBOL(il_free_traffic_mem); + +void il_dbg_log_tx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ + __le16 fc; + u16 len; + + if (likely(!(il_debug_level & IL_DL_TX))) + return; + + if (!il->tx_traffic) + return; + + fc = header->frame_control; + if (ieee80211_is_data(fc)) { + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; + memcpy((il->tx_traffic + + (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + header, len); + il->tx_traffic_idx = + (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + } +} +EXPORT_SYMBOL(il_dbg_log_tx_data_frame); + +void il_dbg_log_rx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ + __le16 fc; + u16 len; + + if (likely(!(il_debug_level & IL_DL_RX))) + return; + + if (!il->rx_traffic) + return; + + fc = header->frame_control; + if (ieee80211_is_data(fc)) { + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; + memcpy((il->rx_traffic + + (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + header, len); + il->rx_traffic_idx = + (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + } +} +EXPORT_SYMBOL(il_dbg_log_rx_data_frame); + +const char *il_get_mgmt_string(int cmd) +{ + switch (cmd) { + IL_CMD(MANAGEMENT_ASSOC_REQ); + IL_CMD(MANAGEMENT_ASSOC_RESP); + IL_CMD(MANAGEMENT_REASSOC_REQ); + IL_CMD(MANAGEMENT_REASSOC_RESP); + IL_CMD(MANAGEMENT_PROBE_REQ); + IL_CMD(MANAGEMENT_PROBE_RESP); + IL_CMD(MANAGEMENT_BEACON); + IL_CMD(MANAGEMENT_ATIM); + IL_CMD(MANAGEMENT_DISASSOC); + IL_CMD(MANAGEMENT_AUTH); + IL_CMD(MANAGEMENT_DEAUTH); + IL_CMD(MANAGEMENT_ACTION); + default: + return "UNKNOWN"; + + } +} + +const char *il_get_ctrl_string(int cmd) +{ + switch (cmd) { + IL_CMD(CONTROL_BACK_REQ); + IL_CMD(CONTROL_BACK); + IL_CMD(CONTROL_PSPOLL); + IL_CMD(CONTROL_RTS); + IL_CMD(CONTROL_CTS); + IL_CMD(CONTROL_ACK); + IL_CMD(CONTROL_CFEND); + IL_CMD(CONTROL_CFENDACK); + default: + return "UNKNOWN"; + + } +} + +void il_clear_traffic_stats(struct il_priv *il) +{ + memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); + memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); +} + +/* + * if CONFIG_IWLEGACY_DEBUGFS defined, + * il_update_stats function will + * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass + * Use debugFs to display the rx/rx_stats + * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL + * information will be recorded, but DATA pkt still will be recorded + * for the reason of il_led.c need to control the led blinking based on + * number of tx and rx data. + * + */ +void +il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) +{ + struct traffic_stats *stats; + + if (is_tx) + stats = &il->tx_stats; + else + stats = &il->rx_stats; + + if (ieee80211_is_mgmt(fc)) { + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { + case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): + stats->mgmt[MANAGEMENT_ASSOC_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): + stats->mgmt[MANAGEMENT_ASSOC_RESP]++; + break; + case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): + stats->mgmt[MANAGEMENT_REASSOC_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): + stats->mgmt[MANAGEMENT_REASSOC_RESP]++; + break; + case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): + stats->mgmt[MANAGEMENT_PROBE_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): + stats->mgmt[MANAGEMENT_PROBE_RESP]++; + break; + case cpu_to_le16(IEEE80211_STYPE_BEACON): + stats->mgmt[MANAGEMENT_BEACON]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ATIM): + stats->mgmt[MANAGEMENT_ATIM]++; + break; + case cpu_to_le16(IEEE80211_STYPE_DISASSOC): + stats->mgmt[MANAGEMENT_DISASSOC]++; + break; + case cpu_to_le16(IEEE80211_STYPE_AUTH): + stats->mgmt[MANAGEMENT_AUTH]++; + break; + case cpu_to_le16(IEEE80211_STYPE_DEAUTH): + stats->mgmt[MANAGEMENT_DEAUTH]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ACTION): + stats->mgmt[MANAGEMENT_ACTION]++; + break; + } + } else if (ieee80211_is_ctl(fc)) { + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { + case cpu_to_le16(IEEE80211_STYPE_BACK_REQ): + stats->ctrl[CONTROL_BACK_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_BACK): + stats->ctrl[CONTROL_BACK]++; + break; + case cpu_to_le16(IEEE80211_STYPE_PSPOLL): + stats->ctrl[CONTROL_PSPOLL]++; + break; + case cpu_to_le16(IEEE80211_STYPE_RTS): + stats->ctrl[CONTROL_RTS]++; + break; + case cpu_to_le16(IEEE80211_STYPE_CTS): + stats->ctrl[CONTROL_CTS]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ACK): + stats->ctrl[CONTROL_ACK]++; + break; + case cpu_to_le16(IEEE80211_STYPE_CFEND): + stats->ctrl[CONTROL_CFEND]++; + break; + case cpu_to_le16(IEEE80211_STYPE_CFENDACK): + stats->ctrl[CONTROL_CFENDACK]++; + break; + } + } else { + /* data */ + stats->data_cnt++; + stats->data_bytes += len; + } +} +EXPORT_SYMBOL(il_update_stats); +#endif + +int il_force_reset(struct il_priv *il, bool external) +{ + struct il_force_reset *force_reset; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return -EINVAL; + + force_reset = &il->force_reset; + force_reset->reset_request_count++; + if (!external) { + if (force_reset->last_force_reset_jiffies && + time_after(force_reset->last_force_reset_jiffies + + force_reset->reset_duration, jiffies)) { + D_INFO("force reset rejected\n"); + force_reset->reset_reject_count++; + return -EAGAIN; + } + } + force_reset->reset_success_count++; + force_reset->last_force_reset_jiffies = jiffies; + + /* + * if the request is from external(ex: debugfs), + * then always perform the request in regardless the module + * parameter setting + * if the request is from internal (uCode error or driver + * detect failure), then fw_restart module parameter + * need to be check before performing firmware reload + */ + + if (!external && !il->cfg->mod_params->restart_fw) { + D_INFO("Cancel firmware reload based on " + "module parameter setting\n"); + return 0; + } + + IL_ERR("On demand firmware reload\n"); + + /* Set the FW error flag -- cleared on il_down */ + set_bit(S_FW_ERROR, &il->status); + wake_up(&il->wait_command_queue); + /* + * Keep the restart process from trying to send host + * commands by clearing the INIT status bit + */ + clear_bit(S_READY, &il->status); + queue_work(il->workqueue, &il->restart); + + return 0; +} + +int +il_mac_change_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum nl80211_iftype newtype, bool newp2p) +{ + struct il_priv *il = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + u32 modes; + int err; + + newtype = ieee80211_iftype_p2p(newtype, newp2p); + + mutex_lock(&il->mutex); + + if (!ctx->vif || !il_is_ready_rf(il)) { + /* + * Huh? But wait ... this can maybe happen when + * we're in the middle of a firmware restart! + */ + err = -EBUSY; + goto out; + } + + modes = ctx->interface_modes | ctx->exclusive_interface_modes; + if (!(modes & BIT(newtype))) { + err = -EOPNOTSUPP; + goto out; + } + + if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) || + (il->ctx.exclusive_interface_modes & BIT(newtype))) { + err = -EINVAL; + goto out; + } + + /* success */ + il_teardown_interface(il, vif, true); + vif->type = newtype; + vif->p2p = newp2p; + err = il_setup_interface(il, ctx); + WARN_ON(err); + /* + * We've switched internally, but submitting to the + * device may have failed for some reason. Mask this + * error, because otherwise mac80211 will not switch + * (and set the interface type back) and we'll be + * out of sync with it. + */ + err = 0; + + out: + mutex_unlock(&il->mutex); + return err; +} +EXPORT_SYMBOL(il_mac_change_interface); + +/* + * On every watchdog tick we check (latest) time stamp. If it does not + * change during timeout period and queue is not empty we reset firmware. + */ +static int il_check_stuck_queue(struct il_priv *il, int cnt) +{ + struct il_tx_queue *txq = &il->txq[cnt]; + struct il_queue *q = &txq->q; + unsigned long timeout; + int ret; + + if (q->read_ptr == q->write_ptr) { + txq->time_stamp = jiffies; + return 0; + } + + timeout = txq->time_stamp + + msecs_to_jiffies(il->cfg->base_params->wd_timeout); + + if (time_after(jiffies, timeout)) { + IL_ERR("Queue %d stuck for %u ms.\n", + q->id, il->cfg->base_params->wd_timeout); + ret = il_force_reset(il, false); + return (ret == -EAGAIN) ? 0 : 1; + } + + return 0; +} + +/* + * Making watchdog tick be a quarter of timeout assure we will + * discover the queue hung between timeout and 1.25*timeout + */ +#define IL_WD_TICK(timeout) ((timeout) / 4) + +/* + * Watchdog timer callback, we check each tx queue for stuck, if if hung + * we reset the firmware. If everything is fine just rearm the timer. + */ +void il_bg_watchdog(unsigned long data) +{ + struct il_priv *il = (struct il_priv *)data; + int cnt; + unsigned long timeout; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return; + + timeout = il->cfg->base_params->wd_timeout; + if (timeout == 0) + return; + + /* monitor and check for stuck cmd queue */ + if (il_check_stuck_queue(il, il->cmd_queue)) + return; + + /* monitor and check for other stuck queues */ + if (il_is_any_associated(il)) { + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + /* skip as we already checked the command queue */ + if (cnt == il->cmd_queue) + continue; + if (il_check_stuck_queue(il, cnt)) + return; + } + } + + mod_timer(&il->watchdog, jiffies + + msecs_to_jiffies(IL_WD_TICK(timeout))); +} +EXPORT_SYMBOL(il_bg_watchdog); + +void il_setup_watchdog(struct il_priv *il) +{ + unsigned int timeout = il->cfg->base_params->wd_timeout; + + if (timeout) + mod_timer(&il->watchdog, + jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); + else + del_timer(&il->watchdog); +} +EXPORT_SYMBOL(il_setup_watchdog); + +/* + * extended beacon time format + * time in usec will be changed into a 32-bit value in extended:internal format + * the extended part is the beacon counts + * the internal part is the time in usec within one beacon interval + */ +u32 +il_usecs_to_beacons(struct il_priv *il, + u32 usec, u32 beacon_interval) +{ + u32 quot; + u32 rem; + u32 interval = beacon_interval * TIME_UNIT; + + if (!interval || !usec) + return 0; + + quot = (usec / interval) & + (il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits) >> + il->hw_params.beacon_time_tsf_bits); + rem = (usec % interval) & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + + return (quot << il->hw_params.beacon_time_tsf_bits) + rem; +} +EXPORT_SYMBOL(il_usecs_to_beacons); + +/* base is usually what we get from ucode with each received frame, + * the same as HW timer counter counting down + */ +__le32 il_add_beacon_time(struct il_priv *il, u32 base, + u32 addon, u32 beacon_interval) +{ + u32 base_low = base & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + u32 addon_low = addon & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + u32 interval = beacon_interval * TIME_UNIT; + u32 res = (base & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)) + + (addon & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)); + + if (base_low > addon_low) + res += base_low - addon_low; + else if (base_low < addon_low) { + res += interval + base_low - addon_low; + res += (1 << il->hw_params.beacon_time_tsf_bits); + } else + res += (1 << il->hw_params.beacon_time_tsf_bits); + + return cpu_to_le32(res); +} +EXPORT_SYMBOL(il_add_beacon_time); + +#ifdef CONFIG_PM + +int il_pci_suspend(struct device *device) +{ + struct pci_dev *pdev = to_pci_dev(device); + struct il_priv *il = pci_get_drvdata(pdev); + + /* + * This function is called when system goes into suspend state + * mac80211 will call il_mac_stop() from the mac80211 suspend function + * first but since il_mac_stop() has no knowledge of who the caller is, + * it will not call apm_ops.stop() to stop the DMA operation. + * Calling apm_ops.stop here to make sure we stop the DMA. + */ + il_apm_stop(il); + + return 0; +} +EXPORT_SYMBOL(il_pci_suspend); + +int il_pci_resume(struct device *device) +{ + struct pci_dev *pdev = to_pci_dev(device); + struct il_priv *il = pci_get_drvdata(pdev); + bool hw_rfkill = false; + + /* + * We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state. + */ + pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); + + il_enable_interrupts(il); + + if (!(_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + hw_rfkill = true; + + if (hw_rfkill) + set_bit(S_RF_KILL_HW, &il->status); + else + clear_bit(S_RF_KILL_HW, &il->status); + + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); + + return 0; +} +EXPORT_SYMBOL(il_pci_resume); + +const struct dev_pm_ops il_pm_ops = { + .suspend = il_pci_suspend, + .resume = il_pci_resume, + .freeze = il_pci_suspend, + .thaw = il_pci_resume, + .poweroff = il_pci_suspend, + .restore = il_pci_resume, +}; +EXPORT_SYMBOL(il_pm_ops); + +#endif /* CONFIG_PM */ + +static void +il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) +{ + if (test_bit(S_EXIT_PENDING, &il->status)) + return; + + if (!ctx->is_active) + return; + + ctx->qos_data.def_qos_parm.qos_flags = 0; + + if (ctx->qos_data.qos_active) + ctx->qos_data.def_qos_parm.qos_flags |= + QOS_PARAM_FLG_UPDATE_EDCA_MSK; + + if (ctx->ht.enabled) + ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; + + D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", + ctx->qos_data.qos_active, + ctx->qos_data.def_qos_parm.qos_flags); + + il_send_cmd_pdu_async(il, ctx->qos_cmd, + sizeof(struct il_qosparam_cmd), + &ctx->qos_data.def_qos_parm, NULL); +} + +/** + * il_mac_config - mac80211 config callback + */ +int il_mac_config(struct ieee80211_hw *hw, u32 changed) +{ + struct il_priv *il = hw->priv; + const struct il_channel_info *ch_info; + struct ieee80211_conf *conf = &hw->conf; + struct ieee80211_channel *channel = conf->channel; + struct il_ht_config *ht_conf = &il->current_ht_config; + struct il_rxon_context *ctx = &il->ctx; + unsigned long flags = 0; + int ret = 0; + u16 ch; + int scan_active = 0; + bool ht_changed = false; + + if (WARN_ON(!il->cfg->ops->legacy)) + return -EOPNOTSUPP; + + mutex_lock(&il->mutex); + + D_MAC80211("enter to channel %d changed 0x%X\n", + channel->hw_value, changed); + + if (unlikely(test_bit(S_SCANNING, &il->status))) { + scan_active = 1; + D_MAC80211("scan active\n"); + } + + if (changed & (IEEE80211_CONF_CHANGE_SMPS | + IEEE80211_CONF_CHANGE_CHANNEL)) { + /* mac80211 uses static for non-HT which is what we want */ + il->current_ht_config.smps = conf->smps_mode; + + /* + * Recalculate chain counts. + * + * If monitor mode is enabled then mac80211 will + * set up the SM PS mode to OFF if an HT channel is + * configured. + */ + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); + } + + /* during scanning mac80211 will delay channel setting until + * scan finish with changed = 0 + */ + if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { + + if (scan_active) + goto set_ch_out; + + ch = channel->hw_value; + ch_info = il_get_channel_info(il, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + D_MAC80211("leave - invalid channel\n"); + ret = -EINVAL; + goto set_ch_out; + } + + if (il->iw_mode == NL80211_IFTYPE_ADHOC && + !il_is_channel_ibss(ch_info)) { + D_MAC80211("leave - not IBSS channel\n"); + ret = -EINVAL; + goto set_ch_out; + } + + spin_lock_irqsave(&il->lock, flags); + + /* Configure HT40 channels */ + if (ctx->ht.enabled != conf_is_ht(conf)) { + ctx->ht.enabled = conf_is_ht(conf); + ht_changed = true; + } + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; + + /* + * Default to no protection. Protection mode will + * later be set from BSS config in il_ht_conf + */ + ctx->ht.protection = + IEEE80211_HT_OP_MODE_PROTECTION_NONE; + + /* if we are switching from ht to 2.4 clear flags + * from any ht related info since 2.4 does not + * support ht */ + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; + + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); + + il_set_flags_for_band(il, ctx, channel->band, + ctx->vif); + + spin_unlock_irqrestore(&il->lock, flags); + + if (il->cfg->ops->legacy->update_bcast_stations) + ret = + il->cfg->ops->legacy->update_bcast_stations(il); + + set_ch_out: + /* The list of supported rates and rate mask can be different + * for each band; since the band may have changed, reset + * the rate mask to what mac80211 lists */ + il_set_rate(il); + } + + if (changed & (IEEE80211_CONF_CHANGE_PS | + IEEE80211_CONF_CHANGE_IDLE)) { + ret = il_power_update_mode(il, false); + if (ret) + D_MAC80211("Error setting sleep level\n"); + } + + if (changed & IEEE80211_CONF_CHANGE_POWER) { + D_MAC80211("TX Power old=%d new=%d\n", + il->tx_power_user_lmt, conf->power_level); + + il_set_tx_power(il, conf->power_level, false); + } + + if (!il_is_ready(il)) { + D_MAC80211("leave - not ready\n"); + goto out; + } + + if (scan_active) + goto out; + + if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) + il_commit_rxon(il, ctx); + else + D_INFO("Not re-sending same RXON configuration.\n"); + if (ht_changed) + il_update_qos(il, ctx); + +out: + D_MAC80211("leave\n"); + mutex_unlock(&il->mutex); + return ret; +} +EXPORT_SYMBOL(il_mac_config); + +void il_mac_reset_tsf(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + unsigned long flags; + struct il_rxon_context *ctx = &il->ctx; + + if (WARN_ON(!il->cfg->ops->legacy)) + return; + + mutex_lock(&il->mutex); + D_MAC80211("enter\n"); + + spin_lock_irqsave(&il->lock, flags); + memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); + spin_unlock_irqrestore(&il->lock, flags); + + spin_lock_irqsave(&il->lock, flags); + + /* new association get rid of ibss beacon skb */ + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + + il->beacon_skb = NULL; + + il->timestamp = 0; + + spin_unlock_irqrestore(&il->lock, flags); + + il_scan_cancel_timeout(il, 100); + if (!il_is_ready_rf(il)) { + D_MAC80211("leave - not ready\n"); + mutex_unlock(&il->mutex); + return; + } + + /* we are restarting association process + * clear RXON_FILTER_ASSOC_MSK bit + */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + + il_set_rate(il); + + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); +} +EXPORT_SYMBOL(il_mac_reset_tsf); + +static void il_ht_conf(struct il_priv *il, + struct ieee80211_vif *vif) +{ + struct il_ht_config *ht_conf = &il->current_ht_config; + struct ieee80211_sta *sta; + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + D_ASSOC("enter:\n"); + + if (!ctx->ht.enabled) + return; + + ctx->ht.protection = + bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; + ctx->ht.non_gf_sta_present = + !!(bss_conf->ht_operation_mode & + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); + + ht_conf->single_chain_sufficient = false; + + switch (vif->type) { + case NL80211_IFTYPE_STATION: + rcu_read_lock(); + sta = ieee80211_find_sta(vif, bss_conf->bssid); + if (sta) { + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + int maxstreams; + + maxstreams = (ht_cap->mcs.tx_params & + IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) + >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; + maxstreams += 1; + + if (ht_cap->mcs.rx_mask[1] == 0 && + ht_cap->mcs.rx_mask[2] == 0) + ht_conf->single_chain_sufficient = true; + if (maxstreams <= 1) + ht_conf->single_chain_sufficient = true; + } else { + /* + * If at all, this can only happen through a race + * when the AP disconnects us while we're still + * setting up the connection, in that case mac80211 + * will soon tell us about that. + */ + ht_conf->single_chain_sufficient = true; + } + rcu_read_unlock(); + break; + case NL80211_IFTYPE_ADHOC: + ht_conf->single_chain_sufficient = true; + break; + default: + break; + } + + D_ASSOC("leave\n"); +} + +static inline void il_set_no_assoc(struct il_priv *il, + struct ieee80211_vif *vif) +{ + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + /* + * inform the ucode that there is no longer an + * association and that no more packets should be + * sent + */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + ctx->staging.assoc_id = 0; + il_commit_rxon(il, ctx); +} + +static void il_beacon_update(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + unsigned long flags; + __le64 timestamp; + struct sk_buff *skb = ieee80211_beacon_get(hw, vif); + + if (!skb) + return; + + D_MAC80211("enter\n"); + + lockdep_assert_held(&il->mutex); + + if (!il->beacon_ctx) { + IL_ERR("update beacon but no beacon context!\n"); + dev_kfree_skb(skb); + return; + } + + spin_lock_irqsave(&il->lock, flags); + + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + + il->beacon_skb = skb; + + timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; + il->timestamp = le64_to_cpu(timestamp); + + D_MAC80211("leave\n"); + spin_unlock_irqrestore(&il->lock, flags); + + if (!il_is_ready_rf(il)) { + D_MAC80211("leave - RF not ready\n"); + return; + } + + il->cfg->ops->legacy->post_associate(il); +} + +void il_mac_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, + u32 changes) +{ + struct il_priv *il = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + int ret; + + if (WARN_ON(!il->cfg->ops->legacy)) + return; + + D_MAC80211("changes = 0x%X\n", changes); + + mutex_lock(&il->mutex); + + if (!il_is_alive(il)) { + mutex_unlock(&il->mutex); + return; + } + + if (changes & BSS_CHANGED_QOS) { + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + ctx->qos_data.qos_active = bss_conf->qos; + il_update_qos(il, ctx); + spin_unlock_irqrestore(&il->lock, flags); + } + + if (changes & BSS_CHANGED_BEACON_ENABLED) { + /* + * the add_interface code must make sure we only ever + * have a single interface that could be beaconing at + * any time. + */ + if (vif->bss_conf.enable_beacon) + il->beacon_ctx = ctx; + else + il->beacon_ctx = NULL; + } + + if (changes & BSS_CHANGED_BSSID) { + D_MAC80211("BSSID %pM\n", bss_conf->bssid); + + /* + * If there is currently a HW scan going on in the + * background then we need to cancel it else the RXON + * below/in post_associate will fail. + */ + if (il_scan_cancel_timeout(il, 100)) { + IL_WARN( + "Aborted scan still in progress after 100ms\n"); + D_MAC80211( + "leaving - scan abort failed.\n"); + mutex_unlock(&il->mutex); + return; + } + + /* mac80211 only sets assoc when in STATION mode */ + if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { + memcpy(ctx->staging.bssid_addr, + bss_conf->bssid, ETH_ALEN); + + /* currently needed in a few places */ + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); + } else { + ctx->staging.filter_flags &= + ~RXON_FILTER_ASSOC_MSK; + } + + } + + /* + * This needs to be after setting the BSSID in case + * mac80211 decides to do both changes at once because + * it will invoke post_associate. + */ + if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) + il_beacon_update(hw, vif); + + if (changes & BSS_CHANGED_ERP_PREAMBLE) { + D_MAC80211("ERP_PREAMBLE %d\n", + bss_conf->use_short_preamble); + if (bss_conf->use_short_preamble) + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + } + + if (changes & BSS_CHANGED_ERP_CTS_PROT) { + D_MAC80211( + "ERP_CTS %d\n", bss_conf->use_cts_prot); + if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) + ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; + if (bss_conf->use_cts_prot) + ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; + else + ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; + } + + if (changes & BSS_CHANGED_BASIC_RATES) { + /* XXX use this information + * + * To do that, remove code from il_set_rate() and put something + * like this here: + * + if (A-band) + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates; + else + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates >> 4; + ctx->staging.cck_basic_rates = + bss_conf->basic_rates & 0xF; + */ + } + + if (changes & BSS_CHANGED_HT) { + il_ht_conf(il, vif); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + } + + if (changes & BSS_CHANGED_ASSOC) { + D_MAC80211("ASSOC %d\n", bss_conf->assoc); + if (bss_conf->assoc) { + il->timestamp = bss_conf->timestamp; + + if (!il_is_rfkill(il)) + il->cfg->ops->legacy->post_associate(il); + } else + il_set_no_assoc(il, vif); + } + + if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { + D_MAC80211("Changes (%#x) while associated\n", + changes); + ret = il_send_rxon_assoc(il, ctx); + if (!ret) { + /* Sync active_rxon with latest change. */ + memcpy((void *)&ctx->active, + &ctx->staging, + sizeof(struct il_rxon_cmd)); + } + } + + if (changes & BSS_CHANGED_BEACON_ENABLED) { + if (vif->bss_conf.enable_beacon) { + memcpy(ctx->staging.bssid_addr, + bss_conf->bssid, ETH_ALEN); + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); + il->cfg->ops->legacy->config_ap(il); + } else + il_set_no_assoc(il, vif); + } + + if (changes & BSS_CHANGED_IBSS) { + ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, + bss_conf->ibss_joined); + if (ret) + IL_ERR("failed to %s IBSS station %pM\n", + bss_conf->ibss_joined ? "add" : "remove", + bss_conf->bssid); + } + + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); +} +EXPORT_SYMBOL(il_mac_bss_info_changed); + +irqreturn_t il_isr(int irq, void *data) +{ + struct il_priv *il = data; + u32 inta, inta_mask; + u32 inta_fh; + unsigned long flags; + if (!il) + return IRQ_NONE; + + spin_lock_irqsave(&il->lock, flags); + + /* Disable (but don't clear!) interrupts here to avoid + * back-to-back ISRs and sporadic interrupts from our NIC. + * If we have something to service, the tasklet will re-enable ints. + * If we *don't* have something, we'll re-enable before leaving here. */ + inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ + _il_wr(il, CSR_INT_MASK, 0x00000000); + + /* Discover which interrupts are active/pending */ + inta = _il_rd(il, CSR_INT); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + + /* Ignore interrupt if there's nothing in NIC to service. + * This may be due to IRQ shared with another device, + * or due to sporadic interrupts thrown from our NIC. */ + if (!inta && !inta_fh) { + D_ISR( + "Ignore interrupt, inta == 0, inta_fh == 0\n"); + goto none; + } + + if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) { + /* Hardware disappeared. It might have already raised + * an interrupt */ + IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); + goto unplugged; + } + + D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta, inta_mask, inta_fh); + + inta &= ~CSR_INT_BIT_SCD; + + /* il_irq_tasklet() will service interrupts and re-enable them */ + if (likely(inta || inta_fh)) + tasklet_schedule(&il->irq_tasklet); + +unplugged: + spin_unlock_irqrestore(&il->lock, flags); + return IRQ_HANDLED; + +none: + /* re-enable interrupts here since we don't have anything to service. */ + /* only Re-enable if disabled by irq */ + if (test_bit(S_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + return IRQ_NONE; +} +EXPORT_SYMBOL(il_isr); + +/* + * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this + * function. + */ +void il_tx_cmd_protection(struct il_priv *il, + struct ieee80211_tx_info *info, + __le16 fc, __le32 *tx_flags) +{ + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { + *tx_flags |= TX_CMD_FLG_RTS_MSK; + *tx_flags &= ~TX_CMD_FLG_CTS_MSK; + *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; + + if (!ieee80211_is_mgmt(fc)) + return; + + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { + case cpu_to_le16(IEEE80211_STYPE_AUTH): + case cpu_to_le16(IEEE80211_STYPE_DEAUTH): + case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): + case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): + *tx_flags &= ~TX_CMD_FLG_RTS_MSK; + *tx_flags |= TX_CMD_FLG_CTS_MSK; + break; + } + } else if (info->control.rates[0].flags & + IEEE80211_TX_RC_USE_CTS_PROTECT) { + *tx_flags &= ~TX_CMD_FLG_RTS_MSK; + *tx_flags |= TX_CMD_FLG_CTS_MSK; + *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; + } +} +EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c deleted file mode 100644 index 856a321..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ /dev/null @@ -1,2608 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-debug.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-power.h" -#include "iwl-sta.h" -#include "iwl-helpers.h" - - -MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965"); -MODULE_VERSION(IWLWIFI_VERSION); -MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); -MODULE_LICENSE("GPL"); - -/* - * set bt_coex_active to true, uCode will do kill/defer - * every time the priority line is asserted (BT is sending signals on the - * priority line in the PCIx). - * set bt_coex_active to false, uCode will ignore the BT activity and - * perform the normal operation - * - * User might experience transmit issue on some platform due to WiFi/BT - * co-exist problem. The possible behaviors are: - * Able to scan and finding all the available AP - * Not able to associate with any AP - * On those platforms, WiFi communication can be restored by set - * "bt_coex_active" module parameter to "false" - * - * default: bt_coex_active = true (BT_COEX_ENABLE) - */ -static bool bt_coex_active = true; -module_param(bt_coex_active, bool, S_IRUGO); -MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); - -u32 il_debug_level; -EXPORT_SYMBOL(il_debug_level); - -const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -EXPORT_SYMBOL(il_bcast_addr); - - -/* This function both allocates and initializes hw and il. */ -struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) -{ - struct il_priv *il; - /* mac80211 allocates memory for this device instance, including - * space for this driver's ilate structure */ - struct ieee80211_hw *hw; - - hw = ieee80211_alloc_hw(sizeof(struct il_priv), - cfg->ops->ieee80211_ops); - if (hw == NULL) { - pr_err("%s: Can not allocate network device\n", - cfg->name); - goto out; - } - - il = hw->priv; - il->hw = hw; - -out: - return hw; -} -EXPORT_SYMBOL(il_alloc_all); - -#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ -#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void il_init_ht_hw_capab(const struct il_priv *il, - struct ieee80211_sta_ht_cap *ht_info, - enum ieee80211_band band) -{ - u16 max_bit_rate = 0; - u8 rx_chains_num = il->hw_params.rx_chains_num; - u8 tx_chains_num = il->hw_params.tx_chains_num; - - ht_info->cap = 0; - memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); - - ht_info->ht_supported = true; - - ht_info->cap |= IEEE80211_HT_CAP_SGI_20; - max_bit_rate = MAX_BIT_RATE_20_MHZ; - if (il->hw_params.ht40_channel & BIT(band)) { - ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; - ht_info->cap |= IEEE80211_HT_CAP_SGI_40; - ht_info->mcs.rx_mask[4] = 0x01; - max_bit_rate = MAX_BIT_RATE_40_MHZ; - } - - if (il->cfg->mod_params->amsdu_size_8K) - ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; - - ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; - ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; - - ht_info->mcs.rx_mask[0] = 0xFF; - if (rx_chains_num >= 2) - ht_info->mcs.rx_mask[1] = 0xFF; - if (rx_chains_num >= 3) - ht_info->mcs.rx_mask[2] = 0xFF; - - /* Highest supported Rx data rate */ - max_bit_rate *= rx_chains_num; - WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK); - ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); - - /* Tx MCS capabilities */ - ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; - if (tx_chains_num != rx_chains_num) { - ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; - ht_info->mcs.tx_params |= ((tx_chains_num - 1) << - IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); - } -} - -/** - * il_init_geos - Initialize mac80211's geo/channel info based from eeprom - */ -int il_init_geos(struct il_priv *il) -{ - struct il_channel_info *ch; - struct ieee80211_supported_band *sband; - struct ieee80211_channel *channels; - struct ieee80211_channel *geo_ch; - struct ieee80211_rate *rates; - int i = 0; - s8 max_tx_power = 0; - - if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || - il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - D_INFO("Geography modes already initialized.\n"); - set_bit(S_GEO_CONFIGURED, &il->status); - return 0; - } - - channels = kzalloc(sizeof(struct ieee80211_channel) * - il->channel_count, GFP_KERNEL); - if (!channels) - return -ENOMEM; - - rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), - GFP_KERNEL); - if (!rates) { - kfree(channels); - return -ENOMEM; - } - - /* 5.2GHz channels start after the 2.4GHz channels */ - sband = &il->bands[IEEE80211_BAND_5GHZ]; - sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; - /* just OFDM */ - sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; - sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; - - if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_5GHZ); - - sband = &il->bands[IEEE80211_BAND_2GHZ]; - sband->channels = channels; - /* OFDM & CCK */ - sband->bitrates = rates; - sband->n_bitrates = RATE_COUNT_LEGACY; - - if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_2GHZ); - - il->ieee_channels = channels; - il->ieee_rates = rates; - - for (i = 0; i < il->channel_count; i++) { - ch = &il->channel_info[i]; - - if (!il_is_channel_valid(ch)) - continue; - - sband = &il->bands[ch->band]; - - geo_ch = &sband->channels[sband->n_channels++]; - - geo_ch->center_freq = - ieee80211_channel_to_frequency(ch->channel, ch->band); - geo_ch->max_power = ch->max_power_avg; - geo_ch->max_antenna_gain = 0xff; - geo_ch->hw_value = ch->channel; - - if (il_is_channel_valid(ch)) { - if (!(ch->flags & EEPROM_CHANNEL_IBSS)) - geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; - - if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) - geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; - - if (ch->flags & EEPROM_CHANNEL_RADAR) - geo_ch->flags |= IEEE80211_CHAN_RADAR; - - geo_ch->flags |= ch->ht40_extension_channel; - - if (ch->max_power_avg > max_tx_power) - max_tx_power = ch->max_power_avg; - } else { - geo_ch->flags |= IEEE80211_CHAN_DISABLED; - } - - D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", - ch->channel, geo_ch->center_freq, - il_is_channel_a_band(ch) ? "5.2" : "2.4", - geo_ch->flags & IEEE80211_CHAN_DISABLED ? - "restricted" : "valid", - geo_ch->flags); - } - - il->tx_power_device_lmt = max_tx_power; - il->tx_power_user_lmt = max_tx_power; - il->tx_power_next = max_tx_power; - - if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 && - (il->cfg->sku & IL_SKU_A)) { - IL_INFO("Incorrectly detected BG card as ABG. " - "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", - il->pci_dev->device, - il->pci_dev->subsystem_device); - il->cfg->sku &= ~IL_SKU_A; - } - - IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", - il->bands[IEEE80211_BAND_2GHZ].n_channels, - il->bands[IEEE80211_BAND_5GHZ].n_channels); - - set_bit(S_GEO_CONFIGURED, &il->status); - - return 0; -} -EXPORT_SYMBOL(il_init_geos); - -/* - * il_free_geos - undo allocations in il_init_geos - */ -void il_free_geos(struct il_priv *il) -{ - kfree(il->ieee_channels); - kfree(il->ieee_rates); - clear_bit(S_GEO_CONFIGURED, &il->status); -} -EXPORT_SYMBOL(il_free_geos); - -static bool il_is_channel_extension(struct il_priv *il, - enum ieee80211_band band, - u16 channel, u8 extension_chan_offset) -{ - const struct il_channel_info *ch_info; - - ch_info = il_get_channel_info(il, band, channel); - if (!il_is_channel_valid(ch_info)) - return false; - - if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40PLUS); - else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40MINUS); - - return false; -} - -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap) -{ - if (!ctx->ht.enabled || !ctx->ht.is_40mhz) - return false; - - /* - * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40 - * the bit will not set if it is pure 40MHz case - */ - if (ht_cap && !ht_cap->ht_supported) - return false; - -#ifdef CONFIG_IWLEGACY_DEBUGFS - if (il->disable_ht40) - return false; -#endif - - return il_is_channel_extension(il, il->band, - le16_to_cpu(ctx->staging.channel), - ctx->ht.extension_chan_offset); -} -EXPORT_SYMBOL(il_is_ht40_tx_allowed); - -static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) -{ - u16 new_val; - u16 beacon_factor; - - /* - * If mac80211 hasn't given us a beacon interval, program - * the default into the device. - */ - if (!beacon_val) - return DEFAULT_BEACON_INTERVAL; - - /* - * If the beacon interval we obtained from the peer - * is too large, we'll have to wake up more often - * (and in IBSS case, we'll beacon too much) - * - * For example, if max_beacon_val is 4096, and the - * requested beacon interval is 7000, we'll have to - * use 3500 to be able to wake up on the beacons. - * - * This could badly influence beacon detection stats. - */ - - beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; - new_val = beacon_val / beacon_factor; - - if (!new_val) - new_val = max_beacon_val; - - return new_val; -} - -int -il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) -{ - u64 tsf; - s32 interval_tm, rem; - struct ieee80211_conf *conf = NULL; - u16 beacon_int; - struct ieee80211_vif *vif = ctx->vif; - - conf = il_ieee80211_get_hw_conf(il->hw); - - lockdep_assert_held(&il->mutex); - - memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); - - ctx->timing.timestamp = cpu_to_le64(il->timestamp); - ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); - - beacon_int = vif ? vif->bss_conf.beacon_int : 0; - - /* - * TODO: For IBSS we need to get atim_win from mac80211, - * for now just always use 0 - */ - ctx->timing.atim_win = 0; - - beacon_int = il_adjust_beacon_interval(beacon_int, - il->hw_params.max_beacon_itrvl * TIME_UNIT); - ctx->timing.beacon_interval = cpu_to_le16(beacon_int); - - tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ - interval_tm = beacon_int * TIME_UNIT; - rem = do_div(tsf, interval_tm); - ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); - - ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - - D_ASSOC( - "beacon interval %d beacon timer %d beacon tim %d\n", - le16_to_cpu(ctx->timing.beacon_interval), - le32_to_cpu(ctx->timing.beacon_init_val), - le16_to_cpu(ctx->timing.atim_win)); - - return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, - sizeof(ctx->timing), &ctx->timing); -} -EXPORT_SYMBOL(il_send_rxon_timing); - -void -il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - - if (hw_decrypt) - rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; - else - rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; - -} -EXPORT_SYMBOL(il_set_rxon_hwcrypto); - -/* validate RXON structure is valid */ -int -il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - bool error = false; - - if (rxon->flags & RXON_FLG_BAND_24G_MSK) { - if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IL_WARN("check 2.4G: wrong narrow\n"); - error = true; - } - if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IL_WARN("check 2.4G: wrong radar\n"); - error = true; - } - } else { - if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN("check 5.2G: not short slot!\n"); - error = true; - } - if (rxon->flags & RXON_FLG_CCK_MSK) { - IL_WARN("check 5.2G: CCK!\n"); - error = true; - } - } - if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IL_WARN("mac/bssid mcast!\n"); - error = true; - } - - /* make sure basic rates 6Mbps and 1Mbps are supported */ - if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && - (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { - IL_WARN("neither 1 nor 6 are basic\n"); - error = true; - } - - if (le16_to_cpu(rxon->assoc_id) > 2007) { - IL_WARN("aid > 2007\n"); - error = true; - } - - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN("CCK and short slot\n"); - error = true; - } - - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IL_WARN("CCK and auto detect"); - error = true; - } - - if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | - RXON_FLG_TGG_PROTECT_MSK)) == - RXON_FLG_TGG_PROTECT_MSK) { - IL_WARN("TGg but no auto-detect\n"); - error = true; - } - - if (error) - IL_WARN("Tuning to channel %d\n", - le16_to_cpu(rxon->channel)); - - if (error) { - IL_ERR("Invalid RXON\n"); - return -EINVAL; - } - return 0; -} -EXPORT_SYMBOL(il_check_rxon_cmd); - -/** - * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed - * @il: staging_rxon is compared to active_rxon - * - * If the RXON structure is changing enough to require a new tune, - * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that - * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. - */ -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx) -{ - const struct il_rxon_cmd *staging = &ctx->staging; - const struct il_rxon_cmd *active = &ctx->active; - -#define CHK(cond) \ - if ((cond)) { \ - D_INFO("need full RXON - " #cond "\n"); \ - return 1; \ - } - -#define CHK_NEQ(c1, c2) \ - if ((c1) != (c2)) { \ - D_INFO("need full RXON - " \ - #c1 " != " #c2 " - %d != %d\n", \ - (c1), (c2)); \ - return 1; \ - } - - /* These items are only settable from the full RXON command */ - CHK(!il_is_associated_ctx(ctx)); - CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); - CHK(compare_ether_addr(staging->node_addr, active->node_addr)); - CHK(compare_ether_addr(staging->wlap_bssid_addr, - active->wlap_bssid_addr)); - CHK_NEQ(staging->dev_type, active->dev_type); - CHK_NEQ(staging->channel, active->channel); - CHK_NEQ(staging->air_propagation, active->air_propagation); - CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, - active->ofdm_ht_single_stream_basic_rates); - CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, - active->ofdm_ht_dual_stream_basic_rates); - CHK_NEQ(staging->assoc_id, active->assoc_id); - - /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can - * be updated with the RXON_ASSOC command -- however only some - * flag transitions are allowed using RXON_ASSOC */ - - /* Check if we are not switching bands */ - CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, - active->flags & RXON_FLG_BAND_24G_MSK); - - /* Check if we are switching association toggle */ - CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, - active->filter_flags & RXON_FILTER_ASSOC_MSK); - -#undef CHK -#undef CHK_NEQ - - return 0; -} -EXPORT_SYMBOL(il_full_rxon_required); - -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx) -{ - /* - * Assign the lowest rate -- should really get this from - * the beacon skb from mac80211. - */ - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) - return RATE_1M_PLCP; - else - return RATE_6M_PLCP; -} -EXPORT_SYMBOL(il_get_lowest_plcp); - -static void _il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf, - struct il_rxon_context *ctx) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - - if (!ctx->ht.enabled) { - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | - RXON_FLG_HT40_PROT_MSK | - RXON_FLG_HT_PROT_MSK); - return; - } - - rxon->flags |= cpu_to_le32(ctx->ht.protection << - RXON_FLG_HT_OPERATING_MODE_POS); - - /* Set up channel bandwidth: - * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ - /* clear the HT channel mode before set the mode */ - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - if (il_is_ht40_tx_allowed(il, ctx, NULL)) { - /* pure ht40 */ - if (ctx->ht.protection == - IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { - rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; - /* Note: control channel is opposite of extension channel */ - switch (ctx->ht.extension_chan_offset) { - case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: - rxon->flags &= - ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; - break; - case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; - break; - } - } else { - /* Note: control channel is opposite of extension channel */ - switch (ctx->ht.extension_chan_offset) { - case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: - rxon->flags &= - ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; - break; - case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; - rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; - break; - case IEEE80211_HT_PARAM_CHA_SEC_NONE: - default: - /* channel location only valid if in Mixed mode */ - IL_ERR( - "invalid extension channel offset\n"); - break; - } - } - } else { - rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; - } - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - D_ASSOC("rxon flags 0x%X operation mode :0x%X " - "extension channel offset 0x%x\n", - le32_to_cpu(rxon->flags), ctx->ht.protection, - ctx->ht.extension_chan_offset); -} - -void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) -{ - _il_set_rxon_ht(il, ht_conf, &il->ctx); -} -EXPORT_SYMBOL(il_set_rxon_ht); - -/* Return valid, unused, channel for a passive scan to reset the RF */ -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band) -{ - const struct il_channel_info *ch_info; - int i; - u8 channel = 0; - u8 min, max; - - if (band == IEEE80211_BAND_5GHZ) { - min = 14; - max = il->channel_count; - } else { - min = 0; - max = 14; - } - - for (i = min; i < max; i++) { - channel = il->channel_info[i].channel; - if (channel == le16_to_cpu(il->ctx.staging.channel)) - continue; - - ch_info = il_get_channel_info(il, band, channel); - if (il_is_channel_valid(ch_info)) - break; - } - - return channel; -} -EXPORT_SYMBOL(il_get_single_channel_number); - -/** - * il_set_rxon_channel - Set the band and channel values in staging RXON - * @ch: requested channel as a pointer to struct ieee80211_channel - - * NOTE: Does not commit to the hardware; it sets appropriate bit fields - * in the staging RXON flag structure based on the ch->band - */ -int -il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, - struct il_rxon_context *ctx) -{ - enum ieee80211_band band = ch->band; - u16 channel = ch->hw_value; - - if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) - return 0; - - ctx->staging.channel = cpu_to_le16(channel); - if (band == IEEE80211_BAND_5GHZ) - ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; - else - ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; - - il->band = band; - - D_INFO("Staging channel set to %d [%d]\n", channel, band); - - return 0; -} -EXPORT_SYMBOL(il_set_rxon_channel); - -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif) -{ - if (band == IEEE80211_BAND_5GHZ) { - ctx->staging.flags &= - ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK - | RXON_FLG_CCK_MSK); - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - } else { - /* Copied from il_post_associate() */ - if (vif && vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; - - ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; - ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; - ctx->staging.flags &= ~RXON_FLG_CCK_MSK; - } -} -EXPORT_SYMBOL(il_set_flags_for_band); - -/* - * initialize rxon structure with default values from eeprom - */ -void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx) -{ - const struct il_channel_info *ch_info; - - memset(&ctx->staging, 0, sizeof(ctx->staging)); - - if (!ctx->vif) { - ctx->staging.dev_type = ctx->unused_devtype; - } else - switch (ctx->vif->type) { - - case NL80211_IFTYPE_STATION: - ctx->staging.dev_type = ctx->station_devtype; - ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; - break; - - case NL80211_IFTYPE_ADHOC: - ctx->staging.dev_type = ctx->ibss_devtype; - ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; - ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | - RXON_FILTER_ACCEPT_GRP_MSK; - break; - - default: - IL_ERR("Unsupported interface type %d\n", - ctx->vif->type); - break; - } - -#if 0 - /* TODO: Figure out when short_preamble would be set and cache from - * that */ - if (!hw_to_local(il->hw)->short_preamble) - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; -#endif - - ch_info = il_get_channel_info(il, il->band, - le16_to_cpu(ctx->active.channel)); - - if (!ch_info) - ch_info = &il->channel_info[0]; - - ctx->staging.channel = cpu_to_le16(ch_info->channel); - il->band = ch_info->band; - - il_set_flags_for_band(il, ctx, il->band, ctx->vif); - - ctx->staging.ofdm_basic_rates = - (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - ctx->staging.cck_basic_rates = - (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; - - /* clear both MIX and PURE40 mode flag */ - ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | - RXON_FLG_CHANNEL_MODE_PURE_40); - if (ctx->vif) - memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); - - ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; - ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; -} -EXPORT_SYMBOL(il_connection_init_rx_config); - -void il_set_rate(struct il_priv *il) -{ - const struct ieee80211_supported_band *hw = NULL; - struct ieee80211_rate *rate; - int i; - - hw = il_get_hw_mode(il, il->band); - if (!hw) { - IL_ERR("Failed to set rate: unable to get hw mode\n"); - return; - } - - il->active_rate = 0; - - for (i = 0; i < hw->n_bitrates; i++) { - rate = &(hw->bitrates[i]); - if (rate->hw_value < RATE_COUNT_LEGACY) - il->active_rate |= (1 << rate->hw_value); - } - - D_RATE("Set active_rate = %0x\n", il->active_rate); - - il->ctx.staging.cck_basic_rates = - (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; - - il->ctx.staging.ofdm_basic_rates = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; -} -EXPORT_SYMBOL(il_set_rate); - -void il_chswitch_done(struct il_priv *il, bool is_success) -{ - struct il_rxon_context *ctx = &il->ctx; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return; - - if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) - ieee80211_chswitch_done(ctx->vif, is_success); -} -EXPORT_SYMBOL(il_chswitch_done); - -void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_csa_notification *csa = &(pkt->u.csa_notif); - - struct il_rxon_context *ctx = &il->ctx; - struct il_rxon_cmd *rxon = (void *)&ctx->active; - - if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) - return; - - if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { - rxon->channel = csa->channel; - ctx->staging.channel = csa->channel; - D_11H("CSA notif: channel %d\n", - le16_to_cpu(csa->channel)); - il_chswitch_done(il, true); - } else { - IL_ERR("CSA notif (fail) : channel %d\n", - le16_to_cpu(csa->channel)); - il_chswitch_done(il, false); - } -} -EXPORT_SYMBOL(il_hdl_csa); - -#ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - - D_RADIO("RX CONFIG:\n"); - il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - D_RADIO("u16 channel: 0x%x\n", - le16_to_cpu(rxon->channel)); - D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - D_RADIO("u32 filter_flags: 0x%08x\n", - le32_to_cpu(rxon->filter_flags)); - D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); - D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", - rxon->ofdm_basic_rates); - D_RADIO("u8 cck_basic_rates: 0x%02x\n", - rxon->cck_basic_rates); - D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); - D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - D_RADIO("u16 assoc_id: 0x%x\n", - le16_to_cpu(rxon->assoc_id)); -} -EXPORT_SYMBOL(il_print_rx_config_cmd); -#endif -/** - * il_irq_handle_error - called for HW or SW error interrupt from card - */ -void il_irq_handle_error(struct il_priv *il) -{ - /* Set the FW error flag -- cleared on il_down */ - set_bit(S_FW_ERROR, &il->status); - - /* Cancel currently queued command. */ - clear_bit(S_HCMD_ACTIVE, &il->status); - - IL_ERR("Loaded firmware version: %s\n", - il->hw->wiphy->fw_version); - - il->cfg->ops->lib->dump_nic_error_log(il); - if (il->cfg->ops->lib->dump_fh) - il->cfg->ops->lib->dump_fh(il, NULL, false); -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & IL_DL_FW_ERRORS) - il_print_rx_config_cmd(il, - &il->ctx); -#endif - - wake_up(&il->wait_command_queue); - - /* Keep the restart process from trying to send host - * commands by clearing the INIT status bit */ - clear_bit(S_READY, &il->status); - - if (!test_bit(S_EXIT_PENDING, &il->status)) { - IL_DBG(IL_DL_FW_ERRORS, - "Restarting adapter due to uCode error.\n"); - - if (il->cfg->mod_params->restart_fw) - queue_work(il->workqueue, &il->restart); - } -} -EXPORT_SYMBOL(il_irq_handle_error); - -static int il_apm_stop_master(struct il_priv *il) -{ - int ret = 0; - - /* stop device's busmaster DMA activity */ - il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - - ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, - CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); - if (ret) - IL_WARN("Master Disable Timed Out, 100 usec\n"); - - D_INFO("stop master\n"); - - return ret; -} - -void il_apm_stop(struct il_priv *il) -{ - D_INFO("Stop card, put in low power state\n"); - - /* Stop device's DMA activity */ - il_apm_stop_master(il); - - /* Reset the entire device */ - il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); - - udelay(10); - - /* - * Clear "initialization complete" bit to move adapter from - * D0A* (powered-up Active) --> D0U* (Uninitialized) state. - */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_INIT_DONE); -} -EXPORT_SYMBOL(il_apm_stop); - - -/* - * Start up NIC's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via il_apm_stop()) - * NOTE: This does not load uCode nor start the embedded processor - */ -int il_apm_init(struct il_priv *il) -{ - int ret = 0; - u16 lctl; - - D_INFO("Init card's basic functions\n"); - - /* - * Use "set_bit" below rather than "write", to preserve any hardware - * bits already set by default after reset. - */ - - /* Disable L0S exit timer (platform NMI Work/Around) */ - il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); - - /* - * Disable L0s without affecting L1; - * don't wait for ICH L0s (ICH bug W/A) - */ - il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); - - /* Set FH wait threshold to maximum (HW error during stress W/A) */ - il_set_bit(il, CSR_DBG_HPET_MEM_REG, - CSR_DBG_HPET_MEM_REG_VAL); - - /* - * Enable HAP INTA (interrupt from management bus) to - * wake device's PCI Express link L1a -> L0s - * NOTE: This is no-op for 3945 (non-existent bit) - */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); - - /* - * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. - * Check if BIOS (or OS) enabled L1-ASPM on this device. - * If so (likely), disable L0S, so device moves directly L0->L1; - * costs negligible amount of power savings. - * If not (unlikely), enable L0S, so there is at least some - * power savings, even without L1. - */ - if (il->cfg->base_params->set_l0s) { - lctl = il_pcie_link_ctl(il); - if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == - PCI_CFG_LINK_CTRL_VAL_L1_EN) { - /* L1-ASPM enabled; disable(!) L0S */ - il_set_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - D_POWER("L1 Enabled; Disabling L0S\n"); - } else { - /* L1-ASPM disabled; enable(!) L0S */ - il_clear_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - D_POWER("L1 Disabled; Enabling L0S\n"); - } - } - - /* Configure analog phase-lock-loop before activating to D0A */ - if (il->cfg->base_params->pll_cfg_val) - il_set_bit(il, CSR_ANA_PLL_CFG, - il->cfg->base_params->pll_cfg_val); - - /* - * Set "initialization complete" bit to move adapter from - * D0U* --> D0A* (powered-up active) state. - */ - il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); - - /* - * Wait for clock stabilization; once stabilized, access to - * device-internal resources is supported, e.g. il_wr_prph() - * and accesses to uCode SRAM. - */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); - if (ret < 0) { - D_INFO("Failed to init the card\n"); - goto out; - } - - /* - * Enable DMA and BSM (if used) clocks, wait for them to stabilize. - * BSM (Boostrap State Machine) is only in 3945 and 4965. - * - * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits - * do not disable clocks. This preserves any hardware bits already - * set by default in "CLK_CTRL_REG" after reset. - */ - if (il->cfg->base_params->use_bsm) - il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); - else - il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT); - udelay(20); - - /* Disable L1-Active */ - il_set_bits_prph(il, APMG_PCIDEV_STT_REG, - APMG_PCIDEV_STT_VAL_L1_ACT_DIS); - -out: - return ret; -} -EXPORT_SYMBOL(il_apm_init); - - -int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) -{ - int ret; - s8 prev_tx_power; - bool defer; - struct il_rxon_context *ctx = &il->ctx; - - lockdep_assert_held(&il->mutex); - - if (il->tx_power_user_lmt == tx_power && !force) - return 0; - - if (!il->cfg->ops->lib->send_tx_power) - return -EOPNOTSUPP; - - /* 0 dBm mean 1 milliwatt */ - if (tx_power < 0) { - IL_WARN( - "Requested user TXPOWER %d below 1 mW.\n", - tx_power); - return -EINVAL; - } - - if (tx_power > il->tx_power_device_lmt) { - IL_WARN( - "Requested user TXPOWER %d above upper limit %d.\n", - tx_power, il->tx_power_device_lmt); - return -EINVAL; - } - - if (!il_is_ready_rf(il)) - return -EIO; - - /* scan complete and commit_rxon use tx_power_next value, - * it always need to be updated for newest request */ - il->tx_power_next = tx_power; - - /* do not set tx power when scanning or channel changing */ - defer = test_bit(S_SCANNING, &il->status) || - memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); - if (defer && !force) { - D_INFO("Deferring tx power set\n"); - return 0; - } - - prev_tx_power = il->tx_power_user_lmt; - il->tx_power_user_lmt = tx_power; - - ret = il->cfg->ops->lib->send_tx_power(il); - - /* if fail to set tx_power, restore the orig. tx power */ - if (ret) { - il->tx_power_user_lmt = prev_tx_power; - il->tx_power_next = prev_tx_power; - } - return ret; -} -EXPORT_SYMBOL(il_set_tx_power); - -void il_send_bt_config(struct il_priv *il) -{ - struct il_bt_cmd bt_cmd = { - .lead_time = BT_LEAD_TIME_DEF, - .max_kill = BT_MAX_KILL_DEF, - .kill_ack_mask = 0, - .kill_cts_mask = 0, - }; - - if (!bt_coex_active) - bt_cmd.flags = BT_COEX_DISABLE; - else - bt_cmd.flags = BT_COEX_ENABLE; - - D_INFO("BT coex %s\n", - (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - - if (il_send_cmd_pdu(il, C_BT_CONFIG, - sizeof(struct il_bt_cmd), &bt_cmd)) - IL_ERR("failed to send BT Coex Config\n"); -} -EXPORT_SYMBOL(il_send_bt_config); - -int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) -{ - struct il_stats_cmd stats_cmd = { - .configuration_flags = - clear ? IL_STATS_CONF_CLEAR_STATS : 0, - }; - - if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd, NULL); - else - return il_send_cmd_pdu(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd); -} -EXPORT_SYMBOL(il_send_stats_request); - -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); - D_RX("sleep mode: %d, src: %d\n", - sleep->pm_sleep_mode, sleep->pm_wakeup_src); -#endif -} -EXPORT_SYMBOL(il_hdl_pm_sleep); - -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - D_RADIO("Dumping %d bytes of unhandled " - "notification for %s:\n", len, - il_get_cmd_string(pkt->hdr.cmd)); - il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); -} -EXPORT_SYMBOL(il_hdl_pm_debug_stats); - -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - - IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " - "seq 0x%04X ser 0x%08X\n", - le32_to_cpu(pkt->u.err_resp.error_type), - il_get_cmd_string(pkt->u.err_resp.cmd_id), - pkt->u.err_resp.cmd_id, - le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), - le32_to_cpu(pkt->u.err_resp.error_info)); -} -EXPORT_SYMBOL(il_hdl_error); - -void il_clear_isr_stats(struct il_priv *il) -{ - memset(&il->isr_stats, 0, sizeof(il->isr_stats)); -} - -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params) -{ - struct il_priv *il = hw->priv; - unsigned long flags; - int q; - - D_MAC80211("enter\n"); - - if (!il_is_ready_rf(il)) { - D_MAC80211("leave - RF not ready\n"); - return -EIO; - } - - if (queue >= AC_NUM) { - D_MAC80211("leave - queue >= AC_NUM %d\n", queue); - return 0; - } - - q = AC_NUM - 1 - queue; - - spin_lock_irqsave(&il->lock, flags); - - il->ctx.qos_data.def_qos_parm.ac[q].cw_min = - cpu_to_le16(params->cw_min); - il->ctx.qos_data.def_qos_parm.ac[q].cw_max = - cpu_to_le16(params->cw_max); - il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; - il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = - cpu_to_le16((params->txop * 32)); - - il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; - - spin_unlock_irqrestore(&il->lock, flags); - - D_MAC80211("leave\n"); - return 0; -} -EXPORT_SYMBOL(il_mac_conf_tx); - -int il_mac_tx_last_beacon(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - - return il->ibss_manager == IL_IBSS_MANAGER; -} -EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); - -static int -il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) -{ - il_connection_init_rx_config(il, ctx); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - return il_commit_rxon(il, ctx); -} - -static int il_setup_interface(struct il_priv *il, - struct il_rxon_context *ctx) -{ - struct ieee80211_vif *vif = ctx->vif; - int err; - - lockdep_assert_held(&il->mutex); - - /* - * This variable will be correct only when there's just - * a single context, but all code using it is for hardware - * that supports only one context. - */ - il->iw_mode = vif->type; - - ctx->is_active = true; - - err = il_set_mode(il, ctx); - if (err) { - if (!ctx->always_active) - ctx->is_active = false; - return err; - } - - return 0; -} - -int -il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - int err; - u32 modes; - - D_MAC80211("enter: type %d, addr %pM\n", - vif->type, vif->addr); - - mutex_lock(&il->mutex); - - if (!il_is_ready_rf(il)) { - IL_WARN("Try to add interface when device not ready\n"); - err = -EINVAL; - goto out; - } - - - /* check if busy context is exclusive */ - if (il->ctx.vif && - (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { - err = -EINVAL; - goto out; - } - - modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; - if (!(modes & BIT(vif->type))) { - err = -EOPNOTSUPP; - goto out; - } - - vif_priv->ctx = &il->ctx; - il->ctx.vif = vif; - - err = il_setup_interface(il, &il->ctx); - if (err) { - il->ctx.vif = NULL; - il->iw_mode = NL80211_IFTYPE_STATION; - } - - out: - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); - return err; -} -EXPORT_SYMBOL(il_mac_add_interface); - -static void il_teardown_interface(struct il_priv *il, - struct ieee80211_vif *vif, - bool mode_change) -{ - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - lockdep_assert_held(&il->mutex); - - if (il->scan_vif == vif) { - il_scan_cancel_timeout(il, 200); - il_force_scan_end(il); - } - - if (!mode_change) { - il_set_mode(il, ctx); - if (!ctx->always_active) - ctx->is_active = false; - } -} - -void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - D_MAC80211("enter\n"); - - mutex_lock(&il->mutex); - - WARN_ON(ctx->vif != vif); - ctx->vif = NULL; - - il_teardown_interface(il, vif, false); - - memset(il->bssid, 0, ETH_ALEN); - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); - -} -EXPORT_SYMBOL(il_mac_remove_interface); - -int il_alloc_txq_mem(struct il_priv *il) -{ - if (!il->txq) - il->txq = kzalloc( - sizeof(struct il_tx_queue) * - il->cfg->base_params->num_of_queues, - GFP_KERNEL); - if (!il->txq) { - IL_ERR("Not enough memory for txq\n"); - return -ENOMEM; - } - return 0; -} -EXPORT_SYMBOL(il_alloc_txq_mem); - -void il_txq_mem(struct il_priv *il) -{ - kfree(il->txq); - il->txq = NULL; -} -EXPORT_SYMBOL(il_txq_mem); - -#ifdef CONFIG_IWLEGACY_DEBUGFS - -#define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) - -void il_reset_traffic_log(struct il_priv *il) -{ - il->tx_traffic_idx = 0; - il->rx_traffic_idx = 0; - if (il->tx_traffic) - memset(il->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); - if (il->rx_traffic) - memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); -} - -int il_alloc_traffic_mem(struct il_priv *il) -{ - u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; - - if (il_debug_level & IL_DL_TX) { - if (!il->tx_traffic) { - il->tx_traffic = - kzalloc(traffic_size, GFP_KERNEL); - if (!il->tx_traffic) - return -ENOMEM; - } - } - if (il_debug_level & IL_DL_RX) { - if (!il->rx_traffic) { - il->rx_traffic = - kzalloc(traffic_size, GFP_KERNEL); - if (!il->rx_traffic) - return -ENOMEM; - } - } - il_reset_traffic_log(il); - return 0; -} -EXPORT_SYMBOL(il_alloc_traffic_mem); - -void il_free_traffic_mem(struct il_priv *il) -{ - kfree(il->tx_traffic); - il->tx_traffic = NULL; - - kfree(il->rx_traffic); - il->rx_traffic = NULL; -} -EXPORT_SYMBOL(il_free_traffic_mem); - -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ - __le16 fc; - u16 len; - - if (likely(!(il_debug_level & IL_DL_TX))) - return; - - if (!il->tx_traffic) - return; - - fc = header->frame_control; - if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((il->tx_traffic + - (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); - il->tx_traffic_idx = - (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; - } -} -EXPORT_SYMBOL(il_dbg_log_tx_data_frame); - -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ - __le16 fc; - u16 len; - - if (likely(!(il_debug_level & IL_DL_RX))) - return; - - if (!il->rx_traffic) - return; - - fc = header->frame_control; - if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((il->rx_traffic + - (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); - il->rx_traffic_idx = - (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; - } -} -EXPORT_SYMBOL(il_dbg_log_rx_data_frame); - -const char *il_get_mgmt_string(int cmd) -{ - switch (cmd) { - IL_CMD(MANAGEMENT_ASSOC_REQ); - IL_CMD(MANAGEMENT_ASSOC_RESP); - IL_CMD(MANAGEMENT_REASSOC_REQ); - IL_CMD(MANAGEMENT_REASSOC_RESP); - IL_CMD(MANAGEMENT_PROBE_REQ); - IL_CMD(MANAGEMENT_PROBE_RESP); - IL_CMD(MANAGEMENT_BEACON); - IL_CMD(MANAGEMENT_ATIM); - IL_CMD(MANAGEMENT_DISASSOC); - IL_CMD(MANAGEMENT_AUTH); - IL_CMD(MANAGEMENT_DEAUTH); - IL_CMD(MANAGEMENT_ACTION); - default: - return "UNKNOWN"; - - } -} - -const char *il_get_ctrl_string(int cmd) -{ - switch (cmd) { - IL_CMD(CONTROL_BACK_REQ); - IL_CMD(CONTROL_BACK); - IL_CMD(CONTROL_PSPOLL); - IL_CMD(CONTROL_RTS); - IL_CMD(CONTROL_CTS); - IL_CMD(CONTROL_ACK); - IL_CMD(CONTROL_CFEND); - IL_CMD(CONTROL_CFENDACK); - default: - return "UNKNOWN"; - - } -} - -void il_clear_traffic_stats(struct il_priv *il) -{ - memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); - memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); -} - -/* - * if CONFIG_IWLEGACY_DEBUGFS defined, - * il_update_stats function will - * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass - * Use debugFs to display the rx/rx_stats - * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL - * information will be recorded, but DATA pkt still will be recorded - * for the reason of il_led.c need to control the led blinking based on - * number of tx and rx data. - * - */ -void -il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) -{ - struct traffic_stats *stats; - - if (is_tx) - stats = &il->tx_stats; - else - stats = &il->rx_stats; - - if (ieee80211_is_mgmt(fc)) { - switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { - case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): - stats->mgmt[MANAGEMENT_ASSOC_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): - stats->mgmt[MANAGEMENT_ASSOC_RESP]++; - break; - case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): - stats->mgmt[MANAGEMENT_REASSOC_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): - stats->mgmt[MANAGEMENT_REASSOC_RESP]++; - break; - case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): - stats->mgmt[MANAGEMENT_PROBE_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): - stats->mgmt[MANAGEMENT_PROBE_RESP]++; - break; - case cpu_to_le16(IEEE80211_STYPE_BEACON): - stats->mgmt[MANAGEMENT_BEACON]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ATIM): - stats->mgmt[MANAGEMENT_ATIM]++; - break; - case cpu_to_le16(IEEE80211_STYPE_DISASSOC): - stats->mgmt[MANAGEMENT_DISASSOC]++; - break; - case cpu_to_le16(IEEE80211_STYPE_AUTH): - stats->mgmt[MANAGEMENT_AUTH]++; - break; - case cpu_to_le16(IEEE80211_STYPE_DEAUTH): - stats->mgmt[MANAGEMENT_DEAUTH]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ACTION): - stats->mgmt[MANAGEMENT_ACTION]++; - break; - } - } else if (ieee80211_is_ctl(fc)) { - switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { - case cpu_to_le16(IEEE80211_STYPE_BACK_REQ): - stats->ctrl[CONTROL_BACK_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_BACK): - stats->ctrl[CONTROL_BACK]++; - break; - case cpu_to_le16(IEEE80211_STYPE_PSPOLL): - stats->ctrl[CONTROL_PSPOLL]++; - break; - case cpu_to_le16(IEEE80211_STYPE_RTS): - stats->ctrl[CONTROL_RTS]++; - break; - case cpu_to_le16(IEEE80211_STYPE_CTS): - stats->ctrl[CONTROL_CTS]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ACK): - stats->ctrl[CONTROL_ACK]++; - break; - case cpu_to_le16(IEEE80211_STYPE_CFEND): - stats->ctrl[CONTROL_CFEND]++; - break; - case cpu_to_le16(IEEE80211_STYPE_CFENDACK): - stats->ctrl[CONTROL_CFENDACK]++; - break; - } - } else { - /* data */ - stats->data_cnt++; - stats->data_bytes += len; - } -} -EXPORT_SYMBOL(il_update_stats); -#endif - -int il_force_reset(struct il_priv *il, bool external) -{ - struct il_force_reset *force_reset; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return -EINVAL; - - force_reset = &il->force_reset; - force_reset->reset_request_count++; - if (!external) { - if (force_reset->last_force_reset_jiffies && - time_after(force_reset->last_force_reset_jiffies + - force_reset->reset_duration, jiffies)) { - D_INFO("force reset rejected\n"); - force_reset->reset_reject_count++; - return -EAGAIN; - } - } - force_reset->reset_success_count++; - force_reset->last_force_reset_jiffies = jiffies; - - /* - * if the request is from external(ex: debugfs), - * then always perform the request in regardless the module - * parameter setting - * if the request is from internal (uCode error or driver - * detect failure), then fw_restart module parameter - * need to be check before performing firmware reload - */ - - if (!external && !il->cfg->mod_params->restart_fw) { - D_INFO("Cancel firmware reload based on " - "module parameter setting\n"); - return 0; - } - - IL_ERR("On demand firmware reload\n"); - - /* Set the FW error flag -- cleared on il_down */ - set_bit(S_FW_ERROR, &il->status); - wake_up(&il->wait_command_queue); - /* - * Keep the restart process from trying to send host - * commands by clearing the INIT status bit - */ - clear_bit(S_READY, &il->status); - queue_work(il->workqueue, &il->restart); - - return 0; -} - -int -il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p) -{ - struct il_priv *il = hw->priv; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - u32 modes; - int err; - - newtype = ieee80211_iftype_p2p(newtype, newp2p); - - mutex_lock(&il->mutex); - - if (!ctx->vif || !il_is_ready_rf(il)) { - /* - * Huh? But wait ... this can maybe happen when - * we're in the middle of a firmware restart! - */ - err = -EBUSY; - goto out; - } - - modes = ctx->interface_modes | ctx->exclusive_interface_modes; - if (!(modes & BIT(newtype))) { - err = -EOPNOTSUPP; - goto out; - } - - if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) || - (il->ctx.exclusive_interface_modes & BIT(newtype))) { - err = -EINVAL; - goto out; - } - - /* success */ - il_teardown_interface(il, vif, true); - vif->type = newtype; - vif->p2p = newp2p; - err = il_setup_interface(il, ctx); - WARN_ON(err); - /* - * We've switched internally, but submitting to the - * device may have failed for some reason. Mask this - * error, because otherwise mac80211 will not switch - * (and set the interface type back) and we'll be - * out of sync with it. - */ - err = 0; - - out: - mutex_unlock(&il->mutex); - return err; -} -EXPORT_SYMBOL(il_mac_change_interface); - -/* - * On every watchdog tick we check (latest) time stamp. If it does not - * change during timeout period and queue is not empty we reset firmware. - */ -static int il_check_stuck_queue(struct il_priv *il, int cnt) -{ - struct il_tx_queue *txq = &il->txq[cnt]; - struct il_queue *q = &txq->q; - unsigned long timeout; - int ret; - - if (q->read_ptr == q->write_ptr) { - txq->time_stamp = jiffies; - return 0; - } - - timeout = txq->time_stamp + - msecs_to_jiffies(il->cfg->base_params->wd_timeout); - - if (time_after(jiffies, timeout)) { - IL_ERR("Queue %d stuck for %u ms.\n", - q->id, il->cfg->base_params->wd_timeout); - ret = il_force_reset(il, false); - return (ret == -EAGAIN) ? 0 : 1; - } - - return 0; -} - -/* - * Making watchdog tick be a quarter of timeout assure we will - * discover the queue hung between timeout and 1.25*timeout - */ -#define IL_WD_TICK(timeout) ((timeout) / 4) - -/* - * Watchdog timer callback, we check each tx queue for stuck, if if hung - * we reset the firmware. If everything is fine just rearm the timer. - */ -void il_bg_watchdog(unsigned long data) -{ - struct il_priv *il = (struct il_priv *)data; - int cnt; - unsigned long timeout; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return; - - timeout = il->cfg->base_params->wd_timeout; - if (timeout == 0) - return; - - /* monitor and check for stuck cmd queue */ - if (il_check_stuck_queue(il, il->cmd_queue)) - return; - - /* monitor and check for other stuck queues */ - if (il_is_any_associated(il)) { - for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { - /* skip as we already checked the command queue */ - if (cnt == il->cmd_queue) - continue; - if (il_check_stuck_queue(il, cnt)) - return; - } - } - - mod_timer(&il->watchdog, jiffies + - msecs_to_jiffies(IL_WD_TICK(timeout))); -} -EXPORT_SYMBOL(il_bg_watchdog); - -void il_setup_watchdog(struct il_priv *il) -{ - unsigned int timeout = il->cfg->base_params->wd_timeout; - - if (timeout) - mod_timer(&il->watchdog, - jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); - else - del_timer(&il->watchdog); -} -EXPORT_SYMBOL(il_setup_watchdog); - -/* - * extended beacon time format - * time in usec will be changed into a 32-bit value in extended:internal format - * the extended part is the beacon counts - * the internal part is the time in usec within one beacon interval - */ -u32 -il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval) -{ - u32 quot; - u32 rem; - u32 interval = beacon_interval * TIME_UNIT; - - if (!interval || !usec) - return 0; - - quot = (usec / interval) & - (il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits) >> - il->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); - - return (quot << il->hw_params.beacon_time_tsf_bits) + rem; -} -EXPORT_SYMBOL(il_usecs_to_beacons); - -/* base is usually what we get from ucode with each received frame, - * the same as HW timer counter counting down - */ -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval) -{ - u32 base_low = base & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); - u32 addon_low = addon & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); - u32 interval = beacon_interval * TIME_UNIT; - u32 res = (base & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)) + - (addon & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)); - - if (base_low > addon_low) - res += base_low - addon_low; - else if (base_low < addon_low) { - res += interval + base_low - addon_low; - res += (1 << il->hw_params.beacon_time_tsf_bits); - } else - res += (1 << il->hw_params.beacon_time_tsf_bits); - - return cpu_to_le32(res); -} -EXPORT_SYMBOL(il_add_beacon_time); - -#ifdef CONFIG_PM - -int il_pci_suspend(struct device *device) -{ - struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *il = pci_get_drvdata(pdev); - - /* - * This function is called when system goes into suspend state - * mac80211 will call il_mac_stop() from the mac80211 suspend function - * first but since il_mac_stop() has no knowledge of who the caller is, - * it will not call apm_ops.stop() to stop the DMA operation. - * Calling apm_ops.stop here to make sure we stop the DMA. - */ - il_apm_stop(il); - - return 0; -} -EXPORT_SYMBOL(il_pci_suspend); - -int il_pci_resume(struct device *device) -{ - struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *il = pci_get_drvdata(pdev); - bool hw_rfkill = false; - - /* - * We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state. - */ - pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - - il_enable_interrupts(il); - - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) - hw_rfkill = true; - - if (hw_rfkill) - set_bit(S_RF_KILL_HW, &il->status); - else - clear_bit(S_RF_KILL_HW, &il->status); - - wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); - - return 0; -} -EXPORT_SYMBOL(il_pci_resume); - -const struct dev_pm_ops il_pm_ops = { - .suspend = il_pci_suspend, - .resume = il_pci_resume, - .freeze = il_pci_suspend, - .thaw = il_pci_resume, - .poweroff = il_pci_suspend, - .restore = il_pci_resume, -}; -EXPORT_SYMBOL(il_pm_ops); - -#endif /* CONFIG_PM */ - -static void -il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) -{ - if (test_bit(S_EXIT_PENDING, &il->status)) - return; - - if (!ctx->is_active) - return; - - ctx->qos_data.def_qos_parm.qos_flags = 0; - - if (ctx->qos_data.qos_active) - ctx->qos_data.def_qos_parm.qos_flags |= - QOS_PARAM_FLG_UPDATE_EDCA_MSK; - - if (ctx->ht.enabled) - ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - - D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", - ctx->qos_data.qos_active, - ctx->qos_data.def_qos_parm.qos_flags); - - il_send_cmd_pdu_async(il, ctx->qos_cmd, - sizeof(struct il_qosparam_cmd), - &ctx->qos_data.def_qos_parm, NULL); -} - -/** - * il_mac_config - mac80211 config callback - */ -int il_mac_config(struct ieee80211_hw *hw, u32 changed) -{ - struct il_priv *il = hw->priv; - const struct il_channel_info *ch_info; - struct ieee80211_conf *conf = &hw->conf; - struct ieee80211_channel *channel = conf->channel; - struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx = &il->ctx; - unsigned long flags = 0; - int ret = 0; - u16 ch; - int scan_active = 0; - bool ht_changed = false; - - if (WARN_ON(!il->cfg->ops->legacy)) - return -EOPNOTSUPP; - - mutex_lock(&il->mutex); - - D_MAC80211("enter to channel %d changed 0x%X\n", - channel->hw_value, changed); - - if (unlikely(test_bit(S_SCANNING, &il->status))) { - scan_active = 1; - D_MAC80211("scan active\n"); - } - - if (changed & (IEEE80211_CONF_CHANGE_SMPS | - IEEE80211_CONF_CHANGE_CHANNEL)) { - /* mac80211 uses static for non-HT which is what we want */ - il->current_ht_config.smps = conf->smps_mode; - - /* - * Recalculate chain counts. - * - * If monitor mode is enabled then mac80211 will - * set up the SM PS mode to OFF if an HT channel is - * configured. - */ - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); - } - - /* during scanning mac80211 will delay channel setting until - * scan finish with changed = 0 - */ - if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { - - if (scan_active) - goto set_ch_out; - - ch = channel->hw_value; - ch_info = il_get_channel_info(il, channel->band, ch); - if (!il_is_channel_valid(ch_info)) { - D_MAC80211("leave - invalid channel\n"); - ret = -EINVAL; - goto set_ch_out; - } - - if (il->iw_mode == NL80211_IFTYPE_ADHOC && - !il_is_channel_ibss(ch_info)) { - D_MAC80211("leave - not IBSS channel\n"); - ret = -EINVAL; - goto set_ch_out; - } - - spin_lock_irqsave(&il->lock, flags); - - /* Configure HT40 channels */ - if (ctx->ht.enabled != conf_is_ht(conf)) { - ctx->ht.enabled = conf_is_ht(conf); - ht_changed = true; - } - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else - ctx->ht.is_40mhz = false; - - /* - * Default to no protection. Protection mode will - * later be set from BSS config in il_ht_conf - */ - ctx->ht.protection = - IEEE80211_HT_OP_MODE_PROTECTION_NONE; - - /* if we are switching from ht to 2.4 clear flags - * from any ht related info since 2.4 does not - * support ht */ - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; - - il_set_rxon_channel(il, channel, ctx); - il_set_rxon_ht(il, ht_conf); - - il_set_flags_for_band(il, ctx, channel->band, - ctx->vif); - - spin_unlock_irqrestore(&il->lock, flags); - - if (il->cfg->ops->legacy->update_bcast_stations) - ret = - il->cfg->ops->legacy->update_bcast_stations(il); - - set_ch_out: - /* The list of supported rates and rate mask can be different - * for each band; since the band may have changed, reset - * the rate mask to what mac80211 lists */ - il_set_rate(il); - } - - if (changed & (IEEE80211_CONF_CHANGE_PS | - IEEE80211_CONF_CHANGE_IDLE)) { - ret = il_power_update_mode(il, false); - if (ret) - D_MAC80211("Error setting sleep level\n"); - } - - if (changed & IEEE80211_CONF_CHANGE_POWER) { - D_MAC80211("TX Power old=%d new=%d\n", - il->tx_power_user_lmt, conf->power_level); - - il_set_tx_power(il, conf->power_level, false); - } - - if (!il_is_ready(il)) { - D_MAC80211("leave - not ready\n"); - goto out; - } - - if (scan_active) - goto out; - - if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - il_commit_rxon(il, ctx); - else - D_INFO("Not re-sending same RXON configuration.\n"); - if (ht_changed) - il_update_qos(il, ctx); - -out: - D_MAC80211("leave\n"); - mutex_unlock(&il->mutex); - return ret; -} -EXPORT_SYMBOL(il_mac_config); - -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - unsigned long flags; - struct il_rxon_context *ctx = &il->ctx; - - if (WARN_ON(!il->cfg->ops->legacy)) - return; - - mutex_lock(&il->mutex); - D_MAC80211("enter\n"); - - spin_lock_irqsave(&il->lock, flags); - memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); - spin_unlock_irqrestore(&il->lock, flags); - - spin_lock_irqsave(&il->lock, flags); - - /* new association get rid of ibss beacon skb */ - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - - il->beacon_skb = NULL; - - il->timestamp = 0; - - spin_unlock_irqrestore(&il->lock, flags); - - il_scan_cancel_timeout(il, 100); - if (!il_is_ready_rf(il)) { - D_MAC80211("leave - not ready\n"); - mutex_unlock(&il->mutex); - return; - } - - /* we are restarting association process - * clear RXON_FILTER_ASSOC_MSK bit - */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - - il_set_rate(il); - - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); -} -EXPORT_SYMBOL(il_mac_reset_tsf); - -static void il_ht_conf(struct il_priv *il, - struct ieee80211_vif *vif) -{ - struct il_ht_config *ht_conf = &il->current_ht_config; - struct ieee80211_sta *sta; - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - D_ASSOC("enter:\n"); - - if (!ctx->ht.enabled) - return; - - ctx->ht.protection = - bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; - ctx->ht.non_gf_sta_present = - !!(bss_conf->ht_operation_mode & - IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); - - ht_conf->single_chain_sufficient = false; - - switch (vif->type) { - case NL80211_IFTYPE_STATION: - rcu_read_lock(); - sta = ieee80211_find_sta(vif, bss_conf->bssid); - if (sta) { - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - int maxstreams; - - maxstreams = (ht_cap->mcs.tx_params & - IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) - >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; - maxstreams += 1; - - if (ht_cap->mcs.rx_mask[1] == 0 && - ht_cap->mcs.rx_mask[2] == 0) - ht_conf->single_chain_sufficient = true; - if (maxstreams <= 1) - ht_conf->single_chain_sufficient = true; - } else { - /* - * If at all, this can only happen through a race - * when the AP disconnects us while we're still - * setting up the connection, in that case mac80211 - * will soon tell us about that. - */ - ht_conf->single_chain_sufficient = true; - } - rcu_read_unlock(); - break; - case NL80211_IFTYPE_ADHOC: - ht_conf->single_chain_sufficient = true; - break; - default: - break; - } - - D_ASSOC("leave\n"); -} - -static inline void il_set_no_assoc(struct il_priv *il, - struct ieee80211_vif *vif) -{ - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - /* - * inform the ucode that there is no longer an - * association and that no more packets should be - * sent - */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ctx->staging.assoc_id = 0; - il_commit_rxon(il, ctx); -} - -static void il_beacon_update(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - unsigned long flags; - __le64 timestamp; - struct sk_buff *skb = ieee80211_beacon_get(hw, vif); - - if (!skb) - return; - - D_MAC80211("enter\n"); - - lockdep_assert_held(&il->mutex); - - if (!il->beacon_ctx) { - IL_ERR("update beacon but no beacon context!\n"); - dev_kfree_skb(skb); - return; - } - - spin_lock_irqsave(&il->lock, flags); - - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - - il->beacon_skb = skb; - - timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; - il->timestamp = le64_to_cpu(timestamp); - - D_MAC80211("leave\n"); - spin_unlock_irqrestore(&il->lock, flags); - - if (!il_is_ready_rf(il)) { - D_MAC80211("leave - RF not ready\n"); - return; - } - - il->cfg->ops->legacy->post_associate(il); -} - -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes) -{ - struct il_priv *il = hw->priv; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - int ret; - - if (WARN_ON(!il->cfg->ops->legacy)) - return; - - D_MAC80211("changes = 0x%X\n", changes); - - mutex_lock(&il->mutex); - - if (!il_is_alive(il)) { - mutex_unlock(&il->mutex); - return; - } - - if (changes & BSS_CHANGED_QOS) { - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - ctx->qos_data.qos_active = bss_conf->qos; - il_update_qos(il, ctx); - spin_unlock_irqrestore(&il->lock, flags); - } - - if (changes & BSS_CHANGED_BEACON_ENABLED) { - /* - * the add_interface code must make sure we only ever - * have a single interface that could be beaconing at - * any time. - */ - if (vif->bss_conf.enable_beacon) - il->beacon_ctx = ctx; - else - il->beacon_ctx = NULL; - } - - if (changes & BSS_CHANGED_BSSID) { - D_MAC80211("BSSID %pM\n", bss_conf->bssid); - - /* - * If there is currently a HW scan going on in the - * background then we need to cancel it else the RXON - * below/in post_associate will fail. - */ - if (il_scan_cancel_timeout(il, 100)) { - IL_WARN( - "Aborted scan still in progress after 100ms\n"); - D_MAC80211( - "leaving - scan abort failed.\n"); - mutex_unlock(&il->mutex); - return; - } - - /* mac80211 only sets assoc when in STATION mode */ - if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); - - /* currently needed in a few places */ - memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); - } else { - ctx->staging.filter_flags &= - ~RXON_FILTER_ASSOC_MSK; - } - - } - - /* - * This needs to be after setting the BSSID in case - * mac80211 decides to do both changes at once because - * it will invoke post_associate. - */ - if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) - il_beacon_update(hw, vif); - - if (changes & BSS_CHANGED_ERP_PREAMBLE) { - D_MAC80211("ERP_PREAMBLE %d\n", - bss_conf->use_short_preamble); - if (bss_conf->use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - } - - if (changes & BSS_CHANGED_ERP_CTS_PROT) { - D_MAC80211( - "ERP_CTS %d\n", bss_conf->use_cts_prot); - if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) - ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; - if (bss_conf->use_cts_prot) - ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; - else - ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; - } - - if (changes & BSS_CHANGED_BASIC_RATES) { - /* XXX use this information - * - * To do that, remove code from il_set_rate() and put something - * like this here: - * - if (A-band) - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates; - else - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates >> 4; - ctx->staging.cck_basic_rates = - bss_conf->basic_rates & 0xF; - */ - } - - if (changes & BSS_CHANGED_HT) { - il_ht_conf(il, vif); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - } - - if (changes & BSS_CHANGED_ASSOC) { - D_MAC80211("ASSOC %d\n", bss_conf->assoc); - if (bss_conf->assoc) { - il->timestamp = bss_conf->timestamp; - - if (!il_is_rfkill(il)) - il->cfg->ops->legacy->post_associate(il); - } else - il_set_no_assoc(il, vif); - } - - if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - D_MAC80211("Changes (%#x) while associated\n", - changes); - ret = il_send_rxon_assoc(il, ctx); - if (!ret) { - /* Sync active_rxon with latest change. */ - memcpy((void *)&ctx->active, - &ctx->staging, - sizeof(struct il_rxon_cmd)); - } - } - - if (changes & BSS_CHANGED_BEACON_ENABLED) { - if (vif->bss_conf.enable_beacon) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); - memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); - il->cfg->ops->legacy->config_ap(il); - } else - il_set_no_assoc(il, vif); - } - - if (changes & BSS_CHANGED_IBSS) { - ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, - bss_conf->ibss_joined); - if (ret) - IL_ERR("failed to %s IBSS station %pM\n", - bss_conf->ibss_joined ? "add" : "remove", - bss_conf->bssid); - } - - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); -} -EXPORT_SYMBOL(il_mac_bss_info_changed); - -irqreturn_t il_isr(int irq, void *data) -{ - struct il_priv *il = data; - u32 inta, inta_mask; - u32 inta_fh; - unsigned long flags; - if (!il) - return IRQ_NONE; - - spin_lock_irqsave(&il->lock, flags); - - /* Disable (but don't clear!) interrupts here to avoid - * back-to-back ISRs and sporadic interrupts from our NIC. - * If we have something to service, the tasklet will re-enable ints. - * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ - _il_wr(il, CSR_INT_MASK, 0x00000000); - - /* Discover which interrupts are active/pending */ - inta = _il_rd(il, CSR_INT); - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - - /* Ignore interrupt if there's nothing in NIC to service. - * This may be due to IRQ shared with another device, - * or due to sporadic interrupts thrown from our NIC. */ - if (!inta && !inta_fh) { - D_ISR( - "Ignore interrupt, inta == 0, inta_fh == 0\n"); - goto none; - } - - if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) { - /* Hardware disappeared. It might have already raised - * an interrupt */ - IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); - goto unplugged; - } - - D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); - - inta &= ~CSR_INT_BIT_SCD; - - /* il_irq_tasklet() will service interrupts and re-enable them */ - if (likely(inta || inta_fh)) - tasklet_schedule(&il->irq_tasklet); - -unplugged: - spin_unlock_irqrestore(&il->lock, flags); - return IRQ_HANDLED; - -none: - /* re-enable interrupts here since we don't have anything to service. */ - /* only Re-enable if disabled by irq */ - if (test_bit(S_INT_ENABLED, &il->status)) - il_enable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - return IRQ_NONE; -} -EXPORT_SYMBOL(il_isr); - -/* - * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this - * function. - */ -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags) -{ - if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { - *tx_flags |= TX_CMD_FLG_RTS_MSK; - *tx_flags &= ~TX_CMD_FLG_CTS_MSK; - *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; - - if (!ieee80211_is_mgmt(fc)) - return; - - switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { - case cpu_to_le16(IEEE80211_STYPE_AUTH): - case cpu_to_le16(IEEE80211_STYPE_DEAUTH): - case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): - case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): - *tx_flags &= ~TX_CMD_FLG_RTS_MSK; - *tx_flags |= TX_CMD_FLG_CTS_MSK; - break; - } - } else if (info->control.rates[0].flags & - IEEE80211_TX_RC_USE_CTS_PROTECT) { - *tx_flags &= ~TX_CMD_FLG_RTS_MSK; - *tx_flags |= TX_CMD_FLG_CTS_MSK; - *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; - } -} -EXPORT_SYMBOL(il_tx_cmd_protection); -- cgit v0.10.2 From 0cdc21363cc27989fe9aa1cde614ef4c0429d62f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:40:15 +0100 Subject: iwlegacy: merge common .c files Merge iwl-{tx,rx,sta,scan,power,eeprom,led,hcmd}.c into common.c . Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 0f51f9d..413213b 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,7 +1,5 @@ obj-$(CONFIG_IWLEGACY) += iwl-legacy.o -iwl-legacy-objs := common.o iwl-eeprom.o iwl-hcmd.o iwl-power.o -iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o -iwl-legacy-objs += iwl-scan.o iwl-led.o +iwl-legacy-objs := common.o iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o iwl-legacy-objs += $(iwl-legacy-m) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 856a321..7062574 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -31,6 +31,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include "iwl-eeprom.h" @@ -42,6 +49,3145 @@ #include "iwl-sta.h" #include "iwl-helpers.h" +const char *il_get_cmd_string(u8 cmd) +{ + switch (cmd) { + IL_CMD(N_ALIVE); + IL_CMD(N_ERROR); + IL_CMD(C_RXON); + IL_CMD(C_RXON_ASSOC); + IL_CMD(C_QOS_PARAM); + IL_CMD(C_RXON_TIMING); + IL_CMD(C_ADD_STA); + IL_CMD(C_REM_STA); + IL_CMD(C_WEPKEY); + IL_CMD(N_3945_RX); + IL_CMD(C_TX); + IL_CMD(C_RATE_SCALE); + IL_CMD(C_LEDS); + IL_CMD(C_TX_LINK_QUALITY_CMD); + IL_CMD(C_CHANNEL_SWITCH); + IL_CMD(N_CHANNEL_SWITCH); + IL_CMD(C_SPECTRUM_MEASUREMENT); + IL_CMD(N_SPECTRUM_MEASUREMENT); + IL_CMD(C_POWER_TBL); + IL_CMD(N_PM_SLEEP); + IL_CMD(N_PM_DEBUG_STATS); + IL_CMD(C_SCAN); + IL_CMD(C_SCAN_ABORT); + IL_CMD(N_SCAN_START); + IL_CMD(N_SCAN_RESULTS); + IL_CMD(N_SCAN_COMPLETE); + IL_CMD(N_BEACON); + IL_CMD(C_TX_BEACON); + IL_CMD(C_TX_PWR_TBL); + IL_CMD(C_BT_CONFIG); + IL_CMD(C_STATS); + IL_CMD(N_STATS); + IL_CMD(N_CARD_STATE); + IL_CMD(N_MISSED_BEACONS); + IL_CMD(C_CT_KILL_CONFIG); + IL_CMD(C_SENSITIVITY); + IL_CMD(C_PHY_CALIBRATION); + IL_CMD(N_RX_PHY); + IL_CMD(N_RX_MPDU); + IL_CMD(N_RX); + IL_CMD(N_COMPRESSED_BA); + default: + return "UNKNOWN"; + + } +} +EXPORT_SYMBOL(il_get_cmd_string); + +#define HOST_COMPLETE_TIMEOUT (HZ / 2) + +static void il_generic_cmd_callback(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) +{ + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + return; + } + +#ifdef CONFIG_IWLEGACY_DEBUG + switch (cmd->hdr.cmd) { + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: + D_HC_DUMP("back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + break; + default: + D_HC("back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + } +#endif +} + +static int +il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) +{ + int ret; + + BUG_ON(!(cmd->flags & CMD_ASYNC)); + + /* An asynchronous command can not expect an SKB to be set. */ + BUG_ON(cmd->flags & CMD_WANT_SKB); + + /* Assign a generic callback if one is not provided */ + if (!cmd->callback) + cmd->callback = il_generic_cmd_callback; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return -EBUSY; + + ret = il_enqueue_hcmd(il, cmd); + if (ret < 0) { + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); + return ret; + } + return 0; +} + +int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) +{ + int cmd_idx; + int ret; + + lockdep_assert_held(&il->mutex); + + BUG_ON(cmd->flags & CMD_ASYNC); + + /* A synchronous command can not have a callback set. */ + BUG_ON(cmd->callback); + + D_INFO("Attempting to send sync command %s\n", + il_get_cmd_string(cmd->id)); + + set_bit(S_HCMD_ACTIVE, &il->status); + D_INFO("Setting HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); + + cmd_idx = il_enqueue_hcmd(il, cmd); + if (cmd_idx < 0) { + ret = cmd_idx; + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); + goto out; + } + + ret = wait_event_timeout(il->wait_command_queue, + !test_bit(S_HCMD_ACTIVE, &il->status), + HOST_COMPLETE_TIMEOUT); + if (!ret) { + if (test_bit(S_HCMD_ACTIVE, &il->status)) { + IL_ERR( + "Error sending %s: time out after %dms.\n", + il_get_cmd_string(cmd->id), + jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); + + clear_bit(S_HCMD_ACTIVE, &il->status); + D_INFO( + "Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); + ret = -ETIMEDOUT; + goto cancel; + } + } + + if (test_bit(S_RF_KILL_HW, &il->status)) { + IL_ERR("Command %s aborted: RF KILL Switch\n", + il_get_cmd_string(cmd->id)); + ret = -ECANCELED; + goto fail; + } + if (test_bit(S_FW_ERROR, &il->status)) { + IL_ERR("Command %s failed: FW Error\n", + il_get_cmd_string(cmd->id)); + ret = -EIO; + goto fail; + } + if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { + IL_ERR("Error: Response NULL in '%s'\n", + il_get_cmd_string(cmd->id)); + ret = -EIO; + goto cancel; + } + + ret = 0; + goto out; + +cancel: + if (cmd->flags & CMD_WANT_SKB) { + /* + * Cancel the CMD_WANT_SKB flag for the cmd in the + * TX cmd queue. Otherwise in case the cmd comes + * in later, it will possibly set an invalid + * address (cmd->meta.source). + */ + il->txq[il->cmd_queue].meta[cmd_idx].flags &= + ~CMD_WANT_SKB; + } +fail: + if (cmd->reply_page) { + il_free_pages(il, cmd->reply_page); + cmd->reply_page = 0; + } +out: + return ret; +} +EXPORT_SYMBOL(il_send_cmd_sync); + +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) +{ + if (cmd->flags & CMD_ASYNC) + return il_send_cmd_async(il, cmd); + + return il_send_cmd_sync(il, cmd); +} +EXPORT_SYMBOL(il_send_cmd); + +int +il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) +{ + struct il_host_cmd cmd = { + .id = id, + .len = len, + .data = data, + }; + + return il_send_cmd_sync(il, &cmd); +} +EXPORT_SYMBOL(il_send_cmd_pdu); + +int il_send_cmd_pdu_async(struct il_priv *il, + u8 id, u16 len, const void *data, + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)) +{ + struct il_host_cmd cmd = { + .id = id, + .len = len, + .data = data, + }; + + cmd.flags |= CMD_ASYNC; + cmd.callback = callback; + + return il_send_cmd_async(il, &cmd); +} +EXPORT_SYMBOL(il_send_cmd_pdu_async); + +/* default: IL_LED_BLINK(0) using blinking idx table */ +static int led_mode; +module_param(led_mode, int, S_IRUGO); +MODULE_PARM_DESC(led_mode, "0=system default, " + "1=On(RF On)/Off(RF Off), 2=blinking"); + +/* Throughput OFF time(ms) ON time (ms) + * >300 25 25 + * >200 to 300 40 40 + * >100 to 200 55 55 + * >70 to 100 65 65 + * >50 to 70 75 75 + * >20 to 50 85 85 + * >10 to 20 95 95 + * >5 to 10 110 110 + * >1 to 5 130 130 + * >0 to 1 167 167 + * <=0 SOLID ON + */ +static const struct ieee80211_tpt_blink il_blink[] = { + { .throughput = 0, .blink_time = 334 }, + { .throughput = 1 * 1024 - 1, .blink_time = 260 }, + { .throughput = 5 * 1024 - 1, .blink_time = 220 }, + { .throughput = 10 * 1024 - 1, .blink_time = 190 }, + { .throughput = 20 * 1024 - 1, .blink_time = 170 }, + { .throughput = 50 * 1024 - 1, .blink_time = 150 }, + { .throughput = 70 * 1024 - 1, .blink_time = 130 }, + { .throughput = 100 * 1024 - 1, .blink_time = 110 }, + { .throughput = 200 * 1024 - 1, .blink_time = 80 }, + { .throughput = 300 * 1024 - 1, .blink_time = 50 }, +}; + +/* + * Adjust led blink rate to compensate on a MAC Clock difference on every HW + * Led blink rate analysis showed an average deviation of 0% on 3945, + * 5% on 4965 HW. + * Need to compensate on the led on/off time per HW according to the deviation + * to achieve the desired led frequency + * The calculation is: (100-averageDeviation)/100 * blinkTime + * For code efficiency the calculation will be: + * compensation = (100 - averageDeviation) * 64 / 100 + * NewBlinkTime = (compensation * BlinkTime) / 64 + */ +static inline u8 il_blink_compensation(struct il_priv *il, + u8 time, u16 compensation) +{ + if (!compensation) { + IL_ERR("undefined blink compensation: " + "use pre-defined blinking time\n"); + return time; + } + + return (u8)((time * compensation) >> 6); +} + +/* Set led pattern command */ +static int il_led_cmd(struct il_priv *il, + unsigned long on, + unsigned long off) +{ + struct il_led_cmd led_cmd = { + .id = IL_LED_LINK, + .interval = IL_DEF_LED_INTRVL + }; + int ret; + + if (!test_bit(S_READY, &il->status)) + return -EBUSY; + + if (il->blink_on == on && il->blink_off == off) + return 0; + + if (off == 0) { + /* led is SOLID_ON */ + on = IL_LED_SOLID; + } + + D_LED("Led blink time compensation=%u\n", + il->cfg->base_params->led_compensation); + led_cmd.on = il_blink_compensation(il, on, + il->cfg->base_params->led_compensation); + led_cmd.off = il_blink_compensation(il, off, + il->cfg->base_params->led_compensation); + + ret = il->cfg->ops->led->cmd(il, &led_cmd); + if (!ret) { + il->blink_on = on; + il->blink_off = off; + } + return ret; +} + +static void il_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct il_priv *il = container_of(led_cdev, struct il_priv, led); + unsigned long on = 0; + + if (brightness > 0) + on = IL_LED_SOLID; + + il_led_cmd(il, on, 0); +} + +static int il_led_blink_set(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct il_priv *il = container_of(led_cdev, struct il_priv, led); + + return il_led_cmd(il, *delay_on, *delay_off); +} + +void il_leds_init(struct il_priv *il) +{ + int mode = led_mode; + int ret; + + if (mode == IL_LED_DEFAULT) + mode = il->cfg->led_mode; + + il->led.name = kasprintf(GFP_KERNEL, "%s-led", + wiphy_name(il->hw->wiphy)); + il->led.brightness_set = il_led_brightness_set; + il->led.blink_set = il_led_blink_set; + il->led.max_brightness = 1; + + switch (mode) { + case IL_LED_DEFAULT: + WARN_ON(1); + break; + case IL_LED_BLINK: + il->led.default_trigger = + ieee80211_create_tpt_led_trigger(il->hw, + IEEE80211_TPT_LEDTRIG_FL_CONNECTED, + il_blink, ARRAY_SIZE(il_blink)); + break; + case IL_LED_RF_STATE: + il->led.default_trigger = + ieee80211_get_radio_led_name(il->hw); + break; + } + + ret = led_classdev_register(&il->pci_dev->dev, &il->led); + if (ret) { + kfree(il->led.name); + return; + } + + il->led_registered = true; +} +EXPORT_SYMBOL(il_leds_init); + +void il_leds_exit(struct il_priv *il) +{ + if (!il->led_registered) + return; + + led_classdev_unregister(&il->led); + kfree(il->led.name); +} +EXPORT_SYMBOL(il_leds_exit); + +/************************** EEPROM BANDS **************************** + * + * The il_eeprom_band definitions below provide the mapping from the + * EEPROM contents to the specific channel number supported for each + * band. + * + * For example, il_priv->eeprom.band_3_channels[4] from the band_3 + * definition below maps to physical channel 42 in the 5.2GHz spectrum. + * The specific geography and calibration information for that channel + * is contained in the eeprom map itself. + * + * During init, we copy the eeprom information and channel map + * information into il->channel_info_24/52 and il->channel_map_24/52 + * + * channel_map_24/52 provides the idx in the channel_info array for a + * given channel. We have to have two separate maps as there is channel + * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and + * band_2 + * + * A value of 0xff stored in the channel_map indicates that the channel + * is not supported by the hardware at all. + * + * A value of 0xfe in the channel_map indicates that the channel is not + * valid for Tx with the current hardware. This means that + * while the system can tune and receive on a given channel, it may not + * be able to associate or transmit any frames on that + * channel. There is no corresponding channel information for that + * entry. + * + *********************************************************************/ + +/* 2.4 GHz */ +const u8 il_eeprom_band_1[14] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 +}; + +/* 5.2 GHz bands */ +static const u8 il_eeprom_band_2[] = { /* 4915-5080MHz */ + 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 +}; + +static const u8 il_eeprom_band_3[] = { /* 5170-5320MHz */ + 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 +}; + +static const u8 il_eeprom_band_4[] = { /* 5500-5700MHz */ + 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 +}; + +static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ + 145, 149, 153, 157, 161, 165 +}; + +static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ + 1, 2, 3, 4, 5, 6, 7 +}; + +static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ + 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 +}; + +/****************************************************************************** + * + * EEPROM related functions + * +******************************************************************************/ + +static int il_eeprom_verify_signature(struct il_priv *il) +{ + u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + int ret = 0; + + D_EEPROM("EEPROM signature=0x%08x\n", gp); + switch (gp) { + case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: + case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: + break; + default: + IL_ERR("bad EEPROM signature," + "EEPROM_GP=0x%08x\n", gp); + ret = -ENOENT; + break; + } + return ret; +} + +const u8 +*il_eeprom_query_addr(const struct il_priv *il, size_t offset) +{ + BUG_ON(offset >= il->cfg->base_params->eeprom_size); + return &il->eeprom[offset]; +} +EXPORT_SYMBOL(il_eeprom_query_addr); + +u16 il_eeprom_query16(const struct il_priv *il, size_t offset) +{ + if (!il->eeprom) + return 0; + return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); +} +EXPORT_SYMBOL(il_eeprom_query16); + +/** + * il_eeprom_init - read EEPROM contents + * + * Load the EEPROM contents from adapter into il->eeprom + * + * NOTE: This routine uses the non-debug IO access functions. + */ +int il_eeprom_init(struct il_priv *il) +{ + __le16 *e; + u32 gp = _il_rd(il, CSR_EEPROM_GP); + int sz; + int ret; + u16 addr; + + /* allocate eeprom */ + sz = il->cfg->base_params->eeprom_size; + D_EEPROM("NVM size = %d\n", sz); + il->eeprom = kzalloc(sz, GFP_KERNEL); + if (!il->eeprom) { + ret = -ENOMEM; + goto alloc_err; + } + e = (__le16 *)il->eeprom; + + il->cfg->ops->lib->apm_ops.init(il); + + ret = il_eeprom_verify_signature(il); + if (ret < 0) { + IL_ERR("EEPROM not found, EEPROM_GP=0x%08x\n", gp); + ret = -ENOENT; + goto err; + } + + /* Make sure driver (instead of uCode) is allowed to read EEPROM */ + ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); + if (ret < 0) { + IL_ERR("Failed to acquire EEPROM semaphore.\n"); + ret = -ENOENT; + goto err; + } + + /* eeprom is an array of 16bit values */ + for (addr = 0; addr < sz; addr += sizeof(u16)) { + u32 r; + + _il_wr(il, CSR_EEPROM_REG, + CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); + + ret = _il_poll_bit(il, CSR_EEPROM_REG, + CSR_EEPROM_REG_READ_VALID_MSK, + CSR_EEPROM_REG_READ_VALID_MSK, + IL_EEPROM_ACCESS_TIMEOUT); + if (ret < 0) { + IL_ERR("Time out reading EEPROM[%d]\n", + addr); + goto done; + } + r = _il_rd(il, CSR_EEPROM_REG); + e[addr / 2] = cpu_to_le16(r >> 16); + } + + D_EEPROM("NVM Type: %s, version: 0x%x\n", + "EEPROM", + il_eeprom_query16(il, EEPROM_VERSION)); + + ret = 0; +done: + il->cfg->ops->lib->eeprom_ops.release_semaphore(il); + +err: + if (ret) + il_eeprom_free(il); + /* Reset chip to save power until we load uCode during "up". */ + il_apm_stop(il); +alloc_err: + return ret; +} +EXPORT_SYMBOL(il_eeprom_init); + +void il_eeprom_free(struct il_priv *il) +{ + kfree(il->eeprom); + il->eeprom = NULL; +} +EXPORT_SYMBOL(il_eeprom_free); + +static void il_init_band_reference(const struct il_priv *il, + int eep_band, int *eeprom_ch_count, + const struct il_eeprom_channel **eeprom_ch_info, + const u8 **eeprom_ch_idx) +{ + u32 offset = il->cfg->ops->lib-> + eeprom_ops.regulatory_bands[eep_band - 1]; + switch (eep_band) { + case 1: /* 2.4GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_1; + break; + case 2: /* 4.9GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_2; + break; + case 3: /* 5.2GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_3; + break; + case 4: /* 5.5GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_4; + break; + case 5: /* 5.7GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_5; + break; + case 6: /* 2.4GHz ht40 channels */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_6; + break; + case 7: /* 5 GHz ht40 channels */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_7; + break; + default: + BUG(); + } +} + +#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ + ? # x " " : "") +/** + * il_mod_ht40_chan_info - Copy ht40 channel info into driver's il. + * + * Does not set up a command, or touch hardware. + */ +static int il_mod_ht40_chan_info(struct il_priv *il, + enum ieee80211_band band, u16 channel, + const struct il_eeprom_channel *eeprom_ch, + u8 clear_ht40_extension_channel) +{ + struct il_channel_info *ch_info; + + ch_info = (struct il_channel_info *) + il_get_channel_info(il, band, channel); + + if (!il_is_channel_valid(ch_info)) + return -1; + + D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + " Ad-Hoc %ssupported\n", + ch_info->channel, + il_is_channel_a_band(ch_info) ? + "5.2" : "2.4", + CHECK_AND_PRINT(IBSS), + CHECK_AND_PRINT(ACTIVE), + CHECK_AND_PRINT(RADAR), + CHECK_AND_PRINT(WIDE), + CHECK_AND_PRINT(DFS), + eeprom_ch->flags, + eeprom_ch->max_power_avg, + ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) + && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? + "" : "not "); + + ch_info->ht40_eeprom = *eeprom_ch; + ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; + ch_info->ht40_flags = eeprom_ch->flags; + if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) + ch_info->ht40_extension_channel &= + ~clear_ht40_extension_channel; + + return 0; +} + +#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \ + ? # x " " : "") + +/** + * il_init_channel_map - Set up driver's info for all possible channels + */ +int il_init_channel_map(struct il_priv *il) +{ + int eeprom_ch_count = 0; + const u8 *eeprom_ch_idx = NULL; + const struct il_eeprom_channel *eeprom_ch_info = NULL; + int band, ch; + struct il_channel_info *ch_info; + + if (il->channel_count) { + D_EEPROM("Channel map already initialized.\n"); + return 0; + } + + D_EEPROM("Initializing regulatory info from EEPROM\n"); + + il->channel_count = + ARRAY_SIZE(il_eeprom_band_1) + + ARRAY_SIZE(il_eeprom_band_2) + + ARRAY_SIZE(il_eeprom_band_3) + + ARRAY_SIZE(il_eeprom_band_4) + + ARRAY_SIZE(il_eeprom_band_5); + + D_EEPROM("Parsing data for %d channels.\n", + il->channel_count); + + il->channel_info = kzalloc(sizeof(struct il_channel_info) * + il->channel_count, GFP_KERNEL); + if (!il->channel_info) { + IL_ERR("Could not allocate channel_info\n"); + il->channel_count = 0; + return -ENOMEM; + } + + ch_info = il->channel_info; + + /* Loop through the 5 EEPROM bands adding them in order to the + * channel map we maintain (that contains additional information than + * what just in the EEPROM) */ + for (band = 1; band <= 5; band++) { + + il_init_band_reference(il, band, &eeprom_ch_count, + &eeprom_ch_info, &eeprom_ch_idx); + + /* Loop through each band adding each of the channels */ + for (ch = 0; ch < eeprom_ch_count; ch++) { + ch_info->channel = eeprom_ch_idx[ch]; + ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : + IEEE80211_BAND_5GHZ; + + /* permanently store EEPROM's channel regulatory flags + * and max power in channel info database. */ + ch_info->eeprom = eeprom_ch_info[ch]; + + /* Copy the run-time flags so they are there even on + * invalid channels */ + ch_info->flags = eeprom_ch_info[ch].flags; + /* First write that ht40 is not enabled, and then enable + * one by one */ + ch_info->ht40_extension_channel = + IEEE80211_CHAN_NO_HT40; + + if (!(il_is_channel_valid(ch_info))) { + D_EEPROM( + "Ch. %d Flags %x [%sGHz] - " + "No traffic\n", + ch_info->channel, + ch_info->flags, + il_is_channel_a_band(ch_info) ? + "5.2" : "2.4"); + ch_info++; + continue; + } + + /* Initialize regulatory-based run-time data */ + ch_info->max_power_avg = ch_info->curr_txpow = + eeprom_ch_info[ch].max_power_avg; + ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; + ch_info->min_power = 0; + + D_EEPROM("Ch. %d [%sGHz] " + "%s%s%s%s%s%s(0x%02x %ddBm):" + " Ad-Hoc %ssupported\n", + ch_info->channel, + il_is_channel_a_band(ch_info) ? + "5.2" : "2.4", + CHECK_AND_PRINT_I(VALID), + CHECK_AND_PRINT_I(IBSS), + CHECK_AND_PRINT_I(ACTIVE), + CHECK_AND_PRINT_I(RADAR), + CHECK_AND_PRINT_I(WIDE), + CHECK_AND_PRINT_I(DFS), + eeprom_ch_info[ch].flags, + eeprom_ch_info[ch].max_power_avg, + ((eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_IBSS) + && !(eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_RADAR)) + ? "" : "not "); + + ch_info++; + } + } + + /* Check if we do have HT40 channels */ + if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == + EEPROM_REGULATORY_BAND_NO_HT40 && + il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == + EEPROM_REGULATORY_BAND_NO_HT40) + return 0; + + /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */ + for (band = 6; band <= 7; band++) { + enum ieee80211_band ieeeband; + + il_init_band_reference(il, band, &eeprom_ch_count, + &eeprom_ch_info, &eeprom_ch_idx); + + /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ + ieeeband = + (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + + /* Loop through each band adding each of the channels */ + for (ch = 0; ch < eeprom_ch_count; ch++) { + /* Set up driver's info for lower half */ + il_mod_ht40_chan_info(il, ieeeband, + eeprom_ch_idx[ch], + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40PLUS); + + /* Set up driver's info for upper half */ + il_mod_ht40_chan_info(il, ieeeband, + eeprom_ch_idx[ch] + 4, + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40MINUS); + } + } + + return 0; +} +EXPORT_SYMBOL(il_init_channel_map); + +/* + * il_free_channel_map - undo allocations in il_init_channel_map + */ +void il_free_channel_map(struct il_priv *il) +{ + kfree(il->channel_info); + il->channel_count = 0; +} +EXPORT_SYMBOL(il_free_channel_map); + +/** + * il_get_channel_info - Find driver's ilate channel info + * + * Based on band and channel number. + */ +const struct +il_channel_info *il_get_channel_info(const struct il_priv *il, + enum ieee80211_band band, u16 channel) +{ + int i; + + switch (band) { + case IEEE80211_BAND_5GHZ: + for (i = 14; i < il->channel_count; i++) { + if (il->channel_info[i].channel == channel) + return &il->channel_info[i]; + } + break; + case IEEE80211_BAND_2GHZ: + if (channel >= 1 && channel <= 14) + return &il->channel_info[channel - 1]; + break; + default: + BUG(); + } + + return NULL; +} +EXPORT_SYMBOL(il_get_channel_info); + +/* + * Setting power level allows the card to go to sleep when not busy. + * + * We calculate a sleep command based on the required latency, which + * we get from mac80211. In order to handle thermal throttling, we can + * also use pre-defined power levels. + */ + +/* + * This defines the old power levels. They are still used by default + * (level 1) and for thermal throttle (levels 3 through 5) + */ + +struct il_power_vec_entry { + struct il_powertable_cmd cmd; + u8 no_dtim; /* number of skip dtim */ +}; + +static void il_power_sleep_cam_cmd(struct il_priv *il, + struct il_powertable_cmd *cmd) +{ + memset(cmd, 0, sizeof(*cmd)); + + if (il->power_data.pci_pm) + cmd->flags |= IL_POWER_PCI_PM_MSK; + + D_POWER("Sleep command for CAM\n"); +} + +static int +il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) +{ + D_POWER("Sending power/sleep command\n"); + D_POWER("Flags value = 0x%08X\n", cmd->flags); + D_POWER("Tx timeout = %u\n", + le32_to_cpu(cmd->tx_data_timeout)); + D_POWER("Rx timeout = %u\n", + le32_to_cpu(cmd->rx_data_timeout)); + D_POWER( + "Sleep interval vector = { %d , %d , %d , %d , %d }\n", + le32_to_cpu(cmd->sleep_interval[0]), + le32_to_cpu(cmd->sleep_interval[1]), + le32_to_cpu(cmd->sleep_interval[2]), + le32_to_cpu(cmd->sleep_interval[3]), + le32_to_cpu(cmd->sleep_interval[4])); + + return il_send_cmd_pdu(il, C_POWER_TBL, + sizeof(struct il_powertable_cmd), cmd); +} + +int +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, + bool force) +{ + int ret; + bool update_chains; + + lockdep_assert_held(&il->mutex); + + /* Don't update the RX chain when chain noise calibration is running */ + update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || + il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; + + if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) + return 0; + + if (!il_is_ready_rf(il)) + return -EIO; + + /* scan complete use sleep_power_next, need to be updated */ + memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); + if (test_bit(S_SCANNING, &il->status) && !force) { + D_INFO("Defer power set mode while scanning\n"); + return 0; + } + + if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) + set_bit(S_POWER_PMI, &il->status); + + ret = il_set_power(il, cmd); + if (!ret) { + if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) + clear_bit(S_POWER_PMI, &il->status); + + if (il->cfg->ops->lib->update_chain_flags && update_chains) + il->cfg->ops->lib->update_chain_flags(il); + else if (il->cfg->ops->lib->update_chain_flags) + D_POWER( + "Cannot update the power, chain noise " + "calibration running: %d\n", + il->chain_noise_data.state); + + memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); + } else + IL_ERR("set power fail, ret = %d", ret); + + return ret; +} + +int il_power_update_mode(struct il_priv *il, bool force) +{ + struct il_powertable_cmd cmd; + + il_power_sleep_cam_cmd(il, &cmd); + return il_power_set_mode(il, &cmd, force); +} +EXPORT_SYMBOL(il_power_update_mode); + +/* initialize to default */ +void il_power_initialize(struct il_priv *il) +{ + u16 lctl = il_pcie_link_ctl(il); + + il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); + + il->power_data.debug_sleep_level_override = -1; + + memset(&il->power_data.sleep_cmd, 0, + sizeof(il->power_data.sleep_cmd)); +} +EXPORT_SYMBOL(il_power_initialize); + +/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after + * sending probe req. This should be set long enough to hear probe responses + * from more than one AP. */ +#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ +#define IL_ACTIVE_DWELL_TIME_52 (20) + +#define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) +#define IL_ACTIVE_DWELL_FACTOR_52GHZ (2) + +/* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. + * Must be set longer than active dwell time. + * For the most reliable scan, set > AP beacon interval (typically 100msec). */ +#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ +#define IL_PASSIVE_DWELL_TIME_52 (10) +#define IL_PASSIVE_DWELL_BASE (100) +#define IL_CHANNEL_TUNE_TIME 5 + +static int il_send_scan_abort(struct il_priv *il) +{ + int ret; + struct il_rx_pkt *pkt; + struct il_host_cmd cmd = { + .id = C_SCAN_ABORT, + .flags = CMD_WANT_SKB, + }; + + /* Exit instantly with error when device is not ready + * to receive scan abort command or it does not perform + * hardware scan currently */ + if (!test_bit(S_READY, &il->status) || + !test_bit(S_GEO_CONFIGURED, &il->status) || + !test_bit(S_SCAN_HW, &il->status) || + test_bit(S_FW_ERROR, &il->status) || + test_bit(S_EXIT_PENDING, &il->status)) + return -EIO; + + ret = il_send_cmd_sync(il, &cmd); + if (ret) + return ret; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->u.status != CAN_ABORT_STATUS) { + /* The scan abort will return 1 for success or + * 2 for "failure". A failure condition can be + * due to simply not being in an active scan which + * can occur if we send the scan abort before we + * the microcode has notified us that a scan is + * completed. */ + D_SCAN("SCAN_ABORT ret %d.\n", pkt->u.status); + ret = -EIO; + } + + il_free_pages(il, cmd.reply_page); + return ret; +} + +static void il_complete_scan(struct il_priv *il, bool aborted) +{ + /* check if scan was requested from mac80211 */ + if (il->scan_request) { + D_SCAN("Complete scan in mac80211\n"); + ieee80211_scan_completed(il->hw, aborted); + } + + il->scan_vif = NULL; + il->scan_request = NULL; +} + +void il_force_scan_end(struct il_priv *il) +{ + lockdep_assert_held(&il->mutex); + + if (!test_bit(S_SCANNING, &il->status)) { + D_SCAN("Forcing scan end while not scanning\n"); + return; + } + + D_SCAN("Forcing scan end\n"); + clear_bit(S_SCANNING, &il->status); + clear_bit(S_SCAN_HW, &il->status); + clear_bit(S_SCAN_ABORTING, &il->status); + il_complete_scan(il, true); +} + +static void il_do_scan_abort(struct il_priv *il) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + if (!test_bit(S_SCANNING, &il->status)) { + D_SCAN("Not performing scan to abort\n"); + return; + } + + if (test_and_set_bit(S_SCAN_ABORTING, &il->status)) { + D_SCAN("Scan abort in progress\n"); + return; + } + + ret = il_send_scan_abort(il); + if (ret) { + D_SCAN("Send scan abort failed %d\n", ret); + il_force_scan_end(il); + } else + D_SCAN("Successfully send scan abort\n"); +} + +/** + * il_scan_cancel - Cancel any currently executing HW scan + */ +int il_scan_cancel(struct il_priv *il) +{ + D_SCAN("Queuing abort scan\n"); + queue_work(il->workqueue, &il->abort_scan); + return 0; +} +EXPORT_SYMBOL(il_scan_cancel); + +/** + * il_scan_cancel_timeout - Cancel any currently executing HW scan + * @ms: amount of time to wait (in milliseconds) for scan to abort + * + */ +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(ms); + + lockdep_assert_held(&il->mutex); + + D_SCAN("Scan cancel timeout\n"); + + il_do_scan_abort(il); + + while (time_before_eq(jiffies, timeout)) { + if (!test_bit(S_SCAN_HW, &il->status)) + break; + msleep(20); + } + + return test_bit(S_SCAN_HW, &il->status); +} +EXPORT_SYMBOL(il_scan_cancel_timeout); + +/* Service response to C_SCAN (0x80) */ +static void il_hdl_scan(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scanreq_notification *notif = + (struct il_scanreq_notification *)pkt->u.raw; + + D_SCAN("Scan request status = 0x%x\n", notif->status); +#endif +} + +/* Service N_SCAN_START (0x82) */ +static void il_hdl_scan_start(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scanstart_notification *notif = + (struct il_scanstart_notification *)pkt->u.raw; + il->scan_start_tsf = le32_to_cpu(notif->tsf_low); + D_SCAN("Scan start: " + "%d [802.11%s] " + "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", + notif->channel, + notif->band ? "bg" : "a", + le32_to_cpu(notif->tsf_high), + le32_to_cpu(notif->tsf_low), + notif->status, notif->beacon_timer); +} + +/* Service N_SCAN_RESULTS (0x83) */ +static void il_hdl_scan_results(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scanresults_notification *notif = + (struct il_scanresults_notification *)pkt->u.raw; + + D_SCAN("Scan ch.res: " + "%d [802.11%s] " + "(TSF: 0x%08X:%08X) - %d " + "elapsed=%lu usec\n", + notif->channel, + notif->band ? "bg" : "a", + le32_to_cpu(notif->tsf_high), + le32_to_cpu(notif->tsf_low), + le32_to_cpu(notif->stats[0]), + le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); +#endif +} + +/* Service N_SCAN_COMPLETE (0x84) */ +static void il_hdl_scan_complete(struct il_priv *il, + struct il_rx_buf *rxb) +{ + +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; +#endif + + D_SCAN( + "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", + scan_notif->scanned_channels, + scan_notif->tsf_low, + scan_notif->tsf_high, scan_notif->status); + + /* The HW is no longer scanning */ + clear_bit(S_SCAN_HW, &il->status); + + D_SCAN("Scan on %sGHz took %dms\n", + (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", + jiffies_to_msecs(jiffies - il->scan_start)); + + queue_work(il->workqueue, &il->scan_completed); +} + +void il_setup_rx_scan_handlers(struct il_priv *il) +{ + /* scan handlers */ + il->handlers[C_SCAN] = il_hdl_scan; + il->handlers[N_SCAN_START] = + il_hdl_scan_start; + il->handlers[N_SCAN_RESULTS] = + il_hdl_scan_results; + il->handlers[N_SCAN_COMPLETE] = + il_hdl_scan_complete; +} +EXPORT_SYMBOL(il_setup_rx_scan_handlers); + +inline u16 il_get_active_dwell_time(struct il_priv *il, + enum ieee80211_band band, + u8 n_probes) +{ + if (band == IEEE80211_BAND_5GHZ) + return IL_ACTIVE_DWELL_TIME_52 + + IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); + else + return IL_ACTIVE_DWELL_TIME_24 + + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); +} +EXPORT_SYMBOL(il_get_active_dwell_time); + +u16 il_get_passive_dwell_time(struct il_priv *il, + enum ieee80211_band band, + struct ieee80211_vif *vif) +{ + struct il_rxon_context *ctx = &il->ctx; + u16 value; + + u16 passive = (band == IEEE80211_BAND_2GHZ) ? + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; + + if (il_is_any_associated(il)) { + /* + * If we're associated, we clamp the maximum passive + * dwell time to be 98% of the smallest beacon interval + * (minus 2 * channel tune time) + */ + value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; + if (value > IL_PASSIVE_DWELL_BASE || !value) + value = IL_PASSIVE_DWELL_BASE; + value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; + passive = min(value, passive); + } + + return passive; +} +EXPORT_SYMBOL(il_get_passive_dwell_time); + +void il_init_scan_params(struct il_priv *il) +{ + u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; + if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) + il->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; + if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) + il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; +} +EXPORT_SYMBOL(il_init_scan_params); + +static int il_scan_initiate(struct il_priv *il, + struct ieee80211_vif *vif) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + if (WARN_ON(!il->cfg->ops->utils->request_scan)) + return -EOPNOTSUPP; + + cancel_delayed_work(&il->scan_check); + + if (!il_is_ready_rf(il)) { + IL_WARN("Request scan called when driver not ready.\n"); + return -EIO; + } + + if (test_bit(S_SCAN_HW, &il->status)) { + D_SCAN( + "Multiple concurrent scan requests in parallel.\n"); + return -EBUSY; + } + + if (test_bit(S_SCAN_ABORTING, &il->status)) { + D_SCAN("Scan request while abort pending.\n"); + return -EBUSY; + } + + D_SCAN("Starting scan...\n"); + + set_bit(S_SCANNING, &il->status); + il->scan_start = jiffies; + + ret = il->cfg->ops->utils->request_scan(il, vif); + if (ret) { + clear_bit(S_SCANNING, &il->status); + return ret; + } + + queue_delayed_work(il->workqueue, &il->scan_check, + IL_SCAN_CHECK_WATCHDOG); + + return 0; +} + +int il_mac_hw_scan(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct cfg80211_scan_request *req) +{ + struct il_priv *il = hw->priv; + int ret; + + D_MAC80211("enter\n"); + + if (req->n_channels == 0) + return -EINVAL; + + mutex_lock(&il->mutex); + + if (test_bit(S_SCANNING, &il->status)) { + D_SCAN("Scan already in progress.\n"); + ret = -EAGAIN; + goto out_unlock; + } + + /* mac80211 will only ask for one band at a time */ + il->scan_request = req; + il->scan_vif = vif; + il->scan_band = req->channels[0]->band; + + ret = il_scan_initiate(il, vif); + + D_MAC80211("leave\n"); + +out_unlock: + mutex_unlock(&il->mutex); + + return ret; +} +EXPORT_SYMBOL(il_mac_hw_scan); + +static void il_bg_scan_check(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, scan_check.work); + + D_SCAN("Scan check work\n"); + + /* Since we are here firmware does not finish scan and + * most likely is in bad shape, so we don't bother to + * send abort command, just force scan complete to mac80211 */ + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); +} + +/** + * il_fill_probe_req - fill in all required fields and IE for probe request + */ + +u16 +il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, + const u8 *ta, const u8 *ies, int ie_len, int left) +{ + int len = 0; + u8 *pos = NULL; + + /* Make sure there is enough space for the probe request, + * two mandatory IEs and the data */ + left -= 24; + if (left < 0) + return 0; + + frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); + memcpy(frame->da, il_bcast_addr, ETH_ALEN); + memcpy(frame->sa, ta, ETH_ALEN); + memcpy(frame->bssid, il_bcast_addr, ETH_ALEN); + frame->seq_ctrl = 0; + + len += 24; + + /* ...next IE... */ + pos = &frame->u.probe_req.variable[0]; + + /* fill in our indirect SSID IE */ + left -= 2; + if (left < 0) + return 0; + *pos++ = WLAN_EID_SSID; + *pos++ = 0; + + len += 2; + + if (WARN_ON(left < ie_len)) + return len; + + if (ies && ie_len) { + memcpy(pos, ies, ie_len); + len += ie_len; + } + + return (u16)len; +} +EXPORT_SYMBOL(il_fill_probe_req); + +static void il_bg_abort_scan(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, abort_scan); + + D_SCAN("Abort scan work\n"); + + /* We keep scan_check work queued in case when firmware will not + * report back scan completed notification */ + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 200); + mutex_unlock(&il->mutex); +} + +static void il_bg_scan_completed(struct work_struct *work) +{ + struct il_priv *il = + container_of(work, struct il_priv, scan_completed); + bool aborted; + + D_SCAN("Completed scan.\n"); + + cancel_delayed_work(&il->scan_check); + + mutex_lock(&il->mutex); + + aborted = test_and_clear_bit(S_SCAN_ABORTING, &il->status); + if (aborted) + D_SCAN("Aborted scan completed.\n"); + + if (!test_and_clear_bit(S_SCANNING, &il->status)) { + D_SCAN("Scan already completed.\n"); + goto out_settings; + } + + il_complete_scan(il, aborted); + +out_settings: + /* Can we still talk to firmware ? */ + if (!il_is_ready_rf(il)) + goto out; + + /* + * We do not commit power settings while scan is pending, + * do it now if the settings changed. + */ + il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); + il_set_tx_power(il, il->tx_power_next, false); + + il->cfg->ops->utils->post_scan(il); + +out: + mutex_unlock(&il->mutex); +} + +void il_setup_scan_deferred_work(struct il_priv *il) +{ + INIT_WORK(&il->scan_completed, il_bg_scan_completed); + INIT_WORK(&il->abort_scan, il_bg_abort_scan); + INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); +} +EXPORT_SYMBOL(il_setup_scan_deferred_work); + +void il_cancel_scan_deferred_work(struct il_priv *il) +{ + cancel_work_sync(&il->abort_scan); + cancel_work_sync(&il->scan_completed); + + if (cancel_delayed_work_sync(&il->scan_check)) { + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); + } +} +EXPORT_SYMBOL(il_cancel_scan_deferred_work); + +/* il->sta_lock must be held */ +static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) +{ + + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) + IL_ERR( + "ACTIVATE a non DRIVER active station id %u addr %pM\n", + sta_id, il->stations[sta_id].sta.sta.addr); + + if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { + D_ASSOC( + "STA id %u addr %pM already present" + " in uCode (according to driver)\n", + sta_id, il->stations[sta_id].sta.sta.addr); + } else { + il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; + D_ASSOC("Added STA id %u addr %pM to uCode\n", + sta_id, il->stations[sta_id].sta.sta.addr); + } +} + +static int il_process_add_sta_resp(struct il_priv *il, + struct il_addsta_cmd *addsta, + struct il_rx_pkt *pkt, + bool sync) +{ + u8 sta_id = addsta->sta.sta_id; + unsigned long flags; + int ret = -EIO; + + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", + pkt->hdr.flags); + return ret; + } + + D_INFO("Processing response for adding station %u\n", + sta_id); + + spin_lock_irqsave(&il->sta_lock, flags); + + switch (pkt->u.add_sta.status) { + case ADD_STA_SUCCESS_MSK: + D_INFO("C_ADD_STA PASSED\n"); + il_sta_ucode_activate(il, sta_id); + ret = 0; + break; + case ADD_STA_NO_ROOM_IN_TBL: + IL_ERR("Adding station %d failed, no room in table.\n", + sta_id); + break; + case ADD_STA_NO_BLOCK_ACK_RESOURCE: + IL_ERR( + "Adding station %d failed, no block ack resource.\n", + sta_id); + break; + case ADD_STA_MODIFY_NON_EXIST_STA: + IL_ERR("Attempting to modify non-existing station %d\n", + sta_id); + break; + default: + D_ASSOC("Received C_ADD_STA:(0x%08X)\n", + pkt->u.add_sta.status); + break; + } + + D_INFO("%s station id %u addr %pM\n", + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", + sta_id, il->stations[sta_id].sta.sta.addr); + + /* + * XXX: The MAC address in the command buffer is often changed from + * the original sent to the device. That is, the MAC address + * written to the command buffer often is not the same MAC address + * read from the command buffer when the command returns. This + * issue has not yet been resolved and this debugging is left to + * observe the problem. + */ + D_INFO("%s station according to cmd buffer %pM\n", + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", + addsta->sta.addr); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return ret; +} + +static void il_add_sta_callback(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) +{ + struct il_addsta_cmd *addsta = + (struct il_addsta_cmd *)cmd->cmd.payload; + + il_process_add_sta_resp(il, addsta, pkt, false); + +} + +int il_send_add_sta(struct il_priv *il, + struct il_addsta_cmd *sta, u8 flags) +{ + struct il_rx_pkt *pkt = NULL; + int ret = 0; + u8 data[sizeof(*sta)]; + struct il_host_cmd cmd = { + .id = C_ADD_STA, + .flags = flags, + .data = data, + }; + u8 sta_id __maybe_unused = sta->sta.sta_id; + + D_INFO("Adding sta %u (%pM) %ssynchronously\n", + sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); + + if (flags & CMD_ASYNC) + cmd.callback = il_add_sta_callback; + else { + cmd.flags |= CMD_WANT_SKB; + might_sleep(); + } + + cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); + ret = il_send_cmd(il, &cmd); + + if (ret || (flags & CMD_ASYNC)) + return ret; + + if (ret == 0) { + pkt = (struct il_rx_pkt *)cmd.reply_page; + ret = il_process_add_sta_resp(il, sta, pkt, true); + } + il_free_pages(il, cmd.reply_page); + + return ret; +} +EXPORT_SYMBOL(il_send_add_sta); + +static void il_set_ht_add_station(struct il_priv *il, u8 idx, + struct ieee80211_sta *sta, + struct il_rxon_context *ctx) +{ + struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; + __le32 sta_flags; + u8 mimo_ps_mode; + + if (!sta || !sta_ht_inf->ht_supported) + goto done; + + mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; + D_ASSOC("spatial multiplexing power save mode: %s\n", + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? + "static" : + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? + "dynamic" : "disabled"); + + sta_flags = il->stations[idx].sta.station_flags; + + sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); + + switch (mimo_ps_mode) { + case WLAN_HT_CAP_SM_PS_STATIC: + sta_flags |= STA_FLG_MIMO_DIS_MSK; + break; + case WLAN_HT_CAP_SM_PS_DYNAMIC: + sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK; + break; + case WLAN_HT_CAP_SM_PS_DISABLED: + break; + default: + IL_WARN("Invalid MIMO PS mode %d\n", mimo_ps_mode); + break; + } + + sta_flags |= cpu_to_le32( + (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); + + sta_flags |= cpu_to_le32( + (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); + + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + sta_flags |= STA_FLG_HT40_EN_MSK; + else + sta_flags &= ~STA_FLG_HT40_EN_MSK; + + il->stations[idx].sta.station_flags = sta_flags; + done: + return; +} + +/** + * il_prep_station - Prepare station information for addition + * + * should be called with sta_lock held + */ +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, struct ieee80211_sta *sta) +{ + struct il_station_entry *station; + int i; + u8 sta_id = IL_INVALID_STATION; + u16 rate; + + if (is_ap) + sta_id = ctx->ap_sta_id; + else if (is_broadcast_ether_addr(addr)) + sta_id = ctx->bcast_sta_id; + else + for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { + if (!compare_ether_addr(il->stations[i].sta.sta.addr, + addr)) { + sta_id = i; + break; + } + + if (!il->stations[i].used && + sta_id == IL_INVALID_STATION) + sta_id = i; + } + + /* + * These two conditions have the same outcome, but keep them + * separate + */ + if (unlikely(sta_id == IL_INVALID_STATION)) + return sta_id; + + /* + * uCode is not able to deal with multiple requests to add a + * station. Keep track if one is in progress so that we do not send + * another. + */ + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + D_INFO( + "STA %d already in process of being added.\n", + sta_id); + return sta_id; + } + + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && + !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { + D_ASSOC( + "STA %d (%pM) already added, not adding again.\n", + sta_id, addr); + return sta_id; + } + + station = &il->stations[sta_id]; + station->used = IL_STA_DRIVER_ACTIVE; + D_ASSOC("Add STA to driver ID %d: %pM\n", + sta_id, addr); + il->num_stations++; + + /* Set up the C_ADD_STA command to send to device */ + memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); + memcpy(station->sta.sta.addr, addr, ETH_ALEN); + station->sta.mode = 0; + station->sta.sta.sta_id = sta_id; + station->sta.station_flags = ctx->station_flags; + station->ctxid = ctx->ctxid; + + if (sta) { + struct il_station_priv_common *sta_priv; + + sta_priv = (void *)sta->drv_priv; + sta_priv->ctx = ctx; + } + + /* + * OK to call unconditionally, since local stations (IBSS BSSID + * STA and broadcast STA) pass in a NULL sta, and mac80211 + * doesn't allow HT IBSS. + */ + il_set_ht_add_station(il, sta_id, sta, ctx); + + /* 3945 only */ + rate = (il->band == IEEE80211_BAND_5GHZ) ? + RATE_6M_PLCP : RATE_1M_PLCP; + /* Turn on both antennas for the station... */ + station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); + + return sta_id; + +} +EXPORT_SYMBOL_GPL(il_prep_station); + +#define STA_WAIT_TIMEOUT (HZ/2) + +/** + * il_add_station_common - + */ +int +il_add_station_common(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta, u8 *sta_id_r) +{ + unsigned long flags_spin; + int ret = 0; + u8 sta_id; + struct il_addsta_cmd sta_cmd; + + *sta_id_r = 0; + spin_lock_irqsave(&il->sta_lock, flags_spin); + sta_id = il_prep_station(il, ctx, addr, is_ap, sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Unable to prepare station %pM for addition\n", + addr); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EINVAL; + } + + /* + * uCode is not able to deal with multiple requests to add a + * station. Keep track if one is in progress so that we do not send + * another. + */ + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + D_INFO( + "STA %d already in process of being added.\n", + sta_id); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EEXIST; + } + + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + D_ASSOC( + "STA %d (%pM) already added, not adding again.\n", + sta_id, addr); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EEXIST; + } + + il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + /* Add station to device's station table */ + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); + if (ret) { + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR("Adding station %pM failed.\n", + il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + } + *sta_id_r = sta_id; + return ret; +} +EXPORT_SYMBOL(il_add_station_common); + +/** + * il_sta_ucode_deactivate - deactivate ucode status for a station + * + * il->sta_lock must be held + */ +static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) +{ + /* Ucode must be active and driver must be non active */ + if ((il->stations[sta_id].used & + (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != + IL_STA_UCODE_ACTIVE) + IL_ERR("removed non active STA %u\n", sta_id); + + il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; + + memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); + D_ASSOC("Removed STA %u\n", sta_id); +} + +static int il_send_remove_station(struct il_priv *il, + const u8 *addr, int sta_id, + bool temporary) +{ + struct il_rx_pkt *pkt; + int ret; + + unsigned long flags_spin; + struct il_rem_sta_cmd rm_sta_cmd; + + struct il_host_cmd cmd = { + .id = C_REM_STA, + .len = sizeof(struct il_rem_sta_cmd), + .flags = CMD_SYNC, + .data = &rm_sta_cmd, + }; + + memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd)); + rm_sta_cmd.num_sta = 1; + memcpy(&rm_sta_cmd.addr, addr, ETH_ALEN); + + cmd.flags |= CMD_WANT_SKB; + + ret = il_send_cmd(il, &cmd); + + if (ret) + return ret; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from C_REM_STA (0x%08X)\n", + pkt->hdr.flags); + ret = -EIO; + } + + if (!ret) { + switch (pkt->u.rem_sta.status) { + case REM_STA_SUCCESS_MSK: + if (!temporary) { + spin_lock_irqsave(&il->sta_lock, flags_spin); + il_sta_ucode_deactivate(il, sta_id); + spin_unlock_irqrestore(&il->sta_lock, + flags_spin); + } + D_ASSOC("C_REM_STA PASSED\n"); + break; + default: + ret = -EIO; + IL_ERR("C_REM_STA failed\n"); + break; + } + } + il_free_pages(il, cmd.reply_page); + + return ret; +} + +/** + * il_remove_station - Remove driver's knowledge of station. + */ +int il_remove_station(struct il_priv *il, const u8 sta_id, + const u8 *addr) +{ + unsigned long flags; + + if (!il_is_ready(il)) { + D_INFO( + "Unable to remove station %pM, device not ready.\n", + addr); + /* + * It is typical for stations to be removed when we are + * going down. Return success since device will be down + * soon anyway + */ + return 0; + } + + D_ASSOC("Removing STA from driver:%d %pM\n", + sta_id, addr); + + if (WARN_ON(sta_id == IL_INVALID_STATION)) + return -EINVAL; + + spin_lock_irqsave(&il->sta_lock, flags); + + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { + D_INFO("Removing %pM but non DRIVER active\n", + addr); + goto out_err; + } + + if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + D_INFO("Removing %pM but non UCODE active\n", + addr); + goto out_err; + } + + if (il->stations[sta_id].used & IL_STA_LOCAL) { + kfree(il->stations[sta_id].lq); + il->stations[sta_id].lq = NULL; + } + + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + + il->num_stations--; + + BUG_ON(il->num_stations < 0); + + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_remove_station(il, addr, sta_id, false); +out_err: + spin_unlock_irqrestore(&il->sta_lock, flags); + return -EINVAL; +} +EXPORT_SYMBOL_GPL(il_remove_station); + +/** + * il_clear_ucode_stations - clear ucode station table bits + * + * This function clears all the bits in the driver indicating + * which stations are active in the ucode. Call when something + * other than explicit station management would cause this in + * the ucode, e.g. unassociated RXON. + */ +void il_clear_ucode_stations(struct il_priv *il, + struct il_rxon_context *ctx) +{ + int i; + unsigned long flags_spin; + bool cleared = false; + + D_INFO("Clearing ucode stations in driver\n"); + + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx && ctx->ctxid != il->stations[i].ctxid) + continue; + + if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { + D_INFO( + "Clearing ucode active for station %d\n", i); + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + cleared = true; + } + } + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + if (!cleared) + D_INFO( + "No active stations found to be cleared\n"); +} +EXPORT_SYMBOL(il_clear_ucode_stations); + +/** + * il_restore_stations() - Restore driver known stations to device + * + * All stations considered active by driver, but not present in ucode, is + * restored. + * + * Function sleeps. + */ +void +il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) +{ + struct il_addsta_cmd sta_cmd; + struct il_link_quality_cmd lq; + unsigned long flags_spin; + int i; + bool found = false; + int ret; + bool send_lq; + + if (!il_is_ready(il)) { + D_INFO( + "Not ready yet, not restoring any stations.\n"); + return; + } + + D_ASSOC("Restoring all known stations ... start.\n"); + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx->ctxid != il->stations[i].ctxid) + continue; + if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && + !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { + D_ASSOC("Restoring sta %pM\n", + il->stations[i].sta.sta.addr); + il->stations[i].sta.mode = 0; + il->stations[i].used |= IL_STA_UCODE_INPROGRESS; + found = true; + } + } + + for (i = 0; i < il->hw_params.max_stations; i++) { + if ((il->stations[i].used & IL_STA_UCODE_INPROGRESS)) { + memcpy(&sta_cmd, &il->stations[i].sta, + sizeof(struct il_addsta_cmd)); + send_lq = false; + if (il->stations[i].lq) { + memcpy(&lq, il->stations[i].lq, + sizeof(struct il_link_quality_cmd)); + send_lq = true; + } + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); + if (ret) { + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR("Adding station %pM failed.\n", + il->stations[i].sta.sta.addr); + il->stations[i].used &= + ~IL_STA_DRIVER_ACTIVE; + il->stations[i].used &= + ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, + flags_spin); + } + /* + * Rate scaling has already been initialized, send + * current LQ command + */ + if (send_lq) + il_send_lq_cmd(il, ctx, &lq, + CMD_SYNC, true); + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; + } + } + + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + if (!found) + D_INFO("Restoring all known stations" + " .... no stations to be restored.\n"); + else + D_INFO("Restoring all known stations" + " .... complete.\n"); +} +EXPORT_SYMBOL(il_restore_stations); + +int il_get_free_ucode_key_idx(struct il_priv *il) +{ + int i; + + for (i = 0; i < il->sta_key_max_num; i++) + if (!test_and_set_bit(i, &il->ucode_key_table)) + return i; + + return WEP_INVALID_OFFSET; +} +EXPORT_SYMBOL(il_get_free_ucode_key_idx); + +void il_dealloc_bcast_stations(struct il_priv *il) +{ + unsigned long flags; + int i; + + spin_lock_irqsave(&il->sta_lock, flags); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (!(il->stations[i].used & IL_STA_BCAST)) + continue; + + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + il->num_stations--; + BUG_ON(il->num_stations < 0); + kfree(il->stations[i].lq); + il->stations[i].lq = NULL; + } + spin_unlock_irqrestore(&il->sta_lock, flags); +} +EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); + +#ifdef CONFIG_IWLEGACY_DEBUG +static void il_dump_lq_cmd(struct il_priv *il, + struct il_link_quality_cmd *lq) +{ + int i; + D_RATE("lq station id 0x%x\n", lq->sta_id); + D_RATE("lq ant 0x%X 0x%X\n", + lq->general_params.single_stream_ant_msk, + lq->general_params.dual_stream_ant_msk); + + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) + D_RATE("lq idx %d 0x%X\n", + i, lq->rs_table[i].rate_n_flags); +} +#else +static inline void il_dump_lq_cmd(struct il_priv *il, + struct il_link_quality_cmd *lq) +{ +} +#endif + +/** + * il_is_lq_table_valid() - Test one aspect of LQ cmd for validity + * + * It sometimes happens when a HT rate has been in use and we + * loose connectivity with AP then mac80211 will first tell us that the + * current channel is not HT anymore before removing the station. In such a + * scenario the RXON flags will be updated to indicate we are not + * communicating HT anymore, but the LQ command may still contain HT rates. + * Test for this to prevent driver from sending LQ command between the time + * RXON flags are updated and when LQ command is updated. + */ +static bool il_is_lq_table_valid(struct il_priv *il, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq) +{ + int i; + + if (ctx->ht.enabled) + return true; + + D_INFO("Channel %u is not an HT channel\n", + ctx->active.channel); + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { + if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & + RATE_MCS_HT_MSK) { + D_INFO( + "idx %d of LQ expects HT channel\n", + i); + return false; + } + } + return true; +} + +/** + * il_send_lq_cmd() - Send link quality command + * @init: This command is sent as part of station initialization right + * after station has been added. + * + * The link quality command is sent as the last step of station creation. + * This is the special case in which init is set and we call a callback in + * this case to clear the state indicating that station creation is in + * progress. + */ +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init) +{ + int ret = 0; + unsigned long flags_spin; + + struct il_host_cmd cmd = { + .id = C_TX_LINK_QUALITY_CMD, + .len = sizeof(struct il_link_quality_cmd), + .flags = flags, + .data = lq, + }; + + if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) + return -EINVAL; + + + spin_lock_irqsave(&il->sta_lock, flags_spin); + if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EINVAL; + } + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + il_dump_lq_cmd(il, lq); + BUG_ON(init && (cmd.flags & CMD_ASYNC)); + + if (il_is_lq_table_valid(il, ctx, lq)) + ret = il_send_cmd(il, &cmd); + else + ret = -EINVAL; + + if (cmd.flags & CMD_ASYNC) + return ret; + + if (init) { + D_INFO("init LQ command complete," + " clearing sta addition status for sta %d\n", + lq->sta_id); + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + } + return ret; +} +EXPORT_SYMBOL(il_send_lq_cmd); + +int il_mac_sta_remove(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct il_priv *il = hw->priv; + struct il_station_priv_common *sta_common = (void *)sta->drv_priv; + int ret; + + D_INFO("received request to remove station %pM\n", + sta->addr); + mutex_lock(&il->mutex); + D_INFO("proceeding to remove station %pM\n", + sta->addr); + ret = il_remove_station(il, sta_common->sta_id, sta->addr); + if (ret) + IL_ERR("Error removing station %pM\n", + sta->addr); + mutex_unlock(&il->mutex); + return ret; +} +EXPORT_SYMBOL(il_mac_sta_remove); + +/************************** RX-FUNCTIONS ****************************/ +/* + * Rx theory of operation + * + * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs), + * each of which point to Receive Buffers to be filled by the NIC. These get + * used not only for Rx frames, but for any command response or notification + * from the NIC. The driver and NIC manage the Rx buffers by means + * of idxes into the circular buffer. + * + * Rx Queue Indexes + * The host/firmware share two idx registers for managing the Rx buffers. + * + * The READ idx maps to the first position that the firmware may be writing + * to -- the driver can read up to (but not including) this position and get + * good data. + * The READ idx is managed by the firmware once the card is enabled. + * + * The WRITE idx maps to the last position the driver has read from -- the + * position preceding WRITE is the last slot the firmware can place a packet. + * + * The queue is empty (no good data) if WRITE = READ - 1, and is full if + * WRITE = READ. + * + * During initialization, the host sets up the READ queue position to the first + * IDX position, and WRITE to the last (READ - 1 wrapped) + * + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it + * resets the Rx queue buffers with new memory. + * + * The management in the driver is as follows: + * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When + * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled + * to replenish the iwl->rxq->rx_free. + * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the + * iwl->rxq is replenished and the READ IDX is updated (updating the + * 'processed' and 'read' driver idxes as well) + * + A received packet is processed and handed to the kernel network stack, + * detached from the iwl->rxq. The driver 'processed' idx is updated. + * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free + * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there + * were enough free buffers and RX_STALLED is set it is cleared. + * + * + * Driver sequence: + * + * il_rx_queue_alloc() Allocates rx_free + * il_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il_rx_queue_restock + * il_rx_queue_restock() Moves available buffers from rx_free into Rx + * queue, updates firmware pointers, and updates + * the WRITE idx. If insufficient rx_free buffers + * are available, schedules il_rx_replenish + * + * -- enable interrupts -- + * ISR - il_rx() Detach il_rx_bufs from pool up to the + * READ IDX, detaching the SKB from the pool. + * Moves the packet buffer from queue to rx_used. + * Calls il_rx_queue_restock to refill any empty + * slots. + * ... + * + */ + +/** + * il_rx_queue_space - Return number of free slots available in queue. + */ +int il_rx_queue_space(const struct il_rx_queue *q) +{ + int s = q->read - q->write; + if (s <= 0) + s += RX_QUEUE_SIZE; + /* keep some buffer to not confuse full and empty queue */ + s -= 2; + if (s < 0) + s = 0; + return s; +} +EXPORT_SYMBOL(il_rx_queue_space); + +/** + * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue + */ +void +il_rx_queue_update_write_ptr(struct il_priv *il, + struct il_rx_queue *q) +{ + unsigned long flags; + u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; + u32 reg; + + spin_lock_irqsave(&q->lock, flags); + + if (q->need_update == 0) + goto exit_unlock; + + /* If power-saving is in use, make sure device is awake */ + if (test_bit(S_POWER_PMI, &il->status)) { + reg = _il_rd(il, CSR_UCODE_DRV_GP1); + + if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { + D_INFO( + "Rx queue requesting wakeup," + " GP1 = 0x%x\n", reg); + il_set_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + goto exit_unlock; + } + + q->write_actual = (q->write & ~0x7); + il_wr(il, rx_wrt_ptr_reg, + q->write_actual); + + /* Else device is assumed to be awake */ + } else { + /* Device expects a multiple of 8 */ + q->write_actual = (q->write & ~0x7); + il_wr(il, rx_wrt_ptr_reg, + q->write_actual); + } + + q->need_update = 0; + + exit_unlock: + spin_unlock_irqrestore(&q->lock, flags); +} +EXPORT_SYMBOL(il_rx_queue_update_write_ptr); + +int il_rx_queue_alloc(struct il_priv *il) +{ + struct il_rx_queue *rxq = &il->rxq; + struct device *dev = &il->pci_dev->dev; + int i; + + spin_lock_init(&rxq->lock); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + + /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ + rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, + GFP_KERNEL); + if (!rxq->bd) + goto err_bd; + + rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), + &rxq->rb_stts_dma, GFP_KERNEL); + if (!rxq->rb_stts) + goto err_rb; + + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + rxq->need_update = 0; + return 0; + +err_rb: + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); +err_bd: + return -ENOMEM; +} +EXPORT_SYMBOL(il_rx_queue_alloc); + + +void il_hdl_spectrum_measurement(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); + + if (!report->state) { + D_11H( + "Spectrum Measure Notification: Start\n"); + return; + } + + memcpy(&il->measure_report, report, sizeof(*report)); + il->measurement_status |= MEASUREMENT_READY; +} +EXPORT_SYMBOL(il_hdl_spectrum_measurement); + +/* + * returns non-zero if packet should be dropped + */ +int il_set_decrypted_flag(struct il_priv *il, + struct ieee80211_hdr *hdr, + u32 decrypt_res, + struct ieee80211_rx_status *stats) +{ + u16 fc = le16_to_cpu(hdr->frame_control); + + /* + * All contexts have the same setting here due to it being + * a module parameter, so OK to check any context. + */ + if (il->ctx.active.filter_flags & + RXON_FILTER_DIS_DECRYPT_MSK) + return 0; + + if (!(fc & IEEE80211_FCTL_PROTECTED)) + return 0; + + D_RX("decrypt_res:0x%x\n", decrypt_res); + switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { + case RX_RES_STATUS_SEC_TYPE_TKIP: + /* The uCode has got a bad phase 1 Key, pushes the packet. + * Decryption will be done in SW. */ + if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == + RX_RES_STATUS_BAD_KEY_TTAK) + break; + + case RX_RES_STATUS_SEC_TYPE_WEP: + if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == + RX_RES_STATUS_BAD_ICV_MIC) { + /* bad ICV, the packet is destroyed since the + * decryption is inplace, drop it */ + D_RX("Packet destroyed\n"); + return -1; + } + case RX_RES_STATUS_SEC_TYPE_CCMP: + if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == + RX_RES_STATUS_DECRYPT_OK) { + D_RX("hw decrypt successfully!!!\n"); + stats->flag |= RX_FLAG_DECRYPTED; + } + break; + + default: + break; + } + return 0; +} +EXPORT_SYMBOL(il_set_decrypted_flag); + +/** + * il_txq_update_write_ptr - Send new write idx to hardware + */ +void +il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) +{ + u32 reg = 0; + int txq_id = txq->q.id; + + if (txq->need_update == 0) + return; + + /* if we're trying to save power */ + if (test_bit(S_POWER_PMI, &il->status)) { + /* wake up nic if it's powered down ... + * uCode will wake up, and interrupt us again, so next + * time we'll skip this part. */ + reg = _il_rd(il, CSR_UCODE_DRV_GP1); + + if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { + D_INFO( + "Tx queue %d requesting wakeup," + " GP1 = 0x%x\n", txq_id, reg); + il_set_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + return; + } + + il_wr(il, HBUS_TARG_WRPTR, + txq->q.write_ptr | (txq_id << 8)); + + /* + * else not in power-save mode, + * uCode will never sleep when we're + * trying to tx (during RFKILL, we're not trying to tx). + */ + } else + _il_wr(il, HBUS_TARG_WRPTR, + txq->q.write_ptr | (txq_id << 8)); + txq->need_update = 0; +} +EXPORT_SYMBOL(il_txq_update_write_ptr); + +/** + * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's + */ +void il_tx_queue_unmap(struct il_priv *il, int txq_id) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + + if (q->n_bd == 0) + return; + + while (q->write_ptr != q->read_ptr) { + il->cfg->ops->lib->txq_free_tfd(il, txq); + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); + } +} +EXPORT_SYMBOL(il_tx_queue_unmap); + +/** + * il_tx_queue_free - Deallocate DMA queue. + * @txq: Transmit queue to deallocate. + * + * Empty queue by removing and destroying all BD's. + * Free all buffers. + * 0-fill, but do not free "txq" descriptor structure. + */ +void il_tx_queue_free(struct il_priv *il, int txq_id) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct device *dev = &il->pci_dev->dev; + int i; + + il_tx_queue_unmap(il, txq_id); + + /* De-alloc array of command/tx buffers */ + for (i = 0; i < TFD_TX_CMD_SLOTS; i++) + kfree(txq->cmd[i]); + + /* De-alloc circular buffer of TFDs */ + if (txq->q.n_bd) + dma_free_coherent(dev, il->hw_params.tfd_size * + txq->q.n_bd, txq->tfds, txq->q.dma_addr); + + /* De-alloc array of per-TFD driver data */ + kfree(txq->txb); + txq->txb = NULL; + + /* deallocate arrays */ + kfree(txq->cmd); + kfree(txq->meta); + txq->cmd = NULL; + txq->meta = NULL; + + /* 0-fill queue descriptor structure */ + memset(txq, 0, sizeof(*txq)); +} +EXPORT_SYMBOL(il_tx_queue_free); + +/** + * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue + */ +void il_cmd_queue_unmap(struct il_priv *il) +{ + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct il_queue *q = &txq->q; + int i; + + if (q->n_bd == 0) + return; + + while (q->read_ptr != q->write_ptr) { + i = il_get_cmd_idx(q, q->read_ptr, 0); + + if (txq->meta[i].flags & CMD_MAPPED) { + pci_unmap_single(il->pci_dev, + dma_unmap_addr(&txq->meta[i], mapping), + dma_unmap_len(&txq->meta[i], len), + PCI_DMA_BIDIRECTIONAL); + txq->meta[i].flags = 0; + } + + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); + } + + i = q->n_win; + if (txq->meta[i].flags & CMD_MAPPED) { + pci_unmap_single(il->pci_dev, + dma_unmap_addr(&txq->meta[i], mapping), + dma_unmap_len(&txq->meta[i], len), + PCI_DMA_BIDIRECTIONAL); + txq->meta[i].flags = 0; + } +} +EXPORT_SYMBOL(il_cmd_queue_unmap); + +/** + * il_cmd_queue_free - Deallocate DMA queue. + * @txq: Transmit queue to deallocate. + * + * Empty queue by removing and destroying all BD's. + * Free all buffers. + * 0-fill, but do not free "txq" descriptor structure. + */ +void il_cmd_queue_free(struct il_priv *il) +{ + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct device *dev = &il->pci_dev->dev; + int i; + + il_cmd_queue_unmap(il); + + /* De-alloc array of command/tx buffers */ + for (i = 0; i <= TFD_CMD_SLOTS; i++) + kfree(txq->cmd[i]); + + /* De-alloc circular buffer of TFDs */ + if (txq->q.n_bd) + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, + txq->tfds, txq->q.dma_addr); + + /* deallocate arrays */ + kfree(txq->cmd); + kfree(txq->meta); + txq->cmd = NULL; + txq->meta = NULL; + + /* 0-fill queue descriptor structure */ + memset(txq, 0, sizeof(*txq)); +} +EXPORT_SYMBOL(il_cmd_queue_free); + +/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** + * DMA services + * + * Theory of operation + * + * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer + * of buffer descriptors, each of which points to one or more data buffers for + * the device to read from or fill. Driver and device exchange status of each + * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty + * entries in each circular buffer, to protect against confusing empty and full + * queue states. + * + * The device reads or writes the data in the queues via the device's several + * DMA/FIFO channels. Each queue is mapped to a single DMA channel. + * + * For Tx queue, there are low mark and high mark limits. If, after queuing + * the packet for Tx, free space become < low mark, Tx queue stopped. When + * reclaiming packets (on 'tx done IRQ), if free space become > high mark, + * Tx queue resumed. + * + * See more detailed info in 4965.h. + ***************************************************/ + +int il_queue_space(const struct il_queue *q) +{ + int s = q->read_ptr - q->write_ptr; + + if (q->read_ptr > q->write_ptr) + s -= q->n_bd; + + if (s <= 0) + s += q->n_win; + /* keep some reserve to not confuse empty and full situations */ + s -= 2; + if (s < 0) + s = 0; + return s; +} +EXPORT_SYMBOL(il_queue_space); + + +/** + * il_queue_init - Initialize queue's high/low-water and read/write idxes + */ +static int il_queue_init(struct il_priv *il, struct il_queue *q, + int count, int slots_num, u32 id) +{ + q->n_bd = count; + q->n_win = slots_num; + q->id = id; + + /* count must be power-of-two size, otherwise il_queue_inc_wrap + * and il_queue_dec_wrap are broken. */ + BUG_ON(!is_power_of_2(count)); + + /* slots_num must be power-of-two size, otherwise + * il_get_cmd_idx is broken. */ + BUG_ON(!is_power_of_2(slots_num)); + + q->low_mark = q->n_win / 4; + if (q->low_mark < 4) + q->low_mark = 4; + + q->high_mark = q->n_win / 8; + if (q->high_mark < 2) + q->high_mark = 2; + + q->write_ptr = q->read_ptr = 0; + + return 0; +} + +/** + * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue + */ +static int il_tx_queue_alloc(struct il_priv *il, + struct il_tx_queue *txq, u32 id) +{ + struct device *dev = &il->pci_dev->dev; + size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; + + /* Driver ilate data, only for Tx (not command) queues, + * not shared with device. */ + if (id != il->cmd_queue) { + txq->txb = kzalloc(sizeof(txq->txb[0]) * + TFD_QUEUE_SIZE_MAX, GFP_KERNEL); + if (!txq->txb) { + IL_ERR("kmalloc for auxiliary BD " + "structures failed\n"); + goto error; + } + } else { + txq->txb = NULL; + } + + /* Circular buffer of transmit frame descriptors (TFDs), + * shared with device */ + txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, + GFP_KERNEL); + if (!txq->tfds) { + IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); + goto error; + } + txq->q.id = id; + + return 0; + + error: + kfree(txq->txb); + txq->txb = NULL; + + return -ENOMEM; +} + +/** + * il_tx_queue_init - Allocate and initialize one tx/cmd queue + */ +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id) +{ + int i, len; + int ret; + int actual_slots = slots_num; + + /* + * Alloc buffer array for commands (Tx or other types of commands). + * For the command queue (#4/#9), allocate command space + one big + * command for scan, since scan command is very huge; the system will + * not have two scans at the same time, so only one is needed. + * For normal Tx queues (all other queues), no super-size command + * space is needed. + */ + if (txq_id == il->cmd_queue) + actual_slots++; + + txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, + GFP_KERNEL); + txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, + GFP_KERNEL); + + if (!txq->meta || !txq->cmd) + goto out_free_arrays; + + len = sizeof(struct il_device_cmd); + for (i = 0; i < actual_slots; i++) { + /* only happens for cmd queue */ + if (i == slots_num) + len = IL_MAX_CMD_SIZE; + + txq->cmd[i] = kmalloc(len, GFP_KERNEL); + if (!txq->cmd[i]) + goto err; + } + + /* Alloc driver data array and TFD circular buffer */ + ret = il_tx_queue_alloc(il, txq, txq_id); + if (ret) + goto err; + + txq->need_update = 0; + + /* + * For the default queues 0-3, set up the swq_id + * already -- all others need to get one later + * (if they need one at all). + */ + if (txq_id < 4) + il_set_swq_id(txq, txq_id, txq_id); + + /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise + * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ + BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); + + /* Initialize queue's high/low-water marks, and head/tail idxes */ + il_queue_init(il, &txq->q, + TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + + /* Tell device where to find queue */ + il->cfg->ops->lib->txq_init(il, txq); + + return 0; +err: + for (i = 0; i < actual_slots; i++) + kfree(txq->cmd[i]); +out_free_arrays: + kfree(txq->meta); + kfree(txq->cmd); + + return -ENOMEM; +} +EXPORT_SYMBOL(il_tx_queue_init); + +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id) +{ + int actual_slots = slots_num; + + if (txq_id == il->cmd_queue) + actual_slots++; + + memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); + + txq->need_update = 0; + + /* Initialize queue's high/low-water marks, and head/tail idxes */ + il_queue_init(il, &txq->q, + TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + + /* Tell device where to find queue */ + il->cfg->ops->lib->txq_init(il, txq); +} +EXPORT_SYMBOL(il_tx_queue_reset); + +/*************** HOST COMMAND QUEUE FUNCTIONS *****/ + +/** + * il_enqueue_hcmd - enqueue a uCode command + * @il: device ilate data point + * @cmd: a point to the ucode command structure + * + * The function returns < 0 values to indicate the operation is + * failed. On success, it turns the idx (> 0) of command in the + * command queue. + */ +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) +{ + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct il_queue *q = &txq->q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + dma_addr_t phys_addr; + unsigned long flags; + int len; + u32 idx; + u16 fix_size; + + cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); + fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); + + /* If any of the command structures end up being larger than + * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then + * we will need to increase the size of the TFD entries + * Also, check to see if command buffer should not exceed the size + * of device_cmd and max_cmd_size. */ + BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && + !(cmd->flags & CMD_SIZE_HUGE)); + BUG_ON(fix_size > IL_MAX_CMD_SIZE); + + if (il_is_rfkill(il) || il_is_ctkill(il)) { + IL_WARN("Not sending command - %s KILL\n", + il_is_rfkill(il) ? "RF" : "CT"); + return -EIO; + } + + spin_lock_irqsave(&il->hcmd_lock, flags); + + if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { + spin_unlock_irqrestore(&il->hcmd_lock, flags); + + IL_ERR("Restarting adapter due to command queue full\n"); + queue_work(il->workqueue, &il->restart); + return -ENOSPC; + } + + idx = il_get_cmd_idx(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); + out_cmd = txq->cmd[idx]; + out_meta = &txq->meta[idx]; + + if (WARN_ON(out_meta->flags & CMD_MAPPED)) { + spin_unlock_irqrestore(&il->hcmd_lock, flags); + return -ENOSPC; + } + + memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */ + out_meta->flags = cmd->flags | CMD_MAPPED; + if (cmd->flags & CMD_WANT_SKB) + out_meta->source = cmd; + if (cmd->flags & CMD_ASYNC) + out_meta->callback = cmd->callback; + + out_cmd->hdr.cmd = cmd->id; + memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); + + /* At this point, the out_cmd now has all of the incoming cmd + * information */ + + out_cmd->hdr.flags = 0; + out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | + IDX_TO_SEQ(q->write_ptr)); + if (cmd->flags & CMD_SIZE_HUGE) + out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; + len = sizeof(struct il_device_cmd); + if (idx == TFD_CMD_SLOTS) + len = IL_MAX_CMD_SIZE; + +#ifdef CONFIG_IWLEGACY_DEBUG + switch (out_cmd->hdr.cmd) { + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: + D_HC_DUMP( + "Sending command %s (#%x), seq: 0x%04X, " + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), + out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, + q->write_ptr, idx, il->cmd_queue); + break; + default: + D_HC("Sending command %s (#%x), seq: 0x%04X, " + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), + out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, + q->write_ptr, idx, il->cmd_queue); + } +#endif + txq->need_update = 1; + + if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) + /* Set up entry in queue's byte count circular buffer */ + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); + + phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, + fix_size, PCI_DMA_BIDIRECTIONAL); + dma_unmap_addr_set(out_meta, mapping, phys_addr); + dma_unmap_len_set(out_meta, len, fix_size); + + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + phys_addr, fix_size, 1, + U32_PAD(cmd->len)); + + /* Increment and update queue's write idx */ + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(il, txq); + + spin_unlock_irqrestore(&il->hcmd_lock, flags); + return idx; +} + +/** + * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd + * + * When FW advances 'R' idx, all entries between old and new 'R' idx + * need to be reclaimed. As result, some free space forms. If there is + * enough free space (> low mark), wake the stack that feeds us. + */ +static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, + int idx, int cmd_idx) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + int nfreed = 0; + + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " + "is out of range [0-%d] %d %d.\n", txq_id, + idx, q->n_bd, q->write_ptr, q->read_ptr); + return; + } + + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + + if (nfreed++ > 0) { + IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, + q->write_ptr, q->read_ptr); + queue_work(il->workqueue, &il->restart); + } + + } +} + +/** + * il_tx_cmd_complete - Pull unused buffers off the queue and reclaim them + * @rxb: Rx buffer to reclaim + * + * If an Rx buffer has an async callback associated with it the callback + * will be executed. The attached skb (if present) will only be freed + * if the callback returns 1 + */ +void +il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int txq_id = SEQ_TO_QUEUE(sequence); + int idx = SEQ_TO_IDX(sequence); + int cmd_idx; + bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); + struct il_device_cmd *cmd; + struct il_cmd_meta *meta; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + unsigned long flags; + + /* If a Tx command is being handled and it isn't in the actual + * command queue then there a command routing bug has been introduced + * in the queue management code. */ + if (WARN(txq_id != il->cmd_queue, + "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", + txq_id, il->cmd_queue, sequence, + il->txq[il->cmd_queue].q.read_ptr, + il->txq[il->cmd_queue].q.write_ptr)) { + il_print_hex_error(il, pkt, 32); + return; + } + + cmd_idx = il_get_cmd_idx(&txq->q, idx, huge); + cmd = txq->cmd[cmd_idx]; + meta = &txq->meta[cmd_idx]; + + txq->time_stamp = jiffies; + + pci_unmap_single(il->pci_dev, + dma_unmap_addr(meta, mapping), + dma_unmap_len(meta, len), + PCI_DMA_BIDIRECTIONAL); + + /* Input error checking is done when commands are added to queue. */ + if (meta->flags & CMD_WANT_SKB) { + meta->source->reply_page = (unsigned long)rxb_addr(rxb); + rxb->page = NULL; + } else if (meta->callback) + meta->callback(il, cmd, pkt); + + spin_lock_irqsave(&il->hcmd_lock, flags); + + il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); + + if (!(meta->flags & CMD_ASYNC)) { + clear_bit(S_HCMD_ACTIVE, &il->status); + D_INFO("Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->hdr.cmd)); + wake_up(&il->wait_command_queue); + } + + /* Mark as unmapped */ + meta->flags = 0; + + spin_unlock_irqrestore(&il->hcmd_lock, flags); +} +EXPORT_SYMBOL(il_tx_cmd_complete); MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965"); MODULE_VERSION(IWLWIFI_VERSION); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c deleted file mode 100644 index ee5ad69..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ /dev/null @@ -1,553 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include "iwl-commands.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" -#include "iwl-eeprom.h" -#include "iwl-io.h" - -/************************** EEPROM BANDS **************************** - * - * The il_eeprom_band definitions below provide the mapping from the - * EEPROM contents to the specific channel number supported for each - * band. - * - * For example, il_priv->eeprom.band_3_channels[4] from the band_3 - * definition below maps to physical channel 42 in the 5.2GHz spectrum. - * The specific geography and calibration information for that channel - * is contained in the eeprom map itself. - * - * During init, we copy the eeprom information and channel map - * information into il->channel_info_24/52 and il->channel_map_24/52 - * - * channel_map_24/52 provides the idx in the channel_info array for a - * given channel. We have to have two separate maps as there is channel - * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and - * band_2 - * - * A value of 0xff stored in the channel_map indicates that the channel - * is not supported by the hardware at all. - * - * A value of 0xfe in the channel_map indicates that the channel is not - * valid for Tx with the current hardware. This means that - * while the system can tune and receive on a given channel, it may not - * be able to associate or transmit any frames on that - * channel. There is no corresponding channel information for that - * entry. - * - *********************************************************************/ - -/* 2.4 GHz */ -const u8 il_eeprom_band_1[14] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 -}; - -/* 5.2 GHz bands */ -static const u8 il_eeprom_band_2[] = { /* 4915-5080MHz */ - 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 -}; - -static const u8 il_eeprom_band_3[] = { /* 5170-5320MHz */ - 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 -}; - -static const u8 il_eeprom_band_4[] = { /* 5500-5700MHz */ - 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 -}; - -static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ - 145, 149, 153, 157, 161, 165 -}; - -static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ - 1, 2, 3, 4, 5, 6, 7 -}; - -static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ - 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 -}; - -/****************************************************************************** - * - * EEPROM related functions - * -******************************************************************************/ - -static int il_eeprom_verify_signature(struct il_priv *il) -{ - u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; - int ret = 0; - - D_EEPROM("EEPROM signature=0x%08x\n", gp); - switch (gp) { - case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: - case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: - break; - default: - IL_ERR("bad EEPROM signature," - "EEPROM_GP=0x%08x\n", gp); - ret = -ENOENT; - break; - } - return ret; -} - -const u8 -*il_eeprom_query_addr(const struct il_priv *il, size_t offset) -{ - BUG_ON(offset >= il->cfg->base_params->eeprom_size); - return &il->eeprom[offset]; -} -EXPORT_SYMBOL(il_eeprom_query_addr); - -u16 il_eeprom_query16(const struct il_priv *il, size_t offset) -{ - if (!il->eeprom) - return 0; - return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); -} -EXPORT_SYMBOL(il_eeprom_query16); - -/** - * il_eeprom_init - read EEPROM contents - * - * Load the EEPROM contents from adapter into il->eeprom - * - * NOTE: This routine uses the non-debug IO access functions. - */ -int il_eeprom_init(struct il_priv *il) -{ - __le16 *e; - u32 gp = _il_rd(il, CSR_EEPROM_GP); - int sz; - int ret; - u16 addr; - - /* allocate eeprom */ - sz = il->cfg->base_params->eeprom_size; - D_EEPROM("NVM size = %d\n", sz); - il->eeprom = kzalloc(sz, GFP_KERNEL); - if (!il->eeprom) { - ret = -ENOMEM; - goto alloc_err; - } - e = (__le16 *)il->eeprom; - - il->cfg->ops->lib->apm_ops.init(il); - - ret = il_eeprom_verify_signature(il); - if (ret < 0) { - IL_ERR("EEPROM not found, EEPROM_GP=0x%08x\n", gp); - ret = -ENOENT; - goto err; - } - - /* Make sure driver (instead of uCode) is allowed to read EEPROM */ - ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); - if (ret < 0) { - IL_ERR("Failed to acquire EEPROM semaphore.\n"); - ret = -ENOENT; - goto err; - } - - /* eeprom is an array of 16bit values */ - for (addr = 0; addr < sz; addr += sizeof(u16)) { - u32 r; - - _il_wr(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - - ret = _il_poll_bit(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_READ_VALID_MSK, - CSR_EEPROM_REG_READ_VALID_MSK, - IL_EEPROM_ACCESS_TIMEOUT); - if (ret < 0) { - IL_ERR("Time out reading EEPROM[%d]\n", - addr); - goto done; - } - r = _il_rd(il, CSR_EEPROM_REG); - e[addr / 2] = cpu_to_le16(r >> 16); - } - - D_EEPROM("NVM Type: %s, version: 0x%x\n", - "EEPROM", - il_eeprom_query16(il, EEPROM_VERSION)); - - ret = 0; -done: - il->cfg->ops->lib->eeprom_ops.release_semaphore(il); - -err: - if (ret) - il_eeprom_free(il); - /* Reset chip to save power until we load uCode during "up". */ - il_apm_stop(il); -alloc_err: - return ret; -} -EXPORT_SYMBOL(il_eeprom_init); - -void il_eeprom_free(struct il_priv *il) -{ - kfree(il->eeprom); - il->eeprom = NULL; -} -EXPORT_SYMBOL(il_eeprom_free); - -static void il_init_band_reference(const struct il_priv *il, - int eep_band, int *eeprom_ch_count, - const struct il_eeprom_channel **eeprom_ch_info, - const u8 **eeprom_ch_idx) -{ - u32 offset = il->cfg->ops->lib-> - eeprom_ops.regulatory_bands[eep_band - 1]; - switch (eep_band) { - case 1: /* 2.4GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_1; - break; - case 2: /* 4.9GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_2; - break; - case 3: /* 5.2GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_3; - break; - case 4: /* 5.5GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_4; - break; - case 5: /* 5.7GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_5; - break; - case 6: /* 2.4GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_6; - break; - case 7: /* 5 GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_7; - break; - default: - BUG(); - } -} - -#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ - ? # x " " : "") -/** - * il_mod_ht40_chan_info - Copy ht40 channel info into driver's il. - * - * Does not set up a command, or touch hardware. - */ -static int il_mod_ht40_chan_info(struct il_priv *il, - enum ieee80211_band band, u16 channel, - const struct il_eeprom_channel *eeprom_ch, - u8 clear_ht40_extension_channel) -{ - struct il_channel_info *ch_info; - - ch_info = (struct il_channel_info *) - il_get_channel_info(il, band, channel); - - if (!il_is_channel_valid(ch_info)) - return -1; - - D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT(IBSS), - CHECK_AND_PRINT(ACTIVE), - CHECK_AND_PRINT(RADAR), - CHECK_AND_PRINT(WIDE), - CHECK_AND_PRINT(DFS), - eeprom_ch->flags, - eeprom_ch->max_power_avg, - ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? - "" : "not "); - - ch_info->ht40_eeprom = *eeprom_ch; - ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; - ch_info->ht40_flags = eeprom_ch->flags; - if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) - ch_info->ht40_extension_channel &= - ~clear_ht40_extension_channel; - - return 0; -} - -#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \ - ? # x " " : "") - -/** - * il_init_channel_map - Set up driver's info for all possible channels - */ -int il_init_channel_map(struct il_priv *il) -{ - int eeprom_ch_count = 0; - const u8 *eeprom_ch_idx = NULL; - const struct il_eeprom_channel *eeprom_ch_info = NULL; - int band, ch; - struct il_channel_info *ch_info; - - if (il->channel_count) { - D_EEPROM("Channel map already initialized.\n"); - return 0; - } - - D_EEPROM("Initializing regulatory info from EEPROM\n"); - - il->channel_count = - ARRAY_SIZE(il_eeprom_band_1) + - ARRAY_SIZE(il_eeprom_band_2) + - ARRAY_SIZE(il_eeprom_band_3) + - ARRAY_SIZE(il_eeprom_band_4) + - ARRAY_SIZE(il_eeprom_band_5); - - D_EEPROM("Parsing data for %d channels.\n", - il->channel_count); - - il->channel_info = kzalloc(sizeof(struct il_channel_info) * - il->channel_count, GFP_KERNEL); - if (!il->channel_info) { - IL_ERR("Could not allocate channel_info\n"); - il->channel_count = 0; - return -ENOMEM; - } - - ch_info = il->channel_info; - - /* Loop through the 5 EEPROM bands adding them in order to the - * channel map we maintain (that contains additional information than - * what just in the EEPROM) */ - for (band = 1; band <= 5; band++) { - - il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); - - /* Loop through each band adding each of the channels */ - for (ch = 0; ch < eeprom_ch_count; ch++) { - ch_info->channel = eeprom_ch_idx[ch]; - ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : - IEEE80211_BAND_5GHZ; - - /* permanently store EEPROM's channel regulatory flags - * and max power in channel info database. */ - ch_info->eeprom = eeprom_ch_info[ch]; - - /* Copy the run-time flags so they are there even on - * invalid channels */ - ch_info->flags = eeprom_ch_info[ch].flags; - /* First write that ht40 is not enabled, and then enable - * one by one */ - ch_info->ht40_extension_channel = - IEEE80211_CHAN_NO_HT40; - - if (!(il_is_channel_valid(ch_info))) { - D_EEPROM( - "Ch. %d Flags %x [%sGHz] - " - "No traffic\n", - ch_info->channel, - ch_info->flags, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4"); - ch_info++; - continue; - } - - /* Initialize regulatory-based run-time data */ - ch_info->max_power_avg = ch_info->curr_txpow = - eeprom_ch_info[ch].max_power_avg; - ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; - ch_info->min_power = 0; - - D_EEPROM("Ch. %d [%sGHz] " - "%s%s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT_I(VALID), - CHECK_AND_PRINT_I(IBSS), - CHECK_AND_PRINT_I(ACTIVE), - CHECK_AND_PRINT_I(RADAR), - CHECK_AND_PRINT_I(WIDE), - CHECK_AND_PRINT_I(DFS), - eeprom_ch_info[ch].flags, - eeprom_ch_info[ch].max_power_avg, - ((eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_RADAR)) - ? "" : "not "); - - ch_info++; - } - } - - /* Check if we do have HT40 channels */ - if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == - EEPROM_REGULATORY_BAND_NO_HT40 && - il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == - EEPROM_REGULATORY_BAND_NO_HT40) - return 0; - - /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */ - for (band = 6; band <= 7; band++) { - enum ieee80211_band ieeeband; - - il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); - - /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ - ieeeband = - (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; - - /* Loop through each band adding each of the channels */ - for (ch = 0; ch < eeprom_ch_count; ch++) { - /* Set up driver's info for lower half */ - il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch], - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40PLUS); - - /* Set up driver's info for upper half */ - il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch] + 4, - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40MINUS); - } - } - - return 0; -} -EXPORT_SYMBOL(il_init_channel_map); - -/* - * il_free_channel_map - undo allocations in il_init_channel_map - */ -void il_free_channel_map(struct il_priv *il) -{ - kfree(il->channel_info); - il->channel_count = 0; -} -EXPORT_SYMBOL(il_free_channel_map); - -/** - * il_get_channel_info - Find driver's ilate channel info - * - * Based on band and channel number. - */ -const struct -il_channel_info *il_get_channel_info(const struct il_priv *il, - enum ieee80211_band band, u16 channel) -{ - int i; - - switch (band) { - case IEEE80211_BAND_5GHZ: - for (i = 14; i < il->channel_count; i++) { - if (il->channel_info[i].channel == channel) - return &il->channel_info[i]; - } - break; - case IEEE80211_BAND_2GHZ: - if (channel >= 1 && channel <= 14) - return &il->channel_info[channel - 1]; - break; - default: - BUG(); - } - - return NULL; -} -EXPORT_SYMBOL(il_get_channel_info); diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c deleted file mode 100644 index 670a398..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ /dev/null @@ -1,271 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-debug.h" -#include "iwl-eeprom.h" -#include "iwl-core.h" - - -const char *il_get_cmd_string(u8 cmd) -{ - switch (cmd) { - IL_CMD(N_ALIVE); - IL_CMD(N_ERROR); - IL_CMD(C_RXON); - IL_CMD(C_RXON_ASSOC); - IL_CMD(C_QOS_PARAM); - IL_CMD(C_RXON_TIMING); - IL_CMD(C_ADD_STA); - IL_CMD(C_REM_STA); - IL_CMD(C_WEPKEY); - IL_CMD(N_3945_RX); - IL_CMD(C_TX); - IL_CMD(C_RATE_SCALE); - IL_CMD(C_LEDS); - IL_CMD(C_TX_LINK_QUALITY_CMD); - IL_CMD(C_CHANNEL_SWITCH); - IL_CMD(N_CHANNEL_SWITCH); - IL_CMD(C_SPECTRUM_MEASUREMENT); - IL_CMD(N_SPECTRUM_MEASUREMENT); - IL_CMD(C_POWER_TBL); - IL_CMD(N_PM_SLEEP); - IL_CMD(N_PM_DEBUG_STATS); - IL_CMD(C_SCAN); - IL_CMD(C_SCAN_ABORT); - IL_CMD(N_SCAN_START); - IL_CMD(N_SCAN_RESULTS); - IL_CMD(N_SCAN_COMPLETE); - IL_CMD(N_BEACON); - IL_CMD(C_TX_BEACON); - IL_CMD(C_TX_PWR_TBL); - IL_CMD(C_BT_CONFIG); - IL_CMD(C_STATS); - IL_CMD(N_STATS); - IL_CMD(N_CARD_STATE); - IL_CMD(N_MISSED_BEACONS); - IL_CMD(C_CT_KILL_CONFIG); - IL_CMD(C_SENSITIVITY); - IL_CMD(C_PHY_CALIBRATION); - IL_CMD(N_RX_PHY); - IL_CMD(N_RX_MPDU); - IL_CMD(N_RX); - IL_CMD(N_COMPRESSED_BA); - default: - return "UNKNOWN"; - - } -} -EXPORT_SYMBOL(il_get_cmd_string); - -#define HOST_COMPLETE_TIMEOUT (HZ / 2) - -static void il_generic_cmd_callback(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt) -{ - if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); - return; - } - -#ifdef CONFIG_IWLEGACY_DEBUG - switch (cmd->hdr.cmd) { - case C_TX_LINK_QUALITY_CMD: - case C_SENSITIVITY: - D_HC_DUMP("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); - break; - default: - D_HC("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); - } -#endif -} - -static int -il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) -{ - int ret; - - BUG_ON(!(cmd->flags & CMD_ASYNC)); - - /* An asynchronous command can not expect an SKB to be set. */ - BUG_ON(cmd->flags & CMD_WANT_SKB); - - /* Assign a generic callback if one is not provided */ - if (!cmd->callback) - cmd->callback = il_generic_cmd_callback; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return -EBUSY; - - ret = il_enqueue_hcmd(il, cmd); - if (ret < 0) { - IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); - return ret; - } - return 0; -} - -int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) -{ - int cmd_idx; - int ret; - - lockdep_assert_held(&il->mutex); - - BUG_ON(cmd->flags & CMD_ASYNC); - - /* A synchronous command can not have a callback set. */ - BUG_ON(cmd->callback); - - D_INFO("Attempting to send sync command %s\n", - il_get_cmd_string(cmd->id)); - - set_bit(S_HCMD_ACTIVE, &il->status); - D_INFO("Setting HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); - - cmd_idx = il_enqueue_hcmd(il, cmd); - if (cmd_idx < 0) { - ret = cmd_idx; - IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); - goto out; - } - - ret = wait_event_timeout(il->wait_command_queue, - !test_bit(S_HCMD_ACTIVE, &il->status), - HOST_COMPLETE_TIMEOUT); - if (!ret) { - if (test_bit(S_HCMD_ACTIVE, &il->status)) { - IL_ERR( - "Error sending %s: time out after %dms.\n", - il_get_cmd_string(cmd->id), - jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - - clear_bit(S_HCMD_ACTIVE, &il->status); - D_INFO( - "Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); - ret = -ETIMEDOUT; - goto cancel; - } - } - - if (test_bit(S_RF_KILL_HW, &il->status)) { - IL_ERR("Command %s aborted: RF KILL Switch\n", - il_get_cmd_string(cmd->id)); - ret = -ECANCELED; - goto fail; - } - if (test_bit(S_FW_ERROR, &il->status)) { - IL_ERR("Command %s failed: FW Error\n", - il_get_cmd_string(cmd->id)); - ret = -EIO; - goto fail; - } - if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IL_ERR("Error: Response NULL in '%s'\n", - il_get_cmd_string(cmd->id)); - ret = -EIO; - goto cancel; - } - - ret = 0; - goto out; - -cancel: - if (cmd->flags & CMD_WANT_SKB) { - /* - * Cancel the CMD_WANT_SKB flag for the cmd in the - * TX cmd queue. Otherwise in case the cmd comes - * in later, it will possibly set an invalid - * address (cmd->meta.source). - */ - il->txq[il->cmd_queue].meta[cmd_idx].flags &= - ~CMD_WANT_SKB; - } -fail: - if (cmd->reply_page) { - il_free_pages(il, cmd->reply_page); - cmd->reply_page = 0; - } -out: - return ret; -} -EXPORT_SYMBOL(il_send_cmd_sync); - -int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) -{ - if (cmd->flags & CMD_ASYNC) - return il_send_cmd_async(il, cmd); - - return il_send_cmd_sync(il, cmd); -} -EXPORT_SYMBOL(il_send_cmd); - -int -il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) -{ - struct il_host_cmd cmd = { - .id = id, - .len = len, - .data = data, - }; - - return il_send_cmd_sync(il, &cmd); -} -EXPORT_SYMBOL(il_send_cmd_pdu); - -int il_send_cmd_pdu_async(struct il_priv *il, - u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)) -{ - struct il_host_cmd cmd = { - .id = id, - .len = len, - .data = data, - }; - - cmd.flags |= CMD_ASYNC; - cmd.callback = callback; - - return il_send_cmd_async(il, &cmd); -} -EXPORT_SYMBOL(il_send_cmd_pdu_async); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c deleted file mode 100644 index a840c2e..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ /dev/null @@ -1,205 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" - -/* default: IL_LED_BLINK(0) using blinking idx table */ -static int led_mode; -module_param(led_mode, int, S_IRUGO); -MODULE_PARM_DESC(led_mode, "0=system default, " - "1=On(RF On)/Off(RF Off), 2=blinking"); - -/* Throughput OFF time(ms) ON time (ms) - * >300 25 25 - * >200 to 300 40 40 - * >100 to 200 55 55 - * >70 to 100 65 65 - * >50 to 70 75 75 - * >20 to 50 85 85 - * >10 to 20 95 95 - * >5 to 10 110 110 - * >1 to 5 130 130 - * >0 to 1 167 167 - * <=0 SOLID ON - */ -static const struct ieee80211_tpt_blink il_blink[] = { - { .throughput = 0, .blink_time = 334 }, - { .throughput = 1 * 1024 - 1, .blink_time = 260 }, - { .throughput = 5 * 1024 - 1, .blink_time = 220 }, - { .throughput = 10 * 1024 - 1, .blink_time = 190 }, - { .throughput = 20 * 1024 - 1, .blink_time = 170 }, - { .throughput = 50 * 1024 - 1, .blink_time = 150 }, - { .throughput = 70 * 1024 - 1, .blink_time = 130 }, - { .throughput = 100 * 1024 - 1, .blink_time = 110 }, - { .throughput = 200 * 1024 - 1, .blink_time = 80 }, - { .throughput = 300 * 1024 - 1, .blink_time = 50 }, -}; - -/* - * Adjust led blink rate to compensate on a MAC Clock difference on every HW - * Led blink rate analysis showed an average deviation of 0% on 3945, - * 5% on 4965 HW. - * Need to compensate on the led on/off time per HW according to the deviation - * to achieve the desired led frequency - * The calculation is: (100-averageDeviation)/100 * blinkTime - * For code efficiency the calculation will be: - * compensation = (100 - averageDeviation) * 64 / 100 - * NewBlinkTime = (compensation * BlinkTime) / 64 - */ -static inline u8 il_blink_compensation(struct il_priv *il, - u8 time, u16 compensation) -{ - if (!compensation) { - IL_ERR("undefined blink compensation: " - "use pre-defined blinking time\n"); - return time; - } - - return (u8)((time * compensation) >> 6); -} - -/* Set led pattern command */ -static int il_led_cmd(struct il_priv *il, - unsigned long on, - unsigned long off) -{ - struct il_led_cmd led_cmd = { - .id = IL_LED_LINK, - .interval = IL_DEF_LED_INTRVL - }; - int ret; - - if (!test_bit(S_READY, &il->status)) - return -EBUSY; - - if (il->blink_on == on && il->blink_off == off) - return 0; - - if (off == 0) { - /* led is SOLID_ON */ - on = IL_LED_SOLID; - } - - D_LED("Led blink time compensation=%u\n", - il->cfg->base_params->led_compensation); - led_cmd.on = il_blink_compensation(il, on, - il->cfg->base_params->led_compensation); - led_cmd.off = il_blink_compensation(il, off, - il->cfg->base_params->led_compensation); - - ret = il->cfg->ops->led->cmd(il, &led_cmd); - if (!ret) { - il->blink_on = on; - il->blink_off = off; - } - return ret; -} - -static void il_led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - struct il_priv *il = container_of(led_cdev, struct il_priv, led); - unsigned long on = 0; - - if (brightness > 0) - on = IL_LED_SOLID; - - il_led_cmd(il, on, 0); -} - -static int il_led_blink_set(struct led_classdev *led_cdev, - unsigned long *delay_on, - unsigned long *delay_off) -{ - struct il_priv *il = container_of(led_cdev, struct il_priv, led); - - return il_led_cmd(il, *delay_on, *delay_off); -} - -void il_leds_init(struct il_priv *il) -{ - int mode = led_mode; - int ret; - - if (mode == IL_LED_DEFAULT) - mode = il->cfg->led_mode; - - il->led.name = kasprintf(GFP_KERNEL, "%s-led", - wiphy_name(il->hw->wiphy)); - il->led.brightness_set = il_led_brightness_set; - il->led.blink_set = il_led_blink_set; - il->led.max_brightness = 1; - - switch (mode) { - case IL_LED_DEFAULT: - WARN_ON(1); - break; - case IL_LED_BLINK: - il->led.default_trigger = - ieee80211_create_tpt_led_trigger(il->hw, - IEEE80211_TPT_LEDTRIG_FL_CONNECTED, - il_blink, ARRAY_SIZE(il_blink)); - break; - case IL_LED_RF_STATE: - il->led.default_trigger = - ieee80211_get_radio_led_name(il->hw); - break; - } - - ret = led_classdev_register(&il->pci_dev->dev, &il->led); - if (ret) { - kfree(il->led.name); - return; - } - - il->led_registered = true; -} -EXPORT_SYMBOL(il_leds_init); - -void il_leds_exit(struct il_priv *il) -{ - if (!il->led_registered) - return; - - led_classdev_unregister(&il->led); - kfree(il->led.name); -} -EXPORT_SYMBOL(il_leds_exit); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c deleted file mode 100644 index 2b06a95..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ /dev/null @@ -1,165 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-commands.h" -#include "iwl-debug.h" -#include "iwl-power.h" - -/* - * Setting power level allows the card to go to sleep when not busy. - * - * We calculate a sleep command based on the required latency, which - * we get from mac80211. In order to handle thermal throttling, we can - * also use pre-defined power levels. - */ - -/* - * This defines the old power levels. They are still used by default - * (level 1) and for thermal throttle (levels 3 through 5) - */ - -struct il_power_vec_entry { - struct il_powertable_cmd cmd; - u8 no_dtim; /* number of skip dtim */ -}; - -static void il_power_sleep_cam_cmd(struct il_priv *il, - struct il_powertable_cmd *cmd) -{ - memset(cmd, 0, sizeof(*cmd)); - - if (il->power_data.pci_pm) - cmd->flags |= IL_POWER_PCI_PM_MSK; - - D_POWER("Sleep command for CAM\n"); -} - -static int -il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) -{ - D_POWER("Sending power/sleep command\n"); - D_POWER("Flags value = 0x%08X\n", cmd->flags); - D_POWER("Tx timeout = %u\n", - le32_to_cpu(cmd->tx_data_timeout)); - D_POWER("Rx timeout = %u\n", - le32_to_cpu(cmd->rx_data_timeout)); - D_POWER( - "Sleep interval vector = { %d , %d , %d , %d , %d }\n", - le32_to_cpu(cmd->sleep_interval[0]), - le32_to_cpu(cmd->sleep_interval[1]), - le32_to_cpu(cmd->sleep_interval[2]), - le32_to_cpu(cmd->sleep_interval[3]), - le32_to_cpu(cmd->sleep_interval[4])); - - return il_send_cmd_pdu(il, C_POWER_TBL, - sizeof(struct il_powertable_cmd), cmd); -} - -int -il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, - bool force) -{ - int ret; - bool update_chains; - - lockdep_assert_held(&il->mutex); - - /* Don't update the RX chain when chain noise calibration is running */ - update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || - il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; - - if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) - return 0; - - if (!il_is_ready_rf(il)) - return -EIO; - - /* scan complete use sleep_power_next, need to be updated */ - memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); - if (test_bit(S_SCANNING, &il->status) && !force) { - D_INFO("Defer power set mode while scanning\n"); - return 0; - } - - if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) - set_bit(S_POWER_PMI, &il->status); - - ret = il_set_power(il, cmd); - if (!ret) { - if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) - clear_bit(S_POWER_PMI, &il->status); - - if (il->cfg->ops->lib->update_chain_flags && update_chains) - il->cfg->ops->lib->update_chain_flags(il); - else if (il->cfg->ops->lib->update_chain_flags) - D_POWER( - "Cannot update the power, chain noise " - "calibration running: %d\n", - il->chain_noise_data.state); - - memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); - } else - IL_ERR("set power fail, ret = %d", ret); - - return ret; -} - -int il_power_update_mode(struct il_priv *il, bool force) -{ - struct il_powertable_cmd cmd; - - il_power_sleep_cam_cmd(il, &cmd); - return il_power_set_mode(il, &cmd, force); -} -EXPORT_SYMBOL(il_power_update_mode); - -/* initialize to default */ -void il_power_initialize(struct il_priv *il) -{ - u16 lctl = il_pcie_link_ctl(il); - - il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); - - il->power_data.debug_sleep_level_override = -1; - - memset(&il->power_data.sleep_cmd, 0, - sizeof(il->power_data.sleep_cmd)); -} -EXPORT_SYMBOL(il_power_initialize); diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c deleted file mode 100644 index 7a8ae55..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ /dev/null @@ -1,281 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -/************************** RX-FUNCTIONS ****************************/ -/* - * Rx theory of operation - * - * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs), - * each of which point to Receive Buffers to be filled by the NIC. These get - * used not only for Rx frames, but for any command response or notification - * from the NIC. The driver and NIC manage the Rx buffers by means - * of idxes into the circular buffer. - * - * Rx Queue Indexes - * The host/firmware share two idx registers for managing the Rx buffers. - * - * The READ idx maps to the first position that the firmware may be writing - * to -- the driver can read up to (but not including) this position and get - * good data. - * The READ idx is managed by the firmware once the card is enabled. - * - * The WRITE idx maps to the last position the driver has read from -- the - * position preceding WRITE is the last slot the firmware can place a packet. - * - * The queue is empty (no good data) if WRITE = READ - 1, and is full if - * WRITE = READ. - * - * During initialization, the host sets up the READ queue position to the first - * IDX position, and WRITE to the last (READ - 1 wrapped) - * - * When the firmware places a packet in a buffer, it will advance the READ idx - * and fire the RX interrupt. The driver can then query the READ idx and - * process as many packets as possible, moving the WRITE idx forward as it - * resets the Rx queue buffers with new memory. - * - * The management in the driver is as follows: - * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When - * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled - * to replenish the iwl->rxq->rx_free. - * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver idxes as well) - * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' idx is updated. - * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free - * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * IDX is not incremented and iwl->status(RX_STALLED) is set. If there - * were enough free buffers and RX_STALLED is set it is cleared. - * - * - * Driver sequence: - * - * il_rx_queue_alloc() Allocates rx_free - * il_rx_replenish() Replenishes rx_free list from rx_used, and calls - * il_rx_queue_restock - * il_rx_queue_restock() Moves available buffers from rx_free into Rx - * queue, updates firmware pointers, and updates - * the WRITE idx. If insufficient rx_free buffers - * are available, schedules il_rx_replenish - * - * -- enable interrupts -- - * ISR - il_rx() Detach il_rx_bufs from pool up to the - * READ IDX, detaching the SKB from the pool. - * Moves the packet buffer from queue to rx_used. - * Calls il_rx_queue_restock to refill any empty - * slots. - * ... - * - */ - -/** - * il_rx_queue_space - Return number of free slots available in queue. - */ -int il_rx_queue_space(const struct il_rx_queue *q) -{ - int s = q->read - q->write; - if (s <= 0) - s += RX_QUEUE_SIZE; - /* keep some buffer to not confuse full and empty queue */ - s -= 2; - if (s < 0) - s = 0; - return s; -} -EXPORT_SYMBOL(il_rx_queue_space); - -/** - * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue - */ -void -il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q) -{ - unsigned long flags; - u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; - u32 reg; - - spin_lock_irqsave(&q->lock, flags); - - if (q->need_update == 0) - goto exit_unlock; - - /* If power-saving is in use, make sure device is awake */ - if (test_bit(S_POWER_PMI, &il->status)) { - reg = _il_rd(il, CSR_UCODE_DRV_GP1); - - if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Rx queue requesting wakeup," - " GP1 = 0x%x\n", reg); - il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - goto exit_unlock; - } - - q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); - - /* Else device is assumed to be awake */ - } else { - /* Device expects a multiple of 8 */ - q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); - } - - q->need_update = 0; - - exit_unlock: - spin_unlock_irqrestore(&q->lock, flags); -} -EXPORT_SYMBOL(il_rx_queue_update_write_ptr); - -int il_rx_queue_alloc(struct il_priv *il) -{ - struct il_rx_queue *rxq = &il->rxq; - struct device *dev = &il->pci_dev->dev; - int i; - - spin_lock_init(&rxq->lock); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - - /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ - rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, - GFP_KERNEL); - if (!rxq->bd) - goto err_bd; - - rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), - &rxq->rb_stts_dma, GFP_KERNEL); - if (!rxq->rb_stts) - goto err_rb; - - /* Fill the rx_used queue with _all_ of the Rx buffers */ - for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) - list_add_tail(&rxq->pool[i].list, &rxq->rx_used); - - /* Set us so that we have processed and used all buffers, but have - * not restocked the Rx queue with fresh buffers */ - rxq->read = rxq->write = 0; - rxq->write_actual = 0; - rxq->free_count = 0; - rxq->need_update = 0; - return 0; - -err_rb: - dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, - rxq->bd_dma); -err_bd: - return -ENOMEM; -} -EXPORT_SYMBOL(il_rx_queue_alloc); - - -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); - - if (!report->state) { - D_11H( - "Spectrum Measure Notification: Start\n"); - return; - } - - memcpy(&il->measure_report, report, sizeof(*report)); - il->measurement_status |= MEASUREMENT_READY; -} -EXPORT_SYMBOL(il_hdl_spectrum_measurement); - -/* - * returns non-zero if packet should be dropped - */ -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats) -{ - u16 fc = le16_to_cpu(hdr->frame_control); - - /* - * All contexts have the same setting here due to it being - * a module parameter, so OK to check any context. - */ - if (il->ctx.active.filter_flags & - RXON_FILTER_DIS_DECRYPT_MSK) - return 0; - - if (!(fc & IEEE80211_FCTL_PROTECTED)) - return 0; - - D_RX("decrypt_res:0x%x\n", decrypt_res); - switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { - case RX_RES_STATUS_SEC_TYPE_TKIP: - /* The uCode has got a bad phase 1 Key, pushes the packet. - * Decryption will be done in SW. */ - if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == - RX_RES_STATUS_BAD_KEY_TTAK) - break; - - case RX_RES_STATUS_SEC_TYPE_WEP: - if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == - RX_RES_STATUS_BAD_ICV_MIC) { - /* bad ICV, the packet is destroyed since the - * decryption is inplace, drop it */ - D_RX("Packet destroyed\n"); - return -1; - } - case RX_RES_STATUS_SEC_TYPE_CCMP: - if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == - RX_RES_STATUS_DECRYPT_OK) { - D_RX("hw decrypt successfully!!!\n"); - stats->flag |= RX_FLAG_DECRYPTED; - } - break; - - default: - break; - } - return 0; -} -EXPORT_SYMBOL(il_set_decrypted_flag); diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c deleted file mode 100644 index aaa589a..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ /dev/null @@ -1,545 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" - -/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after - * sending probe req. This should be set long enough to hear probe responses - * from more than one AP. */ -#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ -#define IL_ACTIVE_DWELL_TIME_52 (20) - -#define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) -#define IL_ACTIVE_DWELL_FACTOR_52GHZ (2) - -/* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. - * Must be set longer than active dwell time. - * For the most reliable scan, set > AP beacon interval (typically 100msec). */ -#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ -#define IL_PASSIVE_DWELL_TIME_52 (10) -#define IL_PASSIVE_DWELL_BASE (100) -#define IL_CHANNEL_TUNE_TIME 5 - -static int il_send_scan_abort(struct il_priv *il) -{ - int ret; - struct il_rx_pkt *pkt; - struct il_host_cmd cmd = { - .id = C_SCAN_ABORT, - .flags = CMD_WANT_SKB, - }; - - /* Exit instantly with error when device is not ready - * to receive scan abort command or it does not perform - * hardware scan currently */ - if (!test_bit(S_READY, &il->status) || - !test_bit(S_GEO_CONFIGURED, &il->status) || - !test_bit(S_SCAN_HW, &il->status) || - test_bit(S_FW_ERROR, &il->status) || - test_bit(S_EXIT_PENDING, &il->status)) - return -EIO; - - ret = il_send_cmd_sync(il, &cmd); - if (ret) - return ret; - - pkt = (struct il_rx_pkt *)cmd.reply_page; - if (pkt->u.status != CAN_ABORT_STATUS) { - /* The scan abort will return 1 for success or - * 2 for "failure". A failure condition can be - * due to simply not being in an active scan which - * can occur if we send the scan abort before we - * the microcode has notified us that a scan is - * completed. */ - D_SCAN("SCAN_ABORT ret %d.\n", pkt->u.status); - ret = -EIO; - } - - il_free_pages(il, cmd.reply_page); - return ret; -} - -static void il_complete_scan(struct il_priv *il, bool aborted) -{ - /* check if scan was requested from mac80211 */ - if (il->scan_request) { - D_SCAN("Complete scan in mac80211\n"); - ieee80211_scan_completed(il->hw, aborted); - } - - il->scan_vif = NULL; - il->scan_request = NULL; -} - -void il_force_scan_end(struct il_priv *il) -{ - lockdep_assert_held(&il->mutex); - - if (!test_bit(S_SCANNING, &il->status)) { - D_SCAN("Forcing scan end while not scanning\n"); - return; - } - - D_SCAN("Forcing scan end\n"); - clear_bit(S_SCANNING, &il->status); - clear_bit(S_SCAN_HW, &il->status); - clear_bit(S_SCAN_ABORTING, &il->status); - il_complete_scan(il, true); -} - -static void il_do_scan_abort(struct il_priv *il) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - if (!test_bit(S_SCANNING, &il->status)) { - D_SCAN("Not performing scan to abort\n"); - return; - } - - if (test_and_set_bit(S_SCAN_ABORTING, &il->status)) { - D_SCAN("Scan abort in progress\n"); - return; - } - - ret = il_send_scan_abort(il); - if (ret) { - D_SCAN("Send scan abort failed %d\n", ret); - il_force_scan_end(il); - } else - D_SCAN("Successfully send scan abort\n"); -} - -/** - * il_scan_cancel - Cancel any currently executing HW scan - */ -int il_scan_cancel(struct il_priv *il) -{ - D_SCAN("Queuing abort scan\n"); - queue_work(il->workqueue, &il->abort_scan); - return 0; -} -EXPORT_SYMBOL(il_scan_cancel); - -/** - * il_scan_cancel_timeout - Cancel any currently executing HW scan - * @ms: amount of time to wait (in milliseconds) for scan to abort - * - */ -int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) -{ - unsigned long timeout = jiffies + msecs_to_jiffies(ms); - - lockdep_assert_held(&il->mutex); - - D_SCAN("Scan cancel timeout\n"); - - il_do_scan_abort(il); - - while (time_before_eq(jiffies, timeout)) { - if (!test_bit(S_SCAN_HW, &il->status)) - break; - msleep(20); - } - - return test_bit(S_SCAN_HW, &il->status); -} -EXPORT_SYMBOL(il_scan_cancel_timeout); - -/* Service response to C_SCAN (0x80) */ -static void il_hdl_scan(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scanreq_notification *notif = - (struct il_scanreq_notification *)pkt->u.raw; - - D_SCAN("Scan request status = 0x%x\n", notif->status); -#endif -} - -/* Service N_SCAN_START (0x82) */ -static void il_hdl_scan_start(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scanstart_notification *notif = - (struct il_scanstart_notification *)pkt->u.raw; - il->scan_start_tsf = le32_to_cpu(notif->tsf_low); - D_SCAN("Scan start: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - notif->status, notif->beacon_timer); -} - -/* Service N_SCAN_RESULTS (0x83) */ -static void il_hdl_scan_results(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scanresults_notification *notif = - (struct il_scanresults_notification *)pkt->u.raw; - - D_SCAN("Scan ch.res: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d " - "elapsed=%lu usec\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - le32_to_cpu(notif->stats[0]), - le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); -#endif -} - -/* Service N_SCAN_COMPLETE (0x84) */ -static void il_hdl_scan_complete(struct il_priv *il, - struct il_rx_buf *rxb) -{ - -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; -#endif - - D_SCAN( - "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", - scan_notif->scanned_channels, - scan_notif->tsf_low, - scan_notif->tsf_high, scan_notif->status); - - /* The HW is no longer scanning */ - clear_bit(S_SCAN_HW, &il->status); - - D_SCAN("Scan on %sGHz took %dms\n", - (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", - jiffies_to_msecs(jiffies - il->scan_start)); - - queue_work(il->workqueue, &il->scan_completed); -} - -void il_setup_rx_scan_handlers(struct il_priv *il) -{ - /* scan handlers */ - il->handlers[C_SCAN] = il_hdl_scan; - il->handlers[N_SCAN_START] = - il_hdl_scan_start; - il->handlers[N_SCAN_RESULTS] = - il_hdl_scan_results; - il->handlers[N_SCAN_COMPLETE] = - il_hdl_scan_complete; -} -EXPORT_SYMBOL(il_setup_rx_scan_handlers); - -inline u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes) -{ - if (band == IEEE80211_BAND_5GHZ) - return IL_ACTIVE_DWELL_TIME_52 + - IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); - else - return IL_ACTIVE_DWELL_TIME_24 + - IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); -} -EXPORT_SYMBOL(il_get_active_dwell_time); - -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif) -{ - struct il_rxon_context *ctx = &il->ctx; - u16 value; - - u16 passive = (band == IEEE80211_BAND_2GHZ) ? - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; - - if (il_is_any_associated(il)) { - /* - * If we're associated, we clamp the maximum passive - * dwell time to be 98% of the smallest beacon interval - * (minus 2 * channel tune time) - */ - value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if (value > IL_PASSIVE_DWELL_BASE || !value) - value = IL_PASSIVE_DWELL_BASE; - value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; - passive = min(value, passive); - } - - return passive; -} -EXPORT_SYMBOL(il_get_passive_dwell_time); - -void il_init_scan_params(struct il_priv *il) -{ - u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; - if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) - il->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; - if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) - il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; -} -EXPORT_SYMBOL(il_init_scan_params); - -static int il_scan_initiate(struct il_priv *il, - struct ieee80211_vif *vif) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - if (WARN_ON(!il->cfg->ops->utils->request_scan)) - return -EOPNOTSUPP; - - cancel_delayed_work(&il->scan_check); - - if (!il_is_ready_rf(il)) { - IL_WARN("Request scan called when driver not ready.\n"); - return -EIO; - } - - if (test_bit(S_SCAN_HW, &il->status)) { - D_SCAN( - "Multiple concurrent scan requests in parallel.\n"); - return -EBUSY; - } - - if (test_bit(S_SCAN_ABORTING, &il->status)) { - D_SCAN("Scan request while abort pending.\n"); - return -EBUSY; - } - - D_SCAN("Starting scan...\n"); - - set_bit(S_SCANNING, &il->status); - il->scan_start = jiffies; - - ret = il->cfg->ops->utils->request_scan(il, vif); - if (ret) { - clear_bit(S_SCANNING, &il->status); - return ret; - } - - queue_delayed_work(il->workqueue, &il->scan_check, - IL_SCAN_CHECK_WATCHDOG); - - return 0; -} - -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req) -{ - struct il_priv *il = hw->priv; - int ret; - - D_MAC80211("enter\n"); - - if (req->n_channels == 0) - return -EINVAL; - - mutex_lock(&il->mutex); - - if (test_bit(S_SCANNING, &il->status)) { - D_SCAN("Scan already in progress.\n"); - ret = -EAGAIN; - goto out_unlock; - } - - /* mac80211 will only ask for one band at a time */ - il->scan_request = req; - il->scan_vif = vif; - il->scan_band = req->channels[0]->band; - - ret = il_scan_initiate(il, vif); - - D_MAC80211("leave\n"); - -out_unlock: - mutex_unlock(&il->mutex); - - return ret; -} -EXPORT_SYMBOL(il_mac_hw_scan); - -static void il_bg_scan_check(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, scan_check.work); - - D_SCAN("Scan check work\n"); - - /* Since we are here firmware does not finish scan and - * most likely is in bad shape, so we don't bother to - * send abort command, just force scan complete to mac80211 */ - mutex_lock(&il->mutex); - il_force_scan_end(il); - mutex_unlock(&il->mutex); -} - -/** - * il_fill_probe_req - fill in all required fields and IE for probe request - */ - -u16 -il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ies, int ie_len, int left) -{ - int len = 0; - u8 *pos = NULL; - - /* Make sure there is enough space for the probe request, - * two mandatory IEs and the data */ - left -= 24; - if (left < 0) - return 0; - - frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - memcpy(frame->da, il_bcast_addr, ETH_ALEN); - memcpy(frame->sa, ta, ETH_ALEN); - memcpy(frame->bssid, il_bcast_addr, ETH_ALEN); - frame->seq_ctrl = 0; - - len += 24; - - /* ...next IE... */ - pos = &frame->u.probe_req.variable[0]; - - /* fill in our indirect SSID IE */ - left -= 2; - if (left < 0) - return 0; - *pos++ = WLAN_EID_SSID; - *pos++ = 0; - - len += 2; - - if (WARN_ON(left < ie_len)) - return len; - - if (ies && ie_len) { - memcpy(pos, ies, ie_len); - len += ie_len; - } - - return (u16)len; -} -EXPORT_SYMBOL(il_fill_probe_req); - -static void il_bg_abort_scan(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, abort_scan); - - D_SCAN("Abort scan work\n"); - - /* We keep scan_check work queued in case when firmware will not - * report back scan completed notification */ - mutex_lock(&il->mutex); - il_scan_cancel_timeout(il, 200); - mutex_unlock(&il->mutex); -} - -static void il_bg_scan_completed(struct work_struct *work) -{ - struct il_priv *il = - container_of(work, struct il_priv, scan_completed); - bool aborted; - - D_SCAN("Completed scan.\n"); - - cancel_delayed_work(&il->scan_check); - - mutex_lock(&il->mutex); - - aborted = test_and_clear_bit(S_SCAN_ABORTING, &il->status); - if (aborted) - D_SCAN("Aborted scan completed.\n"); - - if (!test_and_clear_bit(S_SCANNING, &il->status)) { - D_SCAN("Scan already completed.\n"); - goto out_settings; - } - - il_complete_scan(il, aborted); - -out_settings: - /* Can we still talk to firmware ? */ - if (!il_is_ready_rf(il)) - goto out; - - /* - * We do not commit power settings while scan is pending, - * do it now if the settings changed. - */ - il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); - il_set_tx_power(il, il->tx_power_next, false); - - il->cfg->ops->utils->post_scan(il); - -out: - mutex_unlock(&il->mutex); -} - -void il_setup_scan_deferred_work(struct il_priv *il) -{ - INIT_WORK(&il->scan_completed, il_bg_scan_completed); - INIT_WORK(&il->abort_scan, il_bg_abort_scan); - INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); -} -EXPORT_SYMBOL(il_setup_scan_deferred_work); - -void il_cancel_scan_deferred_work(struct il_priv *il) -{ - cancel_work_sync(&il->abort_scan); - cancel_work_sync(&il->scan_completed); - - if (cancel_delayed_work_sync(&il->scan_check)) { - mutex_lock(&il->mutex); - il_force_scan_end(il); - mutex_unlock(&il->mutex); - } -} -EXPORT_SYMBOL(il_cancel_scan_deferred_work); diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c deleted file mode 100644 index 3b588b3..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ /dev/null @@ -1,655 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" - -/** - * il_txq_update_write_ptr - Send new write idx to hardware - */ -void -il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) -{ - u32 reg = 0; - int txq_id = txq->q.id; - - if (txq->need_update == 0) - return; - - /* if we're trying to save power */ - if (test_bit(S_POWER_PMI, &il->status)) { - /* wake up nic if it's powered down ... - * uCode will wake up, and interrupt us again, so next - * time we'll skip this part. */ - reg = _il_rd(il, CSR_UCODE_DRV_GP1); - - if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Tx queue %d requesting wakeup," - " GP1 = 0x%x\n", txq_id, reg); - il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - return; - } - - il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); - - /* - * else not in power-save mode, - * uCode will never sleep when we're - * trying to tx (during RFKILL, we're not trying to tx). - */ - } else - _il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); - txq->need_update = 0; -} -EXPORT_SYMBOL(il_txq_update_write_ptr); - -/** - * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's - */ -void il_tx_queue_unmap(struct il_priv *il, int txq_id) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - - if (q->n_bd == 0) - return; - - while (q->write_ptr != q->read_ptr) { - il->cfg->ops->lib->txq_free_tfd(il, txq); - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); - } -} -EXPORT_SYMBOL(il_tx_queue_unmap); - -/** - * il_tx_queue_free - Deallocate DMA queue. - * @txq: Transmit queue to deallocate. - * - * Empty queue by removing and destroying all BD's. - * Free all buffers. - * 0-fill, but do not free "txq" descriptor structure. - */ -void il_tx_queue_free(struct il_priv *il, int txq_id) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct device *dev = &il->pci_dev->dev; - int i; - - il_tx_queue_unmap(il, txq_id); - - /* De-alloc array of command/tx buffers */ - for (i = 0; i < TFD_TX_CMD_SLOTS; i++) - kfree(txq->cmd[i]); - - /* De-alloc circular buffer of TFDs */ - if (txq->q.n_bd) - dma_free_coherent(dev, il->hw_params.tfd_size * - txq->q.n_bd, txq->tfds, txq->q.dma_addr); - - /* De-alloc array of per-TFD driver data */ - kfree(txq->txb); - txq->txb = NULL; - - /* deallocate arrays */ - kfree(txq->cmd); - kfree(txq->meta); - txq->cmd = NULL; - txq->meta = NULL; - - /* 0-fill queue descriptor structure */ - memset(txq, 0, sizeof(*txq)); -} -EXPORT_SYMBOL(il_tx_queue_free); - -/** - * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue - */ -void il_cmd_queue_unmap(struct il_priv *il) -{ - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - struct il_queue *q = &txq->q; - int i; - - if (q->n_bd == 0) - return; - - while (q->read_ptr != q->write_ptr) { - i = il_get_cmd_idx(q, q->read_ptr, 0); - - if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(il->pci_dev, - dma_unmap_addr(&txq->meta[i], mapping), - dma_unmap_len(&txq->meta[i], len), - PCI_DMA_BIDIRECTIONAL); - txq->meta[i].flags = 0; - } - - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); - } - - i = q->n_win; - if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(il->pci_dev, - dma_unmap_addr(&txq->meta[i], mapping), - dma_unmap_len(&txq->meta[i], len), - PCI_DMA_BIDIRECTIONAL); - txq->meta[i].flags = 0; - } -} -EXPORT_SYMBOL(il_cmd_queue_unmap); - -/** - * il_cmd_queue_free - Deallocate DMA queue. - * @txq: Transmit queue to deallocate. - * - * Empty queue by removing and destroying all BD's. - * Free all buffers. - * 0-fill, but do not free "txq" descriptor structure. - */ -void il_cmd_queue_free(struct il_priv *il) -{ - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - struct device *dev = &il->pci_dev->dev; - int i; - - il_cmd_queue_unmap(il); - - /* De-alloc array of command/tx buffers */ - for (i = 0; i <= TFD_CMD_SLOTS; i++) - kfree(txq->cmd[i]); - - /* De-alloc circular buffer of TFDs */ - if (txq->q.n_bd) - dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, - txq->tfds, txq->q.dma_addr); - - /* deallocate arrays */ - kfree(txq->cmd); - kfree(txq->meta); - txq->cmd = NULL; - txq->meta = NULL; - - /* 0-fill queue descriptor structure */ - memset(txq, 0, sizeof(*txq)); -} -EXPORT_SYMBOL(il_cmd_queue_free); - -/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** - * DMA services - * - * Theory of operation - * - * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer - * of buffer descriptors, each of which points to one or more data buffers for - * the device to read from or fill. Driver and device exchange status of each - * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty - * entries in each circular buffer, to protect against confusing empty and full - * queue states. - * - * The device reads or writes the data in the queues via the device's several - * DMA/FIFO channels. Each queue is mapped to a single DMA channel. - * - * For Tx queue, there are low mark and high mark limits. If, after queuing - * the packet for Tx, free space become < low mark, Tx queue stopped. When - * reclaiming packets (on 'tx done IRQ), if free space become > high mark, - * Tx queue resumed. - * - * See more detailed info in 4965.h. - ***************************************************/ - -int il_queue_space(const struct il_queue *q) -{ - int s = q->read_ptr - q->write_ptr; - - if (q->read_ptr > q->write_ptr) - s -= q->n_bd; - - if (s <= 0) - s += q->n_win; - /* keep some reserve to not confuse empty and full situations */ - s -= 2; - if (s < 0) - s = 0; - return s; -} -EXPORT_SYMBOL(il_queue_space); - - -/** - * il_queue_init - Initialize queue's high/low-water and read/write idxes - */ -static int il_queue_init(struct il_priv *il, struct il_queue *q, - int count, int slots_num, u32 id) -{ - q->n_bd = count; - q->n_win = slots_num; - q->id = id; - - /* count must be power-of-two size, otherwise il_queue_inc_wrap - * and il_queue_dec_wrap are broken. */ - BUG_ON(!is_power_of_2(count)); - - /* slots_num must be power-of-two size, otherwise - * il_get_cmd_idx is broken. */ - BUG_ON(!is_power_of_2(slots_num)); - - q->low_mark = q->n_win / 4; - if (q->low_mark < 4) - q->low_mark = 4; - - q->high_mark = q->n_win / 8; - if (q->high_mark < 2) - q->high_mark = 2; - - q->write_ptr = q->read_ptr = 0; - - return 0; -} - -/** - * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue - */ -static int il_tx_queue_alloc(struct il_priv *il, - struct il_tx_queue *txq, u32 id) -{ - struct device *dev = &il->pci_dev->dev; - size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; - - /* Driver ilate data, only for Tx (not command) queues, - * not shared with device. */ - if (id != il->cmd_queue) { - txq->txb = kzalloc(sizeof(txq->txb[0]) * - TFD_QUEUE_SIZE_MAX, GFP_KERNEL); - if (!txq->txb) { - IL_ERR("kmalloc for auxiliary BD " - "structures failed\n"); - goto error; - } - } else { - txq->txb = NULL; - } - - /* Circular buffer of transmit frame descriptors (TFDs), - * shared with device */ - txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, - GFP_KERNEL); - if (!txq->tfds) { - IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); - goto error; - } - txq->q.id = id; - - return 0; - - error: - kfree(txq->txb); - txq->txb = NULL; - - return -ENOMEM; -} - -/** - * il_tx_queue_init - Allocate and initialize one tx/cmd queue - */ -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) -{ - int i, len; - int ret; - int actual_slots = slots_num; - - /* - * Alloc buffer array for commands (Tx or other types of commands). - * For the command queue (#4/#9), allocate command space + one big - * command for scan, since scan command is very huge; the system will - * not have two scans at the same time, so only one is needed. - * For normal Tx queues (all other queues), no super-size command - * space is needed. - */ - if (txq_id == il->cmd_queue) - actual_slots++; - - txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, - GFP_KERNEL); - txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, - GFP_KERNEL); - - if (!txq->meta || !txq->cmd) - goto out_free_arrays; - - len = sizeof(struct il_device_cmd); - for (i = 0; i < actual_slots; i++) { - /* only happens for cmd queue */ - if (i == slots_num) - len = IL_MAX_CMD_SIZE; - - txq->cmd[i] = kmalloc(len, GFP_KERNEL); - if (!txq->cmd[i]) - goto err; - } - - /* Alloc driver data array and TFD circular buffer */ - ret = il_tx_queue_alloc(il, txq, txq_id); - if (ret) - goto err; - - txq->need_update = 0; - - /* - * For the default queues 0-3, set up the swq_id - * already -- all others need to get one later - * (if they need one at all). - */ - if (txq_id < 4) - il_set_swq_id(txq, txq_id, txq_id); - - /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise - * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ - BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); - - /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); - - /* Tell device where to find queue */ - il->cfg->ops->lib->txq_init(il, txq); - - return 0; -err: - for (i = 0; i < actual_slots; i++) - kfree(txq->cmd[i]); -out_free_arrays: - kfree(txq->meta); - kfree(txq->cmd); - - return -ENOMEM; -} -EXPORT_SYMBOL(il_tx_queue_init); - -void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) -{ - int actual_slots = slots_num; - - if (txq_id == il->cmd_queue) - actual_slots++; - - memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); - - txq->need_update = 0; - - /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); - - /* Tell device where to find queue */ - il->cfg->ops->lib->txq_init(il, txq); -} -EXPORT_SYMBOL(il_tx_queue_reset); - -/*************** HOST COMMAND QUEUE FUNCTIONS *****/ - -/** - * il_enqueue_hcmd - enqueue a uCode command - * @il: device ilate data point - * @cmd: a point to the ucode command structure - * - * The function returns < 0 values to indicate the operation is - * failed. On success, it turns the idx (> 0) of command in the - * command queue. - */ -int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) -{ - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - struct il_queue *q = &txq->q; - struct il_device_cmd *out_cmd; - struct il_cmd_meta *out_meta; - dma_addr_t phys_addr; - unsigned long flags; - int len; - u32 idx; - u16 fix_size; - - cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); - fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); - - /* If any of the command structures end up being larger than - * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then - * we will need to increase the size of the TFD entries - * Also, check to see if command buffer should not exceed the size - * of device_cmd and max_cmd_size. */ - BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && - !(cmd->flags & CMD_SIZE_HUGE)); - BUG_ON(fix_size > IL_MAX_CMD_SIZE); - - if (il_is_rfkill(il) || il_is_ctkill(il)) { - IL_WARN("Not sending command - %s KILL\n", - il_is_rfkill(il) ? "RF" : "CT"); - return -EIO; - } - - spin_lock_irqsave(&il->hcmd_lock, flags); - - if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { - spin_unlock_irqrestore(&il->hcmd_lock, flags); - - IL_ERR("Restarting adapter due to command queue full\n"); - queue_work(il->workqueue, &il->restart); - return -ENOSPC; - } - - idx = il_get_cmd_idx(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); - out_cmd = txq->cmd[idx]; - out_meta = &txq->meta[idx]; - - if (WARN_ON(out_meta->flags & CMD_MAPPED)) { - spin_unlock_irqrestore(&il->hcmd_lock, flags); - return -ENOSPC; - } - - memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */ - out_meta->flags = cmd->flags | CMD_MAPPED; - if (cmd->flags & CMD_WANT_SKB) - out_meta->source = cmd; - if (cmd->flags & CMD_ASYNC) - out_meta->callback = cmd->callback; - - out_cmd->hdr.cmd = cmd->id; - memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); - - /* At this point, the out_cmd now has all of the incoming cmd - * information */ - - out_cmd->hdr.flags = 0; - out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | - IDX_TO_SEQ(q->write_ptr)); - if (cmd->flags & CMD_SIZE_HUGE) - out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; - len = sizeof(struct il_device_cmd); - if (idx == TFD_CMD_SLOTS) - len = IL_MAX_CMD_SIZE; - -#ifdef CONFIG_IWLEGACY_DEBUG - switch (out_cmd->hdr.cmd) { - case C_TX_LINK_QUALITY_CMD: - case C_SENSITIVITY: - D_HC_DUMP( - "Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); - break; - default: - D_HC("Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); - } -#endif - txq->need_update = 1; - - if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) - /* Set up entry in queue's byte count circular buffer */ - il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); - - phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, - fix_size, PCI_DMA_BIDIRECTIONAL); - dma_unmap_addr_set(out_meta, mapping, phys_addr); - dma_unmap_len_set(out_meta, len, fix_size); - - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, fix_size, 1, - U32_PAD(cmd->len)); - - /* Increment and update queue's write idx */ - q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(il, txq); - - spin_unlock_irqrestore(&il->hcmd_lock, flags); - return idx; -} - -/** - * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd - * - * When FW advances 'R' idx, all entries between old and new 'R' idx - * need to be reclaimed. As result, some free space forms. If there is - * enough free space (> low mark), wake the stack that feeds us. - */ -static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, - int idx, int cmd_idx) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - int nfreed = 0; - - if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); - return; - } - - for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { - - if (nfreed++ > 0) { - IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, - q->write_ptr, q->read_ptr); - queue_work(il->workqueue, &il->restart); - } - - } -} - -/** - * il_tx_cmd_complete - Pull unused buffers off the queue and reclaim them - * @rxb: Rx buffer to reclaim - * - * If an Rx buffer has an async callback associated with it the callback - * will be executed. The attached skb (if present) will only be freed - * if the callback returns 1 - */ -void -il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u16 sequence = le16_to_cpu(pkt->hdr.sequence); - int txq_id = SEQ_TO_QUEUE(sequence); - int idx = SEQ_TO_IDX(sequence); - int cmd_idx; - bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); - struct il_device_cmd *cmd; - struct il_cmd_meta *meta; - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - unsigned long flags; - - /* If a Tx command is being handled and it isn't in the actual - * command queue then there a command routing bug has been introduced - * in the queue management code. */ - if (WARN(txq_id != il->cmd_queue, - "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", - txq_id, il->cmd_queue, sequence, - il->txq[il->cmd_queue].q.read_ptr, - il->txq[il->cmd_queue].q.write_ptr)) { - il_print_hex_error(il, pkt, 32); - return; - } - - cmd_idx = il_get_cmd_idx(&txq->q, idx, huge); - cmd = txq->cmd[cmd_idx]; - meta = &txq->meta[cmd_idx]; - - txq->time_stamp = jiffies; - - pci_unmap_single(il->pci_dev, - dma_unmap_addr(meta, mapping), - dma_unmap_len(meta, len), - PCI_DMA_BIDIRECTIONAL); - - /* Input error checking is done when commands are added to queue. */ - if (meta->flags & CMD_WANT_SKB) { - meta->source->reply_page = (unsigned long)rxb_addr(rxb); - rxb->page = NULL; - } else if (meta->callback) - meta->callback(il, cmd, pkt); - - spin_lock_irqsave(&il->hcmd_lock, flags); - - il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); - - if (!(meta->flags & CMD_ASYNC)) { - clear_bit(S_HCMD_ACTIVE, &il->status); - D_INFO("Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->hdr.cmd)); - wake_up(&il->wait_command_queue); - } - - /* Mark as unmapped */ - meta->flags = 0; - - spin_unlock_irqrestore(&il->hcmd_lock, flags); -} -EXPORT_SYMBOL(il_tx_cmd_complete); -- cgit v0.10.2 From 7f8e12238049b0e5398e77cdf15f95a41077841f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:42:04 +0100 Subject: iwlegacy: rename module name Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 413213b..7421841 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,8 +1,8 @@ -obj-$(CONFIG_IWLEGACY) += iwl-legacy.o -iwl-legacy-objs := common.o -iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o +obj-$(CONFIG_IWLEGACY) += iwlegacy.o +iwlegacy-objs := common.o +iwlegacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o -iwl-legacy-objs += $(iwl-legacy-m) +iwlegacy-objs += $(iwlegacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -- cgit v0.10.2 From d4459a99c41e0e4fe7e36b3816b461c42827fb80 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 10:59:02 +0200 Subject: iwlegacy: rename iwl-commands.h to commands.h On the way remove also not needed iwl-fh.h include. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index e33ebca..ae60410 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -51,8 +51,7 @@ #define DRV_NAME "iwl3945" -#include "iwl-fh.h" -#include "iwl-commands.h" +#include "commands.h" #include "iwl-sta.h" #include "3945.h" #include "iwl-core.h" diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 0d2beba..4aa0432 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -36,7 +36,7 @@ #include -#include "iwl-commands.h" +#include "commands.h" #include "3945.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 83fe531..ff8818b 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -39,8 +39,7 @@ #include #include -#include "iwl-fh.h" -#include "iwl-commands.h" +#include "commands.h" #include "iwl-sta.h" #include "iwl-eeprom.h" #include "iwl-core.h" diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 9854cf1..7559a5e 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -36,7 +36,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "iwl-csr.h" #include "iwl-prph.h" -#include "iwl-fh.h" #include "iwl-debug.h" #include "iwl-power.h" #include "iwl-dev.h" diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h new file mode 100644 index 0000000..82cf472 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -0,0 +1,3393 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +#ifndef __il_commands_h__ +#define __il_commands_h__ + +struct il_priv; + +/* uCode version contains 4 values: Major/Minor/API/Serial */ +#define IL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) +#define IL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) +#define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) +#define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) + + +/* Tx rates */ +#define IL_CCK_RATES 4 +#define IL_OFDM_RATES 8 +#define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) + +enum { + N_ALIVE = 0x1, + N_ERROR = 0x2, + + /* RXON and QOS commands */ + C_RXON = 0x10, + C_RXON_ASSOC = 0x11, + C_QOS_PARAM = 0x13, + C_RXON_TIMING = 0x14, + + /* Multi-Station support */ + C_ADD_STA = 0x18, + C_REM_STA = 0x19, + + /* Security */ + C_WEPKEY = 0x20, + + /* RX, TX, LEDs */ + N_3945_RX = 0x1b, /* 3945 only */ + C_TX = 0x1c, + C_RATE_SCALE = 0x47, /* 3945 only */ + C_LEDS = 0x48, + C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ + + /* 802.11h related */ + C_CHANNEL_SWITCH = 0x72, + N_CHANNEL_SWITCH = 0x73, + C_SPECTRUM_MEASUREMENT = 0x74, + N_SPECTRUM_MEASUREMENT = 0x75, + + /* Power Management */ + C_POWER_TBL = 0x77, + N_PM_SLEEP = 0x7A, + N_PM_DEBUG_STATS = 0x7B, + + /* Scan commands and notifications */ + C_SCAN = 0x80, + C_SCAN_ABORT = 0x81, + N_SCAN_START = 0x82, + N_SCAN_RESULTS = 0x83, + N_SCAN_COMPLETE = 0x84, + + /* IBSS/AP commands */ + N_BEACON = 0x90, + C_TX_BEACON= 0x91, + + /* Miscellaneous commands */ + C_TX_PWR_TBL = 0x97, + + /* Bluetooth device coexistence config command */ + C_BT_CONFIG = 0x9b, + + /* Statistics */ + C_STATS = 0x9c, + N_STATS = 0x9d, + + /* RF-KILL commands and notifications */ + N_CARD_STATE = 0xa1, + + /* Missed beacons notification */ + N_MISSED_BEACONS = 0xa2, + + C_CT_KILL_CONFIG = 0xa4, + C_SENSITIVITY = 0xa8, + C_PHY_CALIBRATION = 0xb0, + N_RX_PHY = 0xc0, + N_RX_MPDU = 0xc1, + N_RX = 0xc3, + N_COMPRESSED_BA = 0xc5, + + IL_CN_MAX = 0xff +}; + +/****************************************************************************** + * (0) + * Commonly used structures and definitions: + * Command header, rate_n_flags, txpower + * + *****************************************************************************/ + +/* il_cmd_header flags value */ +#define IL_CMD_FAILED_MSK 0x40 + +#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) +#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) +#define SEQ_TO_IDX(s) ((s) & 0xff) +#define IDX_TO_SEQ(i) ((i) & 0xff) +#define SEQ_HUGE_FRAME cpu_to_le16(0x4000) +#define SEQ_RX_FRAME cpu_to_le16(0x8000) + +/** + * struct il_cmd_header + * + * This header format appears in the beginning of each command sent from the + * driver, and each response/notification received from uCode. + */ +struct il_cmd_header { + u8 cmd; /* Command ID: C_RXON, etc. */ + u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ + /* + * The driver sets up the sequence number to values of its choosing. + * uCode does not use this value, but passes it back to the driver + * when sending the response to each driver-originated command, so + * the driver can match the response to the command. Since the values + * don't get used by uCode, the driver may set up an arbitrary format. + * + * There is one exception: uCode sets bit 15 when it originates + * the response/notification, i.e. when the response/notification + * is not a direct response to a command sent by the driver. For + * example, uCode issues N_3945_RX when it sends a received frame + * to the driver; it is not a direct response to any driver command. + * + * The Linux driver uses the following format: + * + * 0:7 tfd idx - position within TX queue + * 8:12 TX queue id + * 13 reserved + * 14 huge - driver sets this to indicate command is in the + * 'huge' storage at the end of the command buffers + * 15 unsolicited RX or uCode-originated notification + */ + __le16 sequence; + + /* command or response/notification data follows immediately */ + u8 data[0]; +} __packed; + + +/** + * struct il3945_tx_power + * + * Used in C_TX_PWR_TBL, C_SCAN, C_CHANNEL_SWITCH + * + * Each entry contains two values: + * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained + * linear value that multiplies the output of the digital signal processor, + * before being sent to the analog radio. + * 2) Radio gain. This sets the analog gain of the radio Tx path. + * It is a coarser setting, and behaves in a logarithmic (dB) fashion. + * + * Driver obtains values from struct il3945_tx_power power_gain_table[][]. + */ +struct il3945_tx_power { + u8 tx_gain; /* gain for analog radio */ + u8 dsp_atten; /* gain for DSP */ +} __packed; + +/** + * struct il3945_power_per_rate + * + * Used in C_TX_PWR_TBL, C_CHANNEL_SWITCH + */ +struct il3945_power_per_rate { + u8 rate; /* plcp */ + struct il3945_tx_power tpc; + u8 reserved; +} __packed; + +/** + * iwl4965 rate_n_flags bit fields + * + * rate_n_flags format is used in following iwl4965 commands: + * N_RX (response only) + * N_RX_MPDU (response only) + * C_TX (both command and response) + * C_TX_LINK_QUALITY_CMD + * + * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"): + * 2-0: 0) 6 Mbps + * 1) 12 Mbps + * 2) 18 Mbps + * 3) 24 Mbps + * 4) 36 Mbps + * 5) 48 Mbps + * 6) 54 Mbps + * 7) 60 Mbps + * + * 4-3: 0) Single stream (SISO) + * 1) Dual stream (MIMO) + * 2) Triple stream (MIMO) + * + * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data + * + * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"): + * 3-0: 0xD) 6 Mbps + * 0xF) 9 Mbps + * 0x5) 12 Mbps + * 0x7) 18 Mbps + * 0x9) 24 Mbps + * 0xB) 36 Mbps + * 0x1) 48 Mbps + * 0x3) 54 Mbps + * + * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"): + * 6-0: 10) 1 Mbps + * 20) 2 Mbps + * 55) 5.5 Mbps + * 110) 11 Mbps + */ +#define RATE_MCS_CODE_MSK 0x7 +#define RATE_MCS_SPATIAL_POS 3 +#define RATE_MCS_SPATIAL_MSK 0x18 +#define RATE_MCS_HT_DUP_POS 5 +#define RATE_MCS_HT_DUP_MSK 0x20 + +/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */ +#define RATE_MCS_FLAGS_POS 8 +#define RATE_MCS_HT_POS 8 +#define RATE_MCS_HT_MSK 0x100 + +/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */ +#define RATE_MCS_CCK_POS 9 +#define RATE_MCS_CCK_MSK 0x200 + +/* Bit 10: (1) Use Green Field preamble */ +#define RATE_MCS_GF_POS 10 +#define RATE_MCS_GF_MSK 0x400 + +/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */ +#define RATE_MCS_HT40_POS 11 +#define RATE_MCS_HT40_MSK 0x800 + +/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */ +#define RATE_MCS_DUP_POS 12 +#define RATE_MCS_DUP_MSK 0x1000 + +/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */ +#define RATE_MCS_SGI_POS 13 +#define RATE_MCS_SGI_MSK 0x2000 + +/** + * rate_n_flags Tx antenna masks + * 4965 has 2 transmitters + * bit14:16 + */ +#define RATE_MCS_ANT_POS 14 +#define RATE_MCS_ANT_A_MSK 0x04000 +#define RATE_MCS_ANT_B_MSK 0x08000 +#define RATE_MCS_ANT_C_MSK 0x10000 +#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK) +#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK) +#define RATE_ANT_NUM 3 + +#define POWER_TBL_NUM_ENTRIES 33 +#define POWER_TBL_NUM_HT_OFDM_ENTRIES 32 +#define POWER_TBL_CCK_ENTRY 32 + +#define IL_PWR_NUM_HT_OFDM_ENTRIES 24 +#define IL_PWR_CCK_ENTRIES 2 + +/** + * union il4965_tx_power_dual_stream + * + * Host format used for C_TX_PWR_TBL, C_CHANNEL_SWITCH + * Use __le32 version (struct tx_power_dual_stream) when building command. + * + * Driver provides radio gain and DSP attenuation settings to device in pairs, + * one value for each transmitter chain. The first value is for transmitter A, + * second for transmitter B. + * + * For SISO bit rates, both values in a pair should be identical. + * For MIMO rates, one value may be different from the other, + * in order to balance the Tx output between the two transmitters. + * + * See more details in doc for TXPOWER in 4965.h. + */ +union il4965_tx_power_dual_stream { + struct { + u8 radio_tx_gain[2]; + u8 dsp_predis_atten[2]; + } s; + u32 dw; +}; + +/** + * struct tx_power_dual_stream + * + * Table entries in C_TX_PWR_TBL, C_CHANNEL_SWITCH + * + * Same format as il_tx_power_dual_stream, but __le32 + */ +struct tx_power_dual_stream { + __le32 dw; +} __packed; + +/** + * struct il4965_tx_power_db + * + * Entire table within C_TX_PWR_TBL, C_CHANNEL_SWITCH + */ +struct il4965_tx_power_db { + struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; +} __packed; + +/****************************************************************************** + * (0a) + * Alive and Error Commands & Responses: + * + *****************************************************************************/ + +#define UCODE_VALID_OK cpu_to_le32(0x1) +#define INITIALIZE_SUBTYPE (9) + +/* + * ("Initialize") N_ALIVE = 0x1 (response only, not a command) + * + * uCode issues this "initialize alive" notification once the initialization + * uCode image has completed its work, and is ready to load the runtime image. + * This is the *first* "alive" notification that the driver will receive after + * rebooting uCode; the "initialize" alive is indicated by subtype field == 9. + * + * See comments documenting "BSM" (bootstrap state machine). + * + * For 4965, this notification contains important calibration data for + * calculating txpower settings: + * + * 1) Power supply voltage indication. The voltage sensor outputs higher + * values for lower voltage, and vice verse. + * + * 2) Temperature measurement parameters, for each of two channel widths + * (20 MHz and 40 MHz) supported by the radios. Temperature sensing + * is done via one of the receiver chains, and channel width influences + * the results. + * + * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, + * for each of 5 frequency ranges. + */ +struct il_init_alive_resp { + u8 ucode_minor; + u8 ucode_major; + __le16 reserved1; + u8 sw_rev[8]; + u8 ver_type; + u8 ver_subtype; /* "9" for initialize alive */ + __le16 reserved2; + __le32 log_event_table_ptr; + __le32 error_event_table_ptr; + __le32 timestamp; + __le32 is_valid; + + /* calibration values from "initialize" uCode */ + __le32 voltage; /* signed, higher value is lower voltage */ + __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */ + __le32 therm_r2[2]; /* signed */ + __le32 therm_r3[2]; /* signed */ + __le32 therm_r4[2]; /* signed */ + __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups, + * 2 Tx chains */ +} __packed; + + +/** + * N_ALIVE = 0x1 (response only, not a command) + * + * uCode issues this "alive" notification once the runtime image is ready + * to receive commands from the driver. This is the *second* "alive" + * notification that the driver will receive after rebooting uCode; + * this "alive" is indicated by subtype field != 9. + * + * See comments documenting "BSM" (bootstrap state machine). + * + * This response includes two pointers to structures within the device's + * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging: + * + * 1) log_event_table_ptr indicates base of the event log. This traces + * a 256-entry history of uCode execution within a circular buffer. + * Its header format is: + * + * __le32 log_size; log capacity (in number of entries) + * __le32 type; (1) timestamp with each entry, (0) no timestamp + * __le32 wraps; # times uCode has wrapped to top of circular buffer + * __le32 write_idx; next circular buffer entry that uCode would fill + * + * The header is followed by the circular buffer of log entries. Entries + * with timestamps have the following format: + * + * __le32 event_id; range 0 - 1500 + * __le32 timestamp; low 32 bits of TSF (of network, if associated) + * __le32 data; event_id-specific data value + * + * Entries without timestamps contain only event_id and data. + * + * + * 2) error_event_table_ptr indicates base of the error log. This contains + * information about any uCode error that occurs. For 4965, the format + * of the error log is: + * + * __le32 valid; (nonzero) valid, (0) log is empty + * __le32 error_id; type of error + * __le32 pc; program counter + * __le32 blink1; branch link + * __le32 blink2; branch link + * __le32 ilink1; interrupt link + * __le32 ilink2; interrupt link + * __le32 data1; error-specific data + * __le32 data2; error-specific data + * __le32 line; source code line of error + * __le32 bcon_time; beacon timer + * __le32 tsf_low; network timestamp function timer + * __le32 tsf_hi; network timestamp function timer + * __le32 gp1; GP1 timer register + * __le32 gp2; GP2 timer register + * __le32 gp3; GP3 timer register + * __le32 ucode_ver; uCode version + * __le32 hw_ver; HW Silicon version + * __le32 brd_ver; HW board version + * __le32 log_pc; log program counter + * __le32 frame_ptr; frame pointer + * __le32 stack_ptr; stack pointer + * __le32 hcmd; last host command + * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag + * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag + * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag + * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag + * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt + * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT + * __le32 wait_event; wait event() caller address + * __le32 l2p_control; L2pControlField + * __le32 l2p_duration; L2pDurationField + * __le32 l2p_mhvalid; L2pMhValidBits + * __le32 l2p_addr_match; L2pAddrMatchStat + * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL) + * __le32 u_timestamp; indicate when the date and time of the compilation + * __le32 reserved; + * + * The Linux driver can print both logs to the system log when a uCode error + * occurs. + */ +struct il_alive_resp { + u8 ucode_minor; + u8 ucode_major; + __le16 reserved1; + u8 sw_rev[8]; + u8 ver_type; + u8 ver_subtype; /* not "9" for runtime alive */ + __le16 reserved2; + __le32 log_event_table_ptr; /* SRAM address for event log */ + __le32 error_event_table_ptr; /* SRAM address for error log */ + __le32 timestamp; + __le32 is_valid; +} __packed; + +/* + * N_ERROR = 0x2 (response only, not a command) + */ +struct il_error_resp { + __le32 error_type; + u8 cmd_id; + u8 reserved1; + __le16 bad_cmd_seq_num; + __le32 error_info; + __le64 timestamp; +} __packed; + +/****************************************************************************** + * (1) + * RXON Commands & Responses: + * + *****************************************************************************/ + +/* + * Rx config defines & structure + */ +/* rx_config device types */ +enum { + RXON_DEV_TYPE_AP = 1, + RXON_DEV_TYPE_ESS = 3, + RXON_DEV_TYPE_IBSS = 4, + RXON_DEV_TYPE_SNIFFER = 6, +}; + + +#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0) +#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0) +#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1) +#define RXON_RX_CHAIN_VALID_POS (1) +#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4) +#define RXON_RX_CHAIN_FORCE_SEL_POS (4) +#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7) +#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7) +#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10) +#define RXON_RX_CHAIN_CNT_POS (10) +#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12) +#define RXON_RX_CHAIN_MIMO_CNT_POS (12) +#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14) +#define RXON_RX_CHAIN_MIMO_FORCE_POS (14) + +/* rx_config flags */ +/* band & modulation selection */ +#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0) +#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1) +/* auto detection enable */ +#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2) +/* TGg protection when tx */ +#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3) +/* cck short slot & preamble */ +#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4) +#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5) +/* antenna selection */ +#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7) +#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00) +#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8) +#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9) +/* radar detection enable */ +#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12) +#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13) +/* rx response to host with 8-byte TSF +* (according to ON_AIR deassertion) */ +#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15) + + +/* HT flags */ +#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22) +#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22) + +#define RXON_FLG_HT_OPERATING_MODE_POS (23) + +#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23) +#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23) + +#define RXON_FLG_CHANNEL_MODE_POS (25) +#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25) + +/* channel mode */ +enum { + CHANNEL_MODE_LEGACY = 0, + CHANNEL_MODE_PURE_40 = 1, + CHANNEL_MODE_MIXED = 2, + CHANNEL_MODE_RESERVED = 3, +}; +#define RXON_FLG_CHANNEL_MODE_LEGACY \ + cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS) +#define RXON_FLG_CHANNEL_MODE_PURE_40 \ + cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS) +#define RXON_FLG_CHANNEL_MODE_MIXED \ + cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS) + +/* CTS to self (if spec allows) flag */ +#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30) + +/* rx_config filter flags */ +/* accept all data frames */ +#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0) +/* pass control & management to host */ +#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1) +/* accept multi-cast */ +#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2) +/* don't decrypt uni-cast frames */ +#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3) +/* don't decrypt multi-cast frames */ +#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4) +/* STA is associated */ +#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5) +/* transfer to host non bssid beacons in associated state */ +#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6) + +/** + * C_RXON = 0x10 (command, has simple generic response) + * + * RXON tunes the radio tuner to a service channel, and sets up a number + * of parameters that are used primarily for Rx, but also for Tx operations. + * + * NOTE: When tuning to a new channel, driver must set the + * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent + * info within the device, including the station tables, tx retry + * rate tables, and txpower tables. Driver must build a new station + * table and txpower table before transmitting anything on the RXON + * channel. + * + * NOTE: All RXONs wipe clean the internal txpower table. Driver must + * issue a new C_TX_PWR_TBL after each C_RXON (0x10), + * regardless of whether RXON_FILTER_ASSOC_MSK is set. + */ + +struct il3945_rxon_cmd { + u8 node_addr[6]; + __le16 reserved1; + u8 bssid_addr[6]; + __le16 reserved2; + u8 wlap_bssid_addr[6]; + __le16 reserved3; + u8 dev_type; + u8 air_propagation; + __le16 reserved4; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 assoc_id; + __le32 flags; + __le32 filter_flags; + __le16 channel; + __le16 reserved5; +} __packed; + +struct il4965_rxon_cmd { + u8 node_addr[6]; + __le16 reserved1; + u8 bssid_addr[6]; + __le16 reserved2; + u8 wlap_bssid_addr[6]; + __le16 reserved3; + u8 dev_type; + u8 air_propagation; + __le16 rx_chain; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 assoc_id; + __le32 flags; + __le32 filter_flags; + __le16 channel; + u8 ofdm_ht_single_stream_basic_rates; + u8 ofdm_ht_dual_stream_basic_rates; +} __packed; + +/* Create a common rxon cmd which will be typecast into the 3945 or 4965 + * specific rxon cmd, depending on where it is called from. + */ +struct il_rxon_cmd { + u8 node_addr[6]; + __le16 reserved1; + u8 bssid_addr[6]; + __le16 reserved2; + u8 wlap_bssid_addr[6]; + __le16 reserved3; + u8 dev_type; + u8 air_propagation; + __le16 rx_chain; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 assoc_id; + __le32 flags; + __le32 filter_flags; + __le16 channel; + u8 ofdm_ht_single_stream_basic_rates; + u8 ofdm_ht_dual_stream_basic_rates; + u8 reserved4; + u8 reserved5; +} __packed; + + +/* + * C_RXON_ASSOC = 0x11 (command, has simple generic response) + */ +struct il3945_rxon_assoc_cmd { + __le32 flags; + __le32 filter_flags; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 reserved; +} __packed; + +struct il4965_rxon_assoc_cmd { + __le32 flags; + __le32 filter_flags; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + u8 ofdm_ht_single_stream_basic_rates; + u8 ofdm_ht_dual_stream_basic_rates; + __le16 rx_chain_select_flags; + __le16 reserved; +} __packed; + +#define IL_CONN_MAX_LISTEN_INTERVAL 10 +#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ +#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ + +/* + * C_RXON_TIMING = 0x14 (command, has simple generic response) + */ +struct il_rxon_time_cmd { + __le64 timestamp; + __le16 beacon_interval; + __le16 atim_win; + __le32 beacon_init_val; + __le16 listen_interval; + u8 dtim_period; + u8 delta_cp_bss_tbtts; +} __packed; + +/* + * C_CHANNEL_SWITCH = 0x72 (command, has simple generic response) + */ +struct il3945_channel_switch_cmd { + u8 band; + u8 expect_beacon; + __le16 channel; + __le32 rxon_flags; + __le32 rxon_filter_flags; + __le32 switch_time; + struct il3945_power_per_rate power[IL_MAX_RATES]; +} __packed; + +struct il4965_channel_switch_cmd { + u8 band; + u8 expect_beacon; + __le16 channel; + __le32 rxon_flags; + __le32 rxon_filter_flags; + __le32 switch_time; + struct il4965_tx_power_db tx_power; +} __packed; + +/* + * N_CHANNEL_SWITCH = 0x73 (notification only, not a command) + */ +struct il_csa_notification { + __le16 band; + __le16 channel; + __le32 status; /* 0 - OK, 1 - fail */ +} __packed; + +/****************************************************************************** + * (2) + * Quality-of-Service (QOS) Commands & Responses: + * + *****************************************************************************/ + +/** + * struct il_ac_qos -- QOS timing params for C_QOS_PARAM + * One for each of 4 EDCA access categories in struct il_qosparam_cmd + * + * @cw_min: Contention win, start value in numbers of slots. + * Should be a power-of-2, minus 1. Device's default is 0x0f. + * @cw_max: Contention win, max value in numbers of slots. + * Should be a power-of-2, minus 1. Device's default is 0x3f. + * @aifsn: Number of slots in Arbitration Interframe Space (before + * performing random backoff timing prior to Tx). Device default 1. + * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. + * + * Device will automatically increase contention win by (2*CW) + 1 for each + * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW + * value, to cap the CW value. + */ +struct il_ac_qos { + __le16 cw_min; + __le16 cw_max; + u8 aifsn; + u8 reserved1; + __le16 edca_txop; +} __packed; + +/* QoS flags defines */ +#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01) +#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02) +#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10) + +/* Number of Access Categories (AC) (EDCA), queues 0..3 */ +#define AC_NUM 4 + +/* + * C_QOS_PARAM = 0x13 (command, has simple generic response) + * + * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs + * 0: Background, 1: Best Effort, 2: Video, 3: Voice. + */ +struct il_qosparam_cmd { + __le32 qos_flags; + struct il_ac_qos ac[AC_NUM]; +} __packed; + +/****************************************************************************** + * (3) + * Add/Modify Stations Commands & Responses: + * + *****************************************************************************/ +/* + * Multi station support + */ + +/* Special, dedicated locations within device's station table */ +#define IL_AP_ID 0 +#define IL_STA_ID 2 +#define IL3945_BROADCAST_ID 24 +#define IL3945_STATION_COUNT 25 +#define IL4965_BROADCAST_ID 31 +#define IL4965_STATION_COUNT 32 + +#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ +#define IL_INVALID_STATION 255 + +#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) +#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) +#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17) +#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18) +#define STA_FLG_MAX_AGG_SIZE_POS (19) +#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19) +#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21) +#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22) +#define STA_FLG_AGG_MPDU_DENSITY_POS (23) +#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23) + +/* Use in mode field. 1: modify existing entry, 0: add new station entry */ +#define STA_CONTROL_MODIFY_MSK 0x01 + +/* key flags __le16*/ +#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007) +#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000) +#define STA_KEY_FLG_WEP cpu_to_le16(0x0001) +#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002) +#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003) + +#define STA_KEY_FLG_KEYID_POS 8 +#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800) +/* wep key is either from global key (0) or from station info array (1) */ +#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008) + +/* wep key in STA: 5-bytes (0) or 13-bytes (1) */ +#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000) +#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000) +#define STA_KEY_MAX_NUM 8 + +/* Flags indicate whether to modify vs. don't change various station params */ +#define STA_MODIFY_KEY_MASK 0x01 +#define STA_MODIFY_TID_DISABLE_TX 0x02 +#define STA_MODIFY_TX_RATE_MSK 0x04 +#define STA_MODIFY_ADDBA_TID_MSK 0x08 +#define STA_MODIFY_DELBA_TID_MSK 0x10 +#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20 + +/* Receiver address (actually, Rx station's idx into station table), + * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ +#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) + +struct il4965_keyinfo { + __le16 key_flags; + u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */ + u8 reserved1; + __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */ + u8 key_offset; + u8 reserved2; + u8 key[16]; /* 16-byte unicast decryption key */ +} __packed; + +/** + * struct sta_id_modify + * @addr[ETH_ALEN]: station's MAC address + * @sta_id: idx of station in uCode's station table + * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change + * + * Driver selects unused table idx when adding new station, + * or the idx to a pre-existing station entry when modifying that station. + * Some idxes have special purposes (IL_AP_ID, idx 0, is for AP). + * + * modify_mask flags select which parameters to modify vs. leave alone. + */ +struct sta_id_modify { + u8 addr[ETH_ALEN]; + __le16 reserved1; + u8 sta_id; + u8 modify_mask; + __le16 reserved2; +} __packed; + +/* + * C_ADD_STA = 0x18 (command) + * + * The device contains an internal table of per-station information, + * with info on security keys, aggregation parameters, and Tx rates for + * initial Tx attempt and any retries (4965 devices uses + * C_TX_LINK_QUALITY_CMD, + * 3945 uses C_RATE_SCALE to set up rate tables). + * + * C_ADD_STA sets up the table entry for one station, either creating + * a new entry, or modifying a pre-existing one. + * + * NOTE: RXON command (without "associated" bit set) wipes the station table + * clean. Moving into RF_KILL state does this also. Driver must set up + * new station table before transmitting anything on the RXON channel + * (except active scans or active measurements; those commands carry + * their own txpower/rate setup data). + * + * When getting started on a new channel, driver must set up the + * IL_BROADCAST_ID entry (last entry in the table). For a client + * station in a BSS, once an AP is selected, driver sets up the AP STA + * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP + * are all that are needed for a BSS client station. If the device is + * used as AP, or in an IBSS network, driver must set up station table + * entries for all STAs in network, starting with idx IL_STA_ID. + */ + +struct il3945_addsta_cmd { + u8 mode; /* 1: modify existing, 0: add new station */ + u8 reserved[3]; + struct sta_id_modify sta; + struct il4965_keyinfo key; + __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags_msk; /* STA_FLG_* */ + + /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) + * corresponding to bit (e.g. bit 5 controls TID 5). + * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ + __le16 tid_disable_tx; + + __le16 rate_n_flags; + + /* TID for which to add block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + u8 add_immediate_ba_tid; + + /* TID for which to remove block-ack support. + * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ + u8 remove_immediate_ba_tid; + + /* Starting Sequence Number for added block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + __le16 add_immediate_ba_ssn; +} __packed; + +struct il4965_addsta_cmd { + u8 mode; /* 1: modify existing, 0: add new station */ + u8 reserved[3]; + struct sta_id_modify sta; + struct il4965_keyinfo key; + __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags_msk; /* STA_FLG_* */ + + /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) + * corresponding to bit (e.g. bit 5 controls TID 5). + * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ + __le16 tid_disable_tx; + + __le16 reserved1; + + /* TID for which to add block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + u8 add_immediate_ba_tid; + + /* TID for which to remove block-ack support. + * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ + u8 remove_immediate_ba_tid; + + /* Starting Sequence Number for added block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + __le16 add_immediate_ba_ssn; + + /* + * Number of packets OK to transmit to station even though + * it is asleep -- used to synchronise PS-poll and u-APSD + * responses while ucode keeps track of STA sleep state. + */ + __le16 sleep_tx_count; + + __le16 reserved2; +} __packed; + +/* Wrapper struct for 3945 and 4965 addsta_cmd structures */ +struct il_addsta_cmd { + u8 mode; /* 1: modify existing, 0: add new station */ + u8 reserved[3]; + struct sta_id_modify sta; + struct il4965_keyinfo key; + __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags_msk; /* STA_FLG_* */ + + /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) + * corresponding to bit (e.g. bit 5 controls TID 5). + * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ + __le16 tid_disable_tx; + + __le16 rate_n_flags; /* 3945 only */ + + /* TID for which to add block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + u8 add_immediate_ba_tid; + + /* TID for which to remove block-ack support. + * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ + u8 remove_immediate_ba_tid; + + /* Starting Sequence Number for added block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + __le16 add_immediate_ba_ssn; + + /* + * Number of packets OK to transmit to station even though + * it is asleep -- used to synchronise PS-poll and u-APSD + * responses while ucode keeps track of STA sleep state. + */ + __le16 sleep_tx_count; + + __le16 reserved2; +} __packed; + + +#define ADD_STA_SUCCESS_MSK 0x1 +#define ADD_STA_NO_ROOM_IN_TBL 0x2 +#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 +#define ADD_STA_MODIFY_NON_EXIST_STA 0x8 +/* + * C_ADD_STA = 0x18 (response) + */ +struct il_add_sta_resp { + u8 status; /* ADD_STA_* */ +} __packed; + +#define REM_STA_SUCCESS_MSK 0x1 +/* + * C_REM_STA = 0x19 (response) + */ +struct il_rem_sta_resp { + u8 status; +} __packed; + +/* + * C_REM_STA = 0x19 (command) + */ +struct il_rem_sta_cmd { + u8 num_sta; /* number of removed stations */ + u8 reserved[3]; + u8 addr[ETH_ALEN]; /* MAC addr of the first station */ + u8 reserved2[2]; +} __packed; + +#define IL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) +#define IL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) +#define IL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) +#define IL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) +#define IL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) + +#define IL_DROP_SINGLE 0 +#define IL_DROP_SELECTED 1 +#define IL_DROP_ALL 2 + +/* + * REPLY_WEP_KEY = 0x20 + */ +struct il_wep_key { + u8 key_idx; + u8 key_offset; + u8 reserved1[2]; + u8 key_size; + u8 reserved2[3]; + u8 key[16]; +} __packed; + +struct il_wep_cmd { + u8 num_keys; + u8 global_key_type; + u8 flags; + u8 reserved; + struct il_wep_key key[0]; +} __packed; + +#define WEP_KEY_WEP_TYPE 1 +#define WEP_KEYS_MAX 4 +#define WEP_INVALID_OFFSET 0xff +#define WEP_KEY_LEN_64 5 +#define WEP_KEY_LEN_128 13 + +/****************************************************************************** + * (4) + * Rx Responses: + * + *****************************************************************************/ + +#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0) +#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1) + +#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0) +#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1) +#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2) +#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3) +#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0 +#define RX_RES_PHY_FLAGS_ANTENNA_POS 4 + +#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) +#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8) +#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8) +#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8) +#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8) +#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8) + +#define RX_RES_STATUS_STATION_FOUND (1<<6) +#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7) + +#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11) +#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11) +#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11) +#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11) +#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11) + +#define RX_MPDU_RES_STATUS_ICV_OK (0x20) +#define RX_MPDU_RES_STATUS_MIC_OK (0x40) +#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7) +#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) + + +struct il3945_rx_frame_stats { + u8 phy_count; + u8 id; + u8 rssi; + u8 agc; + __le16 sig_avg; + __le16 noise_diff; + u8 payload[0]; +} __packed; + +struct il3945_rx_frame_hdr { + __le16 channel; + __le16 phy_flags; + u8 reserved1; + u8 rate; + __le16 len; + u8 payload[0]; +} __packed; + +struct il3945_rx_frame_end { + __le32 status; + __le64 timestamp; + __le32 beacon_timestamp; +} __packed; + +/* + * N_3945_RX = 0x1b (response only, not a command) + * + * NOTE: DO NOT dereference from casts to this structure + * It is provided only for calculating minimum data set size. + * The actual offsets of the hdr and end are dynamic based on + * stats.phy_count + */ +struct il3945_rx_frame { + struct il3945_rx_frame_stats stats; + struct il3945_rx_frame_hdr hdr; + struct il3945_rx_frame_end end; +} __packed; + +#define IL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) + +/* Fixed (non-configurable) rx data from phy */ + +#define IL49_RX_RES_PHY_CNT 14 +#define IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) +#define IL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) +#define IL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ +#define IL49_AGC_DB_POS (7) +struct il4965_rx_non_cfg_phy { + __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ + __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ + u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */ + u8 pad[0]; +} __packed; + + +/* + * N_RX = 0xc3 (response only, not a command) + * Used only for legacy (non 11n) frames. + */ +struct il_rx_phy_res { + u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ + u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ + u8 stat_id; /* configurable DSP phy data set ID */ + u8 reserved1; + __le64 timestamp; /* TSF at on air rise */ + __le32 beacon_time_stamp; /* beacon at on-air rise */ + __le16 phy_flags; /* general phy flags: band, modulation, ... */ + __le16 channel; /* channel number */ + u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ + __le32 rate_n_flags; /* RATE_MCS_* */ + __le16 byte_count; /* frame's byte-count */ + __le16 frame_time; /* frame's time on the air */ +} __packed; + +struct il_rx_mpdu_res_start { + __le16 byte_count; + __le16 reserved; +} __packed; + + +/****************************************************************************** + * (5) + * Tx Commands & Responses: + * + * Driver must place each C_TX command into one of the prioritized Tx + * queues in host DRAM, shared between driver and device (see comments for + * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode + * are preparing to transmit, the device pulls the Tx command over the PCI + * bus via one of the device's Tx DMA channels, to fill an internal FIFO + * from which data will be transmitted. + * + * uCode handles all timing and protocol related to control frames + * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler + * handle reception of block-acks; uCode updates the host driver via + * N_COMPRESSED_BA. + * + * uCode handles retrying Tx when an ACK is expected but not received. + * This includes trying lower data rates than the one requested in the Tx + * command, as set up by the C_RATE_SCALE (for 3945) or + * C_TX_LINK_QUALITY_CMD (4965). + * + * Driver sets up transmit power for various rates via C_TX_PWR_TBL. + * This command must be executed after every RXON command, before Tx can occur. + *****************************************************************************/ + +/* C_TX Tx flags field */ + +/* + * 1: Use Request-To-Send protocol before this frame. + * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. + */ +#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1) + +/* + * 1: Transmit Clear-To-Send to self before this frame. + * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames. + * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. + */ +#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2) + +/* 1: Expect ACK from receiving station + * 0: Don't expect ACK (MAC header's duration field s/b 0) + * Set this for unicast frames, but not broadcast/multicast. */ +#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3) + +/* For 4965 devices: + * 1: Use rate scale table (see C_TX_LINK_QUALITY_CMD). + * Tx command's initial_rate_idx indicates first rate to try; + * uCode walks through table for additional Tx attempts. + * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. + * This rate will be used for all Tx attempts; it will not be scaled. */ +#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4) + +/* 1: Expect immediate block-ack. + * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */ +#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6) + +/* + * 1: Frame requires full Tx-Op protection. + * Set this if either RTS or CTS Tx Flag gets set. + */ +#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7) + +/* Tx antenna selection field; used only for 3945, reserved (0) for 4965 devices. + * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ +#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00) +#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8) +#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9) + +/* 1: uCode overrides sequence control field in MAC header. + * 0: Driver provides sequence control field in MAC header. + * Set this for management frames, non-QOS data frames, non-unicast frames, + * and also in Tx command embedded in C_SCAN for active scans. */ +#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13) + +/* 1: This frame is non-last MPDU; more fragments are coming. + * 0: Last fragment, or not using fragmentation. */ +#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14) + +/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame. + * 0: No TSF required in outgoing frame. + * Set this for transmitting beacons and probe responses. */ +#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16) + +/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword + * alignment of frame's payload data field. + * 0: No pad + * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4 + * field (but not both). Driver must align frame data (i.e. data following + * MAC header) to DWORD boundary. */ +#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20) + +/* accelerate aggregation support + * 0 - no CCMP encryption; 1 - CCMP encryption */ +#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22) + +/* HCCA-AP - disable duration overwriting. */ +#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25) + + +/* + * TX command security control + */ +#define TX_CMD_SEC_WEP 0x01 +#define TX_CMD_SEC_CCM 0x02 +#define TX_CMD_SEC_TKIP 0x03 +#define TX_CMD_SEC_MSK 0x03 +#define TX_CMD_SEC_SHIFT 6 +#define TX_CMD_SEC_KEY128 0x08 + +/* + * security overhead sizes + */ +#define WEP_IV_LEN 4 +#define WEP_ICV_LEN 4 +#define CCMP_MIC_LEN 8 +#define TKIP_ICV_LEN 4 + +/* + * C_TX = 0x1c (command) + */ + +struct il3945_tx_cmd { + /* + * MPDU byte count: + * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, + * + 8 byte IV for CCM or TKIP (not used for WEP) + * + Data payload + * + 8-byte MIC (not used for CCM/WEP) + * NOTE: Does not include Tx command bytes, post-MAC pad bytes, + * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i + * Range: 14-2342 bytes. + */ + __le16 len; + + /* + * MPDU or MSDU byte count for next frame. + * Used for fragmentation and bursting, but not 11n aggregation. + * Same as "len", but for next frame. Set to 0 if not applicable. + */ + __le16 next_frame_len; + + __le32 tx_flags; /* TX_CMD_FLG_* */ + + u8 rate; + + /* Index of recipient station in uCode's station table */ + u8 sta_id; + u8 tid_tspec; + u8 sec_ctl; + u8 key[16]; + union { + u8 byte[8]; + __le16 word[4]; + __le32 dw[2]; + } tkip_mic; + __le32 next_frame_info; + union { + __le32 life_time; + __le32 attempt; + } stop_time; + u8 supp_rates[2]; + u8 rts_retry_limit; /*byte 50 */ + u8 data_retry_limit; /*byte 51 */ + union { + __le16 pm_frame_timeout; + __le16 attempt_duration; + } timeout; + + /* + * Duration of EDCA burst Tx Opportunity, in 32-usec units. + * Set this if txop time is not specified by HCCA protocol (e.g. by AP). + */ + __le16 driver_txop; + + /* + * MAC header goes here, followed by 2 bytes padding if MAC header + * length is 26 or 30 bytes, followed by payload data + */ + u8 payload[0]; + struct ieee80211_hdr hdr[0]; +} __packed; + +/* + * C_TX = 0x1c (response) + */ +struct il3945_tx_resp { + u8 failure_rts; + u8 failure_frame; + u8 bt_kill_count; + u8 rate; + __le32 wireless_media_time; + __le32 status; /* TX status */ +} __packed; + + +/* + * 4965 uCode updates these Tx attempt count values in host DRAM. + * Used for managing Tx retries when expecting block-acks. + * Driver should set these fields to 0. + */ +struct il_dram_scratch { + u8 try_cnt; /* Tx attempts */ + u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */ + __le16 reserved; +} __packed; + +struct il_tx_cmd { + /* + * MPDU byte count: + * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, + * + 8 byte IV for CCM or TKIP (not used for WEP) + * + Data payload + * + 8-byte MIC (not used for CCM/WEP) + * NOTE: Does not include Tx command bytes, post-MAC pad bytes, + * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i + * Range: 14-2342 bytes. + */ + __le16 len; + + /* + * MPDU or MSDU byte count for next frame. + * Used for fragmentation and bursting, but not 11n aggregation. + * Same as "len", but for next frame. Set to 0 if not applicable. + */ + __le16 next_frame_len; + + __le32 tx_flags; /* TX_CMD_FLG_* */ + + /* uCode may modify this field of the Tx command (in host DRAM!). + * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */ + struct il_dram_scratch scratch; + + /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */ + __le32 rate_n_flags; /* RATE_MCS_* */ + + /* Index of destination station in uCode's station table */ + u8 sta_id; + + /* Type of security encryption: CCM or TKIP */ + u8 sec_ctl; /* TX_CMD_SEC_* */ + + /* + * Index into rate table (see C_TX_LINK_QUALITY_CMD) for initial + * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for + * data frames, this field may be used to selectively reduce initial + * rate (via non-0 value) for special frames (e.g. management), while + * still supporting rate scaling for all frames. + */ + u8 initial_rate_idx; + u8 reserved; + u8 key[16]; + __le16 next_frame_flags; + __le16 reserved2; + union { + __le32 life_time; + __le32 attempt; + } stop_time; + + /* Host DRAM physical address pointer to "scratch" in this command. + * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */ + __le32 dram_lsb_ptr; + u8 dram_msb_ptr; + + u8 rts_retry_limit; /*byte 50 */ + u8 data_retry_limit; /*byte 51 */ + u8 tid_tspec; + union { + __le16 pm_frame_timeout; + __le16 attempt_duration; + } timeout; + + /* + * Duration of EDCA burst Tx Opportunity, in 32-usec units. + * Set this if txop time is not specified by HCCA protocol (e.g. by AP). + */ + __le16 driver_txop; + + /* + * MAC header goes here, followed by 2 bytes padding if MAC header + * length is 26 or 30 bytes, followed by payload data + */ + u8 payload[0]; + struct ieee80211_hdr hdr[0]; +} __packed; + +/* TX command response is sent after *3945* transmission attempts. + * + * NOTES: + * + * TX_STATUS_FAIL_NEXT_FRAG + * + * If the fragment flag in the MAC header for the frame being transmitted + * is set and there is insufficient time to transmit the next frame, the + * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'. + * + * TX_STATUS_FIFO_UNDERRUN + * + * Indicates the host did not provide bytes to the FIFO fast enough while + * a TX was in progress. + * + * TX_STATUS_FAIL_MGMNT_ABORT + * + * This status is only possible if the ABORT ON MGMT RX parameter was + * set to true with the TX command. + * + * If the MSB of the status parameter is set then an abort sequence is + * required. This sequence consists of the host activating the TX Abort + * control line, and then waiting for the TX Abort command response. This + * indicates that a the device is no longer in a transmit state, and that the + * command FIFO has been cleared. The host must then deactivate the TX Abort + * control line. Receiving is still allowed in this case. + */ +enum { + TX_3945_STATUS_SUCCESS = 0x01, + TX_3945_STATUS_DIRECT_DONE = 0x02, + TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82, + TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83, + TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84, + TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85, + TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86, + TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87, + TX_3945_STATUS_FAIL_DEST_PS = 0x88, + TX_3945_STATUS_FAIL_ABORTED = 0x89, + TX_3945_STATUS_FAIL_BT_RETRY = 0x8a, + TX_3945_STATUS_FAIL_STA_INVALID = 0x8b, + TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c, + TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d, + TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e, + TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, + TX_3945_STATUS_FAIL_TX_LOCKED = 0x90, + TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, +}; + +/* + * TX command response is sent after *4965* transmission attempts. + * + * both postpone and abort status are expected behavior from uCode. there is + * no special operation required from driver; except for RFKILL_FLUSH, + * which required tx flush host command to flush all the tx frames in queues + */ +enum { + TX_STATUS_SUCCESS = 0x01, + TX_STATUS_DIRECT_DONE = 0x02, + /* postpone TX */ + TX_STATUS_POSTPONE_DELAY = 0x40, + TX_STATUS_POSTPONE_FEW_BYTES = 0x41, + TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43, + TX_STATUS_POSTPONE_CALC_TTAK = 0x44, + /* abort TX */ + TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81, + TX_STATUS_FAIL_SHORT_LIMIT = 0x82, + TX_STATUS_FAIL_LONG_LIMIT = 0x83, + TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84, + TX_STATUS_FAIL_DRAIN_FLOW = 0x85, + TX_STATUS_FAIL_RFKILL_FLUSH = 0x86, + TX_STATUS_FAIL_LIFE_EXPIRE = 0x87, + TX_STATUS_FAIL_DEST_PS = 0x88, + TX_STATUS_FAIL_HOST_ABORTED = 0x89, + TX_STATUS_FAIL_BT_RETRY = 0x8a, + TX_STATUS_FAIL_STA_INVALID = 0x8b, + TX_STATUS_FAIL_FRAG_DROPPED = 0x8c, + TX_STATUS_FAIL_TID_DISABLE = 0x8d, + TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e, + TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, + TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90, + TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, +}; + +#define TX_PACKET_MODE_REGULAR 0x0000 +#define TX_PACKET_MODE_BURST_SEQ 0x0100 +#define TX_PACKET_MODE_BURST_FIRST 0x0200 + +enum { + TX_POWER_PA_NOT_ACTIVE = 0x0, +}; + +enum { + TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ + TX_STATUS_DELAY_MSK = 0x00000040, + TX_STATUS_ABORT_MSK = 0x00000080, + TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */ + TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */ + TX_RESERVED = 0x00780000, /* bits 19:22 */ + TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */ + TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ +}; + +/* ******************************* + * TX aggregation status + ******************************* */ + +enum { + AGG_TX_STATE_TRANSMITTED = 0x00, + AGG_TX_STATE_UNDERRUN_MSK = 0x01, + AGG_TX_STATE_FEW_BYTES_MSK = 0x04, + AGG_TX_STATE_ABORT_MSK = 0x08, + AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10, + AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20, + AGG_TX_STATE_SCD_QUERY_MSK = 0x80, + AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100, + AGG_TX_STATE_RESPONSE_MSK = 0x1ff, + AGG_TX_STATE_DUMP_TX_MSK = 0x200, + AGG_TX_STATE_DELAY_TX_MSK = 0x400 +}; + +#define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */ +#define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */ + +#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \ + AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK) + +/* # tx attempts for first frame in aggregation */ +#define AGG_TX_STATE_TRY_CNT_POS 12 +#define AGG_TX_STATE_TRY_CNT_MSK 0xf000 + +/* Command ID and sequence number of Tx command for this frame */ +#define AGG_TX_STATE_SEQ_NUM_POS 16 +#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 + +/* + * C_TX = 0x1c (response) + * + * This response may be in one of two slightly different formats, indicated + * by the frame_count field: + * + * 1) No aggregation (frame_count == 1). This reports Tx results for + * a single frame. Multiple attempts, at various bit rates, may have + * been made for this frame. + * + * 2) Aggregation (frame_count > 1). This reports Tx results for + * 2 or more frames that used block-acknowledge. All frames were + * transmitted at same rate. Rate scaling may have been used if first + * frame in this new agg block failed in previous agg block(s). + * + * Note that, for aggregation, ACK (block-ack) status is not delivered here; + * block-ack has not been received by the time the 4965 device records + * this status. + * This status relates to reasons the tx might have been blocked or aborted + * within the sending station (this 4965 device), rather than whether it was + * received successfully by the destination station. + */ +struct agg_tx_status { + __le16 status; + __le16 sequence; +} __packed; + +struct il4965_tx_resp { + u8 frame_count; /* 1 no aggregation, >1 aggregation */ + u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ + u8 failure_rts; /* # failures due to unsuccessful RTS */ + u8 failure_frame; /* # failures due to no ACK (unused for agg) */ + + /* For non-agg: Rate at which frame was successful. + * For agg: Rate at which all frames were transmitted. */ + __le32 rate_n_flags; /* RATE_MCS_* */ + + /* For non-agg: RTS + CTS + frame tx attempts time + ACK. + * For agg: RTS + CTS + aggregation tx time + block-ack time. */ + __le16 wireless_media_time; /* uSecs */ + + __le16 reserved; + __le32 pa_power1; /* RF power amplifier measurement (not used) */ + __le32 pa_power2; + + /* + * For non-agg: frame status TX_STATUS_* + * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status + * fields follow this one, up to frame_count. + * Bit fields: + * 11- 0: AGG_TX_STATE_* status code + * 15-12: Retry count for 1st frame in aggregation (retries + * occur if tx failed for this frame when it was a + * member of a previous aggregation block). If rate + * scaling is used, retry count indicates the rate + * table entry used for all frames in the new agg. + * 31-16: Sequence # for this frame's Tx cmd (not SSN!) + */ + union { + __le32 status; + struct agg_tx_status agg_status[0]; /* for each agg frame */ + } u; +} __packed; + +/* + * N_COMPRESSED_BA = 0xc5 (response only, not a command) + * + * Reports Block-Acknowledge from recipient station + */ +struct il_compressed_ba_resp { + __le32 sta_addr_lo32; + __le16 sta_addr_hi16; + __le16 reserved; + + /* Index of recipient (BA-sending) station in uCode's station table */ + u8 sta_id; + u8 tid; + __le16 seq_ctl; + __le64 bitmap; + __le16 scd_flow; + __le16 scd_ssn; +} __packed; + +/* + * C_TX_PWR_TBL = 0x97 (command, has simple generic response) + * + * See details under "TXPOWER" in 4965.h. + */ + +struct il3945_txpowertable_cmd { + u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ + u8 reserved; + __le16 channel; + struct il3945_power_per_rate power[IL_MAX_RATES]; +} __packed; + +struct il4965_txpowertable_cmd { + u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ + u8 reserved; + __le16 channel; + struct il4965_tx_power_db tx_power; +} __packed; + + +/** + * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response + * + * C_RATE_SCALE = 0x47 (command, has simple generic response) + * + * NOTE: The table of rates passed to the uCode via the + * RATE_SCALE command sets up the corresponding order of + * rates used for all related commands, including rate + * masks, etc. + * + * For example, if you set 9MB (PLCP 0x0f) as the first + * rate in the rate table, the bit mask for that rate + * when passed through ofdm_basic_rates on the C_RXON + * command would be bit 0 (1 << 0) + */ +struct il3945_rate_scaling_info { + __le16 rate_n_flags; + u8 try_cnt; + u8 next_rate_idx; +} __packed; + +struct il3945_rate_scaling_cmd { + u8 table_id; + u8 reserved[3]; + struct il3945_rate_scaling_info table[IL_MAX_RATES]; +} __packed; + + +/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */ +#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0) + +/* # of EDCA prioritized tx fifos */ +#define LINK_QUAL_AC_NUM AC_NUM + +/* # entries in rate scale table to support Tx retries */ +#define LINK_QUAL_MAX_RETRY_NUM 16 + +/* Tx antenna selection values */ +#define LINK_QUAL_ANT_A_MSK (1 << 0) +#define LINK_QUAL_ANT_B_MSK (1 << 1) +#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK) + + +/** + * struct il_link_qual_general_params + * + * Used in C_TX_LINK_QUALITY_CMD + */ +struct il_link_qual_general_params { + u8 flags; + + /* No entries at or above this (driver chosen) idx contain MIMO */ + u8 mimo_delimiter; + + /* Best single antenna to use for single stream (legacy, SISO). */ + u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */ + + /* Best antennas to use for MIMO (unused for 4965, assumes both). */ + u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ + + /* + * If driver needs to use different initial rates for different + * EDCA QOS access categories (as implemented by tx fifos 0-3), + * this table will set that up, by indicating the idxes in the + * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start. + * Otherwise, driver should set all entries to 0. + * + * Entry usage: + * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice + * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3. + */ + u8 start_rate_idx[LINK_QUAL_AC_NUM]; +} __packed; + +#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ +#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000) +#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100) + +#define LINK_QUAL_AGG_DISABLE_START_DEF (3) +#define LINK_QUAL_AGG_DISABLE_START_MAX (255) +#define LINK_QUAL_AGG_DISABLE_START_MIN (0) + +#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31) +#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63) +#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) + +/** + * struct il_link_qual_agg_params + * + * Used in C_TX_LINK_QUALITY_CMD + */ +struct il_link_qual_agg_params { + + /* + *Maximum number of uSec in aggregation. + * default set to 4000 (4 milliseconds) if not configured in .cfg + */ + __le16 agg_time_limit; + + /* + * Number of Tx retries allowed for a frame, before that frame will + * no longer be considered for the start of an aggregation sequence + * (scheduler will then try to tx it as single frame). + * Driver should set this to 3. + */ + u8 agg_dis_start_th; + + /* + * Maximum number of frames in aggregation. + * 0 = no limit (default). 1 = no aggregation. + * Other values = max # frames in aggregation. + */ + u8 agg_frame_cnt_limit; + + __le32 reserved; +} __packed; + +/* + * C_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) + * + * For 4965 devices only; 3945 uses C_RATE_SCALE. + * + * Each station in the 4965 device's internal station table has its own table + * of 16 + * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when + * an ACK is not received. This command replaces the entire table for + * one station. + * + * NOTE: Station must already be in 4965 device's station table. + * Use C_ADD_STA. + * + * The rate scaling procedures described below work well. Of course, other + * procedures are possible, and may work better for particular environments. + * + * + * FILLING THE RATE TBL + * + * Given a particular initial rate and mode, as determined by the rate + * scaling algorithm described below, the Linux driver uses the following + * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the + * Link Quality command: + * + * + * 1) If using High-throughput (HT) (SISO or MIMO) initial rate: + * a) Use this same initial rate for first 3 entries. + * b) Find next lower available rate using same mode (SISO or MIMO), + * use for next 3 entries. If no lower rate available, switch to + * legacy mode (no HT40 channel, no MIMO, no short guard interval). + * c) If using MIMO, set command's mimo_delimiter to number of entries + * using MIMO (3 or 6). + * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel, + * no MIMO, no short guard interval), at the next lower bit rate + * (e.g. if second HT bit rate was 54, try 48 legacy), and follow + * legacy procedure for remaining table entries. + * + * 2) If using legacy initial rate: + * a) Use the initial rate for only one entry. + * b) For each following entry, reduce the rate to next lower available + * rate, until reaching the lowest available rate. + * c) When reducing rate, also switch antenna selection. + * d) Once lowest available rate is reached, repeat this rate until + * rate table is filled (16 entries), switching antenna each entry. + * + * + * ACCUMULATING HISTORY + * + * The rate scaling algorithm for 4965 devices, as implemented in Linux driver, + * uses two sets of frame Tx success history: One for the current/active + * modulation mode, and one for a speculative/search mode that is being + * attempted. If the speculative mode turns out to be more effective (i.e. + * actual transfer rate is better), then the driver continues to use the + * speculative mode as the new current active mode. + * + * Each history set contains, separately for each possible rate, data for a + * sliding win of the 62 most recent tx attempts at that rate. The data + * includes a shifting bitmap of success(1)/failure(0), and sums of successful + * and attempted frames, from which the driver can additionally calculate a + * success ratio (success / attempted) and number of failures + * (attempted - success), and control the size of the win (attempted). + * The driver uses the bit map to remove successes from the success sum, as + * the oldest tx attempts fall out of the win. + * + * When the 4965 device makes multiple tx attempts for a given frame, each + * attempt might be at a different rate, and have different modulation + * characteristics (e.g. antenna, fat channel, short guard interval), as set + * up in the rate scaling table in the Link Quality command. The driver must + * determine which rate table entry was used for each tx attempt, to determine + * which rate-specific history to update, and record only those attempts that + * match the modulation characteristics of the history set. + * + * When using block-ack (aggregation), all frames are transmitted at the same + * rate, since there is no per-attempt acknowledgment from the destination + * station. The Tx response struct il_tx_resp indicates the Tx rate in + * rate_n_flags field. After receiving a block-ack, the driver can update + * history for the entire block all at once. + * + * + * FINDING BEST STARTING RATE: + * + * When working with a selected initial modulation mode (see below), the + * driver attempts to find a best initial rate. The initial rate is the + * first entry in the Link Quality command's rate table. + * + * 1) Calculate actual throughput (success ratio * expected throughput, see + * table below) for current initial rate. Do this only if enough frames + * have been attempted to make the value meaningful: at least 6 failed + * tx attempts, or at least 8 successes. If not enough, don't try rate + * scaling yet. + * + * 2) Find available rates adjacent to current initial rate. Available means: + * a) supported by hardware && + * b) supported by association && + * c) within any constraints selected by user + * + * 3) Gather measured throughputs for adjacent rates. These might not have + * enough history to calculate a throughput. That's okay, we might try + * using one of them anyway! + * + * 4) Try decreasing rate if, for current rate: + * a) success ratio is < 15% || + * b) lower adjacent rate has better measured throughput || + * c) higher adjacent rate has worse throughput, and lower is unmeasured + * + * As a sanity check, if decrease was determined above, leave rate + * unchanged if: + * a) lower rate unavailable + * b) success ratio at current rate > 85% (very good) + * c) current measured throughput is better than expected throughput + * of lower rate (under perfect 100% tx conditions, see table below) + * + * 5) Try increasing rate if, for current rate: + * a) success ratio is < 15% || + * b) both adjacent rates' throughputs are unmeasured (try it!) || + * b) higher adjacent rate has better measured throughput || + * c) lower adjacent rate has worse throughput, and higher is unmeasured + * + * As a sanity check, if increase was determined above, leave rate + * unchanged if: + * a) success ratio at current rate < 70%. This is not particularly + * good performance; higher rate is sure to have poorer success. + * + * 6) Re-evaluate the rate after each tx frame. If working with block- + * acknowledge, history and stats may be calculated for the entire + * block (including prior history that fits within the history wins), + * before re-evaluation. + * + * FINDING BEST STARTING MODULATION MODE: + * + * After working with a modulation mode for a "while" (and doing rate scaling), + * the driver searches for a new initial mode in an attempt to improve + * throughput. The "while" is measured by numbers of attempted frames: + * + * For legacy mode, search for new mode after: + * 480 successful frames, or 160 failed frames + * For high-throughput modes (SISO or MIMO), search for new mode after: + * 4500 successful frames, or 400 failed frames + * + * Mode switch possibilities are (3 for each mode): + * + * For legacy: + * Change antenna, try SISO (if HT association), try MIMO (if HT association) + * For SISO: + * Change antenna, try MIMO, try shortened guard interval (SGI) + * For MIMO: + * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI) + * + * When trying a new mode, use the same bit rate as the old/current mode when + * trying antenna switches and shortened guard interval. When switching to + * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate + * for which the expected throughput (under perfect conditions) is about the + * same or slightly better than the actual measured throughput delivered by + * the old/current mode. + * + * Actual throughput can be estimated by multiplying the expected throughput + * by the success ratio (successful / attempted tx frames). Frame size is + * not considered in this calculation; it assumes that frame size will average + * out to be fairly consistent over several samples. The following are + * metric values for expected throughput assuming 100% success ratio. + * Only G band has support for CCK rates: + * + * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60 + * + * G: 7 13 35 58 40 57 72 98 121 154 177 186 186 + * A: 0 0 0 0 40 57 72 98 121 154 177 186 186 + * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202 + * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211 + * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251 + * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257 + * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257 + * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264 + * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289 + * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293 + * + * After the new mode has been tried for a short while (minimum of 6 failed + * frames or 8 successful frames), compare success ratio and actual throughput + * estimate of the new mode with the old. If either is better with the new + * mode, continue to use the new mode. + * + * Continue comparing modes until all 3 possibilities have been tried. + * If moving from legacy to HT, try all 3 possibilities from the new HT + * mode. After trying all 3, a best mode is found. Continue to use this mode + * for the longer "while" described above (e.g. 480 successful frames for + * legacy), and then repeat the search process. + * + */ +struct il_link_quality_cmd { + + /* Index of destination/recipient station in uCode's station table */ + u8 sta_id; + u8 reserved1; + __le16 control; /* not used */ + struct il_link_qual_general_params general_params; + struct il_link_qual_agg_params agg_params; + + /* + * Rate info; when using rate-scaling, Tx command's initial_rate_idx + * specifies 1st Tx rate attempted, via idx into this table. + * 4965 devices works its way through table when retrying Tx. + */ + struct { + __le32 rate_n_flags; /* RATE_MCS_*, RATE_* */ + } rs_table[LINK_QUAL_MAX_RETRY_NUM]; + __le32 reserved2; +} __packed; + +/* + * BT configuration enable flags: + * bit 0 - 1: BT channel announcement enabled + * 0: disable + * bit 1 - 1: priority of BT device enabled + * 0: disable + */ +#define BT_COEX_DISABLE (0x0) +#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0) +#define BT_ENABLE_PRIORITY BIT(1) + +#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY) + +#define BT_LEAD_TIME_DEF (0x1E) + +#define BT_MAX_KILL_DEF (0x5) + +/* + * C_BT_CONFIG = 0x9b (command, has simple generic response) + * + * 3945 and 4965 devices support hardware handshake with Bluetooth device on + * same platform. Bluetooth device alerts wireless device when it will Tx; + * wireless device can delay or kill its own Tx to accommodate. + */ +struct il_bt_cmd { + u8 flags; + u8 lead_time; + u8 max_kill; + u8 reserved; + __le32 kill_ack_mask; + __le32 kill_cts_mask; +} __packed; + + +/****************************************************************************** + * (6) + * Spectrum Management (802.11h) Commands, Responses, Notifications: + * + *****************************************************************************/ + +/* + * Spectrum Management + */ +#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \ + RXON_FILTER_CTL2HOST_MSK | \ + RXON_FILTER_ACCEPT_GRP_MSK | \ + RXON_FILTER_DIS_DECRYPT_MSK | \ + RXON_FILTER_DIS_GRP_DECRYPT_MSK | \ + RXON_FILTER_ASSOC_MSK | \ + RXON_FILTER_BCON_AWARE_MSK) + +struct il_measure_channel { + __le32 duration; /* measurement duration in extended beacon + * format */ + u8 channel; /* channel to measure */ + u8 type; /* see enum il_measure_type */ + __le16 reserved; +} __packed; + +/* + * C_SPECTRUM_MEASUREMENT = 0x74 (command) + */ +struct il_spectrum_cmd { + __le16 len; /* number of bytes starting from token */ + u8 token; /* token id */ + u8 id; /* measurement id -- 0 or 1 */ + u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */ + u8 periodic; /* 1 = periodic */ + __le16 path_loss_timeout; + __le32 start_time; /* start time in extended beacon format */ + __le32 reserved2; + __le32 flags; /* rxon flags */ + __le32 filter_flags; /* rxon filter flags */ + __le16 channel_count; /* minimum 1, maximum 10 */ + __le16 reserved3; + struct il_measure_channel channels[10]; +} __packed; + +/* + * C_SPECTRUM_MEASUREMENT = 0x74 (response) + */ +struct il_spectrum_resp { + u8 token; + u8 id; /* id of the prior command replaced, or 0xff */ + __le16 status; /* 0 - command will be handled + * 1 - cannot handle (conflicts with another + * measurement) */ +} __packed; + +enum il_measurement_state { + IL_MEASUREMENT_START = 0, + IL_MEASUREMENT_STOP = 1, +}; + +enum il_measurement_status { + IL_MEASUREMENT_OK = 0, + IL_MEASUREMENT_CONCURRENT = 1, + IL_MEASUREMENT_CSA_CONFLICT = 2, + IL_MEASUREMENT_TGH_CONFLICT = 3, + /* 4-5 reserved */ + IL_MEASUREMENT_STOPPED = 6, + IL_MEASUREMENT_TIMEOUT = 7, + IL_MEASUREMENT_PERIODIC_FAILED = 8, +}; + +#define NUM_ELEMENTS_IN_HISTOGRAM 8 + +struct il_measurement_histogram { + __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */ + __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */ +} __packed; + +/* clear channel availability counters */ +struct il_measurement_cca_counters { + __le32 ofdm; + __le32 cck; +} __packed; + +enum il_measure_type { + IL_MEASURE_BASIC = (1 << 0), + IL_MEASURE_CHANNEL_LOAD = (1 << 1), + IL_MEASURE_HISTOGRAM_RPI = (1 << 2), + IL_MEASURE_HISTOGRAM_NOISE = (1 << 3), + IL_MEASURE_FRAME = (1 << 4), + /* bits 5:6 are reserved */ + IL_MEASURE_IDLE = (1 << 7), +}; + +/* + * N_SPECTRUM_MEASUREMENT = 0x75 (notification only, not a command) + */ +struct il_spectrum_notification { + u8 id; /* measurement id -- 0 or 1 */ + u8 token; + u8 channel_idx; /* idx in measurement channel list */ + u8 state; /* 0 - start, 1 - stop */ + __le32 start_time; /* lower 32-bits of TSF */ + u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ + u8 channel; + u8 type; /* see enum il_measurement_type */ + u8 reserved1; + /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only + * valid if applicable for measurement type requested. */ + __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */ + __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */ + __le32 cca_time; /* channel load time in usecs */ + u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 - + * unidentified */ + u8 reserved2[3]; + struct il_measurement_histogram histogram; + __le32 stop_time; /* lower 32-bits of TSF */ + __le32 status; /* see il_measurement_status */ +} __packed; + +/****************************************************************************** + * (7) + * Power Management Commands, Responses, Notifications: + * + *****************************************************************************/ + +/** + * struct il_powertable_cmd - Power Table Command + * @flags: See below: + * + * C_POWER_TBL = 0x77 (command, has simple generic response) + * + * PM allow: + * bit 0 - '0' Driver not allow power management + * '1' Driver allow PM (use rest of parameters) + * + * uCode send sleep notifications: + * bit 1 - '0' Don't send sleep notification + * '1' send sleep notification (SEND_PM_NOTIFICATION) + * + * Sleep over DTIM + * bit 2 - '0' PM have to walk up every DTIM + * '1' PM could sleep over DTIM till listen Interval. + * + * PCI power managed + * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1) + * '1' !(PCI_CFG_LINK_CTRL & 0x1) + * + * Fast PD + * bit 4 - '1' Put radio to sleep when receiving frame for others + * + * Force sleep Modes + * bit 31/30- '00' use both mac/xtal sleeps + * '01' force Mac sleep + * '10' force xtal sleep + * '11' Illegal set + * + * NOTE: if sleep_interval[SLEEP_INTRVL_TBL_SIZE-1] > DTIM period then + * ucode assume sleep over DTIM is allowed and we don't need to wake up + * for every DTIM. + */ +#define IL_POWER_VEC_SIZE 5 + +#define IL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) +#define IL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) + +struct il3945_powertable_cmd { + __le16 flags; + u8 reserved[2]; + __le32 rx_data_timeout; + __le32 tx_data_timeout; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; +} __packed; + +struct il_powertable_cmd { + __le16 flags; + u8 keep_alive_seconds; /* 3945 reserved */ + u8 debug_flags; /* 3945 reserved */ + __le32 rx_data_timeout; + __le32 tx_data_timeout; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; + __le32 keep_alive_beacons; +} __packed; + +/* + * N_PM_SLEEP = 0x7A (notification only, not a command) + * all devices identical. + */ +struct il_sleep_notification { + u8 pm_sleep_mode; + u8 pm_wakeup_src; + __le16 reserved; + __le32 sleep_time; + __le32 tsf_low; + __le32 bcon_timer; +} __packed; + +/* Sleep states. all devices identical. */ +enum { + IL_PM_NO_SLEEP = 0, + IL_PM_SLP_MAC = 1, + IL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, + IL_PM_SLP_FULL_MAC_CARD_STATE = 3, + IL_PM_SLP_PHY = 4, + IL_PM_SLP_REPENT = 5, + IL_PM_WAKEUP_BY_TIMER = 6, + IL_PM_WAKEUP_BY_DRIVER = 7, + IL_PM_WAKEUP_BY_RFKILL = 8, + /* 3 reserved */ + IL_PM_NUM_OF_MODES = 12, +}; + +/* + * N_CARD_STATE = 0xa1 (notification only, not a command) + */ +struct il_card_state_notif { + __le32 flags; +} __packed; + +#define HW_CARD_DISABLED 0x01 +#define SW_CARD_DISABLED 0x02 +#define CT_CARD_DISABLED 0x04 +#define RXON_CARD_DISABLED 0x10 + +struct il_ct_kill_config { + __le32 reserved; + __le32 critical_temperature_M; + __le32 critical_temperature_R; +} __packed; + +/****************************************************************************** + * (8) + * Scan Commands, Responses, Notifications: + * + *****************************************************************************/ + +#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0) +#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) + +/** + * struct il_scan_channel - entry in C_SCAN channel table + * + * One for each channel in the scan list. + * Each channel can independently select: + * 1) SSID for directed active scans + * 2) Txpower setting (for rate specified within Tx command) + * 3) How long to stay on-channel (behavior may be modified by quiet_time, + * quiet_plcp_th, good_CRC_th) + * + * To avoid uCode errors, make sure the following are true (see comments + * under struct il_scan_cmd about max_out_time and quiet_time): + * 1) If using passive_dwell (i.e. passive_dwell != 0): + * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0) + * 2) quiet_time <= active_dwell + * 3) If restricting off-channel time (i.e. max_out_time !=0): + * passive_dwell < max_out_time + * active_dwell < max_out_time + */ +struct il3945_scan_channel { + /* + * type is defined as: + * 0:0 1 = active, 0 = passive + * 1:4 SSID direct bit map; if a bit is set, then corresponding + * SSID IE is transmitted in probe request. + * 5:7 reserved + */ + u8 type; + u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ + struct il3945_tx_power tpc; + __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ + __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ +} __packed; + +/* set number of direct probes u8 type */ +#define IL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) + +struct il_scan_channel { + /* + * type is defined as: + * 0:0 1 = active, 0 = passive + * 1:20 SSID direct bit map; if a bit is set, then corresponding + * SSID IE is transmitted in probe request. + * 21:31 reserved + */ + __le32 type; + __le16 channel; /* band is selected by il_scan_cmd "flags" field */ + u8 tx_gain; /* gain for analog radio */ + u8 dsp_atten; /* gain for DSP */ + __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ + __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ +} __packed; + +/* set number of direct probes __le32 type */ +#define IL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) + +/** + * struct il_ssid_ie - directed scan network information element + * + * Up to 20 of these may appear in C_SCAN (Note: Only 4 are in + * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; + * each channel may select different ssids from among the 20 (4) entries. + * SSID IEs get transmitted in reverse order of entry. + */ +struct il_ssid_ie { + u8 id; + u8 len; + u8 ssid[32]; +} __packed; + +#define PROBE_OPTION_MAX_3945 4 +#define PROBE_OPTION_MAX 20 +#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) +#define IL_GOOD_CRC_TH_DISABLED 0 +#define IL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) +#define IL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) +#define IL_MAX_SCAN_SIZE 1024 +#define IL_MAX_CMD_SIZE 4096 + +/* + * C_SCAN = 0x80 (command) + * + * The hardware scan command is very powerful; the driver can set it up to + * maintain (relatively) normal network traffic while doing a scan in the + * background. The max_out_time and suspend_time control the ratio of how + * long the device stays on an associated network channel ("service channel") + * vs. how long it's away from the service channel, i.e. tuned to other channels + * for scanning. + * + * max_out_time is the max time off-channel (in usec), and suspend_time + * is how long (in "extended beacon" format) that the scan is "suspended" + * after returning to the service channel. That is, suspend_time is the + * time that we stay on the service channel, doing normal work, between + * scan segments. The driver may set these parameters differently to support + * scanning when associated vs. not associated, and light vs. heavy traffic + * loads when associated. + * + * After receiving this command, the device's scan engine does the following; + * + * 1) Sends SCAN_START notification to driver + * 2) Checks to see if it has time to do scan for one channel + * 3) Sends NULL packet, with power-save (PS) bit set to 1, + * to tell AP that we're going off-channel + * 4) Tunes to first channel in scan list, does active or passive scan + * 5) Sends SCAN_RESULT notification to driver + * 6) Checks to see if it has time to do scan on *next* channel in list + * 7) Repeats 4-6 until it no longer has time to scan the next channel + * before max_out_time expires + * 8) Returns to service channel + * 9) Sends NULL packet with PS=0 to tell AP that we're back + * 10) Stays on service channel until suspend_time expires + * 11) Repeats entire process 2-10 until list is complete + * 12) Sends SCAN_COMPLETE notification + * + * For fast, efficient scans, the scan command also has support for staying on + * a channel for just a short time, if doing active scanning and getting no + * responses to the transmitted probe request. This time is controlled by + * quiet_time, and the number of received packets below which a channel is + * considered "quiet" is controlled by quiet_plcp_threshold. + * + * For active scanning on channels that have regulatory restrictions against + * blindly transmitting, the scan can listen before transmitting, to make sure + * that there is already legitimate activity on the channel. If enough + * packets are cleanly received on the channel (controlled by good_CRC_th, + * typical value 1), the scan engine starts transmitting probe requests. + * + * Driver must use separate scan commands for 2.4 vs. 5 GHz bands. + * + * To avoid uCode errors, see timing restrictions described under + * struct il_scan_channel. + */ + +struct il3945_scan_cmd { + __le16 len; + u8 reserved0; + u8 channel_count; /* # channels in channel list */ + __le16 quiet_time; /* dwell only this # millisecs on quiet channel + * (only for active scan) */ + __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ + __le16 good_CRC_th; /* passive -> active promotion threshold */ + __le16 reserved1; + __le32 max_out_time; /* max usec to be away from associated (service) + * channel */ + __le32 suspend_time; /* pause scan this long (in "extended beacon + * format") when returning to service channel: + * 3945; 31:24 # beacons, 19:0 additional usec, + * 4965; 31:22 # beacons, 21:0 additional usec. + */ + __le32 flags; /* RXON_FLG_* */ + __le32 filter_flags; /* RXON_FILTER_* */ + + /* For active scans (set to all-0s for passive scans). + * Does not include payload. Must specify Tx rate; no rate scaling. */ + struct il3945_tx_cmd tx_cmd; + + /* For directed active scans (set to all-0s otherwise) */ + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; + + /* + * Probe request frame, followed by channel list. + * + * Size of probe request frame is specified by byte count in tx_cmd. + * Channel list follows immediately after probe request frame. + * Number of channels in list is specified by channel_count. + * Each channel in list is of type: + * + * struct il3945_scan_channel channels[0]; + * + * NOTE: Only one band of channels can be scanned per pass. You + * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) + * before requesting another scan. + */ + u8 data[0]; +} __packed; + +struct il_scan_cmd { + __le16 len; + u8 reserved0; + u8 channel_count; /* # channels in channel list */ + __le16 quiet_time; /* dwell only this # millisecs on quiet channel + * (only for active scan) */ + __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ + __le16 good_CRC_th; /* passive -> active promotion threshold */ + __le16 rx_chain; /* RXON_RX_CHAIN_* */ + __le32 max_out_time; /* max usec to be away from associated (service) + * channel */ + __le32 suspend_time; /* pause scan this long (in "extended beacon + * format") when returning to service chnl: + * 3945; 31:24 # beacons, 19:0 additional usec, + * 4965; 31:22 # beacons, 21:0 additional usec. + */ + __le32 flags; /* RXON_FLG_* */ + __le32 filter_flags; /* RXON_FILTER_* */ + + /* For active scans (set to all-0s for passive scans). + * Does not include payload. Must specify Tx rate; no rate scaling. */ + struct il_tx_cmd tx_cmd; + + /* For directed active scans (set to all-0s otherwise) */ + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX]; + + /* + * Probe request frame, followed by channel list. + * + * Size of probe request frame is specified by byte count in tx_cmd. + * Channel list follows immediately after probe request frame. + * Number of channels in list is specified by channel_count. + * Each channel in list is of type: + * + * struct il_scan_channel channels[0]; + * + * NOTE: Only one band of channels can be scanned per pass. You + * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) + * before requesting another scan. + */ + u8 data[0]; +} __packed; + +/* Can abort will notify by complete notification with abort status. */ +#define CAN_ABORT_STATUS cpu_to_le32(0x1) +/* complete notification statuses */ +#define ABORT_STATUS 0x2 + +/* + * C_SCAN = 0x80 (response) + */ +struct il_scanreq_notification { + __le32 status; /* 1: okay, 2: cannot fulfill request */ +} __packed; + +/* + * N_SCAN_START = 0x82 (notification only, not a command) + */ +struct il_scanstart_notification { + __le32 tsf_low; + __le32 tsf_high; + __le32 beacon_timer; + u8 channel; + u8 band; + u8 reserved[2]; + __le32 status; +} __packed; + +#define SCAN_OWNER_STATUS 0x1 +#define MEASURE_OWNER_STATUS 0x2 + +#define IL_PROBE_STATUS_OK 0 +#define IL_PROBE_STATUS_TX_FAILED BIT(0) +/* error statuses combined with TX_FAILED */ +#define IL_PROBE_STATUS_FAIL_TTL BIT(1) +#define IL_PROBE_STATUS_FAIL_BT BIT(2) + +#define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ +/* + * N_SCAN_RESULTS = 0x83 (notification only, not a command) + */ +struct il_scanresults_notification { + u8 channel; + u8 band; + u8 probe_status; + u8 num_probe_not_sent; /* not enough time to send */ + __le32 tsf_low; + __le32 tsf_high; + __le32 stats[NUMBER_OF_STATS]; +} __packed; + +/* + * N_SCAN_COMPLETE = 0x84 (notification only, not a command) + */ +struct il_scancomplete_notification { + u8 scanned_channels; + u8 status; + u8 last_channel; + __le32 tsf_low; + __le32 tsf_high; +} __packed; + + +/****************************************************************************** + * (9) + * IBSS/AP Commands and Notifications: + * + *****************************************************************************/ + +enum il_ibss_manager { + IL_NOT_IBSS_MANAGER = 0, + IL_IBSS_MANAGER = 1, +}; + +/* + * N_BEACON = 0x90 (notification only, not a command) + */ + +struct il3945_beacon_notif { + struct il3945_tx_resp beacon_notify_hdr; + __le32 low_tsf; + __le32 high_tsf; + __le32 ibss_mgr_status; +} __packed; + +struct il4965_beacon_notif { + struct il4965_tx_resp beacon_notify_hdr; + __le32 low_tsf; + __le32 high_tsf; + __le32 ibss_mgr_status; +} __packed; + +/* + * C_TX_BEACON= 0x91 (command, has simple generic response) + */ + +struct il3945_tx_beacon_cmd { + struct il3945_tx_cmd tx; + __le16 tim_idx; + u8 tim_size; + u8 reserved1; + struct ieee80211_hdr frame[0]; /* beacon frame */ +} __packed; + +struct il_tx_beacon_cmd { + struct il_tx_cmd tx; + __le16 tim_idx; + u8 tim_size; + u8 reserved1; + struct ieee80211_hdr frame[0]; /* beacon frame */ +} __packed; + +/****************************************************************************** + * (10) + * Statistics Commands and Notifications: + * + *****************************************************************************/ + +#define IL_TEMP_CONVERT 260 + +#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 +#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 +#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 + +/* Used for passing to driver number of successes and failures per rate */ +struct rate_histogram { + union { + __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; + __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; + __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; + } success; + union { + __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; + __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; + __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; + } failed; +} __packed; + +/* stats command response */ + +struct iwl39_stats_rx_phy { + __le32 ina_cnt; + __le32 fina_cnt; + __le32 plcp_err; + __le32 crc32_err; + __le32 overrun_err; + __le32 early_overrun_err; + __le32 crc32_good; + __le32 false_alarm_cnt; + __le32 fina_sync_err_cnt; + __le32 sfd_timeout; + __le32 fina_timeout; + __le32 unresponded_rts; + __le32 rxe_frame_limit_overrun; + __le32 sent_ack_cnt; + __le32 sent_cts_cnt; +} __packed; + +struct iwl39_stats_rx_non_phy { + __le32 bogus_cts; /* CTS received when not expecting CTS */ + __le32 bogus_ack; /* ACK received when not expecting ACK */ + __le32 non_bssid_frames; /* number of frames with BSSID that + * doesn't belong to the STA BSSID */ + __le32 filtered_frames; /* count frames that were dumped in the + * filtering process */ + __le32 non_channel_beacons; /* beacons with our bss id but not on + * our serving channel */ +} __packed; + +struct iwl39_stats_rx { + struct iwl39_stats_rx_phy ofdm; + struct iwl39_stats_rx_phy cck; + struct iwl39_stats_rx_non_phy general; +} __packed; + +struct iwl39_stats_tx { + __le32 preamble_cnt; + __le32 rx_detected_cnt; + __le32 bt_prio_defer_cnt; + __le32 bt_prio_kill_cnt; + __le32 few_bytes_cnt; + __le32 cts_timeout; + __le32 ack_timeout; + __le32 expected_ack_cnt; + __le32 actual_ack_cnt; +} __packed; + +struct stats_dbg { + __le32 burst_check; + __le32 burst_count; + __le32 wait_for_silence_timeout_cnt; + __le32 reserved[3]; +} __packed; + +struct iwl39_stats_div { + __le32 tx_on_a; + __le32 tx_on_b; + __le32 exec_time; + __le32 probe_time; +} __packed; + +struct iwl39_stats_general { + __le32 temperature; + struct stats_dbg dbg; + __le32 sleep_time; + __le32 slots_out; + __le32 slots_idle; + __le32 ttl_timestamp; + struct iwl39_stats_div div; +} __packed; + +struct stats_rx_phy { + __le32 ina_cnt; + __le32 fina_cnt; + __le32 plcp_err; + __le32 crc32_err; + __le32 overrun_err; + __le32 early_overrun_err; + __le32 crc32_good; + __le32 false_alarm_cnt; + __le32 fina_sync_err_cnt; + __le32 sfd_timeout; + __le32 fina_timeout; + __le32 unresponded_rts; + __le32 rxe_frame_limit_overrun; + __le32 sent_ack_cnt; + __le32 sent_cts_cnt; + __le32 sent_ba_rsp_cnt; + __le32 dsp_self_kill; + __le32 mh_format_err; + __le32 re_acq_main_rssi_sum; + __le32 reserved3; +} __packed; + +struct stats_rx_ht_phy { + __le32 plcp_err; + __le32 overrun_err; + __le32 early_overrun_err; + __le32 crc32_good; + __le32 crc32_err; + __le32 mh_format_err; + __le32 agg_crc32_good; + __le32 agg_mpdu_cnt; + __le32 agg_cnt; + __le32 unsupport_mcs; +} __packed; + +#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1) + +struct stats_rx_non_phy { + __le32 bogus_cts; /* CTS received when not expecting CTS */ + __le32 bogus_ack; /* ACK received when not expecting ACK */ + __le32 non_bssid_frames; /* number of frames with BSSID that + * doesn't belong to the STA BSSID */ + __le32 filtered_frames; /* count frames that were dumped in the + * filtering process */ + __le32 non_channel_beacons; /* beacons with our bss id but not on + * our serving channel */ + __le32 channel_beacons; /* beacons with our bss id and in our + * serving channel */ + __le32 num_missed_bcon; /* number of missed beacons */ + __le32 adc_rx_saturation_time; /* count in 0.8us units the time the + * ADC was in saturation */ + __le32 ina_detection_search_time;/* total time (in 0.8us) searched + * for INA */ + __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */ + __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */ + __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */ + __le32 interference_data_flag; /* flag for interference data + * availability. 1 when data is + * available. */ + __le32 channel_load; /* counts RX Enable time in uSec */ + __le32 dsp_false_alarms; /* DSP false alarm (both OFDM + * and CCK) counter */ + __le32 beacon_rssi_a; + __le32 beacon_rssi_b; + __le32 beacon_rssi_c; + __le32 beacon_energy_a; + __le32 beacon_energy_b; + __le32 beacon_energy_c; +} __packed; + +struct stats_rx { + struct stats_rx_phy ofdm; + struct stats_rx_phy cck; + struct stats_rx_non_phy general; + struct stats_rx_ht_phy ofdm_ht; +} __packed; + +/** + * struct stats_tx_power - current tx power + * + * @ant_a: current tx power on chain a in 1/2 dB step + * @ant_b: current tx power on chain b in 1/2 dB step + * @ant_c: current tx power on chain c in 1/2 dB step + */ +struct stats_tx_power { + u8 ant_a; + u8 ant_b; + u8 ant_c; + u8 reserved; +} __packed; + +struct stats_tx_non_phy_agg { + __le32 ba_timeout; + __le32 ba_reschedule_frames; + __le32 scd_query_agg_frame_cnt; + __le32 scd_query_no_agg; + __le32 scd_query_agg; + __le32 scd_query_mismatch; + __le32 frame_not_ready; + __le32 underrun; + __le32 bt_prio_kill; + __le32 rx_ba_rsp_cnt; +} __packed; + +struct stats_tx { + __le32 preamble_cnt; + __le32 rx_detected_cnt; + __le32 bt_prio_defer_cnt; + __le32 bt_prio_kill_cnt; + __le32 few_bytes_cnt; + __le32 cts_timeout; + __le32 ack_timeout; + __le32 expected_ack_cnt; + __le32 actual_ack_cnt; + __le32 dump_msdu_cnt; + __le32 burst_abort_next_frame_mismatch_cnt; + __le32 burst_abort_missing_next_frame_cnt; + __le32 cts_timeout_collision; + __le32 ack_or_ba_timeout_collision; + struct stats_tx_non_phy_agg agg; + + __le32 reserved1; +} __packed; + + +struct stats_div { + __le32 tx_on_a; + __le32 tx_on_b; + __le32 exec_time; + __le32 probe_time; + __le32 reserved1; + __le32 reserved2; +} __packed; + +struct stats_general_common { + __le32 temperature; /* radio temperature */ + struct stats_dbg dbg; + __le32 sleep_time; + __le32 slots_out; + __le32 slots_idle; + __le32 ttl_timestamp; + struct stats_div div; + __le32 rx_enable_counter; + /* + * num_of_sos_states: + * count the number of times we have to re-tune + * in order to get out of bad PHY status + */ + __le32 num_of_sos_states; +} __packed; + +struct stats_general { + struct stats_general_common common; + __le32 reserved2; + __le32 reserved3; +} __packed; + +#define UCODE_STATS_CLEAR_MSK (0x1 << 0) +#define UCODE_STATS_FREQUENCY_MSK (0x1 << 1) +#define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) + +/* + * C_STATS = 0x9c, + * all devices identical. + * + * This command triggers an immediate response containing uCode stats. + * The response is in the same format as N_STATS 0x9d, below. + * + * If the CLEAR_STATS configuration flag is set, uCode will clear its + * internal copy of the stats (counters) after issuing the response. + * This flag does not affect N_STATSs after beacons (see below). + * + * If the DISABLE_NOTIF configuration flag is set, uCode will not issue + * N_STATSs after received beacons (see below). This flag + * does not affect the response to the C_STATS 0x9c itself. + */ +#define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ +#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ +struct il_stats_cmd { + __le32 configuration_flags; /* IL_STATS_CONF_* */ +} __packed; + +/* + * N_STATS = 0x9d (notification only, not a command) + * + * By default, uCode issues this notification after receiving a beacon + * while associated. To disable this behavior, set DISABLE_NOTIF flag in the + * C_STATS 0x9c, above. + * + * Statistics counters continue to increment beacon after beacon, but are + * cleared when changing channels or when driver issues C_STATS + * 0x9c with CLEAR_STATS bit set (see above). + * + * uCode also issues this notification during scans. uCode clears stats + * appropriately so that each notification contains stats for only the + * one channel that has just been scanned. + */ +#define STATS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) +#define STATS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) + +struct il3945_notif_stats { + __le32 flag; + struct iwl39_stats_rx rx; + struct iwl39_stats_tx tx; + struct iwl39_stats_general general; +} __packed; + +struct il_notif_stats { + __le32 flag; + struct stats_rx rx; + struct stats_tx tx; + struct stats_general general; +} __packed; + +/* + * N_MISSED_BEACONS = 0xa2 (notification only, not a command) + * + * uCode send N_MISSED_BEACONS to driver when detect beacon missed + * in regardless of how many missed beacons, which mean when driver receive the + * notification, inside the command, it can find all the beacons information + * which include number of total missed beacons, number of consecutive missed + * beacons, number of beacons received and number of beacons expected to + * receive. + * + * If uCode detected consecutive_missed_beacons > 5, it will reset the radio + * in order to bring the radio/PHY back to working state; which has no relation + * to when driver will perform sensitivity calibration. + * + * Driver should set it own missed_beacon_threshold to decide when to perform + * sensitivity calibration based on number of consecutive missed beacons in + * order to improve overall performance, especially in noisy environment. + * + */ + +#define IL_MISSED_BEACON_THRESHOLD_MIN (1) +#define IL_MISSED_BEACON_THRESHOLD_DEF (5) +#define IL_MISSED_BEACON_THRESHOLD_MAX IL_MISSED_BEACON_THRESHOLD_DEF + +struct il_missed_beacon_notif { + __le32 consecutive_missed_beacons; + __le32 total_missed_becons; + __le32 num_expected_beacons; + __le32 num_recvd_beacons; +} __packed; + + +/****************************************************************************** + * (11) + * Rx Calibration Commands: + * + * With the uCode used for open source drivers, most Tx calibration (except + * for Tx Power) and most Rx calibration is done by uCode during the + * "initialize" phase of uCode boot. Driver must calibrate only: + * + * 1) Tx power (depends on temperature), described elsewhere + * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas) + * 3) Receiver sensitivity (to optimize signal detection) + * + *****************************************************************************/ + +/** + * C_SENSITIVITY = 0xa8 (command, has simple generic response) + * + * This command sets up the Rx signal detector for a sensitivity level that + * is high enough to lock onto all signals within the associated network, + * but low enough to ignore signals that are below a certain threshold, so as + * not to have too many "false alarms". False alarms are signals that the + * Rx DSP tries to lock onto, but then discards after determining that they + * are noise. + * + * The optimum number of false alarms is between 5 and 50 per 200 TUs + * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e. + * time listening, not transmitting). Driver must adjust sensitivity so that + * the ratio of actual false alarms to actual Rx time falls within this range. + * + * While associated, uCode delivers N_STATSs after each + * received beacon. These provide information to the driver to analyze the + * sensitivity. Don't analyze stats that come in from scanning, or any + * other non-associated-network source. Pertinent stats include: + * + * From "general" stats (struct stats_rx_non_phy): + * + * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level) + * Measure of energy of desired signal. Used for establishing a level + * below which the device does not detect signals. + * + * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB) + * Measure of background noise in silent period after beacon. + * + * channel_load + * uSecs of actual Rx time during beacon period (varies according to + * how much time was spent transmitting). + * + * From "cck" and "ofdm" stats (struct stats_rx_phy), separately: + * + * false_alarm_cnt + * Signal locks abandoned early (before phy-level header). + * + * plcp_err + * Signal locks abandoned late (during phy-level header). + * + * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from + * beacon to beacon, i.e. each value is an accumulation of all errors + * before and including the latest beacon. Values will wrap around to 0 + * after counting up to 2^32 - 1. Driver must differentiate vs. + * previous beacon's values to determine # false alarms in the current + * beacon period. + * + * Total number of false alarms = false_alarms + plcp_errs + * + * For OFDM, adjust the following table entries in struct il_sensitivity_cmd + * (notice that the start points for OFDM are at or close to settings for + * maximum sensitivity): + * + * START / MIN / MAX + * HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX 90 / 85 / 120 + * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX 170 / 170 / 210 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX 105 / 105 / 140 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX 220 / 220 / 270 + * + * If actual rate of OFDM false alarms (+ plcp_errors) is too high + * (greater than 50 for each 204.8 msecs listening), reduce sensitivity + * by *adding* 1 to all 4 of the table entries above, up to the max for + * each entry. Conversely, if false alarm rate is too low (less than 5 + * for each 204.8 msecs listening), *subtract* 1 from each entry to + * increase sensitivity. + * + * For CCK sensitivity, keep track of the following: + * + * 1). 20-beacon history of maximum background noise, indicated by + * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the + * 3 receivers. For any given beacon, the "silence reference" is + * the maximum of last 60 samples (20 beacons * 3 receivers). + * + * 2). 10-beacon history of strongest signal level, as indicated + * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers, + * i.e. the strength of the signal through the best receiver at the + * moment. These measurements are "upside down", with lower values + * for stronger signals, so max energy will be *minimum* value. + * + * Then for any given beacon, the driver must determine the *weakest* + * of the strongest signals; this is the minimum level that needs to be + * successfully detected, when using the best receiver at the moment. + * "Max cck energy" is the maximum (higher value means lower energy!) + * of the last 10 minima. Once this is determined, driver must add + * a little margin by adding "6" to it. + * + * 3). Number of consecutive beacon periods with too few false alarms. + * Reset this to 0 at the first beacon period that falls within the + * "good" range (5 to 50 false alarms per 204.8 milliseconds rx). + * + * Then, adjust the following CCK table entries in struct il_sensitivity_cmd + * (notice that the start points for CCK are at maximum sensitivity): + * + * START / MIN / MAX + * HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX 125 / 125 / 200 + * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX 200 / 200 / 400 + * HD_MIN_ENERGY_CCK_DET_IDX 100 / 0 / 100 + * + * If actual rate of CCK false alarms (+ plcp_errors) is too high + * (greater than 50 for each 204.8 msecs listening), method for reducing + * sensitivity is: + * + * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, + * up to max 400. + * + * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is < 160, + * sensitivity has been reduced a significant amount; bring it up to + * a moderate 161. Otherwise, *add* 3, up to max 200. + * + * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is > 160, + * sensitivity has been reduced only a moderate or small amount; + * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_IDX, + * down to min 0. Otherwise (if gain has been significantly reduced), + * don't change the HD_MIN_ENERGY_CCK_DET_IDX value. + * + * b) Save a snapshot of the "silence reference". + * + * If actual rate of CCK false alarms (+ plcp_errors) is too low + * (less than 5 for each 204.8 msecs listening), method for increasing + * sensitivity is used only if: + * + * 1a) Previous beacon did not have too many false alarms + * 1b) AND difference between previous "silence reference" and current + * "silence reference" (prev - current) is 2 or more, + * OR 2) 100 or more consecutive beacon periods have had rate of + * less than 5 false alarms per 204.8 milliseconds rx time. + * + * Method for increasing sensitivity: + * + * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX, + * down to min 125. + * + * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, + * down to min 200. + * + * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_IDX, up to max 100. + * + * If actual rate of CCK false alarms (+ plcp_errors) is within good range + * (between 5 and 50 for each 204.8 msecs listening): + * + * 1) Save a snapshot of the silence reference. + * + * 2) If previous beacon had too many CCK false alarms (+ plcp_errors), + * give some extra margin to energy threshold by *subtracting* 8 + * from value in HD_MIN_ENERGY_CCK_DET_IDX. + * + * For all cases (too few, too many, good range), make sure that the CCK + * detection threshold (energy) is below the energy level for robust + * detection over the past 10 beacon periods, the "Max cck energy". + * Lower values mean higher energy; this means making sure that the value + * in HD_MIN_ENERGY_CCK_DET_IDX is at or *above* "Max cck energy". + * + */ + +/* + * Table entries in C_SENSITIVITY (struct il_sensitivity_cmd) + */ +#define HD_TBL_SIZE (11) /* number of entries */ +#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ +#define HD_MIN_ENERGY_OFDM_DET_IDX (1) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX (5) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6) +#define HD_BARKER_CORR_TH_ADD_MIN_IDX (7) +#define HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX (8) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX (9) +#define HD_OFDM_ENERGY_TH_IN_IDX (10) + +/* Control field in struct il_sensitivity_cmd */ +#define C_SENSITIVITY_CONTROL_DEFAULT_TBL cpu_to_le16(0) +#define C_SENSITIVITY_CONTROL_WORK_TBL cpu_to_le16(1) + +/** + * struct il_sensitivity_cmd + * @control: (1) updates working table, (0) updates default table + * @table: energy threshold values, use HD_* as idx into table + * + * Always use "1" in "control" to update uCode's working table and DSP. + */ +struct il_sensitivity_cmd { + __le16 control; /* always use "1" */ + __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ +} __packed; + + +/** + * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) + * + * This command sets the relative gains of 4965 device's 3 radio receiver chains. + * + * After the first association, driver should accumulate signal and noise + * stats from the N_STATSs that follow the first 20 + * beacons from the associated network (don't collect stats that come + * in from scanning, or any other non-network source). + * + * DISCONNECTED ANTENNA: + * + * Driver should determine which antennas are actually connected, by comparing + * average beacon signal levels for the 3 Rx chains. Accumulate (add) the + * following values over 20 beacons, one accumulator for each of the chains + * a/b/c, from struct stats_rx_non_phy: + * + * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB) + * + * Find the strongest signal from among a/b/c. Compare the other two to the + * strongest. If any signal is more than 15 dB (times 20, unless you + * divide the accumulated values by 20) below the strongest, the driver + * considers that antenna to be disconnected, and should not try to use that + * antenna/chain for Rx or Tx. If both A and B seem to be disconnected, + * driver should declare the stronger one as connected, and attempt to use it + * (A and B are the only 2 Tx chains!). + * + * + * RX BALANCE: + * + * Driver should balance the 3 receivers (but just the ones that are connected + * to antennas, see above) for gain, by comparing the average signal levels + * detected during the silence after each beacon (background noise). + * Accumulate (add) the following values over 20 beacons, one accumulator for + * each of the chains a/b/c, from struct stats_rx_non_phy: + * + * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB) + * + * Find the weakest background noise level from among a/b/c. This Rx chain + * will be the reference, with 0 gain adjustment. Attenuate other channels by + * finding noise difference: + * + * (accum_noise[i] - accum_noise[reference]) / 30 + * + * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB. + * For use in diff_gain_[abc] fields of struct il_calibration_cmd, the + * driver should limit the difference results to a range of 0-3 (0-4.5 dB), + * and set bit 2 to indicate "reduce gain". The value for the reference + * (weakest) chain should be "0". + * + * diff_gain_[abc] bit fields: + * 2: (1) reduce gain, (0) increase gain + * 1-0: amount of gain, units of 1.5 dB + */ + +/* Phy calibration command for series */ +/* The default calibrate table size if not specified by firmware */ +#define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 +enum { + IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, + IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, +}; + +#define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) + +struct il_calib_hdr { + u8 op_code; + u8 first_group; + u8 groups_num; + u8 data_valid; +} __packed; + +/* IL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ +struct il_calib_diff_gain_cmd { + struct il_calib_hdr hdr; + s8 diff_gain_a; /* see above */ + s8 diff_gain_b; + s8 diff_gain_c; + u8 reserved1; +} __packed; + +/****************************************************************************** + * (12) + * Miscellaneous Commands: + * + *****************************************************************************/ + +/* + * LEDs Command & Response + * C_LEDS = 0x48 (command, has simple generic response) + * + * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), + * this command turns it on or off, or sets up a periodic blinking cycle. + */ +struct il_led_cmd { + __le32 interval; /* "interval" in uSec */ + u8 id; /* 1: Activity, 2: Link, 3: Tech */ + u8 off; /* # intervals off while blinking; + * "0", with >0 "on" value, turns LED on */ + u8 on; /* # intervals on while blinking; + * "0", regardless of "off", turns LED off */ + u8 reserved; +} __packed; + + +/****************************************************************************** + * (13) + * Union of all expected notifications/responses: + * + *****************************************************************************/ + +struct il_rx_pkt { + /* + * The first 4 bytes of the RX frame header contain both the RX frame + * size and some flags. + * Bit fields: + * 31: flag flush RB request + * 30: flag ignore TC (terminal counter) request + * 29: flag fast IRQ request + * 28-14: Reserved + * 13-00: RX frame size + */ + __le32 len_n_flags; + struct il_cmd_header hdr; + union { + struct il3945_rx_frame rx_frame; + struct il3945_tx_resp tx_resp; + struct il3945_beacon_notif beacon_status; + + struct il_alive_resp alive_frame; + struct il_spectrum_notification spectrum_notif; + struct il_csa_notification csa_notif; + struct il_error_resp err_resp; + struct il_card_state_notif card_state_notif; + struct il_add_sta_resp add_sta; + struct il_rem_sta_resp rem_sta; + struct il_sleep_notification sleep_notif; + struct il_spectrum_resp spectrum; + struct il_notif_stats stats; + struct il_compressed_ba_resp compressed_ba; + struct il_missed_beacon_notif missed_beacon; + __le32 status; + u8 raw[0]; + } u; +} __packed; + +#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h deleted file mode 100644 index 8df4d25..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ /dev/null @@ -1,3398 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Please use this file (iwl-commands.h) only for uCode API definitions. - * Please use iwl-xxxx-hw.h for hardware-related definitions. - * Please use iwl-dev.h for driver implementation definitions. - */ - -#ifndef __il_commands_h__ -#define __il_commands_h__ - -struct il_priv; - -/* uCode version contains 4 values: Major/Minor/API/Serial */ -#define IL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) -#define IL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) -#define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) -#define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) - - -/* Tx rates */ -#define IL_CCK_RATES 4 -#define IL_OFDM_RATES 8 -#define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) - -enum { - N_ALIVE = 0x1, - N_ERROR = 0x2, - - /* RXON and QOS commands */ - C_RXON = 0x10, - C_RXON_ASSOC = 0x11, - C_QOS_PARAM = 0x13, - C_RXON_TIMING = 0x14, - - /* Multi-Station support */ - C_ADD_STA = 0x18, - C_REM_STA = 0x19, - - /* Security */ - C_WEPKEY = 0x20, - - /* RX, TX, LEDs */ - N_3945_RX = 0x1b, /* 3945 only */ - C_TX = 0x1c, - C_RATE_SCALE = 0x47, /* 3945 only */ - C_LEDS = 0x48, - C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ - - /* 802.11h related */ - C_CHANNEL_SWITCH = 0x72, - N_CHANNEL_SWITCH = 0x73, - C_SPECTRUM_MEASUREMENT = 0x74, - N_SPECTRUM_MEASUREMENT = 0x75, - - /* Power Management */ - C_POWER_TBL = 0x77, - N_PM_SLEEP = 0x7A, - N_PM_DEBUG_STATS = 0x7B, - - /* Scan commands and notifications */ - C_SCAN = 0x80, - C_SCAN_ABORT = 0x81, - N_SCAN_START = 0x82, - N_SCAN_RESULTS = 0x83, - N_SCAN_COMPLETE = 0x84, - - /* IBSS/AP commands */ - N_BEACON = 0x90, - C_TX_BEACON= 0x91, - - /* Miscellaneous commands */ - C_TX_PWR_TBL = 0x97, - - /* Bluetooth device coexistence config command */ - C_BT_CONFIG = 0x9b, - - /* Statistics */ - C_STATS = 0x9c, - N_STATS = 0x9d, - - /* RF-KILL commands and notifications */ - N_CARD_STATE = 0xa1, - - /* Missed beacons notification */ - N_MISSED_BEACONS = 0xa2, - - C_CT_KILL_CONFIG = 0xa4, - C_SENSITIVITY = 0xa8, - C_PHY_CALIBRATION = 0xb0, - N_RX_PHY = 0xc0, - N_RX_MPDU = 0xc1, - N_RX = 0xc3, - N_COMPRESSED_BA = 0xc5, - - IL_CN_MAX = 0xff -}; - -/****************************************************************************** - * (0) - * Commonly used structures and definitions: - * Command header, rate_n_flags, txpower - * - *****************************************************************************/ - -/* il_cmd_header flags value */ -#define IL_CMD_FAILED_MSK 0x40 - -#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) -#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) -#define SEQ_TO_IDX(s) ((s) & 0xff) -#define IDX_TO_SEQ(i) ((i) & 0xff) -#define SEQ_HUGE_FRAME cpu_to_le16(0x4000) -#define SEQ_RX_FRAME cpu_to_le16(0x8000) - -/** - * struct il_cmd_header - * - * This header format appears in the beginning of each command sent from the - * driver, and each response/notification received from uCode. - */ -struct il_cmd_header { - u8 cmd; /* Command ID: C_RXON, etc. */ - u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ - /* - * The driver sets up the sequence number to values of its choosing. - * uCode does not use this value, but passes it back to the driver - * when sending the response to each driver-originated command, so - * the driver can match the response to the command. Since the values - * don't get used by uCode, the driver may set up an arbitrary format. - * - * There is one exception: uCode sets bit 15 when it originates - * the response/notification, i.e. when the response/notification - * is not a direct response to a command sent by the driver. For - * example, uCode issues N_3945_RX when it sends a received frame - * to the driver; it is not a direct response to any driver command. - * - * The Linux driver uses the following format: - * - * 0:7 tfd idx - position within TX queue - * 8:12 TX queue id - * 13 reserved - * 14 huge - driver sets this to indicate command is in the - * 'huge' storage at the end of the command buffers - * 15 unsolicited RX or uCode-originated notification - */ - __le16 sequence; - - /* command or response/notification data follows immediately */ - u8 data[0]; -} __packed; - - -/** - * struct il3945_tx_power - * - * Used in C_TX_PWR_TBL, C_SCAN, C_CHANNEL_SWITCH - * - * Each entry contains two values: - * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained - * linear value that multiplies the output of the digital signal processor, - * before being sent to the analog radio. - * 2) Radio gain. This sets the analog gain of the radio Tx path. - * It is a coarser setting, and behaves in a logarithmic (dB) fashion. - * - * Driver obtains values from struct il3945_tx_power power_gain_table[][]. - */ -struct il3945_tx_power { - u8 tx_gain; /* gain for analog radio */ - u8 dsp_atten; /* gain for DSP */ -} __packed; - -/** - * struct il3945_power_per_rate - * - * Used in C_TX_PWR_TBL, C_CHANNEL_SWITCH - */ -struct il3945_power_per_rate { - u8 rate; /* plcp */ - struct il3945_tx_power tpc; - u8 reserved; -} __packed; - -/** - * iwl4965 rate_n_flags bit fields - * - * rate_n_flags format is used in following iwl4965 commands: - * N_RX (response only) - * N_RX_MPDU (response only) - * C_TX (both command and response) - * C_TX_LINK_QUALITY_CMD - * - * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"): - * 2-0: 0) 6 Mbps - * 1) 12 Mbps - * 2) 18 Mbps - * 3) 24 Mbps - * 4) 36 Mbps - * 5) 48 Mbps - * 6) 54 Mbps - * 7) 60 Mbps - * - * 4-3: 0) Single stream (SISO) - * 1) Dual stream (MIMO) - * 2) Triple stream (MIMO) - * - * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data - * - * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"): - * 3-0: 0xD) 6 Mbps - * 0xF) 9 Mbps - * 0x5) 12 Mbps - * 0x7) 18 Mbps - * 0x9) 24 Mbps - * 0xB) 36 Mbps - * 0x1) 48 Mbps - * 0x3) 54 Mbps - * - * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"): - * 6-0: 10) 1 Mbps - * 20) 2 Mbps - * 55) 5.5 Mbps - * 110) 11 Mbps - */ -#define RATE_MCS_CODE_MSK 0x7 -#define RATE_MCS_SPATIAL_POS 3 -#define RATE_MCS_SPATIAL_MSK 0x18 -#define RATE_MCS_HT_DUP_POS 5 -#define RATE_MCS_HT_DUP_MSK 0x20 - -/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */ -#define RATE_MCS_FLAGS_POS 8 -#define RATE_MCS_HT_POS 8 -#define RATE_MCS_HT_MSK 0x100 - -/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */ -#define RATE_MCS_CCK_POS 9 -#define RATE_MCS_CCK_MSK 0x200 - -/* Bit 10: (1) Use Green Field preamble */ -#define RATE_MCS_GF_POS 10 -#define RATE_MCS_GF_MSK 0x400 - -/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */ -#define RATE_MCS_HT40_POS 11 -#define RATE_MCS_HT40_MSK 0x800 - -/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */ -#define RATE_MCS_DUP_POS 12 -#define RATE_MCS_DUP_MSK 0x1000 - -/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */ -#define RATE_MCS_SGI_POS 13 -#define RATE_MCS_SGI_MSK 0x2000 - -/** - * rate_n_flags Tx antenna masks - * 4965 has 2 transmitters - * bit14:16 - */ -#define RATE_MCS_ANT_POS 14 -#define RATE_MCS_ANT_A_MSK 0x04000 -#define RATE_MCS_ANT_B_MSK 0x08000 -#define RATE_MCS_ANT_C_MSK 0x10000 -#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK) -#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK) -#define RATE_ANT_NUM 3 - -#define POWER_TBL_NUM_ENTRIES 33 -#define POWER_TBL_NUM_HT_OFDM_ENTRIES 32 -#define POWER_TBL_CCK_ENTRY 32 - -#define IL_PWR_NUM_HT_OFDM_ENTRIES 24 -#define IL_PWR_CCK_ENTRIES 2 - -/** - * union il4965_tx_power_dual_stream - * - * Host format used for C_TX_PWR_TBL, C_CHANNEL_SWITCH - * Use __le32 version (struct tx_power_dual_stream) when building command. - * - * Driver provides radio gain and DSP attenuation settings to device in pairs, - * one value for each transmitter chain. The first value is for transmitter A, - * second for transmitter B. - * - * For SISO bit rates, both values in a pair should be identical. - * For MIMO rates, one value may be different from the other, - * in order to balance the Tx output between the two transmitters. - * - * See more details in doc for TXPOWER in 4965.h. - */ -union il4965_tx_power_dual_stream { - struct { - u8 radio_tx_gain[2]; - u8 dsp_predis_atten[2]; - } s; - u32 dw; -}; - -/** - * struct tx_power_dual_stream - * - * Table entries in C_TX_PWR_TBL, C_CHANNEL_SWITCH - * - * Same format as il_tx_power_dual_stream, but __le32 - */ -struct tx_power_dual_stream { - __le32 dw; -} __packed; - -/** - * struct il4965_tx_power_db - * - * Entire table within C_TX_PWR_TBL, C_CHANNEL_SWITCH - */ -struct il4965_tx_power_db { - struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; -} __packed; - -/****************************************************************************** - * (0a) - * Alive and Error Commands & Responses: - * - *****************************************************************************/ - -#define UCODE_VALID_OK cpu_to_le32(0x1) -#define INITIALIZE_SUBTYPE (9) - -/* - * ("Initialize") N_ALIVE = 0x1 (response only, not a command) - * - * uCode issues this "initialize alive" notification once the initialization - * uCode image has completed its work, and is ready to load the runtime image. - * This is the *first* "alive" notification that the driver will receive after - * rebooting uCode; the "initialize" alive is indicated by subtype field == 9. - * - * See comments documenting "BSM" (bootstrap state machine). - * - * For 4965, this notification contains important calibration data for - * calculating txpower settings: - * - * 1) Power supply voltage indication. The voltage sensor outputs higher - * values for lower voltage, and vice verse. - * - * 2) Temperature measurement parameters, for each of two channel widths - * (20 MHz and 40 MHz) supported by the radios. Temperature sensing - * is done via one of the receiver chains, and channel width influences - * the results. - * - * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, - * for each of 5 frequency ranges. - */ -struct il_init_alive_resp { - u8 ucode_minor; - u8 ucode_major; - __le16 reserved1; - u8 sw_rev[8]; - u8 ver_type; - u8 ver_subtype; /* "9" for initialize alive */ - __le16 reserved2; - __le32 log_event_table_ptr; - __le32 error_event_table_ptr; - __le32 timestamp; - __le32 is_valid; - - /* calibration values from "initialize" uCode */ - __le32 voltage; /* signed, higher value is lower voltage */ - __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */ - __le32 therm_r2[2]; /* signed */ - __le32 therm_r3[2]; /* signed */ - __le32 therm_r4[2]; /* signed */ - __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups, - * 2 Tx chains */ -} __packed; - - -/** - * N_ALIVE = 0x1 (response only, not a command) - * - * uCode issues this "alive" notification once the runtime image is ready - * to receive commands from the driver. This is the *second* "alive" - * notification that the driver will receive after rebooting uCode; - * this "alive" is indicated by subtype field != 9. - * - * See comments documenting "BSM" (bootstrap state machine). - * - * This response includes two pointers to structures within the device's - * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging: - * - * 1) log_event_table_ptr indicates base of the event log. This traces - * a 256-entry history of uCode execution within a circular buffer. - * Its header format is: - * - * __le32 log_size; log capacity (in number of entries) - * __le32 type; (1) timestamp with each entry, (0) no timestamp - * __le32 wraps; # times uCode has wrapped to top of circular buffer - * __le32 write_idx; next circular buffer entry that uCode would fill - * - * The header is followed by the circular buffer of log entries. Entries - * with timestamps have the following format: - * - * __le32 event_id; range 0 - 1500 - * __le32 timestamp; low 32 bits of TSF (of network, if associated) - * __le32 data; event_id-specific data value - * - * Entries without timestamps contain only event_id and data. - * - * - * 2) error_event_table_ptr indicates base of the error log. This contains - * information about any uCode error that occurs. For 4965, the format - * of the error log is: - * - * __le32 valid; (nonzero) valid, (0) log is empty - * __le32 error_id; type of error - * __le32 pc; program counter - * __le32 blink1; branch link - * __le32 blink2; branch link - * __le32 ilink1; interrupt link - * __le32 ilink2; interrupt link - * __le32 data1; error-specific data - * __le32 data2; error-specific data - * __le32 line; source code line of error - * __le32 bcon_time; beacon timer - * __le32 tsf_low; network timestamp function timer - * __le32 tsf_hi; network timestamp function timer - * __le32 gp1; GP1 timer register - * __le32 gp2; GP2 timer register - * __le32 gp3; GP3 timer register - * __le32 ucode_ver; uCode version - * __le32 hw_ver; HW Silicon version - * __le32 brd_ver; HW board version - * __le32 log_pc; log program counter - * __le32 frame_ptr; frame pointer - * __le32 stack_ptr; stack pointer - * __le32 hcmd; last host command - * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag - * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag - * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag - * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag - * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt - * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT - * __le32 wait_event; wait event() caller address - * __le32 l2p_control; L2pControlField - * __le32 l2p_duration; L2pDurationField - * __le32 l2p_mhvalid; L2pMhValidBits - * __le32 l2p_addr_match; L2pAddrMatchStat - * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL) - * __le32 u_timestamp; indicate when the date and time of the compilation - * __le32 reserved; - * - * The Linux driver can print both logs to the system log when a uCode error - * occurs. - */ -struct il_alive_resp { - u8 ucode_minor; - u8 ucode_major; - __le16 reserved1; - u8 sw_rev[8]; - u8 ver_type; - u8 ver_subtype; /* not "9" for runtime alive */ - __le16 reserved2; - __le32 log_event_table_ptr; /* SRAM address for event log */ - __le32 error_event_table_ptr; /* SRAM address for error log */ - __le32 timestamp; - __le32 is_valid; -} __packed; - -/* - * N_ERROR = 0x2 (response only, not a command) - */ -struct il_error_resp { - __le32 error_type; - u8 cmd_id; - u8 reserved1; - __le16 bad_cmd_seq_num; - __le32 error_info; - __le64 timestamp; -} __packed; - -/****************************************************************************** - * (1) - * RXON Commands & Responses: - * - *****************************************************************************/ - -/* - * Rx config defines & structure - */ -/* rx_config device types */ -enum { - RXON_DEV_TYPE_AP = 1, - RXON_DEV_TYPE_ESS = 3, - RXON_DEV_TYPE_IBSS = 4, - RXON_DEV_TYPE_SNIFFER = 6, -}; - - -#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0) -#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0) -#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1) -#define RXON_RX_CHAIN_VALID_POS (1) -#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4) -#define RXON_RX_CHAIN_FORCE_SEL_POS (4) -#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7) -#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7) -#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10) -#define RXON_RX_CHAIN_CNT_POS (10) -#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12) -#define RXON_RX_CHAIN_MIMO_CNT_POS (12) -#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14) -#define RXON_RX_CHAIN_MIMO_FORCE_POS (14) - -/* rx_config flags */ -/* band & modulation selection */ -#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0) -#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1) -/* auto detection enable */ -#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2) -/* TGg protection when tx */ -#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3) -/* cck short slot & preamble */ -#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4) -#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5) -/* antenna selection */ -#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7) -#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00) -#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8) -#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9) -/* radar detection enable */ -#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12) -#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13) -/* rx response to host with 8-byte TSF -* (according to ON_AIR deassertion) */ -#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15) - - -/* HT flags */ -#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22) -#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22) - -#define RXON_FLG_HT_OPERATING_MODE_POS (23) - -#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23) -#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23) - -#define RXON_FLG_CHANNEL_MODE_POS (25) -#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25) - -/* channel mode */ -enum { - CHANNEL_MODE_LEGACY = 0, - CHANNEL_MODE_PURE_40 = 1, - CHANNEL_MODE_MIXED = 2, - CHANNEL_MODE_RESERVED = 3, -}; -#define RXON_FLG_CHANNEL_MODE_LEGACY \ - cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS) -#define RXON_FLG_CHANNEL_MODE_PURE_40 \ - cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS) -#define RXON_FLG_CHANNEL_MODE_MIXED \ - cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS) - -/* CTS to self (if spec allows) flag */ -#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30) - -/* rx_config filter flags */ -/* accept all data frames */ -#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0) -/* pass control & management to host */ -#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1) -/* accept multi-cast */ -#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2) -/* don't decrypt uni-cast frames */ -#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3) -/* don't decrypt multi-cast frames */ -#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4) -/* STA is associated */ -#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5) -/* transfer to host non bssid beacons in associated state */ -#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6) - -/** - * C_RXON = 0x10 (command, has simple generic response) - * - * RXON tunes the radio tuner to a service channel, and sets up a number - * of parameters that are used primarily for Rx, but also for Tx operations. - * - * NOTE: When tuning to a new channel, driver must set the - * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent - * info within the device, including the station tables, tx retry - * rate tables, and txpower tables. Driver must build a new station - * table and txpower table before transmitting anything on the RXON - * channel. - * - * NOTE: All RXONs wipe clean the internal txpower table. Driver must - * issue a new C_TX_PWR_TBL after each C_RXON (0x10), - * regardless of whether RXON_FILTER_ASSOC_MSK is set. - */ - -struct il3945_rxon_cmd { - u8 node_addr[6]; - __le16 reserved1; - u8 bssid_addr[6]; - __le16 reserved2; - u8 wlap_bssid_addr[6]; - __le16 reserved3; - u8 dev_type; - u8 air_propagation; - __le16 reserved4; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 assoc_id; - __le32 flags; - __le32 filter_flags; - __le16 channel; - __le16 reserved5; -} __packed; - -struct il4965_rxon_cmd { - u8 node_addr[6]; - __le16 reserved1; - u8 bssid_addr[6]; - __le16 reserved2; - u8 wlap_bssid_addr[6]; - __le16 reserved3; - u8 dev_type; - u8 air_propagation; - __le16 rx_chain; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 assoc_id; - __le32 flags; - __le32 filter_flags; - __le16 channel; - u8 ofdm_ht_single_stream_basic_rates; - u8 ofdm_ht_dual_stream_basic_rates; -} __packed; - -/* Create a common rxon cmd which will be typecast into the 3945 or 4965 - * specific rxon cmd, depending on where it is called from. - */ -struct il_rxon_cmd { - u8 node_addr[6]; - __le16 reserved1; - u8 bssid_addr[6]; - __le16 reserved2; - u8 wlap_bssid_addr[6]; - __le16 reserved3; - u8 dev_type; - u8 air_propagation; - __le16 rx_chain; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 assoc_id; - __le32 flags; - __le32 filter_flags; - __le16 channel; - u8 ofdm_ht_single_stream_basic_rates; - u8 ofdm_ht_dual_stream_basic_rates; - u8 reserved4; - u8 reserved5; -} __packed; - - -/* - * C_RXON_ASSOC = 0x11 (command, has simple generic response) - */ -struct il3945_rxon_assoc_cmd { - __le32 flags; - __le32 filter_flags; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 reserved; -} __packed; - -struct il4965_rxon_assoc_cmd { - __le32 flags; - __le32 filter_flags; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - u8 ofdm_ht_single_stream_basic_rates; - u8 ofdm_ht_dual_stream_basic_rates; - __le16 rx_chain_select_flags; - __le16 reserved; -} __packed; - -#define IL_CONN_MAX_LISTEN_INTERVAL 10 -#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ -#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ - -/* - * C_RXON_TIMING = 0x14 (command, has simple generic response) - */ -struct il_rxon_time_cmd { - __le64 timestamp; - __le16 beacon_interval; - __le16 atim_win; - __le32 beacon_init_val; - __le16 listen_interval; - u8 dtim_period; - u8 delta_cp_bss_tbtts; -} __packed; - -/* - * C_CHANNEL_SWITCH = 0x72 (command, has simple generic response) - */ -struct il3945_channel_switch_cmd { - u8 band; - u8 expect_beacon; - __le16 channel; - __le32 rxon_flags; - __le32 rxon_filter_flags; - __le32 switch_time; - struct il3945_power_per_rate power[IL_MAX_RATES]; -} __packed; - -struct il4965_channel_switch_cmd { - u8 band; - u8 expect_beacon; - __le16 channel; - __le32 rxon_flags; - __le32 rxon_filter_flags; - __le32 switch_time; - struct il4965_tx_power_db tx_power; -} __packed; - -/* - * N_CHANNEL_SWITCH = 0x73 (notification only, not a command) - */ -struct il_csa_notification { - __le16 band; - __le16 channel; - __le32 status; /* 0 - OK, 1 - fail */ -} __packed; - -/****************************************************************************** - * (2) - * Quality-of-Service (QOS) Commands & Responses: - * - *****************************************************************************/ - -/** - * struct il_ac_qos -- QOS timing params for C_QOS_PARAM - * One for each of 4 EDCA access categories in struct il_qosparam_cmd - * - * @cw_min: Contention win, start value in numbers of slots. - * Should be a power-of-2, minus 1. Device's default is 0x0f. - * @cw_max: Contention win, max value in numbers of slots. - * Should be a power-of-2, minus 1. Device's default is 0x3f. - * @aifsn: Number of slots in Arbitration Interframe Space (before - * performing random backoff timing prior to Tx). Device default 1. - * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. - * - * Device will automatically increase contention win by (2*CW) + 1 for each - * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW - * value, to cap the CW value. - */ -struct il_ac_qos { - __le16 cw_min; - __le16 cw_max; - u8 aifsn; - u8 reserved1; - __le16 edca_txop; -} __packed; - -/* QoS flags defines */ -#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01) -#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02) -#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10) - -/* Number of Access Categories (AC) (EDCA), queues 0..3 */ -#define AC_NUM 4 - -/* - * C_QOS_PARAM = 0x13 (command, has simple generic response) - * - * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs - * 0: Background, 1: Best Effort, 2: Video, 3: Voice. - */ -struct il_qosparam_cmd { - __le32 qos_flags; - struct il_ac_qos ac[AC_NUM]; -} __packed; - -/****************************************************************************** - * (3) - * Add/Modify Stations Commands & Responses: - * - *****************************************************************************/ -/* - * Multi station support - */ - -/* Special, dedicated locations within device's station table */ -#define IL_AP_ID 0 -#define IL_STA_ID 2 -#define IL3945_BROADCAST_ID 24 -#define IL3945_STATION_COUNT 25 -#define IL4965_BROADCAST_ID 31 -#define IL4965_STATION_COUNT 32 - -#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ -#define IL_INVALID_STATION 255 - -#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) -#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) -#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17) -#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18) -#define STA_FLG_MAX_AGG_SIZE_POS (19) -#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19) -#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21) -#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22) -#define STA_FLG_AGG_MPDU_DENSITY_POS (23) -#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23) - -/* Use in mode field. 1: modify existing entry, 0: add new station entry */ -#define STA_CONTROL_MODIFY_MSK 0x01 - -/* key flags __le16*/ -#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007) -#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000) -#define STA_KEY_FLG_WEP cpu_to_le16(0x0001) -#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002) -#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003) - -#define STA_KEY_FLG_KEYID_POS 8 -#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800) -/* wep key is either from global key (0) or from station info array (1) */ -#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008) - -/* wep key in STA: 5-bytes (0) or 13-bytes (1) */ -#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000) -#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000) -#define STA_KEY_MAX_NUM 8 - -/* Flags indicate whether to modify vs. don't change various station params */ -#define STA_MODIFY_KEY_MASK 0x01 -#define STA_MODIFY_TID_DISABLE_TX 0x02 -#define STA_MODIFY_TX_RATE_MSK 0x04 -#define STA_MODIFY_ADDBA_TID_MSK 0x08 -#define STA_MODIFY_DELBA_TID_MSK 0x10 -#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20 - -/* Receiver address (actually, Rx station's idx into station table), - * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ -#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) - -struct il4965_keyinfo { - __le16 key_flags; - u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */ - u8 reserved1; - __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */ - u8 key_offset; - u8 reserved2; - u8 key[16]; /* 16-byte unicast decryption key */ -} __packed; - -/** - * struct sta_id_modify - * @addr[ETH_ALEN]: station's MAC address - * @sta_id: idx of station in uCode's station table - * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change - * - * Driver selects unused table idx when adding new station, - * or the idx to a pre-existing station entry when modifying that station. - * Some idxes have special purposes (IL_AP_ID, idx 0, is for AP). - * - * modify_mask flags select which parameters to modify vs. leave alone. - */ -struct sta_id_modify { - u8 addr[ETH_ALEN]; - __le16 reserved1; - u8 sta_id; - u8 modify_mask; - __le16 reserved2; -} __packed; - -/* - * C_ADD_STA = 0x18 (command) - * - * The device contains an internal table of per-station information, - * with info on security keys, aggregation parameters, and Tx rates for - * initial Tx attempt and any retries (4965 devices uses - * C_TX_LINK_QUALITY_CMD, - * 3945 uses C_RATE_SCALE to set up rate tables). - * - * C_ADD_STA sets up the table entry for one station, either creating - * a new entry, or modifying a pre-existing one. - * - * NOTE: RXON command (without "associated" bit set) wipes the station table - * clean. Moving into RF_KILL state does this also. Driver must set up - * new station table before transmitting anything on the RXON channel - * (except active scans or active measurements; those commands carry - * their own txpower/rate setup data). - * - * When getting started on a new channel, driver must set up the - * IL_BROADCAST_ID entry (last entry in the table). For a client - * station in a BSS, once an AP is selected, driver sets up the AP STA - * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP - * are all that are needed for a BSS client station. If the device is - * used as AP, or in an IBSS network, driver must set up station table - * entries for all STAs in network, starting with idx IL_STA_ID. - */ - -struct il3945_addsta_cmd { - u8 mode; /* 1: modify existing, 0: add new station */ - u8 reserved[3]; - struct sta_id_modify sta; - struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ - __le32 station_flags_msk; /* STA_FLG_* */ - - /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) - * corresponding to bit (e.g. bit 5 controls TID 5). - * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ - __le16 tid_disable_tx; - - __le16 rate_n_flags; - - /* TID for which to add block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - u8 add_immediate_ba_tid; - - /* TID for which to remove block-ack support. - * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ - u8 remove_immediate_ba_tid; - - /* Starting Sequence Number for added block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - __le16 add_immediate_ba_ssn; -} __packed; - -struct il4965_addsta_cmd { - u8 mode; /* 1: modify existing, 0: add new station */ - u8 reserved[3]; - struct sta_id_modify sta; - struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ - __le32 station_flags_msk; /* STA_FLG_* */ - - /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) - * corresponding to bit (e.g. bit 5 controls TID 5). - * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ - __le16 tid_disable_tx; - - __le16 reserved1; - - /* TID for which to add block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - u8 add_immediate_ba_tid; - - /* TID for which to remove block-ack support. - * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ - u8 remove_immediate_ba_tid; - - /* Starting Sequence Number for added block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - __le16 add_immediate_ba_ssn; - - /* - * Number of packets OK to transmit to station even though - * it is asleep -- used to synchronise PS-poll and u-APSD - * responses while ucode keeps track of STA sleep state. - */ - __le16 sleep_tx_count; - - __le16 reserved2; -} __packed; - -/* Wrapper struct for 3945 and 4965 addsta_cmd structures */ -struct il_addsta_cmd { - u8 mode; /* 1: modify existing, 0: add new station */ - u8 reserved[3]; - struct sta_id_modify sta; - struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ - __le32 station_flags_msk; /* STA_FLG_* */ - - /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) - * corresponding to bit (e.g. bit 5 controls TID 5). - * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ - __le16 tid_disable_tx; - - __le16 rate_n_flags; /* 3945 only */ - - /* TID for which to add block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - u8 add_immediate_ba_tid; - - /* TID for which to remove block-ack support. - * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ - u8 remove_immediate_ba_tid; - - /* Starting Sequence Number for added block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - __le16 add_immediate_ba_ssn; - - /* - * Number of packets OK to transmit to station even though - * it is asleep -- used to synchronise PS-poll and u-APSD - * responses while ucode keeps track of STA sleep state. - */ - __le16 sleep_tx_count; - - __le16 reserved2; -} __packed; - - -#define ADD_STA_SUCCESS_MSK 0x1 -#define ADD_STA_NO_ROOM_IN_TBL 0x2 -#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 -#define ADD_STA_MODIFY_NON_EXIST_STA 0x8 -/* - * C_ADD_STA = 0x18 (response) - */ -struct il_add_sta_resp { - u8 status; /* ADD_STA_* */ -} __packed; - -#define REM_STA_SUCCESS_MSK 0x1 -/* - * C_REM_STA = 0x19 (response) - */ -struct il_rem_sta_resp { - u8 status; -} __packed; - -/* - * C_REM_STA = 0x19 (command) - */ -struct il_rem_sta_cmd { - u8 num_sta; /* number of removed stations */ - u8 reserved[3]; - u8 addr[ETH_ALEN]; /* MAC addr of the first station */ - u8 reserved2[2]; -} __packed; - -#define IL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) -#define IL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) -#define IL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) -#define IL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) -#define IL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) - -#define IL_DROP_SINGLE 0 -#define IL_DROP_SELECTED 1 -#define IL_DROP_ALL 2 - -/* - * REPLY_WEP_KEY = 0x20 - */ -struct il_wep_key { - u8 key_idx; - u8 key_offset; - u8 reserved1[2]; - u8 key_size; - u8 reserved2[3]; - u8 key[16]; -} __packed; - -struct il_wep_cmd { - u8 num_keys; - u8 global_key_type; - u8 flags; - u8 reserved; - struct il_wep_key key[0]; -} __packed; - -#define WEP_KEY_WEP_TYPE 1 -#define WEP_KEYS_MAX 4 -#define WEP_INVALID_OFFSET 0xff -#define WEP_KEY_LEN_64 5 -#define WEP_KEY_LEN_128 13 - -/****************************************************************************** - * (4) - * Rx Responses: - * - *****************************************************************************/ - -#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0) -#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1) - -#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0) -#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1) -#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2) -#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3) -#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0 -#define RX_RES_PHY_FLAGS_ANTENNA_POS 4 - -#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) -#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8) -#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8) -#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8) -#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8) -#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8) - -#define RX_RES_STATUS_STATION_FOUND (1<<6) -#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7) - -#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11) -#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11) -#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11) -#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11) -#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11) - -#define RX_MPDU_RES_STATUS_ICV_OK (0x20) -#define RX_MPDU_RES_STATUS_MIC_OK (0x40) -#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7) -#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) - - -struct il3945_rx_frame_stats { - u8 phy_count; - u8 id; - u8 rssi; - u8 agc; - __le16 sig_avg; - __le16 noise_diff; - u8 payload[0]; -} __packed; - -struct il3945_rx_frame_hdr { - __le16 channel; - __le16 phy_flags; - u8 reserved1; - u8 rate; - __le16 len; - u8 payload[0]; -} __packed; - -struct il3945_rx_frame_end { - __le32 status; - __le64 timestamp; - __le32 beacon_timestamp; -} __packed; - -/* - * N_3945_RX = 0x1b (response only, not a command) - * - * NOTE: DO NOT dereference from casts to this structure - * It is provided only for calculating minimum data set size. - * The actual offsets of the hdr and end are dynamic based on - * stats.phy_count - */ -struct il3945_rx_frame { - struct il3945_rx_frame_stats stats; - struct il3945_rx_frame_hdr hdr; - struct il3945_rx_frame_end end; -} __packed; - -#define IL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) - -/* Fixed (non-configurable) rx data from phy */ - -#define IL49_RX_RES_PHY_CNT 14 -#define IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) -#define IL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) -#define IL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ -#define IL49_AGC_DB_POS (7) -struct il4965_rx_non_cfg_phy { - __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ - __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ - u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */ - u8 pad[0]; -} __packed; - - -/* - * N_RX = 0xc3 (response only, not a command) - * Used only for legacy (non 11n) frames. - */ -struct il_rx_phy_res { - u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ - u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ - u8 stat_id; /* configurable DSP phy data set ID */ - u8 reserved1; - __le64 timestamp; /* TSF at on air rise */ - __le32 beacon_time_stamp; /* beacon at on-air rise */ - __le16 phy_flags; /* general phy flags: band, modulation, ... */ - __le16 channel; /* channel number */ - u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ - __le32 rate_n_flags; /* RATE_MCS_* */ - __le16 byte_count; /* frame's byte-count */ - __le16 frame_time; /* frame's time on the air */ -} __packed; - -struct il_rx_mpdu_res_start { - __le16 byte_count; - __le16 reserved; -} __packed; - - -/****************************************************************************** - * (5) - * Tx Commands & Responses: - * - * Driver must place each C_TX command into one of the prioritized Tx - * queues in host DRAM, shared between driver and device (see comments for - * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode - * are preparing to transmit, the device pulls the Tx command over the PCI - * bus via one of the device's Tx DMA channels, to fill an internal FIFO - * from which data will be transmitted. - * - * uCode handles all timing and protocol related to control frames - * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler - * handle reception of block-acks; uCode updates the host driver via - * N_COMPRESSED_BA. - * - * uCode handles retrying Tx when an ACK is expected but not received. - * This includes trying lower data rates than the one requested in the Tx - * command, as set up by the C_RATE_SCALE (for 3945) or - * C_TX_LINK_QUALITY_CMD (4965). - * - * Driver sets up transmit power for various rates via C_TX_PWR_TBL. - * This command must be executed after every RXON command, before Tx can occur. - *****************************************************************************/ - -/* C_TX Tx flags field */ - -/* - * 1: Use Request-To-Send protocol before this frame. - * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. - */ -#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1) - -/* - * 1: Transmit Clear-To-Send to self before this frame. - * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames. - * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. - */ -#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2) - -/* 1: Expect ACK from receiving station - * 0: Don't expect ACK (MAC header's duration field s/b 0) - * Set this for unicast frames, but not broadcast/multicast. */ -#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3) - -/* For 4965 devices: - * 1: Use rate scale table (see C_TX_LINK_QUALITY_CMD). - * Tx command's initial_rate_idx indicates first rate to try; - * uCode walks through table for additional Tx attempts. - * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. - * This rate will be used for all Tx attempts; it will not be scaled. */ -#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4) - -/* 1: Expect immediate block-ack. - * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */ -#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6) - -/* - * 1: Frame requires full Tx-Op protection. - * Set this if either RTS or CTS Tx Flag gets set. - */ -#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7) - -/* Tx antenna selection field; used only for 3945, reserved (0) for 4965 devices. - * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ -#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00) -#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8) -#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9) - -/* 1: uCode overrides sequence control field in MAC header. - * 0: Driver provides sequence control field in MAC header. - * Set this for management frames, non-QOS data frames, non-unicast frames, - * and also in Tx command embedded in C_SCAN for active scans. */ -#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13) - -/* 1: This frame is non-last MPDU; more fragments are coming. - * 0: Last fragment, or not using fragmentation. */ -#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14) - -/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame. - * 0: No TSF required in outgoing frame. - * Set this for transmitting beacons and probe responses. */ -#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16) - -/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword - * alignment of frame's payload data field. - * 0: No pad - * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4 - * field (but not both). Driver must align frame data (i.e. data following - * MAC header) to DWORD boundary. */ -#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20) - -/* accelerate aggregation support - * 0 - no CCMP encryption; 1 - CCMP encryption */ -#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22) - -/* HCCA-AP - disable duration overwriting. */ -#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25) - - -/* - * TX command security control - */ -#define TX_CMD_SEC_WEP 0x01 -#define TX_CMD_SEC_CCM 0x02 -#define TX_CMD_SEC_TKIP 0x03 -#define TX_CMD_SEC_MSK 0x03 -#define TX_CMD_SEC_SHIFT 6 -#define TX_CMD_SEC_KEY128 0x08 - -/* - * security overhead sizes - */ -#define WEP_IV_LEN 4 -#define WEP_ICV_LEN 4 -#define CCMP_MIC_LEN 8 -#define TKIP_ICV_LEN 4 - -/* - * C_TX = 0x1c (command) - */ - -struct il3945_tx_cmd { - /* - * MPDU byte count: - * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, - * + 8 byte IV for CCM or TKIP (not used for WEP) - * + Data payload - * + 8-byte MIC (not used for CCM/WEP) - * NOTE: Does not include Tx command bytes, post-MAC pad bytes, - * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i - * Range: 14-2342 bytes. - */ - __le16 len; - - /* - * MPDU or MSDU byte count for next frame. - * Used for fragmentation and bursting, but not 11n aggregation. - * Same as "len", but for next frame. Set to 0 if not applicable. - */ - __le16 next_frame_len; - - __le32 tx_flags; /* TX_CMD_FLG_* */ - - u8 rate; - - /* Index of recipient station in uCode's station table */ - u8 sta_id; - u8 tid_tspec; - u8 sec_ctl; - u8 key[16]; - union { - u8 byte[8]; - __le16 word[4]; - __le32 dw[2]; - } tkip_mic; - __le32 next_frame_info; - union { - __le32 life_time; - __le32 attempt; - } stop_time; - u8 supp_rates[2]; - u8 rts_retry_limit; /*byte 50 */ - u8 data_retry_limit; /*byte 51 */ - union { - __le16 pm_frame_timeout; - __le16 attempt_duration; - } timeout; - - /* - * Duration of EDCA burst Tx Opportunity, in 32-usec units. - * Set this if txop time is not specified by HCCA protocol (e.g. by AP). - */ - __le16 driver_txop; - - /* - * MAC header goes here, followed by 2 bytes padding if MAC header - * length is 26 or 30 bytes, followed by payload data - */ - u8 payload[0]; - struct ieee80211_hdr hdr[0]; -} __packed; - -/* - * C_TX = 0x1c (response) - */ -struct il3945_tx_resp { - u8 failure_rts; - u8 failure_frame; - u8 bt_kill_count; - u8 rate; - __le32 wireless_media_time; - __le32 status; /* TX status */ -} __packed; - - -/* - * 4965 uCode updates these Tx attempt count values in host DRAM. - * Used for managing Tx retries when expecting block-acks. - * Driver should set these fields to 0. - */ -struct il_dram_scratch { - u8 try_cnt; /* Tx attempts */ - u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */ - __le16 reserved; -} __packed; - -struct il_tx_cmd { - /* - * MPDU byte count: - * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, - * + 8 byte IV for CCM or TKIP (not used for WEP) - * + Data payload - * + 8-byte MIC (not used for CCM/WEP) - * NOTE: Does not include Tx command bytes, post-MAC pad bytes, - * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i - * Range: 14-2342 bytes. - */ - __le16 len; - - /* - * MPDU or MSDU byte count for next frame. - * Used for fragmentation and bursting, but not 11n aggregation. - * Same as "len", but for next frame. Set to 0 if not applicable. - */ - __le16 next_frame_len; - - __le32 tx_flags; /* TX_CMD_FLG_* */ - - /* uCode may modify this field of the Tx command (in host DRAM!). - * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */ - struct il_dram_scratch scratch; - - /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */ - __le32 rate_n_flags; /* RATE_MCS_* */ - - /* Index of destination station in uCode's station table */ - u8 sta_id; - - /* Type of security encryption: CCM or TKIP */ - u8 sec_ctl; /* TX_CMD_SEC_* */ - - /* - * Index into rate table (see C_TX_LINK_QUALITY_CMD) for initial - * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for - * data frames, this field may be used to selectively reduce initial - * rate (via non-0 value) for special frames (e.g. management), while - * still supporting rate scaling for all frames. - */ - u8 initial_rate_idx; - u8 reserved; - u8 key[16]; - __le16 next_frame_flags; - __le16 reserved2; - union { - __le32 life_time; - __le32 attempt; - } stop_time; - - /* Host DRAM physical address pointer to "scratch" in this command. - * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */ - __le32 dram_lsb_ptr; - u8 dram_msb_ptr; - - u8 rts_retry_limit; /*byte 50 */ - u8 data_retry_limit; /*byte 51 */ - u8 tid_tspec; - union { - __le16 pm_frame_timeout; - __le16 attempt_duration; - } timeout; - - /* - * Duration of EDCA burst Tx Opportunity, in 32-usec units. - * Set this if txop time is not specified by HCCA protocol (e.g. by AP). - */ - __le16 driver_txop; - - /* - * MAC header goes here, followed by 2 bytes padding if MAC header - * length is 26 or 30 bytes, followed by payload data - */ - u8 payload[0]; - struct ieee80211_hdr hdr[0]; -} __packed; - -/* TX command response is sent after *3945* transmission attempts. - * - * NOTES: - * - * TX_STATUS_FAIL_NEXT_FRAG - * - * If the fragment flag in the MAC header for the frame being transmitted - * is set and there is insufficient time to transmit the next frame, the - * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'. - * - * TX_STATUS_FIFO_UNDERRUN - * - * Indicates the host did not provide bytes to the FIFO fast enough while - * a TX was in progress. - * - * TX_STATUS_FAIL_MGMNT_ABORT - * - * This status is only possible if the ABORT ON MGMT RX parameter was - * set to true with the TX command. - * - * If the MSB of the status parameter is set then an abort sequence is - * required. This sequence consists of the host activating the TX Abort - * control line, and then waiting for the TX Abort command response. This - * indicates that a the device is no longer in a transmit state, and that the - * command FIFO has been cleared. The host must then deactivate the TX Abort - * control line. Receiving is still allowed in this case. - */ -enum { - TX_3945_STATUS_SUCCESS = 0x01, - TX_3945_STATUS_DIRECT_DONE = 0x02, - TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82, - TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83, - TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84, - TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85, - TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86, - TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87, - TX_3945_STATUS_FAIL_DEST_PS = 0x88, - TX_3945_STATUS_FAIL_ABORTED = 0x89, - TX_3945_STATUS_FAIL_BT_RETRY = 0x8a, - TX_3945_STATUS_FAIL_STA_INVALID = 0x8b, - TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c, - TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d, - TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e, - TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, - TX_3945_STATUS_FAIL_TX_LOCKED = 0x90, - TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, -}; - -/* - * TX command response is sent after *4965* transmission attempts. - * - * both postpone and abort status are expected behavior from uCode. there is - * no special operation required from driver; except for RFKILL_FLUSH, - * which required tx flush host command to flush all the tx frames in queues - */ -enum { - TX_STATUS_SUCCESS = 0x01, - TX_STATUS_DIRECT_DONE = 0x02, - /* postpone TX */ - TX_STATUS_POSTPONE_DELAY = 0x40, - TX_STATUS_POSTPONE_FEW_BYTES = 0x41, - TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43, - TX_STATUS_POSTPONE_CALC_TTAK = 0x44, - /* abort TX */ - TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81, - TX_STATUS_FAIL_SHORT_LIMIT = 0x82, - TX_STATUS_FAIL_LONG_LIMIT = 0x83, - TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84, - TX_STATUS_FAIL_DRAIN_FLOW = 0x85, - TX_STATUS_FAIL_RFKILL_FLUSH = 0x86, - TX_STATUS_FAIL_LIFE_EXPIRE = 0x87, - TX_STATUS_FAIL_DEST_PS = 0x88, - TX_STATUS_FAIL_HOST_ABORTED = 0x89, - TX_STATUS_FAIL_BT_RETRY = 0x8a, - TX_STATUS_FAIL_STA_INVALID = 0x8b, - TX_STATUS_FAIL_FRAG_DROPPED = 0x8c, - TX_STATUS_FAIL_TID_DISABLE = 0x8d, - TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e, - TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, - TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90, - TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, -}; - -#define TX_PACKET_MODE_REGULAR 0x0000 -#define TX_PACKET_MODE_BURST_SEQ 0x0100 -#define TX_PACKET_MODE_BURST_FIRST 0x0200 - -enum { - TX_POWER_PA_NOT_ACTIVE = 0x0, -}; - -enum { - TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ - TX_STATUS_DELAY_MSK = 0x00000040, - TX_STATUS_ABORT_MSK = 0x00000080, - TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */ - TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */ - TX_RESERVED = 0x00780000, /* bits 19:22 */ - TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */ - TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ -}; - -/* ******************************* - * TX aggregation status - ******************************* */ - -enum { - AGG_TX_STATE_TRANSMITTED = 0x00, - AGG_TX_STATE_UNDERRUN_MSK = 0x01, - AGG_TX_STATE_FEW_BYTES_MSK = 0x04, - AGG_TX_STATE_ABORT_MSK = 0x08, - AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10, - AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20, - AGG_TX_STATE_SCD_QUERY_MSK = 0x80, - AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100, - AGG_TX_STATE_RESPONSE_MSK = 0x1ff, - AGG_TX_STATE_DUMP_TX_MSK = 0x200, - AGG_TX_STATE_DELAY_TX_MSK = 0x400 -}; - -#define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */ -#define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */ - -#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \ - AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK) - -/* # tx attempts for first frame in aggregation */ -#define AGG_TX_STATE_TRY_CNT_POS 12 -#define AGG_TX_STATE_TRY_CNT_MSK 0xf000 - -/* Command ID and sequence number of Tx command for this frame */ -#define AGG_TX_STATE_SEQ_NUM_POS 16 -#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 - -/* - * C_TX = 0x1c (response) - * - * This response may be in one of two slightly different formats, indicated - * by the frame_count field: - * - * 1) No aggregation (frame_count == 1). This reports Tx results for - * a single frame. Multiple attempts, at various bit rates, may have - * been made for this frame. - * - * 2) Aggregation (frame_count > 1). This reports Tx results for - * 2 or more frames that used block-acknowledge. All frames were - * transmitted at same rate. Rate scaling may have been used if first - * frame in this new agg block failed in previous agg block(s). - * - * Note that, for aggregation, ACK (block-ack) status is not delivered here; - * block-ack has not been received by the time the 4965 device records - * this status. - * This status relates to reasons the tx might have been blocked or aborted - * within the sending station (this 4965 device), rather than whether it was - * received successfully by the destination station. - */ -struct agg_tx_status { - __le16 status; - __le16 sequence; -} __packed; - -struct il4965_tx_resp { - u8 frame_count; /* 1 no aggregation, >1 aggregation */ - u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ - u8 failure_rts; /* # failures due to unsuccessful RTS */ - u8 failure_frame; /* # failures due to no ACK (unused for agg) */ - - /* For non-agg: Rate at which frame was successful. - * For agg: Rate at which all frames were transmitted. */ - __le32 rate_n_flags; /* RATE_MCS_* */ - - /* For non-agg: RTS + CTS + frame tx attempts time + ACK. - * For agg: RTS + CTS + aggregation tx time + block-ack time. */ - __le16 wireless_media_time; /* uSecs */ - - __le16 reserved; - __le32 pa_power1; /* RF power amplifier measurement (not used) */ - __le32 pa_power2; - - /* - * For non-agg: frame status TX_STATUS_* - * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status - * fields follow this one, up to frame_count. - * Bit fields: - * 11- 0: AGG_TX_STATE_* status code - * 15-12: Retry count for 1st frame in aggregation (retries - * occur if tx failed for this frame when it was a - * member of a previous aggregation block). If rate - * scaling is used, retry count indicates the rate - * table entry used for all frames in the new agg. - * 31-16: Sequence # for this frame's Tx cmd (not SSN!) - */ - union { - __le32 status; - struct agg_tx_status agg_status[0]; /* for each agg frame */ - } u; -} __packed; - -/* - * N_COMPRESSED_BA = 0xc5 (response only, not a command) - * - * Reports Block-Acknowledge from recipient station - */ -struct il_compressed_ba_resp { - __le32 sta_addr_lo32; - __le16 sta_addr_hi16; - __le16 reserved; - - /* Index of recipient (BA-sending) station in uCode's station table */ - u8 sta_id; - u8 tid; - __le16 seq_ctl; - __le64 bitmap; - __le16 scd_flow; - __le16 scd_ssn; -} __packed; - -/* - * C_TX_PWR_TBL = 0x97 (command, has simple generic response) - * - * See details under "TXPOWER" in 4965.h. - */ - -struct il3945_txpowertable_cmd { - u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ - u8 reserved; - __le16 channel; - struct il3945_power_per_rate power[IL_MAX_RATES]; -} __packed; - -struct il4965_txpowertable_cmd { - u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ - u8 reserved; - __le16 channel; - struct il4965_tx_power_db tx_power; -} __packed; - - -/** - * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response - * - * C_RATE_SCALE = 0x47 (command, has simple generic response) - * - * NOTE: The table of rates passed to the uCode via the - * RATE_SCALE command sets up the corresponding order of - * rates used for all related commands, including rate - * masks, etc. - * - * For example, if you set 9MB (PLCP 0x0f) as the first - * rate in the rate table, the bit mask for that rate - * when passed through ofdm_basic_rates on the C_RXON - * command would be bit 0 (1 << 0) - */ -struct il3945_rate_scaling_info { - __le16 rate_n_flags; - u8 try_cnt; - u8 next_rate_idx; -} __packed; - -struct il3945_rate_scaling_cmd { - u8 table_id; - u8 reserved[3]; - struct il3945_rate_scaling_info table[IL_MAX_RATES]; -} __packed; - - -/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */ -#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0) - -/* # of EDCA prioritized tx fifos */ -#define LINK_QUAL_AC_NUM AC_NUM - -/* # entries in rate scale table to support Tx retries */ -#define LINK_QUAL_MAX_RETRY_NUM 16 - -/* Tx antenna selection values */ -#define LINK_QUAL_ANT_A_MSK (1 << 0) -#define LINK_QUAL_ANT_B_MSK (1 << 1) -#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK) - - -/** - * struct il_link_qual_general_params - * - * Used in C_TX_LINK_QUALITY_CMD - */ -struct il_link_qual_general_params { - u8 flags; - - /* No entries at or above this (driver chosen) idx contain MIMO */ - u8 mimo_delimiter; - - /* Best single antenna to use for single stream (legacy, SISO). */ - u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */ - - /* Best antennas to use for MIMO (unused for 4965, assumes both). */ - u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ - - /* - * If driver needs to use different initial rates for different - * EDCA QOS access categories (as implemented by tx fifos 0-3), - * this table will set that up, by indicating the idxes in the - * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start. - * Otherwise, driver should set all entries to 0. - * - * Entry usage: - * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice - * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3. - */ - u8 start_rate_idx[LINK_QUAL_AC_NUM]; -} __packed; - -#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ -#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000) -#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100) - -#define LINK_QUAL_AGG_DISABLE_START_DEF (3) -#define LINK_QUAL_AGG_DISABLE_START_MAX (255) -#define LINK_QUAL_AGG_DISABLE_START_MIN (0) - -#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31) -#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63) -#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) - -/** - * struct il_link_qual_agg_params - * - * Used in C_TX_LINK_QUALITY_CMD - */ -struct il_link_qual_agg_params { - - /* - *Maximum number of uSec in aggregation. - * default set to 4000 (4 milliseconds) if not configured in .cfg - */ - __le16 agg_time_limit; - - /* - * Number of Tx retries allowed for a frame, before that frame will - * no longer be considered for the start of an aggregation sequence - * (scheduler will then try to tx it as single frame). - * Driver should set this to 3. - */ - u8 agg_dis_start_th; - - /* - * Maximum number of frames in aggregation. - * 0 = no limit (default). 1 = no aggregation. - * Other values = max # frames in aggregation. - */ - u8 agg_frame_cnt_limit; - - __le32 reserved; -} __packed; - -/* - * C_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) - * - * For 4965 devices only; 3945 uses C_RATE_SCALE. - * - * Each station in the 4965 device's internal station table has its own table - * of 16 - * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when - * an ACK is not received. This command replaces the entire table for - * one station. - * - * NOTE: Station must already be in 4965 device's station table. - * Use C_ADD_STA. - * - * The rate scaling procedures described below work well. Of course, other - * procedures are possible, and may work better for particular environments. - * - * - * FILLING THE RATE TBL - * - * Given a particular initial rate and mode, as determined by the rate - * scaling algorithm described below, the Linux driver uses the following - * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the - * Link Quality command: - * - * - * 1) If using High-throughput (HT) (SISO or MIMO) initial rate: - * a) Use this same initial rate for first 3 entries. - * b) Find next lower available rate using same mode (SISO or MIMO), - * use for next 3 entries. If no lower rate available, switch to - * legacy mode (no HT40 channel, no MIMO, no short guard interval). - * c) If using MIMO, set command's mimo_delimiter to number of entries - * using MIMO (3 or 6). - * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel, - * no MIMO, no short guard interval), at the next lower bit rate - * (e.g. if second HT bit rate was 54, try 48 legacy), and follow - * legacy procedure for remaining table entries. - * - * 2) If using legacy initial rate: - * a) Use the initial rate for only one entry. - * b) For each following entry, reduce the rate to next lower available - * rate, until reaching the lowest available rate. - * c) When reducing rate, also switch antenna selection. - * d) Once lowest available rate is reached, repeat this rate until - * rate table is filled (16 entries), switching antenna each entry. - * - * - * ACCUMULATING HISTORY - * - * The rate scaling algorithm for 4965 devices, as implemented in Linux driver, - * uses two sets of frame Tx success history: One for the current/active - * modulation mode, and one for a speculative/search mode that is being - * attempted. If the speculative mode turns out to be more effective (i.e. - * actual transfer rate is better), then the driver continues to use the - * speculative mode as the new current active mode. - * - * Each history set contains, separately for each possible rate, data for a - * sliding win of the 62 most recent tx attempts at that rate. The data - * includes a shifting bitmap of success(1)/failure(0), and sums of successful - * and attempted frames, from which the driver can additionally calculate a - * success ratio (success / attempted) and number of failures - * (attempted - success), and control the size of the win (attempted). - * The driver uses the bit map to remove successes from the success sum, as - * the oldest tx attempts fall out of the win. - * - * When the 4965 device makes multiple tx attempts for a given frame, each - * attempt might be at a different rate, and have different modulation - * characteristics (e.g. antenna, fat channel, short guard interval), as set - * up in the rate scaling table in the Link Quality command. The driver must - * determine which rate table entry was used for each tx attempt, to determine - * which rate-specific history to update, and record only those attempts that - * match the modulation characteristics of the history set. - * - * When using block-ack (aggregation), all frames are transmitted at the same - * rate, since there is no per-attempt acknowledgment from the destination - * station. The Tx response struct il_tx_resp indicates the Tx rate in - * rate_n_flags field. After receiving a block-ack, the driver can update - * history for the entire block all at once. - * - * - * FINDING BEST STARTING RATE: - * - * When working with a selected initial modulation mode (see below), the - * driver attempts to find a best initial rate. The initial rate is the - * first entry in the Link Quality command's rate table. - * - * 1) Calculate actual throughput (success ratio * expected throughput, see - * table below) for current initial rate. Do this only if enough frames - * have been attempted to make the value meaningful: at least 6 failed - * tx attempts, or at least 8 successes. If not enough, don't try rate - * scaling yet. - * - * 2) Find available rates adjacent to current initial rate. Available means: - * a) supported by hardware && - * b) supported by association && - * c) within any constraints selected by user - * - * 3) Gather measured throughputs for adjacent rates. These might not have - * enough history to calculate a throughput. That's okay, we might try - * using one of them anyway! - * - * 4) Try decreasing rate if, for current rate: - * a) success ratio is < 15% || - * b) lower adjacent rate has better measured throughput || - * c) higher adjacent rate has worse throughput, and lower is unmeasured - * - * As a sanity check, if decrease was determined above, leave rate - * unchanged if: - * a) lower rate unavailable - * b) success ratio at current rate > 85% (very good) - * c) current measured throughput is better than expected throughput - * of lower rate (under perfect 100% tx conditions, see table below) - * - * 5) Try increasing rate if, for current rate: - * a) success ratio is < 15% || - * b) both adjacent rates' throughputs are unmeasured (try it!) || - * b) higher adjacent rate has better measured throughput || - * c) lower adjacent rate has worse throughput, and higher is unmeasured - * - * As a sanity check, if increase was determined above, leave rate - * unchanged if: - * a) success ratio at current rate < 70%. This is not particularly - * good performance; higher rate is sure to have poorer success. - * - * 6) Re-evaluate the rate after each tx frame. If working with block- - * acknowledge, history and stats may be calculated for the entire - * block (including prior history that fits within the history wins), - * before re-evaluation. - * - * FINDING BEST STARTING MODULATION MODE: - * - * After working with a modulation mode for a "while" (and doing rate scaling), - * the driver searches for a new initial mode in an attempt to improve - * throughput. The "while" is measured by numbers of attempted frames: - * - * For legacy mode, search for new mode after: - * 480 successful frames, or 160 failed frames - * For high-throughput modes (SISO or MIMO), search for new mode after: - * 4500 successful frames, or 400 failed frames - * - * Mode switch possibilities are (3 for each mode): - * - * For legacy: - * Change antenna, try SISO (if HT association), try MIMO (if HT association) - * For SISO: - * Change antenna, try MIMO, try shortened guard interval (SGI) - * For MIMO: - * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI) - * - * When trying a new mode, use the same bit rate as the old/current mode when - * trying antenna switches and shortened guard interval. When switching to - * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate - * for which the expected throughput (under perfect conditions) is about the - * same or slightly better than the actual measured throughput delivered by - * the old/current mode. - * - * Actual throughput can be estimated by multiplying the expected throughput - * by the success ratio (successful / attempted tx frames). Frame size is - * not considered in this calculation; it assumes that frame size will average - * out to be fairly consistent over several samples. The following are - * metric values for expected throughput assuming 100% success ratio. - * Only G band has support for CCK rates: - * - * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60 - * - * G: 7 13 35 58 40 57 72 98 121 154 177 186 186 - * A: 0 0 0 0 40 57 72 98 121 154 177 186 186 - * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202 - * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211 - * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251 - * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257 - * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257 - * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264 - * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289 - * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293 - * - * After the new mode has been tried for a short while (minimum of 6 failed - * frames or 8 successful frames), compare success ratio and actual throughput - * estimate of the new mode with the old. If either is better with the new - * mode, continue to use the new mode. - * - * Continue comparing modes until all 3 possibilities have been tried. - * If moving from legacy to HT, try all 3 possibilities from the new HT - * mode. After trying all 3, a best mode is found. Continue to use this mode - * for the longer "while" described above (e.g. 480 successful frames for - * legacy), and then repeat the search process. - * - */ -struct il_link_quality_cmd { - - /* Index of destination/recipient station in uCode's station table */ - u8 sta_id; - u8 reserved1; - __le16 control; /* not used */ - struct il_link_qual_general_params general_params; - struct il_link_qual_agg_params agg_params; - - /* - * Rate info; when using rate-scaling, Tx command's initial_rate_idx - * specifies 1st Tx rate attempted, via idx into this table. - * 4965 devices works its way through table when retrying Tx. - */ - struct { - __le32 rate_n_flags; /* RATE_MCS_*, RATE_* */ - } rs_table[LINK_QUAL_MAX_RETRY_NUM]; - __le32 reserved2; -} __packed; - -/* - * BT configuration enable flags: - * bit 0 - 1: BT channel announcement enabled - * 0: disable - * bit 1 - 1: priority of BT device enabled - * 0: disable - */ -#define BT_COEX_DISABLE (0x0) -#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0) -#define BT_ENABLE_PRIORITY BIT(1) - -#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY) - -#define BT_LEAD_TIME_DEF (0x1E) - -#define BT_MAX_KILL_DEF (0x5) - -/* - * C_BT_CONFIG = 0x9b (command, has simple generic response) - * - * 3945 and 4965 devices support hardware handshake with Bluetooth device on - * same platform. Bluetooth device alerts wireless device when it will Tx; - * wireless device can delay or kill its own Tx to accommodate. - */ -struct il_bt_cmd { - u8 flags; - u8 lead_time; - u8 max_kill; - u8 reserved; - __le32 kill_ack_mask; - __le32 kill_cts_mask; -} __packed; - - -/****************************************************************************** - * (6) - * Spectrum Management (802.11h) Commands, Responses, Notifications: - * - *****************************************************************************/ - -/* - * Spectrum Management - */ -#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \ - RXON_FILTER_CTL2HOST_MSK | \ - RXON_FILTER_ACCEPT_GRP_MSK | \ - RXON_FILTER_DIS_DECRYPT_MSK | \ - RXON_FILTER_DIS_GRP_DECRYPT_MSK | \ - RXON_FILTER_ASSOC_MSK | \ - RXON_FILTER_BCON_AWARE_MSK) - -struct il_measure_channel { - __le32 duration; /* measurement duration in extended beacon - * format */ - u8 channel; /* channel to measure */ - u8 type; /* see enum il_measure_type */ - __le16 reserved; -} __packed; - -/* - * C_SPECTRUM_MEASUREMENT = 0x74 (command) - */ -struct il_spectrum_cmd { - __le16 len; /* number of bytes starting from token */ - u8 token; /* token id */ - u8 id; /* measurement id -- 0 or 1 */ - u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */ - u8 periodic; /* 1 = periodic */ - __le16 path_loss_timeout; - __le32 start_time; /* start time in extended beacon format */ - __le32 reserved2; - __le32 flags; /* rxon flags */ - __le32 filter_flags; /* rxon filter flags */ - __le16 channel_count; /* minimum 1, maximum 10 */ - __le16 reserved3; - struct il_measure_channel channels[10]; -} __packed; - -/* - * C_SPECTRUM_MEASUREMENT = 0x74 (response) - */ -struct il_spectrum_resp { - u8 token; - u8 id; /* id of the prior command replaced, or 0xff */ - __le16 status; /* 0 - command will be handled - * 1 - cannot handle (conflicts with another - * measurement) */ -} __packed; - -enum il_measurement_state { - IL_MEASUREMENT_START = 0, - IL_MEASUREMENT_STOP = 1, -}; - -enum il_measurement_status { - IL_MEASUREMENT_OK = 0, - IL_MEASUREMENT_CONCURRENT = 1, - IL_MEASUREMENT_CSA_CONFLICT = 2, - IL_MEASUREMENT_TGH_CONFLICT = 3, - /* 4-5 reserved */ - IL_MEASUREMENT_STOPPED = 6, - IL_MEASUREMENT_TIMEOUT = 7, - IL_MEASUREMENT_PERIODIC_FAILED = 8, -}; - -#define NUM_ELEMENTS_IN_HISTOGRAM 8 - -struct il_measurement_histogram { - __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */ - __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */ -} __packed; - -/* clear channel availability counters */ -struct il_measurement_cca_counters { - __le32 ofdm; - __le32 cck; -} __packed; - -enum il_measure_type { - IL_MEASURE_BASIC = (1 << 0), - IL_MEASURE_CHANNEL_LOAD = (1 << 1), - IL_MEASURE_HISTOGRAM_RPI = (1 << 2), - IL_MEASURE_HISTOGRAM_NOISE = (1 << 3), - IL_MEASURE_FRAME = (1 << 4), - /* bits 5:6 are reserved */ - IL_MEASURE_IDLE = (1 << 7), -}; - -/* - * N_SPECTRUM_MEASUREMENT = 0x75 (notification only, not a command) - */ -struct il_spectrum_notification { - u8 id; /* measurement id -- 0 or 1 */ - u8 token; - u8 channel_idx; /* idx in measurement channel list */ - u8 state; /* 0 - start, 1 - stop */ - __le32 start_time; /* lower 32-bits of TSF */ - u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ - u8 channel; - u8 type; /* see enum il_measurement_type */ - u8 reserved1; - /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only - * valid if applicable for measurement type requested. */ - __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */ - __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */ - __le32 cca_time; /* channel load time in usecs */ - u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 - - * unidentified */ - u8 reserved2[3]; - struct il_measurement_histogram histogram; - __le32 stop_time; /* lower 32-bits of TSF */ - __le32 status; /* see il_measurement_status */ -} __packed; - -/****************************************************************************** - * (7) - * Power Management Commands, Responses, Notifications: - * - *****************************************************************************/ - -/** - * struct il_powertable_cmd - Power Table Command - * @flags: See below: - * - * C_POWER_TBL = 0x77 (command, has simple generic response) - * - * PM allow: - * bit 0 - '0' Driver not allow power management - * '1' Driver allow PM (use rest of parameters) - * - * uCode send sleep notifications: - * bit 1 - '0' Don't send sleep notification - * '1' send sleep notification (SEND_PM_NOTIFICATION) - * - * Sleep over DTIM - * bit 2 - '0' PM have to walk up every DTIM - * '1' PM could sleep over DTIM till listen Interval. - * - * PCI power managed - * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1) - * '1' !(PCI_CFG_LINK_CTRL & 0x1) - * - * Fast PD - * bit 4 - '1' Put radio to sleep when receiving frame for others - * - * Force sleep Modes - * bit 31/30- '00' use both mac/xtal sleeps - * '01' force Mac sleep - * '10' force xtal sleep - * '11' Illegal set - * - * NOTE: if sleep_interval[SLEEP_INTRVL_TBL_SIZE-1] > DTIM period then - * ucode assume sleep over DTIM is allowed and we don't need to wake up - * for every DTIM. - */ -#define IL_POWER_VEC_SIZE 5 - -#define IL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) -#define IL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) - -struct il3945_powertable_cmd { - __le16 flags; - u8 reserved[2]; - __le32 rx_data_timeout; - __le32 tx_data_timeout; - __le32 sleep_interval[IL_POWER_VEC_SIZE]; -} __packed; - -struct il_powertable_cmd { - __le16 flags; - u8 keep_alive_seconds; /* 3945 reserved */ - u8 debug_flags; /* 3945 reserved */ - __le32 rx_data_timeout; - __le32 tx_data_timeout; - __le32 sleep_interval[IL_POWER_VEC_SIZE]; - __le32 keep_alive_beacons; -} __packed; - -/* - * N_PM_SLEEP = 0x7A (notification only, not a command) - * all devices identical. - */ -struct il_sleep_notification { - u8 pm_sleep_mode; - u8 pm_wakeup_src; - __le16 reserved; - __le32 sleep_time; - __le32 tsf_low; - __le32 bcon_timer; -} __packed; - -/* Sleep states. all devices identical. */ -enum { - IL_PM_NO_SLEEP = 0, - IL_PM_SLP_MAC = 1, - IL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, - IL_PM_SLP_FULL_MAC_CARD_STATE = 3, - IL_PM_SLP_PHY = 4, - IL_PM_SLP_REPENT = 5, - IL_PM_WAKEUP_BY_TIMER = 6, - IL_PM_WAKEUP_BY_DRIVER = 7, - IL_PM_WAKEUP_BY_RFKILL = 8, - /* 3 reserved */ - IL_PM_NUM_OF_MODES = 12, -}; - -/* - * N_CARD_STATE = 0xa1 (notification only, not a command) - */ -struct il_card_state_notif { - __le32 flags; -} __packed; - -#define HW_CARD_DISABLED 0x01 -#define SW_CARD_DISABLED 0x02 -#define CT_CARD_DISABLED 0x04 -#define RXON_CARD_DISABLED 0x10 - -struct il_ct_kill_config { - __le32 reserved; - __le32 critical_temperature_M; - __le32 critical_temperature_R; -} __packed; - -/****************************************************************************** - * (8) - * Scan Commands, Responses, Notifications: - * - *****************************************************************************/ - -#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0) -#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) - -/** - * struct il_scan_channel - entry in C_SCAN channel table - * - * One for each channel in the scan list. - * Each channel can independently select: - * 1) SSID for directed active scans - * 2) Txpower setting (for rate specified within Tx command) - * 3) How long to stay on-channel (behavior may be modified by quiet_time, - * quiet_plcp_th, good_CRC_th) - * - * To avoid uCode errors, make sure the following are true (see comments - * under struct il_scan_cmd about max_out_time and quiet_time): - * 1) If using passive_dwell (i.e. passive_dwell != 0): - * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0) - * 2) quiet_time <= active_dwell - * 3) If restricting off-channel time (i.e. max_out_time !=0): - * passive_dwell < max_out_time - * active_dwell < max_out_time - */ -struct il3945_scan_channel { - /* - * type is defined as: - * 0:0 1 = active, 0 = passive - * 1:4 SSID direct bit map; if a bit is set, then corresponding - * SSID IE is transmitted in probe request. - * 5:7 reserved - */ - u8 type; - u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ - struct il3945_tx_power tpc; - __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ - __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ -} __packed; - -/* set number of direct probes u8 type */ -#define IL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) - -struct il_scan_channel { - /* - * type is defined as: - * 0:0 1 = active, 0 = passive - * 1:20 SSID direct bit map; if a bit is set, then corresponding - * SSID IE is transmitted in probe request. - * 21:31 reserved - */ - __le32 type; - __le16 channel; /* band is selected by il_scan_cmd "flags" field */ - u8 tx_gain; /* gain for analog radio */ - u8 dsp_atten; /* gain for DSP */ - __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ - __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ -} __packed; - -/* set number of direct probes __le32 type */ -#define IL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) - -/** - * struct il_ssid_ie - directed scan network information element - * - * Up to 20 of these may appear in C_SCAN (Note: Only 4 are in - * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; - * each channel may select different ssids from among the 20 (4) entries. - * SSID IEs get transmitted in reverse order of entry. - */ -struct il_ssid_ie { - u8 id; - u8 len; - u8 ssid[32]; -} __packed; - -#define PROBE_OPTION_MAX_3945 4 -#define PROBE_OPTION_MAX 20 -#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) -#define IL_GOOD_CRC_TH_DISABLED 0 -#define IL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) -#define IL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) -#define IL_MAX_SCAN_SIZE 1024 -#define IL_MAX_CMD_SIZE 4096 - -/* - * C_SCAN = 0x80 (command) - * - * The hardware scan command is very powerful; the driver can set it up to - * maintain (relatively) normal network traffic while doing a scan in the - * background. The max_out_time and suspend_time control the ratio of how - * long the device stays on an associated network channel ("service channel") - * vs. how long it's away from the service channel, i.e. tuned to other channels - * for scanning. - * - * max_out_time is the max time off-channel (in usec), and suspend_time - * is how long (in "extended beacon" format) that the scan is "suspended" - * after returning to the service channel. That is, suspend_time is the - * time that we stay on the service channel, doing normal work, between - * scan segments. The driver may set these parameters differently to support - * scanning when associated vs. not associated, and light vs. heavy traffic - * loads when associated. - * - * After receiving this command, the device's scan engine does the following; - * - * 1) Sends SCAN_START notification to driver - * 2) Checks to see if it has time to do scan for one channel - * 3) Sends NULL packet, with power-save (PS) bit set to 1, - * to tell AP that we're going off-channel - * 4) Tunes to first channel in scan list, does active or passive scan - * 5) Sends SCAN_RESULT notification to driver - * 6) Checks to see if it has time to do scan on *next* channel in list - * 7) Repeats 4-6 until it no longer has time to scan the next channel - * before max_out_time expires - * 8) Returns to service channel - * 9) Sends NULL packet with PS=0 to tell AP that we're back - * 10) Stays on service channel until suspend_time expires - * 11) Repeats entire process 2-10 until list is complete - * 12) Sends SCAN_COMPLETE notification - * - * For fast, efficient scans, the scan command also has support for staying on - * a channel for just a short time, if doing active scanning and getting no - * responses to the transmitted probe request. This time is controlled by - * quiet_time, and the number of received packets below which a channel is - * considered "quiet" is controlled by quiet_plcp_threshold. - * - * For active scanning on channels that have regulatory restrictions against - * blindly transmitting, the scan can listen before transmitting, to make sure - * that there is already legitimate activity on the channel. If enough - * packets are cleanly received on the channel (controlled by good_CRC_th, - * typical value 1), the scan engine starts transmitting probe requests. - * - * Driver must use separate scan commands for 2.4 vs. 5 GHz bands. - * - * To avoid uCode errors, see timing restrictions described under - * struct il_scan_channel. - */ - -struct il3945_scan_cmd { - __le16 len; - u8 reserved0; - u8 channel_count; /* # channels in channel list */ - __le16 quiet_time; /* dwell only this # millisecs on quiet channel - * (only for active scan) */ - __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ - __le16 good_CRC_th; /* passive -> active promotion threshold */ - __le16 reserved1; - __le32 max_out_time; /* max usec to be away from associated (service) - * channel */ - __le32 suspend_time; /* pause scan this long (in "extended beacon - * format") when returning to service channel: - * 3945; 31:24 # beacons, 19:0 additional usec, - * 4965; 31:22 # beacons, 21:0 additional usec. - */ - __le32 flags; /* RXON_FLG_* */ - __le32 filter_flags; /* RXON_FILTER_* */ - - /* For active scans (set to all-0s for passive scans). - * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct il3945_tx_cmd tx_cmd; - - /* For directed active scans (set to all-0s otherwise) */ - struct il_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; - - /* - * Probe request frame, followed by channel list. - * - * Size of probe request frame is specified by byte count in tx_cmd. - * Channel list follows immediately after probe request frame. - * Number of channels in list is specified by channel_count. - * Each channel in list is of type: - * - * struct il3945_scan_channel channels[0]; - * - * NOTE: Only one band of channels can be scanned per pass. You - * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive N_SCAN_COMPLETE) - * before requesting another scan. - */ - u8 data[0]; -} __packed; - -struct il_scan_cmd { - __le16 len; - u8 reserved0; - u8 channel_count; /* # channels in channel list */ - __le16 quiet_time; /* dwell only this # millisecs on quiet channel - * (only for active scan) */ - __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ - __le16 good_CRC_th; /* passive -> active promotion threshold */ - __le16 rx_chain; /* RXON_RX_CHAIN_* */ - __le32 max_out_time; /* max usec to be away from associated (service) - * channel */ - __le32 suspend_time; /* pause scan this long (in "extended beacon - * format") when returning to service chnl: - * 3945; 31:24 # beacons, 19:0 additional usec, - * 4965; 31:22 # beacons, 21:0 additional usec. - */ - __le32 flags; /* RXON_FLG_* */ - __le32 filter_flags; /* RXON_FILTER_* */ - - /* For active scans (set to all-0s for passive scans). - * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct il_tx_cmd tx_cmd; - - /* For directed active scans (set to all-0s otherwise) */ - struct il_ssid_ie direct_scan[PROBE_OPTION_MAX]; - - /* - * Probe request frame, followed by channel list. - * - * Size of probe request frame is specified by byte count in tx_cmd. - * Channel list follows immediately after probe request frame. - * Number of channels in list is specified by channel_count. - * Each channel in list is of type: - * - * struct il_scan_channel channels[0]; - * - * NOTE: Only one band of channels can be scanned per pass. You - * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive N_SCAN_COMPLETE) - * before requesting another scan. - */ - u8 data[0]; -} __packed; - -/* Can abort will notify by complete notification with abort status. */ -#define CAN_ABORT_STATUS cpu_to_le32(0x1) -/* complete notification statuses */ -#define ABORT_STATUS 0x2 - -/* - * C_SCAN = 0x80 (response) - */ -struct il_scanreq_notification { - __le32 status; /* 1: okay, 2: cannot fulfill request */ -} __packed; - -/* - * N_SCAN_START = 0x82 (notification only, not a command) - */ -struct il_scanstart_notification { - __le32 tsf_low; - __le32 tsf_high; - __le32 beacon_timer; - u8 channel; - u8 band; - u8 reserved[2]; - __le32 status; -} __packed; - -#define SCAN_OWNER_STATUS 0x1 -#define MEASURE_OWNER_STATUS 0x2 - -#define IL_PROBE_STATUS_OK 0 -#define IL_PROBE_STATUS_TX_FAILED BIT(0) -/* error statuses combined with TX_FAILED */ -#define IL_PROBE_STATUS_FAIL_TTL BIT(1) -#define IL_PROBE_STATUS_FAIL_BT BIT(2) - -#define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ -/* - * N_SCAN_RESULTS = 0x83 (notification only, not a command) - */ -struct il_scanresults_notification { - u8 channel; - u8 band; - u8 probe_status; - u8 num_probe_not_sent; /* not enough time to send */ - __le32 tsf_low; - __le32 tsf_high; - __le32 stats[NUMBER_OF_STATS]; -} __packed; - -/* - * N_SCAN_COMPLETE = 0x84 (notification only, not a command) - */ -struct il_scancomplete_notification { - u8 scanned_channels; - u8 status; - u8 last_channel; - __le32 tsf_low; - __le32 tsf_high; -} __packed; - - -/****************************************************************************** - * (9) - * IBSS/AP Commands and Notifications: - * - *****************************************************************************/ - -enum il_ibss_manager { - IL_NOT_IBSS_MANAGER = 0, - IL_IBSS_MANAGER = 1, -}; - -/* - * N_BEACON = 0x90 (notification only, not a command) - */ - -struct il3945_beacon_notif { - struct il3945_tx_resp beacon_notify_hdr; - __le32 low_tsf; - __le32 high_tsf; - __le32 ibss_mgr_status; -} __packed; - -struct il4965_beacon_notif { - struct il4965_tx_resp beacon_notify_hdr; - __le32 low_tsf; - __le32 high_tsf; - __le32 ibss_mgr_status; -} __packed; - -/* - * C_TX_BEACON= 0x91 (command, has simple generic response) - */ - -struct il3945_tx_beacon_cmd { - struct il3945_tx_cmd tx; - __le16 tim_idx; - u8 tim_size; - u8 reserved1; - struct ieee80211_hdr frame[0]; /* beacon frame */ -} __packed; - -struct il_tx_beacon_cmd { - struct il_tx_cmd tx; - __le16 tim_idx; - u8 tim_size; - u8 reserved1; - struct ieee80211_hdr frame[0]; /* beacon frame */ -} __packed; - -/****************************************************************************** - * (10) - * Statistics Commands and Notifications: - * - *****************************************************************************/ - -#define IL_TEMP_CONVERT 260 - -#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 -#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 -#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 - -/* Used for passing to driver number of successes and failures per rate */ -struct rate_histogram { - union { - __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; - __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; - __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; - } success; - union { - __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; - __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; - __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; - } failed; -} __packed; - -/* stats command response */ - -struct iwl39_stats_rx_phy { - __le32 ina_cnt; - __le32 fina_cnt; - __le32 plcp_err; - __le32 crc32_err; - __le32 overrun_err; - __le32 early_overrun_err; - __le32 crc32_good; - __le32 false_alarm_cnt; - __le32 fina_sync_err_cnt; - __le32 sfd_timeout; - __le32 fina_timeout; - __le32 unresponded_rts; - __le32 rxe_frame_limit_overrun; - __le32 sent_ack_cnt; - __le32 sent_cts_cnt; -} __packed; - -struct iwl39_stats_rx_non_phy { - __le32 bogus_cts; /* CTS received when not expecting CTS */ - __le32 bogus_ack; /* ACK received when not expecting ACK */ - __le32 non_bssid_frames; /* number of frames with BSSID that - * doesn't belong to the STA BSSID */ - __le32 filtered_frames; /* count frames that were dumped in the - * filtering process */ - __le32 non_channel_beacons; /* beacons with our bss id but not on - * our serving channel */ -} __packed; - -struct iwl39_stats_rx { - struct iwl39_stats_rx_phy ofdm; - struct iwl39_stats_rx_phy cck; - struct iwl39_stats_rx_non_phy general; -} __packed; - -struct iwl39_stats_tx { - __le32 preamble_cnt; - __le32 rx_detected_cnt; - __le32 bt_prio_defer_cnt; - __le32 bt_prio_kill_cnt; - __le32 few_bytes_cnt; - __le32 cts_timeout; - __le32 ack_timeout; - __le32 expected_ack_cnt; - __le32 actual_ack_cnt; -} __packed; - -struct stats_dbg { - __le32 burst_check; - __le32 burst_count; - __le32 wait_for_silence_timeout_cnt; - __le32 reserved[3]; -} __packed; - -struct iwl39_stats_div { - __le32 tx_on_a; - __le32 tx_on_b; - __le32 exec_time; - __le32 probe_time; -} __packed; - -struct iwl39_stats_general { - __le32 temperature; - struct stats_dbg dbg; - __le32 sleep_time; - __le32 slots_out; - __le32 slots_idle; - __le32 ttl_timestamp; - struct iwl39_stats_div div; -} __packed; - -struct stats_rx_phy { - __le32 ina_cnt; - __le32 fina_cnt; - __le32 plcp_err; - __le32 crc32_err; - __le32 overrun_err; - __le32 early_overrun_err; - __le32 crc32_good; - __le32 false_alarm_cnt; - __le32 fina_sync_err_cnt; - __le32 sfd_timeout; - __le32 fina_timeout; - __le32 unresponded_rts; - __le32 rxe_frame_limit_overrun; - __le32 sent_ack_cnt; - __le32 sent_cts_cnt; - __le32 sent_ba_rsp_cnt; - __le32 dsp_self_kill; - __le32 mh_format_err; - __le32 re_acq_main_rssi_sum; - __le32 reserved3; -} __packed; - -struct stats_rx_ht_phy { - __le32 plcp_err; - __le32 overrun_err; - __le32 early_overrun_err; - __le32 crc32_good; - __le32 crc32_err; - __le32 mh_format_err; - __le32 agg_crc32_good; - __le32 agg_mpdu_cnt; - __le32 agg_cnt; - __le32 unsupport_mcs; -} __packed; - -#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1) - -struct stats_rx_non_phy { - __le32 bogus_cts; /* CTS received when not expecting CTS */ - __le32 bogus_ack; /* ACK received when not expecting ACK */ - __le32 non_bssid_frames; /* number of frames with BSSID that - * doesn't belong to the STA BSSID */ - __le32 filtered_frames; /* count frames that were dumped in the - * filtering process */ - __le32 non_channel_beacons; /* beacons with our bss id but not on - * our serving channel */ - __le32 channel_beacons; /* beacons with our bss id and in our - * serving channel */ - __le32 num_missed_bcon; /* number of missed beacons */ - __le32 adc_rx_saturation_time; /* count in 0.8us units the time the - * ADC was in saturation */ - __le32 ina_detection_search_time;/* total time (in 0.8us) searched - * for INA */ - __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */ - __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */ - __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */ - __le32 interference_data_flag; /* flag for interference data - * availability. 1 when data is - * available. */ - __le32 channel_load; /* counts RX Enable time in uSec */ - __le32 dsp_false_alarms; /* DSP false alarm (both OFDM - * and CCK) counter */ - __le32 beacon_rssi_a; - __le32 beacon_rssi_b; - __le32 beacon_rssi_c; - __le32 beacon_energy_a; - __le32 beacon_energy_b; - __le32 beacon_energy_c; -} __packed; - -struct stats_rx { - struct stats_rx_phy ofdm; - struct stats_rx_phy cck; - struct stats_rx_non_phy general; - struct stats_rx_ht_phy ofdm_ht; -} __packed; - -/** - * struct stats_tx_power - current tx power - * - * @ant_a: current tx power on chain a in 1/2 dB step - * @ant_b: current tx power on chain b in 1/2 dB step - * @ant_c: current tx power on chain c in 1/2 dB step - */ -struct stats_tx_power { - u8 ant_a; - u8 ant_b; - u8 ant_c; - u8 reserved; -} __packed; - -struct stats_tx_non_phy_agg { - __le32 ba_timeout; - __le32 ba_reschedule_frames; - __le32 scd_query_agg_frame_cnt; - __le32 scd_query_no_agg; - __le32 scd_query_agg; - __le32 scd_query_mismatch; - __le32 frame_not_ready; - __le32 underrun; - __le32 bt_prio_kill; - __le32 rx_ba_rsp_cnt; -} __packed; - -struct stats_tx { - __le32 preamble_cnt; - __le32 rx_detected_cnt; - __le32 bt_prio_defer_cnt; - __le32 bt_prio_kill_cnt; - __le32 few_bytes_cnt; - __le32 cts_timeout; - __le32 ack_timeout; - __le32 expected_ack_cnt; - __le32 actual_ack_cnt; - __le32 dump_msdu_cnt; - __le32 burst_abort_next_frame_mismatch_cnt; - __le32 burst_abort_missing_next_frame_cnt; - __le32 cts_timeout_collision; - __le32 ack_or_ba_timeout_collision; - struct stats_tx_non_phy_agg agg; - - __le32 reserved1; -} __packed; - - -struct stats_div { - __le32 tx_on_a; - __le32 tx_on_b; - __le32 exec_time; - __le32 probe_time; - __le32 reserved1; - __le32 reserved2; -} __packed; - -struct stats_general_common { - __le32 temperature; /* radio temperature */ - struct stats_dbg dbg; - __le32 sleep_time; - __le32 slots_out; - __le32 slots_idle; - __le32 ttl_timestamp; - struct stats_div div; - __le32 rx_enable_counter; - /* - * num_of_sos_states: - * count the number of times we have to re-tune - * in order to get out of bad PHY status - */ - __le32 num_of_sos_states; -} __packed; - -struct stats_general { - struct stats_general_common common; - __le32 reserved2; - __le32 reserved3; -} __packed; - -#define UCODE_STATS_CLEAR_MSK (0x1 << 0) -#define UCODE_STATS_FREQUENCY_MSK (0x1 << 1) -#define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) - -/* - * C_STATS = 0x9c, - * all devices identical. - * - * This command triggers an immediate response containing uCode stats. - * The response is in the same format as N_STATS 0x9d, below. - * - * If the CLEAR_STATS configuration flag is set, uCode will clear its - * internal copy of the stats (counters) after issuing the response. - * This flag does not affect N_STATSs after beacons (see below). - * - * If the DISABLE_NOTIF configuration flag is set, uCode will not issue - * N_STATSs after received beacons (see below). This flag - * does not affect the response to the C_STATS 0x9c itself. - */ -#define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ -#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ -struct il_stats_cmd { - __le32 configuration_flags; /* IL_STATS_CONF_* */ -} __packed; - -/* - * N_STATS = 0x9d (notification only, not a command) - * - * By default, uCode issues this notification after receiving a beacon - * while associated. To disable this behavior, set DISABLE_NOTIF flag in the - * C_STATS 0x9c, above. - * - * Statistics counters continue to increment beacon after beacon, but are - * cleared when changing channels or when driver issues C_STATS - * 0x9c with CLEAR_STATS bit set (see above). - * - * uCode also issues this notification during scans. uCode clears stats - * appropriately so that each notification contains stats for only the - * one channel that has just been scanned. - */ -#define STATS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) -#define STATS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) - -struct il3945_notif_stats { - __le32 flag; - struct iwl39_stats_rx rx; - struct iwl39_stats_tx tx; - struct iwl39_stats_general general; -} __packed; - -struct il_notif_stats { - __le32 flag; - struct stats_rx rx; - struct stats_tx tx; - struct stats_general general; -} __packed; - -/* - * N_MISSED_BEACONS = 0xa2 (notification only, not a command) - * - * uCode send N_MISSED_BEACONS to driver when detect beacon missed - * in regardless of how many missed beacons, which mean when driver receive the - * notification, inside the command, it can find all the beacons information - * which include number of total missed beacons, number of consecutive missed - * beacons, number of beacons received and number of beacons expected to - * receive. - * - * If uCode detected consecutive_missed_beacons > 5, it will reset the radio - * in order to bring the radio/PHY back to working state; which has no relation - * to when driver will perform sensitivity calibration. - * - * Driver should set it own missed_beacon_threshold to decide when to perform - * sensitivity calibration based on number of consecutive missed beacons in - * order to improve overall performance, especially in noisy environment. - * - */ - -#define IL_MISSED_BEACON_THRESHOLD_MIN (1) -#define IL_MISSED_BEACON_THRESHOLD_DEF (5) -#define IL_MISSED_BEACON_THRESHOLD_MAX IL_MISSED_BEACON_THRESHOLD_DEF - -struct il_missed_beacon_notif { - __le32 consecutive_missed_beacons; - __le32 total_missed_becons; - __le32 num_expected_beacons; - __le32 num_recvd_beacons; -} __packed; - - -/****************************************************************************** - * (11) - * Rx Calibration Commands: - * - * With the uCode used for open source drivers, most Tx calibration (except - * for Tx Power) and most Rx calibration is done by uCode during the - * "initialize" phase of uCode boot. Driver must calibrate only: - * - * 1) Tx power (depends on temperature), described elsewhere - * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas) - * 3) Receiver sensitivity (to optimize signal detection) - * - *****************************************************************************/ - -/** - * C_SENSITIVITY = 0xa8 (command, has simple generic response) - * - * This command sets up the Rx signal detector for a sensitivity level that - * is high enough to lock onto all signals within the associated network, - * but low enough to ignore signals that are below a certain threshold, so as - * not to have too many "false alarms". False alarms are signals that the - * Rx DSP tries to lock onto, but then discards after determining that they - * are noise. - * - * The optimum number of false alarms is between 5 and 50 per 200 TUs - * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e. - * time listening, not transmitting). Driver must adjust sensitivity so that - * the ratio of actual false alarms to actual Rx time falls within this range. - * - * While associated, uCode delivers N_STATSs after each - * received beacon. These provide information to the driver to analyze the - * sensitivity. Don't analyze stats that come in from scanning, or any - * other non-associated-network source. Pertinent stats include: - * - * From "general" stats (struct stats_rx_non_phy): - * - * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level) - * Measure of energy of desired signal. Used for establishing a level - * below which the device does not detect signals. - * - * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB) - * Measure of background noise in silent period after beacon. - * - * channel_load - * uSecs of actual Rx time during beacon period (varies according to - * how much time was spent transmitting). - * - * From "cck" and "ofdm" stats (struct stats_rx_phy), separately: - * - * false_alarm_cnt - * Signal locks abandoned early (before phy-level header). - * - * plcp_err - * Signal locks abandoned late (during phy-level header). - * - * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from - * beacon to beacon, i.e. each value is an accumulation of all errors - * before and including the latest beacon. Values will wrap around to 0 - * after counting up to 2^32 - 1. Driver must differentiate vs. - * previous beacon's values to determine # false alarms in the current - * beacon period. - * - * Total number of false alarms = false_alarms + plcp_errs - * - * For OFDM, adjust the following table entries in struct il_sensitivity_cmd - * (notice that the start points for OFDM are at or close to settings for - * maximum sensitivity): - * - * START / MIN / MAX - * HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX 90 / 85 / 120 - * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX 170 / 170 / 210 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX 105 / 105 / 140 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX 220 / 220 / 270 - * - * If actual rate of OFDM false alarms (+ plcp_errors) is too high - * (greater than 50 for each 204.8 msecs listening), reduce sensitivity - * by *adding* 1 to all 4 of the table entries above, up to the max for - * each entry. Conversely, if false alarm rate is too low (less than 5 - * for each 204.8 msecs listening), *subtract* 1 from each entry to - * increase sensitivity. - * - * For CCK sensitivity, keep track of the following: - * - * 1). 20-beacon history of maximum background noise, indicated by - * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the - * 3 receivers. For any given beacon, the "silence reference" is - * the maximum of last 60 samples (20 beacons * 3 receivers). - * - * 2). 10-beacon history of strongest signal level, as indicated - * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers, - * i.e. the strength of the signal through the best receiver at the - * moment. These measurements are "upside down", with lower values - * for stronger signals, so max energy will be *minimum* value. - * - * Then for any given beacon, the driver must determine the *weakest* - * of the strongest signals; this is the minimum level that needs to be - * successfully detected, when using the best receiver at the moment. - * "Max cck energy" is the maximum (higher value means lower energy!) - * of the last 10 minima. Once this is determined, driver must add - * a little margin by adding "6" to it. - * - * 3). Number of consecutive beacon periods with too few false alarms. - * Reset this to 0 at the first beacon period that falls within the - * "good" range (5 to 50 false alarms per 204.8 milliseconds rx). - * - * Then, adjust the following CCK table entries in struct il_sensitivity_cmd - * (notice that the start points for CCK are at maximum sensitivity): - * - * START / MIN / MAX - * HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX 125 / 125 / 200 - * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX 200 / 200 / 400 - * HD_MIN_ENERGY_CCK_DET_IDX 100 / 0 / 100 - * - * If actual rate of CCK false alarms (+ plcp_errors) is too high - * (greater than 50 for each 204.8 msecs listening), method for reducing - * sensitivity is: - * - * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, - * up to max 400. - * - * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is < 160, - * sensitivity has been reduced a significant amount; bring it up to - * a moderate 161. Otherwise, *add* 3, up to max 200. - * - * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is > 160, - * sensitivity has been reduced only a moderate or small amount; - * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_IDX, - * down to min 0. Otherwise (if gain has been significantly reduced), - * don't change the HD_MIN_ENERGY_CCK_DET_IDX value. - * - * b) Save a snapshot of the "silence reference". - * - * If actual rate of CCK false alarms (+ plcp_errors) is too low - * (less than 5 for each 204.8 msecs listening), method for increasing - * sensitivity is used only if: - * - * 1a) Previous beacon did not have too many false alarms - * 1b) AND difference between previous "silence reference" and current - * "silence reference" (prev - current) is 2 or more, - * OR 2) 100 or more consecutive beacon periods have had rate of - * less than 5 false alarms per 204.8 milliseconds rx time. - * - * Method for increasing sensitivity: - * - * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX, - * down to min 125. - * - * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, - * down to min 200. - * - * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_IDX, up to max 100. - * - * If actual rate of CCK false alarms (+ plcp_errors) is within good range - * (between 5 and 50 for each 204.8 msecs listening): - * - * 1) Save a snapshot of the silence reference. - * - * 2) If previous beacon had too many CCK false alarms (+ plcp_errors), - * give some extra margin to energy threshold by *subtracting* 8 - * from value in HD_MIN_ENERGY_CCK_DET_IDX. - * - * For all cases (too few, too many, good range), make sure that the CCK - * detection threshold (energy) is below the energy level for robust - * detection over the past 10 beacon periods, the "Max cck energy". - * Lower values mean higher energy; this means making sure that the value - * in HD_MIN_ENERGY_CCK_DET_IDX is at or *above* "Max cck energy". - * - */ - -/* - * Table entries in C_SENSITIVITY (struct il_sensitivity_cmd) - */ -#define HD_TBL_SIZE (11) /* number of entries */ -#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ -#define HD_MIN_ENERGY_OFDM_DET_IDX (1) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX (5) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6) -#define HD_BARKER_CORR_TH_ADD_MIN_IDX (7) -#define HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX (8) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX (9) -#define HD_OFDM_ENERGY_TH_IN_IDX (10) - -/* Control field in struct il_sensitivity_cmd */ -#define C_SENSITIVITY_CONTROL_DEFAULT_TBL cpu_to_le16(0) -#define C_SENSITIVITY_CONTROL_WORK_TBL cpu_to_le16(1) - -/** - * struct il_sensitivity_cmd - * @control: (1) updates working table, (0) updates default table - * @table: energy threshold values, use HD_* as idx into table - * - * Always use "1" in "control" to update uCode's working table and DSP. - */ -struct il_sensitivity_cmd { - __le16 control; /* always use "1" */ - __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ -} __packed; - - -/** - * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) - * - * This command sets the relative gains of 4965 device's 3 radio receiver chains. - * - * After the first association, driver should accumulate signal and noise - * stats from the N_STATSs that follow the first 20 - * beacons from the associated network (don't collect stats that come - * in from scanning, or any other non-network source). - * - * DISCONNECTED ANTENNA: - * - * Driver should determine which antennas are actually connected, by comparing - * average beacon signal levels for the 3 Rx chains. Accumulate (add) the - * following values over 20 beacons, one accumulator for each of the chains - * a/b/c, from struct stats_rx_non_phy: - * - * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB) - * - * Find the strongest signal from among a/b/c. Compare the other two to the - * strongest. If any signal is more than 15 dB (times 20, unless you - * divide the accumulated values by 20) below the strongest, the driver - * considers that antenna to be disconnected, and should not try to use that - * antenna/chain for Rx or Tx. If both A and B seem to be disconnected, - * driver should declare the stronger one as connected, and attempt to use it - * (A and B are the only 2 Tx chains!). - * - * - * RX BALANCE: - * - * Driver should balance the 3 receivers (but just the ones that are connected - * to antennas, see above) for gain, by comparing the average signal levels - * detected during the silence after each beacon (background noise). - * Accumulate (add) the following values over 20 beacons, one accumulator for - * each of the chains a/b/c, from struct stats_rx_non_phy: - * - * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB) - * - * Find the weakest background noise level from among a/b/c. This Rx chain - * will be the reference, with 0 gain adjustment. Attenuate other channels by - * finding noise difference: - * - * (accum_noise[i] - accum_noise[reference]) / 30 - * - * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB. - * For use in diff_gain_[abc] fields of struct il_calibration_cmd, the - * driver should limit the difference results to a range of 0-3 (0-4.5 dB), - * and set bit 2 to indicate "reduce gain". The value for the reference - * (weakest) chain should be "0". - * - * diff_gain_[abc] bit fields: - * 2: (1) reduce gain, (0) increase gain - * 1-0: amount of gain, units of 1.5 dB - */ - -/* Phy calibration command for series */ -/* The default calibrate table size if not specified by firmware */ -#define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 -enum { - IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, - IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, -}; - -#define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) - -struct il_calib_hdr { - u8 op_code; - u8 first_group; - u8 groups_num; - u8 data_valid; -} __packed; - -/* IL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ -struct il_calib_diff_gain_cmd { - struct il_calib_hdr hdr; - s8 diff_gain_a; /* see above */ - s8 diff_gain_b; - s8 diff_gain_c; - u8 reserved1; -} __packed; - -/****************************************************************************** - * (12) - * Miscellaneous Commands: - * - *****************************************************************************/ - -/* - * LEDs Command & Response - * C_LEDS = 0x48 (command, has simple generic response) - * - * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), - * this command turns it on or off, or sets up a periodic blinking cycle. - */ -struct il_led_cmd { - __le32 interval; /* "interval" in uSec */ - u8 id; /* 1: Activity, 2: Link, 3: Tech */ - u8 off; /* # intervals off while blinking; - * "0", with >0 "on" value, turns LED on */ - u8 on; /* # intervals on while blinking; - * "0", regardless of "off", turns LED off */ - u8 reserved; -} __packed; - - -/****************************************************************************** - * (13) - * Union of all expected notifications/responses: - * - *****************************************************************************/ - -struct il_rx_pkt { - /* - * The first 4 bytes of the RX frame header contain both the RX frame - * size and some flags. - * Bit fields: - * 31: flag flush RB request - * 30: flag ignore TC (terminal counter) request - * 29: flag fast IRQ request - * 28-14: Reserved - * 13-00: RX frame size - */ - __le32 len_n_flags; - struct il_cmd_header hdr; - union { - struct il3945_rx_frame rx_frame; - struct il3945_tx_resp tx_resp; - struct il3945_beacon_notif beacon_status; - - struct il_alive_resp alive_frame; - struct il_spectrum_notification spectrum_notif; - struct il_csa_notification csa_notif; - struct il_error_resp err_resp; - struct il_card_state_notif card_state_notif; - struct il_add_sta_resp add_sta; - struct il_rem_sta_resp rem_sta; - struct il_sleep_notification sleep_notif; - struct il_spectrum_resp spectrum; - struct il_notif_stats stats; - struct il_compressed_ba_resp compressed_ba; - struct il_missed_beacon_notif missed_beacon; - __le32 status; - u8 raw[0]; - } u; -} __packed; - -#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 2ebd807..991b455 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -25,7 +25,7 @@ *****************************************************************************/ /* * Please use this file (iwl-dev.h) for driver implementation definitions. - * Please use iwl-commands.h for uCode API definitions. + * Please use commands.h for uCode API definitions. * Please use 4965.h for hardware-related definitions. */ @@ -42,7 +42,6 @@ #include "iwl-eeprom.h" #include "iwl-csr.h" #include "iwl-prph.h" -#include "iwl-fh.h" #include "iwl-debug.h" #include "4965.h" #include "iwl-led.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index e4a0ef2..c0ae3fa 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -28,7 +28,7 @@ #ifndef __il_power_setting_h__ #define __il_power_setting_h__ -#include "iwl-commands.h" +#include "commands.h" enum il_power_level { IL_POWER_IDX_1, -- cgit v0.10.2 From 6278ddab9f859b8d6311879d35f2b1f74a789964 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 11:13:05 +0200 Subject: iwlegacy: remove il_ieee80211_get_hw_conf Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index ae60410..cd7ae58 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -2759,7 +2759,7 @@ void il3945_post_associate(struct il_priv *il) il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(il->hw); + conf = &il->hw->conf; ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il3945_commit_rxon(il, ctx); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index ed2c617..6833a3c 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2184,7 +2184,7 @@ static void il4965_post_associate(struct il_priv *il) il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(il->hw); + conf = &il->hw->conf; ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il_commit_rxon(il, ctx); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 7062574..bbf674d 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -3514,7 +3514,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) u16 beacon_int; struct ieee80211_vif *vif = ctx->vif; - conf = il_ieee80211_get_hw_conf(il->hw); + conf = &il->hw->conf; lockdep_assert_held(&il->mutex); diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index 0e64003..eb5a287 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -38,12 +38,6 @@ #define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -static inline struct ieee80211_conf *il_ieee80211_get_hw_conf( - struct ieee80211_hw *hw) -{ - return &hw->conf; -} - /** * il_queue_inc_wrap - increment queue idx, wrap back to beginning * @idx -- current idx -- cgit v0.10.2 From e53aac424767a9f42b3bbac22eb001491f605d4e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 11:18:16 +0200 Subject: iwlegacy: move IL_MASK Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2bab0fc..dbe5bf2 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -4944,6 +4944,8 @@ static const s8 default_queue_to_tx_fifo[] = { IL_TX_FIFO_UNUSED, }; +#define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) + static int il4965_alive_notify(struct il_priv *il) { u32 a; diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index eb5a287..2db83fc3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -35,9 +35,6 @@ #include "iwl-io.h" -#define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) - - /** * il_queue_inc_wrap - increment queue idx, wrap back to beginning * @idx -- current idx -- cgit v0.10.2 From 77375bb01cc030c680d5892eb1e756bc100c8022 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 11:19:51 +0200 Subject: iwlegacy: rename iwl-csr.h to csr.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 7559a5e..e89ca5d 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -34,7 +34,6 @@ /* Hardware specific file defines the PCI IDs table for that hardware module */ extern const struct pci_device_id il3945_hw_card_ids[]; -#include "iwl-csr.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "iwl-power.h" diff --git a/drivers/net/wireless/iwlegacy/csr.h b/drivers/net/wireless/iwlegacy/csr.h new file mode 100644 index 0000000..4db0429 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/csr.h @@ -0,0 +1,422 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ +#ifndef __il_csr_h__ +#define __il_csr_h__ +/* + * CSR (control and status registers) + * + * CSR registers are mapped directly into PCI bus space, and are accessible + * whenever platform supplies power to device, even when device is in + * low power states due to driver-invoked device resets + * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. + * + * Use _il_wr() and _il_rd() family to access these registers; + * these provide simple PCI bus access, without waking up the MAC. + * Do not use il_wr() family for these registers; + * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. + * The MAC (uCode processor, etc.) does not need to be powered up for accessing + * the CSR registers. + * + * NOTE: Device does need to be awake in order to read this memory + * via CSR_EEPROM register + */ +#define CSR_BASE (0x000) + +#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ +#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ +#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ +#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ +#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/ +#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ +#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ +#define CSR_GP_CNTRL (CSR_BASE+0x024) + +/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ +#define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) + +/* + * Hardware revision info + * Bit fields: + * 31-8: Reserved + * 7-4: Type of device: see CSR_HW_REV_TYPE_xxx definitions + * 3-2: Revision step: 0 = A, 1 = B, 2 = C, 3 = D + * 1-0: "Dash" (-) value, as in A-1, etc. + * + * NOTE: Revision step affects calculation of CCK txpower for 4965. + * NOTE: See also CSR_HW_REV_WA_REG (work-around for bug in 4965). + */ +#define CSR_HW_REV (CSR_BASE+0x028) + +/* + * EEPROM memory reads + * + * NOTE: Device must be awake, initialized via apm_ops.init(), + * in order to read. + */ +#define CSR_EEPROM_REG (CSR_BASE+0x02c) +#define CSR_EEPROM_GP (CSR_BASE+0x030) + +#define CSR_GIO_REG (CSR_BASE+0x03C) +#define CSR_GP_UCODE_REG (CSR_BASE+0x048) +#define CSR_GP_DRIVER_REG (CSR_BASE+0x050) + +/* + * UCODE-DRIVER GP (general purpose) mailbox registers. + * SET/CLR registers set/clear bit(s) if "1" is written. + */ +#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054) +#define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058) +#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c) +#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060) + +#define CSR_LED_REG (CSR_BASE+0x094) +#define CSR_DRAM_INT_TBL_REG (CSR_BASE+0x0A0) + +/* GIO Chicken Bits (PCI Express bus link power management) */ +#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100) + +/* Analog phase-lock-loop configuration */ +#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c) + +/* + * CSR Hardware Revision Workaround Register. Indicates hardware rev; + * "step" determines CCK backoff for txpower calculation. Used for 4965 only. + * See also CSR_HW_REV register. + * Bit fields: + * 3-2: 0 = A, 1 = B, 2 = C, 3 = D step + * 1-0: "Dash" (-) value, as in C-1, etc. + */ +#define CSR_HW_REV_WA_REG (CSR_BASE+0x22C) + +#define CSR_DBG_HPET_MEM_REG (CSR_BASE+0x240) +#define CSR_DBG_LINK_PWR_MGMT_REG (CSR_BASE+0x250) + +/* Bits for CSR_HW_IF_CONFIG_REG */ +#define CSR49_HW_IF_CONFIG_REG_BIT_4965_R (0x00000010) +#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00) +#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100) +#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200) + +#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MB (0x00000100) +#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MM (0x00000200) +#define CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400) +#define CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800) +#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000) +#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000) + +#define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A (0x00080000) +#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000) +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ +#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ + +#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int*/ +#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec*/ + +/* interrupt flags in INTA, set by uCode or hardware (e.g. dma), + * acknowledged (reset) by host writing "1" to flagged bits. */ +#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ +#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ +#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ +#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ +#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ +#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ +#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ +#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ +#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ +#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ +#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ + +#define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \ + CSR_INT_BIT_HW_ERR | \ + CSR_INT_BIT_FH_TX | \ + CSR_INT_BIT_SW_ERR | \ + CSR_INT_BIT_RF_KILL | \ + CSR_INT_BIT_SW_RX | \ + CSR_INT_BIT_WAKEUP | \ + CSR_INT_BIT_ALIVE) + +/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */ +#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ +#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ +#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ +#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ +#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ +#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ +#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ +#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ + +#define CSR39_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ + CSR39_FH_INT_BIT_RX_CHNL2 | \ + CSR_FH_INT_BIT_RX_CHNL1 | \ + CSR_FH_INT_BIT_RX_CHNL0) + + +#define CSR39_FH_INT_TX_MASK (CSR39_FH_INT_BIT_TX_CHNL6 | \ + CSR_FH_INT_BIT_TX_CHNL1 | \ + CSR_FH_INT_BIT_TX_CHNL0) + +#define CSR49_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ + CSR_FH_INT_BIT_RX_CHNL1 | \ + CSR_FH_INT_BIT_RX_CHNL0) + +#define CSR49_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL1 | \ + CSR_FH_INT_BIT_TX_CHNL0) + +/* GPIO */ +#define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200) +#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000) +#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC (0x00000200) + +/* RESET */ +#define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001) +#define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002) +#define CSR_RESET_REG_FLAG_SW_RESET (0x00000080) +#define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100) +#define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200) +#define CSR_RESET_LINK_PWR_MGMT_DISABLED (0x80000000) + +/* + * GP (general purpose) CONTROL REGISTER + * Bit fields: + * 27: HW_RF_KILL_SW + * Indicates state of (platform's) hardware RF-Kill switch + * 26-24: POWER_SAVE_TYPE + * Indicates current power-saving mode: + * 000 -- No power saving + * 001 -- MAC power-down + * 010 -- PHY (radio) power-down + * 011 -- Error + * 9-6: SYS_CONFIG + * Indicates current system configuration, reflecting pins on chip + * as forced high/low by device circuit board. + * 4: GOING_TO_SLEEP + * Indicates MAC is entering a power-saving sleep power-down. + * Not a good time to access device-internal resources. + * 3: MAC_ACCESS_REQ + * Host sets this to request and maintain MAC wakeup, to allow host + * access to device-internal resources. Host must wait for + * MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR + * device registers. + * 2: INIT_DONE + * Host sets this to put device into fully operational D0 power mode. + * Host resets this after SW_RESET to put device into low power mode. + * 0: MAC_CLOCK_READY + * Indicates MAC (ucode processor, etc.) is powered up and can run. + * Internal resources are accessible. + * NOTE: This does not indicate that the processor is actually running. + * NOTE: This does not indicate that 4965 or 3945 has completed + * init or post-power-down restore of internal SRAM memory. + * Use CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that + * SRAM is restored and uCode is in normal operation mode. + * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and + * do not need to save/restore it. + * NOTE: After device reset, this bit remains "0" until host sets + * INIT_DONE + */ +#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001) +#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004) +#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008) +#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010) + +#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001) + +#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000) +#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000) +#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000) + + +/* EEPROM REG */ +#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001) +#define CSR_EEPROM_REG_BIT_CMD (0x00000002) +#define CSR_EEPROM_REG_MSK_ADDR (0x0000FFFC) +#define CSR_EEPROM_REG_MSK_DATA (0xFFFF0000) + +/* EEPROM GP */ +#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ +#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) +#define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K (0x00000002) +#define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K (0x00000004) + +/* GP REG */ +#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ +#define CSR_GP_REG_NO_POWER_SAVE (0x00000000) +#define CSR_GP_REG_MAC_POWER_SAVE (0x01000000) +#define CSR_GP_REG_PHY_POWER_SAVE (0x02000000) +#define CSR_GP_REG_POWER_SAVE_ERROR (0x03000000) + + +/* CSR GIO */ +#define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002) + +/* + * UCODE-DRIVER GP (general purpose) mailbox register 1 + * Host driver and uCode write and/or read this register to communicate with + * each other. + * Bit fields: + * 4: UCODE_DISABLE + * Host sets this to request permanent halt of uCode, same as + * sending CARD_STATE command with "halt" bit set. + * 3: CT_KILL_EXIT + * Host sets this to request exit from CT_KILL state, i.e. host thinks + * device temperature is low enough to continue normal operation. + * 2: CMD_BLOCKED + * Host sets this during RF KILL power-down sequence (HW, SW, CT KILL) + * to release uCode to clear all Tx and command queues, enter + * unassociated mode, and power down. + * NOTE: Some devices also use HBUS_TARG_MBX_C register for this bit. + * 1: SW_BIT_RFKILL + * Host sets this when issuing CARD_STATE command to request + * device sleep. + * 0: MAC_SLEEP + * uCode sets this when preparing a power-saving power-down. + * uCode resets this when power-up is complete and SRAM is sane. + * NOTE: 3945/4965 saves internal SRAM data to host when powering down, + * and must restore this data after powering back up. + * MAC_SLEEP is the best indication that restore is complete. + * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and + * do not need to save/restore it. + */ +#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001) +#define CSR_UCODE_SW_BIT_RFKILL (0x00000002) +#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004) +#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008) + +/* GIO Chicken Bits (PCI Express bus link power management) */ +#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000) +#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000) + +/* LED */ +#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF) +#define CSR_LED_REG_TRUN_ON (0x78) +#define CSR_LED_REG_TRUN_OFF (0x38) + +/* ANA_PLL */ +#define CSR39_ANA_PLL_CFG_VAL (0x01000000) + +/* HPET MEM debug */ +#define CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000) + +/* DRAM INT TBL */ +#define CSR_DRAM_INT_TBL_ENABLE (1 << 31) +#define CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27) + +/* + * HBUS (Host-side Bus) + * + * HBUS registers are mapped directly into PCI bus space, but are used + * to indirectly access device's internal memory or registers that + * may be powered-down. + * + * Use il_wr()/il_rd() family + * for these registers; + * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ + * to make sure the MAC (uCode processor, etc.) is powered up for accessing + * internal resources. + * + * Do not use _il_wr()/_il_rd() family to access these registers; + * these provide only simple PCI bus access, without waking up the MAC. + */ +#define HBUS_BASE (0x400) + +/* + * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM + * structures, error log, event log, verifying uCode load). + * First write to address register, then read from or write to data register + * to complete the job. Once the address register is set up, accesses to + * data registers auto-increment the address by one dword. + * Bit usage for address registers (read or write): + * 0-31: memory address within device + */ +#define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c) +#define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010) +#define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018) +#define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c) + +/* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */ +#define HBUS_TARG_MBX_C (HBUS_BASE+0x030) +#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004) + +/* + * Registers for accessing device's internal peripheral registers + * (e.g. SCD, BSM, etc.). First write to address register, + * then read from or write to data register to complete the job. + * Bit usage for address registers (read or write): + * 0-15: register address (offset) within device + * 24-25: (# bytes - 1) to read or write (e.g. 3 for dword) + */ +#define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044) +#define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048) +#define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c) +#define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050) + +/* + * Per-Tx-queue write pointer (idx, really!) + * Indicates idx to next TFD that driver will fill (1 past latest filled). + * Bit usage: + * 0-7: queue write idx + * 11-8: queue selector + */ +#define HBUS_TARG_WRPTR (HBUS_BASE+0x060) + +#endif /* !__il_csr_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h deleted file mode 100644 index 4db0429..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ /dev/null @@ -1,422 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#ifndef __il_csr_h__ -#define __il_csr_h__ -/* - * CSR (control and status registers) - * - * CSR registers are mapped directly into PCI bus space, and are accessible - * whenever platform supplies power to device, even when device is in - * low power states due to driver-invoked device resets - * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. - * - * Use _il_wr() and _il_rd() family to access these registers; - * these provide simple PCI bus access, without waking up the MAC. - * Do not use il_wr() family for these registers; - * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. - * The MAC (uCode processor, etc.) does not need to be powered up for accessing - * the CSR registers. - * - * NOTE: Device does need to be awake in order to read this memory - * via CSR_EEPROM register - */ -#define CSR_BASE (0x000) - -#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ -#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ -#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ -#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ -#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/ -#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ -#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ -#define CSR_GP_CNTRL (CSR_BASE+0x024) - -/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ -#define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) - -/* - * Hardware revision info - * Bit fields: - * 31-8: Reserved - * 7-4: Type of device: see CSR_HW_REV_TYPE_xxx definitions - * 3-2: Revision step: 0 = A, 1 = B, 2 = C, 3 = D - * 1-0: "Dash" (-) value, as in A-1, etc. - * - * NOTE: Revision step affects calculation of CCK txpower for 4965. - * NOTE: See also CSR_HW_REV_WA_REG (work-around for bug in 4965). - */ -#define CSR_HW_REV (CSR_BASE+0x028) - -/* - * EEPROM memory reads - * - * NOTE: Device must be awake, initialized via apm_ops.init(), - * in order to read. - */ -#define CSR_EEPROM_REG (CSR_BASE+0x02c) -#define CSR_EEPROM_GP (CSR_BASE+0x030) - -#define CSR_GIO_REG (CSR_BASE+0x03C) -#define CSR_GP_UCODE_REG (CSR_BASE+0x048) -#define CSR_GP_DRIVER_REG (CSR_BASE+0x050) - -/* - * UCODE-DRIVER GP (general purpose) mailbox registers. - * SET/CLR registers set/clear bit(s) if "1" is written. - */ -#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054) -#define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058) -#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c) -#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060) - -#define CSR_LED_REG (CSR_BASE+0x094) -#define CSR_DRAM_INT_TBL_REG (CSR_BASE+0x0A0) - -/* GIO Chicken Bits (PCI Express bus link power management) */ -#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100) - -/* Analog phase-lock-loop configuration */ -#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c) - -/* - * CSR Hardware Revision Workaround Register. Indicates hardware rev; - * "step" determines CCK backoff for txpower calculation. Used for 4965 only. - * See also CSR_HW_REV register. - * Bit fields: - * 3-2: 0 = A, 1 = B, 2 = C, 3 = D step - * 1-0: "Dash" (-) value, as in C-1, etc. - */ -#define CSR_HW_REV_WA_REG (CSR_BASE+0x22C) - -#define CSR_DBG_HPET_MEM_REG (CSR_BASE+0x240) -#define CSR_DBG_LINK_PWR_MGMT_REG (CSR_BASE+0x250) - -/* Bits for CSR_HW_IF_CONFIG_REG */ -#define CSR49_HW_IF_CONFIG_REG_BIT_4965_R (0x00000010) -#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00) -#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100) -#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200) - -#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MB (0x00000100) -#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MM (0x00000200) -#define CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400) -#define CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800) -#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000) -#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000) - -#define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A (0x00080000) -#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000) -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ -#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ - -#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int*/ -#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec*/ - -/* interrupt flags in INTA, set by uCode or hardware (e.g. dma), - * acknowledged (reset) by host writing "1" to flagged bits. */ -#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ -#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ -#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ -#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ -#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ -#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ -#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ -#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ -#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ -#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ -#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ - -#define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \ - CSR_INT_BIT_HW_ERR | \ - CSR_INT_BIT_FH_TX | \ - CSR_INT_BIT_SW_ERR | \ - CSR_INT_BIT_RF_KILL | \ - CSR_INT_BIT_SW_RX | \ - CSR_INT_BIT_WAKEUP | \ - CSR_INT_BIT_ALIVE) - -/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */ -#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ -#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ -#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ -#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ -#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ -#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ -#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ -#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ - -#define CSR39_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ - CSR39_FH_INT_BIT_RX_CHNL2 | \ - CSR_FH_INT_BIT_RX_CHNL1 | \ - CSR_FH_INT_BIT_RX_CHNL0) - - -#define CSR39_FH_INT_TX_MASK (CSR39_FH_INT_BIT_TX_CHNL6 | \ - CSR_FH_INT_BIT_TX_CHNL1 | \ - CSR_FH_INT_BIT_TX_CHNL0) - -#define CSR49_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ - CSR_FH_INT_BIT_RX_CHNL1 | \ - CSR_FH_INT_BIT_RX_CHNL0) - -#define CSR49_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL1 | \ - CSR_FH_INT_BIT_TX_CHNL0) - -/* GPIO */ -#define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200) -#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000) -#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC (0x00000200) - -/* RESET */ -#define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001) -#define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002) -#define CSR_RESET_REG_FLAG_SW_RESET (0x00000080) -#define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100) -#define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200) -#define CSR_RESET_LINK_PWR_MGMT_DISABLED (0x80000000) - -/* - * GP (general purpose) CONTROL REGISTER - * Bit fields: - * 27: HW_RF_KILL_SW - * Indicates state of (platform's) hardware RF-Kill switch - * 26-24: POWER_SAVE_TYPE - * Indicates current power-saving mode: - * 000 -- No power saving - * 001 -- MAC power-down - * 010 -- PHY (radio) power-down - * 011 -- Error - * 9-6: SYS_CONFIG - * Indicates current system configuration, reflecting pins on chip - * as forced high/low by device circuit board. - * 4: GOING_TO_SLEEP - * Indicates MAC is entering a power-saving sleep power-down. - * Not a good time to access device-internal resources. - * 3: MAC_ACCESS_REQ - * Host sets this to request and maintain MAC wakeup, to allow host - * access to device-internal resources. Host must wait for - * MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR - * device registers. - * 2: INIT_DONE - * Host sets this to put device into fully operational D0 power mode. - * Host resets this after SW_RESET to put device into low power mode. - * 0: MAC_CLOCK_READY - * Indicates MAC (ucode processor, etc.) is powered up and can run. - * Internal resources are accessible. - * NOTE: This does not indicate that the processor is actually running. - * NOTE: This does not indicate that 4965 or 3945 has completed - * init or post-power-down restore of internal SRAM memory. - * Use CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that - * SRAM is restored and uCode is in normal operation mode. - * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and - * do not need to save/restore it. - * NOTE: After device reset, this bit remains "0" until host sets - * INIT_DONE - */ -#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001) -#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004) -#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008) -#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010) - -#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001) - -#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000) -#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000) -#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000) - - -/* EEPROM REG */ -#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001) -#define CSR_EEPROM_REG_BIT_CMD (0x00000002) -#define CSR_EEPROM_REG_MSK_ADDR (0x0000FFFC) -#define CSR_EEPROM_REG_MSK_DATA (0xFFFF0000) - -/* EEPROM GP */ -#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ -#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) -#define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K (0x00000002) -#define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K (0x00000004) - -/* GP REG */ -#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ -#define CSR_GP_REG_NO_POWER_SAVE (0x00000000) -#define CSR_GP_REG_MAC_POWER_SAVE (0x01000000) -#define CSR_GP_REG_PHY_POWER_SAVE (0x02000000) -#define CSR_GP_REG_POWER_SAVE_ERROR (0x03000000) - - -/* CSR GIO */ -#define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002) - -/* - * UCODE-DRIVER GP (general purpose) mailbox register 1 - * Host driver and uCode write and/or read this register to communicate with - * each other. - * Bit fields: - * 4: UCODE_DISABLE - * Host sets this to request permanent halt of uCode, same as - * sending CARD_STATE command with "halt" bit set. - * 3: CT_KILL_EXIT - * Host sets this to request exit from CT_KILL state, i.e. host thinks - * device temperature is low enough to continue normal operation. - * 2: CMD_BLOCKED - * Host sets this during RF KILL power-down sequence (HW, SW, CT KILL) - * to release uCode to clear all Tx and command queues, enter - * unassociated mode, and power down. - * NOTE: Some devices also use HBUS_TARG_MBX_C register for this bit. - * 1: SW_BIT_RFKILL - * Host sets this when issuing CARD_STATE command to request - * device sleep. - * 0: MAC_SLEEP - * uCode sets this when preparing a power-saving power-down. - * uCode resets this when power-up is complete and SRAM is sane. - * NOTE: 3945/4965 saves internal SRAM data to host when powering down, - * and must restore this data after powering back up. - * MAC_SLEEP is the best indication that restore is complete. - * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and - * do not need to save/restore it. - */ -#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001) -#define CSR_UCODE_SW_BIT_RFKILL (0x00000002) -#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004) -#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008) - -/* GIO Chicken Bits (PCI Express bus link power management) */ -#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000) -#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000) - -/* LED */ -#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF) -#define CSR_LED_REG_TRUN_ON (0x78) -#define CSR_LED_REG_TRUN_OFF (0x38) - -/* ANA_PLL */ -#define CSR39_ANA_PLL_CFG_VAL (0x01000000) - -/* HPET MEM debug */ -#define CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000) - -/* DRAM INT TBL */ -#define CSR_DRAM_INT_TBL_ENABLE (1 << 31) -#define CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27) - -/* - * HBUS (Host-side Bus) - * - * HBUS registers are mapped directly into PCI bus space, but are used - * to indirectly access device's internal memory or registers that - * may be powered-down. - * - * Use il_wr()/il_rd() family - * for these registers; - * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ - * to make sure the MAC (uCode processor, etc.) is powered up for accessing - * internal resources. - * - * Do not use _il_wr()/_il_rd() family to access these registers; - * these provide only simple PCI bus access, without waking up the MAC. - */ -#define HBUS_BASE (0x400) - -/* - * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM - * structures, error log, event log, verifying uCode load). - * First write to address register, then read from or write to data register - * to complete the job. Once the address register is set up, accesses to - * data registers auto-increment the address by one dword. - * Bit usage for address registers (read or write): - * 0-31: memory address within device - */ -#define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c) -#define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010) -#define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018) -#define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c) - -/* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */ -#define HBUS_TARG_MBX_C (HBUS_BASE+0x030) -#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004) - -/* - * Registers for accessing device's internal peripheral registers - * (e.g. SCD, BSM, etc.). First write to address register, - * then read from or write to data register to complete the job. - * Bit usage for address registers (read or write): - * 0-15: register address (offset) within device - * 24-25: (# bytes - 1) to read or write (e.g. 3 for dword) - */ -#define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044) -#define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048) -#define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c) -#define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050) - -/* - * Per-Tx-queue write pointer (idx, really!) - * Indicates idx to next TFD that driver will fill (1 past latest filled). - * Bit usage: - * 0-7: queue write idx - * 11-8: queue selector - */ -#define HBUS_TARG_WRPTR (HBUS_BASE+0x060) - -#endif /* !__il_csr_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 991b455..ce5bc53 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -40,7 +40,7 @@ #include #include "iwl-eeprom.h" -#include "iwl-csr.h" +#include "csr.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "4965.h" -- cgit v0.10.2 From 98613be06e9de8acd20841d2d85b99c39b3b7814 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:19:34 +0100 Subject: iwlegacy: rename iwl-core.h to common.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index fc2d651..b73b425 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -27,7 +27,7 @@ *****************************************************************************/ #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "3945.h" static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index cd7ae58..b650292 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -54,7 +54,7 @@ #include "commands.h" #include "iwl-sta.h" #include "3945.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-helpers.h" #include "iwl-dev.h" #include "iwl-spectrum.h" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index ff8818b..795d206 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -42,7 +42,7 @@ #include "commands.h" #include "iwl-sta.h" #include "iwl-eeprom.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-helpers.h" #include "iwl-led.h" #include "3945.h" diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index c5dcc52..1e47798 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -64,7 +64,7 @@ #include #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "4965.h" /***************************************************************************** diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index ad9c6d0..1056d3e 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -26,7 +26,7 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "4965.h" static const char *fmt_value = " %-30s %10u\n"; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index dbe5bf2..2f747e4 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -52,7 +52,7 @@ #include "iwl-eeprom.h" #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" #include "iwl-helpers.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 4809a9d..06f5beb 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -37,7 +37,7 @@ #include "iwl-dev.h" #include "iwl-sta.h" -#include "iwl-core.h" +#include "common.h" #include "4965.h" #define IL4965_RS_NAME "iwl-4965-rs" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 6833a3c..7febcf3 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -39,7 +39,7 @@ #include "iwl-eeprom.h" #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" #include "iwl-helpers.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index bbf674d..d99ed75 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -43,7 +43,7 @@ #include "iwl-eeprom.h" #include "iwl-dev.h" #include "iwl-debug.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" #include "iwl-power.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h new file mode 100644 index 0000000..5de742c --- /dev/null +++ b/drivers/net/wireless/iwlegacy/common.h @@ -0,0 +1,636 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef __il_core_h__ +#define __il_core_h__ + +/************************ + * forward declarations * + ************************/ +struct il_host_cmd; +struct il_cmd; + + +#define IWLWIFI_VERSION "in-tree:" +#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" +#define DRV_AUTHOR "" + +#define IL_PCI_DEVICE(dev, subdev, cfg) \ + .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ + .driver_data = (kernel_ulong_t)&(cfg) + +#define TIME_UNIT 1024 + +#define IL_SKU_G 0x1 +#define IL_SKU_A 0x2 +#define IL_SKU_N 0x8 + +#define IL_CMD(x) case x: return #x + +struct il_hcmd_ops { + int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); + int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); + void (*set_rxon_chain)(struct il_priv *il, + struct il_rxon_context *ctx); +}; + +struct il_hcmd_utils_ops { + u16 (*get_hcmd_size)(u8 cmd_id, u16 len); + u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, + u8 *data); + int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); + void (*post_scan)(struct il_priv *il); +}; + +struct il_apm_ops { + int (*init)(struct il_priv *il); + void (*config)(struct il_priv *il); +}; + +struct il_debugfs_ops { + ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +}; + +struct il_temp_ops { + void (*temperature)(struct il_priv *il); +}; + +struct il_lib_ops { + /* set hw dependent parameters */ + int (*set_hw_params)(struct il_priv *il); + /* Handling TX */ + void (*txq_update_byte_cnt_tbl)(struct il_priv *il, + struct il_tx_queue *txq, + u16 byte_cnt); + int (*txq_attach_buf_to_tfd)(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, + u16 len, u8 reset, u8 pad); + void (*txq_free_tfd)(struct il_priv *il, + struct il_tx_queue *txq); + int (*txq_init)(struct il_priv *il, + struct il_tx_queue *txq); + /* setup Rx handler */ + void (*handler_setup)(struct il_priv *il); + /* alive notification after init uCode load */ + void (*init_alive_start)(struct il_priv *il); + /* check validity of rtc data address */ + int (*is_valid_rtc_data_addr)(u32 addr); + /* 1st ucode load */ + int (*load_ucode)(struct il_priv *il); + + void (*dump_nic_error_log)(struct il_priv *il); + int (*dump_fh)(struct il_priv *il, char **buf, bool display); + int (*set_channel_switch)(struct il_priv *il, + struct ieee80211_channel_switch *ch_switch); + /* power management */ + struct il_apm_ops apm_ops; + + /* power */ + int (*send_tx_power) (struct il_priv *il); + void (*update_chain_flags)(struct il_priv *il); + + /* eeprom operations (as defined in iwl-eeprom.h) */ + struct il_eeprom_ops eeprom_ops; + + /* temperature */ + struct il_temp_ops temp_ops; + + struct il_debugfs_ops debugfs_ops; + +}; + +struct il_led_ops { + int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); +}; + +struct il_legacy_ops { + void (*post_associate)(struct il_priv *il); + void (*config_ap)(struct il_priv *il); + /* station management */ + int (*update_bcast_stations)(struct il_priv *il); + int (*manage_ibss_station)(struct il_priv *il, + struct ieee80211_vif *vif, bool add); +}; + +struct il_ops { + const struct il_lib_ops *lib; + const struct il_hcmd_ops *hcmd; + const struct il_hcmd_utils_ops *utils; + const struct il_led_ops *led; + const struct il_nic_ops *nic; + const struct il_legacy_ops *legacy; + const struct ieee80211_ops *ieee80211_ops; +}; + +struct il_mod_params { + int sw_crypto; /* def: 0 = using hardware encryption */ + int disable_hw_scan; /* def: 0 = use h/w scan */ + int num_of_queues; /* def: HW dependent */ + int disable_11n; /* def: 0 = 11n capabilities enabled */ + int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ + int antenna; /* def: 0 = both antennas (use diversity) */ + int restart_fw; /* def: 1 = restart firmware */ +}; + +/* + * @led_compensation: compensate on the led on/off time per HW according + * to the deviation to achieve the desired led frequency. + * The detail algorithm is described in iwl-led.c + * @chain_noise_num_beacons: number of beacons used to compute chain noise + * @wd_timeout: TX queues watchdog timeout + * @temperature_kelvin: temperature report by uCode in kelvin + * @ucode_tracing: support ucode continuous tracing + * @sensitivity_calib_by_driver: driver has the capability to perform + * sensitivity calibration operation + * @chain_noise_calib_by_driver: driver has the capability to perform + * chain noise calibration operation + */ +struct il_base_params { + int eeprom_size; + int num_of_queues; /* def: HW dependent */ + int num_of_ampdu_queues;/* def: HW dependent */ + /* for il_apm_init() */ + u32 pll_cfg_val; + bool set_l0s; + bool use_bsm; + + u16 led_compensation; + int chain_noise_num_beacons; + unsigned int wd_timeout; + bool temperature_kelvin; + const bool ucode_tracing; + const bool sensitivity_calib_by_driver; + const bool chain_noise_calib_by_driver; +}; + +/** + * struct il_cfg + * @fw_name_pre: Firmware filename prefix. The api version and extension + * (.ucode) will be added to filename before loading from disk. The + * filename is constructed as fw_name_pre.ucode. + * @ucode_api_max: Highest version of uCode API supported by driver. + * @ucode_api_min: Lowest version of uCode API supported by driver. + * @scan_antennas: available antenna for scan operation + * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) + * + * We enable the driver to be backward compatible wrt API version. The + * driver specifies which APIs it supports (with @ucode_api_max being the + * highest and @ucode_api_min the lowest). Firmware will only be loaded if + * it has a supported API version. The firmware's API version will be + * stored in @il_priv, enabling the driver to make runtime changes based + * on firmware version used. + * + * For example, + * if (IL_UCODE_API(il->ucode_ver) >= 2) { + * Driver interacts with Firmware API version >= 2. + * } else { + * Driver interacts with Firmware API version 1. + * } + * + * The ideal usage of this infrastructure is to treat a new ucode API + * release as a new hardware revision. That is, through utilizing the + * il_hcmd_utils_ops etc. we accommodate different command structures + * and flows between hardware versions as well as their API + * versions. + * + */ +struct il_cfg { + /* params specific to an individual device within a device family */ + const char *name; + const char *fw_name_pre; + const unsigned int ucode_api_max; + const unsigned int ucode_api_min; + u8 valid_tx_ant; + u8 valid_rx_ant; + unsigned int sku; + u16 eeprom_ver; + u16 eeprom_calib_ver; + const struct il_ops *ops; + /* module based parameters which can be set from modprobe cmd */ + const struct il_mod_params *mod_params; + /* params not likely to change within a device family */ + struct il_base_params *base_params; + /* params likely to change within a device family */ + u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; + enum il_led_mode led_mode; +}; + +/*************************** + * L i b * + ***************************/ + +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); +int il_mac_conf_tx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *params); +int il_mac_tx_last_beacon(struct ieee80211_hw *hw); +void il_set_rxon_hwcrypto(struct il_priv *il, + struct il_rxon_context *ctx, + int hw_decrypt); +int il_check_rxon_cmd(struct il_priv *il, + struct il_rxon_context *ctx); +int il_full_rxon_required(struct il_priv *il, + struct il_rxon_context *ctx); +int il_set_rxon_channel(struct il_priv *il, + struct ieee80211_channel *ch, + struct il_rxon_context *ctx); +void il_set_flags_for_band(struct il_priv *il, + struct il_rxon_context *ctx, + enum ieee80211_band band, + struct ieee80211_vif *vif); +u8 il_get_single_channel_number(struct il_priv *il, + enum ieee80211_band band); +void il_set_rxon_ht(struct il_priv *il, + struct il_ht_config *ht_conf); +bool il_is_ht40_tx_allowed(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap); +void il_connection_init_rx_config(struct il_priv *il, + struct il_rxon_context *ctx); +void il_set_rate(struct il_priv *il); +int il_set_decrypted_flag(struct il_priv *il, + struct ieee80211_hdr *hdr, + u32 decrypt_res, + struct ieee80211_rx_status *stats); +void il_irq_handle_error(struct il_priv *il); +int il_mac_add_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); +void il_mac_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); +int il_mac_change_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum nl80211_iftype newtype, bool newp2p); +int il_alloc_txq_mem(struct il_priv *il); +void il_txq_mem(struct il_priv *il); + +#ifdef CONFIG_IWLEGACY_DEBUGFS +int il_alloc_traffic_mem(struct il_priv *il); +void il_free_traffic_mem(struct il_priv *il); +void il_reset_traffic_log(struct il_priv *il); +void il_dbg_log_tx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header); +void il_dbg_log_rx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header); +const char *il_get_mgmt_string(int cmd); +const char *il_get_ctrl_string(int cmd); +void il_clear_traffic_stats(struct il_priv *il); +void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, + u16 len); +#else +static inline int il_alloc_traffic_mem(struct il_priv *il) +{ + return 0; +} +static inline void il_free_traffic_mem(struct il_priv *il) +{ +} +static inline void il_reset_traffic_log(struct il_priv *il) +{ +} +static inline void il_dbg_log_tx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ +} +static inline void il_dbg_log_rx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ +} +static inline void il_update_stats(struct il_priv *il, bool is_tx, + __le16 fc, u16 len) +{ +} +#endif +/***************************************************** + * RX handlers. + * **************************************************/ +void il_hdl_pm_sleep(struct il_priv *il, + struct il_rx_buf *rxb); +void il_hdl_pm_debug_stats(struct il_priv *il, + struct il_rx_buf *rxb); +void il_hdl_error(struct il_priv *il, + struct il_rx_buf *rxb); + +/***************************************************** +* RX +******************************************************/ +void il_cmd_queue_unmap(struct il_priv *il); +void il_cmd_queue_free(struct il_priv *il); +int il_rx_queue_alloc(struct il_priv *il); +void il_rx_queue_update_write_ptr(struct il_priv *il, + struct il_rx_queue *q); +int il_rx_queue_space(const struct il_rx_queue *q); +void il_tx_cmd_complete(struct il_priv *il, + struct il_rx_buf *rxb); +/* Handlers */ +void il_hdl_spectrum_measurement(struct il_priv *il, + struct il_rx_buf *rxb); +void il_recover_from_stats(struct il_priv *il, + struct il_rx_pkt *pkt); +void il_chswitch_done(struct il_priv *il, bool is_success); +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); + +/* TX helpers */ + +/***************************************************** +* TX +******************************************************/ +void il_txq_update_write_ptr(struct il_priv *il, + struct il_tx_queue *txq); +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id); +void il_tx_queue_reset(struct il_priv *il, + struct il_tx_queue *txq, + int slots_num, u32 txq_id); +void il_tx_queue_unmap(struct il_priv *il, int txq_id); +void il_tx_queue_free(struct il_priv *il, int txq_id); +void il_setup_watchdog(struct il_priv *il); +/***************************************************** + * TX power + ****************************************************/ +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); + +/******************************************************************************* + * Rate + ******************************************************************************/ + +u8 il_get_lowest_plcp(struct il_priv *il, + struct il_rxon_context *ctx); + +/******************************************************************************* + * Scanning + ******************************************************************************/ +void il_init_scan_params(struct il_priv *il); +int il_scan_cancel(struct il_priv *il); +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); +void il_force_scan_end(struct il_priv *il); +int il_mac_hw_scan(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct cfg80211_scan_request *req); +void il_internal_short_hw_scan(struct il_priv *il); +int il_force_reset(struct il_priv *il, bool external); +u16 il_fill_probe_req(struct il_priv *il, + struct ieee80211_mgmt *frame, + const u8 *ta, const u8 *ie, int ie_len, int left); +void il_setup_rx_scan_handlers(struct il_priv *il); +u16 il_get_active_dwell_time(struct il_priv *il, + enum ieee80211_band band, + u8 n_probes); +u16 il_get_passive_dwell_time(struct il_priv *il, + enum ieee80211_band band, + struct ieee80211_vif *vif); +void il_setup_scan_deferred_work(struct il_priv *il); +void il_cancel_scan_deferred_work(struct il_priv *il); + +/* For faster active scanning, scan will move to the next channel if fewer than + * PLCP_QUIET_THRESH packets are heard on this channel within + * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell + * time if it's a quiet channel (nothing responded to our probe, and there's + * no other traffic). + * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ +#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ +#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ + +#define IL_SCAN_CHECK_WATCHDOG (HZ * 7) + +/***************************************************** + * S e n d i n g H o s t C o m m a n d s * + *****************************************************/ + +const char *il_get_cmd_string(u8 cmd); +int __must_check il_send_cmd_sync(struct il_priv *il, + struct il_host_cmd *cmd); +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); +int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, + u16 len, const void *data); +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, + const void *data, + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)); + +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); + + +/***************************************************** + * PCI * + *****************************************************/ + +static inline u16 il_pcie_link_ctl(struct il_priv *il) +{ + int pos; + u16 pci_lnk_ctl; + pos = pci_pcie_cap(il->pci_dev); + pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); + return pci_lnk_ctl; +} + +void il_bg_watchdog(unsigned long data); +u32 il_usecs_to_beacons(struct il_priv *il, + u32 usec, u32 beacon_interval); +__le32 il_add_beacon_time(struct il_priv *il, u32 base, + u32 addon, u32 beacon_interval); + +#ifdef CONFIG_PM +int il_pci_suspend(struct device *device); +int il_pci_resume(struct device *device); +extern const struct dev_pm_ops il_pm_ops; + +#define IL_LEGACY_PM_OPS (&il_pm_ops) + +#else /* !CONFIG_PM */ + +#define IL_LEGACY_PM_OPS NULL + +#endif /* !CONFIG_PM */ + +/***************************************************** +* Error Handling Debugging +******************************************************/ +void il4965_dump_nic_error_log(struct il_priv *il); +#ifdef CONFIG_IWLEGACY_DEBUG +void il_print_rx_config_cmd(struct il_priv *il, + struct il_rxon_context *ctx); +#else +static inline void il_print_rx_config_cmd(struct il_priv *il, + struct il_rxon_context *ctx) +{ +} +#endif + +void il_clear_isr_stats(struct il_priv *il); + +/***************************************************** +* GEOS +******************************************************/ +int il_init_geos(struct il_priv *il); +void il_free_geos(struct il_priv *il); + +/*************** DRIVER STATUS FUNCTIONS *****/ + +#define S_HCMD_ACTIVE 0 /* host command in progress */ +/* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */ +#define S_INT_ENABLED 2 +#define S_RF_KILL_HW 3 +#define S_CT_KILL 4 +#define S_INIT 5 +#define S_ALIVE 6 +#define S_READY 7 +#define S_TEMPERATURE 8 +#define S_GEO_CONFIGURED 9 +#define S_EXIT_PENDING 10 +#define S_STATS 12 +#define S_SCANNING 13 +#define S_SCAN_ABORTING 14 +#define S_SCAN_HW 15 +#define S_POWER_PMI 16 +#define S_FW_ERROR 17 +#define S_CHANNEL_SWITCH_PENDING 18 + +static inline int il_is_ready(struct il_priv *il) +{ + /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are + * set but EXIT_PENDING is not */ + return test_bit(S_READY, &il->status) && + test_bit(S_GEO_CONFIGURED, &il->status) && + !test_bit(S_EXIT_PENDING, &il->status); +} + +static inline int il_is_alive(struct il_priv *il) +{ + return test_bit(S_ALIVE, &il->status); +} + +static inline int il_is_init(struct il_priv *il) +{ + return test_bit(S_INIT, &il->status); +} + +static inline int il_is_rfkill_hw(struct il_priv *il) +{ + return test_bit(S_RF_KILL_HW, &il->status); +} + +static inline int il_is_rfkill(struct il_priv *il) +{ + return il_is_rfkill_hw(il); +} + +static inline int il_is_ctkill(struct il_priv *il) +{ + return test_bit(S_CT_KILL, &il->status); +} + +static inline int il_is_ready_rf(struct il_priv *il) +{ + + if (il_is_rfkill(il)) + return 0; + + return il_is_ready(il); +} + +extern void il_send_bt_config(struct il_priv *il); +extern int il_send_stats_request(struct il_priv *il, + u8 flags, bool clear); +void il_apm_stop(struct il_priv *il); +int il_apm_init(struct il_priv *il); + +int il_send_rxon_timing(struct il_priv *il, + struct il_rxon_context *ctx); +static inline int il_send_rxon_assoc(struct il_priv *il, + struct il_rxon_context *ctx) +{ + return il->cfg->ops->hcmd->rxon_assoc(il, ctx); +} +static inline int il_commit_rxon(struct il_priv *il, + struct il_rxon_context *ctx) +{ + return il->cfg->ops->hcmd->commit_rxon(il, ctx); +} +static inline const struct ieee80211_supported_band *il_get_hw_mode( + struct il_priv *il, enum ieee80211_band band) +{ + return il->hw->wiphy->bands[band]; +} + +/* mac80211 handlers */ +int il_mac_config(struct ieee80211_hw *hw, u32 changed); +void il_mac_reset_tsf(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); +void il_mac_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, + u32 changes); +void il_tx_cmd_protection(struct il_priv *il, + struct ieee80211_tx_info *info, + __le16 fc, __le32 *tx_flags); + +irqreturn_t il_isr(int irq, void *data); + +#endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h deleted file mode 100644 index 5de742c..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ /dev/null @@ -1,636 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_core_h__ -#define __il_core_h__ - -/************************ - * forward declarations * - ************************/ -struct il_host_cmd; -struct il_cmd; - - -#define IWLWIFI_VERSION "in-tree:" -#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" -#define DRV_AUTHOR "" - -#define IL_PCI_DEVICE(dev, subdev, cfg) \ - .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ - .driver_data = (kernel_ulong_t)&(cfg) - -#define TIME_UNIT 1024 - -#define IL_SKU_G 0x1 -#define IL_SKU_A 0x2 -#define IL_SKU_N 0x8 - -#define IL_CMD(x) case x: return #x - -struct il_hcmd_ops { - int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); - int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); - void (*set_rxon_chain)(struct il_priv *il, - struct il_rxon_context *ctx); -}; - -struct il_hcmd_utils_ops { - u16 (*get_hcmd_size)(u8 cmd_id, u16 len); - u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, - u8 *data); - int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); - void (*post_scan)(struct il_priv *il); -}; - -struct il_apm_ops { - int (*init)(struct il_priv *il); - void (*config)(struct il_priv *il); -}; - -struct il_debugfs_ops { - ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -}; - -struct il_temp_ops { - void (*temperature)(struct il_priv *il); -}; - -struct il_lib_ops { - /* set hw dependent parameters */ - int (*set_hw_params)(struct il_priv *il); - /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, - u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct il_priv *il, - struct il_tx_queue *txq); - int (*txq_init)(struct il_priv *il, - struct il_tx_queue *txq); - /* setup Rx handler */ - void (*handler_setup)(struct il_priv *il); - /* alive notification after init uCode load */ - void (*init_alive_start)(struct il_priv *il); - /* check validity of rtc data address */ - int (*is_valid_rtc_data_addr)(u32 addr); - /* 1st ucode load */ - int (*load_ucode)(struct il_priv *il); - - void (*dump_nic_error_log)(struct il_priv *il); - int (*dump_fh)(struct il_priv *il, char **buf, bool display); - int (*set_channel_switch)(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch); - /* power management */ - struct il_apm_ops apm_ops; - - /* power */ - int (*send_tx_power) (struct il_priv *il); - void (*update_chain_flags)(struct il_priv *il); - - /* eeprom operations (as defined in iwl-eeprom.h) */ - struct il_eeprom_ops eeprom_ops; - - /* temperature */ - struct il_temp_ops temp_ops; - - struct il_debugfs_ops debugfs_ops; - -}; - -struct il_led_ops { - int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); -}; - -struct il_legacy_ops { - void (*post_associate)(struct il_priv *il); - void (*config_ap)(struct il_priv *il); - /* station management */ - int (*update_bcast_stations)(struct il_priv *il); - int (*manage_ibss_station)(struct il_priv *il, - struct ieee80211_vif *vif, bool add); -}; - -struct il_ops { - const struct il_lib_ops *lib; - const struct il_hcmd_ops *hcmd; - const struct il_hcmd_utils_ops *utils; - const struct il_led_ops *led; - const struct il_nic_ops *nic; - const struct il_legacy_ops *legacy; - const struct ieee80211_ops *ieee80211_ops; -}; - -struct il_mod_params { - int sw_crypto; /* def: 0 = using hardware encryption */ - int disable_hw_scan; /* def: 0 = use h/w scan */ - int num_of_queues; /* def: HW dependent */ - int disable_11n; /* def: 0 = 11n capabilities enabled */ - int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ - int antenna; /* def: 0 = both antennas (use diversity) */ - int restart_fw; /* def: 1 = restart firmware */ -}; - -/* - * @led_compensation: compensate on the led on/off time per HW according - * to the deviation to achieve the desired led frequency. - * The detail algorithm is described in iwl-led.c - * @chain_noise_num_beacons: number of beacons used to compute chain noise - * @wd_timeout: TX queues watchdog timeout - * @temperature_kelvin: temperature report by uCode in kelvin - * @ucode_tracing: support ucode continuous tracing - * @sensitivity_calib_by_driver: driver has the capability to perform - * sensitivity calibration operation - * @chain_noise_calib_by_driver: driver has the capability to perform - * chain noise calibration operation - */ -struct il_base_params { - int eeprom_size; - int num_of_queues; /* def: HW dependent */ - int num_of_ampdu_queues;/* def: HW dependent */ - /* for il_apm_init() */ - u32 pll_cfg_val; - bool set_l0s; - bool use_bsm; - - u16 led_compensation; - int chain_noise_num_beacons; - unsigned int wd_timeout; - bool temperature_kelvin; - const bool ucode_tracing; - const bool sensitivity_calib_by_driver; - const bool chain_noise_calib_by_driver; -}; - -/** - * struct il_cfg - * @fw_name_pre: Firmware filename prefix. The api version and extension - * (.ucode) will be added to filename before loading from disk. The - * filename is constructed as fw_name_pre.ucode. - * @ucode_api_max: Highest version of uCode API supported by driver. - * @ucode_api_min: Lowest version of uCode API supported by driver. - * @scan_antennas: available antenna for scan operation - * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) - * - * We enable the driver to be backward compatible wrt API version. The - * driver specifies which APIs it supports (with @ucode_api_max being the - * highest and @ucode_api_min the lowest). Firmware will only be loaded if - * it has a supported API version. The firmware's API version will be - * stored in @il_priv, enabling the driver to make runtime changes based - * on firmware version used. - * - * For example, - * if (IL_UCODE_API(il->ucode_ver) >= 2) { - * Driver interacts with Firmware API version >= 2. - * } else { - * Driver interacts with Firmware API version 1. - * } - * - * The ideal usage of this infrastructure is to treat a new ucode API - * release as a new hardware revision. That is, through utilizing the - * il_hcmd_utils_ops etc. we accommodate different command structures - * and flows between hardware versions as well as their API - * versions. - * - */ -struct il_cfg { - /* params specific to an individual device within a device family */ - const char *name; - const char *fw_name_pre; - const unsigned int ucode_api_max; - const unsigned int ucode_api_min; - u8 valid_tx_ant; - u8 valid_rx_ant; - unsigned int sku; - u16 eeprom_ver; - u16 eeprom_calib_ver; - const struct il_ops *ops; - /* module based parameters which can be set from modprobe cmd */ - const struct il_mod_params *mod_params; - /* params not likely to change within a device family */ - struct il_base_params *base_params; - /* params likely to change within a device family */ - u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; - enum il_led_mode led_mode; -}; - -/*************************** - * L i b * - ***************************/ - -struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params); -int il_mac_tx_last_beacon(struct ieee80211_hw *hw); -void il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt); -int il_check_rxon_cmd(struct il_priv *il, - struct il_rxon_context *ctx); -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx); -int il_set_rxon_channel(struct il_priv *il, - struct ieee80211_channel *ch, - struct il_rxon_context *ctx); -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif); -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band); -void il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf); -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap); -void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx); -void il_set_rate(struct il_priv *il); -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats); -void il_irq_handle_error(struct il_priv *il); -int il_mac_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -int il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p); -int il_alloc_txq_mem(struct il_priv *il); -void il_txq_mem(struct il_priv *il); - -#ifdef CONFIG_IWLEGACY_DEBUGFS -int il_alloc_traffic_mem(struct il_priv *il); -void il_free_traffic_mem(struct il_priv *il); -void il_reset_traffic_log(struct il_priv *il); -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); -const char *il_get_mgmt_string(int cmd); -const char *il_get_ctrl_string(int cmd); -void il_clear_traffic_stats(struct il_priv *il); -void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, - u16 len); -#else -static inline int il_alloc_traffic_mem(struct il_priv *il) -{ - return 0; -} -static inline void il_free_traffic_mem(struct il_priv *il) -{ -} -static inline void il_reset_traffic_log(struct il_priv *il) -{ -} -static inline void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ -} -static inline void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ -} -static inline void il_update_stats(struct il_priv *il, bool is_tx, - __le16 fc, u16 len) -{ -} -#endif -/***************************************************** - * RX handlers. - * **************************************************/ -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb); - -/***************************************************** -* RX -******************************************************/ -void il_cmd_queue_unmap(struct il_priv *il); -void il_cmd_queue_free(struct il_priv *il); -int il_rx_queue_alloc(struct il_priv *il); -void il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q); -int il_rx_queue_space(const struct il_rx_queue *q); -void il_tx_cmd_complete(struct il_priv *il, - struct il_rx_buf *rxb); -/* Handlers */ -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb); -void il_recover_from_stats(struct il_priv *il, - struct il_rx_pkt *pkt); -void il_chswitch_done(struct il_priv *il, bool is_success); -void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); - -/* TX helpers */ - -/***************************************************** -* TX -******************************************************/ -void il_txq_update_write_ptr(struct il_priv *il, - struct il_tx_queue *txq); -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id); -void il_tx_queue_reset(struct il_priv *il, - struct il_tx_queue *txq, - int slots_num, u32 txq_id); -void il_tx_queue_unmap(struct il_priv *il, int txq_id); -void il_tx_queue_free(struct il_priv *il, int txq_id); -void il_setup_watchdog(struct il_priv *il); -/***************************************************** - * TX power - ****************************************************/ -int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); - -/******************************************************************************* - * Rate - ******************************************************************************/ - -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx); - -/******************************************************************************* - * Scanning - ******************************************************************************/ -void il_init_scan_params(struct il_priv *il); -int il_scan_cancel(struct il_priv *il); -int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); -void il_force_scan_end(struct il_priv *il); -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req); -void il_internal_short_hw_scan(struct il_priv *il); -int il_force_reset(struct il_priv *il, bool external); -u16 il_fill_probe_req(struct il_priv *il, - struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ie, int ie_len, int left); -void il_setup_rx_scan_handlers(struct il_priv *il); -u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes); -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif); -void il_setup_scan_deferred_work(struct il_priv *il); -void il_cancel_scan_deferred_work(struct il_priv *il); - -/* For faster active scanning, scan will move to the next channel if fewer than - * PLCP_QUIET_THRESH packets are heard on this channel within - * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell - * time if it's a quiet channel (nothing responded to our probe, and there's - * no other traffic). - * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ -#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ -#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ - -#define IL_SCAN_CHECK_WATCHDOG (HZ * 7) - -/***************************************************** - * S e n d i n g H o s t C o m m a n d s * - *****************************************************/ - -const char *il_get_cmd_string(u8 cmd); -int __must_check il_send_cmd_sync(struct il_priv *il, - struct il_host_cmd *cmd); -int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); -int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, - u16 len, const void *data); -int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, - const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)); - -int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); - - -/***************************************************** - * PCI * - *****************************************************/ - -static inline u16 il_pcie_link_ctl(struct il_priv *il) -{ - int pos; - u16 pci_lnk_ctl; - pos = pci_pcie_cap(il->pci_dev); - pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); - return pci_lnk_ctl; -} - -void il_bg_watchdog(unsigned long data); -u32 il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval); -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval); - -#ifdef CONFIG_PM -int il_pci_suspend(struct device *device); -int il_pci_resume(struct device *device); -extern const struct dev_pm_ops il_pm_ops; - -#define IL_LEGACY_PM_OPS (&il_pm_ops) - -#else /* !CONFIG_PM */ - -#define IL_LEGACY_PM_OPS NULL - -#endif /* !CONFIG_PM */ - -/***************************************************** -* Error Handling Debugging -******************************************************/ -void il4965_dump_nic_error_log(struct il_priv *il); -#ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx); -#else -static inline void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) -{ -} -#endif - -void il_clear_isr_stats(struct il_priv *il); - -/***************************************************** -* GEOS -******************************************************/ -int il_init_geos(struct il_priv *il); -void il_free_geos(struct il_priv *il); - -/*************** DRIVER STATUS FUNCTIONS *****/ - -#define S_HCMD_ACTIVE 0 /* host command in progress */ -/* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */ -#define S_INT_ENABLED 2 -#define S_RF_KILL_HW 3 -#define S_CT_KILL 4 -#define S_INIT 5 -#define S_ALIVE 6 -#define S_READY 7 -#define S_TEMPERATURE 8 -#define S_GEO_CONFIGURED 9 -#define S_EXIT_PENDING 10 -#define S_STATS 12 -#define S_SCANNING 13 -#define S_SCAN_ABORTING 14 -#define S_SCAN_HW 15 -#define S_POWER_PMI 16 -#define S_FW_ERROR 17 -#define S_CHANNEL_SWITCH_PENDING 18 - -static inline int il_is_ready(struct il_priv *il) -{ - /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are - * set but EXIT_PENDING is not */ - return test_bit(S_READY, &il->status) && - test_bit(S_GEO_CONFIGURED, &il->status) && - !test_bit(S_EXIT_PENDING, &il->status); -} - -static inline int il_is_alive(struct il_priv *il) -{ - return test_bit(S_ALIVE, &il->status); -} - -static inline int il_is_init(struct il_priv *il) -{ - return test_bit(S_INIT, &il->status); -} - -static inline int il_is_rfkill_hw(struct il_priv *il) -{ - return test_bit(S_RF_KILL_HW, &il->status); -} - -static inline int il_is_rfkill(struct il_priv *il) -{ - return il_is_rfkill_hw(il); -} - -static inline int il_is_ctkill(struct il_priv *il) -{ - return test_bit(S_CT_KILL, &il->status); -} - -static inline int il_is_ready_rf(struct il_priv *il) -{ - - if (il_is_rfkill(il)) - return 0; - - return il_is_ready(il); -} - -extern void il_send_bt_config(struct il_priv *il); -extern int il_send_stats_request(struct il_priv *il, - u8 flags, bool clear); -void il_apm_stop(struct il_priv *il); -int il_apm_init(struct il_priv *il); - -int il_send_rxon_timing(struct il_priv *il, - struct il_rxon_context *ctx); -static inline int il_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) -{ - return il->cfg->ops->hcmd->rxon_assoc(il, ctx); -} -static inline int il_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx) -{ - return il->cfg->ops->hcmd->commit_rxon(il, ctx); -} -static inline const struct ieee80211_supported_band *il_get_hw_mode( - struct il_priv *il, enum ieee80211_band band) -{ - return il->hw->wiphy->bands[band]; -} - -/* mac80211 handlers */ -int il_mac_config(struct ieee80211_hw *hw, u32 changed); -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes); -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags); - -irqreturn_t il_isr(int irq, void *data); - -#endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 3f6b06e..6c4bc50 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -31,7 +31,7 @@ #include "iwl-dev.h" #include "iwl-debug.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" /* create and remove of files */ -- cgit v0.10.2 From e94a4099adb2ec148776975bcd953a01c6bec992 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:23:20 +0200 Subject: iwlegacy: merge common header files Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index b73b425..1a690a0 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -26,7 +26,6 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-dev.h" #include "common.h" #include "3945.h" diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index b650292..3c89999 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -52,11 +52,8 @@ #define DRV_NAME "iwl3945" #include "commands.h" -#include "iwl-sta.h" -#include "3945.h" #include "common.h" -#include "iwl-helpers.h" -#include "iwl-dev.h" +#include "3945.h" #include "iwl-spectrum.h" /* @@ -1242,7 +1239,7 @@ static void il3945_rx_handle(struct il_priv *il) PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 4aa0432..dc0dfdd 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -38,7 +38,6 @@ #include "commands.h" #include "3945.h" -#include "iwl-sta.h" #define RS_NAME "iwl-3945-rs" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 795d206..02ae32c 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -39,11 +39,9 @@ #include #include +#include "common.h" #include "commands.h" -#include "iwl-sta.h" #include "iwl-eeprom.h" -#include "common.h" -#include "iwl-helpers.h" #include "iwl-led.h" #include "3945.h" @@ -417,7 +415,7 @@ void il3945_hdl_stats(struct il_priv *il, D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_stats), - le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); + le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); #endif diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index e89ca5d..726ca2c 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -34,10 +34,10 @@ /* Hardware specific file defines the PCI IDs table for that hardware module */ extern const struct pci_device_id il3945_hw_card_ids[]; +#include "common.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "iwl-power.h" -#include "iwl-dev.h" #include "iwl-led.h" #include "iwl-eeprom.h" @@ -455,10 +455,6 @@ struct il3945_eeprom { #define RFD_SIZE 4 #define NUM_TFD_CHUNKS 4 -#define RX_QUEUE_SIZE 256 -#define RX_QUEUE_MASK 255 -#define RX_QUEUE_SIZE_LOG 8 - #define TFD_CTL_COUNT_SET(n) (n << 24) #define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7) #define TFD_CTL_PAD_SET(n) (n << 28) @@ -659,7 +655,4 @@ static ssize_t il3945_ucode_general_stats_read(struct file *file, } #endif -/* Requires full declaration of il_priv before including */ -#include "iwl-io.h" - #endif diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 1e47798..405032a 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -63,7 +63,6 @@ #include #include -#include "iwl-dev.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 1056d3e..5f89031 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -25,7 +25,6 @@ * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-dev.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2f747e4..6848b91 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -51,11 +51,7 @@ #define DRV_NAME "iwl4965" #include "iwl-eeprom.h" -#include "iwl-dev.h" #include "common.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-sta.h" #include "4965.h" @@ -1362,7 +1358,7 @@ void il4965_hdl_stats(struct il_priv *il, "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il_notif_stats), le32_to_cpu(pkt->len_n_flags) & - FH_RSCSR_FRAME_SIZE_MSK); + IL_RX_FRAME_SIZE_MSK); change = ((il->_4965.stats.general.common.temperature != pkt->u.stats.general.common.temperature) || @@ -4009,7 +4005,7 @@ void il4965_rx_handle(struct il_priv *il) PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 06f5beb..f9db9df 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -35,8 +35,6 @@ #include -#include "iwl-dev.h" -#include "iwl-sta.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 7febcf3..d66d4e8 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -37,12 +37,8 @@ #include #include -#include "iwl-eeprom.h" -#include "iwl-dev.h" #include "common.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-sta.h" +#include "iwl-eeprom.h" #include "4965.h" #define IL_AC_UNSET -1 diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h index 82cf472..2f64ed3 100644 --- a/drivers/net/wireless/iwlegacy/commands.h +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -3355,6 +3355,8 @@ struct il_led_cmd { * *****************************************************************************/ +#define IL_RX_FRAME_SIZE_MSK 0x00003fff + struct il_rx_pkt { /* * The first 4 bytes of the RX frame header contain both the RX frame diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index d99ed75..4258bf6 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -41,13 +41,9 @@ #include #include "iwl-eeprom.h" -#include "iwl-dev.h" #include "iwl-debug.h" #include "common.h" -#include "iwl-io.h" #include "iwl-power.h" -#include "iwl-sta.h" -#include "iwl-helpers.h" const char *il_get_cmd_string(u8 cmd) { @@ -4351,7 +4347,7 @@ void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + u32 len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; D_RADIO("Dumping %d bytes of unhandled " "notification for %s:\n", len, il_get_cmd_string(pkt->hdr.cmd)); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 5de742c..e83c6ab 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1,74 +1,1358 @@ /****************************************************************************** * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. * * Contact Information: * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ + *****************************************************************************/ +#ifndef __il_core_h__ +#define __il_core_h__ + +#include +#include /* for struct pci_device_id */ +#include +#include +#include +#include + +#include "iwl-eeprom.h" +#include "csr.h" +#include "iwl-prph.h" +#include "iwl-debug.h" +#include "iwl-led.h" +#include "iwl-power.h" +#include "iwl-legacy-rs.h" + +struct il_host_cmd; +struct il_cmd; +struct il_tx_queue; + +#define RX_QUEUE_SIZE 256 +#define RX_QUEUE_MASK 255 +#define RX_QUEUE_SIZE_LOG 8 + +/* + * RX related structures and functions + */ +#define RX_FREE_BUFFERS 64 +#define RX_LOW_WATERMARK 8 + +#define U32_PAD(n) ((4-(n))&0x3) + +/* CT-KILL constants */ +#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ + +/* Default noise level to report when noise measurement is not available. + * This may be because we're: + * 1) Not associated (4965, no beacon stats being sent to driver) + * 2) Scanning (noise measurement does not apply to associated channel) + * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) + * Use default noise value of -127 ... this is below the range of measurable + * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. + * Also, -127 works better than 0 when averaging frames with/without + * noise info (e.g. averaging might be done in app); measured dBm values are + * always negative ... using a negative value as the default keeps all + * averages within an s8's (used in some apps) range of negative values. */ +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) + +/* + * RTS threshold here is total size [2347] minus 4 FCS bytes + * Per spec: + * a value of 0 means RTS on all data/management packets + * a value > max MSDU size means no RTS + * else RTS for data/management frames where MPDU is larger + * than RTS value. + */ +#define DEFAULT_RTS_THRESHOLD 2347U +#define MIN_RTS_THRESHOLD 0U +#define MAX_RTS_THRESHOLD 2347U +#define MAX_MSDU_SIZE 2304U +#define MAX_MPDU_SIZE 2346U +#define DEFAULT_BEACON_INTERVAL 100U +#define DEFAULT_SHORT_RETRY_LIMIT 7U +#define DEFAULT_LONG_RETRY_LIMIT 4U + +struct il_rx_buf { + dma_addr_t page_dma; + struct page *page; + struct list_head list; +}; + +#define rxb_addr(r) page_address(r->page) + +/* defined below */ +struct il_device_cmd; + +struct il_cmd_meta { + /* only for SYNC commands, iff the reply skb is wanted */ + struct il_host_cmd *source; + /* + * only for ASYNC commands + * (which is somewhat stupid -- look at common.c for instance + * which duplicates a bunch of code because the callback isn't + * invoked for SYNC commands, if it were and its result passed + * through it would be simpler...) + */ + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); + + /* The CMD_SIZE_HUGE flag bit indicates that the command + * structure is stored at the end of the shared queue memory. */ + u32 flags; + + DEFINE_DMA_UNMAP_ADDR(mapping); + DEFINE_DMA_UNMAP_LEN(len); +}; + +/* + * Generic queue structure + * + * Contains common data for Rx and Tx queues + */ +struct il_queue { + int n_bd; /* number of BDs in this queue */ + int write_ptr; /* 1-st empty entry (idx) host_w*/ + int read_ptr; /* last used entry (idx) host_r*/ + /* use for monitoring and recovering the stuck queue */ + dma_addr_t dma_addr; /* physical addr for BD's */ + int n_win; /* safe queue win */ + u32 id; + int low_mark; /* low watermark, resume queue if free + * space more than this */ + int high_mark; /* high watermark, stop queue if free + * space less than this */ +}; + +/* One for each TFD */ +struct il_tx_info { + struct sk_buff *skb; + struct il_rxon_context *ctx; +}; + +/** + * struct il_tx_queue - Tx Queue for DMA + * @q: generic Rx/Tx queue descriptor + * @bd: base of circular buffer of TFDs + * @cmd: array of command/TX buffer pointers + * @meta: array of meta data for each command/tx buffer + * @dma_addr_cmd: physical address of cmd/tx buffer array + * @txb: array of per-TFD driver data + * @time_stamp: time (in jiffies) of last read_ptr change + * @need_update: indicates need to update read/write idx + * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled + * + * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame + * descriptors) and required locking structures. + */ +#define TFD_TX_CMD_SLOTS 256 +#define TFD_CMD_SLOTS 32 + +struct il_tx_queue { + struct il_queue q; + void *tfds; + struct il_device_cmd **cmd; + struct il_cmd_meta *meta; + struct il_tx_info *txb; + unsigned long time_stamp; + u8 need_update; + u8 sched_retry; + u8 active; + u8 swq_id; +}; + +#define IL_NUM_SCAN_RATES (2) + +struct il4965_channel_tgd_info { + u8 type; + s8 max_power; +}; + +struct il4965_channel_tgh_info { + s64 last_radar_time; +}; + +#define IL4965_MAX_RATE (33) + +struct il3945_clip_group { + /* maximum power level to prevent clipping for each rate, derived by + * us from this band's saturation power in EEPROM */ + const s8 clip_powers[IL_MAX_RATES]; +}; + +/* current Tx power values to use, one for each rate for each channel. + * requested power is limited by: + * -- regulatory EEPROM limits for this channel + * -- hardware capabilities (clip-powers) + * -- spectrum management + * -- user preference (e.g. iwconfig) + * when requested power is set, base power idx must also be set. */ +struct il3945_channel_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ + s8 base_power_idx; /* gain idx for power at factory temp. */ + s8 requested_power; /* power (dBm) requested for this chnl/rate */ +}; + +/* current scan Tx power values to use, one for each scan rate for each + * channel. */ +struct il3945_scan_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ + s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ +}; + +/* + * One for each channel, holds all channel setup data + * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant + * with one another! + */ +struct il_channel_info { + struct il4965_channel_tgd_info tgd; + struct il4965_channel_tgh_info tgh; + struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */ + struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for + * HT40 channel */ + + u8 channel; /* channel number */ + u8 flags; /* flags copied from EEPROM */ + s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ + s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ + s8 min_power; /* always 0 */ + s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ + + u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ + u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ + enum ieee80211_band band; + + /* HT40 channel info */ + s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ + u8 ht40_flags; /* flags copied from EEPROM */ + u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ + + /* Radio/DSP gain settings for each "normal" data Tx rate. + * These include, in addition to RF and DSP gain, a few fields for + * remembering/modifying gain settings (idxes). */ + struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; + + /* Radio/DSP gain settings for each scan rate, for directed scans. */ + struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; +}; + +#define IL_TX_FIFO_BK 0 /* shared */ +#define IL_TX_FIFO_BE 1 +#define IL_TX_FIFO_VI 2 /* shared */ +#define IL_TX_FIFO_VO 3 +#define IL_TX_FIFO_UNUSED -1 + +/* Minimum number of queues. MAX_NUM is defined in hw specific files. + * Set the minimum to accommodate the 4 standard TX queues, 1 command + * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */ +#define IL_MIN_NUM_QUEUES 10 + +#define IL_DEFAULT_CMD_QUEUE_NUM 4 + +#define IEEE80211_DATA_LEN 2304 +#define IEEE80211_4ADDR_LEN 30 +#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) +#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) + +struct il_frame { + union { + struct ieee80211_hdr frame; + struct il_tx_beacon_cmd beacon; + u8 raw[IEEE80211_FRAME_LEN]; + u8 cmd[360]; + } u; + struct list_head list; +}; + +#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) +#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) +#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) + +enum { + CMD_SYNC = 0, + CMD_SIZE_NORMAL = 0, + CMD_NO_SKB = 0, + CMD_SIZE_HUGE = (1 << 0), + CMD_ASYNC = (1 << 1), + CMD_WANT_SKB = (1 << 2), + CMD_MAPPED = (1 << 3), +}; + +#define DEF_CMD_PAYLOAD_SIZE 320 + +/** + * struct il_device_cmd + * + * For allocation of the command and tx queues, this establishes the overall + * size of the largest command we send to uCode, except for a scan command + * (which is relatively huge; space is allocated separately). + */ +struct il_device_cmd { + struct il_cmd_header hdr; /* uCode API */ + union { + u32 flags; + u8 val8; + u16 val16; + u32 val32; + struct il_tx_cmd tx; + u8 payload[DEF_CMD_PAYLOAD_SIZE]; + } __packed cmd; +} __packed; + +#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) + + +struct il_host_cmd { + const void *data; + unsigned long reply_page; + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); + u32 flags; + u16 len; + u8 id; +}; + +#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 +#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 +#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 + +/** + * struct il_rx_queue - Rx queue + * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) + * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) + * @read: Shared idx to newest available Rx buffer + * @write: Shared idx to oldest written Rx packet + * @free_count: Number of pre-allocated buffers in rx_free + * @rx_free: list of free SKBs for use + * @rx_used: List of Rx buffers with no SKB + * @need_update: flag to indicate we need to update read/write idx + * @rb_stts: driver's pointer to receive buffer status + * @rb_stts_dma: bus address of receive buffer status + * + * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs + */ +struct il_rx_queue { + __le32 *bd; + dma_addr_t bd_dma; + struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; + struct il_rx_buf *queue[RX_QUEUE_SIZE]; + u32 read; + u32 write; + u32 free_count; + u32 write_actual; + struct list_head rx_free; + struct list_head rx_used; + int need_update; + struct il_rb_status *rb_stts; + dma_addr_t rb_stts_dma; + spinlock_t lock; +}; + +#define IL_SUPPORTED_RATES_IE_LEN 8 + +#define MAX_TID_COUNT 9 + +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 + +/** + * struct il_ht_agg -- aggregation status while waiting for block-ack + * @txq_id: Tx queue used for Tx attempt + * @frame_count: # frames attempted by Tx command + * @wait_for_ba: Expect block-ack before next Tx reply + * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win + * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win + * @bitmap1: High order, one bit for each frame pending ACK in Tx win + * @rate_n_flags: Rate at which Tx was attempted + * + * If C_TX indicates that aggregation was attempted, driver must wait + * for block ack (N_COMPRESSED_BA). This struct stores tx reply info + * until block ack arrives. + */ +struct il_ht_agg { + u16 txq_id; + u16 frame_count; + u16 wait_for_ba; + u16 start_idx; + u64 bitmap; + u32 rate_n_flags; +#define IL_AGG_OFF 0 +#define IL_AGG_ON 1 +#define IL_EMPTYING_HW_QUEUE_ADDBA 2 +#define IL_EMPTYING_HW_QUEUE_DELBA 3 + u8 state; +}; + + +struct il_tid_data { + u16 seq_number; /* 4965 only */ + u16 tfds_in_queue; + struct il_ht_agg agg; +}; + +struct il_hw_key { + u32 cipher; + int keylen; + u8 keyidx; + u8 key[32]; +}; + +union il_ht_rate_supp { + u16 rates; + struct { + u8 siso_rate; + u8 mimo_rate; + }; +}; + +#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0) +#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1) +#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2) +#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3) +#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K +#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K +#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K + +/* + * Maximal MPDU density for TX aggregation + * 4 - 2us density + * 5 - 4us density + * 6 - 8us density + * 7 - 16us density + */ +#define CFG_HT_MPDU_DENSITY_2USEC (0x4) +#define CFG_HT_MPDU_DENSITY_4USEC (0x5) +#define CFG_HT_MPDU_DENSITY_8USEC (0x6) +#define CFG_HT_MPDU_DENSITY_16USEC (0x7) +#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC +#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC +#define CFG_HT_MPDU_DENSITY_MIN (0x1) + +struct il_ht_config { + bool single_chain_sufficient; + enum ieee80211_smps_mode smps; /* current smps mode */ +}; + +/* QoS structures */ +struct il_qos_info { + int qos_active; + struct il_qosparam_cmd def_qos_parm; +}; + +/* + * Structure should be accessed with sta_lock held. When station addition + * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only + * the commands (il_addsta_cmd and il_link_quality_cmd) without + * sta_lock held. + */ +struct il_station_entry { + struct il_addsta_cmd sta; + struct il_tid_data tid[MAX_TID_COUNT]; + u8 used, ctxid; + struct il_hw_key keyinfo; + struct il_link_quality_cmd *lq; +}; + +struct il_station_priv_common { + struct il_rxon_context *ctx; + u8 sta_id; +}; + +/* + * il_station_priv: Driver's ilate station information + * + * When mac80211 creates a station it reserves some space (hw->sta_data_size) + * in the structure for use by driver. This structure is places in that + * space. + * + * The common struct MUST be first because it is shared between + * 3945 and 4965! + */ +struct il_station_priv { + struct il_station_priv_common common; + struct il_lq_sta lq_sta; + atomic_t pending_frames; + bool client; + bool asleep; +}; + +/** + * struct il_vif_priv - driver's ilate per-interface information + * + * When mac80211 allocates a virtual interface, it can allocate + * space for us to put data into. + */ +struct il_vif_priv { + struct il_rxon_context *ctx; + u8 ibss_bssid_sta_id; +}; + +/* one for each uCode image (inst/data, boot/init/runtime) */ +struct fw_desc { + void *v_addr; /* access by driver */ + dma_addr_t p_addr; /* access by card's busmaster DMA */ + u32 len; /* bytes */ +}; + +/* uCode file layout */ +struct il_ucode_header { + __le32 ver; /* major/minor/API/serial */ + struct { + __le32 inst_size; /* bytes of runtime code */ + __le32 data_size; /* bytes of runtime data */ + __le32 init_size; /* bytes of init code */ + __le32 init_data_size; /* bytes of init data */ + __le32 boot_size; /* bytes of bootstrap code */ + u8 data[0]; /* in same order as sizes */ + } v1; +}; + +struct il4965_ibss_seq { + u8 mac[ETH_ALEN]; + u16 seq_num; + u16 frag_num; + unsigned long packet_time; + struct list_head list; +}; + +struct il_sensitivity_ranges { + u16 min_nrg_cck; + u16 max_nrg_cck; + + u16 nrg_th_cck; + u16 nrg_th_ofdm; + + u16 auto_corr_min_ofdm; + u16 auto_corr_min_ofdm_mrc; + u16 auto_corr_min_ofdm_x1; + u16 auto_corr_min_ofdm_mrc_x1; + + u16 auto_corr_max_ofdm; + u16 auto_corr_max_ofdm_mrc; + u16 auto_corr_max_ofdm_x1; + u16 auto_corr_max_ofdm_mrc_x1; + + u16 auto_corr_max_cck; + u16 auto_corr_max_cck_mrc; + u16 auto_corr_min_cck; + u16 auto_corr_min_cck_mrc; + + u16 barker_corr_th_min; + u16 barker_corr_th_min_mrc; + u16 nrg_th_cca; +}; + + +#define KELVIN_TO_CELSIUS(x) ((x)-273) +#define CELSIUS_TO_KELVIN(x) ((x)+273) + + +/** + * struct il_hw_params + * @max_txq_num: Max # Tx queues supported + * @dma_chnl_num: Number of Tx DMA/FIFO channels + * @scd_bc_tbls_size: size of scheduler byte count tables + * @tfd_size: TFD size + * @tx/rx_chains_num: Number of TX/RX chains + * @valid_tx/rx_ant: usable antennas + * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2) + * @max_rxq_log: Log-base-2 of max_rxq_size + * @rx_page_order: Rx buffer page order + * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR + * @max_stations: + * @ht40_channel: is 40MHz width possible in band 2.4 + * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ) + * @sw_crypto: 0 for hw, 1 for sw + * @max_xxx_size: for ucode uses + * @ct_kill_threshold: temperature threshold + * @beacon_time_tsf_bits: number of valid tsf bits for beacon time + * @struct il_sensitivity_ranges: range of sensitivity values + */ +struct il_hw_params { + u8 max_txq_num; + u8 dma_chnl_num; + u16 scd_bc_tbls_size; + u32 tfd_size; + u8 tx_chains_num; + u8 rx_chains_num; + u8 valid_tx_ant; + u8 valid_rx_ant; + u16 max_rxq_size; + u16 max_rxq_log; + u32 rx_page_order; + u32 rx_wrt_ptr_reg; + u8 max_stations; + u8 ht40_channel; + u8 max_beacon_itrvl; /* in 1024 ms */ + u32 max_inst_size; + u32 max_data_size; + u32 max_bsm_size; + u32 ct_kill_threshold; /* value in hw-dependent units */ + u16 beacon_time_tsf_bits; + const struct il_sensitivity_ranges *sens; +}; + + +/****************************************************************************** + * + * Functions implemented in core module which are forward declared here + * for use by iwl-[4-5].c + * + * NOTE: The implementation of these functions are not hardware specific + * which is why they are in the core module files. + * + * Naming convention -- + * il_ <-- Is part of iwlwifi + * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) + * il4965_bg_ <-- Called from work queue context + * il4965_mac_ <-- mac80211 callback + * + ****************************************************************************/ +extern void il4965_update_chain_flags(struct il_priv *il); +extern const u8 il_bcast_addr[ETH_ALEN]; +extern int il_queue_space(const struct il_queue *q); +static inline int il_queue_used(const struct il_queue *q, int i) +{ + return q->write_ptr >= q->read_ptr ? + (i >= q->read_ptr && i < q->write_ptr) : + !(i < q->read_ptr && i >= q->write_ptr); +} + + +static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, + int is_huge) +{ + /* + * This is for init calibration result and scan command which + * required buffer > TFD_MAX_PAYLOAD_SIZE, + * the big buffer at end of command array + */ + if (is_huge) + return q->n_win; /* must be power of 2 */ + + /* Otherwise, use normal size buffers */ + return idx & (q->n_win - 1); +} + + +struct il_dma_ptr { + dma_addr_t dma; + void *addr; + size_t size; +}; + +#define IL_OPERATION_MODE_AUTO 0 +#define IL_OPERATION_MODE_HT_ONLY 1 +#define IL_OPERATION_MODE_MIXED 2 +#define IL_OPERATION_MODE_20MHZ 3 + +#define IL_TX_CRC_SIZE 4 +#define IL_TX_DELIMITER_SIZE 4 + +#define TX_POWER_IL_ILLEGAL_VOLTAGE -10000 + +/* Sensitivity and chain noise calibration */ +#define INITIALIZATION_VALUE 0xFFFF +#define IL4965_CAL_NUM_BEACONS 20 +#define IL_CAL_NUM_BEACONS 16 +#define MAXIMUM_ALLOWED_PATHLOSS 15 + +#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 + +#define MAX_FA_OFDM 50 +#define MIN_FA_OFDM 5 +#define MAX_FA_CCK 50 +#define MIN_FA_CCK 5 + +#define AUTO_CORR_STEP_OFDM 1 + +#define AUTO_CORR_STEP_CCK 3 +#define AUTO_CORR_MAX_TH_CCK 160 + +#define NRG_DIFF 2 +#define NRG_STEP_CCK 2 +#define NRG_MARGIN 8 +#define MAX_NUMBER_CCK_NO_FA 100 + +#define AUTO_CORR_CCK_MIN_VAL_DEF (125) + +#define CHAIN_A 0 +#define CHAIN_B 1 +#define CHAIN_C 2 +#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4 +#define ALL_BAND_FILTER 0xFF00 +#define IN_BAND_FILTER 0xFF +#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF + +#define NRG_NUM_PREV_STAT_L 20 +#define NUM_RX_CHAINS 3 + +enum il4965_false_alarm_state { + IL_FA_TOO_MANY = 0, + IL_FA_TOO_FEW = 1, + IL_FA_GOOD_RANGE = 2, +}; + +enum il4965_chain_noise_state { + IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ + IL_CHAIN_NOISE_ACCUMULATE, + IL_CHAIN_NOISE_CALIBRATED, + IL_CHAIN_NOISE_DONE, +}; + +enum il4965_calib_enabled_state { + IL_CALIB_DISABLED = 0, /* must be 0 */ + IL_CALIB_ENABLED = 1, +}; + +/* + * enum il_calib + * defines the order in which results of initial calibrations + * should be sent to the runtime uCode + */ +enum il_calib { + IL_CALIB_MAX, +}; + +/* Opaque calibration results */ +struct il_calib_result { + void *buf; + size_t buf_len; +}; + +enum ucode_type { + UCODE_NONE = 0, + UCODE_INIT, + UCODE_RT +}; + +/* Sensitivity calib data */ +struct il_sensitivity_data { + u32 auto_corr_ofdm; + u32 auto_corr_ofdm_mrc; + u32 auto_corr_ofdm_x1; + u32 auto_corr_ofdm_mrc_x1; + u32 auto_corr_cck; + u32 auto_corr_cck_mrc; + + u32 last_bad_plcp_cnt_ofdm; + u32 last_fa_cnt_ofdm; + u32 last_bad_plcp_cnt_cck; + u32 last_fa_cnt_cck; + + u32 nrg_curr_state; + u32 nrg_prev_state; + u32 nrg_value[10]; + u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; + u32 nrg_silence_ref; + u32 nrg_energy_idx; + u32 nrg_silence_idx; + u32 nrg_th_cck; + s32 nrg_auto_corr_silence_diff; + u32 num_in_cck_no_fa; + u32 nrg_th_ofdm; + + u16 barker_corr_th_min; + u16 barker_corr_th_min_mrc; + u16 nrg_th_cca; +}; + +/* Chain noise (differential Rx gain) calib data */ +struct il_chain_noise_data { + u32 active_chains; + u32 chain_noise_a; + u32 chain_noise_b; + u32 chain_noise_c; + u32 chain_signal_a; + u32 chain_signal_b; + u32 chain_signal_c; + u16 beacon_count; + u8 disconn_array[NUM_RX_CHAINS]; + u8 delta_gain_code[NUM_RX_CHAINS]; + u8 radio_write; + u8 state; +}; + +#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ +#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ + +#define IL_TRAFFIC_ENTRIES (256) +#define IL_TRAFFIC_ENTRY_SIZE (64) + +enum { + MEASUREMENT_READY = (1 << 0), + MEASUREMENT_ACTIVE = (1 << 1), +}; + +/* interrupt stats */ +struct isr_stats { + u32 hw; + u32 sw; + u32 err_code; + u32 sch; + u32 alive; + u32 rfkill; + u32 ctkill; + u32 wakeup; + u32 rx; + u32 handlers[IL_CN_MAX]; + u32 tx; + u32 unhandled; +}; + +/* management stats */ +enum il_mgmt_stats { + MANAGEMENT_ASSOC_REQ = 0, + MANAGEMENT_ASSOC_RESP, + MANAGEMENT_REASSOC_REQ, + MANAGEMENT_REASSOC_RESP, + MANAGEMENT_PROBE_REQ, + MANAGEMENT_PROBE_RESP, + MANAGEMENT_BEACON, + MANAGEMENT_ATIM, + MANAGEMENT_DISASSOC, + MANAGEMENT_AUTH, + MANAGEMENT_DEAUTH, + MANAGEMENT_ACTION, + MANAGEMENT_MAX, +}; +/* control stats */ +enum il_ctrl_stats { + CONTROL_BACK_REQ = 0, + CONTROL_BACK, + CONTROL_PSPOLL, + CONTROL_RTS, + CONTROL_CTS, + CONTROL_ACK, + CONTROL_CFEND, + CONTROL_CFENDACK, + CONTROL_MAX, +}; + +struct traffic_stats { +#ifdef CONFIG_IWLEGACY_DEBUGFS + u32 mgmt[MANAGEMENT_MAX]; + u32 ctrl[CONTROL_MAX]; + u32 data_cnt; + u64 data_bytes; +#endif +}; + +/* + * host interrupt timeout value + * used with setting interrupt coalescing timer + * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit + * + * default interrupt coalescing timer is 64 x 32 = 2048 usecs + * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs + */ +#define IL_HOST_INT_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_TIMEOUT_DEF (0x40) +#define IL_HOST_INT_TIMEOUT_MIN (0x0) +#define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) +#define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) + +#define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) + +/* TX queue watchdog timeouts in mSecs */ +#define IL_DEF_WD_TIMEOUT (2000) +#define IL_LONG_WD_TIMEOUT (10000) +#define IL_MAX_WD_TIMEOUT (120000) + +struct il_force_reset { + int reset_request_count; + int reset_success_count; + int reset_reject_count; + unsigned long reset_duration; + unsigned long last_force_reset_jiffies; +}; + +/* extend beacon time format bit shifting */ +/* + * for _3945 devices + * bits 31:24 - extended + * bits 23:0 - interval + */ +#define IL3945_EXT_BEACON_TIME_POS 24 +/* + * for _4965 devices + * bits 31:22 - extended + * bits 21:0 - interval + */ +#define IL4965_EXT_BEACON_TIME_POS 22 + +struct il_rxon_context { + struct ieee80211_vif *vif; + + const u8 *ac_to_fifo; + const u8 *ac_to_queue; + u8 mcast_queue; + + /* + * We could use the vif to indicate active, but we + * also need it to be active during disabling when + * we already removed the vif for type setting. + */ + bool always_active, is_active; + + bool ht_need_multiple_chains; + + int ctxid; + + u32 interface_modes, exclusive_interface_modes; + u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; + + /* + * We declare this const so it can only be + * changed via explicit cast within the + * routines that actually update the physical + * hardware. + */ + const struct il_rxon_cmd active; + struct il_rxon_cmd staging; + + struct il_rxon_time_cmd timing; + + struct il_qos_info qos_data; + + u8 bcast_sta_id, ap_sta_id; + + u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; + u8 qos_cmd; + u8 wep_key_cmd; + + struct il_wep_key wep_keys[WEP_KEYS_MAX]; + u8 key_mapping_keys; + + __le32 station_flags; + + struct { + bool non_gf_sta_present; + u8 protection; + bool enabled, is_40mhz; + u8 extension_chan_offset; + } ht; +}; + +struct il_priv { + + /* ieee device used by generic ieee processing code */ + struct ieee80211_hw *hw; + struct ieee80211_channel *ieee_channels; + struct ieee80211_rate *ieee_rates; + struct il_cfg *cfg; + + /* temporary frame storage list */ + struct list_head free_frames; + int frames_count; + + enum ieee80211_band band; + int alloc_rxb_page; + + void (*handlers[IL_CN_MAX])(struct il_priv *il, + struct il_rx_buf *rxb); + + struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; + + /* spectrum measurement report caching */ + struct il_spectrum_notification measure_report; + u8 measurement_status; + + /* ucode beacon time */ + u32 ucode_beacon_time; + int missed_beacon_threshold; + + /* track IBSS manager (last beacon) status */ + u32 ibss_manager; + + /* force reset */ + struct il_force_reset force_reset; + + /* we allocate array of il_channel_info for NIC's valid channels. + * Access via channel # using indirect idx array */ + struct il_channel_info *channel_info; /* channel info array */ + u8 channel_count; /* # of channels */ + + /* thermal calibration */ + s32 temperature; /* degrees Kelvin */ + s32 last_temperature; + + /* init calibration results */ + struct il_calib_result calib_results[IL_CALIB_MAX]; + + /* Scan related variables */ + unsigned long scan_start; + unsigned long scan_start_tsf; + void *scan_cmd; + enum ieee80211_band scan_band; + struct cfg80211_scan_request *scan_request; + struct ieee80211_vif *scan_vif; + u8 scan_tx_ant[IEEE80211_NUM_BANDS]; + u8 mgmt_tx_ant; + + /* spinlock */ + spinlock_t lock; /* protect general shared data */ + spinlock_t hcmd_lock; /* protect hcmd */ + spinlock_t reg_lock; /* protect hw register access */ + struct mutex mutex; + + /* basic pci-network driver stuff */ + struct pci_dev *pci_dev; + + /* pci hardware address support */ + void __iomem *hw_base; + u32 hw_rev; + u32 hw_wa_rev; + u8 rev_id; + + /* command queue number */ + u8 cmd_queue; + + /* max number of station keys */ + u8 sta_key_max_num; + + /* EEPROM MAC addresses */ + struct mac_address addresses[1]; + + /* uCode images, save to reload in case of failure */ + int fw_idx; /* firmware we're trying to load */ + u32 ucode_ver; /* version of ucode, copy of + il_ucode.ver */ + struct fw_desc ucode_code; /* runtime inst */ + struct fw_desc ucode_data; /* runtime data original */ + struct fw_desc ucode_data_backup; /* runtime data save/restore */ + struct fw_desc ucode_init; /* initialization inst */ + struct fw_desc ucode_init_data; /* initialization data */ + struct fw_desc ucode_boot; /* bootstrap inst */ + enum ucode_type ucode_type; + u8 ucode_write_complete; /* the image write is complete */ + char firmware_name[25]; + + struct il_rxon_context ctx; + + __le16 switch_channel; + + /* 1st responses from initialize and runtime uCode images. + * _4965's initialize alive response contains some calibration data. */ + struct il_init_alive_resp card_alive_init; + struct il_alive_resp card_alive; + + u16 active_rate; + + u8 start_calib; + struct il_sensitivity_data sensitivity_data; + struct il_chain_noise_data chain_noise_data; + __le16 sensitivity_tbl[HD_TBL_SIZE]; + + struct il_ht_config current_ht_config; + + /* Rate scaling data */ + u8 retry_rate; + + wait_queue_head_t wait_command_queue; + + int activity_timer_active; + + /* Rx and Tx DMA processing queues */ + struct il_rx_queue rxq; + struct il_tx_queue *txq; + unsigned long txq_ctx_active_msk; + struct il_dma_ptr kw; /* keep warm address */ + struct il_dma_ptr scd_bc_tbls; + + u32 scd_base_addr; /* scheduler sram base address */ + + unsigned long status; + + /* counts mgmt, ctl, and data packets */ + struct traffic_stats tx_stats; + struct traffic_stats rx_stats; + + /* counts interrupts */ + struct isr_stats isr_stats; + + struct il_power_mgr power_data; + + /* context information */ + u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ + + /* station table variables */ + + /* Note: if lock and sta_lock are needed, lock must be acquired first */ + spinlock_t sta_lock; + int num_stations; + struct il_station_entry stations[IL_STATION_COUNT]; + unsigned long ucode_key_table; + + /* queue refcounts */ +#define IL_MAX_HW_QUEUES 32 + unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)]; + /* for each AC */ + atomic_t queue_stop_count[4]; + + /* Indication if ieee80211_ops->open has been called */ + u8 is_open; + + u8 mac80211_registered; + + /* eeprom -- this is in the card's little endian byte order */ + u8 *eeprom; + struct il_eeprom_calib_info *calib_info; + + enum nl80211_iftype iw_mode; + + /* Last Rx'd beacon timestamp */ + u64 timestamp; + + union { +#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE) + struct { + void *shared_virt; + dma_addr_t shared_phys; + + struct delayed_work thermal_periodic; + struct delayed_work rfkill_poll; + + struct il3945_notif_stats stats; +#ifdef CONFIG_IWLEGACY_DEBUGFS + struct il3945_notif_stats accum_stats; + struct il3945_notif_stats delta_stats; + struct il3945_notif_stats max_delta; +#endif + + u32 sta_supp_rates; + int last_rx_rssi; /* From Rx packet stats */ + + /* Rx'd packet timing information */ + u32 last_beacon_time; + u64 last_tsf; + + /* + * each calibration channel group in the + * EEPROM has a derived clip setting for + * each rate. + */ + const struct il3945_clip_group clip_groups[5]; + + } _3945; +#endif +#if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) + struct { + struct il_rx_phy_res last_phy_res; + bool last_phy_res_valid; + + struct completion firmware_loading_complete; + + /* + * chain noise reset and gain commands are the + * two extra calibration commands follows the standard + * phy calibration commands + */ + u8 phy_calib_chain_noise_reset_cmd; + u8 phy_calib_chain_noise_gain_cmd; + + struct il_notif_stats stats; +#ifdef CONFIG_IWLEGACY_DEBUGFS + struct il_notif_stats accum_stats; + struct il_notif_stats delta_stats; + struct il_notif_stats max_delta; +#endif + + } _4965; +#endif + }; + + struct il_hw_params hw_params; + + u32 inta_mask; + + struct workqueue_struct *workqueue; + + struct work_struct restart; + struct work_struct scan_completed; + struct work_struct rx_replenish; + struct work_struct abort_scan; + + struct il_rxon_context *beacon_ctx; + struct sk_buff *beacon_skb; + + struct work_struct tx_flush; + + struct tasklet_struct irq_tasklet; + + struct delayed_work init_alive_start; + struct delayed_work alive_start; + struct delayed_work scan_check; + + /* TX Power */ + s8 tx_power_user_lmt; + s8 tx_power_device_lmt; + s8 tx_power_next; + + +#ifdef CONFIG_IWLEGACY_DEBUG + /* debugging info */ + u32 debug_level; /* per device debugging will override global + il_debug_level if set */ +#endif /* CONFIG_IWLEGACY_DEBUG */ +#ifdef CONFIG_IWLEGACY_DEBUGFS + /* debugfs */ + u16 tx_traffic_idx; + u16 rx_traffic_idx; + u8 *tx_traffic; + u8 *rx_traffic; + struct dentry *debugfs_dir; + u32 dbgfs_sram_offset, dbgfs_sram_len; + bool disable_ht40; +#endif /* CONFIG_IWLEGACY_DEBUGFS */ + + struct work_struct txpower_work; + u32 disable_sens_cal; + u32 disable_chain_noise_cal; + u32 disable_tx_power_cal; + struct work_struct run_time_calib_work; + struct timer_list stats_periodic; + struct timer_list watchdog; + bool hw_ready; + + struct led_classdev led; + unsigned long blink_on, blink_off; + bool led_registered; +}; /*il_priv */ + +static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) +{ + set_bit(txq_id, &il->txq_ctx_active_msk); +} + +static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) +{ + clear_bit(txq_id, &il->txq_ctx_active_msk); +} + +#ifdef CONFIG_IWLEGACY_DEBUG +/* + * il_get_debug_level: Return active debug level for device + * + * Using sysfs it is possible to set per device debug level. This debug + * level will be used if set, otherwise the global debug level which can be + * set via module parameter is used. + */ +static inline u32 il_get_debug_level(struct il_priv *il) +{ + if (il->debug_level) + return il->debug_level; + else + return il_debug_level; +} +#else +static inline u32 il_get_debug_level(struct il_priv *il) +{ + return il_debug_level; +} +#endif -#ifndef __il_core_h__ -#define __il_core_h__ -/************************ - * forward declarations * - ************************/ -struct il_host_cmd; -struct il_cmd; +static inline struct ieee80211_hdr * +il_tx_queue_get_hdr(struct il_priv *il, + int txq_id, int idx) +{ + if (il->txq[txq_id].txb[idx].skb) + return (struct ieee80211_hdr *)il->txq[txq_id]. + txb[idx].skb->data; + return NULL; +} + +static inline struct il_rxon_context * +il_rxon_ctx_from_vif(struct ieee80211_vif *vif) +{ + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + + return vif_priv->ctx; +} + +#define for_each_context(il, _ctx) \ + for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) + +static inline int il_is_associated(struct il_priv *il) +{ + return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; +} + +static inline int il_is_any_associated(struct il_priv *il) +{ + return il_is_associated(il); +} + +static inline int il_is_associated_ctx(struct il_rxon_context *ctx) +{ + return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; +} + +static inline int il_is_channel_valid(const struct il_channel_info *ch_info) +{ + if (ch_info == NULL) + return 0; + return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; +} + +static inline int il_is_channel_radar(const struct il_channel_info *ch_info) +{ + return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; +} + +static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) +{ + return ch_info->band == IEEE80211_BAND_5GHZ; +} + +static inline int +il_is_channel_passive(const struct il_channel_info *ch) +{ + return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; +} + +static inline int +il_is_channel_ibss(const struct il_channel_info *ch) +{ + return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; +} +static inline void +__il_free_pages(struct il_priv *il, struct page *page) +{ + __free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; +} + +static inline void il_free_pages(struct il_priv *il, unsigned long page) +{ + free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; +} #define IWLWIFI_VERSION "in-tree:" #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" @@ -87,6 +1371,11 @@ struct il_cmd; #define IL_CMD(x) case x: return #x +/* Size of one Rx buffer in host DRAM */ +#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ +#define IL_RX_BUF_SIZE_4K (4 * 1024) +#define IL_RX_BUF_SIZE_8K (8 * 1024) + struct il_hcmd_ops { int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); @@ -633,4 +1922,655 @@ void il_tx_cmd_protection(struct il_priv *il, irqreturn_t il_isr(int irq, void *data); + +#include + +static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) +{ + iowrite8(val, il->hw_base + ofs); +} +#define il_write8(il, ofs, val) _il_write8(il, ofs, val) + +static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) +{ + iowrite32(val, il->hw_base + ofs); +} + +static inline u32 _il_rd(struct il_priv *il, u32 ofs) +{ + return ioread32(il->hw_base + ofs); +} + +#define IL_POLL_INTERVAL 10 /* microseconds */ +static inline int +_il_poll_bit(struct il_priv *il, u32 addr, + u32 bits, u32 mask, int timeout) +{ + int t = 0; + + do { + if ((_il_rd(il, addr) & mask) == (bits & mask)) + return t; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; + } while (t < timeout); + + return -ETIMEDOUT; +} + +static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) +{ + _il_wr(il, reg, _il_rd(il, reg) | mask); +} + +static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&p->reg_lock, reg_flags); + _il_set_bit(p, r, m); + spin_unlock_irqrestore(&p->reg_lock, reg_flags); +} + +static inline void +_il_clear_bit(struct il_priv *il, u32 reg, u32 mask) +{ + _il_wr(il, reg, _il_rd(il, reg) & ~mask); +} + +static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&p->reg_lock, reg_flags); + _il_clear_bit(p, r, m); + spin_unlock_irqrestore(&p->reg_lock, reg_flags); +} + +static inline int _il_grab_nic_access(struct il_priv *il) +{ + int ret; + u32 val; + + /* this bit wakes up the NIC */ + _il_set_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + + /* + * These bits say the device is running, and should keep running for + * at least a short while (at least as long as MAC_ACCESS_REQ stays 1), + * but they do not indicate that embedded SRAM is restored yet; + * 3945 and 4965 have volatile SRAM, and must save/restore contents + * to/from host DRAM when sleeping/waking for power-saving. + * Each direction takes approximately 1/4 millisecond; with this + * overhead, it's a good idea to grab and hold MAC_ACCESS_REQUEST if a + * series of register accesses are expected (e.g. reading Event Log), + * to keep device from sleeping. + * + * CSR_UCODE_DRV_GP1 register bit MAC_SLEEP == 0 indicates that + * SRAM is okay/restored. We don't check that here because this call + * is just for hardware register access; but GP1 MAC_SLEEP check is a + * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). + * + */ + ret = _il_poll_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, + (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | + CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); + if (ret < 0) { + val = _il_rd(il, CSR_GP_CNTRL); + IL_ERR( + "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); + _il_wr(il, CSR_RESET, + CSR_RESET_REG_FLAG_FORCE_NMI); + return -EIO; + } + + return 0; +} + +static inline void _il_release_nic_access(struct il_priv *il) +{ + _il_clear_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); +} + +static inline u32 il_rd(struct il_priv *il, u32 reg) +{ + u32 value; + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + value = _il_rd(il, reg); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); + return value; + +} + +static inline void +il_wr(struct il_priv *il, u32 reg, u32 value) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr(il, reg, value); + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline void il_write_reg_buf(struct il_priv *il, + u32 reg, u32 len, u32 *values) +{ + u32 count = sizeof(u32); + + if (il != NULL && values != NULL) { + for (; 0 < len; len -= count, reg += count, values++) + il_wr(il, reg, *values); + } +} + +static inline int il_poll_bit(struct il_priv *il, u32 addr, + u32 mask, int timeout) +{ + int t = 0; + + do { + if ((il_rd(il, addr) & mask) == mask) + return t; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; + } while (t < timeout); + + return -ETIMEDOUT; +} + +static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) +{ + _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + rmb(); + return _il_rd(il, HBUS_TARG_PRPH_RDAT); +} + +static inline u32 il_rd_prph(struct il_priv *il, u32 reg) +{ + unsigned long reg_flags; + u32 val; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + val = _il_rd_prph(il, reg); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); + return val; +} + +static inline void _il_wr_prph(struct il_priv *il, + u32 addr, u32 val) +{ + _il_wr(il, HBUS_TARG_PRPH_WADDR, + ((addr & 0x0000FFFF) | (3 << 24))); + wmb(); + _il_wr(il, HBUS_TARG_PRPH_WDAT, val); +} + +static inline void +il_wr_prph(struct il_priv *il, u32 addr, u32 val) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr_prph(il, addr, val); + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +#define _il_set_bits_prph(il, reg, mask) \ +_il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)) + +static inline void +il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + _il_set_bits_prph(il, reg, mask); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +#define _il_set_bits_mask_prph(il, reg, bits, mask) \ +_il_wr_prph(il, reg, \ + ((_il_rd_prph(il, reg) & mask) | bits)) + +static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, + u32 bits, u32 mask) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + _il_set_bits_mask_prph(il, reg, bits, mask); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline void il_clear_bits_prph(struct il_priv + *il, u32 reg, u32 mask) +{ + unsigned long reg_flags; + u32 val; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + val = _il_rd_prph(il, reg); + _il_wr_prph(il, reg, (val & ~mask)); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) +{ + unsigned long reg_flags; + u32 value; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + + _il_wr(il, HBUS_TARG_MEM_RADDR, addr); + rmb(); + value = _il_rd(il, HBUS_TARG_MEM_RDAT); + + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); + return value; +} + +static inline void +il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); + wmb(); + _il_wr(il, HBUS_TARG_MEM_WDAT, val); + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline void +il_write_targ_mem_buf(struct il_priv *il, u32 addr, + u32 len, u32 *values) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); + wmb(); + for (; 0 < len; len -= sizeof(u32), values++) + _il_wr(il, + HBUS_TARG_MEM_WDAT, *values); + + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +#define HW_KEY_DYNAMIC 0 +#define HW_KEY_DEFAULT 1 + +#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ +#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ +#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of + being activated */ +#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; + (this is for the IBSS BSSID stations) */ +#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ + + +void il_restore_stations(struct il_priv *il, + struct il_rxon_context *ctx); +void il_clear_ucode_stations(struct il_priv *il, + struct il_rxon_context *ctx); +void il_dealloc_bcast_stations(struct il_priv *il); +int il_get_free_ucode_key_idx(struct il_priv *il); +int il_send_add_sta(struct il_priv *il, + struct il_addsta_cmd *sta, u8 flags); +int il_add_station_common(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta, u8 *sta_id_r); +int il_remove_station(struct il_priv *il, + const u8 sta_id, + const u8 *addr); +int il_mac_sta_remove(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta); + +u8 il_prep_station(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta); + +int il_send_lq_cmd(struct il_priv *il, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, + u8 flags, bool init); + +/** + * il_clear_driver_stations - clear knowledge of all stations from driver + * @il: iwl il struct + * + * This is called during il_down() to make sure that in the case + * we're coming there from a hardware restart mac80211 will be + * able to reconfigure stations -- if we're getting there in the + * normal down flow then the stations will already be cleared. + */ +static inline void il_clear_driver_stations(struct il_priv *il) +{ + unsigned long flags; + struct il_rxon_context *ctx = &il->ctx; + + spin_lock_irqsave(&il->sta_lock, flags); + memset(il->stations, 0, sizeof(il->stations)); + il->num_stations = 0; + + il->ucode_key_table = 0; + + /* + * Remove all key information that is not stored as part + * of station information since mac80211 may not have had + * a chance to remove all the keys. When device is + * reconfigured by mac80211 after an error all keys will + * be reconfigured. + */ + memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); + ctx->key_mapping_keys = 0; + + spin_unlock_irqrestore(&il->sta_lock, flags); +} + +static inline int il_sta_id(struct ieee80211_sta *sta) +{ + if (WARN_ON(!sta)) + return IL_INVALID_STATION; + + return ((struct il_station_priv_common *)sta->drv_priv)->sta_id; +} + +/** + * il_sta_id_or_broadcast - return sta_id or broadcast sta + * @il: iwl il + * @context: the current context + * @sta: mac80211 station + * + * In certain circumstances mac80211 passes a station pointer + * that may be %NULL, for example during TX or key setup. In + * that case, we need to use the broadcast station, so this + * inline wraps that pattern. + */ +static inline int il_sta_id_or_broadcast(struct il_priv *il, + struct il_rxon_context *context, + struct ieee80211_sta *sta) +{ + int sta_id; + + if (!sta) + return context->bcast_sta_id; + + sta_id = il_sta_id(sta); + + /* + * mac80211 should not be passing a partially + * initialised station! + */ + WARN_ON(sta_id == IL_INVALID_STATION); + + return sta_id; +} + +/** + * il_queue_inc_wrap - increment queue idx, wrap back to beginning + * @idx -- current idx + * @n_bd -- total number of entries in queue (must be power of 2) + */ +static inline int il_queue_inc_wrap(int idx, int n_bd) +{ + return ++idx & (n_bd - 1); +} + +/** + * il_queue_dec_wrap - decrement queue idx, wrap back to end + * @idx -- current idx + * @n_bd -- total number of entries in queue (must be power of 2) + */ +static inline int il_queue_dec_wrap(int idx, int n_bd) +{ + return --idx & (n_bd - 1); +} + +/* TODO: Move fw_desc functions to iwl-pci.ko */ +static inline void il_free_fw_desc(struct pci_dev *pci_dev, + struct fw_desc *desc) +{ + if (desc->v_addr) + dma_free_coherent(&pci_dev->dev, desc->len, + desc->v_addr, desc->p_addr); + desc->v_addr = NULL; + desc->len = 0; +} + +static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, + struct fw_desc *desc) +{ + if (!desc->len) { + desc->v_addr = NULL; + return -EINVAL; + } + + desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len, + &desc->p_addr, GFP_KERNEL); + return (desc->v_addr != NULL) ? 0 : -ENOMEM; +} + +/* + * we have 8 bits used like this: + * + * 7 6 5 4 3 2 1 0 + * | | | | | | | | + * | | | | | | +-+-------- AC queue (0-3) + * | | | | | | + * | +-+-+-+-+------------ HW queue ID + * | + * +---------------------- unused + */ +static inline void +il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) +{ + BUG_ON(ac > 3); /* only have 2 bits */ + BUG_ON(hwq > 31); /* only use 5 bits */ + + txq->swq_id = (hwq << 2) | ac; +} + +static inline void il_wake_queue(struct il_priv *il, + struct il_tx_queue *txq) +{ + u8 queue = txq->swq_id; + u8 ac = queue & 3; + u8 hwq = (queue >> 2) & 0x1f; + + if (test_and_clear_bit(hwq, il->queue_stopped)) + if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0) + ieee80211_wake_queue(il->hw, ac); +} + +static inline void il_stop_queue(struct il_priv *il, + struct il_tx_queue *txq) +{ + u8 queue = txq->swq_id; + u8 ac = queue & 3; + u8 hwq = (queue >> 2) & 0x1f; + + if (!test_and_set_bit(hwq, il->queue_stopped)) + if (atomic_inc_return(&il->queue_stop_count[ac]) > 0) + ieee80211_stop_queue(il->hw, ac); +} + +#ifdef ieee80211_stop_queue +#undef ieee80211_stop_queue +#endif + +#define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue + +#ifdef ieee80211_wake_queue +#undef ieee80211_wake_queue +#endif + +#define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue + +static inline void il_disable_interrupts(struct il_priv *il) +{ + clear_bit(S_INT_ENABLED, &il->status); + + /* disable interrupts from uCode/NIC to host */ + _il_wr(il, CSR_INT_MASK, 0x00000000); + + /* acknowledge/clear/reset any interrupts still pending + * from uCode or flow handler (Rx/Tx DMA) */ + _il_wr(il, CSR_INT, 0xffffffff); + _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); + D_ISR("Disabled interrupts\n"); +} + +static inline void il_enable_rfkill_int(struct il_priv *il) +{ + D_ISR("Enabling rfkill interrupt\n"); + _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); +} + +static inline void il_enable_interrupts(struct il_priv *il) +{ + D_ISR("Enabling interrupts\n"); + set_bit(S_INT_ENABLED, &il->status); + _il_wr(il, CSR_INT_MASK, il->inta_mask); +} + +/** + * il_beacon_time_mask_low - mask of lower 32 bit of beacon time + * @il -- pointer to il_priv data structure + * @tsf_bits -- number of bits need to shift for masking) + */ +static inline u32 il_beacon_time_mask_low(struct il_priv *il, + u16 tsf_bits) +{ + return (1 << tsf_bits) - 1; +} + +/** + * il_beacon_time_mask_high - mask of higher 32 bit of beacon time + * @il -- pointer to il_priv data structure + * @tsf_bits -- number of bits need to shift for masking) + */ +static inline u32 il_beacon_time_mask_high(struct il_priv *il, + u16 tsf_bits) +{ + return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; +} + +/** + * struct il_rb_status - reseve buffer status host memory mapped FH registers + * + * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed + * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed + * @finished_rb_num [0:11] - Indicates the idx of the current RB + * in which the last frame was written to + * @finished_fr_num [0:11] - Indicates the idx of the RX Frame + * which was transferred + */ +struct il_rb_status { + __le16 closed_rb_num; + __le16 closed_fr_num; + __le16 finished_rb_num; + __le16 finished_fr_nam; + __le32 __unused; /* 3945 only */ +} __packed; + + +#define TFD_QUEUE_SIZE_MAX (256) +#define TFD_QUEUE_SIZE_BC_DUP (64) +#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) +#define IL_TX_DMA_MASK DMA_BIT_MASK(36) +#define IL_NUM_OF_TBS 20 + +static inline u8 il_get_dma_hi_addr(dma_addr_t addr) +{ + return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; +} +/** + * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor + * + * This structure contains dma address and length of transmission address + * + * @lo: low [31:0] portion of the dma address of TX buffer + * every even is unaligned on 16 bit boundary + * @hi_n_len 0-3 [35:32] portion of dma + * 4-15 length of the tx buffer + */ +struct il_tfd_tb { + __le32 lo; + __le16 hi_n_len; +} __packed; + +/** + * struct il_tfd + * + * Transmit Frame Descriptor (TFD) + * + * @ __reserved1[3] reserved + * @ num_tbs 0-4 number of active tbs + * 5 reserved + * 6-7 padding (not used) + * @ tbs[20] transmit frame buffer descriptors + * @ __pad padding + * + * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. + * Both driver and device share these circular buffers, each of which must be + * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes + * + * Driver must indicate the physical address of the base of each + * circular buffer via the FH_MEM_CBBC_QUEUE registers. + * + * Each TFD contains pointer/size information for up to 20 data buffers + * in host DRAM. These buffers collectively contain the (one) frame described + * by the TFD. Each buffer must be a single contiguous block of memory within + * itself, but buffers may be scattered in host DRAM. Each buffer has max size + * of (4K - 4). The concatenates all of a TFD's buffers into a single + * Tx frame, up to 8 KBytes in size. + * + * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. + */ +struct il_tfd { + u8 __reserved1[3]; + u8 num_tbs; + struct il_tfd_tb tbs[IL_NUM_OF_TBS]; + __le32 __pad; +} __packed; +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 + +/* PCI register values */ +#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 +#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 6c4bc50..62292a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -29,10 +29,8 @@ #include -#include "iwl-dev.h" #include "iwl-debug.h" #include "common.h" -#include "iwl-io.h" /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h deleted file mode 100644 index ce5bc53..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ /dev/null @@ -1,1351 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -/* - * Please use this file (iwl-dev.h) for driver implementation definitions. - * Please use commands.h for uCode API definitions. - * Please use 4965.h for hardware-related definitions. - */ - -#ifndef __il_dev_h__ -#define __il_dev_h__ - -#include -#include /* for struct pci_device_id */ -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "csr.h" -#include "iwl-prph.h" -#include "iwl-debug.h" -#include "4965.h" -#include "iwl-led.h" -#include "iwl-power.h" -#include "iwl-legacy-rs.h" - -#define U32_PAD(n) ((4-(n))&0x3) - -struct il_tx_queue; - -/* CT-KILL constants */ -#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ - -/* Default noise level to report when noise measurement is not available. - * This may be because we're: - * 1) Not associated (4965, no beacon stats being sent to driver) - * 2) Scanning (noise measurement does not apply to associated channel) - * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) - * Use default noise value of -127 ... this is below the range of measurable - * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. - * Also, -127 works better than 0 when averaging frames with/without - * noise info (e.g. averaging might be done in app); measured dBm values are - * always negative ... using a negative value as the default keeps all - * averages within an s8's (used in some apps) range of negative values. */ -#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) - -/* - * RTS threshold here is total size [2347] minus 4 FCS bytes - * Per spec: - * a value of 0 means RTS on all data/management packets - * a value > max MSDU size means no RTS - * else RTS for data/management frames where MPDU is larger - * than RTS value. - */ -#define DEFAULT_RTS_THRESHOLD 2347U -#define MIN_RTS_THRESHOLD 0U -#define MAX_RTS_THRESHOLD 2347U -#define MAX_MSDU_SIZE 2304U -#define MAX_MPDU_SIZE 2346U -#define DEFAULT_BEACON_INTERVAL 100U -#define DEFAULT_SHORT_RETRY_LIMIT 7U -#define DEFAULT_LONG_RETRY_LIMIT 4U - -struct il_rx_buf { - dma_addr_t page_dma; - struct page *page; - struct list_head list; -}; - -#define rxb_addr(r) page_address(r->page) - -/* defined below */ -struct il_device_cmd; - -struct il_cmd_meta { - /* only for SYNC commands, iff the reply skb is wanted */ - struct il_host_cmd *source; - /* - * only for ASYNC commands - * (which is somewhat stupid -- look at iwl-sta.c for instance - * which duplicates a bunch of code because the callback isn't - * invoked for SYNC commands, if it were and its result passed - * through it would be simpler...) - */ - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); - - /* The CMD_SIZE_HUGE flag bit indicates that the command - * structure is stored at the end of the shared queue memory. */ - u32 flags; - - DEFINE_DMA_UNMAP_ADDR(mapping); - DEFINE_DMA_UNMAP_LEN(len); -}; - -/* - * Generic queue structure - * - * Contains common data for Rx and Tx queues - */ -struct il_queue { - int n_bd; /* number of BDs in this queue */ - int write_ptr; /* 1-st empty entry (idx) host_w*/ - int read_ptr; /* last used entry (idx) host_r*/ - /* use for monitoring and recovering the stuck queue */ - dma_addr_t dma_addr; /* physical addr for BD's */ - int n_win; /* safe queue win */ - u32 id; - int low_mark; /* low watermark, resume queue if free - * space more than this */ - int high_mark; /* high watermark, stop queue if free - * space less than this */ -}; - -/* One for each TFD */ -struct il_tx_info { - struct sk_buff *skb; - struct il_rxon_context *ctx; -}; - -/** - * struct il_tx_queue - Tx Queue for DMA - * @q: generic Rx/Tx queue descriptor - * @bd: base of circular buffer of TFDs - * @cmd: array of command/TX buffer pointers - * @meta: array of meta data for each command/tx buffer - * @dma_addr_cmd: physical address of cmd/tx buffer array - * @txb: array of per-TFD driver data - * @time_stamp: time (in jiffies) of last read_ptr change - * @need_update: indicates need to update read/write idx - * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled - * - * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame - * descriptors) and required locking structures. - */ -#define TFD_TX_CMD_SLOTS 256 -#define TFD_CMD_SLOTS 32 - -struct il_tx_queue { - struct il_queue q; - void *tfds; - struct il_device_cmd **cmd; - struct il_cmd_meta *meta; - struct il_tx_info *txb; - unsigned long time_stamp; - u8 need_update; - u8 sched_retry; - u8 active; - u8 swq_id; -}; - -#define IL_NUM_SCAN_RATES (2) - -struct il4965_channel_tgd_info { - u8 type; - s8 max_power; -}; - -struct il4965_channel_tgh_info { - s64 last_radar_time; -}; - -#define IL4965_MAX_RATE (33) - -struct il3945_clip_group { - /* maximum power level to prevent clipping for each rate, derived by - * us from this band's saturation power in EEPROM */ - const s8 clip_powers[IL_MAX_RATES]; -}; - -/* current Tx power values to use, one for each rate for each channel. - * requested power is limited by: - * -- regulatory EEPROM limits for this channel - * -- hardware capabilities (clip-powers) - * -- spectrum management - * -- user preference (e.g. iwconfig) - * when requested power is set, base power idx must also be set. */ -struct il3945_channel_power_info { - struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_idx; /* actual (compenst'd) idx into gain table */ - s8 base_power_idx; /* gain idx for power at factory temp. */ - s8 requested_power; /* power (dBm) requested for this chnl/rate */ -}; - -/* current scan Tx power values to use, one for each scan rate for each - * channel. */ -struct il3945_scan_power_info { - struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_idx; /* actual (compenst'd) idx into gain table */ - s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ -}; - -/* - * One for each channel, holds all channel setup data - * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant - * with one another! - */ -struct il_channel_info { - struct il4965_channel_tgd_info tgd; - struct il4965_channel_tgh_info tgh; - struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */ - struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for - * HT40 channel */ - - u8 channel; /* channel number */ - u8 flags; /* flags copied from EEPROM */ - s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ - s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ - s8 min_power; /* always 0 */ - s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ - - u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ - u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ - enum ieee80211_band band; - - /* HT40 channel info */ - s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ - u8 ht40_flags; /* flags copied from EEPROM */ - u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ - - /* Radio/DSP gain settings for each "normal" data Tx rate. - * These include, in addition to RF and DSP gain, a few fields for - * remembering/modifying gain settings (idxes). */ - struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; - - /* Radio/DSP gain settings for each scan rate, for directed scans. */ - struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; -}; - -#define IL_TX_FIFO_BK 0 /* shared */ -#define IL_TX_FIFO_BE 1 -#define IL_TX_FIFO_VI 2 /* shared */ -#define IL_TX_FIFO_VO 3 -#define IL_TX_FIFO_UNUSED -1 - -/* Minimum number of queues. MAX_NUM is defined in hw specific files. - * Set the minimum to accommodate the 4 standard TX queues, 1 command - * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */ -#define IL_MIN_NUM_QUEUES 10 - -#define IL_DEFAULT_CMD_QUEUE_NUM 4 - -#define IEEE80211_DATA_LEN 2304 -#define IEEE80211_4ADDR_LEN 30 -#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) -#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) - -struct il_frame { - union { - struct ieee80211_hdr frame; - struct il_tx_beacon_cmd beacon; - u8 raw[IEEE80211_FRAME_LEN]; - u8 cmd[360]; - } u; - struct list_head list; -}; - -#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) -#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) -#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) - -enum { - CMD_SYNC = 0, - CMD_SIZE_NORMAL = 0, - CMD_NO_SKB = 0, - CMD_SIZE_HUGE = (1 << 0), - CMD_ASYNC = (1 << 1), - CMD_WANT_SKB = (1 << 2), - CMD_MAPPED = (1 << 3), -}; - -#define DEF_CMD_PAYLOAD_SIZE 320 - -/** - * struct il_device_cmd - * - * For allocation of the command and tx queues, this establishes the overall - * size of the largest command we send to uCode, except for a scan command - * (which is relatively huge; space is allocated separately). - */ -struct il_device_cmd { - struct il_cmd_header hdr; /* uCode API */ - union { - u32 flags; - u8 val8; - u16 val16; - u32 val32; - struct il_tx_cmd tx; - u8 payload[DEF_CMD_PAYLOAD_SIZE]; - } __packed cmd; -} __packed; - -#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) - - -struct il_host_cmd { - const void *data; - unsigned long reply_page; - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); - u32 flags; - u16 len; - u8 id; -}; - -#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 -#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 -#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 - -/** - * struct il_rx_queue - Rx queue - * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) - * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) - * @read: Shared idx to newest available Rx buffer - * @write: Shared idx to oldest written Rx packet - * @free_count: Number of pre-allocated buffers in rx_free - * @rx_free: list of free SKBs for use - * @rx_used: List of Rx buffers with no SKB - * @need_update: flag to indicate we need to update read/write idx - * @rb_stts: driver's pointer to receive buffer status - * @rb_stts_dma: bus address of receive buffer status - * - * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs - */ -struct il_rx_queue { - __le32 *bd; - dma_addr_t bd_dma; - struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; - struct il_rx_buf *queue[RX_QUEUE_SIZE]; - u32 read; - u32 write; - u32 free_count; - u32 write_actual; - struct list_head rx_free; - struct list_head rx_used; - int need_update; - struct il_rb_status *rb_stts; - dma_addr_t rb_stts_dma; - spinlock_t lock; -}; - -#define IL_SUPPORTED_RATES_IE_LEN 8 - -#define MAX_TID_COUNT 9 - -#define IL_INVALID_RATE 0xFF -#define IL_INVALID_VALUE -1 - -/** - * struct il_ht_agg -- aggregation status while waiting for block-ack - * @txq_id: Tx queue used for Tx attempt - * @frame_count: # frames attempted by Tx command - * @wait_for_ba: Expect block-ack before next Tx reply - * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win - * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win - * @bitmap1: High order, one bit for each frame pending ACK in Tx win - * @rate_n_flags: Rate at which Tx was attempted - * - * If C_TX indicates that aggregation was attempted, driver must wait - * for block ack (N_COMPRESSED_BA). This struct stores tx reply info - * until block ack arrives. - */ -struct il_ht_agg { - u16 txq_id; - u16 frame_count; - u16 wait_for_ba; - u16 start_idx; - u64 bitmap; - u32 rate_n_flags; -#define IL_AGG_OFF 0 -#define IL_AGG_ON 1 -#define IL_EMPTYING_HW_QUEUE_ADDBA 2 -#define IL_EMPTYING_HW_QUEUE_DELBA 3 - u8 state; -}; - - -struct il_tid_data { - u16 seq_number; /* 4965 only */ - u16 tfds_in_queue; - struct il_ht_agg agg; -}; - -struct il_hw_key { - u32 cipher; - int keylen; - u8 keyidx; - u8 key[32]; -}; - -union il_ht_rate_supp { - u16 rates; - struct { - u8 siso_rate; - u8 mimo_rate; - }; -}; - -#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0) -#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1) -#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2) -#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3) -#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K -#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K -#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K - -/* - * Maximal MPDU density for TX aggregation - * 4 - 2us density - * 5 - 4us density - * 6 - 8us density - * 7 - 16us density - */ -#define CFG_HT_MPDU_DENSITY_2USEC (0x4) -#define CFG_HT_MPDU_DENSITY_4USEC (0x5) -#define CFG_HT_MPDU_DENSITY_8USEC (0x6) -#define CFG_HT_MPDU_DENSITY_16USEC (0x7) -#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC -#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC -#define CFG_HT_MPDU_DENSITY_MIN (0x1) - -struct il_ht_config { - bool single_chain_sufficient; - enum ieee80211_smps_mode smps; /* current smps mode */ -}; - -/* QoS structures */ -struct il_qos_info { - int qos_active; - struct il_qosparam_cmd def_qos_parm; -}; - -/* - * Structure should be accessed with sta_lock held. When station addition - * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only - * the commands (il_addsta_cmd and il_link_quality_cmd) without - * sta_lock held. - */ -struct il_station_entry { - struct il_addsta_cmd sta; - struct il_tid_data tid[MAX_TID_COUNT]; - u8 used, ctxid; - struct il_hw_key keyinfo; - struct il_link_quality_cmd *lq; -}; - -struct il_station_priv_common { - struct il_rxon_context *ctx; - u8 sta_id; -}; - -/* - * il_station_priv: Driver's ilate station information - * - * When mac80211 creates a station it reserves some space (hw->sta_data_size) - * in the structure for use by driver. This structure is places in that - * space. - * - * The common struct MUST be first because it is shared between - * 3945 and 4965! - */ -struct il_station_priv { - struct il_station_priv_common common; - struct il_lq_sta lq_sta; - atomic_t pending_frames; - bool client; - bool asleep; -}; - -/** - * struct il_vif_priv - driver's ilate per-interface information - * - * When mac80211 allocates a virtual interface, it can allocate - * space for us to put data into. - */ -struct il_vif_priv { - struct il_rxon_context *ctx; - u8 ibss_bssid_sta_id; -}; - -/* one for each uCode image (inst/data, boot/init/runtime) */ -struct fw_desc { - void *v_addr; /* access by driver */ - dma_addr_t p_addr; /* access by card's busmaster DMA */ - u32 len; /* bytes */ -}; - -/* uCode file layout */ -struct il_ucode_header { - __le32 ver; /* major/minor/API/serial */ - struct { - __le32 inst_size; /* bytes of runtime code */ - __le32 data_size; /* bytes of runtime data */ - __le32 init_size; /* bytes of init code */ - __le32 init_data_size; /* bytes of init data */ - __le32 boot_size; /* bytes of bootstrap code */ - u8 data[0]; /* in same order as sizes */ - } v1; -}; - -struct il4965_ibss_seq { - u8 mac[ETH_ALEN]; - u16 seq_num; - u16 frag_num; - unsigned long packet_time; - struct list_head list; -}; - -struct il_sensitivity_ranges { - u16 min_nrg_cck; - u16 max_nrg_cck; - - u16 nrg_th_cck; - u16 nrg_th_ofdm; - - u16 auto_corr_min_ofdm; - u16 auto_corr_min_ofdm_mrc; - u16 auto_corr_min_ofdm_x1; - u16 auto_corr_min_ofdm_mrc_x1; - - u16 auto_corr_max_ofdm; - u16 auto_corr_max_ofdm_mrc; - u16 auto_corr_max_ofdm_x1; - u16 auto_corr_max_ofdm_mrc_x1; - - u16 auto_corr_max_cck; - u16 auto_corr_max_cck_mrc; - u16 auto_corr_min_cck; - u16 auto_corr_min_cck_mrc; - - u16 barker_corr_th_min; - u16 barker_corr_th_min_mrc; - u16 nrg_th_cca; -}; - - -#define KELVIN_TO_CELSIUS(x) ((x)-273) -#define CELSIUS_TO_KELVIN(x) ((x)+273) - - -/** - * struct il_hw_params - * @max_txq_num: Max # Tx queues supported - * @dma_chnl_num: Number of Tx DMA/FIFO channels - * @scd_bc_tbls_size: size of scheduler byte count tables - * @tfd_size: TFD size - * @tx/rx_chains_num: Number of TX/RX chains - * @valid_tx/rx_ant: usable antennas - * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2) - * @max_rxq_log: Log-base-2 of max_rxq_size - * @rx_page_order: Rx buffer page order - * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR - * @max_stations: - * @ht40_channel: is 40MHz width possible in band 2.4 - * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ) - * @sw_crypto: 0 for hw, 1 for sw - * @max_xxx_size: for ucode uses - * @ct_kill_threshold: temperature threshold - * @beacon_time_tsf_bits: number of valid tsf bits for beacon time - * @struct il_sensitivity_ranges: range of sensitivity values - */ -struct il_hw_params { - u8 max_txq_num; - u8 dma_chnl_num; - u16 scd_bc_tbls_size; - u32 tfd_size; - u8 tx_chains_num; - u8 rx_chains_num; - u8 valid_tx_ant; - u8 valid_rx_ant; - u16 max_rxq_size; - u16 max_rxq_log; - u32 rx_page_order; - u32 rx_wrt_ptr_reg; - u8 max_stations; - u8 ht40_channel; - u8 max_beacon_itrvl; /* in 1024 ms */ - u32 max_inst_size; - u32 max_data_size; - u32 max_bsm_size; - u32 ct_kill_threshold; /* value in hw-dependent units */ - u16 beacon_time_tsf_bits; - const struct il_sensitivity_ranges *sens; -}; - - -/****************************************************************************** - * - * Functions implemented in core module which are forward declared here - * for use by iwl-[4-5].c - * - * NOTE: The implementation of these functions are not hardware specific - * which is why they are in the core module files. - * - * Naming convention -- - * il_ <-- Is part of iwlwifi - * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * il4965_bg_ <-- Called from work queue context - * il4965_mac_ <-- mac80211 callback - * - ****************************************************************************/ -extern void il4965_update_chain_flags(struct il_priv *il); -extern const u8 il_bcast_addr[ETH_ALEN]; -extern int il_queue_space(const struct il_queue *q); -static inline int il_queue_used(const struct il_queue *q, int i) -{ - return q->write_ptr >= q->read_ptr ? - (i >= q->read_ptr && i < q->write_ptr) : - !(i < q->read_ptr && i >= q->write_ptr); -} - - -static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, - int is_huge) -{ - /* - * This is for init calibration result and scan command which - * required buffer > TFD_MAX_PAYLOAD_SIZE, - * the big buffer at end of command array - */ - if (is_huge) - return q->n_win; /* must be power of 2 */ - - /* Otherwise, use normal size buffers */ - return idx & (q->n_win - 1); -} - - -struct il_dma_ptr { - dma_addr_t dma; - void *addr; - size_t size; -}; - -#define IL_OPERATION_MODE_AUTO 0 -#define IL_OPERATION_MODE_HT_ONLY 1 -#define IL_OPERATION_MODE_MIXED 2 -#define IL_OPERATION_MODE_20MHZ 3 - -#define IL_TX_CRC_SIZE 4 -#define IL_TX_DELIMITER_SIZE 4 - -#define TX_POWER_IL_ILLEGAL_VOLTAGE -10000 - -/* Sensitivity and chain noise calibration */ -#define INITIALIZATION_VALUE 0xFFFF -#define IL4965_CAL_NUM_BEACONS 20 -#define IL_CAL_NUM_BEACONS 16 -#define MAXIMUM_ALLOWED_PATHLOSS 15 - -#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 - -#define MAX_FA_OFDM 50 -#define MIN_FA_OFDM 5 -#define MAX_FA_CCK 50 -#define MIN_FA_CCK 5 - -#define AUTO_CORR_STEP_OFDM 1 - -#define AUTO_CORR_STEP_CCK 3 -#define AUTO_CORR_MAX_TH_CCK 160 - -#define NRG_DIFF 2 -#define NRG_STEP_CCK 2 -#define NRG_MARGIN 8 -#define MAX_NUMBER_CCK_NO_FA 100 - -#define AUTO_CORR_CCK_MIN_VAL_DEF (125) - -#define CHAIN_A 0 -#define CHAIN_B 1 -#define CHAIN_C 2 -#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4 -#define ALL_BAND_FILTER 0xFF00 -#define IN_BAND_FILTER 0xFF -#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF - -#define NRG_NUM_PREV_STAT_L 20 -#define NUM_RX_CHAINS 3 - -enum il4965_false_alarm_state { - IL_FA_TOO_MANY = 0, - IL_FA_TOO_FEW = 1, - IL_FA_GOOD_RANGE = 2, -}; - -enum il4965_chain_noise_state { - IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ - IL_CHAIN_NOISE_ACCUMULATE, - IL_CHAIN_NOISE_CALIBRATED, - IL_CHAIN_NOISE_DONE, -}; - -enum il4965_calib_enabled_state { - IL_CALIB_DISABLED = 0, /* must be 0 */ - IL_CALIB_ENABLED = 1, -}; - -/* - * enum il_calib - * defines the order in which results of initial calibrations - * should be sent to the runtime uCode - */ -enum il_calib { - IL_CALIB_MAX, -}; - -/* Opaque calibration results */ -struct il_calib_result { - void *buf; - size_t buf_len; -}; - -enum ucode_type { - UCODE_NONE = 0, - UCODE_INIT, - UCODE_RT -}; - -/* Sensitivity calib data */ -struct il_sensitivity_data { - u32 auto_corr_ofdm; - u32 auto_corr_ofdm_mrc; - u32 auto_corr_ofdm_x1; - u32 auto_corr_ofdm_mrc_x1; - u32 auto_corr_cck; - u32 auto_corr_cck_mrc; - - u32 last_bad_plcp_cnt_ofdm; - u32 last_fa_cnt_ofdm; - u32 last_bad_plcp_cnt_cck; - u32 last_fa_cnt_cck; - - u32 nrg_curr_state; - u32 nrg_prev_state; - u32 nrg_value[10]; - u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; - u32 nrg_silence_ref; - u32 nrg_energy_idx; - u32 nrg_silence_idx; - u32 nrg_th_cck; - s32 nrg_auto_corr_silence_diff; - u32 num_in_cck_no_fa; - u32 nrg_th_ofdm; - - u16 barker_corr_th_min; - u16 barker_corr_th_min_mrc; - u16 nrg_th_cca; -}; - -/* Chain noise (differential Rx gain) calib data */ -struct il_chain_noise_data { - u32 active_chains; - u32 chain_noise_a; - u32 chain_noise_b; - u32 chain_noise_c; - u32 chain_signal_a; - u32 chain_signal_b; - u32 chain_signal_c; - u16 beacon_count; - u8 disconn_array[NUM_RX_CHAINS]; - u8 delta_gain_code[NUM_RX_CHAINS]; - u8 radio_write; - u8 state; -}; - -#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ -#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ - -#define IL_TRAFFIC_ENTRIES (256) -#define IL_TRAFFIC_ENTRY_SIZE (64) - -enum { - MEASUREMENT_READY = (1 << 0), - MEASUREMENT_ACTIVE = (1 << 1), -}; - -/* interrupt stats */ -struct isr_stats { - u32 hw; - u32 sw; - u32 err_code; - u32 sch; - u32 alive; - u32 rfkill; - u32 ctkill; - u32 wakeup; - u32 rx; - u32 handlers[IL_CN_MAX]; - u32 tx; - u32 unhandled; -}; - -/* management stats */ -enum il_mgmt_stats { - MANAGEMENT_ASSOC_REQ = 0, - MANAGEMENT_ASSOC_RESP, - MANAGEMENT_REASSOC_REQ, - MANAGEMENT_REASSOC_RESP, - MANAGEMENT_PROBE_REQ, - MANAGEMENT_PROBE_RESP, - MANAGEMENT_BEACON, - MANAGEMENT_ATIM, - MANAGEMENT_DISASSOC, - MANAGEMENT_AUTH, - MANAGEMENT_DEAUTH, - MANAGEMENT_ACTION, - MANAGEMENT_MAX, -}; -/* control stats */ -enum il_ctrl_stats { - CONTROL_BACK_REQ = 0, - CONTROL_BACK, - CONTROL_PSPOLL, - CONTROL_RTS, - CONTROL_CTS, - CONTROL_ACK, - CONTROL_CFEND, - CONTROL_CFENDACK, - CONTROL_MAX, -}; - -struct traffic_stats { -#ifdef CONFIG_IWLEGACY_DEBUGFS - u32 mgmt[MANAGEMENT_MAX]; - u32 ctrl[CONTROL_MAX]; - u32 data_cnt; - u64 data_bytes; -#endif -}; - -/* - * host interrupt timeout value - * used with setting interrupt coalescing timer - * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit - * - * default interrupt coalescing timer is 64 x 32 = 2048 usecs - * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs - */ -#define IL_HOST_INT_TIMEOUT_MAX (0xFF) -#define IL_HOST_INT_TIMEOUT_DEF (0x40) -#define IL_HOST_INT_TIMEOUT_MIN (0x0) -#define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) -#define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) -#define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) - -#define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) - -/* TX queue watchdog timeouts in mSecs */ -#define IL_DEF_WD_TIMEOUT (2000) -#define IL_LONG_WD_TIMEOUT (10000) -#define IL_MAX_WD_TIMEOUT (120000) - -struct il_force_reset { - int reset_request_count; - int reset_success_count; - int reset_reject_count; - unsigned long reset_duration; - unsigned long last_force_reset_jiffies; -}; - -/* extend beacon time format bit shifting */ -/* - * for _3945 devices - * bits 31:24 - extended - * bits 23:0 - interval - */ -#define IL3945_EXT_BEACON_TIME_POS 24 -/* - * for _4965 devices - * bits 31:22 - extended - * bits 21:0 - interval - */ -#define IL4965_EXT_BEACON_TIME_POS 22 - -struct il_rxon_context { - struct ieee80211_vif *vif; - - const u8 *ac_to_fifo; - const u8 *ac_to_queue; - u8 mcast_queue; - - /* - * We could use the vif to indicate active, but we - * also need it to be active during disabling when - * we already removed the vif for type setting. - */ - bool always_active, is_active; - - bool ht_need_multiple_chains; - - int ctxid; - - u32 interface_modes, exclusive_interface_modes; - u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; - - /* - * We declare this const so it can only be - * changed via explicit cast within the - * routines that actually update the physical - * hardware. - */ - const struct il_rxon_cmd active; - struct il_rxon_cmd staging; - - struct il_rxon_time_cmd timing; - - struct il_qos_info qos_data; - - u8 bcast_sta_id, ap_sta_id; - - u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; - u8 qos_cmd; - u8 wep_key_cmd; - - struct il_wep_key wep_keys[WEP_KEYS_MAX]; - u8 key_mapping_keys; - - __le32 station_flags; - - struct { - bool non_gf_sta_present; - u8 protection; - bool enabled, is_40mhz; - u8 extension_chan_offset; - } ht; -}; - -struct il_priv { - - /* ieee device used by generic ieee processing code */ - struct ieee80211_hw *hw; - struct ieee80211_channel *ieee_channels; - struct ieee80211_rate *ieee_rates; - struct il_cfg *cfg; - - /* temporary frame storage list */ - struct list_head free_frames; - int frames_count; - - enum ieee80211_band band; - int alloc_rxb_page; - - void (*handlers[IL_CN_MAX])(struct il_priv *il, - struct il_rx_buf *rxb); - - struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; - - /* spectrum measurement report caching */ - struct il_spectrum_notification measure_report; - u8 measurement_status; - - /* ucode beacon time */ - u32 ucode_beacon_time; - int missed_beacon_threshold; - - /* track IBSS manager (last beacon) status */ - u32 ibss_manager; - - /* force reset */ - struct il_force_reset force_reset; - - /* we allocate array of il_channel_info for NIC's valid channels. - * Access via channel # using indirect idx array */ - struct il_channel_info *channel_info; /* channel info array */ - u8 channel_count; /* # of channels */ - - /* thermal calibration */ - s32 temperature; /* degrees Kelvin */ - s32 last_temperature; - - /* init calibration results */ - struct il_calib_result calib_results[IL_CALIB_MAX]; - - /* Scan related variables */ - unsigned long scan_start; - unsigned long scan_start_tsf; - void *scan_cmd; - enum ieee80211_band scan_band; - struct cfg80211_scan_request *scan_request; - struct ieee80211_vif *scan_vif; - u8 scan_tx_ant[IEEE80211_NUM_BANDS]; - u8 mgmt_tx_ant; - - /* spinlock */ - spinlock_t lock; /* protect general shared data */ - spinlock_t hcmd_lock; /* protect hcmd */ - spinlock_t reg_lock; /* protect hw register access */ - struct mutex mutex; - - /* basic pci-network driver stuff */ - struct pci_dev *pci_dev; - - /* pci hardware address support */ - void __iomem *hw_base; - u32 hw_rev; - u32 hw_wa_rev; - u8 rev_id; - - /* command queue number */ - u8 cmd_queue; - - /* max number of station keys */ - u8 sta_key_max_num; - - /* EEPROM MAC addresses */ - struct mac_address addresses[1]; - - /* uCode images, save to reload in case of failure */ - int fw_idx; /* firmware we're trying to load */ - u32 ucode_ver; /* version of ucode, copy of - il_ucode.ver */ - struct fw_desc ucode_code; /* runtime inst */ - struct fw_desc ucode_data; /* runtime data original */ - struct fw_desc ucode_data_backup; /* runtime data save/restore */ - struct fw_desc ucode_init; /* initialization inst */ - struct fw_desc ucode_init_data; /* initialization data */ - struct fw_desc ucode_boot; /* bootstrap inst */ - enum ucode_type ucode_type; - u8 ucode_write_complete; /* the image write is complete */ - char firmware_name[25]; - - struct il_rxon_context ctx; - - __le16 switch_channel; - - /* 1st responses from initialize and runtime uCode images. - * _4965's initialize alive response contains some calibration data. */ - struct il_init_alive_resp card_alive_init; - struct il_alive_resp card_alive; - - u16 active_rate; - - u8 start_calib; - struct il_sensitivity_data sensitivity_data; - struct il_chain_noise_data chain_noise_data; - __le16 sensitivity_tbl[HD_TBL_SIZE]; - - struct il_ht_config current_ht_config; - - /* Rate scaling data */ - u8 retry_rate; - - wait_queue_head_t wait_command_queue; - - int activity_timer_active; - - /* Rx and Tx DMA processing queues */ - struct il_rx_queue rxq; - struct il_tx_queue *txq; - unsigned long txq_ctx_active_msk; - struct il_dma_ptr kw; /* keep warm address */ - struct il_dma_ptr scd_bc_tbls; - - u32 scd_base_addr; /* scheduler sram base address */ - - unsigned long status; - - /* counts mgmt, ctl, and data packets */ - struct traffic_stats tx_stats; - struct traffic_stats rx_stats; - - /* counts interrupts */ - struct isr_stats isr_stats; - - struct il_power_mgr power_data; - - /* context information */ - u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ - - /* station table variables */ - - /* Note: if lock and sta_lock are needed, lock must be acquired first */ - spinlock_t sta_lock; - int num_stations; - struct il_station_entry stations[IL_STATION_COUNT]; - unsigned long ucode_key_table; - - /* queue refcounts */ -#define IL_MAX_HW_QUEUES 32 - unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)]; - /* for each AC */ - atomic_t queue_stop_count[4]; - - /* Indication if ieee80211_ops->open has been called */ - u8 is_open; - - u8 mac80211_registered; - - /* eeprom -- this is in the card's little endian byte order */ - u8 *eeprom; - struct il_eeprom_calib_info *calib_info; - - enum nl80211_iftype iw_mode; - - /* Last Rx'd beacon timestamp */ - u64 timestamp; - - union { -#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE) - struct { - void *shared_virt; - dma_addr_t shared_phys; - - struct delayed_work thermal_periodic; - struct delayed_work rfkill_poll; - - struct il3945_notif_stats stats; -#ifdef CONFIG_IWLEGACY_DEBUGFS - struct il3945_notif_stats accum_stats; - struct il3945_notif_stats delta_stats; - struct il3945_notif_stats max_delta; -#endif - - u32 sta_supp_rates; - int last_rx_rssi; /* From Rx packet stats */ - - /* Rx'd packet timing information */ - u32 last_beacon_time; - u64 last_tsf; - - /* - * each calibration channel group in the - * EEPROM has a derived clip setting for - * each rate. - */ - const struct il3945_clip_group clip_groups[5]; - - } _3945; -#endif -#if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) - struct { - struct il_rx_phy_res last_phy_res; - bool last_phy_res_valid; - - struct completion firmware_loading_complete; - - /* - * chain noise reset and gain commands are the - * two extra calibration commands follows the standard - * phy calibration commands - */ - u8 phy_calib_chain_noise_reset_cmd; - u8 phy_calib_chain_noise_gain_cmd; - - struct il_notif_stats stats; -#ifdef CONFIG_IWLEGACY_DEBUGFS - struct il_notif_stats accum_stats; - struct il_notif_stats delta_stats; - struct il_notif_stats max_delta; -#endif - - } _4965; -#endif - }; - - struct il_hw_params hw_params; - - u32 inta_mask; - - struct workqueue_struct *workqueue; - - struct work_struct restart; - struct work_struct scan_completed; - struct work_struct rx_replenish; - struct work_struct abort_scan; - - struct il_rxon_context *beacon_ctx; - struct sk_buff *beacon_skb; - - struct work_struct tx_flush; - - struct tasklet_struct irq_tasklet; - - struct delayed_work init_alive_start; - struct delayed_work alive_start; - struct delayed_work scan_check; - - /* TX Power */ - s8 tx_power_user_lmt; - s8 tx_power_device_lmt; - s8 tx_power_next; - - -#ifdef CONFIG_IWLEGACY_DEBUG - /* debugging info */ - u32 debug_level; /* per device debugging will override global - il_debug_level if set */ -#endif /* CONFIG_IWLEGACY_DEBUG */ -#ifdef CONFIG_IWLEGACY_DEBUGFS - /* debugfs */ - u16 tx_traffic_idx; - u16 rx_traffic_idx; - u8 *tx_traffic; - u8 *rx_traffic; - struct dentry *debugfs_dir; - u32 dbgfs_sram_offset, dbgfs_sram_len; - bool disable_ht40; -#endif /* CONFIG_IWLEGACY_DEBUGFS */ - - struct work_struct txpower_work; - u32 disable_sens_cal; - u32 disable_chain_noise_cal; - u32 disable_tx_power_cal; - struct work_struct run_time_calib_work; - struct timer_list stats_periodic; - struct timer_list watchdog; - bool hw_ready; - - struct led_classdev led; - unsigned long blink_on, blink_off; - bool led_registered; -}; /*il_priv */ - -static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) -{ - set_bit(txq_id, &il->txq_ctx_active_msk); -} - -static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) -{ - clear_bit(txq_id, &il->txq_ctx_active_msk); -} - -#ifdef CONFIG_IWLEGACY_DEBUG -/* - * il_get_debug_level: Return active debug level for device - * - * Using sysfs it is possible to set per device debug level. This debug - * level will be used if set, otherwise the global debug level which can be - * set via module parameter is used. - */ -static inline u32 il_get_debug_level(struct il_priv *il) -{ - if (il->debug_level) - return il->debug_level; - else - return il_debug_level; -} -#else -static inline u32 il_get_debug_level(struct il_priv *il) -{ - return il_debug_level; -} -#endif - - -static inline struct ieee80211_hdr * -il_tx_queue_get_hdr(struct il_priv *il, - int txq_id, int idx) -{ - if (il->txq[txq_id].txb[idx].skb) - return (struct ieee80211_hdr *)il->txq[txq_id]. - txb[idx].skb->data; - return NULL; -} - -static inline struct il_rxon_context * -il_rxon_ctx_from_vif(struct ieee80211_vif *vif) -{ - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - - return vif_priv->ctx; -} - -#define for_each_context(il, _ctx) \ - for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) - -static inline int il_is_associated(struct il_priv *il) -{ - return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; -} - -static inline int il_is_any_associated(struct il_priv *il) -{ - return il_is_associated(il); -} - -static inline int il_is_associated_ctx(struct il_rxon_context *ctx) -{ - return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; -} - -static inline int il_is_channel_valid(const struct il_channel_info *ch_info) -{ - if (ch_info == NULL) - return 0; - return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; -} - -static inline int il_is_channel_radar(const struct il_channel_info *ch_info) -{ - return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; -} - -static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) -{ - return ch_info->band == IEEE80211_BAND_5GHZ; -} - -static inline int -il_is_channel_passive(const struct il_channel_info *ch) -{ - return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; -} - -static inline int -il_is_channel_ibss(const struct il_channel_info *ch) -{ - return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; -} - -static inline void -__il_free_pages(struct il_priv *il, struct page *page) -{ - __free_pages(page, il->hw_params.rx_page_order); - il->alloc_rxb_page--; -} - -static inline void il_free_pages(struct il_priv *il, unsigned long page) -{ - free_pages(page, il->hw_params.rx_page_order); - il->alloc_rxb_page--; -} -#endif /* __il_dev_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index f53f1b8..7846bae 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -266,8 +266,6 @@ #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) -#define FH_RSCSR_FRAME_SIZE_MSK (0x00003FFF) /* bits 0-13 */ - /** * Rx Shared Status Registers (RSSR) * @@ -413,100 +411,6 @@ */ #define FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) -#define RX_QUEUE_SIZE 256 -#define RX_QUEUE_MASK 255 -#define RX_QUEUE_SIZE_LOG 8 - -/* - * RX related structures and functions - */ -#define RX_FREE_BUFFERS 64 -#define RX_LOW_WATERMARK 8 - -/* Size of one Rx buffer in host DRAM */ -#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ -#define IL_RX_BUF_SIZE_4K (4 * 1024) -#define IL_RX_BUF_SIZE_8K (8 * 1024) - -/** - * struct il_rb_status - reseve buffer status - * host memory mapped FH registers - * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed - * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed - * @finished_rb_num [0:11] - Indicates the idx of the current RB - * in which the last frame was written to - * @finished_fr_num [0:11] - Indicates the idx of the RX Frame - * which was transferred - */ -struct il_rb_status { - __le16 closed_rb_num; - __le16 closed_fr_num; - __le16 finished_rb_num; - __le16 finished_fr_nam; - __le32 __unused; /* 3945 only */ -} __packed; - - -#define TFD_QUEUE_SIZE_MAX (256) -#define TFD_QUEUE_SIZE_BC_DUP (64) -#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) -#define IL_TX_DMA_MASK DMA_BIT_MASK(36) -#define IL_NUM_OF_TBS 20 - -static inline u8 il_get_dma_hi_addr(dma_addr_t addr) -{ - return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; -} -/** - * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor - * - * This structure contains dma address and length of transmission address - * - * @lo: low [31:0] portion of the dma address of TX buffer - * every even is unaligned on 16 bit boundary - * @hi_n_len 0-3 [35:32] portion of dma - * 4-15 length of the tx buffer - */ -struct il_tfd_tb { - __le32 lo; - __le16 hi_n_len; -} __packed; - -/** - * struct il_tfd - * - * Transmit Frame Descriptor (TFD) - * - * @ __reserved1[3] reserved - * @ num_tbs 0-4 number of active tbs - * 5 reserved - * 6-7 padding (not used) - * @ tbs[20] transmit frame buffer descriptors - * @ __pad padding - * - * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. - * Both driver and device share these circular buffers, each of which must be - * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes - * - * Driver must indicate the physical address of the base of each - * circular buffer via the FH_MEM_CBBC_QUEUE registers. - * - * Each TFD contains pointer/size information for up to 20 data buffers - * in host DRAM. These buffers collectively contain the (one) frame described - * by the TFD. Each buffer must be a single contiguous block of memory within - * itself, but buffers may be scattered in host DRAM. Each buffer has max size - * of (4K - 4). The concatenates all of a TFD's buffers into a single - * Tx frame, up to 8 KBytes in size. - * - * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. - */ -struct il_tfd { - u8 __reserved1[3]; - u8 num_tbs; - struct il_tfd_tb tbs[IL_NUM_OF_TBS]; - __le32 __pad; -} __packed; - /* Keep Warm Size */ #define IL_KW_SIZE 0x1000 /* 4k */ diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h deleted file mode 100644 index 9d33da8..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ /dev/null @@ -1,337 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_io_h__ -#define __il_io_h__ - -#include - -#include "iwl-dev.h" -#include "iwl-debug.h" - -static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) -{ - iowrite8(val, il->hw_base + ofs); -} -#define il_write8(il, ofs, val) _il_write8(il, ofs, val) - -static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) -{ - iowrite32(val, il->hw_base + ofs); -} - -static inline u32 _il_rd(struct il_priv *il, u32 ofs) -{ - return ioread32(il->hw_base + ofs); -} - -#define IL_POLL_INTERVAL 10 /* microseconds */ -static inline int -_il_poll_bit(struct il_priv *il, u32 addr, - u32 bits, u32 mask, int timeout) -{ - int t = 0; - - do { - if ((_il_rd(il, addr) & mask) == (bits & mask)) - return t; - udelay(IL_POLL_INTERVAL); - t += IL_POLL_INTERVAL; - } while (t < timeout); - - return -ETIMEDOUT; -} - -static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) -{ - _il_wr(il, reg, _il_rd(il, reg) | mask); -} - -static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&p->reg_lock, reg_flags); - _il_set_bit(p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} - -static inline void -_il_clear_bit(struct il_priv *il, u32 reg, u32 mask) -{ - _il_wr(il, reg, _il_rd(il, reg) & ~mask); -} - -static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&p->reg_lock, reg_flags); - _il_clear_bit(p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} - -static inline int _il_grab_nic_access(struct il_priv *il) -{ - int ret; - u32 val; - - /* this bit wakes up the NIC */ - _il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - - /* - * These bits say the device is running, and should keep running for - * at least a short while (at least as long as MAC_ACCESS_REQ stays 1), - * but they do not indicate that embedded SRAM is restored yet; - * 3945 and 4965 have volatile SRAM, and must save/restore contents - * to/from host DRAM when sleeping/waking for power-saving. - * Each direction takes approximately 1/4 millisecond; with this - * overhead, it's a good idea to grab and hold MAC_ACCESS_REQUEST if a - * series of register accesses are expected (e.g. reading Event Log), - * to keep device from sleeping. - * - * CSR_UCODE_DRV_GP1 register bit MAC_SLEEP == 0 indicates that - * SRAM is okay/restored. We don't check that here because this call - * is just for hardware register access; but GP1 MAC_SLEEP check is a - * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). - * - */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, - (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | - CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); - if (ret < 0) { - val = _il_rd(il, CSR_GP_CNTRL); - IL_ERR( - "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_wr(il, CSR_RESET, - CSR_RESET_REG_FLAG_FORCE_NMI); - return -EIO; - } - - return 0; -} - -static inline void _il_release_nic_access(struct il_priv *il) -{ - _il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); -} - -static inline u32 il_rd(struct il_priv *il, u32 reg) -{ - u32 value; - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - value = _il_rd(il, reg); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return value; - -} - -static inline void -il_wr(struct il_priv *il, u32 reg, u32 value) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr(il, reg, value); - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline void il_write_reg_buf(struct il_priv *il, - u32 reg, u32 len, u32 *values) -{ - u32 count = sizeof(u32); - - if (il != NULL && values != NULL) { - for (; 0 < len; len -= count, reg += count, values++) - il_wr(il, reg, *values); - } -} - -static inline int il_poll_bit(struct il_priv *il, u32 addr, - u32 mask, int timeout) -{ - int t = 0; - - do { - if ((il_rd(il, addr) & mask) == mask) - return t; - udelay(IL_POLL_INTERVAL); - t += IL_POLL_INTERVAL; - } while (t < timeout); - - return -ETIMEDOUT; -} - -static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) -{ - _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); - rmb(); - return _il_rd(il, HBUS_TARG_PRPH_RDAT); -} - -static inline u32 il_rd_prph(struct il_priv *il, u32 reg) -{ - unsigned long reg_flags; - u32 val; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - val = _il_rd_prph(il, reg); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return val; -} - -static inline void _il_wr_prph(struct il_priv *il, - u32 addr, u32 val) -{ - _il_wr(il, HBUS_TARG_PRPH_WADDR, - ((addr & 0x0000FFFF) | (3 << 24))); - wmb(); - _il_wr(il, HBUS_TARG_PRPH_WDAT, val); -} - -static inline void -il_wr_prph(struct il_priv *il, u32 addr, u32 val) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr_prph(il, addr, val); - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -#define _il_set_bits_prph(il, reg, mask) \ -_il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)) - -static inline void -il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - _il_set_bits_prph(il, reg, mask); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -#define _il_set_bits_mask_prph(il, reg, bits, mask) \ -_il_wr_prph(il, reg, \ - ((_il_rd_prph(il, reg) & mask) | bits)) - -static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, - u32 bits, u32 mask) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - _il_set_bits_mask_prph(il, reg, bits, mask); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline void il_clear_bits_prph(struct il_priv - *il, u32 reg, u32 mask) -{ - unsigned long reg_flags; - u32 val; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - val = _il_rd_prph(il, reg); - _il_wr_prph(il, reg, (val & ~mask)); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) -{ - unsigned long reg_flags; - u32 value; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - - _il_wr(il, HBUS_TARG_MEM_RADDR, addr); - rmb(); - value = _il_rd(il, HBUS_TARG_MEM_RDAT); - - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return value; -} - -static inline void -il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr(il, HBUS_TARG_MEM_WADDR, addr); - wmb(); - _il_wr(il, HBUS_TARG_MEM_WDAT, val); - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline void -il_write_targ_mem_buf(struct il_priv *il, u32 addr, - u32 len, u32 *values) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr(il, HBUS_TARG_MEM_WADDR, addr); - wmb(); - for (; 0 < len; len -= sizeof(u32), values++) - _il_wr(il, - HBUS_TARG_MEM_WDAT, *values); - - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h deleted file mode 100644 index afd3003..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ /dev/null @@ -1,146 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -#ifndef __il_sta_h__ -#define __il_sta_h__ - -#include "iwl-dev.h" - -#define HW_KEY_DYNAMIC 0 -#define HW_KEY_DEFAULT 1 - -#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ -#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ -#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of - being activated */ -#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; - (this is for the IBSS BSSID stations) */ -#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ - - -void il_restore_stations(struct il_priv *il, - struct il_rxon_context *ctx); -void il_clear_ucode_stations(struct il_priv *il, - struct il_rxon_context *ctx); -void il_dealloc_bcast_stations(struct il_priv *il); -int il_get_free_ucode_key_idx(struct il_priv *il); -int il_send_add_sta(struct il_priv *il, - struct il_addsta_cmd *sta, u8 flags); -int il_add_station_common(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta, u8 *sta_id_r); -int il_remove_station(struct il_priv *il, - const u8 sta_id, - const u8 *addr); -int il_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta); - -u8 il_prep_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta); - -int il_send_lq_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq, - u8 flags, bool init); - -/** - * il_clear_driver_stations - clear knowledge of all stations from driver - * @il: iwl il struct - * - * This is called during il_down() to make sure that in the case - * we're coming there from a hardware restart mac80211 will be - * able to reconfigure stations -- if we're getting there in the - * normal down flow then the stations will already be cleared. - */ -static inline void il_clear_driver_stations(struct il_priv *il) -{ - unsigned long flags; - struct il_rxon_context *ctx = &il->ctx; - - spin_lock_irqsave(&il->sta_lock, flags); - memset(il->stations, 0, sizeof(il->stations)); - il->num_stations = 0; - - il->ucode_key_table = 0; - - /* - * Remove all key information that is not stored as part - * of station information since mac80211 may not have had - * a chance to remove all the keys. When device is - * reconfigured by mac80211 after an error all keys will - * be reconfigured. - */ - memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); - ctx->key_mapping_keys = 0; - - spin_unlock_irqrestore(&il->sta_lock, flags); -} - -static inline int il_sta_id(struct ieee80211_sta *sta) -{ - if (WARN_ON(!sta)) - return IL_INVALID_STATION; - - return ((struct il_station_priv_common *)sta->drv_priv)->sta_id; -} - -/** - * il_sta_id_or_broadcast - return sta_id or broadcast sta - * @il: iwl il - * @context: the current context - * @sta: mac80211 station - * - * In certain circumstances mac80211 passes a station pointer - * that may be %NULL, for example during TX or key setup. In - * that case, we need to use the broadcast station, so this - * inline wraps that pattern. - */ -static inline int il_sta_id_or_broadcast(struct il_priv *il, - struct il_rxon_context *context, - struct ieee80211_sta *sta) -{ - int sta_id; - - if (!sta) - return context->bcast_sta_id; - - sta_id = il_sta_id(sta); - - /* - * mac80211 should not be passing a partially - * initialised station! - */ - WARN_ON(sta_id == IL_INVALID_STATION); - - return sta_id; -} -#endif /* __il_sta_h__ */ -- cgit v0.10.2 From f44cfaf330b911b43f0763d1932ba0b4e0e353a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:24:32 +0200 Subject: iwlegacy: remove iwl-helpers.h This file was already merged into common.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h deleted file mode 100644 index 2db83fc3..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ /dev/null @@ -1,187 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_helpers_h__ -#define __il_helpers_h__ - -#include -#include - -#include "iwl-io.h" - -/** - * il_queue_inc_wrap - increment queue idx, wrap back to beginning - * @idx -- current idx - * @n_bd -- total number of entries in queue (must be power of 2) - */ -static inline int il_queue_inc_wrap(int idx, int n_bd) -{ - return ++idx & (n_bd - 1); -} - -/** - * il_queue_dec_wrap - decrement queue idx, wrap back to end - * @idx -- current idx - * @n_bd -- total number of entries in queue (must be power of 2) - */ -static inline int il_queue_dec_wrap(int idx, int n_bd) -{ - return --idx & (n_bd - 1); -} - -/* TODO: Move fw_desc functions to iwl-pci.ko */ -static inline void il_free_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) -{ - if (desc->v_addr) - dma_free_coherent(&pci_dev->dev, desc->len, - desc->v_addr, desc->p_addr); - desc->v_addr = NULL; - desc->len = 0; -} - -static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) -{ - if (!desc->len) { - desc->v_addr = NULL; - return -EINVAL; - } - - desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len, - &desc->p_addr, GFP_KERNEL); - return (desc->v_addr != NULL) ? 0 : -ENOMEM; -} - -/* - * we have 8 bits used like this: - * - * 7 6 5 4 3 2 1 0 - * | | | | | | | | - * | | | | | | +-+-------- AC queue (0-3) - * | | | | | | - * | +-+-+-+-+------------ HW queue ID - * | - * +---------------------- unused - */ -static inline void -il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) -{ - BUG_ON(ac > 3); /* only have 2 bits */ - BUG_ON(hwq > 31); /* only use 5 bits */ - - txq->swq_id = (hwq << 2) | ac; -} - -static inline void il_wake_queue(struct il_priv *il, - struct il_tx_queue *txq) -{ - u8 queue = txq->swq_id; - u8 ac = queue & 3; - u8 hwq = (queue >> 2) & 0x1f; - - if (test_and_clear_bit(hwq, il->queue_stopped)) - if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0) - ieee80211_wake_queue(il->hw, ac); -} - -static inline void il_stop_queue(struct il_priv *il, - struct il_tx_queue *txq) -{ - u8 queue = txq->swq_id; - u8 ac = queue & 3; - u8 hwq = (queue >> 2) & 0x1f; - - if (!test_and_set_bit(hwq, il->queue_stopped)) - if (atomic_inc_return(&il->queue_stop_count[ac]) > 0) - ieee80211_stop_queue(il->hw, ac); -} - -#ifdef ieee80211_stop_queue -#undef ieee80211_stop_queue -#endif - -#define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue - -#ifdef ieee80211_wake_queue -#undef ieee80211_wake_queue -#endif - -#define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue - -static inline void il_disable_interrupts(struct il_priv *il) -{ - clear_bit(S_INT_ENABLED, &il->status); - - /* disable interrupts from uCode/NIC to host */ - _il_wr(il, CSR_INT_MASK, 0x00000000); - - /* acknowledge/clear/reset any interrupts still pending - * from uCode or flow handler (Rx/Tx DMA) */ - _il_wr(il, CSR_INT, 0xffffffff); - _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); - D_ISR("Disabled interrupts\n"); -} - -static inline void il_enable_rfkill_int(struct il_priv *il) -{ - D_ISR("Enabling rfkill interrupt\n"); - _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); -} - -static inline void il_enable_interrupts(struct il_priv *il) -{ - D_ISR("Enabling interrupts\n"); - set_bit(S_INT_ENABLED, &il->status); - _il_wr(il, CSR_INT_MASK, il->inta_mask); -} - -/** - * il_beacon_time_mask_low - mask of lower 32 bit of beacon time - * @il -- pointer to il_priv data structure - * @tsf_bits -- number of bits need to shift for masking) - */ -static inline u32 il_beacon_time_mask_low(struct il_priv *il, - u16 tsf_bits) -{ - return (1 << tsf_bits) - 1; -} - -/** - * il_beacon_time_mask_high - mask of higher 32 bit of beacon time - * @il -- pointer to il_priv data structure - * @tsf_bits -- number of bits need to shift for masking) - */ -static inline u32 il_beacon_time_mask_high(struct il_priv *il, - u16 tsf_bits) -{ - return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; -} - -#endif /* __il_helpers_h__ */ -- cgit v0.10.2 From 3fbbf9a8083049718c44e43dc88c8e79cb0b7793 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:39:29 +0200 Subject: iwlegacy: merge iwl-legacy-rs.h into common.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index e83c6ab..2e66929 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -39,7 +39,6 @@ #include "iwl-debug.h" #include "iwl-led.h" #include "iwl-power.h" -#include "iwl-legacy-rs.h" struct il_host_cmd; struct il_cmd; @@ -480,24 +479,6 @@ struct il_station_priv_common { u8 sta_id; }; -/* - * il_station_priv: Driver's ilate station information - * - * When mac80211 creates a station it reserves some space (hw->sta_data_size) - * in the structure for use by driver. This structure is places in that - * space. - * - * The common struct MUST be first because it is shared between - * 3945 and 4965! - */ -struct il_station_priv { - struct il_station_priv_common common; - struct il_lq_sta lq_sta; - atomic_t pending_frames; - bool client; - bool asleep; -}; - /** * struct il_vif_priv - driver's ilate per-interface information * @@ -2573,4 +2554,446 @@ struct il_tfd { #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 +struct il_rate_info { + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ + u8 prev_ieee; /* previous rate in IEEE speeds */ + u8 next_ieee; /* next rate in IEEE speeds */ + u8 prev_rs; /* previous rate used in rs algo */ + u8 next_rs; /* next rate used in rs algo */ + u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ + u8 next_rs_tgg; /* next rate used in TGG rs algo */ +}; + +struct il3945_rate_info { + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ + u8 prev_ieee; /* previous rate in IEEE speeds */ + u8 next_ieee; /* next rate in IEEE speeds */ + u8 prev_rs; /* previous rate used in rs algo */ + u8 next_rs; /* next rate used in rs algo */ + u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ + u8 next_rs_tgg; /* next rate used in TGG rs algo */ + u8 table_rs_idx; /* idx in rate scale table cmd */ + u8 prev_table_rs; /* prev in rate table cmd */ +}; + + +/* + * These serve as idxes into + * struct il_rate_info il_rates[RATE_COUNT]; + */ +enum { + RATE_1M_IDX = 0, + RATE_2M_IDX, + RATE_5M_IDX, + RATE_11M_IDX, + RATE_6M_IDX, + RATE_9M_IDX, + RATE_12M_IDX, + RATE_18M_IDX, + RATE_24M_IDX, + RATE_36M_IDX, + RATE_48M_IDX, + RATE_54M_IDX, + RATE_60M_IDX, + RATE_COUNT, + RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ + RATE_COUNT_3945 = RATE_COUNT - 1, + RATE_INVM_IDX = RATE_COUNT, + RATE_INVALID = RATE_COUNT, +}; + +enum { + RATE_6M_IDX_TBL = 0, + RATE_9M_IDX_TBL, + RATE_12M_IDX_TBL, + RATE_18M_IDX_TBL, + RATE_24M_IDX_TBL, + RATE_36M_IDX_TBL, + RATE_48M_IDX_TBL, + RATE_54M_IDX_TBL, + RATE_1M_IDX_TBL, + RATE_2M_IDX_TBL, + RATE_5M_IDX_TBL, + RATE_11M_IDX_TBL, + RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1, +}; + +enum { + IL_FIRST_OFDM_RATE = RATE_6M_IDX, + IL39_LAST_OFDM_RATE = RATE_54M_IDX, + IL_LAST_OFDM_RATE = RATE_60M_IDX, + IL_FIRST_CCK_RATE = RATE_1M_IDX, + IL_LAST_CCK_RATE = RATE_11M_IDX, +}; + +/* #define vs. enum to keep from defaulting to 'large integer' */ +#define RATE_6M_MASK (1 << RATE_6M_IDX) +#define RATE_9M_MASK (1 << RATE_9M_IDX) +#define RATE_12M_MASK (1 << RATE_12M_IDX) +#define RATE_18M_MASK (1 << RATE_18M_IDX) +#define RATE_24M_MASK (1 << RATE_24M_IDX) +#define RATE_36M_MASK (1 << RATE_36M_IDX) +#define RATE_48M_MASK (1 << RATE_48M_IDX) +#define RATE_54M_MASK (1 << RATE_54M_IDX) +#define RATE_60M_MASK (1 << RATE_60M_IDX) +#define RATE_1M_MASK (1 << RATE_1M_IDX) +#define RATE_2M_MASK (1 << RATE_2M_IDX) +#define RATE_5M_MASK (1 << RATE_5M_IDX) +#define RATE_11M_MASK (1 << RATE_11M_IDX) + +/* uCode API values for legacy bit rates, both OFDM and CCK */ +enum { + RATE_6M_PLCP = 13, + RATE_9M_PLCP = 15, + RATE_12M_PLCP = 5, + RATE_18M_PLCP = 7, + RATE_24M_PLCP = 9, + RATE_36M_PLCP = 11, + RATE_48M_PLCP = 1, + RATE_54M_PLCP = 3, + RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ + RATE_1M_PLCP = 10, + RATE_2M_PLCP = 20, + RATE_5M_PLCP = 55, + RATE_11M_PLCP = 110, + /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ +}; + +/* uCode API values for OFDM high-throughput (HT) bit rates */ +enum { + RATE_SISO_6M_PLCP = 0, + RATE_SISO_12M_PLCP = 1, + RATE_SISO_18M_PLCP = 2, + RATE_SISO_24M_PLCP = 3, + RATE_SISO_36M_PLCP = 4, + RATE_SISO_48M_PLCP = 5, + RATE_SISO_54M_PLCP = 6, + RATE_SISO_60M_PLCP = 7, + RATE_MIMO2_6M_PLCP = 0x8, + RATE_MIMO2_12M_PLCP = 0x9, + RATE_MIMO2_18M_PLCP = 0xa, + RATE_MIMO2_24M_PLCP = 0xb, + RATE_MIMO2_36M_PLCP = 0xc, + RATE_MIMO2_48M_PLCP = 0xd, + RATE_MIMO2_54M_PLCP = 0xe, + RATE_MIMO2_60M_PLCP = 0xf, + RATE_SISO_INVM_PLCP, + RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP, +}; + +/* MAC header values for bit rates */ +enum { + RATE_6M_IEEE = 12, + RATE_9M_IEEE = 18, + RATE_12M_IEEE = 24, + RATE_18M_IEEE = 36, + RATE_24M_IEEE = 48, + RATE_36M_IEEE = 72, + RATE_48M_IEEE = 96, + RATE_54M_IEEE = 108, + RATE_60M_IEEE = 120, + RATE_1M_IEEE = 2, + RATE_2M_IEEE = 4, + RATE_5M_IEEE = 11, + RATE_11M_IEEE = 22, +}; + +#define IL_CCK_BASIC_RATES_MASK \ + (RATE_1M_MASK | \ + RATE_2M_MASK) + +#define IL_CCK_RATES_MASK \ + (IL_CCK_BASIC_RATES_MASK | \ + RATE_5M_MASK | \ + RATE_11M_MASK) + +#define IL_OFDM_BASIC_RATES_MASK \ + (RATE_6M_MASK | \ + RATE_12M_MASK | \ + RATE_24M_MASK) + +#define IL_OFDM_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + RATE_9M_MASK | \ + RATE_18M_MASK | \ + RATE_36M_MASK | \ + RATE_48M_MASK | \ + RATE_54M_MASK) + +#define IL_BASIC_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + IL_CCK_BASIC_RATES_MASK) + +#define RATES_MASK ((1 << RATE_COUNT) - 1) +#define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1) + +#define IL_INVALID_VALUE -1 + +#define IL_MIN_RSSI_VAL -100 +#define IL_MAX_RSSI_VAL 0 + +/* These values specify how many Tx frame attempts before + * searching for a new modulation mode */ +#define IL_LEGACY_FAILURE_LIMIT 160 +#define IL_LEGACY_SUCCESS_LIMIT 480 +#define IL_LEGACY_TBL_COUNT 160 + +#define IL_NONE_LEGACY_FAILURE_LIMIT 400 +#define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 +#define IL_NONE_LEGACY_TBL_COUNT 1500 + +/* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ +#define IL_RS_GOOD_RATIO 12800 /* 100% */ +#define RATE_SCALE_SWITCH 10880 /* 85% */ +#define RATE_HIGH_TH 10880 /* 85% */ +#define RATE_INCREASE_TH 6400 /* 50% */ +#define RATE_DECREASE_TH 1920 /* 15% */ + +/* possible actions when in legacy mode */ +#define IL_LEGACY_SWITCH_ANTENNA1 0 +#define IL_LEGACY_SWITCH_ANTENNA2 1 +#define IL_LEGACY_SWITCH_SISO 2 +#define IL_LEGACY_SWITCH_MIMO2_AB 3 +#define IL_LEGACY_SWITCH_MIMO2_AC 4 +#define IL_LEGACY_SWITCH_MIMO2_BC 5 + +/* possible actions when in siso mode */ +#define IL_SISO_SWITCH_ANTENNA1 0 +#define IL_SISO_SWITCH_ANTENNA2 1 +#define IL_SISO_SWITCH_MIMO2_AB 2 +#define IL_SISO_SWITCH_MIMO2_AC 3 +#define IL_SISO_SWITCH_MIMO2_BC 4 +#define IL_SISO_SWITCH_GI 5 + +/* possible actions when in mimo mode */ +#define IL_MIMO2_SWITCH_ANTENNA1 0 +#define IL_MIMO2_SWITCH_ANTENNA2 1 +#define IL_MIMO2_SWITCH_SISO_A 2 +#define IL_MIMO2_SWITCH_SISO_B 3 +#define IL_MIMO2_SWITCH_SISO_C 4 +#define IL_MIMO2_SWITCH_GI 5 + +#define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI + +#define IL_ACTION_LIMIT 3 /* # possible actions */ + +#define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */ + +/* load per tid defines for A-MPDU activation */ +#define IL_AGG_TPT_THREHOLD 0 +#define IL_AGG_LOAD_THRESHOLD 10 +#define IL_AGG_ALL_TID 0xff +#define TID_QUEUE_CELL_SPACING 50 /*mS */ +#define TID_QUEUE_MAX_SIZE 20 +#define TID_ROUND_VALUE 5 /* mS */ +#define TID_MAX_LOAD_COUNT 8 + +#define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) +#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) + +extern const struct il_rate_info il_rates[RATE_COUNT]; + +enum il_table_type { + LQ_NONE, + LQ_G, /* legacy types */ + LQ_A, + LQ_SISO, /* high-throughput types */ + LQ_MIMO2, + LQ_MAX, +}; + +#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A) +#define is_siso(tbl) ((tbl) == LQ_SISO) +#define is_mimo2(tbl) ((tbl) == LQ_MIMO2) +#define is_mimo(tbl) (is_mimo2(tbl)) +#define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl)) +#define is_a_band(tbl) ((tbl) == LQ_A) +#define is_g_and(tbl) ((tbl) == LQ_G) + +#define ANT_NONE 0x0 +#define ANT_A BIT(0) +#define ANT_B BIT(1) +#define ANT_AB (ANT_A | ANT_B) +#define ANT_C BIT(2) +#define ANT_AC (ANT_A | ANT_C) +#define ANT_BC (ANT_B | ANT_C) +#define ANT_ABC (ANT_AB | ANT_C) + +#define IL_MAX_MCS_DISPLAY_SIZE 12 + +struct il_rate_mcs_info { + char mbps[IL_MAX_MCS_DISPLAY_SIZE]; + char mcs[IL_MAX_MCS_DISPLAY_SIZE]; +}; + +/** + * struct il_rate_scale_data -- tx success history for one rate + */ +struct il_rate_scale_data { + u64 data; /* bitmap of successful frames */ + s32 success_counter; /* number of frames successful */ + s32 success_ratio; /* per-cent * 128 */ + s32 counter; /* number of frames attempted */ + s32 average_tpt; /* success ratio * expected throughput */ + unsigned long stamp; +}; + +/** + * struct il_scale_tbl_info -- tx params and success history for all rates + * + * There are two of these in struct il_lq_sta, + * one for "active", and one for "search". + */ +struct il_scale_tbl_info { + enum il_table_type lq_type; + u8 ant_type; + u8 is_SGI; /* 1 = short guard interval */ + u8 is_ht40; /* 1 = 40 MHz channel width */ + u8 is_dup; /* 1 = duplicated data streams */ + u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ + u8 max_search; /* maximun number of tables we can search */ + s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ + u32 current_rate; /* rate_n_flags, uCode API format */ + struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ +}; + +struct il_traffic_load { + unsigned long time_stamp; /* age of the oldest stats */ + u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time + * slice */ + u32 total; /* total num of packets during the + * last TID_MAX_TIME_DIFF */ + u8 queue_count; /* number of queues that has + * been used since the last cleanup */ + u8 head; /* start of the circular buffer */ +}; + +/** + * struct il_lq_sta -- driver's rate scaling ilate structure + * + * Pointer to this gets passed back and forth between driver and mac80211. + */ +struct il_lq_sta { + u8 active_tbl; /* idx of active table, range 0-1 */ + u8 enable_counter; /* indicates HT mode */ + u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ + u8 search_better_tbl; /* 1: currently trying alternate mode */ + s32 last_tpt; + + /* The following determine when to search for a new mode */ + u32 table_count_limit; + u32 max_failure_limit; /* # failed frames before new search */ + u32 max_success_limit; /* # successful frames before new search */ + u32 table_count; + u32 total_failed; /* total failed frames, any/all rates */ + u32 total_success; /* total successful frames, any/all rates */ + u64 flush_timer; /* time staying in mode before new search */ + + u8 action_counter; /* # mode-switch actions tried */ + u8 is_green; + u8 is_dup; + enum ieee80211_band band; + + /* The following are bitmaps of rates; RATE_6M_MASK, etc. */ + u32 supp_rates; + u16 active_legacy_rate; + u16 active_siso_rate; + u16 active_mimo2_rate; + s8 max_rate_idx; /* Max rate set by user */ + u8 missed_rate_counter; + + struct il_link_quality_cmd lq; + struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ + struct il_traffic_load load[TID_MAX_LOAD_COUNT]; + u8 tx_agg_tid_en; +#ifdef CONFIG_MAC80211_DEBUGFS + struct dentry *rs_sta_dbgfs_scale_table_file; + struct dentry *rs_sta_dbgfs_stats_table_file; + struct dentry *rs_sta_dbgfs_rate_scale_data_file; + struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; + u32 dbg_fixed_rate; +#endif + struct il_priv *drv; + + /* used to be in sta_info */ + int last_txrate_idx; + /* last tx rate_n_flags */ + u32 last_rate_n_flags; + /* packets destined for this STA are aggregated */ + u8 is_agg; +}; + +/* + * il_station_priv: Driver's ilate station information + * + * When mac80211 creates a station it reserves some space (hw->sta_data_size) + * in the structure for use by driver. This structure is places in that + * space. + * + * The common struct MUST be first because it is shared between + * 3945 and 4965! + */ +struct il_station_priv { + struct il_station_priv_common common; + struct il_lq_sta lq_sta; + atomic_t pending_frames; + bool client; + bool asleep; +}; + +static inline u8 il4965_num_of_ant(u8 m) +{ + return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); +} + +static inline u8 il4965_first_antenna(u8 mask) +{ + if (mask & ANT_A) + return ANT_A; + if (mask & ANT_B) + return ANT_B; + return ANT_C; +} + + +/** + * il3945_rate_scale_init - Initialize the rate scale table based on assoc info + * + * The specific throughput table used is based on the type of network + * the associated with, including A, B, G, and G w/ TGG protection + */ +extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); + +/* Initialize station's rate scaling information after adding station */ +extern void il4965_rs_rate_init(struct il_priv *il, + struct ieee80211_sta *sta, u8 sta_id); +extern void il3945_rs_rate_init(struct il_priv *il, + struct ieee80211_sta *sta, u8 sta_id); + +/** + * il_rate_control_register - Register the rate control algorithm callbacks + * + * Since the rate control algorithm is hardware specific, there is no need + * or reason to place it as a stand alone module. The driver can call + * il_rate_control_register in order to register the rate control callbacks + * with the mac80211 subsystem. This should be performed prior to calling + * ieee80211_register_hw + * + */ +extern int il4965_rate_control_register(void); +extern int il3945_rate_control_register(void); + +/** + * il_rate_control_unregister - Unregister the rate control callbacks + * + * This should be called after calling ieee80211_unregister_hw, but before + * the driver is unloaded. + */ +extern void il4965_rate_control_unregister(void); +extern void il3945_rate_control_unregister(void); + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h deleted file mode 100644 index 58e04cb..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ /dev/null @@ -1,454 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_rs_h__ -#define __il_rs_h__ - -struct il_rate_info { - u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ - u8 prev_ieee; /* previous rate in IEEE speeds */ - u8 next_ieee; /* next rate in IEEE speeds */ - u8 prev_rs; /* previous rate used in rs algo */ - u8 next_rs; /* next rate used in rs algo */ - u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ - u8 next_rs_tgg; /* next rate used in TGG rs algo */ -}; - -struct il3945_rate_info { - u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ - u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ - u8 prev_ieee; /* previous rate in IEEE speeds */ - u8 next_ieee; /* next rate in IEEE speeds */ - u8 prev_rs; /* previous rate used in rs algo */ - u8 next_rs; /* next rate used in rs algo */ - u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ - u8 next_rs_tgg; /* next rate used in TGG rs algo */ - u8 table_rs_idx; /* idx in rate scale table cmd */ - u8 prev_table_rs; /* prev in rate table cmd */ -}; - - -/* - * These serve as idxes into - * struct il_rate_info il_rates[RATE_COUNT]; - */ -enum { - RATE_1M_IDX = 0, - RATE_2M_IDX, - RATE_5M_IDX, - RATE_11M_IDX, - RATE_6M_IDX, - RATE_9M_IDX, - RATE_12M_IDX, - RATE_18M_IDX, - RATE_24M_IDX, - RATE_36M_IDX, - RATE_48M_IDX, - RATE_54M_IDX, - RATE_60M_IDX, - RATE_COUNT, - RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ - RATE_COUNT_3945 = RATE_COUNT - 1, - RATE_INVM_IDX = RATE_COUNT, - RATE_INVALID = RATE_COUNT, -}; - -enum { - RATE_6M_IDX_TBL = 0, - RATE_9M_IDX_TBL, - RATE_12M_IDX_TBL, - RATE_18M_IDX_TBL, - RATE_24M_IDX_TBL, - RATE_36M_IDX_TBL, - RATE_48M_IDX_TBL, - RATE_54M_IDX_TBL, - RATE_1M_IDX_TBL, - RATE_2M_IDX_TBL, - RATE_5M_IDX_TBL, - RATE_11M_IDX_TBL, - RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1, -}; - -enum { - IL_FIRST_OFDM_RATE = RATE_6M_IDX, - IL39_LAST_OFDM_RATE = RATE_54M_IDX, - IL_LAST_OFDM_RATE = RATE_60M_IDX, - IL_FIRST_CCK_RATE = RATE_1M_IDX, - IL_LAST_CCK_RATE = RATE_11M_IDX, -}; - -/* #define vs. enum to keep from defaulting to 'large integer' */ -#define RATE_6M_MASK (1 << RATE_6M_IDX) -#define RATE_9M_MASK (1 << RATE_9M_IDX) -#define RATE_12M_MASK (1 << RATE_12M_IDX) -#define RATE_18M_MASK (1 << RATE_18M_IDX) -#define RATE_24M_MASK (1 << RATE_24M_IDX) -#define RATE_36M_MASK (1 << RATE_36M_IDX) -#define RATE_48M_MASK (1 << RATE_48M_IDX) -#define RATE_54M_MASK (1 << RATE_54M_IDX) -#define RATE_60M_MASK (1 << RATE_60M_IDX) -#define RATE_1M_MASK (1 << RATE_1M_IDX) -#define RATE_2M_MASK (1 << RATE_2M_IDX) -#define RATE_5M_MASK (1 << RATE_5M_IDX) -#define RATE_11M_MASK (1 << RATE_11M_IDX) - -/* uCode API values for legacy bit rates, both OFDM and CCK */ -enum { - RATE_6M_PLCP = 13, - RATE_9M_PLCP = 15, - RATE_12M_PLCP = 5, - RATE_18M_PLCP = 7, - RATE_24M_PLCP = 9, - RATE_36M_PLCP = 11, - RATE_48M_PLCP = 1, - RATE_54M_PLCP = 3, - RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - RATE_1M_PLCP = 10, - RATE_2M_PLCP = 20, - RATE_5M_PLCP = 55, - RATE_11M_PLCP = 110, - /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ -}; - -/* uCode API values for OFDM high-throughput (HT) bit rates */ -enum { - RATE_SISO_6M_PLCP = 0, - RATE_SISO_12M_PLCP = 1, - RATE_SISO_18M_PLCP = 2, - RATE_SISO_24M_PLCP = 3, - RATE_SISO_36M_PLCP = 4, - RATE_SISO_48M_PLCP = 5, - RATE_SISO_54M_PLCP = 6, - RATE_SISO_60M_PLCP = 7, - RATE_MIMO2_6M_PLCP = 0x8, - RATE_MIMO2_12M_PLCP = 0x9, - RATE_MIMO2_18M_PLCP = 0xa, - RATE_MIMO2_24M_PLCP = 0xb, - RATE_MIMO2_36M_PLCP = 0xc, - RATE_MIMO2_48M_PLCP = 0xd, - RATE_MIMO2_54M_PLCP = 0xe, - RATE_MIMO2_60M_PLCP = 0xf, - RATE_SISO_INVM_PLCP, - RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP, -}; - -/* MAC header values for bit rates */ -enum { - RATE_6M_IEEE = 12, - RATE_9M_IEEE = 18, - RATE_12M_IEEE = 24, - RATE_18M_IEEE = 36, - RATE_24M_IEEE = 48, - RATE_36M_IEEE = 72, - RATE_48M_IEEE = 96, - RATE_54M_IEEE = 108, - RATE_60M_IEEE = 120, - RATE_1M_IEEE = 2, - RATE_2M_IEEE = 4, - RATE_5M_IEEE = 11, - RATE_11M_IEEE = 22, -}; - -#define IL_CCK_BASIC_RATES_MASK \ - (RATE_1M_MASK | \ - RATE_2M_MASK) - -#define IL_CCK_RATES_MASK \ - (IL_CCK_BASIC_RATES_MASK | \ - RATE_5M_MASK | \ - RATE_11M_MASK) - -#define IL_OFDM_BASIC_RATES_MASK \ - (RATE_6M_MASK | \ - RATE_12M_MASK | \ - RATE_24M_MASK) - -#define IL_OFDM_RATES_MASK \ - (IL_OFDM_BASIC_RATES_MASK | \ - RATE_9M_MASK | \ - RATE_18M_MASK | \ - RATE_36M_MASK | \ - RATE_48M_MASK | \ - RATE_54M_MASK) - -#define IL_BASIC_RATES_MASK \ - (IL_OFDM_BASIC_RATES_MASK | \ - IL_CCK_BASIC_RATES_MASK) - -#define RATES_MASK ((1 << RATE_COUNT) - 1) -#define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1) - -#define IL_INVALID_VALUE -1 - -#define IL_MIN_RSSI_VAL -100 -#define IL_MAX_RSSI_VAL 0 - -/* These values specify how many Tx frame attempts before - * searching for a new modulation mode */ -#define IL_LEGACY_FAILURE_LIMIT 160 -#define IL_LEGACY_SUCCESS_LIMIT 480 -#define IL_LEGACY_TBL_COUNT 160 - -#define IL_NONE_LEGACY_FAILURE_LIMIT 400 -#define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 -#define IL_NONE_LEGACY_TBL_COUNT 1500 - -/* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ -#define IL_RS_GOOD_RATIO 12800 /* 100% */ -#define RATE_SCALE_SWITCH 10880 /* 85% */ -#define RATE_HIGH_TH 10880 /* 85% */ -#define RATE_INCREASE_TH 6400 /* 50% */ -#define RATE_DECREASE_TH 1920 /* 15% */ - -/* possible actions when in legacy mode */ -#define IL_LEGACY_SWITCH_ANTENNA1 0 -#define IL_LEGACY_SWITCH_ANTENNA2 1 -#define IL_LEGACY_SWITCH_SISO 2 -#define IL_LEGACY_SWITCH_MIMO2_AB 3 -#define IL_LEGACY_SWITCH_MIMO2_AC 4 -#define IL_LEGACY_SWITCH_MIMO2_BC 5 - -/* possible actions when in siso mode */ -#define IL_SISO_SWITCH_ANTENNA1 0 -#define IL_SISO_SWITCH_ANTENNA2 1 -#define IL_SISO_SWITCH_MIMO2_AB 2 -#define IL_SISO_SWITCH_MIMO2_AC 3 -#define IL_SISO_SWITCH_MIMO2_BC 4 -#define IL_SISO_SWITCH_GI 5 - -/* possible actions when in mimo mode */ -#define IL_MIMO2_SWITCH_ANTENNA1 0 -#define IL_MIMO2_SWITCH_ANTENNA2 1 -#define IL_MIMO2_SWITCH_SISO_A 2 -#define IL_MIMO2_SWITCH_SISO_B 3 -#define IL_MIMO2_SWITCH_SISO_C 4 -#define IL_MIMO2_SWITCH_GI 5 - -#define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI - -#define IL_ACTION_LIMIT 3 /* # possible actions */ - -#define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */ - -/* load per tid defines for A-MPDU activation */ -#define IL_AGG_TPT_THREHOLD 0 -#define IL_AGG_LOAD_THRESHOLD 10 -#define IL_AGG_ALL_TID 0xff -#define TID_QUEUE_CELL_SPACING 50 /*mS */ -#define TID_QUEUE_MAX_SIZE 20 -#define TID_ROUND_VALUE 5 /* mS */ -#define TID_MAX_LOAD_COUNT 8 - -#define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) -#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) - -extern const struct il_rate_info il_rates[RATE_COUNT]; - -enum il_table_type { - LQ_NONE, - LQ_G, /* legacy types */ - LQ_A, - LQ_SISO, /* high-throughput types */ - LQ_MIMO2, - LQ_MAX, -}; - -#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A) -#define is_siso(tbl) ((tbl) == LQ_SISO) -#define is_mimo2(tbl) ((tbl) == LQ_MIMO2) -#define is_mimo(tbl) (is_mimo2(tbl)) -#define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl)) -#define is_a_band(tbl) ((tbl) == LQ_A) -#define is_g_and(tbl) ((tbl) == LQ_G) - -#define ANT_NONE 0x0 -#define ANT_A BIT(0) -#define ANT_B BIT(1) -#define ANT_AB (ANT_A | ANT_B) -#define ANT_C BIT(2) -#define ANT_AC (ANT_A | ANT_C) -#define ANT_BC (ANT_B | ANT_C) -#define ANT_ABC (ANT_AB | ANT_C) - -#define IL_MAX_MCS_DISPLAY_SIZE 12 - -struct il_rate_mcs_info { - char mbps[IL_MAX_MCS_DISPLAY_SIZE]; - char mcs[IL_MAX_MCS_DISPLAY_SIZE]; -}; - -/** - * struct il_rate_scale_data -- tx success history for one rate - */ -struct il_rate_scale_data { - u64 data; /* bitmap of successful frames */ - s32 success_counter; /* number of frames successful */ - s32 success_ratio; /* per-cent * 128 */ - s32 counter; /* number of frames attempted */ - s32 average_tpt; /* success ratio * expected throughput */ - unsigned long stamp; -}; - -/** - * struct il_scale_tbl_info -- tx params and success history for all rates - * - * There are two of these in struct il_lq_sta, - * one for "active", and one for "search". - */ -struct il_scale_tbl_info { - enum il_table_type lq_type; - u8 ant_type; - u8 is_SGI; /* 1 = short guard interval */ - u8 is_ht40; /* 1 = 40 MHz channel width */ - u8 is_dup; /* 1 = duplicated data streams */ - u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ - u8 max_search; /* maximun number of tables we can search */ - s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ - u32 current_rate; /* rate_n_flags, uCode API format */ - struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ -}; - -struct il_traffic_load { - unsigned long time_stamp; /* age of the oldest stats */ - u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time - * slice */ - u32 total; /* total num of packets during the - * last TID_MAX_TIME_DIFF */ - u8 queue_count; /* number of queues that has - * been used since the last cleanup */ - u8 head; /* start of the circular buffer */ -}; - -/** - * struct il_lq_sta -- driver's rate scaling ilate structure - * - * Pointer to this gets passed back and forth between driver and mac80211. - */ -struct il_lq_sta { - u8 active_tbl; /* idx of active table, range 0-1 */ - u8 enable_counter; /* indicates HT mode */ - u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ - u8 search_better_tbl; /* 1: currently trying alternate mode */ - s32 last_tpt; - - /* The following determine when to search for a new mode */ - u32 table_count_limit; - u32 max_failure_limit; /* # failed frames before new search */ - u32 max_success_limit; /* # successful frames before new search */ - u32 table_count; - u32 total_failed; /* total failed frames, any/all rates */ - u32 total_success; /* total successful frames, any/all rates */ - u64 flush_timer; /* time staying in mode before new search */ - - u8 action_counter; /* # mode-switch actions tried */ - u8 is_green; - u8 is_dup; - enum ieee80211_band band; - - /* The following are bitmaps of rates; RATE_6M_MASK, etc. */ - u32 supp_rates; - u16 active_legacy_rate; - u16 active_siso_rate; - u16 active_mimo2_rate; - s8 max_rate_idx; /* Max rate set by user */ - u8 missed_rate_counter; - - struct il_link_quality_cmd lq; - struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ - struct il_traffic_load load[TID_MAX_LOAD_COUNT]; - u8 tx_agg_tid_en; -#ifdef CONFIG_MAC80211_DEBUGFS - struct dentry *rs_sta_dbgfs_scale_table_file; - struct dentry *rs_sta_dbgfs_stats_table_file; - struct dentry *rs_sta_dbgfs_rate_scale_data_file; - struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; - u32 dbg_fixed_rate; -#endif - struct il_priv *drv; - - /* used to be in sta_info */ - int last_txrate_idx; - /* last tx rate_n_flags */ - u32 last_rate_n_flags; - /* packets destined for this STA are aggregated */ - u8 is_agg; -}; - -static inline u8 il4965_num_of_ant(u8 m) -{ - return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); -} - -static inline u8 il4965_first_antenna(u8 mask) -{ - if (mask & ANT_A) - return ANT_A; - if (mask & ANT_B) - return ANT_B; - return ANT_C; -} - - -/** - * il3945_rate_scale_init - Initialize the rate scale table based on assoc info - * - * The specific throughput table used is based on the type of network - * the associated with, including A, B, G, and G w/ TGG protection - */ -extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); - -/* Initialize station's rate scaling information after adding station */ -extern void il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); -extern void il3945_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); - -/** - * il_rate_control_register - Register the rate control algorithm callbacks - * - * Since the rate control algorithm is hardware specific, there is no need - * or reason to place it as a stand alone module. The driver can call - * il_rate_control_register in order to register the rate control callbacks - * with the mac80211 subsystem. This should be performed prior to calling - * ieee80211_register_hw - * - */ -extern int il4965_rate_control_register(void); -extern int il3945_rate_control_register(void); - -/** - * il_rate_control_unregister - Unregister the rate control callbacks - * - * This should be called after calling ieee80211_unregister_hw, but before - * the driver is unloaded. - */ -extern void il4965_rate_control_unregister(void); -extern void il3945_rate_control_unregister(void); - -#endif /* __il_rs__ */ -- cgit v0.10.2 From 99412002a07b63781adfc3d1272d3677841d4170 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:53:04 +0200 Subject: iwlegacy: merge iwl-power.h into common.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 726ca2c..22166bd 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -37,7 +37,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" #include "iwl-prph.h" #include "iwl-debug.h" -#include "iwl-power.h" #include "iwl-led.h" #include "iwl-eeprom.h" diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h index 2f64ed3..9eb7a83 100644 --- a/drivers/net/wireless/iwlegacy/commands.h +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -64,6 +64,8 @@ #ifndef __il_commands_h__ #define __il_commands_h__ +#include + struct il_priv; /* uCode version contains 4 values: Major/Minor/API/Serial */ diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 4258bf6..3b8d47c 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -43,7 +43,6 @@ #include "iwl-eeprom.h" #include "iwl-debug.h" #include "common.h" -#include "iwl-power.h" const char *il_get_cmd_string(u8 cmd) { diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 2e66929..65c593d 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -33,12 +33,12 @@ #include #include +#include "commands.h" #include "iwl-eeprom.h" #include "csr.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "iwl-led.h" -#include "iwl-power.h" struct il_host_cmd; struct il_cmd; @@ -938,6 +938,13 @@ struct il_rxon_context { } ht; }; +struct il_power_mgr { + struct il_powertable_cmd sleep_cmd; + struct il_powertable_cmd sleep_cmd_next; + int debug_sleep_level_override; + bool pci_pm; +}; + struct il_priv { /* ieee device used by generic ieee processing code */ @@ -2996,4 +3003,6 @@ extern int il3945_rate_control_register(void); extern void il4965_rate_control_unregister(void); extern void il3945_rate_control_unregister(void); +extern int il_power_update_mode(struct il_priv *il, bool force); +extern void il_power_initialize(struct il_priv *il); #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h deleted file mode 100644 index c0ae3fa..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ -#ifndef __il_power_setting_h__ -#define __il_power_setting_h__ - -#include "commands.h" - -enum il_power_level { - IL_POWER_IDX_1, - IL_POWER_IDX_2, - IL_POWER_IDX_3, - IL_POWER_IDX_4, - IL_POWER_IDX_5, - IL_POWER_NUM -}; - -struct il_power_mgr { - struct il_powertable_cmd sleep_cmd; - struct il_powertable_cmd sleep_cmd_next; - int debug_sleep_level_override; - bool pci_pm; -}; - -int -il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, - bool force); -int il_power_update_mode(struct il_priv *il, bool force); -void il_power_initialize(struct il_priv *il); - -#endif /* __il_power_setting_h__ */ -- cgit v0.10.2 From 47ef694dd47b1e97a0d766f3c74067bab3debfa5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:04:45 +0200 Subject: iwlegacy: merge iwl-{eeprom,led}.h into common.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 02ae32c..b1ced05 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -40,9 +40,6 @@ #include #include "common.h" -#include "commands.h" -#include "iwl-eeprom.h" -#include "iwl-led.h" #include "3945.h" /* Send led command */ diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 22166bd..5e4fcbc 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -37,8 +37,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" #include "iwl-prph.h" #include "iwl-debug.h" -#include "iwl-led.h" -#include "iwl-eeprom.h" /* Highest firmware API version supported */ #define IL3945_UCODE_API_MAX 2 diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 6848b91..82b6a7b 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -50,7 +50,6 @@ #define DRV_NAME "iwl4965" -#include "iwl-eeprom.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index d66d4e8..4b97717 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -38,7 +38,6 @@ #include #include "common.h" -#include "iwl-eeprom.h" #include "4965.h" #define IL_AC_UNSET -1 diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 3b8d47c..5d5efcb4 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -40,7 +40,6 @@ #include #include -#include "iwl-eeprom.h" #include "iwl-debug.h" #include "common.h" diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 65c593d..8e4450e 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -31,14 +31,13 @@ #include #include #include +#include #include #include "commands.h" -#include "iwl-eeprom.h" #include "csr.h" #include "iwl-prph.h" #include "iwl-debug.h" -#include "iwl-led.h" struct il_host_cmd; struct il_cmd; @@ -178,6 +177,281 @@ struct il_tx_queue { u8 swq_id; }; +/* + * EEPROM access time values: + * + * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG. + * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1). + * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. + * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. + */ +#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ + +#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ +#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ + + +/* + * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. + * + * IBSS and/or AP operation is allowed *only* on those channels with + * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because + * RADAR detection is not supported by the 4965 driver, but is a + * requirement for establishing a new network for legal operation on channels + * requiring RADAR detection or restricting ACTIVE scanning. + * + * NOTE: "WIDE" flag does not indicate anything about "HT40" 40 MHz channels. + * It only indicates that 20 MHz channel use is supported; HT40 channel + * usage is indicated by a separate set of regulatory flags for each + * HT40 channel pair. + * + * NOTE: Using a channel inappropriately will result in a uCode error! + */ +#define IL_NUM_TX_CALIB_GROUPS 5 +enum { + EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ + EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ + /* Bit 2 Reserved */ + EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ + EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ + EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ + /* Bit 6 Reserved (was Narrow Channel) */ + EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ +}; + +/* SKU Capabilities */ +/* 3945 only */ +#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0) +#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1) + +/* *regulatory* channel data format in eeprom, one for each channel. + * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */ +struct il_eeprom_channel { + u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ + s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ +} __packed; + +/* 3945 Specific */ +#define EEPROM_3945_EEPROM_VERSION (0x2f) + +/* 4965 has two radio transmitters (and 3 radio receivers) */ +#define EEPROM_TX_POWER_TX_CHAINS (2) + +/* 4965 has room for up to 8 sets of txpower calibration data */ +#define EEPROM_TX_POWER_BANDS (8) + +/* 4965 factory calibration measures txpower gain settings for + * each of 3 target output levels */ +#define EEPROM_TX_POWER_MEASUREMENTS (3) + +/* 4965 Specific */ +/* 4965 driver does not work with txpower calibration version < 5 */ +#define EEPROM_4965_TX_POWER_VERSION (5) +#define EEPROM_4965_EEPROM_VERSION (0x2f) +#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ +#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ +#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ +#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ + +/* 2.4 GHz */ +extern const u8 il_eeprom_band_1[14]; + +/* + * factory calibration data for one txpower level, on one channel, + * measured on one of the 2 tx chains (radio transmitter and associated + * antenna). EEPROM contains: + * + * 1) Temperature (degrees Celsius) of device when measurement was made. + * + * 2) Gain table idx used to achieve the target measurement power. + * This refers to the "well-known" gain tables (see 4965.h). + * + * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). + * + * 4) RF power amplifier detector level measurement (not used). + */ +struct il_eeprom_calib_measure { + u8 temperature; /* Device temperature (Celsius) */ + u8 gain_idx; /* Index into gain table */ + u8 actual_pow; /* Measured RF output power, half-dBm */ + s8 pa_det; /* Power amp detector level (not used) */ +} __packed; + + +/* + * measurement set for one channel. EEPROM contains: + * + * 1) Channel number measured + * + * 2) Measurements for each of 3 power levels for each of 2 radio transmitters + * (a.k.a. "tx chains") (6 measurements altogether) + */ +struct il_eeprom_calib_ch_info { + u8 ch_num; + struct il_eeprom_calib_measure + measurements[EEPROM_TX_POWER_TX_CHAINS] + [EEPROM_TX_POWER_MEASUREMENTS]; +} __packed; + +/* + * txpower subband info. + * + * For each frequency subband, EEPROM contains the following: + * + * 1) First and last channels within range of the subband. "0" values + * indicate that this sample set is not being used. + * + * 2) Sample measurement sets for 2 channels close to the range endpoints. + */ +struct il_eeprom_calib_subband_info { + u8 ch_from; /* channel number of lowest channel in subband */ + u8 ch_to; /* channel number of highest channel in subband */ + struct il_eeprom_calib_ch_info ch1; + struct il_eeprom_calib_ch_info ch2; +} __packed; + + +/* + * txpower calibration info. EEPROM contains: + * + * 1) Factory-measured saturation power levels (maximum levels at which + * tx power amplifier can output a signal without too much distortion). + * There is one level for 2.4 GHz band and one for 5 GHz band. These + * values apply to all channels within each of the bands. + * + * 2) Factory-measured power supply voltage level. This is assumed to be + * constant (i.e. same value applies to all channels/bands) while the + * factory measurements are being made. + * + * 3) Up to 8 sets of factory-measured txpower calibration values. + * These are for different frequency ranges, since txpower gain + * characteristics of the analog radio circuitry vary with frequency. + * + * Not all sets need to be filled with data; + * struct il_eeprom_calib_subband_info contains range of channels + * (0 if unused) for each set of data. + */ +struct il_eeprom_calib_info { + u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ + u8 saturation_power52; /* half-dBm */ + __le16 voltage; /* signed */ + struct il_eeprom_calib_subband_info + band_info[EEPROM_TX_POWER_BANDS]; +} __packed; + + +/* General */ +#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ +#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ +#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */ +#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */ +#define EEPROM_VERSION (2*0x44) /* 2 bytes */ +#define EEPROM_SKU_CAP (2*0x45) /* 2 bytes */ +#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */ +#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */ +#define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */ +#define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */ + +/* The following masks are to be applied on EEPROM_RADIO_CONFIG */ +#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ +#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ +#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ +#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ +#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ +#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ + +#define EEPROM_3945_RF_CFG_TYPE_MAX 0x0 +#define EEPROM_4965_RF_CFG_TYPE_MAX 0x1 + +/* + * Per-channel regulatory data. + * + * Each channel that *might* be supported by iwl has a fixed location + * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory + * txpower (MSB). + * + * Entries immediately below are for 20 MHz channel width. HT40 (40 MHz) + * channels (only for 4965, not supported by 3945) appear later in the EEPROM. + * + * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 + */ +#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ +#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ + +/* + * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, + * 5.0 GHz channels 7, 8, 11, 12, 16 + * (4915-5080MHz) (none of these is ever supported) + */ +#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */ + +/* + * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 + * (5170-5320MHz) + */ +#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */ + +/* + * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 + * (5500-5700MHz) + */ +#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */ + +/* + * 5.7 GHz channels 145, 149, 153, 157, 161, 165 + * (5725-5825MHz) + */ +#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */ + +/* + * 2.4 GHz HT40 channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11) + * + * The channel listed is the center of the lower 20 MHz half of the channel. + * The overall center frequency is actually 2 channels (10 MHz) above that, + * and the upper half of each HT40 channel is centered 4 channels (20 MHz) away + * from the lower half; e.g. the upper half of HT40 channel 1 is channel 5, + * and the overall HT40 channel width centers on channel 3. + * + * NOTE: The RXON command uses 20 MHz channel numbers to specify the + * control channel to which to tune. RXON also specifies whether the + * control channel is the upper or lower half of a HT40 channel. + * + * NOTE: 4965 does not support HT40 channels on 2.4 GHz. + */ +#define EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS (2*0xA0) /* 14 bytes */ + +/* + * 5.2 GHz HT40 channels 36 (40), 44 (48), 52 (56), 60 (64), + * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161) + */ +#define EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS (2*0xA8) /* 22 bytes */ + +#define EEPROM_REGULATORY_BAND_NO_HT40 (0) + +struct il_eeprom_ops { + const u32 regulatory_bands[7]; + int (*acquire_semaphore) (struct il_priv *il); + void (*release_semaphore) (struct il_priv *il); +}; + + +int il_eeprom_init(struct il_priv *il); +void il_eeprom_free(struct il_priv *il); +const u8 *il_eeprom_query_addr(const struct il_priv *il, + size_t offset); +u16 il_eeprom_query16(const struct il_priv *il, size_t offset); +int il_init_channel_map(struct il_priv *il); +void il_free_channel_map(struct il_priv *il); +const struct il_channel_info *il_get_channel_info( + const struct il_priv *il, + enum ieee80211_band band, u16 channel); + + #define IL_NUM_SCAN_RATES (2) struct il4965_channel_tgd_info { @@ -1329,6 +1603,7 @@ il_is_channel_ibss(const struct il_channel_info *ch) return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; } + static inline void __il_free_pages(struct il_priv *il, struct page *page) { @@ -1432,7 +1707,7 @@ struct il_lib_ops { int (*send_tx_power) (struct il_priv *il); void (*update_chain_flags)(struct il_priv *il); - /* eeprom operations (as defined in iwl-eeprom.h) */ + /* eeprom operations */ struct il_eeprom_ops eeprom_ops; /* temperature */ @@ -1478,7 +1753,7 @@ struct il_mod_params { /* * @led_compensation: compensate on the led on/off time per HW according * to the deviation to achieve the desired led frequency. - * The detail algorithm is described in iwl-led.c + * The detail algorithm is described in common.c * @chain_noise_num_beacons: number of beacons used to compute chain noise * @wd_timeout: TX queues watchdog timeout * @temperature_kelvin: temperature report by uCode in kelvin @@ -1506,6 +1781,29 @@ struct il_base_params { const bool chain_noise_calib_by_driver; }; +#define IL_LED_SOLID 11 +#define IL_DEF_LED_INTRVL cpu_to_le32(1000) + +#define IL_LED_ACTIVITY (0<<1) +#define IL_LED_LINK (1<<1) + +/* + * LED mode + * IL_LED_DEFAULT: use device default + * IL_LED_RF_STATE: turn LED on/off based on RF state + * LED ON = RF ON + * LED OFF = RF OFF + * IL_LED_BLINK: adjust led blink rate based on blink table + */ +enum il_led_mode { + IL_LED_DEFAULT, + IL_LED_RF_STATE, + IL_LED_BLINK, +}; + +void il_leds_init(struct il_priv *il); +void il_leds_exit(struct il_priv *il); + /** * struct il_cfg * @fw_name_pre: Firmware filename prefix. The api version and extension @@ -3005,4 +3303,5 @@ extern void il3945_rate_control_unregister(void); extern int il_power_update_mode(struct il_priv *il, bool force); extern void il_power_initialize(struct il_priv *il); + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h deleted file mode 100644 index 61435a5..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ /dev/null @@ -1,344 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_eeprom_h__ -#define __il_eeprom_h__ - -#include - -struct il_priv; - -/* - * EEPROM access time values: - * - * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG. - * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1). - * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. - * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. - */ -#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ - -#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ -#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ - - -/* - * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. - * - * IBSS and/or AP operation is allowed *only* on those channels with - * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because - * RADAR detection is not supported by the 4965 driver, but is a - * requirement for establishing a new network for legal operation on channels - * requiring RADAR detection or restricting ACTIVE scanning. - * - * NOTE: "WIDE" flag does not indicate anything about "HT40" 40 MHz channels. - * It only indicates that 20 MHz channel use is supported; HT40 channel - * usage is indicated by a separate set of regulatory flags for each - * HT40 channel pair. - * - * NOTE: Using a channel inappropriately will result in a uCode error! - */ -#define IL_NUM_TX_CALIB_GROUPS 5 -enum { - EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ - EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ - /* Bit 2 Reserved */ - EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ - EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ - EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ - /* Bit 6 Reserved (was Narrow Channel) */ - EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ -}; - -/* SKU Capabilities */ -/* 3945 only */ -#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0) -#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1) - -/* *regulatory* channel data format in eeprom, one for each channel. - * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */ -struct il_eeprom_channel { - u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ - s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ -} __packed; - -/* 3945 Specific */ -#define EEPROM_3945_EEPROM_VERSION (0x2f) - -/* 4965 has two radio transmitters (and 3 radio receivers) */ -#define EEPROM_TX_POWER_TX_CHAINS (2) - -/* 4965 has room for up to 8 sets of txpower calibration data */ -#define EEPROM_TX_POWER_BANDS (8) - -/* 4965 factory calibration measures txpower gain settings for - * each of 3 target output levels */ -#define EEPROM_TX_POWER_MEASUREMENTS (3) - -/* 4965 Specific */ -/* 4965 driver does not work with txpower calibration version < 5 */ -#define EEPROM_4965_TX_POWER_VERSION (5) -#define EEPROM_4965_EEPROM_VERSION (0x2f) -#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ -#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ -#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ -#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ - -/* 2.4 GHz */ -extern const u8 il_eeprom_band_1[14]; - -/* - * factory calibration data for one txpower level, on one channel, - * measured on one of the 2 tx chains (radio transmitter and associated - * antenna). EEPROM contains: - * - * 1) Temperature (degrees Celsius) of device when measurement was made. - * - * 2) Gain table idx used to achieve the target measurement power. - * This refers to the "well-known" gain tables (see 4965.h). - * - * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). - * - * 4) RF power amplifier detector level measurement (not used). - */ -struct il_eeprom_calib_measure { - u8 temperature; /* Device temperature (Celsius) */ - u8 gain_idx; /* Index into gain table */ - u8 actual_pow; /* Measured RF output power, half-dBm */ - s8 pa_det; /* Power amp detector level (not used) */ -} __packed; - - -/* - * measurement set for one channel. EEPROM contains: - * - * 1) Channel number measured - * - * 2) Measurements for each of 3 power levels for each of 2 radio transmitters - * (a.k.a. "tx chains") (6 measurements altogether) - */ -struct il_eeprom_calib_ch_info { - u8 ch_num; - struct il_eeprom_calib_measure - measurements[EEPROM_TX_POWER_TX_CHAINS] - [EEPROM_TX_POWER_MEASUREMENTS]; -} __packed; - -/* - * txpower subband info. - * - * For each frequency subband, EEPROM contains the following: - * - * 1) First and last channels within range of the subband. "0" values - * indicate that this sample set is not being used. - * - * 2) Sample measurement sets for 2 channels close to the range endpoints. - */ -struct il_eeprom_calib_subband_info { - u8 ch_from; /* channel number of lowest channel in subband */ - u8 ch_to; /* channel number of highest channel in subband */ - struct il_eeprom_calib_ch_info ch1; - struct il_eeprom_calib_ch_info ch2; -} __packed; - - -/* - * txpower calibration info. EEPROM contains: - * - * 1) Factory-measured saturation power levels (maximum levels at which - * tx power amplifier can output a signal without too much distortion). - * There is one level for 2.4 GHz band and one for 5 GHz band. These - * values apply to all channels within each of the bands. - * - * 2) Factory-measured power supply voltage level. This is assumed to be - * constant (i.e. same value applies to all channels/bands) while the - * factory measurements are being made. - * - * 3) Up to 8 sets of factory-measured txpower calibration values. - * These are for different frequency ranges, since txpower gain - * characteristics of the analog radio circuitry vary with frequency. - * - * Not all sets need to be filled with data; - * struct il_eeprom_calib_subband_info contains range of channels - * (0 if unused) for each set of data. - */ -struct il_eeprom_calib_info { - u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ - u8 saturation_power52; /* half-dBm */ - __le16 voltage; /* signed */ - struct il_eeprom_calib_subband_info - band_info[EEPROM_TX_POWER_BANDS]; -} __packed; - - -/* General */ -#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ -#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ -#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */ -#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */ -#define EEPROM_VERSION (2*0x44) /* 2 bytes */ -#define EEPROM_SKU_CAP (2*0x45) /* 2 bytes */ -#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */ -#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */ -#define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */ -#define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */ - -/* The following masks are to be applied on EEPROM_RADIO_CONFIG */ -#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ -#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ -#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ -#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ -#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ -#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ - -#define EEPROM_3945_RF_CFG_TYPE_MAX 0x0 -#define EEPROM_4965_RF_CFG_TYPE_MAX 0x1 - -/* - * Per-channel regulatory data. - * - * Each channel that *might* be supported by iwl has a fixed location - * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory - * txpower (MSB). - * - * Entries immediately below are for 20 MHz channel width. HT40 (40 MHz) - * channels (only for 4965, not supported by 3945) appear later in the EEPROM. - * - * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 - */ -#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ -#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ - -/* - * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, - * 5.0 GHz channels 7, 8, 11, 12, 16 - * (4915-5080MHz) (none of these is ever supported) - */ -#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */ - -/* - * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 - * (5170-5320MHz) - */ -#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */ - -/* - * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 - * (5500-5700MHz) - */ -#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */ - -/* - * 5.7 GHz channels 145, 149, 153, 157, 161, 165 - * (5725-5825MHz) - */ -#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */ - -/* - * 2.4 GHz HT40 channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11) - * - * The channel listed is the center of the lower 20 MHz half of the channel. - * The overall center frequency is actually 2 channels (10 MHz) above that, - * and the upper half of each HT40 channel is centered 4 channels (20 MHz) away - * from the lower half; e.g. the upper half of HT40 channel 1 is channel 5, - * and the overall HT40 channel width centers on channel 3. - * - * NOTE: The RXON command uses 20 MHz channel numbers to specify the - * control channel to which to tune. RXON also specifies whether the - * control channel is the upper or lower half of a HT40 channel. - * - * NOTE: 4965 does not support HT40 channels on 2.4 GHz. - */ -#define EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS (2*0xA0) /* 14 bytes */ - -/* - * 5.2 GHz HT40 channels 36 (40), 44 (48), 52 (56), 60 (64), - * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161) - */ -#define EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS (2*0xA8) /* 22 bytes */ - -#define EEPROM_REGULATORY_BAND_NO_HT40 (0) - -struct il_eeprom_ops { - const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv *il); - void (*release_semaphore) (struct il_priv *il); -}; - - -int il_eeprom_init(struct il_priv *il); -void il_eeprom_free(struct il_priv *il); -const u8 *il_eeprom_query_addr(const struct il_priv *il, - size_t offset); -u16 il_eeprom_query16(const struct il_priv *il, size_t offset); -int il_init_channel_map(struct il_priv *il); -void il_free_channel_map(struct il_priv *il); -const struct il_channel_info *il_get_channel_info( - const struct il_priv *il, - enum ieee80211_band band, u16 channel); - -#endif /* __il_eeprom_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-led.h b/drivers/net/wireless/iwlegacy/iwl-led.h deleted file mode 100644 index d3aba57..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-led.h +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_leds_h__ -#define __il_leds_h__ - - -struct il_priv; - -#define IL_LED_SOLID 11 -#define IL_DEF_LED_INTRVL cpu_to_le32(1000) - -#define IL_LED_ACTIVITY (0<<1) -#define IL_LED_LINK (1<<1) - -/* - * LED mode - * IL_LED_DEFAULT: use device default - * IL_LED_RF_STATE: turn LED on/off based on RF state - * LED ON = RF ON - * LED OFF = RF OFF - * IL_LED_BLINK: adjust led blink rate based on blink table - */ -enum il_led_mode { - IL_LED_DEFAULT, - IL_LED_RF_STATE, - IL_LED_BLINK, -}; - -void il_leds_init(struct il_priv *il); -void il_leds_exit(struct il_priv *il); - -#endif /* __il_leds_h__ */ -- cgit v0.10.2 From e8c39d4e62a01c21330bcccd7989c9c8deac4271 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:09:39 +0200 Subject: iwlegacy: rename iwl-prph.h to prph.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 5e4fcbc..33233ab 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -35,7 +35,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" -#include "iwl-prph.h" #include "iwl-debug.h" /* Highest firmware API version supported */ diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 8e4450e..8ae4e3f 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -36,7 +36,7 @@ #include "commands.h" #include "csr.h" -#include "iwl-prph.h" +#include "prph.h" #include "iwl-debug.h" struct il_host_cmd; diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h deleted file mode 100644 index 029ea8a..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ /dev/null @@ -1,523 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_prph_h__ -#define __il_prph_h__ - -/* - * Registers in this file are internal, not PCI bus memory mapped. - * Driver accesses these via HBUS_TARG_PRPH_* registers. - */ -#define PRPH_BASE (0x00000) -#define PRPH_END (0xFFFFF) - -/* APMG (power management) constants */ -#define APMG_BASE (PRPH_BASE + 0x3000) -#define APMG_CLK_CTRL_REG (APMG_BASE + 0x0000) -#define APMG_CLK_EN_REG (APMG_BASE + 0x0004) -#define APMG_CLK_DIS_REG (APMG_BASE + 0x0008) -#define APMG_PS_CTRL_REG (APMG_BASE + 0x000c) -#define APMG_PCIDEV_STT_REG (APMG_BASE + 0x0010) -#define APMG_RFKILL_REG (APMG_BASE + 0x0014) -#define APMG_RTC_INT_STT_REG (APMG_BASE + 0x001c) -#define APMG_RTC_INT_MSK_REG (APMG_BASE + 0x0020) -#define APMG_DIGITAL_SVR_REG (APMG_BASE + 0x0058) -#define APMG_ANALOG_SVR_REG (APMG_BASE + 0x006C) - -#define APMS_CLK_VAL_MRB_FUNC_MODE (0x00000001) -#define APMG_CLK_VAL_DMA_CLK_RQT (0x00000200) -#define APMG_CLK_VAL_BSM_CLK_RQT (0x00000800) - -#define APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS (0x00400000) -#define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000) -#define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000) -#define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) -#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ -#define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) -#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ -#define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) - -#define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) - -/** - * BSM (Bootstrap State Machine) - * - * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program - * in special SRAM that does not power down when the embedded control - * processor is sleeping (e.g. for periodic power-saving shutdowns of radio). - * - * When powering back up after sleeps (or during initial uCode load), the BSM - * internally loads the short bootstrap program from the special SRAM into the - * embedded processor's instruction SRAM, and starts the processor so it runs - * the bootstrap program. - * - * This bootstrap program loads (via PCI busmaster DMA) instructions and data - * images for a uCode program from host DRAM locations. The host driver - * indicates DRAM locations and sizes for instruction and data images via the - * four BSM_DRAM_* registers. Once the bootstrap program loads the new program, - * the new program starts automatically. - * - * The uCode used for open-source drivers includes two programs: - * - * 1) Initialization -- performs hardware calibration and sets up some - * internal data, then notifies host via "initialize alive" notification - * (struct il_init_alive_resp) that it has completed all of its work. - * After signal from host, it then loads and starts the runtime program. - * The initialization program must be used when initially setting up the - * NIC after loading the driver. - * - * 2) Runtime/Protocol -- performs all normal runtime operations. This - * notifies host via "alive" notification (struct il_alive_resp) that it - * is ready to be used. - * - * When initializing the NIC, the host driver does the following procedure: - * - * 1) Load bootstrap program (instructions only, no data image for bootstrap) - * into bootstrap memory. Use dword writes starting at BSM_SRAM_LOWER_BOUND - * - * 2) Point (via BSM_DRAM_*) to the "initialize" uCode data and instruction - * images in host DRAM. - * - * 3) Set up BSM to copy from BSM SRAM into uCode instruction SRAM when asked: - * BSM_WR_MEM_SRC_REG = 0 - * BSM_WR_MEM_DST_REG = RTC_INST_LOWER_BOUND - * BSM_WR_MEM_DWCOUNT_REG = # dwords in bootstrap instruction image - * - * 4) Load bootstrap into instruction SRAM: - * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START - * - * 5) Wait for load completion: - * Poll BSM_WR_CTRL_REG for BSM_WR_CTRL_REG_BIT_START = 0 - * - * 6) Enable future boot loads whenever NIC's power management triggers it: - * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START_EN - * - * 7) Start the NIC by removing all reset bits: - * CSR_RESET = 0 - * - * The bootstrap uCode (already in instruction SRAM) loads initialization - * uCode. Initialization uCode performs data initialization, sends - * "initialize alive" notification to host, and waits for a signal from - * host to load runtime code. - * - * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction - * images in host DRAM. The last register loaded must be the instruction - * byte count register ("1" in MSbit tells initialization uCode to load - * the runtime uCode): - * BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD - * - * 5) Wait for "alive" notification, then issue normal runtime commands. - * - * Data caching during power-downs: - * - * Just before the embedded controller powers down (e.g for automatic - * power-saving modes, or for RFKILL), uCode stores (via PCI busmaster DMA) - * a current snapshot of the embedded processor's data SRAM into host DRAM. - * This caches the data while the embedded processor's memory is powered down. - * Location and size are controlled by BSM_DRAM_DATA_* registers. - * - * NOTE: Instruction SRAM does not need to be saved, since that doesn't - * change during operation; the original image (from uCode distribution - * file) can be used for reload. - * - * When powering back up, the BSM loads the bootstrap program. Bootstrap looks - * at the BSM_DRAM_* registers, which now point to the runtime instruction - * image and the cached (modified) runtime data (*not* the initialization - * uCode). Bootstrap reloads these runtime images into SRAM, and restarts the - * uCode from where it left off before the power-down. - * - * NOTE: Initialization uCode does *not* run as part of the save/restore - * procedure. - * - * This save/restore method is mostly for autonomous power management during - * normal operation (result of C_POWER_TBL). Platform suspend/resume and - * RFKILL should use complete restarts (with total re-initialization) of uCode, - * allowing total shutdown (including BSM memory). - * - * Note that, during normal operation, the host DRAM that held the initial - * startup data for the runtime code is now being used as a backup data cache - * for modified data! If you need to completely re-initialize the NIC, make - * sure that you use the runtime data image from the uCode distribution file, - * not the modified/saved runtime data. You may want to store a separate - * "clean" runtime data image in DRAM to avoid disk reads of distribution file. - */ - -/* BSM bit fields */ -#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ -#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup*/ -#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ - -/* BSM addresses */ -#define BSM_BASE (PRPH_BASE + 0x3400) -#define BSM_END (PRPH_BASE + 0x3800) - -#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ -#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ -#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ -#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ -#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ - -/* - * Pointers and size regs for bootstrap load and data SRAM save/restore. - * NOTE: 3945 pointers use bits 31:0 of DRAM address. - * 4965 pointers use bits 35:4 of DRAM address. - */ -#define BSM_DRAM_INST_PTR_REG (BSM_BASE + 0x090) -#define BSM_DRAM_INST_BYTECOUNT_REG (BSM_BASE + 0x094) -#define BSM_DRAM_DATA_PTR_REG (BSM_BASE + 0x098) -#define BSM_DRAM_DATA_BYTECOUNT_REG (BSM_BASE + 0x09C) - -/* - * BSM special memory, stays powered on during power-save sleeps. - * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1) - */ -#define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800) -#define BSM_SRAM_SIZE (1024) /* bytes */ - - -/* 3945 Tx scheduler registers */ -#define ALM_SCD_BASE (PRPH_BASE + 0x2E00) -#define ALM_SCD_MODE_REG (ALM_SCD_BASE + 0x000) -#define ALM_SCD_ARASTAT_REG (ALM_SCD_BASE + 0x004) -#define ALM_SCD_TXFACT_REG (ALM_SCD_BASE + 0x010) -#define ALM_SCD_TXF4MF_REG (ALM_SCD_BASE + 0x014) -#define ALM_SCD_TXF5MF_REG (ALM_SCD_BASE + 0x020) -#define ALM_SCD_SBYP_MODE_1_REG (ALM_SCD_BASE + 0x02C) -#define ALM_SCD_SBYP_MODE_2_REG (ALM_SCD_BASE + 0x030) - -/** - * Tx Scheduler - * - * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs - * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in - * host DRAM. It steers each frame's Tx command (which contains the frame - * data) into one of up to 7 prioritized Tx DMA FIFO channels within the - * device. A queue maps to only one (selectable by driver) Tx DMA channel, - * but one DMA channel may take input from several queues. - * - * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows - * (cf. default_queue_to_tx_fifo in 4965.c): - * - * 0 -- EDCA BK (background) frames, lowest priority - * 1 -- EDCA BE (best effort) frames, normal priority - * 2 -- EDCA VI (video) frames, higher priority - * 3 -- EDCA VO (voice) and management frames, highest priority - * 4 -- Commands (e.g. RXON, etc.) - * 5 -- unused (HCCA) - * 6 -- unused (HCCA) - * 7 -- not used by driver (device-internal only) - * - * - * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6. - * In addition, driver can map the remaining queues to Tx DMA/FIFO - * channels 0-3 to support 11n aggregation via EDCA DMA channels. - * - * The driver sets up each queue to work in one of two modes: - * - * 1) Scheduler-Ack, in which the scheduler automatically supports a - * block-ack (BA) win of up to 64 TFDs. In this mode, each queue - * contains TFDs for a unique combination of Recipient Address (RA) - * and Traffic Identifier (TID), that is, traffic of a given - * Quality-Of-Service (QOS) priority, destined for a single station. - * - * In scheduler-ack mode, the scheduler keeps track of the Tx status of - * each frame within the BA win, including whether it's been transmitted, - * and whether it's been acknowledged by the receiving station. The device - * automatically processes block-acks received from the receiving STA, - * and reschedules un-acked frames to be retransmitted (successful - * Tx completion may end up being out-of-order). - * - * The driver must maintain the queue's Byte Count table in host DRAM - * (struct il4965_sched_queue_byte_cnt_tbl) for this mode. - * This mode does not support fragmentation. - * - * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. - * The device may automatically retry Tx, but will retry only one frame - * at a time, until receiving ACK from receiving station, or reaching - * retry limit and giving up. - * - * The command queue (#4/#9) must use this mode! - * This mode does not require use of the Byte Count table in host DRAM. - * - * Driver controls scheduler operation via 3 means: - * 1) Scheduler registers - * 2) Shared scheduler data base in internal 4956 SRAM - * 3) Shared data in host DRAM - * - * Initialization: - * - * When loading, driver should allocate memory for: - * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs. - * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory - * (1024 bytes for each queue). - * - * After receiving "Alive" response from uCode, driver must initialize - * the scheduler (especially for queue #4/#9, the command queue, otherwise - * the driver can't issue commands!): - */ - -/** - * Max Tx win size is the max number of contiguous TFDs that the scheduler - * can keep track of at one time when creating block-ack chains of frames. - * Note that "64" matches the number of ack bits in a block-ack packet. - * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize - * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. - */ -#define SCD_WIN_SIZE 64 -#define SCD_FRAME_LIMIT 64 - -/* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ -#define IL49_SCD_START_OFFSET 0xa02c00 - -/* - * 4965 tells driver SRAM address for internal scheduler structs via this reg. - * Value is valid only after "Alive" response from uCode. - */ -#define IL49_SCD_SRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x0) - -/* - * Driver may need to update queue-empty bits after changing queue's - * write and read pointers (idxes) during (re-)initialization (i.e. when - * scheduler is not tracking what's happening). - * Bit fields: - * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit - * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty - * NOTE: This register is not used by Linux driver. - */ -#define IL49_SCD_EMPTY_BITS (IL49_SCD_START_OFFSET + 0x4) - -/* - * Physical base address of array of byte count (BC) circular buffers (CBs). - * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode. - * This register points to BC CB for queue 0, must be on 1024-byte boundary. - * Others are spaced by 1024 bytes. - * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. - * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff). - * Bit fields: - * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. - */ -#define IL49_SCD_DRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x10) - -/* - * Enables any/all Tx DMA/FIFO channels. - * Scheduler generates requests for only the active channels. - * Set this to 0xff to enable all 8 channels (normal usage). - * Bit fields: - * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 - */ -#define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) -/* - * Queue (x) Write Pointers (idxes, really!), one for each Tx queue. - * Initialized and updated by driver as new TFDs are added to queue. - * NOTE: If using Block Ack, idx must correspond to frame's - * Start Sequence Number; idx = (SSN & 0xff) - * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? - */ -#define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) - -/* - * Queue (x) Read Pointers (idxes, really!), one for each Tx queue. - * For FIFO mode, idx indicates next frame to transmit. - * For Scheduler-ACK mode, idx indicates first frame in Tx win. - * Initialized by driver, updated by scheduler. - */ -#define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) - -/* - * Select which queues work in chain mode (1) vs. not (0). - * Use chain mode to build chains of aggregated frames. - * Bit fields: - * 31-16: Reserved - * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time - * NOTE: If driver sets up queue for chain mode, it should be also set up - * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). - */ -#define IL49_SCD_QUEUECHAIN_SEL (IL49_SCD_START_OFFSET + 0xd0) - -/* - * Select which queues interrupt driver when scheduler increments - * a queue's read pointer (idx). - * Bit fields: - * 31-16: Reserved - * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled - * NOTE: This functionality is apparently a no-op; driver relies on interrupts - * from Rx queue to read Tx command responses and update Tx queues. - */ -#define IL49_SCD_INTERRUPT_MASK (IL49_SCD_START_OFFSET + 0xe4) - -/* - * Queue search status registers. One for each queue. - * Sets up queue mode and assigns queue to Tx DMA channel. - * Bit fields: - * 19-10: Write mask/enable bits for bits 0-9 - * 9: Driver should init to "0" - * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0). - * Driver should init to "1" for aggregation mode, or "0" otherwise. - * 7-6: Driver should init to "0" - * 5: Window Size Left; indicates whether scheduler can request - * another TFD, based on win size, etc. Driver should init - * this bit to "1" for aggregation mode, or "0" for non-agg. - * 4-1: Tx FIFO to use (range 0-7). - * 0: Queue is active (1), not active (0). - * Other bits should be written as "0" - * - * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled - * via SCD_QUEUECHAIN_SEL. - */ -#define IL49_SCD_QUEUE_STATUS_BITS(x)\ - (IL49_SCD_START_OFFSET + 0x104 + (x) * 4) - -/* Bit field positions */ -#define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) -#define IL49_SCD_QUEUE_STTS_REG_POS_TXF (1) -#define IL49_SCD_QUEUE_STTS_REG_POS_WSL (5) -#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) - -/* Write masks */ -#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) -#define IL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) - -/** - * 4965 internal SRAM structures for scheduler, shared with driver ... - * - * Driver should clear and initialize the following areas after receiving - * "Alive" response from 4965 uCode, i.e. after initial - * uCode load, or after a uCode load done for error recovery: - * - * SCD_CONTEXT_DATA_OFFSET (size 128 bytes) - * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes) - * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes) - * - * Driver accesses SRAM via HBUS_TARG_MEM_* registers. - * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR. - * All OFFSET values must be added to this base address. - */ - -/* - * Queue context. One 8-byte entry for each of 16 queues. - * - * Driver should clear this entire area (size 0x80) to 0 after receiving - * "Alive" notification from uCode. Additionally, driver should init - * each queue's entry as follows: - * - * LS Dword bit fields: - * 0-06: Max Tx win size for Scheduler-ACK. Driver should init to 64. - * - * MS Dword bit fields: - * 16-22: Frame limit. Driver should init to 10 (0xa). - * - * Driver should init all other bits to 0. - * - * Init must be done after driver receives "Alive" response from 4965 uCode, - * and when setting up queue for aggregation. - */ -#define IL49_SCD_CONTEXT_DATA_OFFSET 0x380 -#define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ - (IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) - -#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) -#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) -#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) -#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) - -/* - * Tx Status Bitmap - * - * Driver should clear this entire area (size 0x100) to 0 after receiving - * "Alive" notification from uCode. Area is used only by device itself; - * no other support (besides clearing) is required from driver. - */ -#define IL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 - -/* - * RAxTID to queue translation mapping. - * - * When queue is in Scheduler-ACK mode, frames placed in a that queue must be - * for only one combination of receiver address (RA) and traffic ID (TID), i.e. - * one QOS priority level destined for one station (for this wireless link, - * not final destination). The SCD_TRANSLATE_TBL area provides 16 16-bit - * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK - * mode, the device ignores the mapping value. - * - * Bit fields, for each 16-bit map: - * 15-9: Reserved, set to 0 - * 8-4: Index into device's station table for recipient station - * 3-0: Traffic ID (tid), range 0-15 - * - * Driver should clear this entire area (size 32 bytes) to 0 after receiving - * "Alive" notification from uCode. To update a 16-bit map value, driver - * must read a dword-aligned value from device SRAM, replace the 16-bit map - * value of interest, and write the dword value back into device SRAM. - */ -#define IL49_SCD_TRANSLATE_TBL_OFFSET 0x500 - -/* Find translation table dword to read/write for given queue */ -#define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ - ((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) - -#define IL_SCD_TXFIFO_POS_TID (0) -#define IL_SCD_TXFIFO_POS_RA (4) -#define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) - -/*********************** END TX SCHEDULER *************************************/ - -#endif /* __il_prph_h__ */ diff --git a/drivers/net/wireless/iwlegacy/prph.h b/drivers/net/wireless/iwlegacy/prph.h new file mode 100644 index 0000000..029ea8a --- /dev/null +++ b/drivers/net/wireless/iwlegacy/prph.h @@ -0,0 +1,523 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef __il_prph_h__ +#define __il_prph_h__ + +/* + * Registers in this file are internal, not PCI bus memory mapped. + * Driver accesses these via HBUS_TARG_PRPH_* registers. + */ +#define PRPH_BASE (0x00000) +#define PRPH_END (0xFFFFF) + +/* APMG (power management) constants */ +#define APMG_BASE (PRPH_BASE + 0x3000) +#define APMG_CLK_CTRL_REG (APMG_BASE + 0x0000) +#define APMG_CLK_EN_REG (APMG_BASE + 0x0004) +#define APMG_CLK_DIS_REG (APMG_BASE + 0x0008) +#define APMG_PS_CTRL_REG (APMG_BASE + 0x000c) +#define APMG_PCIDEV_STT_REG (APMG_BASE + 0x0010) +#define APMG_RFKILL_REG (APMG_BASE + 0x0014) +#define APMG_RTC_INT_STT_REG (APMG_BASE + 0x001c) +#define APMG_RTC_INT_MSK_REG (APMG_BASE + 0x0020) +#define APMG_DIGITAL_SVR_REG (APMG_BASE + 0x0058) +#define APMG_ANALOG_SVR_REG (APMG_BASE + 0x006C) + +#define APMS_CLK_VAL_MRB_FUNC_MODE (0x00000001) +#define APMG_CLK_VAL_DMA_CLK_RQT (0x00000200) +#define APMG_CLK_VAL_BSM_CLK_RQT (0x00000800) + +#define APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS (0x00400000) +#define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000) +#define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000) +#define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) +#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ +#define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) +#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ +#define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) + +#define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) + +/** + * BSM (Bootstrap State Machine) + * + * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program + * in special SRAM that does not power down when the embedded control + * processor is sleeping (e.g. for periodic power-saving shutdowns of radio). + * + * When powering back up after sleeps (or during initial uCode load), the BSM + * internally loads the short bootstrap program from the special SRAM into the + * embedded processor's instruction SRAM, and starts the processor so it runs + * the bootstrap program. + * + * This bootstrap program loads (via PCI busmaster DMA) instructions and data + * images for a uCode program from host DRAM locations. The host driver + * indicates DRAM locations and sizes for instruction and data images via the + * four BSM_DRAM_* registers. Once the bootstrap program loads the new program, + * the new program starts automatically. + * + * The uCode used for open-source drivers includes two programs: + * + * 1) Initialization -- performs hardware calibration and sets up some + * internal data, then notifies host via "initialize alive" notification + * (struct il_init_alive_resp) that it has completed all of its work. + * After signal from host, it then loads and starts the runtime program. + * The initialization program must be used when initially setting up the + * NIC after loading the driver. + * + * 2) Runtime/Protocol -- performs all normal runtime operations. This + * notifies host via "alive" notification (struct il_alive_resp) that it + * is ready to be used. + * + * When initializing the NIC, the host driver does the following procedure: + * + * 1) Load bootstrap program (instructions only, no data image for bootstrap) + * into bootstrap memory. Use dword writes starting at BSM_SRAM_LOWER_BOUND + * + * 2) Point (via BSM_DRAM_*) to the "initialize" uCode data and instruction + * images in host DRAM. + * + * 3) Set up BSM to copy from BSM SRAM into uCode instruction SRAM when asked: + * BSM_WR_MEM_SRC_REG = 0 + * BSM_WR_MEM_DST_REG = RTC_INST_LOWER_BOUND + * BSM_WR_MEM_DWCOUNT_REG = # dwords in bootstrap instruction image + * + * 4) Load bootstrap into instruction SRAM: + * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START + * + * 5) Wait for load completion: + * Poll BSM_WR_CTRL_REG for BSM_WR_CTRL_REG_BIT_START = 0 + * + * 6) Enable future boot loads whenever NIC's power management triggers it: + * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START_EN + * + * 7) Start the NIC by removing all reset bits: + * CSR_RESET = 0 + * + * The bootstrap uCode (already in instruction SRAM) loads initialization + * uCode. Initialization uCode performs data initialization, sends + * "initialize alive" notification to host, and waits for a signal from + * host to load runtime code. + * + * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction + * images in host DRAM. The last register loaded must be the instruction + * byte count register ("1" in MSbit tells initialization uCode to load + * the runtime uCode): + * BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD + * + * 5) Wait for "alive" notification, then issue normal runtime commands. + * + * Data caching during power-downs: + * + * Just before the embedded controller powers down (e.g for automatic + * power-saving modes, or for RFKILL), uCode stores (via PCI busmaster DMA) + * a current snapshot of the embedded processor's data SRAM into host DRAM. + * This caches the data while the embedded processor's memory is powered down. + * Location and size are controlled by BSM_DRAM_DATA_* registers. + * + * NOTE: Instruction SRAM does not need to be saved, since that doesn't + * change during operation; the original image (from uCode distribution + * file) can be used for reload. + * + * When powering back up, the BSM loads the bootstrap program. Bootstrap looks + * at the BSM_DRAM_* registers, which now point to the runtime instruction + * image and the cached (modified) runtime data (*not* the initialization + * uCode). Bootstrap reloads these runtime images into SRAM, and restarts the + * uCode from where it left off before the power-down. + * + * NOTE: Initialization uCode does *not* run as part of the save/restore + * procedure. + * + * This save/restore method is mostly for autonomous power management during + * normal operation (result of C_POWER_TBL). Platform suspend/resume and + * RFKILL should use complete restarts (with total re-initialization) of uCode, + * allowing total shutdown (including BSM memory). + * + * Note that, during normal operation, the host DRAM that held the initial + * startup data for the runtime code is now being used as a backup data cache + * for modified data! If you need to completely re-initialize the NIC, make + * sure that you use the runtime data image from the uCode distribution file, + * not the modified/saved runtime data. You may want to store a separate + * "clean" runtime data image in DRAM to avoid disk reads of distribution file. + */ + +/* BSM bit fields */ +#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ +#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup*/ +#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ + +/* BSM addresses */ +#define BSM_BASE (PRPH_BASE + 0x3400) +#define BSM_END (PRPH_BASE + 0x3800) + +#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ +#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ +#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ +#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ +#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ + +/* + * Pointers and size regs for bootstrap load and data SRAM save/restore. + * NOTE: 3945 pointers use bits 31:0 of DRAM address. + * 4965 pointers use bits 35:4 of DRAM address. + */ +#define BSM_DRAM_INST_PTR_REG (BSM_BASE + 0x090) +#define BSM_DRAM_INST_BYTECOUNT_REG (BSM_BASE + 0x094) +#define BSM_DRAM_DATA_PTR_REG (BSM_BASE + 0x098) +#define BSM_DRAM_DATA_BYTECOUNT_REG (BSM_BASE + 0x09C) + +/* + * BSM special memory, stays powered on during power-save sleeps. + * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1) + */ +#define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800) +#define BSM_SRAM_SIZE (1024) /* bytes */ + + +/* 3945 Tx scheduler registers */ +#define ALM_SCD_BASE (PRPH_BASE + 0x2E00) +#define ALM_SCD_MODE_REG (ALM_SCD_BASE + 0x000) +#define ALM_SCD_ARASTAT_REG (ALM_SCD_BASE + 0x004) +#define ALM_SCD_TXFACT_REG (ALM_SCD_BASE + 0x010) +#define ALM_SCD_TXF4MF_REG (ALM_SCD_BASE + 0x014) +#define ALM_SCD_TXF5MF_REG (ALM_SCD_BASE + 0x020) +#define ALM_SCD_SBYP_MODE_1_REG (ALM_SCD_BASE + 0x02C) +#define ALM_SCD_SBYP_MODE_2_REG (ALM_SCD_BASE + 0x030) + +/** + * Tx Scheduler + * + * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs + * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in + * host DRAM. It steers each frame's Tx command (which contains the frame + * data) into one of up to 7 prioritized Tx DMA FIFO channels within the + * device. A queue maps to only one (selectable by driver) Tx DMA channel, + * but one DMA channel may take input from several queues. + * + * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows + * (cf. default_queue_to_tx_fifo in 4965.c): + * + * 0 -- EDCA BK (background) frames, lowest priority + * 1 -- EDCA BE (best effort) frames, normal priority + * 2 -- EDCA VI (video) frames, higher priority + * 3 -- EDCA VO (voice) and management frames, highest priority + * 4 -- Commands (e.g. RXON, etc.) + * 5 -- unused (HCCA) + * 6 -- unused (HCCA) + * 7 -- not used by driver (device-internal only) + * + * + * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6. + * In addition, driver can map the remaining queues to Tx DMA/FIFO + * channels 0-3 to support 11n aggregation via EDCA DMA channels. + * + * The driver sets up each queue to work in one of two modes: + * + * 1) Scheduler-Ack, in which the scheduler automatically supports a + * block-ack (BA) win of up to 64 TFDs. In this mode, each queue + * contains TFDs for a unique combination of Recipient Address (RA) + * and Traffic Identifier (TID), that is, traffic of a given + * Quality-Of-Service (QOS) priority, destined for a single station. + * + * In scheduler-ack mode, the scheduler keeps track of the Tx status of + * each frame within the BA win, including whether it's been transmitted, + * and whether it's been acknowledged by the receiving station. The device + * automatically processes block-acks received from the receiving STA, + * and reschedules un-acked frames to be retransmitted (successful + * Tx completion may end up being out-of-order). + * + * The driver must maintain the queue's Byte Count table in host DRAM + * (struct il4965_sched_queue_byte_cnt_tbl) for this mode. + * This mode does not support fragmentation. + * + * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. + * The device may automatically retry Tx, but will retry only one frame + * at a time, until receiving ACK from receiving station, or reaching + * retry limit and giving up. + * + * The command queue (#4/#9) must use this mode! + * This mode does not require use of the Byte Count table in host DRAM. + * + * Driver controls scheduler operation via 3 means: + * 1) Scheduler registers + * 2) Shared scheduler data base in internal 4956 SRAM + * 3) Shared data in host DRAM + * + * Initialization: + * + * When loading, driver should allocate memory for: + * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs. + * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory + * (1024 bytes for each queue). + * + * After receiving "Alive" response from uCode, driver must initialize + * the scheduler (especially for queue #4/#9, the command queue, otherwise + * the driver can't issue commands!): + */ + +/** + * Max Tx win size is the max number of contiguous TFDs that the scheduler + * can keep track of at one time when creating block-ack chains of frames. + * Note that "64" matches the number of ack bits in a block-ack packet. + * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize + * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. + */ +#define SCD_WIN_SIZE 64 +#define SCD_FRAME_LIMIT 64 + +/* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ +#define IL49_SCD_START_OFFSET 0xa02c00 + +/* + * 4965 tells driver SRAM address for internal scheduler structs via this reg. + * Value is valid only after "Alive" response from uCode. + */ +#define IL49_SCD_SRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x0) + +/* + * Driver may need to update queue-empty bits after changing queue's + * write and read pointers (idxes) during (re-)initialization (i.e. when + * scheduler is not tracking what's happening). + * Bit fields: + * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit + * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty + * NOTE: This register is not used by Linux driver. + */ +#define IL49_SCD_EMPTY_BITS (IL49_SCD_START_OFFSET + 0x4) + +/* + * Physical base address of array of byte count (BC) circular buffers (CBs). + * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode. + * This register points to BC CB for queue 0, must be on 1024-byte boundary. + * Others are spaced by 1024 bytes. + * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. + * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff). + * Bit fields: + * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. + */ +#define IL49_SCD_DRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x10) + +/* + * Enables any/all Tx DMA/FIFO channels. + * Scheduler generates requests for only the active channels. + * Set this to 0xff to enable all 8 channels (normal usage). + * Bit fields: + * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 + */ +#define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) +/* + * Queue (x) Write Pointers (idxes, really!), one for each Tx queue. + * Initialized and updated by driver as new TFDs are added to queue. + * NOTE: If using Block Ack, idx must correspond to frame's + * Start Sequence Number; idx = (SSN & 0xff) + * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? + */ +#define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) + +/* + * Queue (x) Read Pointers (idxes, really!), one for each Tx queue. + * For FIFO mode, idx indicates next frame to transmit. + * For Scheduler-ACK mode, idx indicates first frame in Tx win. + * Initialized by driver, updated by scheduler. + */ +#define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) + +/* + * Select which queues work in chain mode (1) vs. not (0). + * Use chain mode to build chains of aggregated frames. + * Bit fields: + * 31-16: Reserved + * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time + * NOTE: If driver sets up queue for chain mode, it should be also set up + * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). + */ +#define IL49_SCD_QUEUECHAIN_SEL (IL49_SCD_START_OFFSET + 0xd0) + +/* + * Select which queues interrupt driver when scheduler increments + * a queue's read pointer (idx). + * Bit fields: + * 31-16: Reserved + * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled + * NOTE: This functionality is apparently a no-op; driver relies on interrupts + * from Rx queue to read Tx command responses and update Tx queues. + */ +#define IL49_SCD_INTERRUPT_MASK (IL49_SCD_START_OFFSET + 0xe4) + +/* + * Queue search status registers. One for each queue. + * Sets up queue mode and assigns queue to Tx DMA channel. + * Bit fields: + * 19-10: Write mask/enable bits for bits 0-9 + * 9: Driver should init to "0" + * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0). + * Driver should init to "1" for aggregation mode, or "0" otherwise. + * 7-6: Driver should init to "0" + * 5: Window Size Left; indicates whether scheduler can request + * another TFD, based on win size, etc. Driver should init + * this bit to "1" for aggregation mode, or "0" for non-agg. + * 4-1: Tx FIFO to use (range 0-7). + * 0: Queue is active (1), not active (0). + * Other bits should be written as "0" + * + * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled + * via SCD_QUEUECHAIN_SEL. + */ +#define IL49_SCD_QUEUE_STATUS_BITS(x)\ + (IL49_SCD_START_OFFSET + 0x104 + (x) * 4) + +/* Bit field positions */ +#define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) +#define IL49_SCD_QUEUE_STTS_REG_POS_TXF (1) +#define IL49_SCD_QUEUE_STTS_REG_POS_WSL (5) +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) + +/* Write masks */ +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) +#define IL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) + +/** + * 4965 internal SRAM structures for scheduler, shared with driver ... + * + * Driver should clear and initialize the following areas after receiving + * "Alive" response from 4965 uCode, i.e. after initial + * uCode load, or after a uCode load done for error recovery: + * + * SCD_CONTEXT_DATA_OFFSET (size 128 bytes) + * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes) + * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes) + * + * Driver accesses SRAM via HBUS_TARG_MEM_* registers. + * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR. + * All OFFSET values must be added to this base address. + */ + +/* + * Queue context. One 8-byte entry for each of 16 queues. + * + * Driver should clear this entire area (size 0x80) to 0 after receiving + * "Alive" notification from uCode. Additionally, driver should init + * each queue's entry as follows: + * + * LS Dword bit fields: + * 0-06: Max Tx win size for Scheduler-ACK. Driver should init to 64. + * + * MS Dword bit fields: + * 16-22: Frame limit. Driver should init to 10 (0xa). + * + * Driver should init all other bits to 0. + * + * Init must be done after driver receives "Alive" response from 4965 uCode, + * and when setting up queue for aggregation. + */ +#define IL49_SCD_CONTEXT_DATA_OFFSET 0x380 +#define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ + (IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) + +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) + +/* + * Tx Status Bitmap + * + * Driver should clear this entire area (size 0x100) to 0 after receiving + * "Alive" notification from uCode. Area is used only by device itself; + * no other support (besides clearing) is required from driver. + */ +#define IL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 + +/* + * RAxTID to queue translation mapping. + * + * When queue is in Scheduler-ACK mode, frames placed in a that queue must be + * for only one combination of receiver address (RA) and traffic ID (TID), i.e. + * one QOS priority level destined for one station (for this wireless link, + * not final destination). The SCD_TRANSLATE_TBL area provides 16 16-bit + * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK + * mode, the device ignores the mapping value. + * + * Bit fields, for each 16-bit map: + * 15-9: Reserved, set to 0 + * 8-4: Index into device's station table for recipient station + * 3-0: Traffic ID (tid), range 0-15 + * + * Driver should clear this entire area (size 32 bytes) to 0 after receiving + * "Alive" notification from uCode. To update a 16-bit map value, driver + * must read a dword-aligned value from device SRAM, replace the 16-bit map + * value of interest, and write the dword value back into device SRAM. + */ +#define IL49_SCD_TRANSLATE_TBL_OFFSET 0x500 + +/* Find translation table dword to read/write for given queue */ +#define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ + ((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) + +#define IL_SCD_TXFIFO_POS_TID (0) +#define IL_SCD_TXFIFO_POS_RA (4) +#define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) + +/*********************** END TX SCHEDULER *************************************/ + +#endif /* __il_prph_h__ */ -- cgit v0.10.2 From 53143a1809db521ff34371f066bfd8f1619ec2c9 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:14:18 +0200 Subject: iwlegacy: use FH39_ prefix in 3945 code Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 3c89999..ffd6ddf 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -1528,7 +1528,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (inta & ~il->inta_mask) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with inta_fh = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 33233ab..ed367bb 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -481,8 +481,8 @@ static inline int il3945_hw_valid_rtc_data_addr(u32 addr) addr < IL39_RTC_DATA_UPPER_BOUND); } -/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE - * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ +/* Base physical address of il3945_shared is provided to FH39_TSSR_CBB_BASE + * and &il3945_shared.rx_read_ptr[0] is provided to FH39_RCSR_RPTR_ADDR(0) */ struct il3945_shared { __le32 tx_base_ptr[8]; } __packed; -- cgit v0.10.2 From 9a95b37015de03aa82bf340b3ee8e97af11be910 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:20:23 +0200 Subject: iwlegacy: use FH49_ prefix in 4965 code Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 82b6a7b..9e3f74c 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -138,22 +138,22 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) u32 rb_timeout = 0; if (il->cfg->mod_params->amsdu_size_8K) - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; + rb_size = FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; else - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; + rb_size = FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write idx */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_wr(il, FH49_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_wr(il, FH49_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_wr(il, FH49_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -162,13 +162,13 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | - FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | + il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, + FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | rb_size| - (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| - (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + (rb_timeout << FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| + (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); @@ -443,9 +443,9 @@ int il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, - FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_bit(il, FH49_MEM_RSSR_RX_STATUS_REG, + FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; } @@ -1180,15 +1180,15 @@ u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) static const char *il4965_get_fh_string(int cmd) { switch (cmd) { - IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); - IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); - IL_CMD(FH_RSCSR_CHNL0_WPTR); - IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); - IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); - IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); - IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IL_CMD(FH_TSSR_TX_STATUS_REG); - IL_CMD(FH_TSSR_TX_ERROR_REG); + IL_CMD(FH49_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH49_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH49_RSCSR_CHNL0_WPTR); + IL_CMD(FH49_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH49_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH49_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH49_TSSR_TX_STATUS_REG); + IL_CMD(FH49_TSSR_TX_ERROR_REG); default: return "UNKNOWN"; } @@ -1202,15 +1202,15 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) size_t bufsz = 0; #endif static const u32 fh_tbl[] = { - FH_RSCSR_CHNL0_STTS_WPTR_REG, - FH_RSCSR_CHNL0_RBDCB_BASE_REG, - FH_RSCSR_CHNL0_WPTR, - FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_MEM_RSSR_SHARED_CTRL_REG, - FH_MEM_RSSR_RX_STATUS_REG, - FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, - FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_ERROR_REG + FH49_RSCSR_CHNL0_STTS_WPTR_REG, + FH49_RSCSR_CHNL0_RBDCB_BASE_REG, + FH49_RSCSR_CHNL0_WPTR, + FH49_MEM_RCSR_CHNL0_CONFIG_REG, + FH49_MEM_RSSR_SHARED_CTRL_REG, + FH49_MEM_RSSR_RX_STATUS_REG, + FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, + FH49_TSSR_TX_STATUS_REG, + FH49_TSSR_TX_ERROR_REG }; #ifdef CONFIG_IWLEGACY_DEBUG if (display) { @@ -2010,7 +2010,7 @@ int il4965_txq_ctx_alloc(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -2049,7 +2049,7 @@ void il4965_txq_ctx_reset(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -2078,14 +2078,14 @@ void il4965_txq_ctx_stop(struct il_priv *il) /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), + FH49_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); + if (il_poll_bit(il, FH49_TSSR_TX_STATUS_REG, + FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, il_rd(il, - FH_TSSR_TX_STATUS_REG)); + FH49_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); @@ -3743,7 +3743,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), + il_wr(il, FH49_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -4262,7 +4262,7 @@ static void il4965_irq_tasklet(struct il_priv *il) if (inta & ~(il->inta_mask)) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with FH49_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ @@ -4798,7 +4798,7 @@ static const char * const desc_lookup_text[] = { "HW_ERROR_TEMPERATURE", "ILLEGAL_CHAN_FREQ", "VCC_NOT_STBL", - "FH_ERROR", + "FH49_ERROR", "NMI_INTERRUPT_HOST", "NMI_INTERRUPT_ACTION_PT", "NMI_INTERRUPT_UNKNOWN", @@ -4969,14 +4969,14 @@ static int il4965_alive_notify(struct il_priv *il) /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(chan), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); + FH49_TCSR_CHNL_TX_CONFIG_REG(chan), + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); - il_wr(il, FH_TX_CHICKEN_BITS_REG, - reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); + reg_val = il_rd(il, FH49_TX_CHICKEN_BITS_REG); + il_wr(il, FH49_TX_CHICKEN_BITS_REG, + reg_val | FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 4b97717..cbbb2c0 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -630,7 +630,7 @@ static int il4965_hw_set_hw_params(struct il_priv *il) il->hw_params.max_bsm_size = BSM_SRAM_SIZE; il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); - il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; + il->hw_params.rx_wrt_ptr_reg = FH49_RSCSR_CHNL0_WPTR; il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 8ae4e3f..be057aa 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -2835,7 +2835,7 @@ struct il_tfd_tb { * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes * * Driver must indicate the physical address of the base of each - * circular buffer via the FH_MEM_CBBC_QUEUE registers. + * circular buffer via the FH49_MEM_CBBC_QUEUE registers. * * Each TFD contains pointer/size information for up to 20 data buffers * in host DRAM. These buffers collectively contain the (one) frame described diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index 7846bae..ac7c212 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -71,8 +71,8 @@ * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) * Addresses are offsets from device's PCI hardware base address. */ -#define FH_MEM_LOWER_BOUND (0x1000) -#define FH_MEM_UPPER_BOUND (0x2000) +#define FH49_MEM_LOWER_BOUND (0x1000) +#define FH49_MEM_UPPER_BOUND (0x2000) /** * Keep-Warm (KW) buffer base address. @@ -83,7 +83,7 @@ * from going into a power-savings mode that would cause higher DRAM latency, * and possible data over/under-runs, before all Tx/Rx is complete. * - * Driver loads FH_KW_MEM_ADDR_REG with the physical address (bits 35:4) + * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4) * of the buffer, which must be 4K aligned. Once this is set up, the 4965 * automatically invokes keep-warm accesses when normal accesses might not * be sufficient to maintain fast DRAM response. @@ -91,7 +91,7 @@ * Bit fields: * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned */ -#define FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C) +#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) /** @@ -106,11 +106,11 @@ * Bit fields in each pointer register: * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned */ -#define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0) -#define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10) +#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10) /* Find TFD CB base pointer for given queue (range 0-15). */ -#define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4) +#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) /** @@ -132,18 +132,18 @@ * Each entry (1 dword) points to a receive buffer (RB) of consistent size * (typically 4K, although 8K or 16K are also selectable by driver). * Driver sets up RB size and number of RBDs in the CB via Rx config - * register FH_MEM_RCSR_CHNL0_CONFIG_REG. + * register FH49_MEM_RCSR_CHNL0_CONFIG_REG. * * Bit fields within one RBD: * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned * * Driver sets physical address [35:8] of base of RBD circular buffer - * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. + * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. * * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers * (RBs) have been filled, via a "write pointer", actually the idx of * the RB's corresponding RBD within the circular buffer. Driver sets - * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. + * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. * * Bit fields in lower dword of Rx status buffer (upper dword not used * by driver; see struct il4965_shared, val0): @@ -154,7 +154,7 @@ * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must * enter pointers to these RBs into contiguous RBD circular buffer entries, * and update the 4965's "write" idx register, - * FH_RSCSR_CHNL0_RBDCB_WPTR_REG. + * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG. * * This "write" idx corresponds to the *next* RBD that the driver will make * available, i.e. one RBD past the tail of the ready-to-fill RBDs within @@ -182,23 +182,23 @@ * and "read" idxes; that is, make sure that there are no more than 254 * buffers waiting to be filled. */ -#define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0) -#define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00) -#define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND) +#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0) +#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND) /** * Physical base address of 8-byte Rx Status buffer. * Bit fields: * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. */ -#define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0) +#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0) /** * Physical base address of Rx Buffer Descriptor Circular Buffer. * Bit fields: * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. */ -#define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004) +#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004) /** * Rx write pointer (idx, really!). @@ -206,20 +206,20 @@ * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. * NOTE: For 256-entry circular buffer, use only bits [7:0]. */ -#define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008) -#define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG) +#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) +#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) /** * Rx Config/Status Registers (RCSR) * Rx Config Reg for channel 0 (only channel used) * - * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for + * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for * normal operation (see bit fields). * - * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. - * Driver should poll FH_MEM_RSSR_RX_STATUS_REG for - * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. + * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. + * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for + * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. * * Bit fields: * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, @@ -236,67 +236,67 @@ * typical value 0x10 (about 1/2 msec) * 3- 0: reserved */ -#define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00) -#define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0) -#define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND) +#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0) +#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND) -#define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0) +#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) -#define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ -#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ -#define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ -#define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ -#define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ -#define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ -#define FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) -#define FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) +#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) +#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) #define RX_RB_TIMEOUT (0x10) -#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) -#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) -#define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) -#define FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) -#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) -#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) +#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) /** * Rx Shared Status Registers (RSSR) * * After stopping Rx DMA channel (writing 0 to - * FH_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll - * FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. + * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll + * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. * * Bit fields: * 24: 1 = Channel 0 is idle * - * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV + * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV * contain default values that should not be altered by the driver. */ -#define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40) -#define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00) +#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40) +#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) -#define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND) -#define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004) -#define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ - (FH_MEM_RSSR_LOWER_BOUND + 0x008) +#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND) +#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004) +#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ + (FH49_MEM_RSSR_LOWER_BOUND + 0x008) -#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) +#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) -#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 +#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 /* TFDB Area - TFDs buffer table */ -#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) -#define FH_TFDIB_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x900) -#define FH_TFDIB_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x958) -#define FH_TFDIB_CTRL0_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) -#define FH_TFDIB_CTRL1_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) +#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) +#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900) +#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958) +#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) +#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) /** * Transmit DMA Channel Control/Status Registers (TCSR) @@ -306,10 +306,10 @@ * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. * * To use a Tx DMA channel, driver must initialize its - * FH_TCSR_CHNL_TX_CONFIG_REG(chnl) with: + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with: * - * FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - * FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL * * All other bits should be 0. * @@ -320,62 +320,62 @@ * 3: Enable internal DMA requests (1, normal operation), disable (0) * 2- 0: Reserved, set to "0" */ -#define FH_TCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xD00) -#define FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60) +#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) +#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60) /* Find Control/Status reg for given Tx DMA/FIFO channel */ #define FH49_TCSR_CHNL_NUM (7) #define FH50_TCSR_CHNL_NUM (8) /* TCSR: tx_config register values */ -#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ - (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl)) -#define FH_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ - (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) -#define FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ - (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) +#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl)) +#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) -#define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) /** * Tx Shared Status Registers (TSSR) * * After stopping Tx DMA channel (writing 0 to - * FH_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll - * FH_TSSR_TX_STATUS_REG until selected Tx channel is idle + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll + * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle * (channel's buffers empty | no pending requests). * * Bit fields: * 31-24: 1 = Channel buffers empty (channel 7:0) * 23-16: 1 = No pending requests (channel 7:0) */ -#define FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0) -#define FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0) +#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0) +#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0) -#define FH_TSSR_TX_STATUS_REG (FH_TSSR_LOWER_BOUND + 0x010) +#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010) /** * Bit fields for TSSR(Tx Shared Status & Control) error status register: @@ -394,22 +394,22 @@ * synchronized to the TxFIFO status * uCode/driver must write "1" in order to clear this flag */ -#define FH_TSSR_TX_ERROR_REG (FH_TSSR_LOWER_BOUND + 0x018) +#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018) -#define FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) +#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) /* Tx service channels */ -#define FH_SRVC_CHNL (9) -#define FH_SRVC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9C8) -#define FH_SRVC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0) -#define FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ - (FH_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) +#define FH49_SRVC_CHNL (9) +#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8) +#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ + (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) -#define FH_TX_CHICKEN_BITS_REG (FH_MEM_LOWER_BOUND + 0xE98) +#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98) /* Instruct FH to increment the retry count of a packet when * it is brought from the memory to TX-FIFO */ -#define FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) +#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) /* Keep Warm Size */ #define IL_KW_SIZE 0x1000 /* 4k */ -- cgit v0.10.2 From eac3b2127749af8ba033a755efdc0d4b43167906 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:29:46 +0200 Subject: iwlegacy: merge iwl-fh.h into 4965.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 5234de7..10d0b13 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -30,7 +30,6 @@ #ifndef __il_4965_h__ #define __il_4965_h__ -#include "iwl-fh.h" #include "iwl-debug.h" struct il_rx_queue; @@ -1001,4 +1000,355 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, } #endif +/****************************/ +/* Flow Handler Definitions */ +/****************************/ + +/** + * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) + * Addresses are offsets from device's PCI hardware base address. + */ +#define FH49_MEM_LOWER_BOUND (0x1000) +#define FH49_MEM_UPPER_BOUND (0x2000) + +/** + * Keep-Warm (KW) buffer base address. + * + * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the + * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency + * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host + * from going into a power-savings mode that would cause higher DRAM latency, + * and possible data over/under-runs, before all Tx/Rx is complete. + * + * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4) + * of the buffer, which must be 4K aligned. Once this is set up, the 4965 + * automatically invokes keep-warm accesses when normal accesses might not + * be sufficient to maintain fast DRAM response. + * + * Bit fields: + * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned + */ +#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) + + +/** + * TFD Circular Buffers Base (CBBC) addresses + * + * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident + * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) + * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04 + * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte + * aligned (address bits 0-7 must be 0). + * + * Bit fields in each pointer register: + * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned + */ +#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10) + +/* Find TFD CB base pointer for given queue (range 0-15). */ +#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) + + +/** + * Rx SRAM Control and Status Registers (RSCSR) + * + * These registers provide handshake between driver and 4965 for the Rx queue + * (this queue handles *all* command responses, notifications, Rx data, etc. + * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx + * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can + * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer + * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1 + * mapping between RBDs and RBs. + * + * Driver must allocate host DRAM memory for the following, and set the + * physical address of each into 4965 registers: + * + * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256 + * entries (although any power of 2, up to 4096, is selectable by driver). + * Each entry (1 dword) points to a receive buffer (RB) of consistent size + * (typically 4K, although 8K or 16K are also selectable by driver). + * Driver sets up RB size and number of RBDs in the CB via Rx config + * register FH49_MEM_RCSR_CHNL0_CONFIG_REG. + * + * Bit fields within one RBD: + * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned + * + * Driver sets physical address [35:8] of base of RBD circular buffer + * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. + * + * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers + * (RBs) have been filled, via a "write pointer", actually the idx of + * the RB's corresponding RBD within the circular buffer. Driver sets + * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. + * + * Bit fields in lower dword of Rx status buffer (upper dword not used + * by driver; see struct il4965_shared, val0): + * 31-12: Not used by driver + * 11- 0: Index of last filled Rx buffer descriptor + * (4965 writes, driver reads this value) + * + * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must + * enter pointers to these RBs into contiguous RBD circular buffer entries, + * and update the 4965's "write" idx register, + * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG. + * + * This "write" idx corresponds to the *next* RBD that the driver will make + * available, i.e. one RBD past the tail of the ready-to-fill RBDs within + * the circular buffer. This value should initially be 0 (before preparing any + * RBs), should be 8 after preparing the first 8 RBs (for example), and must + * wrap back to 0 at the end of the circular buffer (but don't wrap before + * "read" idx has advanced past 1! See below). + * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. + * + * As the 4965 fills RBs (referenced from contiguous RBDs within the circular + * buffer), it updates the Rx status buffer in host DRAM, 2) described above, + * to tell the driver the idx of the latest filled RBD. The driver must + * read this "read" idx from DRAM after receiving an Rx interrupt from 4965. + * + * The driver must also internally keep track of a third idx, which is the + * next RBD to process. When receiving an Rx interrupt, driver should process + * all filled but unprocessed RBs up to, but not including, the RB + * corresponding to the "read" idx. For example, if "read" idx becomes "1", + * driver may process the RB pointed to by RBD 0. Depending on volume of + * traffic, there may be many RBs to process. + * + * If read idx == write idx, 4965 thinks there is no room to put new data. + * Due to this, the maximum number of filled RBs is 255, instead of 256. To + * be safe, make sure that there is a gap of at least 2 RBDs between "write" + * and "read" idxes; that is, make sure that there are no more than 254 + * buffers waiting to be filled. + */ +#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0) +#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND) + +/** + * Physical base address of 8-byte Rx Status buffer. + * Bit fields: + * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. + */ +#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0) + +/** + * Physical base address of Rx Buffer Descriptor Circular Buffer. + * Bit fields: + * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. + */ +#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004) + +/** + * Rx write pointer (idx, really!). + * Bit fields: + * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. + * NOTE: For 256-entry circular buffer, use only bits [7:0]. + */ +#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) +#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) + + +/** + * Rx Config/Status Registers (RCSR) + * Rx Config Reg for channel 0 (only channel used) + * + * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for + * normal operation (see bit fields). + * + * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. + * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for + * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. + * + * Bit fields: + * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, + * '10' operate normally + * 29-24: reserved + * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal), + * min "5" for 32 RBDs, max "12" for 4096 RBDs. + * 19-18: reserved + * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K, + * '10' 12K, '11' 16K. + * 15-14: reserved + * 13-12: IRQ destination; '00' none, '01' host driver (normal operation) + * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec) + * typical value 0x10 (about 1/2 msec) + * 3- 0: reserved + */ +#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0) +#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND) + +#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) + +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ + +#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) +#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) +#define RX_RB_TIMEOUT (0x10) + +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) + +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) + +#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) + +/** + * Rx Shared Status Registers (RSSR) + * + * After stopping Rx DMA channel (writing 0 to + * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll + * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. + * + * Bit fields: + * 24: 1 = Channel 0 is idle + * + * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV + * contain default values that should not be altered by the driver. + */ +#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40) +#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) + +#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND) +#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004) +#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ + (FH49_MEM_RSSR_LOWER_BOUND + 0x008) + +#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) + +#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 + +/* TFDB Area - TFDs buffer table */ +#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) +#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900) +#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958) +#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) +#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) + +/** + * Transmit DMA Channel Control/Status Registers (TCSR) + * + * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels + * supported in hardware (don't confuse these with the 16 Tx queues in DRAM, + * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. + * + * To use a Tx DMA channel, driver must initialize its + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with: + * + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL + * + * All other bits should be 0. + * + * Bit fields: + * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame, + * '10' operate normally + * 29- 4: Reserved, set to "0" + * 3: Enable internal DMA requests (1, normal operation), disable (0) + * 2- 0: Reserved, set to "0" + */ +#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) +#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60) + +/* Find Control/Status reg for given Tx DMA/FIFO channel */ +#define FH49_TCSR_CHNL_NUM (7) +#define FH50_TCSR_CHNL_NUM (8) + +/* TCSR: tx_config register values */ +#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl)) +#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) + +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) + +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) + +/** + * Tx Shared Status Registers (TSSR) + * + * After stopping Tx DMA channel (writing 0 to + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll + * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle + * (channel's buffers empty | no pending requests). + * + * Bit fields: + * 31-24: 1 = Channel buffers empty (channel 7:0) + * 23-16: 1 = No pending requests (channel 7:0) + */ +#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0) +#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0) + +#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010) + +/** + * Bit fields for TSSR(Tx Shared Status & Control) error status register: + * 31: Indicates an address error when accessed to internal memory + * uCode/driver must write "1" in order to clear this flag + * 30: Indicates that Host did not send the expected number of dwords to FH + * uCode/driver must write "1" in order to clear this flag + * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA + * command was received from the scheduler while the TRB was already full + * with previous command + * uCode/driver must write "1" in order to clear this flag + * 7-0: Each status bit indicates a channel's TxCredit error. When an error + * bit is set, it indicates that the FH has received a full indication + * from the RTC TxFIFO and the current value of the TxCredit counter was + * not equal to zero. This mean that the credit mechanism was not + * synchronized to the TxFIFO status + * uCode/driver must write "1" in order to clear this flag + */ +#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018) + +#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) + +/* Tx service channels */ +#define FH49_SRVC_CHNL (9) +#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8) +#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ + (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) + +#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98) +/* Instruct FH to increment the retry count of a packet when + * it is brought from the memory to TX-FIFO + */ +#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) + +/* Keep Warm Size */ +#define IL_KW_SIZE 0x1000 /* 4k */ + #endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h deleted file mode 100644 index ac7c212..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ /dev/null @@ -1,417 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#ifndef __il_fh_h__ -#define __il_fh_h__ - -/****************************/ -/* Flow Handler Definitions */ -/****************************/ - -/** - * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) - * Addresses are offsets from device's PCI hardware base address. - */ -#define FH49_MEM_LOWER_BOUND (0x1000) -#define FH49_MEM_UPPER_BOUND (0x2000) - -/** - * Keep-Warm (KW) buffer base address. - * - * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the - * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency - * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host - * from going into a power-savings mode that would cause higher DRAM latency, - * and possible data over/under-runs, before all Tx/Rx is complete. - * - * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4) - * of the buffer, which must be 4K aligned. Once this is set up, the 4965 - * automatically invokes keep-warm accesses when normal accesses might not - * be sufficient to maintain fast DRAM response. - * - * Bit fields: - * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned - */ -#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) - - -/** - * TFD Circular Buffers Base (CBBC) addresses - * - * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident - * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) - * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04 - * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte - * aligned (address bits 0-7 must be 0). - * - * Bit fields in each pointer register: - * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned - */ -#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) -#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10) - -/* Find TFD CB base pointer for given queue (range 0-15). */ -#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) - - -/** - * Rx SRAM Control and Status Registers (RSCSR) - * - * These registers provide handshake between driver and 4965 for the Rx queue - * (this queue handles *all* command responses, notifications, Rx data, etc. - * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx - * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can - * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer - * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1 - * mapping between RBDs and RBs. - * - * Driver must allocate host DRAM memory for the following, and set the - * physical address of each into 4965 registers: - * - * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256 - * entries (although any power of 2, up to 4096, is selectable by driver). - * Each entry (1 dword) points to a receive buffer (RB) of consistent size - * (typically 4K, although 8K or 16K are also selectable by driver). - * Driver sets up RB size and number of RBDs in the CB via Rx config - * register FH49_MEM_RCSR_CHNL0_CONFIG_REG. - * - * Bit fields within one RBD: - * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned - * - * Driver sets physical address [35:8] of base of RBD circular buffer - * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. - * - * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers - * (RBs) have been filled, via a "write pointer", actually the idx of - * the RB's corresponding RBD within the circular buffer. Driver sets - * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. - * - * Bit fields in lower dword of Rx status buffer (upper dword not used - * by driver; see struct il4965_shared, val0): - * 31-12: Not used by driver - * 11- 0: Index of last filled Rx buffer descriptor - * (4965 writes, driver reads this value) - * - * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must - * enter pointers to these RBs into contiguous RBD circular buffer entries, - * and update the 4965's "write" idx register, - * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG. - * - * This "write" idx corresponds to the *next* RBD that the driver will make - * available, i.e. one RBD past the tail of the ready-to-fill RBDs within - * the circular buffer. This value should initially be 0 (before preparing any - * RBs), should be 8 after preparing the first 8 RBs (for example), and must - * wrap back to 0 at the end of the circular buffer (but don't wrap before - * "read" idx has advanced past 1! See below). - * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. - * - * As the 4965 fills RBs (referenced from contiguous RBDs within the circular - * buffer), it updates the Rx status buffer in host DRAM, 2) described above, - * to tell the driver the idx of the latest filled RBD. The driver must - * read this "read" idx from DRAM after receiving an Rx interrupt from 4965. - * - * The driver must also internally keep track of a third idx, which is the - * next RBD to process. When receiving an Rx interrupt, driver should process - * all filled but unprocessed RBs up to, but not including, the RB - * corresponding to the "read" idx. For example, if "read" idx becomes "1", - * driver may process the RB pointed to by RBD 0. Depending on volume of - * traffic, there may be many RBs to process. - * - * If read idx == write idx, 4965 thinks there is no room to put new data. - * Due to this, the maximum number of filled RBs is 255, instead of 256. To - * be safe, make sure that there is a gap of at least 2 RBDs between "write" - * and "read" idxes; that is, make sure that there are no more than 254 - * buffers waiting to be filled. - */ -#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0) -#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) -#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND) - -/** - * Physical base address of 8-byte Rx Status buffer. - * Bit fields: - * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. - */ -#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0) - -/** - * Physical base address of Rx Buffer Descriptor Circular Buffer. - * Bit fields: - * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. - */ -#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004) - -/** - * Rx write pointer (idx, really!). - * Bit fields: - * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. - * NOTE: For 256-entry circular buffer, use only bits [7:0]. - */ -#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) -#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) - - -/** - * Rx Config/Status Registers (RCSR) - * Rx Config Reg for channel 0 (only channel used) - * - * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for - * normal operation (see bit fields). - * - * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. - * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for - * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. - * - * Bit fields: - * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, - * '10' operate normally - * 29-24: reserved - * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal), - * min "5" for 32 RBDs, max "12" for 4096 RBDs. - * 19-18: reserved - * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K, - * '10' 12K, '11' 16K. - * 15-14: reserved - * 13-12: IRQ destination; '00' none, '01' host driver (normal operation) - * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec) - * typical value 0x10 (about 1/2 msec) - * 3- 0: reserved - */ -#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) -#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0) -#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND) - -#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) - -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ - -#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) -#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) -#define RX_RB_TIMEOUT (0x10) - -#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) -#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) -#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) - -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) - -#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) - -/** - * Rx Shared Status Registers (RSSR) - * - * After stopping Rx DMA channel (writing 0 to - * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll - * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. - * - * Bit fields: - * 24: 1 = Channel 0 is idle - * - * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV - * contain default values that should not be altered by the driver. - */ -#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40) -#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) - -#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND) -#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004) -#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ - (FH49_MEM_RSSR_LOWER_BOUND + 0x008) - -#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) - -#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 - -/* TFDB Area - TFDs buffer table */ -#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) -#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900) -#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958) -#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) -#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) - -/** - * Transmit DMA Channel Control/Status Registers (TCSR) - * - * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels - * supported in hardware (don't confuse these with the 16 Tx queues in DRAM, - * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. - * - * To use a Tx DMA channel, driver must initialize its - * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with: - * - * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL - * - * All other bits should be 0. - * - * Bit fields: - * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame, - * '10' operate normally - * 29- 4: Reserved, set to "0" - * 3: Enable internal DMA requests (1, normal operation), disable (0) - * 2- 0: Reserved, set to "0" - */ -#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) -#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60) - -/* Find Control/Status reg for given Tx DMA/FIFO channel */ -#define FH49_TCSR_CHNL_NUM (7) -#define FH50_TCSR_CHNL_NUM (8) - -/* TCSR: tx_config register values */ -#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ - (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl)) -#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ - (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ - (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) - -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) - -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) - -/** - * Tx Shared Status Registers (TSSR) - * - * After stopping Tx DMA channel (writing 0 to - * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll - * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle - * (channel's buffers empty | no pending requests). - * - * Bit fields: - * 31-24: 1 = Channel buffers empty (channel 7:0) - * 23-16: 1 = No pending requests (channel 7:0) - */ -#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0) -#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0) - -#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010) - -/** - * Bit fields for TSSR(Tx Shared Status & Control) error status register: - * 31: Indicates an address error when accessed to internal memory - * uCode/driver must write "1" in order to clear this flag - * 30: Indicates that Host did not send the expected number of dwords to FH - * uCode/driver must write "1" in order to clear this flag - * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA - * command was received from the scheduler while the TRB was already full - * with previous command - * uCode/driver must write "1" in order to clear this flag - * 7-0: Each status bit indicates a channel's TxCredit error. When an error - * bit is set, it indicates that the FH has received a full indication - * from the RTC TxFIFO and the current value of the TxCredit counter was - * not equal to zero. This mean that the credit mechanism was not - * synchronized to the TxFIFO status - * uCode/driver must write "1" in order to clear this flag - */ -#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018) - -#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) - -/* Tx service channels */ -#define FH49_SRVC_CHNL (9) -#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8) -#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) -#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ - (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) - -#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98) -/* Instruct FH to increment the retry count of a packet when - * it is brought from the memory to TX-FIFO - */ -#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) - -/* Keep Warm Size */ -#define IL_KW_SIZE 0x1000 /* 4k */ - -#endif /* !__il_fh_h__ */ -- cgit v0.10.2 From f19ab370a7ba40570dcdb2c0c3cdaa8c20efde97 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:24:36 +0100 Subject: iwlegacy: rename iwl-debug.c to debug.c Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 7421841..c985a01 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_IWLEGACY) += iwlegacy.o iwlegacy-objs := common.o -iwlegacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o +iwlegacy-$(CONFIG_IWLEGACY_DEBUGFS) += debug.o iwlegacy-objs += $(iwlegacy-m) diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c new file mode 100644 index 0000000..62292a6 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -0,0 +1,1309 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + *****************************************************************************/ +#include +#include + + +#include "iwl-debug.h" +#include "common.h" + +/* create and remove of files */ +#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ + if (!debugfs_create_file(#name, mode, parent, il, \ + &il_dbgfs_##name##_ops)) \ + goto err; \ +} while (0) + +#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ + struct dentry *__tmp; \ + __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ + parent, ptr); \ + if (IS_ERR(__tmp) || !__tmp) \ + goto err; \ +} while (0) + +#define DEBUGFS_ADD_X32(name, parent, ptr) do { \ + struct dentry *__tmp; \ + __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ + parent, ptr); \ + if (IS_ERR(__tmp) || !__tmp) \ + goto err; \ +} while (0) + +/* file operation */ +#define DEBUGFS_READ_FUNC(name) \ +static ssize_t il_dbgfs_##name##_read(struct file *file, \ + char __user *user_buf, \ + size_t count, loff_t *ppos); + +#define DEBUGFS_WRITE_FUNC(name) \ +static ssize_t il_dbgfs_##name##_write(struct file *file, \ + const char __user *user_buf, \ + size_t count, loff_t *ppos); + + +static int +il_dbgfs_open_file_generic(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +#define DEBUGFS_READ_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ +}; + +#define DEBUGFS_WRITE_FILE_OPS(name) \ + DEBUGFS_WRITE_FUNC(name); \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ +}; + +#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ + DEBUGFS_WRITE_FUNC(name); \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ +}; + +static ssize_t il_dbgfs_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char *buf; + int pos = 0; + + int cnt; + ssize_t ret; + const size_t bufsz = 100 + + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); + for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), + il->tx_stats.mgmt[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); + for (cnt = 0; cnt < CONTROL_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), + il->tx_stats.ctrl[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); + pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->tx_stats.data_cnt); + pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->tx_stats.data_bytes); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t +il_dbgfs_clear_traffic_stats_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + u32 clear_flag; + char buf[8]; + int buf_size; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%x", &clear_flag) != 1) + return -EFAULT; + il_clear_traffic_stats(il); + + return count; +} + +static ssize_t il_dbgfs_rx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char *buf; + int pos = 0; + int cnt; + ssize_t ret; + const size_t bufsz = 100 + + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); + for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), + il->rx_stats.mgmt[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); + for (cnt = 0; cnt < CONTROL_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), + il->rx_stats.ctrl[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); + pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->rx_stats.data_cnt); + pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->rx_stats.data_bytes); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +#define BYTE1_MASK 0x000000ff; +#define BYTE2_MASK 0x0000ffff; +#define BYTE3_MASK 0x00ffffff; +static ssize_t il_dbgfs_sram_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + u32 val; + char *buf; + ssize_t ret; + int i; + int pos = 0; + struct il_priv *il = file->private_data; + size_t bufsz; + + /* default is to dump the entire data segment */ + if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) { + il->dbgfs_sram_offset = 0x800000; + if (il->ucode_type == UCODE_INIT) + il->dbgfs_sram_len = il->ucode_init_data.len; + else + il->dbgfs_sram_len = il->ucode_data.len; + } + bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; + buf = kmalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", + il->dbgfs_sram_len); + pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", + il->dbgfs_sram_offset); + for (i = il->dbgfs_sram_len; i > 0; i -= 4) { + val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ + il->dbgfs_sram_len - i); + if (i < 4) { + switch (i) { + case 1: + val &= BYTE1_MASK; + break; + case 2: + val &= BYTE2_MASK; + break; + case 3: + val &= BYTE3_MASK; + break; + } + } + if (!(i % 16)) + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_sram_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[64]; + int buf_size; + u32 offset, len; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + if (sscanf(buf, "%x,%x", &offset, &len) == 2) { + il->dbgfs_sram_offset = offset; + il->dbgfs_sram_len = len; + } else { + il->dbgfs_sram_offset = 0; + il->dbgfs_sram_len = 0; + } + + return count; +} + +static ssize_t +il_dbgfs_stations_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + struct il_station_entry *station; + int max_sta = il->hw_params.max_stations; + char *buf; + int i, j, pos = 0; + ssize_t ret; + /* Add 30 for initial string */ + const size_t bufsz = 30 + sizeof(char) * 500 * (il->num_stations); + + buf = kmalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", + il->num_stations); + + for (i = 0; i < max_sta; i++) { + station = &il->stations[i]; + if (!station->used) + continue; + pos += scnprintf(buf + pos, bufsz - pos, + "station %d - addr: %pM, flags: %#x\n", + i, station->sta.sta.addr, + station->sta.station_flags_msk); + pos += scnprintf(buf + pos, bufsz - pos, + "TID\tseq_num\ttxq_id\tframes\ttfds\t"); + pos += scnprintf(buf + pos, bufsz - pos, + "start_idx\tbitmap\t\t\trate_n_flags\n"); + + for (j = 0; j < MAX_TID_COUNT; j++) { + pos += scnprintf(buf + pos, bufsz - pos, + "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", + j, station->tid[j].seq_number, + station->tid[j].agg.txq_id, + station->tid[j].agg.frame_count, + station->tid[j].tfds_in_queue, + station->tid[j].agg.start_idx, + station->tid[j].agg.bitmap, + station->tid[j].agg.rate_n_flags); + + if (station->tid[j].agg.wait_for_ba) + pos += scnprintf(buf + pos, bufsz - pos, + " - waitforba"); + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + } + + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_nvm_read(struct file *file, + char __user *user_buf, + size_t count, + loff_t *ppos) +{ + ssize_t ret; + struct il_priv *il = file->private_data; + int pos = 0, ofs = 0, buf_size = 0; + const u8 *ptr; + char *buf; + u16 eeprom_ver; + size_t eeprom_len = il->cfg->base_params->eeprom_size; + buf_size = 4 * eeprom_len + 256; + + if (eeprom_len % 16) { + IL_ERR("NVM size is not multiple of 16.\n"); + return -ENODATA; + } + + ptr = il->eeprom; + if (!ptr) { + IL_ERR("Invalid EEPROM memory\n"); + return -ENOMEM; + } + + /* 4 characters for byte 0xYY */ + buf = kzalloc(buf_size, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); + pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " + "version: 0x%x\n", eeprom_ver); + for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { + pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); + hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, + buf_size - pos, 0); + pos += strlen(buf + pos); + if (buf_size - pos > 0) + buf[pos++] = '\n'; + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t +il_dbgfs_channels_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + struct ieee80211_channel *channels = NULL; + const struct ieee80211_supported_band *supp_band = NULL; + int pos = 0, i, bufsz = PAGE_SIZE; + char *buf; + ssize_t ret; + + if (!test_bit(S_GEO_CONFIGURED, &il->status)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ); + if (supp_band) { + channels = supp_band->channels; + + pos += scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 2.4GHz band 802.11bg):\n", + supp_band->n_channels); + + for (i = 0; i < supp_band->n_channels; i++) + pos += scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i].flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) + || (channels[i].flags & + IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i].flags & + IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); + } + supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); + if (supp_band) { + channels = supp_band->channels; + + pos += scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 5.2GHz band (802.11a)\n", + supp_band->n_channels); + + for (i = 0; i < supp_band->n_channels; i++) + pos += scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i].flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) + || (channels[i].flags & + IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i].flags & + IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); + } + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_status_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char buf[512]; + int pos = 0; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", + test_bit(S_HCMD_ACTIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", + test_bit(S_INT_ENABLED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", + test_bit(S_RF_KILL_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", + test_bit(S_CT_KILL, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", + test_bit(S_INIT, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", + test_bit(S_ALIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", + test_bit(S_READY, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", + test_bit(S_TEMPERATURE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", + test_bit(S_GEO_CONFIGURED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", + test_bit(S_EXIT_PENDING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", + test_bit(S_STATS, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", + test_bit(S_SCANNING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", + test_bit(S_SCAN_ABORTING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", + test_bit(S_SCAN_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", + test_bit(S_POWER_PMI, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", + test_bit(S_FW_ERROR, &il->status)); + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_interrupt_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + int cnt = 0; + char *buf; + int bufsz = 24 * 64; /* 24 items * 64 char per item */ + ssize_t ret; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + pos += scnprintf(buf + pos, bufsz - pos, + "Interrupt Statistics Report:\n"); + + pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", + il->isr_stats.hw); + pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", + il->isr_stats.sw); + if (il->isr_stats.sw || il->isr_stats.hw) { + pos += scnprintf(buf + pos, bufsz - pos, + "\tLast Restarting Code: 0x%X\n", + il->isr_stats.err_code); + } +#ifdef CONFIG_IWLEGACY_DEBUG + pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", + il->isr_stats.sch); + pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", + il->isr_stats.alive); +#endif + pos += scnprintf(buf + pos, bufsz - pos, + "HW RF KILL switch toggled:\t %u\n", + il->isr_stats.rfkill); + + pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", + il->isr_stats.ctkill); + + pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", + il->isr_stats.wakeup); + + pos += scnprintf(buf + pos, bufsz - pos, + "Rx command responses:\t\t %u\n", + il->isr_stats.rx); + for (cnt = 0; cnt < IL_CN_MAX; cnt++) { + if (il->isr_stats.handlers[cnt] > 0) + pos += scnprintf(buf + pos, bufsz - pos, + "\tRx handler[%36s]:\t\t %u\n", + il_get_cmd_string(cnt), + il->isr_stats.handlers[cnt]); + } + + pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", + il->isr_stats.tx); + + pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", + il->isr_stats.unhandled); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_interrupt_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + u32 reset_flag; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%x", &reset_flag) != 1) + return -EFAULT; + if (reset_flag == 0) + il_clear_isr_stats(il); + + return count; +} + +static ssize_t +il_dbgfs_qos_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + struct il_rxon_context *ctx = &il->ctx; + int pos = 0, i; + char buf[256]; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", + ctx->ctxid); + for (i = 0; i < AC_NUM; i++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\tcw_min\tcw_max\taifsn\ttxop\n"); + pos += scnprintf(buf + pos, bufsz - pos, + "AC[%d]\t%u\t%u\t%u\t%u\n", i, + ctx->qos_data.def_qos_parm.ac[i].cw_min, + ctx->qos_data.def_qos_parm.ac[i].cw_max, + ctx->qos_data.def_qos_parm.ac[i].aifsn, + ctx->qos_data.def_qos_parm.ac[i].edca_txop); + } + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_disable_ht40_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int ht40; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &ht40) != 1) + return -EFAULT; + if (!il_is_any_associated(il)) + il->disable_ht40 = ht40 ? true : false; + else { + IL_ERR("Sta associated with AP - " + "Change to 40MHz channel support is not allowed\n"); + return -EINVAL; + } + + return count; +} + +static ssize_t il_dbgfs_disable_ht40_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[100]; + int pos = 0; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, + "11n 40MHz Mode: %s\n", + il->disable_ht40 ? "Disabled" : "Enabled"); + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +DEBUGFS_READ_WRITE_FILE_OPS(sram); +DEBUGFS_READ_FILE_OPS(nvm); +DEBUGFS_READ_FILE_OPS(stations); +DEBUGFS_READ_FILE_OPS(channels); +DEBUGFS_READ_FILE_OPS(status); +DEBUGFS_READ_WRITE_FILE_OPS(interrupt); +DEBUGFS_READ_FILE_OPS(qos); +DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); + +static ssize_t il_dbgfs_traffic_log_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0, ofs = 0; + int cnt = 0, entry; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_rx_queue *rxq = &il->rxq; + char *buf; + int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + + (il->cfg->base_params->num_of_queues * 32 * 8) + 400; + const u8 *ptr; + ssize_t ret; + + if (!il->txq) { + IL_ERR("txq not ready\n"); + return -EAGAIN; + } + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate buffer\n"); + return -ENOMEM; + } + pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; + q = &txq->q; + pos += scnprintf(buf + pos, bufsz - pos, + "q[%d]: read_ptr: %u, write_ptr: %u\n", + cnt, q->read_ptr, q->write_ptr); + } + if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { + ptr = il->tx_traffic; + pos += scnprintf(buf + pos, bufsz - pos, + "Tx Traffic idx: %u\n", il->tx_traffic_idx); + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; + entry++, ofs += 16) { + pos += scnprintf(buf + pos, bufsz - pos, + "0x%.4x ", ofs); + hex_dump_to_buffer(ptr + ofs, 16, 16, 2, + buf + pos, bufsz - pos, 0); + pos += strlen(buf + pos); + if (bufsz - pos > 0) + buf[pos++] = '\n'; + } + } + } + + pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); + pos += scnprintf(buf + pos, bufsz - pos, + "read: %u, write: %u\n", + rxq->read, rxq->write); + + if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { + ptr = il->rx_traffic; + pos += scnprintf(buf + pos, bufsz - pos, + "Rx Traffic idx: %u\n", il->rx_traffic_idx); + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; + entry++, ofs += 16) { + pos += scnprintf(buf + pos, bufsz - pos, + "0x%.4x ", ofs); + hex_dump_to_buffer(ptr + ofs, 16, 16, 2, + buf + pos, bufsz - pos, 0); + pos += strlen(buf + pos); + if (bufsz - pos > 0) + buf[pos++] = '\n'; + } + } + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_traffic_log_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int traffic_log; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &traffic_log) != 1) + return -EFAULT; + if (traffic_log == 0) + il_reset_traffic_log(il); + + return count; +} + +static ssize_t il_dbgfs_tx_queue_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + struct il_tx_queue *txq; + struct il_queue *q; + char *buf; + int pos = 0; + int cnt; + int ret; + const size_t bufsz = sizeof(char) * 64 * + il->cfg->base_params->num_of_queues; + + if (!il->txq) { + IL_ERR("txq not ready\n"); + return -EAGAIN; + } + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; + q = &txq->q; + pos += scnprintf(buf + pos, bufsz - pos, + "hwq %.2d: read=%u write=%u stop=%d" + " swq_id=%#.2x (ac %d/hwq %d)\n", + cnt, q->read_ptr, q->write_ptr, + !!test_bit(cnt, il->queue_stopped), + txq->swq_id, txq->swq_id & 3, + (txq->swq_id >> 2) & 0x1f); + if (cnt >= 4) + continue; + /* for the ACs, display the stop count too */ + pos += scnprintf(buf + pos, bufsz - pos, + " stop-count: %d\n", + atomic_read(&il->queue_stop_count[cnt])); + } + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_rx_queue_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + struct il_rx_queue *rxq = &il->rxq; + char buf[256]; + int pos = 0; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", + rxq->read); + pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", + rxq->write); + pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", + rxq->free_count); + if (rxq->rb_stts) { + pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", + le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); + } else { + pos += scnprintf(buf + pos, bufsz - pos, + "closed_rb_num: Not Allocated\n"); + } + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, + user_buf, count, ppos); +} + +static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, + user_buf, count, ppos); +} + +static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, + user_buf, count, ppos); +} + +static ssize_t il_dbgfs_sensitivity_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + int cnt = 0; + char *buf; + int bufsz = sizeof(struct il_sensitivity_data) * 4 + 100; + ssize_t ret; + struct il_sensitivity_data *data; + + data = &il->sensitivity_data; + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", + data->auto_corr_ofdm); + pos += scnprintf(buf + pos, bufsz - pos, + "auto_corr_ofdm_mrc:\t\t %u\n", + data->auto_corr_ofdm_mrc); + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", + data->auto_corr_ofdm_x1); + pos += scnprintf(buf + pos, bufsz - pos, + "auto_corr_ofdm_mrc_x1:\t\t %u\n", + data->auto_corr_ofdm_mrc_x1); + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", + data->auto_corr_cck); + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", + data->auto_corr_cck_mrc); + pos += scnprintf(buf + pos, bufsz - pos, + "last_bad_plcp_cnt_ofdm:\t\t %u\n", + data->last_bad_plcp_cnt_ofdm); + pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", + data->last_fa_cnt_ofdm); + pos += scnprintf(buf + pos, bufsz - pos, + "last_bad_plcp_cnt_cck:\t\t %u\n", + data->last_bad_plcp_cnt_cck); + pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", + data->last_fa_cnt_cck); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", + data->nrg_curr_state); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", + data->nrg_prev_state); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); + for (cnt = 0; cnt < 10; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_value[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); + for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_silence_rssi[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", + data->nrg_silence_ref); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", + data->nrg_energy_idx); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", + data->nrg_silence_idx); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", + data->nrg_th_cck); + pos += scnprintf(buf + pos, bufsz - pos, + "nrg_auto_corr_silence_diff:\t %u\n", + data->nrg_auto_corr_silence_diff); + pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", + data->num_in_cck_no_fa); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", + data->nrg_th_ofdm); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + + +static ssize_t il_dbgfs_chain_noise_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + int cnt = 0; + char *buf; + int bufsz = sizeof(struct il_chain_noise_data) * 4 + 100; + ssize_t ret; + struct il_chain_noise_data *data; + + data = &il->chain_noise_data; + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", + data->active_chains); + pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", + data->chain_noise_a); + pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", + data->chain_noise_b); + pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", + data->chain_noise_c); + pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", + data->chain_signal_a); + pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", + data->chain_signal_b); + pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", + data->chain_signal_c); + pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", + data->beacon_count); + + pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); + for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->disconn_array[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); + for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->delta_gain_code[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", + data->radio_write); + pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", + data->state); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_power_save_status_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[60]; + int pos = 0; + const size_t bufsz = sizeof(buf); + u32 pwrsave_status; + + pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & + CSR_GP_REG_POWER_SAVE_STATUS_MSK; + + pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); + pos += scnprintf(buf + pos, bufsz - pos, "%s\n", + (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : + (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : + (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : + "error"); + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int clear; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &clear) != 1) + return -EFAULT; + + /* make request to uCode to retrieve stats information */ + mutex_lock(&il->mutex); + il_send_stats_request(il, CMD_SYNC, true); + mutex_unlock(&il->mutex); + + return count; +} + +static ssize_t il_dbgfs_rxon_flags_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int len = 0; + char buf[20]; + + len = sprintf(buf, "0x%04X\n", + le32_to_cpu(il->ctx.active.flags)); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int len = 0; + char buf[20]; + + len = sprintf(buf, "0x%04X\n", + le32_to_cpu(il->ctx.active.filter_flags)); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t il_dbgfs_fh_reg_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char *buf; + int pos = 0; + ssize_t ret = -EFAULT; + + if (il->cfg->ops->lib->dump_fh) { + ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); + if (buf) { + ret = simple_read_from_buffer(user_buf, + count, ppos, buf, pos); + kfree(buf); + } + } + + return ret; +} + +static ssize_t il_dbgfs_missed_beacon_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + char buf[12]; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "%d\n", + il->missed_beacon_threshold); + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_missed_beacon_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int missed; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &missed) != 1) + return -EINVAL; + + if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || + missed > IL_MISSED_BEACON_THRESHOLD_MAX) + il->missed_beacon_threshold = + IL_MISSED_BEACON_THRESHOLD_DEF; + else + il->missed_beacon_threshold = missed; + + return count; +} + +static ssize_t il_dbgfs_force_reset_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + char buf[300]; + const size_t bufsz = sizeof(buf); + struct il_force_reset *force_reset; + + force_reset = &il->force_reset; + + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request: %d\n", + force_reset->reset_request_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request success: %d\n", + force_reset->reset_success_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request reject: %d\n", + force_reset->reset_reject_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\treset duration: %lu\n", + force_reset->reset_duration); + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_force_reset_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) { + + int ret; + struct il_priv *il = file->private_data; + + ret = il_force_reset(il, true); + + return ret ? ret : count; +} + +static ssize_t il_dbgfs_wd_timeout_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int timeout; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &timeout) != 1) + return -EINVAL; + if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) + timeout = IL_DEF_WD_TIMEOUT; + + il->cfg->base_params->wd_timeout = timeout; + il_setup_watchdog(il); + return count; +} + +DEBUGFS_READ_FILE_OPS(rx_stats); +DEBUGFS_READ_FILE_OPS(tx_stats); +DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); +DEBUGFS_READ_FILE_OPS(rx_queue); +DEBUGFS_READ_FILE_OPS(tx_queue); +DEBUGFS_READ_FILE_OPS(ucode_rx_stats); +DEBUGFS_READ_FILE_OPS(ucode_tx_stats); +DEBUGFS_READ_FILE_OPS(ucode_general_stats); +DEBUGFS_READ_FILE_OPS(sensitivity); +DEBUGFS_READ_FILE_OPS(chain_noise); +DEBUGFS_READ_FILE_OPS(power_save_status); +DEBUGFS_WRITE_FILE_OPS(clear_ucode_stats); +DEBUGFS_WRITE_FILE_OPS(clear_traffic_stats); +DEBUGFS_READ_FILE_OPS(fh_reg); +DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); +DEBUGFS_READ_WRITE_FILE_OPS(force_reset); +DEBUGFS_READ_FILE_OPS(rxon_flags); +DEBUGFS_READ_FILE_OPS(rxon_filter_flags); +DEBUGFS_WRITE_FILE_OPS(wd_timeout); + +/* + * Create the debugfs files and directories + * + */ +int il_dbgfs_register(struct il_priv *il, const char *name) +{ + struct dentry *phyd = il->hw->wiphy->debugfsdir; + struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; + + dir_drv = debugfs_create_dir(name, phyd); + if (!dir_drv) + return -ENOMEM; + + il->debugfs_dir = dir_drv; + + dir_data = debugfs_create_dir("data", dir_drv); + if (!dir_data) + goto err; + dir_rf = debugfs_create_dir("rf", dir_drv); + if (!dir_rf) + goto err; + dir_debug = debugfs_create_dir("debug", dir_drv); + if (!dir_debug) + goto err; + + DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(clear_ucode_stats, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(clear_traffic_stats, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); + + if (il->cfg->base_params->sensitivity_calib_by_driver) + DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); + if (il->cfg->base_params->chain_noise_calib_by_driver) + DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); + if (il->cfg->base_params->sensitivity_calib_by_driver) + DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, + &il->disable_sens_cal); + if (il->cfg->base_params->chain_noise_calib_by_driver) + DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, + &il->disable_chain_noise_cal); + DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, + &il->disable_tx_power_cal); + return 0; + +err: + IL_ERR("Can't create the debugfs directory\n"); + il_dbgfs_unregister(il); + return -ENOMEM; +} +EXPORT_SYMBOL(il_dbgfs_register); + +/** + * Remove the debugfs files and directories + * + */ +void il_dbgfs_unregister(struct il_priv *il) +{ + if (!il->debugfs_dir) + return; + + debugfs_remove_recursive(il->debugfs_dir); + il->debugfs_dir = NULL; +} +EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c deleted file mode 100644 index 62292a6..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ /dev/null @@ -1,1309 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ -#include -#include - - -#include "iwl-debug.h" -#include "common.h" - -/* create and remove of files */ -#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ - if (!debugfs_create_file(#name, mode, parent, il, \ - &il_dbgfs_##name##_ops)) \ - goto err; \ -} while (0) - -#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ - struct dentry *__tmp; \ - __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ - parent, ptr); \ - if (IS_ERR(__tmp) || !__tmp) \ - goto err; \ -} while (0) - -#define DEBUGFS_ADD_X32(name, parent, ptr) do { \ - struct dentry *__tmp; \ - __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ - parent, ptr); \ - if (IS_ERR(__tmp) || !__tmp) \ - goto err; \ -} while (0) - -/* file operation */ -#define DEBUGFS_READ_FUNC(name) \ -static ssize_t il_dbgfs_##name##_read(struct file *file, \ - char __user *user_buf, \ - size_t count, loff_t *ppos); - -#define DEBUGFS_WRITE_FUNC(name) \ -static ssize_t il_dbgfs_##name##_write(struct file *file, \ - const char __user *user_buf, \ - size_t count, loff_t *ppos); - - -static int -il_dbgfs_open_file_generic(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -#define DEBUGFS_READ_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ -static const struct file_operations il_dbgfs_##name##_ops = { \ - .read = il_dbgfs_##name##_read, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ -}; - -#define DEBUGFS_WRITE_FILE_OPS(name) \ - DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations il_dbgfs_##name##_ops = { \ - .write = il_dbgfs_##name##_write, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ -}; - -#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ - DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations il_dbgfs_##name##_ops = { \ - .write = il_dbgfs_##name##_write, \ - .read = il_dbgfs_##name##_read, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ -}; - -static ssize_t il_dbgfs_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char *buf; - int pos = 0; - - int cnt; - ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); - for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->tx_stats.mgmt[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); - for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->tx_stats.ctrl[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->tx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->tx_stats.data_bytes); - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t -il_dbgfs_clear_traffic_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - u32 clear_flag; - char buf[8]; - int buf_size; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%x", &clear_flag) != 1) - return -EFAULT; - il_clear_traffic_stats(il); - - return count; -} - -static ssize_t il_dbgfs_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char *buf; - int pos = 0; - int cnt; - ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); - for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->rx_stats.mgmt[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); - for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->rx_stats.ctrl[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->rx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->rx_stats.data_bytes); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -#define BYTE1_MASK 0x000000ff; -#define BYTE2_MASK 0x0000ffff; -#define BYTE3_MASK 0x00ffffff; -static ssize_t il_dbgfs_sram_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - u32 val; - char *buf; - ssize_t ret; - int i; - int pos = 0; - struct il_priv *il = file->private_data; - size_t bufsz; - - /* default is to dump the entire data segment */ - if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) { - il->dbgfs_sram_offset = 0x800000; - if (il->ucode_type == UCODE_INIT) - il->dbgfs_sram_len = il->ucode_init_data.len; - else - il->dbgfs_sram_len = il->ucode_data.len; - } - bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; - buf = kmalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", - il->dbgfs_sram_len); - pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", - il->dbgfs_sram_offset); - for (i = il->dbgfs_sram_len; i > 0; i -= 4) { - val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ - il->dbgfs_sram_len - i); - if (i < 4) { - switch (i) { - case 1: - val &= BYTE1_MASK; - break; - case 2: - val &= BYTE2_MASK; - break; - case 3: - val &= BYTE3_MASK; - break; - } - } - if (!(i % 16)) - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_sram_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[64]; - int buf_size; - u32 offset, len; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - - if (sscanf(buf, "%x,%x", &offset, &len) == 2) { - il->dbgfs_sram_offset = offset; - il->dbgfs_sram_len = len; - } else { - il->dbgfs_sram_offset = 0; - il->dbgfs_sram_len = 0; - } - - return count; -} - -static ssize_t -il_dbgfs_stations_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - struct il_station_entry *station; - int max_sta = il->hw_params.max_stations; - char *buf; - int i, j, pos = 0; - ssize_t ret; - /* Add 30 for initial string */ - const size_t bufsz = 30 + sizeof(char) * 500 * (il->num_stations); - - buf = kmalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", - il->num_stations); - - for (i = 0; i < max_sta; i++) { - station = &il->stations[i]; - if (!station->used) - continue; - pos += scnprintf(buf + pos, bufsz - pos, - "station %d - addr: %pM, flags: %#x\n", - i, station->sta.sta.addr, - station->sta.station_flags_msk); - pos += scnprintf(buf + pos, bufsz - pos, - "TID\tseq_num\ttxq_id\tframes\ttfds\t"); - pos += scnprintf(buf + pos, bufsz - pos, - "start_idx\tbitmap\t\t\trate_n_flags\n"); - - for (j = 0; j < MAX_TID_COUNT; j++) { - pos += scnprintf(buf + pos, bufsz - pos, - "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", - j, station->tid[j].seq_number, - station->tid[j].agg.txq_id, - station->tid[j].agg.frame_count, - station->tid[j].tfds_in_queue, - station->tid[j].agg.start_idx, - station->tid[j].agg.bitmap, - station->tid[j].agg.rate_n_flags); - - if (station->tid[j].agg.wait_for_ba) - pos += scnprintf(buf + pos, bufsz - pos, - " - waitforba"); - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - } - - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_nvm_read(struct file *file, - char __user *user_buf, - size_t count, - loff_t *ppos) -{ - ssize_t ret; - struct il_priv *il = file->private_data; - int pos = 0, ofs = 0, buf_size = 0; - const u8 *ptr; - char *buf; - u16 eeprom_ver; - size_t eeprom_len = il->cfg->base_params->eeprom_size; - buf_size = 4 * eeprom_len + 256; - - if (eeprom_len % 16) { - IL_ERR("NVM size is not multiple of 16.\n"); - return -ENODATA; - } - - ptr = il->eeprom; - if (!ptr) { - IL_ERR("Invalid EEPROM memory\n"); - return -ENOMEM; - } - - /* 4 characters for byte 0xYY */ - buf = kzalloc(buf_size, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " - "version: 0x%x\n", eeprom_ver); - for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { - pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, - buf_size - pos, 0); - pos += strlen(buf + pos); - if (buf_size - pos > 0) - buf[pos++] = '\n'; - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t -il_dbgfs_channels_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - struct ieee80211_channel *channels = NULL; - const struct ieee80211_supported_band *supp_band = NULL; - int pos = 0, i, bufsz = PAGE_SIZE; - char *buf; - ssize_t ret; - - if (!test_bit(S_GEO_CONFIGURED, &il->status)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ); - if (supp_band) { - channels = supp_band->channels; - - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 2.4GHz band 802.11bg):\n", - supp_band->n_channels); - - for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); - } - supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); - if (supp_band) { - channels = supp_band->channels; - - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 5.2GHz band (802.11a)\n", - supp_band->n_channels); - - for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); - } - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char buf[512]; - int pos = 0; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", - test_bit(S_HCMD_ACTIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", - test_bit(S_INT_ENABLED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", - test_bit(S_RF_KILL_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", - test_bit(S_CT_KILL, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", - test_bit(S_INIT, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", - test_bit(S_ALIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", - test_bit(S_READY, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", - test_bit(S_TEMPERATURE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", - test_bit(S_GEO_CONFIGURED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", - test_bit(S_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", - test_bit(S_STATS, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", - test_bit(S_SCANNING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", - test_bit(S_SCAN_ABORTING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", - test_bit(S_SCAN_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", - test_bit(S_POWER_PMI, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", - test_bit(S_FW_ERROR, &il->status)); - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_interrupt_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - int cnt = 0; - char *buf; - int bufsz = 24 * 64; /* 24 items * 64 char per item */ - ssize_t ret; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - pos += scnprintf(buf + pos, bufsz - pos, - "Interrupt Statistics Report:\n"); - - pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", - il->isr_stats.hw); - pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", - il->isr_stats.sw); - if (il->isr_stats.sw || il->isr_stats.hw) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tLast Restarting Code: 0x%X\n", - il->isr_stats.err_code); - } -#ifdef CONFIG_IWLEGACY_DEBUG - pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", - il->isr_stats.sch); - pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", - il->isr_stats.alive); -#endif - pos += scnprintf(buf + pos, bufsz - pos, - "HW RF KILL switch toggled:\t %u\n", - il->isr_stats.rfkill); - - pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", - il->isr_stats.ctkill); - - pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", - il->isr_stats.wakeup); - - pos += scnprintf(buf + pos, bufsz - pos, - "Rx command responses:\t\t %u\n", - il->isr_stats.rx); - for (cnt = 0; cnt < IL_CN_MAX; cnt++) { - if (il->isr_stats.handlers[cnt] > 0) - pos += scnprintf(buf + pos, bufsz - pos, - "\tRx handler[%36s]:\t\t %u\n", - il_get_cmd_string(cnt), - il->isr_stats.handlers[cnt]); - } - - pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", - il->isr_stats.tx); - - pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", - il->isr_stats.unhandled); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_interrupt_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - u32 reset_flag; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%x", &reset_flag) != 1) - return -EFAULT; - if (reset_flag == 0) - il_clear_isr_stats(il); - - return count; -} - -static ssize_t -il_dbgfs_qos_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - struct il_rxon_context *ctx = &il->ctx; - int pos = 0, i; - char buf[256]; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", - ctx->ctxid); - for (i = 0; i < AC_NUM; i++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tcw_min\tcw_max\taifsn\ttxop\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "AC[%d]\t%u\t%u\t%u\t%u\n", i, - ctx->qos_data.def_qos_parm.ac[i].cw_min, - ctx->qos_data.def_qos_parm.ac[i].cw_max, - ctx->qos_data.def_qos_parm.ac[i].aifsn, - ctx->qos_data.def_qos_parm.ac[i].edca_txop); - } - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_disable_ht40_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int ht40; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &ht40) != 1) - return -EFAULT; - if (!il_is_any_associated(il)) - il->disable_ht40 = ht40 ? true : false; - else { - IL_ERR("Sta associated with AP - " - "Change to 40MHz channel support is not allowed\n"); - return -EINVAL; - } - - return count; -} - -static ssize_t il_dbgfs_disable_ht40_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[100]; - int pos = 0; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, - "11n 40MHz Mode: %s\n", - il->disable_ht40 ? "Disabled" : "Enabled"); - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -DEBUGFS_READ_WRITE_FILE_OPS(sram); -DEBUGFS_READ_FILE_OPS(nvm); -DEBUGFS_READ_FILE_OPS(stations); -DEBUGFS_READ_FILE_OPS(channels); -DEBUGFS_READ_FILE_OPS(status); -DEBUGFS_READ_WRITE_FILE_OPS(interrupt); -DEBUGFS_READ_FILE_OPS(qos); -DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); - -static ssize_t il_dbgfs_traffic_log_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0, ofs = 0; - int cnt = 0, entry; - struct il_tx_queue *txq; - struct il_queue *q; - struct il_rx_queue *rxq = &il->rxq; - char *buf; - int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (il->cfg->base_params->num_of_queues * 32 * 8) + 400; - const u8 *ptr; - ssize_t ret; - - if (!il->txq) { - IL_ERR("txq not ready\n"); - return -EAGAIN; - } - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate buffer\n"); - return -ENOMEM; - } - pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); - for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { - txq = &il->txq[cnt]; - q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "q[%d]: read_ptr: %u, write_ptr: %u\n", - cnt, q->read_ptr, q->write_ptr); - } - if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { - ptr = il->tx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Tx Traffic idx: %u\n", il->tx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16, 16, 2, - buf + pos, bufsz - pos, 0); - pos += strlen(buf + pos); - if (bufsz - pos > 0) - buf[pos++] = '\n'; - } - } - } - - pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "read: %u, write: %u\n", - rxq->read, rxq->write); - - if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { - ptr = il->rx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Rx Traffic idx: %u\n", il->rx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16, 16, 2, - buf + pos, bufsz - pos, 0); - pos += strlen(buf + pos); - if (bufsz - pos > 0) - buf[pos++] = '\n'; - } - } - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_traffic_log_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int traffic_log; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &traffic_log) != 1) - return -EFAULT; - if (traffic_log == 0) - il_reset_traffic_log(il); - - return count; -} - -static ssize_t il_dbgfs_tx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - struct il_tx_queue *txq; - struct il_queue *q; - char *buf; - int pos = 0; - int cnt; - int ret; - const size_t bufsz = sizeof(char) * 64 * - il->cfg->base_params->num_of_queues; - - if (!il->txq) { - IL_ERR("txq not ready\n"); - return -EAGAIN; - } - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { - txq = &il->txq[cnt]; - q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "hwq %.2d: read=%u write=%u stop=%d" - " swq_id=%#.2x (ac %d/hwq %d)\n", - cnt, q->read_ptr, q->write_ptr, - !!test_bit(cnt, il->queue_stopped), - txq->swq_id, txq->swq_id & 3, - (txq->swq_id >> 2) & 0x1f); - if (cnt >= 4) - continue; - /* for the ACs, display the stop count too */ - pos += scnprintf(buf + pos, bufsz - pos, - " stop-count: %d\n", - atomic_read(&il->queue_stop_count[cnt])); - } - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_rx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - struct il_rx_queue *rxq = &il->rxq; - char buf[256]; - int pos = 0; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", - rxq->read); - pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", - rxq->write); - pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", - rxq->free_count); - if (rxq->rb_stts) { - pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", - le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); - } else { - pos += scnprintf(buf + pos, bufsz - pos, - "closed_rb_num: Not Allocated\n"); - } - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, - user_buf, count, ppos); -} - -static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, - user_buf, count, ppos); -} - -static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, - user_buf, count, ppos); -} - -static ssize_t il_dbgfs_sensitivity_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - int cnt = 0; - char *buf; - int bufsz = sizeof(struct il_sensitivity_data) * 4 + 100; - ssize_t ret; - struct il_sensitivity_data *data; - - data = &il->sensitivity_data; - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", - data->auto_corr_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc:\t\t %u\n", - data->auto_corr_ofdm_mrc); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", - data->auto_corr_ofdm_x1); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc_x1:\t\t %u\n", - data->auto_corr_ofdm_mrc_x1); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", - data->auto_corr_cck); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", - data->auto_corr_cck_mrc); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_ofdm:\t\t %u\n", - data->last_bad_plcp_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", - data->last_fa_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_cck:\t\t %u\n", - data->last_bad_plcp_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", - data->last_fa_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", - data->nrg_curr_state); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", - data->nrg_prev_state); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); - for (cnt = 0; cnt < 10; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_value[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); - for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_silence_rssi[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", - data->nrg_silence_ref); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", - data->nrg_energy_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", - data->nrg_silence_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", - data->nrg_th_cck); - pos += scnprintf(buf + pos, bufsz - pos, - "nrg_auto_corr_silence_diff:\t %u\n", - data->nrg_auto_corr_silence_diff); - pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", - data->num_in_cck_no_fa); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", - data->nrg_th_ofdm); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - - -static ssize_t il_dbgfs_chain_noise_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - int cnt = 0; - char *buf; - int bufsz = sizeof(struct il_chain_noise_data) * 4 + 100; - ssize_t ret; - struct il_chain_noise_data *data; - - data = &il->chain_noise_data; - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", - data->active_chains); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", - data->chain_noise_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", - data->chain_noise_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", - data->chain_noise_c); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", - data->chain_signal_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", - data->chain_signal_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", - data->chain_signal_c); - pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", - data->beacon_count); - - pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); - for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->disconn_array[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); - for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->delta_gain_code[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", - data->radio_write); - pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", - data->state); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_power_save_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[60]; - int pos = 0; - const size_t bufsz = sizeof(buf); - u32 pwrsave_status; - - pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & - CSR_GP_REG_POWER_SAVE_STATUS_MSK; - - pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); - pos += scnprintf(buf + pos, bufsz - pos, "%s\n", - (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : - (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : - (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : - "error"); - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int clear; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &clear) != 1) - return -EFAULT; - - /* make request to uCode to retrieve stats information */ - mutex_lock(&il->mutex); - il_send_stats_request(il, CMD_SYNC, true); - mutex_unlock(&il->mutex); - - return count; -} - -static ssize_t il_dbgfs_rxon_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int len = 0; - char buf[20]; - - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.flags)); - return simple_read_from_buffer(user_buf, count, ppos, buf, len); -} - -static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int len = 0; - char buf[20]; - - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.filter_flags)); - return simple_read_from_buffer(user_buf, count, ppos, buf, len); -} - -static ssize_t il_dbgfs_fh_reg_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char *buf; - int pos = 0; - ssize_t ret = -EFAULT; - - if (il->cfg->ops->lib->dump_fh) { - ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); - if (buf) { - ret = simple_read_from_buffer(user_buf, - count, ppos, buf, pos); - kfree(buf); - } - } - - return ret; -} - -static ssize_t il_dbgfs_missed_beacon_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - char buf[12]; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "%d\n", - il->missed_beacon_threshold); - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_missed_beacon_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int missed; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &missed) != 1) - return -EINVAL; - - if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || - missed > IL_MISSED_BEACON_THRESHOLD_MAX) - il->missed_beacon_threshold = - IL_MISSED_BEACON_THRESHOLD_DEF; - else - il->missed_beacon_threshold = missed; - - return count; -} - -static ssize_t il_dbgfs_force_reset_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - char buf[300]; - const size_t bufsz = sizeof(buf); - struct il_force_reset *force_reset; - - force_reset = &il->force_reset; - - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request: %d\n", - force_reset->reset_request_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request success: %d\n", - force_reset->reset_success_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request reject: %d\n", - force_reset->reset_reject_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\treset duration: %lu\n", - force_reset->reset_duration); - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_force_reset_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { - - int ret; - struct il_priv *il = file->private_data; - - ret = il_force_reset(il, true); - - return ret ? ret : count; -} - -static ssize_t il_dbgfs_wd_timeout_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int timeout; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &timeout) != 1) - return -EINVAL; - if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) - timeout = IL_DEF_WD_TIMEOUT; - - il->cfg->base_params->wd_timeout = timeout; - il_setup_watchdog(il); - return count; -} - -DEBUGFS_READ_FILE_OPS(rx_stats); -DEBUGFS_READ_FILE_OPS(tx_stats); -DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); -DEBUGFS_READ_FILE_OPS(rx_queue); -DEBUGFS_READ_FILE_OPS(tx_queue); -DEBUGFS_READ_FILE_OPS(ucode_rx_stats); -DEBUGFS_READ_FILE_OPS(ucode_tx_stats); -DEBUGFS_READ_FILE_OPS(ucode_general_stats); -DEBUGFS_READ_FILE_OPS(sensitivity); -DEBUGFS_READ_FILE_OPS(chain_noise); -DEBUGFS_READ_FILE_OPS(power_save_status); -DEBUGFS_WRITE_FILE_OPS(clear_ucode_stats); -DEBUGFS_WRITE_FILE_OPS(clear_traffic_stats); -DEBUGFS_READ_FILE_OPS(fh_reg); -DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); -DEBUGFS_READ_WRITE_FILE_OPS(force_reset); -DEBUGFS_READ_FILE_OPS(rxon_flags); -DEBUGFS_READ_FILE_OPS(rxon_filter_flags); -DEBUGFS_WRITE_FILE_OPS(wd_timeout); - -/* - * Create the debugfs files and directories - * - */ -int il_dbgfs_register(struct il_priv *il, const char *name) -{ - struct dentry *phyd = il->hw->wiphy->debugfsdir; - struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; - - dir_drv = debugfs_create_dir(name, phyd); - if (!dir_drv) - return -ENOMEM; - - il->debugfs_dir = dir_drv; - - dir_data = debugfs_create_dir("data", dir_drv); - if (!dir_data) - goto err; - dir_rf = debugfs_create_dir("rf", dir_drv); - if (!dir_rf) - goto err; - dir_debug = debugfs_create_dir("debug", dir_drv); - if (!dir_debug) - goto err; - - DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(clear_ucode_stats, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(clear_traffic_stats, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); - - if (il->cfg->base_params->sensitivity_calib_by_driver) - DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); - if (il->cfg->base_params->chain_noise_calib_by_driver) - DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); - if (il->cfg->base_params->sensitivity_calib_by_driver) - DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, - &il->disable_sens_cal); - if (il->cfg->base_params->chain_noise_calib_by_driver) - DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, - &il->disable_chain_noise_cal); - DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, - &il->disable_tx_power_cal); - return 0; - -err: - IL_ERR("Can't create the debugfs directory\n"); - il_dbgfs_unregister(il); - return -ENOMEM; -} -EXPORT_SYMBOL(il_dbgfs_register); - -/** - * Remove the debugfs files and directories - * - */ -void il_dbgfs_unregister(struct il_priv *il) -{ - if (!il->debugfs_dir) - return; - - debugfs_remove_recursive(il->debugfs_dir); - il->debugfs_dir = NULL; -} -EXPORT_SYMBOL(il_dbgfs_unregister); -- cgit v0.10.2 From f02579e3a81954c8f0944c7d2a95159ee48f052d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:49:56 +0200 Subject: iwlegacy: merge iwl-debug.h into common.h Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index ed367bb..1a2430b 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -35,7 +35,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" -#include "iwl-debug.h" /* Highest firmware API version supported */ #define IL3945_UCODE_API_MAX 2 diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 10d0b13..a4e256b 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -30,8 +30,6 @@ #ifndef __il_4965_h__ #define __il_4965_h__ -#include "iwl-debug.h" - struct il_rx_queue; struct il_rx_buf; struct il_rx_pkt; diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index b4be3b4..05bd375 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -29,7 +29,7 @@ config IWLEGACY_DEBUG % echo 0x43fff > /sys/class/net/wlan0/device/debug_level You can find the list of debug mask values in: - drivers/net/wireless/iwlegacy/iwl-debug.h + drivers/net/wireless/iwlegacy/common.h If this is your first time using this driver, you should say Y here as the debug information can assist others in helping you resolve diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 5d5efcb4..627ac9b 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -40,7 +40,6 @@ #include #include -#include "iwl-debug.h" #include "common.h" const char *il_get_cmd_string(u8 cmd) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index be057aa..b1d237f 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -37,12 +37,15 @@ #include "commands.h" #include "csr.h" #include "prph.h" -#include "iwl-debug.h" struct il_host_cmd; struct il_cmd; struct il_tx_queue; +#define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) +#define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) +#define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) + #define RX_QUEUE_SIZE 256 #define RX_QUEUE_MASK 255 #define RX_QUEUE_SIZE_LOG 8 @@ -1515,29 +1518,6 @@ static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) clear_bit(txq_id, &il->txq_ctx_active_msk); } -#ifdef CONFIG_IWLEGACY_DEBUG -/* - * il_get_debug_level: Return active debug level for device - * - * Using sysfs it is possible to set per device debug level. This debug - * level will be used if set, otherwise the global debug level which can be - * set via module parameter is used. - */ -static inline u32 il_get_debug_level(struct il_priv *il) -{ - if (il->debug_level) - return il->debug_level; - else - return il_debug_level; -} -#else -static inline u32 il_get_debug_level(struct il_priv *il) -{ - return il_debug_level; -} -#endif - - static inline struct ieee80211_hdr * il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx) @@ -2736,18 +2716,15 @@ static inline void il_disable_interrupts(struct il_priv *il) * from uCode or flow handler (Rx/Tx DMA) */ _il_wr(il, CSR_INT, 0xffffffff); _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); - D_ISR("Disabled interrupts\n"); } static inline void il_enable_rfkill_int(struct il_priv *il) { - D_ISR("Enabling rfkill interrupt\n"); _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } static inline void il_enable_interrupts(struct il_priv *il) { - D_ISR("Enabling interrupts\n"); set_bit(S_INT_ENABLED, &il->status); _il_wr(il, CSR_INT_MASK, il->inta_mask); } @@ -3304,4 +3281,164 @@ extern void il3945_rate_control_unregister(void); extern int il_power_update_mode(struct il_priv *il, bool force); extern void il_power_initialize(struct il_priv *il); +extern u32 il_debug_level; + +#ifdef CONFIG_IWLEGACY_DEBUG +/* + * il_get_debug_level: Return active debug level for device + * + * Using sysfs it is possible to set per device debug level. This debug + * level will be used if set, otherwise the global debug level which can be + * set via module parameter is used. + */ +static inline u32 il_get_debug_level(struct il_priv *il) +{ + if (il->debug_level) + return il->debug_level; + else + return il_debug_level; +} +#else +static inline u32 il_get_debug_level(struct il_priv *il) +{ + return il_debug_level; +} +#endif + +#define il_print_hex_error(il, p, len) \ +do { \ + print_hex_dump(KERN_ERR, "iwl data: ", \ + DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ +} while (0) + +#ifdef CONFIG_IWLEGACY_DEBUG +#define IL_DBG(level, fmt, args...) \ +do { \ + if (il_get_debug_level(il) & level) \ + dev_printk(KERN_ERR, &il->hw->wiphy->dev, \ + "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ + __func__ , ## args); \ +} while (0) + +#define il_print_hex_dump(il, level, p, len) \ +do { \ + if (il_get_debug_level(il) & level) \ + print_hex_dump(KERN_DEBUG, "iwl data: ", \ + DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ +} while (0) + +#else +#define IL_DBG(level, fmt, args...) +static inline void il_print_hex_dump(struct il_priv *il, int level, + const void *p, u32 len) +{} +#endif /* CONFIG_IWLEGACY_DEBUG */ + +#ifdef CONFIG_IWLEGACY_DEBUGFS +int il_dbgfs_register(struct il_priv *il, const char *name); +void il_dbgfs_unregister(struct il_priv *il); +#else +static inline int +il_dbgfs_register(struct il_priv *il, const char *name) +{ + return 0; +} +static inline void il_dbgfs_unregister(struct il_priv *il) +{ +} +#endif /* CONFIG_IWLEGACY_DEBUGFS */ + +/* + * To use the debug system: + * + * If you are defining a new debug classification, simply add it to the #define + * list here in the form of + * + * #define IL_DL_xxxx VALUE + * + * where xxxx should be the name of the classification (for example, WEP). + * + * You then need to either add a IL_xxxx_DEBUG() macro definition for your + * classification, or use IL_DBG(IL_DL_xxxx, ...) whenever you want + * to send output to that classification. + * + * The active debug levels can be accessed via files + * + * /sys/module/iwl4965/parameters/debug + * /sys/module/iwl3945/parameters/debug + * /sys/class/net/wlan0/device/debug_level + * + * when CONFIG_IWLEGACY_DEBUG=y. + */ + +/* 0x0000000F - 0x00000001 */ +#define IL_DL_INFO (1 << 0) +#define IL_DL_MAC80211 (1 << 1) +#define IL_DL_HCMD (1 << 2) +#define IL_DL_STATE (1 << 3) +/* 0x000000F0 - 0x00000010 */ +#define IL_DL_MACDUMP (1 << 4) +#define IL_DL_HCMD_DUMP (1 << 5) +#define IL_DL_EEPROM (1 << 6) +#define IL_DL_RADIO (1 << 7) +/* 0x00000F00 - 0x00000100 */ +#define IL_DL_POWER (1 << 8) +#define IL_DL_TEMP (1 << 9) +#define IL_DL_NOTIF (1 << 10) +#define IL_DL_SCAN (1 << 11) +/* 0x0000F000 - 0x00001000 */ +#define IL_DL_ASSOC (1 << 12) +#define IL_DL_DROP (1 << 13) +#define IL_DL_TXPOWER (1 << 14) +#define IL_DL_AP (1 << 15) +/* 0x000F0000 - 0x00010000 */ +#define IL_DL_FW (1 << 16) +#define IL_DL_RF_KILL (1 << 17) +#define IL_DL_FW_ERRORS (1 << 18) +#define IL_DL_LED (1 << 19) +/* 0x00F00000 - 0x00100000 */ +#define IL_DL_RATE (1 << 20) +#define IL_DL_CALIB (1 << 21) +#define IL_DL_WEP (1 << 22) +#define IL_DL_TX (1 << 23) +/* 0x0F000000 - 0x01000000 */ +#define IL_DL_RX (1 << 24) +#define IL_DL_ISR (1 << 25) +#define IL_DL_HT (1 << 26) +/* 0xF0000000 - 0x10000000 */ +#define IL_DL_11H (1 << 28) +#define IL_DL_STATS (1 << 29) +#define IL_DL_TX_REPLY (1 << 30) +#define IL_DL_QOS (1 << 31) + +#define D_INFO(f, a...) IL_DBG(IL_DL_INFO, f, ## a) +#define D_MAC80211(f, a...) IL_DBG(IL_DL_MAC80211, f, ## a) +#define D_MACDUMP(f, a...) IL_DBG(IL_DL_MACDUMP, f, ## a) +#define D_TEMP(f, a...) IL_DBG(IL_DL_TEMP, f, ## a) +#define D_SCAN(f, a...) IL_DBG(IL_DL_SCAN, f, ## a) +#define D_RX(f, a...) IL_DBG(IL_DL_RX, f, ## a) +#define D_TX(f, a...) IL_DBG(IL_DL_TX, f, ## a) +#define D_ISR(f, a...) IL_DBG(IL_DL_ISR, f, ## a) +#define D_LED(f, a...) IL_DBG(IL_DL_LED, f, ## a) +#define D_WEP(f, a...) IL_DBG(IL_DL_WEP, f, ## a) +#define D_HC(f, a...) IL_DBG(IL_DL_HCMD, f, ## a) +#define D_HC_DUMP(f, a...) IL_DBG(IL_DL_HCMD_DUMP, f, ## a) +#define D_EEPROM(f, a...) IL_DBG(IL_DL_EEPROM, f, ## a) +#define D_CALIB(f, a...) IL_DBG(IL_DL_CALIB, f, ## a) +#define D_FW(f, a...) IL_DBG(IL_DL_FW, f, ## a) +#define D_RF_KILL(f, a...) IL_DBG(IL_DL_RF_KILL, f, ## a) +#define D_DROP(f, a...) IL_DBG(IL_DL_DROP, f, ## a) +#define D_AP(f, a...) IL_DBG(IL_DL_AP, f, ## a) +#define D_TXPOWER(f, a...) IL_DBG(IL_DL_TXPOWER, f, ## a) +#define D_RATE(f, a...) IL_DBG(IL_DL_RATE, f, ## a) +#define D_NOTIF(f, a...) IL_DBG(IL_DL_NOTIF, f, ## a) +#define D_ASSOC(f, a...) IL_DBG(IL_DL_ASSOC, f, ## a) +#define D_HT(f, a...) IL_DBG(IL_DL_HT, f, ## a) +#define D_STATS(f, a...) IL_DBG(IL_DL_STATS, f, ## a) +#define D_TX_REPLY(f, a...) IL_DBG(IL_DL_TX_REPLY, f, ## a) +#define D_QOS(f, a...) IL_DBG(IL_DL_QOS, f, ## a) +#define D_RADIO(f, a...) IL_DBG(IL_DL_RADIO, f, ## a) +#define D_POWER(f, a...) IL_DBG(IL_DL_POWER, f, ## a) +#define D_11H(f, a...) IL_DBG(IL_DL_11H, f, ## a) + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 62292a6..4e2b6c8 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -28,8 +28,6 @@ #include #include - -#include "iwl-debug.h" #include "common.h" /* create and remove of files */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h deleted file mode 100644 index c58003a..0000000 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ /dev/null @@ -1,175 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_debug_h__ -#define __il_debug_h__ - -struct il_priv; -extern u32 il_debug_level; - -#define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) -#define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) -#define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) - -#define il_print_hex_error(il, p, len) \ -do { \ - print_hex_dump(KERN_ERR, "iwl data: ", \ - DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ -} while (0) - -#ifdef CONFIG_IWLEGACY_DEBUG -#define IL_DBG(level, fmt, args...) \ -do { \ - if (il_get_debug_level(il) & level) \ - dev_printk(KERN_ERR, &il->hw->wiphy->dev, \ - "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ - __func__ , ## args); \ -} while (0) - -#define il_print_hex_dump(il, level, p, len) \ -do { \ - if (il_get_debug_level(il) & level) \ - print_hex_dump(KERN_DEBUG, "iwl data: ", \ - DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ -} while (0) - -#else -#define IL_DBG(level, fmt, args...) -static inline void il_print_hex_dump(struct il_priv *il, int level, - const void *p, u32 len) -{} -#endif /* CONFIG_IWLEGACY_DEBUG */ - -#ifdef CONFIG_IWLEGACY_DEBUGFS -int il_dbgfs_register(struct il_priv *il, const char *name); -void il_dbgfs_unregister(struct il_priv *il); -#else -static inline int -il_dbgfs_register(struct il_priv *il, const char *name) -{ - return 0; -} -static inline void il_dbgfs_unregister(struct il_priv *il) -{ -} -#endif /* CONFIG_IWLEGACY_DEBUGFS */ - -/* - * To use the debug system: - * - * If you are defining a new debug classification, simply add it to the #define - * list here in the form of - * - * #define IL_DL_xxxx VALUE - * - * where xxxx should be the name of the classification (for example, WEP). - * - * You then need to either add a IL_xxxx_DEBUG() macro definition for your - * classification, or use IL_DBG(IL_DL_xxxx, ...) whenever you want - * to send output to that classification. - * - * The active debug levels can be accessed via files - * - * /sys/module/iwl4965/parameters/debug - * /sys/module/iwl3945/parameters/debug - * /sys/class/net/wlan0/device/debug_level - * - * when CONFIG_IWLEGACY_DEBUG=y. - */ - -/* 0x0000000F - 0x00000001 */ -#define IL_DL_INFO (1 << 0) -#define IL_DL_MAC80211 (1 << 1) -#define IL_DL_HCMD (1 << 2) -#define IL_DL_STATE (1 << 3) -/* 0x000000F0 - 0x00000010 */ -#define IL_DL_MACDUMP (1 << 4) -#define IL_DL_HCMD_DUMP (1 << 5) -#define IL_DL_EEPROM (1 << 6) -#define IL_DL_RADIO (1 << 7) -/* 0x00000F00 - 0x00000100 */ -#define IL_DL_POWER (1 << 8) -#define IL_DL_TEMP (1 << 9) -#define IL_DL_NOTIF (1 << 10) -#define IL_DL_SCAN (1 << 11) -/* 0x0000F000 - 0x00001000 */ -#define IL_DL_ASSOC (1 << 12) -#define IL_DL_DROP (1 << 13) -#define IL_DL_TXPOWER (1 << 14) -#define IL_DL_AP (1 << 15) -/* 0x000F0000 - 0x00010000 */ -#define IL_DL_FW (1 << 16) -#define IL_DL_RF_KILL (1 << 17) -#define IL_DL_FW_ERRORS (1 << 18) -#define IL_DL_LED (1 << 19) -/* 0x00F00000 - 0x00100000 */ -#define IL_DL_RATE (1 << 20) -#define IL_DL_CALIB (1 << 21) -#define IL_DL_WEP (1 << 22) -#define IL_DL_TX (1 << 23) -/* 0x0F000000 - 0x01000000 */ -#define IL_DL_RX (1 << 24) -#define IL_DL_ISR (1 << 25) -#define IL_DL_HT (1 << 26) -/* 0xF0000000 - 0x10000000 */ -#define IL_DL_11H (1 << 28) -#define IL_DL_STATS (1 << 29) -#define IL_DL_TX_REPLY (1 << 30) -#define IL_DL_QOS (1 << 31) - -#define D_INFO(f, a...) IL_DBG(IL_DL_INFO, f, ## a) -#define D_MAC80211(f, a...) IL_DBG(IL_DL_MAC80211, f, ## a) -#define D_MACDUMP(f, a...) IL_DBG(IL_DL_MACDUMP, f, ## a) -#define D_TEMP(f, a...) IL_DBG(IL_DL_TEMP, f, ## a) -#define D_SCAN(f, a...) IL_DBG(IL_DL_SCAN, f, ## a) -#define D_RX(f, a...) IL_DBG(IL_DL_RX, f, ## a) -#define D_TX(f, a...) IL_DBG(IL_DL_TX, f, ## a) -#define D_ISR(f, a...) IL_DBG(IL_DL_ISR, f, ## a) -#define D_LED(f, a...) IL_DBG(IL_DL_LED, f, ## a) -#define D_WEP(f, a...) IL_DBG(IL_DL_WEP, f, ## a) -#define D_HC(f, a...) IL_DBG(IL_DL_HCMD, f, ## a) -#define D_HC_DUMP(f, a...) IL_DBG(IL_DL_HCMD_DUMP, f, ## a) -#define D_EEPROM(f, a...) IL_DBG(IL_DL_EEPROM, f, ## a) -#define D_CALIB(f, a...) IL_DBG(IL_DL_CALIB, f, ## a) -#define D_FW(f, a...) IL_DBG(IL_DL_FW, f, ## a) -#define D_RF_KILL(f, a...) IL_DBG(IL_DL_RF_KILL, f, ## a) -#define D_DROP(f, a...) IL_DBG(IL_DL_DROP, f, ## a) -#define D_AP(f, a...) IL_DBG(IL_DL_AP, f, ## a) -#define D_TXPOWER(f, a...) IL_DBG(IL_DL_TXPOWER, f, ## a) -#define D_RATE(f, a...) IL_DBG(IL_DL_RATE, f, ## a) -#define D_NOTIF(f, a...) IL_DBG(IL_DL_NOTIF, f, ## a) -#define D_ASSOC(f, a...) IL_DBG(IL_DL_ASSOC, f, ## a) -#define D_HT(f, a...) IL_DBG(IL_DL_HT, f, ## a) -#define D_STATS(f, a...) IL_DBG(IL_DL_STATS, f, ## a) -#define D_TX_REPLY(f, a...) IL_DBG(IL_DL_TX_REPLY, f, ## a) -#define D_QOS(f, a...) IL_DBG(IL_DL_QOS, f, ## a) -#define D_RADIO(f, a...) IL_DBG(IL_DL_RADIO, f, ## a) -#define D_POWER(f, a...) IL_DBG(IL_DL_POWER, f, ## a) -#define D_11H(f, a...) IL_DBG(IL_DL_11H, f, ## a) - -#endif -- cgit v0.10.2 From e7392364fcd1004a5e495f15cf21b1e0ef874215 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:45:59 +0100 Subject: iwlegacy: indentions and whitespaces Process iwlegacy source files using: indent -npro -l500 -nhnl indent -npro -kr -i8 -ts8 -sob -l80 -nbbo -ss -ncs -cp1 -il0 -psl Plus manual compilation fixes. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 1a690a0..382af2e 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -29,39 +29,37 @@ #include "common.h" #include "3945.h" -static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) +static int +il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", le32_to_cpu(il->_3945.stats.flag)); - if (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATS_CLEAR_MSK) + if (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); + UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); + UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; } -ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il3945_ucode_rx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + - sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; + int bufsz = + sizeof(struct iwl39_stats_rx_phy) * 40 + + sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; ssize_t ret; - struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, - *max_ofdm; + struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; struct iwl39_stats_rx_non_phy *general, *accum_general; struct iwl39_stats_rx_non_phy *delta_general, *max_general; @@ -94,240 +92,230 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, max_general = &il->_3945.max_delta.rx.general; pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, - delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, - delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, - delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, - delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - OFDM:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "ina_cnt:", + le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "overrun_err:", + le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err, + delta_ofdm->overrun_err, max_ofdm->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_good:", + le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good, + delta_ofdm->crc32_good, max_ofdm->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout, + delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout, + delta_ofdm->fina_timeout, max_ofdm->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt, + delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt, + delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, - delta_cck->overrun_err, max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, - max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, - delta_cck->sfd_timeout, max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, - delta_cck->fina_timeout, max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, - delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, - delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, - delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - CCK:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "overrun_err:", + le32_to_cpu(cck->overrun_err), accum_cck->overrun_err, + delta_cck->overrun_err, max_cck->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, max_cck->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, max_cck->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt, + max_cck->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout, + delta_cck->sfd_timeout, max_cck->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_timeout:", + le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout, + delta_cck->fina_timeout, max_cck->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt, + delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt, + delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, - delta_general->bogus_cts, max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, - delta_general->bogus_ack, max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - GENERAL:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bogus_cts:", + le32_to_cpu(general->bogus_cts), accum_general->bogus_cts, + delta_general->bogus_cts, max_general->bogus_cts); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bogus_ack:", + le32_to_cpu(general->bogus_ack), accum_general->bogus_ack, + delta_general->bogus_ack, max_general->bogus_ack); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il3945_ucode_tx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -355,75 +343,69 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, delta_tx = &il->_3945.delta_stats.tx; max_tx = &il->_3945.max_delta.tx; pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Tx:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "preamble:", + le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt, + max_tx->rx_detected_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "ack_timeout:", + le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il3945_ucode_general_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -462,61 +444,61 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, delta_div = &il->_3945.delta_stats.general.div; max_div = &il->_3945.max_delta.general.div; pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_General:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "burst_check:", + le32_to_cpu(dbg->burst_check), accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "burst_count:", + le32_to_cpu(dbg->burst_count), accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, delta_general->sleep_time, + max_general->sleep_time); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "slots_out:", + le32_to_cpu(general->slots_out), accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, delta_general->slots_idle, + max_general->slots_idle); + pos += + scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", + le32_to_cpu(general->ttl_timestamp)); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index ffd6ddf..2249fe4 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -102,7 +102,8 @@ struct il_mod_params il3945_mod_params = { * IL_ANTENNA_MAIN - Force MAIN antenna * IL_ANTENNA_AUX - Force AUX antenna */ -__le32 il3945_get_antenna_flags(const struct il_priv *il) +__le32 +il3945_get_antenna_flags(const struct il_priv *il) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -123,14 +124,14 @@ __le32 il3945_get_antenna_flags(const struct il_priv *il) /* bad antenna selector value */ IL_ERR("Bad antenna selector value (0x%x)\n", - il3945_mod_params.antenna); + il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ } -static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il3945_set_ccmp_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; @@ -149,21 +150,19 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].keyinfo.cipher = keyconf->cipher; il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ + * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; @@ -171,49 +170,50 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, D_INFO("hwcrypto: modify ucode station key info\n"); - ret = il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); + ret = il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il3945_set_tkip_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_set_wep_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il3945_set_wep_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) +static int +il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) { unsigned long flags; struct il_addsta_cmd sta_cmd; spin_lock_irqsave(&il->sta_lock, flags); memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); D_INFO("hwcrypto: clear ucode station key info\n"); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il3945_set_dynamic_key(struct il_priv *il, - struct ieee80211_key_conf *keyconf, u8 sta_id) +static int +il3945_set_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, + u8 sta_id) { int ret = 0; @@ -231,27 +231,26 @@ static int il3945_set_dynamic_key(struct il_priv *il, ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); break; default: - IL_ERR("Unknown alg: %s alg=%x\n", __func__, - keyconf->cipher); + IL_ERR("Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); + keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } -static int il3945_remove_static_key(struct il_priv *il) +static int +il3945_remove_static_key(struct il_priv *il) { int ret = -EOPNOTSUPP; return ret; } -static int il3945_set_static_key(struct il_priv *il, - struct ieee80211_key_conf *key) +static int +il3945_set_static_key(struct il_priv *il, struct ieee80211_key_conf *key) { if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) @@ -261,12 +260,12 @@ static int il3945_set_static_key(struct il_priv *il, return -EINVAL; } -static void il3945_clear_free_frames(struct il_priv *il) +static void +il3945_clear_free_frames(struct il_priv *il) { struct list_head *element; - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { element = il->free_frames.next; @@ -277,12 +276,13 @@ static void il3945_clear_free_frames(struct il_priv *il) if (il->frames_count) { IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); + il->frames_count); il->frames_count = 0; } } -static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) +static struct il3945_frame * +il3945_get_free_frame(struct il_priv *il) { struct il3945_frame *frame; struct list_head *element; @@ -302,15 +302,16 @@ static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) return list_entry(element, struct il3945_frame, list); } -static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) +static void +il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &il->free_frames); } -unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) +unsigned int +il3945_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, + int left) { if (!il_is_associated(il) || !il->beacon_skb) @@ -324,7 +325,8 @@ unsigned int il3945_fill_beacon_frame(struct il_priv *il, return il->beacon_skb->len; } -static int il3945_send_beacon_cmd(struct il_priv *il) +static int +il3945_send_beacon_cmd(struct il_priv *il) { struct il3945_frame *frame; unsigned int frame_size; @@ -335,37 +337,34 @@ static int il3945_send_beacon_cmd(struct il_priv *il) if (!frame) { IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); + "command.\n"); return -ENOMEM; } - rate = il_get_lowest_plcp(il, - &il->ctx); + rate = il_get_lowest_plcp(il, &il->ctx); frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, - &frame->u.cmd[0]); + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il3945_free_frame(il, frame); return rc; } -static void il3945_unset_hw_params(struct il_priv *il) +static void +il3945_unset_hw_params(struct il_priv *il) { if (il->_3945.shared_virt) dma_free_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), - il->_3945.shared_virt, - il->_3945.shared_phys); + il->_3945.shared_virt, il->_3945.shared_phys); } -static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_device_cmd *cmd, - struct sk_buff *skb_frag, - int sta_id) +static void +il3945_build_tx_cmd_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, + struct il_device_cmd *cmd, + struct sk_buff *skb_frag, int sta_id) { struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; @@ -386,13 +385,15 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; /* fall through */ case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= TX_CMD_SEC_WEP | - (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; + tx_cmd->sec_ctl |= + TX_CMD_SEC_WEP | (info->control.hw_key-> + hw_key_idx & TX_CMD_SEC_MSK) << + TX_CMD_SEC_SHIFT; memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - D_TX("Configuring packet for WEP encryption " - "with key %d\n", info->control.hw_key->hw_key_idx); + D_TX("Configuring packet for WEP encryption " "with key %d\n", + info->control.hw_key->hw_key_idx); break; default: @@ -404,10 +405,10 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, /* * handle build C_TX command notification. */ -static void il3945_build_tx_cmd_basic(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, u8 std_id) +static void +il3945_build_tx_cmd_basic(struct il_priv *il, struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, u8 std_id) { struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; __le32 tx_flags = tx_cmd->tx_flags; @@ -458,7 +459,8 @@ static void il3945_build_tx_cmd_basic(struct il_priv *il, /* * start C_TX command process */ -static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) +static int +il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -485,7 +487,8 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) goto drop_unlock; } - if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == + IL_INVALID_RATE) { IL_ERR("ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -509,12 +512,9 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) hdr_len = ieee80211_hdrlen(fc); /* Find idx into station table for destination station */ - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, - info->control.sta); + sta_id = il_sta_id_or_broadcast(il, &il->ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } @@ -557,13 +557,13 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) * locate the frame within the tx queue and do post-tx processing. */ out_cmd->hdr.cmd = C_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); + out_cmd->hdr.sequence = + cpu_to_le16((u16) + (QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); - if (info->control.hw_key) il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); @@ -574,7 +574,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); /* Total # bytes to be transmitted */ - len = (u16)skb->len; + len = (u16) skb->len; tx_cmd->len = cpu_to_le16(len); il_dbg_log_tx_data_frame(il, len, hdr); @@ -589,12 +589,11 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) txq->need_update = 0; } - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, - ieee80211_hdrlen(fc)); + il_print_hex_dump(il, IL_DL_TX, (u8 *) tx_cmd->hdr, + ieee80211_hdrlen(fc)); /* * Use the first empty entry in this queue's command buffer array @@ -605,14 +604,15 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct il3945_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; + len = + sizeof(struct il3945_tx_cmd) + sizeof(struct il_cmd_header) + + hdr_len; len = (len + 3) & ~3; /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, - len, PCI_DMA_TODEVICE); + txcmd_phys = + pci_map_single(il->pci_dev, &out_cmd->hdr, len, PCI_DMA_TODEVICE); /* we do not map meta data ... so we can safely access address to * provide to unmap command*/ dma_unmap_addr_set(out_meta, mapping, txcmd_phys); @@ -620,29 +620,26 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, len, 1, 0); - + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, + 0); /* Set up TFD's 2nd entry to point directly to remainder of skb, * if any (802.11 null frames have no payload). */ len = skb->len - hdr_len; if (len) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - len, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, len, - 0, U32_PAD(len)); + phys_addr = + pci_map_single(il->pci_dev, skb->data + hdr_len, len, + PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, + len, 0, U32_PAD(len)); } - /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); - if (il_queue_space(q) < q->high_mark - && il->mac80211_registered) { + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; @@ -661,9 +658,9 @@ drop: return -1; } -static int il3945_get_measurement(struct il_priv *il, - struct ieee80211_measurement_params *params, - u8 type) +static int +il3945_get_measurement(struct il_priv *il, + struct ieee80211_measurement_params *params, u8 type) { struct il_spectrum_cmd spectrum; struct il_rx_pkt *pkt; @@ -679,9 +676,12 @@ static int il3945_get_measurement(struct il_priv *il, struct il_rxon_context *ctx = &il->ctx; if (il_is_associated(il)) - add_time = il_usecs_to_beacons(il, - le64_to_cpu(params->start_time) - il->_3945.last_tsf, - le16_to_cpu(ctx->timing.beacon_interval)); + add_time = + il_usecs_to_beacons(il, + le64_to_cpu(params->start_time) - + il->_3945.last_tsf, + le16_to_cpu(ctx->timing. + beacon_interval)); memset(&spectrum, 0, sizeof(spectrum)); @@ -694,9 +694,9 @@ static int il3945_get_measurement(struct il_priv *il, if (il_is_associated(il)) spectrum.start_time = - il_add_beacon_time(il, - il->_3945.last_beacon_time, add_time, - le16_to_cpu(ctx->timing.beacon_interval)); + il_add_beacon_time(il, il->_3945.last_beacon_time, add_time, + le16_to_cpu(ctx->timing. + beacon_interval)); else spectrum.start_time = 0; @@ -704,8 +704,9 @@ static int il3945_get_measurement(struct il_priv *il, spectrum.channels[0].channel = params->channel; spectrum.channels[0].type = type; if (ctx->active.flags & RXON_FLG_BAND_24G_MSK) - spectrum.flags |= RXON_FLG_BAND_24G_MSK | - RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; + spectrum.flags |= + RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | + RXON_FLG_TGG_PROTECT_MSK; rc = il_send_cmd_sync(il, &cmd); if (rc) @@ -722,7 +723,7 @@ static int il3945_get_measurement(struct il_priv *il, case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { D_INFO("Replaced existing measurement: %d\n", - pkt->u.spectrum.id); + pkt->u.spectrum.id); il->measurement_status &= ~MEASUREMENT_READY; } il->measurement_status |= MEASUREMENT_ACTIVE; @@ -739,8 +740,8 @@ static int il3945_get_measurement(struct il_priv *il, return rc; } -static void il3945_hdl_alive(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -748,10 +749,8 @@ static void il3945_hdl_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { D_INFO("Initialization Alive received.\n"); @@ -769,14 +768,13 @@ static void il3945_hdl_alive(struct il_priv *il, /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else IL_WARN("uCode did not respond OK.\n"); } -static void il3945_hdl_add_sta(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_add_sta(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -785,21 +783,19 @@ static void il3945_hdl_add_sta(struct il_priv *il, D_RX("Received C_ADD_STA: 0x%02X\n", pkt->u.status); } -static void il3945_hdl_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); #ifdef CONFIG_IWLEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); #endif il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); @@ -808,32 +804,30 @@ static void il3945_hdl_beacon(struct il_priv *il, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il3945_hdl_card_state(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; IL_WARN("Card state received: HW:%s SW:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On"); + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) set_bit(S_RF_KILL_HW, &il->status); else clear_bit(S_RF_KILL_HW, &il->status); - il_scan_cancel(il); if ((test_bit(S_RF_KILL_HW, &status) != test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -847,17 +841,16 @@ static void il3945_hdl_card_state(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il3945_setup_handlers(struct il_priv *il) +static void +il3945_setup_handlers(struct il_priv *il) { il->handlers[N_ALIVE] = il3945_hdl_alive; il->handlers[C_ADD_STA] = il3945_hdl_add_sta; il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; - il->handlers[N_SPECTRUM_MEASUREMENT] = - il_hdl_spectrum_measurement; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_hdl_spectrum_measurement; il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; - il->handlers[N_PM_DEBUG_STATS] = - il_hdl_pm_debug_stats; + il->handlers[N_PM_DEBUG_STATS] = il_hdl_pm_debug_stats; il->handlers[N_BEACON] = il3945_hdl_beacon; /* @@ -942,10 +935,10 @@ static void il3945_setup_handlers(struct il_priv *il) /** * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) +static inline __le32 +il3945_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { - return cpu_to_le32((u32)dma_addr); + return cpu_to_le32((u32) dma_addr); } /** @@ -959,7 +952,8 @@ static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, * also updates the memory address in the firmware to reference the new * target buffer. */ -static void il3945_rx_queue_restock(struct il_priv *il) +static void +il3945_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -976,7 +970,8 @@ static void il3945_rx_queue_restock(struct il_priv *il) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); + rxq->bd[rxq->write] = + il3945_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -987,7 +982,6 @@ static void il3945_rx_queue_restock(struct il_priv *il) if (rxq->free_count <= RX_LOW_WATERMARK) queue_work(il->workqueue, &il->rx_replenish); - /* If we've added more space for the firmware to place data, tell it. * Increment device's write pointer in multiples of 8. */ if (rxq->write_actual != (rxq->write & ~0x7) || @@ -1007,7 +1001,8 @@ static void il3945_rx_queue_restock(struct il_priv *il) * Also restock the Rx queue via il3945_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) +static void +il3945_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -1038,9 +1033,11 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) - IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); + IL_ERR + ("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + priority == + GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); /* We don't reschedule replenish work here -- we will * call the restock method and if it still needs * more buffers it will schedule replenish */ @@ -1060,9 +1057,10 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) rxb->page = page; /* Get physical address of RB/SKB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); spin_lock_irqsave(&rxq->lock, flags); @@ -1074,7 +1072,8 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) } } -void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +void +il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -1087,8 +1086,8 @@ void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -1103,7 +1102,8 @@ void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -void il3945_rx_replenish(void *data) +void +il3945_rx_replenish(void *data) { struct il_priv *il = data; unsigned long flags; @@ -1115,27 +1115,28 @@ void il3945_rx_replenish(void *data) spin_unlock_irqrestore(&il->lock, flags); } -static void il3945_rx_replenish_now(struct il_priv *il) +static void +il3945_rx_replenish_now(struct il_priv *il) { il3945_rx_allocate(il, GFP_ATOMIC); il3945_rx_queue_restock(il); } - /* Assumes that the skb field of the buffers in 'pool' is kept accurate. * If an SKB has been detached, the POOL needs to have its SKB set to NULL * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +static void +il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -1146,29 +1147,29 @@ static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; - rxq->rb_stts = NULL; + rxq->rb_stts = NULL; } - /* Convert linear signal-to-noise ratio into dB */ static u8 ratio2dB[100] = { /* 0 1 2 3 4 5 6 7 8 9 */ - 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ - 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ - 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ - 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ - 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ - 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ - 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ - 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ - 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ - 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ + 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ + 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ + 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ + 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ + 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ + 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ + 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ + 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ + 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ + 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ }; /* Calculates a relative dB value from a ratio of linear * (i.e. not dB) signal levels. * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ -int il3945_calc_db_from_ratio(int sig_ratio) +int +il3945_calc_db_from_ratio(int sig_ratio) { /* 1000:1 or higher just report as 60 dB */ if (sig_ratio >= 1000) @@ -1177,7 +1178,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) /* 100:1 or higher, divide by 10 and use table, * add 20 dB to make up for divide by 10 */ if (sig_ratio >= 100) - return 20 + (int)ratio2dB[sig_ratio/10]; + return 20 + (int)ratio2dB[sig_ratio / 10]; /* We shouldn't see this */ if (sig_ratio < 1) @@ -1194,7 +1195,8 @@ int il3945_calc_db_from_ratio(int sig_ratio) * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -static void il3945_rx_handle(struct il_priv *il) +static void +il3945_rx_handle(struct il_priv *il) { struct il_rx_buf *rxb; struct il_rx_pkt *pkt; @@ -1208,7 +1210,7 @@ static void il3945_rx_handle(struct il_priv *il) /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; /* calculate total frames need to be restock after handling RX */ @@ -1240,7 +1242,7 @@ static void il3945_rx_handle(struct il_priv *il) pkt = rxb_addr(rxb); len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ + len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -1249,23 +1251,20 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != N_STATS && - pkt->hdr.cmd != C_TX; + pkt->hdr.cmd != N_STATS && pkt->hdr.cmd != C_TX; /* Based on type of command response or notification, * handle those that need handling via function in * handlers table. See il3945_setup_handlers() */ if (il->handlers[pkt->hdr.cmd]) { D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, - il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.handlers[pkt->hdr.cmd]++; il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); + D_RX("r %d i %d No handler needed for %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } /* @@ -1290,9 +1289,10 @@ static void il3945_rx_handle(struct il_priv *il) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, rxb->page, 0, + PAGE_SIZE << il->hw_params. + rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; } else @@ -1322,14 +1322,16 @@ static void il3945_rx_handle(struct il_priv *il) } /* call this function to flush any scheduled tasklet */ -static inline void il3945_synchronize_irq(struct il_priv *il) +static inline void +il3945_synchronize_irq(struct il_priv *il) { - /* wait to make sure we flush pending tasklet*/ + /* wait to make sure we flush pending tasklet */ synchronize_irq(il->pci_dev->irq); tasklet_kill(&il->irq_tasklet); } -static const char *il3945_desc_lookup(int i) +static const char * +il3945_desc_lookup(int i) { switch (i) { case 1: @@ -1352,7 +1354,8 @@ static const char *il3945_desc_lookup(int i) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il3945_dump_nic_error_log(struct il_priv *il) +void +il3945_dump_nic_error_log(struct il_priv *il) { u32 i; u32 desc, time, count, base, data1; @@ -1365,42 +1368,34 @@ void il3945_dump_nic_error_log(struct il_priv *il) return; } - count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } IL_ERR("Desc Time asrtPC blink2 " - "ilink1 nmiPC Line\n"); + "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; i += ERROR_ELEM_SIZE) { desc = il_read_targ_mem(il, base + i); - time = - il_read_targ_mem(il, base + i + 1 * sizeof(u32)); - blink1 = - il_read_targ_mem(il, base + i + 2 * sizeof(u32)); - blink2 = - il_read_targ_mem(il, base + i + 3 * sizeof(u32)); - ilink1 = - il_read_targ_mem(il, base + i + 4 * sizeof(u32)); - ilink2 = - il_read_targ_mem(il, base + i + 5 * sizeof(u32)); - data1 = - il_read_targ_mem(il, base + i + 6 * sizeof(u32)); + time = il_read_targ_mem(il, base + i + 1 * sizeof(u32)); + blink1 = il_read_targ_mem(il, base + i + 2 * sizeof(u32)); + blink2 = il_read_targ_mem(il, base + i + 3 * sizeof(u32)); + ilink1 = il_read_targ_mem(il, base + i + 4 * sizeof(u32)); + ilink2 = il_read_targ_mem(il, base + i + 5 * sizeof(u32)); + data1 = il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - IL_ERR( - "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", - il3945_desc_lookup(desc), desc, time, blink1, blink2, - ilink1, ilink2, data1); + IL_ERR("%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", + il3945_desc_lookup(desc), desc, time, blink1, blink2, + ilink1, ilink2, data1); } } -static void il3945_irq_tasklet(struct il_priv *il) +static void +il3945_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -1427,8 +1422,8 @@ static void il3945_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, + inta_mask, inta_fh); } #endif @@ -1457,13 +1452,12 @@ static void il3945_irq_tasklet(struct il_priv *il) return; } - #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); + "the frame/frames.\n"); il->isr_stats.sch++; } @@ -1479,8 +1473,8 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - "Restarting 0x%X.\n", inta); + IL_ERR("Microcode SW error detected. " "Restarting 0x%X.\n", + inta); il->isr_stats.sw++; il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; @@ -1515,8 +1509,7 @@ static void il3945_irq_tasklet(struct il_priv *il) il->isr_stats.tx++; _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); - il_wr(il, FH39_TCSR_CREDIT - (FH39_SRVC_CHNL), 0x0); + il_wr(il, FH39_TCSR_CREDIT(FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } @@ -1527,7 +1520,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (inta & ~il->inta_mask) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); + inta & ~il->inta_mask); IL_WARN(" with inta_fh = 0x%08x\n", inta_fh); } @@ -1542,16 +1535,16 @@ static void il3945_irq_tasklet(struct il_priv *il) inta_mask = _il_rd(il, CSR_INT_MASK); inta_fh = _il_rd(il, CSR_FH_INT_STATUS); D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } -static int il3945_get_channels_for_scan(struct il_priv *il, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il3945_scan_channel *scan_ch, - struct ieee80211_vif *vif) +static int +il3945_get_channels_for_scan(struct il_priv *il, enum ieee80211_band band, + u8 is_active, u8 n_probes, + struct il3945_scan_channel *scan_ch, + struct ieee80211_vif *vif) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; @@ -1578,11 +1571,9 @@ static int il3945_get_channels_for_scan(struct il_priv *il, scan_ch->channel = chan->hw_value; - ch_info = il_get_channel_info(il, band, - scan_ch->channel); + ch_info = il_get_channel_info(il, band, scan_ch->channel); if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", + D_SCAN("Channel %d is INVALID for this band.\n", scan_ch->channel); continue; } @@ -1596,7 +1587,8 @@ static int il3945_get_channels_for_scan(struct il_priv *il, (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { scan_ch->type = 0; /* passive */ if (IL_UCODE_API(il->ucode_ver) == 1) - scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); + scan_ch->active_dwell = + cpu_to_le16(passive_dwell - 1); } else { scan_ch->type = 1; /* active */ } @@ -1630,11 +1622,9 @@ static int il3945_get_channels_for_scan(struct il_priv *il, */ } - D_SCAN("Scanning %d [%s %d]\n", - scan_ch->channel, - (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", - (scan_ch->type & 1) ? - active_dwell : passive_dwell); + D_SCAN("Scanning %d [%s %d]\n", scan_ch->channel, + (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", + (scan_ch->type & 1) ? active_dwell : passive_dwell); scan_ch++; added++; @@ -1644,22 +1634,23 @@ static int il3945_get_channels_for_scan(struct il_priv *il, return added; } -static void il3945_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) +static void +il3945_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il3945_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { /* * If CCK != 1M then set short preamble rate flag. */ - rates[i].flags |= (il3945_rates[i].plcp == 10) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; + rates[i].flags |= + (il3945_rates[i].plcp == + 10) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } } @@ -1670,7 +1661,8 @@ static void il3945_init_hw_rates(struct il_priv *il, * ******************************************************************************/ -static void il3945_dealloc_ucode_pci(struct il_priv *il) +static void +il3945_dealloc_ucode_pci(struct il_priv *il) { il_free_fw_desc(il->pci_dev, &il->ucode_code); il_free_fw_desc(il->pci_dev, &il->ucode_data); @@ -1684,7 +1676,8 @@ static void il3945_dealloc_ucode_pci(struct il_priv *il) * il3945_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) +static int +il3945_verify_inst_full(struct il_priv *il, __le32 * image, u32 len) { u32 val; u32 save_len = len; @@ -1693,8 +1686,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - il_wr(il, HBUS_TARG_MEM_RADDR, - IL39_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, IL39_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { @@ -1704,8 +1696,8 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); rc = -EIO; errcnt++; if (errcnt >= 20) @@ -1713,21 +1705,19 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) } } - if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); + D_INFO("ucode image in INSTRUCTION memory is good\n"); return rc; } - /** * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ -static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +static int +il3945_verify_inst_sparse(struct il_priv *il, __le32 * image, u32 len) { u32 val; int rc = 0; @@ -1736,18 +1726,17 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + for (i = 0; i < len; i += 100, image += 100 / sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL39_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, i + IL39_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { -#if 0 /* Enable this if you want to see details */ +#if 0 /* Enable this if you want to see details */ IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - i, val, *image); + "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, + *image); #endif rc = -EIO; errcnt++; @@ -1759,19 +1748,19 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) return rc; } - /** * il3945_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int il3945_verify_ucode(struct il_priv *il) +static int +il3945_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int rc = 0; /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { @@ -1780,7 +1769,7 @@ static int il3945_verify_ucode(struct il_priv *il) } /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; + image = (__le32 *) il->ucode_init.v_addr; len = il->ucode_init.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { @@ -1789,7 +1778,7 @@ static int il3945_verify_ucode(struct il_priv *il) } /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; + image = (__le32 *) il->ucode_code.v_addr; len = il->ucode_code.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { @@ -1802,14 +1791,15 @@ static int il3945_verify_ucode(struct il_priv *il) /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; rc = il3945_verify_inst_full(il, image, len); return rc; } -static void il3945_nic_start(struct il_priv *il) +static void +il3945_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ _il_wr(il, CSR_RESET, 0); @@ -1821,12 +1811,14 @@ static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ return le32_to_cpu(ucode->v1.item); \ } -static u32 il3945_ucode_get_header_size(u32 api_ver) +static u32 +il3945_ucode_get_header_size(u32 api_ver) { return 24; } -static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) +static u8 * +il3945_ucode_get_data(const struct il_ucode_header *ucode) { return (u8 *) ucode->v1.data; } @@ -1842,7 +1834,8 @@ IL3945_UCODE_GET(boot_size); * * Copy into buffers for card to fetch via bus-mastering */ -static int il3945_read_ucode(struct il_priv *il) +static int +il3945_read_ucode(struct il_priv *il) { const struct il_ucode_header *ucode; int ret = -EINVAL, idx; @@ -1862,8 +1855,7 @@ static int il3945_read_ucode(struct il_priv *il) sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { - IL_ERR("%s firmware file req failed: %d\n", - buf, ret); + IL_ERR("%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; else @@ -1871,12 +1863,11 @@ static int il3945_read_ucode(struct il_priv *il) } else { if (idx < api_max) IL_ERR("Loaded firmware %s, " - "which is deprecated. " - " Please use API v%u instead.\n", - buf, api_max); + "which is deprecated. " + " Please use API v%u instead.\n", buf, + api_max); D_INFO("Got firmware '%s' file " - "(%zd bytes) from disk\n", - buf, ucode_raw->size); + "(%zd bytes) from disk\n", buf, ucode_raw->size); break; } } @@ -1885,7 +1876,7 @@ static int il3945_read_ucode(struct il_priv *il) goto error; /* Make sure that we got at least our header! */ - if (ucode_raw->size < il3945_ucode_get_header_size(1)) { + if (ucode_raw->size < il3945_ucode_get_header_size(1)) { IL_ERR("File size way too small!\n"); ret = -EINVAL; goto err_release; @@ -1909,90 +1900,72 @@ static int il3945_read_ucode(struct il_priv *il) if (api_ver < api_min || api_ver > api_max) { IL_ERR("Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); + "Driver supports v%u, firmware is v%u.\n", api_max, + api_ver); il->ucode_ver = 0; ret = -EINVAL; goto err_release; } if (api_ver != api_max) IL_ERR("Firmware has old API version. Expected %u, " - "got %u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); + "got %u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", api_max, + api_ver); IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); + IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %u\n", - inst_size); - D_INFO("f/w package hdr runtime data size = %u\n", - data_size); - D_INFO("f/w package hdr init inst size = %u\n", - init_size); - D_INFO("f/w package hdr init data size = %u\n", - init_data_size); - D_INFO("f/w package hdr boot inst size = %u\n", - boot_size); + snprintf(il->hw->wiphy->fw_version, sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %u\n", inst_size); + D_INFO("f/w package hdr runtime data size = %u\n", data_size); + D_INFO("f/w package hdr init inst size = %u\n", init_size); + D_INFO("f/w package hdr init data size = %u\n", init_data_size); + D_INFO("f/w package hdr boot inst size = %u\n", boot_size); /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + - inst_size + data_size + init_size + - init_data_size + boot_size) { + if (ucode_raw->size != + il3945_ucode_get_header_size(api_ver) + inst_size + data_size + + init_size + init_data_size + boot_size) { - D_INFO( - "uCode file size %zd does not match expected size\n", - ucode_raw->size); + D_INFO("uCode file size %zd does not match expected size\n", + ucode_raw->size); ret = -EINVAL; goto err_release; } /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IL39_MAX_INST_SIZE) { - D_INFO("uCode instr len %d too large to fit in\n", - inst_size); + D_INFO("uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IL39_MAX_DATA_SIZE) { - D_INFO("uCode data len %d too large to fit in\n", - data_size); + D_INFO("uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IL39_MAX_INST_SIZE) { - D_INFO( - "uCode init instr len %d too large to fit in\n", - init_size); + D_INFO("uCode init instr len %d too large to fit in\n", + init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IL39_MAX_DATA_SIZE) { - D_INFO( - "uCode init data len %d too large to fit in\n", - init_data_size); + D_INFO("uCode init data len %d too large to fit in\n", + init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IL39_MAX_BSM_SIZE) { - D_INFO( - "uCode boot instr len %d too large to fit in\n", - boot_size); + D_INFO("uCode boot instr len %d too large to fit in\n", + boot_size); ret = -EINVAL; goto err_release; } @@ -2040,19 +2013,17 @@ static int il3945_read_ucode(struct il_priv *il) /* Runtime instructions (first block of data in file) */ len = inst_size; - D_INFO( - "Copying (but not loading) uCode instr len %zd\n", len); + D_INFO("Copying (but not loading) uCode instr len %zd\n", len); memcpy(il->ucode_code.v_addr, src, len); src += len; D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + il->ucode_code.v_addr, (u32) il->ucode_code.p_addr); /* Runtime data (2nd block) * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - D_INFO( - "Copying (but not loading) uCode data len %zd\n", len); + D_INFO("Copying (but not loading) uCode data len %zd\n", len); memcpy(il->ucode_data.v_addr, src, len); memcpy(il->ucode_data_backup.v_addr, src, len); src += len; @@ -2060,8 +2031,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - D_INFO( - "Copying (but not loading) init instr len %zd\n", len); + D_INFO("Copying (but not loading) init instr len %zd\n", len); memcpy(il->ucode_init.v_addr, src, len); src += len; } @@ -2069,35 +2039,32 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - D_INFO( - "Copying (but not loading) init data len %zd\n", len); + D_INFO("Copying (but not loading) init data len %zd\n", len); memcpy(il->ucode_init_data.v_addr, src, len); src += len; } /* Bootstrap instructions (5th block) */ len = boot_size; - D_INFO( - "Copying (but not loading) boot instr len %zd\n", len); + D_INFO("Copying (but not loading) boot instr len %zd\n", len); memcpy(il->ucode_boot.v_addr, src, len); /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); return 0; - err_pci_alloc: +err_pci_alloc: IL_ERR("failed to allocate pci memory\n"); ret = -ENOMEM; il3945_dealloc_ucode_pci(il); - err_release: +err_release: release_firmware(ucode_raw); - error: +error: return ret; } - /** * il3945_set_ucode_ptrs - Set uCode address location * @@ -2107,7 +2074,8 @@ static int il3945_read_ucode(struct il_priv *il) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il3945_set_ucode_ptrs(struct il_priv *il) +static int +il3945_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; @@ -2119,13 +2087,12 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) /* Tell bootstrap uCode where to find image to load */ il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); + il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); @@ -2139,7 +2106,8 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il3945_init_alive_start(struct il_priv *il) +static void +il3945_init_alive_start(struct il_priv *il) { /* Check alive response for "valid" sign from uCode */ if (il->card_alive_init.is_valid != UCODE_VALID_OK) { @@ -2171,7 +2139,7 @@ static void il3945_init_alive_start(struct il_priv *il) } return; - restart: +restart: queue_work(il->workqueue, &il->restart); } @@ -2180,7 +2148,8 @@ static void il3945_init_alive_start(struct il_priv *il) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il3945_init_alive_start()). */ -static void il3945_alive_start(struct il_priv *il) +static void +il3945_alive_start(struct il_priv *il) { int thermal_spin = 0; u32 rfkill; @@ -2219,7 +2188,7 @@ static void il3945_alive_start(struct il_priv *il) if (thermal_spin) D_INFO("Thermal calibration took %dus\n", - thermal_spin * 10); + thermal_spin * 10); } else set_bit(S_RF_KILL_HW, &il->status); @@ -2240,7 +2209,7 @@ static void il3945_alive_start(struct il_priv *il) if (il_is_associated(il)) { struct il3945_rxon_cmd *active_rxon = - (struct il3945_rxon_cmd *)(&ctx->active); + (struct il3945_rxon_cmd *)(&ctx->active); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -2264,13 +2233,14 @@ static void il3945_alive_start(struct il_priv *il) return; - restart: +restart: queue_work(il->workqueue, &il->restart); } static void il3945_cancel_deferred_work(struct il_priv *il); -static void __il3945_down(struct il_priv *il) +static void +__il3945_down(struct il_priv *il) { unsigned long flags; int exit_pending; @@ -2313,25 +2283,28 @@ static void __il3945_down(struct il_priv *il) /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ if (!il_is_init(il)) { - il->status = test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status = + test_bit(S_RF_KILL_HW, + &il-> + status) << S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, + &il-> + status) << S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_FW_ERROR, &il->status) << - S_FW_ERROR | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status &= + test_bit(S_RF_KILL_HW, + &il->status) << S_RF_KILL_HW | test_bit(S_GEO_CONFIGURED, + &il-> + status) << + S_GEO_CONFIGURED | test_bit(S_FW_ERROR, + &il-> + status) << S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; il3945_hw_txq_ctx_stop(il); il3945_hw_rxq_stop(il); @@ -2343,7 +2316,7 @@ static void __il3945_down(struct il_priv *il) /* Stop the device, and put it in low power state */ il_apm_stop(il); - exit: +exit: memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); if (il->beacon_skb) @@ -2354,7 +2327,8 @@ static void __il3945_down(struct il_priv *il) il3945_clear_free_frames(il); } -static void il3945_down(struct il_priv *il) +static void +il3945_down(struct il_priv *il) { mutex_lock(&il->mutex); __il3945_down(il); @@ -2365,15 +2339,15 @@ static void il3945_down(struct il_priv *il) #define MAX_HW_RESTARTS 5 -static int il3945_alloc_bcast_station(struct il_priv *il) +static int +il3945_alloc_bcast_station(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; unsigned long flags; u8 sta_id; spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, - il_bcast_addr, false, NULL); + sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); @@ -2388,7 +2362,8 @@ static int il3945_alloc_bcast_station(struct il_priv *il) return 0; } -static int __il3945_up(struct il_priv *il) +static int +__il3945_up(struct il_priv *il) { int rc, i; @@ -2407,8 +2382,7 @@ static int __il3945_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(S_RF_KILL_HW, &il->status); else { set_bit(S_RF_KILL_HW, &il->status); @@ -2426,8 +2400,7 @@ static int __il3945_up(struct il_priv *il) /* make sure rfkill handshake bits are cleared */ _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ _il_wr(il, CSR_INT, 0xFFFFFFFF); @@ -2455,8 +2428,7 @@ static int __il3945_up(struct il_priv *il) rc = il->cfg->ops->lib->load_ucode(il); if (rc) { - IL_ERR( - "Unable to set up bootstrap uCode: %d\n", rc); + IL_ERR("Unable to set up bootstrap uCode: %d\n", rc); continue; } @@ -2478,14 +2450,14 @@ static int __il3945_up(struct il_priv *il) return -EIO; } - /***************************************************************************** * * Workqueue callbacks * *****************************************************************************/ -static void il3945_bg_init_alive_start(struct work_struct *data) +static void +il3945_bg_init_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); @@ -2499,7 +2471,8 @@ out: mutex_unlock(&il->mutex); } -static void il3945_bg_alive_start(struct work_struct *data) +static void +il3945_bg_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, alive_start.work); @@ -2519,13 +2492,14 @@ out: * *is* readable even when device has been SW_RESET into low power mode * (e.g. during RF KILL). */ -static void il3945_rfkill_poll(struct work_struct *data) +static void +il3945_rfkill_poll(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); bool old_rfkill = test_bit(S_RF_KILL_HW, &il->status); - bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) - & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); + bool new_rfkill = + !(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { if (new_rfkill) @@ -2536,7 +2510,7 @@ static void il3945_rfkill_poll(struct work_struct *data) wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); D_RF_KILL("RF_KILL bit toggled to %s.\n", - new_rfkill ? "disable radio" : "enable radio"); + new_rfkill ? "disable radio" : "enable radio"); } /* Keep this running, even if radio now enabled. This will be @@ -2546,7 +2520,8 @@ static void il3945_rfkill_poll(struct work_struct *data) } -int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +int +il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = C_SCAN, @@ -2563,8 +2538,9 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) lockdep_assert_held(&il->mutex); if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); + il->scan_cmd = + kmalloc(sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE, + GFP_KERNEL); if (!il->scan_cmd) { D_SCAN("Fail to allocate scan memory\n"); return -ENOMEM; @@ -2598,12 +2574,12 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) */ extra = (suspend_time / interval) << 24; - scan_suspend_time = 0xFF0FFFFF & - (extra | ((suspend_time % interval) * 1024)); + scan_suspend_time = + 0xFF0FFFFF & (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); + scan_suspend_time, interval); } if (il->scan_request->n_ssids) { @@ -2615,7 +2591,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, il->scan_request->ssids[i].ssid, il->scan_request->ssids[i].ssid_len); @@ -2654,26 +2630,29 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) * is marked passive, we can do active scanning if we * detect transmissions. */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_DISABLED; - - len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, - vif->addr, il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); + scan->good_CRC_th = + is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_DISABLED; + + len = + il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(len); /* select Rx antennas */ scan->flags |= il3945_get_antenna_flags(il); - scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, - (void *)&scan->data[len], vif); + scan->channel_count = + il3945_get_channels_for_scan(il, band, is_active, n_probes, + (void *)&scan->data[len], vif); if (scan->channel_count == 0) { D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } - cmd.len += le16_to_cpu(scan->tx_cmd.len) + + cmd.len += + le16_to_cpu(scan->tx_cmd.len) + scan->channel_count * sizeof(struct il3945_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); @@ -2685,7 +2664,8 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) return ret; } -void il3945_post_scan(struct il_priv *il) +void +il3945_post_scan(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; @@ -2697,7 +2677,8 @@ void il3945_post_scan(struct il_priv *il) il3945_commit_rxon(il, ctx); } -static void il3945_bg_restart(struct work_struct *data) +static void +il3945_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); @@ -2725,10 +2706,10 @@ static void il3945_bg_restart(struct work_struct *data) } } -static void il3945_bg_rx_replenish(struct work_struct *data) +static void +il3945_bg_rx_replenish(struct work_struct *data) { - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); mutex_lock(&il->mutex); if (test_bit(S_EXIT_PENDING, &il->status)) @@ -2739,7 +2720,8 @@ out: mutex_unlock(&il->mutex); } -void il3945_post_associate(struct il_priv *il) +void +il3945_post_associate(struct il_priv *il) { int rc = 0; struct ieee80211_conf *conf = NULL; @@ -2748,8 +2730,8 @@ void il3945_post_associate(struct il_priv *il) if (!ctx->vif || !il->is_open) return; - D_ASSOC("Associated as %d to: %pM\n", - ctx->vif->bss_conf.aid, ctx->active.bssid_addr); + D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, + ctx->active.bssid_addr); if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -2763,15 +2745,14 @@ void il3945_post_associate(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN("C_RXON_TIMING failed - " - "Attempting to continue.\n"); + IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - D_ASSOC("assoc id %d beacon interval %d\n", - ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); + D_ASSOC("assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, + ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2795,8 +2776,8 @@ void il3945_post_associate(struct il_priv *il) il3945_send_beacon_cmd(il); break; default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, ctx->vif->type); + IL_ERR("%s Should not be called in %d mode\n", __func__, + ctx->vif->type); break; } } @@ -2809,7 +2790,8 @@ void il3945_post_associate(struct il_priv *il) #define UCODE_READY_TIMEOUT (2 * HZ) -static int il3945_mac_start(struct ieee80211_hw *hw) +static int +il3945_mac_start(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; int ret; @@ -2843,13 +2825,12 @@ static int il3945_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(S_READY, &il->status), - UCODE_READY_TIMEOUT); + test_bit(S_READY, &il->status), + UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(S_READY, &il->status)) { - IL_ERR( - "Wait for START_ALIVE timeout after %dms.\n", - jiffies_to_msecs(UCODE_READY_TIMEOUT)); + IL_ERR("Wait for START_ALIVE timeout after %dms.\n", + jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; goto out_release_irq; } @@ -2869,7 +2850,8 @@ out_release_irq: return ret; } -static void il3945_mac_stop(struct ieee80211_hw *hw) +static void +il3945_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; @@ -2893,14 +2875,15 @@ static void il3945_mac_stop(struct ieee80211_hw *hw) D_MAC80211("leave\n"); } -static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +static void +il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; D_MAC80211("enter\n"); D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il3945_tx_skb(il, skb)) dev_kfree_skb_any(skb); @@ -2908,7 +2891,8 @@ static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) D_MAC80211("leave\n"); } -void il3945_config_ap(struct il_priv *il) +void +il3945_config_ap(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; @@ -2928,24 +2912,20 @@ void il3945_config_ap(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) IL_WARN("C_RXON_TIMING failed - " - "Attempting to continue.\n"); + "Attempting to continue.\n"); ctx->staging.assoc_id = 0; if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2954,10 +2934,10 @@ void il3945_config_ap(struct il_priv *il) il3945_send_beacon_cmd(il); } -static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) +static int +il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) { struct il_priv *il = hw->priv; int ret = 0; @@ -2982,8 +2962,7 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, static_key = !il_is_associated(il); if (!static_key) { - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, sta); + sta_id = il_sta_id_or_broadcast(il, &il->ctx, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; } @@ -3016,9 +2995,9 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return ret; } -static int il3945_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +static int +il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct il_priv *il = hw->priv; struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; @@ -3026,20 +3005,15 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - D_INFO("received request to add station %pM\n", - sta->addr); + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; - - ret = il_add_station_common(il, - &il->ctx, - sta->addr, is_ap, sta, &sta_id); + ret = + il_add_station_common(il, &il->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); return ret; @@ -3048,18 +3022,16 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il3945_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); return 0; } -static void il3945_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) +static void +il3945_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, + unsigned int *total_flags, u64 multicast) { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; @@ -3072,8 +3044,8 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, + *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); @@ -3100,11 +3072,11 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * since we currently do not support programming multicast * filters into the device. */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; + *total_flags &= + FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; } - /***************************************************************************** * * sysfs attributes @@ -3124,15 +3096,17 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t il3945_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_debug_level(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } -static ssize_t il3945_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) + +static ssize_t +il3945_store_debug_level(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); unsigned long val; @@ -3144,19 +3118,19 @@ static ssize_t il3945_store_debug_level(struct device *d, else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il3945_show_debug_level, il3945_store_debug_level); +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il3945_show_debug_level, + il3945_store_debug_level); #endif /* CONFIG_IWLEGACY_DEBUG */ -static ssize_t il3945_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_temperature(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -3168,16 +3142,16 @@ static ssize_t il3945_show_temperature(struct device *d, static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); -static ssize_t il3945_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "%d\n", il->tx_power_user_lmt); } -static ssize_t il3945_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_tx_power(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; @@ -3192,10 +3166,11 @@ static ssize_t il3945_store_tx_power(struct device *d, return count; } -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, + il3945_store_tx_power); -static ssize_t il3945_show_flags(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; @@ -3203,9 +3178,9 @@ static ssize_t il3945_show_flags(struct device *d, return sprintf(buf, "0x%04X\n", ctx->active.flags); } -static ssize_t il3945_store_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_flags(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); @@ -3217,8 +3192,7 @@ static ssize_t il3945_store_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN("Could not cancel scan.\n"); else { - D_INFO("Committing rxon.flags = 0x%04X\n", - flags); + D_INFO("Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); il3945_commit_rxon(il, ctx); } @@ -3228,21 +3202,22 @@ static ssize_t il3945_store_flags(struct device *d, return count; } -static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); +static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, + il3945_store_flags); -static ssize_t il3945_show_filter_flags(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_filter_flags(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; - return sprintf(buf, "0x%04X\n", - le32_to_cpu(ctx->active.filter_flags)); + return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); } -static ssize_t il3945_store_filter_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_filter_flags(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; @@ -3254,10 +3229,9 @@ static ssize_t il3945_store_filter_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN("Could not cancel scan.\n"); else { - D_INFO("Committing rxon.filter_flags = " - "0x%04X\n", filter_flags); - ctx->staging.filter_flags = - cpu_to_le32(filter_flags); + D_INFO("Committing rxon.filter_flags = " "0x%04X\n", + filter_flags); + ctx->staging.filter_flags = cpu_to_le32(filter_flags); il3945_commit_rxon(il, ctx); } } @@ -3269,13 +3243,14 @@ static ssize_t il3945_store_filter_flags(struct device *d, static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, il3945_store_filter_flags); -static ssize_t il3945_show_measurement(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_measurement(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; - u8 *data = (u8 *)&measure_report; + u8 *data = (u8 *) & measure_report; unsigned long flags; spin_lock_irqsave(&il->lock, flags); @@ -3301,9 +3276,9 @@ static ssize_t il3945_show_measurement(struct device *d, return len; } -static ssize_t il3945_store_measurement(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_measurement(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; @@ -3330,19 +3305,19 @@ static ssize_t il3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - D_INFO("Invoking measurement of type %d on " - "channel %d (for '%s')\n", type, params.channel, buf); + D_INFO("Invoking measurement of type %d on " "channel %d (for '%s')\n", + type, params.channel, buf); il3945_get_measurement(il, ¶ms, type); return count; } -static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, - il3945_show_measurement, il3945_store_measurement); +static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, il3945_show_measurement, + il3945_store_measurement); -static ssize_t il3945_store_retry_rate(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_retry_rate(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); @@ -3353,8 +3328,9 @@ static ssize_t il3945_store_retry_rate(struct device *d, return count; } -static ssize_t il3945_show_retry_rate(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_retry_rate(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "%d", il->retry_rate); @@ -3363,9 +3339,8 @@ static ssize_t il3945_show_retry_rate(struct device *d, static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, il3945_store_retry_rate); - -static ssize_t il3945_show_channels(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_channels(struct device *d, struct device_attribute *attr, char *buf) { /* all this shit doesn't belong into sysfs anyway */ return 0; @@ -3373,8 +3348,8 @@ static ssize_t il3945_show_channels(struct device *d, static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); -static ssize_t il3945_show_antenna(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_antenna(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -3384,9 +3359,9 @@ static ssize_t il3945_show_antenna(struct device *d, return sprintf(buf, "%d\n", il3945_mod_params.antenna); } -static ssize_t il3945_store_antenna(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_antenna(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il __maybe_unused = dev_get_drvdata(d); int ant; @@ -3405,14 +3380,14 @@ static ssize_t il3945_store_antenna(struct device *d, } else D_INFO("Bad antenna select value %d.\n", ant); - return count; } -static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); +static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, + il3945_store_antenna); -static ssize_t il3945_show_status(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_status(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); if (!il_is_alive(il)) @@ -3422,9 +3397,9 @@ static ssize_t il3945_show_status(struct device *d, static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); -static ssize_t il3945_dump_error_log(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_dump_error_log(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; @@ -3443,7 +3418,8 @@ static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); * *****************************************************************************/ -static void il3945_setup_deferred_work(struct il_priv *il) +static void +il3945_setup_deferred_work(struct il_priv *il) { il->workqueue = create_singlethread_workqueue(DRV_NAME); @@ -3463,11 +3439,13 @@ static void il3945_setup_deferred_work(struct il_priv *il) il->watchdog.data = (unsigned long)il; il->watchdog.function = il_bg_watchdog; - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il3945_irq_tasklet, (unsigned long)il); + tasklet_init(&il->irq_tasklet, + (void (*)(unsigned long))il3945_irq_tasklet, + (unsigned long)il); } -static void il3945_cancel_deferred_work(struct il_priv *il) +static void +il3945_cancel_deferred_work(struct il_priv *il) { il3945_hw_cancel_deferred_work(il); @@ -3518,7 +3496,8 @@ struct ieee80211_ops il3945_hw_ops = { .tx_last_beacon = il_mac_tx_last_beacon, }; -static int il3945_init_drv(struct il_priv *il) +static int +il3945_init_drv(struct il_priv *il) { int ret; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -3545,7 +3524,7 @@ static int il3945_init_drv(struct il_priv *il) if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { IL_WARN("Unsupported EEPROM version: 0x%04X\n", - eeprom->version); + eeprom->version); ret = -EINVAL; goto err; } @@ -3578,7 +3557,8 @@ err: #define IL3945_MAX_PROBE_REQUEST 200 -static int il3945_setup_mac(struct il_priv *il) +static int +il3945_setup_mac(struct il_priv *il) { int ret; struct ieee80211_hw *hw = il->hw; @@ -3588,15 +3568,13 @@ static int il3945_setup_mac(struct il_priv *il) hw->vif_data_size = sizeof(struct il_vif_priv); /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_SPECTRUM_MGMT; + hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SPECTRUM_MGMT; - hw->wiphy->interface_modes = - il->ctx.interface_modes; + hw->wiphy->interface_modes = il->ctx.interface_modes; - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS | - WIPHY_FLAG_IBSS_RSN; + hw->wiphy->flags |= + WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | + WIPHY_FLAG_IBSS_RSN; hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; /* we create the 802.11 header and a zero-length SSID element */ @@ -3607,11 +3585,11 @@ static int il3945_setup_mac(struct il_priv *il) if (il->bands[IEEE80211_BAND_2GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; + &il->bands[IEEE80211_BAND_2GHZ]; if (il->bands[IEEE80211_BAND_5GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; + &il->bands[IEEE80211_BAND_5GHZ]; il_leds_init(il); @@ -3625,7 +3603,8 @@ static int il3945_setup_mac(struct il_priv *il) return 0; } -static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +static int +il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0; struct il_priv *il; @@ -3660,8 +3639,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->ctx.ap_sta_id = IL_AP_ID; il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC); + BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; il->ctx.station_devtype = RXON_DEV_TYPE_ESS; il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; @@ -3686,8 +3664,9 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /*************************** * 2. Initializing PCI bus * *************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); + pci_disable_link_state(pdev, + PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); if (pci_enable_device(pdev)) { err = -ENODEV; @@ -3719,7 +3698,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en } D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); + (unsigned long long)pci_resource_len(pdev, 0)); D_INFO("pci_resource_base = %p\n", il->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep @@ -3773,8 +3752,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en goto out_unset_hw_params; } - IL_INFO("Detected Intel Wireless WiFi Link %s\n", - il->cfg->name); + IL_INFO("Detected Intel Wireless WiFi Link %s\n", il->cfg->name); /*********************** * 7. Setup Services @@ -3786,8 +3764,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en pci_enable_msi(il->pci_dev); - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); + err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; @@ -3799,9 +3776,8 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en goto out_release_irq; } - il_set_rxon_channel(il, - &il->bands[IEEE80211_BAND_2GHZ].channels[5], - &il->ctx); + il_set_rxon_channel(il, &il->bands[IEEE80211_BAND_2GHZ].channels[5], + &il->ctx); il3945_setup_deferred_work(il); il3945_setup_handlers(il); il_power_initialize(il); @@ -3814,47 +3790,48 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = il3945_setup_mac(il); if (err) - goto out_remove_sysfs; + goto out_remove_sysfs; err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", + err); /* Start monitoring the killswitch */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - 2 * HZ); + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ); return 0; - out_remove_sysfs: +out_remove_sysfs: destroy_workqueue(il->workqueue); il->workqueue = NULL; sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - out_release_irq: +out_release_irq: free_irq(il->pci_dev->irq, il); - out_disable_msi: +out_disable_msi: pci_disable_msi(il->pci_dev); il_free_geos(il); il_free_channel_map(il); - out_unset_hw_params: +out_unset_hw_params: il3945_unset_hw_params(il); - out_eeprom_free: +out_eeprom_free: il_eeprom_free(il); - out_iounmap: +out_iounmap: pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: +out_pci_release_regions: pci_release_regions(pdev); - out_pci_disable_device: +out_pci_disable_device: pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); - out_ieee80211_free_hw: +out_ieee80211_free_hw: il_free_traffic_mem(il); ieee80211_free_hw(il->hw); - out: +out: return err; } -static void __devexit il3945_pci_remove(struct pci_dev *pdev) +static void __devexit +il3945_pci_remove(struct pci_dev *pdev) { struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; @@ -3934,7 +3911,6 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) ieee80211_free_hw(il->hw); } - /***************************************************************************** * * driver and module entry point @@ -3949,7 +3925,8 @@ static struct pci_driver il3945_driver = { .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init il3945_init(void) +static int __init +il3945_init(void) { int ret; @@ -3975,7 +3952,8 @@ error_register: return ret; } -static void __exit il3945_exit(void) +static void __exit +il3945_exit(void) { pci_unregister_driver(&il3945_driver); il3945_rate_control_unregister(); @@ -3986,10 +3964,9 @@ MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); -MODULE_PARM_DESC(swcrypto, - "using software crypto (default 1 [software])"); -module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, - int, S_IRUGO); +MODULE_PARM_DESC(swcrypto, "using software crypto (default 1 [software])"); +module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, + S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); #ifdef CONFIG_IWLEGACY_DEBUG module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index dc0dfdd..3420b1c 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -97,7 +97,8 @@ static struct il3945_tpt_entry il3945_tpt_table_g[] = { #define RATE_DECREASE_TH 1920 #define RATE_RETRY_TH 15 -static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) +static u8 +il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) { u32 idx = 0; u32 table_size = 0; @@ -130,7 +131,8 @@ static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) return tpt_table[idx].idx; } -static void il3945_clear_win(struct il3945_rate_scale_data *win) +static void +il3945_clear_win(struct il3945_rate_scale_data *win) { win->data = 0; win->success_counter = 0; @@ -147,7 +149,8 @@ static void il3945_clear_win(struct il3945_rate_scale_data *win) * not flushed. If there were any that were not flushed, then * reschedule the rate flushing routine. */ -static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) +static int +il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) { int unflushed = 0; int i; @@ -164,11 +167,9 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) continue; spin_lock_irqsave(&rs_sta->lock, flags); - if (time_after(jiffies, rs_sta->win[i].stamp + - RATE_WIN_FLUSH)) { - D_RATE("flushing %d samples of rate " - "idx %d\n", - rs_sta->win[i].counter, i); + if (time_after(jiffies, rs_sta->win[i].stamp + RATE_WIN_FLUSH)) { + D_RATE("flushing %d samples of rate " "idx %d\n", + rs_sta->win[i].counter, i); il3945_clear_win(&rs_sta->win[i]); } else unflushed++; @@ -182,7 +183,8 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) #define RATE_FLUSH_MIN 50 /* msec */ #define IL_AVERAGE_PACKETS 1500 -static void il3945_bg_rate_scale_flush(unsigned long data) +static void +il3945_bg_rate_scale_flush(unsigned long data) { struct il3945_rs_sta *rs_sta = (void *)data; struct il_priv *il __maybe_unused = rs_sta->il; @@ -205,8 +207,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - D_RATE("Tx'd %d packets in %dms\n", - packet_count, duration); + D_RATE("Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ if (duration) @@ -225,11 +226,11 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->flush_time = msecs_to_jiffies(duration); - D_RATE("new flush period: %d msec ave %d\n", - duration, packet_count); + D_RATE("new flush period: %d msec ave %d\n", duration, + packet_count); - mod_timer(&rs_sta->rate_scale_flush, jiffies + - rs_sta->flush_time); + mod_timer(&rs_sta->rate_scale_flush, + jiffies + rs_sta->flush_time); rs_sta->last_partial_flush = jiffies; } else { @@ -253,9 +254,10 @@ static void il3945_bg_rate_scale_flush(unsigned long data) * at this rate. win->data contains the bitmask of successful * packets. */ -static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, - struct il3945_rate_scale_data *win, - int success, int retries, int idx) +static void +il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, + struct il3945_rate_scale_data *win, int success, + int retries, int idx) { unsigned long flags; s32 fail_count; @@ -306,8 +308,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* Calculate current success ratio, avoid divide-by-0! */ if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; + win->success_ratio = + 128 * (100 * win->success_counter) / win->counter; else win->success_ratio = IL_INVALID_VALUE; @@ -316,8 +318,9 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* Calculate average throughput, if we have enough history. */ if (fail_count >= RATE_MIN_FAILURE_TH || win->success_counter >= RATE_MIN_SUCCESS_TH) - win->average_tpt = ((win->success_ratio * - rs_sta->expected_tpt[idx] + 64) / 128); + win->average_tpt = + ((win->success_ratio * rs_sta->expected_tpt[idx] + + 64) / 128); else win->average_tpt = IL_INVALID_VALUE; @@ -331,7 +334,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* * Called after adding a new station to initialize rate scaling */ -void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) +void +il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { struct ieee80211_hw *hw = il->hw; struct ieee80211_conf *conf = &il->hw->conf; @@ -344,7 +348,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i if (sta_id == il->ctx.bcast_sta_id) goto out; - psta = (struct il3945_sta_priv *) sta->drv_priv; + psta = (struct il3945_sta_priv *)sta->drv_priv; rs_sta = &psta->rs_sta; sband = hw->wiphy->bands[conf->channel->band]; @@ -382,8 +386,8 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ if (sband->band == IEEE80211_BAND_5GHZ) { rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << - IL_FIRST_OFDM_RATE; + il->_3945.sta_supp_rates = + il->_3945.sta_supp_rates << IL_FIRST_OFDM_RATE; } out: @@ -392,21 +396,24 @@ out: D_INFO("leave\n"); } -static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +static void * +il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } /* rate scale requires free function to be implemented */ -static void il3945_rs_free(void *il) +static void +il3945_rs_free(void *il) { return; } -static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) +static void * +il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) { struct il3945_rs_sta *rs_sta; - struct il3945_sta_priv *psta = (void *) sta->drv_priv; + struct il3945_sta_priv *psta = (void *)sta->drv_priv; struct il_priv *il __maybe_unused = il_priv; D_RATE("enter\n"); @@ -421,8 +428,8 @@ static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t return rs_sta; } -static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, - void *il_sta) +static void +il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, void *il_sta) { struct il3945_rs_sta *rs_sta = il_sta; @@ -434,16 +441,16 @@ static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, del_timer_sync(&rs_sta->rate_scale_flush); } - /** * il3945_rs_tx_status - Update rate control values based on Tx results * * NOTE: Uses il_priv->retry_rate for the # of retries attempted by * the hardware for each rate. */ -static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) +static void +il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) { s8 retries = 0, current_count; int scale_rate_idx, first_idx, last_idx; @@ -476,7 +483,6 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * return; } - rs_sta->tx_packets++; scale_rate_idx = first_idx; @@ -498,32 +504,27 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * last_idx = scale_rate_idx; } else { current_count = il->retry_rate; - last_idx = il3945_rs_next_rate(il, - scale_rate_idx); + last_idx = il3945_rs_next_rate(il, scale_rate_idx); } /* Update this rate accounting for as many retries * as was used for it (per current_count) */ - il3945_collect_tx_data(rs_sta, - &rs_sta->win[scale_rate_idx], - 0, current_count, scale_rate_idx); - D_RATE("Update rate %d for %d retries.\n", - scale_rate_idx, current_count); + il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_idx], 0, + current_count, scale_rate_idx); + D_RATE("Update rate %d for %d retries.\n", scale_rate_idx, + current_count); retries -= current_count; scale_rate_idx = last_idx; } - /* Update the last idx win with success/failure based on ACK */ - D_RATE("Update rate %d with %s.\n", - last_idx, - (info->flags & IEEE80211_TX_STAT_ACK) ? - "success" : "failure"); - il3945_collect_tx_data(rs_sta, - &rs_sta->win[last_idx], - info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); + D_RATE("Update rate %d with %s.\n", last_idx, + (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); + il3945_collect_tx_data(rs_sta, &rs_sta->win[last_idx], + info->flags & IEEE80211_TX_STAT_ACK, 1, + last_idx); /* We updated the rate scale win -- if its been more than * flush_time since the last run, schedule the flush @@ -531,8 +532,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * spin_lock_irqsave(&rs_sta->lock, flags); if (!rs_sta->flush_pending && - time_after(jiffies, rs_sta->last_flush + - rs_sta->flush_time)) { + time_after(jiffies, rs_sta->last_flush + rs_sta->flush_time)) { rs_sta->last_partial_flush = jiffies; rs_sta->flush_pending = 1; @@ -545,8 +545,9 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * D_RATE("leave\n"); } -static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, - u8 idx, u16 rate_mask, enum ieee80211_band band) +static u16 +il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u8 idx, u16 rate_mask, + enum ieee80211_band band) { u8 high = RATE_INVALID; u8 low = RATE_INVALID; @@ -569,8 +570,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, /* Find the next rate that is in the rate mask */ i = idx + 1; - for (mask = (1 << i); i < RATE_COUNT_3945; - i++, mask <<= 1) { + for (mask = (1 << i); i < RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { high = i; break; @@ -625,8 +625,9 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, * rate table and must reference the driver allocated rate table * */ -static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, - void *il_sta, struct ieee80211_tx_rate_control *txrc) +static void +il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, + struct ieee80211_tx_rate_control *txrc) { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; @@ -679,7 +680,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, */ if (rs_sta->start_rate != RATE_INVALID) { if (rs_sta->start_rate < idx && - (rate_mask & (1 << rs_sta->start_rate))) + (rate_mask & (1 << rs_sta->start_rate))) idx = rs_sta->start_rate; rs_sta->start_rate = RATE_INVALID; } @@ -699,14 +700,12 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " - "counter: %d, success_counter: %d, " - "expected_tpt is %sNULL\n", - idx, - win->counter, - win->success_counter, - rs_sta->expected_tpt ? "not " : ""); - - /* Can't calculate this yet; not enough history */ + "counter: %d, success_counter: %d, " + "expected_tpt is %sNULL\n", idx, win->counter, + win->success_counter, + rs_sta->expected_tpt ? "not " : ""); + + /* Can't calculate this yet; not enough history */ win->average_tpt = IL_INVALID_VALUE; goto out; @@ -714,8 +713,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, current_tpt = win->average_tpt; - high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, - sband->band); + high_low = + il3945_get_adjacent_rate(rs_sta, idx, rate_mask, sband->band); low = high_low & 0xff; high = (high_low >> 8) & 0xff; @@ -738,46 +737,42 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; - /* No throughput measured yet for adjacent rates, - * try increase */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { + /* No throughput measured yet for adjacent rates, + * try increase */ + } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) + if (high != RATE_INVALID && + win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; else if (low != RATE_INVALID) scale_action = 0; - /* Both adjacent throughputs are measured, but neither one has - * better throughput; we're using the best rate, don't change - * it! */ - } else if (low_tpt != IL_INVALID_VALUE && - high_tpt != IL_INVALID_VALUE && - low_tpt < current_tpt && high_tpt < current_tpt) { + /* Both adjacent throughputs are measured, but neither one has + * better throughput; we're using the best rate, don't change + * it! */ + } else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE + && low_tpt < current_tpt && high_tpt < current_tpt) { D_RATE("No action -- low [%d] & high [%d] < " - "current_tpt [%d]\n", - low_tpt, high_tpt, current_tpt); + "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; - /* At least one of the rates has better throughput */ + /* At least one of the rates has better throughput */ } else { if (high_tpt != IL_INVALID_VALUE) { /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - win->success_ratio >= RATE_INCREASE_TH) + win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; else { - D_RATE( - "decrease rate because of high tpt\n"); + D_RATE("decrease rate because of high tpt\n"); scale_action = 0; } } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); + D_RATE("decrease rate because of low tpt\n"); scale_action = -1; } else if (win->success_ratio >= RATE_INCREASE_TH) { /* Lower rate has better @@ -815,10 +810,10 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, break; } - D_RATE("Selected %d (action %d) - low %d high %d\n", - idx, scale_action, low, high); + D_RATE("Selected %d (action %d) - low %d high %d\n", idx, scale_action, + low, high); - out: +out: if (sband->band == IEEE80211_BAND_5GHZ) { if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) @@ -834,15 +829,16 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } #ifdef CONFIG_MAC80211_DEBUGFS -static int il3945_open_file_generic(struct inode *inode, struct file *file) +static int +il3945_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il3945_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { char *buff; int desc = 0; @@ -854,17 +850,18 @@ static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, if (!buff) return -ENOMEM; - desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" - "rate=0x%X flush time %d\n", - lq_sta->tx_packets, - lq_sta->last_txrate_idx, - lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); + desc += + sprintf(buff + desc, + "tx packets=%d last rate idx=%d\n" + "rate=0x%X flush time %d\n", lq_sta->tx_packets, + lq_sta->last_txrate_idx, lq_sta->start_rate, + jiffies_to_msecs(lq_sta->flush_time)); for (j = 0; j < RATE_COUNT_3945; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->win[j].counter, - lq_sta->win[j].success_counter, - lq_sta->win[j].success_ratio); + desc += + sprintf(buff + desc, "counter=%d success=%d %%=%d\n", + lq_sta->win[j].counter, + lq_sta->win[j].success_counter, + lq_sta->win[j].success_ratio); } ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); kfree(buff); @@ -877,18 +874,19 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { .llseek = default_llseek, }; -static void il3945_add_debugfs(void *il, void *il_sta, - struct dentry *dir) +static void +il3945_add_debugfs(void *il, void *il_sta, struct dentry *dir) { struct il3945_rs_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", 0600, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); + debugfs_create_file("rate_stats_table", 0600, dir, lq_sta, + &rs_sta_dbgfs_stats_table_ops); } -static void il3945_remove_debugfs(void *il, void *il_sta) +static void +il3945_remove_debugfs(void *il, void *il_sta) { struct il3945_rs_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); @@ -900,9 +898,9 @@ static void il3945_remove_debugfs(void *il, void *il_sta) * the station is added. Since mac80211 calls this function before a * station is added we ignore it. */ -static void il3945_rs_rate_init_stub(void *il_r, - struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta) +static void +il3945_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) { } @@ -922,7 +920,9 @@ static struct rate_control_ops rs_ops = { #endif }; -void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) + +void +il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) { struct il_priv *il = hw->priv; s32 rssi = 0; @@ -935,15 +935,15 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rcu_read_lock(); - sta = ieee80211_find_sta(il->ctx.vif, - il->stations[sta_id].sta.sta.addr); + sta = + ieee80211_find_sta(il->ctx.vif, il->stations[sta_id].sta.sta.addr); if (!sta) { D_RATE("Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } - psta = (void *) sta->drv_priv; + psta = (void *)sta->drv_priv; rs_sta = &psta->rs_sta; spin_lock_irqsave(&rs_sta->lock, flags); @@ -952,8 +952,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) switch (il->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (il->ctx.active.flags & - RXON_FLG_TGG_PROTECT_MSK) { + if (il->ctx.active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; rs_sta->expected_tpt = il3945_expected_tpt_g_prot; } else @@ -978,18 +977,19 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); - D_RATE("leave: rssi %d assign rate idx: " - "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, - il3945_rates[rs_sta->start_rate].plcp); + D_RATE("leave: rssi %d assign rate idx: " "%d (plcp 0x%x)\n", rssi, + rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); } -int il3945_rate_control_register(void) +int +il3945_rate_control_register(void) { return ieee80211_rate_control_register(&rs_ops); } -void il3945_rate_control_unregister(void) +void +il3945_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_ops); } diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b1ced05..7f0b9f5 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -43,8 +43,8 @@ #include "3945.h" /* Send led command */ -static int il3945_send_led_cmd(struct il_priv *il, - struct il_led_cmd *led_cmd) +static int +il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { .id = C_LEDS, @@ -82,21 +82,22 @@ const struct il_led_ops il3945_led_ops = { * */ const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { - IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV), /* 54mbps */ }; -static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) +static inline u8 +il3945_get_prev_ieee_rate(u8 rate_idx) { u8 rate = il3945_rates[rate_idx].prev_ieee; @@ -118,7 +119,8 @@ static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) * Use for only special debugging. This function is just a placeholder as-is, * you'll need to provide the special bits! ... * ... and set IL_EVT_DISABLE to 1. */ -void il3945_disable_events(struct il_priv *il) +void +il3945_disable_events(struct il_priv *il) { int i; u32 base; /* SRAM address of event log header */ @@ -185,22 +187,22 @@ void il3945_disable_events(struct il_priv *il) if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { D_INFO("Disabling selected uCode log events at 0x%x\n", - disable_ptr); + disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) - il_write_targ_mem(il, - disable_ptr + (i * sizeof(u32)), - evt_disable[i]); + il_write_targ_mem(il, disable_ptr + (i * sizeof(u32)), + evt_disable[i]); } else { D_INFO("Selected uCode log events may be disabled\n"); D_INFO(" by writing \"1\"s into disable bitmap\n"); - D_INFO(" in SRAM at 0x%x, size %d u32s\n", - disable_ptr, array_size); + D_INFO(" in SRAM at 0x%x, size %d u32s\n", disable_ptr, + array_size); } } -static int il3945_hwrate_to_plcp_idx(u8 plcp) +static int +il3945_hwrate_to_plcp_idx(u8 plcp) { int idx; @@ -213,7 +215,8 @@ static int il3945_hwrate_to_plcp_idx(u8 plcp) #ifdef CONFIG_IWLEGACY_DEBUG #define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x -static const char *il3945_get_tx_fail_reason(u32 status) +static const char * +il3945_get_tx_fail_reason(u32 status) { switch (status & TX_STATUS_MSK) { case TX_3945_STATUS_SUCCESS: @@ -239,7 +242,8 @@ static const char *il3945_get_tx_fail_reason(u32 status) return "UNKNOWN"; } #else -static inline const char *il3945_get_tx_fail_reason(u32 status) +static inline const char * +il3945_get_tx_fail_reason(u32 status) { return ""; } @@ -250,7 +254,8 @@ static inline const char *il3945_get_tx_fail_reason(u32 status) * for A and B mode we need to overright prev * value */ -int il3945_rs_next_rate(struct il_priv *il, int rate) +int +il3945_rs_next_rate(struct il_priv *il, int rate) { int next_rate = il3945_get_prev_ieee_rate(rate); @@ -276,7 +281,6 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) return next_rate; } - /** * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd * @@ -284,8 +288,8 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il3945_tx_queue_reclaim(struct il_priv *il, - int txq_id, int idx) +static void +il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -293,9 +297,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); @@ -311,8 +314,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, /** * il3945_hdl_tx - Handle Tx response */ -static void il3945_hdl_tx(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -321,15 +324,14 @@ static void il3945_hdl_tx(struct il_priv *il, struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->status); + u32 status = le32_to_cpu(tx_resp->status); int rate_idx; int fail; if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); + "is out of range [0-%d] %d %d\n", txq_id, idx, + txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -345,15 +347,16 @@ static void il3945_hdl_tx(struct il_priv *il, fail = tx_resp->failure_frame; info->status.rates[0].idx = rate_idx; - info->status.rates[0].count = fail + 1; /* add final attempt */ + info->status.rates[0].count = fail + 1; /* add final attempt */ /* tx_status->rts_retry_count = tx_resp->failure_rts; */ - info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? - IEEE80211_TX_STAT_ACK : 0; + info->flags |= + ((status & TX_STATUS_MSK) == + TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", - txq_id, il3945_get_tx_fail_reason(status), status, - tx_resp->rate, tx_resp->failure_frame); + D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", txq_id, + il3945_get_tx_fail_reason(status), status, tx_resp->rate, + tx_resp->failure_frame); D_TX_REPLY("Tx queue reclaim %d\n", idx); il3945_tx_queue_reclaim(il, txq_id, idx); @@ -362,8 +365,6 @@ static void il3945_hdl_tx(struct il_priv *il, IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); } - - /***************************************************************************** * * Intel PRO/Wireless 3945ABG/BG Network Connection @@ -372,25 +373,26 @@ static void il3945_hdl_tx(struct il_priv *il, * *****************************************************************************/ #ifdef CONFIG_IWLEGACY_DEBUGFS -static void il3945_accumulative_stats(struct il_priv *il, - __le32 *stats) +static void +il3945_accumulative_stats(struct il_priv *il, __le32 * stats) { int i; __le32 *prev_stats; u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *)&il->_3945.stats; - accum_stats = (u32 *)&il->_3945.accum_stats; - delta = (u32 *)&il->_3945.delta_stats; - max_delta = (u32 *)&il->_3945.max_delta; + prev_stats = (__le32 *) & il->_3945.stats; + accum_stats = (u32 *) & il->_3945.accum_stats; + delta = (u32 *) & il->_3945.delta_stats; + max_delta = (u32 *) & il->_3945.max_delta; for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { + i += + sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, + accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); + *delta = + (le32_to_cpu(*stats) - le32_to_cpu(*prev_stats)); *accum_stats += *delta; if (*delta > *max_delta) *max_delta = *delta; @@ -399,48 +401,47 @@ static void il3945_accumulative_stats(struct il_priv *il, /* reset accumulative stats for "no-counter" type stats */ il->_3945.accum_stats.general.temperature = - il->_3945.stats.general.temperature; + il->_3945.stats.general.temperature; il->_3945.accum_stats.general.ttl_timestamp = - il->_3945.stats.general.ttl_timestamp; + il->_3945.stats.general.ttl_timestamp; } #endif -void il3945_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX("Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il3945_notif_stats), - le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); + (int)sizeof(struct il3945_notif_stats), + le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); + il3945_accumulative_stats(il, (__le32 *) & pkt->u.raw); #endif memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); } -void il3945_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); - __le32 *flag = (__le32 *)&pkt->u.raw; + __le32 *flag = (__le32 *) & pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_3945.accum_stats, 0, - sizeof(struct il3945_notif_stats)); + sizeof(struct il3945_notif_stats)); memset(&il->_3945.delta_stats, 0, - sizeof(struct il3945_notif_stats)); + sizeof(struct il3945_notif_stats)); memset(&il->_3945.max_delta, 0, - sizeof(struct il3945_notif_stats)); + sizeof(struct il3945_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } il3945_hdl_stats(il, rxb); } - /****************************************************************************** * * Misc. internal state and helper functions @@ -448,16 +449,16 @@ void il3945_hdl_c_stats(struct il_priv *il, ******************************************************************************/ /* This is necessary only for a number of stats, see the caller. */ -static int il3945_is_network_packet(struct il_priv *il, - struct ieee80211_hdr *header) +static int +il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) { /* Filter incoming packets to determine if they are targeted toward * this network, discarding packets coming from ourselves */ switch (il->iw_mode) { - case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ + case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ /* packets to our IBSS update information */ return !compare_ether_addr(header->addr3, il->bssid); - case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ + case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ /* packets to our IBSS update information */ return !compare_ether_addr(header->addr2, il->bssid); default: @@ -465,9 +466,9 @@ static int il3945_is_network_packet(struct il_priv *il, } } -static void il3945_pass_packet_to_mac80211(struct il_priv *il, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) +static void +il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); @@ -478,16 +479,16 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, __le16 fc = hdr->frame_control; /* We received data from the HW, so stop the watchdog */ - if (unlikely(len + IL39_RX_FRAME_SIZE > - PAGE_SIZE << il->hw_params.rx_page_order)) { + if (unlikely + (len + IL39_RX_FRAME_SIZE > + PAGE_SIZE << il->hw_params.rx_page_order)) { D_DROP("Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); + D_DROP("Dropping packet while interface is not open.\n"); return; } @@ -498,9 +499,8 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, } if (!il3945_mod_params.sw_crypto) - il_set_decrypted_flag(il, - (struct ieee80211_hdr *)rxb_addr(rxb), - le32_to_cpu(rx_end->status), stats); + il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb), + le32_to_cpu(rx_end->status), stats); skb_add_rx_frag(skb, 0, rxb->page, (void *)rx_hdr->payload - (void *)pkt, len); @@ -515,8 +515,8 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void il3945_hdl_rx(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; @@ -525,23 +525,27 @@ static void il3945_hdl_rx(struct il_priv *il, struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); - u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); + u16 rx_stats_noise_diff __maybe_unused = + le16_to_cpu(rx_stats->noise_diff); u8 network_packet; rx_status.flag = 0; rx_status.mactime = le64_to_cpu(rx_end->timestamp); - rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.band = + (rx_hdr-> + phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? IEEE80211_BAND_2GHZ : + IEEE80211_BAND_5GHZ; rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), - rx_status.band); + ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), + rx_status.band); rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); if (rx_status.band == IEEE80211_BAND_5GHZ) rx_status.rate_idx -= IL_FIRST_OFDM_RATE; - rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & - RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; + rx_status.antenna = + (le16_to_cpu(rx_hdr->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> + 4; /* set the preamble flag if appropriate */ if (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) @@ -549,7 +553,7 @@ static void il3945_hdl_rx(struct il_priv *il, if ((unlikely(rx_stats->phy_count > 20))) { D_DROP("dsp size out of range [0,20]: %d/n", - rx_stats->phy_count); + rx_stats->phy_count); return; } @@ -559,31 +563,25 @@ static void il3945_hdl_rx(struct il_priv *il, return; } - - /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; - D_STATS("Rssi %d sig_avg %d noise_diff %d\n", - rx_status.signal, rx_stats_sig_avg, - rx_stats_noise_diff); + D_STATS("Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, + rx_stats_sig_avg, rx_stats_noise_diff); header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); network_packet = il3945_is_network_packet(il, header); D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", - network_packet ? '*' : ' ', - le16_to_cpu(rx_hdr->channel), - rx_status.signal, rx_status.signal, - rx_status.rate_idx); + network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), + rx_status.signal, rx_status.signal, rx_status.rate_idx); - il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), - header); + il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), header); if (network_packet) { il->_3945.last_beacon_time = - le32_to_cpu(rx_end->beacon_timestamp); + le32_to_cpu(rx_end->beacon_timestamp); il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); il->_3945.last_rx_rssi = rx_status.signal; } @@ -591,9 +589,9 @@ static void il3945_hdl_rx(struct il_priv *il, il3945_pass_packet_to_mac80211(il, rxb, &rx_status); } -int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad) +int +il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad) { int count; struct il_queue *q; @@ -610,7 +608,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, if (count >= NUM_TFD_CHUNKS || count < 0) { IL_ERR("Error can not send more than %d chunks\n", - NUM_TFD_CHUNKS); + NUM_TFD_CHUNKS); return -EINVAL; } @@ -619,8 +617,8 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, count++; - tfd->control_flags = cpu_to_le32(TFD_CTL_COUNT_SET(count) | - TFD_CTL_PAD_SET(pad)); + tfd->control_flags = + cpu_to_le32(TFD_CTL_COUNT_SET(count) | TFD_CTL_PAD_SET(pad)); return 0; } @@ -630,7 +628,8 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, * * Does NOT advance any idxes */ -void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +void +il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; int idx = txq->q.read_ptr; @@ -649,16 +648,16 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (counter) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_TODEVICE); + pci_unmap_single(dev, dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_TODEVICE); /* unmap chunks if any */ for (i = 1; i < counter; i++) pci_unmap_single(dev, le32_to_cpu(tfd->tbs[i].addr), - le32_to_cpu(tfd->tbs[i].len), PCI_DMA_TODEVICE); + le32_to_cpu(tfd->tbs[i].len), + PCI_DMA_TODEVICE); /* free SKB */ if (txq->txb) { @@ -678,11 +677,10 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: * */ -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id) +void +il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); @@ -701,7 +699,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, * in this running context */ rate_mask = RATES_MASK_3945; - /* Set retry limit on DATA packets and Probe Responses*/ + /* Set retry limit on DATA packets and Probe Responses */ if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else @@ -722,18 +720,19 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, /* OFDM */ tx_cmd->supp_rates[0] = - ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; + ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " - "cck/ofdm mask: 0x%x/0x%x\n", sta_id, - tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), - tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); + "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, + le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], + tx_cmd->supp_rates[0]); } -static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) +static u8 +il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) { unsigned long flags_spin; struct il_station_entry *station; @@ -750,12 +749,12 @@ static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) il_send_add_sta(il, &station->sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags_spin); - D_RATE("SCALE sync station %d to rate %d\n", - sta_id, tx_rate); + D_RATE("SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } -static void il3945_set_pwr_vmain(struct il_priv *il) +static void +il3945_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) @@ -773,28 +772,28 @@ static void il3945_set_pwr_vmain(struct il_priv *il) */ il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); - _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, - CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } -static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +static int +il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_wr(il, FH39_RCSR_RPTR_ADDR(0), - rxq->rb_stts_dma); + il_wr(il, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); il_wr(il, FH39_RCSR_WPTR(0), 0); il_wr(il, FH39_RCSR_CONFIG(0), - FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | - FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | - (RX_QUEUE_SIZE_LOG << FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) | - FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | - (1 << FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) | - FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); + FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | + FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | (RX_QUEUE_SIZE_LOG + << + FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) + | FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | (1 << + FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) + | FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ il_rd(il, FH39_RSSR_CTRL); @@ -802,7 +801,8 @@ static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) return 0; } -static int il3945_tx_reset(struct il_priv *il) +static int +il3945_tx_reset(struct il_priv *il) { /* bypass mode */ @@ -819,18 +819,16 @@ static int il3945_tx_reset(struct il_priv *il) il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - il_wr(il, FH39_TSSR_CBB_BASE, - il->_3945.shared_phys); + il_wr(il, FH39_TSSR_CBB_BASE, il->_3945.shared_phys); il_wr(il, FH39_TSSR_MSG_CONFIG, - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); - + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); return 0; } @@ -840,7 +838,8 @@ static int il3945_tx_reset(struct il_priv *il) * * Destroys all DMA structures and initialize them again */ -static int il3945_txq_ctx_reset(struct il_priv *il) +static int +il3945_txq_ctx_reset(struct il_priv *il) { int rc; int txq_id, slots_num; @@ -859,10 +858,10 @@ static int il3945_txq_ctx_reset(struct il_priv *il) /* Tx queue(s) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = il_tx_queue_init(il, &il->txq[txq_id], - slots_num, txq_id); + slots_num = + (txq_id == + IL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (rc) { IL_ERR("Tx %d queue init failed\n", txq_id); goto error; @@ -871,18 +870,18 @@ static int il3945_txq_ctx_reset(struct il_priv *il) return rc; - error: +error: il3945_hw_txq_ctx_free(il); return rc; } - /* * Start up 3945's basic functionality after it has been reset * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -static int il3945_apm_init(struct il_priv *il) +static int +il3945_apm_init(struct il_priv *il) { int ret = il_apm_init(il); @@ -891,16 +890,15 @@ static int il3945_apm_init(struct il_priv *il) il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ - il_set_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); + il_set_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - il_clear_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); + il_clear_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); return ret; } -static void il3945_nic_config(struct il_priv *il) +static void +il3945_nic_config(struct il_priv *il) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; unsigned long flags; @@ -916,42 +914,40 @@ static void il3945_nic_config(struct il_priv *il) else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { D_INFO("3945 RADIO-MB type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); + CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { D_INFO("3945 RADIO-MM type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); + CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { D_INFO("SKU OP mode is mrc\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); + CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else D_INFO("SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } if (eeprom->almgor_m_version <= 1) { il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); D_INFO("Card M type A version is 0x%X\n", - eeprom->almgor_m_version); + eeprom->almgor_m_version); } else { D_INFO("Card M type B version is 0x%X\n", - eeprom->almgor_m_version); + eeprom->almgor_m_version); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); } spin_unlock_irqrestore(&il->lock, flags); @@ -962,7 +958,8 @@ static void il3945_nic_config(struct il_priv *il) D_RF_KILL("HW RF KILL supported in EEPROM.\n"); } -int il3945_hw_nic_init(struct il_priv *il) +int +il3945_hw_nic_init(struct il_priv *il) { int rc; unsigned long flags; @@ -990,11 +987,10 @@ int il3945_hw_nic_init(struct il_priv *il) il3945_rx_init(il, rxq); - /* Look at using this instead: - rxq->need_update = 1; - il_rx_queue_update_write_ptr(il, rxq); - */ + rxq->need_update = 1; + il_rx_queue_update_write_ptr(il, rxq); + */ il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); @@ -1012,14 +1008,14 @@ int il3945_hw_nic_init(struct il_priv *il) * * Destroy all TX DMA queues and structures */ -void il3945_hw_txq_ctx_free(struct il_priv *il) +void +il3945_hw_txq_ctx_free(struct il_priv *il) { int txq_id; /* Tx queues */ if (il->txq) - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; - txq_id++) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) if (txq_id == IL39_CMD_QUEUE_NUM) il_cmd_queue_free(il); else @@ -1029,7 +1025,8 @@ void il3945_hw_txq_ctx_free(struct il_priv *il) il_txq_mem(il); } -void il3945_hw_txq_ctx_stop(struct il_priv *il) +void +il3945_hw_txq_ctx_stop(struct il_priv *il) { int txq_id; @@ -1041,8 +1038,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); il_poll_bit(il, FH39_TSSR_TX_STATUS, - FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), - 1000); + FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), + 1000); } il3945_hw_txq_ctx_free(il); @@ -1052,7 +1049,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) * il3945_hw_reg_adjust_power_by_temp * return idx delta into power gain settings table */ -static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) +static int +il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) { return (new_reading - old_reading) * (-11) / 100; } @@ -1060,12 +1058,14 @@ static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) /** * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range */ -static inline int il3945_hw_reg_temp_out_of_range(int temperature) +static inline int +il3945_hw_reg_temp_out_of_range(int temperature) { return (temperature < -260 || temperature > 25) ? 1 : 0; } -int il3945_hw_get_temperature(struct il_priv *il) +int +il3945_hw_get_temperature(struct il_priv *il) { return _il_rd(il, CSR_UCODE_DRV_GP2); } @@ -1074,7 +1074,8 @@ int il3945_hw_get_temperature(struct il_priv *il) * il3945_hw_reg_txpower_get_temperature * get the current temperature by reading from NIC */ -static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) +static int +il3945_hw_reg_txpower_get_temperature(struct il_priv *il) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int temperature; @@ -1093,7 +1094,7 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) * substitute the 3rd band/group's temp measured at factory */ if (il->last_temperature > 100) temperature = eeprom->groups[2].temperature; - else /* else use most recent "sane" value from driver */ + else /* else use most recent "sane" value from driver */ temperature = il->last_temperature; } @@ -1111,7 +1112,8 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) * records new temperature in tx_mgr->temperature. * replaces tx_mgr->last_temperature *only* if calib needed * (assumes caller will actually do the calibration!). */ -static int il3945_is_temp_calib_needed(struct il_priv *il) +static int +il3945_is_temp_calib_needed(struct il_priv *il) { int temp_diff; @@ -1226,7 +1228,7 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {3, 113}, {3, 106}, {3, 102}, - {3, 95} }, /* 2.4 GHz, lowest power */ + {3, 95}}, /* 2.4 GHz, lowest power */ { {251, 127}, /* 5.x GHz, highest power */ {251, 120}, @@ -1305,10 +1307,11 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {35, 113}, {35, 107}, {35, 99}, - {3, 120} } /* 5.x GHz, lowest power */ + {3, 120}} /* 5.x GHz, lowest power */ }; -static inline u8 il3945_hw_reg_fix_power_idx(int idx) +static inline u8 +il3945_hw_reg_fix_power_idx(int idx) { if (idx < 0) return 0; @@ -1326,10 +1329,10 @@ static inline u8 il3945_hw_reg_fix_power_idx(int idx) * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, - s32 rate_idx, const s8 *clip_pwrs, - struct il_channel_info *ch_info, - int band_idx) +static void +il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, s32 rate_idx, + const s8 * clip_pwrs, + struct il_channel_info *ch_info, int band_idx) { struct il3945_scan_power_info *scan_power_info; s8 power; @@ -1350,9 +1353,13 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, * current "normal" temperature-compensated Tx power *idx* for * this rate (1Mb or 6Mb) to yield new temp-compensated scan power * *idx*. */ - power_idx = ch_info->power_info[rate_idx].power_table_idx - - (power - ch_info->power_info - [RATE_6M_IDX_TBL].requested_power) * 2; + power_idx = + ch_info->power_info[rate_idx].power_table_idx - (power - + ch_info-> + power_info + [RATE_6M_IDX_TBL]. + requested_power) * + 2; /* store reference idx that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1379,7 +1386,8 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, * Configures power settings for all rates for the current channel, * using values from channel info struct, and send to NIC */ -static int il3945_send_tx_power(struct il_priv *il) +static int +il3945_send_tx_power(struct il_priv *il) { int rate_idx, i; const struct il_channel_info *ch_info = NULL; @@ -1388,8 +1396,9 @@ static int il3945_send_tx_power(struct il_priv *il) }; u16 chan; - if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) + if (WARN_ONCE + (test_bit(S_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) return -EAGAIN; chan = le16_to_cpu(il->ctx.active.channel); @@ -1397,15 +1406,13 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; ch_info = il_get_channel_info(il, il->band, chan); if (!ch_info) { - IL_ERR( - "Failed to get channel info for channel %d [%d]\n", - chan, il->band); + IL_ERR("Failed to get channel info for channel %d [%d]\n", chan, + il->band); return -EINVAL; } if (!il_is_channel_valid(ch_info)) { - D_POWER("Not calling TX_PWR_TBL_CMD on " - "non-Tx channel.\n"); + D_POWER("Not calling TX_PWR_TBL_CMD on " "non-Tx channel.\n"); return 0; } @@ -1418,29 +1425,25 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].rate = il3945_rates[rate_idx].plcp; D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); + le16_to_cpu(txpower.channel), txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, txpower.power[i].rate); } /* Fill CCK rates */ - for (rate_idx = IL_FIRST_CCK_RATE; - rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { + for (rate_idx = IL_FIRST_CCK_RATE; rate_idx <= IL_LAST_CCK_RATE; + rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); + le16_to_cpu(txpower.channel), txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, txpower.power[i].rate); } return il_send_cmd_pdu(il, C_TX_PWR_TBL, - sizeof(struct il3945_txpowertable_cmd), - &txpower); + sizeof(struct il3945_txpowertable_cmd), + &txpower); } @@ -1460,8 +1463,8 @@ static int il3945_send_tx_power(struct il_priv *il) * properly fill out the scan powers, and actual h/w gain settings, * and send changes to NIC */ -static int il3945_hw_reg_set_new_power(struct il_priv *il, - struct il_channel_info *ch_info) +static int +il3945_hw_reg_set_new_power(struct il_priv *il, struct il_channel_info *ch_info) { struct il3945_channel_power_info *power_info; int power_changed = 0; @@ -1476,8 +1479,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; - i++, ++power_info) { + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++, ++power_info) { int delta_idx; /* limit new power to be no more than h/w capability */ @@ -1500,8 +1502,8 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[RATE_12M_IDX_TBL]. - requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; + ch_info->power_info[RATE_12M_IDX_TBL].requested_power + + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { @@ -1523,15 +1525,17 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * based strictly on regulatory (eeprom and spectrum mgt) limitations * (no consideration for h/w clipping limitations). */ -static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) +static int +il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) { s8 max_power; #if 0 /* if we're using TGd limits, use lower of TGd or EEPROM */ if (ch_info->tgd_data.max_power != 0) - max_power = min(ch_info->tgd_data.max_power, - ch_info->eeprom.max_power_avg); + max_power = + min(ch_info->tgd_data.max_power, + ch_info->eeprom.max_power_avg); /* else just use EEPROM limits */ else @@ -1551,12 +1555,13 @@ static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) * * If RxOn is "associated", this sends the new Txpower to NIC! */ -static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) +static int +il3945_hw_reg_comp_txpower_temp(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int delta_idx; - const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ + const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; u8 rate_idx; u8 scan_tbl_idx; @@ -1564,8 +1569,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) int ref_temp; int temperature = il->temperature; - if (il->disable_tx_power_cal || - test_bit(S_SCANNING, &il->status)) { + if (il->disable_tx_power_cal || test_bit(S_SCANNING, &il->status)) { /* do not perform tx power calibration */ return 0; } @@ -1575,17 +1579,15 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ - ref_temp = (s16)eeprom->groups[ch_info->group_idx]. - temperature; + ref_temp = (s16) eeprom->groups[ch_info->group_idx].temperature; /* get power idx adjustment based on current and factory * temps */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - ref_temp); + delta_idx = + il3945_hw_reg_adjust_power_by_temp(temperature, ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_idx = 0; rate_idx < RATE_COUNT_3945; - rate_idx++) { + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; rate_idx++) { int power_idx = ch_info->power_info[rate_idx].base_power_idx; @@ -1594,23 +1596,25 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) /* stay within table range */ power_idx = il3945_hw_reg_fix_power_idx(power_idx); - ch_info->power_info[rate_idx]. - power_table_idx = (u8) power_idx; + ch_info->power_info[rate_idx].power_table_idx = + (u8) power_idx; ch_info->power_info[rate_idx].tpc = power_gain_table[a_band][power_idx]; } /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + clip_pwrs = + il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; + scan_tbl_idx++) { + s32 actual_idx = + (scan_tbl_idx == + 0) ? RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, - ch_info, a_band); + actual_idx, clip_pwrs, + ch_info, a_band); } } @@ -1618,7 +1622,8 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) return il->cfg->ops->lib->send_tx_power(il); } -int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) +int +il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) { struct il_channel_info *ch_info; s8 max_power; @@ -1626,8 +1631,8 @@ int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) u8 i; if (il->tx_power_user_lmt == power) { - D_POWER("Requested Tx power same as current " - "limit: %ddBm.\n", power); + D_POWER("Requested Tx power same as current " "limit: %ddBm.\n", + power); return 0; } @@ -1660,8 +1665,8 @@ int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) return 0; } -static int il3945_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int rc = 0; struct il_rx_pkt *pkt; @@ -1712,7 +1717,8 @@ static int il3945_send_rxon_assoc(struct il_priv *il, * function correctly transitions out of the RXON_ASSOC_MSK state if * a HW tune is required based on the RXON structure changes. */ -int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +int +il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; @@ -1730,8 +1736,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK; /* select antenna */ - staging_rxon->flags &= - ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); + staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); staging_rxon->flags |= il3945_get_antenna_flags(il); rc = il_check_rxon_cmd(il, ctx); @@ -1743,13 +1748,11 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) /* If we don't need to send a full RXON, we can use * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(il, - &il->ctx)) { - rc = il_send_rxon_assoc(il, - &il->ctx); + if (!il_full_rxon_required(il, &il->ctx)) { + rc = il_send_rxon_assoc(il, &il->ctx); if (rc) { IL_ERR("Error setting RXON_ASSOC " - "configuration (%d).\n", rc); + "configuration (%d).\n", rc); return rc; } @@ -1776,31 +1779,24 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(il, C_RXON, - sizeof(struct il3945_rxon_cmd), - &il->ctx.active); + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), + &il->ctx.active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; IL_ERR("Error clearing ASSOC_MSK on current " - "configuration (%d).\n", rc); + "configuration (%d).\n", rc); return rc; } - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); + il_clear_ucode_stations(il, &il->ctx); + il_restore_stations(il, &il->ctx); } - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(staging_rxon->channel), - staging_rxon->bssid_addr); + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" "* bssid = %pM\n", (new_assoc ? "" : "out"), + le16_to_cpu(staging_rxon->channel), staging_rxon->bssid_addr); /* * reserved4 and 5 could have been filled by the iwlcore code. @@ -1812,9 +1808,8 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = il_send_cmd_pdu(il, C_RXON, - sizeof(struct il3945_rxon_cmd), - staging_rxon); + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), + staging_rxon); if (rc) { IL_ERR("Error setting new configuration (%d).\n", rc); return rc; @@ -1823,10 +1818,8 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); if (!new_assoc) { - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); + il_clear_ucode_stations(il, &il->ctx); + il_restore_stations(il, &il->ctx); } /* If we issue a new RXON command which required a tune then we must @@ -1857,7 +1850,8 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * -- send new set of gain settings to NIC * NOTE: This should continue working, even when we're not associated, * so we can keep our internal table of scan powers current. */ -void il3945_reg_txpower_periodic(struct il_priv *il) +void +il3945_reg_txpower_periodic(struct il_priv *il) { /* This will kick in the "brute force" * il3945_hw_reg_comp_txpower_temp() below */ @@ -1869,15 +1863,16 @@ void il3945_reg_txpower_periodic(struct il_priv *il) * ignoring any previous power measurements */ il3945_hw_reg_comp_txpower_temp(il); - reschedule: - queue_delayed_work(il->workqueue, - &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); +reschedule: + queue_delayed_work(il->workqueue, &il->_3945.thermal_periodic, + REG_RECALIB_PERIOD * HZ); } -static void il3945_bg_reg_txpower_periodic(struct work_struct *work) +static void +il3945_bg_reg_txpower_periodic(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, - _3945.thermal_periodic.work); + _3945.thermal_periodic.work); if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -1898,8 +1893,9 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, - const struct il_channel_info *ch_info) +static u16 +il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, + const struct il_channel_info *ch_info) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; @@ -1922,8 +1918,7 @@ static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, } else group_idx = 0; /* 2.4 GHz, group 0 */ - D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, - group_idx); + D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, group_idx); return group_idx; } @@ -1933,9 +1928,9 @@ static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, * Interpolate to get nominal (i.e. at factory calibration temperature) idx * into radio/DSP gain settings table for requested power. */ -static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, - s8 requested_power, - s32 setting_idx, s32 *new_idx) +static int +il3945_hw_reg_get_matched_power_idx(struct il_priv *il, s8 requested_power, + s32 setting_idx, s32 * new_idx) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -1975,14 +1970,16 @@ static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, return -EINVAL; gains0 = (s32) samples[idx0].gain_idx * (1 << 19); gains1 = (s32) samples[idx1].gain_idx * (1 << 19); - res = gains0 + (gains1 - gains0) * - ((s32) power - (s32) samples[idx0].power) / denominator + - (1 << 18); + res = + gains0 + (gains1 - gains0) * ((s32) power - + (s32) samples[idx0].power) / + denominator + (1 << 18); *new_idx = res >> 19; return 0; } -static void il3945_hw_reg_init_channel_groups(struct il_priv *il) +static void +il3945_hw_reg_init_channel_groups(struct il_priv *il) { u32 i; s32 rate_idx; @@ -1999,8 +1996,8 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { IL_WARN("Error: saturation power is %d, " - "less than minimum expected 40\n", - group->saturation_power); + "less than minimum expected 40\n", + group->saturation_power); return; } @@ -2019,8 +2016,8 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) satur_pwr = (s8) (group->saturation_power >> 1); /* fill in channel group's nominal powers for each rate */ - for (rate_idx = 0; - rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; + rate_idx++, clip_pwrs++) { switch (rate_idx) { case RATE_36M_IDX_TBL: if (i == 0) /* B/G */ @@ -2063,7 +2060,8 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) * * This does *not* write values to NIC, just sets up our internal table. */ -int il3945_txpower_set_from_eeprom(struct il_priv *il) +int +il3945_txpower_set_from_eeprom(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_channel_power_info *pwr_info; @@ -2093,25 +2091,25 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) continue; /* find this channel's channel group (*not* "band") idx */ - ch_info->group_idx = - il3945_hw_reg_get_ch_grp_idx(il, ch_info); + ch_info->group_idx = il3945_hw_reg_get_ch_grp_idx(il, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + clip_pwrs = + il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* calculate power idx *adjustment* value according to * diff between current temperature and factory temperature */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - eeprom->groups[ch_info->group_idx]. - temperature); + delta_idx = + il3945_hw_reg_adjust_power_by_temp(temperature, + eeprom->groups[ch_info-> + group_idx]. + temperature); - D_POWER("Delta idx for channel %d: %d [%d]\n", - ch_info->channel, delta_idx, temperature + - IL_TEMP_CONVERT); + D_POWER("Delta idx for channel %d: %d [%d]\n", ch_info->channel, + delta_idx, temperature + IL_TEMP_CONVERT); /* set tx power value for all OFDM rates */ - for (rate_idx = 0; rate_idx < IL_OFDM_RATES; - rate_idx++) { + for (rate_idx = 0; rate_idx < IL_OFDM_RATES; rate_idx++) { s32 uninitialized_var(power_idx); int rc; @@ -2125,8 +2123,9 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) /* get base (i.e. at factory-measured temperature) * power table idx for this rate's power */ rc = il3945_hw_reg_get_matched_power_idx(il, pwr, - ch_info->group_idx, - &power_idx); + ch_info-> + group_idx, + &power_idx); if (rc) { IL_ERR("Invalid power idx\n"); return rc; @@ -2148,14 +2147,12 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) power_gain_table[a_band][power_idx].dsp_atten; } - /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ + /* set tx power for CCK rates, based on OFDM 12 Mbit settings */ pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; - power = pwr_info->requested_power + - IL_CCK_FROM_OFDM_POWER_DIFF; - pwr_idx = pwr_info->power_table_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; - base_pwr_idx = pwr_info->base_power_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; + power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; + pwr_idx = pwr_info->power_table_idx + IL_CCK_FROM_OFDM_IDX_DIFF; + base_pwr_idx = + pwr_info->base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; /* stay within table range */ pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); @@ -2165,9 +2162,9 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) /* fill each CCK rate's il3945_channel_power_info structure * NOTE: All CCK-rate Txpwrs are the same for a given chnl! * NOTE: CCK rates start at end of OFDM rates! */ - for (rate_idx = 0; - rate_idx < IL_CCK_RATES; rate_idx++) { - pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; + for (rate_idx = 0; rate_idx < IL_CCK_RATES; rate_idx++) { + pwr_info = + &ch_info->power_info[rate_idx + IL_OFDM_RATES]; pwr_info->requested_power = power; pwr_info->power_table_idx = pwr_idx; pwr_info->base_power_idx = base_pwr_idx; @@ -2176,48 +2173,52 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; + scan_tbl_idx++) { + s32 actual_idx = + (scan_tbl_idx == + 0) ? RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, ch_info, a_band); + actual_idx, clip_pwrs, + ch_info, a_band); } } return 0; } -int il3945_hw_rxq_stop(struct il_priv *il) +int +il3945_hw_rxq_stop(struct il_priv *il) { int rc; il_wr(il, FH39_RCSR_CONFIG(0), 0); rc = il_poll_bit(il, FH39_RSSR_STATUS, - FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) IL_ERR("Can't stop Rx DMA.\n"); return 0; } -int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) +int +il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; struct il3945_shared *shared_data = il->_3945.shared_virt; - shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); + shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32) txq->q.dma_addr); il_wr(il, FH39_CBCC_CTRL(txq_id), 0); il_wr(il, FH39_CBCC_BASE(txq_id), 0); il_wr(il, FH39_TCSR_CONFIG(txq_id), - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | - FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | + FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ _il_rd(il, FH39_TSSR_CBB_BASE); @@ -2228,7 +2229,8 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) /* * HCMD utils */ -static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) +static u16 +il3945_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case C_RXON: @@ -2240,9 +2242,8 @@ static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) } } - -static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) +static u16 +il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) { struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; addsta->mode = cmd->mode; @@ -2256,11 +2257,11 @@ static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - return (u16)sizeof(struct il3945_addsta_cmd); + return (u16) sizeof(struct il3945_addsta_cmd); } -static int il3945_add_bssid_station(struct il_priv *il, - const u8 *addr, u8 *sta_id_r) +static int +il3945_add_bssid_station(struct il_priv *il, const u8 * addr, u8 * sta_id_r) { struct il_rxon_context *ctx = &il->ctx; int ret; @@ -2285,34 +2286,39 @@ static int il3945_add_bssid_station(struct il_priv *il, return 0; } -static int il3945_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) + +static int +il3945_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, + bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; int ret; if (add) { - ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, - &vif_priv->ibss_bssid_sta_id); + ret = + il3945_add_bssid_station(il, vif->bss_conf.bssid, + &vif_priv->ibss_bssid_sta_id); if (ret) return ret; il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, - (il->band == IEEE80211_BAND_5GHZ) ? - RATE_6M_PLCP : RATE_1M_PLCP); + (il->band == + IEEE80211_BAND_5GHZ) ? RATE_6M_PLCP : + RATE_1M_PLCP); il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); return 0; } return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); + vif->bss_conf.bssid); } /** * il3945_init_hw_rate_table - Initialize the hardware rate fallback table */ -int il3945_init_hw_rate_table(struct il_priv *il) +int +il3945_init_hw_rate_table(struct il_priv *il) { int rc, i, idx, prev_idx; struct il3945_rate_scaling_cmd rate_cmd = { @@ -2324,11 +2330,10 @@ int il3945_init_hw_rate_table(struct il_priv *il) idx = il3945_rates[i].table_rs_idx; table[idx].rate_n_flags = - il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); + il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); table[idx].try_cnt = il->retry_rate; prev_idx = il3945_get_prev_ieee_rate(i); - table[idx].next_rate_idx = - il3945_rates[prev_idx].table_rs_idx; + table[idx].next_rate_idx = il3945_rates[prev_idx].table_rs_idx; } switch (il->band) { @@ -2336,14 +2341,12 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_IDX_TBL; - i <= RATE_11M_IDX_TBL; i++) + for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) table[i].next_rate_idx = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TBL].next_rate_idx = - RATE_9M_IDX_TBL; + table[RATE_12M_IDX_TBL].next_rate_idx = RATE_9M_IDX_TBL; /* Don't drop out of OFDM rates */ table[RATE_6M_IDX_TBL].next_rate_idx = @@ -2359,10 +2362,9 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { idx = IL_FIRST_CCK_RATE; - for (i = RATE_6M_IDX_TBL; - i <= RATE_54M_IDX_TBL; i++) + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++) table[i].next_rate_idx = - il3945_rates[idx].table_rs_idx; + il3945_rates[idx].table_rs_idx; idx = RATE_11M_IDX_TBL; /* CCK shouldn't fall back to OFDM... */ @@ -2377,27 +2379,24 @@ int il3945_init_hw_rate_table(struct il_priv *il) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); + rc = il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); + return il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } /* Called when initializing driver */ -int il3945_hw_set_hw_params(struct il_priv *il) +int +il3945_hw_set_hw_params(struct il_priv *il) { - memset((void *)&il->hw_params, 0, - sizeof(struct il_hw_params)); + memset((void *)&il->hw_params, 0, sizeof(struct il_hw_params)); il->_3945.shared_virt = - dma_alloc_coherent(&il->pci_dev->dev, - sizeof(struct il3945_shared), - &il->_3945.shared_phys, GFP_KERNEL); + dma_alloc_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), + &il->_3945.shared_phys, GFP_KERNEL); if (!il->_3945.shared_virt) { IL_ERR("failed to allocate pci memory\n"); return -ENOMEM; @@ -2422,8 +2421,9 @@ int il3945_hw_set_hw_params(struct il_priv *il) return 0; } -unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate) +unsigned int +il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame, + u8 rate) { struct il3945_tx_beacon_cmd *tx_beacon_cmd; unsigned int frame_size; @@ -2431,51 +2431,53 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); - tx_beacon_cmd->tx.sta_id = - il->ctx.bcast_sta_id; + tx_beacon_cmd->tx.sta_id = il->ctx.bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - frame_size = il3945_fill_beacon_frame(il, - tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + frame_size = + il3945_fill_beacon_frame(il, tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); BUG_ON(frame_size > MAX_MPDU_SIZE); - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + tx_beacon_cmd->tx.len = cpu_to_le16((u16) frame_size); tx_beacon_cmd->tx.rate = rate; - tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK); + tx_beacon_cmd->tx.tx_flags = + (TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK); - /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ + /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE */ tx_beacon_cmd->tx.supp_rates[0] = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - tx_beacon_cmd->tx.supp_rates[1] = - (IL_CCK_BASIC_RATES_MASK & 0xF); + tx_beacon_cmd->tx.supp_rates[1] = (IL_CCK_BASIC_RATES_MASK & 0xF); return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void il3945_hw_handler_setup(struct il_priv *il) +void +il3945_hw_handler_setup(struct il_priv *il) { il->handlers[C_TX] = il3945_hdl_tx; il->handlers[N_3945_RX] = il3945_hdl_rx; } -void il3945_hw_setup_deferred_work(struct il_priv *il) +void +il3945_hw_setup_deferred_work(struct il_priv *il) { INIT_DELAYED_WORK(&il->_3945.thermal_periodic, il3945_bg_reg_txpower_periodic); } -void il3945_hw_cancel_deferred_work(struct il_priv *il) +void +il3945_hw_cancel_deferred_work(struct il_priv *il) { cancel_delayed_work(&il->_3945.thermal_periodic); } /* check contents of special bootstrap uCode SRAM */ -static int il3945_verify_bsm(struct il_priv *il) - { +static int +il3945_verify_bsm(struct il_priv *il) +{ __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; u32 reg; @@ -2485,16 +2487,14 @@ static int il3945_verify_bsm(struct il_priv *il) /* verify BSM SRAM contents */ val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; + for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, + len, val, le32_to_cpu(*image)); return -EIO; } } @@ -2504,7 +2504,6 @@ static int il3945_verify_bsm(struct il_priv *il) return 0; } - /****************************************************************************** * * EEPROM related functions @@ -2519,14 +2518,15 @@ static int il3945_verify_bsm(struct il_priv *il) * simply claims ownership, which should be safe when this function is called * (i.e. before loading uCode!). */ -static int il3945_eeprom_acquire_semaphore(struct il_priv *il) +static int +il3945_eeprom_acquire_semaphore(struct il_priv *il) { _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); return 0; } - -static void il3945_eeprom_release_semaphore(struct il_priv *il) +static void +il3945_eeprom_release_semaphore(struct il_priv *il) { return; } @@ -2563,7 +2563,8 @@ static void il3945_eeprom_release_semaphore(struct il_priv *il) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il3945_load_bsm(struct il_priv *il) +static int +il3945_load_bsm(struct il_priv *il) { __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; @@ -2583,10 +2584,10 @@ static int il3945_load_bsm(struct il_priv *il) return -EINVAL; /* Tell bootstrap uCode where to find the "Initialize" uCode - * in host DRAM ... host DRAM physical address bits 31:0 for 3945. - * NOTE: il3945_initialize_alive_start() will replace these values, - * after the "initialize" uCode has run, to point to - * runtime/protocol instructions and backup data cache. */ + * in host DRAM ... host DRAM physical address bits 31:0 for 3945. + * NOTE: il3945_initialize_alive_start() will replace these values, + * after the "initialize" uCode has run, to point to + * runtime/protocol instructions and backup data cache. */ pinst = il->ucode_init.p_addr; pdata = il->ucode_init_data.p_addr; inst_len = il->ucode_init.len; @@ -2601,8 +2602,7 @@ static int il3945_load_bsm(struct il_priv *il) for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_wr_prph(il, reg_offset, - le32_to_cpu(*image)); + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); rc = il3945_verify_bsm(il); if (rc) @@ -2610,14 +2610,12 @@ static int il3945_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, BSM_WR_MEM_DST_REG, - IL39_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IL39_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START); + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { @@ -2635,8 +2633,7 @@ static int il3945_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START_EN); + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; } @@ -2653,30 +2650,30 @@ static struct il_lib_ops il3945_lib = { .load_ucode = il3945_load_bsm, .dump_nic_error_log = il3945_dump_nic_error_log, .apm_ops = { - .init = il3945_apm_init, - .config = il3945_nic_config, - }, + .init = il3945_apm_init, + .config = il3945_nic_config, + }, .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_REGULATORY_BAND_NO_HT40, - EEPROM_REGULATORY_BAND_NO_HT40, - }, - .acquire_semaphore = il3945_eeprom_acquire_semaphore, - .release_semaphore = il3945_eeprom_release_semaphore, - }, - .send_tx_power = il3945_send_tx_power, + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_REGULATORY_BAND_NO_HT40, + EEPROM_REGULATORY_BAND_NO_HT40, + }, + .acquire_semaphore = il3945_eeprom_acquire_semaphore, + .release_semaphore = il3945_eeprom_release_semaphore, + }, + .send_tx_power = il3945_send_tx_power, .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, .debugfs_ops = { - .rx_stats_read = il3945_ucode_rx_stats_read, - .tx_stats_read = il3945_ucode_tx_stats_read, - .general_stats_read = il3945_ucode_general_stats_read, - }, + .rx_stats_read = il3945_ucode_rx_stats_read, + .tx_stats_read = il3945_ucode_tx_stats_read, + .general_stats_read = il3945_ucode_general_stats_read, + }, }; static const struct il_legacy_ops il3945_legacy_ops = { @@ -2729,7 +2726,7 @@ static struct il_cfg il3945_abg_cfg = { .fw_name_pre = IL3945_FW_PRE, .ucode_api_max = IL3945_UCODE_API_MAX, .ucode_api_min = IL3945_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G, + .sku = IL_SKU_A | IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .ops = &il3945_ops, .mod_params = &il3945_mod_params, @@ -2738,13 +2735,14 @@ static struct il_cfg il3945_abg_cfg = { }; DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { - {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, - {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, - {0} + { + IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, { + IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, { + 0} }; MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 1a2430b..8e53751 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -27,7 +27,7 @@ #ifndef __il_3945_h__ #define __il_3945_h__ -#include /* for struct pci_device_id */ +#include /* for struct pci_device_id */ #include #include @@ -93,7 +93,6 @@ struct il3945_rs_sta { int last_txrate_idx; }; - /* * The common struct MUST be first because it is shared between * 3945 and 4965! @@ -186,7 +185,6 @@ struct il3945_ibss_seq { #define IL_RX_STATS(x) (&x->u.rx_frame.stats) #define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) - /****************************************************************************** * * Functions implemented in iwl3945-base.c which are forward declared here @@ -197,9 +195,10 @@ extern int il3945_calc_db_from_ratio(int sig_ratio); extern void il3945_rx_replenish(void *data); extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, int left); + struct ieee80211_hdr *hdr, + int left); extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, - char **buf, bool display); + char **buf, bool display); extern void il3945_dump_nic_error_log(struct il_priv *il); /****************************************************************************** @@ -229,34 +228,29 @@ extern void il3945_hw_txq_ctx_free(struct il_priv *il); extern void il3945_hw_txq_ctx_stop(struct il_priv *il); extern int il3945_hw_nic_reset(struct il_priv *il); extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad); -extern void il3945_hw_txq_free_tfd(struct il_priv *il, - struct il_tx_queue *txq); + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, + u8 pad); +extern void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); extern int il3945_hw_get_temperature(struct il_priv *il); -extern int il3945_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); +extern int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate); -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id); + struct il3945_frame *frame, + u8 rate); +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, int sta_id, + int tx_id); extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il3945_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb); +extern void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); +void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); extern void il3945_post_associate(struct il_priv *il); extern void il3945_config_ap(struct il_priv *il); -extern int il3945_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx); +extern int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx); /** * il3945_hw_find_station - Find station id for a given BSSID @@ -266,7 +260,7 @@ extern int il3945_commit_rxon(struct il_priv *il, * not yet been merged into a single common layer for managing the * station tables. */ -extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); +extern u8 il3945_hw_find_station(struct il_priv *il, const u8 * bssid); extern struct ieee80211_ops il3945_hw_ops; @@ -275,8 +269,10 @@ extern int il3945_init_hw_rate_table(struct il_priv *il); extern void il3945_reg_txpower_periodic(struct il_priv *il); extern int il3945_txpower_set_from_eeprom(struct il_priv *il); -extern const struct il_channel_info *il3945_get_channel_info( - const struct il_priv *il, enum ieee80211_band band, u16 channel); +extern const struct il_channel_info *il3945_get_channel_info(const struct + il_priv *il, + enum ieee80211_band + band, u16 channel); extern int il3945_rs_next_rate(struct il_priv *il, int rate); @@ -287,8 +283,6 @@ void il3945_post_scan(struct il_priv *il); /* rates */ extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; - - /* RSSI to dBm */ #define IL39_RSSI_OFFSET 95 @@ -323,7 +317,7 @@ struct il3945_eeprom_txpower_sample { * DO NOT ALTER THIS STRUCTURE!!! */ struct il3945_eeprom_txpower_group { - struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ + struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ s32 a, b, c, d, e; /* coefficients for voltage->power * formula (signed) */ s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on @@ -354,7 +348,7 @@ struct il3945_eeprom_temperature_corr { */ struct il3945_eeprom { u8 reserved0[16]; - u16 device_id; /* abs.ofs: 16 */ + u16 device_id; /* abs.ofs: 16 */ u8 reserved1[2]; u16 pmc; /* abs.ofs: 20 */ u8 reserved2[20]; @@ -389,7 +383,7 @@ struct il3945_eeprom { * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ u16 band_1_count; /* abs.ofs: 196 */ - struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ + struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ /* * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, @@ -397,28 +391,28 @@ struct il3945_eeprom { * (4915-5080MHz) (none of these is ever supported) */ u16 band_2_count; /* abs.ofs: 226 */ - struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ + struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ /* * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 * (5170-5320MHz) */ u16 band_3_count; /* abs.ofs: 254 */ - struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ + struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ /* * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 * (5500-5700MHz) */ u16 band_4_count; /* abs.ofs: 280 */ - struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ + struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ /* * 5.7 GHz channels 145, 149, 153, 157, 161, 165 * (5725-5825MHz) */ u16 band_5_count; /* abs.ofs: 304 */ - struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ + struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ u8 reserved9[194]; @@ -428,7 +422,7 @@ struct il3945_eeprom { #define IL_NUM_TX_CALIB_GROUPS 5 struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; /* abs.ofs: 512 */ - struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ + struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ u8 reserved16[172]; /* fill out to full 1024 byte block */ } __packed; @@ -474,7 +468,8 @@ struct il3945_eeprom { /* Size of uCode instruction memory in bootstrap state machine */ #define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE -static inline int il3945_hw_valid_rtc_data_addr(u32 addr) +static inline int +il3945_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IL39_RTC_DATA_LOWER_BOUND && addr < IL39_RTC_DATA_UPPER_BOUND); @@ -486,19 +481,22 @@ struct il3945_shared { __le32 tx_base_ptr[8]; } __packed; -static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) +static inline u8 +il3945_hw_get_rate(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags) & 0xFF; } -static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) +static inline u16 +il3945_hw_get_rate_n_flags(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags); } -static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) +static inline __le16 +il3945_hw_set_rate_n_flags(u8 rate, u16 flags) { - return cpu_to_le16((u16)rate|flags); + return cpu_to_le16((u16) rate | flags); } /************************************/ @@ -553,7 +551,6 @@ static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) #define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) #define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) - /* DBM */ #define FH39_SRVC_CHNL (6) @@ -622,29 +619,31 @@ struct il3945_tfd { } __packed; #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos); + char __user * user_buf, size_t count, + loff_t * ppos); #else -static ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) +static ssize_t +il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } -static ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) + +static ssize_t +il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } -static ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) + +static ssize_t +il3945_ucode_general_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 405032a..efb3233 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -79,7 +79,8 @@ struct stats_general_data { u32 beacon_energy_c; }; -void il4965_calib_free_results(struct il_priv *il) +void +il4965_calib_free_results(struct il_priv *il) { int i; @@ -102,10 +103,9 @@ void il4965_calib_free_results(struct il_priv *il) * enough to receive all of our own network traffic, but not so * high that our DSP gets too busy trying to lock onto non-network * activity/noise. */ -static int il4965_sens_energy_cck(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time, - struct stats_general_data *rx_info) +static int +il4965_sens_energy_cck(struct il_priv *il, u32 norm_fa, u32 rx_enable_time, + struct stats_general_data *rx_info) { u32 max_nrg_cck = 0; int i = 0; @@ -138,12 +138,12 @@ static int il4965_sens_energy_cck(struct il_priv *il, /* Find max silence rssi among all 3 receivers. * This is background noise, which may include transmissions from other * networks, measured during silence before our network's beacon */ - silence_rssi_a = (u8)((rx_info->beacon_silence_rssi_a & - ALL_BAND_FILTER) >> 8); - silence_rssi_b = (u8)((rx_info->beacon_silence_rssi_b & - ALL_BAND_FILTER) >> 8); - silence_rssi_c = (u8)((rx_info->beacon_silence_rssi_c & - ALL_BAND_FILTER) >> 8); + silence_rssi_a = + (u8) ((rx_info->beacon_silence_rssi_a & ALL_BAND_FILTER) >> 8); + silence_rssi_b = + (u8) ((rx_info->beacon_silence_rssi_b & ALL_BAND_FILTER) >> 8); + silence_rssi_c = + (u8) ((rx_info->beacon_silence_rssi_c & ALL_BAND_FILTER) >> 8); val = max(silence_rssi_b, silence_rssi_c); max_silence_rssi = max(silence_rssi_a, (u8) val); @@ -159,9 +159,8 @@ static int il4965_sens_energy_cck(struct il_priv *il, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", - silence_rssi_a, silence_rssi_b, silence_rssi_c, - silence_ref); + D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, + silence_rssi_b, silence_rssi_c, silence_ref); /* Find max rx energy (min value!) among all 3 receivers, * measured during beacon frame. @@ -184,8 +183,8 @@ static int il4965_sens_energy_cck(struct il_priv *il, max_nrg_cck += 6; D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", - rx_info->beacon_energy_a, rx_info->beacon_energy_b, - rx_info->beacon_energy_c, max_nrg_cck - 6); + rx_info->beacon_energy_a, rx_info->beacon_energy_b, + rx_info->beacon_energy_c, max_nrg_cck - 6); /* Count number of consecutive beacons with fewer-than-desired * false alarms. */ @@ -194,13 +193,13 @@ static int il4965_sens_energy_cck(struct il_priv *il, else data->num_in_cck_no_fa = 0; D_CALIB("consecutive bcns with few false alarms = %u\n", - data->num_in_cck_no_fa); + data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms && data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { - D_CALIB("norm FA %u > max FA %u\n", - false_alarms, max_false_alarms); + D_CALIB("norm FA %u > max FA %u\n", false_alarms, + max_false_alarms); D_CALIB("... reducing sensitivity\n"); data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ @@ -209,19 +208,18 @@ static int il4965_sens_energy_cck(struct il_priv *il, /* increase energy threshold (reduce nrg value) * to decrease sensitivity */ data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; - /* Else if we got fewer than desired, increase sensitivity */ + /* Else if we got fewer than desired, increase sensitivity */ } else if (false_alarms < min_false_alarms) { data->nrg_curr_state = IL_FA_TOO_FEW; /* Compare silence level with silence level for most recent * healthy number or too many false alarms */ - data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - - (s32)silence_ref; + data->nrg_auto_corr_silence_diff = + (s32) data->nrg_silence_ref - (s32) silence_ref; - D_CALIB( - "norm FA %u < min FA %u, silence diff %d\n", - false_alarms, min_false_alarms, - data->nrg_auto_corr_silence_diff); + D_CALIB("norm FA %u < min FA %u, silence diff %d\n", + false_alarms, min_false_alarms, + data->nrg_auto_corr_silence_diff); /* Increase value to increase sensitivity, but only if: * 1a) previous beacon did *not* have *too many* false alarms @@ -236,13 +234,12 @@ static int il4965_sens_energy_cck(struct il_priv *il, D_CALIB("... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; - data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); + data->nrg_th_cck = min((u32) ranges->min_nrg_cck, val); } else { - D_CALIB( - "... but not changing sensitivity\n"); + D_CALIB("... but not changing sensitivity\n"); } - /* Else we got a healthy number of false alarms, keep status quo */ + /* Else we got a healthy number of false alarms, keep status quo */ } else { D_CALIB(" FA in safe zone\n"); data->nrg_curr_state = IL_FA_GOOD_RANGE; @@ -283,31 +280,28 @@ static int il4965_sens_energy_cck(struct il_priv *il, else { val = data->auto_corr_cck + AUTO_CORR_STEP_CCK; data->auto_corr_cck = - min((u32)ranges->auto_corr_max_cck, val); + min((u32) ranges->auto_corr_max_cck, val); } val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; data->auto_corr_cck_mrc = - min((u32)ranges->auto_corr_max_cck_mrc, val); + min((u32) ranges->auto_corr_max_cck_mrc, val); } else if (false_alarms < min_false_alarms && (data->nrg_auto_corr_silence_diff > NRG_DIFF || data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { /* Decrease auto_corr values to increase sensitivity */ val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; - data->auto_corr_cck = - max((u32)ranges->auto_corr_min_cck, val); + data->auto_corr_cck = max((u32) ranges->auto_corr_min_cck, val); val = data->auto_corr_cck_mrc - AUTO_CORR_STEP_CCK; data->auto_corr_cck_mrc = - max((u32)ranges->auto_corr_min_cck_mrc, val); + max((u32) ranges->auto_corr_min_cck_mrc, val); } return 0; } - -static int il4965_sens_auto_corr_ofdm(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time) +static int +il4965_sens_auto_corr_ofdm(struct il_priv *il, u32 norm_fa, u32 rx_enable_time) { u32 val; u32 false_alarms = norm_fa * 200 * 1024; @@ -321,96 +315,94 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - D_CALIB("norm FA %u > max FA %u)\n", - false_alarms, max_false_alarms); + D_CALIB("norm FA %u > max FA %u)\n", false_alarms, + max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm = - min((u32)ranges->auto_corr_max_ofdm, val); + min((u32) ranges->auto_corr_max_ofdm, val); val = data->auto_corr_ofdm_mrc + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc = - min((u32)ranges->auto_corr_max_ofdm_mrc, val); + min((u32) ranges->auto_corr_max_ofdm_mrc, val); val = data->auto_corr_ofdm_x1 + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_x1 = - min((u32)ranges->auto_corr_max_ofdm_x1, val); + min((u32) ranges->auto_corr_max_ofdm_x1, val); val = data->auto_corr_ofdm_mrc_x1 + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc_x1 = - min((u32)ranges->auto_corr_max_ofdm_mrc_x1, val); + min((u32) ranges->auto_corr_max_ofdm_mrc_x1, val); } /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - D_CALIB("norm FA %u < min FA %u\n", - false_alarms, min_false_alarms); + D_CALIB("norm FA %u < min FA %u\n", false_alarms, + min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm = - max((u32)ranges->auto_corr_min_ofdm, val); + max((u32) ranges->auto_corr_min_ofdm, val); val = data->auto_corr_ofdm_mrc - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc = - max((u32)ranges->auto_corr_min_ofdm_mrc, val); + max((u32) ranges->auto_corr_min_ofdm_mrc, val); val = data->auto_corr_ofdm_x1 - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_x1 = - max((u32)ranges->auto_corr_min_ofdm_x1, val); + max((u32) ranges->auto_corr_min_ofdm_x1, val); val = data->auto_corr_ofdm_mrc_x1 - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc_x1 = - max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); + max((u32) ranges->auto_corr_min_ofdm_mrc_x1, val); } else { D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", - min_false_alarms, false_alarms, max_false_alarms); + min_false_alarms, false_alarms, max_false_alarms); } return 0; } -static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, - struct il_sensitivity_data *data, - __le16 *tbl) +static void +il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, + struct il_sensitivity_data *data, + __le16 * tbl) { tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm); + cpu_to_le16((u16) data->auto_corr_ofdm); tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc); + cpu_to_le16((u16) data->auto_corr_ofdm_mrc); tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_x1); + cpu_to_le16((u16) data->auto_corr_ofdm_x1); tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); + cpu_to_le16((u16) data->auto_corr_ofdm_mrc_x1); tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_cck); + cpu_to_le16((u16) data->auto_corr_cck); tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_cck_mrc); + cpu_to_le16((u16) data->auto_corr_cck_mrc); - tbl[HD_MIN_ENERGY_CCK_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_cck); - tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_ofdm); + tbl[HD_MIN_ENERGY_CCK_DET_IDX] = cpu_to_le16((u16) data->nrg_th_cck); + tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = cpu_to_le16((u16) data->nrg_th_ofdm); tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = - cpu_to_le16(data->barker_corr_th_min); + cpu_to_le16(data->barker_corr_th_min); tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16(data->barker_corr_th_min_mrc); - tbl[HD_OFDM_ENERGY_TH_IN_IDX] = - cpu_to_le16(data->nrg_th_cca); + cpu_to_le16(data->barker_corr_th_min_mrc); + tbl[HD_OFDM_ENERGY_TH_IN_IDX] = cpu_to_le16(data->nrg_th_cca); D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", - data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, - data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, - data->nrg_th_ofdm); + data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, + data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, + data->nrg_th_ofdm); - D_CALIB("cck: ac %u mrc %u thresh %u\n", - data->auto_corr_cck, data->auto_corr_cck_mrc, - data->nrg_th_cck); + D_CALIB("cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, + data->auto_corr_cck_mrc, data->nrg_th_cck); } /* Prepare a C_SENSITIVITY, send to uCode if values have changed */ -static int il4965_sensitivity_write(struct il_priv *il) +static int +il4965_sensitivity_write(struct il_priv *il) { struct il_sensitivity_cmd cmd; struct il_sensitivity_data *data = NULL; @@ -431,20 +423,22 @@ static int il4965_sensitivity_write(struct il_priv *il) cmd.control = C_SENSITIVITY_CONTROL_WORK_TBL; /* Don't send command to uCode if nothing has changed */ - if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), - sizeof(u16)*HD_TBL_SIZE)) { + if (!memcmp + (&cmd.table[0], &(il->sensitivity_tbl[0]), + sizeof(u16) * HD_TBL_SIZE)) { D_CALIB("No change in C_SENSITIVITY\n"); return 0; } /* Copy table for comparison next time */ memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), - sizeof(u16)*HD_TBL_SIZE); + sizeof(u16) * HD_TBL_SIZE); return il_send_cmd(il, &cmd_out); } -void il4965_init_sensitivity(struct il_priv *il) +void +il4965_init_sensitivity(struct il_priv *il) { int ret = 0; int i; @@ -477,9 +471,9 @@ void il4965_init_sensitivity(struct il_priv *il) for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) data->nrg_silence_rssi[i] = 0; - data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; + data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; - data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; + data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; data->auto_corr_cck = AUTO_CORR_CCK_MIN_VAL_DEF; data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; @@ -498,7 +492,8 @@ void il4965_init_sensitivity(struct il_priv *il) D_CALIB("<plcp_err); statis.beacon_silence_rssi_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a); + le32_to_cpu(rx_info->beacon_silence_rssi_a); statis.beacon_silence_rssi_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b); + le32_to_cpu(rx_info->beacon_silence_rssi_b); statis.beacon_silence_rssi_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c); - statis.beacon_energy_a = - le32_to_cpu(rx_info->beacon_energy_a); - statis.beacon_energy_b = - le32_to_cpu(rx_info->beacon_energy_b); - statis.beacon_energy_c = - le32_to_cpu(rx_info->beacon_energy_c); + le32_to_cpu(rx_info->beacon_silence_rssi_c); + statis.beacon_energy_a = le32_to_cpu(rx_info->beacon_energy_a); + statis.beacon_energy_b = le32_to_cpu(rx_info->beacon_energy_b); + statis.beacon_energy_c = le32_to_cpu(rx_info->beacon_energy_c); spin_unlock_irqrestore(&il->lock, flags); @@ -599,9 +591,8 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - D_CALIB( - "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, - bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); + D_CALIB("cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, + bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); @@ -609,7 +600,8 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) il4965_sensitivity_write(il); } -static inline u8 il4965_find_first_chain(u8 mask) +static inline u8 +il4965_find_first_chain(u8 mask) { if (mask & ANT_A) return CHAIN_A; @@ -623,8 +615,8 @@ static inline u8 il4965_find_first_chain(u8 mask) * disconnected. */ static void -il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, - struct il_chain_noise_data *data) +il4965_find_disconn_antenna(struct il_priv *il, u32 * average_sig, + struct il_chain_noise_data *data) { u32 active_chains = 0; u32 max_average_sig; @@ -633,12 +625,15 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, u8 first_chain; u16 i = 0; - average_sig[0] = data->chain_signal_a / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[1] = data->chain_signal_b / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[2] = data->chain_signal_c / - il->cfg->base_params->chain_noise_num_beacons; + average_sig[0] = + data->chain_signal_a / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[1] = + data->chain_signal_b / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[2] = + data->chain_signal_c / + il->cfg->base_params->chain_noise_num_beacons; if (average_sig[0] >= average_sig[1]) { max_average_sig = average_sig[0]; @@ -656,10 +651,10 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - D_CALIB("average_sig: a %d b %d c %d\n", - average_sig[0], average_sig[1], average_sig[2]); - D_CALIB("max_average_sig = %d, antenna %d\n", - max_average_sig, max_average_sig_antenna_i); + D_CALIB("average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], + average_sig[2]); + D_CALIB("max_average_sig = %d, antenna %d\n", max_average_sig, + max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ for (i = 0; i < NUM_RX_CHAINS; i++) { @@ -673,8 +668,8 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, else active_chains |= (1 << i); D_CALIB("i = %d rssiDelta = %d " - "disconn_array[i] = %d\n", - i, rssi_delta, data->disconn_array[i]); + "disconn_array[i] = %d\n", i, rssi_delta, + data->disconn_array[i]); } } @@ -709,34 +704,31 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, * connect the first valid tx chain */ first_chain = - il4965_find_first_chain(il->cfg->valid_tx_ant); + il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - D_CALIB( - "All Tx chains are disconnected W/A - declare %d as connected\n", - first_chain); + D_CALIB + ("All Tx chains are disconnected W/A - declare %d as connected\n", + first_chain); break; } } if (active_chains != il->hw_params.valid_rx_ant && active_chains != il->chain_noise_data.active_chains) - D_CALIB( - "Detected that not all antennas are connected! " - "Connected: %#x, valid: %#x.\n", - active_chains, il->hw_params.valid_rx_ant); + D_CALIB("Detected that not all antennas are connected! " + "Connected: %#x, valid: %#x.\n", active_chains, + il->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - D_CALIB("active_chains (bitwise) = 0x%x\n", - active_chains); + D_CALIB("active_chains (bitwise) = 0x%x\n", active_chains); } -static void il4965_gain_computation(struct il_priv *il, - u32 *average_noise, - u16 min_average_noise_antenna_i, - u32 min_average_noise, - u8 default_chain) +static void +il4965_gain_computation(struct il_priv *il, u32 * average_noise, + u16 min_average_noise_antenna_i, u32 min_average_noise, + u8 default_chain) { int i, ret; struct il_chain_noise_data *data = &il->chain_noise_data; @@ -747,23 +739,22 @@ static void il4965_gain_computation(struct il_priv *il, s32 delta_g = 0; if (!data->disconn_array[i] && - data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { + data->delta_gain_code[i] == + CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { delta_g = average_noise[i] - min_average_noise; - data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); + data->delta_gain_code[i] = (u8) ((delta_g * 10) / 15); data->delta_gain_code[i] = - min(data->delta_gain_code[i], + min(data->delta_gain_code[i], (u8) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); data->delta_gain_code[i] = - (data->delta_gain_code[i] | (1 << 2)); + (data->delta_gain_code[i] | (1 << 2)); } else { data->delta_gain_code[i] = 0; } } - D_CALIB("delta_gain_codes: a %d b %d c %d\n", - data->delta_gain_code[0], - data->delta_gain_code[1], - data->delta_gain_code[2]); + D_CALIB("delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], + data->delta_gain_code[1], data->delta_gain_code[2]); /* Differential gain gets sent to uCode only once */ if (!data->radio_write) { @@ -775,11 +766,9 @@ static void il4965_gain_computation(struct il_priv *il, cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(il, C_PHY_CALIBRATION, - sizeof(cmd), &cmd); + ret = il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd); if (ret) - D_CALIB("fail sending cmd " - "C_PHY_CALIBRATION\n"); + D_CALIB("fail sending cmd " "C_PHY_CALIBRATION\n"); /* TODO we might want recalculate * rx_chain in rxon cmd */ @@ -789,15 +778,14 @@ static void il4965_gain_computation(struct il_priv *il, } } - - /* * Accumulate 16 beacons of signal and noise stats for each of * 3 receivers/antennas/rx-chains, then figure out: * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. */ -void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) +void +il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) { struct il_chain_noise_data *data = NULL; @@ -807,8 +795,8 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) u32 chain_sig_a; u32 chain_sig_b; u32 chain_sig_c; - u32 average_sig[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; - u32 average_noise[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; + u32 average_sig[NUM_RX_CHAINS] = { INITIALIZATION_VALUE }; + u32 average_noise[NUM_RX_CHAINS] = { INITIALIZATION_VALUE }; u32 min_average_noise = MIN_AVERAGE_NOISE_MAX_VALUE; u16 min_average_noise_antenna_i = INITIALIZATION_VALUE; u16 i = 0; @@ -838,8 +826,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) spin_lock_irqsave(&il->lock, flags); - rx_info = &(((struct il_notif_stats *)stat_resp)-> - rx.general); + rx_info = &(((struct il_notif_stats *)stat_resp)->rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { D_CALIB(" << Interference data unavailable\n"); @@ -850,17 +837,17 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); rxon_chnum = le16_to_cpu(ctx->staging.channel); - stat_band24 = !!(((struct il_notif_stats *) - stat_resp)->flag & - STATS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct il_notif_stats *) - stat_resp)->flag) >> 16; + stat_band24 = + !!(((struct il_notif_stats *)stat_resp)-> + flag & STATS_REPLY_FLG_BAND_24G_MSK); + stat_chnum = + le32_to_cpu(((struct il_notif_stats *)stat_resp)->flag) >> 16; /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { - D_CALIB("Stats not from chan=%d, band24=%d\n", - rxon_chnum, rxon_band24); + D_CALIB("Stats not from chan=%d, band24=%d\n", rxon_chnum, + rxon_band24); spin_unlock_irqrestore(&il->lock, flags); return; } @@ -869,12 +856,12 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) * Accumulate beacon stats values across * "chain_noise_num_beacons" */ - chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & - IN_BAND_FILTER; - chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & - IN_BAND_FILTER; - chain_noise_c = le32_to_cpu(rx_info->beacon_silence_rssi_c) & - IN_BAND_FILTER; + chain_noise_a = + le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; + chain_noise_b = + le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; + chain_noise_c = + le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; chain_sig_a = le32_to_cpu(rx_info->beacon_rssi_a) & IN_BAND_FILTER; chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; @@ -892,30 +879,29 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - D_CALIB("chan=%d, band24=%d, beacon=%d\n", - rxon_chnum, rxon_band24, data->beacon_count); - D_CALIB("chain_sig: a %d b %d c %d\n", - chain_sig_a, chain_sig_b, chain_sig_c); - D_CALIB("chain_noise: a %d b %d c %d\n", - chain_noise_a, chain_noise_b, chain_noise_c); + D_CALIB("chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, + data->beacon_count); + D_CALIB("chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, + chain_sig_c); + D_CALIB("chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, + chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: * 1) Disconnected antennas (using signal strengths) * 2) Differential gain (using silence noise) to balance receivers */ - if (data->beacon_count != - il->cfg->base_params->chain_noise_num_beacons) + if (data->beacon_count != il->cfg->base_params->chain_noise_num_beacons) return; /* Analyze signal for disconnected antenna */ il4965_find_disconn_antenna(il, average_sig, data); /* Analyze noise for rx balance */ - average_noise[0] = data->chain_noise_a / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[1] = data->chain_noise_b / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[2] = data->chain_noise_c / - il->cfg->base_params->chain_noise_num_beacons; + average_noise[0] = + data->chain_noise_a / il->cfg->base_params->chain_noise_num_beacons; + average_noise[1] = + data->chain_noise_b / il->cfg->base_params->chain_noise_num_beacons; + average_noise[2] = + data->chain_noise_c / il->cfg->base_params->chain_noise_num_beacons; for (i = 0; i < NUM_RX_CHAINS; i++) { if (!data->disconn_array[i] && @@ -927,16 +913,15 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) } } - D_CALIB("average_noise: a %d b %d c %d\n", - average_noise[0], average_noise[1], - average_noise[2]); + D_CALIB("average_noise: a %d b %d c %d\n", average_noise[0], + average_noise[1], average_noise[2]); - D_CALIB("min_average_noise = %d, antenna %d\n", - min_average_noise, min_average_noise_antenna_i); + D_CALIB("min_average_noise = %d, antenna %d\n", min_average_noise, + min_average_noise_antenna_i); - il4965_gain_computation(il, average_noise, - min_average_noise_antenna_i, min_average_noise, - il4965_find_first_chain(il->cfg->valid_rx_ant)); + il4965_gain_computation(il, average_noise, min_average_noise_antenna_i, + min_average_noise, + il4965_find_first_chain(il->cfg->valid_rx_ant)); /* Some power changes may have been made during the calibration. * Update and commit the RXON @@ -948,16 +933,15 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) il_power_update_mode(il, false); } -void il4965_reset_run_time_calib(struct il_priv *il) +void +il4965_reset_run_time_calib(struct il_priv *il) { int i; - memset(&(il->sensitivity_data), 0, - sizeof(struct il_sensitivity_data)); - memset(&(il->chain_noise_data), 0, - sizeof(struct il_chain_noise_data)); + memset(&(il->sensitivity_data), 0, sizeof(struct il_sensitivity_data)); + memset(&(il->chain_noise_data), 0, sizeof(struct il_chain_noise_data)); for (i = 0; i < NUM_RX_CHAINS; i++) il->chain_noise_data.delta_gain_code[i] = - CHAIN_NOISE_DELTA_GAIN_INIT_VAL; + CHAIN_NOISE_DELTA_GAIN_INIT_VAL; /* Ask for stats now, the uCode will send notification * periodically after association */ diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 5f89031..5299399 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -31,9 +31,10 @@ static const char *fmt_value = " %-30s %10u\n"; static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = - "%-32s current cumulative delta max\n"; + "%-32s current cumulative delta max\n"; -static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) +static int +il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; u32 flag; @@ -43,26 +44,28 @@ static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); if (flag & UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, - "\tStatistics have been cleared\n"); + "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (flag & UCODE_STATS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); + (flag & UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : + "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (flag & UCODE_STATS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); + (flag & UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : + "disabled"); return p; } -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il4965_ucode_rx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct stats_rx_phy) * 40 + - sizeof(struct stats_rx_non_phy) * 40 + - sizeof(struct stats_rx_ht_phy) * 40 + 400; + int bufsz = + sizeof(struct stats_rx_phy) * 40 + + sizeof(struct stats_rx_non_phy) * 40 + + sizeof(struct stats_rx_ht_phy) * 40 + 400; ssize_t ret; struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; @@ -102,392 +105,371 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, max_ht = &il->_4965.max_delta.rx.ofdm_ht; pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, - max_ofdm->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(ofdm->sent_ba_rsp_cnt), - accum_ofdm->sent_ba_rsp_cnt, - delta_ofdm->sent_ba_rsp_cnt, - max_ofdm->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(ofdm->dsp_self_kill), - accum_ofdm->dsp_self_kill, - delta_ofdm->dsp_self_kill, - max_ofdm->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ofdm->mh_format_err), - accum_ofdm->mh_format_err, - delta_ofdm->mh_format_err, - max_ofdm->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(ofdm->re_acq_main_rssi_sum), - accum_ofdm->re_acq_main_rssi_sum, - delta_ofdm->re_acq_main_rssi_sum, - max_ofdm->re_acq_main_rssi_sum); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - OFDM:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:", + le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", + le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err, + delta_ofdm->overrun_err, max_ofdm->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", + le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good, + delta_ofdm->crc32_good, max_ofdm->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout, + delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout, + delta_ofdm->fina_timeout, max_ofdm->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt, + delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt, + delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(ofdm->sent_ba_rsp_cnt), + accum_ofdm->sent_ba_rsp_cnt, delta_ofdm->sent_ba_rsp_cnt, + max_ofdm->sent_ba_rsp_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:", + le32_to_cpu(ofdm->dsp_self_kill), + accum_ofdm->dsp_self_kill, delta_ofdm->dsp_self_kill, + max_ofdm->dsp_self_kill); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", + le32_to_cpu(ofdm->mh_format_err), + accum_ofdm->mh_format_err, delta_ofdm->mh_format_err, + max_ofdm->mh_format_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "re_acq_main_rssi_sum:", + le32_to_cpu(ofdm->re_acq_main_rssi_sum), + accum_ofdm->re_acq_main_rssi_sum, + delta_ofdm->re_acq_main_rssi_sum, + max_ofdm->re_acq_main_rssi_sum); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, delta_cck->overrun_err, - max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, delta_cck->sfd_timeout, - max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, delta_cck->fina_timeout, - max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(cck->sent_ba_rsp_cnt), - accum_cck->sent_ba_rsp_cnt, - delta_cck->sent_ba_rsp_cnt, - max_cck->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(cck->dsp_self_kill), - accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, - max_cck->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(cck->mh_format_err), - accum_cck->mh_format_err, delta_cck->mh_format_err, - max_cck->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(cck->re_acq_main_rssi_sum), - accum_cck->re_acq_main_rssi_sum, - delta_cck->re_acq_main_rssi_sum, - max_cck->re_acq_main_rssi_sum); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - CCK:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", + le32_to_cpu(cck->overrun_err), accum_cck->overrun_err, + delta_cck->overrun_err, max_cck->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, max_cck->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, max_cck->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt, + max_cck->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout, + delta_cck->sfd_timeout, max_cck->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:", + le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout, + delta_cck->fina_timeout, max_cck->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt, + delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt, + delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(cck->sent_ba_rsp_cnt), + accum_cck->sent_ba_rsp_cnt, delta_cck->sent_ba_rsp_cnt, + max_cck->sent_ba_rsp_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:", + le32_to_cpu(cck->dsp_self_kill), accum_cck->dsp_self_kill, + delta_cck->dsp_self_kill, max_cck->dsp_self_kill); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", + le32_to_cpu(cck->mh_format_err), accum_cck->mh_format_err, + delta_cck->mh_format_err, max_cck->mh_format_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "re_acq_main_rssi_sum:", + le32_to_cpu(cck->re_acq_main_rssi_sum), + accum_cck->re_acq_main_rssi_sum, + delta_cck->re_acq_main_rssi_sum, + max_cck->re_acq_main_rssi_sum); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, delta_general->bogus_cts, - max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, delta_general->bogus_ack, - max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_beacons:", - le32_to_cpu(general->channel_beacons), - accum_general->channel_beacons, - delta_general->channel_beacons, - max_general->channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_missed_bcon:", - le32_to_cpu(general->num_missed_bcon), - accum_general->num_missed_bcon, - delta_general->num_missed_bcon, - max_general->num_missed_bcon); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "adc_rx_saturation_time:", - le32_to_cpu(general->adc_rx_saturation_time), - accum_general->adc_rx_saturation_time, - delta_general->adc_rx_saturation_time, - max_general->adc_rx_saturation_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_detect_search_tm:", - le32_to_cpu(general->ina_detection_search_time), - accum_general->ina_detection_search_time, - delta_general->ina_detection_search_time, - max_general->ina_detection_search_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_a:", - le32_to_cpu(general->beacon_silence_rssi_a), - accum_general->beacon_silence_rssi_a, - delta_general->beacon_silence_rssi_a, - max_general->beacon_silence_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_b:", - le32_to_cpu(general->beacon_silence_rssi_b), - accum_general->beacon_silence_rssi_b, - delta_general->beacon_silence_rssi_b, - max_general->beacon_silence_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_c:", - le32_to_cpu(general->beacon_silence_rssi_c), - accum_general->beacon_silence_rssi_c, - delta_general->beacon_silence_rssi_c, - max_general->beacon_silence_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "interference_data_flag:", - le32_to_cpu(general->interference_data_flag), - accum_general->interference_data_flag, - delta_general->interference_data_flag, - max_general->interference_data_flag); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_load:", - le32_to_cpu(general->channel_load), - accum_general->channel_load, - delta_general->channel_load, - max_general->channel_load); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_false_alarms:", - le32_to_cpu(general->dsp_false_alarms), - accum_general->dsp_false_alarms, - delta_general->dsp_false_alarms, - max_general->dsp_false_alarms); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_a:", - le32_to_cpu(general->beacon_rssi_a), - accum_general->beacon_rssi_a, - delta_general->beacon_rssi_a, - max_general->beacon_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_b:", - le32_to_cpu(general->beacon_rssi_b), - accum_general->beacon_rssi_b, - delta_general->beacon_rssi_b, - max_general->beacon_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_c:", - le32_to_cpu(general->beacon_rssi_c), - accum_general->beacon_rssi_c, - delta_general->beacon_rssi_c, - max_general->beacon_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_a:", - le32_to_cpu(general->beacon_energy_a), - accum_general->beacon_energy_a, - delta_general->beacon_energy_a, - max_general->beacon_energy_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_b:", - le32_to_cpu(general->beacon_energy_b), - accum_general->beacon_energy_b, - delta_general->beacon_energy_b, - max_general->beacon_energy_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_c:", - le32_to_cpu(general->beacon_energy_c), - accum_general->beacon_energy_c, - delta_general->beacon_energy_c, - max_general->beacon_energy_c); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - GENERAL:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_cts:", + le32_to_cpu(general->bogus_cts), accum_general->bogus_cts, + delta_general->bogus_cts, max_general->bogus_cts); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_ack:", + le32_to_cpu(general->bogus_ack), accum_general->bogus_ack, + delta_general->bogus_ack, max_general->bogus_ack); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_beacons:", + le32_to_cpu(general->channel_beacons), + accum_general->channel_beacons, + delta_general->channel_beacons, + max_general->channel_beacons); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "num_missed_bcon:", + le32_to_cpu(general->num_missed_bcon), + accum_general->num_missed_bcon, + delta_general->num_missed_bcon, + max_general->num_missed_bcon); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "adc_rx_saturation_time:", + le32_to_cpu(general->adc_rx_saturation_time), + accum_general->adc_rx_saturation_time, + delta_general->adc_rx_saturation_time, + max_general->adc_rx_saturation_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "ina_detect_search_tm:", + le32_to_cpu(general->ina_detection_search_time), + accum_general->ina_detection_search_time, + delta_general->ina_detection_search_time, + max_general->ina_detection_search_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "beacon_silence_rssi_a:", + le32_to_cpu(general->beacon_silence_rssi_a), + accum_general->beacon_silence_rssi_a, + delta_general->beacon_silence_rssi_a, + max_general->beacon_silence_rssi_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "beacon_silence_rssi_b:", + le32_to_cpu(general->beacon_silence_rssi_b), + accum_general->beacon_silence_rssi_b, + delta_general->beacon_silence_rssi_b, + max_general->beacon_silence_rssi_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "beacon_silence_rssi_c:", + le32_to_cpu(general->beacon_silence_rssi_c), + accum_general->beacon_silence_rssi_c, + delta_general->beacon_silence_rssi_c, + max_general->beacon_silence_rssi_c); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "interference_data_flag:", + le32_to_cpu(general->interference_data_flag), + accum_general->interference_data_flag, + delta_general->interference_data_flag, + max_general->interference_data_flag); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_load:", + le32_to_cpu(general->channel_load), + accum_general->channel_load, delta_general->channel_load, + max_general->channel_load); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_false_alarms:", + le32_to_cpu(general->dsp_false_alarms), + accum_general->dsp_false_alarms, + delta_general->dsp_false_alarms, + max_general->dsp_false_alarms); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_a:", + le32_to_cpu(general->beacon_rssi_a), + accum_general->beacon_rssi_a, + delta_general->beacon_rssi_a, max_general->beacon_rssi_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_b:", + le32_to_cpu(general->beacon_rssi_b), + accum_general->beacon_rssi_b, + delta_general->beacon_rssi_b, max_general->beacon_rssi_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_c:", + le32_to_cpu(general->beacon_rssi_c), + accum_general->beacon_rssi_c, + delta_general->beacon_rssi_c, max_general->beacon_rssi_c); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_a:", + le32_to_cpu(general->beacon_energy_a), + accum_general->beacon_energy_a, + delta_general->beacon_energy_a, + max_general->beacon_energy_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_b:", + le32_to_cpu(general->beacon_energy_b), + accum_general->beacon_energy_b, + delta_general->beacon_energy_b, + max_general->beacon_energy_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_c:", + le32_to_cpu(general->beacon_energy_c), + accum_general->beacon_energy_c, + delta_general->beacon_energy_c, + max_general->beacon_energy_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM_HT:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, - delta_ht->plcp_err, max_ht->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, - delta_ht->overrun_err, max_ht->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ht->early_overrun_err), - accum_ht->early_overrun_err, - delta_ht->early_overrun_err, - max_ht->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, - delta_ht->crc32_good, max_ht->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, - delta_ht->crc32_err, max_ht->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ht->mh_format_err), - accum_ht->mh_format_err, - delta_ht->mh_format_err, max_ht->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_crc32_good:", - le32_to_cpu(ht->agg_crc32_good), - accum_ht->agg_crc32_good, - delta_ht->agg_crc32_good, max_ht->agg_crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_mpdu_cnt:", - le32_to_cpu(ht->agg_mpdu_cnt), - accum_ht->agg_mpdu_cnt, - delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_cnt:", - le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, - delta_ht->agg_cnt, max_ht->agg_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unsupport_mcs:", - le32_to_cpu(ht->unsupport_mcs), - accum_ht->unsupport_mcs, - delta_ht->unsupport_mcs, max_ht->unsupport_mcs); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - OFDM_HT:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", + le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, + delta_ht->plcp_err, max_ht->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", + le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, + delta_ht->overrun_err, max_ht->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", + le32_to_cpu(ht->early_overrun_err), + accum_ht->early_overrun_err, delta_ht->early_overrun_err, + max_ht->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", + le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, + delta_ht->crc32_good, max_ht->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", + le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, + delta_ht->crc32_err, max_ht->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", + le32_to_cpu(ht->mh_format_err), accum_ht->mh_format_err, + delta_ht->mh_format_err, max_ht->mh_format_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_crc32_good:", + le32_to_cpu(ht->agg_crc32_good), accum_ht->agg_crc32_good, + delta_ht->agg_crc32_good, max_ht->agg_crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_mpdu_cnt:", + le32_to_cpu(ht->agg_mpdu_cnt), accum_ht->agg_mpdu_cnt, + delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_cnt:", + le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, + delta_ht->agg_cnt, max_ht->agg_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "unsupport_mcs:", + le32_to_cpu(ht->unsupport_mcs), accum_ht->unsupport_mcs, + delta_ht->unsupport_mcs, max_ht->unsupport_mcs); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -ssize_t il4965_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il4965_ucode_tx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -506,154 +488,145 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, } /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ + * the last stats notification from uCode + * might not reflect the current uCode activity + */ tx = &il->_4965.stats.tx; accum_tx = &il->_4965.accum_stats.tx; delta_tx = &il->_4965.delta_stats.tx; max_tx = &il->_4965.max_delta.tx; pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dump_msdu_cnt:", - le32_to_cpu(tx->dump_msdu_cnt), - accum_tx->dump_msdu_cnt, - delta_tx->dump_msdu_cnt, - max_tx->dump_msdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_nxt_frame_mismatch:", - le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), - accum_tx->burst_abort_next_frame_mismatch_cnt, - delta_tx->burst_abort_next_frame_mismatch_cnt, - max_tx->burst_abort_next_frame_mismatch_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_missing_nxt_frame:", - le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), - accum_tx->burst_abort_missing_next_frame_cnt, - delta_tx->burst_abort_missing_next_frame_cnt, - max_tx->burst_abort_missing_next_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout_collision:", - le32_to_cpu(tx->cts_timeout_collision), - accum_tx->cts_timeout_collision, - delta_tx->cts_timeout_collision, - max_tx->cts_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_ba_timeout_collision:", - le32_to_cpu(tx->ack_or_ba_timeout_collision), - accum_tx->ack_or_ba_timeout_collision, - delta_tx->ack_or_ba_timeout_collision, - max_tx->ack_or_ba_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_timeout:", - le32_to_cpu(tx->agg.ba_timeout), - accum_tx->agg.ba_timeout, - delta_tx->agg.ba_timeout, - max_tx->agg.ba_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_resched_frames:", - le32_to_cpu(tx->agg.ba_reschedule_frames), - accum_tx->agg.ba_reschedule_frames, - delta_tx->agg.ba_reschedule_frames, - max_tx->agg.ba_reschedule_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg_frame:", - le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), - accum_tx->agg.scd_query_agg_frame_cnt, - delta_tx->agg.scd_query_agg_frame_cnt, - max_tx->agg.scd_query_agg_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_no_agg:", - le32_to_cpu(tx->agg.scd_query_no_agg), - accum_tx->agg.scd_query_no_agg, - delta_tx->agg.scd_query_no_agg, - max_tx->agg.scd_query_no_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg:", - le32_to_cpu(tx->agg.scd_query_agg), - accum_tx->agg.scd_query_agg, - delta_tx->agg.scd_query_agg, - max_tx->agg.scd_query_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_mismatch:", - le32_to_cpu(tx->agg.scd_query_mismatch), - accum_tx->agg.scd_query_mismatch, - delta_tx->agg.scd_query_mismatch, - max_tx->agg.scd_query_mismatch); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg frame_not_ready:", - le32_to_cpu(tx->agg.frame_not_ready), - accum_tx->agg.frame_not_ready, - delta_tx->agg.frame_not_ready, - max_tx->agg.frame_not_ready); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg underrun:", - le32_to_cpu(tx->agg.underrun), - accum_tx->agg.underrun, - delta_tx->agg.underrun, max_tx->agg.underrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg bt_prio_kill:", - le32_to_cpu(tx->agg.bt_prio_kill), - accum_tx->agg.bt_prio_kill, - delta_tx->agg.bt_prio_kill, - max_tx->agg.bt_prio_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg rx_ba_rsp_cnt:", - le32_to_cpu(tx->agg.rx_ba_rsp_cnt), - accum_tx->agg.rx_ba_rsp_cnt, - delta_tx->agg.rx_ba_rsp_cnt, - max_tx->agg.rx_ba_rsp_cnt); + pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "preamble:", + le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt, + max_tx->rx_detected_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "ack_timeout:", + le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dump_msdu_cnt:", + le32_to_cpu(tx->dump_msdu_cnt), accum_tx->dump_msdu_cnt, + delta_tx->dump_msdu_cnt, max_tx->dump_msdu_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "abort_nxt_frame_mismatch:", + le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), + accum_tx->burst_abort_next_frame_mismatch_cnt, + delta_tx->burst_abort_next_frame_mismatch_cnt, + max_tx->burst_abort_next_frame_mismatch_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "abort_missing_nxt_frame:", + le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), + accum_tx->burst_abort_missing_next_frame_cnt, + delta_tx->burst_abort_missing_next_frame_cnt, + max_tx->burst_abort_missing_next_frame_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "cts_timeout_collision:", + le32_to_cpu(tx->cts_timeout_collision), + accum_tx->cts_timeout_collision, + delta_tx->cts_timeout_collision, + max_tx->cts_timeout_collision); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "ack_ba_timeout_collision:", + le32_to_cpu(tx->ack_or_ba_timeout_collision), + accum_tx->ack_or_ba_timeout_collision, + delta_tx->ack_or_ba_timeout_collision, + max_tx->ack_or_ba_timeout_collision); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg ba_timeout:", + le32_to_cpu(tx->agg.ba_timeout), accum_tx->agg.ba_timeout, + delta_tx->agg.ba_timeout, max_tx->agg.ba_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg ba_resched_frames:", + le32_to_cpu(tx->agg.ba_reschedule_frames), + accum_tx->agg.ba_reschedule_frames, + delta_tx->agg.ba_reschedule_frames, + max_tx->agg.ba_reschedule_frames); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg scd_query_agg_frame:", + le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), + accum_tx->agg.scd_query_agg_frame_cnt, + delta_tx->agg.scd_query_agg_frame_cnt, + max_tx->agg.scd_query_agg_frame_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg scd_query_no_agg:", + le32_to_cpu(tx->agg.scd_query_no_agg), + accum_tx->agg.scd_query_no_agg, + delta_tx->agg.scd_query_no_agg, + max_tx->agg.scd_query_no_agg); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg scd_query_agg:", + le32_to_cpu(tx->agg.scd_query_agg), + accum_tx->agg.scd_query_agg, delta_tx->agg.scd_query_agg, + max_tx->agg.scd_query_agg); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg scd_query_mismatch:", + le32_to_cpu(tx->agg.scd_query_mismatch), + accum_tx->agg.scd_query_mismatch, + delta_tx->agg.scd_query_mismatch, + max_tx->agg.scd_query_mismatch); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg frame_not_ready:", + le32_to_cpu(tx->agg.frame_not_ready), + accum_tx->agg.frame_not_ready, + delta_tx->agg.frame_not_ready, + max_tx->agg.frame_not_ready); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg underrun:", + le32_to_cpu(tx->agg.underrun), accum_tx->agg.underrun, + delta_tx->agg.underrun, max_tx->agg.underrun); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg bt_prio_kill:", + le32_to_cpu(tx->agg.bt_prio_kill), + accum_tx->agg.bt_prio_kill, delta_tx->agg.bt_prio_kill, + max_tx->agg.bt_prio_kill); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg rx_ba_rsp_cnt:", + le32_to_cpu(tx->agg.rx_ba_rsp_cnt), + accum_tx->agg.rx_ba_rsp_cnt, delta_tx->agg.rx_ba_rsp_cnt, + max_tx->agg.rx_ba_rsp_cnt); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -661,8 +634,8 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, } ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_general_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -684,9 +657,9 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, } /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ + * the last stats notification from uCode + * might not reflect the current uCode activity + */ general = &il->_4965.stats.general.common; dbg = &il->_4965.stats.general.common.dbg; div = &il->_4965.stats.general.common.div; @@ -701,73 +674,72 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, max_div = &il->_4965.max_delta.general.common.div; pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "temperature:", - le32_to_cpu(general->temperature)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "ttl_timestamp:", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "wait_for_silence_timeout_count:", - le32_to_cpu(dbg->wait_for_silence_timeout_cnt), - accum_dbg->wait_for_silence_timeout_cnt, - delta_dbg->wait_for_silence_timeout_cnt, - max_dbg->wait_for_silence_timeout_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_enable_counter:", - le32_to_cpu(general->rx_enable_counter), - accum_general->rx_enable_counter, - delta_general->rx_enable_counter, - max_general->rx_enable_counter); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_of_sos_states:", - le32_to_cpu(general->num_of_sos_states), - accum_general->num_of_sos_states, - delta_general->num_of_sos_states, - max_general->num_of_sos_states); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_General:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_value, "temperature:", + le32_to_cpu(general->temperature)); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_value, "ttl_timestamp:", + le32_to_cpu(general->ttl_timestamp)); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_check:", + le32_to_cpu(dbg->burst_check), accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_count:", + le32_to_cpu(dbg->burst_count), accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "wait_for_silence_timeout_count:", + le32_to_cpu(dbg->wait_for_silence_timeout_cnt), + accum_dbg->wait_for_silence_timeout_cnt, + delta_dbg->wait_for_silence_timeout_cnt, + max_dbg->wait_for_silence_timeout_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, delta_general->sleep_time, + max_general->sleep_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_out:", + le32_to_cpu(general->slots_out), accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, delta_general->slots_idle, + max_general->slots_idle); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_enable_counter:", + le32_to_cpu(general->rx_enable_counter), + accum_general->rx_enable_counter, + delta_general->rx_enable_counter, + max_general->rx_enable_counter); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "num_of_sos_states:", + le32_to_cpu(general->num_of_sos_states), + accum_general->num_of_sos_states, + delta_general->num_of_sos_states, + max_general->num_of_sos_states); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 9e3f74c..ca819d8 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -53,7 +53,6 @@ #include "common.h" #include "4965.h" - /****************************************************************************** * * module boiler plate @@ -73,15 +72,14 @@ #define DRV_VERSION IWLWIFI_VERSION VD - MODULE_DESCRIPTION(DRV_DESCRIPTION); MODULE_VERSION(DRV_VERSION); MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status) +void +il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { IL_ERR("Tx flush command to flush out all frames\n"); @@ -99,7 +97,8 @@ struct il_mod_params il4965_mod_params = { /* the rest are 0 by default */ }; -void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +void +il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -112,8 +111,8 @@ void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -131,10 +130,11 @@ void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +int +il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { u32 rb_size; - const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ + const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ u32 rb_timeout = 0; if (il->cfg->mod_params->amsdu_size_8K) @@ -149,12 +149,10 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) il_wr(il, FH49_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_wr(il, FH49_RSCSR_CHNL0_RBDCB_BASE_REG, - (u32)(rxq->bd_dma >> 8)); + il_wr(il, FH49_RSCSR_CHNL0_RBDCB_BASE_REG, (u32) (rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_wr(il, FH49_RSCSR_CHNL0_STTS_WPTR_REG, - rxq->rb_stts_dma >> 4); + il_wr(il, FH49_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA * Direct rx interrupts to hosts @@ -163,12 +161,12 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) * 256 RBDs */ il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, - FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | - FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | - rb_size| - (rb_timeout << FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| - (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | rb_size | (rb_timeout + << + FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) + | (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); @@ -176,7 +174,8 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) return 0; } -static void il4965_set_pwr_vmain(struct il_priv *il) +static void +il4965_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) @@ -189,11 +188,12 @@ static void il4965_set_pwr_vmain(struct il_priv *il) */ il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); } -int il4965_hw_nic_init(struct il_priv *il) +int +il4965_hw_nic_init(struct il_priv *il) { unsigned long flags; struct il_rx_queue *rxq = &il->rxq; @@ -249,10 +249,10 @@ int il4965_hw_nic_init(struct il_priv *il) /** * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) +static inline __le32 +il4965_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { - return cpu_to_le32((u32)(dma_addr >> 8)); + return cpu_to_le32((u32) (dma_addr >> 8)); } /** @@ -266,7 +266,8 @@ static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, * also updates the memory address in the firmware to reference the new * target buffer. */ -void il4965_rx_queue_restock(struct il_priv *il) +void +il4965_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -285,8 +286,8 @@ void il4965_rx_queue_restock(struct il_priv *il) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, - rxb->page_dma); + rxq->bd[rxq->write] = + il4965_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -297,7 +298,6 @@ void il4965_rx_queue_restock(struct il_priv *il) if (rxq->free_count <= RX_LOW_WATERMARK) queue_work(il->workqueue, &il->rx_replenish); - /* If we've added more space for the firmware to place data, tell it. * Increment device's write pointer in multiples of 8. */ if (rxq->write_actual != (rxq->write & ~0x7)) { @@ -316,7 +316,8 @@ void il4965_rx_queue_restock(struct il_priv *il) * Also restock the Rx queue via il_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) +static void +il4965_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -343,18 +344,16 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - D_INFO("alloc_pages failed, " - "order: %d\n", - il->hw_params.rx_page_order); + D_INFO("alloc_pages failed, " "order: %d\n", + il->hw_params.rx_page_order); if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) - IL_ERR( - "Failed to alloc_pages with %s. " - "Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? - "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); + IL_ERR("Failed to alloc_pages with %s. " + "Only %u free buffers remaining.\n", + priority == + GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); /* We don't reschedule replenish work here -- we will * call the restock method and if it still needs * more buffers it will schedule replenish */ @@ -377,9 +376,10 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) BUG_ON(rxb->page); rxb->page = page; /* Get physical address of the RB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); /* dma address must be no more than 36 bits */ BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); /* and also 256 byte aligned! */ @@ -395,7 +395,8 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) } } -void il4965_rx_replenish(struct il_priv *il) +void +il4965_rx_replenish(struct il_priv *il) { unsigned long flags; @@ -406,7 +407,8 @@ void il4965_rx_replenish(struct il_priv *il) spin_unlock_irqrestore(&il->lock, flags); } -void il4965_rx_replenish_now(struct il_priv *il) +void +il4965_rx_replenish_now(struct il_priv *il) { il4965_rx_allocate(il, GFP_ATOMIC); @@ -418,14 +420,15 @@ void il4965_rx_replenish_now(struct il_priv *il) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +void +il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -436,21 +439,23 @@ void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; - rxq->rb_stts = NULL; + rxq->rb_stts = NULL; } -int il4965_rxq_stop(struct il_priv *il) +int +il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, 0); il_poll_bit(il, FH49_MEM_RSSR_RX_STATUS_REG, - FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; } -int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) +int +il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) { int idx = 0; int band_offset = 0; @@ -459,7 +464,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) if (rate_n_flags & RATE_MCS_HT_MSK) { idx = (rate_n_flags & 0xff); return idx; - /* Legacy rate format, search for match in table */ + /* Legacy rate format, search for match in table */ } else { if (band == IEEE80211_BAND_5GHZ) band_offset = IL_FIRST_OFDM_RATE; @@ -471,19 +476,20 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) return -1; } -static int il4965_calc_rssi(struct il_priv *il, - struct il_rx_phy_res *rx_resp) +static int +il4965_calc_rssi(struct il_priv *il, struct il_rx_phy_res *rx_resp) { /* data from PHY/DSP regarding signal strength, etc., * contents are always there, not configurable by host. */ struct il4965_rx_non_cfg_phy *ncphy = (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; - u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) - >> IL49_AGC_DB_POS; + u32 agc = + (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) >> + IL49_AGC_DB_POS; u32 valid_antennae = (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) - >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; + >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; u8 max_rssi = 0; u32 i; @@ -505,31 +511,32 @@ static int il4965_calc_rssi(struct il_priv *il, return max_rssi - agc - IL4965_RSSI_OFFSET; } - -static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) +static u32 +il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) { u32 decrypt_out = 0; if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) == - RX_RES_STATUS_STATION_FOUND) - decrypt_out |= (RX_RES_STATUS_STATION_FOUND | - RX_RES_STATUS_NO_STATION_INFO_MISMATCH); + RX_RES_STATUS_STATION_FOUND) + decrypt_out |= + (RX_RES_STATUS_STATION_FOUND | + RX_RES_STATUS_NO_STATION_INFO_MISMATCH); decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK); /* packet was not encrypted */ if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_NONE) + RX_RES_STATUS_SEC_TYPE_NONE) return decrypt_out; /* packet was encrypted with unknown alg */ if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_ERR) + RX_RES_STATUS_SEC_TYPE_ERR) return decrypt_out; /* decryption was not done in HW */ if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) != - RX_MPDU_RES_STATUS_DEC_DONE_MSK) + RX_MPDU_RES_STATUS_DEC_DONE_MSK) return decrypt_out; switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) { @@ -559,26 +566,22 @@ static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) break; } - D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", - decrypt_in, decrypt_out); + D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; } -static void il4965_pass_packet_to_mac80211(struct il_priv *il, - struct ieee80211_hdr *hdr, - u16 len, - u32 ampdu_status, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) +static void +il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, + u16 len, u32 ampdu_status, struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) { struct sk_buff *skb; __le16 fc = hdr->frame_control; /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); + D_DROP("Dropping packet while interface is not open.\n"); return; } @@ -605,8 +608,8 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* Called for N_RX (legacy ABG frames), or * N_RX_MPDU (HT high-throughput N frames). */ -void il4965_hdl_rx(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; @@ -629,12 +632,14 @@ void il4965_hdl_rx(struct il_priv *il, */ if (pkt->hdr.cmd == N_RX) { phy_res = (struct il_rx_phy_res *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) - + phy_res->cfg_phy_cnt); + header = + (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt); len = le16_to_cpu(phy_res->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) + - phy_res->cfg_phy_cnt + len); + rx_pkt_status = + *(__le32 *) (pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt + len); ampdu_status = le32_to_cpu(rx_pkt_status); } else { if (!il->_4965.last_phy_res_valid) { @@ -645,21 +650,20 @@ void il4965_hdl_rx(struct il_priv *il, amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); len = le16_to_cpu(amsdu->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = il4965_translate_rx_status(il, - le32_to_cpu(rx_pkt_status)); + rx_pkt_status = *(__le32 *) (pkt->u.raw + sizeof(*amsdu) + len); + ampdu_status = + il4965_translate_rx_status(il, le32_to_cpu(rx_pkt_status)); } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { D_DROP("dsp size out of range [0,20]: %d/n", - phy_res->cfg_phy_cnt); + phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - D_RX("Bad CRC or FIFO: 0x%08X.\n", - le32_to_cpu(rx_pkt_status)); + D_RX("Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -668,18 +672,20 @@ void il4965_hdl_rx(struct il_priv *il, /* rx_status carries information about the packet to mac80211 */ rx_status.mactime = le64_to_cpu(phy_res->timestamp); - rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.band = + (phy_res-> + phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? IEEE80211_BAND_2GHZ : + IEEE80211_BAND_5GHZ; rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), - rx_status.band); + ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), + rx_status.band); rx_status.rate_idx = - il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); + il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); rx_status.flag = 0; /* TSF isn't reliable. In order to allow smooth user experience, * this W/A doesn't propagate it to the mac80211 */ - /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ + /*rx_status.flag |= RX_FLAG_MACTIME_MPDU; */ il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); @@ -687,8 +693,8 @@ void il4965_hdl_rx(struct il_priv *il, rx_status.signal = il4965_calc_rssi(il, phy_res); il_dbg_log_rx_data_frame(il, len, header); - D_STATS("Rssi %d, TSF %llu\n", - rx_status.signal, (unsigned long long)rx_status.mactime); + D_STATS("Rssi %d, TSF %llu\n", rx_status.signal, + (unsigned long long)rx_status.mactime); /* * "antenna number" @@ -704,8 +710,8 @@ void il4965_hdl_rx(struct il_priv *il, * as a bitmask. */ rx_status.antenna = - (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) - >> RX_RES_PHY_FLAGS_ANTENNA_POS; + (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> + RX_RES_PHY_FLAGS_ANTENNA_POS; /* set the preamble flag if appropriate */ if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) @@ -719,14 +725,14 @@ void il4965_hdl_rx(struct il_priv *il, if (rate_n_flags & RATE_MCS_SGI_MSK) rx_status.flag |= RX_FLAG_SHORT_GI; - il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, - rxb, &rx_status); + il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, rxb, + &rx_status); } /* Cache phy data (Rx signal strength, etc) for HT frame (N_RX_PHY). * This will be used later in il_hdl_rx() for N_RX_MPDU. */ -void il4965_hdl_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); il->_4965.last_phy_res_valid = true; @@ -734,11 +740,10 @@ void il4965_hdl_rx_phy(struct il_priv *il, sizeof(struct il_rx_phy_res)); } -static int il4965_get_channels_for_scan(struct il_priv *il, - struct ieee80211_vif *vif, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il_scan_channel *scan_ch) +static int +il4965_get_channels_for_scan(struct il_priv *il, struct ieee80211_vif *vif, + enum ieee80211_band band, u8 is_active, + u8 n_probes, struct il_scan_channel *scan_ch) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; @@ -769,9 +774,8 @@ static int il4965_get_channels_for_scan(struct il_priv *il, ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", - channel); + D_SCAN("Channel %d is INVALID for this band.\n", + channel); continue; } @@ -799,12 +803,13 @@ static int il4965_get_channels_for_scan(struct il_priv *il, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", - channel, le32_to_cpu(scan_ch->type), - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - "ACTIVE" : "PASSIVE", - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - active_dwell : passive_dwell); + D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", channel, + le32_to_cpu(scan_ch->type), + (scan_ch-> + type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", + (scan_ch-> + type & SCAN_CHANNEL_TYPE_ACTIVE) ? active_dwell : + passive_dwell); scan_ch++; added++; @@ -814,12 +819,14 @@ static int il4965_get_channels_for_scan(struct il_priv *il, return added; } -static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) +static inline u32 +il4965_ant_idx_to_flags(u8 ant_idx) { return BIT(ant_idx) << RATE_MCS_ANT_POS; } -int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +int +il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = C_SCAN, @@ -836,7 +843,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) u8 rx_ant = il->hw_params.valid_rx_ant; u8 rate; bool is_active = false; - int chan_mod; + int chan_mod; u8 active_chains; u8 scan_tx_antennas = il->hw_params.valid_tx_ant; int ret; @@ -847,11 +854,11 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) ctx = il_rxon_ctx_from_vif(vif); if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); + il->scan_cmd = + kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE, + GFP_KERNEL); if (!il->scan_cmd) { - D_SCAN( - "fail to allocate memory for scan\n"); + D_SCAN("fail to allocate memory for scan\n"); return -ENOMEM; } } @@ -876,11 +883,11 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) interval = suspend_time; extra = (suspend_time / interval) << 22; - scan_suspend_time = (extra | - ((suspend_time % interval) * 1024)); + scan_suspend_time = + (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); + scan_suspend_time, interval); } if (il->scan_request->n_ssids) { @@ -892,7 +899,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, il->scan_request->ssids[i].ssid, il->scan_request->ssids[i].ssid_len); @@ -910,10 +917,10 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - chan_mod = le32_to_cpu( - il->ctx.active.flags & - RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; + chan_mod = + le32_to_cpu(il->ctx.active. + flags & RXON_FLG_CHANNEL_MODE_MSK) >> + RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { rate = RATE_6M_PLCP; } else { @@ -946,30 +953,30 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER * here instead of IL_GOOD_CRC_TH_DISABLED. */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_NEVER; + scan->good_CRC_th = + is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_NEVER; band = il->scan_band; if (il->cfg->scan_rx_antennas[band]) rx_ant = il->cfg->scan_rx_antennas[band]; - il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, - il->scan_tx_ant[band], - scan_tx_antennas); + il->scan_tx_ant[band] = + il4965_toggle_tx_ant(il, il->scan_tx_ant[band], scan_tx_antennas); rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); - scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); + scan->tx_cmd.rate_n_flags = + il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ if (test_bit(S_POWER_PMI, &il->status)) { /* rx_ant has been set to all valid chains previously */ - active_chains = rx_ant & - ((u8)(il->chain_noise_data.active_chains)); + active_chains = + rx_ant & ((u8) (il->chain_noise_data.active_chains)); if (!active_chains) active_chains = rx_ant; D_SCAN("chain_noise_data.active_chains: %u\n", - il->chain_noise_data.active_chains); + il->chain_noise_data.active_chains); rx_ant = il4965_first_antenna(active_chains); } @@ -981,26 +988,26 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; scan->rx_chain = cpu_to_le16(rx_chain); - cmd_len = il_fill_probe_req(il, - (struct ieee80211_mgmt *)scan->data, - vif->addr, - il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); + cmd_len = + il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(cmd_len); - scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | - RXON_FILTER_BCON_AWARE_MSK); + scan->filter_flags |= + (RXON_FILTER_ACCEPT_GRP_MSK | RXON_FILTER_BCON_AWARE_MSK); - scan->channel_count = il4965_get_channels_for_scan(il, vif, band, - is_active, n_probes, - (void *)&scan->data[cmd_len]); + scan->channel_count = + il4965_get_channels_for_scan(il, vif, band, is_active, n_probes, + (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } - cmd.len += le16_to_cpu(scan->tx_cmd.len) + + cmd.len += + le16_to_cpu(scan->tx_cmd.len) + scan->channel_count * sizeof(struct il_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); @@ -1014,8 +1021,9 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) return ret; } -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) +int +il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, + bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; @@ -1024,11 +1032,11 @@ int il4965_manage_ibss_station(struct il_priv *il, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); + vif->bss_conf.bssid); } -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed) +void +il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, int freed) { lockdep_assert_held(&il->sta_lock); @@ -1036,18 +1044,18 @@ void il4965_free_tfds_in_queue(struct il_priv *il, il->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { D_TX("free more than tfds_in_queue (%u:%d)\n", - il->stations[sta_id].tid[tid].tfds_in_queue, - freed); + il->stations[sta_id].tid[tid].tfds_in_queue, freed); il->stations[sta_id].tid[tid].tfds_in_queue = 0; } } #define IL_TX_QUEUE_MSK 0xfffff -static bool il4965_is_single_rx_stream(struct il_priv *il) +static bool +il4965_is_single_rx_stream(struct il_priv *il) { return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || - il->current_ht_config.single_chain_sufficient; + il->current_ht_config.single_chain_sufficient; } #define IL_NUM_RX_CHAINS_MULTIPLE 3 @@ -1065,7 +1073,8 @@ static bool il4965_is_single_rx_stream(struct il_priv *il) * MIMO (dual stream) requires at least 2, but works better with 3. * This does not determine *which* chains to use, just how many. */ -static int il4965_get_active_rx_chain_count(struct il_priv *il) +static int +il4965_get_active_rx_chain_count(struct il_priv *il) { /* # of Rx chains to use when expecting MIMO. */ if (il4965_is_single_rx_stream(il)) @@ -1089,14 +1098,14 @@ il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) case IEEE80211_SMPS_OFF: return active_cnt; default: - WARN(1, "invalid SMPS mode %d", - il->current_ht_config.smps); + WARN(1, "invalid SMPS mode %d", il->current_ht_config.smps); return active_cnt; } } /* up to 4 chains */ -static u8 il4965_count_chain_bitmap(u32 chain_bitmap) +static u8 +il4965_count_chain_bitmap(u32 chain_bitmap) { u8 res; res = (chain_bitmap & BIT(0)) >> 0; @@ -1112,7 +1121,8 @@ static u8 il4965_count_chain_bitmap(u32 chain_bitmap) * Selects how many and which Rx receivers/antennas/chains to use. * This should not be used for scan command ... it puts data in wrong place. */ -void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) +void +il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) { bool is_single = il4965_is_single_rx_stream(il); bool is_cam = !test_bit(S_POWER_PMI, &il->status); @@ -1135,7 +1145,6 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) active_rx_cnt = il4965_get_active_rx_chain_count(il); idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); - /* correct rx chain count according hw settings * and chain noise calibration */ @@ -1147,7 +1156,7 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) idle_rx_cnt = valid_rx_cnt; rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; - rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; + rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; ctx->staging.rx_chain = cpu_to_le16(rx_chain); @@ -1156,45 +1165,47 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", - ctx->staging.rx_chain, - active_rx_cnt, idle_rx_cnt); + D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, + active_rx_cnt, idle_rx_cnt); WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || active_rx_cnt < idle_rx_cnt); } -u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) +u8 +il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) { int i; u8 ind = ant; for (i = 0; i < RATE_ANT_NUM - 1; i++) { - ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; + ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; if (valid & BIT(ind)) return ind; } return ant; } -static const char *il4965_get_fh_string(int cmd) +static const char * +il4965_get_fh_string(int cmd) { switch (cmd) { - IL_CMD(FH49_RSCSR_CHNL0_STTS_WPTR_REG); - IL_CMD(FH49_RSCSR_CHNL0_RBDCB_BASE_REG); - IL_CMD(FH49_RSCSR_CHNL0_WPTR); - IL_CMD(FH49_MEM_RCSR_CHNL0_CONFIG_REG); - IL_CMD(FH49_MEM_RSSR_SHARED_CTRL_REG); - IL_CMD(FH49_MEM_RSSR_RX_STATUS_REG); - IL_CMD(FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IL_CMD(FH49_TSSR_TX_STATUS_REG); - IL_CMD(FH49_TSSR_TX_ERROR_REG); + IL_CMD(FH49_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH49_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH49_RSCSR_CHNL0_WPTR); + IL_CMD(FH49_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH49_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH49_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH49_TSSR_TX_STATUS_REG); + IL_CMD(FH49_TSSR_TX_ERROR_REG); default: return "UNKNOWN"; } } -int il4965_dump_fh(struct il_priv *il, char **buf, bool display) +int +il4965_dump_fh(struct il_priv *il, char **buf, bool display) { int i; #ifdef CONFIG_IWLEGACY_DEBUG @@ -1218,28 +1229,29 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) *buf = kmalloc(bufsz, GFP_KERNEL); if (!*buf) return -ENOMEM; - pos += scnprintf(*buf + pos, bufsz - pos, - "FH register values:\n"); + pos += + scnprintf(*buf + pos, bufsz - pos, "FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - pos += scnprintf(*buf + pos, bufsz - pos, - " %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); + pos += + scnprintf(*buf + pos, bufsz - pos, + " %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), il_rd(il, + fh_tbl + [i])); } return pos; } #endif IL_ERR("FH register values:\n"); - for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(" %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); + for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { + IL_ERR(" %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); } return 0; } -void il4965_hdl_missed_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_missed_beacon_notif *missed_beacon; @@ -1247,12 +1259,11 @@ void il4965_hdl_missed_beacon(struct il_priv *il, missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > il->missed_beacon_threshold) { - D_CALIB( - "missed bcn cnsq %d totl %d rcd %d expctd %d\n", - le32_to_cpu(missed_beacon->consecutive_missed_beacons), - le32_to_cpu(missed_beacon->total_missed_becons), - le32_to_cpu(missed_beacon->num_recvd_beacons), - le32_to_cpu(missed_beacon->num_expected_beacons)); + D_CALIB("missed bcn cnsq %d totl %d rcd %d expctd %d\n", + le32_to_cpu(missed_beacon->consecutive_missed_beacons), + le32_to_cpu(missed_beacon->total_missed_becons), + le32_to_cpu(missed_beacon->num_recvd_beacons), + le32_to_cpu(missed_beacon->num_expected_beacons)); if (!test_bit(S_SCANNING, &il->status)) il4965_init_sensitivity(il); } @@ -1261,7 +1272,8 @@ void il4965_hdl_missed_beacon(struct il_priv *il, /* Calculate noise level, based on measurements during network silence just * before arriving beacon. This measurement can be done only if we know * exactly when to expect beacons, therefore only when we're associated. */ -static void il4965_rx_calc_noise(struct il_priv *il) +static void +il4965_rx_calc_noise(struct il_priv *il) { struct stats_rx_non_phy *rx_info; int num_active_rx = 0; @@ -1271,11 +1283,11 @@ static void il4965_rx_calc_noise(struct il_priv *il) rx_info = &(il->_4965.stats.rx.general); bcn_silence_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; + le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; bcn_silence_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; + le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; bcn_silence_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; + le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; if (bcn_silence_a) { total_silence += bcn_silence_a; @@ -1296,9 +1308,8 @@ static void il4965_rx_calc_noise(struct il_priv *il) else last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", - bcn_silence_a, bcn_silence_b, bcn_silence_c, - last_rx_noise); + D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, + bcn_silence_b, bcn_silence_c, last_rx_noise); } #ifdef CONFIG_IWLEGACY_DEBUGFS @@ -1307,8 +1318,8 @@ static void il4965_rx_calc_noise(struct il_priv *il) * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void il4965_accumulative_stats(struct il_priv *il, - __le32 *stats) +static void +il4965_accumulative_stats(struct il_priv *il, __le32 * stats) { int i, size; __le32 *prev_stats; @@ -1317,22 +1328,23 @@ static void il4965_accumulative_stats(struct il_priv *il, struct stats_general_common *general, *accum_general; struct stats_tx *tx, *accum_tx; - prev_stats = (__le32 *)&il->_4965.stats; - accum_stats = (u32 *)&il->_4965.accum_stats; + prev_stats = (__le32 *) & il->_4965.stats; + accum_stats = (u32 *) & il->_4965.accum_stats; size = sizeof(struct il_notif_stats); general = &il->_4965.stats.general.common; accum_general = &il->_4965.accum_stats.general.common; tx = &il->_4965.stats.tx; accum_tx = &il->_4965.accum_stats.tx; - delta = (u32 *)&il->_4965.delta_stats; - max_delta = (u32 *)&il->_4965.max_delta; + delta = (u32 *) & il->_4965.delta_stats; + max_delta = (u32 *) & il->_4965.max_delta; for (i = sizeof(__le32); i < size; - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { + i += + sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, + accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); + *delta = + (le32_to_cpu(*stats) - le32_to_cpu(*prev_stats)); *accum_stats += *delta; if (*delta > *max_delta) *max_delta = *delta; @@ -1347,31 +1359,27 @@ static void il4965_accumulative_stats(struct il_priv *il, #define REG_RECALIB_PERIOD (60) -void il4965_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { int change; struct il_rx_pkt *pkt = rxb_addr(rxb); - D_RX( - "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il_notif_stats), - le32_to_cpu(pkt->len_n_flags) & - IL_RX_FRAME_SIZE_MSK); - - change = ((il->_4965.stats.general.common.temperature != - pkt->u.stats.general.common.temperature) || - ((il->_4965.stats.flag & - STATS_REPLY_FLG_HT40_MODE_MSK) != - (pkt->u.stats.flag & - STATS_REPLY_FLG_HT40_MODE_MSK))); + D_RX("Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il_notif_stats), + le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); + + change = + ((il->_4965.stats.general.common.temperature != + pkt->u.stats.general.common.temperature) || + ((il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK) != + (pkt->u.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); + il4965_accumulative_stats(il, (__le32 *) & pkt->u.stats); #endif /* TODO: reading some of stats is unneeded */ - memcpy(&il->_4965.stats, &pkt->u.stats, - sizeof(il->_4965.stats)); + memcpy(&il->_4965.stats, &pkt->u.stats, sizeof(il->_4965.stats)); set_bit(S_STATS, &il->status); @@ -1379,8 +1387,8 @@ void il4965_hdl_stats(struct il_priv *il, * REG_RECALIB_PERIOD seconds to ensure we get a * thermal update even if the uCode doesn't give * us one */ - mod_timer(&il->stats_periodic, jiffies + - msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); + mod_timer(&il->stats_periodic, + jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(S_SCANNING, &il->status)) && (pkt->hdr.cmd == N_STATS)) { @@ -1391,19 +1399,18 @@ void il4965_hdl_stats(struct il_priv *il, il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_4965.accum_stats, 0, - sizeof(struct il_notif_stats)); + sizeof(struct il_notif_stats)); memset(&il->_4965.delta_stats, 0, - sizeof(struct il_notif_stats)); - memset(&il->_4965.max_delta, 0, - sizeof(struct il_notif_stats)); + sizeof(struct il_notif_stats)); + memset(&il->_4965.max_delta, 0, sizeof(struct il_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } @@ -1448,7 +1455,8 @@ static const u8 tid_to_ac[] = { IEEE80211_AC_VO }; -static inline int il4965_get_ac_from_tid(u16 tid) +static inline int +il4965_get_ac_from_tid(u16 tid) { if (likely(tid < ARRAY_SIZE(tid_to_ac))) return tid_to_ac[tid]; @@ -1470,12 +1478,11 @@ il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) /* * handle build C_TX command notification. */ -static void il4965_tx_cmd_build_basic(struct il_priv *il, - struct sk_buff *skb, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - u8 std_id) +static void +il4965_tx_cmd_build_basic(struct il_priv *il, struct sk_buff *skb, + struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, u8 std_id) { __le16 fc = hdr->frame_control; __le32 tx_flags = tx_cmd->tx_flags; @@ -1527,10 +1534,9 @@ static void il4965_tx_cmd_build_basic(struct il_priv *il, #define RTS_DFAULT_RETRY_LIMIT 60 -static void il4965_tx_cmd_build_rate(struct il_priv *il, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - __le16 fc) +static void +il4965_tx_cmd_build_rate(struct il_priv *il, struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, __le16 fc) { u32 rate_flags; int rate_idx; @@ -1538,7 +1544,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, u8 data_retry_limit; u8 rate_plcp; - /* Set retry limit on DATA packets and Probe Responses*/ + /* Set retry limit on DATA packets and Probe Responses */ if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else @@ -1566,10 +1572,11 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, * idx is invalid. */ rate_idx = info->control.rates[0].idx; - if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || - rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) - rate_idx = rate_lowest_index(&il->bands[info->band], - info->control.sta); + if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0 + || rate_idx > RATE_COUNT_LEGACY) + rate_idx = + rate_lowest_index(&il->bands[info->band], + info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ if (info->band == IEEE80211_BAND_5GHZ) rate_idx += IL_FIRST_OFDM_RATE; @@ -1583,20 +1590,21 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); + il->mgmt_tx_ant = + il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); /* Set the rate in the TX cmd */ - tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); + tx_cmd->rate_n_flags = + il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); } -static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_tx_cmd *tx_cmd, - struct sk_buff *skb_frag, - int sta_id) +static void +il4965_tx_cmd_build_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, + struct il_tx_cmd *tx_cmd, struct sk_buff *skb_frag, + int sta_id) { struct ieee80211_key_conf *keyconf = info->control.hw_key; @@ -1619,13 +1627,14 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; /* fall through */ case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | - (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); + tx_cmd->sec_ctl |= + (TX_CMD_SEC_WEP | (keyconf->keyidx & TX_CMD_SEC_MSK) << + TX_CMD_SEC_SHIFT); memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - D_TX("Configuring packet for WEP encryption " - "with key %d\n", keyconf->keyidx); + D_TX("Configuring packet for WEP encryption " "with key %d\n", + keyconf->keyidx); break; default: @@ -1637,7 +1646,8 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, /* * start C_TX command process */ -int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) +int +il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -1694,8 +1704,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } @@ -1729,8 +1738,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * The microcode will clear the more data * bit in the last frame it transmits. */ - hdr->frame_control |= - cpu_to_le16(IEEE80211_FCTL_MOREDATA); + hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); } else txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; @@ -1746,8 +1754,8 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) } seq_number = il->stations[sta_id].tid[tid].seq_number; seq_number &= IEEE80211_SCTL_SEQ; - hdr->seq_ctrl = hdr->seq_ctrl & - cpu_to_le16(IEEE80211_SCTL_FRAG); + hdr->seq_ctrl = + hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG); hdr->seq_ctrl |= cpu_to_le16(seq_number); seq_number += 0x10; /* aggregation is on for this */ @@ -1793,15 +1801,15 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * locate the frame within the tx queue and do post-tx processing. */ out_cmd->hdr.cmd = C_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); + out_cmd->hdr.sequence = + cpu_to_le16((u16) + (QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); - /* Total # bytes to be transmitted */ - len = (u16)skb->len; + len = (u16) skb->len; tx_cmd->len = cpu_to_le16(len); if (info->control.hw_key) @@ -1823,8 +1831,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct il_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; + len = sizeof(struct il_tx_cmd) + sizeof(struct il_cmd_header) + hdr_len; firstlen = (len + 3) & ~3; /* Tell NIC about any 2-byte padding after MAC header */ @@ -1833,15 +1840,15 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, - &out_cmd->hdr, firstlen, - PCI_DMA_BIDIRECTIONAL); + txcmd_phys = + pci_map_single(il->pci_dev, &out_cmd->hdr, firstlen, + PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, txcmd_phys); dma_unmap_len_set(out_meta, len, firstlen); /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, firstlen, 1, 0); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, + 1, 0); if (!ieee80211_has_morefrags(hdr->frame_control)) { txq->need_update = 1; @@ -1854,35 +1861,36 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * if any (802.11 null frames have no payload). */ secondlen = skb->len - hdr_len; if (secondlen > 0) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - secondlen, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, secondlen, - 0, 0); + phys_addr = + pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen, + PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, + secondlen, 0, 0); } - scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + - offsetof(struct il_tx_cmd, scratch); + scratch_phys = + txcmd_phys + sizeof(struct il_cmd_header) + + offsetof(struct il_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ - pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); + pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, firstlen, + PCI_DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + il_print_hex_dump(il, IL_DL_TX, (u8 *) tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *) tx_cmd->hdr, hdr_len); /* Set up entry for this TFD in Tx byte-count array */ if (info->flags & IEEE80211_TX_CTL_AMPDU) il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, - le16_to_cpu(tx_cmd->len)); + le16_to_cpu(tx_cmd-> + len)); - pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); + pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen, + PCI_DMA_BIDIRECTIONAL); /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); @@ -1924,19 +1932,19 @@ drop_unlock: return -1; } -static inline int il4965_alloc_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr, size_t size) +static inline int +il4965_alloc_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr, size_t size) { - ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, - GFP_KERNEL); + ptr->addr = + dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, GFP_KERNEL); if (!ptr->addr) return -ENOMEM; ptr->size = size; return 0; } -static inline void il4965_free_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr) +static inline void +il4965_free_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr) { if (unlikely(!ptr->addr)) return; @@ -1950,7 +1958,8 @@ static inline void il4965_free_dma_ptr(struct il_priv *il, * * Destroy all TX DMA queues and structures */ -void il4965_hw_txq_ctx_free(struct il_priv *il) +void +il4965_hw_txq_ctx_free(struct il_priv *il) { int txq_id; @@ -1977,7 +1986,8 @@ void il4965_hw_txq_ctx_free(struct il_priv *il) * @param il * @return error code */ -int il4965_txq_ctx_alloc(struct il_priv *il) +int +il4965_txq_ctx_alloc(struct il_priv *il) { int ret; int txq_id, slots_num; @@ -1986,8 +1996,9 @@ int il4965_txq_ctx_alloc(struct il_priv *il) /* Free all tx/cmd queues and keep-warm buffer */ il4965_hw_txq_ctx_free(il); - ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, - il->hw_params.scd_bc_tbls_size); + ret = + il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, + il->hw_params.scd_bc_tbls_size); if (ret) { IL_ERR("Scheduler BC Table allocation failed\n"); goto error_bc_tbls; @@ -2016,11 +2027,10 @@ int il4965_txq_ctx_alloc(struct il_priv *il) /* Alloc and init all Tx queues, including the command queue (#4/#9) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == il->cmd_queue) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = il_tx_queue_init(il, - &il->txq[txq_id], slots_num, - txq_id); + slots_num = + (txq_id == + il->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + ret = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (ret) { IL_ERR("Tx %d queue init failed\n", txq_id); goto error; @@ -2029,16 +2039,17 @@ int il4965_txq_ctx_alloc(struct il_priv *il) return ret; - error: +error: il4965_hw_txq_ctx_free(il); il4965_free_dma_ptr(il, &il->kw); - error_kw: +error_kw: il4965_free_dma_ptr(il, &il->scd_bc_tbls); - error_bc_tbls: +error_bc_tbls: return ret; } -void il4965_txq_ctx_reset(struct il_priv *il) +void +il4965_txq_ctx_reset(struct il_priv *il) { int txq_id, slots_num; unsigned long flags; @@ -2055,17 +2066,17 @@ void il4965_txq_ctx_reset(struct il_priv *il) /* Alloc and init all Tx queues, including the command queue (#4) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = txq_id == il->cmd_queue ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - il_tx_queue_reset(il, &il->txq[txq_id], - slots_num, txq_id); + slots_num = + txq_id == il->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + il_tx_queue_reset(il, &il->txq[txq_id], slots_num, txq_id); } } /** * il4965_txq_ctx_stop - Stop all Tx DMA channels */ -void il4965_txq_ctx_stop(struct il_priv *il) +void +il4965_txq_ctx_stop(struct il_priv *il) { int ch, txq_id; unsigned long flags; @@ -2077,15 +2088,13 @@ void il4965_txq_ctx_stop(struct il_priv *il) /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { - il_wr(il, - FH49_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_bit(il, FH49_TSSR_TX_STATUS_REG, - FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), - 1000)) + il_wr(il, FH49_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); + if (il_poll_bit + (il, FH49_TSSR_TX_STATUS_REG, + FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" - " DMA channel %d [0x%08x]", ch, - il_rd(il, - FH49_TSSR_TX_STATUS_REG)); + " DMA channel %d [0x%08x]", ch, il_rd(il, + FH49_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); @@ -2106,7 +2115,8 @@ void il4965_txq_ctx_stop(struct il_priv *il) * Should never return anything < 7, because they should already * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) */ -static int il4965_txq_ctx_activate_free(struct il_priv *il) +static int +il4965_txq_ctx_activate_free(struct il_priv *il) { int txq_id; @@ -2119,22 +2129,21 @@ static int il4965_txq_ctx_activate_free(struct il_priv *il) /** * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration */ -static void il4965_tx_queue_stop_scheduler(struct il_priv *il, - u16 txq_id) +static void +il4965_tx_queue_stop_scheduler(struct il_priv *il, u16 txq_id) { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_wr_prph(il, - IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| - (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); + il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (1 << + IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue */ -static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, - u16 txq_id) +static int +il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, u16 txq_id) { u32 tbl_dw_addr; u32 tbl_dw; @@ -2142,8 +2151,8 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; - tbl_dw_addr = il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); + tbl_dw_addr = + il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); tbl_dw = il_read_targ_mem(il, tbl_dw_addr); @@ -2163,8 +2172,9 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ -static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, - int tx_fifo, int sta_id, int tid, u16 ssn_idx) +static int +il4965_txq_agg_enable(struct il_priv *il, int txq_id, int tx_fifo, int sta_id, + int tid, u16 ssn_idx) { unsigned long flags; u16 ra_tid; @@ -2172,9 +2182,8 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN("queue number out of range: %d, must be %d to %d\n", txq_id, IL49_FIRST_AMPDU_QUEUE, IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); @@ -2207,14 +2216,17 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, /* Set up Tx win size and frame limit for this queue */ il_write_targ_mem(il, - il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), - (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) + & IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), - (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) - & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + il_write_targ_mem(il, + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), + (SCD_FRAME_LIMIT << + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); @@ -2226,9 +2238,9 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, return 0; } - -int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn) +int +il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 * ssn) { int sta_id; int tx_fifo; @@ -2241,8 +2253,7 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN("%s on ra = %pM tid = %d\n", - __func__, sta->addr, tid); + IL_WARN("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { @@ -2267,12 +2278,10 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, tid_data = &il->stations[sta_id].tid[tid]; *ssn = SEQ_TO_SN(tid_data->seq_number); tid_data->agg.txq_id = txq_id; - il_set_swq_id(&il->txq[txq_id], - il4965_get_ac_from_tid(tid), txq_id); + il_set_swq_id(&il->txq[txq_id], il4965_get_ac_from_tid(tid), txq_id); spin_unlock_irqrestore(&il->sta_lock, flags); - ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, - sta_id, tid, *ssn); + ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, sta_id, tid, *ssn); if (ret) return ret; @@ -2283,9 +2292,8 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - D_HT( - "HW queue is NOT empty: %d packets in HW queue\n", - tid_data->tfds_in_queue); + D_HT("HW queue is NOT empty: %d packets in HW queue\n", + tid_data->tfds_in_queue); tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; } spin_unlock_irqrestore(&il->sta_lock, flags); @@ -2296,14 +2304,13 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE * il->lock must be held by the caller */ -static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, - u16 ssn_idx, u8 tx_fifo) +static int +il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN("queue number out of range: %d, must be %d to %d\n", txq_id, IL49_FIRST_AMPDU_QUEUE, IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); @@ -2312,24 +2319,23 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, il4965_tx_queue_stop_scheduler(il, txq_id); - il_clear_bits_prph(il, - IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_clear_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); /* supposes that ssn_idx is valid (!= 0xFFF) */ il4965_set_wr_ptrs(il, txq_id, ssn_idx); - il_clear_bits_prph(il, - IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_clear_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); il_txq_ctx_deactivate(il, txq_id); il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); return 0; } -int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid) +int +il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid) { int tx_fifo_id, txq_id, sta_id, ssn; struct il_tid_data *tid_data; @@ -2376,13 +2382,13 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, if (write_ptr != read_ptr) { D_HT("Stopping a non empty AGG HW QUEUE\n"); il->stations[sta_id].tid[tid].agg.state = - IL_EMPTYING_HW_QUEUE_DELBA; + IL_EMPTYING_HW_QUEUE_DELBA; spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } D_HT("HW queue is empty\n"); - turn_off: +turn_off: il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; /* do not restore/save irqs */ @@ -2404,8 +2410,8 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, return 0; } -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id) +int +il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id) { struct il_queue *q = &il->txq[txq_id].q; u8 *addr = il->stations[sta_id].sta.sta.addr; @@ -2420,12 +2426,11 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ - if (txq_id == tid_data->agg.txq_id && + if (txq_id == tid_data->agg.txq_id && q->read_ptr == q->write_ptr) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - D_HT( - "HW queue empty: continue DELBA flow\n"); + D_HT("HW queue empty: continue DELBA flow\n"); il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); tid_data->agg.state = IL_AGG_OFF; ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); @@ -2434,8 +2439,7 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - D_HT( - "HW queue empty: continue ADDBA flow\n"); + D_HT("HW queue empty: continue ADDBA flow\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } @@ -2445,9 +2449,9 @@ int il4965_txq_check_empty(struct il_priv *il, return 0; } -static void il4965_non_agg_tx_status(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr1) +static void +il4965_non_agg_tx_status(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr1) { struct ieee80211_sta *sta; struct il_station_priv *sta_priv; @@ -2465,10 +2469,9 @@ static void il4965_non_agg_tx_status(struct il_priv *il, } static void -il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, - bool is_agg) +il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, bool is_agg) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data; if (!is_agg) il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); @@ -2476,7 +2479,8 @@ il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); } -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) +int +il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -2486,13 +2490,12 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); + "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, + q->write_ptr, q->read_ptr); return 0; } - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -2519,10 +2522,9 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) * Go through block-ack's bitmap of ACK'd frames, update driver's record of * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. */ -static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, - struct il_ht_agg *agg, - struct il_compressed_ba_resp *ba_resp) - +static int +il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct il_ht_agg *agg, + struct il_compressed_ba_resp *ba_resp) { int i, sh, ack; u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl); @@ -2531,7 +2533,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct ieee80211_tx_info *info; u64 bitmap, sent_bitmap; - if (unlikely(!agg->wait_for_ba)) { + if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) IL_ERR("Received BA when not expected\n"); return -EINVAL; @@ -2539,12 +2541,11 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - D_TX_REPLY("BA %d %d\n", agg->start_idx, - ba_resp->seq_ctl); + D_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx win bits */ sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); - if (sh < 0) /* tbw something is wrong with indices */ + if (sh < 0) /* tbw something is wrong with indices */ sh += 0x100; if (agg->frame_count > (64 - sh)) { @@ -2565,16 +2566,13 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", - ack ? "ACK" : "NACK", i, - (agg->start_idx + i) & 0xff, - agg->start_idx + i); + D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", + i, (agg->start_idx + i) & 0xff, agg->start_idx + i); sent_bitmap >>= 1; ++i; } - D_TX_REPLY("Bitmap %llx\n", - (unsigned long long)bitmap); + D_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); memset(&info->status, 0, sizeof(info->status)); @@ -2590,13 +2588,14 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, /** * translate ucode response to mac80211 tx status control values */ -void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info) +void +il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, + struct ieee80211_tx_info *info) { struct ieee80211_tx_rate *r = &info->control.rates[0]; info->antenna_sel_tx = - ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); + ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); if (rate_n_flags & RATE_MCS_HT_MSK) r->flags |= IEEE80211_TX_RC_MCS; if (rate_n_flags & RATE_MCS_GF_MSK) @@ -2616,8 +2615,8 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void il4965_hdl_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; @@ -2636,8 +2635,7 @@ void il4965_hdl_compressed_ba(struct il_priv *il, u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= il->hw_params.max_txq_num) { - IL_ERR( - "BUG_ON scd_flow is bigger than number of queues\n"); + IL_ERR("BUG_ON scd_flow is bigger than number of queues\n"); return; } @@ -2652,9 +2650,8 @@ void il4965_hdl_compressed_ba(struct il_priv *il, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - D_TX_REPLY( - "BA scd_flow %d does not match txq_id %d\n", - scd_flow, agg->txq_id); + D_TX_REPLY("BA scd_flow %d does not match txq_id %d\n", + scd_flow, agg->txq_id); return; } @@ -2663,22 +2660,15 @@ void il4965_hdl_compressed_ba(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); - D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " - "sta_id = %d\n", - agg->wait_for_ba, - (u8 *) &ba_resp->sta_addr_lo32, - ba_resp->sta_id); - D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," - "scd_flow = " - "%d, scd_ssn = %d\n", - ba_resp->tid, - ba_resp->seq_ctl, - (unsigned long long)le64_to_cpu(ba_resp->bitmap), - ba_resp->scd_flow, - ba_resp->scd_ssn); - D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", - agg->start_idx, - (unsigned long long)agg->bitmap); + D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", + agg->wait_for_ba, (u8 *) & ba_resp->sta_addr_lo32, + ba_resp->sta_id); + D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " + "%d, scd_ssn = %d\n", ba_resp->tid, ba_resp->seq_ctl, + (unsigned long long)le64_to_cpu(ba_resp->bitmap), + ba_resp->scd_flow, ba_resp->scd_ssn); + D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, + (unsigned long long)agg->bitmap); /* Update driver's record of ACK vs. not for each frame in win */ il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); @@ -2703,7 +2693,8 @@ void il4965_hdl_compressed_ba(struct il_priv *il, } #ifdef CONFIG_IWLEGACY_DEBUG -const char *il4965_get_tx_fail_reason(u32 status) +const char * +il4965_get_tx_fail_reason(u32 status) { #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x #define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x @@ -2711,27 +2702,27 @@ const char *il4965_get_tx_fail_reason(u32 status) switch (status & TX_STATUS_MSK) { case TX_STATUS_SUCCESS: return "SUCCESS"; - TX_STATUS_POSTPONE(DELAY); - TX_STATUS_POSTPONE(FEW_BYTES); - TX_STATUS_POSTPONE(QUIET_PERIOD); - TX_STATUS_POSTPONE(CALC_TTAK); - TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); - TX_STATUS_FAIL(SHORT_LIMIT); - TX_STATUS_FAIL(LONG_LIMIT); - TX_STATUS_FAIL(FIFO_UNDERRUN); - TX_STATUS_FAIL(DRAIN_FLOW); - TX_STATUS_FAIL(RFKILL_FLUSH); - TX_STATUS_FAIL(LIFE_EXPIRE); - TX_STATUS_FAIL(DEST_PS); - TX_STATUS_FAIL(HOST_ABORTED); - TX_STATUS_FAIL(BT_RETRY); - TX_STATUS_FAIL(STA_INVALID); - TX_STATUS_FAIL(FRAG_DROPPED); - TX_STATUS_FAIL(TID_DISABLE); - TX_STATUS_FAIL(FIFO_FLUSHED); - TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); - TX_STATUS_FAIL(PASSIVE_NO_RX); - TX_STATUS_FAIL(NO_BEACON_ON_RADAR); + TX_STATUS_POSTPONE(DELAY); + TX_STATUS_POSTPONE(FEW_BYTES); + TX_STATUS_POSTPONE(QUIET_PERIOD); + TX_STATUS_POSTPONE(CALC_TTAK); + TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); + TX_STATUS_FAIL(SHORT_LIMIT); + TX_STATUS_FAIL(LONG_LIMIT); + TX_STATUS_FAIL(FIFO_UNDERRUN); + TX_STATUS_FAIL(DRAIN_FLOW); + TX_STATUS_FAIL(RFKILL_FLUSH); + TX_STATUS_FAIL(LIFE_EXPIRE); + TX_STATUS_FAIL(DEST_PS); + TX_STATUS_FAIL(HOST_ABORTED); + TX_STATUS_FAIL(BT_RETRY); + TX_STATUS_FAIL(STA_INVALID); + TX_STATUS_FAIL(FRAG_DROPPED); + TX_STATUS_FAIL(TID_DISABLE); + TX_STATUS_FAIL(FIFO_FLUSHED); + TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); + TX_STATUS_FAIL(PASSIVE_NO_RX); + TX_STATUS_FAIL(NO_BEACON_ON_RADAR); } return "UNKNOWN"; @@ -2764,29 +2755,29 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; - rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << - RATE_MCS_ANT_POS; - rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, - rate_flags); + rate_flags |= + il4965_first_antenna(il->hw_params. + valid_tx_ant) << RATE_MCS_ANT_POS; + rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, rate_flags); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; link_cmd->general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & ~il4965_first_antenna(il->hw_params. + valid_tx_ant); if (!link_cmd->general_params.dual_stream_ant_msk) { link_cmd->general_params.dual_stream_ant_msk = ANT_AB; } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; link_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); link_cmd->sta_id = sta_id; @@ -2800,7 +2791,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) */ int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r) + const u8 * addr, u8 * sta_id_r) { int ret; u8 sta_id; @@ -2826,9 +2817,8 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, /* Set up default rate scaling table in device's station table */ link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for station %pM.\n", - addr); + IL_ERR("Unable to initialize rate scaling for station %pM.\n", + addr); return -ENOMEM; } @@ -2843,15 +2833,15 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, return 0; } -static int il4965_static_wepkey_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - bool send_if_empty) +static int +il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, + bool send_if_empty) { int i, not_empty = 0; u8 buff[sizeof(struct il_wep_cmd) + sizeof(struct il_wep_key) * WEP_KEYS_MAX]; struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; - size_t cmd_size = sizeof(struct il_wep_cmd); + size_t cmd_size = sizeof(struct il_wep_cmd); struct il_host_cmd cmd = { .id = ctx->wep_key_cmd, .data = wep_cmd, @@ -2860,10 +2850,10 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, might_sleep(); - memset(wep_cmd, 0, cmd_size + - (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); + memset(wep_cmd, 0, + cmd_size + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); - for (i = 0; i < WEP_KEYS_MAX ; i++) { + for (i = 0; i < WEP_KEYS_MAX; i++) { wep_cmd->key[i].key_idx = i; if (ctx->wep_keys[i].key_size) { wep_cmd->key[i].key_offset = i; @@ -2874,7 +2864,7 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, - ctx->wep_keys[i].key_size); + ctx->wep_keys[i].key_size); } wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; @@ -2890,42 +2880,39 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, return 0; } -int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx) +int +il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx) { lockdep_assert_held(&il->mutex); return il4965_static_wepkey_cmd(il, ctx, false); } -int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) +int +il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) { int ret; lockdep_assert_held(&il->mutex); - D_WEP("Removing default WEP key: idx=%d\n", - keyconf->keyidx); + D_WEP("Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); if (il_is_rfkill(il)) { - D_WEP( - "Not sending C_WEPKEY command due to RFKILL.\n"); + D_WEP("Not sending C_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } ret = il4965_static_wepkey_cmd(il, ctx, 1); - D_WEP("Remove default WEP key: idx=%d ret=%d\n", - keyconf->keyidx, ret); + D_WEP("Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; } -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) +int +il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) { int ret; @@ -2943,19 +2930,18 @@ int il4965_set_default_wep_key(struct il_priv *il, ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, - keyconf->keylen); + keyconf->keylen); ret = il4965_static_wepkey_cmd(il, ctx, false); - D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", - keyconf->keylen, keyconf->keyidx, ret); + D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, + keyconf->keyidx, ret); return ret; } -static int il4965_set_wep_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; @@ -2981,37 +2967,36 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *il, il->stations[sta_id].keyinfo.keylen = keyconf->keylen; il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; - memcpy(il->stations[sta_id].keyinfo.key, - keyconf->key, keyconf->keylen); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(&il->stations[sta_id].sta.key.key[3], - keyconf->key, keyconf->keylen); + memcpy(&il->stations[sta_id].sta.key.key[3], keyconf->key, + keyconf->keylen); - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il4965_set_ccmp_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; @@ -3032,37 +3017,35 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, il->stations[sta_id].keyinfo.cipher = keyconf->cipher; il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il4965_set_tkip_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; int ret = 0; @@ -3083,19 +3066,18 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, il->stations[sta_id].keyinfo.cipher = keyconf->cipher; il->stations[sta_id].keyinfo.keylen = 16; - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; - /* This copy is acutally not needed: we get the key with each TX */ memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); @@ -3106,10 +3088,10 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, return ret; } -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) +void +il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 * phase1key) { u8 sta_id; unsigned long flags; @@ -3131,7 +3113,7 @@ void il4965_update_tkip_key(struct il_priv *il, for (i = 0; i < 5; i++) il->stations[sta_id].sta.key.tkip_rx_ttak[i] = - cpu_to_le16(phase1key[i]); + cpu_to_le16(phase1key[i]); il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; @@ -3142,10 +3124,9 @@ void il4965_update_tkip_key(struct il_priv *il, } -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +int +il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; u16 key_flags; @@ -3160,8 +3141,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - D_WEP("Remove dynamic key: idx=%d sta=%d\n", - keyconf->keyidx, sta_id); + D_WEP("Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { /* We need to remove a key with idx different that the one @@ -3174,41 +3154,40 @@ int il4965_remove_dynamic_key(struct il_priv *il, } if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN("Removing wrong key %d 0x%x\n", - keyconf->keyidx, key_flags); + IL_WARN("Removing wrong key %d 0x%x\n", keyconf->keyidx, + key_flags); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, - &il->ucode_key_table)) + if (!test_and_clear_bit + (il->stations[sta_id].sta.key.key_offset, &il->ucode_key_table)) IL_ERR("idx %d not used in uCode key table.\n", - il->stations[sta_id].sta.key.key_offset); - memset(&il->stations[sta_id].keyinfo, 0, - sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); + il->stations[sta_id].sta.key.key_offset); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); il->stations[sta_id].sta.key.key_flags = - STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; + STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; if (il_is_rfkill(il)) { - D_WEP( - "Not sending C_ADD_STA command because RFKILL enabled.\n"); + D_WEP + ("Not sending C_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, u8 sta_id) +int +il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret; @@ -3219,29 +3198,25 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = il4965_set_ccmp_dynamic_key_info(il, ctx, - keyconf, sta_id); + ret = + il4965_set_ccmp_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = il4965_set_tkip_dynamic_key_info(il, ctx, - keyconf, sta_id); + ret = + il4965_set_tkip_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = il4965_set_wep_dynamic_key_info(il, ctx, - keyconf, sta_id); + ret = il4965_set_wep_dynamic_key_info(il, ctx, keyconf, sta_id); break; default: - IL_ERR( - "Unknown alg: %s cipher = %x\n", __func__, - keyconf->cipher); + IL_ERR("Unknown alg: %s cipher = %x\n", __func__, + keyconf->cipher); ret = -EINVAL; } - D_WEP( - "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); + D_WEP("Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", + keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } @@ -3253,16 +3228,15 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, * and marks it driver active, so that it will be restored to the * device at the next best time. */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) +int +il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { struct il_link_quality_cmd *link_cmd; unsigned long flags; u8 sta_id; spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, il_bcast_addr, - false, NULL); + sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); @@ -3276,8 +3250,8 @@ int il4965_alloc_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); + IL_ERR + ("Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -3294,8 +3268,8 @@ int il4965_alloc_bcast_station(struct il_priv *il, * Only used by iwl4965. Placed here to have all bcast station management * code together. */ -static int il4965_update_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { unsigned long flags; struct il_link_quality_cmd *link_cmd; @@ -3303,8 +3277,8 @@ static int il4965_update_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); + IL_ERR + ("Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -3312,15 +3286,16 @@ static int il4965_update_bcast_station(struct il_priv *il, if (il->stations[sta_id].lq) kfree(il->stations[sta_id].lq); else - D_INFO( - "Bcast station rate scaling has not been initialized yet.\n"); + D_INFO + ("Bcast station rate scaling has not been initialized yet.\n"); il->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -int il4965_update_bcast_stations(struct il_priv *il) +int +il4965_update_bcast_stations(struct il_priv *il) { return il4965_update_bcast_station(il, &il->ctx); } @@ -3328,7 +3303,8 @@ int il4965_update_bcast_stations(struct il_priv *il) /** * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table */ -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) +int +il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) { unsigned long flags; struct il_addsta_cmd sta_cmd; @@ -3341,14 +3317,15 @@ int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn) +int +il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, + u16 ssn) { unsigned long flags; int sta_id; @@ -3363,18 +3340,18 @@ int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].sta.station_flags_msk = 0; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; - il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.add_immediate_ba_tid = (u8) tid; il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid) +int +il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, int tid) { unsigned long flags; int sta_id; @@ -3391,10 +3368,10 @@ int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].sta.station_flags_msk = 0; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; - il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.remove_immediate_ba_tid = (u8) tid; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); @@ -3409,16 +3386,16 @@ il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; il->stations[sta_id].sta.sta.modify_mask = - STA_MODIFY_SLEEP_TX_COUNT_MSK; + STA_MODIFY_SLEEP_TX_COUNT_MSK; il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); + il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags); } -void il4965_update_chain_flags(struct il_priv *il) +void +il4965_update_chain_flags(struct il_priv *il) { if (il->cfg->ops->hcmd->set_rxon_chain) { il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); @@ -3427,12 +3404,12 @@ void il4965_update_chain_flags(struct il_priv *il) } } -static void il4965_clear_free_frames(struct il_priv *il) +static void +il4965_clear_free_frames(struct il_priv *il) { struct list_head *element; - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { element = il->free_frames.next; @@ -3443,12 +3420,13 @@ static void il4965_clear_free_frames(struct il_priv *il) if (il->frames_count) { IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); + il->frames_count); il->frames_count = 0; } } -static struct il_frame *il4965_get_free_frame(struct il_priv *il) +static struct il_frame * +il4965_get_free_frame(struct il_priv *il) { struct il_frame *frame; struct list_head *element; @@ -3468,15 +3446,16 @@ static struct il_frame *il4965_get_free_frame(struct il_priv *il) return list_entry(element, struct il_frame, list); } -static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) +static void +il4965_free_frame(struct il_priv *il, struct il_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &il->free_frames); } -static u32 il4965_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) +static u32 +il4965_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, + int left) { lockdep_assert_held(&il->mutex); @@ -3492,9 +3471,10 @@ static u32 il4965_fill_beacon_frame(struct il_priv *il, } /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void il4965_set_beacon_tim(struct il_priv *il, - struct il_tx_beacon_cmd *tx_beacon_cmd, - u8 *beacon, u32 frame_size) +static void +il4965_set_beacon_tim(struct il_priv *il, + struct il_tx_beacon_cmd *tx_beacon_cmd, u8 * beacon, + u32 frame_size) { u16 tim_idx; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; @@ -3507,19 +3487,19 @@ static void il4965_set_beacon_tim(struct il_priv *il, /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ while ((tim_idx < (frame_size - 2)) && - (beacon[tim_idx] != WLAN_EID_TIM)) - tim_idx += beacon[tim_idx+1] + 2; + (beacon[tim_idx] != WLAN_EID_TIM)) + tim_idx += beacon[tim_idx + 1] + 2; /* If TIM field was found, set variables */ if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); - tx_beacon_cmd->tim_size = beacon[tim_idx+1]; + tx_beacon_cmd->tim_size = beacon[tim_idx + 1]; } else IL_WARN("Unable to find TIM Element in beacon\n"); } -static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, - struct il_frame *frame) +static unsigned int +il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame) { struct il_tx_beacon_cmd *tx_beacon_cmd; u32 frame_size; @@ -3542,38 +3522,42 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); /* Set up TX beacon contents */ - frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + frame_size = + il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) return 0; if (!frame_size) return 0; /* Set up TX command fields */ - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + tx_beacon_cmd->tx.len = cpu_to_le16((u16) frame_size); tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; + tx_beacon_cmd->tx.tx_flags = + TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK | + TX_CMD_FLG_STA_RATE_MSK; /* Set up TX beacon command fields */ - il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, - frame_size); + il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *) tx_beacon_cmd->frame, + frame_size); /* Set up packet rate and flags */ rate = il_get_lowest_plcp(il, il->beacon_ctx); - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); + il->mgmt_tx_ant = + il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; - tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, - rate_flags); + tx_beacon_cmd->tx.rate_n_flags = + il4965_hw_set_rate_n_flags(rate, rate_flags); return sizeof(*tx_beacon_cmd) + frame_size; } -int il4965_send_beacon_cmd(struct il_priv *il) +int +il4965_send_beacon_cmd(struct il_priv *il) { struct il_frame *frame; unsigned int frame_size; @@ -3582,7 +3566,7 @@ int il4965_send_beacon_cmd(struct il_priv *il) frame = il4965_get_free_frame(il); if (!frame) { IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); + "command.\n"); return -ENOMEM; } @@ -3593,35 +3577,37 @@ int il4965_send_beacon_cmd(struct il_priv *il) return -EINVAL; } - rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, - &frame->u.cmd[0]); + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il4965_free_frame(il, frame); return rc; } -static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) +static inline dma_addr_t +il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) { struct il_tfd_tb *tb = &tfd->tbs[idx]; dma_addr_t addr = get_unaligned_le32(&tb->lo); if (sizeof(dma_addr_t) > sizeof(u32)) addr |= - ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; + ((dma_addr_t) (le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << + 16; return addr; } -static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) +static inline u16 +il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) { struct il_tfd_tb *tb = &tfd->tbs[idx]; return le16_to_cpu(tb->hi_n_len) >> 4; } -static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, - dma_addr_t addr, u16 len) +static inline void +il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, dma_addr_t addr, u16 len) { struct il_tfd_tb *tb = &tfd->tbs[idx]; u16 hi_n_len = len << 4; @@ -3635,7 +3621,8 @@ static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, tfd->num_tbs = idx + 1; } -static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) +static inline u8 +il4965_tfd_get_num_tbs(struct il_tfd *tfd) { return tfd->num_tbs & 0x1f; } @@ -3648,7 +3635,8 @@ static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) * Does NOT advance any TFD circular buffer read/write idxes * Does NOT free the TFD itself (which is within circular buffer) */ -void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +void +il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; struct il_tfd *tfd; @@ -3670,16 +3658,15 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (num_tbs) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_BIDIRECTIONAL); + pci_unmap_single(dev, dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_BIDIRECTIONAL); /* Unmap chunks, if any. */ for (i = 1; i < num_tbs; i++) pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), - il4965_tfd_tb_get_len(tfd, i), - PCI_DMA_TODEVICE); + il4965_tfd_tb_get_len(tfd, i), + PCI_DMA_TODEVICE); /* free SKB */ if (txq->txb) { @@ -3695,10 +3682,9 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) } } -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad) +int +il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad) { struct il_queue *q; struct il_tfd *tfd, *tfd_tmp; @@ -3716,14 +3702,13 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, /* Each TFD can point to a maximum 20 Tx buffers */ if (num_tbs >= IL_NUM_OF_TBS) { IL_ERR("Error can not send more than %d chunks\n", - IL_NUM_OF_TBS); + IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR("Unaligned address = %llx\n", - (unsigned long long)addr); + IL_ERR("Unaligned address = %llx\n", (unsigned long long)addr); il4965_tfd_set_tb(tfd, num_tbs, addr, len); @@ -3737,14 +3722,13 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA * channels supported in hardware. */ -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq) +int +il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_wr(il, FH49_MEM_CBBC_QUEUE(txq_id), - txq->q.dma_addr >> 8); + il_wr(il, FH49_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; } @@ -3754,8 +3738,8 @@ int il4965_hw_tx_queue_init(struct il_priv *il, * Generic RX handler implementations * ******************************************************************************/ -static void il4965_hdl_alive(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -3763,15 +3747,12 @@ static void il4965_hdl_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { D_INFO("Initialization Alive received.\n"); - memcpy(&il->card_alive_init, - &pkt->u.alive_frame, + memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_init_alive_resp)); pwork = &il->init_alive_start; } else { @@ -3784,8 +3765,7 @@ static void il4965_hdl_alive(struct il_priv *il, /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else IL_WARN("uCode did not respond OK.\n"); } @@ -3800,7 +3780,8 @@ static void il4965_hdl_alive(struct il_priv *il, * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ -static void il4965_bg_stats_periodic(unsigned long data) +static void +il4965_bg_stats_periodic(unsigned long data) { struct il_priv *il = (struct il_priv *)data; @@ -3814,28 +3795,27 @@ static void il4965_bg_stats_periodic(unsigned long data) il_send_stats_request(il, CMD_ASYNC, false); } -static void il4965_hdl_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = - (struct il4965_beacon_notif *)pkt->u.raw; + (struct il4965_beacon_notif *)pkt->u.raw; #ifdef CONFIG_IWLEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); #endif il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } -static void il4965_perform_ct_kill_task(struct il_priv *il) +static void +il4965_perform_ct_kill_task(struct il_priv *il) { unsigned long flags; @@ -3845,7 +3825,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) ieee80211_stop_queues(il->hw); _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); _il_rd(il, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&il->reg_lock, flags); @@ -3856,33 +3836,30 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il4965_hdl_card_state(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On", - (flags & CT_CARD_DISABLED) ? - "Reached" : "Not reached"); + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On", + (flags & CT_CARD_DISABLED) ? "Reached" : "Not reached"); - if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | - CT_CARD_DISABLED)) { + if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + il_wr(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } @@ -3900,7 +3877,7 @@ static void il4965_hdl_card_state(struct il_priv *il, if ((test_bit(S_RF_KILL_HW, &status) != test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -3914,16 +3891,15 @@ static void il4965_hdl_card_state(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il4965_setup_handlers(struct il_priv *il) +static void +il4965_setup_handlers(struct il_priv *il) { il->handlers[N_ALIVE] = il4965_hdl_alive; il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; - il->handlers[N_SPECTRUM_MEASUREMENT] = - il_hdl_spectrum_measurement; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_hdl_spectrum_measurement; il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; - il->handlers[N_PM_DEBUG_STATS] = - il_hdl_pm_debug_stats; + il->handlers[N_PM_DEBUG_STATS] = il_hdl_pm_debug_stats; il->handlers[N_BEACON] = il4965_hdl_beacon; /* @@ -3937,11 +3913,9 @@ static void il4965_setup_handlers(struct il_priv *il) il_setup_rx_scan_handlers(il); /* status change handler */ - il->handlers[N_CARD_STATE] = - il4965_hdl_card_state; + il->handlers[N_CARD_STATE] = il4965_hdl_card_state; - il->handlers[N_MISSED_BEACONS] = - il4965_hdl_missed_beacon; + il->handlers[N_MISSED_BEACONS] = il4965_hdl_missed_beacon; /* Rx handlers */ il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; il->handlers[N_RX_MPDU] = il4965_hdl_rx; @@ -3958,7 +3932,8 @@ static void il4965_setup_handlers(struct il_priv *il) * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -void il4965_rx_handle(struct il_priv *il) +void +il4965_rx_handle(struct il_priv *il) { struct il_rx_buf *rxb; struct il_rx_pkt *pkt; @@ -3972,7 +3947,7 @@ void il4965_rx_handle(struct il_priv *il) /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; /* Rx interrupt, but nothing sent from uCode */ @@ -4005,7 +3980,7 @@ void il4965_rx_handle(struct il_priv *il) pkt = rxb_addr(rxb); len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ + len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -4014,28 +3989,23 @@ void il4965_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != N_RX_PHY) && - (pkt->hdr.cmd != N_RX) && - (pkt->hdr.cmd != N_RX_MPDU) && - (pkt->hdr.cmd != N_COMPRESSED_BA) && - (pkt->hdr.cmd != N_STATS) && - (pkt->hdr.cmd != C_TX); + (pkt->hdr.cmd != N_RX_PHY) && (pkt->hdr.cmd != N_RX) && + (pkt->hdr.cmd != N_RX_MPDU) && + (pkt->hdr.cmd != N_COMPRESSED_BA) && + (pkt->hdr.cmd != N_STATS) && (pkt->hdr.cmd != C_TX); /* Based on type of command response or notification, * handle those that need handling via function in * handlers table. See il4965_setup_handlers() */ if (il->handlers[pkt->hdr.cmd]) { - D_RX("r = %d, i = %d, %s, 0x%02x\n", r, - i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.handlers[pkt->hdr.cmd]++; il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); + D_RX("r %d i %d No handler needed for %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } /* @@ -4060,9 +4030,10 @@ void il4965_rx_handle(struct il_priv *il) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, rxb->page, 0, + PAGE_SIZE << il->hw_params. + rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; } else @@ -4092,14 +4063,16 @@ void il4965_rx_handle(struct il_priv *il) } /* call this function to flush any scheduled tasklet */ -static inline void il4965_synchronize_irq(struct il_priv *il) +static inline void +il4965_synchronize_irq(struct il_priv *il) { - /* wait to make sure we flush pending tasklet*/ + /* wait to make sure we flush pending tasklet */ synchronize_irq(il->pci_dev->irq); tasklet_kill(&il->irq_tasklet); } -static void il4965_irq_tasklet(struct il_priv *il) +static void +il4965_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -4127,8 +4100,8 @@ static void il4965_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, + inta_mask, inta_fh); } #endif @@ -4157,13 +4130,12 @@ static void il4965_irq_tasklet(struct il_priv *il) return; } - #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); + "the frame/frames.\n"); il->isr_stats.sch++; } @@ -4180,12 +4152,13 @@ static void il4965_irq_tasklet(struct il_priv *il) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + if (! + (_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; IL_WARN("RF_KILL bit toggled to %s.\n", - hw_rf_kill ? "disable radio" : "enable radio"); + hw_rf_kill ? "disable radio" : "enable radio"); il->isr_stats.rfkill++; @@ -4214,8 +4187,8 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - " Restarting 0x%X.\n", inta); + IL_ERR("Microcode SW error detected. " " Restarting 0x%X.\n", + inta); il->isr_stats.sw++; il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; @@ -4261,7 +4234,7 @@ static void il4965_irq_tasklet(struct il_priv *il) if (inta & ~(il->inta_mask)) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); + inta & ~il->inta_mask); IL_WARN(" with FH49_INT = 0x%08x\n", inta_fh); } @@ -4278,9 +4251,8 @@ static void il4965_irq_tasklet(struct il_priv *il) inta = _il_rd(il, CSR_INT); inta_mask = _il_rd(il, CSR_INT_MASK); inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - D_ISR( - "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } @@ -4304,15 +4276,17 @@ static void il4965_irq_tasklet(struct il_priv *il) * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t il4965_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il4965_show_debug_level(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } -static ssize_t il4965_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) + +static ssize_t +il4965_store_debug_level(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); unsigned long val; @@ -4324,21 +4298,19 @@ static ssize_t il4965_store_debug_level(struct device *d, else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il4965_show_debug_level, il4965_store_debug_level); - +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il4965_show_debug_level, + il4965_store_debug_level); #endif /* CONFIG_IWLEGACY_DEBUG */ - -static ssize_t il4965_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il4965_show_temperature(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -4350,8 +4322,8 @@ static ssize_t il4965_show_temperature(struct device *d, static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); -static ssize_t il4965_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il4965_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -4361,9 +4333,9 @@ static ssize_t il4965_show_tx_power(struct device *d, return sprintf(buf, "%d\n", il->tx_power_user_lmt); } -static ssize_t il4965_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il4965_store_tx_power(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); unsigned long val; @@ -4375,16 +4347,15 @@ static ssize_t il4965_store_tx_power(struct device *d, else { ret = il_set_tx_power(il, val, false); if (ret) - IL_ERR("failed setting tx power (0x%d).\n", - ret); + IL_ERR("failed setting tx power (0x%d).\n", ret); else ret = count; } return ret; } -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, - il4965_show_tx_power, il4965_store_tx_power); +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il4965_show_tx_power, + il4965_store_tx_power); static struct attribute *il_sysfs_entries[] = { &dev_attr_temperature.attr, @@ -4406,7 +4377,8 @@ static struct attribute_group il_attribute_group = { * ******************************************************************************/ -static void il4965_dealloc_ucode_pci(struct il_priv *il) +static void +il4965_dealloc_ucode_pci(struct il_priv *il) { il_free_fw_desc(il->pci_dev, &il->ucode_code); il_free_fw_desc(il->pci_dev, &il->ucode_data); @@ -4416,18 +4388,19 @@ static void il4965_dealloc_ucode_pci(struct il_priv *il) il_free_fw_desc(il->pci_dev, &il->ucode_boot); } -static void il4965_nic_start(struct il_priv *il) +static void +il4965_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ _il_wr(il, CSR_RESET, 0); } static void il4965_ucode_callback(const struct firmware *ucode_raw, - void *context); -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length); + void *context); +static int il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length); -static int __must_check il4965_request_firmware(struct il_priv *il, bool first) +static int __must_check +il4965_request_firmware(struct il_priv *il, bool first) { const char *name_pre = il->cfg->fw_name_pre; char tag[8]; @@ -4447,8 +4420,7 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - D_INFO("attempting to load firmware '%s'\n", - il->firmware_name); + D_INFO("attempting to load firmware '%s'\n", il->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, &il->pci_dev->dev, GFP_KERNEL, il, @@ -4460,9 +4432,9 @@ struct il4965_firmware_pieces { size_t inst_size, data_size, init_size, init_data_size, boot_size; }; -static int il4965_load_firmware(struct il_priv *il, - const struct firmware *ucode_raw, - struct il4965_firmware_pieces *pieces) +static int +il4965_load_firmware(struct il_priv *il, const struct firmware *ucode_raw, + struct il4965_firmware_pieces *pieces) { struct il_ucode_header *ucode = (void *)ucode_raw->data; u32 api_ver, hdr_size; @@ -4484,21 +4456,19 @@ static int il4965_load_firmware(struct il_priv *il, pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); pieces->data_size = le32_to_cpu(ucode->v1.data_size); pieces->init_size = le32_to_cpu(ucode->v1.init_size); - pieces->init_data_size = - le32_to_cpu(ucode->v1.init_data_size); + pieces->init_data_size = le32_to_cpu(ucode->v1.init_data_size); pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); src = ucode->v1.data; break; } /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != hdr_size + pieces->inst_size + - pieces->data_size + pieces->init_size + - pieces->init_data_size + pieces->boot_size) { + if (ucode_raw->size != + hdr_size + pieces->inst_size + pieces->data_size + + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IL_ERR( - "uCode file size %d does not match expected size\n", - (int)ucode_raw->size); + IL_ERR("uCode file size %d does not match expected size\n", + (int)ucode_raw->size); return -EINVAL; } @@ -4535,20 +4505,19 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) u32 max_probe_length = 200; u32 standard_phy_calibration_size = - IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; + IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { if (il->fw_idx <= il->cfg->ucode_api_max) - IL_ERR( - "request for firmware file '%s' failed.\n", - il->firmware_name); + IL_ERR("request for firmware file '%s' failed.\n", + il->firmware_name); goto try_again; } - D_INFO("Loaded firmware file '%s' (%zd bytes).\n", - il->firmware_name, ucode_raw->size); + D_INFO("Loaded firmware file '%s' (%zd bytes).\n", il->firmware_name, + ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { @@ -4572,32 +4541,25 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR( - "Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); + IL_ERR("Driver unable to support your firmware API. " + "Driver supports v%u, firmware is v%u.\n", api_max, + api_ver); goto try_again; } if (api_ver != api_max) - IL_ERR( - "Firmware has old API version. Expected v%u, " - "got v%u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); + IL_ERR("Firmware has old API version. Expected v%u, " + "got v%u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", api_max, + api_ver); IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); + IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), + snprintf(il->hw->wiphy->fw_version, sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); /* @@ -4606,47 +4568,41 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %Zd\n", - pieces.inst_size); - D_INFO("f/w package hdr runtime data size = %Zd\n", - pieces.data_size); - D_INFO("f/w package hdr init inst size = %Zd\n", - pieces.init_size); - D_INFO("f/w package hdr init data size = %Zd\n", - pieces.init_data_size); - D_INFO("f/w package hdr boot inst size = %Zd\n", - pieces.boot_size); + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); + D_INFO("f/w package hdr runtime data size = %Zd\n", pieces.data_size); + D_INFO("f/w package hdr init inst size = %Zd\n", pieces.init_size); + D_INFO("f/w package hdr init data size = %Zd\n", pieces.init_data_size); + D_INFO("f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ if (pieces.inst_size > il->hw_params.max_inst_size) { IL_ERR("uCode instr len %Zd too large to fit in\n", - pieces.inst_size); + pieces.inst_size); goto try_again; } if (pieces.data_size > il->hw_params.max_data_size) { IL_ERR("uCode data len %Zd too large to fit in\n", - pieces.data_size); + pieces.data_size); goto try_again; } if (pieces.init_size > il->hw_params.max_inst_size) { IL_ERR("uCode init instr len %Zd too large to fit in\n", - pieces.init_size); + pieces.init_size); goto try_again; } if (pieces.init_data_size > il->hw_params.max_data_size) { IL_ERR("uCode init data len %Zd too large to fit in\n", - pieces.init_data_size); + pieces.init_data_size); goto try_again; } if (pieces.boot_size > il->hw_params.max_bsm_size) { IL_ERR("uCode boot instr len %Zd too large to fit in\n", - pieces.boot_size); + pieces.boot_size); goto try_again; } @@ -4697,41 +4653,39 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Runtime instructions (first block of data in file) */ D_INFO("Copying (but not loading) uCode instr len %Zd\n", - pieces.inst_size); + pieces.inst_size); memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + il->ucode_code.v_addr, (u32) il->ucode_code.p_addr); /* * Runtime data * NOTE: Copy into backup buffer will be done in il_up() */ D_INFO("Copying (but not loading) uCode data len %Zd\n", - pieces.data_size); + pieces.data_size); memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - D_INFO( - "Copying (but not loading) init instr len %Zd\n", - pieces.init_size); + D_INFO("Copying (but not loading) init instr len %Zd\n", + pieces.init_size); memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); } /* Initialization data */ if (pieces.init_data_size) { - D_INFO( - "Copying (but not loading) init data len %Zd\n", - pieces.init_data_size); + D_INFO("Copying (but not loading) init data len %Zd\n", + pieces.init_data_size); memcpy(il->ucode_init_data.v_addr, pieces.init_data, pieces.init_data_size); } /* Bootstrap instructions */ D_INFO("Copying (but not loading) boot instr len %Zd\n", - pieces.boot_size); + pieces.boot_size); memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); /* @@ -4739,9 +4693,9 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * base on the size of standard phy calibration commands table size */ il->_4965.phy_calib_chain_noise_reset_cmd = - standard_phy_calibration_size; + standard_phy_calibration_size; il->_4965.phy_calib_chain_noise_gain_cmd = - standard_phy_calibration_size + 1; + standard_phy_calibration_size + 1; /************************************************** * This is still part of probe() in a sense... @@ -4754,11 +4708,10 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR( - "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", + err); - err = sysfs_create_group(&il->pci_dev->dev.kobj, - &il_attribute_group); + err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); if (err) { IL_ERR("failed to create sysfs device attributes\n"); goto out_unbind; @@ -4769,23 +4722,23 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) complete(&il->_4965.firmware_loading_complete); return; - try_again: +try_again: /* try next, if any */ if (il4965_request_firmware(il, false)) goto out_unbind; release_firmware(ucode_raw); return; - err_pci_alloc: +err_pci_alloc: IL_ERR("failed to allocate pci memory\n"); il4965_dealloc_ucode_pci(il); - out_unbind: +out_unbind: complete(&il->_4965.firmware_loading_complete); device_release_driver(&il->pci_dev->dev); release_firmware(ucode_raw); } -static const char * const desc_lookup_text[] = { +static const char *const desc_lookup_text[] = { "OK", "FAIL", "BAD_PARAM", @@ -4816,26 +4769,30 @@ static const char * const desc_lookup_text[] = { "DEBUG_3", }; -static struct { char *name; u8 num; } advanced_lookup[] = { - { "NMI_INTERRUPT_WDG", 0x34 }, - { "SYSASSERT", 0x35 }, - { "UCODE_VERSION_MISMATCH", 0x37 }, - { "BAD_COMMAND", 0x38 }, - { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, - { "FATAL_ERROR", 0x3D }, - { "NMI_TRM_HW_ERR", 0x46 }, - { "NMI_INTERRUPT_TRM", 0x4C }, - { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, - { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, - { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, - { "NMI_INTERRUPT_HOST", 0x66 }, - { "NMI_INTERRUPT_ACTION_PT", 0x7C }, - { "NMI_INTERRUPT_UNKNOWN", 0x84 }, - { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, - { "ADVANCED_SYSASSERT", 0 }, -}; - -static const char *il4965_desc_lookup(u32 num) +static struct { + char *name; + u8 num; +} advanced_lookup[] = { + { + "NMI_INTERRUPT_WDG", 0x34}, { + "SYSASSERT", 0x35}, { + "UCODE_VERSION_MISMATCH", 0x37}, { + "BAD_COMMAND", 0x38}, { + "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C}, { + "FATAL_ERROR", 0x3D}, { + "NMI_TRM_HW_ERR", 0x46}, { + "NMI_INTERRUPT_TRM", 0x4C}, { + "NMI_INTERRUPT_BREAK_POINT", 0x54}, { + "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C}, { + "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64}, { + "NMI_INTERRUPT_HOST", 0x66}, { + "NMI_INTERRUPT_ACTION_PT", 0x7C}, { + "NMI_INTERRUPT_UNKNOWN", 0x84}, { + "NMI_INTERRUPT_INST_ACTION_PT", 0x86}, { +"ADVANCED_SYSASSERT", 0},}; + +static const char * +il4965_desc_lookup(u32 num) { int i; int max = ARRAY_SIZE(desc_lookup_text); @@ -4854,7 +4811,8 @@ static const char *il4965_desc_lookup(u32 num) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il4965_dump_nic_error_log(struct il_priv *il) +void +il4965_dump_nic_error_log(struct il_priv *il) { u32 data2, line; u32 desc, time, count, base, data1; @@ -4868,9 +4826,8 @@ void il4965_dump_nic_error_log(struct il_priv *il) } if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR( - "Not valid error log pointer 0x%08X for %s uCode\n", - base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); + IL_ERR("Not valid error log pointer 0x%08X for %s uCode\n", + base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; } @@ -4878,8 +4835,7 @@ void il4965_dump_nic_error_log(struct il_priv *il) if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); @@ -4896,15 +4852,16 @@ void il4965_dump_nic_error_log(struct il_priv *il) hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); IL_ERR("Desc Time " - "data1 data2 line\n"); + "data1 data2 line\n"); IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", - il4965_desc_lookup(desc), desc, time, data1, data2, line); + il4965_desc_lookup(desc), desc, time, data1, data2, line); IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", - pc, blink1, blink2, ilink1, ilink2, hcmd); + IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, + blink2, ilink1, ilink2, hcmd); } -static void il4965_rf_kill_ct_config(struct il_priv *il) +static void +il4965_rf_kill_ct_config(struct il_priv *il) { struct il_ct_kill_config cmd; unsigned long flags; @@ -4912,21 +4869,19 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); spin_unlock_irqrestore(&il->lock, flags); cmd.critical_temperature_R = - cpu_to_le32(il->hw_params.ct_kill_threshold); + cpu_to_le32(il->hw_params.ct_kill_threshold); - ret = il_send_cmd_pdu(il, C_CT_KILL_CONFIG, - sizeof(cmd), &cmd); + ret = il_send_cmd_pdu(il, C_CT_KILL_CONFIG, sizeof(cmd), &cmd); if (ret) IL_ERR("C_CT_KILL_CONFIG failed\n"); else - D_INFO("C_CT_KILL_CONFIG " - "succeeded, " - "critical temperature is %d\n", - il->hw_params.ct_kill_threshold); + D_INFO("C_CT_KILL_CONFIG " "succeeded, " + "critical temperature is %d\n", + il->hw_params.ct_kill_threshold); } static const s8 default_queue_to_tx_fifo[] = { @@ -4941,7 +4896,8 @@ static const s8 default_queue_to_tx_fifo[] = { #define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -static int il4965_alive_notify(struct il_priv *il) +static int +il4965_alive_notify(struct il_priv *il) { u32 a; unsigned long flags; @@ -4951,32 +4907,32 @@ static int il4965_alive_notify(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - il->scd_base_addr = il_rd_prph(il, - IL49_SCD_SRAM_BASE_ADDR); + il->scd_base_addr = il_rd_prph(il, IL49_SCD_SRAM_BASE_ADDR); a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) il_write_targ_mem(il, a, 0); for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + for (; + a < + il->scd_base_addr + + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); + a += 4) il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, - il->scd_bc_tbls.dma >> 10); + il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ - for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_wr(il, - FH49_TCSR_CHNL_TX_CONFIG_REG(chan), - FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); + for (chan = 0; chan < FH49_TCSR_CHNL_NUM; chan++) + il_wr(il, FH49_TCSR_CHNL_TX_CONFIG_REG(chan), + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ reg_val = il_rd(il, FH49_TX_CHICKEN_BITS_REG); il_wr(il, FH49_TX_CHICKEN_BITS_REG, - reg_val | FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); + reg_val | FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); @@ -4989,23 +4945,25 @@ static int il4965_alive_notify(struct il_priv *il) il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i), - (SCD_WIN_SIZE << - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + il_write_targ_mem(il, + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i), + (SCD_WIN_SIZE << + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + - sizeof(u32), - (SCD_FRAME_LIMIT << - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + il_write_targ_mem(il, + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + + sizeof(u32), + (SCD_FRAME_LIMIT << + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, - (1 << il->hw_params.max_txq_num) - 1); + (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ il4965_txq_set_sched(il, IL_MASK(0, 6)); @@ -5043,7 +5001,8 @@ static int il4965_alive_notify(struct il_priv *il) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il_init_alive_start()). */ -static void il4965_alive_start(struct il_priv *il) +static void +il4965_alive_start(struct il_priv *il) { int ret = 0; struct il_rxon_context *ctx = &il->ctx; @@ -5069,12 +5028,10 @@ static void il4965_alive_start(struct il_priv *il) ret = il4965_alive_notify(il); if (ret) { - IL_WARN( - "Could not complete ALIVE transition [ntf]: %d\n", ret); + IL_WARN("Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } - /* After the ALIVE response, we can send host commands to the uCode */ set_bit(S_ALIVE, &il->status); @@ -5090,7 +5047,7 @@ static void il4965_alive_start(struct il_priv *il) if (il_is_associated_ctx(ctx)) { struct il_rxon_cmd *active_rxon = - (struct il_rxon_cmd *)&ctx->active; + (struct il_rxon_cmd *)&ctx->active; /* apply any changes in staging */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -5123,13 +5080,14 @@ static void il4965_alive_start(struct il_priv *il) return; - restart: +restart: queue_work(il->workqueue, &il->restart); } static void il4965_cancel_deferred_work(struct il_priv *il); -static void __il4965_down(struct il_priv *il) +static void +__il4965_down(struct il_priv *il) { unsigned long flags; int exit_pending; @@ -5171,25 +5129,28 @@ static void __il4965_down(struct il_priv *il) /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ if (!il_is_init(il)) { - il->status = test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status = + test_bit(S_RF_KILL_HW, + &il-> + status) << S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, + &il-> + status) << S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_FW_ERROR, &il->status) << - S_FW_ERROR | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status &= + test_bit(S_RF_KILL_HW, + &il->status) << S_RF_KILL_HW | test_bit(S_GEO_CONFIGURED, + &il-> + status) << + S_GEO_CONFIGURED | test_bit(S_FW_ERROR, + &il-> + status) << S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; il4965_txq_ctx_stop(il); il4965_rxq_stop(il); @@ -5199,13 +5160,12 @@ static void __il4965_down(struct il_priv *il) udelay(5); /* Make sure (redundant) we've released our request to stay awake */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ il_apm_stop(il); - exit: +exit: memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); dev_kfree_skb(il->beacon_skb); @@ -5215,7 +5175,8 @@ static void __il4965_down(struct il_priv *il) il4965_clear_free_frames(il); } -static void il4965_down(struct il_priv *il) +static void +il4965_down(struct il_priv *il) { mutex_lock(&il->mutex); __il4965_down(il); @@ -5226,29 +5187,30 @@ static void il4965_down(struct il_priv *il) #define HW_READY_TIMEOUT (50) -static int il4965_set_hw_ready(struct il_priv *il) +static int +il4965_set_hw_ready(struct il_priv *il) { int ret = 0; il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - HW_READY_TIMEOUT); + ret = + _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); if (ret != -ETIMEDOUT) il->hw_ready = true; else il->hw_ready = false; - D_INFO("hardware %s\n", - (il->hw_ready == 1) ? "ready" : "not ready"); + D_INFO("hardware %s\n", (il->hw_ready == 1) ? "ready" : "not ready"); return ret; } -static int il4965_prepare_card_hw(struct il_priv *il) +static int +il4965_prepare_card_hw(struct il_priv *il) { int ret = 0; @@ -5259,12 +5221,12 @@ static int il4965_prepare_card_hw(struct il_priv *il) return ret; /* If HW is not ready, prepare the conditions to check again */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_PREPARE); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, - CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); + ret = + _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, + CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); /* HW should be ready by now, check again. */ if (ret != -ETIMEDOUT) @@ -5275,7 +5237,8 @@ static int il4965_prepare_card_hw(struct il_priv *il) #define MAX_HW_RESTARTS 5 -static int __il4965_up(struct il_priv *il) +static int +__il4965_up(struct il_priv *il) { int i; int ret; @@ -5304,8 +5267,7 @@ static int __il4965_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, - CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(S_RF_KILL_HW, &il->status); else set_bit(S_RF_KILL_HW, &il->status); @@ -5331,8 +5293,7 @@ static int __il4965_up(struct il_priv *il) /* make sure rfkill handshake bits are cleared */ _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ _il_wr(il, CSR_INT, 0xFFFFFFFF); @@ -5356,8 +5317,7 @@ static int __il4965_up(struct il_priv *il) ret = il->cfg->ops->lib->load_ucode(il); if (ret) { - IL_ERR("Unable to set up bootstrap uCode: %d\n", - ret); + IL_ERR("Unable to set up bootstrap uCode: %d\n", ret); continue; } @@ -5379,14 +5339,14 @@ static int __il4965_up(struct il_priv *il) return -EIO; } - /***************************************************************************** * * Workqueue callbacks * *****************************************************************************/ -static void il4965_bg_init_alive_start(struct work_struct *data) +static void +il4965_bg_init_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); @@ -5400,7 +5360,8 @@ out: mutex_unlock(&il->mutex); } -static void il4965_bg_alive_start(struct work_struct *data) +static void +il4965_bg_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, alive_start.work); @@ -5414,10 +5375,11 @@ out: mutex_unlock(&il->mutex); } -static void il4965_bg_run_time_calib_work(struct work_struct *work) +static void +il4965_bg_run_time_calib_work(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, - run_time_calib_work); + run_time_calib_work); mutex_lock(&il->mutex); @@ -5428,16 +5390,15 @@ static void il4965_bg_run_time_calib_work(struct work_struct *work) } if (il->start_calib) { - il4965_chain_noise_calibration(il, - (void *)&il->_4965.stats); - il4965_sensitivity_calibration(il, - (void *)&il->_4965.stats); + il4965_chain_noise_calibration(il, (void *)&il->_4965.stats); + il4965_sensitivity_calibration(il, (void *)&il->_4965.stats); } mutex_unlock(&il->mutex); } -static void il4965_bg_restart(struct work_struct *data) +static void +il4965_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); @@ -5468,10 +5429,10 @@ static void il4965_bg_restart(struct work_struct *data) } } -static void il4965_bg_rx_replenish(struct work_struct *data) +static void +il4965_bg_rx_replenish(struct work_struct *data) { - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -5493,8 +5454,8 @@ static void il4965_bg_rx_replenish(struct work_struct *data) * Not a mac80211 entry point function, but it fits in with all the * other mac80211 functions grouped here. */ -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length) +static int +il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length) { int ret; struct ieee80211_hw *hw = il->hw; @@ -5502,15 +5463,15 @@ static int il4965_mac_setup_register(struct il_priv *il, hw->rate_control_algorithm = "iwl-4965-rs"; /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_AMPDU_AGGREGATION | - IEEE80211_HW_NEED_DTIM_PERIOD | - IEEE80211_HW_SPECTRUM_MGMT | - IEEE80211_HW_REPORTS_TX_ACK_STATUS; + hw->flags = + IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_AMPDU_AGGREGATION | + IEEE80211_HW_NEED_DTIM_PERIOD | IEEE80211_HW_SPECTRUM_MGMT | + IEEE80211_HW_REPORTS_TX_ACK_STATUS; if (il->cfg->sku & IL_SKU_N) - hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | - IEEE80211_HW_SUPPORTS_STATIC_SMPS; + hw->flags |= + IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | + IEEE80211_HW_SUPPORTS_STATIC_SMPS; hw->sta_data_size = sizeof(struct il_station_priv); hw->vif_data_size = sizeof(struct il_vif_priv); @@ -5518,8 +5479,8 @@ static int il4965_mac_setup_register(struct il_priv *il, hw->wiphy->interface_modes |= il->ctx.interface_modes; hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS; + hw->wiphy->flags |= + WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS; /* * For now, disable PS by default because it affects @@ -5538,10 +5499,10 @@ static int il4965_mac_setup_register(struct il_priv *il, if (il->bands[IEEE80211_BAND_2GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; + &il->bands[IEEE80211_BAND_2GHZ]; if (il->bands[IEEE80211_BAND_5GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; + &il->bands[IEEE80211_BAND_5GHZ]; il_leds_init(il); @@ -5555,8 +5516,8 @@ static int il4965_mac_setup_register(struct il_priv *il, return 0; } - -int il4965_mac_start(struct ieee80211_hw *hw) +int +il4965_mac_start(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; int ret; @@ -5579,8 +5540,8 @@ int il4965_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(S_READY, &il->status), - UCODE_READY_TIMEOUT); + test_bit(S_READY, &il->status), + UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(S_READY, &il->status)) { IL_ERR("START_ALIVE timeout after %dms.\n", @@ -5597,7 +5558,8 @@ out: return 0; } -void il4965_mac_stop(struct ieee80211_hw *hw) +void +il4965_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; @@ -5620,14 +5582,15 @@ void il4965_mac_stop(struct ieee80211_hw *hw) D_MAC80211("leave\n"); } -void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +void +il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; D_MACDUMP("enter\n"); D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il4965_tx_skb(il, skb)) dev_kfree_skb_any(skb); @@ -5635,26 +5598,26 @@ void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) D_MACDUMP("leave\n"); } -void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key) +void +il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 * phase1key) { struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; D_MAC80211("enter\n"); - il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, - iv32, phase1key); + il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, iv32, + phase1key); D_MAC80211("leave\n"); } -int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) +int +il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) { struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; @@ -5684,23 +5647,23 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, * In legacy wep mode, we use another host command to the uCode. */ if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) && - !sta) { + key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { if (cmd == SET_KEY) is_default_wep_key = !ctx->key_mapping_keys; else is_default_wep_key = - (key->hw_key_idx == HW_KEY_DEFAULT); + (key->hw_key_idx == HW_KEY_DEFAULT); } switch (cmd) { case SET_KEY: if (is_default_wep_key) - ret = il4965_set_default_wep_key(il, - vif_priv->ctx, key); + ret = + il4965_set_default_wep_key(il, vif_priv->ctx, key); else - ret = il4965_set_dynamic_key(il, vif_priv->ctx, - key, sta_id); + ret = + il4965_set_dynamic_key(il, vif_priv->ctx, key, + sta_id); D_MAC80211("enable hwcrypto key\n"); break; @@ -5708,8 +5671,7 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, if (is_default_wep_key) ret = il4965_remove_default_wep_key(il, ctx, key); else - ret = il4965_remove_dynamic_key(il, ctx, - key, sta_id); + ret = il4965_remove_dynamic_key(il, ctx, key, sta_id); D_MAC80211("disable hwcrypto key\n"); break; @@ -5723,17 +5685,16 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return ret; } -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size) +int +il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 * ssn, + u8 buf_size) { struct il_priv *il = hw->priv; int ret = -EINVAL; - D_HT("A-MPDU action on addr %pM tid %d\n", - sta->addr, tid); + D_HT("A-MPDU action on addr %pM tid %d\n", sta->addr, tid); if (!(il->cfg->sku & IL_SKU_N)) return -EACCES; @@ -5770,9 +5731,9 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, return ret; } -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +int +il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct il_priv *il = hw->priv; struct il_station_priv *sta_priv = (void *)sta->drv_priv; @@ -5781,20 +5742,18 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, int ret; u8 sta_id; - D_INFO("received request to add station %pM\n", - sta->addr); + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; atomic_set(&sta_priv->pending_frames, 0); - ret = il_add_station_common(il, vif_priv->ctx, sta->addr, - is_ap, sta, &sta_id); + ret = + il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta, + &sta_id); if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); return ret; @@ -5803,16 +5762,16 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il4965_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); return 0; } -void il4965_mac_channel_switch(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch) +void +il4965_mac_channel_switch(struct ieee80211_hw *hw, + struct ieee80211_channel_switch *ch_switch) { struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; @@ -5860,15 +5819,15 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, if (ctx->ht.enabled) { if (conf_is_ht40_minus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; + IEEE80211_HT_PARAM_CHA_SEC_BELOW; ctx->ht.is_40mhz = true; } else if (conf_is_ht40_plus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; ctx->ht.is_40mhz = true; } else { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; + IEEE80211_HT_PARAM_CHA_SEC_NONE; ctx->ht.is_40mhz = false; } } else @@ -5901,10 +5860,9 @@ out: D_MAC80211("leave\n"); } -void il4965_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) +void +il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, + unsigned int *total_flags, u64 multicast) { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; @@ -5916,8 +5874,8 @@ void il4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, + *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ @@ -5944,8 +5902,9 @@ void il4965_configure_filter(struct ieee80211_hw *hw, * since we currently do not support programming multicast * filters into the device. */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; + *total_flags &= + FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; } /***************************************************************************** @@ -5954,10 +5913,11 @@ void il4965_configure_filter(struct ieee80211_hw *hw, * *****************************************************************************/ -static void il4965_bg_txpower_work(struct work_struct *work) +static void +il4965_bg_txpower_work(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, - txpower_work); + txpower_work); mutex_lock(&il->mutex); @@ -5981,7 +5941,8 @@ out: mutex_unlock(&il->mutex); } -static void il4965_setup_deferred_work(struct il_priv *il) +static void +il4965_setup_deferred_work(struct il_priv *il) { il->workqueue = create_singlethread_workqueue(DRV_NAME); @@ -6005,11 +5966,13 @@ static void il4965_setup_deferred_work(struct il_priv *il) il->watchdog.data = (unsigned long)il; il->watchdog.function = il_bg_watchdog; - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il4965_irq_tasklet, (unsigned long)il); + tasklet_init(&il->irq_tasklet, + (void (*)(unsigned long))il4965_irq_tasklet, + (unsigned long)il); } -static void il4965_cancel_deferred_work(struct il_priv *il) +static void +il4965_cancel_deferred_work(struct il_priv *il) { cancel_work_sync(&il->txpower_work); cancel_delayed_work_sync(&il->init_alive_start); @@ -6021,14 +5984,14 @@ static void il4965_cancel_deferred_work(struct il_priv *il) del_timer_sync(&il->stats_periodic); } -static void il4965_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) +static void +il4965_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { @@ -6036,24 +5999,25 @@ static void il4965_init_hw_rates(struct il_priv *il, * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (il_rates[i].plcp == RATE_1M_PLCP) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; + (il_rates[i].plcp == + RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } } + /* * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) +void +il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) { - il_wr(il, HBUS_TARG_WRPTR, - (idx & 0xff) | (txq_id << 8)); + il_wr(il, HBUS_TARG_WRPTR, (idx & 0xff) | (txq_id << 8)); il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); } -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry) +void +il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry) { int txq_id = txq->q.id; @@ -6062,21 +6026,22 @@ void il4965_tx_queue_set_status(struct il_priv *il, /* Set up and activate */ il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | - (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | - IL49_SCD_QUEUE_STTS_REG_MSK); + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id + << + IL49_SCD_QUEUE_STTS_REG_POS_TXF) + | (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | (scd_retry + << + IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) + | IL49_SCD_QUEUE_STTS_REG_MSK); txq->sched_retry = scd_retry; - D_INFO("%s %s Queue %d on AC %d\n", - active ? "Activate" : "Deactivate", - scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); + D_INFO("%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", + scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } - -static int il4965_init_drv(struct il_priv *il) +static int +il4965_init_drv(struct il_priv *il) { int ret; @@ -6100,8 +6065,7 @@ static int il4965_init_drv(struct il_priv *il) /* Choose which receivers/antennas to use */ if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, - &il->ctx); + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); il_init_scan_params(il); @@ -6126,7 +6090,8 @@ err: return ret; } -static void il4965_uninit_drv(struct il_priv *il) +static void +il4965_uninit_drv(struct il_priv *il) { il4965_calib_free_results(il); il_free_geos(il); @@ -6134,7 +6099,8 @@ static void il4965_uninit_drv(struct il_priv *il) kfree(il->scan_cmd); } -static void il4965_hw_detect(struct il_priv *il) +static void +il4965_hw_detect(struct il_priv *il) { il->hw_rev = _il_rd(il, CSR_HW_REV); il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); @@ -6142,7 +6108,8 @@ static void il4965_hw_detect(struct il_priv *il) D_INFO("HW Revision ID = 0x%X\n", il->rev_id); } -static int il4965_set_hw_params(struct il_priv *il) +static int +il4965_set_hw_params(struct il_priv *il) { il->hw_params.max_rxq_size = RX_QUEUE_SIZE; il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; @@ -6205,10 +6172,8 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; il->ctx.ac_to_queue = il4965_bss_ac_to_queue; - il->ctx.exclusive_interface_modes = - BIT(NL80211_IFTYPE_ADHOC); - il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION); + il->ctx.exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); + il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION); il->ctx.ap_devtype = RXON_DEV_TYPE_AP; il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; il->ctx.station_devtype = RXON_DEV_TYPE_ESS; @@ -6227,8 +6192,9 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /************************** * 2. Initializing PCI bus **************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); + pci_disable_link_state(pdev, + PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); if (pci_enable_device(pdev)) { err = -ENODEV; @@ -6243,8 +6209,8 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) { err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (!err) - err = pci_set_consistent_dma_mask(pdev, - DMA_BIT_MASK(32)); + err = + pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { IL_WARN("No suitable DMA available.\n"); @@ -6258,7 +6224,6 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, il); - /*********************** * 3. Read REV register ***********************/ @@ -6269,7 +6234,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); + (unsigned long long)pci_resource_len(pdev, 0)); D_INFO("pci_resource_base = %p\n", il->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access @@ -6286,8 +6251,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); il4965_hw_detect(il); - IL_INFO("Detected %s, REV=0x%X\n", - il->cfg->name, il->hw_rev); + IL_INFO("Detected %s, REV=0x%X\n", il->cfg->name, il->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -6347,8 +6311,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_enable_msi(il->pci_dev); - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); + err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; @@ -6371,14 +6334,13 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il_enable_rfkill_int(il); /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(S_RF_KILL_HW, &il->status); else set_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); il_power_initialize(il); @@ -6390,30 +6352,31 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; - out_destroy_workqueue: +out_destroy_workqueue: destroy_workqueue(il->workqueue); il->workqueue = NULL; free_irq(il->pci_dev->irq, il); - out_disable_msi: +out_disable_msi: pci_disable_msi(il->pci_dev); il4965_uninit_drv(il); - out_free_eeprom: +out_free_eeprom: il_eeprom_free(il); - out_iounmap: +out_iounmap: pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: +out_pci_release_regions: pci_set_drvdata(pdev, NULL); pci_release_regions(pdev); - out_pci_disable_device: +out_pci_disable_device: pci_disable_device(pdev); - out_ieee80211_free_hw: +out_ieee80211_free_hw: il_free_traffic_mem(il); ieee80211_free_hw(il->hw); - out: +out: return err; } -static void __devexit il4965_pci_remove(struct pci_dev *pdev) +static void __devexit +il4965_pci_remove(struct pci_dev *pdev) { struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; @@ -6469,7 +6432,6 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) il_eeprom_free(il); - /*netif_stop_queue(dev); */ flush_workqueue(il->workqueue); @@ -6498,7 +6460,8 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask * must be called under il->lock and mac access */ -void il4965_txq_set_sched(struct il_priv *il, u32 mask) +void +il4965_txq_set_sched(struct il_priv *il, u32 mask) { il_wr_prph(il, IL49_SCD_TXFACT, mask); } @@ -6525,7 +6488,8 @@ static struct pci_driver il4965_driver = { .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init il4965_init(void) +static int __init +il4965_init(void) { int ret; @@ -6551,7 +6515,8 @@ error_register: return ret; } -static void __exit il4965_exit(void) +static void __exit +il4965_exit(void) { pci_unregister_driver(&il4965_driver); il4965_rate_control_unregister(); @@ -6571,8 +6536,8 @@ module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); MODULE_PARM_DESC(queues_num, "number of hw queues."); module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); -module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, - int, S_IRUGO); +module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, int, + S_IRUGO); MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index f9db9df..3ea2361 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -95,22 +95,23 @@ static const u8 ant_toggle_lookup[] = { * */ const struct il_rate_info il_rates[RATE_COUNT] = { - IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ - IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ + IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV), /* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV), /* 60mbps */ }; -static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) +static int +il4965_hwrate_to_plcp_idx(u32 rate_n_flags) { int idx = 0; @@ -122,13 +123,13 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) idx = idx - RATE_MIMO2_6M_PLCP; idx += IL_FIRST_OFDM_RATE; - /* skip 9M not supported in ht*/ + /* skip 9M not supported in ht */ if (idx >= RATE_9M_IDX) idx += 1; if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; - /* legacy rate format, search for match in table */ + /* legacy rate format, search for match in table */ } else { for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) @@ -139,21 +140,22 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) } static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta); + struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta); static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 rate_n_flags); + struct il_lq_sta *lq_sta, u32 rate_n_flags); static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, - bool force_search); + bool force_search); #ifdef CONFIG_MAC80211_DEBUGFS static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx); + u32 * rate_n_flags, int idx); #else -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) -{} +static void +il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) +{ +} #endif /** @@ -172,55 +174,56 @@ static s32 expected_tpt_legacy[RATE_COUNT] = { }; static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ - {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ - {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ - {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ + {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ + {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ + {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ + {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ }; static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ - {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ - {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ - {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ + {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ + {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ + {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ + {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ }; static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ - {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ - {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ - {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ + {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ + {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ + {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ + {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI */ }; static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ - {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ - {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ - {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ + {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ + {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ + {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ + {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ }; /* mbps, mcs */ static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { - { "1", "BPSK DSSS"}, - { "2", "QPSK DSSS"}, + {"1", "BPSK DSSS"}, + {"2", "QPSK DSSS"}, {"5.5", "BPSK CCK"}, - { "11", "QPSK CCK"}, - { "6", "BPSK 1/2"}, - { "9", "BPSK 1/2"}, - { "12", "QPSK 1/2"}, - { "18", "QPSK 3/4"}, - { "24", "16QAM 1/2"}, - { "36", "16QAM 3/4"}, - { "48", "64QAM 2/3"}, - { "54", "64QAM 3/4"}, - { "60", "64QAM 5/6"}, + {"11", "QPSK CCK"}, + {"6", "BPSK 1/2"}, + {"9", "BPSK 1/2"}, + {"12", "QPSK 1/2"}, + {"18", "QPSK 3/4"}, + {"24", "16QAM 1/2"}, + {"36", "16QAM 3/4"}, + {"48", "64QAM 2/3"}, + {"54", "64QAM 3/4"}, + {"60", "64QAM 5/6"}, }; #define MCS_IDX_PER_STREAM (8) -static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) +static inline u8 +il4965_rs_extract_rate(u32 rate_n_flags) { - return (u8)(rate_n_flags & 0xFF); + return (u8) (rate_n_flags & 0xFF); } static void @@ -234,7 +237,8 @@ il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) win->stamp = 0; } -static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) +static inline u8 +il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) { return (ant_type & valid_antenna) == ant_type; } @@ -264,8 +268,8 @@ il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) * increment traffic load value for tid and also remove * any old values if passed the certain time period */ -static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, - struct ieee80211_hdr *hdr) +static u8 +il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, struct ieee80211_hdr *hdr) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; @@ -317,7 +321,8 @@ static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, /* get the traffic load value for tid */ -static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) +static u32 +il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; @@ -345,9 +350,9 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) return tl->total; } -static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, - struct il_lq_sta *lq_data, u8 tid, - struct ieee80211_sta *sta) +static int +il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, struct il_lq_sta *lq_data, + u8 tid, struct ieee80211_sta *sta) { int ret = -EAGAIN; u32 load; @@ -355,8 +360,7 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, load = il4965_rs_tl_get_load(lq_data, tid); if (load > IL_AGG_LOAD_THRESHOLD) { - D_HT("Starting Tx agg: STA: %pM tid: %d\n", - sta->addr, tid); + D_HT("Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { /* @@ -364,33 +368,33 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, * this might be cause by reloading firmware * stop the tx ba session here */ - IL_ERR("Fail start Tx agg on tid: %d\n", - tid); + IL_ERR("Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { IL_ERR("Aggregation not enabled for tid %d " - "because load = %u\n", tid, load); + "because load = %u\n", tid, load); } return ret; } -static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, - struct il_lq_sta *lq_data, - struct ieee80211_sta *sta) +static void +il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, struct il_lq_sta *lq_data, + struct ieee80211_sta *sta) { if (tid < TID_MAX_LOAD_COUNT) il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); else - IL_ERR("tid exceeds max load count: %d/%d\n", - tid, TID_MAX_LOAD_COUNT); + IL_ERR("tid exceeds max load count: %d/%d\n", tid, + TID_MAX_LOAD_COUNT); } -static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) +static inline int +il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) { return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_C_MSK); + !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + + !!(rate_n_flags & RATE_MCS_ANT_C_MSK); } /* @@ -412,11 +416,12 @@ il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) * at this rate. win->data contains the bitmask of successful * packets. */ -static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, - int scale_idx, int attempts, int successes) +static int +il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_idx, + int attempts, int successes) { struct il_rate_scale_data *win = NULL; - static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); + static const u64 mask = (((u64) 1) << (RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; if (scale_idx < 0 || scale_idx >= RATE_COUNT) @@ -466,8 +471,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, /* Calculate current success ratio, avoid divide-by-0! */ if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; + win->success_ratio = + 128 * (100 * win->success_counter) / win->counter; else win->success_ratio = IL_INVALID_VALUE; @@ -489,9 +494,9 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, /* * Fill uCode API rate_n_flags field, based on "search" or "active" table. */ -static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, - struct il_scale_tbl_info *tbl, - int idx, u8 use_green) +static u32 +il4965_rate_n_flags_from_tbl(struct il_priv *il, struct il_scale_tbl_info *tbl, + int idx, u8 use_green) { u32 rate_n_flags = 0; @@ -508,15 +513,15 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, rate_n_flags = RATE_MCS_HT_MSK; if (is_siso(tbl->lq_type)) - rate_n_flags |= il_rates[idx].plcp_siso; + rate_n_flags |= il_rates[idx].plcp_siso; else - rate_n_flags |= il_rates[idx].plcp_mimo2; + rate_n_flags |= il_rates[idx].plcp_mimo2; } else { IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); } - rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & - RATE_MCS_ANT_ABC_MSK); + rate_n_flags |= + ((tbl->ant_type << RATE_MCS_ANT_POS) & RATE_MCS_ANT_ABC_MSK); if (is_Ht(tbl->lq_type)) { if (tbl->is_ht40) { @@ -543,19 +548,20 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, * Interpret uCode API's rate_n_flags format, * fill "search" or "active" tx mode table. */ -static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, - enum ieee80211_band band, - struct il_scale_tbl_info *tbl, - int *rate_idx) +static int +il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, + enum ieee80211_band band, + struct il_scale_tbl_info *tbl, int *rate_idx) { u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); - u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); + u8 il4965_num_of_ant = + il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); u8 mcs; memset(tbl, 0, sizeof(struct il_scale_tbl_info)); *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - if (*rate_idx == RATE_INVALID) { + if (*rate_idx == RATE_INVALID) { *rate_idx = -1; return -EINVAL; } @@ -574,7 +580,7 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, else tbl->lq_type = LQ_G; } - /* HT rate format */ + /* HT rate format */ } else { if (rate_n_flags & RATE_MCS_SGI_MSK) tbl->is_SGI = 1; @@ -591,8 +597,8 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* SISO */ if (mcs <= RATE_SISO_60M_PLCP) { if (il4965_num_of_ant == 1) - tbl->lq_type = LQ_SISO; /*else NONE*/ - /* MIMO2 */ + tbl->lq_type = LQ_SISO; /*else NONE */ + /* MIMO2 */ } else { if (il4965_num_of_ant == 2) tbl->lq_type = LQ_MIMO2; @@ -603,8 +609,9 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* switch to another antenna/antennas and return 1 */ /* if no other valid antenna found, return 0 */ -static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, - struct il_scale_tbl_info *tbl) +static int +il4965_rs_toggle_antenna(u32 valid_ant, u32 * rate_n_flags, + struct il_scale_tbl_info *tbl) { u8 new_ant_type; @@ -633,13 +640,14 @@ static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, * Green-field mode is valid if the station supports it and * there are no non-GF stations present in the BSS. */ -static bool il4965_rs_use_green(struct ieee80211_sta *sta) +static bool +il4965_rs_use_green(struct ieee80211_sta *sta) { struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && - !(ctx->ht.non_gf_sta_present); + !(ctx->ht.non_gf_sta_present); } /** @@ -649,9 +657,10 @@ static bool il4965_rs_use_green(struct ieee80211_sta *sta) * basic available rates. * */ -static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, - struct ieee80211_hdr *hdr, - enum il_table_type rate_type) +static u16 +il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, + struct ieee80211_hdr *hdr, + enum il_table_type rate_type) { if (is_legacy(rate_type)) { return lq_sta->active_legacy_rate; @@ -665,7 +674,7 @@ static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, static u16 il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, - int rate_type) + int rate_type) { u8 high = RATE_INVALID; u8 low = RATE_INVALID; @@ -720,9 +729,10 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, return (high << 8) | low; } -static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - u8 scale_idx, u8 ht_possible) +static u32 +il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, u8 scale_idx, + u8 ht_possible) { s32 low; u16 rate_mask; @@ -744,7 +754,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, if (il4965_num_of_ant(tbl->ant_type) > 1) tbl->ant_type = - il4965_first_antenna(il->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); tbl->is_ht40 = 0; tbl->is_SGI = 0; @@ -757,10 +767,11 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, if (is_legacy(tbl->lq_type)) { /* supp_rates has no CCK bits in A mode */ if (lq_sta->band == IEEE80211_BAND_5GHZ) - rate_mask = (u16)(rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + rate_mask = + (u16) (rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else - rate_mask = (u16)(rate_mask & lq_sta->supp_rates); + rate_mask = (u16) (rate_mask & lq_sta->supp_rates); } /* If we switched from HT to legacy, check current rate */ @@ -769,8 +780,8 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, goto out; } - high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, - scale_idx, rate_mask, + high_low = + il4965_rs_get_adjacent_rate(lq_sta->drv, scale_idx, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -784,8 +795,9 @@ out: /* * Simple function to compare two rate scale table types */ -static bool il4965_table_type_matches(struct il_scale_tbl_info *a, - struct il_scale_tbl_info *b) +static bool +il4965_table_type_matches(struct il_scale_tbl_info *a, + struct il_scale_tbl_info *b) { return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && a->is_SGI == b->is_SGI); @@ -796,8 +808,8 @@ static bool il4965_table_type_matches(struct il_scale_tbl_info *a, */ static void il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) { int legacy_success; int retries; @@ -814,8 +826,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - D_RATE( - "get frame ack response, update rate scale win\n"); + D_RATE("get frame ack response, update rate scale win\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { @@ -845,8 +856,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, */ table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, - il->band, &tbl_type, &rs_idx); + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, &rs_idx); if (il->band == IEEE80211_BAND_5GHZ) rs_idx -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; @@ -869,12 +879,11 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || tbl_type.ant_type != info->antenna_sel_tx || - !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || - !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || - rs_idx != mac_idx) { - D_RATE( - "initial rate %d does not match %d (0x%x)\n", - mac_idx, rs_idx, tx_rate); + !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) + || !!(tx_rate & RATE_MCS_GF_MSK) != + !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || rs_idx != mac_idx) { + D_RATE("initial rate %d does not match %d (0x%x)\n", mac_idx, + rs_idx, tx_rate); /* * Since rates mis-match, the last LQ command may have failed. * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with @@ -883,8 +892,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter++; if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { lq_sta->missed_rate_counter = 0; - il_send_lq_cmd(il, ctx, &lq_sta->lq, - CMD_ASYNC, false); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } /* Regardless, ignore this status info for outdated rate */ return; @@ -893,25 +901,25 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter = 0; /* Figure out if rate scale algorithm is in active or search table */ - if (il4965_table_type_matches(&tbl_type, - &(lq_sta->lq_info[lq_sta->active_tbl]))) { + if (il4965_table_type_matches + (&tbl_type, &(lq_sta->lq_info[lq_sta->active_tbl]))) { curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - } else if (il4965_table_type_matches(&tbl_type, - &lq_sta->lq_info[1 - lq_sta->active_tbl])) { + } else + if (il4965_table_type_matches + (&tbl_type, &lq_sta->lq_info[1 - lq_sta->active_tbl])) { curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - D_RATE( - "Neither active nor search matches tx rate\n"); + D_RATE("Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - D_RATE("active- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); + D_RATE("active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, + tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - D_RATE("search- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", - tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); + D_RATE("search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, + tmp_tbl->ant_type, tmp_tbl->is_SGI); + D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, + tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection * and continue to perform rate scale to find the rate table @@ -930,21 +938,22 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, - &rs_idx); + &rs_idx); il4965_rs_collect_tx_data(curr_tbl, rs_idx, - info->status.ampdu_len, - info->status.ampdu_ack_len); + info->status.ampdu_len, + info->status.ampdu_ack_len); /* Update success/fail counts if not searching for new mode */ if (lq_sta->stay_in_tbl) { lq_sta->total_success += info->status.ampdu_ack_len; - lq_sta->total_failed += (info->status.ampdu_len - - info->status.ampdu_ack_len); + lq_sta->total_failed += + (info->status.ampdu_len - + info->status.ampdu_ack_len); } } else { - /* - * For legacy, update frame history with for each Tx retry. - */ + /* + * For legacy, update frame history with for each Tx retry. + */ retries = info->status.rates[0].count - 1; /* HW doesn't send more than 15 retries */ retries = min(retries, 15); @@ -955,20 +964,21 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, - &tbl_type, &rs_idx); + &tbl_type, &rs_idx); /* * Only collect stats if retried rate is in the same RS * table as active/search. */ if (il4965_table_type_matches(&tbl_type, curr_tbl)) tmp_tbl = curr_tbl; - else if (il4965_table_type_matches(&tbl_type, - other_tbl)) + else if (il4965_table_type_matches + (&tbl_type, other_tbl)) tmp_tbl = other_tbl; else continue; il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, - i < retries ? 0 : legacy_success); + i < + retries ? 0 : legacy_success); } /* Update success/fail counts if not searching for new mode */ @@ -993,8 +1003,9 @@ done: * These control how long we stay using same modulation mode before * searching for a new mode. */ -static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, - struct il_lq_sta *lq_sta) +static void +il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, + struct il_lq_sta *lq_sta) { D_RATE("we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ @@ -1017,11 +1028,12 @@ static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, /* * Find correct throughput table for given mode of modulation */ -static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl) +static void +il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl) { /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[RATE_COUNT]; + s32(*ht_tbl_pointer)[RATE_COUNT]; /* Check for invalid LQ type */ if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { @@ -1044,16 +1056,16 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, ht_tbl_pointer = expected_tpt_siso40MHz; else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) ht_tbl_pointer = expected_tpt_mimo2_20MHz; - else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ + else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ ht_tbl_pointer = expected_tpt_mimo2_40MHz; - if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ + if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ tbl->expected_tpt = ht_tbl_pointer[0]; else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ tbl->expected_tpt = ht_tbl_pointer[1]; else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ tbl->expected_tpt = ht_tbl_pointer[2]; - else /* AGG+SGI */ + else /* AGG+SGI */ tbl->expected_tpt = ht_tbl_pointer[3]; } @@ -1069,10 +1081,9 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, * to decrease to match "active" throughput. When moving from MIMO to SISO, * bit rate will typically need to increase, but not if performance was bad. */ -static s32 il4965_rs_get_best_rate(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, /* "search" */ - u16 rate_mask, s8 idx) +static s32 +il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ + u16 rate_mask, s8 idx) { /* "active" values */ struct il_scale_tbl_info *active_tbl = @@ -1089,8 +1100,9 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, new_rate = high = low = start_hi = RATE_INVALID; - for (; ;) { - high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, + for (;;) { + high_low = + il4965_rs_get_adjacent_rate(il, rate, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -1112,9 +1124,8 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, * "active" throughput (under perfect conditions). */ if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && - (active_sr > RATE_DECREASE_TH && - active_sr <= RATE_HIGH_TH && - tpt_tbl[rate] <= active_tpt)) || + (active_sr > RATE_DECREASE_TH && active_sr <= RATE_HIGH_TH + && tpt_tbl[rate] <= active_tpt)) || (active_sr >= RATE_SCALE_SWITCH && tpt_tbl[rate] > active_tpt)) { @@ -1136,7 +1147,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, else break; - /* Else try to raise the "search" rate to match "active" */ + /* Else try to raise the "search" rate to match "active" */ } else { /* (2nd or later pass) * If we've already tried to lower the rate, and are @@ -1149,7 +1160,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, start_hi = high; rate = high; - /* Higher rate not available, use the original */ + /* Higher rate not available, use the original */ } else { new_rate = rate; break; @@ -1163,11 +1174,11 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, /* * Set up search table for MIMO2 */ -static int il4965_rs_switch_to_mimo2(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) +static int +il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; s32 rate; @@ -1178,8 +1189,8 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) - == WLAN_HT_CAP_SM_PS_STATIC) + if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) == + WLAN_HT_CAP_SM_PS_STATIC) return -1; /* Need both Tx chains/antennas to support MIMO */ @@ -1203,30 +1214,27 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); - D_RATE("LQ: MIMO2 best rate %d mask %X\n", - rate, rate_mask); + D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "Can't switch with idx %d rate mask %x\n", - rate, rate_mask); + D_RATE("Can't switch with idx %d rate mask %x\n", rate, + rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); + tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, + is_green); return 0; } /* * Set up search table for SISO */ -static int il4965_rs_switch_to_siso(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) +static int +il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; u8 is_green = lq_sta->is_green; @@ -1251,40 +1259,39 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, tbl->is_ht40 = 0; if (is_green) - tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ + tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield */ il4965_rs_set_expected_tpt_table(lq_sta, tbl); rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "can not switch with idx %d rate mask %x\n", - rate, rate_mask); + D_RATE("can not switch with idx %d rate mask %x\n", rate, + rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); + tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, + is_green); return 0; } /* * Try to switch to new modulation mode from legacy */ -static int il4965_rs_move_legacy_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - int idx) +static int +il4965_rs_move_legacy_other(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) { struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[idx]); - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u32 sz = + (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1294,7 +1301,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, tbl->action = IL_LEGACY_SWITCH_SISO; start_action = tbl->action; - for (; ;) { + for (;;) { lq_sta->action_counter++; switch (tbl->action) { case IL_LEGACY_SWITCH_ANTENNA1: @@ -1302,9 +1309,9 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, D_RATE("LQ: Legacy toggle Antenna\n"); if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || + tx_chains_num <= 1) || (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) + tx_chains_num <= 2)) break; /* Don't change antenna if success has been great */ @@ -1314,11 +1321,12 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, /* Set up search table to try other antenna */ memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { + if (il4965_rs_toggle_antenna + (valid_tx_ant, &search_tbl->current_rate, + search_tbl)) { update_search_tbl_counter = 1; il4965_rs_set_expected_tpt_table(lq_sta, - search_tbl); + search_tbl); goto out; } break; @@ -1328,8 +1336,9 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_siso(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1352,13 +1361,13 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, else search_tbl->ant_type = ANT_BC; - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) + if (!il4965_rs_is_valid_ant + (valid_tx_ant, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1390,19 +1399,20 @@ out: /* * Try to switch to new modulation mode from SISO */ -static int il4965_rs_move_siso_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) +static int +il4965_rs_move_siso_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) { u8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u32 sz = + (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1418,17 +1428,18 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, case IL_SISO_SWITCH_ANTENNA2: D_RATE("LQ: SISO toggle Antenna\n"); if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || + tx_chains_num <= 1) || (tbl->action == IL_SISO_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) + tx_chains_num <= 2)) break; if (win->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { + if (il4965_rs_toggle_antenna + (valid_tx_ant, &search_tbl->current_rate, + search_tbl)) { update_search_tbl_counter = 1; goto out; } @@ -1447,22 +1458,22 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, else search_tbl->ant_type = ANT_BC; - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) + if (!il4965_rs_is_valid_ant + (valid_tx_ant, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) goto out; break; case IL_SISO_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) + if (!tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) + if (tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_40)) break; D_RATE("LQ: SISO toggle SGI/NGI\n"); @@ -1472,8 +1483,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, if (!tbl->is_SGI) break; else - IL_ERR( - "SGI was set in GF+SISO\n"); + IL_ERR("SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); @@ -1483,8 +1493,8 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); + il4965_rate_n_flags_from_tbl(il, search_tbl, idx, + is_green); update_search_tbl_counter = 1; goto out; } @@ -1498,7 +1508,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, search_tbl->lq_type = LQ_NONE; return 0; - out: +out: lq_sta->search_better_tbl = 1; tbl->action++; if (tbl->action > IL_SISO_SWITCH_GI) @@ -1512,19 +1522,20 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, /* * Try to switch to new modulation mode from MIMO2 */ -static int il4965_rs_move_mimo2_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) +static int +il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) { s8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u32 sz = + (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1546,8 +1557,9 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, break; memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { + if (il4965_rs_toggle_antenna + (valid_tx_ant, &search_tbl->current_rate, + search_tbl)) { update_search_tbl_counter = 1; goto out; } @@ -1567,24 +1579,24 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, else search_tbl->ant_type = ANT_C; - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) + if (!il4965_rs_is_valid_ant + (valid_tx_ant, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_siso(il, lq_sta, - conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_siso(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) goto out; break; case IL_MIMO2_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) + if (!tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) + if (tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_40)) break; D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); @@ -1605,8 +1617,8 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); + il4965_rate_n_flags_from_tbl(il, search_tbl, idx, + is_green); update_search_tbl_counter = 1; goto out; @@ -1620,7 +1632,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, } search_tbl->lq_type = LQ_NONE; return 0; - out: +out: lq_sta->search_better_tbl = 1; tbl->action++; if (tbl->action > IL_MIMO2_SWITCH_GI) @@ -1659,9 +1671,9 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) /* Elapsed time using current modulation mode */ if (lq_sta->flush_timer) flush_interval_passed = - time_after(jiffies, - (unsigned long)(lq_sta->flush_timer + - RATE_SCALE_FLUSH_INTVL)); + time_after(jiffies, + (unsigned long)(lq_sta->flush_timer + + RATE_SCALE_FLUSH_INTVL)); /* * Check if we should allow search for new modulation mode. @@ -1677,9 +1689,8 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) (!lq_sta->search_better_tbl && lq_sta->flush_timer && flush_interval_passed)) { D_RATE("LQ: stay is expired %d %d %d\n:", - lq_sta->total_failed, - lq_sta->total_success, - flush_interval_passed); + lq_sta->total_failed, lq_sta->total_success, + flush_interval_passed); /* Allow search for new mode */ lq_sta->stay_in_tbl = 0; /* only place reset */ @@ -1687,23 +1698,23 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) lq_sta->total_success = 0; lq_sta->flush_timer = 0; - /* - * Else if we've used this modulation mode enough repetitions - * (regardless of elapsed time or success/failure), reset - * history bitmaps and rate-specific stats for all rates in - * active table. - */ + /* + * Else if we've used this modulation mode enough repetitions + * (regardless of elapsed time or success/failure), reset + * history bitmaps and rate-specific stats for all rates in + * active table. + */ } else { lq_sta->table_count++; - if (lq_sta->table_count >= - lq_sta->table_count_limit) { + if (lq_sta->table_count >= lq_sta->table_count_limit) { lq_sta->table_count = 0; - D_RATE( - "LQ: stay in table clear win\n"); + D_RATE("LQ: stay in table clear win\n"); for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); + il4965_rs_rate_scale_clear_win(& + (tbl-> + win + [i])); } } @@ -1712,8 +1723,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * "search" table). */ if (!lq_sta->stay_in_tbl) { for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); + il4965_rs_rate_scale_clear_win(&(tbl->win[i])); } } } @@ -1722,11 +1732,10 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * setup rate table in uCode * return rate_n_flags as used in the table */ -static u32 il4965_rs_update_rate_tbl(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - int idx, u8 is_green) +static u32 +il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, int idx, u8 is_green) { u32 rate; @@ -1741,10 +1750,10 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *il, /* * Do rate scaling and search for new modulation mode. */ -static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) +static void +il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta) { struct ieee80211_hw *hw = il->hw; struct ieee80211_conf *conf = &hw->conf; @@ -1818,8 +1827,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* current tx rate */ idx = lq_sta->last_txrate_idx; - D_RATE("Rate scale idx %d for type %d\n", idx, - tbl->lq_type); + D_RATE("Rate scale idx %d for type %d\n", idx, tbl->lq_type); /* rates available for this association, and for modulation mode */ rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); @@ -1830,11 +1838,12 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (is_legacy(tbl->lq_type)) { if (lq_sta->band == IEEE80211_BAND_5GHZ) /* supp_rates has no CCK bits in A mode */ - rate_scale_idx_msk = (u16) (rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + rate_scale_idx_msk = + (u16) (rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else - rate_scale_idx_msk = (u16) (rate_mask & - lq_sta->supp_rates); + rate_scale_idx_msk = + (u16) (rate_mask & lq_sta->supp_rates); } else rate_scale_idx_msk = rate_mask; @@ -1845,14 +1854,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (!((1 << idx) & rate_scale_idx_msk)) { IL_ERR("Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { - /* revert to active table if search table is not valid*/ + /* revert to active table if search table is not valid */ tbl->lq_type = LQ_NONE; lq_sta->search_better_tbl = 0; tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); + rate = + il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, + is_green); } return; } @@ -1864,8 +1874,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* force user max rate if set by user */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < idx) { + if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < idx) { idx = lq_sta->max_rate_idx; update_lq = 1; win = &(tbl->win[idx]); @@ -1884,9 +1893,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, fail_count = win->counter - win->success_counter; if (fail_count < RATE_MIN_FAILURE_TH && win->success_counter < RATE_MIN_SUCCESS_TH) { - D_RATE("LQ: still below TH. succ=%d total=%d " - "for idx %d\n", - win->success_counter, win->counter, idx); + D_RATE("LQ: still below TH. succ=%d total=%d " "for idx %d\n", + win->success_counter, win->counter, idx); /* Can't calculate this yet; not enough history */ win->average_tpt = IL_INVALID_VALUE; @@ -1899,12 +1907,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* Else we have enough samples; calculate estimate of * actual average throughput */ - if (win->average_tpt != ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128)) { - IL_ERR( - "expected_tpt should have been calculated by now\n"); - win->average_tpt = ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128); + if (win->average_tpt != + ((win->success_ratio * tbl->expected_tpt[idx] + 64) / 128)) { + IL_ERR("expected_tpt should have been calculated by now\n"); + win->average_tpt = + ((win->success_ratio * tbl->expected_tpt[idx] + 64) / 128); } /* If we are searching for better modulation mode, check success. */ @@ -1915,10 +1922,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (win->average_tpt > lq_sta->last_tpt) { D_RATE("LQ: SWITCHING TO NEW TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, win->average_tpt, + lq_sta->last_tpt); if (!is_legacy(tbl->lq_type)) lq_sta->enable_counter = 1; @@ -1927,14 +1933,13 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->active_tbl = active_tbl; current_tpt = win->average_tpt; - /* Else poor success; go back to mode in "active" table */ + /* Else poor success; go back to mode in "active" table */ } else { D_RATE("LQ: GOING BACK TO THE OLD TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, win->average_tpt, + lq_sta->last_tpt); /* Nullify "search" table */ tbl->lq_type = LQ_NONE; @@ -1960,15 +1965,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(il, idx, - rate_scale_idx_msk, + high_low = + il4965_rs_get_adjacent_rate(il, idx, rate_scale_idx_msk, tbl->lq_type); low = high_low & 0xff; high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < high) + if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < high) high = RATE_INVALID; sr = win->success_ratio; @@ -1984,13 +1988,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Too many failures, decrease rate */ if (sr <= RATE_DECREASE_TH || current_tpt == 0) { - D_RATE( - "decrease rate because of low success_ratio\n"); + D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; - /* No throughput measured yet for adjacent rates; try increase. */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { + /* No throughput measured yet for adjacent rates; try increase. */ + } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) scale_action = 1; @@ -2010,19 +2012,17 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Higher adjacent rate's throughput is measured */ if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ - if (high_tpt > current_tpt && - sr >= RATE_INCREASE_TH) { + if (high_tpt > current_tpt && sr >= RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; } - /* Lower adjacent rate's throughput is measured */ + /* Lower adjacent rate's throughput is measured */ } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); + D_RATE("decrease rate because of low tpt\n"); scale_action = -1; } else if (sr >= RATE_INCREASE_TH) { scale_action = 1; @@ -2059,19 +2059,19 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; } - D_RATE("choose rate scale idx %d action %d low %d " - "high %d type %d\n", - idx, scale_action, low, high, tbl->lq_type); + D_RATE("choose rate scale idx %d action %d low %d " "high %d type %d\n", + idx, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); + rate = + il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, + is_green); /* Should we stay with this modulation mode, * or search for a new one? */ - il4965_rs_stay_in_table(lq_sta, false); + il4965_rs_stay_in_table(lq_sta, false); /* * Search for new modulation mode if we're: @@ -2079,41 +2079,35 @@ lq_update: * 2) Not just finishing up a search * 3) Allowing a new search */ - if (!update_lq && !done_search && !lq_sta->stay_in_tbl && - win->counter) { - /* Save current throughput to compare with "search" throughput*/ + if (!update_lq && !done_search && !lq_sta->stay_in_tbl && win->counter) { + /* Save current throughput to compare with "search" throughput */ lq_sta->last_tpt = current_tpt; /* Select a new "search" modulation mode to try. * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) - il4965_rs_move_legacy_other(il, lq_sta, - conf, sta, idx); + il4965_rs_move_legacy_other(il, lq_sta, conf, sta, idx); else if (is_siso(tbl->lq_type)) - il4965_rs_move_siso_to_other(il, lq_sta, - conf, sta, idx); - else /* (is_mimo2(tbl->lq_type)) */ - il4965_rs_move_mimo2_to_other(il, lq_sta, - conf, sta, idx); + il4965_rs_move_siso_to_other(il, lq_sta, conf, sta, + idx); + else /* (is_mimo2(tbl->lq_type)) */ + il4965_rs_move_mimo2_to_other(il, lq_sta, conf, sta, + idx); /* If new "search" mode was selected, set up in uCode table */ if (lq_sta->search_better_tbl) { /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); + il4965_rs_rate_scale_clear_win(&(tbl->win[i])); /* Use new "search" start rate */ idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - D_RATE( - "Switch current mcs: %X idx: %d\n", - tbl->current_rate, idx); - il4965_rs_fill_link_cmd(il, lq_sta, - tbl->current_rate); - il_send_lq_cmd(il, ctx, - &lq_sta->lq, CMD_ASYNC, false); + D_RATE("Switch current mcs: %X idx: %d\n", + tbl->current_rate, idx); + il4965_rs_fill_link_cmd(il, lq_sta, tbl->current_rate); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } else done_search = 1; } @@ -2140,13 +2134,12 @@ lq_update: (lq_sta->tx_agg_tid_en & (1 << tid)) && tid != MAX_TID_COUNT) { tid_data = - &il->stations[lq_sta->lq.sta_id].tid[tid]; + &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { - D_RATE( - "try to aggregate tid %d\n", - tid); + D_RATE("try to aggregate tid %d\n", + tid); il4965_rs_tl_turn_on_agg(il, tid, - lq_sta, sta); + lq_sta, sta); } } il4965_rs_set_stay_in_table(il, 0, lq_sta); @@ -2154,8 +2147,8 @@ lq_update: } out: - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, - idx, is_green); + tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); i = idx; lq_sta->last_txrate_idx = i; } @@ -2174,10 +2167,9 @@ out: * calling this function (which runs C_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ -static void il4965_rs_initialize_lq(struct il_priv *il, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) +static void +il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, + struct ieee80211_sta *sta, struct il_lq_sta *lq_sta) { struct il_scale_tbl_info *tbl; int rate_idx; @@ -2230,7 +2222,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, static void il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, - struct ieee80211_tx_rate_control *txrc) + struct ieee80211_tx_rate_control *txrc) { struct sk_buff *skb = txrc->skb; @@ -2266,28 +2258,28 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, if (!lq_sta) return; - rate_idx = lq_sta->last_txrate_idx; + rate_idx = lq_sta->last_txrate_idx; if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { rate_idx -= IL_FIRST_OFDM_RATE; /* 6M and 9M shared same MCS idx */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - RATE_MIMO2_6M_PLCP) + RATE_MIMO2_6M_PLCP) rate_idx = rate_idx + MCS_IDX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_SHORT_GI; + IEEE80211_TX_RC_SHORT_GI; if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_DUP_DATA; + IEEE80211_TX_RC_DUP_DATA; if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_40_MHZ_WIDTH; + IEEE80211_TX_RC_40_MHZ_WIDTH; if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_GREEN_FIELD; + IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || @@ -2303,12 +2295,12 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, } -static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, - gfp_t gfp) +static void * +il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, gfp_t gfp) { struct il_lq_sta *lq_sta; struct il_station_priv *sta_priv = - (struct il_station_priv *) sta->drv_priv; + (struct il_station_priv *)sta->drv_priv; struct il_priv *il; il = (struct il_priv *)il_rate; @@ -2323,9 +2315,7 @@ static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, * Called after adding a new station to initialize rate scaling */ void -il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, - u8 sta_id) +il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { int i, j; struct ieee80211_hw *hw = il->hw; @@ -2335,28 +2325,26 @@ il4965_rs_rate_init(struct il_priv *il, struct il_lq_sta *lq_sta; struct ieee80211_supported_band *sband; - sta_priv = (struct il_station_priv *) sta->drv_priv; + sta_priv = (struct il_station_priv *)sta->drv_priv; lq_sta = &sta_priv->lq_sta; sband = hw->wiphy->bands[conf->channel->band]; - lq_sta->lq.sta_id = sta_id; for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); + il4965_rs_rate_scale_clear_win(&lq_sta->lq_info[j]. + win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); + il4965_rs_rate_scale_clear_win(&lq_sta->lq_info[j]. + win[i]); - D_RATE("LQ:" - "*** rate scale station global init for station %d ***\n", - sta_id); + D_RATE("LQ:" "*** rate scale station global init for station %d ***\n", + sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not * the lowest or the highest rate.. Could consider using RSSI from * previous packets? Need to have IEEE 802.1X auth succeed immediately @@ -2374,26 +2362,26 @@ il4965_rs_rate_init(struct il_priv *il, */ lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; - lq_sta->active_siso_rate &= ~((u16)0x2); + lq_sta->active_siso_rate &= ~((u16) 0x2); lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; /* Same here */ lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; - lq_sta->active_mimo2_rate &= ~((u16)0x2); + lq_sta->active_mimo2_rate &= ~((u16) 0x2); lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; /* These values will be overridden later */ lq_sta->lq.general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & ~il4965_first_antenna(il->hw_params. + valid_tx_ant); if (!lq_sta->lq.general_params.dual_stream_ant_msk) { lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } /* as default allow aggregation for all tids */ @@ -2413,8 +2401,9 @@ il4965_rs_rate_init(struct il_priv *il, il4965_rs_initialize_lq(il, conf, sta, lq_sta); } -static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 new_rate) +static void +il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, + u32 new_rate) { struct il_scale_tbl_info tbl_type; int idx = 0; @@ -2429,8 +2418,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Interpret new_rate (rate_n_flags) */ - il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, - &tbl_type, &rate_idx); + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, + &rate_idx); /* How many times should we repeat the initial rate? */ if (is_legacy(tbl_type.lq_type)) { @@ -2441,19 +2430,18 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, } lq_cmd->general_params.mimo_delimiter = - is_mimo(tbl_type.lq_type) ? 1 : 0; + is_mimo(tbl_type.lq_type) ? 1 : 0; /* Fill 1st table entry (idx 0) */ lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); if (il4965_num_of_ant(tbl_type.ant_type) == 1) { lq_cmd->general_params.single_stream_ant_msk = - tbl_type.ant_type; + tbl_type.ant_type; } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { - lq_cmd->general_params.dual_stream_ant_msk = - tbl_type.ant_type; - } /* otherwise we don't modify the existing value */ - + lq_cmd->general_params.dual_stream_ant_msk = tbl_type.ant_type; + } + /* otherwise we don't modify the existing value */ idx++; repeat_rate--; if (il) @@ -2470,7 +2458,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, ant_toggle_cnt++; else if (il && il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) + &new_rate, + &tbl_type)) ant_toggle_cnt = 1; } @@ -2479,14 +2468,13 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, /* Fill next table entry */ lq_cmd->rs_table[idx].rate_n_flags = - cpu_to_le32(new_rate); + cpu_to_le32(new_rate); repeat_rate--; idx++; } - il4965_rs_get_tbl_info_from_mcs(new_rate, - lq_sta->band, &tbl_type, - &rate_idx); + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, + &tbl_type, &rate_idx); /* Indicate to uCode which entries might be MIMO. * If initial rate was MIMO, this will finally end up @@ -2495,8 +2483,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, lq_cmd->general_params.mimo_delimiter = idx; /* Get next rate */ - new_rate = il4965_rs_get_lower_rate(lq_sta, - &tbl_type, rate_idx, + new_rate = + il4965_rs_get_lower_rate(lq_sta, &tbl_type, rate_idx, use_ht_possible); /* How many times should we repeat the next rate? */ @@ -2505,7 +2493,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, ant_toggle_cnt++; else if (il && il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) + &new_rate, &tbl_type)) ant_toggle_cnt = 1; repeat_rate = IL_NUMBER_TRY; @@ -2531,22 +2519,24 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; lq_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); } -static void -*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +static void * +il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } + /* rate scale requires free function to be implemented */ -static void il4965_rs_free(void *il_rate) +static void +il4965_rs_free(void *il_rate) { return; } -static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, - void *il_sta) +static void +il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, void *il_sta) { struct il_priv *il __maybe_unused = il_r; @@ -2554,15 +2544,16 @@ static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, D_RATE("leave\n"); } - #ifdef CONFIG_MAC80211_DEBUGFS -static int il4965_open_file_generic(struct inode *inode, struct file *file) +static int +il4965_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) + +static void +il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) { struct il_priv *il; u8 valid_tx_ant; @@ -2572,16 +2563,17 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, valid_tx_ant = il->hw_params.valid_tx_ant; if (lq_sta->dbg_fixed_rate) { ant_sel_tx = - ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) - >> RATE_MCS_ANT_POS); + ((lq_sta-> + dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) >> + RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; D_RATE("Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IL_ERR( - "Invalid antenna selection 0x%X, Valid is 0x%X\n", - ant_sel_tx, valid_tx_ant); + IL_ERR + ("Invalid antenna selection 0x%X, Valid is 0x%X\n", + ant_sel_tx, valid_tx_ant); D_RATE("Fixed rate OFF\n"); } } else { @@ -2589,8 +2581,10 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, } } -static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, - const char __user *user_buf, size_t count, loff_t *ppos) +static ssize_t +il4965_rs_sta_dbgfs_scale_table_write(struct file *file, + const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_lq_sta *lq_sta = file->private_data; struct il_priv *il; @@ -2598,12 +2592,12 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, size_t buf_size; u32 parsed_rate; struct il_station_priv *sta_priv = - container_of(lq_sta, struct il_station_priv, lq_sta); + container_of(lq_sta, struct il_station_priv, lq_sta); struct il_rxon_context *ctx = sta_priv->common.ctx; il = lq_sta->drv; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; @@ -2613,23 +2607,23 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->dbg_fixed_rate = 0; lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ - lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - D_RATE("sta_id %d rate 0x%X\n", - lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); + D_RATE("sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, + lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); - il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, - false); + il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, false); } return count; } -static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) +static ssize_t +il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { char *buff; int desc = 0; @@ -2646,64 +2640,80 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, if (!buff) return -ENOMEM; - desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); - desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", - lq_sta->total_failed, lq_sta->total_success, - lq_sta->active_legacy_rate); - desc += sprintf(buff+desc, "fixed rate 0x%X\n", - lq_sta->dbg_fixed_rate); - desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", - (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", - (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", - (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); - desc += sprintf(buff+desc, "lq type %s\n", - (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); + desc += sprintf(buff + desc, "sta_id %d\n", lq_sta->lq.sta_id); + desc += + sprintf(buff + desc, "failed=%d success=%d rate=0%X\n", + lq_sta->total_failed, lq_sta->total_success, + lq_sta->active_legacy_rate); + desc += + sprintf(buff + desc, "fixed rate 0x%X\n", lq_sta->dbg_fixed_rate); + desc += + sprintf(buff + desc, "valid_tx_ant %s%s%s\n", + (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", + (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", + (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); + desc += + sprintf(buff + desc, "lq type %s\n", + (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); if (is_Ht(tbl->lq_type)) { - desc += sprintf(buff+desc, " %s", - (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); - desc += sprintf(buff+desc, " %s", - (tbl->is_ht40) ? "40MHz" : "20MHz"); - desc += sprintf(buff+desc, " %s %s %s\n", - (tbl->is_SGI) ? "SGI" : "", - (lq_sta->is_green) ? "GF enabled" : "", - (lq_sta->is_agg) ? "AGG on" : ""); + desc += + sprintf(buff + desc, " %s", + (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); + desc += + sprintf(buff + desc, " %s", + (tbl->is_ht40) ? "40MHz" : "20MHz"); + desc += + sprintf(buff + desc, " %s %s %s\n", + (tbl->is_SGI) ? "SGI" : "", + (lq_sta->is_green) ? "GF enabled" : "", + (lq_sta->is_agg) ? "AGG on" : ""); } - desc += sprintf(buff+desc, "last tx rate=0x%X\n", - lq_sta->last_rate_n_flags); - desc += sprintf(buff+desc, "general:" - "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", - lq_sta->lq.general_params.flags, - lq_sta->lq.general_params.mimo_delimiter, - lq_sta->lq.general_params.single_stream_ant_msk, - lq_sta->lq.general_params.dual_stream_ant_msk); - - desc += sprintf(buff+desc, "agg:" - "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", - le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), - lq_sta->lq.agg_params.agg_dis_start_th, - lq_sta->lq.agg_params.agg_frame_cnt_limit); - - desc += sprintf(buff+desc, - "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", - lq_sta->lq.general_params.start_rate_idx[0], - lq_sta->lq.general_params.start_rate_idx[1], - lq_sta->lq.general_params.start_rate_idx[2], - lq_sta->lq.general_params.start_rate_idx[3]); + desc += + sprintf(buff + desc, "last tx rate=0x%X\n", + lq_sta->last_rate_n_flags); + desc += + sprintf(buff + desc, + "general:" "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", + lq_sta->lq.general_params.flags, + lq_sta->lq.general_params.mimo_delimiter, + lq_sta->lq.general_params.single_stream_ant_msk, + lq_sta->lq.general_params.dual_stream_ant_msk); + + desc += + sprintf(buff + desc, + "agg:" + "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", + le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), + lq_sta->lq.agg_params.agg_dis_start_th, + lq_sta->lq.agg_params.agg_frame_cnt_limit); + + desc += + sprintf(buff + desc, + "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", + lq_sta->lq.general_params.start_rate_idx[0], + lq_sta->lq.general_params.start_rate_idx[1], + lq_sta->lq.general_params.start_rate_idx[2], + lq_sta->lq.general_params.start_rate_idx[3]); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - idx = il4965_hwrate_to_plcp_idx( - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); + idx = + il4965_hwrate_to_plcp_idx(le32_to_cpu + (lq_sta->lq.rs_table[i]. + rate_n_flags)); if (is_legacy(tbl->lq_type)) { - desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps); + desc += + sprintf(buff + desc, " rate[%d] 0x%X %smbps\n", i, + le32_to_cpu(lq_sta->lq.rs_table[i]. + rate_n_flags), + il_rate_mcs[idx].mbps); } else { - desc += sprintf(buff+desc, - " rate[%d] 0x%X %smbps (%s)\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); + desc += + sprintf(buff + desc, " rate[%d] 0x%X %smbps (%s)\n", + i, + le32_to_cpu(lq_sta->lq.rs_table[i]. + rate_n_flags), + il_rate_mcs[idx].mbps, + il_rate_mcs[idx].mcs); } } @@ -2718,8 +2728,10 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = { .open = il4965_open_file_generic, .llseek = default_llseek, }; -static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) + +static ssize_t +il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { char *buff; int desc = 0; @@ -2733,22 +2745,22 @@ static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, return -ENOMEM; for (i = 0; i < LQ_SIZE; i++) { - desc += sprintf(buff+desc, - "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" - "rate=0x%X\n", - lq_sta->active_tbl == i ? "*" : "x", - lq_sta->lq_info[i].lq_type, - lq_sta->lq_info[i].is_SGI, - lq_sta->lq_info[i].is_ht40, - lq_sta->lq_info[i].is_dup, - lq_sta->is_green, - lq_sta->lq_info[i].current_rate); + desc += + sprintf(buff + desc, + "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" + "rate=0x%X\n", lq_sta->active_tbl == i ? "*" : "x", + lq_sta->lq_info[i].lq_type, + lq_sta->lq_info[i].is_SGI, + lq_sta->lq_info[i].is_ht40, + lq_sta->lq_info[i].is_dup, lq_sta->is_green, + lq_sta->lq_info[i].current_rate); for (j = 0; j < RATE_COUNT; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->lq_info[i].win[j].counter, - lq_sta->lq_info[i].win[j].success_counter, - lq_sta->lq_info[i].win[j].success_ratio); + desc += + sprintf(buff + desc, + "counter=%d success=%d %%=%d\n", + lq_sta->lq_info[i].win[j].counter, + lq_sta->lq_info[i].win[j].success_counter, + lq_sta->lq_info[i].win[j].success_ratio); } } ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); @@ -2762,8 +2774,10 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { .llseek = default_llseek, }; -static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) +static ssize_t +il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, + char __user * user_buf, size_t count, + loff_t * ppos) { char buff[120]; int desc = 0; @@ -2776,13 +2790,13 @@ static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, il = lq_sta->drv; if (is_Ht(tbl->lq_type)) - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - tbl->expected_tpt[lq_sta->last_txrate_idx]); + desc += + sprintf(buff + desc, "Bit Rate= %d Mb/s\n", + tbl->expected_tpt[lq_sta->last_txrate_idx]); else - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - il_rates[lq_sta->last_txrate_idx].ieee >> 1); + desc += + sprintf(buff + desc, "Bit Rate= %d Mb/s\n", + il_rates[lq_sta->last_txrate_idx].ieee >> 1); ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); return ret; @@ -2794,26 +2808,27 @@ static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { .llseek = default_llseek, }; -static void il4965_rs_add_debugfs(void *il, void *il_sta, - struct dentry *dir) +static void +il4965_rs_add_debugfs(void *il, void *il_sta, struct dentry *dir) { struct il_lq_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_scale_table_file = - debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, + debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, lq_sta, &rs_sta_dbgfs_scale_table_ops); lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); + debugfs_create_file("rate_stats_table", S_IRUSR, dir, lq_sta, + &rs_sta_dbgfs_stats_table_ops); lq_sta->rs_sta_dbgfs_rate_scale_data_file = - debugfs_create_file("rate_scale_data", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); + debugfs_create_file("rate_scale_data", S_IRUSR, dir, lq_sta, + &rs_sta_dbgfs_rate_scale_data_ops); lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = - debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, - &lq_sta->tx_agg_tid_en); + debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, + &lq_sta->tx_agg_tid_en); } -static void il4965_rs_remove_debugfs(void *il, void *il_sta) +static void +il4965_rs_remove_debugfs(void *il, void *il_sta) { struct il_lq_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); @@ -2833,6 +2848,7 @@ il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *il_sta) { } + static struct rate_control_ops rs_4965_ops = { .module = NULL, .name = IL4965_RS_NAME, @@ -2849,12 +2865,14 @@ static struct rate_control_ops rs_4965_ops = { #endif }; -int il4965_rate_control_register(void) +int +il4965_rate_control_register(void) { return ieee80211_rate_control_register(&rs_4965_ops); } -void il4965_rate_control_unregister(void) +void +il4965_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_4965_ops); } diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index cbbb2c0..be054f1 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -48,7 +48,7 @@ * it's a pretty good bet that everything between them is good, too. */ static int -il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +il4965_verify_inst_sparse(struct il_priv *il, __le32 * image, u32 len) { u32 val; int ret = 0; @@ -57,12 +57,11 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + for (i = 0; i < len; i += 100, image += 100 / sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL4965_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, i + IL4965_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; @@ -79,8 +78,8 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) * il4965_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, - u32 len) +static int +il4965_verify_inst_full(struct il_priv *il, __le32 * image, u32 len) { u32 val; u32 save_len = len; @@ -89,8 +88,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, D_INFO("ucode inst image size is %u\n", len); - il_wr(il, HBUS_TARG_MEM_RADDR, - IL4965_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, IL4965_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { @@ -100,8 +98,8 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); ret = -EIO; errcnt++; if (errcnt >= 20) @@ -110,8 +108,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, } if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); + D_INFO("ucode image in INSTRUCTION memory is good\n"); return ret; } @@ -120,14 +117,15 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, * il4965_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -int il4965_verify_ucode(struct il_priv *il) +int +il4965_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int ret; /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { @@ -136,7 +134,7 @@ int il4965_verify_ucode(struct il_priv *il) } /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; + image = (__le32 *) il->ucode_init.v_addr; len = il->ucode_init.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { @@ -145,7 +143,7 @@ int il4965_verify_ucode(struct il_priv *il) } /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; + image = (__le32 *) il->ucode_code.v_addr; len = il->ucode_code.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { @@ -158,7 +156,7 @@ int il4965_verify_ucode(struct il_priv *il) /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; ret = il4965_verify_inst_full(il, image, len); @@ -177,7 +175,8 @@ int il4965_verify_ucode(struct il_priv *il) * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ -int il4965_eeprom_acquire_semaphore(struct il_priv *il) +int +il4965_eeprom_acquire_semaphore(struct il_priv *il) { u16 count; int ret; @@ -185,13 +184,14 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - EEPROM_SEM_TIMEOUT); + ret = + _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + EEPROM_SEM_TIMEOUT); if (ret >= 0) return ret; } @@ -199,43 +199,43 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) return ret; } -void il4965_eeprom_release_semaphore(struct il_priv *il) +void +il4965_eeprom_release_semaphore(struct il_priv *il) { il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } -int il4965_eeprom_check_version(struct il_priv *il) +int +il4965_eeprom_check_version(struct il_priv *il) { u16 eeprom_ver; u16 calib_ver; eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - calib_ver = il_eeprom_query16(il, - EEPROM_4965_CALIB_VERSION_OFFSET); + calib_ver = il_eeprom_query16(il, EEPROM_4965_CALIB_VERSION_OFFSET); if (eeprom_ver < il->cfg->eeprom_ver || calib_ver < il->cfg->eeprom_calib_ver) goto err; - IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", - eeprom_ver, calib_ver); + IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " - "CALIB=0x%x < 0x%x\n", - eeprom_ver, il->cfg->eeprom_ver, - calib_ver, il->cfg->eeprom_calib_ver); + "CALIB=0x%x < 0x%x\n", eeprom_ver, il->cfg->eeprom_ver, + calib_ver, il->cfg->eeprom_calib_ver); return -EINVAL; } -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) +void +il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac) { const u8 *addr = il_eeprom_query_addr(il, - EEPROM_MAC_ADDRESS); + EEPROM_MAC_ADDRESS); memcpy(mac, addr, ETH_ALEN); } @@ -260,7 +260,8 @@ il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) } /* Set led register off */ -void il4965_led_enable(struct il_priv *il) +void +il4965_led_enable(struct il_priv *il) { _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } @@ -283,7 +284,8 @@ static int il4965_hw_get_temperature(struct il_priv *il); #define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ -static int il4965_verify_bsm(struct il_priv *il) +static int +il4965_verify_bsm(struct il_priv *il) { __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; @@ -294,16 +296,14 @@ static int il4965_verify_bsm(struct il_priv *il) /* verify BSM SRAM contents */ val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; + for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, + len, val, le32_to_cpu(*image)); return -EIO; } } @@ -345,7 +345,8 @@ static int il4965_verify_bsm(struct il_priv *il) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il4965_load_bsm(struct il_priv *il) +static int +il4965_load_bsm(struct il_priv *il) { __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; @@ -394,8 +395,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, - BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, @@ -418,9 +418,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, - BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); - + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; } @@ -434,7 +432,8 @@ static int il4965_load_bsm(struct il_priv *il) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il4965_set_ucode_ptrs(struct il_priv *il) +static int +il4965_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; @@ -447,13 +446,12 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) /* Tell bootstrap uCode where to find image to load */ il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); + il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); return ret; @@ -470,7 +468,8 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il4965_init_alive_start(struct il_priv *il) +static void +il4965_init_alive_start(struct il_priv *il) { /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the @@ -501,15 +500,18 @@ restart: queue_work(il->workqueue, &il->restart); } -static bool iw4965_is_ht40_channel(__le32 rxon_flags) +static bool +iw4965_is_ht40_channel(__le32 rxon_flags) { - int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; + int chan_mod = + le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) >> + RXON_FLG_CHANNEL_MODE_POS; return (chan_mod == CHANNEL_MODE_PURE_40 || chan_mod == CHANNEL_MODE_MIXED); } -static void il4965_nic_config(struct il_priv *il) +static void +il4965_nic_config(struct il_priv *il) { unsigned long flags; u16 radio_cfg; @@ -521,18 +523,18 @@ static void il4965_nic_config(struct il_priv *il) /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) il_set_bit(il, CSR_HW_IF_CONFIG_REG, - EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | - EEPROM_RF_CFG_STEP_MSK(radio_cfg) | - EEPROM_RF_CFG_DASH_MSK(radio_cfg)); + EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | + EEPROM_RF_CFG_STEP_MSK(radio_cfg) | + EEPROM_RF_CFG_DASH_MSK(radio_cfg)); /* set CSR_HW_CONFIG_REG for uCode use */ il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | - CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); + CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | + CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - il->calib_info = (struct il_eeprom_calib_info *) - il_eeprom_query_addr(il, - EEPROM_4965_CALIB_TXPOWER_OFFSET); + il->calib_info = + (struct il_eeprom_calib_info *)il_eeprom_query_addr(il, + EEPROM_4965_CALIB_TXPOWER_OFFSET); spin_unlock_irqrestore(&il->lock, flags); } @@ -540,12 +542,12 @@ static void il4965_nic_config(struct il_priv *il) /* Reset differential Rx gains in NIC to prepare for chain noise calibration. * Called after every association, but this runs only once! * ... once chain noise is calibrated the first time, it's good forever. */ -static void il4965_chain_noise_reset(struct il_priv *il) +static void +il4965_chain_noise_reset(struct il_priv *il) { struct il_chain_noise_data *data = &(il->chain_noise_data); - if (data->state == IL_CHAIN_NOISE_ALIVE && - il_is_any_associated(il)) { + if (data->state == IL_CHAIN_NOISE_ALIVE && il_is_any_associated(il)) { struct il_calib_diff_gain_cmd cmd; /* clear data for chain noise calibration algorithm */ @@ -562,10 +564,8 @@ static void il4965_chain_noise_reset(struct il_priv *il) cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(il, C_PHY_CALIBRATION, - sizeof(cmd), &cmd)) - IL_ERR( - "Could not send C_PHY_CALIBRATION\n"); + if (il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd)) + IL_ERR("Could not send C_PHY_CALIBRATION\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; D_CALIB("Run chain_noise_calibrate\n"); } @@ -573,7 +573,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) static struct il_sensitivity_ranges il4965_sensitivity = { .min_nrg_cck = 97, - .max_nrg_cck = 0, /* not used, set to 0 */ + .max_nrg_cck = 0, /* not used, set to 0 */ .auto_corr_min_ofdm = 85, .auto_corr_min_ofdm_mrc = 170, @@ -598,11 +598,12 @@ static struct il_sensitivity_ranges il4965_sensitivity = { .nrg_th_cca = 62, }; -static void il4965_set_ct_threshold(struct il_priv *il) +static void +il4965_set_ct_threshold(struct il_priv *il) { /* want Kelvin */ il->hw_params.ct_kill_threshold = - CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); + CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); } /** @@ -610,18 +611,19 @@ static void il4965_set_ct_threshold(struct il_priv *il) * * Called when initializing driver */ -static int il4965_hw_set_hw_params(struct il_priv *il) +static int +il4965_hw_set_hw_params(struct il_priv *il) { if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) il->cfg->base_params->num_of_queues = - il->cfg->mod_params->num_of_queues; + il->cfg->mod_params->num_of_queues; il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; il->hw_params.scd_bc_tbls_size = - il->cfg->base_params->num_of_queues * - sizeof(struct il4965_scd_bc_tbl); + il->cfg->base_params->num_of_queues * + sizeof(struct il4965_scd_bc_tbl); il->hw_params.tfd_size = sizeof(struct il_tfd); il->hw_params.max_stations = IL4965_STATION_COUNT; il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; @@ -645,7 +647,8 @@ static int il4965_hw_set_hw_params(struct il_priv *il) return 0; } -static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) +static s32 +il4965_math_div_round(s32 num, s32 denom, s32 * res) { s32 sign = 1; @@ -674,8 +677,8 @@ static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) * Voltage indication is higher for lower voltage. * Lower voltage requires more gain (lower gain table idx). */ -static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, - s32 current_voltage) +static s32 +il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage) { s32 comp = 0; @@ -684,7 +687,7 @@ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, return 0; il4965_math_div_round(current_voltage - eeprom_voltage, - TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); + TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); if (current_voltage > eeprom_voltage) comp *= 2; @@ -694,7 +697,8 @@ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, return comp; } -static s32 il4965_get_tx_atten_grp(u16 channel) +static s32 +il4965_get_tx_atten_grp(u16 channel) { if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && channel <= CALIB_IL_TX_ATTEN_GR5_LCH) @@ -719,7 +723,8 @@ static s32 il4965_get_tx_atten_grp(u16 channel) return -EINVAL; } -static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) +static u32 +il4965_get_sub_band(const struct il_priv *il, u32 channel) { s32 b = -1; @@ -735,7 +740,8 @@ static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) return b; } -static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) +static s32 +il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) { s32 val; @@ -755,8 +761,9 @@ static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) * differences in channel frequencies, which is proportional to differences * in channel number. */ -static int il4965_interpolate_chan(struct il_priv *il, u32 channel, - struct il_eeprom_calib_ch_info *chan_info) +static int +il4965_interpolate_chan(struct il_priv *il, u32 channel, + struct il_eeprom_calib_ch_info *chan_info) { s32 s = -1; u32 c; @@ -777,8 +784,8 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, ch_i2 = il->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", - channel, s, ch_i1, ch_i2); + D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", channel, s, + ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { @@ -790,36 +797,33 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, omeas->actual_pow = (u8) il4965_interpolate_value(channel, ch_i1, - m1->actual_pow, - ch_i2, - m2->actual_pow); + m1->actual_pow, ch_i2, + m2->actual_pow); omeas->gain_idx = (u8) il4965_interpolate_value(channel, ch_i1, - m1->gain_idx, ch_i2, - m2->gain_idx); + m1->gain_idx, ch_i2, + m2->gain_idx); omeas->temperature = (u8) il4965_interpolate_value(channel, ch_i1, - m1->temperature, - ch_i2, - m2->temperature); + m1->temperature, + ch_i2, + m2->temperature); omeas->pa_det = (s8) il4965_interpolate_value(channel, ch_i1, - m1->pa_det, ch_i2, - m2->pa_det); - - D_TXPOWER( - "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, - m1->actual_pow, m2->actual_pow, omeas->actual_pow); - D_TXPOWER( - "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, - m1->gain_idx, m2->gain_idx, omeas->gain_idx); - D_TXPOWER( - "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, - m1->pa_det, m2->pa_det, omeas->pa_det); - D_TXPOWER( - "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, - m1->temperature, m2->temperature, - omeas->temperature); + m1->pa_det, ch_i2, + m2->pa_det); + + D_TXPOWER("chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, + m, m1->actual_pow, m2->actual_pow, + omeas->actual_pow); + D_TXPOWER("chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, + m, m1->gain_idx, m2->gain_idx, + omeas->gain_idx); + D_TXPOWER("chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, + m, m1->pa_det, m2->pa_det, omeas->pa_det); + D_TXPOWER("chain %d meas %d T1=%d T2=%d T=%d\n", c, + m, m1->temperature, m2->temperature, + omeas->temperature); } } @@ -842,14 +846,20 @@ static struct il4965_txpower_comp_entry { s32 degrees_per_05db_a; s32 degrees_per_05db_a_denom; } tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { - {9, 2}, /* group 0 5.2, ch 34-43 */ - {4, 1}, /* group 1 5.2, ch 44-70 */ - {4, 1}, /* group 2 5.2, ch 71-124 */ - {4, 1}, /* group 3 5.2, ch 125-200 */ - {3, 1} /* group 4 2.4, ch all */ + { + 9, 2}, /* group 0 5.2, ch 34-43 */ + { + 4, 1}, /* group 1 5.2, ch 44-70 */ + { + 4, 1}, /* group 2 5.2, ch 71-124 */ + { + 4, 1}, /* group 3 5.2, ch 125-200 */ + { + 3, 1} /* group 4 2.4, ch all */ }; -static s32 get_min_power_idx(s32 rate_power_idx, u32 band) +static s32 +get_min_power_idx(s32 rate_power_idx, u32 band) { if (!band) { if ((rate_power_idx & 7) <= 4) @@ -1088,9 +1098,10 @@ static const struct gain_entry gain_table[2][108] = { } }; -static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, - u8 is_ht40, u8 ctrl_chan_high, - struct il4965_tx_power_db *tx_power_tbl) +static int +il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40, + u8 ctrl_chan_high, + struct il4965_tx_power_db *tx_power_tbl) { u8 saturation_power; s32 target_power; @@ -1121,8 +1132,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, - is_ht40); + D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, is_ht40); ch_info = il_get_channel_info(il, il->band, channel); @@ -1133,13 +1143,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * and 2) mimo txpower balance between Tx chains. */ txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IL_ERR("Can't find txatten group for channel %d.\n", - channel); + IL_ERR("Can't find txatten group for channel %d.\n", channel); return txatten_grp; } - D_TXPOWER("channel %d belongs to txatten group %d\n", - channel, txatten_grp); + D_TXPOWER("channel %d belongs to txatten group %d\n", channel, + txatten_grp); if (is_ht40) { if (ctrl_chan_high) @@ -1184,13 +1193,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* calculate tx gain adjustment based on power supply voltage */ voltage = le16_to_cpu(il->calib_info->voltage); - init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); + init_voltage = (s32) le32_to_cpu(il->card_alive_init.voltage); voltage_compensation = il4965_get_voltage_compensation(voltage, init_voltage); - D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", - init_voltage, - voltage, voltage_compensation); + D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", init_voltage, + voltage, voltage_compensation); /* get current temperature (Celsius) */ current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); @@ -1211,23 +1219,20 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* txgain adjustment (in half-dB steps) based on difference * between factory and current temperature */ factory_temp = measurement->temperature; - il4965_math_div_round((current_temp - factory_temp) * - degrees_per_05db_denom, - degrees_per_05db_num, - &temperature_comp[c]); + il4965_math_div_round((current_temp - + factory_temp) * degrees_per_05db_denom, + degrees_per_05db_num, + &temperature_comp[c]); factory_gain_idx[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; D_TXPOWER("chain = %d\n", c); - D_TXPOWER("fctry tmp %d, " - "curr tmp %d, comp %d steps\n", - factory_temp, current_temp, - temperature_comp[c]); - - D_TXPOWER("fctry idx %d, fctry pwr %d\n", - factory_gain_idx[c], - factory_actual_pwr[c]); + D_TXPOWER("fctry tmp %d, " "curr tmp %d, comp %d steps\n", + factory_temp, current_temp, temperature_comp[c]); + + D_TXPOWER("fctry idx %d, fctry pwr %d\n", factory_gain_idx[c], + factory_actual_pwr[c]); } /* for each of 33 bit-rates (including 1 for CCK) */ @@ -1239,7 +1244,8 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * (3dB, 6 steps), so total output power is regulatory * compliant. */ if (i & 0x8) { - current_regulatory = reg_limit - + current_regulatory = + reg_limit - IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; is_mimo_rate = 1; } else { @@ -1258,10 +1264,9 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", - i, saturation_power - back_off_table[i], - current_regulatory, user_target_power, - target_power); + D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", i, + saturation_power - back_off_table[i], + current_regulatory, user_target_power, target_power); /* for each of 2 Tx chains (radio transmitters) */ for (c = 0; c < 2; c++) { @@ -1269,18 +1274,17 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, if (is_mimo_rate) atten_value = - (s32)le32_to_cpu(il->card_alive_init. - tx_atten[txatten_grp][c]); + (s32) le32_to_cpu(il->card_alive_init. + tx_atten[txatten_grp][c]); else atten_value = 0; /* calculate idx; higher idx means lower txpower */ - power_idx = (u8) (factory_gain_idx[c] - - (target_power - - factory_actual_pwr[c]) - - temperature_comp[c] - - voltage_compensation + - atten_value); + power_idx = + (u8) (factory_gain_idx[c] - + (target_power - factory_actual_pwr[c]) - + temperature_comp[c] - voltage_compensation + + atten_value); /* D_TXPOWER("calculated txpower idx %d\n", power_idx); */ @@ -1299,32 +1303,29 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* stay within the table! */ if (power_idx > 107) { - IL_WARN("txpower idx %d > 107\n", - power_idx); + IL_WARN("txpower idx %d > 107\n", power_idx); power_idx = 107; } if (power_idx < 0) { - IL_WARN("txpower idx %d < 0\n", - power_idx); + IL_WARN("txpower idx %d < 0\n", power_idx); power_idx = 0; } /* fill txpower command for this rate/chain */ tx_power.s.radio_tx_gain[c] = - gain_table[band][power_idx].radio; + gain_table[band][power_idx].radio; tx_power.s.dsp_predis_atten[c] = - gain_table[band][power_idx].dsp; + gain_table[band][power_idx].dsp; D_TXPOWER("chain %d mimo %d idx %d " - "gain 0x%02x dsp %d\n", - c, atten_value, power_idx, - tx_power.s.radio_tx_gain[c], - tx_power.s.dsp_predis_atten[c]); - } /* for each chain */ + "gain 0x%02x dsp %d\n", c, atten_value, + power_idx, tx_power.s.radio_tx_gain[c], + tx_power.s.dsp_predis_atten[c]); + } /* for each chain */ tx_power_tbl->power_tbl[i].dw = cpu_to_le32(tx_power.dw); - } /* for each rate */ + } /* for each rate */ return 0; } @@ -1335,7 +1336,8 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * Uses the active RXON for channel, band, and characteristics (ht40, high) * The power limit is taken from il->tx_power_user_lmt. */ -static int il4965_send_tx_power(struct il_priv *il) +static int +il4965_send_tx_power(struct il_priv *il) { struct il4965_txpowertable_cmd cmd = { 0 }; int ret; @@ -1344,8 +1346,9 @@ static int il4965_send_tx_power(struct il_priv *il) u8 ctrl_chan_high = 0; struct il_rxon_context *ctx = &il->ctx; - if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) + if (WARN_ONCE + (test_bit(S_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) return -EAGAIN; band = il->band == IEEE80211_BAND_2GHZ; @@ -1358,21 +1361,20 @@ static int il4965_send_tx_power(struct il_priv *il) cmd.band = band; cmd.channel = ctx->active.channel; - ret = il4965_fill_txpower_tbl(il, band, - le16_to_cpu(ctx->active.channel), - is_ht40, ctrl_chan_high, &cmd.tx_power); + ret = + il4965_fill_txpower_tbl(il, band, le16_to_cpu(ctx->active.channel), + is_ht40, ctrl_chan_high, &cmd.tx_power); if (ret) goto out; - ret = il_send_cmd_pdu(il, - C_TX_PWR_TBL, sizeof(cmd), &cmd); + ret = il_send_cmd_pdu(il, C_TX_PWR_TBL, sizeof(cmd), &cmd); out: return ret; } -static int il4965_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il4965_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int ret = 0; struct il4965_rxon_assoc_cmd rxon_assoc; @@ -1383,9 +1385,9 @@ static int il4965_send_rxon_assoc(struct il_priv *il, rxon1->filter_flags == rxon2->filter_flags && rxon1->cck_basic_rates == rxon2->cck_basic_rates && rxon1->ofdm_ht_single_stream_basic_rates == - rxon2->ofdm_ht_single_stream_basic_rates && + rxon2->ofdm_ht_single_stream_basic_rates && rxon1->ofdm_ht_dual_stream_basic_rates == - rxon2->ofdm_ht_dual_stream_basic_rates && + rxon2->ofdm_ht_dual_stream_basic_rates && rxon1->rx_chain == rxon2->rx_chain && rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { D_INFO("Using current RXON_ASSOC. Not resending.\n"); @@ -1403,19 +1405,20 @@ static int il4965_send_rxon_assoc(struct il_priv *il, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = il_send_cmd_pdu_async(il, C_RXON_ASSOC, - sizeof(rxon_assoc), &rxon_assoc, NULL); + ret = + il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc), + &rxon_assoc, NULL); return ret; } -static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +static int +il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il_rxon_cmd *active_rxon = (void *)&ctx->active; int ret; - bool new_assoc = - !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); + bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); if (!il_is_alive(il)) return -EBUSY; @@ -1471,9 +1474,9 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), - active_rxon); + ret = + il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), active_rxon); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ @@ -1491,24 +1494,20 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) } } - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(ctx->staging.channel), - ctx->staging.bssid_addr); + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" "* bssid = %pM\n", (new_assoc ? "" : "out"), + le16_to_cpu(ctx->staging.channel), ctx->staging.bssid_addr); - il_set_rxon_hwcrypto(il, ctx, - !il->cfg->mod_params->sw_crypto); + il_set_rxon_hwcrypto(il, ctx, !il->cfg->mod_params->sw_crypto); /* Apply the new configuration * RXON unassoc clears the station table in uCode so restoration of * stations is needed after it (the RXON command) completes */ if (!new_assoc) { - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); + ret = + il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { IL_ERR("Error setting new RXON (%d)\n", ret); return ret; @@ -1528,8 +1527,9 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) /* Apply the new configuration * RXON assoc doesn't clear the station table in uCode, */ - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); + ret = + il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { IL_ERR("Error setting new RXON (%d)\n", ret); return ret; @@ -1551,8 +1551,9 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) return 0; } -static int il4965_hw_channel_switch(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch) +static int +il4965_hw_channel_switch(struct il_priv *il, + struct ieee80211_channel_switch *ch_switch) { struct il_rxon_context *ctx = &il->ctx; int rc; @@ -1571,8 +1572,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); - if (is_ht40 && - (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + if (is_ht40 && (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) ctrl_chan_high = 1; cmd.band = band; @@ -1588,10 +1588,10 @@ static int il4965_hw_channel_switch(struct il_priv *il, * adding TSF as one of the factor for when to switch */ if (il->ucode_beacon_time > tsf_low && beacon_interval) { - if (switch_count > ((il->ucode_beacon_time - tsf_low) / - beacon_interval)) { - switch_count -= (il->ucode_beacon_time - - tsf_low) / beacon_interval; + if (switch_count > + ((il->ucode_beacon_time - tsf_low) / beacon_interval)) { + switch_count -= + (il->ucode_beacon_time - tsf_low) / beacon_interval; } else switch_count = 0; } @@ -1599,43 +1599,40 @@ static int il4965_hw_channel_switch(struct il_priv *il, cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); else { switch_time_in_usec = - vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = il_usecs_to_beacons(il, - switch_time_in_usec, - beacon_interval); - cmd.switch_time = il_add_beacon_time(il, - il->ucode_beacon_time, - ucode_switch_time, - beacon_interval); + vif->bss_conf.beacon_int * switch_count * TIME_UNIT; + ucode_switch_time = + il_usecs_to_beacons(il, switch_time_in_usec, + beacon_interval); + cmd.switch_time = + il_add_beacon_time(il, il->ucode_beacon_time, + ucode_switch_time, beacon_interval); } - D_11H("uCode time for the switch is 0x%x\n", - cmd.switch_time); + D_11H("uCode time for the switch is 0x%x\n", cmd.switch_time); ch_info = il_get_channel_info(il, il->band, ch); if (ch_info) cmd.expect_beacon = il_is_channel_radar(ch_info); else { IL_ERR("invalid channel switch from %u to %u\n", - ctx->active.channel, ch); + ctx->active.channel, ch); return -EFAULT; } - rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, - ctrl_chan_high, &cmd.tx_power); + rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, ctrl_chan_high, + &cmd.tx_power); if (rc) { D_11H("error:%d fill txpower_tbl\n", rc); return rc; } - return il_send_cmd_pdu(il, - C_CHANNEL_SWITCH, sizeof(cmd), &cmd); + return il_send_cmd_pdu(il, C_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array */ -static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt) +static void +il4965_txq_update_byte_cnt_tbl(struct il_priv *il, struct il_tx_queue *txq, + u16 byte_cnt) { struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; int txq_id = txq->q.id; @@ -1651,8 +1648,8 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, /* If within first 64 entries, duplicate at end */ if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) - scd_bc_tbl[txq_id]. - tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent; + scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = + bc_ent; } /** @@ -1661,7 +1658,8 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, * * A return of <0 indicates bogus data in the stats */ -static int il4965_hw_get_temperature(struct il_priv *il) +static int +il4965_hw_get_temperature(struct il_priv *il) { s32 temperature; s32 vt; @@ -1669,18 +1667,17 @@ static int il4965_hw_get_temperature(struct il_priv *il) u32 R4; if (test_bit(S_TEMPERATURE, &il->status) && - (il->_4965.stats.flag & - STATS_REPLY_FLG_HT40_MODE_MSK)) { + (il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); + R1 = (s32) le32_to_cpu(il->card_alive_init.therm_r1[1]); + R2 = (s32) le32_to_cpu(il->card_alive_init.therm_r2[1]); + R3 = (s32) le32_to_cpu(il->card_alive_init.therm_r3[1]); R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); } else { D_TEMP("Running temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); + R1 = (s32) le32_to_cpu(il->card_alive_init.therm_r1[0]); + R2 = (s32) le32_to_cpu(il->card_alive_init.therm_r2[0]); + R3 = (s32) le32_to_cpu(il->card_alive_init.therm_r3[0]); R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); } @@ -1694,8 +1691,9 @@ static int il4965_hw_get_temperature(struct il_priv *il) if (!test_bit(S_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else - vt = sign_extend32(le32_to_cpu(il->_4965.stats. - general.common.temperature), 23); + vt = sign_extend32(le32_to_cpu + (il->_4965.stats.general.common.temperature), + 23); D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); @@ -1708,10 +1706,11 @@ static int il4965_hw_get_temperature(struct il_priv *il) * Add offset to center the adjustment around 0 degrees Centigrade. */ temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); temperature /= (R3 - R1); - temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; + temperature = + (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - D_TEMP("Calibrated temperature: %dK, %dC\n", - temperature, KELVIN_TO_CELSIUS(temperature)); + D_TEMP("Calibrated temperature: %dK, %dC\n", temperature, + KELVIN_TO_CELSIUS(temperature)); return temperature; } @@ -1728,7 +1727,8 @@ static int il4965_hw_get_temperature(struct il_priv *il) * Assumes caller will replace il->last_temperature once calibration * executed. */ -static int il4965_is_temp_calib_needed(struct il_priv *il) +static int +il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; @@ -1758,7 +1758,8 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) return 1; } -static void il4965_temperature_calib(struct il_priv *il) +static void +il4965_temperature_calib(struct il_priv *il) { s32 temp; @@ -1768,26 +1769,25 @@ static void il4965_temperature_calib(struct il_priv *il) if (il->temperature != temp) { if (il->temperature) - D_TEMP("Temperature changed " - "from %dC to %dC\n", - KELVIN_TO_CELSIUS(il->temperature), - KELVIN_TO_CELSIUS(temp)); + D_TEMP("Temperature changed " "from %dC to %dC\n", + KELVIN_TO_CELSIUS(il->temperature), + KELVIN_TO_CELSIUS(temp)); else - D_TEMP("Temperature " - "initialized to %dC\n", - KELVIN_TO_CELSIUS(temp)); + D_TEMP("Temperature " "initialized to %dC\n", + KELVIN_TO_CELSIUS(temp)); } il->temperature = temp; set_bit(S_TEMPERATURE, &il->status); if (!il->disable_tx_power_cal && - unlikely(!test_bit(S_SCANNING, &il->status)) && - il4965_is_temp_calib_needed(il)) + unlikely(!test_bit(S_SCANNING, &il->status)) && + il4965_is_temp_calib_needed(il)) queue_work(il->workqueue, &il->txpower_work); } -static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) +static u16 +il4965_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case C_RXON: @@ -1797,8 +1797,8 @@ static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) } } -static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) +static u16 +il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) { struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; addsta->mode = cmd->mode; @@ -1814,15 +1814,17 @@ static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, addsta->reserved1 = cpu_to_le16(0); addsta->reserved2 = cpu_to_le16(0); - return (u16)sizeof(struct il4965_addsta_cmd); + return (u16) sizeof(struct il4965_addsta_cmd); } -static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) +static inline u32 +il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) { return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; } -static inline u32 il4965_tx_status_to_mac80211(u32 status) +static inline u32 +il4965_tx_status_to_mac80211(u32 status) { status &= TX_STATUS_MSK; @@ -1837,20 +1839,20 @@ static inline u32 il4965_tx_status_to_mac80211(u32 status) } } -static inline bool il4965_is_tx_success(u32 status) +static inline bool +il4965_is_tx_success(u32 status) { status &= TX_STATUS_MSK; - return (status == TX_STATUS_SUCCESS || - status == TX_STATUS_DIRECT_DONE); + return (status == TX_STATUS_SUCCESS || status == TX_STATUS_DIRECT_DONE); } /** * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ -static int il4965_tx_status_reply_tx(struct il_priv *il, - struct il_ht_agg *agg, - struct il4965_tx_resp *tx_resp, - int txq_id, u16 start_idx) +static int +il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, + struct il4965_tx_resp *tx_resp, int txq_id, + u16 start_idx) { u16 status; struct agg_tx_status *frame_status = tx_resp->u.agg_status; @@ -1874,7 +1876,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, idx = start_idx; D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", - agg->frame_count, agg->start_idx, idx); + agg->frame_count, agg->start_idx, idx); info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); info->status.rates[0].count = tx_resp->failure_frame + 1; @@ -1882,8 +1884,8 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, info->flags |= il4965_tx_status_to_mac80211(status); il4965_hwrate_to_tx_control(il, rate_n_flags, info); - D_TX_REPLY("1 Frame 0x%x failure :%d\n", - status & 0xff, tx_resp->failure_frame); + D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff, + tx_resp->failure_frame); D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; @@ -1896,36 +1898,35 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, for (i = 0; i < agg->frame_count; i++) { u16 sc; status = le16_to_cpu(frame_status[i].status); - seq = le16_to_cpu(frame_status[i].sequence); + seq = le16_to_cpu(frame_status[i].sequence); idx = SEQ_TO_IDX(seq); txq_id = SEQ_TO_QUEUE(seq); - if (status & (AGG_TX_STATE_FEW_BYTES_MSK | - AGG_TX_STATE_ABORT_MSK)) + if (status & + (AGG_TX_STATE_FEW_BYTES_MSK | + AGG_TX_STATE_ABORT_MSK)) continue; D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", - agg->frame_count, txq_id, idx); + agg->frame_count, txq_id, idx); hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (!hdr) { - IL_ERR( - "BUG_ON idx doesn't point to valid skb" - " idx=%d, txq_id=%d\n", idx, txq_id); + IL_ERR("BUG_ON idx doesn't point to valid skb" + " idx=%d, txq_id=%d\n", idx, txq_id); return -1; } sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR( - "BUG_ON idx doesn't match seq control" - " idx=%d, seq_idx=%d, seq=%d\n", - idx, SEQ_TO_SN(sc), hdr->seq_ctrl); + IL_ERR("BUG_ON idx doesn't match seq control" + " idx=%d, seq_idx=%d, seq=%d\n", idx, + SEQ_TO_SN(sc), hdr->seq_ctrl); return -1; } - D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", - i, idx, SEQ_TO_SN(sc)); + D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx, + SEQ_TO_SN(sc)); sh = idx - start; if (sh > 64) { @@ -1934,7 +1935,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sh = 0; start = idx; } else if (sh < -64) - sh = 0xff - (start - idx); + sh = 0xff - (start - idx); else if (sh < 0) { sh = start - idx; start = idx; @@ -1942,15 +1943,15 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sh = 0; } bitmap |= 1ULL << sh; - D_TX_REPLY("start=%d bitmap=0x%llx\n", - start, (unsigned long long)bitmap); + D_TX_REPLY("start=%d bitmap=0x%llx\n", start, + (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", - agg->frame_count, agg->start_idx, - (unsigned long long)agg->bitmap); + agg->frame_count, agg->start_idx, + (unsigned long long)agg->bitmap); if (bitmap) agg->wait_for_ba = 1; @@ -1958,7 +1959,8 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, return 0; } -static u8 il4965_find_station(struct il_priv *il, const u8 *addr) +static u8 +il4965_find_station(struct il_priv *il, const u8 * addr) { int i; int start = 0; @@ -1974,16 +1976,14 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) spin_lock_irqsave(&il->sta_lock, flags); for (i = start; i < il->hw_params.max_stations; i++) if (il->stations[i].used && - (!compare_ether_addr(il->stations[i].sta.sta.addr, - addr))) { + (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) { ret = i; goto out; } - D_ASSOC("can not find STA %pM total %d\n", - addr, il->num_stations); + D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations); - out: +out: /* * It may be possible that more commands interacting with stations * arrive before we completed processing the adding of @@ -1994,14 +1994,15 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { IL_ERR("Requested station info for sta %d before ready.\n", - ret); + ret); ret = IL_INVALID_STATION; } spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) +static int +il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) { if (il->iw_mode == NL80211_IFTYPE_STATION) { return IL_AP_ID; @@ -2014,8 +2015,8 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) /** * il4965_hdl_tx - Handle standard (non-aggregation) Tx response */ -static void il4965_hdl_tx(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -2025,7 +2026,7 @@ static void il4965_hdl_tx(struct il_priv *il, struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->u.status); + u32 status = le32_to_cpu(tx_resp->u.status); int uninitialized_var(tid); int sta_id; int freed; @@ -2034,9 +2035,8 @@ static void il4965_hdl_tx(struct il_priv *il, if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); + "is out of range [0-%d] %d %d\n", txq_id, idx, + txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -2067,18 +2067,18 @@ static void il4965_hdl_tx(struct il_priv *il, il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); /* check if BAR is needed */ - if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) + if ((tx_resp->frame_count == 1) && + !il4965_is_tx_success(status)) info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; if (txq->q.read_ptr != (scd_ssn & 0xff)) { - idx = il_queue_dec_wrap(scd_ssn & 0xff, - txq->q.n_bd); + idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); D_TX_REPLY("Retry scheduler reclaim scd_ssn " - "%d idx %d\n", scd_ssn , idx); + "%d idx %d\n", scd_ssn, idx); freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc) - il4965_free_tfds_in_queue(il, sta_id, - tid, freed); + il4965_free_tfds_in_queue(il, sta_id, tid, + freed); if (il->mac80211_registered && il_queue_space(&txq->q) > txq->q.low_mark && @@ -2089,15 +2089,14 @@ static void il4965_hdl_tx(struct il_priv *il, info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags |= il4965_tx_status_to_mac80211(status); il4965_hwrate_to_tx_control(il, - le32_to_cpu(tx_resp->rate_n_flags), - info); + le32_to_cpu(tx_resp->rate_n_flags), + info); D_TX_REPLY("TXQ %d status %s (0x%08x) " - "rate_n_flags 0x%x retries %d\n", - txq_id, - il4965_get_tx_fail_reason(status), status, - le32_to_cpu(tx_resp->rate_n_flags), - tx_resp->failure_frame); + "rate_n_flags 0x%x retries %d\n", txq_id, + il4965_get_tx_fail_reason(status), status, + le32_to_cpu(tx_resp->rate_n_flags), + tx_resp->failure_frame); freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc && likely(sta_id != IL_INVALID_STATION)) @@ -2117,27 +2116,27 @@ static void il4965_hdl_tx(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags); } -static void il4965_hdl_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; u8 rate __maybe_unused = - il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); D_RX("beacon status %#x, retries:%d ibssmgr:%d " - "tsf:0x%.8x%.8x rate:%d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); + "tsf:0x%.8x%.8x rate:%d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } /* Set up 4965-specific Rx frame reply handlers */ -static void il4965_handler_setup(struct il_priv *il) +static void +il4965_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ il->handlers[N_RX] = il4965_hdl_rx; @@ -2152,7 +2151,8 @@ static struct il_hcmd_ops il4965_hcmd = { .set_rxon_chain = il4965_set_rxon_chain, }; -static void il4965_post_scan(struct il_priv *il) +static void +il4965_post_scan(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; @@ -2164,7 +2164,8 @@ static void il4965_post_scan(struct il_priv *il) il_commit_rxon(il, ctx); } -static void il4965_post_associate(struct il_priv *il) +static void +il4965_post_associate(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; @@ -2186,8 +2187,7 @@ static void il4965_post_associate(struct il_priv *il) ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN("RXON timing - " - "Attempting to continue.\n"); + IL_WARN("RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2198,8 +2198,8 @@ static void il4965_post_associate(struct il_priv *il) ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - D_ASSOC("assoc id %d beacon interval %d\n", - vif->bss_conf.aid, vif->bss_conf.beacon_int); + D_ASSOC("assoc id %d beacon interval %d\n", vif->bss_conf.aid, + vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2215,8 +2215,8 @@ static void il4965_post_associate(struct il_priv *il) il_commit_rxon(il, ctx); - D_ASSOC("Associated as %d to: %pM\n", - vif->bss_conf.aid, ctx->active.bssid_addr); + D_ASSOC("Associated as %d to: %pM\n", vif->bss_conf.aid, + ctx->active.bssid_addr); switch (vif->type) { case NL80211_IFTYPE_STATION: @@ -2225,8 +2225,8 @@ static void il4965_post_associate(struct il_priv *il) il4965_send_beacon_cmd(il); break; default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, vif->type); + IL_ERR("%s Should not be called in %d mode\n", __func__, + vif->type); break; } @@ -2241,7 +2241,8 @@ static void il4965_post_associate(struct il_priv *il) il->start_calib = 1; } -static void il4965_config_ap(struct il_priv *il) +static void +il4965_config_ap(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; @@ -2263,11 +2264,10 @@ static void il4965_config_ap(struct il_priv *il) ret = il_send_rxon_timing(il, ctx); if (ret) IL_WARN("RXON timing failed - " - "Attempting to continue.\n"); + "Attempting to continue.\n"); /* AP has all antennas */ - il->chain_noise_data.active_chains = - il->hw_params.valid_rx_ant; + il->chain_noise_data.active_chains = il->hw_params.valid_rx_ant; il_set_rxon_ht(il, &il->current_ht_config); if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, ctx); @@ -2275,19 +2275,15 @@ static void il4965_config_ap(struct il_priv *il) ctx->staging.assoc_id = 0; if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } /* need to send beacon cmd before committing assoc RXON! */ il4965_send_beacon_cmd(il); @@ -2319,32 +2315,31 @@ static struct il_lib_ops il4965_lib = { .dump_fh = il4965_dump_fh, .set_channel_switch = il4965_hw_channel_switch, .apm_ops = { - .init = il_apm_init, - .config = il4965_nic_config, - }, + .init = il_apm_init, + .config = il4965_nic_config, + }, .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, - EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS - }, - .acquire_semaphore = il4965_eeprom_acquire_semaphore, - .release_semaphore = il4965_eeprom_release_semaphore, - }, - .send_tx_power = il4965_send_tx_power, + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, + EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS}, + .acquire_semaphore = il4965_eeprom_acquire_semaphore, + .release_semaphore = il4965_eeprom_release_semaphore, + }, + .send_tx_power = il4965_send_tx_power, .update_chain_flags = il4965_update_chain_flags, .temp_ops = { - .temperature = il4965_temperature_calib, - }, + .temperature = il4965_temperature_calib, + }, .debugfs_ops = { - .rx_stats_read = il4965_ucode_rx_stats_read, - .tx_stats_read = il4965_ucode_tx_stats_read, - .general_stats_read = il4965_ucode_general_stats_read, - }, + .rx_stats_read = il4965_ucode_rx_stats_read, + .tx_stats_read = il4965_ucode_tx_stats_read, + .general_stats_read = il4965_ucode_general_stats_read, + }, }; static const struct il_legacy_ops il4965_legacy_ops = { @@ -2406,7 +2401,7 @@ struct il_cfg il4965_cfg = { .fw_name_pre = IL4965_FW_PRE, .ucode_api_max = IL4965_UCODE_API_MAX, .ucode_api_min = IL4965_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, + .sku = IL_SKU_A | IL_SKU_G | IL_SKU_N, .valid_tx_ant = ANT_AB, .valid_rx_ant = ANT_ABC, .eeprom_ver = EEPROM_4965_EEPROM_VERSION, diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index a4e256b..78eae22 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -44,19 +44,17 @@ extern struct il_mod_params il4965_mod_params; extern struct ieee80211_ops il4965_hw_ops; /* tx queue */ -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed); +void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, + int freed); /* RXON */ -void il4965_set_rxon_chain(struct il_priv *il, - struct il_rxon_context *ctx); +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx); /* uCode */ int il4965_verify_ucode(struct il_priv *il); /* lib */ -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status); +void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status); void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); @@ -70,30 +68,24 @@ void il4965_rx_replenish_now(struct il_priv *il); void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_hdl_rx(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_hdl_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb); +void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb); +void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb); void il4965_rx_handle(struct il_priv *il); /* tx */ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad); -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad); +int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info); + struct ieee80211_tx_info *info); int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn); + struct ieee80211_sta *sta, u16 tid, u16 * ssn); int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id); -void il4965_hdl_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb); +int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); +void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb); int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); void il4965_hw_txq_ctx_free(struct il_priv *il); int il4965_txq_ctx_alloc(struct il_priv *il); @@ -112,28 +104,23 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); * * NOTE: Acquire il->lock before calling this function ! */ -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry); +void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry); u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ -void il4965_hdl_missed_beacon(struct il_priv *il, - struct il_rx_buf *rxb); -bool il4965_good_plcp_health(struct il_priv *il, - struct il_rx_pkt *pkt); -void il4965_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb); +void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb); +bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); +void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); +void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); /* scan */ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); /* station mgmt */ -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add); +int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, + bool add); /* hcmd */ int il4965_send_beacon_cmd(struct il_priv *il); @@ -142,59 +129,57 @@ int il4965_send_beacon_cmd(struct il_priv *il); const char *il4965_get_tx_fail_reason(u32 status); #else static inline const char * -il4965_get_tx_fail_reason(u32 status) { return ""; } +il4965_get_tx_fail_reason(u32 status) +{ + return ""; +} #endif /* station management */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_add_bssid_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r); +int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx); +int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, u8 * sta_id_r); int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key); +int il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key); int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_set_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, - int sta_id, int tid); + struct il_rxon_context *ctx); +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, + u16 * phase1key); +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid); int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn); + int tid, u16 ssn); int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid); -void il4965_sta_modify_sleep_tx_count(struct il_priv *il, - int sta_id, int cnt); + int tid); +void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt); int il4965_update_bcast_stations(struct il_priv *il); /* rate */ -static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) +static inline u8 +il4965_hw_get_rate(__le32 rate_n_flags) { return le32_to_cpu(rate_n_flags) & 0xFF; } -static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) +static inline __le32 +il4965_hw_set_rate_n_flags(u8 rate, u32 flags) { - return cpu_to_le32(flags|(u32)rate); + return cpu_to_le32(flags | (u32) rate); } /* eeprom */ -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); +void il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac); int il4965_eeprom_acquire_semaphore(struct il_priv *il); void il4965_eeprom_release_semaphore(struct il_priv *il); -int il4965_eeprom_check_version(struct il_priv *il); +int il4965_eeprom_check_version(struct il_priv *il); /* mac80211 handlers (for 4965) */ void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); @@ -202,30 +187,26 @@ int il4965_mac_start(struct ieee80211_hw *hw); void il4965_mac_stop(struct ieee80211_hw *hw); void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast); + unsigned int *total_flags, u64 multicast); int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key); void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key); -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u32 iv32, + u16 * phase1key); +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, + struct ieee80211_sta *sta, u16 tid, u16 * ssn, u8 buf_size); -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, +int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch); void il4965_led_enable(struct il_priv *il); - /* EEPROM */ #define IL4965_EEPROM_IMG_SIZE 1024 @@ -255,7 +236,8 @@ void il4965_led_enable(struct il_priv *il); /* Size of uCode instruction memory in bootstrap state machine */ #define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE -static inline int il4965_hw_valid_rtc_data_addr(u32 addr) +static inline int +il4965_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IL49_RTC_DATA_LOWER_BOUND && addr < IL49_RTC_DATA_UPPER_BOUND); @@ -588,8 +570,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * present during factory calibration). A 5 Ghz EEPROM idx of "40" * corresponds to the 49th entry in the table used by the driver. */ -#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ -#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ +#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ +#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ /** * 2.4 GHz gain table @@ -810,7 +792,6 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * 98 78 0x00 */ - /** * Sanity checks and default values for EEPROM regulatory levels. * If EEPROM values fall outside MIN/MAX range, use default values. @@ -894,7 +875,6 @@ enum { /********************* END TXPOWER *****************************************/ - /** * Tx/Rx Queues * @@ -920,7 +900,6 @@ enum { #define IL49_NUM_QUEUES 16 #define IL49_NUM_AMPDU_QUEUES 8 - /** * struct il4965_schedq_bc_tbl * @@ -944,7 +923,6 @@ struct il4965_scd_bc_tbl { u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; } __packed; - #define IL4965_RTC_INST_LOWER_BOUND (0x000000) /* RSSI to dBm */ @@ -971,28 +949,31 @@ void il4965_calib_free_results(struct il_priv *il); /* Debug */ #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); ssize_t il4965_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos); + char __user * user_buf, size_t count, + loff_t * ppos); #else static ssize_t -il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } + static ssize_t -il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } + static ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_general_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } @@ -1028,7 +1009,6 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, */ #define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) - /** * TFD Circular Buffers Base (CBBC) addresses * @@ -1047,7 +1027,6 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, /* Find TFD CB base pointer for given queue (range 0-15). */ #define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) - /** * Rx SRAM Control and Status Registers (RSCSR) * @@ -1144,7 +1123,6 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, #define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) #define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) - /** * Rx Config/Status Registers (RCSR) * Rx Config Reg for channel 0 (only channel used) @@ -1177,12 +1155,12 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, #define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31 */ #define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) #define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h index 9eb7a83..25dd7d2 100644 --- a/drivers/net/wireless/iwlegacy/commands.h +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -74,7 +74,6 @@ struct il_priv; #define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) #define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) - /* Tx rates */ #define IL_CCK_RATES 4 #define IL_OFDM_RATES 8 @@ -98,11 +97,11 @@ enum { C_WEPKEY = 0x20, /* RX, TX, LEDs */ - N_3945_RX = 0x1b, /* 3945 only */ + N_3945_RX = 0x1b, /* 3945 only */ C_TX = 0x1c, C_RATE_SCALE = 0x47, /* 3945 only */ C_LEDS = 0x48, - C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ + C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ /* 802.11h related */ C_CHANNEL_SWITCH = 0x72, @@ -124,7 +123,7 @@ enum { /* IBSS/AP commands */ N_BEACON = 0x90, - C_TX_BEACON= 0x91, + C_TX_BEACON = 0x91, /* Miscellaneous commands */ C_TX_PWR_TBL = 0x97, @@ -177,8 +176,8 @@ enum { * driver, and each response/notification received from uCode. */ struct il_cmd_header { - u8 cmd; /* Command ID: C_RXON, etc. */ - u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ + u8 cmd; /* Command ID: C_RXON, etc. */ + u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ /* * The driver sets up the sequence number to values of its choosing. * uCode does not use this value, but passes it back to the driver @@ -194,20 +193,19 @@ struct il_cmd_header { * * The Linux driver uses the following format: * - * 0:7 tfd idx - position within TX queue - * 8:12 TX queue id - * 13 reserved - * 14 huge - driver sets this to indicate command is in the - * 'huge' storage at the end of the command buffers - * 15 unsolicited RX or uCode-originated notification - */ + * 0:7 tfd idx - position within TX queue + * 8:12 TX queue id + * 13 reserved + * 14 huge - driver sets this to indicate command is in the + * 'huge' storage at the end of the command buffers + * 15 unsolicited RX or uCode-originated notification + */ __le16 sequence; /* command or response/notification data follows immediately */ u8 data[0]; } __packed; - /** * struct il3945_tx_power * @@ -430,7 +428,6 @@ struct il_init_alive_resp { * 2 Tx chains */ } __packed; - /** * N_ALIVE = 0x1 (response only, not a command) * @@ -514,7 +511,7 @@ struct il_alive_resp { __le16 reserved1; u8 sw_rev[8]; u8 ver_type; - u8 ver_subtype; /* not "9" for runtime alive */ + u8 ver_subtype; /* not "9" for runtime alive */ __le16 reserved2; __le32 log_event_table_ptr; /* SRAM address for event log */ __le32 error_event_table_ptr; /* SRAM address for error log */ @@ -551,7 +548,6 @@ enum { RXON_DEV_TYPE_SNIFFER = 6, }; - #define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0) #define RXON_RX_CHAIN_DRIVER_FORCE_POS (0) #define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1) @@ -590,7 +586,6 @@ enum { * (according to ON_AIR deassertion) */ #define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15) - /* HT flags */ #define RXON_FLG_CTRL_CHANNEL_LOC_POS (22) #define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22) @@ -718,7 +713,6 @@ struct il_rxon_cmd { u8 reserved5; } __packed; - /* * C_RXON_ASSOC = 0x11 (command, has simple generic response) */ @@ -742,8 +736,8 @@ struct il4965_rxon_assoc_cmd { } __packed; #define IL_CONN_MAX_LISTEN_INTERVAL 10 -#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ -#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ +#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ +#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* * C_RXON_TIMING = 0x14 (command, has simple generic response) @@ -856,7 +850,7 @@ struct il_qosparam_cmd { #define IL4965_BROADCAST_ID 31 #define IL4965_STATION_COUNT 32 -#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ +#define IL_STATION_COUNT 32 /* MAX(3945,4965) */ #define IL_INVALID_STATION 255 #define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) @@ -964,7 +958,7 @@ struct il3945_addsta_cmd { u8 reserved[3]; struct sta_id_modify sta; struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) @@ -992,7 +986,7 @@ struct il4965_addsta_cmd { u8 reserved[3]; struct sta_id_modify sta; struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) @@ -1000,7 +994,7 @@ struct il4965_addsta_cmd { * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ __le16 tid_disable_tx; - __le16 reserved1; + __le16 reserved1; /* TID for which to add block-ack support. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ @@ -1030,7 +1024,7 @@ struct il_addsta_cmd { u8 reserved[3]; struct sta_id_modify sta; struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) @@ -1038,7 +1032,7 @@ struct il_addsta_cmd { * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ __le16 tid_disable_tx; - __le16 rate_n_flags; /* 3945 only */ + __le16 rate_n_flags; /* 3945 only */ /* TID for which to add block-ack support. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ @@ -1062,7 +1056,6 @@ struct il_addsta_cmd { __le16 reserved2; } __packed; - #define ADD_STA_SUCCESS_MSK 0x1 #define ADD_STA_NO_ROOM_IN_TBL 0x2 #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 @@ -1071,7 +1064,7 @@ struct il_addsta_cmd { * C_ADD_STA = 0x18 (response) */ struct il_add_sta_resp { - u8 status; /* ADD_STA_* */ + u8 status; /* ADD_STA_* */ } __packed; #define REM_STA_SUCCESS_MSK 0x1 @@ -1086,9 +1079,9 @@ struct il_rem_sta_resp { * C_REM_STA = 0x19 (command) */ struct il_rem_sta_cmd { - u8 num_sta; /* number of removed stations */ + u8 num_sta; /* number of removed stations */ u8 reserved[3]; - u8 addr[ETH_ALEN]; /* MAC addr of the first station */ + u8 addr[ETH_ALEN]; /* MAC addr of the first station */ u8 reserved2[2]; } __packed; @@ -1165,7 +1158,6 @@ struct il_wep_cmd { #define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7) #define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) - struct il3945_rx_frame_stats { u8 phy_count; u8 id; @@ -1221,21 +1213,20 @@ struct il4965_rx_non_cfg_phy { u8 pad[0]; } __packed; - /* * N_RX = 0xc3 (response only, not a command) * Used only for legacy (non 11n) frames. */ struct il_rx_phy_res { - u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ + u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ u8 stat_id; /* configurable DSP phy data set ID */ u8 reserved1; __le64 timestamp; /* TSF at on air rise */ - __le32 beacon_time_stamp; /* beacon at on-air rise */ + __le32 beacon_time_stamp; /* beacon at on-air rise */ __le16 phy_flags; /* general phy flags: band, modulation, ... */ __le16 channel; /* channel number */ - u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ + u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ __le32 rate_n_flags; /* RATE_MCS_* */ __le16 byte_count; /* frame's byte-count */ __le16 frame_time; /* frame's time on the air */ @@ -1246,7 +1237,6 @@ struct il_rx_mpdu_res_start { __le16 reserved; } __packed; - /****************************************************************************** * (5) * Tx Commands & Responses: @@ -1346,7 +1336,6 @@ struct il_rx_mpdu_res_start { /* HCCA-AP - disable duration overwriting. */ #define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25) - /* * TX command security control */ @@ -1442,7 +1431,6 @@ struct il3945_tx_resp { __le32 status; /* TX status */ } __packed; - /* * 4965 uCode updates these Tx attempt count values in host DRAM. * Used for managing Tx retries when expecting block-acks. @@ -1625,12 +1613,12 @@ enum { }; enum { - TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ + TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ TX_STATUS_DELAY_MSK = 0x00000040, TX_STATUS_ABORT_MSK = 0x00000080, TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */ TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */ - TX_RESERVED = 0x00780000, /* bits 19:22 */ + TX_RESERVED = 0x00780000, /* bits 19:22 */ TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */ TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ }; @@ -1727,7 +1715,7 @@ struct il4965_tx_resp { */ union { __le32 status; - struct agg_tx_status agg_status[0]; /* for each agg frame */ + struct agg_tx_status agg_status[0]; /* for each agg frame */ } u; } __packed; @@ -1770,7 +1758,6 @@ struct il4965_txpowertable_cmd { struct il4965_tx_power_db tx_power; } __packed; - /** * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response * @@ -1798,7 +1785,6 @@ struct il3945_rate_scaling_cmd { struct il3945_rate_scaling_info table[IL_MAX_RATES]; } __packed; - /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */ #define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0) @@ -1813,7 +1799,6 @@ struct il3945_rate_scaling_cmd { #define LINK_QUAL_ANT_B_MSK (1 << 1) #define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK) - /** * struct il_link_qual_general_params * @@ -1829,7 +1814,7 @@ struct il_link_qual_general_params { u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */ /* Best antennas to use for MIMO (unused for 4965, assumes both). */ - u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ + u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ /* * If driver needs to use different initial rates for different @@ -1845,7 +1830,7 @@ struct il_link_qual_general_params { u8 start_rate_idx[LINK_QUAL_AC_NUM]; } __packed; -#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ +#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ #define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000) #define LINK_QUAL_AGG_TIME_LIMIT_MIN (100) @@ -2129,7 +2114,6 @@ struct il_bt_cmd { __le32 kill_cts_mask; } __packed; - /****************************************************************************** * (6) * Spectrum Management (802.11h) Commands, Responses, Notifications: @@ -2230,7 +2214,7 @@ enum il_measure_type { struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ u8 token; - u8 channel_idx; /* idx in measurement channel list */ + u8 channel_idx; /* idx in measurement channel list */ u8 state; /* 0 - start, 1 - stop */ __le32 start_time; /* lower 32-bits of TSF */ u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ @@ -2306,8 +2290,8 @@ struct il3945_powertable_cmd { struct il_powertable_cmd { __le16 flags; - u8 keep_alive_seconds; /* 3945 reserved */ - u8 debug_flags; /* 3945 reserved */ + u8 keep_alive_seconds; /* 3945 reserved */ + u8 debug_flags; /* 3945 reserved */ __le32 rx_data_timeout; __le32 tx_data_timeout; __le32 sleep_interval[IL_POWER_VEC_SIZE]; @@ -2355,10 +2339,10 @@ struct il_card_state_notif { #define RXON_CARD_DISABLED 0x10 struct il_ct_kill_config { - __le32 reserved; - __le32 critical_temperature_M; - __le32 critical_temperature_R; -} __packed; + __le32 reserved; + __le32 critical_temperature_M; + __le32 critical_temperature_R; +} __packed; /****************************************************************************** * (8) @@ -2397,7 +2381,7 @@ struct il3945_scan_channel { * 5:7 reserved */ u8 type; - u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ + u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ struct il3945_tx_power tpc; __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ @@ -2415,7 +2399,7 @@ struct il_scan_channel { * 21:31 reserved */ __le32 type; - __le16 channel; /* band is selected by il_scan_cmd "flags" field */ + __le16 channel; /* band is selected by il_scan_cmd "flags" field */ u8 tx_gain; /* gain for analog radio */ u8 dsp_atten; /* gain for DSP */ __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ @@ -2631,7 +2615,7 @@ struct il_scanresults_notification { u8 channel; u8 band; u8 probe_status; - u8 num_probe_not_sent; /* not enough time to send */ + u8 num_probe_not_sent; /* not enough time to send */ __le32 tsf_low; __le32 tsf_high; __le32 stats[NUMBER_OF_STATS]; @@ -2648,7 +2632,6 @@ struct il_scancomplete_notification { __le32 tsf_high; } __packed; - /****************************************************************************** * (9) * IBSS/AP Commands and Notifications: @@ -2849,15 +2832,15 @@ struct stats_rx_non_phy { __le32 num_missed_bcon; /* number of missed beacons */ __le32 adc_rx_saturation_time; /* count in 0.8us units the time the * ADC was in saturation */ - __le32 ina_detection_search_time;/* total time (in 0.8us) searched - * for INA */ + __le32 ina_detection_search_time; /* total time (in 0.8us) searched + * for INA */ __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */ __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */ __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */ __le32 interference_data_flag; /* flag for interference data * availability. 1 when data is * available. */ - __le32 channel_load; /* counts RX Enable time in uSec */ + __le32 channel_load; /* counts RX Enable time in uSec */ __le32 dsp_false_alarms; /* DSP false alarm (both OFDM * and CCK) counter */ __le32 beacon_rssi_a; @@ -2922,7 +2905,6 @@ struct stats_tx { __le32 reserved1; } __packed; - struct stats_div { __le32 tx_on_a; __le32 tx_on_b; @@ -2933,7 +2915,7 @@ struct stats_div { } __packed; struct stats_general_common { - __le32 temperature; /* radio temperature */ + __le32 temperature; /* radio temperature */ struct stats_dbg dbg; __le32 sleep_time; __le32 slots_out; @@ -2975,7 +2957,7 @@ struct stats_general { * does not affect the response to the C_STATS 0x9c itself. */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ -#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ +#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2) /* see above */ struct il_stats_cmd { __le32 configuration_flags; /* IL_STATS_CONF_* */ } __packed; @@ -3043,7 +3025,6 @@ struct il_missed_beacon_notif { __le32 num_recvd_beacons; } __packed; - /****************************************************************************** * (11) * Rx Calibration Commands: @@ -3241,11 +3222,10 @@ struct il_missed_beacon_notif { * Always use "1" in "control" to update uCode's working table and DSP. */ struct il_sensitivity_cmd { - __le16 control; /* always use "1" */ + __le16 control; /* always use "1" */ __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ } __packed; - /** * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) * @@ -3305,8 +3285,8 @@ struct il_sensitivity_cmd { /* The default calibrate table size if not specified by firmware */ #define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 enum { - IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, - IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, + IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, + IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, }; #define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) @@ -3350,7 +3330,6 @@ struct il_led_cmd { u8 reserved; } __packed; - /****************************************************************************** * (13) * Union of all expected notifications/responses: @@ -3394,4 +3373,4 @@ struct il_rx_pkt { } u; } __packed; -#endif /* __il_commands_h__ */ +#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 627ac9b..2e1bbb2 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -42,7 +42,8 @@ #include "common.h" -const char *il_get_cmd_string(u8 cmd) +const char * +il_get_cmd_string(u8 cmd) { switch (cmd) { IL_CMD(N_ALIVE); @@ -91,30 +92,30 @@ const char *il_get_cmd_string(u8 cmd) } } + EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) -static void il_generic_cmd_callback(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt) +static void +il_generic_cmd_callback(struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } - #ifdef CONFIG_IWLEGACY_DEBUG switch (cmd->hdr.cmd) { case C_TX_LINK_QUALITY_CMD: case C_SENSITIVITY: D_HC_DUMP("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - D_HC("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + D_HC("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), + pkt->hdr.flags); } #endif } @@ -139,13 +140,14 @@ il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) ret = il_enqueue_hcmd(il, cmd); if (ret < 0) { IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); + il_get_cmd_string(cmd->id), ret); return ret; } return 0; } -int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) +int +il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) { int cmd_idx; int ret; @@ -154,38 +156,36 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) BUG_ON(cmd->flags & CMD_ASYNC); - /* A synchronous command can not have a callback set. */ + /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); D_INFO("Attempting to send sync command %s\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); set_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Setting HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); cmd_idx = il_enqueue_hcmd(il, cmd); if (cmd_idx < 0) { ret = cmd_idx; IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); + il_get_cmd_string(cmd->id), ret); goto out; } ret = wait_event_timeout(il->wait_command_queue, - !test_bit(S_HCMD_ACTIVE, &il->status), - HOST_COMPLETE_TIMEOUT); + !test_bit(S_HCMD_ACTIVE, &il->status), + HOST_COMPLETE_TIMEOUT); if (!ret) { if (test_bit(S_HCMD_ACTIVE, &il->status)) { - IL_ERR( - "Error sending %s: time out after %dms.\n", - il_get_cmd_string(cmd->id), - jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); + IL_ERR("Error sending %s: time out after %dms.\n", + il_get_cmd_string(cmd->id), + jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); clear_bit(S_HCMD_ACTIVE, &il->status); - D_INFO( - "Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); + D_INFO("Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; goto cancel; } @@ -193,19 +193,19 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) if (test_bit(S_RF_KILL_HW, &il->status)) { IL_ERR("Command %s aborted: RF KILL Switch\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } if (test_bit(S_FW_ERROR, &il->status)) { IL_ERR("Command %s failed: FW Error\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { IL_ERR("Error: Response NULL in '%s'\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; } @@ -221,8 +221,7 @@ cancel: * in later, it will possibly set an invalid * address (cmd->meta.source). */ - il->txq[il->cmd_queue].meta[cmd_idx].flags &= - ~CMD_WANT_SKB; + il->txq[il->cmd_queue].meta[cmd_idx].flags &= ~CMD_WANT_SKB; } fail: if (cmd->reply_page) { @@ -232,15 +231,18 @@ fail: out: return ret; } + EXPORT_SYMBOL(il_send_cmd_sync); -int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) +int +il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) { if (cmd->flags & CMD_ASYNC) return il_send_cmd_async(il, cmd); return il_send_cmd_sync(il, cmd); } + EXPORT_SYMBOL(il_send_cmd); int @@ -254,13 +256,14 @@ il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) return il_send_cmd_sync(il, &cmd); } + EXPORT_SYMBOL(il_send_cmd_pdu); -int il_send_cmd_pdu_async(struct il_priv *il, - u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)) +int +il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, + void (*callback) (struct il_priv * il, + struct il_device_cmd * cmd, + struct il_rx_pkt * pkt)) { struct il_host_cmd cmd = { .id = id, @@ -273,13 +276,14 @@ int il_send_cmd_pdu_async(struct il_priv *il, return il_send_cmd_async(il, &cmd); } + EXPORT_SYMBOL(il_send_cmd_pdu_async); /* default: IL_LED_BLINK(0) using blinking idx table */ static int led_mode; module_param(led_mode, int, S_IRUGO); -MODULE_PARM_DESC(led_mode, "0=system default, " - "1=On(RF On)/Off(RF Off), 2=blinking"); +MODULE_PARM_DESC(led_mode, + "0=system default, " "1=On(RF On)/Off(RF Off), 2=blinking"); /* Throughput OFF time(ms) ON time (ms) * >300 25 25 @@ -295,16 +299,16 @@ MODULE_PARM_DESC(led_mode, "0=system default, " * <=0 SOLID ON */ static const struct ieee80211_tpt_blink il_blink[] = { - { .throughput = 0, .blink_time = 334 }, - { .throughput = 1 * 1024 - 1, .blink_time = 260 }, - { .throughput = 5 * 1024 - 1, .blink_time = 220 }, - { .throughput = 10 * 1024 - 1, .blink_time = 190 }, - { .throughput = 20 * 1024 - 1, .blink_time = 170 }, - { .throughput = 50 * 1024 - 1, .blink_time = 150 }, - { .throughput = 70 * 1024 - 1, .blink_time = 130 }, - { .throughput = 100 * 1024 - 1, .blink_time = 110 }, - { .throughput = 200 * 1024 - 1, .blink_time = 80 }, - { .throughput = 300 * 1024 - 1, .blink_time = 50 }, + {.throughput = 0,.blink_time = 334}, + {.throughput = 1 * 1024 - 1,.blink_time = 260}, + {.throughput = 5 * 1024 - 1,.blink_time = 220}, + {.throughput = 10 * 1024 - 1,.blink_time = 190}, + {.throughput = 20 * 1024 - 1,.blink_time = 170}, + {.throughput = 50 * 1024 - 1,.blink_time = 150}, + {.throughput = 70 * 1024 - 1,.blink_time = 130}, + {.throughput = 100 * 1024 - 1,.blink_time = 110}, + {.throughput = 200 * 1024 - 1,.blink_time = 80}, + {.throughput = 300 * 1024 - 1,.blink_time = 50}, }; /* @@ -318,22 +322,21 @@ static const struct ieee80211_tpt_blink il_blink[] = { * compensation = (100 - averageDeviation) * 64 / 100 * NewBlinkTime = (compensation * BlinkTime) / 64 */ -static inline u8 il_blink_compensation(struct il_priv *il, - u8 time, u16 compensation) +static inline u8 +il_blink_compensation(struct il_priv *il, u8 time, u16 compensation) { if (!compensation) { IL_ERR("undefined blink compensation: " - "use pre-defined blinking time\n"); + "use pre-defined blinking time\n"); return time; } - return (u8)((time * compensation) >> 6); + return (u8) ((time * compensation) >> 6); } /* Set led pattern command */ -static int il_led_cmd(struct il_priv *il, - unsigned long on, - unsigned long off) +static int +il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off) { struct il_led_cmd led_cmd = { .id = IL_LED_LINK, @@ -353,11 +356,13 @@ static int il_led_cmd(struct il_priv *il, } D_LED("Led blink time compensation=%u\n", - il->cfg->base_params->led_compensation); - led_cmd.on = il_blink_compensation(il, on, - il->cfg->base_params->led_compensation); - led_cmd.off = il_blink_compensation(il, off, - il->cfg->base_params->led_compensation); + il->cfg->base_params->led_compensation); + led_cmd.on = + il_blink_compensation(il, on, + il->cfg->base_params->led_compensation); + led_cmd.off = + il_blink_compensation(il, off, + il->cfg->base_params->led_compensation); ret = il->cfg->ops->led->cmd(il, &led_cmd); if (!ret) { @@ -367,8 +372,9 @@ static int il_led_cmd(struct il_priv *il, return ret; } -static void il_led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brightness) +static void +il_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) { struct il_priv *il = container_of(led_cdev, struct il_priv, led); unsigned long on = 0; @@ -379,16 +385,17 @@ static void il_led_brightness_set(struct led_classdev *led_cdev, il_led_cmd(il, on, 0); } -static int il_led_blink_set(struct led_classdev *led_cdev, - unsigned long *delay_on, - unsigned long *delay_off) +static int +il_led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, + unsigned long *delay_off) { struct il_priv *il = container_of(led_cdev, struct il_priv, led); return il_led_cmd(il, *delay_on, *delay_off); } -void il_leds_init(struct il_priv *il) +void +il_leds_init(struct il_priv *il) { int mode = led_mode; int ret; @@ -396,8 +403,8 @@ void il_leds_init(struct il_priv *il) if (mode == IL_LED_DEFAULT) mode = il->cfg->led_mode; - il->led.name = kasprintf(GFP_KERNEL, "%s-led", - wiphy_name(il->hw->wiphy)); + il->led.name = + kasprintf(GFP_KERNEL, "%s-led", wiphy_name(il->hw->wiphy)); il->led.brightness_set = il_led_brightness_set; il->led.blink_set = il_led_blink_set; il->led.max_brightness = 1; @@ -408,13 +415,13 @@ void il_leds_init(struct il_priv *il) break; case IL_LED_BLINK: il->led.default_trigger = - ieee80211_create_tpt_led_trigger(il->hw, - IEEE80211_TPT_LEDTRIG_FL_CONNECTED, - il_blink, ARRAY_SIZE(il_blink)); + ieee80211_create_tpt_led_trigger(il->hw, + IEEE80211_TPT_LEDTRIG_FL_CONNECTED, + il_blink, + ARRAY_SIZE(il_blink)); break; case IL_LED_RF_STATE: - il->led.default_trigger = - ieee80211_get_radio_led_name(il->hw); + il->led.default_trigger = ieee80211_get_radio_led_name(il->hw); break; } @@ -426,9 +433,11 @@ void il_leds_init(struct il_priv *il) il->led_registered = true; } + EXPORT_SYMBOL(il_leds_init); -void il_leds_exit(struct il_priv *il) +void +il_leds_exit(struct il_priv *il) { if (!il->led_registered) return; @@ -436,6 +445,7 @@ void il_leds_exit(struct il_priv *il) led_classdev_unregister(&il->led); kfree(il->led.name); } + EXPORT_SYMBOL(il_leds_exit); /************************** EEPROM BANDS **************************** @@ -491,11 +501,11 @@ static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ 145, 149, 153, 157, 161, 165 }; -static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ +static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ 1, 2, 3, 4, 5, 6, 7 }; -static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ +static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 }; @@ -505,7 +515,8 @@ static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ * ******************************************************************************/ -static int il_eeprom_verify_signature(struct il_priv *il) +static int +il_eeprom_verify_signature(struct il_priv *il) { u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; @@ -516,28 +527,30 @@ static int il_eeprom_verify_signature(struct il_priv *il) case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IL_ERR("bad EEPROM signature," - "EEPROM_GP=0x%08x\n", gp); + IL_ERR("bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; } return ret; } -const u8 -*il_eeprom_query_addr(const struct il_priv *il, size_t offset) +const u8 * +il_eeprom_query_addr(const struct il_priv *il, size_t offset) { BUG_ON(offset >= il->cfg->base_params->eeprom_size); return &il->eeprom[offset]; } + EXPORT_SYMBOL(il_eeprom_query_addr); -u16 il_eeprom_query16(const struct il_priv *il, size_t offset) +u16 +il_eeprom_query16(const struct il_priv * il, size_t offset) { if (!il->eeprom) return 0; - return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); + return (u16) il->eeprom[offset] | ((u16) il->eeprom[offset + 1] << 8); } + EXPORT_SYMBOL(il_eeprom_query16); /** @@ -547,7 +560,8 @@ EXPORT_SYMBOL(il_eeprom_query16); * * NOTE: This routine uses the non-debug IO access functions. */ -int il_eeprom_init(struct il_priv *il) +int +il_eeprom_init(struct il_priv *il) { __le16 *e; u32 gp = _il_rd(il, CSR_EEPROM_GP); @@ -563,7 +577,7 @@ int il_eeprom_init(struct il_priv *il) ret = -ENOMEM; goto alloc_err; } - e = (__le16 *)il->eeprom; + e = (__le16 *) il->eeprom; il->cfg->ops->lib->apm_ops.init(il); @@ -587,24 +601,23 @@ int il_eeprom_init(struct il_priv *il) u32 r; _il_wr(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); + CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = _il_poll_bit(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_READ_VALID_MSK, - CSR_EEPROM_REG_READ_VALID_MSK, - IL_EEPROM_ACCESS_TIMEOUT); + ret = + _il_poll_bit(il, CSR_EEPROM_REG, + CSR_EEPROM_REG_READ_VALID_MSK, + CSR_EEPROM_REG_READ_VALID_MSK, + IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IL_ERR("Time out reading EEPROM[%d]\n", - addr); + IL_ERR("Time out reading EEPROM[%d]\n", addr); goto done; } r = _il_rd(il, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } - D_EEPROM("NVM Type: %s, version: 0x%x\n", - "EEPROM", - il_eeprom_query16(il, EEPROM_VERSION)); + D_EEPROM("NVM Type: %s, version: 0x%x\n", "EEPROM", + il_eeprom_query16(il, EEPROM_VERSION)); ret = 0; done: @@ -618,63 +631,74 @@ err: alloc_err: return ret; } + EXPORT_SYMBOL(il_eeprom_init); -void il_eeprom_free(struct il_priv *il) +void +il_eeprom_free(struct il_priv *il) { kfree(il->eeprom); il->eeprom = NULL; } + EXPORT_SYMBOL(il_eeprom_free); -static void il_init_band_reference(const struct il_priv *il, - int eep_band, int *eeprom_ch_count, - const struct il_eeprom_channel **eeprom_ch_info, - const u8 **eeprom_ch_idx) +static void +il_init_band_reference(const struct il_priv *il, int eep_band, + int *eeprom_ch_count, + const struct il_eeprom_channel **eeprom_ch_info, + const u8 ** eeprom_ch_idx) { - u32 offset = il->cfg->ops->lib-> - eeprom_ops.regulatory_bands[eep_band - 1]; + u32 offset = + il->cfg->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_7; break; default: @@ -689,41 +713,35 @@ static void il_init_band_reference(const struct il_priv *il, * * Does not set up a command, or touch hardware. */ -static int il_mod_ht40_chan_info(struct il_priv *il, - enum ieee80211_band band, u16 channel, - const struct il_eeprom_channel *eeprom_ch, - u8 clear_ht40_extension_channel) +static int +il_mod_ht40_chan_info(struct il_priv *il, enum ieee80211_band band, u16 channel, + const struct il_eeprom_channel *eeprom_ch, + u8 clear_ht40_extension_channel) { struct il_channel_info *ch_info; - ch_info = (struct il_channel_info *) - il_get_channel_info(il, band, channel); + ch_info = + (struct il_channel_info *)il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) return -1; D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT(IBSS), - CHECK_AND_PRINT(ACTIVE), - CHECK_AND_PRINT(RADAR), - CHECK_AND_PRINT(WIDE), - CHECK_AND_PRINT(DFS), - eeprom_ch->flags, - eeprom_ch->max_power_avg, - ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? - "" : "not "); + " Ad-Hoc %ssupported\n", ch_info->channel, + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", + CHECK_AND_PRINT(IBSS), CHECK_AND_PRINT(ACTIVE), + CHECK_AND_PRINT(RADAR), CHECK_AND_PRINT(WIDE), + CHECK_AND_PRINT(DFS), eeprom_ch->flags, + eeprom_ch->max_power_avg, + ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) && + !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? "" : "not "); ch_info->ht40_eeprom = *eeprom_ch; ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; ch_info->ht40_flags = eeprom_ch->flags; if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) ch_info->ht40_extension_channel &= - ~clear_ht40_extension_channel; + ~clear_ht40_extension_channel; return 0; } @@ -734,7 +752,8 @@ static int il_mod_ht40_chan_info(struct il_priv *il, /** * il_init_channel_map - Set up driver's info for all possible channels */ -int il_init_channel_map(struct il_priv *il) +int +il_init_channel_map(struct il_priv *il) { int eeprom_ch_count = 0; const u8 *eeprom_ch_idx = NULL; @@ -750,17 +769,15 @@ int il_init_channel_map(struct il_priv *il) D_EEPROM("Initializing regulatory info from EEPROM\n"); il->channel_count = - ARRAY_SIZE(il_eeprom_band_1) + - ARRAY_SIZE(il_eeprom_band_2) + - ARRAY_SIZE(il_eeprom_band_3) + - ARRAY_SIZE(il_eeprom_band_4) + + ARRAY_SIZE(il_eeprom_band_1) + ARRAY_SIZE(il_eeprom_band_2) + + ARRAY_SIZE(il_eeprom_band_3) + ARRAY_SIZE(il_eeprom_band_4) + ARRAY_SIZE(il_eeprom_band_5); - D_EEPROM("Parsing data for %d channels.\n", - il->channel_count); + D_EEPROM("Parsing data for %d channels.\n", il->channel_count); - il->channel_info = kzalloc(sizeof(struct il_channel_info) * - il->channel_count, GFP_KERNEL); + il->channel_info = + kzalloc(sizeof(struct il_channel_info) * il->channel_count, + GFP_KERNEL); if (!il->channel_info) { IL_ERR("Could not allocate channel_info\n"); il->channel_count = 0; @@ -775,13 +792,14 @@ int il_init_channel_map(struct il_priv *il) for (band = 1; band <= 5; band++) { il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); + &eeprom_ch_info, &eeprom_ch_idx); /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { ch_info->channel = eeprom_ch_idx[ch]; - ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : - IEEE80211_BAND_5GHZ; + ch_info->band = + (band == + 1) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; /* permanently store EEPROM's channel regulatory flags * and max power in channel info database. */ @@ -793,16 +811,14 @@ int il_init_channel_map(struct il_priv *il) /* First write that ht40 is not enabled, and then enable * one by one */ ch_info->ht40_extension_channel = - IEEE80211_CHAN_NO_HT40; + IEEE80211_CHAN_NO_HT40; if (!(il_is_channel_valid(ch_info))) { - D_EEPROM( - "Ch. %d Flags %x [%sGHz] - " - "No traffic\n", - ch_info->channel, - ch_info->flags, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4"); + D_EEPROM("Ch. %d Flags %x [%sGHz] - " + "No traffic\n", ch_info->channel, + ch_info->flags, + il_is_channel_a_band(ch_info) ? "5.2" : + "2.4"); ch_info++; continue; } @@ -813,25 +829,22 @@ int il_init_channel_map(struct il_priv *il) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - D_EEPROM("Ch. %d [%sGHz] " - "%s%s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT_I(VALID), - CHECK_AND_PRINT_I(IBSS), - CHECK_AND_PRINT_I(ACTIVE), - CHECK_AND_PRINT_I(RADAR), - CHECK_AND_PRINT_I(WIDE), - CHECK_AND_PRINT_I(DFS), - eeprom_ch_info[ch].flags, - eeprom_ch_info[ch].max_power_avg, - ((eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_RADAR)) - ? "" : "not "); + D_EEPROM("Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" + " Ad-Hoc %ssupported\n", ch_info->channel, + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", + CHECK_AND_PRINT_I(VALID), + CHECK_AND_PRINT_I(IBSS), + CHECK_AND_PRINT_I(ACTIVE), + CHECK_AND_PRINT_I(RADAR), + CHECK_AND_PRINT_I(WIDE), + CHECK_AND_PRINT_I(DFS), + eeprom_ch_info[ch].flags, + eeprom_ch_info[ch].max_power_avg, + ((eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_IBSS) && + !(eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_RADAR)) ? "" : + "not "); ch_info++; } @@ -849,40 +862,42 @@ int il_init_channel_map(struct il_priv *il) enum ieee80211_band ieeeband; il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); + &eeprom_ch_info, &eeprom_ch_idx); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ ieeeband = - (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ - il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch], - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40PLUS); + il_mod_ht40_chan_info(il, ieeeband, eeprom_ch_idx[ch], + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch] + 4, - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40MINUS); + eeprom_ch_idx[ch] + 4, + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40MINUS); } } return 0; } + EXPORT_SYMBOL(il_init_channel_map); /* * il_free_channel_map - undo allocations in il_init_channel_map */ -void il_free_channel_map(struct il_priv *il) +void +il_free_channel_map(struct il_priv *il) { kfree(il->channel_info); il->channel_count = 0; } + EXPORT_SYMBOL(il_free_channel_map); /** @@ -890,9 +905,9 @@ EXPORT_SYMBOL(il_free_channel_map); * * Based on band and channel number. */ -const struct -il_channel_info *il_get_channel_info(const struct il_priv *il, - enum ieee80211_band band, u16 channel) +const struct il_channel_info * +il_get_channel_info(const struct il_priv *il, enum ieee80211_band band, + u16 channel) { int i; @@ -913,6 +928,7 @@ il_channel_info *il_get_channel_info(const struct il_priv *il, return NULL; } + EXPORT_SYMBOL(il_get_channel_info); /* @@ -930,11 +946,11 @@ EXPORT_SYMBOL(il_get_channel_info); struct il_power_vec_entry { struct il_powertable_cmd cmd; - u8 no_dtim; /* number of skip dtim */ + u8 no_dtim; /* number of skip dtim */ }; -static void il_power_sleep_cam_cmd(struct il_priv *il, - struct il_powertable_cmd *cmd) +static void +il_power_sleep_cam_cmd(struct il_priv *il, struct il_powertable_cmd *cmd) { memset(cmd, 0, sizeof(*cmd)); @@ -949,25 +965,21 @@ il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) { D_POWER("Sending power/sleep command\n"); D_POWER("Flags value = 0x%08X\n", cmd->flags); - D_POWER("Tx timeout = %u\n", - le32_to_cpu(cmd->tx_data_timeout)); - D_POWER("Rx timeout = %u\n", - le32_to_cpu(cmd->rx_data_timeout)); - D_POWER( - "Sleep interval vector = { %d , %d , %d , %d , %d }\n", - le32_to_cpu(cmd->sleep_interval[0]), - le32_to_cpu(cmd->sleep_interval[1]), - le32_to_cpu(cmd->sleep_interval[2]), - le32_to_cpu(cmd->sleep_interval[3]), - le32_to_cpu(cmd->sleep_interval[4])); + D_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); + D_POWER("Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); + D_POWER("Sleep interval vector = { %d , %d , %d , %d , %d }\n", + le32_to_cpu(cmd->sleep_interval[0]), + le32_to_cpu(cmd->sleep_interval[1]), + le32_to_cpu(cmd->sleep_interval[2]), + le32_to_cpu(cmd->sleep_interval[3]), + le32_to_cpu(cmd->sleep_interval[4])); return il_send_cmd_pdu(il, C_POWER_TBL, - sizeof(struct il_powertable_cmd), cmd); + sizeof(struct il_powertable_cmd), cmd); } int -il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, - bool force) +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force) { int ret; bool update_chains; @@ -976,7 +988,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, /* Don't update the RX chain when chain noise calibration is running */ update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || - il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; + il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) return 0; @@ -1002,10 +1014,9 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, if (il->cfg->ops->lib->update_chain_flags && update_chains) il->cfg->ops->lib->update_chain_flags(il); else if (il->cfg->ops->lib->update_chain_flags) - D_POWER( - "Cannot update the power, chain noise " - "calibration running: %d\n", - il->chain_noise_data.state); + D_POWER("Cannot update the power, chain noise " + "calibration running: %d\n", + il->chain_noise_data.state); memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else @@ -1014,17 +1025,20 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, return ret; } -int il_power_update_mode(struct il_priv *il, bool force) +int +il_power_update_mode(struct il_priv *il, bool force) { struct il_powertable_cmd cmd; il_power_sleep_cam_cmd(il, &cmd); return il_power_set_mode(il, &cmd, force); } + EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ -void il_power_initialize(struct il_priv *il) +void +il_power_initialize(struct il_priv *il) { u16 lctl = il_pcie_link_ctl(il); @@ -1032,15 +1046,14 @@ void il_power_initialize(struct il_priv *il) il->power_data.debug_sleep_level_override = -1; - memset(&il->power_data.sleep_cmd, 0, - sizeof(il->power_data.sleep_cmd)); + memset(&il->power_data.sleep_cmd, 0, sizeof(il->power_data.sleep_cmd)); } EXPORT_SYMBOL(il_power_initialize); /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after * sending probe req. This should be set long enough to hear probe responses * from more than one AP. */ -#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ +#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ #define IL_ACTIVE_DWELL_TIME_52 (20) #define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) @@ -1049,12 +1062,13 @@ EXPORT_SYMBOL(il_power_initialize); /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. * Must be set longer than active dwell time. * For the most reliable scan, set > AP beacon interval (typically 100msec). */ -#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ +#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ #define IL_PASSIVE_DWELL_TIME_52 (10) #define IL_PASSIVE_DWELL_BASE (100) #define IL_CHANNEL_TUNE_TIME 5 -static int il_send_scan_abort(struct il_priv *il) +static int +il_send_scan_abort(struct il_priv *il) { int ret; struct il_rx_pkt *pkt; @@ -1093,7 +1107,8 @@ static int il_send_scan_abort(struct il_priv *il) return ret; } -static void il_complete_scan(struct il_priv *il, bool aborted) +static void +il_complete_scan(struct il_priv *il, bool aborted) { /* check if scan was requested from mac80211 */ if (il->scan_request) { @@ -1105,7 +1120,8 @@ static void il_complete_scan(struct il_priv *il, bool aborted) il->scan_request = NULL; } -void il_force_scan_end(struct il_priv *il) +void +il_force_scan_end(struct il_priv *il) { lockdep_assert_held(&il->mutex); @@ -1121,7 +1137,8 @@ void il_force_scan_end(struct il_priv *il) il_complete_scan(il, true); } -static void il_do_scan_abort(struct il_priv *il) +static void +il_do_scan_abort(struct il_priv *il) { int ret; @@ -1148,12 +1165,14 @@ static void il_do_scan_abort(struct il_priv *il) /** * il_scan_cancel - Cancel any currently executing HW scan */ -int il_scan_cancel(struct il_priv *il) +int +il_scan_cancel(struct il_priv *il) { D_SCAN("Queuing abort scan\n"); queue_work(il->workqueue, &il->abort_scan); return 0; } + EXPORT_SYMBOL(il_scan_cancel); /** @@ -1161,7 +1180,8 @@ EXPORT_SYMBOL(il_scan_cancel); * @ms: amount of time to wait (in milliseconds) for scan to abort * */ -int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) +int +il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) { unsigned long timeout = jiffies + msecs_to_jiffies(ms); @@ -1179,11 +1199,12 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) return test_bit(S_SCAN_HW, &il->status); } + EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to C_SCAN (0x80) */ -static void il_hdl_scan(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1195,48 +1216,39 @@ static void il_hdl_scan(struct il_priv *il, } /* Service N_SCAN_START (0x82) */ -static void il_hdl_scan_start(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan_start(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; il->scan_start_tsf = le32_to_cpu(notif->tsf_low); - D_SCAN("Scan start: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - notif->status, notif->beacon_timer); + D_SCAN("Scan start: " "%d [802.11%s] " + "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, + notif->band ? "bg" : "a", le32_to_cpu(notif->tsf_high), + le32_to_cpu(notif->tsf_low), notif->status, notif->beacon_timer); } /* Service N_SCAN_RESULTS (0x83) */ -static void il_hdl_scan_results(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan_results(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; - D_SCAN("Scan ch.res: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d " - "elapsed=%lu usec\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - le32_to_cpu(notif->stats[0]), - le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); + D_SCAN("Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " + "elapsed=%lu usec\n", notif->channel, notif->band ? "bg" : "a", + le32_to_cpu(notif->tsf_high), le32_to_cpu(notif->tsf_low), + le32_to_cpu(notif->stats[0]), + le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); #endif } /* Service N_SCAN_COMPLETE (0x84) */ -static void il_hdl_scan_complete(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan_complete(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -1244,58 +1256,58 @@ static void il_hdl_scan_complete(struct il_priv *il, struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - D_SCAN( - "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", - scan_notif->scanned_channels, - scan_notif->tsf_low, - scan_notif->tsf_high, scan_notif->status); + D_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", + scan_notif->scanned_channels, scan_notif->tsf_low, + scan_notif->tsf_high, scan_notif->status); /* The HW is no longer scanning */ clear_bit(S_SCAN_HW, &il->status); D_SCAN("Scan on %sGHz took %dms\n", - (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", - jiffies_to_msecs(jiffies - il->scan_start)); + (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", + jiffies_to_msecs(jiffies - il->scan_start)); queue_work(il->workqueue, &il->scan_completed); } -void il_setup_rx_scan_handlers(struct il_priv *il) +void +il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ il->handlers[C_SCAN] = il_hdl_scan; - il->handlers[N_SCAN_START] = - il_hdl_scan_start; - il->handlers[N_SCAN_RESULTS] = - il_hdl_scan_results; - il->handlers[N_SCAN_COMPLETE] = - il_hdl_scan_complete; + il->handlers[N_SCAN_START] = il_hdl_scan_start; + il->handlers[N_SCAN_RESULTS] = il_hdl_scan_results; + il->handlers[N_SCAN_COMPLETE] = il_hdl_scan_complete; } + EXPORT_SYMBOL(il_setup_rx_scan_handlers); -inline u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes) +inline u16 +il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, + u8 n_probes) { if (band == IEEE80211_BAND_5GHZ) return IL_ACTIVE_DWELL_TIME_52 + - IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); + IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); else return IL_ACTIVE_DWELL_TIME_24 + - IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); } + EXPORT_SYMBOL(il_get_active_dwell_time); -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif) +u16 +il_get_passive_dwell_time(struct il_priv * il, enum ieee80211_band band, + struct ieee80211_vif * vif) { struct il_rxon_context *ctx = &il->ctx; u16 value; - u16 passive = (band == IEEE80211_BAND_2GHZ) ? - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; + u16 passive = + (band == + IEEE80211_BAND_2GHZ) ? IL_PASSIVE_DWELL_BASE + + IL_PASSIVE_DWELL_TIME_24 : IL_PASSIVE_DWELL_BASE + + IL_PASSIVE_DWELL_TIME_52; if (il_is_any_associated(il)) { /* @@ -1312,9 +1324,11 @@ u16 il_get_passive_dwell_time(struct il_priv *il, return passive; } + EXPORT_SYMBOL(il_get_passive_dwell_time); -void il_init_scan_params(struct il_priv *il) +void +il_init_scan_params(struct il_priv *il) { u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) @@ -1322,10 +1336,11 @@ void il_init_scan_params(struct il_priv *il) if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } + EXPORT_SYMBOL(il_init_scan_params); -static int il_scan_initiate(struct il_priv *il, - struct ieee80211_vif *vif) +static int +il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) { int ret; @@ -1342,8 +1357,7 @@ static int il_scan_initiate(struct il_priv *il, } if (test_bit(S_SCAN_HW, &il->status)) { - D_SCAN( - "Multiple concurrent scan requests in parallel.\n"); + D_SCAN("Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } @@ -1369,9 +1383,9 @@ static int il_scan_initiate(struct il_priv *il, return 0; } -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req) +int +il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct cfg80211_scan_request *req) { struct il_priv *il = hw->priv; int ret; @@ -1403,9 +1417,11 @@ out_unlock: return ret; } + EXPORT_SYMBOL(il_mac_hw_scan); -static void il_bg_scan_check(struct work_struct *data) +static void +il_bg_scan_check(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, scan_check.work); @@ -1426,7 +1442,7 @@ static void il_bg_scan_check(struct work_struct *data) u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ies, int ie_len, int left) + const u8 * ta, const u8 * ies, int ie_len, int left) { int len = 0; u8 *pos = NULL; @@ -1465,11 +1481,13 @@ il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, len += ie_len; } - return (u16)len; + return (u16) len; } + EXPORT_SYMBOL(il_fill_probe_req); -static void il_bg_abort_scan(struct work_struct *work) +static void +il_bg_abort_scan(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, abort_scan); @@ -1482,10 +1500,10 @@ static void il_bg_abort_scan(struct work_struct *work) mutex_unlock(&il->mutex); } -static void il_bg_scan_completed(struct work_struct *work) +static void +il_bg_scan_completed(struct work_struct *work) { - struct il_priv *il = - container_of(work, struct il_priv, scan_completed); + struct il_priv *il = container_of(work, struct il_priv, scan_completed); bool aborted; D_SCAN("Completed scan.\n"); @@ -1523,15 +1541,18 @@ out: mutex_unlock(&il->mutex); } -void il_setup_scan_deferred_work(struct il_priv *il) +void +il_setup_scan_deferred_work(struct il_priv *il) { INIT_WORK(&il->scan_completed, il_bg_scan_completed); INIT_WORK(&il->abort_scan, il_bg_abort_scan); INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); } + EXPORT_SYMBOL(il_setup_scan_deferred_work); -void il_cancel_scan_deferred_work(struct il_priv *il) +void +il_cancel_scan_deferred_work(struct il_priv *il) { cancel_work_sync(&il->abort_scan); cancel_work_sync(&il->scan_completed); @@ -1542,46 +1563,43 @@ void il_cancel_scan_deferred_work(struct il_priv *il) mutex_unlock(&il->mutex); } } + EXPORT_SYMBOL(il_cancel_scan_deferred_work); /* il->sta_lock must be held */ -static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) +static void +il_sta_ucode_activate(struct il_priv *il, u8 sta_id) { if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) - IL_ERR( - "ACTIVATE a non DRIVER active station id %u addr %pM\n", - sta_id, il->stations[sta_id].sta.sta.addr); + IL_ERR("ACTIVATE a non DRIVER active station id %u addr %pM\n", + sta_id, il->stations[sta_id].sta.sta.addr); if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { - D_ASSOC( - "STA id %u addr %pM already present" - " in uCode (according to driver)\n", - sta_id, il->stations[sta_id].sta.sta.addr); + D_ASSOC("STA id %u addr %pM already present" + " in uCode (according to driver)\n", sta_id, + il->stations[sta_id].sta.sta.addr); } else { il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; - D_ASSOC("Added STA id %u addr %pM to uCode\n", - sta_id, il->stations[sta_id].sta.sta.addr); + D_ASSOC("Added STA id %u addr %pM to uCode\n", sta_id, + il->stations[sta_id].sta.sta.addr); } } -static int il_process_add_sta_resp(struct il_priv *il, - struct il_addsta_cmd *addsta, - struct il_rx_pkt *pkt, - bool sync) +static int +il_process_add_sta_resp(struct il_priv *il, struct il_addsta_cmd *addsta, + struct il_rx_pkt *pkt, bool sync) { u8 sta_id = addsta->sta.sta_id; unsigned long flags; int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", - pkt->hdr.flags); + IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } - D_INFO("Processing response for adding station %u\n", - sta_id); + D_INFO("Processing response for adding station %u\n", sta_id); spin_lock_irqsave(&il->sta_lock, flags); @@ -1592,28 +1610,25 @@ static int il_process_add_sta_resp(struct il_priv *il, ret = 0; break; case ADD_STA_NO_ROOM_IN_TBL: - IL_ERR("Adding station %d failed, no room in table.\n", - sta_id); + IL_ERR("Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IL_ERR( - "Adding station %d failed, no block ack resource.\n", - sta_id); + IL_ERR("Adding station %d failed, no block ack resource.\n", + sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: IL_ERR("Attempting to modify non-existing station %d\n", - sta_id); + sta_id); break; default: - D_ASSOC("Received C_ADD_STA:(0x%08X)\n", - pkt->u.add_sta.status); + D_ASSOC("Received C_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } D_INFO("%s station id %u addr %pM\n", - il->stations[sta_id].sta.mode == - STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", - sta_id, il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", sta_id, + il->stations[sta_id].sta.sta.addr); /* * XXX: The MAC address in the command buffer is often changed from @@ -1624,27 +1639,25 @@ static int il_process_add_sta_resp(struct il_priv *il, * observe the problem. */ D_INFO("%s station according to cmd buffer %pM\n", - il->stations[sta_id].sta.mode == - STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", - addsta->sta.addr); + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static void il_add_sta_callback(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt) +static void +il_add_sta_callback(struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) { - struct il_addsta_cmd *addsta = - (struct il_addsta_cmd *)cmd->cmd.payload; + struct il_addsta_cmd *addsta = (struct il_addsta_cmd *)cmd->cmd.payload; il_process_add_sta_resp(il, addsta, pkt, false); } -int il_send_add_sta(struct il_priv *il, - struct il_addsta_cmd *sta, u8 flags) +int +il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) { struct il_rx_pkt *pkt = NULL; int ret = 0; @@ -1656,8 +1669,8 @@ int il_send_add_sta(struct il_priv *il, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - D_INFO("Adding sta %u (%pM) %ssynchronously\n", - sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); + D_INFO("Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, + flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) cmd.callback = il_add_sta_callback; @@ -1680,11 +1693,12 @@ int il_send_add_sta(struct il_priv *il, return ret; } + EXPORT_SYMBOL(il_send_add_sta); -static void il_set_ht_add_station(struct il_priv *il, u8 idx, - struct ieee80211_sta *sta, - struct il_rxon_context *ctx) +static void +il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, + struct il_rxon_context *ctx) { struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; __le32 sta_flags; @@ -1695,10 +1709,10 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; D_ASSOC("spatial multiplexing power save mode: %s\n", - (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? - "static" : - (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? - "dynamic" : "disabled"); + (mimo_ps_mode == + WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == + WLAN_HT_CAP_SM_PS_DYNAMIC) + ? "dynamic" : "disabled"); sta_flags = il->stations[idx].sta.station_flags; @@ -1718,11 +1732,13 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, break; } - sta_flags |= cpu_to_le32( - (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); + sta_flags |= + cpu_to_le32((u32) sta_ht_inf-> + ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); - sta_flags |= cpu_to_le32( - (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); + sta_flags |= + cpu_to_le32((u32) sta_ht_inf-> + ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) sta_flags |= STA_FLG_HT40_EN_MSK; @@ -1730,7 +1746,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, sta_flags &= ~STA_FLG_HT40_EN_MSK; il->stations[idx].sta.station_flags = sta_flags; - done: +done: return; } @@ -1739,8 +1755,9 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, * * should be called with sta_lock held */ -u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, struct ieee80211_sta *sta) +u8 +il_prep_station(struct il_priv * il, struct il_rxon_context * ctx, + const u8 * addr, bool is_ap, struct ieee80211_sta * sta) { struct il_station_entry *station; int i; @@ -1753,8 +1770,8 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, sta_id = ctx->bcast_sta_id; else for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { - if (!compare_ether_addr(il->stations[i].sta.sta.addr, - addr)) { + if (!compare_ether_addr + (il->stations[i].sta.sta.addr, addr)) { sta_id = i; break; } @@ -1777,25 +1794,21 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - D_INFO( - "STA %d already in process of being added.\n", - sta_id); + D_INFO("STA %d already in process of being added.\n", sta_id); return sta_id; } if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { - D_ASSOC( - "STA %d (%pM) already added, not adding again.\n", - sta_id, addr); + D_ASSOC("STA %d (%pM) already added, not adding again.\n", + sta_id, addr); return sta_id; } station = &il->stations[sta_id]; station->used = IL_STA_DRIVER_ACTIVE; - D_ASSOC("Add STA to driver ID %d: %pM\n", - sta_id, addr); + D_ASSOC("Add STA to driver ID %d: %pM\n", sta_id, addr); il->num_stations++; /* Set up the C_ADD_STA command to send to device */ @@ -1821,14 +1834,14 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, il_set_ht_add_station(il, sta_id, sta, ctx); /* 3945 only */ - rate = (il->band == IEEE80211_BAND_5GHZ) ? - RATE_6M_PLCP : RATE_1M_PLCP; + rate = (il->band == IEEE80211_BAND_5GHZ) ? RATE_6M_PLCP : RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); return sta_id; } + EXPORT_SYMBOL_GPL(il_prep_station); #define STA_WAIT_TIMEOUT (HZ/2) @@ -1837,10 +1850,9 @@ EXPORT_SYMBOL_GPL(il_prep_station); * il_add_station_common - */ int -il_add_station_common(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta, u8 *sta_id_r) +il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, bool is_ap, struct ieee80211_sta *sta, + u8 * sta_id_r) { unsigned long flags_spin; int ret = 0; @@ -1851,8 +1863,7 @@ il_add_station_common(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags_spin); sta_id = il_prep_station(il, ctx, addr, is_ap, sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR("Unable to prepare station %pM for addition\n", - addr); + IL_ERR("Unable to prepare station %pM for addition\n", addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; } @@ -1863,17 +1874,14 @@ il_add_station_common(struct il_priv *il, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - D_INFO( - "STA %d already in process of being added.\n", - sta_id); + D_INFO("STA %d already in process of being added.\n", sta_id); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; } if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - D_ASSOC( - "STA %d (%pM) already added, not adding again.\n", + D_ASSOC("STA %d (%pM) already added, not adding again.\n", sta_id, addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; @@ -1881,7 +1889,7 @@ il_add_station_common(struct il_priv *il, il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags_spin); /* Add station to device's station table */ @@ -1889,7 +1897,7 @@ il_add_station_common(struct il_priv *il, if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); IL_ERR("Adding station %pM failed.\n", - il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].sta.sta.addr); il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -1897,6 +1905,7 @@ il_add_station_common(struct il_priv *il, *sta_id_r = sta_id; return ret; } + EXPORT_SYMBOL(il_add_station_common); /** @@ -1904,12 +1913,13 @@ EXPORT_SYMBOL(il_add_station_common); * * il->sta_lock must be held */ -static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) +static void +il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) { /* Ucode must be active and driver must be non active */ - if ((il->stations[sta_id].used & - (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != - IL_STA_UCODE_ACTIVE) + if ((il->stations[sta_id]. + used & (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != + IL_STA_UCODE_ACTIVE) IL_ERR("removed non active STA %u\n", sta_id); il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; @@ -1918,9 +1928,9 @@ static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) D_ASSOC("Removed STA %u\n", sta_id); } -static int il_send_remove_station(struct il_priv *il, - const u8 *addr, int sta_id, - bool temporary) +static int +il_send_remove_station(struct il_priv *il, const u8 * addr, int sta_id, + bool temporary) { struct il_rx_pkt *pkt; int ret; @@ -1948,8 +1958,7 @@ static int il_send_remove_station(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from C_REM_STA (0x%08X)\n", - pkt->hdr.flags); + IL_ERR("Bad return from C_REM_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -1960,7 +1969,7 @@ static int il_send_remove_station(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags_spin); il_sta_ucode_deactivate(il, sta_id); spin_unlock_irqrestore(&il->sta_lock, - flags_spin); + flags_spin); } D_ASSOC("C_REM_STA PASSED\n"); break; @@ -1978,15 +1987,14 @@ static int il_send_remove_station(struct il_priv *il, /** * il_remove_station - Remove driver's knowledge of station. */ -int il_remove_station(struct il_priv *il, const u8 sta_id, - const u8 *addr) +int +il_remove_station(struct il_priv *il, const u8 sta_id, const u8 * addr) { unsigned long flags; if (!il_is_ready(il)) { - D_INFO( - "Unable to remove station %pM, device not ready.\n", - addr); + D_INFO("Unable to remove station %pM, device not ready.\n", + addr); /* * It is typical for stations to be removed when we are * going down. Return success since device will be down @@ -1995,8 +2003,7 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, return 0; } - D_ASSOC("Removing STA from driver:%d %pM\n", - sta_id, addr); + D_ASSOC("Removing STA from driver:%d %pM\n", sta_id, addr); if (WARN_ON(sta_id == IL_INVALID_STATION)) return -EINVAL; @@ -2004,14 +2011,12 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, spin_lock_irqsave(&il->sta_lock, flags); if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { - D_INFO("Removing %pM but non DRIVER active\n", - addr); + D_INFO("Removing %pM but non DRIVER active\n", addr); goto out_err; } if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - D_INFO("Removing %pM but non UCODE active\n", - addr); + D_INFO("Removing %pM but non UCODE active\n", addr); goto out_err; } @@ -2033,6 +2038,7 @@ out_err: spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } + EXPORT_SYMBOL_GPL(il_remove_station); /** @@ -2043,8 +2049,8 @@ EXPORT_SYMBOL_GPL(il_remove_station); * other than explicit station management would cause this in * the ucode, e.g. unassociated RXON. */ -void il_clear_ucode_stations(struct il_priv *il, - struct il_rxon_context *ctx) +void +il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) { int i; unsigned long flags_spin; @@ -2058,8 +2064,7 @@ void il_clear_ucode_stations(struct il_priv *il, continue; if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { - D_INFO( - "Clearing ucode active for station %d\n", i); + D_INFO("Clearing ucode active for station %d\n", i); il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; } @@ -2067,9 +2072,9 @@ void il_clear_ucode_stations(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!cleared) - D_INFO( - "No active stations found to be cleared\n"); + D_INFO("No active stations found to be cleared\n"); } + EXPORT_SYMBOL(il_clear_ucode_stations); /** @@ -2092,8 +2097,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) bool send_lq; if (!il_is_ready(il)) { - D_INFO( - "Not ready yet, not restoring any stations.\n"); + D_INFO("Not ready yet, not restoring any stations.\n"); return; } @@ -2105,7 +2109,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { D_ASSOC("Restoring sta %pM\n", - il->stations[i].sta.sta.addr); + il->stations[i].sta.sta.addr); il->stations[i].sta.mode = 0; il->stations[i].used |= IL_STA_UCODE_INPROGRESS; found = true; @@ -2127,21 +2131,19 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); IL_ERR("Adding station %pM failed.\n", - il->stations[i].sta.sta.addr); - il->stations[i].used &= - ~IL_STA_DRIVER_ACTIVE; + il->stations[i].sta.sta.addr); + il->stations[i].used &= ~IL_STA_DRIVER_ACTIVE; il->stations[i].used &= - ~IL_STA_UCODE_INPROGRESS; + ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&il->sta_lock, - flags_spin); + flags_spin); } /* * Rate scaling has already been initialized, send * current LQ command */ if (send_lq) - il_send_lq_cmd(il, ctx, &lq, - CMD_SYNC, true); + il_send_lq_cmd(il, ctx, &lq, CMD_SYNC, true); spin_lock_irqsave(&il->sta_lock, flags_spin); il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; } @@ -2150,14 +2152,15 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!found) D_INFO("Restoring all known stations" - " .... no stations to be restored.\n"); + " .... no stations to be restored.\n"); else - D_INFO("Restoring all known stations" - " .... complete.\n"); + D_INFO("Restoring all known stations" " .... complete.\n"); } + EXPORT_SYMBOL(il_restore_stations); -int il_get_free_ucode_key_idx(struct il_priv *il) +int +il_get_free_ucode_key_idx(struct il_priv *il) { int i; @@ -2167,9 +2170,11 @@ int il_get_free_ucode_key_idx(struct il_priv *il) return WEP_INVALID_OFFSET; } + EXPORT_SYMBOL(il_get_free_ucode_key_idx); -void il_dealloc_bcast_stations(struct il_priv *il) +void +il_dealloc_bcast_stations(struct il_priv *il) { unsigned long flags; int i; @@ -2187,25 +2192,24 @@ void il_dealloc_bcast_stations(struct il_priv *il) } spin_unlock_irqrestore(&il->sta_lock, flags); } + EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLEGACY_DEBUG -static void il_dump_lq_cmd(struct il_priv *il, - struct il_link_quality_cmd *lq) +static void +il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { int i; D_RATE("lq station id 0x%x\n", lq->sta_id); - D_RATE("lq ant 0x%X 0x%X\n", - lq->general_params.single_stream_ant_msk, - lq->general_params.dual_stream_ant_msk); + D_RATE("lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, + lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - D_RATE("lq idx %d 0x%X\n", - i, lq->rs_table[i].rate_n_flags); + D_RATE("lq idx %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else -static inline void il_dump_lq_cmd(struct il_priv *il, - struct il_link_quality_cmd *lq) +static inline void +il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { } #endif @@ -2221,23 +2225,19 @@ static inline void il_dump_lq_cmd(struct il_priv *il, * Test for this to prevent driver from sending LQ command between the time * RXON flags are updated and when LQ command is updated. */ -static bool il_is_lq_table_valid(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq) +static bool +il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq) { int i; if (ctx->ht.enabled) return true; - D_INFO("Channel %u is not an HT channel\n", - ctx->active.channel); + D_INFO("Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & - RATE_MCS_HT_MSK) { - D_INFO( - "idx %d of LQ expects HT channel\n", - i); + if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { + D_INFO("idx %d of LQ expects HT channel\n", i); return false; } } @@ -2254,8 +2254,9 @@ static bool il_is_lq_table_valid(struct il_priv *il, * this case to clear the state indicating that station creation is in * progress. */ -int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq, u8 flags, bool init) +int +il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init) { int ret = 0; unsigned long flags_spin; @@ -2270,7 +2271,6 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) return -EINVAL; - spin_lock_irqsave(&il->sta_lock, flags_spin); if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -2291,36 +2291,35 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, if (init) { D_INFO("init LQ command complete," - " clearing sta addition status for sta %d\n", - lq->sta_id); + " clearing sta addition status for sta %d\n", + lq->sta_id); spin_lock_irqsave(&il->sta_lock, flags_spin); il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&il->sta_lock, flags_spin); } return ret; } + EXPORT_SYMBOL(il_send_lq_cmd); -int il_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +int +il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct il_priv *il = hw->priv; struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - D_INFO("received request to remove station %pM\n", - sta->addr); + D_INFO("received request to remove station %pM\n", sta->addr); mutex_lock(&il->mutex); - D_INFO("proceeding to remove station %pM\n", - sta->addr); + D_INFO("proceeding to remove station %pM\n", sta->addr); ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) - IL_ERR("Error removing station %pM\n", - sta->addr); + IL_ERR("Error removing station %pM\n", sta->addr); mutex_unlock(&il->mutex); return ret; } + EXPORT_SYMBOL(il_mac_sta_remove); /************************** RX-FUNCTIONS ****************************/ @@ -2393,7 +2392,8 @@ EXPORT_SYMBOL(il_mac_sta_remove); /** * il_rx_queue_space - Return number of free slots available in queue. */ -int il_rx_queue_space(const struct il_rx_queue *q) +int +il_rx_queue_space(const struct il_rx_queue *q) { int s = q->read - q->write; if (s <= 0) @@ -2404,14 +2404,14 @@ int il_rx_queue_space(const struct il_rx_queue *q) s = 0; return s; } + EXPORT_SYMBOL(il_rx_queue_space); /** * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue */ void -il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q) +il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q) { unsigned long flags; u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; @@ -2427,34 +2427,33 @@ il_rx_queue_update_write_ptr(struct il_priv *il, reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Rx queue requesting wakeup," - " GP1 = 0x%x\n", reg); + D_INFO("Rx queue requesting wakeup," " GP1 = 0x%x\n", + reg); il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); goto exit_unlock; } q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); + il_wr(il, rx_wrt_ptr_reg, q->write_actual); - /* Else device is assumed to be awake */ + /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); + il_wr(il, rx_wrt_ptr_reg, q->write_actual); } q->need_update = 0; - exit_unlock: +exit_unlock: spin_unlock_irqrestore(&q->lock, flags); } + EXPORT_SYMBOL(il_rx_queue_update_write_ptr); -int il_rx_queue_alloc(struct il_priv *il) +int +il_rx_queue_alloc(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct device *dev = &il->pci_dev->dev; @@ -2465,13 +2464,15 @@ int il_rx_queue_alloc(struct il_priv *il) INIT_LIST_HEAD(&rxq->rx_used); /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ - rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, - GFP_KERNEL); + rxq->bd = + dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, + GFP_KERNEL); if (!rxq->bd) goto err_bd; - rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), - &rxq->rb_stts_dma, GFP_KERNEL); + rxq->rb_stts = + dma_alloc_coherent(dev, sizeof(struct il_rb_status), + &rxq->rb_stts_dma, GFP_KERNEL); if (!rxq->rb_stts) goto err_rb; @@ -2493,33 +2494,32 @@ err_rb: err_bd: return -ENOMEM; } -EXPORT_SYMBOL(il_rx_queue_alloc); +EXPORT_SYMBOL(il_rx_queue_alloc); -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - D_11H( - "Spectrum Measure Notification: Start\n"); + D_11H("Spectrum Measure Notification: Start\n"); return; } memcpy(&il->measure_report, report, sizeof(*report)); il->measurement_status |= MEASUREMENT_READY; } + EXPORT_SYMBOL(il_hdl_spectrum_measurement); /* * returns non-zero if packet should be dropped */ -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats) +int +il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, + u32 decrypt_res, struct ieee80211_rx_status *stats) { u16 fc = le16_to_cpu(hdr->frame_control); @@ -2527,8 +2527,7 @@ int il_set_decrypted_flag(struct il_priv *il, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (il->ctx.active.filter_flags & - RXON_FILTER_DIS_DECRYPT_MSK) + if (il->ctx.active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; if (!(fc & IEEE80211_FCTL_PROTECTED)) @@ -2564,6 +2563,7 @@ int il_set_decrypted_flag(struct il_priv *il, } return 0; } + EXPORT_SYMBOL(il_set_decrypted_flag); /** @@ -2586,16 +2586,14 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Tx queue %d requesting wakeup," - " GP1 = 0x%x\n", txq_id, reg); + D_INFO("Tx queue %d requesting wakeup," " GP1 = 0x%x\n", + txq_id, reg); il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); return; } - il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); + il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* * else not in power-save mode, @@ -2603,16 +2601,17 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - _il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); + _il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } + EXPORT_SYMBOL(il_txq_update_write_ptr); /** * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's */ -void il_tx_queue_unmap(struct il_priv *il, int txq_id) +void +il_tx_queue_unmap(struct il_priv *il, int txq_id) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -2625,6 +2624,7 @@ void il_tx_queue_unmap(struct il_priv *il, int txq_id) q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } + EXPORT_SYMBOL(il_tx_queue_unmap); /** @@ -2635,7 +2635,8 @@ EXPORT_SYMBOL(il_tx_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_tx_queue_free(struct il_priv *il, int txq_id) +void +il_tx_queue_free(struct il_priv *il, int txq_id) { struct il_tx_queue *txq = &il->txq[txq_id]; struct device *dev = &il->pci_dev->dev; @@ -2649,8 +2650,8 @@ void il_tx_queue_free(struct il_priv *il, int txq_id) /* De-alloc circular buffer of TFDs */ if (txq->q.n_bd) - dma_free_coherent(dev, il->hw_params.tfd_size * - txq->q.n_bd, txq->tfds, txq->q.dma_addr); + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, + txq->tfds, txq->q.dma_addr); /* De-alloc array of per-TFD driver data */ kfree(txq->txb); @@ -2665,12 +2666,14 @@ void il_tx_queue_free(struct il_priv *il, int txq_id) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } + EXPORT_SYMBOL(il_tx_queue_free); /** * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue */ -void il_cmd_queue_unmap(struct il_priv *il) +void +il_cmd_queue_unmap(struct il_priv *il) { struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; @@ -2702,6 +2705,7 @@ void il_cmd_queue_unmap(struct il_priv *il) txq->meta[i].flags = 0; } } + EXPORT_SYMBOL(il_cmd_queue_unmap); /** @@ -2712,7 +2716,8 @@ EXPORT_SYMBOL(il_cmd_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_cmd_queue_free(struct il_priv *il) +void +il_cmd_queue_free(struct il_priv *il) { struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct device *dev = &il->pci_dev->dev; @@ -2738,6 +2743,7 @@ void il_cmd_queue_free(struct il_priv *il) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } + EXPORT_SYMBOL(il_cmd_queue_free); /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** @@ -2763,7 +2769,8 @@ EXPORT_SYMBOL(il_cmd_queue_free); * See more detailed info in 4965.h. ***************************************************/ -int il_queue_space(const struct il_queue *q) +int +il_queue_space(const struct il_queue *q) { int s = q->read_ptr - q->write_ptr; @@ -2778,14 +2785,16 @@ int il_queue_space(const struct il_queue *q) s = 0; return s; } + EXPORT_SYMBOL(il_queue_space); /** * il_queue_init - Initialize queue's high/low-water and read/write idxes */ -static int il_queue_init(struct il_priv *il, struct il_queue *q, - int count, int slots_num, u32 id) +static int +il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, + u32 id) { q->n_bd = count; q->n_win = slots_num; @@ -2815,8 +2824,8 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, /** * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue */ -static int il_tx_queue_alloc(struct il_priv *il, - struct il_tx_queue *txq, u32 id) +static int +il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id) { struct device *dev = &il->pci_dev->dev; size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; @@ -2824,11 +2833,12 @@ static int il_tx_queue_alloc(struct il_priv *il, /* Driver ilate data, only for Tx (not command) queues, * not shared with device. */ if (id != il->cmd_queue) { - txq->txb = kzalloc(sizeof(txq->txb[0]) * - TFD_QUEUE_SIZE_MAX, GFP_KERNEL); + txq->txb = + kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, + GFP_KERNEL); if (!txq->txb) { IL_ERR("kmalloc for auxiliary BD " - "structures failed\n"); + "structures failed\n"); goto error; } } else { @@ -2837,8 +2847,8 @@ static int il_tx_queue_alloc(struct il_priv *il, /* Circular buffer of transmit frame descriptors (TFDs), * shared with device */ - txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, - GFP_KERNEL); + txq->tfds = + dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; @@ -2847,7 +2857,7 @@ static int il_tx_queue_alloc(struct il_priv *il, return 0; - error: +error: kfree(txq->txb); txq->txb = NULL; @@ -2857,8 +2867,9 @@ static int il_tx_queue_alloc(struct il_priv *il, /** * il_tx_queue_init - Allocate and initialize one tx/cmd queue */ -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) +int +il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, + u32 txq_id) { int i, len; int ret; @@ -2875,10 +2886,10 @@ int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, if (txq_id == il->cmd_queue) actual_slots++; - txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, - GFP_KERNEL); - txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, - GFP_KERNEL); + txq->meta = + kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); + txq->cmd = + kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL); if (!txq->meta || !txq->cmd) goto out_free_arrays; @@ -2914,8 +2925,7 @@ int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ il->cfg->ops->lib->txq_init(il, txq); @@ -2930,10 +2940,12 @@ out_free_arrays: return -ENOMEM; } + EXPORT_SYMBOL(il_tx_queue_init); -void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) +void +il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, + u32 txq_id) { int actual_slots = slots_num; @@ -2945,12 +2957,12 @@ void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, txq->need_update = 0; /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ il->cfg->ops->lib->txq_init(il, txq); } + EXPORT_SYMBOL(il_tx_queue_reset); /*************** HOST COMMAND QUEUE FUNCTIONS *****/ @@ -2964,7 +2976,8 @@ EXPORT_SYMBOL(il_tx_queue_reset); * failed. On success, it turns the idx (> 0) of command in the * command queue. */ -int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) +int +il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) { struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; @@ -2977,7 +2990,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) u16 fix_size; cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); - fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); + fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr)); /* If any of the command structures end up being larger than * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then @@ -2990,7 +3003,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) if (il_is_rfkill(il) || il_is_ctkill(il)) { IL_WARN("Not sending command - %s KILL\n", - il_is_rfkill(il) ? "RF" : "CT"); + il_is_rfkill(il) ? "RF" : "CT"); return -EIO; } @@ -3027,8 +3040,8 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) * information */ out_cmd->hdr.flags = 0; - out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | - IDX_TO_SEQ(q->write_ptr)); + out_cmd->hdr.sequence = + cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | IDX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; len = sizeof(struct il_device_cmd); @@ -3039,21 +3052,18 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) switch (out_cmd->hdr.cmd) { case C_TX_LINK_QUALITY_CMD: case C_SENSITIVITY: - D_HC_DUMP( - "Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); + D_HC_DUMP("Sending command %s (#%x), seq: 0x%04X, " + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, + q->write_ptr, idx, il->cmd_queue); break; default: D_HC("Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->write_ptr, + idx, il->cmd_queue); } #endif txq->need_update = 1; @@ -3062,14 +3072,14 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) /* Set up entry in queue's byte count circular buffer */ il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); - phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, - fix_size, PCI_DMA_BIDIRECTIONAL); + phys_addr = + pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, + PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, phys_addr); dma_unmap_len_set(out_meta, len, fix_size); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, fix_size, 1, - U32_PAD(cmd->len)); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, + 1, U32_PAD(cmd->len)); /* Increment and update queue's write idx */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); @@ -3086,8 +3096,8 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, - int idx, int cmd_idx) +static void +il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int idx, int cmd_idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -3095,8 +3105,8 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); + "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, + q->write_ptr, q->read_ptr); return; } @@ -3105,7 +3115,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, if (nfreed++ > 0) { IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, - q->write_ptr, q->read_ptr); + q->write_ptr, q->read_ptr); queue_work(il->workqueue, &il->restart); } @@ -3137,11 +3147,11 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) /* If a Tx command is being handled and it isn't in the actual * command queue then there a command routing bug has been introduced * in the queue management code. */ - if (WARN(txq_id != il->cmd_queue, - "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", - txq_id, il->cmd_queue, sequence, - il->txq[il->cmd_queue].q.read_ptr, - il->txq[il->cmd_queue].q.write_ptr)) { + if (WARN + (txq_id != il->cmd_queue, + "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", + txq_id, il->cmd_queue, sequence, il->txq[il->cmd_queue].q.read_ptr, + il->txq[il->cmd_queue].q.write_ptr)) { il_print_hex_error(il, pkt, 32); return; } @@ -3152,10 +3162,8 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) txq->time_stamp = jiffies; - pci_unmap_single(il->pci_dev, - dma_unmap_addr(meta, mapping), - dma_unmap_len(meta, len), - PCI_DMA_BIDIRECTIONAL); + pci_unmap_single(il->pci_dev, dma_unmap_addr(meta, mapping), + dma_unmap_len(meta, len), PCI_DMA_BIDIRECTIONAL); /* Input error checking is done when commands are added to queue. */ if (meta->flags & CMD_WANT_SKB) { @@ -3171,7 +3179,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) if (!(meta->flags & CMD_ASYNC)) { clear_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->hdr.cmd)); + il_get_cmd_string(cmd->hdr.cmd)); wake_up(&il->wait_command_queue); } @@ -3211,11 +3219,12 @@ u32 il_debug_level; EXPORT_SYMBOL(il_debug_level); const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -EXPORT_SYMBOL(il_bcast_addr); +EXPORT_SYMBOL(il_bcast_addr); /* This function both allocates and initializes hw and il. */ -struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) +struct ieee80211_hw * +il_alloc_all(struct il_cfg *cfg) { struct il_priv *il; /* mac80211 allocates memory for this device instance, including @@ -3225,8 +3234,7 @@ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) hw = ieee80211_alloc_hw(sizeof(struct il_priv), cfg->ops->ieee80211_ops); if (hw == NULL) { - pr_err("%s: Can not allocate network device\n", - cfg->name); + pr_err("%s: Can not allocate network device\n", cfg->name); goto out; } @@ -3236,13 +3244,15 @@ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) out: return hw; } + EXPORT_SYMBOL(il_alloc_all); -#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ -#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void il_init_ht_hw_capab(const struct il_priv *il, - struct ieee80211_sta_ht_cap *ht_info, - enum ieee80211_band band) +#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ +#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ +static void +il_init_ht_hw_capab(const struct il_priv *il, + struct ieee80211_sta_ht_cap *ht_info, + enum ieee80211_band band) { u16 max_bit_rate = 0; u8 rx_chains_num = il->hw_params.rx_chains_num; @@ -3283,15 +3293,17 @@ static void il_init_ht_hw_capab(const struct il_priv *il, ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; if (tx_chains_num != rx_chains_num) { ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; - ht_info->mcs.tx_params |= ((tx_chains_num - 1) << - IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); + ht_info->mcs.tx_params |= + ((tx_chains_num - + 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); } } /** * il_init_geos - Initialize mac80211's geo/channel info based from eeprom */ -int il_init_geos(struct il_priv *il) +int +il_init_geos(struct il_priv *il) { struct il_channel_info *ch; struct ieee80211_supported_band *sband; @@ -3308,13 +3320,15 @@ int il_init_geos(struct il_priv *il) return 0; } - channels = kzalloc(sizeof(struct ieee80211_channel) * - il->channel_count, GFP_KERNEL); + channels = + kzalloc(sizeof(struct ieee80211_channel) * il->channel_count, + GFP_KERNEL); if (!channels) return -ENOMEM; - rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), - GFP_KERNEL); + rates = + kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), + GFP_KERNEL); if (!rates) { kfree(channels); return -ENOMEM; @@ -3328,8 +3342,7 @@ int il_init_geos(struct il_priv *il) sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_5GHZ); + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_5GHZ); sband = &il->bands[IEEE80211_BAND_2GHZ]; sband->channels = channels; @@ -3338,13 +3351,12 @@ int il_init_geos(struct il_priv *il) sband->n_bitrates = RATE_COUNT_LEGACY; if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_2GHZ); + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_2GHZ); il->ieee_channels = channels; il->ieee_rates = rates; - for (i = 0; i < il->channel_count; i++) { + for (i = 0; i < il->channel_count; i++) { ch = &il->channel_info[i]; if (!il_is_channel_valid(ch)) @@ -3355,7 +3367,7 @@ int il_init_geos(struct il_priv *il) geo_ch = &sband->channels[sband->n_channels++]; geo_ch->center_freq = - ieee80211_channel_to_frequency(ch->channel, ch->band); + ieee80211_channel_to_frequency(ch->channel, ch->band); geo_ch->max_power = ch->max_power_avg; geo_ch->max_antenna_gain = 0xff; geo_ch->hw_value = ch->channel; @@ -3378,12 +3390,12 @@ int il_init_geos(struct il_priv *il) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", - ch->channel, geo_ch->center_freq, - il_is_channel_a_band(ch) ? "5.2" : "2.4", - geo_ch->flags & IEEE80211_CHAN_DISABLED ? - "restricted" : "valid", - geo_ch->flags); + D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, + geo_ch->center_freq, + il_is_channel_a_band(ch) ? "5.2" : "2.4", + geo_ch-> + flags & IEEE80211_CHAN_DISABLED ? "restricted" : "valid", + geo_ch->flags); } il->tx_power_device_lmt = max_tx_power; @@ -3394,35 +3406,37 @@ int il_init_geos(struct il_priv *il) (il->cfg->sku & IL_SKU_A)) { IL_INFO("Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", - il->pci_dev->device, - il->pci_dev->subsystem_device); + il->pci_dev->device, il->pci_dev->subsystem_device); il->cfg->sku &= ~IL_SKU_A; } IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", - il->bands[IEEE80211_BAND_2GHZ].n_channels, - il->bands[IEEE80211_BAND_5GHZ].n_channels); + il->bands[IEEE80211_BAND_2GHZ].n_channels, + il->bands[IEEE80211_BAND_5GHZ].n_channels); set_bit(S_GEO_CONFIGURED, &il->status); return 0; } + EXPORT_SYMBOL(il_init_geos); /* * il_free_geos - undo allocations in il_init_geos */ -void il_free_geos(struct il_priv *il) +void +il_free_geos(struct il_priv *il) { kfree(il->ieee_channels); kfree(il->ieee_rates); clear_bit(S_GEO_CONFIGURED, &il->status); } + EXPORT_SYMBOL(il_free_geos); -static bool il_is_channel_extension(struct il_priv *il, - enum ieee80211_band band, - u16 channel, u8 extension_chan_offset) +static bool +il_is_channel_extension(struct il_priv *il, enum ieee80211_band band, + u16 channel, u8 extension_chan_offset) { const struct il_channel_info *ch_info; @@ -3431,18 +3445,18 @@ static bool il_is_channel_extension(struct il_priv *il, return false; if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40PLUS); + return !(ch_info-> + ht40_extension_channel & IEEE80211_CHAN_NO_HT40PLUS); else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40MINUS); + return !(ch_info-> + ht40_extension_channel & IEEE80211_CHAN_NO_HT40MINUS); return false; } -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap) +bool +il_is_ht40_tx_allowed(struct il_priv * il, struct il_rxon_context * ctx, + struct ieee80211_sta_ht_cap * ht_cap) { if (!ctx->ht.enabled || !ctx->ht.is_40mhz) return false; @@ -3460,12 +3474,14 @@ bool il_is_ht40_tx_allowed(struct il_priv *il, #endif return il_is_channel_extension(il, il->band, - le16_to_cpu(ctx->staging.channel), - ctx->ht.extension_chan_offset); + le16_to_cpu(ctx->staging.channel), + ctx->ht.extension_chan_offset); } + EXPORT_SYMBOL(il_is_ht40_tx_allowed); -static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) +static u16 +il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) { u16 new_val; u16 beacon_factor; @@ -3520,36 +3536,37 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) /* * TODO: For IBSS we need to get atim_win from mac80211, - * for now just always use 0 + * for now just always use 0 */ ctx->timing.atim_win = 0; - beacon_int = il_adjust_beacon_interval(beacon_int, - il->hw_params.max_beacon_itrvl * TIME_UNIT); + beacon_int = + il_adjust_beacon_interval(beacon_int, + il->hw_params.max_beacon_itrvl * + TIME_UNIT); ctx->timing.beacon_interval = cpu_to_le16(beacon_int); - tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ + tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ interval_tm = beacon_int * TIME_UNIT; rem = do_div(tsf, interval_tm); ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); - ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; + ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ? : 1) : 1; - D_ASSOC( - "beacon interval %d beacon timer %d beacon tim %d\n", - le16_to_cpu(ctx->timing.beacon_interval), - le32_to_cpu(ctx->timing.beacon_init_val), - le16_to_cpu(ctx->timing.atim_win)); + D_ASSOC("beacon interval %d beacon timer %d beacon tim %d\n", + le16_to_cpu(ctx->timing.beacon_interval), + le32_to_cpu(ctx->timing.beacon_init_val), + le16_to_cpu(ctx->timing.atim_win)); - return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, - sizeof(ctx->timing), &ctx->timing); + return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), + &ctx->timing); } + EXPORT_SYMBOL(il_send_rxon_timing); void -il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt) +il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, + int hw_decrypt) { struct il_rxon_cmd *rxon = &ctx->staging; @@ -3559,6 +3576,7 @@ il_set_rxon_hwcrypto(struct il_priv *il, rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; } + EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ @@ -3604,28 +3622,27 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) error = true; } - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == + (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { IL_WARN("CCK and short slot\n"); error = true; } - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == + (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { IL_WARN("CCK and auto detect"); error = true; } - if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | - RXON_FLG_TGG_PROTECT_MSK)) == - RXON_FLG_TGG_PROTECT_MSK) { + if ((rxon-> + flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == + RXON_FLG_TGG_PROTECT_MSK) { IL_WARN("TGg but no auto-detect\n"); error = true; } if (error) - IL_WARN("Tuning to channel %d\n", - le16_to_cpu(rxon->channel)); + IL_WARN("Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { IL_ERR("Invalid RXON\n"); @@ -3633,6 +3650,7 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) } return 0; } + EXPORT_SYMBOL(il_check_rxon_cmd); /** @@ -3643,8 +3661,8 @@ EXPORT_SYMBOL(il_check_rxon_cmd); * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. */ -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx) +int +il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_rxon_cmd *staging = &ctx->staging; const struct il_rxon_cmd *active = &ctx->active; @@ -3667,8 +3685,8 @@ int il_full_rxon_required(struct il_priv *il, CHK(!il_is_associated_ctx(ctx)); CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); CHK(compare_ether_addr(staging->node_addr, active->node_addr)); - CHK(compare_ether_addr(staging->wlap_bssid_addr, - active->wlap_bssid_addr)); + CHK(compare_ether_addr + (staging->wlap_bssid_addr, active->wlap_bssid_addr)); CHK_NEQ(staging->dev_type, active->dev_type); CHK_NEQ(staging->channel, active->channel); CHK_NEQ(staging->air_propagation, active->air_propagation); @@ -3695,10 +3713,11 @@ int il_full_rxon_required(struct il_priv *il, return 0; } + EXPORT_SYMBOL(il_full_rxon_required); -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx) +u8 +il_get_lowest_plcp(struct il_priv * il, struct il_rxon_context * ctx) { /* * Assign the lowest rate -- should really get this from @@ -3709,44 +3728,43 @@ u8 il_get_lowest_plcp(struct il_priv *il, else return RATE_6M_PLCP; } + EXPORT_SYMBOL(il_get_lowest_plcp); -static void _il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf, - struct il_rxon_context *ctx) +static void +_il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, + struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; if (!ctx->ht.enabled) { - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | - RXON_FLG_HT40_PROT_MSK | - RXON_FLG_HT_PROT_MSK); + rxon->flags &= + ~(RXON_FLG_CHANNEL_MODE_MSK | + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | RXON_FLG_HT40_PROT_MSK + | RXON_FLG_HT_PROT_MSK); return; } - rxon->flags |= cpu_to_le32(ctx->ht.protection << - RXON_FLG_HT_OPERATING_MODE_POS); + rxon->flags |= + cpu_to_le32(ctx->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS); /* Set up channel bandwidth: * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ /* clear the HT channel mode before set the mode */ - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + rxon->flags &= + ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); if (il_is_ht40_tx_allowed(il, ctx, NULL)) { /* pure ht40 */ - if (ctx->ht.protection == - IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { + if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; /* Note: control channel is opposite of extension channel */ switch (ctx->ht.extension_chan_offset) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: rxon->flags &= - ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; break; case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; break; } } else { @@ -3754,19 +3772,17 @@ static void _il_set_rxon_ht(struct il_priv *il, switch (ctx->ht.extension_chan_offset) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: rxon->flags &= - ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; break; case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; break; case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IL_ERR( - "invalid extension channel offset\n"); + IL_ERR("invalid extension channel offset\n"); break; } } @@ -3778,20 +3794,21 @@ static void _il_set_rxon_ht(struct il_priv *il, il->cfg->ops->hcmd->set_rxon_chain(il, ctx); D_ASSOC("rxon flags 0x%X operation mode :0x%X " - "extension channel offset 0x%x\n", - le32_to_cpu(rxon->flags), ctx->ht.protection, - ctx->ht.extension_chan_offset); + "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), + ctx->ht.protection, ctx->ht.extension_chan_offset); } -void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) +void +il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { _il_set_rxon_ht(il, ht_conf, &il->ctx); } + EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band) +u8 +il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band) { const struct il_channel_info *ch_info; int i; @@ -3818,6 +3835,7 @@ u8 il_get_single_channel_number(struct il_priv *il, return channel; } + EXPORT_SYMBOL(il_get_single_channel_number); /** @@ -3829,7 +3847,7 @@ EXPORT_SYMBOL(il_get_single_channel_number); */ int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, - struct il_rxon_context *ctx) + struct il_rxon_context *ctx) { enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; @@ -3849,17 +3867,17 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, return 0; } + EXPORT_SYMBOL(il_set_rxon_channel); -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif) +void +il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, + enum ieee80211_band band, struct ieee80211_vif *vif) { if (band == IEEE80211_BAND_5GHZ) { ctx->staging.flags &= - ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK - | RXON_FLG_CCK_MSK); + ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | + RXON_FLG_CCK_MSK); ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; } else { /* Copied from il_post_associate() */ @@ -3873,13 +3891,14 @@ void il_set_flags_for_band(struct il_priv *il, ctx->staging.flags &= ~RXON_FLG_CCK_MSK; } } + EXPORT_SYMBOL(il_set_flags_for_band); /* * initialize rxon structure with default values from eeprom */ -void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx) +void +il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_channel_info *ch_info; @@ -3888,25 +3907,26 @@ void il_connection_init_rx_config(struct il_priv *il, if (!ctx->vif) { ctx->staging.dev_type = ctx->unused_devtype; } else - switch (ctx->vif->type) { + switch (ctx->vif->type) { - case NL80211_IFTYPE_STATION: - ctx->staging.dev_type = ctx->station_devtype; - ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; - break; + case NL80211_IFTYPE_STATION: + ctx->staging.dev_type = ctx->station_devtype; + ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; + break; - case NL80211_IFTYPE_ADHOC: - ctx->staging.dev_type = ctx->ibss_devtype; - ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; - ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | - RXON_FILTER_ACCEPT_GRP_MSK; - break; + case NL80211_IFTYPE_ADHOC: + ctx->staging.dev_type = ctx->ibss_devtype; + ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.filter_flags = + RXON_FILTER_BCON_AWARE_MSK | + RXON_FILTER_ACCEPT_GRP_MSK; + break; - default: - IL_ERR("Unsupported interface type %d\n", - ctx->vif->type); - break; - } + default: + IL_ERR("Unsupported interface type %d\n", + ctx->vif->type); + break; + } #if 0 /* TODO: Figure out when short_preamble would be set and cache from @@ -3917,8 +3937,8 @@ void il_connection_init_rx_config(struct il_priv *il, ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; #endif - ch_info = il_get_channel_info(il, il->band, - le16_to_cpu(ctx->active.channel)); + ch_info = + il_get_channel_info(il, il->band, le16_to_cpu(ctx->active.channel)); if (!ch_info) ch_info = &il->channel_info[0]; @@ -3934,17 +3954,19 @@ void il_connection_init_rx_config(struct il_priv *il, (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; /* clear both MIX and PURE40 mode flag */ - ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | - RXON_FLG_CHANNEL_MODE_PURE_40); + ctx->staging.flags &= + ~(RXON_FLG_CHANNEL_MODE_MIXED | RXON_FLG_CHANNEL_MODE_PURE_40); if (ctx->vif) memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; } + EXPORT_SYMBOL(il_connection_init_rx_config); -void il_set_rate(struct il_priv *il) +void +il_set_rate(struct il_priv *il) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; @@ -3967,14 +3989,16 @@ void il_set_rate(struct il_priv *il) D_RATE("Set active_rate = %0x\n", il->active_rate); il->ctx.staging.cck_basic_rates = - (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; + (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; il->ctx.staging.ofdm_basic_rates = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; } + EXPORT_SYMBOL(il_set_rate); -void il_chswitch_done(struct il_priv *il, bool is_success) +void +il_chswitch_done(struct il_priv *il, bool is_success) { struct il_rxon_context *ctx = &il->ctx; @@ -3984,9 +4008,11 @@ void il_chswitch_done(struct il_priv *il, bool is_success) if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } + EXPORT_SYMBOL(il_chswitch_done); -void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) +void +il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); @@ -4000,46 +4026,43 @@ void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - D_11H("CSA notif: channel %d\n", - le16_to_cpu(csa->channel)); + D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel)); il_chswitch_done(il, true); } else { IL_ERR("CSA notif (fail) : channel %d\n", - le16_to_cpu(csa->channel)); + le16_to_cpu(csa->channel)); il_chswitch_done(il, false); } } + EXPORT_SYMBOL(il_hdl_csa); #ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) +void +il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; D_RADIO("RX CONFIG:\n"); il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - D_RADIO("u16 channel: 0x%x\n", - le16_to_cpu(rxon->channel)); + D_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - D_RADIO("u32 filter_flags: 0x%08x\n", - le32_to_cpu(rxon->filter_flags)); + D_RADIO("u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); - D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", - rxon->ofdm_basic_rates); - D_RADIO("u8 cck_basic_rates: 0x%02x\n", - rxon->cck_basic_rates); + D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); + D_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - D_RADIO("u16 assoc_id: 0x%x\n", - le16_to_cpu(rxon->assoc_id)); + D_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } + EXPORT_SYMBOL(il_print_rx_config_cmd); #endif /** * il_irq_handle_error - called for HW or SW error interrupt from card */ -void il_irq_handle_error(struct il_priv *il) +void +il_irq_handle_error(struct il_priv *il) { /* Set the FW error flag -- cleared on il_down */ set_bit(S_FW_ERROR, &il->status); @@ -4047,16 +4070,14 @@ void il_irq_handle_error(struct il_priv *il) /* Cancel currently queued command. */ clear_bit(S_HCMD_ACTIVE, &il->status); - IL_ERR("Loaded firmware version: %s\n", - il->hw->wiphy->fw_version); + IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); il->cfg->ops->lib->dump_nic_error_log(il); if (il->cfg->ops->lib->dump_fh) il->cfg->ops->lib->dump_fh(il, NULL, false); #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_FW_ERRORS) - il_print_rx_config_cmd(il, - &il->ctx); + il_print_rx_config_cmd(il, &il->ctx); #endif wake_up(&il->wait_command_queue); @@ -4067,23 +4088,26 @@ void il_irq_handle_error(struct il_priv *il) if (!test_bit(S_EXIT_PENDING, &il->status)) { IL_DBG(IL_DL_FW_ERRORS, - "Restarting adapter due to uCode error.\n"); + "Restarting adapter due to uCode error.\n"); if (il->cfg->mod_params->restart_fw) queue_work(il->workqueue, &il->restart); } } + EXPORT_SYMBOL(il_irq_handle_error); -static int il_apm_stop_master(struct il_priv *il) +static int +il_apm_stop_master(struct il_priv *il) { int ret = 0; /* stop device's busmaster DMA activity */ il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, - CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); + ret = + _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) IL_WARN("Master Disable Timed Out, 100 usec\n"); @@ -4092,7 +4116,8 @@ static int il_apm_stop_master(struct il_priv *il) return ret; } -void il_apm_stop(struct il_priv *il) +void +il_apm_stop(struct il_priv *il) { D_INFO("Stop card, put in low power state\n"); @@ -4108,18 +4133,18 @@ void il_apm_stop(struct il_priv *il) * Clear "initialization complete" bit to move adapter from * D0A* (powered-up Active) --> D0U* (Uninitialized) state. */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } -EXPORT_SYMBOL(il_apm_stop); +EXPORT_SYMBOL(il_apm_stop); /* * Start up NIC's basic functionality after it has been reset * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -int il_apm_init(struct il_priv *il) +int +il_apm_init(struct il_priv *il) { int ret = 0; u16 lctl; @@ -4133,18 +4158,17 @@ int il_apm_init(struct il_priv *il) /* Disable L0S exit timer (platform NMI Work/Around) */ il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); + CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); /* * Disable L0s without affecting L1; * don't wait for ICH L0s (ICH bug W/A) */ il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); + CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); /* Set FH wait threshold to maximum (HW error during stress W/A) */ - il_set_bit(il, CSR_DBG_HPET_MEM_REG, - CSR_DBG_HPET_MEM_REG_VAL); + il_set_bit(il, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); /* * Enable HAP INTA (interrupt from management bus) to @@ -4152,7 +4176,7 @@ int il_apm_init(struct il_priv *il) * NOTE: This is no-op for 3945 (non-existent bit) */ il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); + CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); /* * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. @@ -4165,15 +4189,15 @@ int il_apm_init(struct il_priv *il) if (il->cfg->base_params->set_l0s) { lctl = il_pcie_link_ctl(il); if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == - PCI_CFG_LINK_CTRL_VAL_L1_EN) { + PCI_CFG_LINK_CTRL_VAL_L1_EN) { /* L1-ASPM enabled; disable(!) L0S */ il_set_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); + CSR_GIO_REG_VAL_L0S_ENABLED); D_POWER("L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ il_clear_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); + CSR_GIO_REG_VAL_L0S_ENABLED); D_POWER("L1 Disabled; Enabling L0S\n"); } } @@ -4181,7 +4205,7 @@ int il_apm_init(struct il_priv *il) /* Configure analog phase-lock-loop before activating to D0A */ if (il->cfg->base_params->pll_cfg_val) il_set_bit(il, CSR_ANA_PLL_CFG, - il->cfg->base_params->pll_cfg_val); + il->cfg->base_params->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from @@ -4194,9 +4218,10 @@ int il_apm_init(struct il_priv *il) * device-internal resources is supported, e.g. il_wr_prph() * and accesses to uCode SRAM. */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); + ret = + _il_poll_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { D_INFO("Failed to init the card\n"); goto out; @@ -4212,23 +4237,23 @@ int il_apm_init(struct il_priv *il) */ if (il->cfg->base_params->use_bsm) il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); + APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT); + il_wr_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); /* Disable L1-Active */ il_set_bits_prph(il, APMG_PCIDEV_STT_REG, - APMG_PCIDEV_STT_VAL_L1_ACT_DIS); + APMG_PCIDEV_STT_VAL_L1_ACT_DIS); out: return ret; } -EXPORT_SYMBOL(il_apm_init); +EXPORT_SYMBOL(il_apm_init); -int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) +int +il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) { int ret; s8 prev_tx_power; @@ -4245,16 +4270,13 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IL_WARN( - "Requested user TXPOWER %d below 1 mW.\n", - tx_power); + IL_WARN("Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } if (tx_power > il->tx_power_device_lmt) { - IL_WARN( - "Requested user TXPOWER %d above upper limit %d.\n", - tx_power, il->tx_power_device_lmt); + IL_WARN("Requested user TXPOWER %d above upper limit %d.\n", + tx_power, il->tx_power_device_lmt); return -EINVAL; } @@ -4267,7 +4289,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) /* do not set tx power when scanning or channel changing */ defer = test_bit(S_SCANNING, &il->status) || - memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); + memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { D_INFO("Deferring tx power set\n"); return 0; @@ -4285,9 +4307,11 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) } return ret; } + EXPORT_SYMBOL(il_set_tx_power); -void il_send_bt_config(struct il_priv *il) +void +il_send_bt_config(struct il_priv *il) { struct il_bt_cmd bt_cmd = { .lead_time = BT_LEAD_TIME_DEF, @@ -4302,34 +4326,31 @@ void il_send_bt_config(struct il_priv *il) bt_cmd.flags = BT_COEX_ENABLE; D_INFO("BT coex %s\n", - (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); + (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (il_send_cmd_pdu(il, C_BT_CONFIG, - sizeof(struct il_bt_cmd), &bt_cmd)) + if (il_send_cmd_pdu(il, C_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) IL_ERR("failed to send BT Coex Config\n"); } EXPORT_SYMBOL(il_send_bt_config); -int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) +int +il_send_stats_request(struct il_priv *il, u8 flags, bool clear) { struct il_stats_cmd stats_cmd = { - .configuration_flags = - clear ? IL_STATS_CONF_CLEAR_STATS : 0, + .configuration_flags = clear ? IL_STATS_CONF_CLEAR_STATS : 0, }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd, NULL); + return il_send_cmd_pdu_async(il, C_STATS, sizeof(struct il_stats_cmd), + &stats_cmd, NULL); else - return il_send_cmd_pdu(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd); + return il_send_cmd_pdu(il, C_STATS, sizeof(struct il_stats_cmd), + &stats_cmd); } EXPORT_SYMBOL(il_send_stats_request); -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -4340,41 +4361,41 @@ void il_hdl_pm_sleep(struct il_priv *il, } EXPORT_SYMBOL(il_hdl_pm_sleep); -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; - D_RADIO("Dumping %d bytes of unhandled " - "notification for %s:\n", len, - il_get_cmd_string(pkt->hdr.cmd)); + D_RADIO("Dumping %d bytes of unhandled notification for %s:\n", len, + il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } EXPORT_SYMBOL(il_hdl_pm_debug_stats); -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " - "seq 0x%04X ser 0x%08X\n", - le32_to_cpu(pkt->u.err_resp.error_type), - il_get_cmd_string(pkt->u.err_resp.cmd_id), - pkt->u.err_resp.cmd_id, - le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), - le32_to_cpu(pkt->u.err_resp.error_info)); + "seq 0x%04X ser 0x%08X\n", + le32_to_cpu(pkt->u.err_resp.error_type), + il_get_cmd_string(pkt->u.err_resp.cmd_id), + pkt->u.err_resp.cmd_id, + le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), + le32_to_cpu(pkt->u.err_resp.error_info)); } EXPORT_SYMBOL(il_hdl_error); -void il_clear_isr_stats(struct il_priv *il) +void +il_clear_isr_stats(struct il_priv *il) { memset(&il->isr_stats, 0, sizeof(il->isr_stats)); } -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params) +int +il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *params) { struct il_priv *il = hw->priv; unsigned long flags; @@ -4397,12 +4418,12 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, spin_lock_irqsave(&il->lock, flags); il->ctx.qos_data.def_qos_parm.ac[q].cw_min = - cpu_to_le16(params->cw_min); + cpu_to_le16(params->cw_min); il->ctx.qos_data.def_qos_parm.ac[q].cw_max = - cpu_to_le16(params->cw_max); + cpu_to_le16(params->cw_max); il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = - cpu_to_le16((params->txop * 32)); + cpu_to_le16((params->txop * 32)); il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; @@ -4411,14 +4432,17 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, D_MAC80211("leave\n"); return 0; } + EXPORT_SYMBOL(il_mac_conf_tx); -int il_mac_tx_last_beacon(struct ieee80211_hw *hw) +int +il_mac_tx_last_beacon(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; return il->ibss_manager == IL_IBSS_MANAGER; } + EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int @@ -4432,8 +4456,8 @@ il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) return il_commit_rxon(il, ctx); } -static int il_setup_interface(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il_setup_interface(struct il_priv *il, struct il_rxon_context *ctx) { struct ieee80211_vif *vif = ctx->vif; int err; @@ -4467,8 +4491,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) int err; u32 modes; - D_MAC80211("enter: type %d, addr %pM\n", - vif->type, vif->addr); + D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); mutex_lock(&il->mutex); @@ -4478,7 +4501,6 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) goto out; } - /* check if busy context is exclusive */ if (il->ctx.vif && (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { @@ -4501,17 +4523,18 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) il->iw_mode = NL80211_IFTYPE_STATION; } - out: +out: mutex_unlock(&il->mutex); D_MAC80211("leave\n"); return err; } + EXPORT_SYMBOL(il_mac_add_interface); -static void il_teardown_interface(struct il_priv *il, - struct ieee80211_vif *vif, - bool mode_change) +static void +il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, + bool mode_change) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -4529,8 +4552,8 @@ static void il_teardown_interface(struct il_priv *il, } } -void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +void +il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -4550,35 +4573,40 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, D_MAC80211("leave\n"); } + EXPORT_SYMBOL(il_mac_remove_interface); -int il_alloc_txq_mem(struct il_priv *il) +int +il_alloc_txq_mem(struct il_priv *il) { if (!il->txq) - il->txq = kzalloc( - sizeof(struct il_tx_queue) * - il->cfg->base_params->num_of_queues, - GFP_KERNEL); + il->txq = + kzalloc(sizeof(struct il_tx_queue) * + il->cfg->base_params->num_of_queues, GFP_KERNEL); if (!il->txq) { IL_ERR("Not enough memory for txq\n"); return -ENOMEM; } return 0; } + EXPORT_SYMBOL(il_alloc_txq_mem); -void il_txq_mem(struct il_priv *il) +void +il_txq_mem(struct il_priv *il) { kfree(il->txq); il->txq = NULL; } + EXPORT_SYMBOL(il_txq_mem); #ifdef CONFIG_IWLEGACY_DEBUGFS #define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) -void il_reset_traffic_log(struct il_priv *il) +void +il_reset_traffic_log(struct il_priv *il) { il->tx_traffic_idx = 0; il->rx_traffic_idx = 0; @@ -4588,22 +4616,21 @@ void il_reset_traffic_log(struct il_priv *il) memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); } -int il_alloc_traffic_mem(struct il_priv *il) +int +il_alloc_traffic_mem(struct il_priv *il) { u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; if (il_debug_level & IL_DL_TX) { if (!il->tx_traffic) { - il->tx_traffic = - kzalloc(traffic_size, GFP_KERNEL); + il->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); if (!il->tx_traffic) return -ENOMEM; } } if (il_debug_level & IL_DL_RX) { if (!il->rx_traffic) { - il->rx_traffic = - kzalloc(traffic_size, GFP_KERNEL); + il->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); if (!il->rx_traffic) return -ENOMEM; } @@ -4611,9 +4638,11 @@ int il_alloc_traffic_mem(struct il_priv *il) il_reset_traffic_log(il); return 0; } + EXPORT_SYMBOL(il_alloc_traffic_mem); -void il_free_traffic_mem(struct il_priv *il) +void +il_free_traffic_mem(struct il_priv *il) { kfree(il->tx_traffic); il->tx_traffic = NULL; @@ -4621,10 +4650,12 @@ void il_free_traffic_mem(struct il_priv *il) kfree(il->rx_traffic); il->rx_traffic = NULL; } + EXPORT_SYMBOL(il_free_traffic_mem); -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) +void +il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { __le16 fc; u16 len; @@ -4637,19 +4668,22 @@ void il_dbg_log_tx_data_frame(struct il_priv *il, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; + len = + (length > + IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((il->tx_traffic + - (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); + (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, + len); il->tx_traffic_idx = - (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } + EXPORT_SYMBOL(il_dbg_log_tx_data_frame); -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) +void +il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { __le16 fc; u16 len; @@ -4662,18 +4696,21 @@ void il_dbg_log_rx_data_frame(struct il_priv *il, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; + len = + (length > + IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((il->rx_traffic + - (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); + (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, + len); il->rx_traffic_idx = - (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } + EXPORT_SYMBOL(il_dbg_log_rx_data_frame); -const char *il_get_mgmt_string(int cmd) +const char * +il_get_mgmt_string(int cmd) { switch (cmd) { IL_CMD(MANAGEMENT_ASSOC_REQ); @@ -4694,7 +4731,8 @@ const char *il_get_mgmt_string(int cmd) } } -const char *il_get_ctrl_string(int cmd) +const char * +il_get_ctrl_string(int cmd) { switch (cmd) { IL_CMD(CONTROL_BACK_REQ); @@ -4711,7 +4749,8 @@ const char *il_get_ctrl_string(int cmd) } } -void il_clear_traffic_stats(struct il_priv *il) +void +il_clear_traffic_stats(struct il_priv *il) { memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); @@ -4731,7 +4770,7 @@ void il_clear_traffic_stats(struct il_priv *il) void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { - struct traffic_stats *stats; + struct traffic_stats *stats; if (is_tx) stats = &il->tx_stats; @@ -4810,10 +4849,12 @@ il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) stats->data_bytes += len; } } + EXPORT_SYMBOL(il_update_stats); #endif -int il_force_reset(struct il_priv *il, bool external) +int +il_force_reset(struct il_priv *il, bool external) { struct il_force_reset *force_reset; @@ -4825,7 +4866,7 @@ int il_force_reset(struct il_priv *il, bool external) if (!external) { if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + - force_reset->reset_duration, jiffies)) { + force_reset->reset_duration, jiffies)) { D_INFO("force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; @@ -4845,7 +4886,7 @@ int il_force_reset(struct il_priv *il, bool external) if (!external && !il->cfg->mod_params->restart_fw) { D_INFO("Cancel firmware reload based on " - "module parameter setting\n"); + "module parameter setting\n"); return 0; } @@ -4865,8 +4906,7 @@ int il_force_reset(struct il_priv *il, bool external) } int -il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, +il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p) { struct il_priv *il = hw->priv; @@ -4914,17 +4954,19 @@ il_mac_change_interface(struct ieee80211_hw *hw, */ err = 0; - out: +out: mutex_unlock(&il->mutex); return err; } + EXPORT_SYMBOL(il_mac_change_interface); /* * On every watchdog tick we check (latest) time stamp. If it does not * change during timeout period and queue is not empty we reset firmware. */ -static int il_check_stuck_queue(struct il_priv *il, int cnt) +static int +il_check_stuck_queue(struct il_priv *il, int cnt) { struct il_tx_queue *txq = &il->txq[cnt]; struct il_queue *q = &txq->q; @@ -4936,12 +4978,13 @@ static int il_check_stuck_queue(struct il_priv *il, int cnt) return 0; } - timeout = txq->time_stamp + - msecs_to_jiffies(il->cfg->base_params->wd_timeout); + timeout = + txq->time_stamp + + msecs_to_jiffies(il->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IL_ERR("Queue %d stuck for %u ms.\n", - q->id, il->cfg->base_params->wd_timeout); + IL_ERR("Queue %d stuck for %u ms.\n", q->id, + il->cfg->base_params->wd_timeout); ret = il_force_reset(il, false); return (ret == -EAGAIN) ? 0 : 1; } @@ -4959,7 +5002,8 @@ static int il_check_stuck_queue(struct il_priv *il, int cnt) * Watchdog timer callback, we check each tx queue for stuck, if if hung * we reset the firmware. If everything is fine just rearm the timer. */ -void il_bg_watchdog(unsigned long data) +void +il_bg_watchdog(unsigned long data) { struct il_priv *il = (struct il_priv *)data; int cnt; @@ -4987,12 +5031,14 @@ void il_bg_watchdog(unsigned long data) } } - mod_timer(&il->watchdog, jiffies + - msecs_to_jiffies(IL_WD_TICK(timeout))); + mod_timer(&il->watchdog, + jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); } + EXPORT_SYMBOL(il_bg_watchdog); -void il_setup_watchdog(struct il_priv *il) +void +il_setup_watchdog(struct il_priv *il) { unsigned int timeout = il->cfg->base_params->wd_timeout; @@ -5002,6 +5048,7 @@ void il_setup_watchdog(struct il_priv *il) else del_timer(&il->watchdog); } + EXPORT_SYMBOL(il_setup_watchdog); /* @@ -5011,8 +5058,7 @@ EXPORT_SYMBOL(il_setup_watchdog); * the internal part is the time in usec within one beacon interval */ u32 -il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval) +il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval) { u32 quot; u32 rem; @@ -5021,32 +5067,42 @@ il_usecs_to_beacons(struct il_priv *il, if (!interval || !usec) return 0; - quot = (usec / interval) & - (il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits) >> - il->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); + quot = + (usec / + interval) & (il_beacon_time_mask_high(il, + il->hw_params. + beacon_time_tsf_bits) >> il-> + hw_params.beacon_time_tsf_bits); + rem = + (usec % interval) & il_beacon_time_mask_low(il, + il->hw_params. + beacon_time_tsf_bits); return (quot << il->hw_params.beacon_time_tsf_bits) + rem; } + EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval) +__le32 +il_add_beacon_time(struct il_priv * il, u32 base, u32 addon, + u32 beacon_interval) { u32 base_low = base & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); + il->hw_params. + beacon_time_tsf_bits); u32 addon_low = addon & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); + il->hw_params. + beacon_time_tsf_bits); u32 interval = beacon_interval * TIME_UNIT; u32 res = (base & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)) + - (addon & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)); + il->hw_params. + beacon_time_tsf_bits)) + + (addon & il_beacon_time_mask_high(il, + il->hw_params. + beacon_time_tsf_bits)); if (base_low > addon_low) res += base_low - addon_low; @@ -5058,11 +5114,13 @@ __le32 il_add_beacon_time(struct il_priv *il, u32 base, return cpu_to_le32(res); } + EXPORT_SYMBOL(il_add_beacon_time); #ifdef CONFIG_PM -int il_pci_suspend(struct device *device) +int +il_pci_suspend(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); struct il_priv *il = pci_get_drvdata(pdev); @@ -5078,9 +5136,11 @@ int il_pci_suspend(struct device *device) return 0; } + EXPORT_SYMBOL(il_pci_suspend); -int il_pci_resume(struct device *device) +int +il_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); struct il_priv *il = pci_get_drvdata(pdev); @@ -5094,8 +5154,7 @@ int il_pci_resume(struct device *device) il_enable_interrupts(il); - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + if (!(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; if (hw_rfkill) @@ -5107,6 +5166,7 @@ int il_pci_resume(struct device *device) return 0; } + EXPORT_SYMBOL(il_pci_resume); const struct dev_pm_ops il_pm_ops = { @@ -5117,6 +5177,7 @@ const struct dev_pm_ops il_pm_ops = { .poweroff = il_pci_suspend, .restore = il_pci_resume, }; + EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ @@ -5134,24 +5195,23 @@ il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) if (ctx->qos_data.qos_active) ctx->qos_data.def_qos_parm.qos_flags |= - QOS_PARAM_FLG_UPDATE_EDCA_MSK; + QOS_PARAM_FLG_UPDATE_EDCA_MSK; if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", - ctx->qos_data.qos_active, - ctx->qos_data.def_qos_parm.qos_flags); + ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); - il_send_cmd_pdu_async(il, ctx->qos_cmd, - sizeof(struct il_qosparam_cmd), - &ctx->qos_data.def_qos_parm, NULL); + il_send_cmd_pdu_async(il, ctx->qos_cmd, sizeof(struct il_qosparam_cmd), + &ctx->qos_data.def_qos_parm, NULL); } /** * il_mac_config - mac80211 config callback */ -int il_mac_config(struct ieee80211_hw *hw, u32 changed) +int +il_mac_config(struct ieee80211_hw *hw, u32 changed) { struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; @@ -5170,16 +5230,16 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&il->mutex); - D_MAC80211("enter to channel %d changed 0x%X\n", - channel->hw_value, changed); + D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, + changed); if (unlikely(test_bit(S_SCANNING, &il->status))) { scan_active = 1; D_MAC80211("scan active\n"); } - if (changed & (IEEE80211_CONF_CHANGE_SMPS | - IEEE80211_CONF_CHANGE_CHANNEL)) { + if (changed & + (IEEE80211_CONF_CHANGE_SMPS | IEEE80211_CONF_CHANGE_CHANNEL)) { /* mac80211 uses static for non-HT which is what we want */ il->current_ht_config.smps = conf->smps_mode; @@ -5227,15 +5287,15 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if (ctx->ht.enabled) { if (conf_is_ht40_minus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; + IEEE80211_HT_PARAM_CHA_SEC_BELOW; ctx->ht.is_40mhz = true; } else if (conf_is_ht40_plus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; ctx->ht.is_40mhz = true; } else { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; + IEEE80211_HT_PARAM_CHA_SEC_NONE; ctx->ht.is_40mhz = false; } } else @@ -5245,8 +5305,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) * Default to no protection. Protection mode will * later be set from BSS config in il_ht_conf */ - ctx->ht.protection = - IEEE80211_HT_OP_MODE_PROTECTION_NONE; + ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; /* if we are switching from ht to 2.4 clear flags * from any ht related info since 2.4 does not @@ -5257,32 +5316,29 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) il_set_rxon_channel(il, channel, ctx); il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, - ctx->vif); + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); spin_unlock_irqrestore(&il->lock, flags); if (il->cfg->ops->legacy->update_bcast_stations) - ret = - il->cfg->ops->legacy->update_bcast_stations(il); + ret = il->cfg->ops->legacy->update_bcast_stations(il); - set_ch_out: +set_ch_out: /* The list of supported rates and rate mask can be different * for each band; since the band may have changed, reset * the rate mask to what mac80211 lists */ il_set_rate(il); } - if (changed & (IEEE80211_CONF_CHANGE_PS | - IEEE80211_CONF_CHANGE_IDLE)) { + if (changed & (IEEE80211_CONF_CHANGE_PS | IEEE80211_CONF_CHANGE_IDLE)) { ret = il_power_update_mode(il, false); if (ret) D_MAC80211("Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - D_MAC80211("TX Power old=%d new=%d\n", - il->tx_power_user_lmt, conf->power_level); + D_MAC80211("TX Power old=%d new=%d\n", il->tx_power_user_lmt, + conf->power_level); il_set_tx_power(il, conf->power_level, false); } @@ -5309,8 +5365,8 @@ out: } EXPORT_SYMBOL(il_mac_config); -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +void +il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; unsigned long flags; @@ -5357,10 +5413,11 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, D_MAC80211("leave\n"); } + EXPORT_SYMBOL(il_mac_reset_tsf); -static void il_ht_conf(struct il_priv *il, - struct ieee80211_vif *vif) +static void +il_ht_conf(struct il_priv *il, struct ieee80211_vif *vif) { struct il_ht_config *ht_conf = &il->current_ht_config; struct ieee80211_sta *sta; @@ -5373,10 +5430,10 @@ static void il_ht_conf(struct il_priv *il, return; ctx->ht.protection = - bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; + bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; ctx->ht.non_gf_sta_present = - !!(bss_conf->ht_operation_mode & - IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); + !!(bss_conf-> + ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); ht_conf->single_chain_sufficient = false; @@ -5388,9 +5445,10 @@ static void il_ht_conf(struct il_priv *il, struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; int maxstreams; - maxstreams = (ht_cap->mcs.tx_params & - IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) - >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; + maxstreams = + (ht_cap->mcs. + tx_params & IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) + >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; maxstreams += 1; if (ht_cap->mcs.rx_mask[1] == 0 && @@ -5419,8 +5477,8 @@ static void il_ht_conf(struct il_priv *il, D_ASSOC("leave\n"); } -static inline void il_set_no_assoc(struct il_priv *il, - struct ieee80211_vif *vif) +static inline void +il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -5434,8 +5492,8 @@ static inline void il_set_no_assoc(struct il_priv *il, il_commit_rxon(il, ctx); } -static void il_beacon_update(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +static void +il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; unsigned long flags; @@ -5476,10 +5534,9 @@ static void il_beacon_update(struct ieee80211_hw *hw, il->cfg->ops->legacy->post_associate(il); } -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes) +void +il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, u32 changes) { struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -5527,24 +5584,21 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * below/in post_associate will fail. */ if (il_scan_cancel_timeout(il, 100)) { - IL_WARN( - "Aborted scan still in progress after 100ms\n"); - D_MAC80211( - "leaving - scan abort failed.\n"); + IL_WARN("Aborted scan still in progress after 100ms\n"); + D_MAC80211("leaving - scan abort failed.\n"); mutex_unlock(&il->mutex); return; } /* mac80211 only sets assoc when in STATION mode */ if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); + memcpy(ctx->staging.bssid_addr, bss_conf->bssid, + ETH_ALEN); /* currently needed in a few places */ memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); } else { - ctx->staging.filter_flags &= - ~RXON_FILTER_ASSOC_MSK; + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; } } @@ -5558,8 +5612,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - D_MAC80211("ERP_PREAMBLE %d\n", - bss_conf->use_short_preamble); + D_MAC80211("ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else @@ -5567,8 +5620,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - D_MAC80211( - "ERP_CTS %d\n", bss_conf->use_cts_prot); + D_MAC80211("ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; else @@ -5585,14 +5637,14 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * To do that, remove code from il_set_rate() and put something * like this here: * - if (A-band) - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates; - else - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates >> 4; - ctx->staging.cck_basic_rates = - bss_conf->basic_rates & 0xF; + if (A-band) + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates; + else + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates >> 4; + ctx->staging.cck_basic_rates = + bss_conf->basic_rates & 0xF; */ } @@ -5615,21 +5667,19 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - D_MAC80211("Changes (%#x) while associated\n", - changes); + D_MAC80211("Changes (%#x) while associated\n", changes); ret = il_send_rxon_assoc(il, ctx); if (!ret) { /* Sync active_rxon with latest change. */ - memcpy((void *)&ctx->active, - &ctx->staging, - sizeof(struct il_rxon_cmd)); + memcpy((void *)&ctx->active, &ctx->staging, + sizeof(struct il_rxon_cmd)); } } if (changes & BSS_CHANGED_BEACON_ENABLED) { if (vif->bss_conf.enable_beacon) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); + memcpy(ctx->staging.bssid_addr, bss_conf->bssid, + ETH_ALEN); memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); il->cfg->ops->legacy->config_ap(il); } else @@ -5637,21 +5687,25 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_IBSS) { - ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, - bss_conf->ibss_joined); + ret = + il->cfg->ops->legacy->manage_ibss_station(il, vif, + bss_conf-> + ibss_joined); if (ret) IL_ERR("failed to %s IBSS station %pM\n", - bss_conf->ibss_joined ? "add" : "remove", - bss_conf->bssid); + bss_conf->ibss_joined ? "add" : "remove", + bss_conf->bssid); } mutex_unlock(&il->mutex); D_MAC80211("leave\n"); } + EXPORT_SYMBOL(il_mac_bss_info_changed); -irqreturn_t il_isr(int irq, void *data) +irqreturn_t +il_isr(int irq, void *data) { struct il_priv *il = data; u32 inta, inta_mask; @@ -5666,7 +5720,7 @@ irqreturn_t il_isr(int irq, void *data) * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ + inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ _il_wr(il, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ @@ -5677,8 +5731,7 @@ irqreturn_t il_isr(int irq, void *data) * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - D_ISR( - "Ignore interrupt, inta == 0, inta_fh == 0\n"); + D_ISR("Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -5689,8 +5742,8 @@ irqreturn_t il_isr(int irq, void *data) goto unplugged; } - D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); + D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, + inta_fh); inta &= ~CSR_INT_BIT_SCD; @@ -5710,15 +5763,16 @@ none: spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; } + EXPORT_SYMBOL(il_isr); /* * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this * function. */ -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags) +void +il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, + __le16 fc, __le32 * tx_flags) { if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { *tx_flags |= TX_CMD_FLG_RTS_MSK; @@ -5737,11 +5791,12 @@ void il_tx_cmd_protection(struct il_priv *il, *tx_flags |= TX_CMD_FLG_CTS_MSK; break; } - } else if (info->control.rates[0].flags & - IEEE80211_TX_RC_USE_CTS_PROTECT) { + } else if (info->control.rates[0]. + flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { *tx_flags &= ~TX_CMD_FLG_RTS_MSK; *tx_flags |= TX_CMD_FLG_CTS_MSK; *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; } } + EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index b1d237f..38ff3d6 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -27,7 +27,7 @@ #define __il_core_h__ #include -#include /* for struct pci_device_id */ +#include /* for struct pci_device_id */ #include #include #include @@ -59,7 +59,7 @@ struct il_tx_queue; #define U32_PAD(n) ((4-(n))&0x3) /* CT-KILL constants */ -#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ +#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ /* Default noise level to report when noise measurement is not available. * This may be because we're: @@ -112,16 +112,15 @@ struct il_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); + void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, + struct il_rx_pkt * pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ u32 flags; - DEFINE_DMA_UNMAP_ADDR(mapping); - DEFINE_DMA_UNMAP_LEN(len); + DEFINE_DMA_UNMAP_ADDR(mapping); + DEFINE_DMA_UNMAP_LEN(len); }; /* @@ -130,17 +129,17 @@ struct il_cmd_meta { * Contains common data for Rx and Tx queues */ struct il_queue { - int n_bd; /* number of BDs in this queue */ - int write_ptr; /* 1-st empty entry (idx) host_w*/ - int read_ptr; /* last used entry (idx) host_r*/ + int n_bd; /* number of BDs in this queue */ + int write_ptr; /* 1-st empty entry (idx) host_w */ + int read_ptr; /* last used entry (idx) host_r */ /* use for monitoring and recovering the stuck queue */ - dma_addr_t dma_addr; /* physical addr for BD's */ - int n_win; /* safe queue win */ + dma_addr_t dma_addr; /* physical addr for BD's */ + int n_win; /* safe queue win */ u32 id; - int low_mark; /* low watermark, resume queue if free - * space more than this */ - int high_mark; /* high watermark, stop queue if free - * space less than this */ + int low_mark; /* low watermark, resume queue if free + * space more than this */ + int high_mark; /* high watermark, stop queue if free + * space less than this */ }; /* One for each TFD */ @@ -188,11 +187,10 @@ struct il_tx_queue { * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. */ -#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ - -#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ -#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ +#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ +#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ +#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ /* * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. @@ -213,11 +211,11 @@ struct il_tx_queue { #define IL_NUM_TX_CALIB_GROUPS 5 enum { EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ - EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ + EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ /* Bit 2 Reserved */ EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ - EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ + EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ /* Bit 6 Reserved (was Narrow Channel) */ EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ }; @@ -251,10 +249,10 @@ struct il_eeprom_channel { /* 4965 driver does not work with txpower calibration version < 5 */ #define EEPROM_4965_TX_POWER_VERSION (5) #define EEPROM_4965_EEPROM_VERSION (0x2f) -#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ -#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ -#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ -#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ +#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ +#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ +#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ +#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ /* 2.4 GHz */ extern const u8 il_eeprom_band_1[14]; @@ -280,7 +278,6 @@ struct il_eeprom_calib_measure { s8 pa_det; /* Power amp detector level (not used) */ } __packed; - /* * measurement set for one channel. EEPROM contains: * @@ -292,8 +289,8 @@ struct il_eeprom_calib_measure { struct il_eeprom_calib_ch_info { u8 ch_num; struct il_eeprom_calib_measure - measurements[EEPROM_TX_POWER_TX_CHAINS] - [EEPROM_TX_POWER_MEASUREMENTS]; + measurements[EEPROM_TX_POWER_TX_CHAINS] + [EEPROM_TX_POWER_MEASUREMENTS]; } __packed; /* @@ -307,13 +304,12 @@ struct il_eeprom_calib_ch_info { * 2) Sample measurement sets for 2 channels close to the range endpoints. */ struct il_eeprom_calib_subband_info { - u8 ch_from; /* channel number of lowest channel in subband */ - u8 ch_to; /* channel number of highest channel in subband */ + u8 ch_from; /* channel number of lowest channel in subband */ + u8 ch_to; /* channel number of highest channel in subband */ struct il_eeprom_calib_ch_info ch1; struct il_eeprom_calib_ch_info ch2; } __packed; - /* * txpower calibration info. EEPROM contains: * @@ -338,11 +334,9 @@ struct il_eeprom_calib_info { u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ u8 saturation_power52; /* half-dBm */ __le16 voltage; /* signed */ - struct il_eeprom_calib_subband_info - band_info[EEPROM_TX_POWER_BANDS]; + struct il_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS]; } __packed; - /* General */ #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ @@ -356,12 +350,12 @@ struct il_eeprom_calib_info { #define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */ /* The following masks are to be applied on EEPROM_RADIO_CONFIG */ -#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ -#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ -#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ -#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ -#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ -#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ +#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ +#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ +#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ +#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ +#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ +#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ #define EEPROM_3945_RF_CFG_TYPE_MAX 0x0 #define EEPROM_4965_RF_CFG_TYPE_MAX 0x1 @@ -378,7 +372,7 @@ struct il_eeprom_calib_info { * * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ -#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ +#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ #define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ #define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ @@ -438,22 +432,19 @@ struct il_eeprom_calib_info { struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv *il); - void (*release_semaphore) (struct il_priv *il); + int (*acquire_semaphore) (struct il_priv * il); + void (*release_semaphore) (struct il_priv * il); }; - int il_eeprom_init(struct il_priv *il); void il_eeprom_free(struct il_priv *il); -const u8 *il_eeprom_query_addr(const struct il_priv *il, - size_t offset); +const u8 *il_eeprom_query_addr(const struct il_priv *il, size_t offset); u16 il_eeprom_query16(const struct il_priv *il, size_t offset); int il_init_channel_map(struct il_priv *il); void il_free_channel_map(struct il_priv *il); -const struct il_channel_info *il_get_channel_info( - const struct il_priv *il, - enum ieee80211_band band, u16 channel); - +const struct il_channel_info *il_get_channel_info(const struct il_priv *il, + enum ieee80211_band band, + u16 channel); #define IL_NUM_SCAN_RATES (2) @@ -508,21 +499,21 @@ struct il_channel_info { struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for * HT40 channel */ - u8 channel; /* channel number */ - u8 flags; /* flags copied from EEPROM */ - s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ - s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ - s8 min_power; /* always 0 */ - s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ + u8 channel; /* channel number */ + u8 flags; /* flags copied from EEPROM */ + s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ + s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ + s8 min_power; /* always 0 */ + s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ - u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ - u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ + u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ + u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ enum ieee80211_band band; /* HT40 channel info */ s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ u8 ht40_flags; /* flags copied from EEPROM */ - u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ + u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for @@ -598,13 +589,11 @@ struct il_device_cmd { #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) - struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); + void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, + struct il_rx_pkt * pkt); u32 flags; u16 len; u8 id; @@ -681,9 +670,8 @@ struct il_ht_agg { u8 state; }; - struct il_tid_data { - u16 seq_number; /* 4965 only */ + u16 seq_number; /* 4965 only */ u16 tfds_in_queue; struct il_ht_agg agg; }; @@ -728,7 +716,7 @@ union il_ht_rate_supp { struct il_ht_config { bool single_chain_sufficient; - enum ieee80211_smps_mode smps; /* current smps mode */ + enum ieee80211_smps_mode smps; /* current smps mode */ }; /* QoS structures */ @@ -776,14 +764,14 @@ struct fw_desc { /* uCode file layout */ struct il_ucode_header { - __le32 ver; /* major/minor/API/serial */ + __le32 ver; /* major/minor/API/serial */ struct { __le32 inst_size; /* bytes of runtime code */ __le32 data_size; /* bytes of runtime data */ __le32 init_size; /* bytes of init code */ __le32 init_data_size; /* bytes of init data */ __le32 boot_size; /* bytes of bootstrap code */ - u8 data[0]; /* in same order as sizes */ + u8 data[0]; /* in same order as sizes */ } v1; }; @@ -822,11 +810,9 @@ struct il_sensitivity_ranges { u16 nrg_th_cca; }; - #define KELVIN_TO_CELSIUS(x) ((x)-273) #define CELSIUS_TO_KELVIN(x) ((x)+273) - /** * struct il_hw_params * @max_txq_num: Max # Tx queues supported @@ -853,26 +839,25 @@ struct il_hw_params { u8 dma_chnl_num; u16 scd_bc_tbls_size; u32 tfd_size; - u8 tx_chains_num; - u8 rx_chains_num; - u8 valid_tx_ant; - u8 valid_rx_ant; + u8 tx_chains_num; + u8 rx_chains_num; + u8 valid_tx_ant; + u8 valid_rx_ant; u16 max_rxq_size; u16 max_rxq_log; u32 rx_page_order; u32 rx_wrt_ptr_reg; - u8 max_stations; - u8 ht40_channel; - u8 max_beacon_itrvl; /* in 1024 ms */ + u8 max_stations; + u8 ht40_channel; + u8 max_beacon_itrvl; /* in 1024 ms */ u32 max_inst_size; u32 max_data_size; u32 max_bsm_size; - u32 ct_kill_threshold; /* value in hw-dependent units */ + u32 ct_kill_threshold; /* value in hw-dependent units */ u16 beacon_time_tsf_bits; const struct il_sensitivity_ranges *sens; }; - /****************************************************************************** * * Functions implemented in core module which are forward declared here @@ -891,16 +876,19 @@ struct il_hw_params { extern void il4965_update_chain_flags(struct il_priv *il); extern const u8 il_bcast_addr[ETH_ALEN]; extern int il_queue_space(const struct il_queue *q); -static inline int il_queue_used(const struct il_queue *q, int i) +static inline int +il_queue_used(const struct il_queue *q, int i) { - return q->write_ptr >= q->read_ptr ? - (i >= q->read_ptr && i < q->write_ptr) : - !(i < q->read_ptr && i >= q->write_ptr); + return q->write_ptr >= q->read_ptr ? (i >= q->read_ptr && + i < q->write_ptr) : !(i < + q->read_ptr + && i >= + q-> + write_ptr); } - -static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, - int is_huge) +static inline u8 +il_get_cmd_idx(struct il_queue *q, u32 idx, int is_huge) { /* * This is for init calibration result and scan command which @@ -914,7 +902,6 @@ static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, return idx & (q->n_win - 1); } - struct il_dma_ptr { dma_addr_t dma; void *addr; @@ -974,14 +961,14 @@ enum il4965_false_alarm_state { }; enum il4965_chain_noise_state { - IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ + IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ IL_CHAIN_NOISE_ACCUMULATE, IL_CHAIN_NOISE_CALIBRATED, IL_CHAIN_NOISE_DONE, }; enum il4965_calib_enabled_state { - IL_CALIB_DISABLED = 0, /* must be 0 */ + IL_CALIB_DISABLED = 0, /* must be 0 */ IL_CALIB_ENABLED = 1, }; @@ -1023,7 +1010,7 @@ struct il_sensitivity_data { u32 nrg_curr_state; u32 nrg_prev_state; u32 nrg_value[10]; - u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; + u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; u32 nrg_silence_ref; u32 nrg_energy_idx; u32 nrg_silence_idx; @@ -1053,7 +1040,7 @@ struct il_chain_noise_data { u8 state; }; -#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ +#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ #define IL_TRAFFIC_ENTRIES (256) @@ -1098,7 +1085,7 @@ enum il_mgmt_stats { }; /* control stats */ enum il_ctrl_stats { - CONTROL_BACK_REQ = 0, + CONTROL_BACK_REQ = 0, CONTROL_BACK, CONTROL_PSPOLL, CONTROL_RTS, @@ -1237,8 +1224,8 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*handlers[IL_CN_MAX])(struct il_priv *il, - struct il_rx_buf *rxb); + void (*handlers[IL_CN_MAX]) (struct il_priv * il, + struct il_rx_buf * rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -1289,9 +1276,9 @@ struct il_priv { /* pci hardware address support */ void __iomem *hw_base; - u32 hw_rev; - u32 hw_wa_rev; - u8 rev_id; + u32 hw_rev; + u32 hw_wa_rev; + u8 rev_id; /* command queue number */ u8 cmd_queue; @@ -1303,9 +1290,9 @@ struct il_priv { struct mac_address addresses[1]; /* uCode images, save to reload in case of failure */ - int fw_idx; /* firmware we're trying to load */ - u32 ucode_ver; /* version of ucode, copy of - il_ucode.ver */ + int fw_idx; /* firmware we're trying to load */ + u32 ucode_ver; /* version of ucode, copy of + il_ucode.ver */ struct fw_desc ucode_code; /* runtime inst */ struct fw_desc ucode_data; /* runtime data original */ struct fw_desc ucode_data_backup; /* runtime data save/restore */ @@ -1345,8 +1332,8 @@ struct il_priv { struct il_rx_queue rxq; struct il_tx_queue *txq; unsigned long txq_ctx_active_msk; - struct il_dma_ptr kw; /* keep warm address */ - struct il_dma_ptr scd_bc_tbls; + struct il_dma_ptr kw; /* keep warm address */ + struct il_dma_ptr scd_bc_tbls; u32 scd_base_addr; /* scheduler sram base address */ @@ -1362,7 +1349,7 @@ struct il_priv { struct il_power_mgr power_data; /* context information */ - u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ + u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ /* station table variables */ @@ -1477,12 +1464,11 @@ struct il_priv { s8 tx_power_device_lmt; s8 tx_power_next; - #ifdef CONFIG_IWLEGACY_DEBUG /* debugging info */ - u32 debug_level; /* per device debugging will override global - il_debug_level if set */ -#endif /* CONFIG_IWLEGACY_DEBUG */ + u32 debug_level; /* per device debugging will override global + il_debug_level if set */ +#endif /* CONFIG_IWLEGACY_DEBUG */ #ifdef CONFIG_IWLEGACY_DEBUGFS /* debugfs */ u16 tx_traffic_idx; @@ -1492,7 +1478,7 @@ struct il_priv { struct dentry *debugfs_dir; u32 dbgfs_sram_offset, dbgfs_sram_len; bool disable_ht40; -#endif /* CONFIG_IWLEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ struct work_struct txpower_work; u32 disable_sens_cal; @@ -1506,25 +1492,26 @@ struct il_priv { struct led_classdev led; unsigned long blink_on, blink_off; bool led_registered; -}; /*il_priv */ +}; /*il_priv */ -static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) +static inline void +il_txq_ctx_activate(struct il_priv *il, int txq_id) { set_bit(txq_id, &il->txq_ctx_active_msk); } -static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) +static inline void +il_txq_ctx_deactivate(struct il_priv *il, int txq_id) { clear_bit(txq_id, &il->txq_ctx_active_msk); } static inline struct ieee80211_hdr * -il_tx_queue_get_hdr(struct il_priv *il, - int txq_id, int idx) +il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx) { if (il->txq[txq_id].txb[idx].skb) - return (struct ieee80211_hdr *)il->txq[txq_id]. - txb[idx].skb->data; + return (struct ieee80211_hdr *)il->txq[txq_id].txb[idx].skb-> + data; return NULL; } @@ -1539,34 +1526,40 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif) #define for_each_context(il, _ctx) \ for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) -static inline int il_is_associated(struct il_priv *il) +static inline int +il_is_associated(struct il_priv *il) { return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int il_is_any_associated(struct il_priv *il) +static inline int +il_is_any_associated(struct il_priv *il) { return il_is_associated(il); } -static inline int il_is_associated_ctx(struct il_rxon_context *ctx) +static inline int +il_is_associated_ctx(struct il_rxon_context *ctx) { return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int il_is_channel_valid(const struct il_channel_info *ch_info) +static inline int +il_is_channel_valid(const struct il_channel_info *ch_info) { if (ch_info == NULL) return 0; return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; } -static inline int il_is_channel_radar(const struct il_channel_info *ch_info) +static inline int +il_is_channel_radar(const struct il_channel_info *ch_info) { return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; } -static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) +static inline u8 +il_is_channel_a_band(const struct il_channel_info *ch_info) { return ch_info->band == IEEE80211_BAND_5GHZ; } @@ -1583,7 +1576,6 @@ il_is_channel_ibss(const struct il_channel_info *ch) return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; } - static inline void __il_free_pages(struct il_priv *il, struct page *page) { @@ -1591,7 +1583,8 @@ __il_free_pages(struct il_priv *il, struct page *page) il->alloc_rxb_page--; } -static inline void il_free_pages(struct il_priv *il, unsigned long page) +static inline void +il_free_pages(struct il_priv *il, unsigned long page) { free_pages(page, il->hw_params.rx_page_order); il->alloc_rxb_page--; @@ -1615,77 +1608,74 @@ static inline void il_free_pages(struct il_priv *il, unsigned long page) #define IL_CMD(x) case x: return #x /* Size of one Rx buffer in host DRAM */ -#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ +#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ #define IL_RX_BUF_SIZE_4K (4 * 1024) #define IL_RX_BUF_SIZE_8K (8 * 1024) struct il_hcmd_ops { - int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); - int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); - void (*set_rxon_chain)(struct il_priv *il, - struct il_rxon_context *ctx); + int (*rxon_assoc) (struct il_priv * il, struct il_rxon_context * ctx); + int (*commit_rxon) (struct il_priv * il, struct il_rxon_context * ctx); + void (*set_rxon_chain) (struct il_priv * il, + struct il_rxon_context * ctx); }; struct il_hcmd_utils_ops { - u16 (*get_hcmd_size)(u8 cmd_id, u16 len); - u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, - u8 *data); - int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); - void (*post_scan)(struct il_priv *il); + u16(*get_hcmd_size) (u8 cmd_id, u16 len); + u16(*build_addsta_hcmd) (const struct il_addsta_cmd * cmd, u8 * data); + int (*request_scan) (struct il_priv * il, struct ieee80211_vif * vif); + void (*post_scan) (struct il_priv * il); }; struct il_apm_ops { - int (*init)(struct il_priv *il); - void (*config)(struct il_priv *il); + int (*init) (struct il_priv * il); + void (*config) (struct il_priv * il); }; struct il_debugfs_ops { - ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); + ssize_t(*rx_stats_read) (struct file * file, char __user * user_buf, + size_t count, loff_t * ppos); + ssize_t(*tx_stats_read) (struct file * file, char __user * user_buf, + size_t count, loff_t * ppos); + ssize_t(*general_stats_read) (struct file * file, + char __user * user_buf, size_t count, + loff_t * ppos); }; struct il_temp_ops { - void (*temperature)(struct il_priv *il); + void (*temperature) (struct il_priv * il); }; struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params)(struct il_priv *il); + int (*set_hw_params) (struct il_priv * il); /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, - u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct il_priv *il, - struct il_tx_queue *txq); - int (*txq_init)(struct il_priv *il, - struct il_tx_queue *txq); + void (*txq_update_byte_cnt_tbl) (struct il_priv * il, + struct il_tx_queue * txq, + u16 byte_cnt); + int (*txq_attach_buf_to_tfd) (struct il_priv * il, + struct il_tx_queue * txq, dma_addr_t addr, + u16 len, u8 reset, u8 pad); + void (*txq_free_tfd) (struct il_priv * il, struct il_tx_queue * txq); + int (*txq_init) (struct il_priv * il, struct il_tx_queue * txq); /* setup Rx handler */ - void (*handler_setup)(struct il_priv *il); + void (*handler_setup) (struct il_priv * il); /* alive notification after init uCode load */ - void (*init_alive_start)(struct il_priv *il); + void (*init_alive_start) (struct il_priv * il); /* check validity of rtc data address */ - int (*is_valid_rtc_data_addr)(u32 addr); + int (*is_valid_rtc_data_addr) (u32 addr); /* 1st ucode load */ - int (*load_ucode)(struct il_priv *il); + int (*load_ucode) (struct il_priv * il); - void (*dump_nic_error_log)(struct il_priv *il); - int (*dump_fh)(struct il_priv *il, char **buf, bool display); - int (*set_channel_switch)(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch); + void (*dump_nic_error_log) (struct il_priv * il); + int (*dump_fh) (struct il_priv * il, char **buf, bool display); + int (*set_channel_switch) (struct il_priv * il, + struct ieee80211_channel_switch * ch_switch); /* power management */ struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct il_priv *il); - void (*update_chain_flags)(struct il_priv *il); + int (*send_tx_power) (struct il_priv * il); + void (*update_chain_flags) (struct il_priv * il); /* eeprom operations */ struct il_eeprom_ops eeprom_ops; @@ -1698,16 +1688,16 @@ struct il_lib_ops { }; struct il_led_ops { - int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); + int (*cmd) (struct il_priv * il, struct il_led_cmd * led_cmd); }; struct il_legacy_ops { - void (*post_associate)(struct il_priv *il); - void (*config_ap)(struct il_priv *il); + void (*post_associate) (struct il_priv * il); + void (*config_ap) (struct il_priv * il); /* station management */ - int (*update_bcast_stations)(struct il_priv *il); - int (*manage_ibss_station)(struct il_priv *il, - struct ieee80211_vif *vif, bool add); + int (*update_bcast_stations) (struct il_priv * il); + int (*manage_ibss_station) (struct il_priv * il, + struct ieee80211_vif * vif, bool add); }; struct il_ops { @@ -1726,7 +1716,7 @@ struct il_mod_params { int num_of_queues; /* def: HW dependent */ int disable_11n; /* def: 0 = 11n capabilities enabled */ int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ - int antenna; /* def: 0 = both antennas (use diversity) */ + int antenna; /* def: 0 = both antennas (use diversity) */ int restart_fw; /* def: 1 = restart firmware */ }; @@ -1746,7 +1736,7 @@ struct il_mod_params { struct il_base_params { int eeprom_size; int num_of_queues; /* def: HW dependent */ - int num_of_ampdu_queues;/* def: HW dependent */ + int num_of_ampdu_queues; /* def: HW dependent */ /* for il_apm_init() */ u32 pll_cfg_val; bool set_l0s; @@ -1821,11 +1811,11 @@ struct il_cfg { const char *fw_name_pre; const unsigned int ucode_api_max; const unsigned int ucode_api_min; - u8 valid_tx_ant; - u8 valid_rx_ant; + u8 valid_tx_ant; + u8 valid_rx_ant; unsigned int sku; - u16 eeprom_ver; - u16 eeprom_calib_ver; + u16 eeprom_ver; + u16 eeprom_calib_ver; const struct il_ops *ops; /* module based parameters which can be set from modprobe cmd */ const struct il_mod_params *mod_params; @@ -1841,46 +1831,33 @@ struct il_cfg { ***************************/ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params); +int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u16 queue, const struct ieee80211_tx_queue_params *params); int il_mac_tx_last_beacon(struct ieee80211_hw *hw); -void il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt); -int il_check_rxon_cmd(struct il_priv *il, - struct il_rxon_context *ctx); -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx); -int il_set_rxon_channel(struct il_priv *il, - struct ieee80211_channel *ch, + +void il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, + int hw_decrypt); +int il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx); +int il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx); +int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, struct il_rxon_context *ctx); -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif); -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band); -void il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf); -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap); +void il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, + enum ieee80211_band band, struct ieee80211_vif *vif); +u8 il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band); +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf); +bool il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap); void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx); + struct il_rxon_context *ctx); void il_set_rate(struct il_priv *il); -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats); +int il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, + u32 decrypt_res, struct ieee80211_rx_status *stats); void il_irq_handle_error(struct il_priv *il); -int il_mac_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); +int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -int il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p); + struct ieee80211_vif *vif); +int il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + enum nl80211_iftype newtype, bool newp2p); int il_alloc_txq_mem(struct il_priv *il); void il_txq_mem(struct il_priv *il); @@ -1888,48 +1865,54 @@ void il_txq_mem(struct il_priv *il); int il_alloc_traffic_mem(struct il_priv *il); void il_free_traffic_mem(struct il_priv *il); void il_reset_traffic_log(struct il_priv *il); -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); +void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header); +void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header); const char *il_get_mgmt_string(int cmd); const char *il_get_ctrl_string(int cmd); void il_clear_traffic_stats(struct il_priv *il); -void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, - u16 len); +void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len); #else -static inline int il_alloc_traffic_mem(struct il_priv *il) +static inline int +il_alloc_traffic_mem(struct il_priv *il) { return 0; } -static inline void il_free_traffic_mem(struct il_priv *il) + +static inline void +il_free_traffic_mem(struct il_priv *il) { } -static inline void il_reset_traffic_log(struct il_priv *il) + +static inline void +il_reset_traffic_log(struct il_priv *il) { } -static inline void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) + +static inline void +il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { } -static inline void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) + +static inline void +il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { } -static inline void il_update_stats(struct il_priv *il, bool is_tx, - __le16 fc, u16 len) + +static inline void +il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { } #endif /***************************************************** * RX handlers. * **************************************************/ -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb); +void il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb); +void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb); +void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb); /***************************************************** * RX @@ -1937,16 +1920,12 @@ void il_hdl_error(struct il_priv *il, void il_cmd_queue_unmap(struct il_priv *il); void il_cmd_queue_free(struct il_priv *il); int il_rx_queue_alloc(struct il_priv *il); -void il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q); +void il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q); int il_rx_queue_space(const struct il_rx_queue *q); -void il_tx_cmd_complete(struct il_priv *il, - struct il_rx_buf *rxb); +void il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb); /* Handlers */ -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb); -void il_recover_from_stats(struct il_priv *il, - struct il_rx_pkt *pkt); +void il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb); +void il_recover_from_stats(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); @@ -1955,13 +1934,11 @@ void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); /***************************************************** * TX ******************************************************/ -void il_txq_update_write_ptr(struct il_priv *il, - struct il_tx_queue *txq); -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id); -void il_tx_queue_reset(struct il_priv *il, - struct il_tx_queue *txq, - int slots_num, u32 txq_id); +void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq); +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, + u32 txq_id); +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id); void il_tx_queue_unmap(struct il_priv *il, int txq_id); void il_tx_queue_free(struct il_priv *il, int txq_id); void il_setup_watchdog(struct il_priv *il); @@ -1974,8 +1951,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); * Rate ******************************************************************************/ -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx); +u8 il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx); /******************************************************************************* * Scanning @@ -1984,21 +1960,17 @@ void il_init_scan_params(struct il_priv *il); int il_scan_cancel(struct il_priv *il); int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); void il_force_scan_end(struct il_priv *il); -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req); +int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct cfg80211_scan_request *req); void il_internal_short_hw_scan(struct il_priv *il); int il_force_reset(struct il_priv *il, bool external); -u16 il_fill_probe_req(struct il_priv *il, - struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ie, int ie_len, int left); +u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, + const u8 * ta, const u8 * ie, int ie_len, int left); void il_setup_rx_scan_handlers(struct il_priv *il); -u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes); -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif); +u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, + u8 n_probes); +u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, + struct ieee80211_vif *vif); void il_setup_scan_deferred_work(struct il_priv *il); void il_cancel_scan_deferred_work(struct il_priv *il); @@ -2008,8 +1980,8 @@ void il_cancel_scan_deferred_work(struct il_priv *il); * time if it's a quiet channel (nothing responded to our probe, and there's * no other traffic). * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ -#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ -#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ +#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ +#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ #define IL_SCAN_CHECK_WATCHDOG (HZ * 7) @@ -2018,25 +1990,23 @@ void il_cancel_scan_deferred_work(struct il_priv *il); *****************************************************/ const char *il_get_cmd_string(u8 cmd); -int __must_check il_send_cmd_sync(struct il_priv *il, - struct il_host_cmd *cmd); +int __must_check il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd); int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); -int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, - u16 len, const void *data); -int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, - const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)); +int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, + const void *data); +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, + void (*callback) (struct il_priv * il, + struct il_device_cmd * cmd, + struct il_rx_pkt * pkt)); int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); - /***************************************************** * PCI * *****************************************************/ -static inline u16 il_pcie_link_ctl(struct il_priv *il) +static inline u16 +il_pcie_link_ctl(struct il_priv *il) { int pos; u16 pci_lnk_ctl; @@ -2046,10 +2016,9 @@ static inline u16 il_pcie_link_ctl(struct il_priv *il) } void il_bg_watchdog(unsigned long data); -u32 il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval); -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval); +u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval); +__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, + u32 beacon_interval); #ifdef CONFIG_PM int il_pci_suspend(struct device *device); @@ -2069,11 +2038,10 @@ extern const struct dev_pm_ops il_pm_ops; ******************************************************/ void il4965_dump_nic_error_log(struct il_priv *il); #ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx); +void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx); #else -static inline void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) +static inline void +il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { } #endif @@ -2107,41 +2075,48 @@ void il_free_geos(struct il_priv *il); #define S_FW_ERROR 17 #define S_CHANNEL_SWITCH_PENDING 18 -static inline int il_is_ready(struct il_priv *il) +static inline int +il_is_ready(struct il_priv *il) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ return test_bit(S_READY, &il->status) && - test_bit(S_GEO_CONFIGURED, &il->status) && - !test_bit(S_EXIT_PENDING, &il->status); + test_bit(S_GEO_CONFIGURED, &il->status) && + !test_bit(S_EXIT_PENDING, &il->status); } -static inline int il_is_alive(struct il_priv *il) +static inline int +il_is_alive(struct il_priv *il) { return test_bit(S_ALIVE, &il->status); } -static inline int il_is_init(struct il_priv *il) +static inline int +il_is_init(struct il_priv *il) { return test_bit(S_INIT, &il->status); } -static inline int il_is_rfkill_hw(struct il_priv *il) +static inline int +il_is_rfkill_hw(struct il_priv *il) { return test_bit(S_RF_KILL_HW, &il->status); } -static inline int il_is_rfkill(struct il_priv *il) +static inline int +il_is_rfkill(struct il_priv *il) { return il_is_rfkill_hw(il); } -static inline int il_is_ctkill(struct il_priv *il) +static inline int +il_is_ctkill(struct il_priv *il) { return test_bit(S_CT_KILL, &il->status); } -static inline int il_is_ready_rf(struct il_priv *il) +static inline int +il_is_ready_rf(struct il_priv *il) { if (il_is_rfkill(il)) @@ -2151,66 +2126,63 @@ static inline int il_is_ready_rf(struct il_priv *il) } extern void il_send_bt_config(struct il_priv *il); -extern int il_send_stats_request(struct il_priv *il, - u8 flags, bool clear); +extern int il_send_stats_request(struct il_priv *il, u8 flags, bool clear); void il_apm_stop(struct il_priv *il); int il_apm_init(struct il_priv *il); -int il_send_rxon_timing(struct il_priv *il, - struct il_rxon_context *ctx); -static inline int il_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) +int il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx); +static inline int +il_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { return il->cfg->ops->hcmd->rxon_assoc(il, ctx); } -static inline int il_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx) + +static inline int +il_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { return il->cfg->ops->hcmd->commit_rxon(il, ctx); } -static inline const struct ieee80211_supported_band *il_get_hw_mode( - struct il_priv *il, enum ieee80211_band band) + +static inline const struct ieee80211_supported_band * +il_get_hw_mode(struct il_priv *il, enum ieee80211_band band) { return il->hw->wiphy->bands[band]; } /* mac80211 handlers */ int il_mac_config(struct ieee80211_hw *hw, u32 changed); -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes); -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags); +void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif); +void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, u32 changes); +void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, + __le16 fc, __le32 * tx_flags); irqreturn_t il_isr(int irq, void *data); - #include -static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) +static inline void +_il_write8(struct il_priv *il, u32 ofs, u8 val) { iowrite8(val, il->hw_base + ofs); } #define il_write8(il, ofs, val) _il_write8(il, ofs, val) -static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) +static inline void +_il_wr(struct il_priv *il, u32 ofs, u32 val) { iowrite32(val, il->hw_base + ofs); } -static inline u32 _il_rd(struct il_priv *il, u32 ofs) +static inline u32 +_il_rd(struct il_priv *il, u32 ofs) { return ioread32(il->hw_base + ofs); } #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int -_il_poll_bit(struct il_priv *il, u32 addr, - u32 bits, u32 mask, int timeout) +_il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) { int t = 0; @@ -2219,17 +2191,20 @@ _il_poll_bit(struct il_priv *il, u32 addr, return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } while (t < timeout); + } + while (t < timeout); return -ETIMEDOUT; } -static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) +static inline void +_il_set_bit(struct il_priv *il, u32 reg, u32 mask) { _il_wr(il, reg, _il_rd(il, reg) | mask); } -static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) +static inline void +il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -2244,7 +2219,8 @@ _il_clear_bit(struct il_priv *il, u32 reg, u32 mask) _il_wr(il, reg, _il_rd(il, reg) & ~mask); } -static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) +static inline void +il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -2253,14 +2229,14 @@ static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) spin_unlock_irqrestore(&p->reg_lock, reg_flags); } -static inline int _il_grab_nic_access(struct il_priv *il) +static inline int +_il_grab_nic_access(struct il_priv *il) { int ret; u32 val; /* this bit wakes up the NIC */ - _il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + _il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* * These bits say the device is running, and should keep running for @@ -2279,29 +2255,28 @@ static inline int _il_grab_nic_access(struct il_priv *il) * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). * */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, - (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | - CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); + ret = + _il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, + (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | + CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { val = _il_rd(il, CSR_GP_CNTRL); - IL_ERR( - "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_wr(il, CSR_RESET, - CSR_RESET_REG_FLAG_FORCE_NMI); + IL_ERR("MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } return 0; } -static inline void _il_release_nic_access(struct il_priv *il) +static inline void +_il_release_nic_access(struct il_priv *il) { - _il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -static inline u32 il_rd(struct il_priv *il, u32 reg) +static inline u32 +il_rd(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; @@ -2328,8 +2303,8 @@ il_wr(struct il_priv *il, u32 reg, u32 value) spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline void il_write_reg_buf(struct il_priv *il, - u32 reg, u32 len, u32 *values) +static inline void +il_write_reg_buf(struct il_priv *il, u32 reg, u32 len, u32 * values) { u32 count = sizeof(u32); @@ -2339,8 +2314,8 @@ static inline void il_write_reg_buf(struct il_priv *il, } } -static inline int il_poll_bit(struct il_priv *il, u32 addr, - u32 mask, int timeout) +static inline int +il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) { int t = 0; @@ -2349,19 +2324,22 @@ static inline int il_poll_bit(struct il_priv *il, u32 addr, return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } while (t < timeout); + } + while (t < timeout); return -ETIMEDOUT; } -static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) +static inline u32 +_il_rd_prph(struct il_priv *il, u32 reg) { _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); return _il_rd(il, HBUS_TARG_PRPH_RDAT); } -static inline u32 il_rd_prph(struct il_priv *il, u32 reg) +static inline u32 +il_rd_prph(struct il_priv *il, u32 reg) { unsigned long reg_flags; u32 val; @@ -2374,11 +2352,10 @@ static inline u32 il_rd_prph(struct il_priv *il, u32 reg) return val; } -static inline void _il_wr_prph(struct il_priv *il, - u32 addr, u32 val) +static inline void +_il_wr_prph(struct il_priv *il, u32 addr, u32 val) { - _il_wr(il, HBUS_TARG_PRPH_WADDR, - ((addr & 0x0000FFFF) | (3 << 24))); + _il_wr(il, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); _il_wr(il, HBUS_TARG_PRPH_WDAT, val); } @@ -2415,8 +2392,8 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) _il_wr_prph(il, reg, \ ((_il_rd_prph(il, reg) & mask) | bits)) -static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, - u32 bits, u32 mask) +static inline void +il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask) { unsigned long reg_flags; @@ -2427,8 +2404,8 @@ static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline void il_clear_bits_prph(struct il_priv - *il, u32 reg, u32 mask) +static inline void +il_clear_bits_prph(struct il_priv *il, u32 reg, u32 mask) { unsigned long reg_flags; u32 val; @@ -2441,7 +2418,8 @@ static inline void il_clear_bits_prph(struct il_priv spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) +static inline u32 +il_read_targ_mem(struct il_priv *il, u32 addr) { unsigned long reg_flags; u32 value; @@ -2474,8 +2452,7 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) } static inline void -il_write_targ_mem_buf(struct il_priv *il, u32 addr, - u32 len, u32 *values) +il_write_targ_mem_buf(struct il_priv *il, u32 addr, u32 len, u32 * values) { unsigned long reg_flags; @@ -2484,8 +2461,7 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, _il_wr(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _il_wr(il, - HBUS_TARG_MEM_WDAT, *values); + _il_wr(il, HBUS_TARG_MEM_WDAT, *values); _il_release_nic_access(il); } @@ -2495,43 +2471,31 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, #define HW_KEY_DYNAMIC 0 #define HW_KEY_DEFAULT 1 -#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ -#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ -#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of - being activated */ -#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; - (this is for the IBSS BSSID stations) */ -#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ +#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ +#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ +#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of + being activated */ +#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; + (this is for the IBSS BSSID stations) */ +#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ - -void il_restore_stations(struct il_priv *il, - struct il_rxon_context *ctx); -void il_clear_ucode_stations(struct il_priv *il, - struct il_rxon_context *ctx); +void il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx); +void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx); void il_dealloc_bcast_stations(struct il_priv *il); int il_get_free_ucode_key_idx(struct il_priv *il); -int il_send_add_sta(struct il_priv *il, - struct il_addsta_cmd *sta, u8 flags); -int il_add_station_common(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta, u8 *sta_id_r); -int il_remove_station(struct il_priv *il, - const u8 sta_id, - const u8 *addr); -int il_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta); - -u8 il_prep_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta); - -int il_send_lq_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq, - u8 flags, bool init); +int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); +int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, bool is_ap, + struct ieee80211_sta *sta, u8 * sta_id_r); +int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 * addr); +int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta); + +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, bool is_ap, struct ieee80211_sta *sta); + +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init); /** * il_clear_driver_stations - clear knowledge of all stations from driver @@ -2542,7 +2506,8 @@ int il_send_lq_cmd(struct il_priv *il, * able to reconfigure stations -- if we're getting there in the * normal down flow then the stations will already be cleared. */ -static inline void il_clear_driver_stations(struct il_priv *il) +static inline void +il_clear_driver_stations(struct il_priv *il) { unsigned long flags; struct il_rxon_context *ctx = &il->ctx; @@ -2566,7 +2531,8 @@ static inline void il_clear_driver_stations(struct il_priv *il) spin_unlock_irqrestore(&il->sta_lock, flags); } -static inline int il_sta_id(struct ieee80211_sta *sta) +static inline int +il_sta_id(struct ieee80211_sta *sta) { if (WARN_ON(!sta)) return IL_INVALID_STATION; @@ -2585,9 +2551,9 @@ static inline int il_sta_id(struct ieee80211_sta *sta) * that case, we need to use the broadcast station, so this * inline wraps that pattern. */ -static inline int il_sta_id_or_broadcast(struct il_priv *il, - struct il_rxon_context *context, - struct ieee80211_sta *sta) +static inline int +il_sta_id_or_broadcast(struct il_priv *il, struct il_rxon_context *context, + struct ieee80211_sta *sta) { int sta_id; @@ -2610,7 +2576,8 @@ static inline int il_sta_id_or_broadcast(struct il_priv *il, * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_inc_wrap(int idx, int n_bd) +static inline int +il_queue_inc_wrap(int idx, int n_bd) { return ++idx & (n_bd - 1); } @@ -2620,32 +2587,34 @@ static inline int il_queue_inc_wrap(int idx, int n_bd) * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_dec_wrap(int idx, int n_bd) +static inline int +il_queue_dec_wrap(int idx, int n_bd) { return --idx & (n_bd - 1); } /* TODO: Move fw_desc functions to iwl-pci.ko */ -static inline void il_free_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) +static inline void +il_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (desc->v_addr) - dma_free_coherent(&pci_dev->dev, desc->len, - desc->v_addr, desc->p_addr); + dma_free_coherent(&pci_dev->dev, desc->len, desc->v_addr, + desc->p_addr); desc->v_addr = NULL; desc->len = 0; } -static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) +static inline int +il_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (!desc->len) { desc->v_addr = NULL; return -EINVAL; } - desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len, - &desc->p_addr, GFP_KERNEL); + desc->v_addr = + dma_alloc_coherent(&pci_dev->dev, desc->len, &desc->p_addr, + GFP_KERNEL); return (desc->v_addr != NULL) ? 0 : -ENOMEM; } @@ -2663,14 +2632,14 @@ static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, static inline void il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) { - BUG_ON(ac > 3); /* only have 2 bits */ - BUG_ON(hwq > 31); /* only use 5 bits */ + BUG_ON(ac > 3); /* only have 2 bits */ + BUG_ON(hwq > 31); /* only use 5 bits */ txq->swq_id = (hwq << 2) | ac; } -static inline void il_wake_queue(struct il_priv *il, - struct il_tx_queue *txq) +static inline void +il_wake_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -2681,8 +2650,8 @@ static inline void il_wake_queue(struct il_priv *il, ieee80211_wake_queue(il->hw, ac); } -static inline void il_stop_queue(struct il_priv *il, - struct il_tx_queue *txq) +static inline void +il_stop_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -2705,7 +2674,8 @@ static inline void il_stop_queue(struct il_priv *il, #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue -static inline void il_disable_interrupts(struct il_priv *il) +static inline void +il_disable_interrupts(struct il_priv *il) { clear_bit(S_INT_ENABLED, &il->status); @@ -2718,12 +2688,14 @@ static inline void il_disable_interrupts(struct il_priv *il) _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); } -static inline void il_enable_rfkill_int(struct il_priv *il) +static inline void +il_enable_rfkill_int(struct il_priv *il) { _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } -static inline void il_enable_interrupts(struct il_priv *il) +static inline void +il_enable_interrupts(struct il_priv *il) { set_bit(S_INT_ENABLED, &il->status); _il_wr(il, CSR_INT_MASK, il->inta_mask); @@ -2734,8 +2706,8 @@ static inline void il_enable_interrupts(struct il_priv *il) * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_low(struct il_priv *il, - u16 tsf_bits) +static inline u32 +il_beacon_time_mask_low(struct il_priv *il, u16 tsf_bits) { return (1 << tsf_bits) - 1; } @@ -2745,8 +2717,8 @@ static inline u32 il_beacon_time_mask_low(struct il_priv *il, * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_high(struct il_priv *il, - u16 tsf_bits) +static inline u32 +il_beacon_time_mask_high(struct il_priv *il, u16 tsf_bits) { return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; } @@ -2766,20 +2738,21 @@ struct il_rb_status { __le16 closed_fr_num; __le16 finished_rb_num; __le16 finished_fr_nam; - __le32 __unused; /* 3945 only */ + __le32 __unused; /* 3945 only */ } __packed; - #define TFD_QUEUE_SIZE_MAX (256) #define TFD_QUEUE_SIZE_BC_DUP (64) #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) #define IL_TX_DMA_MASK DMA_BIT_MASK(36) #define IL_NUM_OF_TBS 20 -static inline u8 il_get_dma_hi_addr(dma_addr_t addr) +static inline u8 +il_get_dma_hi_addr(dma_addr_t addr) { return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; } + /** * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor * @@ -2837,16 +2810,16 @@ struct il_tfd { #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 struct il_rate_info { - u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ - u8 prev_ieee; /* previous rate in IEEE speeds */ - u8 next_ieee; /* next rate in IEEE speeds */ - u8 prev_rs; /* previous rate used in rs algo */ - u8 next_rs; /* next rate used in rs algo */ - u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ - u8 next_rs_tgg; /* next rate used in TGG rs algo */ + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ + u8 prev_ieee; /* previous rate in IEEE speeds */ + u8 next_ieee; /* next rate in IEEE speeds */ + u8 prev_rs; /* previous rate used in rs algo */ + u8 next_rs; /* next rate used in rs algo */ + u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ + u8 next_rs_tgg; /* next rate used in TGG rs algo */ }; struct il3945_rate_info { @@ -2862,7 +2835,6 @@ struct il3945_rate_info { u8 prev_table_rs; /* prev in rate table cmd */ }; - /* * These serve as idxes into * struct il_rate_info il_rates[RATE_COUNT]; @@ -2929,20 +2901,20 @@ enum { /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { - RATE_6M_PLCP = 13, - RATE_9M_PLCP = 15, + RATE_6M_PLCP = 13, + RATE_9M_PLCP = 15, RATE_12M_PLCP = 5, RATE_18M_PLCP = 7, RATE_24M_PLCP = 9, RATE_36M_PLCP = 11, RATE_48M_PLCP = 1, RATE_54M_PLCP = 3, - RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - RATE_1M_PLCP = 10, - RATE_2M_PLCP = 20, - RATE_5M_PLCP = 55, + RATE_60M_PLCP = 3, /*FIXME:RS:should be removed */ + RATE_1M_PLCP = 10, + RATE_2M_PLCP = 20, + RATE_5M_PLCP = 55, RATE_11M_PLCP = 110, - /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ + /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0, */ }; /* uCode API values for OFDM high-throughput (HT) bit rates */ @@ -2955,7 +2927,7 @@ enum { RATE_SISO_48M_PLCP = 5, RATE_SISO_54M_PLCP = 6, RATE_SISO_60M_PLCP = 7, - RATE_MIMO2_6M_PLCP = 0x8, + RATE_MIMO2_6M_PLCP = 0x8, RATE_MIMO2_12M_PLCP = 0x9, RATE_MIMO2_18M_PLCP = 0xa, RATE_MIMO2_24M_PLCP = 0xb, @@ -2969,8 +2941,8 @@ enum { /* MAC header values for bit rates */ enum { - RATE_6M_IEEE = 12, - RATE_9M_IEEE = 18, + RATE_6M_IEEE = 12, + RATE_9M_IEEE = 18, RATE_12M_IEEE = 24, RATE_18M_IEEE = 36, RATE_24M_IEEE = 48, @@ -2978,9 +2950,9 @@ enum { RATE_48M_IEEE = 96, RATE_54M_IEEE = 108, RATE_60M_IEEE = 120, - RATE_1M_IEEE = 2, - RATE_2M_IEEE = 4, - RATE_5M_IEEE = 11, + RATE_1M_IEEE = 2, + RATE_2M_IEEE = 4, + RATE_5M_IEEE = 11, RATE_11M_IEEE = 22, }; @@ -3081,9 +3053,9 @@ extern const struct il_rate_info il_rates[RATE_COUNT]; enum il_table_type { LQ_NONE, - LQ_G, /* legacy types */ + LQ_G, /* legacy types */ LQ_A, - LQ_SISO, /* high-throughput types */ + LQ_SISO, /* high-throughput types */ LQ_MIMO2, LQ_MAX, }; @@ -3108,8 +3080,8 @@ enum il_table_type { #define IL_MAX_MCS_DISPLAY_SIZE 12 struct il_rate_mcs_info { - char mbps[IL_MAX_MCS_DISPLAY_SIZE]; - char mcs[IL_MAX_MCS_DISPLAY_SIZE]; + char mbps[IL_MAX_MCS_DISPLAY_SIZE]; + char mcs[IL_MAX_MCS_DISPLAY_SIZE]; }; /** @@ -3133,25 +3105,25 @@ struct il_rate_scale_data { struct il_scale_tbl_info { enum il_table_type lq_type; u8 ant_type; - u8 is_SGI; /* 1 = short guard interval */ - u8 is_ht40; /* 1 = 40 MHz channel width */ - u8 is_dup; /* 1 = duplicated data streams */ - u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ - u8 max_search; /* maximun number of tables we can search */ + u8 is_SGI; /* 1 = short guard interval */ + u8 is_ht40; /* 1 = 40 MHz channel width */ + u8 is_dup; /* 1 = duplicated data streams */ + u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ + u8 max_search; /* maximun number of tables we can search */ s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ - u32 current_rate; /* rate_n_flags, uCode API format */ - struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ + u32 current_rate; /* rate_n_flags, uCode API format */ + struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ }; struct il_traffic_load { unsigned long time_stamp; /* age of the oldest stats */ - u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time + u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time * slice */ - u32 total; /* total num of packets during the - * last TID_MAX_TIME_DIFF */ - u8 queue_count; /* number of queues that has - * been used since the last cleanup */ - u8 head; /* start of the circular buffer */ + u32 total; /* total num of packets during the + * last TID_MAX_TIME_DIFF */ + u8 queue_count; /* number of queues that has + * been used since the last cleanup */ + u8 head; /* start of the circular buffer */ }; /** @@ -3185,11 +3157,11 @@ struct il_lq_sta { u16 active_legacy_rate; u16 active_siso_rate; u16 active_mimo2_rate; - s8 max_rate_idx; /* Max rate set by user */ + s8 max_rate_idx; /* Max rate set by user */ u8 missed_rate_counter; struct il_link_quality_cmd lq; - struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ + struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ struct il_traffic_load load[TID_MAX_LOAD_COUNT]; u8 tx_agg_tid_en; #ifdef CONFIG_MAC80211_DEBUGFS @@ -3227,12 +3199,14 @@ struct il_station_priv { bool asleep; }; -static inline u8 il4965_num_of_ant(u8 m) +static inline u8 +il4965_num_of_ant(u8 m) { return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); } -static inline u8 il4965_first_antenna(u8 mask) +static inline u8 +il4965_first_antenna(u8 mask) { if (mask & ANT_A) return ANT_A; @@ -3241,7 +3215,6 @@ static inline u8 il4965_first_antenna(u8 mask) return ANT_C; } - /** * il3945_rate_scale_init - Initialize the rate scale table based on assoc info * @@ -3251,10 +3224,10 @@ static inline u8 il4965_first_antenna(u8 mask) extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); /* Initialize station's rate scaling information after adding station */ -extern void il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); -extern void il3945_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); +extern void il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, + u8 sta_id); +extern void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, + u8 sta_id); /** * il_rate_control_register - Register the rate control algorithm callbacks @@ -3291,7 +3264,8 @@ extern u32 il_debug_level; * level will be used if set, otherwise the global debug level which can be * set via module parameter is used. */ -static inline u32 il_get_debug_level(struct il_priv *il) +static inline u32 +il_get_debug_level(struct il_priv *il) { if (il->debug_level) return il->debug_level; @@ -3299,7 +3273,8 @@ static inline u32 il_get_debug_level(struct il_priv *il) return il_debug_level; } #else -static inline u32 il_get_debug_level(struct il_priv *il) +static inline u32 +il_get_debug_level(struct il_priv *il) { return il_debug_level; } @@ -3329,10 +3304,11 @@ do { \ #else #define IL_DBG(level, fmt, args...) -static inline void il_print_hex_dump(struct il_priv *il, int level, - const void *p, u32 len) -{} -#endif /* CONFIG_IWLEGACY_DEBUG */ +static inline void +il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) +{ +} +#endif /* CONFIG_IWLEGACY_DEBUG */ #ifdef CONFIG_IWLEGACY_DEBUGFS int il_dbgfs_register(struct il_priv *il, const char *name); @@ -3343,10 +3319,12 @@ il_dbgfs_register(struct il_priv *il, const char *name) { return 0; } -static inline void il_dbgfs_unregister(struct il_priv *il) + +static inline void +il_dbgfs_unregister(struct il_priv *il) { } -#endif /* CONFIG_IWLEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ /* * To use the debug system: diff --git a/drivers/net/wireless/iwlegacy/csr.h b/drivers/net/wireless/iwlegacy/csr.h index 4db0429..9138e15 100644 --- a/drivers/net/wireless/iwlegacy/csr.h +++ b/drivers/net/wireless/iwlegacy/csr.h @@ -82,13 +82,13 @@ */ #define CSR_BASE (0x000) -#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ -#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ -#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ -#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ -#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/ -#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ -#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ +#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ +#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ +#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ +#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ +#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack */ +#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ +#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc */ #define CSR_GP_CNTRL (CSR_BASE+0x024) /* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ @@ -166,26 +166,26 @@ #define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A (0x00080000) #define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000) -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ -#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ +#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ -#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int*/ -#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec*/ +#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int */ +#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec */ /* interrupt flags in INTA, set by uCode or hardware (e.g. dma), * acknowledged (reset) by host writing "1" to flagged bits. */ -#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ -#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ -#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ -#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ -#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ -#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ -#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ -#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ -#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ -#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ -#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ +#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ +#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ +#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ +#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ +#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ +#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ +#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ +#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ +#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ +#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ +#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ #define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \ CSR_INT_BIT_HW_ERR | \ @@ -197,21 +197,20 @@ CSR_INT_BIT_ALIVE) /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */ -#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ -#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ -#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ -#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ -#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ -#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ -#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ -#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ +#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ +#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ +#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ +#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ +#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ +#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ +#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ +#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ #define CSR39_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ CSR39_FH_INT_BIT_RX_CHNL2 | \ CSR_FH_INT_BIT_RX_CHNL1 | \ CSR_FH_INT_BIT_RX_CHNL0) - #define CSR39_FH_INT_TX_MASK (CSR39_FH_INT_BIT_TX_CHNL6 | \ CSR_FH_INT_BIT_TX_CHNL1 | \ CSR_FH_INT_BIT_TX_CHNL0) @@ -285,7 +284,6 @@ #define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000) #define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000) - /* EEPROM REG */ #define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001) #define CSR_EEPROM_REG_BIT_CMD (0x00000002) @@ -293,19 +291,18 @@ #define CSR_EEPROM_REG_MSK_DATA (0xFFFF0000) /* EEPROM GP */ -#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ +#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ #define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) #define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K (0x00000002) #define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K (0x00000004) /* GP REG */ -#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ +#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ #define CSR_GP_REG_NO_POWER_SAVE (0x00000000) #define CSR_GP_REG_MAC_POWER_SAVE (0x01000000) #define CSR_GP_REG_PHY_POWER_SAVE (0x02000000) #define CSR_GP_REG_POWER_SAVE_ERROR (0x03000000) - /* CSR GIO */ #define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002) diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 4e2b6c8..e79794a 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -64,7 +64,6 @@ static ssize_t il_dbgfs_##name##_write(struct file *file, \ const char __user *user_buf, \ size_t count, loff_t *ppos); - static int il_dbgfs_open_file_generic(struct inode *inode, struct file *file) { @@ -98,9 +97,10 @@ static const struct file_operations il_dbgfs_##name##_ops = { \ .llseek = generic_file_llseek, \ }; -static ssize_t il_dbgfs_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_tx_stats_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; char *buf; @@ -108,30 +108,30 @@ static ssize_t il_dbgfs_tx_stats_read(struct file *file, int cnt; ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + const size_t bufsz = + 100 + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->tx_stats.mgmt[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), il->tx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->tx_stats.ctrl[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), il->tx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->tx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->tx_stats.data_bytes); + pos += + scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->tx_stats.data_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->tx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; @@ -139,8 +139,8 @@ static ssize_t il_dbgfs_tx_stats_read(struct file *file, static ssize_t il_dbgfs_clear_traffic_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) + const char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; u32 clear_flag; @@ -148,7 +148,7 @@ il_dbgfs_clear_traffic_stats_write(struct file *file, int buf_size; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%x", &clear_flag) != 1) @@ -158,40 +158,41 @@ il_dbgfs_clear_traffic_stats_write(struct file *file, return count; } -static ssize_t il_dbgfs_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rx_stats_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; char *buf; int pos = 0; int cnt; ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + const size_t bufsz = + 100 + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->rx_stats.mgmt[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), il->rx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->rx_stats.ctrl[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), il->rx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->rx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->rx_stats.data_bytes); + pos += + scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->rx_stats.data_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->rx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -201,9 +202,9 @@ static ssize_t il_dbgfs_rx_stats_read(struct file *file, #define BYTE1_MASK 0x000000ff; #define BYTE2_MASK 0x0000ffff; #define BYTE3_MASK 0x00ffffff; -static ssize_t il_dbgfs_sram_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_sram_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { u32 val; char *buf; @@ -221,17 +222,21 @@ static ssize_t il_dbgfs_sram_read(struct file *file, else il->dbgfs_sram_len = il->ucode_data.len; } - bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; + bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; buf = kmalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", - il->dbgfs_sram_len); - pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", - il->dbgfs_sram_offset); + pos += + scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", + il->dbgfs_sram_len); + pos += + scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", + il->dbgfs_sram_offset); for (i = il->dbgfs_sram_len; i > 0; i -= 4) { - val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ - il->dbgfs_sram_len - i); + val = + il_read_targ_mem(il, + il->dbgfs_sram_offset + + il->dbgfs_sram_len - i); if (i < 4) { switch (i) { case 1: @@ -256,9 +261,9 @@ static ssize_t il_dbgfs_sram_read(struct file *file, return ret; } -static ssize_t il_dbgfs_sram_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_sram_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[64]; @@ -266,7 +271,7 @@ static ssize_t il_dbgfs_sram_write(struct file *file, u32 offset, len; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; @@ -282,8 +287,8 @@ static ssize_t il_dbgfs_sram_write(struct file *file, } static ssize_t -il_dbgfs_stations_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il_dbgfs_stations_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; struct il_station_entry *station; @@ -298,36 +303,42 @@ il_dbgfs_stations_read(struct file *file, char __user *user_buf, if (!buf) return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", - il->num_stations); + pos += + scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", + il->num_stations); for (i = 0; i < max_sta; i++) { station = &il->stations[i]; if (!station->used) continue; - pos += scnprintf(buf + pos, bufsz - pos, - "station %d - addr: %pM, flags: %#x\n", - i, station->sta.sta.addr, - station->sta.station_flags_msk); - pos += scnprintf(buf + pos, bufsz - pos, - "TID\tseq_num\ttxq_id\tframes\ttfds\t"); - pos += scnprintf(buf + pos, bufsz - pos, - "start_idx\tbitmap\t\t\trate_n_flags\n"); + pos += + scnprintf(buf + pos, bufsz - pos, + "station %d - addr: %pM, flags: %#x\n", i, + station->sta.sta.addr, + station->sta.station_flags_msk); + pos += + scnprintf(buf + pos, bufsz - pos, + "TID\tseq_num\ttxq_id\tframes\ttfds\t"); + pos += + scnprintf(buf + pos, bufsz - pos, + "start_idx\tbitmap\t\t\trate_n_flags\n"); for (j = 0; j < MAX_TID_COUNT; j++) { - pos += scnprintf(buf + pos, bufsz - pos, - "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", - j, station->tid[j].seq_number, - station->tid[j].agg.txq_id, - station->tid[j].agg.frame_count, - station->tid[j].tfds_in_queue, - station->tid[j].agg.start_idx, - station->tid[j].agg.bitmap, - station->tid[j].agg.rate_n_flags); + pos += + scnprintf(buf + pos, bufsz - pos, + "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", + j, station->tid[j].seq_number, + station->tid[j].agg.txq_id, + station->tid[j].agg.frame_count, + station->tid[j].tfds_in_queue, + station->tid[j].agg.start_idx, + station->tid[j].agg.bitmap, + station->tid[j].agg.rate_n_flags); if (station->tid[j].agg.wait_for_ba) - pos += scnprintf(buf + pos, bufsz - pos, - " - waitforba"); + pos += + scnprintf(buf + pos, bufsz - pos, + " - waitforba"); pos += scnprintf(buf + pos, bufsz - pos, "\n"); } @@ -339,10 +350,9 @@ il_dbgfs_stations_read(struct file *file, char __user *user_buf, return ret; } -static ssize_t il_dbgfs_nvm_read(struct file *file, - char __user *user_buf, - size_t count, - loff_t *ppos) +static ssize_t +il_dbgfs_nvm_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { ssize_t ret; struct il_priv *il = file->private_data; @@ -371,11 +381,12 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, return -ENOMEM; } eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " - "version: 0x%x\n", eeprom_ver); - for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { + pos += + scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n", + eeprom_ver); + for (ofs = 0; ofs < eeprom_len; ofs += 16) { pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, + hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos, buf_size - pos, 0); pos += strlen(buf + pos); if (buf_size - pos > 0) @@ -388,8 +399,8 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, } static ssize_t -il_dbgfs_channels_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il_dbgfs_channels_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; struct ieee80211_channel *channels = NULL; @@ -411,106 +422,132 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, if (supp_band) { channels = supp_band->channels; - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 2.4GHz band 802.11bg):\n", - supp_band->n_channels); + pos += + scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 2.4GHz band 802.11bg):\n", + supp_band->n_channels); for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); + pos += + scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i]. + flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i]. + flags & IEEE80211_CHAN_NO_IBSS) || + (channels[i]. + flags & IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i]. + flags & IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); } supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); if (supp_band) { channels = supp_band->channels; - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 5.2GHz band (802.11a)\n", - supp_band->n_channels); + pos += + scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 5.2GHz band (802.11a)\n", + supp_band->n_channels); for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); + pos += + scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i]. + flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i]. + flags & IEEE80211_CHAN_NO_IBSS) || + (channels[i]. + flags & IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i]. + flags & IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); } ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_status_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; char buf[512]; int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", - test_bit(S_HCMD_ACTIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", - test_bit(S_INT_ENABLED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", - test_bit(S_RF_KILL_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", - test_bit(S_CT_KILL, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", - test_bit(S_INIT, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", - test_bit(S_ALIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", - test_bit(S_READY, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", - test_bit(S_TEMPERATURE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", - test_bit(S_GEO_CONFIGURED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", - test_bit(S_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", - test_bit(S_STATS, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", - test_bit(S_SCANNING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", - test_bit(S_SCAN_ABORTING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", - test_bit(S_SCAN_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", - test_bit(S_POWER_PMI, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", - test_bit(S_FW_ERROR, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", + test_bit(S_HCMD_ACTIVE, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", + test_bit(S_INT_ENABLED, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", + test_bit(S_RF_KILL_HW, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", + test_bit(S_CT_KILL, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", + test_bit(S_INIT, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", + test_bit(S_ALIVE, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", + test_bit(S_READY, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", + test_bit(S_TEMPERATURE, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", + test_bit(S_GEO_CONFIGURED, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", + test_bit(S_EXIT_PENDING, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", + test_bit(S_STATS, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", + test_bit(S_SCANNING, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", + test_bit(S_SCAN_ABORTING, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", + test_bit(S_SCAN_HW, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", + test_bit(S_POWER_PMI, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", + test_bit(S_FW_ERROR, &il->status)); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_interrupt_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_interrupt_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; - int bufsz = 24 * 64; /* 24 items * 64 char per item */ + int bufsz = 24 * 64; /* 24 items * 64 char per item */ ssize_t ret; buf = kzalloc(bufsz, GFP_KERNEL); @@ -519,59 +556,70 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, return -ENOMEM; } - pos += scnprintf(buf + pos, bufsz - pos, - "Interrupt Statistics Report:\n"); + pos += + scnprintf(buf + pos, bufsz - pos, "Interrupt Statistics Report:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", - il->isr_stats.hw); - pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", - il->isr_stats.sw); + pos += + scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", + il->isr_stats.hw); + pos += + scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", + il->isr_stats.sw); if (il->isr_stats.sw || il->isr_stats.hw) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tLast Restarting Code: 0x%X\n", - il->isr_stats.err_code); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tLast Restarting Code: 0x%X\n", + il->isr_stats.err_code); } #ifdef CONFIG_IWLEGACY_DEBUG - pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", - il->isr_stats.sch); - pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", - il->isr_stats.alive); + pos += + scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", + il->isr_stats.sch); + pos += + scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", + il->isr_stats.alive); #endif - pos += scnprintf(buf + pos, bufsz - pos, - "HW RF KILL switch toggled:\t %u\n", - il->isr_stats.rfkill); - - pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", - il->isr_stats.ctkill); - - pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", - il->isr_stats.wakeup); - - pos += scnprintf(buf + pos, bufsz - pos, - "Rx command responses:\t\t %u\n", - il->isr_stats.rx); + pos += + scnprintf(buf + pos, bufsz - pos, + "HW RF KILL switch toggled:\t %u\n", + il->isr_stats.rfkill); + + pos += + scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", + il->isr_stats.ctkill); + + pos += + scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", + il->isr_stats.wakeup); + + pos += + scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n", + il->isr_stats.rx); for (cnt = 0; cnt < IL_CN_MAX; cnt++) { if (il->isr_stats.handlers[cnt] > 0) - pos += scnprintf(buf + pos, bufsz - pos, - "\tRx handler[%36s]:\t\t %u\n", - il_get_cmd_string(cnt), - il->isr_stats.handlers[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tRx handler[%36s]:\t\t %u\n", + il_get_cmd_string(cnt), + il->isr_stats.handlers[cnt]); } - pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", - il->isr_stats.tx); + pos += + scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", + il->isr_stats.tx); - pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", - il->isr_stats.unhandled); + pos += + scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", + il->isr_stats.unhandled); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_interrupt_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_interrupt_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -579,7 +627,7 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, u32 reset_flag; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%x", &reset_flag) != 1) @@ -591,8 +639,8 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, } static ssize_t -il_dbgfs_qos_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il_dbgfs_qos_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; struct il_rxon_context *ctx = &il->ctx; @@ -600,25 +648,26 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, char buf[256]; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", - ctx->ctxid); + pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", ctx->ctxid); for (i = 0; i < AC_NUM; i++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tcw_min\tcw_max\taifsn\ttxop\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "AC[%d]\t%u\t%u\t%u\t%u\n", i, - ctx->qos_data.def_qos_parm.ac[i].cw_min, - ctx->qos_data.def_qos_parm.ac[i].cw_max, - ctx->qos_data.def_qos_parm.ac[i].aifsn, - ctx->qos_data.def_qos_parm.ac[i].edca_txop); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tcw_min\tcw_max\taifsn\ttxop\n"); + pos += + scnprintf(buf + pos, bufsz - pos, + "AC[%d]\t%u\t%u\t%u\t%u\n", i, + ctx->qos_data.def_qos_parm.ac[i].cw_min, + ctx->qos_data.def_qos_parm.ac[i].cw_max, + ctx->qos_data.def_qos_parm.ac[i].aifsn, + ctx->qos_data.def_qos_parm.ac[i].edca_txop); } return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_disable_ht40_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_disable_ht40_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -626,7 +675,7 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, int ht40; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &ht40) != 1) @@ -635,25 +684,25 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, il->disable_ht40 = ht40 ? true : false; else { IL_ERR("Sta associated with AP - " - "Change to 40MHz channel support is not allowed\n"); + "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } return count; } -static ssize_t il_dbgfs_disable_ht40_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_disable_ht40_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[100]; int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, - "11n 40MHz Mode: %s\n", - il->disable_ht40 ? "Disabled" : "Enabled"); + pos += + scnprintf(buf + pos, bufsz - pos, "11n 40MHz Mode: %s\n", + il->disable_ht40 ? "Disabled" : "Enabled"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -666,9 +715,9 @@ DEBUGFS_READ_WRITE_FILE_OPS(interrupt); DEBUGFS_READ_FILE_OPS(qos); DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); -static ssize_t il_dbgfs_traffic_log_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_traffic_log_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0, ofs = 0; @@ -677,8 +726,9 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, struct il_queue *q; struct il_rx_queue *rxq = &il->rxq; char *buf; - int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (il->cfg->base_params->num_of_queues * 32 * 8) + 400; + int bufsz = + ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + + (il->cfg->base_params->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; @@ -695,19 +745,22 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { txq = &il->txq[cnt]; q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "q[%d]: read_ptr: %u, write_ptr: %u\n", - cnt, q->read_ptr, q->write_ptr); + pos += + scnprintf(buf + pos, bufsz - pos, + "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, + q->read_ptr, q->write_ptr); } if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { ptr = il->tx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Tx Traffic idx: %u\n", il->tx_traffic_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", + il->tx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); + entry++, ofs += 16) { + pos += + scnprintf(buf + pos, bufsz - pos, "0x%.4x ", + ofs); hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos, bufsz - pos, 0); pos += strlen(buf + pos); @@ -718,19 +771,21 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, } pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "read: %u, write: %u\n", - rxq->read, rxq->write); + pos += + scnprintf(buf + pos, bufsz - pos, "read: %u, write: %u\n", + rxq->read, rxq->write); if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { ptr = il->rx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Rx Traffic idx: %u\n", il->rx_traffic_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", + il->rx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); + entry++, ofs += 16) { + pos += + scnprintf(buf + pos, bufsz - pos, "0x%.4x ", + ofs); hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos, bufsz - pos, 0); pos += strlen(buf + pos); @@ -745,9 +800,9 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, return ret; } -static ssize_t il_dbgfs_traffic_log_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_traffic_log_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -755,7 +810,7 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, int traffic_log; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &traffic_log) != 1) @@ -766,9 +821,10 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, return count; } -static ssize_t il_dbgfs_tx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; struct il_tx_queue *txq; @@ -777,8 +833,8 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, int pos = 0; int cnt; int ret; - const size_t bufsz = sizeof(char) * 64 * - il->cfg->base_params->num_of_queues; + const size_t bufsz = + sizeof(char) * 64 * il->cfg->base_params->num_of_queues; if (!il->txq) { IL_ERR("txq not ready\n"); @@ -791,28 +847,32 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { txq = &il->txq[cnt]; q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "hwq %.2d: read=%u write=%u stop=%d" - " swq_id=%#.2x (ac %d/hwq %d)\n", - cnt, q->read_ptr, q->write_ptr, - !!test_bit(cnt, il->queue_stopped), - txq->swq_id, txq->swq_id & 3, - (txq->swq_id >> 2) & 0x1f); + pos += + scnprintf(buf + pos, bufsz - pos, + "hwq %.2d: read=%u write=%u stop=%d" + " swq_id=%#.2x (ac %d/hwq %d)\n", cnt, + q->read_ptr, q->write_ptr, !!test_bit(cnt, + il-> + queue_stopped), + txq->swq_id, txq->swq_id & 3, + (txq->swq_id >> 2) & 0x1f); if (cnt >= 4) continue; /* for the ACs, display the stop count too */ - pos += scnprintf(buf + pos, bufsz - pos, - " stop-count: %d\n", - atomic_read(&il->queue_stop_count[cnt])); + pos += + scnprintf(buf + pos, bufsz - pos, + " stop-count: %d\n", + atomic_read(&il->queue_stop_count[cnt])); } ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_rx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rx_queue_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; struct il_rx_queue *rxq = &il->rxq; @@ -820,52 +880,55 @@ static ssize_t il_dbgfs_rx_queue_read(struct file *file, int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", - rxq->read); - pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", - rxq->write); - pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", - rxq->free_count); + pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", rxq->read); + pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", rxq->write); + pos += + scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", + rxq->free_count); if (rxq->rb_stts) { - pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", - le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); + pos += + scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", + le16_to_cpu(rxq->rb_stts-> + closed_rb_num) & 0x0FFF); } else { - pos += scnprintf(buf + pos, bufsz - pos, - "closed_rb_num: Not Allocated\n"); + pos += + scnprintf(buf + pos, bufsz - pos, + "closed_rb_num: Not Allocated\n"); } return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, - user_buf, count, ppos); + return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, + count, ppos); } -static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, - user_buf, count, ppos); + return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, + count, ppos); } -static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_ucode_general_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, - user_buf, count, ppos); + return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, + count, ppos); } -static ssize_t il_dbgfs_sensitivity_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_sensitivity_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; @@ -882,71 +945,89 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, return -ENOMEM; } - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", - data->auto_corr_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc:\t\t %u\n", - data->auto_corr_ofdm_mrc); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", - data->auto_corr_ofdm_x1); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc_x1:\t\t %u\n", - data->auto_corr_ofdm_mrc_x1); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", - data->auto_corr_cck); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", - data->auto_corr_cck_mrc); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_ofdm:\t\t %u\n", - data->last_bad_plcp_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", - data->last_fa_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_cck:\t\t %u\n", - data->last_bad_plcp_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", - data->last_fa_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", - data->nrg_curr_state); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", - data->nrg_prev_state); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", + data->auto_corr_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_mrc:\t\t %u\n", + data->auto_corr_ofdm_mrc); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", + data->auto_corr_ofdm_x1); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_mrc_x1:\t\t %u\n", + data->auto_corr_ofdm_mrc_x1); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", + data->auto_corr_cck); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", + data->auto_corr_cck_mrc); + pos += + scnprintf(buf + pos, bufsz - pos, + "last_bad_plcp_cnt_ofdm:\t\t %u\n", + data->last_bad_plcp_cnt_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", + data->last_fa_cnt_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "last_bad_plcp_cnt_cck:\t\t %u\n", + data->last_bad_plcp_cnt_cck); + pos += + scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", + data->last_fa_cnt_cck); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", + data->nrg_curr_state); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", + data->nrg_prev_state); pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); for (cnt = 0; cnt < 10; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_value[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_value[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_silence_rssi[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_silence_rssi[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", - data->nrg_silence_ref); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", - data->nrg_energy_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", - data->nrg_silence_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", - data->nrg_th_cck); - pos += scnprintf(buf + pos, bufsz - pos, - "nrg_auto_corr_silence_diff:\t %u\n", - data->nrg_auto_corr_silence_diff); - pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", - data->num_in_cck_no_fa); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", - data->nrg_th_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", + data->nrg_silence_ref); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", + data->nrg_energy_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", + data->nrg_silence_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", + data->nrg_th_cck); + pos += + scnprintf(buf + pos, bufsz - pos, + "nrg_auto_corr_silence_diff:\t %u\n", + data->nrg_auto_corr_silence_diff); + pos += + scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", + data->num_in_cck_no_fa); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", + data->nrg_th_ofdm); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } - -static ssize_t il_dbgfs_chain_noise_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_chain_noise_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; @@ -963,48 +1044,60 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, return -ENOMEM; } - pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", - data->active_chains); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", - data->chain_noise_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", - data->chain_noise_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", - data->chain_noise_c); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", - data->chain_signal_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", - data->chain_signal_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", - data->chain_signal_c); - pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", - data->beacon_count); + pos += + scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", + data->active_chains); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", + data->chain_noise_a); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", + data->chain_noise_b); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", + data->chain_noise_c); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", + data->chain_signal_a); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", + data->chain_signal_b); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", + data->chain_signal_c); + pos += + scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", + data->beacon_count); pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->disconn_array[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->disconn_array[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->delta_gain_code[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->delta_gain_code[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", - data->radio_write); - pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", - data->state); + pos += + scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", + data->radio_write); + pos += + scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", + data->state); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_power_save_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_power_save_status_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[60]; @@ -1012,22 +1105,25 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & - CSR_GP_REG_POWER_SAVE_STATUS_MSK; + pwrsave_status = + _il_rd(il, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); - pos += scnprintf(buf + pos, bufsz - pos, "%s\n", - (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : - (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : - (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : - "error"); + pos += + scnprintf(buf + pos, bufsz - pos, "%s\n", + (pwrsave_status == + CSR_GP_REG_NO_POWER_SAVE) ? "none" : (pwrsave_status == + CSR_GP_REG_MAC_POWER_SAVE) + ? "MAC" : (pwrsave_status == + CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : "error"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_clear_ucode_stats_write(struct file *file, + const char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1035,7 +1131,7 @@ static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, int clear; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &clear) != 1) @@ -1049,35 +1145,36 @@ static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, return count; } -static ssize_t il_dbgfs_rxon_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rxon_flags_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int len = 0; char buf[20]; - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.flags)); + len = sprintf(buf, "0x%04X\n", le32_to_cpu(il->ctx.active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rxon_filter_flags_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int len = 0; char buf[20]; - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.filter_flags)); + len = + sprintf(buf, "0x%04X\n", le32_to_cpu(il->ctx.active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t il_dbgfs_fh_reg_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_fh_reg_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; char *buf; @@ -1087,8 +1184,9 @@ static ssize_t il_dbgfs_fh_reg_read(struct file *file, if (il->cfg->ops->lib->dump_fh) { ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); if (buf) { - ret = simple_read_from_buffer(user_buf, - count, ppos, buf, pos); + ret = + simple_read_from_buffer(user_buf, count, ppos, buf, + pos); kfree(buf); } } @@ -1096,24 +1194,26 @@ static ssize_t il_dbgfs_fh_reg_read(struct file *file, return ret; } -static ssize_t il_dbgfs_missed_beacon_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_missed_beacon_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; char buf[12]; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "%d\n", - il->missed_beacon_threshold); + pos += + scnprintf(buf + pos, bufsz - pos, "%d\n", + il->missed_beacon_threshold); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_missed_beacon_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_missed_beacon_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1121,7 +1221,7 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, int missed; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &missed) != 1) @@ -1129,17 +1229,17 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || missed > IL_MISSED_BEACON_THRESHOLD_MAX) - il->missed_beacon_threshold = - IL_MISSED_BEACON_THRESHOLD_DEF; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; else il->missed_beacon_threshold = missed; return count; } -static ssize_t il_dbgfs_force_reset_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_force_reset_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; @@ -1149,25 +1249,28 @@ static ssize_t il_dbgfs_force_reset_read(struct file *file, force_reset = &il->force_reset; - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request: %d\n", - force_reset->reset_request_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request success: %d\n", - force_reset->reset_success_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request reject: %d\n", - force_reset->reset_reject_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\treset duration: %lu\n", - force_reset->reset_duration); + pos += + scnprintf(buf + pos, bufsz - pos, "\tnumber of reset request: %d\n", + force_reset->reset_request_count); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request success: %d\n", + force_reset->reset_success_count); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request reject: %d\n", + force_reset->reset_reject_count); + pos += + scnprintf(buf + pos, bufsz - pos, "\treset duration: %lu\n", + force_reset->reset_duration); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_force_reset_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_force_reset_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) +{ int ret; struct il_priv *il = file->private_data; @@ -1177,9 +1280,10 @@ static ssize_t il_dbgfs_force_reset_write(struct file *file, return ret ? ret : count; } -static ssize_t il_dbgfs_wd_timeout_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_wd_timeout_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; char buf[8]; @@ -1187,7 +1291,7 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, int timeout; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &timeout) != 1) @@ -1224,7 +1328,8 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout); * Create the debugfs files and directories * */ -int il_dbgfs_register(struct il_priv *il, const char *name) +int +il_dbgfs_register(struct il_priv *il, const char *name) { struct dentry *phyd = il->hw->wiphy->debugfsdir; struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; @@ -1281,8 +1386,7 @@ int il_dbgfs_register(struct il_priv *il, const char *name) if (il->cfg->base_params->chain_noise_calib_by_driver) DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, &il->disable_chain_noise_cal); - DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, - &il->disable_tx_power_cal); + DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, &il->disable_tx_power_cal); return 0; err: @@ -1290,13 +1394,15 @@ err: il_dbgfs_unregister(il); return -ENOMEM; } + EXPORT_SYMBOL(il_dbgfs_register); /** * Remove the debugfs files and directories * */ -void il_dbgfs_unregister(struct il_priv *il) +void +il_dbgfs_unregister(struct il_priv *il) { if (!il->debugfs_dir) return; @@ -1304,4 +1410,5 @@ void il_dbgfs_unregister(struct il_priv *il) debugfs_remove_recursive(il->debugfs_dir); il->debugfs_dir = NULL; } + EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/prph.h b/drivers/net/wireless/iwlegacy/prph.h index 029ea8a..ffec4b4 100644 --- a/drivers/net/wireless/iwlegacy/prph.h +++ b/drivers/net/wireless/iwlegacy/prph.h @@ -91,9 +91,9 @@ #define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000) #define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000) #define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) -#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ +#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ #define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) -#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ +#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ #define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) #define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) @@ -202,19 +202,19 @@ */ /* BSM bit fields */ -#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ -#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup*/ -#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ +#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ +#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup */ +#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ /* BSM addresses */ #define BSM_BASE (PRPH_BASE + 0x3400) #define BSM_END (PRPH_BASE + 0x3800) -#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ -#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ -#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ -#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ -#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ +#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ +#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ +#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ +#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ +#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ /* * Pointers and size regs for bootstrap load and data SRAM save/restore. @@ -231,8 +231,7 @@ * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1) */ #define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800) -#define BSM_SRAM_SIZE (1024) /* bytes */ - +#define BSM_SRAM_SIZE (1024) /* bytes */ /* 3945 Tx scheduler registers */ #define ALM_SCD_BASE (PRPH_BASE + 0x2E00) @@ -520,4 +519,4 @@ /*********************** END TX SCHEDULER *************************************/ -#endif /* __il_prph_h__ */ +#endif /* __il_prph_h__ */ -- cgit v0.10.2 From 1722f8e12a9c6117d872bd19ec5919460ccdfb4e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:51:01 +0100 Subject: iwlegacy: checkpatch.pl fixes Fix most checkpatch.pl ERRORs and some WARNINGs. Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 382af2e..5e1a19f 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -49,8 +49,8 @@ il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) } ssize_t -il3945_ucode_rx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -314,8 +314,8 @@ il3945_ucode_rx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il3945_ucode_tx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -404,8 +404,8 @@ il3945_ucode_tx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il3945_ucode_general_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 2249fe4..daef6b5 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -1033,11 +1033,9 @@ il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) - IL_ERR - ("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", - priority == - GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); + IL_ERR("Failed to allocate SKB buffer with %0x." + "Only %u free buffers remaining.\n", + priority, rxq->free_count); /* We don't reschedule replenish work here -- we will * call the restock method and if it still needs * more buffers it will schedule replenish */ @@ -3250,7 +3248,7 @@ il3945_show_measurement(struct device *d, struct device_attribute *attr, struct il_priv *il = dev_get_drvdata(d); struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; - u8 *data = (u8 *) & measure_report; + u8 *data = (u8 *) &measure_report; unsigned long flags; spin_lock_irqsave(&il->lock, flags); diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 3420b1c..30ad404 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -837,8 +837,8 @@ il3945_open_file_generic(struct inode *inode, struct file *file) } static ssize_t -il3945_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { char *buff; int desc = 0; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 7f0b9f5..7367dbb 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -381,10 +381,10 @@ il3945_accumulative_stats(struct il_priv *il, __le32 * stats) u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *) & il->_3945.stats; - accum_stats = (u32 *) & il->_3945.accum_stats; - delta = (u32 *) & il->_3945.delta_stats; - max_delta = (u32 *) & il->_3945.max_delta; + prev_stats = (__le32 *) &il->_3945.stats; + accum_stats = (u32 *) &il->_3945.accum_stats; + delta = (u32 *) &il->_3945.delta_stats; + max_delta = (u32 *) &il->_3945.max_delta; for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); i += @@ -416,7 +416,7 @@ il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) (int)sizeof(struct il3945_notif_stats), le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_stats(il, (__le32 *) & pkt->u.raw); + il3945_accumulative_stats(il, (__le32 *) &pkt->u.raw); #endif memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); @@ -426,7 +426,7 @@ void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); - __le32 *flag = (__le32 *) & pkt->u.raw; + __le32 *flag = (__le32 *) &pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS @@ -775,7 +775,8 @@ il3945_set_pwr_vmain(struct il_priv *il) APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + CSR_GPIO_IN_BIT_AUX_POWER, 5000); } static int @@ -1228,7 +1229,8 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {3, 113}, {3, 106}, {3, 102}, - {3, 95}}, /* 2.4 GHz, lowest power */ + {3, 95} /* 2.4 GHz, lowest power */ + }, { {251, 127}, /* 5.x GHz, highest power */ {251, 120}, @@ -1307,7 +1309,8 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {35, 113}, {35, 107}, {35, 99}, - {3, 120}} /* 5.x GHz, lowest power */ + {3, 120} /* 5.x GHz, lowest power */ + } }; static inline u8 @@ -1331,7 +1334,7 @@ il3945_hw_reg_fix_power_idx(int idx) */ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, s32 rate_idx, - const s8 * clip_pwrs, + const s8 *clip_pwrs, struct il_channel_info *ch_info, int band_idx) { struct il3945_scan_power_info *scan_power_info; @@ -1883,8 +1886,7 @@ il3945_bg_reg_txpower_periodic(struct work_struct *work) } /** - * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) - * for the channel. + * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) for channel. * * This function is used when initializing channel-info structs. * @@ -1930,7 +1932,7 @@ il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, */ static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, s8 requested_power, - s32 setting_idx, s32 * new_idx) + s32 setting_idx, s32 *new_idx) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -2735,14 +2737,13 @@ static struct il_cfg il3945_abg_cfg = { }; DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { - { - IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, { - IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, { - 0} + {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, + {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, + {0} }; MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 8e53751..00d3336 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -269,11 +269,6 @@ extern int il3945_init_hw_rate_table(struct il_priv *il); extern void il3945_reg_txpower_periodic(struct il_priv *il); extern int il3945_txpower_set_from_eeprom(struct il_priv *il); -extern const struct il_channel_info *il3945_get_channel_info(const struct - il_priv *il, - enum ieee80211_band - band, u16 channel); - extern int il3945_rs_next_rate(struct il_priv *il, int rate); /* scanning */ @@ -619,31 +614,31 @@ struct il3945_tfd { } __packed; #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); -ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user * user_buf, size_t count, - loff_t * ppos); + char __user *user_buf, size_t count, + loff_t *ppos); #else static ssize_t -il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il3945_ucode_general_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index efb3233..d3248e3 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -366,7 +366,7 @@ il4965_sens_auto_corr_ofdm(struct il_priv *il, u32 norm_fa, u32 rx_enable_time) static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, struct il_sensitivity_data *data, - __le16 * tbl) + __le16 *tbl) { tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = cpu_to_le16((u16) data->auto_corr_ofdm); @@ -707,9 +707,8 @@ il4965_find_disconn_antenna(struct il_priv *il, u32 * average_sig, il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - D_CALIB - ("All Tx chains are disconnected W/A - declare %d as connected\n", - first_chain); + D_CALIB("All Tx chains are disconnected" + "- declare %d as connected\n", first_chain); break; } } diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 5299399..98ec39f 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -56,8 +56,8 @@ il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) } ssize_t -il4965_ucode_rx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -468,8 +468,8 @@ il4965_ucode_rx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il4965_ucode_tx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -634,8 +634,8 @@ il4965_ucode_tx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il4965_ucode_general_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index ca819d8..21a1381 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -163,10 +163,10 @@ il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | rb_size | (rb_timeout - << - FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) - | (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | + rb_size | + (rb_timeout << FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) | + (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); @@ -1235,9 +1235,8 @@ il4965_dump_fh(struct il_priv *il, char **buf, bool display) pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), il_rd(il, - fh_tbl - [i])); + il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); } return pos; } @@ -1328,15 +1327,15 @@ il4965_accumulative_stats(struct il_priv *il, __le32 * stats) struct stats_general_common *general, *accum_general; struct stats_tx *tx, *accum_tx; - prev_stats = (__le32 *) & il->_4965.stats; - accum_stats = (u32 *) & il->_4965.accum_stats; + prev_stats = (__le32 *) &il->_4965.stats; + accum_stats = (u32 *) &il->_4965.accum_stats; size = sizeof(struct il_notif_stats); general = &il->_4965.stats.general.common; accum_general = &il->_4965.accum_stats.general.common; tx = &il->_4965.stats.tx; accum_tx = &il->_4965.accum_stats.tx; - delta = (u32 *) & il->_4965.delta_stats; - max_delta = (u32 *) & il->_4965.max_delta; + delta = (u32 *) &il->_4965.delta_stats; + max_delta = (u32 *) &il->_4965.max_delta; for (i = sizeof(__le32); i < size; i += @@ -1375,7 +1374,7 @@ il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) ((il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_stats(il, (__le32 *) & pkt->u.stats); + il4965_accumulative_stats(il, (__le32 *) &pkt->u.stats); #endif /* TODO: reading some of stats is unneeded */ @@ -2093,8 +2092,8 @@ il4965_txq_ctx_stop(struct il_priv *il) (il, FH49_TSSR_TX_STATUS_REG, FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" - " DMA channel %d [0x%08x]", ch, il_rd(il, - FH49_TSSR_TX_STATUS_REG)); + " DMA channel %d [0x%08x]", ch, + il_rd(il, FH49_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); @@ -2135,8 +2134,8 @@ il4965_tx_queue_stop_scheduler(struct il_priv *il, u16 txq_id) /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (1 << - IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** @@ -2451,7 +2450,7 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id) static void il4965_non_agg_tx_status(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr1) + const u8 *addr1) { struct ieee80211_sta *sta; struct il_station_priv *sta_priv; @@ -2661,7 +2660,7 @@ il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb) spin_lock_irqsave(&il->sta_lock, flags); D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", - agg->wait_for_ba, (u8 *) & ba_resp->sta_addr_lo32, + agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, ba_resp->seq_ctl, @@ -2791,7 +2790,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) */ int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, u8 * sta_id_r) + const u8 *addr, u8 *sta_id_r) { int ret; u8 sta_id; @@ -3277,8 +3276,7 @@ il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR - ("Unable to initialize rate scaling for bcast station.\n"); + IL_ERR("Unable to initialize rate scaling for bcast sta.\n"); return -ENOMEM; } @@ -3286,8 +3284,7 @@ il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) if (il->stations[sta_id].lq) kfree(il->stations[sta_id].lq); else - D_INFO - ("Bcast station rate scaling has not been initialized yet.\n"); + D_INFO("Bcast sta rate scaling has not been initialized.\n"); il->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&il->sta_lock, flags); @@ -4819,11 +4816,10 @@ il4965_dump_nic_error_log(struct il_priv *il) u32 blink1, blink2, ilink1, ilink2; u32 pc, hcmd; - if (il->ucode_type == UCODE_INIT) { + if (il->ucode_type == UCODE_INIT) base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); - } else { + else base = le32_to_cpu(il->card_alive.error_event_table_ptr); - } if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { IL_ERR("Not valid error log pointer 0x%08X for %s uCode\n", @@ -6026,13 +6022,11 @@ il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, /* Set up and activate */ il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id - << - IL49_SCD_QUEUE_STTS_REG_POS_TXF) - | (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | (scd_retry - << - IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) - | IL49_SCD_QUEUE_STTS_REG_MSK); + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | + IL49_SCD_QUEUE_STTS_REG_MSK); txq->sched_retry = scd_retry; diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 3ea2361..4bc5a18 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -96,18 +96,18 @@ static const u8 ant_toggle_lookup[] = { */ const struct il_rate_info il_rates[RATE_COUNT] = { IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV), /* 54mbps */ - IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV), /* 60mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ }; static int @@ -150,7 +150,7 @@ static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, #ifdef CONFIG_MAC80211_DEBUGFS static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 * rate_n_flags, int idx); + u32 *rate_n_flags, int idx); #else static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) @@ -610,7 +610,7 @@ il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* switch to another antenna/antennas and return 1 */ /* if no other valid antenna found, return 0 */ static int -il4965_rs_toggle_antenna(u32 valid_ant, u32 * rate_n_flags, +il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, struct il_scale_tbl_info *tbl) { u8 new_ant_type; @@ -1082,7 +1082,8 @@ il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, * bit rate will typically need to increase, but not if performance was bad. */ static s32 -il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ +il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, /* "search" */ u16 rate_mask, s8 idx) { /* "active" values */ @@ -2012,11 +2013,10 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, /* Higher adjacent rate's throughput is measured */ if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ - if (high_tpt > current_tpt && sr >= RATE_INCREASE_TH) { + if (high_tpt > current_tpt && sr >= RATE_INCREASE_TH) scale_action = 1; - } else { + else scale_action = 0; - } /* Lower adjacent rate's throughput is measured */ } else if (low_tpt != IL_INVALID_VALUE) { @@ -2583,8 +2583,8 @@ il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, - const char __user * user_buf, - size_t count, loff_t * ppos) + const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_lq_sta *lq_sta = file->private_data; struct il_priv *il; @@ -2622,8 +2622,8 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file, } static ssize_t -il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { char *buff; int desc = 0; @@ -2730,8 +2730,8 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = { }; static ssize_t -il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { char *buff; int desc = 0; @@ -2776,8 +2776,8 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, - char __user * user_buf, size_t count, - loff_t * ppos) + char __user *user_buf, size_t count, + loff_t *ppos) { char buff[120]; int desc = 0; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index be054f1..6f5e6a1 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -533,8 +533,8 @@ il4965_nic_config(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); il->calib_info = - (struct il_eeprom_calib_info *)il_eeprom_query_addr(il, - EEPROM_4965_CALIB_TXPOWER_OFFSET); + (struct il_eeprom_calib_info *) + il_eeprom_query_addr(il, EEPROM_4965_CALIB_TXPOWER_OFFSET); spin_unlock_irqrestore(&il->lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 78eae22..ded8b92 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -138,7 +138,7 @@ il4965_get_tx_fail_reason(u32 status) /* station management */ int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx); int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, u8 * sta_id_r); + const u8 *addr, u8 *sta_id_r); int il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); @@ -153,7 +153,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, - u16 * phase1key); + u16 *phase1key); int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid); int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, u16 ssn); @@ -195,7 +195,7 @@ void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, - u16 * phase1key); + u16 *phase1key); int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 * ssn, @@ -949,31 +949,31 @@ void il4965_calib_free_results(struct il_priv *il); /* Debug */ #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); -ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); ssize_t il4965_ucode_general_stats_read(struct file *file, - char __user * user_buf, size_t count, - loff_t * ppos); + char __user *user_buf, size_t count, + loff_t *ppos); #else static ssize_t -il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 2e1bbb2..7e2924f 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -92,7 +92,6 @@ il_get_cmd_string(u8 cmd) } } - EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) @@ -231,7 +230,6 @@ fail: out: return ret; } - EXPORT_SYMBOL(il_send_cmd_sync); int @@ -242,7 +240,6 @@ il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) return il_send_cmd_sync(il, cmd); } - EXPORT_SYMBOL(il_send_cmd); int @@ -256,14 +253,13 @@ il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) return il_send_cmd_sync(il, &cmd); } - EXPORT_SYMBOL(il_send_cmd_pdu); int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback) (struct il_priv * il, - struct il_device_cmd * cmd, - struct il_rx_pkt * pkt)) + void (*callback) (struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)) { struct il_host_cmd cmd = { .id = id, @@ -276,7 +272,6 @@ il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, return il_send_cmd_async(il, &cmd); } - EXPORT_SYMBOL(il_send_cmd_pdu_async); /* default: IL_LED_BLINK(0) using blinking idx table */ @@ -299,16 +294,16 @@ MODULE_PARM_DESC(led_mode, * <=0 SOLID ON */ static const struct ieee80211_tpt_blink il_blink[] = { - {.throughput = 0,.blink_time = 334}, - {.throughput = 1 * 1024 - 1,.blink_time = 260}, - {.throughput = 5 * 1024 - 1,.blink_time = 220}, - {.throughput = 10 * 1024 - 1,.blink_time = 190}, - {.throughput = 20 * 1024 - 1,.blink_time = 170}, - {.throughput = 50 * 1024 - 1,.blink_time = 150}, - {.throughput = 70 * 1024 - 1,.blink_time = 130}, - {.throughput = 100 * 1024 - 1,.blink_time = 110}, - {.throughput = 200 * 1024 - 1,.blink_time = 80}, - {.throughput = 300 * 1024 - 1,.blink_time = 50}, + {.throughput = 0, .blink_time = 334}, + {.throughput = 1 * 1024 - 1, .blink_time = 260}, + {.throughput = 5 * 1024 - 1, .blink_time = 220}, + {.throughput = 10 * 1024 - 1, .blink_time = 190}, + {.throughput = 20 * 1024 - 1, .blink_time = 170}, + {.throughput = 50 * 1024 - 1, .blink_time = 150}, + {.throughput = 70 * 1024 - 1, .blink_time = 130}, + {.throughput = 100 * 1024 - 1, .blink_time = 110}, + {.throughput = 200 * 1024 - 1, .blink_time = 80}, + {.throughput = 300 * 1024 - 1, .blink_time = 50}, }; /* @@ -433,7 +428,6 @@ il_leds_init(struct il_priv *il) il->led_registered = true; } - EXPORT_SYMBOL(il_leds_init); void @@ -445,7 +439,6 @@ il_leds_exit(struct il_priv *il) led_classdev_unregister(&il->led); kfree(il->led.name); } - EXPORT_SYMBOL(il_leds_exit); /************************** EEPROM BANDS **************************** @@ -540,17 +533,15 @@ il_eeprom_query_addr(const struct il_priv *il, size_t offset) BUG_ON(offset >= il->cfg->base_params->eeprom_size); return &il->eeprom[offset]; } - EXPORT_SYMBOL(il_eeprom_query_addr); u16 -il_eeprom_query16(const struct il_priv * il, size_t offset) +il_eeprom_query16(const struct il_priv *il, size_t offset) { if (!il->eeprom) return 0; return (u16) il->eeprom[offset] | ((u16) il->eeprom[offset + 1] << 8); } - EXPORT_SYMBOL(il_eeprom_query16); /** @@ -631,7 +622,6 @@ err: alloc_err: return ret; } - EXPORT_SYMBOL(il_eeprom_init); void @@ -640,14 +630,13 @@ il_eeprom_free(struct il_priv *il) kfree(il->eeprom); il->eeprom = NULL; } - EXPORT_SYMBOL(il_eeprom_free); static void il_init_band_reference(const struct il_priv *il, int eep_band, int *eeprom_ch_count, const struct il_eeprom_channel **eeprom_ch_info, - const u8 ** eeprom_ch_idx) + const u8 **eeprom_ch_idx) { u32 offset = il->cfg->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; @@ -885,7 +874,6 @@ il_init_channel_map(struct il_priv *il) return 0; } - EXPORT_SYMBOL(il_init_channel_map); /* @@ -897,7 +885,6 @@ il_free_channel_map(struct il_priv *il) kfree(il->channel_info); il->channel_count = 0; } - EXPORT_SYMBOL(il_free_channel_map); /** @@ -928,7 +915,6 @@ il_get_channel_info(const struct il_priv *il, enum ieee80211_band band, return NULL; } - EXPORT_SYMBOL(il_get_channel_info); /* @@ -1033,7 +1019,6 @@ il_power_update_mode(struct il_priv *il, bool force) il_power_sleep_cam_cmd(il, &cmd); return il_power_set_mode(il, &cmd, force); } - EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ @@ -1172,7 +1157,6 @@ il_scan_cancel(struct il_priv *il) queue_work(il->workqueue, &il->abort_scan); return 0; } - EXPORT_SYMBOL(il_scan_cancel); /** @@ -1199,7 +1183,6 @@ il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) return test_bit(S_SCAN_HW, &il->status); } - EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to C_SCAN (0x80) */ @@ -1279,7 +1262,6 @@ il_setup_rx_scan_handlers(struct il_priv *il) il->handlers[N_SCAN_RESULTS] = il_hdl_scan_results; il->handlers[N_SCAN_COMPLETE] = il_hdl_scan_complete; } - EXPORT_SYMBOL(il_setup_rx_scan_handlers); inline u16 @@ -1293,12 +1275,11 @@ il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, return IL_ACTIVE_DWELL_TIME_24 + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); } - EXPORT_SYMBOL(il_get_active_dwell_time); u16 -il_get_passive_dwell_time(struct il_priv * il, enum ieee80211_band band, - struct ieee80211_vif * vif) +il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, + struct ieee80211_vif *vif) { struct il_rxon_context *ctx = &il->ctx; u16 value; @@ -1324,7 +1305,6 @@ il_get_passive_dwell_time(struct il_priv * il, enum ieee80211_band band, return passive; } - EXPORT_SYMBOL(il_get_passive_dwell_time); void @@ -1336,7 +1316,6 @@ il_init_scan_params(struct il_priv *il) if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } - EXPORT_SYMBOL(il_init_scan_params); static int @@ -1417,7 +1396,6 @@ out_unlock: return ret; } - EXPORT_SYMBOL(il_mac_hw_scan); static void @@ -1442,7 +1420,7 @@ il_bg_scan_check(struct work_struct *data) u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 * ta, const u8 * ies, int ie_len, int left) + const u8 *ta, const u8 *ies, int ie_len, int left) { int len = 0; u8 *pos = NULL; @@ -1483,7 +1461,6 @@ il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, return (u16) len; } - EXPORT_SYMBOL(il_fill_probe_req); static void @@ -1548,7 +1525,6 @@ il_setup_scan_deferred_work(struct il_priv *il) INIT_WORK(&il->abort_scan, il_bg_abort_scan); INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); } - EXPORT_SYMBOL(il_setup_scan_deferred_work); void @@ -1563,7 +1539,6 @@ il_cancel_scan_deferred_work(struct il_priv *il) mutex_unlock(&il->mutex); } } - EXPORT_SYMBOL(il_cancel_scan_deferred_work); /* il->sta_lock must be held */ @@ -1693,7 +1668,6 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) return ret; } - EXPORT_SYMBOL(il_send_add_sta); static void @@ -1709,10 +1683,9 @@ il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; D_ASSOC("spatial multiplexing power save mode: %s\n", - (mimo_ps_mode == - WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == - WLAN_HT_CAP_SM_PS_DYNAMIC) - ? "dynamic" : "disabled"); + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? "dynamic" : + "disabled"); sta_flags = il->stations[idx].sta.station_flags; @@ -1756,8 +1729,8 @@ done: * should be called with sta_lock held */ u8 -il_prep_station(struct il_priv * il, struct il_rxon_context * ctx, - const u8 * addr, bool is_ap, struct ieee80211_sta * sta) +il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, struct ieee80211_sta *sta) { struct il_station_entry *station; int i; @@ -1841,7 +1814,6 @@ il_prep_station(struct il_priv * il, struct il_rxon_context * ctx, return sta_id; } - EXPORT_SYMBOL_GPL(il_prep_station); #define STA_WAIT_TIMEOUT (HZ/2) @@ -1851,8 +1823,8 @@ EXPORT_SYMBOL_GPL(il_prep_station); */ int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, bool is_ap, struct ieee80211_sta *sta, - u8 * sta_id_r) + const u8 *addr, bool is_ap, struct ieee80211_sta *sta, + u8 *sta_id_r) { unsigned long flags_spin; int ret = 0; @@ -1905,7 +1877,6 @@ il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, *sta_id_r = sta_id; return ret; } - EXPORT_SYMBOL(il_add_station_common); /** @@ -2038,7 +2009,6 @@ out_err: spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } - EXPORT_SYMBOL_GPL(il_remove_station); /** @@ -2074,7 +2044,6 @@ il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) if (!cleared) D_INFO("No active stations found to be cleared\n"); } - EXPORT_SYMBOL(il_clear_ucode_stations); /** @@ -2156,7 +2125,6 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) else D_INFO("Restoring all known stations" " .... complete.\n"); } - EXPORT_SYMBOL(il_restore_stations); int @@ -2170,7 +2138,6 @@ il_get_free_ucode_key_idx(struct il_priv *il) return WEP_INVALID_OFFSET; } - EXPORT_SYMBOL(il_get_free_ucode_key_idx); void @@ -2192,7 +2159,6 @@ il_dealloc_bcast_stations(struct il_priv *il) } spin_unlock_irqrestore(&il->sta_lock, flags); } - EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLEGACY_DEBUG @@ -2299,7 +2265,6 @@ il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, } return ret; } - EXPORT_SYMBOL(il_send_lq_cmd); int @@ -2319,7 +2284,6 @@ il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mutex_unlock(&il->mutex); return ret; } - EXPORT_SYMBOL(il_mac_sta_remove); /************************** RX-FUNCTIONS ****************************/ @@ -2404,7 +2368,6 @@ il_rx_queue_space(const struct il_rx_queue *q) s = 0; return s; } - EXPORT_SYMBOL(il_rx_queue_space); /** @@ -2449,7 +2412,6 @@ il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q) exit_unlock: spin_unlock_irqrestore(&q->lock, flags); } - EXPORT_SYMBOL(il_rx_queue_update_write_ptr); int @@ -2494,7 +2456,6 @@ err_rb: err_bd: return -ENOMEM; } - EXPORT_SYMBOL(il_rx_queue_alloc); void @@ -2511,7 +2472,6 @@ il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb) memcpy(&il->measure_report, report, sizeof(*report)); il->measurement_status |= MEASUREMENT_READY; } - EXPORT_SYMBOL(il_hdl_spectrum_measurement); /* @@ -2563,7 +2523,6 @@ il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, } return 0; } - EXPORT_SYMBOL(il_set_decrypted_flag); /** @@ -2604,7 +2563,6 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) _il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } - EXPORT_SYMBOL(il_txq_update_write_ptr); /** @@ -2624,7 +2582,6 @@ il_tx_queue_unmap(struct il_priv *il, int txq_id) q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } - EXPORT_SYMBOL(il_tx_queue_unmap); /** @@ -2666,7 +2623,6 @@ il_tx_queue_free(struct il_priv *il, int txq_id) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } - EXPORT_SYMBOL(il_tx_queue_free); /** @@ -2705,7 +2661,6 @@ il_cmd_queue_unmap(struct il_priv *il) txq->meta[i].flags = 0; } } - EXPORT_SYMBOL(il_cmd_queue_unmap); /** @@ -2743,7 +2698,6 @@ il_cmd_queue_free(struct il_priv *il) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } - EXPORT_SYMBOL(il_cmd_queue_free); /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** @@ -2785,7 +2739,6 @@ il_queue_space(const struct il_queue *q) s = 0; return s; } - EXPORT_SYMBOL(il_queue_space); @@ -2940,7 +2893,6 @@ out_free_arrays: return -ENOMEM; } - EXPORT_SYMBOL(il_tx_queue_init); void @@ -2962,7 +2914,6 @@ il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, /* Tell device where to find queue */ il->cfg->ops->lib->txq_init(il, txq); } - EXPORT_SYMBOL(il_tx_queue_reset); /*************** HOST COMMAND QUEUE FUNCTIONS *****/ @@ -3219,7 +3170,6 @@ u32 il_debug_level; EXPORT_SYMBOL(il_debug_level); const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - EXPORT_SYMBOL(il_bcast_addr); /* This function both allocates and initializes hw and il. */ @@ -3244,7 +3194,6 @@ il_alloc_all(struct il_cfg *cfg) out: return hw; } - EXPORT_SYMBOL(il_alloc_all); #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ @@ -3418,7 +3367,6 @@ il_init_geos(struct il_priv *il) return 0; } - EXPORT_SYMBOL(il_init_geos); /* @@ -3431,7 +3379,6 @@ il_free_geos(struct il_priv *il) kfree(il->ieee_rates); clear_bit(S_GEO_CONFIGURED, &il->status); } - EXPORT_SYMBOL(il_free_geos); static bool @@ -3455,8 +3402,8 @@ il_is_channel_extension(struct il_priv *il, enum ieee80211_band band, } bool -il_is_ht40_tx_allowed(struct il_priv * il, struct il_rxon_context * ctx, - struct ieee80211_sta_ht_cap * ht_cap) +il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap) { if (!ctx->ht.enabled || !ctx->ht.is_40mhz) return false; @@ -3477,7 +3424,6 @@ il_is_ht40_tx_allowed(struct il_priv * il, struct il_rxon_context * ctx, le16_to_cpu(ctx->staging.channel), ctx->ht.extension_chan_offset); } - EXPORT_SYMBOL(il_is_ht40_tx_allowed); static u16 @@ -3561,7 +3507,6 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); } - EXPORT_SYMBOL(il_send_rxon_timing); void @@ -3576,7 +3521,6 @@ il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; } - EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ @@ -3650,7 +3594,6 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) } return 0; } - EXPORT_SYMBOL(il_check_rxon_cmd); /** @@ -3713,11 +3656,10 @@ il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) return 0; } - EXPORT_SYMBOL(il_full_rxon_required); u8 -il_get_lowest_plcp(struct il_priv * il, struct il_rxon_context * ctx) +il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx) { /* * Assign the lowest rate -- should really get this from @@ -3728,7 +3670,6 @@ il_get_lowest_plcp(struct il_priv * il, struct il_rxon_context * ctx) else return RATE_6M_PLCP; } - EXPORT_SYMBOL(il_get_lowest_plcp); static void @@ -3803,7 +3744,6 @@ il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { _il_set_rxon_ht(il, ht_conf, &il->ctx); } - EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ @@ -3835,7 +3775,6 @@ il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band) return channel; } - EXPORT_SYMBOL(il_get_single_channel_number); /** @@ -3867,7 +3806,6 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, return 0; } - EXPORT_SYMBOL(il_set_rxon_channel); void @@ -3891,7 +3829,6 @@ il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, ctx->staging.flags &= ~RXON_FLG_CCK_MSK; } } - EXPORT_SYMBOL(il_set_flags_for_band); /* @@ -3962,7 +3899,6 @@ il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; } - EXPORT_SYMBOL(il_connection_init_rx_config); void @@ -3994,7 +3930,6 @@ il_set_rate(struct il_priv *il) il->ctx.staging.ofdm_basic_rates = (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; } - EXPORT_SYMBOL(il_set_rate); void @@ -4008,7 +3943,6 @@ il_chswitch_done(struct il_priv *il, bool is_success) if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } - EXPORT_SYMBOL(il_chswitch_done); void @@ -4034,7 +3968,6 @@ il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) il_chswitch_done(il, false); } } - EXPORT_SYMBOL(il_hdl_csa); #ifdef CONFIG_IWLEGACY_DEBUG @@ -4055,7 +3988,6 @@ il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); D_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } - EXPORT_SYMBOL(il_print_rx_config_cmd); #endif /** @@ -4094,7 +4026,6 @@ il_irq_handle_error(struct il_priv *il) queue_work(il->workqueue, &il->restart); } } - EXPORT_SYMBOL(il_irq_handle_error); static int @@ -4135,7 +4066,6 @@ il_apm_stop(struct il_priv *il) */ il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } - EXPORT_SYMBOL(il_apm_stop); /* @@ -4249,7 +4179,6 @@ il_apm_init(struct il_priv *il) out: return ret; } - EXPORT_SYMBOL(il_apm_init); int @@ -4307,7 +4236,6 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) } return ret; } - EXPORT_SYMBOL(il_set_tx_power); void @@ -4356,7 +4284,7 @@ il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); D_RX("sleep mode: %d, src: %d\n", - sleep->pm_sleep_mode, sleep->pm_wakeup_src); + sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } EXPORT_SYMBOL(il_hdl_pm_sleep); @@ -4432,7 +4360,6 @@ il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, D_MAC80211("leave\n"); return 0; } - EXPORT_SYMBOL(il_mac_conf_tx); int @@ -4442,7 +4369,6 @@ il_mac_tx_last_beacon(struct ieee80211_hw *hw) return il->ibss_manager == IL_IBSS_MANAGER; } - EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int @@ -4529,7 +4455,6 @@ out: D_MAC80211("leave\n"); return err; } - EXPORT_SYMBOL(il_mac_add_interface); static void @@ -4573,7 +4498,6 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) D_MAC80211("leave\n"); } - EXPORT_SYMBOL(il_mac_remove_interface); int @@ -4589,7 +4513,6 @@ il_alloc_txq_mem(struct il_priv *il) } return 0; } - EXPORT_SYMBOL(il_alloc_txq_mem); void @@ -4598,7 +4521,6 @@ il_txq_mem(struct il_priv *il) kfree(il->txq); il->txq = NULL; } - EXPORT_SYMBOL(il_txq_mem); #ifdef CONFIG_IWLEGACY_DEBUGFS @@ -4638,7 +4560,6 @@ il_alloc_traffic_mem(struct il_priv *il) il_reset_traffic_log(il); return 0; } - EXPORT_SYMBOL(il_alloc_traffic_mem); void @@ -4650,7 +4571,6 @@ il_free_traffic_mem(struct il_priv *il) kfree(il->rx_traffic); il->rx_traffic = NULL; } - EXPORT_SYMBOL(il_free_traffic_mem); void @@ -4678,7 +4598,6 @@ il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } - EXPORT_SYMBOL(il_dbg_log_tx_data_frame); void @@ -4706,7 +4625,6 @@ il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } - EXPORT_SYMBOL(il_dbg_log_rx_data_frame); const char * @@ -4849,7 +4767,6 @@ il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) stats->data_bytes += len; } } - EXPORT_SYMBOL(il_update_stats); #endif @@ -4958,7 +4875,6 @@ out: mutex_unlock(&il->mutex); return err; } - EXPORT_SYMBOL(il_mac_change_interface); /* @@ -5034,7 +4950,6 @@ il_bg_watchdog(unsigned long data) mod_timer(&il->watchdog, jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); } - EXPORT_SYMBOL(il_bg_watchdog); void @@ -5048,7 +4963,6 @@ il_setup_watchdog(struct il_priv *il) else del_timer(&il->watchdog); } - EXPORT_SYMBOL(il_setup_watchdog); /* @@ -5080,14 +4994,13 @@ il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval) return (quot << il->hw_params.beacon_time_tsf_bits) + rem; } - EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ __le32 -il_add_beacon_time(struct il_priv * il, u32 base, u32 addon, +il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, u32 beacon_interval) { u32 base_low = base & il_beacon_time_mask_low(il, @@ -5114,7 +5027,6 @@ il_add_beacon_time(struct il_priv * il, u32 base, u32 addon, return cpu_to_le32(res); } - EXPORT_SYMBOL(il_add_beacon_time); #ifdef CONFIG_PM @@ -5136,7 +5048,6 @@ il_pci_suspend(struct device *device) return 0; } - EXPORT_SYMBOL(il_pci_suspend); int @@ -5166,7 +5077,6 @@ il_pci_resume(struct device *device) return 0; } - EXPORT_SYMBOL(il_pci_resume); const struct dev_pm_ops il_pm_ops = { @@ -5177,7 +5087,6 @@ const struct dev_pm_ops il_pm_ops = { .poweroff = il_pci_suspend, .restore = il_pci_resume, }; - EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ @@ -5413,7 +5322,6 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) D_MAC80211("leave\n"); } - EXPORT_SYMBOL(il_mac_reset_tsf); static void @@ -5701,7 +5609,6 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, D_MAC80211("leave\n"); } - EXPORT_SYMBOL(il_mac_bss_info_changed); irqreturn_t @@ -5763,7 +5670,6 @@ none: spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; } - EXPORT_SYMBOL(il_isr); /* @@ -5772,7 +5678,7 @@ EXPORT_SYMBOL(il_isr); */ void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, - __le16 fc, __le32 * tx_flags) + __le16 fc, __le32 *tx_flags) { if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { *tx_flags |= TX_CMD_FLG_RTS_MSK; @@ -5798,5 +5704,4 @@ il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; } } - EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 38ff3d6..d0975ab 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -112,8 +112,8 @@ struct il_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, - struct il_rx_pkt * pkt); + void (*callback) (struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ @@ -432,8 +432,8 @@ struct il_eeprom_calib_info { struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv * il); - void (*release_semaphore) (struct il_priv * il); + int (*acquire_semaphore) (struct il_priv *il); + void (*release_semaphore) (struct il_priv *il); }; int il_eeprom_init(struct il_priv *il); @@ -592,8 +592,8 @@ struct il_device_cmd { struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, - struct il_rx_pkt * pkt); + void (*callback) (struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); u32 flags; u16 len; u8 id; @@ -1224,8 +1224,8 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*handlers[IL_CN_MAX]) (struct il_priv * il, - struct il_rx_buf * rxb); + void (*handlers[IL_CN_MAX]) (struct il_priv *il, + struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -1613,69 +1613,69 @@ il_free_pages(struct il_priv *il, unsigned long page) #define IL_RX_BUF_SIZE_8K (8 * 1024) struct il_hcmd_ops { - int (*rxon_assoc) (struct il_priv * il, struct il_rxon_context * ctx); - int (*commit_rxon) (struct il_priv * il, struct il_rxon_context * ctx); - void (*set_rxon_chain) (struct il_priv * il, - struct il_rxon_context * ctx); + int (*rxon_assoc) (struct il_priv *il, struct il_rxon_context *ctx); + int (*commit_rxon) (struct il_priv *il, struct il_rxon_context *ctx); + void (*set_rxon_chain) (struct il_priv *il, + struct il_rxon_context *ctx); }; struct il_hcmd_utils_ops { u16(*get_hcmd_size) (u8 cmd_id, u16 len); - u16(*build_addsta_hcmd) (const struct il_addsta_cmd * cmd, u8 * data); - int (*request_scan) (struct il_priv * il, struct ieee80211_vif * vif); - void (*post_scan) (struct il_priv * il); + u16(*build_addsta_hcmd) (const struct il_addsta_cmd *cmd, u8 *data); + int (*request_scan) (struct il_priv *il, struct ieee80211_vif *vif); + void (*post_scan) (struct il_priv *il); }; struct il_apm_ops { - int (*init) (struct il_priv * il); - void (*config) (struct il_priv * il); + int (*init) (struct il_priv *il); + void (*config) (struct il_priv *il); }; struct il_debugfs_ops { - ssize_t(*rx_stats_read) (struct file * file, char __user * user_buf, - size_t count, loff_t * ppos); - ssize_t(*tx_stats_read) (struct file * file, char __user * user_buf, - size_t count, loff_t * ppos); - ssize_t(*general_stats_read) (struct file * file, - char __user * user_buf, size_t count, - loff_t * ppos); + ssize_t(*rx_stats_read) (struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t(*tx_stats_read) (struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t(*general_stats_read) (struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos); }; struct il_temp_ops { - void (*temperature) (struct il_priv * il); + void (*temperature) (struct il_priv *il); }; struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params) (struct il_priv * il); + int (*set_hw_params) (struct il_priv *il); /* Handling TX */ - void (*txq_update_byte_cnt_tbl) (struct il_priv * il, - struct il_tx_queue * txq, + void (*txq_update_byte_cnt_tbl) (struct il_priv *il, + struct il_tx_queue *txq, u16 byte_cnt); - int (*txq_attach_buf_to_tfd) (struct il_priv * il, - struct il_tx_queue * txq, dma_addr_t addr, + int (*txq_attach_buf_to_tfd) (struct il_priv *il, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); - void (*txq_free_tfd) (struct il_priv * il, struct il_tx_queue * txq); - int (*txq_init) (struct il_priv * il, struct il_tx_queue * txq); + void (*txq_free_tfd) (struct il_priv *il, struct il_tx_queue *txq); + int (*txq_init) (struct il_priv *il, struct il_tx_queue *txq); /* setup Rx handler */ - void (*handler_setup) (struct il_priv * il); + void (*handler_setup) (struct il_priv *il); /* alive notification after init uCode load */ - void (*init_alive_start) (struct il_priv * il); + void (*init_alive_start) (struct il_priv *il); /* check validity of rtc data address */ int (*is_valid_rtc_data_addr) (u32 addr); /* 1st ucode load */ - int (*load_ucode) (struct il_priv * il); + int (*load_ucode) (struct il_priv *il); - void (*dump_nic_error_log) (struct il_priv * il); - int (*dump_fh) (struct il_priv * il, char **buf, bool display); - int (*set_channel_switch) (struct il_priv * il, - struct ieee80211_channel_switch * ch_switch); + void (*dump_nic_error_log) (struct il_priv *il); + int (*dump_fh) (struct il_priv *il, char **buf, bool display); + int (*set_channel_switch) (struct il_priv *il, + struct ieee80211_channel_switch *ch_switch); /* power management */ struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct il_priv * il); - void (*update_chain_flags) (struct il_priv * il); + int (*send_tx_power) (struct il_priv *il); + void (*update_chain_flags) (struct il_priv *il); /* eeprom operations */ struct il_eeprom_ops eeprom_ops; @@ -1688,16 +1688,16 @@ struct il_lib_ops { }; struct il_led_ops { - int (*cmd) (struct il_priv * il, struct il_led_cmd * led_cmd); + int (*cmd) (struct il_priv *il, struct il_led_cmd *led_cmd); }; struct il_legacy_ops { - void (*post_associate) (struct il_priv * il); - void (*config_ap) (struct il_priv * il); + void (*post_associate) (struct il_priv *il); + void (*config_ap) (struct il_priv *il); /* station management */ - int (*update_bcast_stations) (struct il_priv * il); - int (*manage_ibss_station) (struct il_priv * il, - struct ieee80211_vif * vif, bool add); + int (*update_bcast_stations) (struct il_priv *il); + int (*manage_ibss_station) (struct il_priv *il, + struct ieee80211_vif *vif, bool add); }; struct il_ops { @@ -1965,7 +1965,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, void il_internal_short_hw_scan(struct il_priv *il); int il_force_reset(struct il_priv *il, bool external); u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 * ta, const u8 * ie, int ie_len, int left); + const u8 *ta, const u8 *ie, int ie_len, int left); void il_setup_rx_scan_handlers(struct il_priv *il); u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, u8 n_probes); @@ -1995,9 +1995,9 @@ int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data); int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback) (struct il_priv * il, - struct il_device_cmd * cmd, - struct il_rx_pkt * pkt)); + void (*callback) (struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)); int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); @@ -2155,7 +2155,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, - __le16 fc, __le32 * tx_flags); + __le16 fc, __le32 *tx_flags); irqreturn_t il_isr(int irq, void *data); @@ -2191,8 +2191,7 @@ _il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } - while (t < timeout); + } while (t < timeout); return -ETIMEDOUT; } @@ -2324,8 +2323,7 @@ il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } - while (t < timeout); + } while (t < timeout); return -ETIMEDOUT; } @@ -2485,14 +2483,14 @@ void il_dealloc_bcast_stations(struct il_priv *il); int il_get_free_ucode_key_idx(struct il_priv *il); int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, bool is_ap, - struct ieee80211_sta *sta, u8 * sta_id_r); + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta, u8 *sta_id_r); int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 * addr); int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, bool is_ap, struct ieee80211_sta *sta); + const u8 *addr, bool is_ap, struct ieee80211_sta *sta); int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq, u8 flags, bool init); @@ -2758,10 +2756,10 @@ il_get_dma_hi_addr(dma_addr_t addr) * * This structure contains dma address and length of transmission address * - * @lo: low [31:0] portion of the dma address of TX buffer - * every even is unaligned on 16 bit boundary - * @hi_n_len 0-3 [35:32] portion of dma - * 4-15 length of the tx buffer + * @lo: low [31:0] portion of the dma address of TX buffer every even is + * unaligned on 16 bit boundary + * @hi_n_len: 0-3 [35:32] portion of dma + * 4-15 length of the tx buffer */ struct il_tfd_tb { __le32 lo; @@ -2778,7 +2776,7 @@ struct il_tfd_tb { * 5 reserved * 6-7 padding (not used) * @ tbs[20] transmit frame buffer descriptors - * @ __pad padding + * @ __pad padding * * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. * Both driver and device share these circular buffers, each of which must be @@ -3295,7 +3293,7 @@ do { \ __func__ , ## args); \ } while (0) -#define il_print_hex_dump(il, level, p, len) \ +#define il_print_hex_dump(il, level, p, len) \ do { \ if (il_get_debug_level(il) & level) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ @@ -3342,9 +3340,9 @@ il_dbgfs_unregister(struct il_priv *il) * * The active debug levels can be accessed via files * - * /sys/module/iwl4965/parameters/debug + * /sys/module/iwl4965/parameters/debug * /sys/module/iwl3945/parameters/debug - * /sys/class/net/wlan0/device/debug_level + * /sys/class/net/wlan0/device/debug_level * * when CONFIG_IWLEGACY_DEBUG=y. */ diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index e79794a..928bdbb 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -71,35 +71,35 @@ il_dbgfs_open_file_generic(struct inode *inode, struct file *file) return 0; } -#define DEBUGFS_READ_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ +#define DEBUGFS_READ_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ static const struct file_operations il_dbgfs_##name##_ops = { \ .read = il_dbgfs_##name##_read, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ }; -#define DEBUGFS_WRITE_FILE_OPS(name) \ - DEBUGFS_WRITE_FUNC(name); \ +#define DEBUGFS_WRITE_FILE_OPS(name) \ + DEBUGFS_WRITE_FUNC(name); \ static const struct file_operations il_dbgfs_##name##_ops = { \ .write = il_dbgfs_##name##_write, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ }; -#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ - DEBUGFS_WRITE_FUNC(name); \ +#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ + DEBUGFS_WRITE_FUNC(name); \ static const struct file_operations il_dbgfs_##name##_ops = { \ .write = il_dbgfs_##name##_write, \ .read = il_dbgfs_##name##_read, \ .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ + .llseek = generic_file_llseek, \ }; static ssize_t -il_dbgfs_tx_stats_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -139,8 +139,8 @@ il_dbgfs_tx_stats_read(struct file *file, char __user * user_buf, size_t count, static ssize_t il_dbgfs_clear_traffic_stats_write(struct file *file, - const char __user * user_buf, size_t count, - loff_t * ppos) + const char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; u32 clear_flag; @@ -159,8 +159,8 @@ il_dbgfs_clear_traffic_stats_write(struct file *file, } static ssize_t -il_dbgfs_rx_stats_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -203,8 +203,8 @@ il_dbgfs_rx_stats_read(struct file *file, char __user * user_buf, size_t count, #define BYTE2_MASK 0x0000ffff; #define BYTE3_MASK 0x00ffffff; static ssize_t -il_dbgfs_sram_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_sram_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { u32 val; char *buf; @@ -262,8 +262,8 @@ il_dbgfs_sram_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_sram_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_sram_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[64]; @@ -287,8 +287,8 @@ il_dbgfs_sram_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_stations_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; struct il_station_entry *station; @@ -351,8 +351,8 @@ il_dbgfs_stations_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_nvm_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { ssize_t ret; struct il_priv *il = file->private_data; @@ -399,8 +399,8 @@ il_dbgfs_nvm_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_channels_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; struct ieee80211_channel *channels = NULL; @@ -478,8 +478,8 @@ il_dbgfs_channels_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_status_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -539,8 +539,8 @@ il_dbgfs_status_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_interrupt_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -618,8 +618,8 @@ il_dbgfs_interrupt_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_interrupt_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -639,8 +639,8 @@ il_dbgfs_interrupt_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_qos_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; struct il_rxon_context *ctx = &il->ctx; @@ -666,8 +666,8 @@ il_dbgfs_qos_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_disable_ht40_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -692,8 +692,8 @@ il_dbgfs_disable_ht40_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_disable_ht40_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[100]; @@ -716,8 +716,8 @@ DEBUGFS_READ_FILE_OPS(qos); DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); static ssize_t -il_dbgfs_traffic_log_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0, ofs = 0; @@ -801,8 +801,8 @@ il_dbgfs_traffic_log_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_traffic_log_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -822,8 +822,8 @@ il_dbgfs_traffic_log_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -851,9 +851,8 @@ il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, scnprintf(buf + pos, bufsz - pos, "hwq %.2d: read=%u write=%u stop=%d" " swq_id=%#.2x (ac %d/hwq %d)\n", cnt, - q->read_ptr, q->write_ptr, !!test_bit(cnt, - il-> - queue_stopped), + q->read_ptr, q->write_ptr, + !!test_bit(cnt, il->queue_stopped), txq->swq_id, txq->swq_id & 3, (txq->swq_id >> 2) & 0x1f); if (cnt >= 4) @@ -870,8 +869,8 @@ il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_rx_queue_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -899,8 +898,8 @@ il_dbgfs_rx_queue_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, @@ -908,8 +907,8 @@ il_dbgfs_ucode_rx_stats_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, @@ -917,8 +916,8 @@ il_dbgfs_ucode_tx_stats_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_ucode_general_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, @@ -926,8 +925,8 @@ il_dbgfs_ucode_general_stats_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_sensitivity_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1025,8 +1024,8 @@ il_dbgfs_sensitivity_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_chain_noise_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1096,8 +1095,8 @@ il_dbgfs_chain_noise_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_power_save_status_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[60]; @@ -1111,19 +1110,18 @@ il_dbgfs_power_save_status_read(struct file *file, char __user * user_buf, pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); pos += scnprintf(buf + pos, bufsz - pos, "%s\n", - (pwrsave_status == - CSR_GP_REG_NO_POWER_SAVE) ? "none" : (pwrsave_status == - CSR_GP_REG_MAC_POWER_SAVE) - ? "MAC" : (pwrsave_status == - CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : "error"); + (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : + (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : + (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : + "error"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, - const char __user * user_buf, size_t count, - loff_t * ppos) + const char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1146,8 +1144,8 @@ il_dbgfs_clear_ucode_stats_write(struct file *file, } static ssize_t -il_dbgfs_rxon_flags_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1159,8 +1157,8 @@ il_dbgfs_rxon_flags_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_rxon_filter_flags_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1173,8 +1171,8 @@ il_dbgfs_rxon_filter_flags_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_fh_reg_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; char *buf; @@ -1195,8 +1193,8 @@ il_dbgfs_fh_reg_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_missed_beacon_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1212,8 +1210,8 @@ il_dbgfs_missed_beacon_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_missed_beacon_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1237,8 +1235,8 @@ il_dbgfs_missed_beacon_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_force_reset_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_force_reset_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1268,8 +1266,8 @@ il_dbgfs_force_reset_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_force_reset_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_force_reset_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { int ret; @@ -1281,8 +1279,8 @@ il_dbgfs_force_reset_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_wd_timeout_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1394,7 +1392,6 @@ err: il_dbgfs_unregister(il); return -ENOMEM; } - EXPORT_SYMBOL(il_dbgfs_register); /** @@ -1410,5 +1407,4 @@ il_dbgfs_unregister(struct il_priv *il) debugfs_remove_recursive(il->debugfs_dir); il->debugfs_dir = NULL; } - EXPORT_SYMBOL(il_dbgfs_unregister); -- cgit v0.10.2 From 53611e05263ca2101a29736920fdf86ccad0e93b Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Sun, 28 Aug 2011 08:26:16 -0500 Subject: iwlegacy: change IL_WARN to D_HT in il4965_tx_agg_start This message should be a debug message and not a warning. Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 21a1381..8d2f616 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -2252,7 +2252,7 @@ il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); + D_HT("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { -- cgit v0.10.2 From dd44eb9e13131f7b1fda65518b24fd3dfcf3a114 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Sun, 28 Aug 2011 08:32:10 -0500 Subject: iwlegacy: change IL_ERR to D_HT in iwl4965_rs_tl_turn_on_agg_for_tid This message should be a debug message and not an error. Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 4bc5a18..93c3a4d 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -371,10 +371,10 @@ il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, struct il_lq_sta *lq_data, IL_ERR("Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } - } else { - IL_ERR("Aggregation not enabled for tid %d " - "because load = %u\n", tid, load); - } + } else + D_HT("Aggregation not enabled for tid %d because load = %u\n", + tid, load); + return ret; } -- cgit v0.10.2 From c63b2d01b1bec83f31259651a0ed2a26104cb7a3 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 15:20:03 +0100 Subject: iwlegacy: remove unused IL_AC_UNSET define Signed-off-by: Stanislaw Gruszka diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 6f5e6a1..ac80a00 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -40,8 +40,6 @@ #include "common.h" #include "4965.h" -#define IL_AC_UNSET -1 - /** * il_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, -- cgit v0.10.2 From c688b8b334d20acbc79b0383af2816ecf7365741 Mon Sep 17 00:00:00 2001 From: Bob Peterson Date: Mon, 14 Nov 2011 10:45:40 -0500 Subject: GFS2: Add non-try locks back to get_local_rgrp This upstream patch had what I believe is an unintended consequence: http://git.kernel.org/?p=linux/kernel/git/steve/gfs2-3.0-nmw.git;a=commitdiff;h=beca42486749c1538a5ed58fe9dcc9f26d428c93 The patch changed function get_local_rgrp such that it ONLY used TRY locks for RGRP searches. Prior to that patch, the code used TRY locks during the first loop, and if that was unsuccessful, it used normal blocking locks on subsequent searches. This patch changes it back to the old way. Signed-off-by: Bob Peterson Signed-off-by: Steven Whitehouse diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 96bd6d75..a1a815b 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -978,7 +978,7 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrpd *rgd, *begin = NULL; struct gfs2_alloc *al = ip->i_alloc; - int error, rg_locked; + int error, rg_locked, flags = LM_FLAG_TRY; int loops = 0; if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, ip->i_goal)) @@ -997,7 +997,7 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) error = 0; } else { error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, - LM_FLAG_TRY, &al->al_rgd_gh); + flags, &al->al_rgd_gh); } switch (error) { case 0: @@ -1012,8 +1012,10 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) /* fall through */ case GLR_TRYFAILED: rgd = gfs2_rgrpd_get_next(rgd); - if (rgd == begin) + if (rgd == begin) { + flags = 0; loops++; + } break; default: return error; -- cgit v0.10.2 From 3c5d785acfda7dffa63477951bb6864c6a49ed2e Mon Sep 17 00:00:00 2001 From: Bob Peterson Date: Mon, 14 Nov 2011 11:17:08 -0500 Subject: GFS2: combine gfs2_alloc_block and gfs2_alloc_di GFS2 functions gfs2_alloc_block and gfs2_alloc_di do basically the same things, with a few exceptions. This patch combines the two functions into a slightly more generic gfs2_alloc_block. Having one centralized block allocation function will reduce code redundancy and make it easier to implement multi-block reservations to reduce file fragmentation in the future. Signed-off-by: Bob Peterson Signed-off-by: Steven Whitehouse diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index f6be14f..b69235b 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -133,7 +133,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) and write it out to disk */ unsigned int n = 1; - error = gfs2_alloc_block(ip, &block, &n); + error = gfs2_alloc_block(ip, &block, &n, 0, NULL); if (error) goto out_brelse; if (isdir) { @@ -503,7 +503,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock, do { int error; n = blks - alloced; - error = gfs2_alloc_block(ip, &bn, &n); + error = gfs2_alloc_block(ip, &bn, &n, 0, NULL); if (error) return error; alloced += n; diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 946b6f8..ae75319 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -823,7 +823,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, struct gfs2_dirent *dent; struct qstr name = { .name = "", .len = 0, .hash = 0 }; - error = gfs2_alloc_block(ip, &bn, &n); + error = gfs2_alloc_block(ip, &bn, &n, 0, NULL); if (error) return NULL; bh = gfs2_meta_new(ip->i_gl, bn); diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 377920d..de2668f 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -402,7 +402,7 @@ static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation) if (error) goto out_ipreserv; - error = gfs2_alloc_di(dip, no_addr, generation); + error = gfs2_alloc_block(dip, no_addr, NULL, 1, generation); gfs2_trans_end(sdp); diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index a1a815b..995f4e6 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1304,19 +1304,24 @@ static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd) * @ip: the inode to allocate the block for * @bn: Used to return the starting block number * @n: requested number of blocks/extent length (value/result) + * dinode: 1 if we're allocating a dinode, 0 if it's a data block + * @generation: the generation number of the inode * * Returns: 0 or error */ -int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n) +int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n, + int dinode, u64 *generation) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; struct gfs2_alloc *al = ip->i_alloc; struct gfs2_rgrpd *rgd; - u32 goal, blk; - u64 block; + u32 goal, blk; /* block, within the rgrp scope */ + u64 block; /* block, within the file system scope */ + unsigned int extn = 1; int error; + unsigned char blk_type = dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED; /* Only happens if there is a bug in gfs2, return something distinctive * to ensure that it is noticed. @@ -1324,14 +1329,16 @@ int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n) if (al == NULL) return -ECANCELED; + if (n == NULL) + n = &extn; rgd = ip->i_rgd; - if (rgrp_contains_block(rgd, ip->i_goal)) + if (!dinode && rgrp_contains_block(rgd, ip->i_goal)) goal = ip->i_goal - rgd->rd_data0; else goal = rgd->rd_last_alloc; - blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED, n); + blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, blk_type, n); /* Since all blocks are reserved in advance, this shouldn't happen */ if (blk == BFITNOENT) @@ -1339,82 +1346,43 @@ int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n) rgd->rd_last_alloc = blk; block = rgd->rd_data0 + blk; - ip->i_goal = block + *n - 1; - error = gfs2_meta_inode_buffer(ip, &dibh); - if (error == 0) { - struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data; - gfs2_trans_add_bh(ip->i_gl, dibh, 1); - di->di_goal_meta = di->di_goal_data = cpu_to_be64(ip->i_goal); - brelse(dibh); + if (!dinode) { + ip->i_goal = block + *n - 1; + error = gfs2_meta_inode_buffer(ip, &dibh); + if (error == 0) { + struct gfs2_dinode *di = + (struct gfs2_dinode *)dibh->b_data; + gfs2_trans_add_bh(ip->i_gl, dibh, 1); + di->di_goal_meta = di->di_goal_data = + cpu_to_be64(ip->i_goal); + brelse(dibh); + } } if (rgd->rd_free < *n) goto rgrp_error; rgd->rd_free -= *n; + if (dinode) { + rgd->rd_dinodes++; + *generation = rgd->rd_igeneration++; + if (*generation == 0) + *generation = rgd->rd_igeneration++; + } gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); al->al_alloced += *n; - gfs2_statfs_change(sdp, 0, -(s64)*n, 0); - gfs2_quota_change(ip, *n, ip->i_inode.i_uid, ip->i_inode.i_gid); + gfs2_statfs_change(sdp, 0, -(s64)*n, dinode ? 1 : 0); + if (dinode) + gfs2_trans_add_unrevoke(sdp, block, 1); + else + gfs2_quota_change(ip, *n, ip->i_inode.i_uid, + ip->i_inode.i_gid); rgd->rd_free_clone -= *n; - trace_gfs2_block_alloc(ip, block, *n, GFS2_BLKST_USED); - *bn = block; - return 0; - -rgrp_error: - gfs2_rgrp_error(rgd); - return -EIO; -} - -/** - * gfs2_alloc_di - Allocate a dinode - * @dip: the directory that the inode is going in - * @bn: the block number which is allocated - * @generation: the generation number of the inode - * - * Returns: 0 on success or error - */ - -int gfs2_alloc_di(struct gfs2_inode *dip, u64 *bn, u64 *generation) -{ - struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); - struct gfs2_alloc *al = dip->i_alloc; - struct gfs2_rgrpd *rgd = dip->i_rgd; - u32 blk; - u64 block; - unsigned int n = 1; - - blk = rgblk_search(rgd, rgd->rd_last_alloc, - GFS2_BLKST_FREE, GFS2_BLKST_DINODE, &n); - - /* Since all blocks are reserved in advance, this shouldn't happen */ - if (blk == BFITNOENT) - goto rgrp_error; - - rgd->rd_last_alloc = blk; - block = rgd->rd_data0 + blk; - if (rgd->rd_free == 0) - goto rgrp_error; - - rgd->rd_free--; - rgd->rd_dinodes++; - *generation = rgd->rd_igeneration++; - if (*generation == 0) - *generation = rgd->rd_igeneration++; - gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); - gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); - - al->al_alloced++; - - gfs2_statfs_change(sdp, 0, -1, +1); - gfs2_trans_add_unrevoke(sdp, block, 1); - - rgd->rd_free_clone--; - trace_gfs2_block_alloc(dip, block, 1, GFS2_BLKST_DINODE); + trace_gfs2_block_alloc(ip, block, *n, blk_type); *bn = block; return 0; diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index cf5c501..4cb5608 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h @@ -39,8 +39,8 @@ static inline void gfs2_alloc_put(struct gfs2_inode *ip) extern int gfs2_inplace_reserve(struct gfs2_inode *ip); extern void gfs2_inplace_release(struct gfs2_inode *ip); -extern int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n); -extern int gfs2_alloc_di(struct gfs2_inode *ip, u64 *bn, u64 *generation); +extern int gfs2_alloc_block(struct gfs2_inode *ip, u64 *bn, unsigned int *n, + int dinode, u64 *generation); extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta); extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen); diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index a201a1d..e4794a5 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c @@ -610,7 +610,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp) u64 block; int error; - error = gfs2_alloc_block(ip, &block, &n); + error = gfs2_alloc_block(ip, &block, &n, 0, NULL); if (error) return error; gfs2_trans_add_unrevoke(sdp, block, 1); @@ -672,7 +672,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, int mh_size = sizeof(struct gfs2_meta_header); unsigned int n = 1; - error = gfs2_alloc_block(ip, &block, &n); + error = gfs2_alloc_block(ip, &block, &n, 0, NULL); if (error) return error; gfs2_trans_add_unrevoke(sdp, block, 1); @@ -992,7 +992,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, } else { u64 blk; unsigned int n = 1; - error = gfs2_alloc_block(ip, &blk, &n); + error = gfs2_alloc_block(ip, &blk, &n, 0, NULL); if (error) return error; gfs2_trans_add_unrevoke(sdp, blk, 1); -- cgit v0.10.2 From db0d4db22a78d31c59087f7057b8f1612fecc35d Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Sat, 12 Nov 2011 16:09:49 +0000 Subject: ARM: gic: allow GIC to support non-banked setups The GIC support code is heavily using the fact that hardware implementations are exposing banked registers. Unfortunately, it looks like at least one GIC implementation (EXYNOS) offers both the distributor and the CPU interfaces at different addresses, depending on the CPU. This problem is solved by allowing the distributor and CPU interface addresses to be per-cpu variables for the platforms that require it. The EXYNOS code is updated not to mess with the GIC internals while handling interrupts, and struct gic_chip_data is back to being private. The DT binding for the gic is updated to allow an optional "cpu-offset" value, which is used to compute the various base addresses. Finally, a new config option (GIC_NON_BANKED) is used to control this feature, so the overhead is only present on kernels compiled with support for EXYNOS. Tested on Origen (EXYNOS4) and Panda (OMAP4). Cc: Kukjin Kim Cc: Will Deacon Cc: Thomas Abraham Acked-by: Rob Herring Signed-off-by: Marc Zyngier diff --git a/Documentation/devicetree/bindings/arm/gic.txt b/Documentation/devicetree/bindings/arm/gic.txt index 52916b4..9b4b82a 100644 --- a/Documentation/devicetree/bindings/arm/gic.txt +++ b/Documentation/devicetree/bindings/arm/gic.txt @@ -42,6 +42,10 @@ Optional - interrupts : Interrupt source of the parent interrupt controller. Only present on secondary GICs. +- cpu-offset : per-cpu offset within the distributor and cpu interface + regions, used when the GIC doesn't have banked registers. The offset is + cpu-offset * cpu-nr. + Example: intc: interrupt-controller@fff11000 { diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig index 74df9ca..a3beda1 100644 --- a/arch/arm/common/Kconfig +++ b/arch/arm/common/Kconfig @@ -2,6 +2,9 @@ config ARM_GIC select IRQ_DOMAIN bool +config GIC_NON_BANKED + bool + config ARM_VIC bool diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c index 0e6ae47..43cb6f1 100644 --- a/arch/arm/common/gic.c +++ b/arch/arm/common/gic.c @@ -43,6 +43,31 @@ #include #include +union gic_base { + void __iomem *common_base; + void __percpu __iomem **percpu_base; +}; + +struct gic_chip_data { + unsigned int irq_offset; + union gic_base dist_base; + union gic_base cpu_base; +#ifdef CONFIG_CPU_PM + u32 saved_spi_enable[DIV_ROUND_UP(1020, 32)]; + u32 saved_spi_conf[DIV_ROUND_UP(1020, 16)]; + u32 saved_spi_target[DIV_ROUND_UP(1020, 4)]; + u32 __percpu *saved_ppi_enable; + u32 __percpu *saved_ppi_conf; +#endif +#ifdef CONFIG_IRQ_DOMAIN + struct irq_domain domain; +#endif + unsigned int gic_irqs; +#ifdef CONFIG_GIC_NON_BANKED + void __iomem *(*get_base)(union gic_base *); +#endif +}; + static DEFINE_RAW_SPINLOCK(irq_controller_lock); /* Address of GIC 0 CPU interface */ @@ -67,16 +92,48 @@ struct irq_chip gic_arch_extn = { static struct gic_chip_data gic_data[MAX_GIC_NR] __read_mostly; +#ifdef CONFIG_GIC_NON_BANKED +static void __iomem *gic_get_percpu_base(union gic_base *base) +{ + return *__this_cpu_ptr(base->percpu_base); +} + +static void __iomem *gic_get_common_base(union gic_base *base) +{ + return base->common_base; +} + +static inline void __iomem *gic_data_dist_base(struct gic_chip_data *data) +{ + return data->get_base(&data->dist_base); +} + +static inline void __iomem *gic_data_cpu_base(struct gic_chip_data *data) +{ + return data->get_base(&data->cpu_base); +} + +static inline void gic_set_base_accessor(struct gic_chip_data *data, + void __iomem *(*f)(union gic_base *)) +{ + data->get_base = f; +} +#else +#define gic_data_dist_base(d) ((d)->dist_base.common_base) +#define gic_data_cpu_base(d) ((d)->cpu_base.common_base) +#define gic_set_base_accessor(d,f) +#endif + static inline void __iomem *gic_dist_base(struct irq_data *d) { struct gic_chip_data *gic_data = irq_data_get_irq_chip_data(d); - return gic_data->dist_base; + return gic_data_dist_base(gic_data); } static inline void __iomem *gic_cpu_base(struct irq_data *d) { struct gic_chip_data *gic_data = irq_data_get_irq_chip_data(d); - return gic_data->cpu_base; + return gic_data_cpu_base(gic_data); } static inline unsigned int gic_irq(struct irq_data *d) @@ -225,7 +282,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc) chained_irq_enter(chip, desc); raw_spin_lock(&irq_controller_lock); - status = readl_relaxed(chip_data->cpu_base + GIC_CPU_INTACK); + status = readl_relaxed(gic_data_cpu_base(chip_data) + GIC_CPU_INTACK); raw_spin_unlock(&irq_controller_lock); gic_irq = (status & 0x3ff); @@ -270,7 +327,7 @@ static void __init gic_dist_init(struct gic_chip_data *gic) u32 cpumask; unsigned int gic_irqs = gic->gic_irqs; struct irq_domain *domain = &gic->domain; - void __iomem *base = gic->dist_base; + void __iomem *base = gic_data_dist_base(gic); u32 cpu = 0; #ifdef CONFIG_SMP @@ -330,8 +387,8 @@ static void __init gic_dist_init(struct gic_chip_data *gic) static void __cpuinit gic_cpu_init(struct gic_chip_data *gic) { - void __iomem *dist_base = gic->dist_base; - void __iomem *base = gic->cpu_base; + void __iomem *dist_base = gic_data_dist_base(gic); + void __iomem *base = gic_data_cpu_base(gic); int i; /* @@ -368,7 +425,7 @@ static void gic_dist_save(unsigned int gic_nr) BUG(); gic_irqs = gic_data[gic_nr].gic_irqs; - dist_base = gic_data[gic_nr].dist_base; + dist_base = gic_data_dist_base(&gic_data[gic_nr]); if (!dist_base) return; @@ -403,7 +460,7 @@ static void gic_dist_restore(unsigned int gic_nr) BUG(); gic_irqs = gic_data[gic_nr].gic_irqs; - dist_base = gic_data[gic_nr].dist_base; + dist_base = gic_data_dist_base(&gic_data[gic_nr]); if (!dist_base) return; @@ -439,8 +496,8 @@ static void gic_cpu_save(unsigned int gic_nr) if (gic_nr >= MAX_GIC_NR) BUG(); - dist_base = gic_data[gic_nr].dist_base; - cpu_base = gic_data[gic_nr].cpu_base; + dist_base = gic_data_dist_base(&gic_data[gic_nr]); + cpu_base = gic_data_cpu_base(&gic_data[gic_nr]); if (!dist_base || !cpu_base) return; @@ -465,8 +522,8 @@ static void gic_cpu_restore(unsigned int gic_nr) if (gic_nr >= MAX_GIC_NR) BUG(); - dist_base = gic_data[gic_nr].dist_base; - cpu_base = gic_data[gic_nr].cpu_base; + dist_base = gic_data_dist_base(&gic_data[gic_nr]); + cpu_base = gic_data_cpu_base(&gic_data[gic_nr]); if (!dist_base || !cpu_base) return; @@ -491,6 +548,11 @@ static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v) int i; for (i = 0; i < MAX_GIC_NR; i++) { +#ifdef CONFIG_GIC_NON_BANKED + /* Skip over unused GICs */ + if (!gic_data[i].get_base) + continue; +#endif switch (cmd) { case CPU_PM_ENTER: gic_cpu_save(i); @@ -563,8 +625,9 @@ const struct irq_domain_ops gic_irq_domain_ops = { #endif }; -void __init gic_init(unsigned int gic_nr, int irq_start, - void __iomem *dist_base, void __iomem *cpu_base) +void __init gic_init_bases(unsigned int gic_nr, int irq_start, + void __iomem *dist_base, void __iomem *cpu_base, + u32 percpu_offset) { struct gic_chip_data *gic; struct irq_domain *domain; @@ -574,8 +637,36 @@ void __init gic_init(unsigned int gic_nr, int irq_start, gic = &gic_data[gic_nr]; domain = &gic->domain; - gic->dist_base = dist_base; - gic->cpu_base = cpu_base; +#ifdef CONFIG_GIC_NON_BANKED + if (percpu_offset) { /* Frankein-GIC without banked registers... */ + unsigned int cpu; + + gic->dist_base.percpu_base = alloc_percpu(void __iomem *); + gic->cpu_base.percpu_base = alloc_percpu(void __iomem *); + if (WARN_ON(!gic->dist_base.percpu_base || + !gic->cpu_base.percpu_base)) { + free_percpu(gic->dist_base.percpu_base); + free_percpu(gic->cpu_base.percpu_base); + return; + } + + for_each_possible_cpu(cpu) { + unsigned long offset = percpu_offset * cpu_logical_map(cpu); + *per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset; + *per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset; + } + + gic_set_base_accessor(gic, gic_get_percpu_base); + } else +#endif + { /* Normal, sane GIC... */ + WARN(percpu_offset, + "GIC_NON_BANKED not enabled, ignoring %08x offset!", + percpu_offset); + gic->dist_base.common_base = dist_base; + gic->cpu_base.common_base = cpu_base; + gic_set_base_accessor(gic, gic_get_common_base); + } /* * For primary GICs, skip over SGIs. @@ -593,7 +684,7 @@ void __init gic_init(unsigned int gic_nr, int irq_start, * Find out how many interrupts are supported. * The GIC only supports up to 1020 interrupt sources. */ - gic_irqs = readl_relaxed(dist_base + GIC_DIST_CTR) & 0x1f; + gic_irqs = readl_relaxed(gic_data_dist_base(gic) + GIC_DIST_CTR) & 0x1f; gic_irqs = (gic_irqs + 1) * 32; if (gic_irqs > 1020) gic_irqs = 1020; @@ -641,7 +732,7 @@ void gic_raise_softirq(const struct cpumask *mask, unsigned int irq) dsb(); /* this always happens on GIC0 */ - writel_relaxed(map << 16 | irq, gic_data[0].dist_base + GIC_DIST_SOFTINT); + writel_relaxed(map << 16 | irq, gic_data_dist_base(&gic_data[0]) + GIC_DIST_SOFTINT); } #endif @@ -652,6 +743,7 @@ int __init gic_of_init(struct device_node *node, struct device_node *parent) { void __iomem *cpu_base; void __iomem *dist_base; + u32 percpu_offset; int irq; struct irq_domain *domain = &gic_data[gic_cnt].domain; @@ -664,9 +756,12 @@ int __init gic_of_init(struct device_node *node, struct device_node *parent) cpu_base = of_iomap(node, 1); WARN(!cpu_base, "unable to map gic cpu registers\n"); + if (of_property_read_u32(node, "cpu-offset", &percpu_offset)) + percpu_offset = 0; + domain->of_node = of_node_get(node); - gic_init(gic_cnt, -1, dist_base, cpu_base); + gic_init_bases(gic_cnt, -1, dist_base, cpu_base, percpu_offset); if (parent) { irq = irq_of_parse_and_map(node, 0); diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h index 3e91f22..2721d90 100644 --- a/arch/arm/include/asm/hardware/gic.h +++ b/arch/arm/include/asm/hardware/gic.h @@ -39,27 +39,19 @@ struct device_node; extern void __iomem *gic_cpu_base_addr; extern struct irq_chip gic_arch_extn; -void gic_init(unsigned int, int, void __iomem *, void __iomem *); +void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *, + u32 offset); int gic_of_init(struct device_node *node, struct device_node *parent); void gic_secondary_init(unsigned int); void gic_cascade_irq(unsigned int gic_nr, unsigned int irq); void gic_raise_softirq(const struct cpumask *mask, unsigned int irq); -struct gic_chip_data { - void __iomem *dist_base; - void __iomem *cpu_base; -#ifdef CONFIG_CPU_PM - u32 saved_spi_enable[DIV_ROUND_UP(1020, 32)]; - u32 saved_spi_conf[DIV_ROUND_UP(1020, 16)]; - u32 saved_spi_target[DIV_ROUND_UP(1020, 4)]; - u32 __percpu *saved_ppi_enable; - u32 __percpu *saved_ppi_conf; -#endif -#ifdef CONFIG_IRQ_DOMAIN - struct irq_domain domain; -#endif - unsigned int gic_irqs; -}; +static inline void gic_init(unsigned int nr, int start, + void __iomem *dist , void __iomem *cpu) +{ + gic_init_bases(nr, start, dist, cpu, 0); +} + #endif #endif diff --git a/arch/arm/mach-exynos/cpu.c b/arch/arm/mach-exynos/cpu.c index 90ec247..e92e464 100644 --- a/arch/arm/mach-exynos/cpu.c +++ b/arch/arm/mach-exynos/cpu.c @@ -207,27 +207,13 @@ void __init exynos4_init_clocks(int xtal) exynos4_setup_clocks(); } -static void exynos4_gic_irq_fix_base(struct irq_data *d) -{ - struct gic_chip_data *gic_data = irq_data_get_irq_chip_data(d); - - gic_data->cpu_base = S5P_VA_GIC_CPU + - (gic_bank_offset * smp_processor_id()); - - gic_data->dist_base = S5P_VA_GIC_DIST + - (gic_bank_offset * smp_processor_id()); -} - void __init exynos4_init_irq(void) { int irq; gic_bank_offset = soc_is_exynos4412() ? 0x4000 : 0x8000; - gic_init(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU); - gic_arch_extn.irq_eoi = exynos4_gic_irq_fix_base; - gic_arch_extn.irq_unmask = exynos4_gic_irq_fix_base; - gic_arch_extn.irq_mask = exynos4_gic_irq_fix_base; + gic_init_bases(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU, gic_bank_offset); for (irq = 0; irq < MAX_COMBINER_NR; irq++) { diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c index 69ffb2f..60bc45e 100644 --- a/arch/arm/mach-exynos/platsmp.c +++ b/arch/arm/mach-exynos/platsmp.c @@ -32,7 +32,6 @@ #include -extern unsigned int gic_bank_offset; extern void exynos4_secondary_startup(void); #define CPU1_BOOT_REG (samsung_rev() == EXYNOS4210_REV_1_1 ? \ @@ -65,31 +64,6 @@ static void __iomem *scu_base_addr(void) static DEFINE_SPINLOCK(boot_lock); -static void __cpuinit exynos4_gic_secondary_init(void) -{ - void __iomem *dist_base = S5P_VA_GIC_DIST + - (gic_bank_offset * smp_processor_id()); - void __iomem *cpu_base = S5P_VA_GIC_CPU + - (gic_bank_offset * smp_processor_id()); - int i; - - /* - * Deal with the banked PPI and SGI interrupts - disable all - * PPI interrupts, ensure all SGI interrupts are enabled. - */ - __raw_writel(0xffff0000, dist_base + GIC_DIST_ENABLE_CLEAR); - __raw_writel(0x0000ffff, dist_base + GIC_DIST_ENABLE_SET); - - /* - * Set priority on PPI and SGI interrupts - */ - for (i = 0; i < 32; i += 4) - __raw_writel(0xa0a0a0a0, dist_base + GIC_DIST_PRI + i * 4 / 4); - - __raw_writel(0xf0, cpu_base + GIC_CPU_PRIMASK); - __raw_writel(1, cpu_base + GIC_CPU_CTRL); -} - void __cpuinit platform_secondary_init(unsigned int cpu) { /* @@ -97,7 +71,7 @@ void __cpuinit platform_secondary_init(unsigned int cpu) * core (e.g. timer irq), then they will not have been enabled * for us: do so */ - exynos4_gic_secondary_init(); + gic_secondary_init(0); /* * let the primary processor know we're out of the diff --git a/arch/arm/plat-s5p/Kconfig b/arch/arm/plat-s5p/Kconfig index 9b9968f..8167ce6 100644 --- a/arch/arm/plat-s5p/Kconfig +++ b/arch/arm/plat-s5p/Kconfig @@ -11,6 +11,7 @@ config PLAT_S5P default y select ARM_VIC if !ARCH_EXYNOS4 select ARM_GIC if ARCH_EXYNOS4 + select GIC_NON_BANKED if ARCH_EXYNOS4 select NO_IOPORT select ARCH_REQUIRE_GPIOLIB select S3C_GPIO_TRACK -- cgit v0.10.2 From abeb24ae4d3e543ecf0104cff08a3af4e7a42479 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Sep 2011 09:23:26 +0100 Subject: ARM: Make global handler and CONFIG_MULTI_IRQ_HANDLER mutually exclusive Even when CONFIG_MULTI_IRQ_HANDLER is selected, the core code requires the arch_irq_handler_default macro to be defined as a fallback. It turns out nobody is using that particular feature as both PXA and shmobile have all their machine descriptors populated with the interrupt handler, leaving unused code (or empty macros) in their entry-macro.S file just to be able to compile entry-armv.S. Make CONFIG_MULTI_IRQ_HANDLER exclusive wrt arch_irq_handler_default, which allows to remove one test from the hot path. Also cleanup both PXA and shmobile entry-macro.S. Cc: Paul Mundt Acked-by: Nicolas Pitre Acked-by: Eric Miao Tested-by: Jamie Iles Signed-off-by: Marc Zyngier diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 9ad50c4..bd49a6a 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -36,12 +36,11 @@ #ifdef CONFIG_MULTI_IRQ_HANDLER ldr r1, =handle_arch_irq mov r0, sp - ldr r1, [r1] adr lr, BSYM(9997f) - teq r1, #0 - movne pc, r1 -#endif + ldr pc, [r1] +#else arch_irq_handler_default +#endif 9997: .endm diff --git a/arch/arm/mach-pxa/include/mach/entry-macro.S b/arch/arm/mach-pxa/include/mach/entry-macro.S index a73bc86..260c0c1 100644 --- a/arch/arm/mach-pxa/include/mach/entry-macro.S +++ b/arch/arm/mach-pxa/include/mach/entry-macro.S @@ -7,45 +7,9 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ -#include -#include .macro disable_fiq .endm - .macro get_irqnr_preamble, base, tmp - .endm - .macro arch_ret_to_user, tmp1, tmp2 .endm - - .macro get_irqnr_and_base, irqnr, irqstat, base, tmp - mrc p15, 0, \tmp, c0, c0, 0 @ CPUID - mov \tmp, \tmp, lsr #13 - and \tmp, \tmp, #0x7 @ Core G - cmp \tmp, #1 - bhi 1002f - - @ Core Generation 1 (PXA25x) - mov \base, #io_p2v(0x40000000) @ IIR Ctl = 0x40d00000 - add \base, \base, #0x00d00000 - ldr \irqstat, [\base, #0] @ ICIP - ldr \irqnr, [\base, #4] @ ICMR - - ands \irqnr, \irqstat, \irqnr - beq 1001f - rsb \irqstat, \irqnr, #0 - and \irqstat, \irqstat, \irqnr - clz \irqnr, \irqstat - rsb \irqnr, \irqnr, #(31 + PXA_IRQ(0)) - b 1001f -1002: - @ Core Generation 2 (PXA27x) or Core Generation 3 (PXA3xx) - mrc p6, 0, \irqstat, c5, c0, 0 @ ICHP - tst \irqstat, #0x80000000 - beq 1001f - bic \irqstat, \irqstat, #0x80000000 - mov \irqnr, \irqstat, lsr #16 - add \irqnr, \irqnr, #(PXA_IRQ(0)) -1001: - .endm diff --git a/arch/arm/mach-shmobile/include/mach/entry-macro.S b/arch/arm/mach-shmobile/include/mach/entry-macro.S index 8d4a416..2a57b29 100644 --- a/arch/arm/mach-shmobile/include/mach/entry-macro.S +++ b/arch/arm/mach-shmobile/include/mach/entry-macro.S @@ -18,14 +18,5 @@ .macro disable_fiq .endm - .macro get_irqnr_preamble, base, tmp - .endm - - .macro get_irqnr_and_base, irqnr, irqstat, base, tmp - .endm - - .macro test_for_ipi, irqnr, irqstat, base, tmp - .endm - .macro arch_ret_to_user, tmp1, tmp2 .endm -- cgit v0.10.2 From baeeb8229cace91c10c856d91e5ca861d3c44968 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Wed, 2 Nov 2011 15:28:49 +0000 Subject: ARM: mxc: rename gic_handle_irq to avoid name clash Before introducing a global gic_handle_irq(), rename MXC's version to mxc_gic_handle_irq(). This function will be removed altogether in a later patch. Cc: Sascha Hauer Acked-by: Shawn Guo Signed-off-by: Marc Zyngier diff --git a/arch/arm/plat-mxc/gic.c b/arch/arm/plat-mxc/gic.c index 12f8f81..ea51ea4 100644 --- a/arch/arm/plat-mxc/gic.c +++ b/arch/arm/plat-mxc/gic.c @@ -18,7 +18,7 @@ #include #endif -asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) +asmlinkage void __exception_irq_entry mxc_gic_handle_irq(struct pt_regs *regs) { u32 irqstat, irqnr; diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h index 83b745a..d7c290d 100644 --- a/arch/arm/plat-mxc/include/mach/common.h +++ b/arch/arm/plat-mxc/include/mach/common.h @@ -90,7 +90,7 @@ extern void imx_print_silicon_rev(const char *cpu, int srev); void avic_handle_irq(struct pt_regs *); void tzic_handle_irq(struct pt_regs *); -void gic_handle_irq(struct pt_regs *); +void mxc_gic_handle_irq(struct pt_regs *); #define imx1_handle_irq avic_handle_irq #define imx21_handle_irq avic_handle_irq @@ -101,7 +101,7 @@ void gic_handle_irq(struct pt_regs *); #define imx50_handle_irq tzic_handle_irq #define imx51_handle_irq tzic_handle_irq #define imx53_handle_irq tzic_handle_irq -#define imx6q_handle_irq gic_handle_irq +#define imx6q_handle_irq mxc_gic_handle_irq extern void imx_enable_cpu(int cpu, bool enable); extern void imx_set_cpu_jump(int cpu, void *jump_addr); -- cgit v0.10.2 From 562e0027d21bf64838178e2f5157df3d5833972e Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Sep 2011 09:56:17 +0100 Subject: ARM: GIC: Add global gic_handle_irq() function Provide the GIC code with a low level handler that can be used by platforms using CONFIG_MULTI_IRQ_HANDLER. Signed-off-by: Marc Zyngier diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c index 43cb6f1..3c78b7c 100644 --- a/arch/arm/common/gic.c +++ b/arch/arm/common/gic.c @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -272,6 +273,32 @@ static int gic_set_wake(struct irq_data *d, unsigned int on) #define gic_set_wake NULL #endif +asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) +{ + u32 irqstat, irqnr; + struct gic_chip_data *gic = &gic_data[0]; + void __iomem *cpu_base = gic_data_cpu_base(gic); + + do { + irqstat = readl_relaxed(cpu_base + GIC_CPU_INTACK); + irqnr = irqstat & ~0x1c00; + + if (likely(irqnr > 15 && irqnr < 1021)) { + irqnr = irq_domain_to_irq(&gic->domain, irqnr); + handle_IRQ(irqnr, regs); + continue; + } + if (irqnr < 16) { + writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); +#ifdef CONFIG_SMP + handle_IPI(irqnr, regs); +#endif + continue; + } + break; + } while (1); +} + static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc) { struct gic_chip_data *chip_data = irq_get_handler_data(irq); diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h index 2721d90..ecf7c02 100644 --- a/arch/arm/include/asm/hardware/gic.h +++ b/arch/arm/include/asm/hardware/gic.h @@ -43,6 +43,7 @@ void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *, u32 offset); int gic_of_init(struct device_node *node, struct device_node *parent); void gic_secondary_init(unsigned int); +void gic_handle_irq(struct pt_regs *regs); void gic_cascade_irq(unsigned int gic_nr, unsigned int irq); void gic_raise_softirq(const struct cpumask *mask, unsigned int irq); -- cgit v0.10.2 From fea9fe8329c74159fb2030f1aacf29fdab9fc6d6 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Sep 2011 10:23:45 +0100 Subject: ARM: imx: convert smp platforms to global gic_handle_irq() Convert the SMP imx platforms to use the global gic_handle_irq() function instead a private function. Cc: Sascha Hauer Acked-by: Shawn Guo Signed-off-by: Marc Zyngier diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile index b9f0f5f..076db84f 100644 --- a/arch/arm/plat-mxc/Makefile +++ b/arch/arm/plat-mxc/Makefile @@ -5,7 +5,6 @@ # Common support obj-y := clock.o time.o devices.o cpu.o system.o irq-common.o -obj-$(CONFIG_ARM_GIC) += gic.o obj-$(CONFIG_MXC_TZIC) += tzic.o obj-$(CONFIG_MXC_AVIC) += avic.o diff --git a/arch/arm/plat-mxc/gic.c b/arch/arm/plat-mxc/gic.c deleted file mode 100644 index ea51ea4..0000000 --- a/arch/arm/plat-mxc/gic.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2011 Freescale Semiconductor, Inc. - * Copyright 2011 Linaro Ltd. - * - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include -#include -#include -#include -#ifdef CONFIG_SMP -#include -#endif - -asmlinkage void __exception_irq_entry mxc_gic_handle_irq(struct pt_regs *regs) -{ - u32 irqstat, irqnr; - - do { - irqstat = readl_relaxed(gic_cpu_base_addr + GIC_CPU_INTACK); - irqnr = irqstat & 0x3ff; - if (irqnr == 1023) - break; - - if (irqnr > 15 && irqnr < 1021) - handle_IRQ(irqnr, regs); -#ifdef CONFIG_SMP - else { - writel_relaxed(irqstat, gic_cpu_base_addr + - GIC_CPU_EOI); - handle_IPI(irqnr, regs); - } -#endif - } while (1); -} diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h index d7c290d..14b4703 100644 --- a/arch/arm/plat-mxc/include/mach/common.h +++ b/arch/arm/plat-mxc/include/mach/common.h @@ -90,7 +90,6 @@ extern void imx_print_silicon_rev(const char *cpu, int srev); void avic_handle_irq(struct pt_regs *); void tzic_handle_irq(struct pt_regs *); -void mxc_gic_handle_irq(struct pt_regs *); #define imx1_handle_irq avic_handle_irq #define imx21_handle_irq avic_handle_irq @@ -101,7 +100,7 @@ void mxc_gic_handle_irq(struct pt_regs *); #define imx50_handle_irq tzic_handle_irq #define imx51_handle_irq tzic_handle_irq #define imx53_handle_irq tzic_handle_irq -#define imx6q_handle_irq mxc_gic_handle_irq +#define imx6q_handle_irq gic_handle_irq extern void imx_enable_cpu(int cpu, bool enable); extern void imx_set_cpu_jump(int cpu, void *jump_addr); diff --git a/arch/arm/plat-mxc/include/mach/entry-macro.S b/arch/arm/plat-mxc/include/mach/entry-macro.S index ca5cf26..def5d30 100644 --- a/arch/arm/plat-mxc/include/mach/entry-macro.S +++ b/arch/arm/plat-mxc/include/mach/entry-macro.S @@ -9,19 +9,8 @@ * published by the Free Software Foundation. */ -/* Unused, we use CONFIG_MULTI_IRQ_HANDLER */ - .macro disable_fiq .endm - .macro get_irqnr_preamble, base, tmp - .endm - .macro arch_ret_to_user, tmp1, tmp2 .endm - - .macro get_irqnr_and_base, irqnr, irqstat, base, tmp - .endm - - .macro test_for_ipi, irqnr, irqstat, base, tmp - .endm -- cgit v0.10.2 From 7e01799c669c60460dce43556065ca3b66760dcf Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Sep 2011 10:23:45 +0100 Subject: ARM: highbank: convert to CONFIG_MULTI_IRQ_HANDLER Convert the highbank platform to be using the gic_handle_irq function as its primary interrupt handler. Cc: Rob Herring Signed-off-by: Marc Zyngier diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 44789ef..5c014c6 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -345,6 +345,7 @@ config ARCH_HIGHBANK select GENERIC_CLOCKEVENTS select HAVE_ARM_SCU select USE_OF + select MULTI_IRQ_HANDLER help Support for the Calxeda Highbank SoC based boards. diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c index b82dcf0..89bdf00 100644 --- a/arch/arm/mach-highbank/highbank.c +++ b/arch/arm/mach-highbank/highbank.c @@ -140,6 +140,7 @@ DT_MACHINE_START(HIGHBANK, "Highbank") .map_io = highbank_map_io, .init_irq = highbank_init_irq, .timer = &highbank_timer, + .handle_irq = gic_handle_irq, .init_machine = highbank_init, .dt_compat = highbank_match, MACHINE_END diff --git a/arch/arm/mach-highbank/include/mach/entry-macro.S b/arch/arm/mach-highbank/include/mach/entry-macro.S index 73c1129..a14f9e6 100644 --- a/arch/arm/mach-highbank/include/mach/entry-macro.S +++ b/arch/arm/mach-highbank/include/mach/entry-macro.S @@ -1,5 +1,3 @@ -#include - .macro disable_fiq .endm -- cgit v0.10.2 From 1b99d9ccb52d64bfdab0d58915909b10cbbdf9e1 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Sep 2011 10:23:45 +0100 Subject: ARM: RealView: convert to CONFIG_MULTI_IRQ_HANDLER Convert the RealView platforms to be using the gic_handle_irq function as their primary interrupt handler. Signed-off-by: Marc Zyngier diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5c014c6..5f3b7fe 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -278,6 +278,7 @@ config ARCH_REALVIEW select ARM_TIMER_SP804 select GPIO_PL061 if GPIOLIB select NEED_MACH_MEMORY_H + select MULTI_IRQ_HANDLER help This enables support for ARM Ltd RealView boards. diff --git a/arch/arm/mach-realview/include/mach/entry-macro.S b/arch/arm/mach-realview/include/mach/entry-macro.S index 4071164..e8a5179 100644 --- a/arch/arm/mach-realview/include/mach/entry-macro.S +++ b/arch/arm/mach-realview/include/mach/entry-macro.S @@ -7,8 +7,6 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ -#include -#include .macro disable_fiq .endm diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c index 026c66a..10ef2e7 100644 --- a/arch/arm/mach-realview/realview_eb.c +++ b/arch/arm/mach-realview/realview_eb.c @@ -469,6 +469,7 @@ MACHINE_START(REALVIEW_EB, "ARM-RealView EB") .init_early = realview_init_early, .init_irq = gic_init_irq, .timer = &realview_eb_timer, + .handle_irq = gic_handle_irq, .init_machine = realview_eb_init, #ifdef CONFIG_ZONE_DMA .dma_zone_size = SZ_256M, diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c index c057540..bd8fec8 100644 --- a/arch/arm/mach-realview/realview_pb1176.c +++ b/arch/arm/mach-realview/realview_pb1176.c @@ -392,6 +392,7 @@ MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176") .init_early = realview_init_early, .init_irq = gic_init_irq, .timer = &realview_pb1176_timer, + .handle_irq = gic_handle_irq, .init_machine = realview_pb1176_init, #ifdef CONFIG_ZONE_DMA .dma_zone_size = SZ_256M, diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c index 671ad6d..fa73ba8 100644 --- a/arch/arm/mach-realview/realview_pb11mp.c +++ b/arch/arm/mach-realview/realview_pb11mp.c @@ -366,6 +366,7 @@ MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore") .init_early = realview_init_early, .init_irq = gic_init_irq, .timer = &realview_pb11mp_timer, + .handle_irq = gic_handle_irq, .init_machine = realview_pb11mp_init, #ifdef CONFIG_ZONE_DMA .dma_zone_size = SZ_256M, diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c index cbf22df..6e5f2b9 100644 --- a/arch/arm/mach-realview/realview_pba8.c +++ b/arch/arm/mach-realview/realview_pba8.c @@ -316,6 +316,7 @@ MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8") .init_early = realview_init_early, .init_irq = gic_init_irq, .timer = &realview_pba8_timer, + .handle_irq = gic_handle_irq, .init_machine = realview_pba8_init, #ifdef CONFIG_ZONE_DMA .dma_zone_size = SZ_256M, diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c index 63c4114..291bf1a 100644 --- a/arch/arm/mach-realview/realview_pbx.c +++ b/arch/arm/mach-realview/realview_pbx.c @@ -399,6 +399,7 @@ MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX") .init_early = realview_init_early, .init_irq = gic_init_irq, .timer = &realview_pbx_timer, + .handle_irq = gic_handle_irq, .init_machine = realview_pbx_init, #ifdef CONFIG_ZONE_DMA .dma_zone_size = SZ_256M, -- cgit v0.10.2 From abd3ca51fba8bc200ae78e99bd1ac19c4e3b6781 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Sep 2011 10:23:45 +0100 Subject: ARM: VExpress: convert to CONFIG_MULTI_IRQ_HANDLER Convert the VExpress platform to be using the gic_handle_irq function as its primary interrupt handler. Signed-off-by: Marc Zyngier diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5f3b7fe..8f39263 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -311,6 +311,7 @@ config ARCH_VEXPRESS select ICST select PLAT_VERSATILE select PLAT_VERSATILE_CLCD + select MULTI_IRQ_HANDLER help This enables support for the ARM Ltd Versatile Express boards. diff --git a/arch/arm/mach-vexpress/include/mach/entry-macro.S b/arch/arm/mach-vexpress/include/mach/entry-macro.S index 73c1129..a14f9e6 100644 --- a/arch/arm/mach-vexpress/include/mach/entry-macro.S +++ b/arch/arm/mach-vexpress/include/mach/entry-macro.S @@ -1,5 +1,3 @@ -#include - .macro disable_fiq .endm diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c index 1fafc32..7aa07a8 100644 --- a/arch/arm/mach-vexpress/v2m.c +++ b/arch/arm/mach-vexpress/v2m.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -448,5 +449,6 @@ MACHINE_START(VEXPRESS, "ARM-Versatile Express") .init_early = v2m_init_early, .init_irq = v2m_init_irq, .timer = &v2m_timer, + .handle_irq = gic_handle_irq, .init_machine = v2m_init, MACHINE_END -- cgit v0.10.2 From 041f777c93bab29565d999a292b9b9b533fe6f5e Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Sep 2011 10:23:45 +0100 Subject: ARM: msm: convert SMP platforms to CONFIG_MULTI_IRQ_HANDLER Convert the SMP msm platforms to be using the gic_handle_irq function as their primary interrupt handler. Tested-by: David Brown Acked-by: David Brown Signed-off-by: Marc Zyngier diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig index ebde97f..ba36b74 100644 --- a/arch/arm/mach-msm/Kconfig +++ b/arch/arm/mach-msm/Kconfig @@ -50,6 +50,7 @@ config ARCH_MSM8X60 select GPIO_MSM_V2 select MSM_GPIOMUX select MSM_SCM if SMP + select MULTI_IRQ_HANDLER config ARCH_MSM8960 bool "MSM8960" @@ -60,6 +61,7 @@ config ARCH_MSM8960 select MSM_V2_TLMM select MSM_GPIOMUX select MSM_SCM if SMP + select MULTI_IRQ_HANDLER endchoice diff --git a/arch/arm/mach-msm/board-msm8960.c b/arch/arm/mach-msm/board-msm8960.c index 6dc1cbd..ed35981 100644 --- a/arch/arm/mach-msm/board-msm8960.c +++ b/arch/arm/mach-msm/board-msm8960.c @@ -99,6 +99,7 @@ MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR") .map_io = msm8960_map_io, .init_irq = msm8960_init_irq, .timer = &msm_timer, + .handle_irq = gic_handle_irq, .init_machine = msm8960_sim_init, MACHINE_END @@ -108,6 +109,7 @@ MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3") .map_io = msm8960_map_io, .init_irq = msm8960_init_irq, .timer = &msm_timer, + .handle_irq = gic_handle_irq, .init_machine = msm8960_rumi3_init, MACHINE_END diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c index 44bf716..0a11342 100644 --- a/arch/arm/mach-msm/board-msm8x60.c +++ b/arch/arm/mach-msm/board-msm8x60.c @@ -108,6 +108,7 @@ MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3") .reserve = msm8x60_reserve, .map_io = msm8x60_map_io, .init_irq = msm8x60_init_irq, + .handle_irq = gic_handle_irq, .init_machine = msm8x60_init, .timer = &msm_timer, MACHINE_END @@ -117,6 +118,7 @@ MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF") .reserve = msm8x60_reserve, .map_io = msm8x60_map_io, .init_irq = msm8x60_init_irq, + .handle_irq = gic_handle_irq, .init_machine = msm8x60_init, .timer = &msm_timer, MACHINE_END @@ -126,6 +128,7 @@ MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR") .reserve = msm8x60_reserve, .map_io = msm8x60_map_io, .init_irq = msm8x60_init_irq, + .handle_irq = gic_handle_irq, .init_machine = msm8x60_init, .timer = &msm_timer, MACHINE_END @@ -135,6 +138,7 @@ MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA") .reserve = msm8x60_reserve, .map_io = msm8x60_map_io, .init_irq = msm8x60_init_irq, + .handle_irq = gic_handle_irq, .init_machine = msm8x60_init, .timer = &msm_timer, MACHINE_END diff --git a/arch/arm/mach-msm/include/mach/entry-macro-qgic.S b/arch/arm/mach-msm/include/mach/entry-macro-qgic.S deleted file mode 100644 index 717076f..0000000 --- a/arch/arm/mach-msm/include/mach/entry-macro-qgic.S +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Low-level IRQ helper macros - * - * Copyright (c) 2010, Code Aurora Forum. All rights reserved. - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include - - .macro disable_fiq - .endm - - .macro arch_ret_to_user, tmp1, tmp2 - .endm diff --git a/arch/arm/mach-msm/include/mach/entry-macro-vic.S b/arch/arm/mach-msm/include/mach/entry-macro-vic.S deleted file mode 100644 index 70563ed..0000000 --- a/arch/arm/mach-msm/include/mach/entry-macro-vic.S +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007 Google, Inc. - * Author: Brian Swetland - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include - - .macro disable_fiq - .endm - - .macro get_irqnr_preamble, base, tmp - @ enable imprecise aborts - cpsie a - mov \base, #MSM_VIC_BASE - .endm - - .macro arch_ret_to_user, tmp1, tmp2 - .endm - - .macro get_irqnr_and_base, irqnr, irqstat, base, tmp - @ 0xD0 has irq# or old irq# if the irq has been handled - @ 0xD4 has irq# or -1 if none pending *but* if you just - @ read 0xD4 you never get the first irq for some reason - ldr \irqnr, [\base, #0xD0] - ldr \irqnr, [\base, #0xD4] - cmp \irqnr, #0xffffffff - .endm diff --git a/arch/arm/mach-msm/include/mach/entry-macro.S b/arch/arm/mach-msm/include/mach/entry-macro.S index b16f082..41f7003 100644 --- a/arch/arm/mach-msm/include/mach/entry-macro.S +++ b/arch/arm/mach-msm/include/mach/entry-macro.S @@ -16,8 +16,27 @@ * */ -#if defined(CONFIG_ARM_GIC) -#include -#else -#include + .macro disable_fiq + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm + +#if !defined(CONFIG_ARM_GIC) +#include + + .macro get_irqnr_preamble, base, tmp + @ enable imprecise aborts + cpsie a + mov \base, #MSM_VIC_BASE + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + @ 0xD0 has irq# or old irq# if the irq has been handled + @ 0xD4 has irq# or -1 if none pending *but* if you just + @ read 0xD4 you never get the first irq for some reason + ldr \irqnr, [\base, #0xD0] + ldr \irqnr, [\base, #0xD4] + cmp \irqnr, #0xffffffff + .endm #endif -- cgit v0.10.2 From 4e44d2cb95bd93abe16a131dbcd4c052ae36665f Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Mon, 30 May 2011 11:04:53 +0100 Subject: ARM: exynos4: convert to CONFIG_MULTI_IRQ_HANDLER Convert the Exynos4 platforms to be using the gic_handle_irq function as their primary interrupt handler. Cc: Ben Dooks Cc: Kukjin Kim Signed-off-by: Marc Zyngier diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 8f39263..d897255 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -854,6 +854,7 @@ config ARCH_EXYNOS select HAVE_S3C2410_I2C if I2C select HAVE_S3C2410_WATCHDOG if WATCHDOG select NEED_MACH_MEMORY_H + select MULTI_IRQ_HANDLER help Support for SAMSUNG's EXYNOS SoCs (EXYNOS4/5) diff --git a/arch/arm/mach-exynos/cpu.c b/arch/arm/mach-exynos/cpu.c index e92e464..6e34485 100644 --- a/arch/arm/mach-exynos/cpu.c +++ b/arch/arm/mach-exynos/cpu.c @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -33,8 +34,6 @@ #include #include -unsigned int gic_bank_offset __read_mostly; - extern int combiner_init(unsigned int combiner_nr, void __iomem *base, unsigned int irq_start); extern void combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq); @@ -210,6 +209,7 @@ void __init exynos4_init_clocks(int xtal) void __init exynos4_init_irq(void) { int irq; + unsigned int bank_offset; gic_bank_offset = soc_is_exynos4412() ? 0x4000 : 0x8000; diff --git a/arch/arm/mach-exynos/include/mach/entry-macro.S b/arch/arm/mach-exynos/include/mach/entry-macro.S index f5e9fd8..3ba4f54 100644 --- a/arch/arm/mach-exynos/include/mach/entry-macro.S +++ b/arch/arm/mach-exynos/include/mach/entry-macro.S @@ -9,83 +9,8 @@ * warranty of any kind, whether express or implied. */ -#include -#include -#include - .macro disable_fiq .endm - .macro get_irqnr_preamble, base, tmp - mov \tmp, #0 - - mrc p15, 0, \base, c0, c0, 5 - and \base, \base, #3 - cmp \base, #0 - beq 1f - - ldr \tmp, =gic_bank_offset - ldr \tmp, [\tmp] - cmp \base, #1 - beq 1f - - cmp \base, #2 - addeq \tmp, \tmp, \tmp - addne \tmp, \tmp, \tmp, LSL #1 - -1: ldr \base, =gic_cpu_base_addr - ldr \base, [\base] - add \base, \base, \tmp - .endm - .macro arch_ret_to_user, tmp1, tmp2 .endm - - /* - * The interrupt numbering scheme is defined in the - * interrupt controller spec. To wit: - * - * Interrupts 0-15 are IPI - * 16-28 are reserved - * 29-31 are local. We allow 30 to be used for the watchdog. - * 32-1020 are global - * 1021-1022 are reserved - * 1023 is "spurious" (no interrupt) - * - * For now, we ignore all local interrupts so only return an interrupt if it's - * between 30 and 1020. The test_for_ipi routine below will pick up on IPIs. - * - * A simple read from the controller will tell us the number of the highest - * priority enabled interrupt. We then just need to check whether it is in the - * valid range for an IRQ (30-1020 inclusive). - */ - - .macro get_irqnr_and_base, irqnr, irqstat, base, tmp - - ldr \irqstat, [\base, #GIC_CPU_INTACK] /* bits 12-10 = src CPU, 9-0 = int # */ - - ldr \tmp, =1021 - - bic \irqnr, \irqstat, #0x1c00 - - cmp \irqnr, #15 - cmpcc \irqnr, \irqnr - cmpne \irqnr, \tmp - cmpcs \irqnr, \irqnr - addne \irqnr, \irqnr, #32 - - .endm - - /* We assume that irqstat (the raw value of the IRQ acknowledge - * register) is preserved from the macro above. - * If there is an IPI, we immediately signal end of interrupt on the - * controller, since this requires the original irqstat value which - * we won't easily be able to recreate later. - */ - - .macro test_for_ipi, irqnr, irqstat, base, tmp - bic \irqnr, \irqstat, #0x1c00 - cmp \irqnr, #16 - strcc \irqstat, [\base, #GIC_CPU_EOI] - cmpcs \irqnr, \irqnr - .endm diff --git a/arch/arm/mach-exynos/mach-armlex4210.c b/arch/arm/mach-exynos/mach-armlex4210.c index f0ca6c1..49da308 100644 --- a/arch/arm/mach-exynos/mach-armlex4210.c +++ b/arch/arm/mach-exynos/mach-armlex4210.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -210,6 +211,7 @@ MACHINE_START(ARMLEX4210, "ARMLEX4210") .atag_offset = 0x100, .init_irq = exynos4_init_irq, .map_io = armlex4210_map_io, + .handle_irq = gic_handle_irq, .init_machine = armlex4210_machine_init, .timer = &exynos4_timer, MACHINE_END diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c index 236bbe1..5acec11 100644 --- a/arch/arm/mach-exynos/mach-nuri.c +++ b/arch/arm/mach-exynos/mach-nuri.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -1333,6 +1334,7 @@ MACHINE_START(NURI, "NURI") .atag_offset = 0x100, .init_irq = exynos4_init_irq, .map_io = nuri_map_io, + .handle_irq = gic_handle_irq, .init_machine = nuri_machine_init, .timer = &exynos4_timer, .reserve = &nuri_reserve, diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c index f80b563..5561b06 100644 --- a/arch/arm/mach-exynos/mach-origen.c +++ b/arch/arm/mach-exynos/mach-origen.c @@ -22,6 +22,7 @@ #include #include +#include #include #include